Support Forum

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? Reply To: How to get the template part working with WPSP?

#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!