Tag Query - pre_get_post - CPT

Support MB Custom Post Type Tag Query - pre_get_post - CPTResolved

Viewing 1 post (of 1 total)
  • Author
    Posts
  • #28820
    Prabakaran ShankarPrabakaran Shankar
    Participant

    Post Tag and category were registered for the CPTS. however, the tag and category query has not been working.
    Hence, I have added the below snippet to execute the function.
    'function job_cpt_tags( $query ) {
    if ( $query->is_tag() && $query->is_main_query() ) {
    if ( $query->is_search ) {
    $query->set( 'post_type', array( 'post', 'job' ) );
    }
    }
    }
    add_action( 'pre_get_posts', 'job_cpt_tags' );
    function job_cpt_category( $query ) {
    if ( $query->is_category() && $query->is_main_query() ) {
    if ( $query->is_search ) {
    $query->set( 'post_type', array( 'post', 'job' ) );
    }}
    }
    add_action( 'pre_get_posts', 'job_cpt_category' );'

    For 1 CPT this is fine. But, if there are many CPTS, better to be included in the module.

    Please include this function in the MB CPT module and consider this as a feature request.

Viewing 1 post (of 1 total)
  • You must be logged in to reply to this topic.