WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hi I was wondering if it is possible to create a custom post type called "Gallery" where i only upload photos and ad captions and when i post it, it post as a gallery. Also when it shows on the homepage it shows as "View Photos" instead of read more, and goes straight to the gallery page.

Also i want to be able to add taxonomies such as "Tv Show" so it will be like this


The post below didn't help me, i tried that plugin and it didn't work for me it didn't go to a gallery it went to a single post page with nothing on it.

Creating Photo Gallery System with Custom Post Type

share|improve this question
Why not to use Post Formats, codex.wordpress.org/Post_Formats – amit Aug 2 '12 at 10:13
I didn't know about that i will test this out to see if it works – Terrell Anderson Aug 2 '12 at 10:17
I don't understand that it doesn't work for me – Terrell Anderson Aug 2 '12 at 10:25
up vote 1 down vote accepted

Can I show different text for linking to gallery posts ?

YES, Here's how to do it, put this where you want to output text as - readmore/view photos, depending on theme or way you're generating these text we can use filter to change it as per custom post type.

echo '<a href="'.the_permalink().'">';
if ( 'gallery' == get_post_type() ) {
    echo 'View Photos';
} else {
    echo 'Read More';
echo '</a>';

Custom template for Custome post type

You can configure your blog to use different template for custom post type by creating a template with slug single-gallery.php where gallery is custom post type slug.

Update- To show images as gallery on single post (from this answer)

Add the following code to your themes single.php to show the attached images(full) beneath the post content, And the condition will check for custom post type - gallery.


if ( 'gallery' == get_post_type() ) { //condition to show gallery on post type - gallery

    if ( $attachments = get_children( array(
        'post_type' => 'attachment',
        'post_mime_type'=>'image',   //return all image attachment only
        'numberposts' => -1,   //get all the attachments
        'post_parent' => $post->ID

    foreach ($attachments as $attachment) {
        // you can customize the oputput
        echo wp_get_attachment_link( $attachment->ID, 'full' , false, false, '' );
        echo '<span class="img_cap">'.$attachment->post_excerpt.'</span>';



Read the codex page for more information - wp_get_attachment_link#Parameters

share|improve this answer
This helps but I have a custom post type called photos, But i don't know how to get the single post to show as a gallery, I tried just uploading photos to the post without placing them in the text box and that doesn't work. What do i do? Am i suppose to add the [gallery] tag or what? Once again i don't want it to show up as thumbnails i want it to show up as a full gallery for the photos attached to that post. Aslo where do i put the above code. – Terrell Anderson Aug 2 '12 at 10:30
are you using Wordpress uploader? – amit Aug 2 '12 at 10:32
Yes that i am using wordpress uploader – Terrell Anderson Aug 2 '12 at 10:51
I really really need help with this someone Please – Terrell Anderson Aug 2 '12 at 12:16
That totally worked but do you know how i can style it to look a certain way – Terrell Anderson Aug 2 '12 at 13:09

Your Answer


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.