0
I am using a theme in wordpress and in it is not appearing the name of the author in the posts.
I found this link talking about the code to put the name in the posts: https://codex.wordpress.org/Function_Reference/get_the_author
I tried but it still didn’t show up. Follow the code:
<?php
/**
* The main template file
*
* This is the most generic template file in a WordPress theme
* and one of the two required files for a theme (the other being style.css).
* It is used to display a page when nothing more specific matches a query.
* E.g., it puts together the home page when no home.php file exists.
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package fonts
* @copyright Copyright (c) 2019, Danny Cooper
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*/
get_header(); ?>
<div class="content-area">
<?php
if ( have_posts() ) :
if ( is_home() && ! is_front_page() ) :
?>
<?php the_author(); ?>
<?php $author = get_the_author(); ?>
<header>
<h1 class="page-title"><?php single_post_title(); ?></h1>
</header>
<?php
endif;
/* Start the Loop */
while ( have_posts() ) :
the_post();
/*
* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'template-parts/content', 'archive' );
endwhile;
else :
get_template_part( 'template-parts/content', 'none' );
endif;
?>
</div><!-- .content-area -->
<?php
get_footer();
Follows content code-Archive.php (template-Parts/content-Archive.php):
<?php
/**
* Template part for displaying page content in page.php
*
* @link https://codex.wordpress.org/Template_Hierarchy
*
* @package fonts
* @copyright Copyright (c) 2019, Danny Cooper
* @license http://opensource.org/licenses/gpl-2.0.php GNU Public License
*/
?>
<article <?php post_class(); ?>>
<?php fonts_thumbnail( 'fonts-blog' ); ?>
<header class="entry-header">
<div class="entry-meta">
<?php fonts_posted_on(); ?>
</div><!-- .entry-meta -->
<?php the_title( '<h2 class="entry-title"><a href="' . esc_url( get_permalink() ) . '" rel="bookmark">', '</a></h2>' ); ?>
</header><!-- .entry-header -->
<div class="entry-content">
<?php the_excerpt(); ?>
<p><a class="moretag" href="<?php echo esc_url( get_permalink( $post->ID ) ); ?>"><?php esc_html_e( 'Continue Reading →', 'fonts' ); ?></a></p>
</div><!-- .entry-content -->
</article><!-- #post-## -->
Does anyone know what it can be?
You who entered these codes:
<?php the_author(); ?>
,<?php $author = get_the_author(); ?>
?– Leonardo Barros
post the contents of the 'template-Parts/content', 'Archive'
– Leonardo Barros
Yeah, I’m the one who inserted those codes.
– Márcio
published the code of the mentioned file.
– Márcio
To add something to the question you must edit the question and add the extra content.
– Leonardo Barros
Thanks! I edited and added.
– Márcio
You want to view a single page post or a list of posts?
– Leonardo Barros
in all posts.
– Márcio
I’m sorry about all the questions, but I’m having a hard time understanding where your problem is. Perhaps to facilitate you can indicate a specific page where you have this problem. Another attempt is to put the get_the_author command into content-Archive.php()
– Leonardo Barros
Check in the database if it is saving the author’s information
– Leonardo Barros