Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #11776

    Hi,

    Corona is a fantastic theme, thumbs up!

    I have assigned categories and tags to my posts, however no related posts are visible.

    Can you please help me out? See the related-post.php code below. Thank you in advance!

    $columns = 3;

    $reladed_posts = false;

    $this_id = $post->ID;

    $slidecount = 0;

    $postcount = ($columns * 3) + 1;

    $tags = wp_get_post_tags($post->ID);

    if ($tags) {

    $tag_ids = “”;

    foreach ($tags as $tag ) $tag_ids .= $tag->name.”,”;

    $tag_ids = substr_replace($tag_ids ,””,-1);

    $tag_ids = str_replace(” “, “-”,$tag_ids);

    if($tag_ids)

    {

    $my_query = new WP_Query(“tag=$tag_ids&showposts=$postcount&ignore_sticky_posts=1&orderby=rand”);

    if ($my_query->have_posts())

    {

    $count = 1;

    $output = “”;

    $output .= “<div class=’hr hr_related_posts’></div>”;

    $output .= “<div class=’related-meta’>”;

    $output .= “<h3 class=’miniheading’>”.__(‘Related Posts’,’avia_framework’).”</h3>”;

    $output .= “<span class=’minitext’>”.__(‘Did you like this entry?
    Here are a few more posts that might be interesting for you.’,’avia_framework’).”</span>”;

    $output .= “</div>”;

    $output .= “<div class =’related_posts’>”;

    $output .= “<strong class=’related_single_heading’>Related Posts”;

    $output .= “<div class=’content_slider autoslide_false’>”;

    while ($my_query->have_posts()) : $my_query->the_post();

    if($post->ID != $this_id)

    {

    $reladed_posts = true;

    $slidecount ++;

    if($count == 1)

    {

    $output .= “<div class=’single_slide single_slide_nr_$slidecount’>”;

    }

    $image = “<span class=’related_posts_default_image’></span>”;

    $slides = avia_post_meta(get_the_ID(), ‘slideshow’, true);

    //check if a preview image is set

    if( $slides != “” && !empty( $slides[0]) )

    {

    //check for image or video

    if(is_numeric($slides[0]))

    {

    $image = avia_image_by_id($slides[0], ‘related’, ‘image’);

    }

    else

    {

    $image = “<span class=’related_posts_default_image related_posts_video’></span>”;

    }

    }

    $output .= “<div class=’relThumb relThumb”.$count.”‘>n”;

    $output .= “n”;

    $output .= “<span class=’related_image_wrap’>”;

    $output .= “<span class=’rounded_corner rctl’></span>”;

    $output .= “<span class=’rounded_corner rctr’></span>”;

    $output .= “<span class=’rounded_corner rcbl’></span>”;

    $output .= “<span class=’rounded_corner rcbr’></span>”;

    $output .= $image;

    $output .= “</span>n”;

    $output .= “<span class=’relThumbTitle’>n”;

    $output .= “<strong class=’relThumbHeading’>”.avia_backend_truncate(get_the_title(), 50).”n”;

    $output .= “</span>n“;

    $output .= “</div><!– end .relThumb –>n”;

    $count++;

    if($count == $columns+1)

    {

    $output .= “</div>”;

    $count = 1;

    }

    }

    endwhile;

    if($count != 1) $output .= “</div>”;

    $output .= “</div></div>”;

    if($reladed_posts) echo $output;

    }

    wp_reset_query();

    }

    }

    #73013

    Hello,

    It should work by default. Did you edit anything on the file?

    Please reload the related-post.php and try again. :)

    Regards,

    Ismael

    #73014

    Hi Ismael,

    Thanks for helping out.

    No I didn’t change anything. I updated part of the code (as indicated here on the forum) to activate related posts based on categories (instead of tags). But then switched it back to the original code.

    Some questions:

    1) Is the second line of the code correct? (value is false?)

    $reladed_posts = false;

    2) Is it necessary to upload extra thumbnails for the related posts, or should it automatically scale the featured image?

    Regards, Poirot

    #73015

    Hi,

    Solved. I deleted all tags, then created them again. That’s it :-)

    Thanks anyway, great theme.

    Regards,

    #73016

    Hi Poirot,

    Glad you figured it out! Let us know if you have more questions.

    Regards,

    Mya

Viewing 5 posts - 1 through 5 (of 5 total)

The topic ‘Activate related posts’ is closed to new replies.