1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

How to get Title from WP to a custom PHP page? HELP

Discussion in 'Black Hat SEO' started by eestisiin, Mar 28, 2011.

  1. eestisiin

    eestisiin Regular Member

    Joined:
    Oct 8, 2007
    Messages:
    331
    Likes Received:
    156
    Hi,

    im building a simple site that redirects from wp to a custom php page, what I need is to show the sentence "Came from [REFFERING PAGE TITLE]" but I cant figure it out and no, wordpress page itself wont suite unfortunatelly...

    Could anyone help!?

    Thanks
     
  2. wkrappen91

    wkrappen91 Power Member

    Joined:
    Sep 9, 2010
    Messages:
    588
    Likes Received:
    720
    Location:
    127.0.0.1
    get the refer of the refering page, and then use file_get_contents + regex to extract the title?
    PHP:
    $referer $_SERVER['HTTP_REFERER'];
    $htmlfile_get_contents($referer);
    $regex="/<title>(.+?)<\/title>/";
    preg_match($regex,$html,$match);
    echo 
    "Came from ".$match[1];

    (This is not tested but it should work with a little tweeking.)
     
    • Thanks Thanks x 1
  3. Maruk

    Maruk Power Member

    Joined:
    Jun 15, 2009
    Messages:
    562
    Likes Received:
    898
    Home Page:
  4. eestisiin

    eestisiin Regular Member

    Joined:
    Oct 8, 2007
    Messages:
    331
    Likes Received:
    156
    Thanks, its working, but only problem I have now is styling, since I suck hard core at things like this. I just want to center the echo and give it a custom style which is described in *.css file...

    Edit: NVM, got it done, although its not a big problem I still have one question , how could I remove a certain number of characters from the echo...

    The header says : You came from Mary Antoine Picture - MyBlog, but I want to remove the MyBlog part, i know that its 20 characters long, so I should be able to remove it automatically..

    Edit2: got it working -
    PHP:
    $str "$match[1]";
    $cut_str substr($str0, -22);
     
    • Thanks Thanks x 1
    Last edited: Mar 28, 2011