Page with same wordpress post_type slug

2

Good

I have a post_type of wordpress calling products.

I created an archive-products.php and inside it I have the loop. Inside it, you need to have an editable content before the list, and for that you have the page called Products, inside Pages in wordpress.

What is the best way to do this without conflicts in the url?

Att,

    
asked by anonymous 25.02.2015 / 19:36

2 answers

1

You have to choose which page you want to have with your site URL / products.

If it is the page you are creating within the panel, you will need to change the post_type permalink. If you are registering this post_type programmatically you should add the rewrite argument, as Codex :

  

rewrite       (boolean or array) (optional) Triggers the handling of rewrites for this post type. To prevent rewrites, set to false.       Default: true and use $ post_type as slug       $ args array       'slug' = > string Customize the permalink structure slug. Defaults to the $ post_type value. Should be translatable.       'with_front' = > bool Should the permalink structure be prepended with the base front. (example: if your permalink structure is / blog /,   then your links will be: false- > / news /, true- > / blog / news /). Defaults   to true       'feeds' = > bool Should be a feed for this post type. Defaults to has_archive value.       'pages' = > bool Should the permalink structure provide for pagination. Defaults to true       'ep_mask' = > const As of 3.4 Assign an endpoint mask for this post type. For more info see Rewrite API / add_rewrite_endpoint, Trac Ticket   19275, and this Make WordPress Plugins summary of endpoints.       If not specified and permalink_epmask is set, inherits from permalink_epmask       If not specified and permalink_epmask is not set, defaults to EP_PERMALINK

I also advise using a different file for this page, rather than archive-products.php. It is best to use a template of the page-products.php type and leave the archive-products.php for a simple post-type products file. So you do not run the risk of the page being called by the post type url and the contents of the first loop can not be found.

If you want the custom post type products page to keep this url, then just change the title of the page you are creating within the Panel and remember to use a template for that page. About templates

    
11.03.2015 / 19:08
0

Good morning, I had a similar problem once. The page and the Custom Post Type had the same slug and to solve I used to always use singular name for Custom Post Type, in your case it would be product instead of products.

    
11.06.2015 / 13:37