Question

I created my own author.php template. I want to display author's custom meta fields Code samples is in this image : http://prntscr.com/wsdsa

But Wordpress doesnt display anything ? What should i do ?

                <div class="BCol">
                    <?php echo keepAuthorImage(); ?>
                </div>
                <div class="ACol">
                    <div class="A1"><?php echo get_the_author_meta('first_name') ?> <?php echo get_the_author_meta('last_name') ?></div>
                    <div class="A2"><?php echo the_author_meta('job') ?></div>
                    <div class="A3"><?php echo get_the_author_meta('location') ?></div>
                    <div class="A5">
                        <a href="<?php echo get_the_author_meta('userwebpages') ?>" target="_blank"><img src="<?php echo THEME; ?>/_assets/_img/websiteicon.png" alt=""></a>
                        <a href="http://twitter.com/<?php echo get_the_author_meta('twitter') ?>" target="_blank"><img src="<?php echo THEME; ?>/_assets/_img/twitteric.png" alt=""></a>
                        <a href="http://instagram.com/<?php echo get_the_author_meta('instagram') ?>" target="_blank"><img src="<?php echo THEME; ?>/_assets/_img/instagramic.png" alt=""></a>
                    </div>
                    <div class="A4"><?php echo get_the_author_meta('aboute') ?></div>
                </div>

Any helps ? Thanks.

Était-ce utile?

La solution

Wordpress have pre defined variables, as

$cat

$tag

etc. you have to use

$author

to make your process.

Autres conseils

what you are doing wrong is you are not using your get_the_author_meta() function in side the loop so you need to specify the author id.

either use the function in side your loop or use simple as below code

<?php 
global $current_user;
$current_user = wp_get_current_user();
$uid=$current_user->ID;
?>

change your function author meta as

<?php echo get_the_author_meta('first_name',$uid) ?>

for all your author meta for more help you can check reference code http://codex.wordpress.org/Function_Reference/get_the_author_meta

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top