Disable links to images only if link is an image

I am not a professional when it comes to regular expressions but this should be able to catch all linked images which the href attribute links to an image file ((png|jpg|gif|jpeg|bmp) feel free to add/remove extensions): add_filter(‘the_content’, function($c){ return preg_replace_callback(“#<\s*?a\b[^>]*>(.*?)</a\b[^>]*>#s”, function($m){ $tpl = $m[0]; $cnt = isset($m[1]) ? $m[1] : null; if ( preg_match(‘/<a(.*?)?href=[\'”]?.+\.(png|jpg|gif|jpeg|bmp)[\'”]?(.*?)?><\/a>/i’, str_replace($cnt, … Read more

Shortcode Function – Can’t get anything else to return after running shortcode within shortcode

You shouldn’t call return twice in a function, as it isn’t supported and only the first return is evaluated. What you can do is assign the first do_shortcode to a variable and return the variable concatenanted to the second return. function youtube_media_shortcode() { $shortcode_output = do_shortcode( ‘[x_video_embed no_container=”true”]<iframe width=”560″ height=”315″ src=”‘.get_field(‘youtubeurl’, ‘option’).'” frameborder=”0″ allowfullscreen></iframe>[/x_video_embed]’ ); … Read more

Frontend Feature image upload not work

Use the following code. <?php // Upload image to wordpress media and save image url to custom field. if(isset($_FILES[‘images’])) { // These files need to be included as dependencies when on the front end. require_once( ABSPATH . ‘wp-admin/includes/image.php’ ); require_once( ABSPATH . ‘wp-admin/includes/file.php’ ); require_once( ABSPATH . ‘wp-admin/includes/media.php’ ); require_once( ABSPATH . ‘wp-admin/includes/admin.php’ ); $file_return … Read more

Get child-pages slugs of current page into js-file

I just found what is arguably a cleaner way to do this…thanks to this other WPSE question How do I add a php statement to a jQuery string. I never new about wp_localize_script() until reading the answer to that question (I love WPSE :-). PHP add_action (‘wp_enqueue_scripts’, ‘localize_js’) ; function localize_js () { global $post … Read more

Does WordPress function replace_hello() exists?

This is custom function the author uses to show how to use the_content filter. If you look at the line after the function add_filter(‘the_content’, ‘replace_hello’); this is saying to call the custom function replace_hello when encountering the the_content filter

RSS feed including post updates

what you could possibly do, is set up a post dedicated to the list, then on the post / page do an include to retrieve that list onto it. <?php $my_id = 7 <—this would be the post / page id you set up on for the list; $post_id_7 = get_post($my_id, ARRAY_A); $title = $post_id_7[‘post_content’]; … Read more