Declare global var from Template File and use it in Functions.php

You can use the exact same filter in your template files. If you do need it in functions.php for any reason (maybe you have some additional processing) then you can use your own custom filter. functions.php: function my_custom_authorpage_title( $title ) { // process … return apply_filters( ‘my_title’, $title ); } add_filter( ‘wpseo_title’, ‘my_custom_authorpage_title’ ); author.php … Read more

Changes show up in view source but not live site

You are echoing the author link generator inside an already opened anchor tag, which is causing error. Try this code: Method 1 <?php if ( !is_page() ) : $author_posts_url = the_author_link(); $posts_by_title = sprintf( __( ‘Posts by %1$s ( @%2$s )’, ‘p2-breathe’ ), get_the_author_meta( ‘display_name’ ), get_the_author_meta( ‘user_nicename’ ) ); ?> <a href=”https://wordpress.stackexchange.com/questions/251479/<?php echo esc_url( … Read more

How do I create WordPress Authors Dropdown with links

I could be wrong as I don’t know how WordPress controls the dropdown menu but looks like it could be only returning a name of the author and not a link to their page. I have tested the below code in a WordPress site environment and works including linking to the authors page. <select name=”author-dropdown” … Read more

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

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

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