• I’m putting together a WP site for a friend and what he wants is this.

    Each post will have a link or image that when clicked does a Google search on the words in the title.

    I’ve managed to get a custom field to appear on each post that’s just a link to Google and now I just need that last wee bit to complete this project.

    I suspect some PHP coding is gonna be needed and that will probably be beyond me but any pointers / help would really be appreciated.

Viewing 8 replies - 1 through 8 (of 8 total)
  • <a href="http://www.google.com/search?q=<?php the_title(); ?>"Click Here</a>

    Thread Starter TonyBanjo

    (@tonybanjo)

    Thank you! I’ve added the code to a custom field but it doesn’t show any link on the post. Is there something else I need to add to the single or sidebar php files?

    All I have there at the moment is this?

    <?php the_meta(); ?>

    Thread Starter TonyBanjo

    (@tonybanjo)

    Ignore that last post I got it figured.

    Thanks so much I really appreiate the help!

    Thread Starter TonyBanjo

    (@tonybanjo)

    Sorry I got that wrong. Clickon on the link I get search results for;

    <?php the_title(); ?

    Try this code: <a href="http://www.google.com/search?q=<?php echo the_title(); ?>">Click Here</a> anywhere in your single.php or sidebar.php file.

    Thread Starter TonyBanjo

    (@tonybanjo)

    That’s it! All working.

    Thank you so much.

    Ooops…typo. That’s what happens when I stay up all night. I missed the echo 😉

    Thread Starter TonyBanjo

    (@tonybanjo)

    @jlknauff No worries, between you and Gareth it worked perfectly but more importantly I learned a lot about what can be done with these variables and how to use them.

    I’ve now completed the site and my friend is delighted, opened a door to WP customisation that I didn’t know was possible.

    Thank you both for your help! I guess this thread can be considered closed.

Viewing 8 replies - 1 through 8 (of 8 total)

The topic ‘Creating a link from post title’ is closed to new replies.