[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 - 1 through 15 (of 48 total)
  • Author
    Posts
  • #4825
    Alberto
    Participant

    Hi Tom!
    Let’s see if I can explain the current situation to you:
    I’m working with WPSP and also with Search & Filter plugin.
    I can show my posts in the way I wish when I’m in the archive page (see picture) but if I use the search and filter plugin the results are showed in the content display of the theme (see picture). So I add a taxonomy.php file to my child-theme but I want to render the results as the posts are showed by the WPSP plugin so I wonder if there is a way to achieve this more easily than creating a content with the html structure that I’d use with get_template_part() inside the loop.

    Thanks in advance.

    #4839
    Tom
    Keymaster

    Hey Alberto,

    What does the filter plugin do exactly? Does it allow you to filter things using certain parameters (taxonomy, terms etc..)?

    #4884
    Alberto
    Participant

    Hi Tom!
    Sorry for not replying sooner, I was waiting to receive an email notifying me of your reply but the emails don’t arrive.

    Yes, the plugin works like a wordpress search, allowing you to filter by taxonomy and terms. So I think if WPSP works with the search results page it could be works also with this plugin… Is it possible?

    Thanks in advance!

    #4897
    Tom
    Keymaster

    Hmm, you would need to grab the variables set by the search plugin, and plug them into the settings parameter in the shortcode/plugin.

    For example:

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

    It would require you to use PHP in order to grab those variables from the search plugin.

    #4908
    Alberto
    Participant

    Thanks for replying!
    I’m not sure where I should use that code… The parameters are setting in a custom page (“locutores”) where I use the WPSP shortcode, and the plugin redirects me (when I do my search and filter) to an archive (taxonomy) page.
    Can you tell me where I should use that code?

    Thanks!

    #4910
    Tom
    Keymaster

    That code would need to go into a custom template (taxonomy.php in your case I think).

    Something like this wouldn’t work with shortcodes, as we need to gather values from the search plugin.

    #4927
    Alberto
    Participant

    Hi Tom!
    Thank you for pointing me in the right direction.
    I was trying with your code in taxonomy.php and it works when I filter one taxonomy, but I work with two taxonomies (Gender and Age), so if I want to filter, for example, the posts belong to ‘Female’ and ‘Adult’ I try with this code

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

    But it doesn’t works.
    Colud you tell me how to solve this?

    Thanks in advance!

    #4941
    Tom
    Keymaster

    So it works when you do this?:

    $custom_settings = array(
       array(
         'taxonomy' => 'gender',
         'tax_term' => $gender
       ),
     );
    #4953
    Alberto
    Participant

    Yes, it works if I try to filter by gender (or If I try by age), but I need it filtering by gender and age.

    #4967
    Tom
    Keymaster

    Maybe try this:

    $custom_settings = array(
        'tax_query' => array(
            'relation' => 'AND',
            array(
                'taxonomy' => 'gender',
                'tax_term' => $gender
            ),
            array(
               'taxonomy' => 'age',
               'tax_term' => $age
            ),
        )
    );
    wpsp_display( 123, $custom_settings );
    #4975
    Alberto
    Participant

    Hi Tom!
    Thanks for your suggest but it seems not to works.
    This is the result of $custom_settings var_dump:

    array(1) { ["tax_query"]=> array(3) { ["relation"]=> string(3) "AND" [0]=> array(2) { ["taxonomy"]=> string(6) "gender" ["tax_term"]=> string(6) "female" } [1]=> array(2) { ["taxonomy"]=> string(3) "age" ["tax_term"]=> string(5) "child" } } } 
    

    The result’s page show all the posts, without filtering.

    I’ve also tried with:

    $custom_settings = array(
        'tax_query' => array(
            'relation' => 'AND',
            array(
                'taxonomy' => 'gender',
                'terms' => $gender
            ),
            array(
               'taxonomy' => 'age',
               'terms' => $age
            ),
        )
    );
    wpsp_display( 123, $custom_settings );
    

    And with:

    
    $custom_settings = array(
    	'post_type' => 'locuciones',
    	'tax_query' => array(
    		'relation' => 'AND',
    		array(
    	    	'taxonomy' => 'gender',
    	    	'terms' => array($gender),
    	    ),
    	    array(
    	    	'taxonomy' => 'age',
    	    	'terms' => array($age),
    		),
    	)
    );
    

    What could be wrong with that?

    Thanks in advance.

    #4980
    Tom
    Keymaster

    That’s strange, looks like the right syntax: https://stackoverflow.com/a/45969347/2391422

    I’ll dig into the plugin a bit to see if it’s a bug.

    #4985
    Alberto
    Participant

    Hello Tom!
    According to the syntax reference you’ve given me, I’ve tried with this code:

    $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
    		),
    	)
    );

    But I’m still getting all the posts as result…

    I’ll appreciate so much if you’d take a look at the WPSP plugin code.

    Thanks in advance.

    #5033
    Alberto
    Participant

    Hi Tom!
    Any news on how to solve this problem?
    Days go by and I need to find a solution for my client.

    Thanks

    #5053
    Tom
    Keymaster

    No news yet..

    If you set this up using a new WP_Query (no WPSP), do the arguments work?

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