[Resolved] Posts Page – Show Attachment Image if no Featured Image

Home Forums Support [Resolved] Posts Page – Show Attachment Image if no Featured Image

Home Forums Support Posts Page – Show Attachment Image if no Featured Image

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #245875
    Lisa

    I am in the process of converting a site that has about 1500+ posts. For the Posts Page, I would like to change the layout to show (by row) Post Title, Date & Author, Categories & Tags and then under that to the left show the first image in the post (not featured) image and to the right show the excerpt. On this particular site, they chose to insert an image in the post instead of use Featured image.

    I don’t know what the terminology is but is there a script or filter that I can use that if there is no featured image, check for the first image in the post and use that instead?

    #245898
    Tom
    Lead Developer
    Lead Developer

    Hmm, not easy to do I’m afraid, but a plugin like this might help: https://en-ca.wordpress.org/plugins/quick-featured-images/

    Let me know πŸ™‚

    #245900
    Lisa

    Thanks, I’ll check it out.

    I had this working in the previous theme using W4 Post List. They use a function called “use_fallback” it’s in their documentation after you download the plugin but I can’t find a link online. I’d continue to use it but it doesn’t seem to be updated much and it’s conflicting with this GP theme.

    #245901
    Tom
    Lead Developer
    Lead Developer

    If the plugin I linked to doesn’t work, there should be a solution out there if you search for it.

    Generally, I’m not sure if it’s a good idea as it would have to loop through every single post and insert the URL into the featured image meta value. If at any time you wanted to reverse this, it would be a huge pain/impossible to only remove the ones that were automatically added.

    Of course, you could overwrite the post image function in your child theme and check to see if a featured image exists. If it doesn’t you could code in a fallback.

    That way, nothing in your database would change.

    #245908
    Lisa

    I am using a child theme (always), but don’t have a clue how to go about overwriting the post image function to use a fallback image and even if I use the plugin you mentioned, I’m sure my client will not remember to use featured image for future posts (some old dogs refuse to learn new tricks). I guess I’ll have to keep searching, if you have any other suggestions, please let me know.

    BTW, mucho Kudos… this theme is absolutely fabulous and I am totally loving not having to create custom widgets. With the site I’m working on, I would have had to create 3 custom widgets in the header and then another custom widget for the footer, the GP Hooks saved me a ton of work. Thank you so much!

    #245909
    Tom
    Lead Developer
    Lead Developer

    Something like this might help: http://wordpress.stackexchange.com/a/64813/90661

    It allows you to add a fallback to the featured image if it doesn’t exist.

    You would have to find the necessary code to grab the image from the content to add it in there though.

    Glad you’re enjoying the theme! Great to hear πŸ™‚

    #245912
    Lisa

    Thanks again but still no joy. I added it to my functions but no difference. If I don’t find a solution, I guess I’ll have to hire this part out so I can stick to the Design side of things.

    #245932
    Tom
    Lead Developer
    Lead Developer

    It won’t work as is, you would need to include a fallback image in there or code to grab the first image in the content.

    You might have some luck asking on the WordPress stackexchange site πŸ™‚

Viewing 8 posts - 1 through 8 (of 8 total)
  • You must be logged in to reply to this topic.