How can i read a title of wordpress blog into my website


i have a website and i want to read the title of a wordpress blog into my web pag.

Note that: the wordpress is not mine (it is general).

How can i read a title of wordpress blog into my website ?

i need the answer quickly please.

The correct function :blush:

function getMetaTitle($content){
  $pattern = "|<[\\s]*title[\\s]*>([^<]+)<[\\s]*/[\\s]*title[\\s]*>|Ui";
  if(preg_match($pattern, $content, $match))
  return $match[1];
  return false;

Thank you guido2004, and as you say, ragy can use this to get started. All the best

You copied the wrong function from that website ;).

And the OP isn’t looking for the page title, but for the title of the latest new post in a WP blog (that is, the title of the first post on the blog’s main page).

The code you posted can surely be used as a starting point. It does need some modification though.

i have seen the function below on the web…I hope it helps you.

function getExcerpt($content) {
  $text = html_entity_decode($content);
  $excerpt = array();
  //match all tags
  preg_match_all("|<[^>]+>(.*)</[^>]+>|", $text, $p, PREG_PATTERN_ORDER);
  for ($x = 0; $x < sizeof($p[0]); $x++) {
    //match tags containing "<p>"
    if (preg_match('<p>i', $p[0][$x])) {
      $strip = strip_tags($p[0][$x]);
      if (preg_match("/\\./", $strip))
        $excerpt[] = $strip;
    if (isset($excerpt[0])){
      preg_match("/([^.]+.)/", $strip,$matches);
      return $matches[1];
  return false;

$url = '';             //url to scrape
$content = file_get_contents($url);
$title = getMetaTitle($content);
print "title: $title ";

CREDIT TO Getting website title and description - Tildemark blogs

How about using the RSS feed?

can you tell me how to handle RSS feed with wordpress blog ?


Do you mean the latest post in one particular WP blog?

thnx guido2004 for your quickly answer,

General means i do not post the blog by my self, and i want my web page to read the latest blog posted in word press.


If you want the title of the blog, then why don’t you just type it? A title shouldn’t change that often?

Or do you mean the titles of the posts of a WP blog?