• I have hardedcoded my related post code in my themes side bar and I am on WP-Engine. They have updated my blogs to be on WP 3.8 and a few things happened. The main issue I need to fix asap is the Related Posts code I did. I am not sure why it stopped and im not a guru of PHP so I may need help here figuring out why its not working. Here is the code I wrote:

    <?php if (is_single()): ?>
    		<section>
    			<h3>Related Posts</h3>
    
    			<?php
    			global $post;
    $do_not_duplicate = array();
    			$cats = wp_get_post_categories($post->ID);
    			if (count($cats) > 0):
    			$args = array('category__in' => array($category->term_id), 'post__not_in' => $do_not_duplicate, 'numberposts' => 10, 'category' => implode($cats, ","), 'exclude' => $post->ID, 'caller_get_posts'=> 1);
    			$count = 0;
    			$related_posts = get_posts( $args );
    			if (count($related_posts)): ?>
    
    			<ul>
    				<?php foreach ($related_posts as $post) :  setup_postdata($post); if (!in_array($post->ID, $do_not_duplicate) && $count < 3) : $do_not_duplicate[] = $post->ID; $count++; ?>
    
    				<li><a href="<?php the_permalink() ?>"><?php if ( get_the_title() ) the_title(); else the_ID(); ?>
    				</a></li>
    				<?php endif; endforeach; ?>
    			</ul>
    
    			<?php else: ?>
    			<p>No related posts found.</p>
    			<?php endif; ?>
    			<?php else: ?>
    			<p>No related posts found.</p>
    			<?php endif; ?>
    		</section>
                <?php endif; ?>

    Please let me know if you need any more information for this issue.

    Here is a link to the site: http://blog.chrobinson.com/global-transportation/strategic-inbound-optimization/

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘Related posts code and wp 3.8 broken’ is closed to new replies.