How to remove p tags around img and iframe tags in the acf wysiwyg field

Ok if you want to strip the p tags for img’s and iframe’s for advanced custom fields you have to exchange the_content with acf_the_content . The code looks that way: function filter_ptags_on_images($content) { $content = preg_replace(‘/<p>\s*(<a .*>)?\s*(<img .* \/>)\s*(<\/a>)?\s*<\/p>/iU’, ‘\1\2\3’, $content); return preg_replace(‘/<p>\s*(<iframe .*>*.<\/iframe>)\s*<\/p>/iU’, ‘\1’, $content); } add_filter(‘acf_the_content’, ‘filter_ptags_on_images’);

Can’t seem to attach uploaded image to post and set it as thumbnail

You have a variable scope problem. $post_id = wp_insert_post($post_information); function upload_user_file( $file = array() ) { require_once( ABSPATH . ‘wp-admin/includes/admin.php’ ); $file_return = wp_handle_upload( $file, array(‘test_form’ => false ) ); // … You set $post_id outside of your upload_user_file() function but that means that it is unavailable inside the function where you need it for … Read more

Can I use images as anchor tags with

Well, yes, of course. Take a look at this reference: http://codex.wordpress.org/Function_Reference/previous_post_link http://codex.wordpress.org/Function_Reference/next_post_link You can customize it however you like, so you can simply put an html image tag in there. The function must be used in the loop to work. I’d do it like this: <?php previous_post_link(‘%link’, ‘<img src=”https://wordpress.stackexchange.com/questions/141544/Image URL” width=”20″ height=”20″ alt=”%title” />’); ?> … Read more

How to get cropped thumbnail source for custom post type

You should add your custom image size with this code: add_image_size( ‘my-test-image-size’, 148, 148, true ); Then in your template file you can get cropped image using wp_get_attachment_image_src like this: $attachment_id = …; // i.e. get_post_thumbnail_id() $image_info = wp_get_attachment_image_src($attachment_id, ‘my-test-image-size’); echo ‘<img src=”‘. $image_info[0] .'” … />’; // $image_info[0] contains url of cropped image To … Read more

Multiple images with Media Uploader on front-end

You can’t have two buttons with the same ID (#upload_image_button) as IDs are supposed to be unique. You should give the buttons a class and give the ID equal to that of the name of the associated input. <input type=”text” size=”36″ name=”image_1″ value=”http://” /> <input id=”image_1″ class=”button upload_image_button” type=”button” value=”Upload Image” /> <input type=”text” size=”36″ … Read more

How can I implement an Add to Collection function on my Image Gallery to be downloaded later?

I would skip cookies and use the awesome script store.js Just kick out a data-lightbox attribute on the “Add to Lightbox” link with the image ID and (assuming you’re using jQuery) it’s this simple: $( document.body ).on( “click”, “a[data-lightbox]”, function ( ev ) { ev.preventDefault(); var id = $( this ).data( “lightbox” ), list = … Read more