Add class to all parent elements inside the_content
Add class to all parent elements inside the_content
It appears to be an issue with your RegEx pattern matching images. I modified $pattern to the following and it worked on a test page I setup. $pattern = ‘/<img(.*?)src=”https://wordpress.stackexchange.com/questions/114747/(.*?).(bmp”gif|jpeg|jpg|png)”(.*?)width=”(.*?)” height=”(.*?)” \/>/i’; There were some extra spaces which were throwing it off. I suggest using a RegEx tester to help you make sure your pattern … Read more
You can check for is_home() and is_front_page() inside of your filter: add_filter( ‘the_content’, function( $content ) { if ( ! is_home() and ! is_front_page() ) return $content; return ‘Home, sweet home!<br>’ . $content; });
Your code is OK, however I think the main failure is to call a page #116, if this page not exist on your WP site the front area or HOME page will not display any data. Normaly to avoid page ID # I use the code if (is_page(‘name-of-page’)) {?> Some times is better than PAGE … Read more
Suppress the_content filter in a nested loop
Use buffer to simply do that with ob_start() & ob_get_clean(). function custom_summary($atts) { extract(shortcode_atts(array( “category” => “”, “posts” => “” ), $atts)); ob_start(); $my_query = new WP_Query(“category_name=$category&posts_per_page=$posts”); while ($my_query->have_posts()) : $my_query->the_post(); // Do all the things. endwhile; wp_reset_postdata(); return ob_get_clean(); } add_shortcode(‘summary’, ‘custom_summary’);
Heh… may I ask you what is the point of this? Because one would think that it’s to save bandwidth and shorten the time the page loads. So why would you always want to load all three of them? The display: none will NOT prevent the images from being loaded into the DOM. They will … Read more
Removing image dimensions from `the_content`
Add class to all parent elements inside the_content
the_content is expecting a string, you’ll have to use output buffering: function my_custom_loop() { $taxonomy = ‘state_cat’; $terms = get_the_terms($post->ID, $taxonomy); if ($terms && ! is_wp_error($terms)) : $terms_array = array(); foreach ($terms as $term) { $terms_array[] = $term->slug; } $have_you_read_query = new WP_Query( array( ‘posts_per_page’ => 100, ‘post_type’ => ‘post’, ‘post__not_in’ => array($post->ID), ‘category__not_in’ => … Read more
There are a few issues here, but I’m not sure that any one directly is your problem. First, you need to be more specific in your pre_get_posts callback conditional, to ensure you’re targeting only the main query. Second, you need to clarify the post type you’re intending to show. Third – and the one that … Read more