• I created custom post type in my functions.php with the following code:

    `function awesome_custom_post_type(){
    $labels = array(
    ‘name’ => ‘Portfolio’,
    ‘singular_name’ => ‘Portfolio’,
    ‘add_new’ => ‘Add Item’,
    ‘all_items’ => ‘All Items’,
    ‘add_new_item’ => ‘Add Item’,
    ‘edit_item’ => ‘Edit Item’,
    ‘new_item’ => ‘New Item’,
    ‘view_item’ => ‘View Item’,
    ‘seach_item’ => ‘Search Portfolio’,
    ‘not_found’ => ‘No items found’,
    ‘not_found_in_trash’ => ‘No items found in trash’,
    ‘parent_item_colon’ => ‘Parent Item’
    );
    $args = array(
    ‘labels’ => $labels,
    ‘public’ => true,
    ‘has_archive’ => true,
    ‘publicity_queryable’ => true,
    ‘query_var’ => true,
    ‘rewrite’ => true,
    ‘capability_type’ => ‘post’,
    ‘hierarchical’ => false,
    ‘supports’ => array(
    ‘title’,
    ‘editor’,
    ‘excerpt’,
    ‘thumbnail’,
    ‘revisions’,

    ),
    ‘taxonomies’ => array(‘category’, ‘post_tag’),
    ‘menu_position’ => 5,
    ‘exclude_from_search’ => false
    );
    register_post_type(‘portfolio’,$args);
    }
    add_action(‘init’,’awesome_custom_post_type’);`

    The Portfolio is added on my dashboard and I can create a post.
    the Problem I see is that,when am in post and click on the permalink it gives me a 404 error so I can view the post.

    How can I view the Post?

    I tried adding another file called single-portfolio but still it didn’t work:

    `get_header(); ?>
    <div id=”primary” class=”content-area”>
    <main id=”main” class=”site-main” role=”main”>
    <?php
    while ( have_posts() ) : the_post();
    get_template_part( ‘template-parts/content’, get_post_format() );
    the_post_navigation();
    // If comments are open or we have at least one comment, load up the comment template.
    if ( comments_open() || get_comments_number() ) :
    comments_template();
    endif;
    endwhile; // End of the loop.
    ?>
    </main><!– #main –>
    </div><!– #primary –>
    <?php
    get_sidebar();
    get_footer();`

Viewing 1 replies (of 1 total)
  • maybe there’s something wrong on the codes that the site don’t recognize. maybe you should review the entries..

Viewing 1 replies (of 1 total)
  • The topic ‘Posts from custom port type not showing’ is closed to new replies.