Author Box Meta Issues
get_the_author_meta(‘description’) is meant to return the content to a variable. You’re looking for the_author_meta() <?php the_author_meta(‘description’); ?>
get_the_author_meta(‘description’) is meant to return the content to a variable. You’re looking for the_author_meta() <?php the_author_meta(‘description’); ?>
I’m not where I can run the below, but potential typos, etc. aside, it should be able to point you in the right direction. 1) Limit Query You could add Date Parameters to your query arguments to limit them. $today = getdate(); $args = array( ‘date_query’ => array( array( ‘year’ => $today[‘year’], ‘month’ => $today[‘mon’], … Read more
This was answered here: https://stackoverflow.com/questions/36720949/get-user-role-by-id-wordpress Here is their answer: You can’t get user role directly. First, you have to get the user_meta_data, and it will return an Object that will contain user roles. Code: $user_meta=get_userdata($user_id); $user_roles=$user_meta->roles; //array of roles the user is part of.
WordPress provides its own function to accomplish this: get_most_recent_post_of_user( $user_id ); Source: https://codex.wordpress.org/Function_Reference/get_most_recent_post_of_user
Your example would be accurate if we were talking about a post type, but authors behave a little differently. WordPress automatically creates specific author pages (like your /author-1 example) but does not have a fallback scenario for showing a list of the authors. (More details on how the template hierarchy works can be found here) … Read more
to know if it’s a new post, you juste need to read the value of $postarr[“ID”] : $postType = “post”; add_filter(“wp_insert_post_data” . $postType, function ($data, $postarr) { if (0 === $postarr[“ID”]) { // it’s a new post $data[“post_author”] = 45; } return $data; }, 10, 2);
Switty uses a standard WordPress comments implementation, so the following, added to your proper child theme functions.php, will erase comment author names. The function could be written as an anonymous function – so very short – but I figured you just might want to return something in place of the name, plus anonymous functions are … Read more
Yes, you can do it pretty easily using get_the_author_meta function and post_class filter: function add_author_nicename_to_post_class( $classes, $class, $post_id ) { $classes[] = get_the_author_meta( ‘user_nicename’ ); return $classes; } add_filter( ‘post_class’, ‘add_author_nicename_to_post_class’, 10, 3 );
The problem is that while you can change the URL, you also need to make sure WordPress knows what to do with it. This is called the Rewrite API. There’s a filter specifically for author URLs. If we print that, it looks like this: Array ( [author/([^/]+)/feed/(feed|rdf|rss|rss2|atom)/?$] => index.php?author_name=$matches[1]&feed=$matches[2] [author/([^/]+)/(feed|rdf|rss|rss2|atom)/?$] => index.php?author_name=$matches[1]&feed=$matches[2] [author/([^/]+)/embed/?$] => index.php?author_name=$matches[1]&embed=true … Read more
WordPress doesn’t track page views, so this isn’t possible. You would need to use a plugin or (preferably) an external analytics service to track views. The method of checking views for an author page would then depend on that plugin or service.