How to display Custom Posts on a WordPress homepage?


Staff member
There are a lot of questions on the internet right now on how to display custom posts on a WordPress page. I followed the tutorial from <a href="" rel="nofollow">here</a>.

<strong>1. I registered a custom post</strong>

add_action('init', 'portfolio_register');

function portfolio_register() {     
    $labels = array(
        'name' =&gt; _x('Portofoliu', 'portfolio'),
        'singular_name' =&gt; _x('Portfolio Item', 'post type singular name'),
        'add_new' =&gt; _x('Adauga proiect', 'portfolio item'),
        'add_new_item' =&gt; __('Adauga un proiect la portofoliu'),
        'edit_item' =&gt; __('Edit Portfolio Item'),
        'new_item' =&gt; __('New Portfolio Item'),
        'view_item' =&gt; __('View Portfolio Item'),
        'search_items' =&gt; __('Search Portfolio'),
        'not_found' =&gt;  __('Nothing found'),
        'not_found_in_trash' =&gt; __('Nothing found in Trash'),
        'parent_item_colon' =&gt; ''
    $args = array(
        'labels' =&gt; $labels,
        'public' =&gt; true,
        'publicly_queryable' =&gt; true,
        'show_ui' =&gt; true,
        'query_var' =&gt; true,
        'menu_icon' =&gt; get_stylesheet_directory_uri() . '/article16.png',
        'rewrite' =&gt; true,
        'capability_type' =&gt; 'post',
        'hierarchical' =&gt; false,
        'menu_position' =&gt; null,
        'supports' =&gt; array('title','editor','thumbnail')
    register_post_type( 'portfolio' , $args );

<strong>2. I registered the taxonomy</strong><br >

register_taxonomy("Skills", array("portfolio"), array("hierarchical" =&gt; true, "label" =&gt; "Platforme", "singular_label" =&gt; "Platforma", "rewrite" =&gt; true));

<strong>2. My front-page code is:</strong><br >

&lt;div id="primary" class="site-content"&gt;
        &lt;div id="content" role="main"&gt;
        &lt;?php if ( have_posts() ) : ?&gt;  
            &lt;?php /* Start the Loop */ ?&gt;
            &lt;?php while ( have_posts() ) : the_post(); ?&gt;
                &lt;?php get_template_part( 'content', get_post_format() ); ?&gt;
            &lt;?php endwhile; ?&gt;
            &lt;?php twentytwelve_content_nav( 'nav-below' ); ?&gt;

        &lt;?php else : ?&gt;
            &lt;article id="post-0" class="post no-results not-found"&gt;
            &lt;?php if ( current_user_can( 'edit_posts' ) ) :
                // Show a different message to a logged-in user who can add posts.
                &lt;header class="entry-header"&gt;
                    &lt;h1 class="entry-title"&gt;&lt;?php _e( 'No posts to display', 'twentytwelve' ); ?&gt;&lt;/h1&gt;
                &lt;div class="entry-content"&gt;
                    &lt;p&gt;&lt;?php printf( __( 'Ready to publish your first post? &lt;a href="%s"&gt;Get started here&lt;/a&gt;.', 'twentytwelve' ), admin_url( 'post-new.php' ) ); ?&gt;&lt;/p&gt;

            &lt;?php else :
                // Show the default message to everyone else.
                &lt;header class="entry-header"&gt;
                    &lt;h1 class="entry-title"&gt;&lt;?php _e( 'Nothing Found', 'twentytwelve' ); ?&gt;&lt;/h1&gt;
                &lt;div class="entry-content"&gt;
                    &lt;p&gt;&lt;?php _e( 'Apologies, but no results were found. Perhaps searching will help find a related post.', 'twentytwelve' ); ?&gt;&lt;/p&gt;
                    &lt;?php get_search_form(); ?&gt;
            &lt;?php endif; // end current_user_can() check ?&gt;

        &lt;?php endif; // end have_posts() check ?&gt;

I have the Custom Post and Taxonomy on my admin, but how to display this on my <strong>Portfolio</strong> page?