Skip to content
GeneratePress
  • Home
  • Premium
  • Site Library
  • Install
  • Help
    • Documentation
    • Support Forum
    • Contact
  • Log In
GeneratePress
  • Home
  • Premium
  • Site Library
  • Install
  • Help
    • Documentation
    • Support Forum
    • Contact
  • Log In
  • Log In
  • Free Support

[Resolved] How to Place Recent Posts after Entry-Content

Home › Forums › Support › How to Place Recent Posts after Entry-Content

  • This topic has 3 replies, 3 voices, and was last updated 5 years, 4 months ago by Tom.
Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • October 13, 2015 at 11:15 am #144023
    David

    Hi Tom,

    I wanted to place this recent posts code before the “entry-meta”. Is it better to place it in the content.php or the function.php. Thanks!

    <!-- Related Posts -->
    	<div class="related-posts">
    		<h3>Related Posts</h3>
    		<div>
    		<?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'=> 54, 'caller_get_posts'=>1 ); $my_query = new wp_query( $args ); while( $my_query->have_posts() ) { $my_query->the_post(); ?>
    		
    		<div class="relatedthumb">
    			<a rel="external" href="
    			<? the_permalink()?>">
    			<?php the_post_thumbnail(array(150,150)); ?>
    			<br />
    			<?php the_date(); ?>
    			<br />
    			<?php the_title(); ?>
    			</a>
    		</div>
    		
    		<? } } $post = $orig_post; wp_reset_query(); ?>
    		</div>
    	</div>
    <!-- Related Posts -->
    October 13, 2015 at 1:02 pm #144050
    Tom
    Lead Developer
    Lead Developer

    I would use a hook like this:

    add_action( 'generate_after_entry_content','generate_add_recent_posts' );
    function generate_add_recent_posts()
    {
        // If we're not on a single post, return
        if ( ! is_single() ) 
            return;
    
        ?>
        Everything goes in here.
        <?php
    }

    Documentation: http://docs.generatepress.com/
    Adding CSS: http://docs.generatepress.com/article/adding-css/
    Ongoing Development: https://generatepress.com/ongoing-development

    October 16, 2015 at 9:55 pm #145063
    David

    THANKS!! I getting the hang of this now.

    October 16, 2015 at 11:39 pm #145084
    Tom
    Lead Developer
    Lead Developer

    You’re welcome 🙂

    Documentation: http://docs.generatepress.com/
    Adding CSS: http://docs.generatepress.com/article/adding-css/
    Ongoing Development: https://generatepress.com/ongoing-development

  • Author
    Posts
Viewing 4 posts - 1 through 4 (of 4 total)
  • You must be logged in to reply to this topic.
Log In

Common Issues

  • Missing style.css
  • Updating errors
  • Plugin Install Failed

Useful Articles

  • Installing GP Premium
  • Installing GeneratePress
  • How to add CSS
  • How to add PHP

GeneratePress

  • About
  • Premium
  • Site Library
  • Gutenberg
  • Affiliates
  • Reviews
  • Brand Assets
  • Blog
  • We’re Hiring!

Support

  • Documentation
  • Contact Us
  • Support Forums
  • Fastest WordPress Theme
  • Changelogs
  • Legal
  • Donate
  • Translate

Popular FAQs

  • Install GeneratePress
  • Installing GP Premium
  • Missing style.css
  • Plugin Install Failed
  • Adding CSS
  • Adding PHP
  • WordPress Hosting

Social

  • Facebook
  • Twitter
  • WordPress
  • GitHub
Made with on Vancouver Island
  • Home
  • Premium
  • Site Library
  • Install
  • Contact
  • Support Forum
  • Documentation
  • Account
  • Checkout