I want to show the recent posts from the portfolio. I tried display-posts plugin, I also tried catposts plugin, but all they do is they show the recent posts just from the blog and ignore the portfolio posts. As far as I understand, the portfolio is an extension to blog but for some reason, it doesn't work...
I want to show the recent posts from the portfolio. I tried display-posts plugin, I also tried catposts plugin, but all they do is they show the recent posts just from the blog and ignore the portfolio posts. As far as I understand, the portfolio is an extension to blog but for some reason, it doesn't work...
Share Improve this question asked Oct 10, 2017 at 9:15 ilyailya 11 2- Please post some of the code that you have tried. – Flimm Commented Oct 10, 2017 at 9:27
- portfolio posts are mostly maintained like custom post types, it depends on theme you are using.. – David Klhufek Commented Oct 10, 2017 at 11:38
1 Answer
Reset to default 1You can get latest post from any post type with the simple query
<?php
// Arguments
$args = array(
'post_type' => 'portfolio',
);
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
/* Restore original Post Data */
wp_reset_postdata();
}
Or if you want show latest portfolio posts in the widget, you can use the below plugin:
- https://wordpress/plugins/recent-posts-widget-extended/
- https://wordpress/plugins/recent-posts-widget-with-thumbnails/
- https://wordpress/plugins/flexible-posts-widget/