Site logo

[Resolved] Include a post grid of latest posts at bottom of post content area

Home Forums Support [Resolved] Include a post grid of latest posts at bottom of post content area

Home Forums Support Include a post grid of latest posts at bottom of post content area

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1953538
    TWMA Support

    Hi Team

    Looking to include a grid of the latest 3 posts (of a custom post type) within the post content area at he bottom of the content. Basically left is header, content,latest 3 posts, footer and the right would be header, sidebar, footer. So I am assuming that I would need to fetch the latest 3 posts (to be displayed in a block in a row) and include this fetch php code in teh single.php file.

    Please advise how best to do this so that person creating a post doesnt need to worry about incliuding and building out structure each time a post is created.

    Hope I am making sense.

    Thanks

    #1953594
    David
    Staff
    Customer Support

    Hi there,

    is this to be displayed on all posts ? And will the list contain the latest posts or will it be related to the single post ( eg. by Taxonomy Term ). Let me know and i can give some pointers.

    #1953795
    TWMA Support

    Hi hi

    Yes all posts and if I can show latest posts from the same post category that would be great.

    Thanks

    #1953817
    Leo
    Staff
    Customer Support
    #1953828
    TWMA Support

    Thanks Leo

    Looking for some pho I can add to the theme file so the person adding the post doesn’t need to add shortcodes.

    Is that possible? I have a custom post single theme file setup in the GeneratePress child theme.

    Thanks

    #1953853
    Leo
    Staff
    Customer Support

    Looking for some pho I can add to the theme file

    That’s not possible without a custom solution unfortunately.

    so the person adding the post doesn’t need to add shortcodes.

    If you use the hook method I suggested then set the display rules to all single posts then it will be automatically added to all single posts.

    WordPress offers a core latest posts block now so you can also consider that:
    https://wordpress.org/support/article/latest-posts-block/

    But it doesn’t offer a lot of options.

    #1954029
    TWMA Support

    Hi Leo

    Thanks. I have installed the Show Posts plugin and see that it has a php string and a shortcode, which is useful. However when I put the php string into my template (now casks used to be single.php), nothing shows up (see below…hope I have added the code correctly)…

    Thanks

    <div id="primary" <?php generate_do_element_classes( 'content' ); ?>>
    		<main id="main" <?php generate_do_element_classes( 'main' ); ?>>
    			<?php
    			/**
    			 * generate_before_main_content hook.
    			 *
    			 * @since 0.1
    			 */
    			do_action( 'generate_before_main_content' );
    
    			if ( generate_has_default_loop() ) {
    				while ( have_posts() ) :
    
    					the_post();
    
    					generate_do_template_part( 'casks' );
    
    				endwhile;
    			}
    if ( function_exists( 'wpsp_display' ) ) wpsp_display( 600 );
    			/**
    			 * generate_after_main_content hook.
    			 *
    			 * @since 0.1
    			 */
    			do_action( 'generate_after_main_content' );
    			?>
                
    		</main>
    		
    	</div>
    #1954130
    Elvin
    Staff
    Customer Support

    Hi there,

    I’m not exactly sure that’s the best way of adding it.

    Any particular reason why you have to add it this way? Also, can you verify if the ID within wpsp_display is correct?

    Consider using a Hook element instead.

    Place the shortcode on a Hook element and set its hook to generate_after_main_content. Set the display rule location to the page you want this to apply on.

    #1963785
    TWMA Support

    Hi

    Thanks Elvin. Took you advice and used a hook. Worked a treat. Thanks again.

    #1963855
    Elvin
    Staff
    Customer Support

    No problem. 😀

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.