• Resolved miskettie

    (@miskettie)


    Hello!

    I am using the Scratch theme and I have managed to make a template which turns the page into a blog. However I am trying to show just one category in this template…I don’t mind if I exclude all the other categories or whether I just display the one category. (if you get my drift).

    I have searched all around and tried the <?php query_posts('cat=-3'); ?> (and other variations) but every time I do it brings up an error message. I am not experienced with code, so not sure what I am doing wrong.

    Here is the page, which I am trying to show only one category on:
    https://www.enysthemenace.co.uk/all-the-gear/

    Any help would be greatly appreciated.

Viewing 6 replies - 1 through 6 (of 6 total)
  • The advantage to showing just the one category is that you won’t need to edit the template if you add more categories in the future. What is the id of the category that you want to include?

    Put your template code in a pastebin and post a link to it here.

    Thread Starter miskettie

    (@miskettie)

    Sorry only just seen this reply.

    I want to only show category 8 (reviews) on the template. The template currently shows all of the posts:

    Link to the paste bin

    The template at the moment is just a copy of the blog.php and just shows all the posts. Ideally I would also like it to show the text that I put on that page. I am not very experienced so if you have to explain something you might have to explain very simply!

    Thank you

    Add this just after the line 'post_status' => 'publish',:

    'cat' => 8,
    Thread Starter miskettie

    (@miskettie)

    Fantastic – that has worked…thank you! Do you know how to include the text at the top? It is nothing essential, so if it is complicated then don’t worry.

    Thank you!!!!

    Try changing this:

    <main class="<?php echo $page_layout ?>" role="main">

    to this:

    <main class="<?php echo $page_layout ?>" role="main">
       <div class="top-content">
       <?php if ( have_posts() ) {
          while ( have_posts() ) {
             the_post();
             the_content();
             break;
          }
       } ?>
       </div>
    Thread Starter miskettie

    (@miskettie)

    Brilliant! Thank you so much!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Exclude Category from Blog Template’ is closed to new replies.