Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- * 1. Go to Settings > Permalinks and select any page as home page
- * Then use the following code
- *
- * You can add those codes in your functions.php in the theme, if you think your theme wonβt be changed.
- * Otherwise mu-plugins is the best solution. To use mu-plugins, go to /wp-content/ and find the folder with name 'mu-plugins'.
- * If there is no folder in that name, then create a folder, name it 'mu-plugins', create a file inside that,
- * give any name you like and paste the code in there. You don't need to activate that plugin. Mu-plugins means must use plugins,
- * so it will be activated automatically always. If you use mu-plugins then add a php start tag at the beginning of the code.
- *
- * Just change the correct CPT name
- */
- add_action("pre_get_posts", "custom_front_page");
- function custom_front_page($wp_query){
- if(is_admin()) return;
- if($wp_query->get('page_id') == get_option('page_on_front')){
- $wp_query->set('post_type', 'CUSTOM POST TYPE NAME HERE');
- $wp_query->set('page_id', ''); //Empty
- $wp_query->is_page = 0;
- $wp_query->is_singular = 0;
- $wp_query->is_post_type_archive = 1;
- $wp_query->is_archive = 1;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement