Tagged: categories, portfolio grid
Hi,
Instead of showing all the categories by default in the portfolio grid, is it possible to select one specific category by default ?
When a user sees the porfolio grid, I want to display posts from category XYZ right away.
Hi mike235!
Yes you can select a category to show, just edit the Portfolio Grid, the first box in the edit screen will let you select a category.
Best regards,
Rikard
Hi Rikard,
Thank you for your reply. Sorry I didn’t explain clearly, ok let’s say in the Portfolio grid options you select the two categories “for sale” and “for rent”. On the front end, once the Portfolio grid is displayed, it shows the following links “All | For sale | For rent”. By default, “All” is selected, showing both posts from the “for sale” and “for rent” categories.
What I want to achieve is to show right away the “for rent” category, but still having the choice of clicking on “All” or “For sale” links. Is that possible ?
Best regards,
Mike
Hi!
Add this to the functions.php file:
add_action('wp_footer', 'ava_auto_click');
function ava_auto_click(){
?>
<script>
(function($){
$(window).load(function() {
$('.categoryname_sort_button').trigger('click');
});
})(jQuery);
</script>
<?php
}
Change the “categoryname” to the name of the category that you want to display initially on page load. Remove browser cache before testing the page.
Cheers!
Ismael
Hi Ismael, thanks for the piece of code, it works !