Created
April 9, 2019 10:24
-
-
Save hostz-frank/0f2ae3ee326073d28424f5b13aaff4a6 to your computer and use it in GitHub Desktop.
Add another posttype to Divi's blog module listings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Copy the block below into your child theme's functions.php | |
*/ | |
// Add another posttype to Divi's blog module listings. | |
add_action( 'pre_get_posts', 'divi_child_add_post_type_to_blog_module', 12 ); | |
function divi_child_add_post_type_to_blog_module( $wp_query ) { | |
$slug = 'blog-module'; // ADJUST! => on which page to enable ... | |
$cpt = 'project'; // ADJUST! => desired additional post type | |
global $post; | |
if( $post->post_name == $slug && ! $wp_query->is_main_query() && $wp_query->query['orderby'] != 'menu_order' ) { | |
$wp_query->query_vars['post_type'] = array( 'post', $cpt ); | |
// error_log( print_r( $wp_query, 1 ) ); // uncomment to debug | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment