Warning: : DOMDocument::loadHTML(): Empty string supplied as input in functions.php when adding classes to post images

Here’s an updated version of the code that will avoid the warning by adding a simple check that will return $content unmodified if it’s an empty string. The original code adds <html> to the modified markup (check the page source), which we don’t want. The code below fixes that too. add_filter( ‘the_content’, ‘wpse_add_img_post_class’ ); function … Read more

create filter in functions.php

Whenever you see apply_filters( ‘filter_name’, $value ), you can use add_filter() to replace or modify the value of $value: add_filter( ‘filter_name’, ‘callback_function’ ); Where callback_function is a function that you create. That function will accept $value as an argument, and needs to return a new value. So for your example, that will look like this: … Read more

Pass php dynamic variable to shortcode

I see a few errors in your code… on the html, there was no quotation in front of variable on the php you say you were calling the short code [modifycontent] but by your php you should have been using [mc]. All the same, here’s how I would do it: function modifycontent ($atts, $content = … Read more

How to change the order of Jquery in the footer of my theme?

Understand wp_enqueue’s dependencies parameter You need to ensure the other script depends on jQuery being ready before it loads. Checking the wp_enqueue usage example: <?php wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); ?> It is $deps (dependencies) that we can utilise for this purpose. Properly enqueue the second script, and leverage that parameter Secondly you … Read more