Reputation: 51
1 - I have two members witch settings are set to subscribers.
2 - I have made a page in wordpress with the code:
<img src="get_avatar" alt="Logano" onerror="this.src='./files/defaultHead.jpg'"><a>Get_name</a>
How do I do this, what do I have to do?
I've tried to find a answer but I only see this: <?php echo get_avatar( $id1, $size, $default, $alt ); ?>
Upvotes: 0
Views: 2267
Reputation: 51
Now when I managed to fix this I hit another one directly. I use buddypress and extended fields. When I look at the tag it's field_2 but I can't call it with the code above?
Upvotes: 0
Reputation:
You'll need to think about PHP and HTML as 2 different languages.
<?php
says, "we can start writing php now..." and then - ?>
says "back to regular HTML"
so... <img src='' alt=''>
is the html... and you want a dynamic PHP call in there... right?
then... <img src='<?php *stuff* ?>' alt=''>
<?php echo get_avatar( $id1, $size, $default, $alt ); ?>
echo
mean... "print out" sorta.
the $things
with dollar signs are just placeholders from the doc...
If you read the page, it tells you what each on is. You can leave out the ones you don't need.
you can use your user's ID's or email address I think...
<img src='<?php echo get_avatar("4") ?>' alt=''>
So, something like this should get you on your way.
Scratch that... echo get_avatar spits out an image tag for you...
wonder what happens without the echo though... ?
So, <?php echo get_avatar("4") ?>
For the page name... it's the same idea
the html would be <h2>the title</h2>
so... <h2><?php echo get_the_title( $ID ); ?></h2>
You can put the page's ID in there "2"
or - if it's in the loop, leave the ()
empty and then it will know to grab the name of that page.
Person name would be something like this:
http://codex.wordpress.org/Function_Reference/get_userdata
<?php $user_info = get_userdata(1);
echo $user_info->first_name . "\n";
?>
(in this case though... those $ are global variables... not placeholders. Documentation is really confusing... isn't it? ha )
Good Luck.
Upvotes: 1