Change Post and CPT author on the fly while publish the post
You need to hook into the save_post action filter, get the post meta field, and swap the ID’s and fire the update_post function.
You need to hook into the save_post action filter, get the post meta field, and swap the ID’s and fire the update_post function.
You’ll need to add a rewrite rule as well as the filter you have written. At the moment your filter only changes what is output when the author_link function is called, not WordPress’ permalink structure.
$args = array( ‘author’ => 1, ‘numberposts’ => 1 ); The author parameter isn’t documented on the get_posts() codex page, but it does work.
Where $that_user_your_filtering_out is the user/author ID you wan’t to filter out, make this modification to your loop foreach ($blogusers as $bloguser) { // modification starts here if($bloguser->user_id == $that_user_your_filtering_out){ continue; } // modification ends here echo ‘<div class=”content-slider-body”>’; $user = get_userdata($bloguser->user_id);
Create a custom post type named userinfo. On ‘user_register’ call wp_insert_post() in your filter, and create a new post for the user. Add the user ID as post meta field. When the new page is called on the front-end, display the user data.
So far as I know there is no ‘last posted on’ value saved for a user. You can find that information by referencing the post_date in the *_posts table against the author data in *_users and *_usermeta. With that in mind I can think of several solutions. First Solution: Pull your authors. You need this … Read more
WOO WOO! I got it! I’m using a custom theme for Genesis, so you may see some of that in the notes below, but here it is in case anyone wants to see it. In functions.php /** Display author box on single posts */ add_filter( ‘get_the_author_genesis_author_box_single’, ‘__return_true’ ); /** Display author box on archive pages … Read more
Try reviewing this page on the codex. Using your above template, I would suggest the following: <?php if ( is_user_logged_in() ) : $args = array( ‘posts_per_page’ => ‘5’, ‘author’ => get_current_user_id(), // Removes a few lines of code 😉 ); $author_posts = new WP_Query( $args ); ?> <?php /* Author has posts? */ ?> <?php … Read more
IMO, the only draw-back of the default Post Revisions is that it stores the auto-save actions too. But, it does have a history of what changed and who changed, and seems to fullfil the OP requirements. If some change needs to be applied to this default Meta Box, it should be removed and recreated, as … Read more
You can use the following code to get the most recent post by a given Author, just un-comment one of the two lines as appropriate. See the Codex for more info on WP_Query. The Codex entry is pretty long, so scroll down to the Parameters section for more info on the various options you can … Read more