Parameter sort with anchor text

Hello,

i’ve created a query string with URL parameters to sort the query using a URL via a button.

post_type=post&orderby=title&order={{dc:url:param key=“order” fallback=“asc”}}

Then my Button URL uses this key ?order=desc and all works fine.

My issue is - if I have this set up in the middle of a page, upon clicking the sort button it refreshes the page & returns the users back to the top, to have to scroll down and see the now sorted results.

If i try and anchor text the button with #postlist

e.g. ?order=desc#postlist

to bring the user back down the page, the button reloads the page using only the anchor #postlist and the URL parameter is ignored.

So my question is - is there a way to have my sort parameter URL work with an anchor text?

Or is their a method of enabling users to sort results midway down the page without sending them back to the top with each selection?

Thanks

Hi Jack,

Thanks for reaching out.
I have checked the same in my local environment and it worked perfectly fine.

There might be some different reasons behind your reason, I would like to suggest troubleshooting the following common issue to help us to recognize the reason.

1.Theme Related Issue
2.Plugin Conflict
3.Theme Update related issue
4.Child Theme Related issue ** if you have activated it.
5.CSS/JS Customization
6.Disabling Cache

If you discover that an issue is coming from a custom code or 3rd party plugin, kindly consult with a developer or contact the plugin author. Please note that we do not provide support for custom codes and 3rd party plugins.
If none of the above help, please provide login credentials for your site in a secure note to examine it further, including:

– WordPress Site URL & Login URL
– WordPress Admin username/password

To create a secure note, click the key icon underneath any of your posts.

Thanks

Hello,

It worked and jumped you down the page to the anchor?

Please log in and check my set up…

thanks!

Hi Jack,

I have created the same setup on your test page and it worked too. The DIV element is having the Query String and the parent section is having the postlist ID.

Hope it helps.
Thanks

Hello,

Cheers for taking the time to look.

I have a different solution but the problem was that I couldn’t add an anchor tag to the sort URL of the button e.g. ?orderby=desc#postlist … which would return the user back to the posts listing after the page loads.

Ive updated your example to show you what i mean

Adding the button (in text) as a ‘form’ works and uses a jump to anchor …for any other users that may want to know.

<form action='?q=string#youranchortext' method='GET or POST' >
    <input type='hidden' id='order' name='order' value='desc'>
    <input type='submit' value='Descending Order'>
</form>

Thanks

Hi Jack,

Thanks for sharing the solution.

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.