moshik008
asked on
add custom post type to web.config
Hi all,
I have a problem with permalinks:
I have 2 sites with permalink sets to the "pretty" post-name settings for exaple:
http://www.mydomain.com/sample-post/
i am on windows servers on both sites so I updated the web.config file as suggested all over the internet, posts and pages works as expected, but on both sites i have custom post types and eg.
http://www.mydomain.com/movies/sample-post/
dosen't work.
I know that wordpress and windows servers are not working together all so good, but it is what my customers wants.
i suppose I must add some sort of rewite to the web.config, but i dont know how, can someone can help with the sample code for it.
thanks.
I have a problem with permalinks:
I have 2 sites with permalink sets to the "pretty" post-name settings for exaple:
http://www.mydomain.com/sample-post/
i am on windows servers on both sites so I updated the web.config file as suggested all over the internet, posts and pages works as expected, but on both sites i have custom post types and eg.
http://www.mydomain.com/movies/sample-post/
dosen't work.
I know that wordpress and windows servers are not working together all so good, but it is what my customers wants.
i suppose I must add some sort of rewite to the web.config, but i dont know how, can someone can help with the sample code for it.
thanks.
ASKER
I doubted because both of the sites based on very well known templates (different ones), so I suppose that the slugs are all in place.
If your custom post type creation is in a plugin try to use template_include filter:
add_filter( 'template_include', 'your_prefix_include_templ ate_functi on', 1 );
Or from a class:
add_filter( 'template_include', array( $this, 'include_template_function ' ), 1 );
In this function return your custom post type template path.
You should also take a look at:
- 'template_redirect' action hook
- Rewrite API, 'generate_rewrite_rules' action hook
- and at Rewrite endpoints API (function add_rewrite_endpoint())
but don't forget this tips:
Always refresh your Permalink Settings after you have changed rewrite slug by
Custom Post Types or Custom Taxonomies:
Dashboard/Settings/Permali nk Settings, just save it again.
To automatically flush your rewrite rules use the function flush_rewrite_rules().
add_filter( 'template_include', 'your_prefix_include_templ
Or from a class:
add_filter( 'template_include', array( $this, 'include_template_function
In this function return your custom post type template path.
You should also take a look at:
- 'template_redirect' action hook
- Rewrite API, 'generate_rewrite_rules' action hook
- and at Rewrite endpoints API (function add_rewrite_endpoint())
but don't forget this tips:
Always refresh your Permalink Settings after you have changed rewrite slug by
Custom Post Types or Custom Taxonomies:
Dashboard/Settings/Permali
To automatically flush your rewrite rules use the function flush_rewrite_rules().
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
figured it myself
I almost want to say you don't have the slugs for the custom post types set up correctly in the CPT definition code.