Welcome to the Treehouse Community

The Treehouse Community is a meeting place for developers, designers, and programmers of all backgrounds and skill levels to get support. Collaborate here on code errors or bugs that you need feedback on, or asking for an extra set of eyes on your latest project. Join thousands of Treehouse students and alumni in the community today. (Note: Only Treehouse students can comment or ask questions, but non-students are welcome to browse our conversations.)

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and a supportive community. Start your free trial today.

WordPress

Catherine Millington
Catherine Millington
3,754 Points

How 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!

Jesus Mendoza
Jesus Mendoza
23,274 Points

Do you want to create a portfolio as your first index page or insert portfolio post in your index page?

1 Answer

The 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
Catherine Millington
3,754 Points

HI 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
Catherine Millington
3,754 Points

I 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!!!!