Blog only showing specific Categories

Home Forums SKT Full Width Forum Blog only showing specific Categories

Tagged: ,

This topic contains 4 replies, has 2 voices, and was last updated by  SKT Themes 3 years, 4 months ago.

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #1878

    Andrew Hall
    Member
    • Topics: 2
    • Replies: 2
    • Total: 4
    Member since: September 19, 2014

    I like the layout of the Blog better than I do the Category Page. I was wondering how I could create a Page that displays in the blog format, but is only filled with Posts of a certain Category?

    Thanks in advance.

    #1884

    SKT Themes
    Keymaster
    • Topics: 2
    • Replies: 5637
    • Total: 5639
    Member since: June 12, 2013

    Hi,

    All you need to do is create another page template copying the contents of index.php How to create a page template is given here: http://codex.wordpress.org/Page_Templates

    Within index.php remove the line: <?php if( (is_home() && get_option(‘page_for_posts’)) || is_front_page() ) { ?>

    And also remove this line: <?php } else { ?>

    And then add this code above: <?php query_posts(‘category_name=CATEGORYNAME&showposts=5’);

    <?php if( have_posts() ) : ?>

    Replace CATRGORYNAME with your category name

    This will show blog with category.

    In case its difficult for you we can create one template for you provided you send us FTP details of the folder where your site is (without ftp and with only WordPress we can’t do).

    Regards,
    Shri

    #1886

    Andrew Hall
    Member
    • Topics: 2
    • Replies: 2
    • Total: 4
    Member since: September 19, 2014

    I did what you said, but I am getting the below error:

    Parse error: syntax error, unexpected ‘=’ in C:\xampp\htdocs\www.d-dub.com\wp-content\themes\skt_full_width_pro\page-bonetown.php on line 5

    To make sure I am doing it right, let me tell you what I did. I replaced <?php if( (is_home() && get_option(‘page_for_posts’)) || is_front_page() ) { ?> with the code <?php query_posts(‘category_name=CATEGORYNAME&showposts=5′); (adding a ?> at the end, which you didn’t have, but I assume should be there).

    Next I replaced CATEROYNAME with my category slug name.

    Under this code I added <?php if( have_posts() ) : ?>

    Finally, I deleted <?php } else { ?>

    Right now I am only working on a localhost, so there is no ftp to upload to.

    Here is the code:

    <?php
    /* Template Name: About Game Page */
    get_header(); ?>

    <?php query_posts(‘category_name = aboutgame & showposts=5′); ?>

    <?php if( have_posts() ) : ?>

    <div id=”primary” class=”content-area”>
    <div id=”content” class=”site-content container”>
    <main id=”main” class=”site-main” role=”main”>
    <header class=”page”><h1 class=”entry-title”>Blog</h1></header>
    <div class=”blog-post”>
    <?php if( have_posts() ) : ?>
    <?php while( have_posts() ) : the_post(); ?>
    <?php get_template_part( ‘content’, get_post_format() ); ?>
    <?php endwhile; ?>
    <?php skt_full_width_pagination(); ?>
    <?php else : ?>
    <?php get_template_part( ‘no-results’, ‘index’ ); ?>
    <?php endif; ?>
    </div><!– blog-post –>
    <?php get_sidebar(); ?>
    <div class=”clear”></div>
    </main><!– main –>
    <?php get_footer(); ?>

    </div>
    </div>
    </body>
    </html>

    <?php } ?>

    #1887

    Andrew Hall
    Member
    • Topics: 2
    • Replies: 2
    • Total: 4
    Member since: September 19, 2014

    I figured it out.

    I needed an <?php endif; ?> at the end.

    #1889

    SKT Themes
    Keymaster
    • Topics: 2
    • Replies: 5637
    • Total: 5639
    Member since: June 12, 2013

    Hey glad you figured it out.

    I was going to post the answer now.

    Regards,

    Shri

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.