• Resolved percioandrade

    (@percioandrade)


    `Hello Guys,

    I created a CPT on POD with name ‘perfil’ and in pods admin i’ve associeted this post_type to default post_tag (tags) from WordPress.

    So created a new article on ‘perfil’ and associeted a new tag name ‘playstation’.

    But this article don’t appear if i acess this tag ‘playstation’: domainurl/tag/playstation/

    I inserted this code on functions.php:
    // Enable tags on PODS
    add_action( ‘pre_get_posts’, function ( $q )
    {
    if ( !is_admin() // Only target front end queries
    && $q->is_main_query() // Only target the main query
    && $q->is_category() // Only target category archives [comment out if not needed]
    && $q->is_tag() // Only target tag archives [comment out if not needed]
    ) {
    $q->set( ‘post_type’, [‘post’, ‘perfil’ ] ); // Change ‘custom_post_type’ to YOUR Custom Post Type
    // You can add multiple CPT’s separated by comma’s
    }
    });

    And don’t work.

    Can you help me?

Viewing 1 replies (of 1 total)
  • Thread Starter percioandrade

    (@percioandrade)

    Nevermind, resolved by this code in functions.php

    function tag_filter($query) {
      if ( !is_admin() && $query->is_main_query() ) {
        if ($query->is_tag) {
          $query->set('post_type', array( 'YOUR_CPT', ));
        }
      }
    }
    add_action('pre_get_posts','tag_filter');
Viewing 1 replies (of 1 total)
  • The topic ‘PODS CPT and Tags (post_tag)’ is closed to new replies.