2

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(); ?>

1 Answer 1

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.

6
  • Hi Meias and thanks for your comment. Do I have to add both parts to Page Template?
    – Suffii
    Commented Jan 29, 2013 at 11:24
  • Both parts in the same order and template. And change it to fit your code.
    – M3o
    Commented Jan 29, 2013 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
    – Suffii
    Commented Jan 29, 2013 at 11:39
  • try removing, $meta = $custom_metabox_jurister->the_meta(); part.
    – M3o
    Commented Jan 29, 2013 at 11:40
  • 1
    Please edit the question with more code
    – M3o
    Commented Jan 29, 2013 at 15:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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