0

I have created a custom post type called portfolio so the permalink structure for this type of posts is like this: mydomain.com/portfolio/post-name/

My issue is that after posting a comment on one of these posts i am redirected to mydomain.com//post-name#comment-id (notice how the word "portfolio" is missing) which causes a redirection loop error. I dont know whats the reason and i dont understand why is this happening.

I double checked my permlink structure and is set as mydomain.com/sample-post/ (post name) and I havent made any changes to the htaccess or whatsoever so what could be happening?

Please help.

EDIT:

This is my custom post type code

function my_post_type_portfolio() {
    register_post_type( 'portfolio',
                array(          
                'label' => __('portfolio'), 
                'singular_label' => __('portfolio', 'theme1418'),
                '_builtin' => false,
                'public' => true, 
                'show_ui' => true,
                'show_in_nav_menus' => true,
                'hierarchical' => true,
                'capability_type' => 'page',
                'menu_icon' => get_template_directory_uri() . '/includes/images/icon_portfolio.png',
                'rewrite' => array(
                    'slug' => 'portfolio',
                    'with_front' => FALSE,
                ),
                'supports' => array(
                        'title',
                        'editor',
                        'thumbnail',
                        'excerpt',
                        'custom-fields',
                        'comments')
                    ) 
                );

        register_taxonomy('portfolio_category', 'portfolio', array('hierarchical' => true, 'label' => 'portfolio', 'singular_name' => 'portfolio', "rewrite" => false, "query_var" => true));
}

add_action('init', 'my_post_type_portfolio');

1 Answer 1

0

I think the solution is very easy. After registering you post type:

register_post_type( 'portfolio', $args );

flush_rewrite_rules();

flush_rewrite_rules will do it for you!

12
  • I tried but it didnt work. Please check again my question, i just added my code.
    – Cain
    Commented Aug 28, 2014 at 5:16
  • I have tried your code in fresh WordPress installation and everything works fine. So you might have some plugin or theme functions causing this error. Are you using custom theme or any theme shop theme?
    – Robert hue
    Commented Aug 28, 2014 at 5:37
  • I bought this theme and this code was already included in the theme. I asked for support but the guys are still unable to find out the culprit. By the way, the code i posted has some differences with the actual one. In my code, all my labels and slug are in Japanese which count as special characters. I dont know if that could be related.
    – Cain
    Commented Aug 28, 2014 at 5:42
  • Yes that should be the problem. Why don't you try this code that you posted and you will notice it's working. I guess the issue is special characters.
    – Robert hue
    Commented Aug 28, 2014 at 5:55
  • Because then all my URLs would break. Also, i have special characters in the post names. This should not be a problem since i have many other wordpress sites with special characters in the URLs and they work fine so i dont know whats the problem with this one.
    – Cain
    Commented Aug 28, 2014 at 5:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.