Adding metadata

Next, we will add the metadata. Let's put that in a paragraph with a class called meta as shown here:

<p class="meta">

</p>

In the meta class, we will add Posted at and then get the date and time. To get the date and time, we will add <?php the_time(); ?> and <?php the_data(); ?> respectively:

<p class="meta">
Posted at <?php the_time(); ?> on
<?php the_date(); ?> by
</p>

Next, we want to add the user's name, and we will put that in a link. For this, we will add <a href=""> </a>, add the php tag, and echo out get_author_posts_url() as shown here:

<p class="meta">
Posted at <?php the_time(); ?> on
<?php the_date(); ?> by
<a href="<?php echo get_author_posts_url(); ?>"></a>
</p>

Now, we need to put the ID for the author, which we can add with get_the_author_meta() and pass in ID. This will get us the author's ID. Then for the actual text, we will add <?php the_author(); ?>, as shown here:

<a href="<?php echo get_author_posts_url(get_the_author_meta('ID')) ?>"><?php the_author(); ?></a>

If we check it out, we'll see the page as shown in the following screenshot:

This shows Posted at 1:55 am on December 22, 2017 by admin.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.17.137