0

I am using thesis in wordpress 4.1 i am trying to display related post by category with bellow function but when i go to the post detail page it throws internal server error.i have used same code in another website and the code is working good on that site and each word of code is same on both site i am stucked here i was increased the wordpress memory limit ,in php.ini file memory limit but that also not taking any effect.so guide me to display related post using bellow code.And i am wondering about the same as it is code i am using for another two web site which have thesis theme and it working dam good.

<?php

    function related_posts() {
      if ( is_single() ) {
       global $post;
         $categories = get_the_category();
          foreach ($categories as $category)
           {
      ?>
 <div class="relatedpostAdd">
 <h3 style="margin:5px 0 ">More From <?php echo $category->name; ?></h3>
 <ul>
 <?php
       $posts = get_posts('numberposts=4&category='. $category->term_id);
         foreach($posts as $post)
          {
       ?>
 <li>
     <div class="images_releted">
       <a class="post_thumbnail" href="<? the_permalink()?>" rel="bookmark" title="<?php   
           the_title(); ?>"><?php echo the_post_thumbnail('thumbnail') ?>
          </a>
     </div>
    <a class="post_thumbnail_link" href="<? the_permalink()?>" rel="bookmark" 
    title="<?php the_title(); ?>"><?php short_title(); ?></a>               
 </li>
        <?php } ?>
                  </ul>
 </div>
    <?php } ?>
<?php
     $orig_post = $post;
       global $post;
        $tags = wp_get_post_tags($post->ID);
        if ($tags) {
        $tag_ids = array();
        foreach($tags as $individual_tag) $tag_ids[] = $individual_tag->term_id;
           $args=array(
                       'tag__in' => $tag_ids,
                       'post__not_in' => array($post->ID),
                       'posts_per_page'=>4,
                       'caller_get_posts'=>1,
                       'orderby'=>'rand'
                                          );          
        $my_query = new wp_query( $args );
          if( $my_query->have_posts() ) 
          {
           echo '<div class="relatedpostAdd">
                 <div id="related_posts1" class="reviews clear">
                 <h3 style="margin:5px 0 ">Related Posts</h3>
                 <ul>';
         while( $my_query->have_posts() ) 
         {
            $my_query->the_post(); 
        ?>
 <li>
  <div class="images_releted">
     <a class="post_thumbnail" href="<? the_permalink()?>" rel="bookmark" 
     title="<?php the_title(); ?>"><?php echo the_post_thumbnail('thumbnail') ?>
     </a>
  </div>
    <a class="post_thumbnail_link" href="<? the_permalink()?>" rel="bookmark" 
     title="<?php the_title(); ?>"><?php short_title(); ?></a>              
</li>
    <?php } ?>
                 </ul>
           </div>
   </div>
    <?php} 
    else { 
    echo '<div class="relatedpostAdd">
    <div id="related_posts1" class="reviews clear">
    <h3 style="margin:5px 0 ">Related Posts</h3>' ?>
    <ul>
        <?php
    $args = array( 'numberposts' => 4, 'orderby' => 'rand', 
                 'post_status' => 'publish', 'offset' => 1);
                  $rand_posts = get_posts( $args );

                  foreach( $rand_posts as $post ) : ?>
    <li>
 <div class="images_releted">
    <a class="post_thumbnail" href="<? the_permalink()?>" rel="bookmark"
    title="<?php the_title(); ?>"><?php echo the_post_thumbnail('thumbnail') ?>
    </a>
</div>
    <a class="post_thumbnail_link" href="<?php the_permalink(); ?>">
     <?php short_title();?></a>
     </li>
    <?php endforeach; ?>
      </ul>
   </div>
</div>
    <?php }
        }
    $post = $orig_post;
    wp_reset_query(); 
    }
    }
    add_action('thesis_hook_after_post_box_related_posts','related_posts');
?>

Error I am getting on post detail page

 Internal Server Error
    The server encountered an internal error or misconfiguration and
    was unable to  complete your request.......................
    a 500 Internal Server Error error was encountered while trying to use 
    an ErrorDocument to handle the request.
  • Please, this is not your first question. Properly indent your code. It is an unreadable mess. You will most probably don't get any help just based on your code. To be honest, I'm not going to waste my time to try and figure out your code, sorry. Thank you – Pieter Goosen Nov 7 '14 at 9:11
  • i have edited the code hope this is in readable format. – Sanjay Nakate Nov 7 '14 at 9:46
0

I have sorted this issue i was tested this code on our test server and

i saw error on post detail page the error was Fatal error: Call to undefined function short_title()

after seen this i have remove the function code short_title(); from my custom.php and replace with the_title(); to display tittle.And i have check the site every thing is working good.

But still i am not understand why this function short_title(); not working on my production server and why it throwing Internal Server Error

except this error Fatal error: Call to undefined function short_title()

| improve this answer | |
  • Did you verify this worked in 4.0, but always requires workaround in WP4.1 beta? If so, you might want to let them know in a bug report :) core.trac.wordpress.org/ticket – NoBugs Dec 4 '14 at 5:21
  • Yes I will check on 4.1 and then will proceed for next – Sanjay Nakate Dec 8 '14 at 17:08
  • Are you saying this wasn't a problem introduced in Wordpress 4.1, as originally described in the question? – NoBugs Dec 9 '14 at 2:37
  • Right now I will directly report a bug. – Sanjay Nakate Dec 9 '14 at 15:14
-2

Check here

Read comments for installation

| improve this answer | |
  • Please add some explanation. Link only answer is not quite recommended here. – Nilambar Sharma Nov 10 '14 at 3:14

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.