Replace a specific URL on all apperances on the Website (Maybe a filter?)
Replace a specific URL on all apperances on the Website (Maybe a filter?)
Replace a specific URL on all apperances on the Website (Maybe a filter?)
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
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
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
get_post() with filters applied
Custom sort orderby question
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
How to modify image caption in posts?
Ok, I found a solution. I’ve found the filter excerpt_more that is used to show the string shown within the more link (if theme use standard WP functions). So, to achieve this, we need to hook the excerpt_more and use a lower priority of the one used by the theme. In my example, this add_filter(‘the_title’, … Read more
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 );