WordPress.org

Forums

[closed] Limit Number of POsts in a CPT Feed (1 post)

  1. MCM
    Member
    Posted 2 years ago #

    I have tried the following code but cannot get it to work, it seems the post-type check is not working, what am I doing wrong?

    If I take out the conditional,
    AND 'audio' === $wp_query->query_vars['post_type']

    it works 100% but then it will limit it for all feeds and types.

    I only want to limit to this specific CPT.

    add_filter( 'post_limits', 'podcast_post_limits_audio' );
    function podcast_post_limits_lectures( $limit )
    {
    
    	global $wp_query;
    	if ( TRUE === $wp_query->is_feed AND 'feed' === $wp_query->query_vars['feed'] AND 'audio' === $wp_query->query_vars['post_type'] )
    	{
    		return 'LIMIT 0, 2';
    	}
    	return $limit;
    }


    [Please do not create duplicate threads]

Topic Closed

This topic has been closed to new replies.

About this Topic