Quantcast
Channel: WordPress.org Forums » All Topics
Viewing all articles
Browse latest Browse all 59525

How to include CPT in WP Query in Astra

$
0
0

Replies: 0

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.


Viewing all articles
Browse latest Browse all 59525

Trending Articles