Home › Forums › SKT Full Width Forum › Blog only showing specific Categories
- This topic has 4 replies, 2 voices, and was last updated 10 years, 2 months ago by Sonl Sinha.
-
AuthorPosts
-
September 24, 2014 at 5:25 pm #1878
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.
September 25, 2014 at 10:02 am #1884Hi,
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,
ShriSeptember 25, 2014 at 3:30 pm #1886I 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 } ?>
September 25, 2014 at 9:42 pm #1887I figured it out.
I needed an <?php endif; ?> at the end.
September 26, 2014 at 5:59 am #1889Hey glad you figured it out.
I was going to post the answer now.
Regards,
Shri
-
AuthorPosts
- You must be logged in to reply to this topic.