2158 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Exclusive Author
  • Community Moderator
  • Bought between 50 and 99 items
  • Referred between 200 and 499 users
  • Has been a member for 5-6 years
  • Won a Competition
+10 more
mpc Volunteer moderator says
Hi, I am using a custom post type and custom taxonomy for my portfolio, below you can see how I register it:
function create_portfolio() {

    register_taxonomy('portfolio_cat','portfolio', array(
            'hierarchical' => true,
             'show_ui' => true,
            'query_var' => true,
    )); // add unique categories to portfolio section 

    $portfolio_args = array(
            'label' => __('Portfolio', 'agera'),
            'singular_label' => __('Portfolio', 'agera'),
            'public' => true,
            'show_ui' => true,
            'capability_type' => 'post',
            'hierarchical' => false,
            'rewrite' => true,
            'supports' => array('title', 'editor', 'thumbnail'),
            'taxonomies' => array('post_tag')
    );

    register_post_type('portfolio', $portfolio_args);
}

add_action('init', 'create_portfolio');

Inside my single.php (which displays the single portfolio page) I have a line which displays the categories of Portfolio post types.

<?php echo get_the_term_list( get_the_ID(), 'portfolio_cat', "", ", ");  ?>

In such setup what file should be called if I get the 404 page. I have category.php and taxonomy.php setup.

439 posts
  • Bought between 50 and 99 items
  • Europe
  • Exclusive Author
  • Has been a member for 2-3 years
  • Sold between 5 000 and 10 000 dollars
Pixelous says
Maybe this will help you: Note: In some cases the permalink structure must be updated in order for the new template files to be accessed when viewing a custom post type. To do this go to the permalink menu, change the option to a different option, save the changes, and change it back to the desired option. In the form of the single-type-template. In the same way that posts are shown on their own page with single.php, custom post types will use single-{posttype}.php if it’s available. http://codex.wordpress.org/Post_Types
2158 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Exclusive Author
  • Community Moderator
  • Bought between 50 and 99 items
  • Referred between 200 and 499 users
  • Has been a member for 5-6 years
  • Won a Competition
+10 more
mpc Volunteer moderator says

My single portfolio items are displayed on the single.php page I don’t have a problem with this I have a problem with displaying posts which are contained inside custom category. For example when I click on one of the portfolio cateogies I get 404 page, the url structure looks like this localhost:8888/agera/portfolio_cat/custom_category/

730 posts
  • Elite Author
  • Attended a Community Meetup
  • Has been a member for 4-5 years
  • Sold between 100 000 and 250 000 dollars
  • Bought between 50 and 99 items
  • Exclusive Author
  • Most Wanted Bounty Winner
+2 more
mordauk says

It’s probably a problem with your taxonomy.php template. Can you post its contents?

A small note: please prefix your function for creating the post type.

488 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Won a Competition
  • Referred between 1000 and 1999 users
  • Author had a Free File of the Month
  • Author had a File in an Envato Bundle
  • Bought between 10 and 49 items
+3 more
pixelentity says

if you get the 404 page, problem is permalink structure not being updated (as pixelous pointed out). Either save the permalink page or call once flush_rewrite_rules() .

BF

2158 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Exclusive Author
  • Community Moderator
  • Bought between 50 and 99 items
  • Referred between 200 and 499 users
  • Has been a member for 5-6 years
  • Won a Competition
+10 more
mpc Volunteer moderator says

call once flush_rewrite_rules() . BF

That solved my problem, thanks!

730 posts
  • Elite Author
  • Attended a Community Meetup
  • Has been a member for 4-5 years
  • Sold between 100 000 and 250 000 dollars
  • Bought between 50 and 99 items
  • Exclusive Author
  • Most Wanted Bounty Winner
+2 more
mordauk says


call once flush_rewrite_rules() . BF
That solved my problem, thanks!

Make sure that you have NOT added that to your create_portfolio() function. flush_rewrite_rules() should only ever be run one time at theme/plugin activation.

2158 posts
  • Elite Author
  • Sold between 250 000 and 1 000 000 dollars
  • Exclusive Author
  • Community Moderator
  • Bought between 50 and 99 items
  • Referred between 200 and 499 users
  • Has been a member for 5-6 years
  • Won a Competition
+10 more
mpc Volunteer moderator says



call once flush_rewrite_rules() . BF
That solved my problem, thanks!
Make sure that you have NOT added that to your create_portfolio() function. flush_rewrite_rules() should only ever be run one time at theme/plugin activation.

Should it be added to the release version?

116 posts YeahThemes
  • Exclusive Author
  • Elite Author
  • Sold between 100 000 and 250 000 dollars
  • Has been a member for 3-4 years
  • Bought between 1 and 9 items
  • Referred between 100 and 199 users
Manh says

if you get the 404 page, problem is permalink structure not being updated (as pixelous pointed out). Either save the permalink page or call once flush_rewrite_rules() . BF

+1 just re-save the Permalinks.

730 posts
  • Elite Author
  • Attended a Community Meetup
  • Has been a member for 4-5 years
  • Sold between 100 000 and 250 000 dollars
  • Bought between 50 and 99 items
  • Exclusive Author
  • Most Wanted Bounty Winner
+2 more
mordauk says




call once flush_rewrite_rules() . BF
That solved my problem, thanks!
Make sure that you have NOT added that to your create_portfolio() function. flush_rewrite_rules() should only ever be run one time at theme/plugin activation.
Should it be added to the release version?

What do you mean the release version? The version you release here on Code Canyon or Theme Forest? Sure, as long as you have only included it in an activation hook.

by
by
by
by
by
by