• Resolved William Alexander

    (@williamalexander)


    If I make a post in my site and add an image to it, the image shows up on the post page, as well as the blog home page which lists all of the links, but it does not show up on the category page, even though the exact same code exists on that page as on the home and single post pages. In order for the image to actually appear on the category page, I have to copy the location of the file and paste it into an “image/photo” field that appears to be added as part of the theme. I am using what I believe is an older theme called Business Professional Package.

    My question is – how can I dig in and figure out why the same code shows an image in one page but does not show an image in another? The code that shows the image is this:

    <?php if( get_post_meta($post->ID, "post_image_value", true) ) { ?>
    
                                        <img class="portfolio-full" src="<?php bloginfo('template_url'); ?>/image.php?width=570&image=<? echo get_post_meta($post->ID, 'post_image_value', true) ?>" alt="<? the_title() ?>" />
    
                                    <? } ?>

    This code shows an image when it is placed on the home.php page or on a single.php single post page, but it does not work on category.php. Any guidance would be so welcome. I seem to be out of my pay grade on this.

    Thanks you,

    William Alexander

Viewing 9 replies - 1 through 9 (of 9 total)
  • Thread Starter William Alexander

    (@williamalexander)

    I’m trying to figure out why my search and category pages will not show the post image when my post pages and home page will. I’ve tried every bit of dig-around-and-try-again deleting of code and files to see if I can narrow down wether it’s happening because of js or css or functions or in the category file, but nothing seems to narrow it down. Can anyone suggest what function of WP or of a given theme might allow the post image to appear on one page but not on another, even with the exact same code used to display the image in both? I’ll be glad to post any code that would be helpful or whatever other information might be needed. Hoping someone can help.

    Thanks.

    addendum – I think that possibly the theme author somehow has told the images not to show up on the category page unless the image is explicitly specified so that the correct image is used in a gallery view on the cat page, but I want the post image to automatically show up. Surely this is possible.

    What theme is this? A link to the site would be relevant as well.

    Thread Starter William Alexander

    (@williamalexander)

    The theme is Business Professional Package – site is
    https://williamalexander.co/fretmill/

    How old is that theme? Have you asked the theme developer? We don’t have access to commercial themes (and they aren’t supported here) – so probably can’t help with a theme issue.

    If it’s no longer supported, perhaps finding a new theme would be a better solution?

    Thread Starter William Alexander

    (@williamalexander)

    Whoops sorry I didn’t realize commercial themes are a nono. I guess I’m not actually looking for someone to tell me exactly how to change my specific theme to fix the problem, but looking for help understanding how wordpress and themes work to set up this situation so I can better understand how to logically find and correct it. I think the theme is rather old, although I wasn’t the original person who set the site up. I did put in a ticket with the developer but no response so far. He doesn’t seem to currently sell this theme any more.

    I’m really mostly curious about how someone would cause wordpress to show a photo on one page with a given piece of code, and have it not show up on another page with the same code. It acts as if the Categories page is somehow told to ignore the photo unless it is explicitly provided for the page somehow. I thought maybe it had to do with Excerpt, but I can’t find the word excerpt in any code anywhere – not in any of the places I know to look. It makes me wonder if there is some default behavior for wordpress that is making the cat page ignore the photo. I’m obviously fairly new to php and to the inner workings of wordpress, but I have been tinkering in one way or another with web page coding since 1996, so I feel like I should be able to suss this out. So far no luck.

    Look at the archive pages for your theme.

    Thread Starter William Alexander

    (@williamalexander)

    Well I thought that might have been something, when I looked in there I saw some specifics referring to whether or not that page was a category archive or not, so I added some text to see if it would show up on a category page and it didn’t. But then I went to the category pages and added some text next to the image tag. When I do that, it only shows up if I move it outside of this:

    <?php if( get_post_meta($post->ID, "post_image_value", true) ) { ?>

    So somehow that if right there seems to be the thing that is either showing or hiding the image itself. Maybe the theme writer is using that along with this custom panel he has on the post edit page to trigger whether or not the post image shows up. I could probably rewrite that area of code to show the image no matter what, however when I tried before there would be a broken image if there was not a post image.

    The whole if looks like this:

    <?php if( get_post_meta($post->ID, "post_image_value", true) ) { ?>
    
                                        <div class="thumb-comments">
    
                                            <a href="<? the_permalink() ?>" title="<? the_title() ?>">
                                                <img src="<?php bloginfo('template_url'); ?>/image.php?width=50&height=50&cropratio=80:80&image=<? echo get_post_meta($post->ID, 'post_image_value', true) ?>" alt="<? the_title() ?>" />
    
                                            </a>
    
                                        </div>
    
                                     <? } ?>

    I will give this another try and see what I can work out.

    Thread Starter William Alexander

    (@williamalexander)

    I fixed it! I used this:

    https://www.wprecipes.com/how-to-get-the-first-image-from-the-post-and-display-it

    and made the code look like this:

    <div class="thumb-comments">
    
                                            <a href="<? the_permalink() ?>" title="<? the_title() ?>">
                                                <img src="<?php bloginfo('template_url'); ?>/image.php?width=50&height=50&cropratio=80:80&image=<?php echo catch_that_image() ?>" alt="<? the_title() ?>" />
    
                                            </a>
    
                                        </div>

    and now it seems to work. Thanks for the help!

    Thread Starter William Alexander

    (@williamalexander)

    Marking this as resolved.

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Same code, image displays on home and single post, not on category page’ is closed to new replies.