Domanda

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.
È stato utile?

Soluzione

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()

Altri suggerimenti

Check here

Read comments for installation

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a wordpress.stackexchange
scroll top