WordPress.org

Support

Support » Plugins and Hacks » Hacks » WordPress Query: extract "Excerpt" string

WordPress Query: extract "Excerpt" string

  • mircare

    @mircare

    Hi,

    We need a query for extract a filename of a html string on Excerpt for each post.
    We also need to have a list of filename of image of the html string on “Excerpt”

    How can we do this on PHP using wordpress api? or using mysql query?

    Best Regards.

Viewing 1 replies (of 1 total)
  • Moderator bcworkz

    @bcworkz

    Use something along this line:
    preg_match_all("/a[\s]+[^>]*?href[\s]?=[\s\"\']+"."(.*?)[\"\']+.*?>"."([^<]+|.*?)?<\/a>/", $excerpt, &$matches);

    Where $excerpt is the excerpt output and the urls will end up in the $matches[1] array. There are endless variations for the regexp (first argument) that you can vary for your specific needs. If you don’t understand regexp, a search will bring up many workable examples.

    I haven’t tested this one, I just grabbed it as an example.

Viewing 1 replies (of 1 total)
  • The topic ‘WordPress Query: extract "Excerpt" string’ is closed to new replies.
Skip to toolbar