How can i display the author name into each post

Latest Reply from x.kotos at 2016-05-04 11:14:27 Solution
Hello,
i use the 'middleearth' theme. What i want is to display the author name using the following script ' <?php get_the_author_id(); ?>.'. Unfortunatelly the post.php is not clear. So, in which file may i put this script?

thank you
Hi!

You need to edit theloop.php file that is lcoated inside the theme directory.
Besides, if you enter the code after the line:

while (have_posts()) : the_post();

you don't have to find author id, simply use the code:
<?php get_the_author(); ?>

It will retrieve the author name. Here is function reference: https://codex.wordpress.org/Function_Reference/get_the_author
Hello,

On line 10 after
while (have_posts()) : the_post();
i put the
get_the_author();


The result is that no author name appears. If i put the whole script
<?php get_the_author(); ?>
then is broken.

Any solution?
THanx
Yes, of course. If you insert this code into php you don't have to use open <?php and close this tag afterwords. Just use
get_the_author();

If you insert this code into HTML code you have to write:
<?php get_the_author(); ?>
Hello,

In the 'theloop.php' file i put the code requested.
Have a look at the first 12 lines:

<?php
global $post, $query_string, $SMTheme;

$i=1;
if (have_posts()) :

if (!isset($_GET['ajaxpage'])) {?>
<div class='articles'>
<?php }
while (have_posts()) : the_post();
?><?php get_the_author(); ?>
<div class='one-post'>

As you can see i use html code like
<?php get_the_author(); ?>

However, if you look in a post like the http://xlomo.gr/wordpress/category/video-episkepton/ url, no author appears.
Is there any conflict, or a missing option from backend?

Thanx
Right you are! Sorry for inconvenience.
Please, insert the code:
<?php echo get_the_author(); ?>

Without "echo" you can't see the retrieved value.
thanx for help!
Hi Dave,

I open this topic for the following clarrification.
I am the administrator of the site and so in each page my author name appears. What i want is to appear the author name, which differs from my name, only in the following pages:
-http://xlomo.gr/site/category/eikones-episkepton/
-http://xlomo.gr/site/category/video-episkepton/

That is, any other author name except from my name.

Thank you
Hi!
I'm not sure how to change the post author in this case. You would better ask somebody on WordPress forum because this question is not related to a particular theme, but to the WordPress options.
Hi!

As I can see you have changed structure of html code and that's why some styles doesn't work for your website.

Actually, we don't provide any services for editing themes for individual users paid or unpaid. Anyway, you need to use "z-index" along with "position" property to fix this issue.
For example, for logo you need to replace the code:
.boxed-container.logoinside {
padding:45px 0;
}

with:
.boxed-container.logoinside {
padding:45px 0;
z-index: 8;
}
Hi Dave,

I'm afraid that your solution has to do with the styling whereas the issue is about the WordPress engine itself. So, i'll have a look at WordPress forums.
Thank you for your feedback.

Leave a reply

Add codeAdd image