Home › Forums › Pro Support › How to get the template part working with WPSP?
Tagged: template
- This topic has 47 replies, 3 voices, and was last updated 4 years, 5 months ago by
Tom.
-
AuthorPosts
-
June 28, 2018 at 1:33 am #5059
Alberto
ParticipantHi 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.
June 29, 2018 at 8:47 pm #5073Tom
KeymasterThanks for testing that. I’ll take a look ASAP.
July 9, 2018 at 9:39 am #5176Alberto
ParticipantHi 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.
July 10, 2018 at 10:04 am #5192Tom
KeymasterI 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.
July 10, 2018 at 11:27 am #5193Alberto
ParticipantHi Tom.
Congratulations on fatherhood! Hope everything its OKI’ll keep an eye on the forum for when you can fix it.
Thanks.
July 10, 2018 at 10:13 pm #5197Tom
KeymasterThank you very much! Everything is great, but very busy/tired.
I’ll get to testing this ASAP 🙂
July 23, 2018 at 9:15 am #5379Alberto
ParticipantHi 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.
July 23, 2018 at 8:40 pm #5390Tom
KeymasterLet’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; } );
July 24, 2018 at 11:23 am #5397Alberto
ParticipantHi 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.July 24, 2018 at 8:01 pm #5405Tom
KeymasterIt 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
?July 26, 2018 at 9:32 am #5421Alberto
ParticipantHi 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!
July 27, 2018 at 1:47 pm #5434Tom
KeymasterHmm 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).
July 28, 2018 at 10:51 am #5450Alberto
ParticipantHi 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.
July 28, 2018 at 6:55 pm #5452Tom
KeymasterThat 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?
July 29, 2018 at 9:26 am #5458Alberto
ParticipantHi 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? -
AuthorPosts
- You must be logged in to reply to this topic.