WordPress.org

Ready to get started?Download WordPress

Forums

PHP Template to display single custom post type! (2 posts)

  1. akewt
    Member
    Posted 1 year ago #

    Hello

    Can somebody please help me with a little php template please!? I am so nearly there but have got to the point where I can no longer identify a solution.

    my website: http://www.akewt.com has a cusotm post types, being the portfolio posts. works beautifully in the portfolio and i have managed to duplicate it and remove the bits i don't want for the gallery section: http://www.akewt.com/gallery/.

    no the only thing left i would like to achieve is the gallery template to only show a specific type of portfolio entry. currently you can add different types and i would like the template to only display one type ie 'gallery' so i can define some image posts just for the gallery.

    can somebody identify which is the part that looks for the types and perhaps suggest some code which would define ONLY the gallery type. Should be fairly easy I imagine for somebody that knows php! ;)

    thanks for any help.

    kev

    <?php
    /*
    Template Name: Gallery Sortable Portfolio Three Columns
    */
    ?>
    <?php get_header(); ?>
    <?php $themePath = get_template_directory_uri(); ?>
    <div class="span13 offset3" role="main">
    	<?php if (have_posts()) :  while (have_posts()) : the_post(); ?>
        <?php endwhile; else : endif; ?>
        <div class="row gallery">
            <?php $query = new WP_Query(); $query->query('post_type=portfolio&posts_per_page=-1'); ?>
            <ul class="gallerycolumns">
                <?php $count = 1; ?>
    			<?php if ($query->have_posts()) : while ($query->have_posts()) : $query->the_post();
                      $terms = get_the_terms( get_the_ID(), 'skill-type' );  ?>
                <li data-id="id-<?php echo $count; ?>" class="<?php foreach ($terms as $term) { echo strtolower(preg_replace('/\s+/', '-', $term->name)). ' '; } ?>">
                    <article id="post-<?php the_ID(); ?>" class="gallery_galleryitem3">
                        <?php
                        if ( (function_exists('has_post_thumbnail')) && (has_post_thumbnail()) ) { ?>
                        <div class="postheader">
                            <?php $image_id = get_post_thumbnail_id(); ?>
                            <?php $image_url = wp_get_attachment_image_src($image_id,'full'); $image_url = $image_url[0]; ?>
                            <a href="<?php echo $image_url; ?>" rel="prettyPhoto[gallery]"><span class="gallery_overlay"></span><?php the_post_thumbnail('portfolio-small', array('class' => 'portfolio')); ?></a>
                        </div>
                        <?php } ?>
                    </article>
                </li>
                <?php $count++; ?>
                <?php endwhile; endif; ?>
            </ul>
    		<?php wp_reset_query(); ?>
        </div>
    </div>
    <?php get_footer(); ?>
  2. akewt
    Member
    Posted 1 year ago #

    <li data-id="id-<?php echo $count; ?>" class="<?php foreach ($terms as $term) { echo strtolower(preg_replace('/\s+/', '-', $term->name)). ' '; } ?>">
                    <article id="post-<?php the_ID(); ?>" class="gallery_galleryitem3">
                        <?php

    i'm pretty sure it has something to do with this part!

Topic Closed

This topic has been closed to new replies.

About this Topic

Tags