最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

Display recent posts from portfolio

programmeradmin4浏览0评论

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
Add a comment  | 

1 Answer 1

Reset to default 1

You 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/

与本文相关的文章

发布评论

评论列表(0)

  1. 暂无评论