-
I am trying to create profile template and can’t get the name to display. Here is part of the code. I can not figure out how to do it.
<div class=”title pattern-<?php echo rand(1,4); ?>”>
<div class=”container”>
<?php while ( have_posts() ) : the_post(); ?><h1><?php echo $user_id->display_name; ?></h1>
<?php endwhile; ?>
</div>I think u you have to declare global $userpro;
try:
<div class=”title pattern-<?php echo rand(1,4); ?>”>
<div class=”container”>
<?php while ( have_posts() ) : the_post(); ?><h1><?php global $userpro; echo $user_id->display_name; ?></h1>
<?php endwhile; ?>
</div>I think my code before is not gonna work too, because you have to declare what user e.g.. current logged in user…
try this:
<div class=”title pattern-<?php echo rand(1,4); ?>”>
<div class=”container”>
<?php while ( have_posts() ) : the_post(); ?><h1><?php
global $userpro;
$user_id = get_current_user_id();
echo $user_id->display_name; ?></h1><?php endwhile; ?>
</div>Neither of them did the trick 🙁
I am not sure if this matters but the profile is displayed on the pages /profile with a shortcode and not php in the template.
I wish there was a tutorial on this as this is a big deal for SEO.
If you just copy the code from here, be aware the formatting!!!!
Take care of the ” and the ‘ signs…you need to write them manually in your editor..
You can use the do_shortcode code too I can give u an example later..
You must be logged in to reply to this topic.