How to Display the Latest Blog Post from a Specific Category on a Regular Page?

Needing to display just the latest Blog Post from a specific Blog Post Category on a new regular page. I could use the following php code on a php page but figured there must be another easier way without having to create custom php template pages within the Pro Theme that potentially could get overwritten on updates.

<?php $recent = new WP_Query("cat='7'&showposts=1"); while($recent->have_posts()) : $recent->the_post();?>
    
      <h3><b><?php the_title(); ?></b></h3>
      <?php the_content(); ?>

Hi @razormicro,

Any customization that you for the files should remain as if as long as you do them in a child theme:

As for what you are trying to do, there is no out of the box option to do it so you have to override wp-index.php file that is in wp-content/themes/pro/framework/views/YOUR_STACK/

Kindly note that since this is a custom code that changes the default behavior/display of the theme, you will be responsible to maintain or update the code in case you require further changes or if the code stops working in future updates. If you are uncertain how to proceed, it would be best to get in touch with a developer.

Hope this helps.

Hi, I found a plug-in solution that worked for me and may be helpful for other users to check and try. The plug-in is called Insert PHP Code Snippet https://wordpress.org/plugins/insert-php-code-snippet/

Hello @razormicro,

We are just glad that you have figured it out a way to correct the said issue.
Thanks for letting us know!

Best Regards.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.