WordPress.org

Ready to get started?Download WordPress

Forums

Return only photos (5 posts)

  1. toekneebullard
    Member
    Posted 4 years ago #

    I'm looking for a way to have a category.php file for a specific category that returns only the photos in the posts, but still has the title to each post so you can click through and read the post. Help?

  2. equaldesign
    Member
    Posted 4 years ago #

    You need to create a if statement in your category.php that does this for the specific category. Lets say you wanted to check if category 3 is being shown

    <?php if(is_category(3) ) { ?>

    Then you could add the photos as custom fields when writing the post and retrieve them in your template like this:

    <img src="<?php echo get_post_meta($post->ID, "custom-field-key", true); ?>" alt="<?php the_title(); ?>" />

    Then close the if statement

    <?php } ?>

    This will do the above for only category with the ID 3.

  3. toekneebullard
    Member
    Posted 4 years ago #

    Hmmm...is there a way to do it so that I wouldn't have to go back and edit 4 years of posts? Is there a way to use the img tag alone to identify it?

  4. alainS
    Member
    Posted 4 years ago #

    Try "Get the Image" plug-in. It will do the work.
    http://wordpress.org/extend/plugins/get-the-image/

  5. toekneebullard
    Member
    Posted 4 years ago #

    OK, this seems to be getting me in the right direction, however, I'm hitting one roadblock.

    In the readme it says "You might want to make the script grab the second attached image to a post. You can do that with this code: "

    What if I want it to pull ALL photos from a post?

Topic Closed

This topic has been closed to new replies.

About this Topic