Can I assign a theme to a custom post type?

I have created a custom post type via plugin called landing-pages with a slug /landing/. I would like to assign a theme when the visitor visited a site with the slug /landing/ and when he visited a normal site should use the default theme.

Thanks

Solutions

Setting theme dynamically is certainly possible, but not too convenient since it's hardly "normal" mode of operation.

In my experience this works best if you stay away from higher level template/stylesheet hooks and instead filter underlying options. In that way you can trick WP into thinking that configured theme is different from what it is and use it.

For a code example there are quite a few theme switchers around. You can take a look at Toolbar Theme Switcher plugin's code for one take on it (disclosure — I am its developer).

Similar questions

how to assign custom texanomy term to custom post type from frontend
I am creating post from frontend. I want to assign custom texonomy term to custom post type from front end. I used wp_set_object_terms code but it is replacing custom previous term. PLease help me solve out this issue
Frontend REST API insert custom post type and assign custom taxonomy
I'm using the method from this tutorial and it works well for creating custom posts (sugestie) in frontend. The problem is that i can't find a way to assign a custom taxonomy to those posts when the form is submitted. In backend it works well. This is the taxonomy This is how i get the taxonomies in form This is the js code for submitting the post ...
Wordpress: Can you assign the regular post categories to custom post types?
I am just using custom post types for the first time today, so please forgive my ignorance. I am using a custom post type that is predefined by a plugin. It looks like almost every Event Calendar plugin uses custom post types to set up an "Events" post type. I was wondering if there is a way to use the normal categories I assign to my regular posts...
Assign Menus to Theme Locations with theme activation
A site is using "child1" named child theme. When this site switches to other child theme named "child2", their widgets are moving too but theme locations are not moving. How can i auto assign menus to theme locations on theme activation? I found this solution from http://wordpress.org/support/topic/how-to-assign-a-wordpress-3-menu-to-primary-locati...
Assign a tag to custom post type using a query
I have a custom post type courses with a custom field level. I want to run a query (mysql or WP query) that runs through every course (post) and if the level is greater than 3, append a tag called higher to it. How would I go about this please? Many thanks Tim
Assign Page Template Within A Custom Post Type
I have registered a Custom Post Type and created a file called archive-myCPT.php and another one for single posts called single-myCPT.php. What I want to do is to create a page where I will show just few posts from my Custom Post Type. Inside my archive-myCPT.php I will have a link called let's say "Special Posts" and this link will go to the custo...

Also ask

We use cookies to deliver the best possible experience on our website. By continuing to use this site, accepting or closing this box, you consent to our use of cookies. To learn more, visit our privacy policy.