Bulk-add featured images in posts with no featured image

I have a site with loads of posts (news items). Some posts don't have featured images yet. Adding the images to those posts (few hundreds) is a tedious task. We basically want to add 1 and the same image to all the posts without a featured image. Is there a way to do this in bulk? Like ADD 'this image' to ALL 'posts' (not pages) WHERE 'featured_image' is empty. I really hope there's a plugin for that. Can't find it …
Category: Web

Bulk Update Custom Fields for Custom Post Types

I am using this function which works great in case anyone wants to bulk update custom fields for custom post types (just change parameters as necessary). $args=array( 'posts_per_page' => -1, 'post_type' => 'mycptype' ); $the_query = new WP_Query( $args ); if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); $testa = get_field('br_type'); $testb = get_field('br_category'); if ($testa === 'Apples') { update_field('br_featured', '0', get_the_ID()); } endwhile; wp_reset_postdata(); endif; How to use: Insert the code inside your functions.php and refresh …
Category: Web

Post in bulk based on category template

Let's start with an example of what I want to do. take a look at hardreset.info / devicesfaq.com as you can see, the articles are almost the same, they only change few keywords / or based on title (device name) let's say I have the same categories and a custom article for each one (hard reset, check imei, delete google account, etc). Ok, now I want to post in bulk in all the categories I choose (check imei, hard reset, …
Category: Web

Get the selected posts IDs to use in bulk edit AJAX call

The WordPress codex for bulk_edit_custom_box, along with this bulk edit example use the following piece of JavaScript to create an array of selected post IDs to send with the AJAX call that updates the posts. $bulk_row.find( '#bulk-titles' ).children().each( function() { $post_ids.push( $( this ).attr( 'id' ).replace( /^(ttle)/i, '' ) ); }); The full code surrounding this snippet is below. My list tables have input fields for meta values, and the inline quick edit works successfully, but bulk edit fails. When …
Category: Web

WP_LIST_TABLE bulk action

I created a class extend WP_List_Table and created method for bulk actions like this : function get_bulk_actions() { $actions = array( 'synchronize' => 'Synchronize', 'delete' => 'Delete from Shareino', ); return $actions; } and another method for processing their : function process_bulk_action() { //Detect when a bulk action is being triggered... if ('delete' === $this->current_action()) { wp_die('Items deleted (or they would be if we had items to delete)!'); } } This action's display in a dropbox but when i select …
Category: Web

Bulk Attach Or Insert Media To Post Without Opening Post Editor

How to create a custom panel inside wp admin dashboard where we can insert media to specified posts in bulk? Here is the illustration: As shown on the image above, it list all available media on the left and provide the box where we can insert post id to attach the media to. And we can then bulk insert media to the specified posts by hit the attach buttons after we specified the post id for each listed media. I …
Category: Web

How create bulk website with amount, total, and checkout fields?

I have google sheet with rows like "Name", "Price". I would like to create website with folowing things: Website automaticly sync with google spreadsheet and update "Name", "Price" In website any user can check this table, input numbers in "Amount" row. 3."SubTotal" row for each "Name" will automaticly calculate, according to "Amount". "SubTotal"="Price"*"Amount" Button, which can place user's order with all names, prices, amounts and calculations info which user choose. "Total" will automaticly calculate sum of all "SubTotal" values. I …
Category: Web

Efficient way to move media folder to another folder

The media library is currently organized by months and years .../uploads/2021/09/. I'd like to go without the months and year and use the url .../uploads/ for future uploads. For consistency, I'd like to move the existing media files to .../uploads/ too What will be a faster way to move the files instead of uploading them? sudo mv gives me the error -bash: /usr/bin/sudo: Argument list too long.
Category: Web

Bulk updating a group of WordPress Pages every 10 minutes

I need to bulk update 86 specific WordPress Pages every 10 minutes, with the term updating I mean the same thing as clicking the Blue Update Button on each page, and having them all update at the same time every 10 minutes. I guess I need to write a function into my theme functions.php file, and maybe trigger the function every 10 minutes with the help of the plugin WP Crontrol, or maybe using the Cron in cPanel. I'm a …
Category: Web

Code run fast on a cronjob but slow with a do_action or ajax call

I am creating several posts from a csv, when I execute the code using a cronjob the operation lasts about 7 minutes, but if I use the code directly in a template, or make a call to do_action or execute the code through ajax it takes more than 30 minutes and sometimes it doesn't even complete (generates a time limit error). Does anyone know what could be happening? For the creation of the posts I am using wp_insert_post, update_post_meta and …
Category: Web

Moving post's content to post's comments section

I've resurrected a Blogger blog from the Wayback Machine. The business that did the migration had all of the blog's comments in each post included in the post itself. I would like to keep the years-long history of the comments, but have each be its own comment in Wordpress. Is this possible? A short example of what I have is Post Title and date [Post main body 22 Comments [long block of text for old comments] End post] 0 Comments …
Category: Web

Bulk-create posts from SQL database

I'm new in this forum and fairly new to Wordpress as a whole, so I hope I will abide by all written and unwritten rules when posting this. I have an SQL database with around 4,000 posts from an old website. Each post has an ID, date, title, body, keywords, and category column (and some others that are irrelevant). These columns are, as far as I've seen it, not named in a default manner but are, at least in part, …
Category: Web

Is there an equivalent to Drupal's Batch API in WordPress?

I'm wondering if there is some sort of equivalent to Drupal's Batch API in WordPress? Basically, the API allows you to register a batch request and Drupal will call your function over and over again (with Ajax requests) until your batch is finished. So if you need to perform a complicated update on 1,000,000 posts, you can do so in a batch without having PHP timeout or run out of memory. (You just have to tell Drupal how far along …
Category: Web

woocommerce add a new bulk action in the bulk actions dropdown in the orders list

I'm trying to add a custom bulk action in the WooCommerce orders list that will a piece of code I've made for individual orders but need to make it work recursively. I'm aware of that: Custom bulk_action but it is referring to wordpress bulk action menus and not specifically for woocommerce. could you please help me get it working in my plugin for woocommerce orders list? Furthermore, I'm also a bit stuck about how, after adding that action, to scan …
Category: Web

Bulk activate a theme on multisite

I have a multisite and a new theme that needs to be activated across all subsites. I found an answer by fuxia from 2012 and would like to know (1) if there have been changes in WordPress since that time that would require an update to this filter, and (2) what other methods exist to accomplish this task, like using the switch_theme function or using MySQL if it is about updating an option. Reference: Changing Multisite themes on mass
Category: Web

How to assign an additional/extra/second user-role to multiple users (of a specific user-role)

I have 500 users with 50 of those users assigned to user-role XYZ. I'd like these 50 XYZ users to keep their current XYZ user-role but also be assigned another/additional/extra/second user-role ABC... as a bulk job. I'm looking for a function that could find all users with user-role XYZ then assign them to a second user-role of ABC
Category: Web

About

Geeks Mental is a community that publishes articles and tutorials about Web, Android, Data Science, new techniques and Linux security.