Tagged: x
-
AuthorPosts
-
January 29, 2017 at 8:21 am #1349554
dundidandiParticipantHi There!
I’m Daniel, a total-wp-dummie but very enthusiastic!
I’m trying to set up the homepage of my website to show only one category of blog posts instead of all of them. I was looking for this option everywhere under the “customize” menu but couldn’t find the answer. I’ve read many forum posts as well without success (most are very difficult to me, codes etc.).
I’m using the “Renew” stack of the X Theme.
Could you help me with your advice?
Warm regards,
Daniel
January 29, 2017 at 9:22 am #1349601
ThaiModeratorHi Daniel,
Because this requires a template change, I’d advise that you setup a child theme. This allows you to make code changes that won’t be overwritten when an X update is released. After your child theme is setup, please add following PHP code below into functions.php locates in child theme’s folder:
function x_exclude_cat_from_home($query) { if ($query->is_home() && $query->is_main_query()) { $query->set('cat', '123'); } } add_action('pre_get_posts', 'x_exclude_cat_from_home');The 123 number is your category ID.
Hope it helps.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-1349554 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
