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

Any PHP Guru online to help me with something please ?

Discussion in 'Black Hat SEO' started by IntensE, Oct 24, 2011.

  1. IntensE

    IntensE Power Member

    Joined:
    Aug 19, 2008
    Messages:
    771
    Likes Received:
    656
    Occupation:
    Cashing in
    Location:
    thugz mansion
    I want to create the following:

    I have a WP blog whatever.com and a post "Hello world 2011" for example.

    So, I go to the blog, click the post and end up here: whatever.com/hello-world-2011

    In this post I have an <a href= link >to the php file phpguru.php

    Now when I click on the link it should open whatever.com/phpguru.php and in there I want to echo the post title.

    So it should echo me: "Hello World 2011"

    How can I do that ? I need it badly.
     
  2. gu3sswh0

    gu3sswh0 Regular Member

    Joined:
    Mar 22, 2011
    Messages:
    287
    Likes Received:
    78
    Location:
    Strip Club
    Code:
    <?php the_title(); ?>
     
  3. merieke

    merieke Registered Member

    Joined:
    Jun 20, 2011
    Messages:
    51
    Likes Received:
    20
    It's actually not that straightforward. You are trying to open a php file outside of the Wordpress system so it technically has no access to the_titile() function.

    You could actually just create a post and install the wordpress plugin exec-php plugin which will let you insert php code right into your post content. Maybe that will give you the results you're looking for.

    Outside of that the only way I can think to implement this would be to pass the referring URL into your phpguru.php file, parse the post title out of the URL, then echo out the string.
     
  4. Abstroose

    Abstroose Elite Member

    Joined:
    Nov 20, 2008
    Messages:
    2,097
    Likes Received:
    3,475
    Occupation:
    Thai Boxer
    Location:
    UK
    Home Page:
    As above. If you install exec-php plugin, I'll help you with the coding.
     
  5. IntensE

    IntensE Power Member

    Joined:
    Aug 19, 2008
    Messages:
    771
    Likes Received:
    656
    Occupation:
    Cashing in
    Location:
    thugz mansion
    THIS ! is what i want / need. how to do it ?
    Abstroose can you help on this one please ?
     
  6. IntensE

    IntensE Power Member

    Joined:
    Aug 19, 2008
    Messages:
    771
    Likes Received:
    656
    Occupation:
    Cashing in
    Location:
    thugz mansion
    sweet-bump !
     
  7. Abstroose

    Abstroose Elite Member

    Joined:
    Nov 20, 2008
    Messages:
    2,097
    Likes Received:
    3,475
    Occupation:
    Thai Boxer
    Location:
    UK
    Home Page:
    Give me in a minute.
     
  8. Abstroose

    Abstroose Elite Member

    Joined:
    Nov 20, 2008
    Messages:
    2,097
    Likes Received:
    3,475
    Occupation:
    Thai Boxer
    Location:
    UK
    Home Page:
    Is the format of your permalinks exactly like this: yoursite.com/hello-world-2011

    Or do you have categories?
     
  9. IntensE

    IntensE Power Member

    Joined:
    Aug 19, 2008
    Messages:
    771
    Likes Received:
    656
    Occupation:
    Cashing in
    Location:
    thugz mansion
    /%postname%/
     
  10. Abstroose

    Abstroose Elite Member

    Joined:
    Nov 20, 2008
    Messages:
    2,097
    Likes Received:
    3,475
    Occupation:
    Thai Boxer
    Location:
    UK
    Home Page:
    Link to the following URL from one of your posts and tell me if it works:

    Code:
    http://www.nulbur.com/abc.php
     
  11. IntensE

    IntensE Power Member

    Joined:
    Aug 19, 2008
    Messages:
    771
    Likes Received:
    656
    Occupation:
    Cashing in
    Location:
    thugz mansion
    Works !
     
  12. Abstroose

    Abstroose Elite Member

    Joined:
    Nov 20, 2008
    Messages:
    2,097
    Likes Received:
    3,475
    Occupation:
    Thai Boxer
    Location:
    UK
    Home Page:
    Good. It's a little less reliable than passing the variable from the blog post, since if you change the permalink structure or click the link from your homepage, it won't work.. but other than that it does the job.

    PHP:
    <?php
    $string 
    $_SERVER["HTTP_REFERER"];
    $s explode("/",$string);
    $title $s[3];
    $title str_replace("-"" "$title);
    echo 
    $title;
    ?>
     
    • Thanks Thanks x 1
  13. lianne

    lianne Regular Member

    Joined:
    Jul 26, 2010
    Messages:
    204
    Likes Received:
    12
    PHP guys who know more than me...

    Why not just link to "whatever.com/phpguru.php?postid=<?php echo $post->ID; ?>" ?

    The on the next page:
    <?php echo get_the_title($_GET['postid'); ?>
     
  14. IntensE

    IntensE Power Member

    Joined:
    Aug 19, 2008
    Messages:
    771
    Likes Received:
    656
    Occupation:
    Cashing in
    Location:
    thugz mansion
    cause that looks ugly, and php geeks tend to have clean codes :p

    Abstroose, you are the man ! will send you a beer, thanks a lot !
     
  15. gu3sswh0

    gu3sswh0 Regular Member

    Joined:
    Mar 22, 2011
    Messages:
    287
    Likes Received:
    78
    Location:
    Strip Club
    sorry about my response, skim read the question and responded without reading this was external to wp :)
     
    • Thanks Thanks x 1
  16. IntensE

    IntensE Power Member

    Joined:
    Aug 19, 2008
    Messages:
    771
    Likes Received:
    656
    Occupation:
    Cashing in
    Location:
    thugz mansion
    one more quick question, how can i make the letters upper case ?

    it prints: hello world 2011, would love Hello World 2011
     
  17. cyklotrial

    cyklotrial Regular Member

    Joined:
    Oct 13, 2008
    Messages:
    248
    Likes Received:
    82
    Location:
    Wonderland
    Hello, Your solution is fine but...
    It loses case sensitive and few other things. If posttitle will be long than you will lose some words or letters.
    I think you should use build in PHP and WP functions for this task.

    Code mentioned below SHOULD* give you always correct post title.
    PHP:
    <?php
    require_once( '../wordpress_install_path/wp-load.php' );
    get_header();
    $referer pathinfo(wp_get_referer());
    $slug $referer['basename'];

    $query = new WP_Query('pagename='.$slug);
    while (
    $query->have_posts() ) : $query->the_post();
        
    the_title();
    endwhile;
    ?>
    SHOULD*- i havn't tested it.

     
    • Thanks Thanks x 1
  18. IntensE

    IntensE Power Member

    Joined:
    Aug 19, 2008
    Messages:
    771
    Likes Received:
    656
    Occupation:
    Cashing in
    Location:
    thugz mansion
    nvm figured it out:
    $title = ucwords(strtolower($title));
     
  19. IntensE

    IntensE Power Member

    Joined:
    Aug 19, 2008
    Messages:
    771
    Likes Received:
    656
    Occupation:
    Cashing in
    Location:
    thugz mansion
    Thanks guys for the help, +4 rep to both of you.
     
    • Thanks Thanks x 1
  20. LongBanana

    LongBanana Regular Member

    Joined:
    Oct 23, 2009
    Messages:
    411
    Likes Received:
    247
    Location:
    Chicago, IL