How to add author name in Wordpress post?

Asked

Viewed 80 times

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 &rarr;', '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(); ?>?

  • post the contents of the 'template-Parts/content', 'Archive'

  • Yeah, I’m the one who inserted those codes.

  • published the code of the mentioned file.

  • To add something to the question you must edit the question and add the extra content.

  • Thanks! I edited and added.

  • You want to view a single page post or a list of posts?

  • in all posts.

  • 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()

  • Check in the database if it is saving the author’s information

Show 5 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.