-
AuthorPosts
-
March 27, 2021 at 10:54 am #1290716
I had this working and I just noticed that it simply loads all, instead of the one I had selected.
I was using this:
function add_custom_script1(){ ?> <script> (function($){ $(window).load(function() { $('a[data-filter="a-1_sort"]').trigger('click'); }); })(jQuery); </script> <?php } add_action('wp_footer', 'add_custom_script1');
No longer working.
What is the correct way to select the category to start with on a sorting portfolio?
Example: https://kriesi.at/themes/enfold/portfolio/portfolio-ajax/
I want to start with CSS selected, because I have over 100 items and All is not a choice.Thanks.
March 30, 2021 at 8:46 am #1291255Hi peterolle,
Can you give us a link to the page where you are applying the script? so we can take a closer look.
Best regards,
NikkoMarch 30, 2021 at 8:48 am #1291257It is in functions.php and it was working fine. It is exactly as the example above and for your example page, instead of
a-1_sort
it should becss_sort
, but nothing, it stoped working and I don’t know when.Thanks.
March 31, 2021 at 1:33 pm #1291547I add a bit more info, it seems a jQuery conflict.
Uncaught ReferenceError: jQuery is not defined. Pointing to:
})(jQuery);
as the error.How should the new code be to make it start in the category I want?
Thanks.
March 31, 2021 at 4:59 pm #1291593Hi peterolle,
Can you try using this code instead:
function add_custom_script1(){ ?> <script> (function() { window.addEventListener('load', function(event) { var link = document.querySelector('a[data-filter="a-1_sort"]'); link.click(); }); })(); </script> <?php } add_action('wp_footer', 'add_custom_script1');
Best regards,
NikkoMarch 31, 2021 at 5:34 pm #1291602Thank you Nikko, we are getting close.
If I use just 1 it works, but I have 3 and as soon as I add a second one I get in the second and third:
Uncaught TypeError: Cannot read property ‘click’ of null, pointing to
link.click();
I need 3 blocks of code:
function add_custom_script1()
with a-1_sortfunction add_custom_script2()
with a-2_sortfunction add_custom_script3()
with a-3_sortBut it only works if I have 1, if I add more, the first one stops working and the next ones throw the error.
How to have 3?
Thanks.
March 31, 2021 at 11:40 pm #1291625Hi Nikko,
I am trying to get a resolution on my ticket I put in 2 days ago and one today. I need your support teams help as I am at a loss. Can you please look at my ticket or have one of your team? Please and it is very appreciated. Sorry for jumping this thread I just don’t know what to do. TY.
April 1, 2021 at 9:22 am #1291721And you come to my thread to do that BowmansArrowMarketing? If you already opened your thread, wait for a response or update your own thread, don’t go to other threads that have nothing to do with yours to spam and grab attention.
Mods, feel free to delete BowmansArrowMarketing message in this thread and this message as well to leave the thread clean and waiting for the correct answer.
April 1, 2021 at 4:55 pm #1291826Hi peterolle,
Can you try using this code instead:
function add_custom_script1(){ ?> <script> (function() { window.addEventListener('load', function(event) { var links = document.querySelectorAll('a[data-filter="a-1_sort"]'); links.forEach(function(link) { link.click(); }); }); })(); </script> <?php } add_action('wp_footer', 'add_custom_script1');
@BowmansArrowMarketing we’ll be checking your thread, we apologize for the delay as there are a lot of queries lately.Best regards,
NikkoApril 1, 2021 at 4:59 pm #1291828That fixed the errors, you can mark it as solved.
Thank you Nikko!
April 1, 2021 at 5:08 pm #1291830Hi peterolle,
We’re glad that we could help :)
Thanks for using Enfold and have a great day!Best regards,
Nikko -
AuthorPosts
- The topic ‘Select category for sorting portfolio on load’ is closed to new replies.