• Hi,

    I have created a CPT ‘knot’ and I want to include it in front page. I have found the following code in blog.php and single-blog.php and changed it to include my CPT in the Blog.

    However, I believe this is not an optimal way as this will be overridden when I update the theme. How should I include CPT in WP Query properly?

    Before change:

    function astra_blog_get_post_meta() {
    
    		$enable_meta = apply_filters( 'astra_blog_post_meta_enabled', '__return_true' );
    		$post_meta   = astra_get_option( 'blog-meta' );
    
    		if ( ( 'post' == get_post_type() && is_array( $post_meta ) && $enable_meta ) {

    After change:

    function astra_blog_get_post_meta() {
    
    		$enable_meta = apply_filters( 'astra_blog_post_meta_enabled', '__return_true' );
    		$post_meta   = astra_get_option( 'blog-meta' );
    
    		if ( ( 'post' == get_post_type() || 'knot' == get_post_type() ) && is_array( $post_meta ) && $enable_meta ) {

    Thank you for reading and your help.

    The page I need help with: [log in to see the link]

Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
  • The topic ‘How to include CPT in WP Query in Astra’ is closed to new replies.