• I have this code:

    <div align=”center”><font color=\”#FF00FF\”><?php the_date(‘l – F jS’, ‘<h2>’, ‘</h2>’); ?></font></div>

    I would like to put an ‘a href’ around it.

Viewing 12 replies - 1 through 12 (of 12 total)
  • Something like:

    <div class="date"><a href="link_url_goes here"><?php the_date('l - F jS', '<h2>', '</h2>'); ?></a></div>

    should work. Then style it using CSS – not old HTML 4 markup.

    Thread Starter dml3001

    (@dml3001)

    Thanks for the quick response!

    I apologize, I didn’t explain myself clearly enough. In the a href I would like to have part of the link be a php function. So, for example, I would like www.myquestion.com/<?php the_date?> so that it will bring up something likewww.myquestion.com/2012/04/03.

    <div class="date"><h2><a href="<?php echo esc_url( home_url( '/' ) ); ?>"><?php the_date('l - F jS'); ?></a></h2></div>

    Thread Starter dml3001

    (@dml3001)

    My page breaks when I try to insert a link with a php function in it into the loop.

    Thank you so much for your help. I’ll try to give you another example:

    Lets say I have this text “My Title”. And I want the link to my title to link to the day that the post was made. Following the calendar widget setup, I would need to have my link be: http://www.thenameofmypage.com/year/month/day/

    Therefore, “>My Title…but that doesn’t work so I’m not sure what to do.

    Please post code or markup snippets between backticks or use the code button.

    Thread Starter dml3001

    (@dml3001)

    Sorry about that,

    <a href="www.thenameofmypage.com/<?php the_date('Y/m/d/'); ?>"><My Title></a>

    That’s not the code I suggested above…

    Thread Starter dml3001

    (@dml3001)

    Yes, yes I tried the code suggested and my page broke…I don’t know why.

    There’s obviously nothing wrong with the code I posted above. Perhaps you added it incorrectly?

    Thread Starter dml3001

    (@dml3001)

    When you say home_url do you suggest that I put in www.thenameofmypage.com/<?php the_date('Y/m/d/'); ?> as my home_url. I guess I just don’t understand at what point in your code the current date shows up. Does this ( '/' ) bring up the date?

    When you say home_url do you suggest that I put in http://www.thenameofmypage.com/&lt;?php the_date(‘Y/m/d/’); ?> as my home_url.

    No. Just use <?php echo esc_url( home_url( '/' ) ); ?>">

    Thread Starter dml3001

    (@dml3001)

    Ok. It seems I might have copied it wrong the first time. Now, it doesn’t break, but the link that shows up is a link to the home page and not a link to the home page with /Y/m/d/ at the end. If I am not explaining myself well enough, then I won’t take up any more of your time, but thank you for your help so far.

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

The topic ‘Use php function in url’ is closed to new replies.