Modify Image Source With The_Content Filter?

Let’s give it a try: $str=”<img src=”http://myserver.mydomain/picture.png” />”; $pattern =’#<img src=”http://.*/(.*)” />#’; $replace=”<img src=”http://http://i0.wp.com/$1?quality=70&strip=all />””; $result = preg_replace($pattern, $replace, $str); The $pattern is quite simple and very specific. You might need to generalize it a bit more but it should show you the direction to go. E.g. it takes no care of possible whitespace. A … Read more

Displaying recent post excerpts on static front page

I’ve found the solution. According to https://codex.wordpress.org/Function_Reference/the_content#Overriding_Archive.2FSingle_Page_Behavior, one must add global $more; $more = 0; before the call to the_content(). So now my inner loop reads: <?php $recent_posts_query = new WP_Query(array(‘post_type’ => ‘post’, ‘posts_per_page’ => 5)); while ($recent_posts_query->have_posts()) { $recent_posts_query->the_post(); ?> <div class=”post”> <h3><?php echo the_title(); ?></h3> <p>by <?php the_author(); ?></p> <?php global $more; $more … Read more

How do I Add HTML to the_excerpt() & the_content() Output?

get_the_excerpt() returns the excerpt, but only after applying get_the_excerpt filters to it. This causes infinite recursion, as your filter handler will be called to an infinite depth. Of course, the best solution is the css one (see @spacegrrl’s answer), but if you have your reasons for keeping that <span>, please note that the excerpt can … Read more

Save the_content into custom field

You can get the content with $_REQUEST, Try the below code: add_action(‘publish_post’, ‘save_content_to_field’); function save_content_to_field($post_ID) { if(isset($_REQUEST[‘content’])) { update_post_meta($post_ID, ‘desc’, $_REQUEST[‘content’]); } } UPDATED With the below code if you want to sore with shortcode support: add_action(‘publish_post’, ‘save_content_to_field’); function save_content_to_field($post_ID) { $post = get_post($post_ID); $result = apply_filters(‘the_content’,$post->post_content); if($result) { update_post_meta($post_ID, ‘desc’, $result); } }

Inserting a functions output after the content

Your shares_content function directly outputs content, which won’t work if you’re trying to assign the results to a variable or use it in a return statement within another function. You can change it to return the string: function shares_content() { $content = “<div class=”social-shares-container”><a href=”https://www.facebook.com/sharer/sharer.php?u=%s”>Share on Facebook</a></div>”; return sprintf( $content, get_permalink() ); } It’s also … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)