We're merging with GenerateBlocks! Learn more here.

[Support request] How to get the template part working with WPSP?

Please login to receive premium support.

Support for the free plugin can be found here.

Home Forums Pro Support How to get the template part working with WPSP?

Tagged: 

Viewing 15 posts - 31 through 45 (of 48 total)
  • Author
    Posts
  • #5490
    Tom
    Keymaster

    Can you try this var_dump:

    echo '<pre>' . var_export($query, true) . '</pre>';

    It should make things more readable for us.

    Then be sure to highlight the code in your reply and click the “code” button so it stays formatted.

    #5495
    Alberto
    Participant

    Hi Tom.
    Again, I apologize for putting all this code in, but I think it’s clearer.

    WP_Query::__set_state(array(
       'query' => 
      array (
        'order' => 'desc',
        'orderby' => 'date',
        'post_type' => 'locuciones',
        'posts_per_page' => 12,
        'paged' => 0,
        'post_status' => 
        array (
          0 => 'publish',
        ),
        'tax_query' => 
        array (
          'relation' => 'AND',
          0 => 
          array (
            'taxonomy' => 'genero',
            'terms' => 'femenino',
          ),
          1 => 
          array (
            'taxonomy' => 'edad',
            'terms' => 'infantil',
          ),
        ),
      ),
       'query_vars' => 
      array (
        'order' => 'DESC',
        'orderby' => 'date',
        'post_type' => 'locuciones',
        'posts_per_page' => 12,
        'paged' => 0,
        'post_status' => 
        array (
          0 => 'publish',
        ),
        'tax_query' => 
        array (
          'relation' => 'AND',
          0 => 
          array (
            'taxonomy' => 'genero',
            'terms' => 'femenino',
          ),
          1 => 
          array (
            'taxonomy' => 'edad',
            'terms' => 'infantil',
          ),
        ),
        'error' => '',
        'm' => '',
        'p' => 0,
        'post_parent' => '',
        'subpost' => '',
        'subpost_id' => '',
        'attachment' => '',
        'attachment_id' => 0,
        'name' => '',
        'static' => '',
        'pagename' => '',
        'page_id' => 0,
        'second' => '',
        'minute' => '',
        'hour' => '',
        'day' => 0,
        'monthnum' => 0,
        'year' => 0,
        'w' => 0,
        'category_name' => '',
        'tag' => '',
        'cat' => '',
        'tag_id' => '',
        'author' => '',
        'author_name' => '',
        'feed' => '',
        'tb' => '',
        'meta_key' => '',
        'meta_value' => '',
        'preview' => '',
        's' => '',
        'sentence' => '',
        'title' => '',
        'fields' => '',
        'menu_order' => '',
        'embed' => '',
        'category__in' => 
        array (
        ),
        'category__not_in' => 
        array (
        ),
        'category__and' => 
        array (
        ),
        'post__in' => 
        array (
        ),
        'post__not_in' => 
        array (
        ),
        'post_name__in' => 
        array (
        ),
        'tag__in' => 
        array (
        ),
        'tag__not_in' => 
        array (
        ),
        'tag__and' => 
        array (
        ),
        'tag_slug__in' => 
        array (
        ),
        'tag_slug__and' => 
        array (
        ),
        'post_parent__in' => 
        array (
        ),
        'post_parent__not_in' => 
        array (
        ),
        'author__in' => 
        array (
        ),
        'author__not_in' => 
        array (
        ),
        'ignore_sticky_posts' => false,
        'suppress_filters' => false,
        'cache_results' => true,
        'update_post_term_cache' => true,
        'lazy_load_term_meta' => true,
        'update_post_meta_cache' => true,
        'nopaging' => false,
        'comments_per_page' => '50',
        'no_found_rows' => false,
        'taxonomy' => 'genero',
        'term_id' => 'femenino',
      ),
       'tax_query' => 
      WP_Tax_Query::__set_state(array(
         'queries' => 
        array (
          'relation' => 'AND',
          0 => 
          array (
            'taxonomy' => 'genero',
            'terms' => 
            array (
              0 => 'femenino',
            ),
            'field' => 'term_id',
            'operator' => 'IN',
            'include_children' => true,
          ),
          1 => 
          array (
            'taxonomy' => 'edad',
            'terms' => 
            array (
              0 => 'infantil',
            ),
            'field' => 'term_id',
            'operator' => 'IN',
            'include_children' => true,
          ),
        ),
         'relation' => 'AND',
         'table_aliases' => 
        array (
          0 => 'ch1n0_term_relationships',
          1 => 'tt1',
        ),
         'queried_terms' => 
        array (
          'genero' => 
          array (
            'terms' => 
            array (
              0 => 'femenino',
            ),
            'field' => 'term_id',
          ),
          'edad' => 
          array (
            'terms' => 
            array (
              0 => 'infantil',
            ),
            'field' => 'term_id',
          ),
        ),
         'primary_table' => 'ch1n0_posts',
         'primary_id_column' => 'ID',
      )),
       'meta_query' => 
      WP_Meta_Query::__set_state(array(
         'queries' => 
        array (
        ),
         'relation' => NULL,
         'meta_table' => NULL,
         'meta_id_column' => NULL,
         'primary_table' => NULL,
         'primary_id_column' => NULL,
         'table_aliases' => 
        array (
        ),
         'clauses' => 
        array (
        ),
         'has_or_relation' => false,
      )),
       'date_query' => false,
       'request' => 'SELECT SQL_CALC_FOUND_ROWS  ch1n0_posts.ID FROM ch1n0_posts  LEFT JOIN ch1n0_term_relationships ON (ch1n0_posts.ID = ch1n0_term_relationships.object_id)  LEFT JOIN ch1n0_term_relationships AS tt1 ON (ch1n0_posts.ID = tt1.object_id) WHERE 1=1  AND ( 
      ch1n0_term_relationships.term_taxonomy_id IN (62,63,66) 
      AND 
      tt1.term_taxonomy_id IN (64,65)
    ) AND ch1n0_posts.post_type = \'locuciones\' AND ((ch1n0_posts.post_status = \'publish\')) GROUP BY ch1n0_posts.ID ORDER BY ch1n0_posts.post_date DESC LIMIT 0, 12',
       'posts' => 
      array (
        0 => 
        WP_Post::__set_state(array(
           'ID' => 559,
           'post_author' => '3',
           'post_date' => '2017-07-08 19:25:51',
           'post_date_gmt' => '2017-07-08 19:25:51',
           'post_content' => 'La locución en chino que mostramos a continuación es un ejemplo de introducción histórica narrada por una voz masculina.
    
    历史介绍
    [audio mp3="http://traduccioneschino.es/wp-content/uploads/2017/07/Locutor-varon-chino-29.mp3"][/audio]',
           'post_title' => 'Recorrido museo del Prado',
           'post_excerpt' => '',
           'post_status' => 'publish',
           'comment_status' => 'closed',
           'ping_status' => 'closed',
           'post_password' => '',
           'post_name' => 'chino-nativo-demostracion-hombre',
           'to_ping' => '',
           'pinged' => '',
           'post_modified' => '2018-06-28 09:49:06',
           'post_modified_gmt' => '2018-06-28 09:49:06',
           'post_content_filtered' => '',
           'post_parent' => 0,
           'guid' => 'http://traduccioneschino.es/?post_type=locuciones&p=559',
           'menu_order' => 0,
           'post_type' => 'locuciones',
           'post_mime_type' => '',
           'comment_count' => '0',
           'filter' => 'raw',
        )),
        1 => 

    and so on till 11 and then:

      'post_count' => 12,
       'current_post' => -1,
       'in_the_loop' => false,
       'post' => 
      WP_Post::__set_state(array(
         'ID' => 559,
         'post_author' => '3',
         'post_date' => '2017-07-08 19:25:51',
         'post_date_gmt' => '2017-07-08 19:25:51',
         'post_content' => 'La locución en chino que mostramos a continuación es un ejemplo de introducción histórica narrada por una voz masculina.
    
    历史介绍
    [audio mp3="http://traduccioneschino.es/wp-content/uploads/2017/07/Locutor-varon-chino-29.mp3"][/audio]',
         'post_title' => 'Recorrido museo del Prado',
         'post_excerpt' => '',
         'post_status' => 'publish',
         'comment_status' => 'closed',
         'ping_status' => 'closed',
         'post_password' => '',
         'post_name' => 'chino-nativo-demostracion-hombre',
         'to_ping' => '',
         'pinged' => '',
         'post_modified' => '2018-06-28 09:49:06',
         'post_modified_gmt' => '2018-06-28 09:49:06',
         'post_content_filtered' => '',
         'post_parent' => 0,
         'guid' => 'http://traduccioneschino.es/?post_type=locuciones&p=559',
         'menu_order' => 0,
         'post_type' => 'locuciones',
         'post_mime_type' => '',
         'comment_count' => '0',
         'filter' => 'raw',
      )),
       'comment_count' => 0,
       'current_comment' => -1,
       'found_posts' => '37',
       'max_num_pages' => 4.0,
       'max_num_comment_pages' => 0,
       'is_single' => false,
       'is_preview' => false,
       'is_page' => false,
       'is_archive' => true,
       'is_date' => false,
       'is_year' => false,
       'is_month' => false,
       'is_day' => false,
       'is_time' => false,
       'is_author' => false,
       'is_category' => false,
       'is_tag' => false,
       'is_tax' => true,
       'is_search' => false,
       'is_feed' => false,
       'is_comment_feed' => false,
       'is_trackback' => false,
       'is_home' => false,
       'is_404' => false,
       'is_embed' => false,
       'is_paged' => false,
       'is_admin' => false,
       'is_attachment' => false,
       'is_singular' => false,
       'is_robots' => false,
       'is_posts_page' => false,
       'is_post_type_archive' => true,
       'query_vars_hash' => 'a5de2d5af70eefbca5ead3688a62d3ce',
       'query_vars_changed' => false,
       'thumbnails_cached' => false,
       'stopwords' => NULL,
       'compat_fields' => 
      array (
        0 => 'query_vars_hash',
        1 => 'query_vars_changed',
      ),
       'compat_methods' => 
      array (
        0 => 'init_query_flags',
        1 => 'parse_tax_query',
      ),
    ))

    Hope it can helps…

    #5515
    Tom
    Keymaster

    Ugh, so strange.

    Just to confirm, the posts that are meant to show have both those taxonomies, and both of those terms?

    Earlier in the thread you tried this with a custom query and it worked. Maybe we can compare var_export outputs?

    #5538
    Alberto
    Participant

    Hi Tom!
    Yes, I’m filtering all the posts looking for the ones that have both those taxonomies and both those terms, so it should only show 1 post (the one matching that criteria)
    With the custom query only worked filtering by gender or by age, not both.
    This is the var_exports output:

    WP_Query::__set_state(array(
       'query' => 
      array (
        'order' => 'desc',
        'orderby' => 'date',
        'post_type' => 'locuciones',
        'posts_per_page' => 12,
        'paged' => 0,
        'post_status' => 
        array (
          0 => 'publish',
        ),
      ),
       'query_vars' => 
      array (
        'order' => 'DESC',
        'orderby' => 'date',
        'post_type' => 'locuciones',
        'posts_per_page' => 12,
        'paged' => 0,
        'post_status' => 
        array (
          0 => 'publish',
        ),
        'error' => '',
        'm' => '',
        'p' => 0,
        'post_parent' => '',
        'subpost' => '',
        'subpost_id' => '',
        'attachment' => '',
        'attachment_id' => 0,
        'name' => '',
        'static' => '',
        'pagename' => '',
        'page_id' => 0,
        'second' => '',
        'minute' => '',
        'hour' => '',
        'day' => 0,
        'monthnum' => 0,
        'year' => 0,
        'w' => 0,
        'category_name' => '',
        'tag' => '',
        'cat' => '',
        'tag_id' => '',
        'author' => '',
        'author_name' => '',
        'feed' => '',
        'tb' => '',
        'meta_key' => '',
        'meta_value' => '',
        'preview' => '',
        's' => '',
        'sentence' => '',
        'title' => '',
        'fields' => '',
        'menu_order' => '',
        'embed' => '',
        'category__in' => 
        array (
        ),
        'category__not_in' => 
        array (
        ),
        'category__and' => 
        array (
        ),
        'post__in' => 
        array (
        ),
        'post__not_in' => 
        array (
        ),
        'post_name__in' => 
        array (
        ),
        'tag__in' => 
        array (
        ),
        'tag__not_in' => 
        array (
        ),
        'tag__and' => 
        array (
        ),
        'tag_slug__in' => 
        array (
        ),
        'tag_slug__and' => 
        array (
        ),
        'post_parent__in' => 
        array (
        ),
        'post_parent__not_in' => 
        array (
        ),
        'author__in' => 
        array (
        ),
        'author__not_in' => 
        array (
        ),
        'ignore_sticky_posts' => false,
        'suppress_filters' => false,
        'cache_results' => true,
        'update_post_term_cache' => true,
        'lazy_load_term_meta' => true,
        'update_post_meta_cache' => true,
        'nopaging' => false,
        'comments_per_page' => '50',
        'no_found_rows' => false,
      ),
       'tax_query' => 
      WP_Tax_Query::__set_state(array(
         'queries' => 
        array (
        ),
         'relation' => 'AND',
         'table_aliases' => 
        array (
        ),
         'queried_terms' => 
        array (
        ),
         'primary_table' => 'ch1n0_posts',
         'primary_id_column' => 'ID',
      )),
       'meta_query' => 
      WP_Meta_Query::__set_state(array(
         'queries' => 
        array (
        ),
         'relation' => NULL,
         'meta_table' => NULL,
         'meta_id_column' => NULL,
         'primary_table' => NULL,
         'primary_id_column' => NULL,
         'table_aliases' => 
        array (
        ),
         'clauses' => 
        array (
        ),
         'has_or_relation' => false,
      )),
       'date_query' => false,
       'request' => 'SELECT SQL_CALC_FOUND_ROWS  ch1n0_posts.ID FROM ch1n0_posts  WHERE 1=1  AND ch1n0_posts.post_type = \'locuciones\' AND ((ch1n0_posts.post_status = \'publish\'))  ORDER BY ch1n0_posts.post_date DESC LIMIT 0, 12',
       'posts' => 
      array (
        0 => 
        WP_Post::__set_state(array(...
    

    and so on till 11, then:

    'post_count' => 12,
       'current_post' => -1,
       'in_the_loop' => false,
       'post' => 
      WP_Post::__set_state(array(
         'ID' => 559,
         'post_author' => '3',
         'post_date' => '2017-07-08 19:25:51',
         'post_date_gmt' => '2017-07-08 19:25:51',
         'post_content' => 'La locución en chino que mostramos a continuación es un ejemplo de introducción histórica narrada por una voz masculina.
    
    历史介绍
    [audio mp3="http://traduccioneschino.es/wp-content/uploads/2017/07/Locutor-varon-chino-29.mp3"][/audio]',
         'post_title' => 'Recorrido museo del Prado',
         'post_excerpt' => '',
         'post_status' => 'publish',
         'comment_status' => 'closed',
         'ping_status' => 'closed',
         'post_password' => '',
         'post_name' => 'chino-nativo-demostracion-hombre',
         'to_ping' => '',
         'pinged' => '',
         'post_modified' => '2018-06-28 09:49:06',
         'post_modified_gmt' => '2018-06-28 09:49:06',
         'post_content_filtered' => '',
         'post_parent' => 0,
         'guid' => 'http://traduccioneschino.es/?post_type=locuciones&p=559',
         'menu_order' => 0,
         'post_type' => 'locuciones',
         'post_mime_type' => '',
         'comment_count' => '0',
         'filter' => 'raw',
      )),
       'comment_count' => 0,
       'current_comment' => -1,
       'found_posts' => '38',
       'max_num_pages' => 4.0,
       'max_num_comment_pages' => 0,
       'is_single' => false,
       'is_preview' => false,
       'is_page' => false,
       'is_archive' => true,
       'is_date' => false,
       'is_year' => false,
       'is_month' => false,
       'is_day' => false,
       'is_time' => false,
       'is_author' => false,
       'is_category' => false,
       'is_tag' => false,
       'is_tax' => false,
       'is_search' => false,
       'is_feed' => false,
       'is_comment_feed' => false,
       'is_trackback' => false,
       'is_home' => false,
       'is_404' => false,
       'is_embed' => false,
       'is_paged' => false,
       'is_admin' => false,
       'is_attachment' => false,
       'is_singular' => false,
       'is_robots' => false,
       'is_posts_page' => false,
       'is_post_type_archive' => true,
       'query_vars_hash' => '6406e4db5ba12f5dc1e253aec2e5e334',
       'query_vars_changed' => false,
       'thumbnails_cached' => false,
       'stopwords' => NULL,
       'compat_fields' => 
      array (
        0 => 'query_vars_hash',
        1 => 'query_vars_changed',
      ),
       'compat_methods' => 
      array (
        0 => 'init_query_flags',
        1 => 'parse_tax_query',
      ),
    ))

    Hope it helps…
    Thanks!

    #5539
    Alberto
    Participant

    Just in case it’s clearer, this is the var_exports output just only with gender and femenino (and it works):

    WP_Query::__set_state(array(
       'query' => 
      array (
        'order' => 'desc',
        'orderby' => 'date',
        'post_type' => 'locuciones',
        'posts_per_page' => 12,
        'paged' => 0,
        'post_status' => 
        array (
          0 => 'publish',
        ),
        'tax_query' => 
        array (
          0 => 
          array (
            'taxonomy' => 'genero',
            'field' => 'slug',
            'terms' => 
            array (
              0 => 'femenino',
            ),
            'operator' => 'IN',
          ),
        ),
      ),
       'query_vars' => 
      array (
        'order' => 'DESC',
        'orderby' => 'date',
        'post_type' => 'locuciones',
        'posts_per_page' => 12,
        'paged' => 0,
        'post_status' => 
        array (
          0 => 'publish',
        ),
        'tax_query' => 
        array (
          0 => 
          array (
            'taxonomy' => 'genero',
            'field' => 'slug',
            'terms' => 
            array (
              0 => 'femenino',
            ),
            'operator' => 'IN',
          ),
        ),
        'error' => '',
        'm' => '',
        'p' => 0,
        'post_parent' => '',
        'subpost' => '',
        'subpost_id' => '',
        'attachment' => '',
        'attachment_id' => 0,
        'name' => '',
        'static' => '',
        'pagename' => '',
        'page_id' => 0,
        'second' => '',
        'minute' => '',
        'hour' => '',
        'day' => 0,
        'monthnum' => 0,
        'year' => 0,
        'w' => 0,
        'category_name' => '',
        'tag' => '',
        'cat' => '',
        'tag_id' => '',
        'author' => '',
        'author_name' => '',
        'feed' => '',
        'tb' => '',
        'meta_key' => '',
        'meta_value' => '',
        'preview' => '',
        's' => '',
        'sentence' => '',
        'title' => '',
        'fields' => '',
        'menu_order' => '',
        'embed' => '',
        'category__in' => 
        array (
        ),
        'category__not_in' => 
        array (
        ),
        'category__and' => 
        array (
        ),
        'post__in' => 
        array (
        ),
        'post__not_in' => 
        array (
        ),
        'post_name__in' => 
        array (
        ),
        'tag__in' => 
        array (
        ),
        'tag__not_in' => 
        array (
        ),
        'tag__and' => 
        array (
        ),
        'tag_slug__in' => 
        array (
        ),
        'tag_slug__and' => 
        array (
        ),
        'post_parent__in' => 
        array (
        ),
        'post_parent__not_in' => 
        array (
        ),
        'author__in' => 
        array (
        ),
        'author__not_in' => 
        array (
        ),
        'ignore_sticky_posts' => false,
        'suppress_filters' => false,
        'cache_results' => true,
        'update_post_term_cache' => true,
        'lazy_load_term_meta' => true,
        'update_post_meta_cache' => true,
        'nopaging' => false,
        'comments_per_page' => '50',
        'no_found_rows' => false,
        'taxonomy' => 'genero',
        'term' => 'femenino',
      ),
       'tax_query' => 
      WP_Tax_Query::__set_state(array(
         'queries' => 
        array (
          0 => 
          array (
            'taxonomy' => 'genero',
            'terms' => 
            array (
              0 => 'femenino',
            ),
            'field' => 'slug',
            'operator' => 'IN',
            'include_children' => true,
          ),
        ),
         'relation' => 'AND',
         'table_aliases' => 
        array (
          0 => 'ch1n0_term_relationships',
        ),
         'queried_terms' => 
        array (
          'genero' => 
          array (
            'terms' => 
            array (
              0 => 'femenino',
            ),
            'field' => 'slug',
          ),
        ),
         'primary_table' => 'ch1n0_posts',
         'primary_id_column' => 'ID',
      )),
       'meta_query' => 
      WP_Meta_Query::__set_state(array(
         'queries' => 
        array (
        ),
         'relation' => NULL,
         'meta_table' => NULL,
         'meta_id_column' => NULL,
         'primary_table' => NULL,
         'primary_id_column' => NULL,
         'table_aliases' => 
        array (
        ),
         'clauses' => 
        array (
        ),
         'has_or_relation' => false,
      )),
       'date_query' => false,
       'request' => 'SELECT SQL_CALC_FOUND_ROWS  ch1n0_posts.ID FROM ch1n0_posts  LEFT JOIN ch1n0_term_relationships ON (ch1n0_posts.ID = ch1n0_term_relationships.object_id) WHERE 1=1  AND ( 
      ch1n0_term_relationships.term_taxonomy_id IN (63)
    ) AND ch1n0_posts.post_type = \'locuciones\' AND ((ch1n0_posts.post_status = \'publish\')) GROUP BY ch1n0_posts.ID ORDER BY ch1n0_posts.post_date DESC LIMIT 0, 12',
       'posts' => 
      array (
        0 => 
        WP_Post::__set_state(array(
    

    and so on till 3 and then:

    ),
       'post_count' => 4,
       'current_post' => -1,
       'in_the_loop' => false,
       'post' => 
      WP_Post::__set_state(array(
         'ID' => 485,
         'post_author' => '3',
         'post_date' => '2017-07-07 20:45:47',
         'post_date_gmt' => '2017-07-07 20:45:47',
         'post_content' => '革命根据地广告
    
    La siguiente locución en chino es una narración con voz femenina acerca de un lugar histórico de la revolución e[audio mp3="http://traduccioneschino.es/wp-content/uploads/2017/07/Locutor-femenino-chino-2.mp3"][/audio]n china.',
         'post_title' => 'Locutor femenino chino 2',
         'post_excerpt' => '',
         'post_status' => 'publish',
         'comment_status' => 'closed',
         'ping_status' => 'closed',
         'post_password' => '',
         'post_name' => 'grabacion-audio-mujer-chino',
         'to_ping' => '',
         'pinged' => '',
         'post_modified' => '2017-07-07 20:45:47',
         'post_modified_gmt' => '2017-07-07 20:45:47',
         'post_content_filtered' => '',
         'post_parent' => 0,
         'guid' => 'http://traduccioneschino.es/?post_type=locuciones&p=485',
         'menu_order' => 0,
         'post_type' => 'locuciones',
         'post_mime_type' => '',
         'comment_count' => '0',
         'filter' => 'raw',
      )),
       'comment_count' => 0,
       'current_comment' => -1,
       'found_posts' => '4',
       'max_num_pages' => 1.0,
       'max_num_comment_pages' => 0,
       'is_single' => false,
       'is_preview' => false,
       'is_page' => false,
       'is_archive' => true,
       'is_date' => false,
       'is_year' => false,
       'is_month' => false,
       'is_day' => false,
       'is_time' => false,
       'is_author' => false,
       'is_category' => false,
       'is_tag' => false,
       'is_tax' => true,
       'is_search' => false,
       'is_feed' => false,
       'is_comment_feed' => false,
       'is_trackback' => false,
       'is_home' => false,
       'is_404' => false,
       'is_embed' => false,
       'is_paged' => false,
       'is_admin' => false,
       'is_attachment' => false,
       'is_singular' => false,
       'is_robots' => false,
       'is_posts_page' => false,
       'is_post_type_archive' => true,
       'query_vars_hash' => '81627f9b7acc5e4d0700f02047642d52',
       'query_vars_changed' => false,
       'thumbnails_cached' => false,
       'stopwords' => NULL,
       'compat_fields' => 
      array (
        0 => 'query_vars_hash',
        1 => 'query_vars_changed',
      ),
       'compat_methods' => 
      array (
        0 => 'init_query_flags',
        1 => 'parse_tax_query',
      ),
    ))
    #5549
    Tom
    Keymaster

    Grr, I’m sorry – nothing is coming to mind yet.

    Can you share your custom query PHP?

    #5555
    Alberto
    Participant

    Hello Tom!
    I’m not sure what you mean with ‘custom query PHP’… As I told you earlier in this thread, I’m working with WPSP and also with Search & Filter plugin, so is this plugin that makes the query. It works if I don’t use WPSP, but obviously what I want is to use it.
    If you are talking about the $custom_query variable I’ve used in the last code (previous post) this is it:

    $custom_settings = array(
         'taxonomy' => 'gender',
         'tax_term' => $gender,
    );
    wpsp_display( 123, $custom_settings );

    It is in taxonomy.php Nothing in functions.php

    Hope it helps…

    #5558
    Tom
    Keymaster

    When you say “it works if you don’t use WPSP”, what works? Can you share that code?

    I just want the full picture so I can plug things into my development server and figure this out once and for all for you 🙂

    #5569
    Alberto
    Participant

    Hi Tom.
    Thank you very much for your attention!
    I’m gonna try to explain the situation to you as best I can:
    Working with GeneratePress and Search & Filter plugin, if I don’t use WPSP neither custom taxonomy.php I can filter my posts by gender & age and I get the right results. In this case I only use the Search & Filter shortcode (like this: [searchandfilter taxonomies=”,gender,age” types=”select” submit_label=”Search” headings=”,Gender,Age”]). No code needed.
    But I want to display the posts and results as WPSP allows me, so I use WPSP and a custom taxonomy.php (where I use the WPSP shortcode)

    Please, let me know if you need more info.

    Thanks in advance.

    #5577
    Tom
    Keymaster

    So I just read through the code of that plugin.

    They’re using is_main_query() as a check before the plugin does anything, which is why it’s not working with WPSP.

    On pages that have a WPSP list, the “main query” is the page itself, with the WPSP list being a secondary query. That’s why it’s working with regular posts, but not with WPSP.

    I’m afraid I can’t really think of a way to make the two plugins work together. I am working on a filter functionality within WPSP Pro itself, but it’s not ready for testing yet.

    #5578
    Alberto
    Participant

    Hi Tom
    I don’t know if I’m getting you right because in fact WPSP works if I query only a term (gender or age) but not with an AND relationship…

    Can you think of a possible solution?
    Maybe even modifying the Search & Filter plugin code…

    #5580
    Tom
    Keymaster

    What if you use OR instead of AND just to test?

    Maybe we’re just getting the args wrong: https://wordpress.stackexchange.com/a/108480

    #5692
    Alberto
    Participant

    Hi Tom!
    I’m sorry for late replying. I’ve been out of office for a while.
    I was testing again according your suggest but I get the same results: It works if I search for gender or for age but not for both. I’ve tried also with OR instead AND and I get the same result: All the posts, not only those with terms ‘femenino’ or ‘infantil’.

    I’ve tried this code in taxonomy.php

    if(isset($gender) && !isset($age)){
    	$custom_settings = array(
    	    'taxonomy' => 'gender',
    	    'tax_term' => $gender,
    	);
    	echo '<div class="locutorxs">';
    	wpsp_display( 2993, $custom_settings );
    	echo '</div>';
    };
    if(!isset($gender) && isset($age)){
    	$custom_settings = array(
    	    'taxonomy' => 'age',
    	    'tax_term' => $age,
    	);
    	echo '<div class="locutorxs">';
    	wpsp_display( 2993, $custom_settings );
    	echo '</div>';
    };
    if (isset($gender) && isset($age)) {
    	$custom_settings = array(
    		'post_type' => 'locuciones',
    		'tax_query' => array(
    			'relation' => 'AND', //Also tested with OR
    			array(
    		    	'taxonomy' => 'gender',
    		    	'field'	=> 'slug',
    		    	'terms' => &gender //Also tested with 'femenino'
    		    ),
    		    array(
    		    	'taxonomy' => 'age',
    		    	'field'	=> 'slug',
    		    	'terms' => &age //Also tested with 'infantil'
    			),
    		)
    	);
    	echo '<div class="locutorxs">';
    		/*while ( have_posts() ) : the_post();
    
    			get_template_part( 'contido', get_post_format() ); //Working but without WPSP
    
    		endwhile;*/
    		echo '<div class="locutorxs">';
    		wpsp_display( 2993, $custom_settings ); //Not working
    		echo '</div>';
    	echo '</div>';
    }

    As I comment in code, I tested it without WPSP (i.e., with WP loop) and it works, so it seems is an issue in WPSP. Any kind of incompatibility with Search & Filter plugin.

    Can you think of any way to fix it?

    Thanks in advance!

    #5794
    Laurent
    Participant

    Sorry to intervene but you’re trying to use 2 filtering plugins into one.

    Search&Filter is a tool to filter the posts as WPSP is too (but you filter them within the admin page).

    What you are trying to achieve here is to use the design of WPSP with search filter. For this, you need to customize the output of Search&Filter with the CSS of WPSP. I don’t see how you can use both any other way they both run 2 different queries.

    #5810
    Alberto
    Participant

    Hello Laurent.
    Thanks for comment.
    If so, I’m wondering why it works right if I search for only a term and it doesn’t with an AND relationship (searching by 2 terms).

    Regards.

Viewing 15 posts - 31 through 45 (of 48 total)
  • You must be logged in to reply to this topic.