Automatically wrap multiple images in div

This is a function I use to add a wrapper to each image. I know it’s not 100% what you want, but I thought this might give you a handle to work from. function add_image_wrapper( $content ) { $content = preg_replace_callback( ‘/<img[^>]+>/im’, function ( $matches ) { $image = $matches[0]; $classes = array(); preg_match( ‘/class=”align([^”]+)”/im’, … Read more

Two different inner shortcode under shortcodes or multiple nesting of inner shortcodes

Yes, you can keep nesting shortcodes. Just keep using the do_shortcode() until the deepest level is reached. https://codex.wordpress.org/Shortcode_API#Nested_Shortcodes So you can do this, [container] [other_column class=”extra-class”] [content] col 1 [/content] [another] col 1-2 [/another] [/other_column] [column] [another] col 2 [/another] [/column] [/container] To achieve output like this, <div class=”container”> <div class=”other-column extra-class”> <div class=”content”> col … Read more

How to loop for every result found in the_content() when using the search query?

got a solution with https://stackoverflow.com/questions/15737408/php-find-all-occurrences-of-a-substring-in-a-string $lastPos = 0; $positions = array(); if($pos==”){} else{ while (($lastPos = strpos($content, $findme, $lastPos))!== false){ $positions[] = $lastPos; $lastPos = $lastPos + strlen($findme); } // Displays foreach ($positions as $eachPos){ $pos = $eachPos; $exctractAfterQuery = substr($content,($pos+strlen($findme) ),40); $exctractBeforeQuery = substr($content,$pos-40,40); $newContent .= “[…”.$exctractBeforeQuery.'<strong class=”search-highlight”>’.$findme.”</strong>”.$exctractAfterQuery.”…]<br>”; } } It works well and … Read more

Can somebody tell me how I am supposed to be using blogs.dir for network / MU sites?

blogs.dir was the way to handle specific blog plugins and themes when it was WordPress-MU but since version 3 came out and the WordPress-MU was integrated into WordPress Core and introduced WordPress Multisite, that’s no longer the story. WordPress Handles the creation of the new blogs/sites in the database and mainly in the background so … Read more

Get the content inside shortcode and apply external function to it?

The following adds the shortcode [my_t_shortcode], which accepts an attribute ‘lang’, and applys the above mentioned function to the content. //Add shortcodes add_shortcode( ‘my_t_shortcode’, ‘wpse41477_shortcode_handler’ ); //It’s good practise to make sure your functions are prefixed by something unique function wpse41477_shortcode_handler( $atts, $content = null ) { //This will extract ‘lang’ attribute as $lang. You … Read more

Display content of page template (get_page)

You seem to be confusing the database object that is a post/page, and the rendered output that is a post/page. The data contained in the wp_posts and wp_post_meta tables define the post object. A template file defines the rendered output when a given database object is queried. There are three types of queries: the default, … Read more