Trash a post, send associated comments into the trash bin (change status)

There’s an action called trashed_post_comments that runs right after the comments are set to post-trashed status. You could hook into that: add_action( ‘trashed_post_comments’, ‘wpse134528_really_trash_comments’ ); function wpse134528_really_trash_comments( $post_id ) { $args = array( ‘post_id’ => $post_id, ‘status’ => ‘post-trashed’, ); $comments = get_comments( $args ); foreach( $comments as $comment ) { wp_trash_comment( $comment->comment_id ); } … Read more

Add tags to post before it’s created

I tried to use the filter wp_get_object_terms like this: function add_object_terms($terms, $object_ids, $taxonomies, $args){ if (isset( $_GET[ ‘tags’ ]) && str_replace(“‘”,””,$taxonomies) == “post_tag”) { $newterms = explode(“,”,$_GET[‘tags’]); return array_merge($terms, $newterms); } else { return $terms; } } add_filter(‘wp_get_object_terms’, ‘add_object_terms’,1,4); That doesn’t work though, maybe the return value has the wrong format, I didn’t look it … Read more

My posts section for logged in user

You don’t need to put your code in your theme functions. This needs to be a custom page template. Learn about page templates here: http://codex.wordpress.org/Page_Templates Your code is custom loop so you need to also learn about loops and then using WP_Query so next stop will be here: http://codex.wordpress.org/The_Loop Then read this page: http://codex.wordpress.org/Class_Reference/WP_Query After … Read more

Back up post tags

Just export the wp_terms table (or *_terms if you have a custom prefix) as a .sql file, then truncate the table. This will clear them all. If you want to put them back on, just import the .sql file you just created. Hope this helps

Reading Setting Not Working for Number of Posts

No need to edit your parent themes files as its bad practice. You can use this code in your child themes functions file add_action( ‘pre_get_posts’, ‘wpsites_limit_posts’ ); function wpsites_limit_posts( $query ) { if( $query->is_main_query() && !is_admin() && is_home() ) { $query->set( ‘posts_per_page’, ‘1’ ); } } Won’t work when admin is logged in. Change the … Read more