How to put my site title into a google search url (4 posts)

  1. perthmetro
    Posted 3 years ago #

    I have this code...
    <a href="http://google.com.au/search?q=<?php the_title(); ?> - <?php the_category(' '); ?>" ><?php the_title(); ?></a>

    Which I want it to turn out like this...
    http://google.com.au/search?q=My Awesome Widgets - brown widgets

    But it doesn't

    Sooooooooooo I'd love if anyone could help me out to make it work.

    Thanks heaps!

  2. WebTechGlobal
    Posted 3 years ago #

    What does it turn out like?

    the_category() function is meant to be used inside what is known as the loop. Where WordPress loops through queried posts. I'm going to guess your using it outside of the loop.

    Using it like this...

    Categories: <?php the_category(' '); (within the loop)

    Would list all of the current posts categories.

  3. perthmetro
    Posted 3 years ago #

    It is used inside the loop, no worries there.

    It's filled with spans and data-post_id= and data-type= and all sort of other 'stuff'

  4. perthmetro
    Posted 3 years ago #

    <span data-post_id="1480" data-type="input" data-filter="the_title" class="fee-field">My Awesome Widgets</span> <span data-post_id="1480" data-taxonomy="category" data-before="" data-sep=" " data-after="" data-type="termselect" data-filter="the_category" class="fee-field"><a href="http://xyz" title="View all posts in abc" rel="category tag">My Awesome Widgets</a></span>

Topic Closed

This topic has been closed to new replies.

About this Topic