Solved

add custom post type to web.config

Posted on 2014-01-30
5
240 Views
Last Modified: 2014-02-11
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.
0
Comment
Question by:moshik008
  • 3
5 Comments
 
LVL 70

Expert Comment

by:Jason C. Levine
ID: 39822007
If you have permalinks working for normal posts, then it should also work for custom post types...as far as web.config is concerned, there is no difference between the two things.

I almost want to say you don't have the slugs for the custom post types set up correctly in the CPT definition code.
0
 

Author Comment

by:moshik008
ID: 39823251
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.
0
 
LVL 15

Expert Comment

by:eemit
ID: 39827546
If your custom post type creation is in a plugin try to use template_include filter:

add_filter( 'template_include', 'your_prefix_include_template_function', 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/Permalink Settings, just save it again.

To automatically flush your rewrite rules use the function flush_rewrite_rules().
0
 

Accepted Solution

by:
moshik008 earned 0 total points
ID: 39838862
just needed to add %category% to permalink -grrrr. silly me
0
 

Author Closing Comment

by:moshik008
ID: 39849634
figured it myself
0

Featured Post

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Did you use a default hosting installation of wordpress with the intention of it being your actual site?  Maybe you’ve installed it as a Blog to your current site and recently converted it to be the main site and do away with the old .htm pages.  An…
Who says nothing in life is free? WordPress.com is a freebie. WordPress.org's downloadable publishing platform is free. Heck, even WordPressMU is free. WordPress is an open source project, which means it can be used on any personal or commerc…
This video teaches viewers how to create their own website using cPanel and Wordpress. Tutorial walks users through how to set up their own domain name from tools like Domain Registrar, Hosting Account, and Wordpress. More specifically, the order in…
The is a quite short video tutorial. In this video, I'm going to show you how to create self-host WordPress blog with free hosting service.

776 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question