Add Date and Author to Posts

Use the following code in file template single.php (https://developer.wordpress.org/reference/functions/get_day_link/#user-contributed-notes ) : <?php $archive_year = get_the_time( ‘Y’ ); $archive_month = get_the_time( ‘m’ ); $archive_day = get_the_time( ‘d’ ); $month= get_the_date(‘M’); ?> <div class=”custom_archives”> <p> Posted on: <a href=”https://wordpress.stackexchange.com/questions/310792/<?php echo esc_url( get_day_link( $archive_year, $archive_month, $archive_day ) ); ?>”><?php echo $month. ” “.$archive_day.”, ” .$archive_year; ?> </a> </p> … Read more

Author name is not working on category page

You need to pass in the author ID properly. This line: <?php echo get_the_author_meta(‘display_name’, $author_id); ?> Should be this: <?php echo get_the_author_meta( ‘display_name’, $mypost->post_author ); ?> Alternatively you could use setup_postdata() in your foreach loop to setup the global $post variable and make use of the template tag functions without having to pass in the … Read more

Difference between last_name and user_lastname

Short answer to “Which property am I supposed to use“: Use first_name and last_name. Longer answer: The properties first_name, user_firstname, last_name and user_lastname are defined in the WP_User class, and despite the different names (i.e. one with user_ and the other without that prefix): Both first_name and user_firstname use the value of the first_name meta. … Read more

All posts returned when author of 0 is queried

Welcome to WPSE. The condition you want to prevent is a ID of 0 so only run the query if it does not. Also, DRY – don’t repeat yourself. Rather than call get_current_user_id() multiple times, call it once and store it. $reg_count= 0; $user_id = get_current_user_id(); if ( 0 !== $user_id ) { echo “looking … Read more

Get all comments of author’s posts

It looks like there’s two problem with the code you’re trying to use. The first is AUTHOR_ID. Unless you have this defined somewhere else, then this is going to cause an undefined constant error. The second one is that there should be a closing PHP tag ?> before <?php endwhile; ?>. Another thing is, that … Read more

I have two problems ( SEO )

The problem is that your author pages are marked with the noindex tag, look at the page source: It must be a plugin that is doing that, that is not the default setting. If you don’t want the duplicate pages, try a plugin like Yoast WordPress SEO that let you add Nofollow to comment links.

Clean links in: the_author_meta(‘description’)

<?php // grab description, // note the “get_”, we’re not echoing the author meta, we’re returning it $user_description = get_the_author_meta(‘description’); // removing all HTML tags: echo strip_tags($user_description); // removing all tags apart from paragraphs: echo strip_tags($user_description,'<p>’); // removing just anchors (i.e. <a> tags): echo preg_replace(array(‘{<a[^>]*>}’,'{</a>}’),array(”,”),$user_description); // removing all links including their text (i.e. <a href=”https://wordpress.stackexchange.com/questions/33568/…”>…</a>): … Read more

Most recent post is missing from Author page

The mistake is in your first block of code: <?php if (have_posts()): the_post(); ?> <h3> <?php _e(‘All posts by’); ?> <?php echo get_the_author(); ?> <span class=”arrows”>&raquo;</span> </h3> <?php while (have_posts()) : the_post();?> You call the_post() to populate the regular template tags (i.e. get_the_author()) but don’t use the rest of the post. Then, inside your while … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)