WordPress.org

Ready to get started?Download WordPress

Forums

How to extract image from post from specific category... (1 post)

  1. mfsmall13
    Member
    Posted 3 years ago #

    Hi there. I recently was tasked with an assignment of extracting an image from a WordPress post and placing said image in the header of the site. After scouring the web, I have come across several different options of extracting the first image from the most recent post (which seems to work just fine). The problem is that I need to drill down. I need to extract the first image from the most recent post IN A SPECIFIC CATEGORY. The code I have starts in the functions.php page and is as follows (bear in mind that I am a PHP neophyte):

    [Code moderated as per the Forum Rules. Please use the pastebin]

    The above code will place an image in the header that mirrors the first image from the most recent post. But just to reiterate, I need it do more than that - I need it to mirror the first image from the most recent post of a specific category. Any suggestions/solutions you have to make this happen are greatly appreciated (and if that means scrapping what I have and starting over, I am completely open to that). Thank you for your help.

Topic Closed

This topic has been closed to new replies.

About this Topic