Please how can I display a specific category on Front-Page page, I want to display music category on my WordPress front page at least 3post on Front-Page, I don't know how I can do this

  • Display post as an archive page would display it as in Title with a brief summary of each post, or just the links to the 3 posts? – Kumar Sep 12 '19 at 7:29
  • I don't understand – Oluwatemitope Adeala Sep 12 '19 at 7:32
  • Basically you need to add more details to your question, it gives very little information about what is "Front-Page page" Is it same as home page or it's a different file altogether? How you're trying to display posts, as in any specific format? – Kumar Sep 12 '19 at 9:06

That's easy, just add following code in your theme's functions.php file:

function 348118_my_home_category( $query ) {
    if ( $query->is_home() && $query->is_main_query() ) {
        $query->set( 'cat', '1234' );
add_action( 'pre_get_posts', '348118_my_home_category' );

In the above code change 1234 with the ID of your music category.

  • After adding the code to function file how can I display it on Front-Page.php – Oluwatemitope Adeala Sep 12 '19 at 7:33
  • You don't need to do anything other than that code to show post since your homepage already fetches post by default from all category, with above code, it will now restrict post from only that category. – Den Pat Sep 12 '19 at 14:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.