Run `wp_insert_post_data` on all posts

I ended up just writing a function inside of my template’s index.php like this. function fancySearchAndReplace() { $regex = ‘/myregex/’; $my_posts = get_posts(array(‘post_type’ => ‘post’, ‘numberposts’ => -1)); foreach ($my_posts as $post) { $content = $post->post_content; $theID = $post->ID; $thing = get_field(‘thing’, $theID); $updatedContent = preg_replace($regex, $thing, $content); wp_update_post(array( ‘ID’ => $theID, ‘post_content’ => $updatedContent, … Read more

How can I tranlslate post date in italian?

for example use: _e(‘the things to print’) or if woocommerce is being used its possible to use this way: _e(‘the things to print’, ‘woocommerce’) add_filter( ‘get_the_date’, function($the_date, $d, $post){ $date = new DateTime( $post->post_date ); echo _e($date->format(‘j F, Y’)); // change formatting as needed }, 10, 3 ); for more information about _e() the text … Read more

Hook to change the site URL

You can filter site_url using a filter – called site_url The hook has the following signature: apply_filters( ‘site_url’, string $url, string $path, string|null $scheme, int|null $blog_id ) You can use it like this: add_filter( ‘site_url’, ‘wpse_381006_custom_site_url’, 10, 1 ); function wpse_381006_custom_site_url( $url ){ if( is_admin() ) // you probably don’t want this in admin side … Read more

Extend Nonce Lifetime for Specific Nonce Creation

Not sure if this is the case, but you should know that you need to add the filter both when generating the URL and upon verifying the nonce, i.e. the nonce lifespan needs to match in both cases. Also, you should use add_query_arg() to add query string to an URL.. So if you had this: … Read more

Changing the category for existing Gutenberg blocks

Try this, it changes the core Spacer block from the Design to the Media category in the insertor: function myprefixFilterSpacerCategory(settings, name) { if (name === “core/spacer”) { // Object.assign can also be used instead of lodash.assign return lodash.assign({}, settings, { category: “media”, }); } return settings; } wp.hooks.addFilter( “blocks.registerBlockType”, “myprefix/filter-spacer-category”, myprefixFilterSpacerCategory );

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)