views:

609

answers:

6
+2  Q: 

hyperlink on php

I'm working on a wordpress template and need to add a hyperlink to the cartoon bubble at the top of the page. The bubble, as far as I can tell, is php. Where do I insert the href?

<h1><a href="<?php bloginfo('url'); ?>/"><?php bloginfo('name'); ?></a></h1>

The href should point to www.ojaivalleynews.com

The blog url is www.ovnblog.com if you want a visual on the bubble. I've used firebug to ispect, but alas I don't know enough about php to make sense of it.

Thanks

UPDATE...

I missed the second line of code regarding the above question, and based off of the suggestions here, have made corrections to this line and it works.

<h1><a href="<?php bloginfo('url'); ?>/"><?php bloginfo('name'); ?></a></h1>
<div id="bubble"><p><a href="http://www.ojaivalleynews.com/" target="_blank"><?php bloginfo('description'); ?></p></div>

Thanks for everyone's help. An upvote for everybody!

+1  A: 

Don't you have to echo the return values of the function?

<h1><a href="<?php echo bloginfo('url'); ?>/"><?php echo bloginfo('name'); ?></a></h1>
Endlessdeath
Not if the function itself echo's the return value.
Ólafur Waage
Can't believe I didn't see that myself. However, I'm not sure if that's the problem (which isn't too clear in the first place).
strager
no. wordpress bloginfo function reads like this: function bloginfo($show='') { echo get_bloginfo($show, 'display');} - in other words, the function echoes the output.
Paolo Bergantino
+2  A: 
<h1><a href="http://www.ojaivalleynews.com/"&gt;&lt;?php bloginfo('name'); ?></a></h1>

I think that's what you want, but I can't be sure...

Paolo Bergantino
+2  A: 

if you want to replace this with another -static- link it should be:

<h1><a href="http://www.ojaivalleynews.com"&gt;&lt;?php bloginfo('name'); ?></a></h1>
Laodimos
He didn't escape the ". bloginfo('url') may have printed "http://google.com" (without the quotes), and after that he adds a slash to make it "http://google.com/". Probably meaningless as most web servers cause a redirect, but could be a security feature (some silly defaults for Apache, e.g.).
strager
ok I got it :) you 're right
Laodimos
+2  A: 

just replace the

<?php bloginfo('url'); ?>/

with

http://www.ojaivalleynews.com
Scott Evernden
+2  A: 

In WordPress, bloginfo('url') gives you the url to your blog's home. "bloginfo" is the same as "echo get_bloginfo".

If your blog's main page is http://www.ojaivalleynews.com, that's what it'll output. Else, if http://www.ojaivalleynews.com has nothing to do with your blog, just replace with the static url like others recommended.

If you're a new to WordPress and you're going to use it a lot, see http://codex.wordpress.org/

** UPDATE **

Updating your update, bloginfo('description') gives you your blog's description/headline (generally under your blog's title). If your blog is http://www.ojaivalleynews.com, you're outputing the url dinamically in the first link and staticly in the second. If not, you're giving your blog's description as text on the link to http://www.ojaivalleynews.com.

+2  A: 

rashneon, look for the following HTML (search header.php for 'bubble')

<div id="bubble">
  <p>Click for OVN Homepage!</p>
</div>

replace that with

<div id="bubble">
  <p><a href="http://www.ojaivalleynews.com/"&gt;Click for OVN Homepage!</a></p>
</div>

@Endlessdeath - no, delightfully WordPress mixes a bunch of functions which print with a bunch of functions which return values. So yes, it really is supposed to be <?php bloginfo('url'); ?> - see the default theme file

Chris Burgess