Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I need to list(display) all thumbnails from my Custom Post Types in a page template based on product categories. For Example I have a Custom Category called "Art" and some images(Custom Post Type) products enabled by "Feature Image" associated with "Art" Category.Now I would like to list ONLY all thumbnails of Art category product on my Custom Page Template.

Can you please let me know how to do this? I find this method which works only for one page without ability to select from pages!

<?php the_post_thumbnail(); ?>
share|improve this question
add comment

1 Answer 1

You need to use custom post and make the categorys there and align the thumbnails in each post.

 <?php // query post type */*/

        global $post;
        $args = array(
        'post_type' => 'YOUR-POST-TYPE-HERE',
        'cat' => $category,
        'suppress_filters' => '0',
        'numberposts' =>'-1',
        'orderby' => 'title',
        'order' => 'asc',
        'post_status' => 'publish' );   
        $myposts = get_posts( $args );

        foreach( $myposts as $post ) :  setup_postdata($post);
        $meta = $custom_metabox_jurister->the_meta();?>

And check if post have thumnail:

<?php // Checks if there is a thumbnail and displays it
                if ( has_post_thumbnail() ) { 

                $size = 'thumbnail';
                $attr = array(
                'class' => 'post-logo');
                echo '<div class="image">';
                echo the_post_thumbnail('large', $attr);
                echo '</div>';
                } 
                else{ 
                // Do nothing
                } 
    ?>

Change the code , to fit your idea.

Not sure if I understood exactly what you wanted to do. But hope this helps.

share|improve this answer
    
Hi Meias and thanks for your comment. Do I have to add both parts to Page Template? –  Behseini Jan 29 '13 at 11:24
    
Both parts in the same order and template. And change it to fit your code. –  M3o Jan 29 '13 at 11:31
    
well, I am getting this error message Parse error: syntax error, unexpected $end in /home/content/84/10393684/html/wp-content/themes/myPress/page Gallery.php on line 23 –  Behseini Jan 29 '13 at 11:39
    
try removing, $meta = $custom_metabox_jurister->the_meta(); part. –  M3o Jan 29 '13 at 11:40
    
same! I am getting same issue! –  Behseini Jan 29 '13 at 15:04
show 1 more comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.