Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #304309

    When I visit my Blog page is there any way that it can shows the category : ‘Portrait’ RATHER than always showing the category ALL. as the default?

    http://shutterliving.com/homepage/recent-work/

    #304316

    Hey Jamie A!

    Thank you for using our theme.

    In functions.php put the following:

    
    function my_portrait_click()
    {
    ?>
    <script>
    jQuery(function(){
    	jQuery('.portrait_sort_button').trigger('click');
    });
    </script>
    <?php
    }
    add_action('wp_footer', 'my_portrait_click', 900);
    

    Cheers!
    Günter

    #305730

    Hi, This code worked perfectly,

    However when I load the page only ‘9’ posts show before you have to hit the ‘Load more posts’ button.

    Is there any way I can increase this. (When I edit the page and click the ‘masonry grid’ it show that 60 posts should load?)

    Also, it is a little odd but it seems to have slowed the site down IE: the page loads much slower now? Could I just be imagining this?

    Jamie

    PS: With this code can I just replace the word ‘Portrait’ with another category name, IE: I have a new category named ‘Top’ can I replace where it says Portrait in your code with – ‘Top’ I tried and it seems to work, but some times when I refresh it reverts back to the Portrait category.

    I have no cache plugins and I have cleared my browser cache?

    • This reply was modified 10 years, 3 months ago by Jamie A.
    #305755

    Here is the code i modified:

    function my_top_click()
    {
    ?>
    <script>
    jQuery(function(){
    jQuery(‘.top_sort_button’).trigger(‘click’);
    });
    </script>
    <?php
    }
    add_action(‘wp_footer’, ‘my_top_click’, 900);

    #307254

    Hey!

    1) You can’t increase the number of posts of a certain category but you can increase the total number of posts (can be part of any category) which will show up before you click the “load more” button. The code Günter posted above will then sort these posts with js. It then simply depends on how many “Portrait” posts can be found on the first page. If you increase the number of posts per page you also increase the loading times because the server must query more posts and the browser must load more resources (more html code, more images, etc.). If you just want to show the posts of a certain category I recommend to remove the js/jquery filter and to use wordpress/php to query the posts of a certain category only.

    2) You can try to add a timeout to Günters code – it will delay the trigger event a bit and isotope should hav some time to load properly. The disadvantage is that the loading times may increase a bit. For the sample code I added a delay of 500 ms (0,5 seconds) but you can change it if necessary.

    
    function my_portrait_click()
    {
    ?>
    <script>
    jQuery(function(){
    setTimeout(function(){ jQuery('.portrait_sort_button').trigger('click'); },500);";
    });
    </script>
    <?php
    }
    add_action('wp_footer', 'my_portrait_click', 900);
    

    Best regards,
    Peter

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.