Heartbeat API oEmbed

The problem: The reason why this isn’t working, is this part of the WP_Embed::shortcode() method: if( $post_ID ) { …. cut … // Use oEmbed to get the HTML $html = wp_oembed_get( $url, $attr ); … cut … } When trying to autoembed with the Heartbeat API the $post_ID is null, so wp_oembed_get() is never … Read more

Add Class to Specific Paragraph of the_content()

The following bit of code adds a class to the first paragraph output by the_content: function first_paragraph($content){ return preg_replace(‘/<p([^>]+)?>/’, ‘<p$1 class=”intro”>’, $content, 1); } add_filter(‘the_content’, ‘first_paragraph’); Add the above to your theme’s functions.php file. Then in your CSS add something like: p.intro { font-weight:bold; } I can’t claim credit for this solution (see this thread … Read more

How do I add the featured image to the_content after the first paragraph?

You can do this using the ‘the_content’ filter: add_filter( ‘the_content’, ‘insert_featured_image’, 20 ); function insert_featured_image( $content ) { $content = preg_replace( “/<\/p>/”, “</p>” . get_the_post_thumbnail($post->ID, ‘post-single’), $content, 1 ); return $content; } Of course, you can add options to the the_post_thumbnail() function to define which size of thumbnail you’d like to use, etc… http://codex.wordpress.org/Function_Reference/the_post_thumbnail

Get excerpt from $post->post_content

When in the loop, this will produce excerpt from $post->post_content directly: <?php echo wp_trim_excerpt(); ?> Read more HERE. Alternative Solution: If you are not in the loop, then, you may use similar implementation as done in the wp_trim_excerpt function: $text = strip_shortcodes( $post->post_content ); $text = apply_filters( ‘the_content’, $text ); $text = str_replace(‘]]>’, ‘]]&gt;’, $text); … Read more

Modify ‘Read more’ link adding a new class

What (exactly) happens When calling the_content() inside your template, you are able to call it without any parameters. This means, that the function already has the defaults of null for both arguments: The “more” link text and the boolean switch that allows you to strip teaser content before the “more” link text. The the_content() function … Read more

How to disable content pagination?

EDIT – Now that 4.4 is out, you should use the content_pagination filter. See birgire’s answer below. You can add formatting to raw post content by applying the content filters directly to $post->post_content: echo apply_filters( ‘the_content’, $post->post_content ); This will bypass pagination by not using the get_the_content function, which is what the_content uses internally to … Read more

Add whitespace between Chinese and other letters

Interesting question. This could be a useful part of a specific language file. It cannot be done in CSS, because CSS is (mostly) character agnostic. But using a filter and PHP it is possible and on topic: add_filter( ‘the_content’, ‘t5_chinese_spacing’ ); function t5_chinese_spacing( $content ) { return preg_replace( ‘~([^\p{Han}]*)(\p{Han}+)([^\p{Han}])~imUxu’, ‘\1 \2 \3’, $content ); } … Read more

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