What's the best way to do this (echo php/html)?
So in the Wordpress functions.php I have a function that inserts a copyright into the footer. What's the best way to echo this? Warning: PHP noob.
<?php echo date('Y'); ?> <a href="<?php echo home_url(); ?>/" title="<?php bloginfo('name'); ?>" rel="home"><?php bloginfo('name'); ?> </a>
Here's the function so far.
add_action('wp_footer', 'st_footer');
do_action('st_footer');
function st_footer() {
//loads sidebar-footer.php
get_sidebar( 'footer' );
// prints site credits
echo '<div id="credits">';
}
}
About this post
- Posted
- Archived
- Score
- 0 · 100% up
- Kind
- Text
- ID
- sqlgx
4 comments
...and this is exactly why so many programmers have a problem with wordpress. It's such an unmitigated mess.
I'm not sure what you're trying to do, but if you just want a © 1901 - 2012 type thing, this should work...
You would replace 1901 with whatever year you started your blog or website, and the date(Y) puts in the current year so it's always up to date.
There are more advanced things you can do that check to see if the decades are the same (so you can do 2010-12) and stuff like that, but that's the most basic easiest one I can think of.
Sorry, I probably wasn't that clear. The thing I'm really having trouble with is the href mixed with the php/home_url. Basically going from html to php and back to html.
The only variable you actually need is the date('Y')
The other things like home_url() and bloginfo('name') are always the same. So you can actually hardcode them. I'm assuming you'll be using it on only one website and you're not distributing theme around for other persons to use.