Tagged: x
-
AuthorPosts
-
April 11, 2016 at 12:23 pm #876833
kkendall2010ParticipantI’d like to display only certain blog categories on my blog page of the website. I found on another thread to use
function my_home_category( $query ) {
if ( $query->is_home() && $query->is_main_query() ) {
$query->set( ‘cat’, ‘research’);
}
}
add_action( ‘pre_get_posts’, ‘my_home_category’ );and list the blog ID, which I think I found but I’m not sure why it’s not working.
April 11, 2016 at 12:24 pm #876837
kkendall2010ParticipantThis reply has been marked as private.April 11, 2016 at 11:14 pm #877591
RupokMemberHi there,
Thanks for writing in! I can’t check your site as it’s asking for authentication.
To use the above code, make sure you are using Latest Posts on homepage and the category slug research exists.
In other way, you can use Recent Posts element in Cornerstone and set the category.
Cheers!
April 13, 2016 at 8:21 am #879967
kkendall2010ParticipantThis reply has been marked as private.April 13, 2016 at 7:11 pm #881140
RadModeratorHi there,
I checked and yes that code isn’t working or ineffective. Though, I like to directly check it too through hard coding. Would you mind providing your FTP login credentials as well?
About your second question, do you wish your blog home page not be the home page? I mean, you wish to set a static page at your home page other than the blog page?
Thanks!
April 14, 2016 at 7:56 am #882146
kkendall2010ParticipantI don’t have FTP login’s, and that is correct. I want a static front page, with the blog page somewhere else only displaying one category. I have the blog page established, I just need to specify the category.
April 14, 2016 at 4:28 pm #883132
JadeModeratorHi there,
I’m afraid it would be difficult for us to sort the first item since we need to check the changes in the code you have added in the child theme.
As for the second question you can create a page that will be your homepage then go to Settings > Reading then set a static page for the Front page displays
Hope this helps.
July 13, 2016 at 12:26 pm #1085269
SitegemzParticipantHello I’m trying to do the same thing and I used the shortcode [display-posts category=”directory” posts_per_page=”10″ include_date=”false” order=”ASC” orderby=”title”] to display specific blog categories but it doesn’t seem to be working. I also asked this in another thread but can’t seem to find that one. Sorry
July 13, 2016 at 8:34 pm #1085964
FriechModeratorHi There,
Please update your shortcode to this
[x_recent_posts type="post" count="4" offset="" category="directory" orientation="horizontal" no_sticky="true" no_image="false" fade="true"]Make sure you put a correct value on
category=""attribute.Thanks.
July 14, 2016 at 2:25 pm #1087315
SitegemzParticipantthat works but it’s still not giving me the ability to order in “ASC” or apply pagination for multiple posts. There are some 130 posts categorized in alphabetical order & also in directory I want to show the complete list with pagination 10-15 per page in directory you can look here for the page itself. http://mtz.sitegemz.com/?page_id=430 Vs. what the short code has given me. http://mtz.sitegemz.com/?page_id=683. I tried using wordpress arguments for the shortcode but I’m assuming the arguments have somewhat changed with the x-theme
July 14, 2016 at 10:18 pm #1087954
Rue NelModeratorHello There,
Thanks for the updates! Since recent post element is not working for you, we will go back to your original code. It is not working because you are suppose to insert a category ID and not the category name. Please check out this article and correct your code:
https://premium.wpmudev.org/blog/one-category-wordpress-homepage/?tchv=b&utm_expid=3606929-72.AqocGS0YR5Gn_p3r6t6_AA.1Hope this helps.
July 15, 2016 at 12:05 am #1088044
SitegemzParticipantthanks for the help
July 15, 2016 at 5:07 am #1088278
Rue NelModeratorYou’re welcome! We’re happy to help you out.
If you need anything else we can help you with, don’t hesitate to open another thread.July 17, 2016 at 6:24 pm #1091007
SitegemzParticipantThis worked like a charm but now I need to get them ordered in alphabetical order. This is code I used
}
function my_home_category( $query ) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( ‘cat’, ‘5’); } } add_action( ‘pre_get_posts’, ‘my_home_category’ );This is the code I found in the knowledge base:
add_action(‘pre_get_posts’, ‘category_sort_by_title’);
function category_sort_by_title($query) {
$query->set(‘orderby’, ‘title’);
$query->set(‘order’, ‘ASC’);
}I tried stacking them however they pretty much blew up the site & I needed to upload a backup to get it working again. please advise & thank you for your assistance.
July 17, 2016 at 9:54 pm #1091293
LelyModeratorHi There,
We need to combine those functions into one. Please remove both code and then use this instead:
add_action('pre_get_posts', 'category_sort_by_title'); function category_sort_by_title($query) { if ( $query->is_home() && $query->is_main_query() ) { $query->set( 'cat', '5'); } $query->set('orderby', 'title'); $query->set('order', 'ASC'); }Hope this helps.
-
AuthorPosts
- <script> jQuery(function($){ $("#no-reply-876833 .bbp-template-notice, .bbp-no-topic .bbp-template-notice").removeClass('bbp-template-notice'); }); </script>
