• Hi,

    I installed Zemanta related post plugin today and it is just the on that i looked for. The problem is that it only works when I am logged in to wordpress as an admin. When I logged out, all related posts disappears from the posts. What would cause that issue? what would be the solution?

    Thanks,
    Jimmy Thoj

Viewing 4 replies - 1 through 4 (of 4 total)
  • jessy

    (@jessy-marco)

    II options:

    1, Contact https://www.zemanta.com
    2, Into functions.php write this snippets from https://wpsnipp.com

    Into the function.php:

    function get_related_author_posts() {
        global $authordata, $post;
        $authors_posts = get_posts( array( 'author' => $authordata->ID, 'post__not_in' => array( $post->ID ), 'posts_per_page' => 5 ) );
        $output = '<ul>';
        foreach ( $authors_posts as $authors_post ) {
            $output .= '<li><a href="' . get_permalink( $authors_post->ID ) . '">' . apply_filters( 'the_title', $authors_post->post_title, $authors_post->ID ) . '</a></li>';
        }
        $output .= '</ul>';
        return $output;
    }

    Into the single.php (single page) this tag:

    <?php echo get_related_author_posts(); ?>

    Hey,

    Zemanta’s plugin should work even if you’re not logged in as an admin. Which version of the plugin are you using? Also, can you please provide URL of your blog so we can check what’s going on?

    Best,
    Mateja

    jessy

    (@jessy-marco)

    1, This snippets works fine for non-logged users too.
    2, I do not use any plugin for this simple feature, because it slow down the website. Snippets are great.
    3, Example of the code Beers Pubs
    4, Related posts are the best to create from tags of the post or categories, that is php logic of the function.
    5, Markup based on Bootstrap 2.3.2

    Related posts by tags:

    <?php
    // $current_post = $post;
    
    //Call global variable posts
    global $post;
    
    //Save to variable all tags from the post ID
    $posttags = wp_get_post_tags($post->ID);
    
    //If the post has a tags
    if ($posttags) {
    
    //set up tags_ids as arrays
    $tags_ids = array();
    
    //loop through post tags from the current post and set array tags_ids save it from object posttags
    foreach($posttags as $posttag) $tags_ids[] = $posttag->term_id;
    
    //set arguments as array for the object wp_query
    $args = array(
        'tag__in' => $tags_ids,
        'post__not_in' => array($post->ID),
        'posts_per_page'=> 4, // Number of related posts that will be shown.
        'ignore_sticky_posts'=>1
    );
    
    //Set the new object and asign there an array of the arguments
    $relatedposts = new wp_query( $args );
    
    //loop
    if( $relatedposts->have_posts() ) {
        echo '<div class="related-posts clearfix"><h4>Related Posts</h4><div class="row-fluid">';
    
    while( $relatedposts->have_posts() ) { $relatedposts->the_post(); ?>
    
    <div class="span3">
    <a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_post_thumbnail('relatedpost-image'); ?></a>
    <span><a href="<? the_permalink()?>" rel="bookmark" title="<?php the_title(); ?>"><?php the_title(); ?></a></span>
    </div>
    
    <? }
    
    echo '</div></div>';
    
    } //end of the post
    } //end of if the post has tags
    // $post = $current_post;
    wp_reset_query();
    ?>
    Thread Starter mertcancam

    (@mertcancam)

    Here is my website;

    https://www.jellypeep.com

    Thank you all for your responses. I have deleted Hyper cache and problem is solved.I have another question though. I have intalled w3 total cache after deleting hyper cache. Now when I click a category, a blank page appears. I could solve that so I had to delete the plugin.

    Best Regard,
    Jimmy Thoj

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Zemanta’ is closed to new replies.