2268 posts
  • Elite Author
  • Author Level 10
  • Exclusive Author
  • Winner
+16 more
mpc
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.

438 posts
  • 3 Years of Membership
  • Author Level 4
  • Collector Level 3
  • Exclusive Author
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
2268 posts
  • Elite Author
  • Author Level 10
  • Exclusive Author
  • Winner
+16 more
mpc
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/

737 posts
  • Affiliate Level 7
  • Author Level 8
  • Collector Level 3
  • Top Monthly Author
+9 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.

501 posts
  • Affiliate Level 7
  • Author Level 10
  • Collector Level 2
  • Top Monthly Author
+10 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

2268 posts
  • Elite Author
  • Author Level 10
  • Exclusive Author
  • Winner
+16 more
mpc
says

call once flush_rewrite_rules() . BF

That solved my problem, thanks!

737 posts
  • Affiliate Level 7
  • Author Level 8
  • Collector Level 3
  • Top Monthly Author
+9 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.

2268 posts
  • Elite Author
  • Author Level 10
  • Exclusive Author
  • Winner
+16 more
mpc
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
  • Trendsetter
  • Elite Author
  • Weekly Top Seller
  • Exclusive Author
+4 more
Yhthms
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.

737 posts
  • Affiliate Level 7
  • Author Level 8
  • Collector Level 3
  • Top Monthly Author
+9 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