-
AuthorPosts
-
August 14, 2014 at 11:39 am #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?
August 14, 2014 at 11:55 am #304316Hey 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ünterAugust 18, 2014 at 1:59 pm #305730Hi, 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, 4 months ago by Jamie A.
August 18, 2014 at 2:44 pm #305755Here 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);August 21, 2014 at 10:41 am #307254Hey!
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 -
AuthorPosts
- You must be logged in to reply to this topic.