WordPress Query: extract "Excerpt" string (2 posts)

  1. mircare
    Posted 2 years ago #


    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.

  2. bcworkz
    Posted 2 years ago #

    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.

Topic Closed

This topic has been closed to new replies.

About this Topic