How to add element to the list of adjacent images?

There’s a few problems here. Your regex is pretty broken. You should be using a tool like regex101 to test that. I think for your first function you need to add the possibility of newlines between the image tags like so: /(<img.*?>\r?\n?){2,}/ You can add * before the ?‘s if you want to grab multiple … Read more

How to get featured image of last post in a category?

Correct this line in your code at the end of function. echo get_the_post_thumbnail($page->ID, ‘thumbnail’); should be echo get_the_post_thumbnail($post_id, ‘thumbnail’); also as per WordPress documentation, category_name parameter should be a string representing category slug, not name. So, the complete code should look like this: $arg = array( ‘orderby’ => ‘date’, ‘number’ => 10, ); $categories = … Read more

Images with overlay

I was able to find some jQuery that helped solve the issue: $( “.alignright” ).parent().addClass( “alignright” ); $( “.alignleft” ).parent().addClass( “alignleft” ); $( “.aligncenter” ).parent().addClass( “aligncenter” ); This small piece of code finds alignright, alignleft, and aligncenter then adds those classes to the “parent” container, which is the containing element that those classes are applied … Read more

How to trigger “wp_handle_upload_prefilter” filter when uploading an image programatically?

I eventually got this. Solution was to use wp_handle_upload() function. Kinda obvious, when I come to think about it… function handle_upload( string $path ): array { $filename = basename( $path ); $random_filename = rand( 0, 1000 ) . $filename; $tmp_path = str_replace( $filename, $random_filename, $path ); /** Create a temporary copy of the original file, … Read more

Bootstrap Nav Walker Sub Menu Image

Do you want the same image for each menu item? .menu-item a:before { content: url(“/path/to/image.png”); display: inline-block; } The menu items should already have an ID on each <li> li#menu-item-274 a:before { content: url(“/path/to/another/image.png”); } Failing that, you can implement your own Bootstrap Navwalker and add whatever classes or images you like. See: https://developer.wordpress.org/reference/classes/walker/ and … Read more

WordPress Iframe for blog image

It depends a bit on your theme how to tackle this, because under most circumstances you cannot just change the featured image without writing a plugin. If you’re experienced with writing WordPress plugins (and Instagram’ API) you could write your own plugin that replaces the featured image. I would rather recommend using an existing plugin … Read more

Image sizes reset when changing theme

When you upload an image using Media Uploader, WordPress generates various image sizes(different copies) for the picture that you upload. Go to media and find whether there are multiple images with different sizes. I guess switching themes is not a reason for changing image sizes. Refer this link, it may help you

Delete attached images from posts

Having that resulting XML file from the export it’s just a matter of editing it precisely to get rid of the images before importing it on the other site. Taking Sublime Text for example it’s pretty easy to find and select all occurrences of [caption and add a line break before them for example. Same … Read more