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 trial

WordPress

Wordpress advanced custom taxonomies

Im working on a photo gallery. The landing page(photo-gallery.php) will be displaying all main categories, then when you click on any category it will be take you to single-gallery.php. I want to display all posts from the specific taxomony in to a slider to link to other posts. Similar to a pager. Im using this code in my single-gallery.php and it's working but it displays all taxonomies and I only need the taxomony im currently on. For example if im looking at fashion photos i want to display all photos from that category. if im looking at commercial photos I want to display all photo from the category and so on. Help?

<?php

$myposts = get_posts(array(
    'porst_per_page' => -1,
    'post_type' => 'gallery',
    'tax_query' => array(
        array(
        'taxonomy' => 'photos',
        'field' => 'slug',
        'terms' => $term->slug
    )))
);



foreach ( $myposts as $post ) : setup_postdata( $post ); ?>
    <li>
        <a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
    </li>
<?php endforeach; 
wp_reset_postdata();?>

</ul>```

The code above goes in the include <?php include('_inc/carousel-gallery-scroll.php'); ?>

/// single-gallery.php

```<?php get_header(); ?>

<section class="container">
    <div class="row">

        <div class="col-sm-8">

            <header class="page-header">
                <h1 class="page-header__title"><?php the_title() ?></h1>
                <p><b>Back To Gallery</b> - <?php echo get_the_term_list( $post->ID, 'procedures-used', '', ', ', '' ); ?></p>
            </header>

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

                <div class="mod gallery gallery--single">

                    <?php include('_inc/carousel-gallery.php'); ?>

                    <?php while ( have_posts() ) : the_post(); ?>

                        <?php if($content = $post->post_content ) {
                      echo "<h4>Description:</h4>";
                      the_content();
                    } ?>

                    <?php endwhile; ?>

                    <?php include('_inc/carousel-gallery-scroll.php'); ?>

                </div><!-- /.mod -->

                <hr>


            <?php endif; ?>

        </div><!-- /.col-sm-8 -->

        <div class="col-sm-4">
            <?php get_sidebar(); ?>
        </div><!-- /.col-sm-4 -->

    </div><!-- /.row -->
</section><!-- /.container -->

<?php get_footer(); ?>```