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 - 16 through 30 (of 48 total)
  • Author
    Posts
  • #5059
    Alberto
    Participant

    Hi Tom
    Yes, it works without WPSP using the new WP_Query with those arguments, so it seems might be a problem with the plugin.
    Please, take a look and tell me ASAP.

    Thanks.

    #5073
    Tom
    Keymaster

    Thanks for testing that. I’ll take a look ASAP.

    #5176
    Alberto
    Participant

    Hi Tom!
    I guess you’ll be pretty busy, but it’s been over a week and I really need to solve this issue, so I’d really appreciate it if you could tell me something.

    Thanks in advance.

    #5192
    Tom
    Keymaster

    I haven’t had a chance to fix this yet unfortunately. My wife gave birth a few days ago, so I’m taking a couple family days.

    #5193
    Alberto
    Participant

    Hi Tom.
    Congratulations on fatherhood! Hope everything its OK

    I’ll keep an eye on the forum for when you can fix it.

    Thanks.

    #5197
    Tom
    Keymaster

    Thank you very much! Everything is great, but very busy/tired.

    I’ll get to testing this ASAP 🙂

    #5379
    Alberto
    Participant

    Hi Tom!
    Do you have a time estimate for a new version of WSPS to fix the problem?

    I know you’re busy but I’d appreciate it if you’d help me solve this problem so I can get paid for my work.

    Thanks in advance.

    #5390
    Tom
    Keymaster

    Let’s try this instead:

    Remove $custom_settings from your display list function.

    Then add this function to your site:

    add_filter( 'wp_show_posts_shortcode_args', function( $args ) {
        $gender = 'something';
        $age = 'something';
    
        $args['tax_query'] = array(
            'relation' => 'AND',
            array(
                'taxonomy' => 'gender',
                'terms' => $gender
            ),
            array(
                'taxonomy' => 'age',
                'terms' => $age
            ),
        );
      
        return $args;
    } );
    #5397
    Alberto
    Participant

    Hi Tom.
    Thanks for replying!
    Where must I add that function?
    Still now I was working in taxonomy.php, so I’ve removed $custom_settings from there and only add wpsp_display(the_id)
    I’ve tried that code (add_filter) in functions.php but ir doesn’t work.

    #5405
    Tom
    Keymaster

    It should work inside your functions.php file. I tested it and the values were coming through into the query.

    I assume you updated the code to grab the actual $gender and $age?

    #5421
    Alberto
    Participant

    Hi Tom.
    I’m affraid I’m doing something wrong because in my tests I don’t get any filter working.
    This was my code in taxonomy.php still now:

    
    if ( have_posts() ) :
    	do_action( 'generate_archive_title' );
    
    	$custom_settings = array(
    		'post_type' => 'locuciones',
    		'tax_query' => array(
    			'relation' => 'AND',
    			array(
    		    	'taxonomy' => 'gender',
    		    	'field'	=> 'slug',
    		    	'terms' => $gender
    		    ),
    		    array(
    		    	'taxonomy' => 'age',
    		    	'field'	=> 'slug',
    		    	'terms' => $age
    			),
    		)
    	);
    	wpsp_display( 2993, $custom_settings );
    	generate_content_nav( 'nav-below' );
    else :
    	get_template_part( 'no-results', 'archive' );
    endif;
    

    And this is the new in taxonomy.php in my lastest tests:

    if ( have_posts() ) :
    	do_action( 'generate_archive_title' );
    	wpsp_display( 2993 );
    	generate_content_nav( 'nav-below' );
    else :
    	get_template_part( 'no-results', 'archive' );
    endif;
    

    And I added this code into my functions.php file:

    
    add_filter( 'wp_show_posts_shortcode_args', function( $args ) {
        $gender= 'femenino';
        $age = 'infantil';
    
        $args['tax_query'] = array(
            'relation' => 'AND',
            array(
                'taxonomy' => 'gender',
                'terms' => $gender
            ),
            array(
                'taxonomy' => 'age',
                'terms' => $age
            ),
        );
      
        return $args;
    } );
    

    I’m using constants (femenino and infantil) in tests instead the variables because I don’t know how to pass them…

    Hope you can tell me what I am doing wrong.

    Thanks in advance!

    #5434
    Tom
    Keymaster

    Hmm ok, let’s debug.

    In your wp-show-posts.php file, find this line: https://github.com/tomusborne/wp-show-posts/blob/1.1.3/wp-show-posts.php#L383

    Right after it, add this:

    var_dump($query);

    Now on your site you’ll see all of the args printed. Do you see your custom query in there? (you may need to ctrl + f).

    #5450
    Alberto
    Participant

    Hi Tom!
    Sorry to put it like this, but I’m not exactly know what I am looking for:

    object(WP_Query)#15810 (49) { [“query”]=> array(7) { [“order”]=> string(4) “desc” [“orderby”]=> string(4) “date” [“post_type”]=> string(10) “locuciones” [“posts_per_page”]=> int(12) [“paged”]=> int(0) [“post_status”]=> array(1) { [0]=> string(7) “publish” } [“tax_query”]=> array(3) { [“relation”]=> string(3) “AND” [0]=> array(2) { [“taxonomy”]=> string(6) “gender” [“terms”]=> string(8) “femenino” } [1]=> array(2) { [“taxonomy”]=> string(3) “age” [“terms”]=> string(8) “infantil” } } } [“query_vars”]=> array(69) { [“order”]=> string(4) “DESC” [“orderby”]=> string(4) “date” [“post_type”]=> string(10) “locuciones” [“posts_per_page”]=> int(12) [“paged”]=> int(0) [“post_status”]=> array(1) { [0]=> string(7) “publish” } [“tax_query”]=> array(3) { [“relation”]=> string(3) “AND” [0]=> array(2) { [“taxonomy”]=> string(6) “gender” [“terms”]=> string(8) “femenino” } [1]=> array(2) { [“taxonomy”]=> string(3) “age” [“terms”]=> string(8) “infantil” } } [“error”]=> string(0) “” [“m”]=> string(0) “” [“p”]=> int(0) [“post_parent”]=> string(0) “” [“subpost”]=> string(0) “” [“subpost_id”]=> string(0) “” [“attachment”]=> string(0) “” [“attachment_id”]=> int(0) [“name”]=> string(0) “” [“static”]=> string(0) “” [“pagename”]=> string(0) “” [“page_id”]=> int(0) [“second”]=> string(0) “” [“minute”]=> string(0) “” [“hour”]=> string(0) “” [“day”]=> int(0) [“monthnum”]=> int(0) [“year”]=> int(0) [“w”]=> int(0) [“category_name”]=> string(0) “” [“tag”]=> string(0) “” [“cat”]=> string(0) “” [“tag_id”]=> string(0) “” [“author”]=> string(0) “” [“author_name”]=> string(0) “” [“feed”]=> string(0) “” [“tb”]=> string(0) “” [“meta_key”]=> string(0) “” [“meta_value”]=> string(0) “” [“preview”]=> string(0) “” [“s”]=> string(0) “” [“sentence”]=> string(0) “” [“title”]=> string(0) “” [“fields”]=> string(0) “” [“menu_order”]=> string(0) “” [“embed”]=> string(0) “” [“category__in”]=> array(0) { } [“category__not_in”]=> array(0) { } [“category__and”]=> array(0) { } [“post__in”]=> array(0) { } [“post__not_in”]=> array(0) { } [“post_name__in”]=> array(0) { } [“tag__in”]=> array(0) { } [“tag__not_in”]=> array(0) { } [“tag__and”]=> array(0) { } [“tag_slug__in”]=> array(0) { } [“tag_slug__and”]=> array(0) { } [“post_parent__in”]=> array(0) { } [“post_parent__not_in”]=> array(0) { } [“author__in”]=> array(0) { } [“author__not_in”]=> array(0) { } [“ignore_sticky_posts”]=> bool(false) [“suppress_filters”]=> bool(false) [“cache_results”]=> bool(true) [“update_post_term_cache”]=> bool(true) [“lazy_load_term_meta”]=> bool(true) [“update_post_meta_cache”]=> bool(true) [“nopaging”]=> bool(false) [“comments_per_page”]=> string(2) “50” [“no_found_rows”]=> bool(false) [“taxonomy”]=> string(6) “gender” [“term_id”]=> string(8) “femenino” } [“tax_query”]=> object(WP_Tax_Query)#15807 (6) { [“queries”]=> array(3) { [“relation”]=> string(3) “AND” [0]=> array(5) { [“taxonomy”]=> string(6) “gender” [“terms”]=> array(1) { [0]=> string(8) “femenino” } [“field”]=> string(7) “term_id” [“operator”]=> string(2) “IN” [“include_children”]=> bool(true) } [1]=> array(5) { [“taxonomy”]=> string(3) “age” [“terms”]=> array(1) { [0]=> string(8) “infantil” } [“field”]=> string(7) “term_id” [“operator”]=> string(2) “IN” [“include_children”]=> bool(true) } } [“relation”]=> string(3) “AND” [“table_aliases”:protected]=> array(2) { [0]=> string(24) “ch1n0_term_relationships” [1]=> string(3) “tt1” } [“queried_terms”]=> array(2) { [“gender”]=> array(2) { [“terms”]=> array(1) { [0]=> string(8) “femenino” } [“field”]=> string(7) “term_id” } [“age”]=> array(2) { [“terms”]=> array(1) { [0]=> string(8) “infantil” } [“field”]=> string(7) “term_id” } } [“primary_table”]=> string(11) “ch1n0_posts” [“primary_id_column”]=> string(2) “ID” } [“meta_query”]=> object(WP_Meta_Query)#15808 (9) { [“queries”]=> array(0) { } [“relation”]=> NULL [“meta_table”]=> NULL [“meta_id_column”]=> NULL [“primary_table”]=> NULL [“primary_id_column”]=> NULL [“table_aliases”:protected]=> array(0) { } [“clauses”:protected]=> array(0) { } [“has_or_relation”:protected]=> bool(false) } [“date_query”]=> bool(false) [“request”]=> string(508) “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(12) { [0]=> object(WP_Post)#15820 (24) { [“ID”]=> int(559) [“post_author”]=> string(1) “3” [“post_date”]=> string(19) “2017-07-08 19:25:51” [“post_date_gmt”]=> string(19) “2017-07-08 19:25:51” [“post_content”]=> string(245) “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”]=> string(25) “Recorrido museo del Prado” [“post_excerpt”]=> string(0) “” [“post_status”]=> string(7) “publish” [“comment_status”]=> string(6) “closed” [“ping_status”]=> string(6) “closed” [“post_password”]=> string(0) “” [“post_name”]=> string(32) “chino-nativo-demostracion-hombre” [“to_ping”]=> string(0) “” [“pinged”]=> string(0) “” [“post_modified”]=> string(19) “2018-06-28 09:49:06” [“post_modified_gmt”]=> string(19) “2018-06-28 09:49:06” [“post_content_filtered”]=> string(0) “” [“post_parent”]=> int(0) [“guid”]=> string(60) “http://traduccioneschino.es/?post_type=locuciones&p=559” [“menu_order”]=> int(0) [“post_type”]=> string(10) “locuciones” [“post_mime_type”]=> string(0) “” [“comment_count”]=> string(1) “0” [“filter”]=> string(3) “raw” } [1]=> object(WP_Post)#15819 (24)

    and so on till…

    [11]=> object(WP_Post)#15898 (24) { [“ID”]=> int(532) [“post_author”]=> string(1) “3” [“post_date”]=> string(19) “2017-07-08 12:32:53” [“post_date_gmt”]=> string(19) “2017-07-08 12:32:53” [“post_content”]=> string(219) “产品广告 En la siguiente locución en chino le mostramos un ejemplo de voz masculina anunciando un producto.[audio mp3="http://traduccioneschino.es/wp-content/uploads/2017/07/Locutor-varón-chino-35.mp3"][/audio]” [“post_title”]=> string(23) “Locutor varón chino 35” [“post_excerpt”]=> string(0) “” [“post_status”]=> string(7) “publish” [“comment_status”]=> string(6) “closed” [“ping_status”]=> string(6) “closed” [“post_password”]=> string(0) “” [“post_name”]=> string(29) “audio-grabacion-locutor-chino” [“to_ping”]=> string(0) “” [“pinged”]=> string(0) “” [“post_modified”]=> string(19) “2017-07-08 12:32:53” [“post_modified_gmt”]=> string(19) “2017-07-08 12:32:53” [“post_content_filtered”]=> string(0) “” [“post_parent”]=> int(0) [“guid”]=> string(60) “http://traduccioneschino.es/?post_type=locuciones&p=532” [“menu_order”]=> int(0) [“post_type”]=> string(10) “locuciones” [“post_mime_type”]=> string(0) “” [“comment_count”]=> string(1) “0” [“filter”]=> string(3) “raw” } } [“post_count”]=> int(12) [“current_post”]=> int(-1) [“in_the_loop”]=> bool(false) [“post”]=> object(WP_Post)#15820 (24) { [“ID”]=> int(559) [“post_author”]=> string(1) “3” [“post_date”]=> string(19) “2017-07-08 19:25:51” [“post_date_gmt”]=> string(19) “2017-07-08 19:25:51” [“post_content”]=> string(245) “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”]=> string(25) “Recorrido museo del Prado” [“post_excerpt”]=> string(0) “” [“post_status”]=> string(7) “publish” [“comment_status”]=> string(6) “closed” [“ping_status”]=> string(6) “closed” [“post_password”]=> string(0) “” [“post_name”]=> string(32) “chino-nativo-demostracion-hombre” [“to_ping”]=> string(0) “” [“pinged”]=> string(0) “” [“post_modified”]=> string(19) “2018-06-28 09:49:06” [“post_modified_gmt”]=> string(19) “2018-06-28 09:49:06” [“post_content_filtered”]=> string(0) “” [“post_parent”]=> int(0) [“guid”]=> string(60) “http://traduccioneschino.es/?post_type=locuciones&p=559” [“menu_order”]=> int(0) [“post_type”]=> string(10) “locuciones” [“post_mime_type”]=> string(0) “” [“comment_count”]=> string(1) “0” [“filter”]=> string(3) “raw” } [“comment_count”]=> int(0) [“current_comment”]=> int(-1) [“found_posts”]=> string(2) “37” [“max_num_pages”]=> float(4) [“max_num_comment_pages”]=> int(0) [“is_single”]=> bool(false) [“is_preview”]=> bool(false) [“is_page”]=> bool(false) [“is_archive”]=> bool(true) [“is_date”]=> bool(false) [“is_year”]=> bool(false) [“is_month”]=> bool(false) [“is_day”]=> bool(false) [“is_time”]=> bool(false) [“is_author”]=> bool(false) [“is_category”]=> bool(false) [“is_tag”]=> bool(false) [“is_tax”]=> bool(true) [“is_search”]=> bool(false) [“is_feed”]=> bool(false) [“is_comment_feed”]=> bool(false) [“is_trackback”]=> bool(false) [“is_home”]=> bool(false) [“is_404”]=> bool(false) [“is_embed”]=> bool(false) [“is_paged”]=> bool(false) [“is_admin”]=> bool(false) [“is_attachment”]=> bool(false) [“is_singular”]=> bool(false) [“is_robots”]=> bool(false) [“is_posts_page”]=> bool(false) [“is_post_type_archive”]=> bool(true) [“query_vars_hash”:”WP_Query”:private]=> string(32) “a5de2d5af70eefbca5ead3688a62d3ce” [“query_vars_changed”:”WP_Query”:private]=> bool(false) [“thumbnails_cached”]=> bool(false) [“stopwords”:”WP_Query”:private]=> NULL [“compat_fields”:”WP_Query”:private]=> array(2) { [0]=> string(15) “query_vars_hash” [1]=> string(18) “query_vars_changed” } [“compat_methods”:”WP_Query”:private]=> array(2) { [0]=> string(16) “init_query_flags” [1]=> string(15) “parse_tax_query” } }

    Hope it can help.

    #5452
    Tom
    Keymaster

    That works.

    It looks like the filter is working, as this is in your query:

    [“tax_query”]=> array(3) { [“relation”]=> string(3) “AND” [0]=> array(2) { [“taxonomy”]=> string(6) “gender” [“terms”]=> string(8) “femenino” } [1]=> array(2) { [“taxonomy”]=> string(3) “age” [“terms”]=> string(8) “infantil” } } }

    I assume those are the args you set?

    #5458
    Alberto
    Participant

    Hi Tom!
    Yes, those are the args: gender=femenino and age=infantil, but why am I getting all the posts and not only the posts with gender=femenino and age=infantil?

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