Skip Navigation

[Resolved] Retrieving current archive on ajax filter

This support ticket is created 3 years, 9 months ago. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 9:00 – 13:00 -
- 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 14:00 – 18:00 -

Supporter timezone: Asia/Karachi (GMT+05:00)

This topic contains 11 replies, has 2 voices.

Last updated by Waqar 3 years, 9 months ago.

Assisted by: Waqar.

Author
Posts
#2028865

Tell us what you are trying to do?
Hello, thank you for your help before. What I'm trying to do is with the same shortcode shared before I need the pricing for this these panels to still show the price on an ajax filter. On page load it works. The $obj is the current archive page I am on.

// Pull Each Price Per Community
add_shortcode('ts_com_price', 'ts_com_price_func');
function ts_com_price_func( $atts, $content) {
$cont = do_shortcode($content);
$obj = get_queried_object();

if(have_rows('price_per_community')) :
while(have_rows('price_per_community')) : the_row();

$com = get_sub_field('community');
if($com->name == $obj->name) :
$price = get_sub_field('price');
endif;

endwhile;
endif;
// var_dump($obj);
return $price;
}

As I mentioned on page load $price returns the information I need but on an ajax filter update it returns empty values because $obj
is no longer returning the queried object I need. Is there a way I can globally define the queried object and get it to always return the $price variable on an ajax filter update?

Is there any documentation that you are following?

Is there a similar example that we can see?

What is the link to your site?

#2029423

Hi,

Thank you for contacting us and I'd be happy to assist.

To be able to test this on my test website and suggest the best way forward, I'll need to see exactly how and where this custom shortcode is being used.

Can you please share temporary admin login details, along with the link to an example archive page, where this shortcode can be seen?

Note: Your next reply will be private and please make a complete backup copy, before sharing the access details.

regards,
Waqar

#2030015

I also should have mentioned you'll see this view in action on any of the community pages when you click the "our floorplans" tab.

#2030563

Thank you for sharing the admin access.

I'm going to perform some tests on my website with a similar setup and then share my findings with you accordingly.

Thank you for your patience.

#2031271

Ok thank you sir. We are off for the rest of the weekend, I will be back in office on Monday morning.

#2034129

Thank you for waiting.

Based on the tests on my website, you can get the current taxonomy term's name from its slug that is available in the URL parameter "wpv-community".
( example link: {yourwebsite.com}/community/autumnwood-estates/?wpv-community=autumnwood-estates )

This way, you won't have to rely on the "$obj" from the "get_queried_object" function.

Example:


add_shortcode('ts_com_price', 'ts_com_price_func');
function ts_com_price_func( $atts, $content) {
$cont = do_shortcode($content);

$category = get_term_by('slug', $_GET['wpv-community'], 'community', 'ARRAY_A');
$current_term_name = $category['name'];

if(have_rows('price_per_community')) :
while(have_rows('price_per_community')) : the_row();

$com = get_sub_field('community');
if($com->name == $current_term_name) :
$price = get_sub_field('price');
endif;

endwhile;
endif;
// var_dump($obj);
return $price;
}

I hope this helps.

#2034141

Thank you I will test this out, and update you.

#2034979

Sure, I'll wait to hear back from you.

#2035585

This is working, but there is still a problem. It's only pulling data from one community, and the other ones are returning false.

#2035593

Actually never mind, I see what happened. I might have this covered now.

#2035691

I do have an issue with the filters not resetting themselves or retrieving a value that is clearly set. Like square footage for example, what would be causing this?

New threads created by Waqar and linked to this one are listed below:

https://toolset.com/forums/topic/split-filters-not-resetting-correctly/

#2036421

Thanks for the update and glad that the custom shortcode is working now.

You're welcome to mark this ticket as resolved and I've created a new ticket for your question related to the filter reset.
( ref: https://toolset.com/forums/topic/split-filters-not-resetting-correctly/ )