WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] Archive and Categories don't show pictures and links in posts (9 posts)

  1. yinging
    Member
    Posted 8 years ago #

    I have to following problem:

    When a click the "Archives" link or any of the Categories links, I can see all relevant posts in my blog, but any pictures or links in them are not displayed.

    In normal mode everything is OK, I can see both the pictures and the links.

    What could be the cause of the problem?

  2. Kafkaesqui

    Posted 8 years ago #

    It's an issue with the theme. If you edit the archive.php template, you'll find it uses the_excerpt() to display post content, which filters out html tags. So to get what you're after, you need to change:

    <?php the_excerpt(); ?>

    to

    <?php the_content(); ?>

  3. yinging
    Member
    Posted 8 years ago #

    Kafkaesqui, thank you very VERY much!!! :)))

  4. endrico
    Member
    Posted 8 years ago #

    but is there a way to display only images, and not the text

  5. Kafkaesqui

    Posted 8 years ago #

    "but is there a way to display only images, and not the text"

    A couple ways to do this are:

    1. Keep the_excerpt() in place and insert the image in the excerpt field of your post as well. This is a bit of a hack, and can cause problems elsewhere (especially if you display summaries in your syndication feeds). But it works; well enough.

    2. Parse the post content for an img tag, and display only this. Something like the following (used in place of the_excerpt() or the_content()) should do:

    <?php
    preg_match('/<img[^>]*>/i', $post->post_content, $image);
    foreach ($image as $display) {
    echo $display . '<br />';
    }
    ?>

    You might even choose to display an excerpt (or post content) if no image is found in a post:

    <?php
    preg_match('/<img[^>]*>/i', $post->post_content, $image);
    if($image) {
    foreach ($image as $display) {
    echo $display . '<br />';
    }
    } else {
    the_excerpt();
    }
    ?>

  6. nishe
    Member
    Posted 8 years ago #

    Thank you so much for this! I've had the same problem with a theme.

  7. grmweb
    Member
    Posted 8 years ago #

    Thank you Kafkaesqui for the extremely helpful information. :)

  8. stchatterbox
    Member
    Posted 8 years ago #

    I've the same problem even after changing the <?php the_excerpt();?> to <?php the_content();?>

    I'm using dara's plugin which shows the flickr slideshow thumbnail using the CUSTOM FIELD when writing the post. I'm creating a "page" for this category and the URL is http://seville.u54.oo.nu/blog/category/fotojournal but then the thumbnail is not showing up. I just wonder how dara made it show up on her archive page at http://www.darasplace.com/category/photography/

    I don't have her email thus I can't write her. Please let me know which code shall I put in my archives template. Thanks a lot.

  9. Blythe
    Member
    Posted 8 years ago #

    Had the same problem. Thanks for the fix, Kafkaesqui!

Topic Closed

This topic has been closed to new replies.

About this Topic