How to update all posts at once?

I think you want to mass change old URLs in website database after migration. You can do it either by using plugin or manually. Plugin Method: The Velvet Blues Update URLs plugin enables you to change the URLs at various places, like posts and pages excerpts. Follow these steps: Install and activate Velvet Blues Update … Read more

Where exactly should I hook in order to change the post’s ID before insertion in the database?

I did this and it gave me a post with the set import_id: $my_post = array( ‘import_id’ => 1234567890, ‘post_title’ => ‘Custom ID’, ‘post_content’ => ‘This post has a custom ID.’, ‘post_status’ => ‘publish’, ); wp_insert_post( $my_post ); In addition this will raise ID/index to the integer you set in the import_id so that subsequent … Read more

Display post by click on the link

You can achieve this by using Query String. First you have to make template in your theme folder. To show post list on right side and description of post on left side I am using div with class name right and left (specify your desires css properties in those classes). To show list of posts … Read more

wp_update_post creating revisions instead of updating the post

check: https://codex.wordpress.org/Function_Reference/wp_update_post Make sure not to create an infinite loop. <?php function my_function( $post_id ){ if ( ! wp_is_post_revision( $post_id ) ){ // unhook this function so it doesn’t loop infinitely remove_action(‘save_post’, ‘my_function’); // update the post, which calls save_post again wp_update_post( $my_args ); // re-hook this function add_action(‘save_post’, ‘my_function’); } } add_action(‘save_post’, ‘my_function’); ?> … Read more

wp_set_object_terms NOT working on CPT, but wp_set_post_terms does

After much trial and error, I have found a solution that will allow wp_set_object_terms to be used. Despite already checking if my strings were integers, apparently I needed to convert the array explicitly as well. So I changed this: $customtax = $customtaxarray; to this: $customtax = array_map(‘intval’,$customtaxarray); and suddenly wp_set_object_terms now works. That does not … Read more

Changing Post Tag Color Based On Post Count

Here you go. I just added a class using $tag->count. Tested and works. <div class=”container”> <?php $tags = get_tags(array( ‘hide_empty’ => false, ‘count’ => true )); foreach ($tags as $tag) :?> <a class=”count-<?php echo $tag->count; ?>” href=”https://wordpress.stackexchange.com/questions/324587/<?php echo esc_url( get_tag_link( $tag->term_id ) ); ?>” title=”<?php echo esc_attr( $tag->name ); ?>”><?php echo esc_html( $tag->name ); ?></a> … Read more