Solved

add custom post type to web.config

Posted on 2014-01-30
5
247 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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

Suggested Solutions

Do you think that WordPress is just for blogs?  Think again!  WordPress is really a fantastic all around platform that you can use to develop websites on.  Integrated into its basic functionality is the ability to create pages using your choice of a…
So you have coded your own WordPress plugin and now you want to allow users to upload images to a folder in the plugin folder rather than the default media location? Follow along and this article will show you how to do just that!
The purpose of this video is to demonstrate how to properly insert a Vimeo Video into a WordPress site or Blog. This will be demonstrated using a Windows 8 PC. Go to your WordPress login page. This will look like the following: mywebsite.com/wp…
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.

685 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