Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialCatherine Millington
3,754 PointsHow do I create a new portfolio on the Twenty Fourteen Theme?
I have a child theme and have tried creating a new page, created a new template to use which has an effect and using the index file code (the blog page for the site) as the template but it just doesn't show any posts. I want to create a portfolio page showing only a certain category. Been on this all day and can't work it out :o/ Please help me!
1 Answer
connorriley
23,101 PointsThe simplest way would be to create a new page template. And use a loop filtered by category.
$query = new WP_Query( array( 'category_name' => 'CATEGORY_NAME' ) );
Catherine Millington
3,754 PointsHI i want to keep my index page as a static page and then have one of the other pages set to open up all posts with one category. I have used the code from the index template to see if it would bounce back any posts but it doesn't i guess because it has the coding to turn posts on or off through the dashboard (which i don't really understand so can't find to delete). I'll try and write a loop and put the code above in it and see how i get on. Thanks for your time.
Ok, i have done this but it still doesn't show anything'
'''php
get_header(); ?>
<div id="main-content" class="main-content">
<?php if ( is_front_page() && twentyfourteen_has_featured_posts() ) { // Include the featured content template. get_template_part( 'featured-content' ); } ?>
<div id="primary" class="content-area">
<div id="content" class="site-content" role="main">
<?php
if ( have_posts() ) :
// Start the Loop.
while ( have_posts() ) : the_post();
$query = new WP_Query( array( 'category_name' => 'whats-on' ) ); get_template_part( 'content', get_post_format() );
endwhile;
// Previous/next post navigation.
twentyfourteen_paging_nav();
else :
// If no content, include the "No posts found" template.
get_template_part( 'content', 'none' );
endif;
?>
</div><!-- #content -->
</div><!-- #primary -->
<?php get_sidebar( 'content' ); ?>
</div><!-- #main-content -->
<?php get_sidebar(); get_footer();
'''
Catherine Millington
3,754 PointsI was over complicating things.....category searches are already set up with this theme so i just made a custom link on the menu for .............../category/whats-on/ and it now works. Sorry to be a pain!!!!
Jesus Mendoza
23,289 PointsJesus Mendoza
23,289 PointsDo you want to create a portfolio as your first index page or insert portfolio post in your index page?