Changing the avatar for the author of a post - wordpress

When someone edits a post created by somebody else and changes the author of the post, can the avatar shown for that post throughout the site change to reflect the newly designated author?
It seems like Wordpress always wants to show the avatar of the user who created the post, regardless of who the author may have been changed to after the fact.

The last author is saved in the (hidden) post meta field _edit_last, so you could do something like:
$last_id = get_post_meta( get_queried_object_id(), '_edit_last', true );
$last_user = get_userdata( $last_id );
echo get_avatar( $last_user->user_email );

Related

how to get the last read post name by logged user in wordpress?

I need the get the name of the last post read by logged user in Wordpress. To use it as a hint on the logged user dashboard. "Your last read post was {post_name}"
Could you please advise how can i get this last read post ID or name?
Thank you.
Add following code in your theme's functions.php or plugin file.
add_action( 'wp', 'wp_user_last_view_post_func' );
function wp_user_last_view_post_func(){
if (is_user_logged_in() AND is_singular() AND get_post_type()==="post"){
update_user_meta(get_current_user_id(),'last_view_post_id',get_the_ID());
}
}
add_action('wp_dashboard_setup', 'last_post_dashboard_widgets');
function last_post_dashboard_widgets() {
global $wp_meta_boxes;
wp_add_dashboard_widget('last_read_post_widget', 'Last Read Post', 'last_read_post_widget_dashboard');
}
function last_read_post_widget_dashboard() {
$last_post_id = get_user_meta(get_current_user_id(),'last_view_post_id',true);
echo '<p>Your last read post was '.get_the_title($last_post_id).'</p>';
}
You can see last read post on wordpress dashboard like this : See Attachment
I hope this may be helpful to you.
Thanks

Is there plugin for WP to show latest news with specific word in title or somewhere?

I need help with WordPress. For example, I have 100 posts in my blog, and only one post has a word: "HOT". I'd like to show this post on the right side (like widget). Can you advise me something?
There are plugins like "Recent Posts Widget Extended" that can filtered by tag or filter the post query on functions.php like :
add_filter( 'rpwe_default_query_arguments', 'your_custom_function' );
function your_custom_function( $args ) {
$args['s'] = 'HOT';
return $args;
}

Copy user meta into post meta in WordPress

As geo mashup only retrieves post_meta, I am trying to copy over the geo_location from a custom registration field into the meta for page containing the map.
The code I am using is:
<?php
$blogusers = get_users_of_blog();
if ($blogusers) {
foreach ($blogusers as $bloguser) {
$user = get_userdata($bloguser->user_id);
$user_location = the_author_meta('geo_address', $user->ID);
add_post_meta( 463, 'geo_move', $user_location);
}}
?>
This creates the post meta, but the value is written as a blank, so it looks like $user_location isn't working. Any suggestions?
The answer was submitted here: https://wordpress.stackexchange.com/questions/121713/retrieve-user-meta-and-copy-to-post-meta
I'm answering this myself to close this and not waste anyones time

Wordpress; Vantage theme & ACF plugin?

I have repeatedly been trying to implement the Advanced Custom Fields (ACF) plugin in the Vantage theme (from AppThemes), but without any success. I've had extensive contact with the admin of ACF, on this subject, but unfortunately we did not succeed. He advised to ask here, maybe seek for a (paid) developer, to solve this problem.
Ok, so what am i trying?
I have created a custom field group and want to implement that field group within the listing form of Vantage. To do so i have read several docs, including: http://www.advancedcustomfields.com/resources/tutorials/creating-a-front-end-form/. To be complete, based on this i did the following in the Vantage theme folder:
I created 2 custom field groups, with the id's: 88 & 139.
In Wrapper.php i added the code: <?php acf_form_head(); ?>
In form-listing.php i created 2 custom hooks, 'product_custom' and 'product_custom2': <?php do_action( 'product_custom' ); ?> <?php do_action( 'product_custom2' ); ?>
In fuctions.php i created 3 functions:
add_action( 'wp_print_styles' , 'my_deregister_styles' , 100 );
function my_deregister_styles() {
wp_deregister_style( 'wp-admin' );
}
add_action( 'product_custom' , 'productfields' );
function productfields() {
$options = array(
'field_groups' => array('post' => '88' ),
'form' => false,
);
acf_form( $options );
}
add_action( 'product_custom2' , 'productfields2' );
function productfields2() {
$options2 = array(
'field_groups' => array('post' => '139' ),
'form' => false,
);
acf_form( $options2 );
}
This actually made the custom field group show up in the listing form of Vantage. However the following things keep going wrong:
Both field groups have a WYSIWYG field. However for some reason the WYSIWYG buttons and media button stop working
I cannot fill in any text in the first WYSIWYG field. Only the second one works for that matter.
No data is stored at all after saving the listing form. On advise of the ACF admin, i tried the following in the acf-master/core/api.php file:
// run database save first
if( isset($_POST['acf_save']) )
{
$txt="Hello world!";
echo $txt;
die();
However the string does not display after saving the listing form. So the if statement is not used...
4. To display the dataon the frontend, once they are saved, I guess the default wordpress codex can be used..
I tried to be as complete as possible;) Is there anybody who can help me any further? Paid assistance is also negotiable..
Thanks a lot in advance!
Robbert
I have succeed on implementing ACF with vantage themes.
I add ACF form at vantage listing form and combine the vantage form with ACF form. with one button.
The data has been saved to database and can be called to displayed in listing area. Only add image button is not working from front-end but in back-end the button is working.
Adding <?php acf_form_head(); ?> to wrapper.php
Do this tutorial front end form help
Eliminate default vantage submit button in form-listing.php
Add this code in ACF api.php in function acf_form_head()
// allow for custom save
$post_id = apply_filters('acf_form_pre_save_post','va_after_create_listing_form', $post_id);
That's it, hope it work in your site.
Is that you want when someone visits the website that they are able to send info via the page they visits eg www.yoursite.com/listing/listing-name like probably an email or contact for more info relating to that business?
If not then you can simply add in the ACF data from the back-end i.e. dreamweaver etc onto single-listing.php and use the ACF tutorial on working with fields.
Hope this helps somewhat
Cheers

Multiple Authors on same post in Wordpress

I have a friend who has asked me to build a site for him and two friends to write movie reviews. I'm pretty good with Wordpress, so it was the obvious choice for the site. The only difficulty I have is that they each plan to write a review on the same movie, and I can't think of how to achieve multiple authors in one post.
I've checked out a few plugins such as Co-Author Plus which allows multiple authors credited to the same post, but it doesn't provide the functionality for keeping each author's content separate.
The only solution I can think of is to use custom fields, but I would prefer if the authors can use the main content editor for their reviews. Any help is greatly appreciated!
Like I said, it should be better to have 1 review = 1 post.
So, I think the best way to achieve this should be to create post types :
movie
review, with a movie reference field
And modify post template to display movie and associated reviews on the same page.
An alternate solution should be to use taxonomy to handle movies and attach post to them.
I ran into the same problem with trying to figure out how to do this as well and I followed soju's advice and came up with a solution. There might be a better solution to this, but this is how I went about it. Me and my friend are doing an anime review blog and both me and him will be writing a review on the same anime.
I first created two post types:
anime: main page on the specific anime, like the description, pictures, etc.
reviews: the author's review on the anime. the options i have enabled on here are the editor, the title, and the author. Along with the associated anime taxonomy. That's all that's needed here
Then I created a taxonomy for anime titles so when a user needs to write a review on an anime that hasn't been added as a review yet they can add the title into the taxonomy.
I associated the taxonomy to both post_types and wala! That's pretty much all you need.
So now when you want to write a new review for a new anime you add a anime post type first and write down what the anime is about and include pictures etc. Add the title to the taxonomy and check it. After that you then create a new post of the post type reviews and write your review, remember to check the correct title in your taxonomy for what anime this is going to, then you are ready to go!
Problem 1: How do I include this into my loop?
Well you don't want to include both post types in your loop you just want to include posts and the other post type anime in your loop so you do the following in your functions.php file:
function include_custom_post_types( $query ) {
global $wp_query;
// Get all custom post types
$custom_post_type = get_query_var( 'post_type' );
// Get all post types
$post_types = get_post_types();
// If what you are getting is a category or a tag or that there are no custom
// post types you just want to set the post types to be the current post types
if ( (is_category() || is_tag()) && empty( $custom_post_type ))
$query->set( 'post_type' , $post_types );
// Set the custom post types you want to ignore
$ignore_types = array('reviews');
//Unset the post types that are gonna be ignored
foreach($post_types as $key=>$type)
{
if(in_array($type,$ignore_types))
{
unset($post_types[$key]);
}
}
// Set the post types for the query
if ( (is_home() && false == $query->query_vars['suppress_filters']) || is_feed())
$query->set( 'post_type', $post_types);
return $query;
}
add_filter( 'pre_get_posts' , 'include_custom_post_types' );
Problem 2: How do I display the reviews?
I solved this by creating another single.php file and renamed it to single-post_type_name.php. So in this case i created a single-anime.php file for my post type anime. Then in place of the contents i want to get all the reviews for this specific anime so I added the following within the file in the main content area:
<?php
//You grab the taxonomy that you have selected for this post
$terms = wp_get_post_terms(get_the_ID(), 'animes_reviewed');
// This is the args array for the criteria that the posts need to be in
$args = array(
// This is the post type of where your reviews are at
post_type' => 'reviews',
// this is for searching the taxonomy usually it's
// taxonomy_name => checked_taxonomy
'anime' => $terms[0]->name,
'post_status' => 'publish'
);
// Grab the posts
$posts = get_posts($args);
//Here I echo out the information for debugging purpose, but
//Here is where you can do HTML to display your reviews
foreach($posts as $post)
{
echo($post->post_content);
the_author_meta( 'nickname', $post->post_author);
}
?>
You can do a lot more with this adding more taxonomies etc. I have actually implemented an episode review by just adding a taxonomy and adding a criteria to look for in the post section. Hopefully this will help you out, might be a bit late though :( Thanks soju for recommending the custom post types!

Resources