Viewing 4 posts - 1 through 4 (of 4 total)
  • Author
    Posts
  • #1466074

    Hello
    Checked the related answers in the support forum, but nothing worked. The I asked a friend of mine: Chad Gipiti – and together we found a solution.

    Me and Chad, and Chad and me,
    We faced a challenge, tricky as could be.
    A line of code, a filter gone awry,
    But with patience and skill, we reached the sky!

    Me and Chad, and Chad and me,
    We solved the puzzle, set it free.
    With code that sings in perfect rhyme,
    We conquered the problem, one line at a time.

    Well, might not be the sky, but it works. My question: Is it “perfect”? I really would like to know, if you consider this as a “very good solution”, or if you find some flaws in it, or if you got something more elegant..
    Thanks in advance!
    Megan
    ——————————————————–

    
    function click_masonry_sort_option() {
        ?>
        <script>
        document.addEventListener("DOMContentLoaded", function() {
            var checkExist = setInterval(function() {
                var element = document.querySelector('.primary-projects_sort_button');
                if (element) {
                    element.click();
                    clearInterval(checkExist);
                }
            }, 100); // checks every 100 ms to see if the element is present.
        });
        </script>
        <?php
    }
    add_action('wp_footer', 'click_masonry_sort_option');
    
    #1466078

    Hey meganp46,

    Thank you for the poem.

    If the script is meant to automatically click a specific sort button, then it’s perfectly fine. Let us know if you need further assistance.

    Best regards,
    Ismael

    #1466328

    In Enfold’s world, with answers bright,
    They help with care, from dawn till night.
    With effort, joy, and humor too,
    They guide you kindly, see it through.

    A thousand questions every day,
    But never once a tired “nay”.
    With smiles and patience, they understand,
    Solving problems with a helping hand.

    It’s not assumed, we know it’s rare,
    But Enfold’s support is beyond compare!

    Thanks for your answer :)
    Happy days.

    Topic closed.

    • This reply was modified 2 months, 1 week ago by meganp46.
    #1466363

    Hi,

    No problem. Glad we could be of help! :)

    Have a nice day.

    Best regards,
    Ismael

Viewing 4 posts - 1 through 4 (of 4 total)
  • The topic ‘blog masonry sort option: activating new default category on page load’ is closed to new replies.