Viewing 11 posts - 1 through 11 (of 11 total)
  • Author
    Posts
  • #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.

    #1291255

    Hi 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,
    Nikko

    #1291257

    It 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 be css_sort, but nothing, it stoped working and I don’t know when.

    Thanks.

    #1291547

    I 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.

    #1291593

    Hi 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,
    Nikko

    #1291602

    Thank 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_sort

    function add_custom_script2()
    with a-2_sort

    function add_custom_script3()
    with a-3_sort

    But 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.

    #1291625

    Hi 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.

    #1291721

    And 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.

    #1291826

    Hi 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,
    Nikko

    #1291828

    That fixed the errors, you can mark it as solved.

    Thank you Nikko!

    #1291830

    Hi peterolle,

    We’re glad that we could help :)
    Thanks for using Enfold and have a great day!

    Best regards,
    Nikko

Viewing 11 posts - 1 through 11 (of 11 total)
  • The topic ‘Select category for sorting portfolio on load’ is closed to new replies.