Execute multiple PHP Snippets causes error?

Maybe I’m misunderstanding something, and it’s still not clear to me how you’re using this code, but it seems like a straightforward PHP error. You can’t declare an independent function with the same name twice. You declare (or define) the function with the function function_name() only once, and then you can call it by name. … Read more

Assign a tag to custom post type using a query

Put code below to your functions.php add_filter(‘pre_get_posts’, ‘query_post_type’); function query_post_type($query) { if(is_category() || is_tag()) { $post_type = get_query_var(‘post_type’); if($post_type) $post_type = $post_type; else $post_type = array(‘post’,’cpt’); // replace cpt to your custom post type $query->set(‘post_type’,$post_type); return $query; } }

Share or sync user table data with another user table

Welcome to WPSE. Asking for plugin recommendations is considered off-topic here, so here’s an action approach to the problem. wp_insert_user() takes care of adding new users to the database. The last action the function fires is user_register, which “Fires immediately after a new user is registered”. You could hook your function to this action and … Read more

Need SQL query to find&replace image URL

If you don’t have WPCLI installed, but still have commandline access or access via PHPMyAdmin, run: UPDATE wp_posts SET post_content = REPLACE(post_content,'<old URL>’,'<new URL>’); UPDATE wp_postmeta SET meta_value = REPLACE(meta_value,'<old URL>’,'<new URL>’);