Randomise upload filenames (or another solution to hide the original image URL from theft?)

Where am I going wrong? Actually, your code is just fine. Except that I would simply use wp_generate_password() to generate the random string. 🙂 WordPress will still think that the scaled version is called painting-scaled.jpg , etc. Resulting in broken images. Yes, that’s correct. Images are stored as posts of the attachment type in the … Read more

Convert HTML Script to Shortcode [closed]

Your JavaScript targets a HTML element with the id ‘banner_div’. So the first step is to output such an element in the shortcode. add_shortcode( ‘shortcode_name’, function () { $out=”<div id=”banner_div’></div>’; return $out; } ); Now you need to save the JavaScript (everything between the <script> tags) as a file. This you can now enqueue which … Read more

How to do multiple searches (with logical OR) in WP_Query in hook pre_get_posts?

You could do something like this add_action(‘pre_get_posts’, ‘bt_search_posts’); function bt_search_posts ($query) { // the posts ids that contain foo bar OR lorem ipsum dolor OR ping pong $posts_ids = []; // get the current query vars $query_vars = $query->query_vars; // loop each term we want to search and if found, add the post id into … Read more