Is it possible to change the contents of “the_content()”?

Add a filter to the_content and put your code in there so you don’t need your custom content function: function wpa_content_filter( $content ) { // run your code on $content and return $content; } add_filter( ‘the_content’, ‘wpa_content_filter’ ); You may need to adjust priority to run your filter before or after others: // high priority, … Read more

Word limit in post_content after more tag

Use wp_trim_words function to limit the content to a certain number of words and returns the trimmed text. Example use of wp_trim_words function. <?php $content = get_the_content(); $trimmed_content = wp_trim_words( $content, 50, NULL ); echo $trimmed_content; ?> So I added wp_trim_words function in your code to get 50 words after <!– more –>. <?php $after_more … Read more

Static page homepage not showing the_content

You don’t really have a Loop. <?php get_header(); ?> <div class=”content”> <div class=”welcome_area”> <div class=”welcome_area_title”><?php the_title(”);?></div> <div class=”welcome_area_text”><?php if (have_posts()) { while (have_posts()) { the_post(); the_content(); } } ?> What is happening is: You use have_posts() to check that you have post content. You can use an else clause to provide default content if you … Read more

How to to stop html editor from addig tags to shortcodes, images, etc

1. Filtering the content Here’s a one-function content filter to meet the above four requirements: add_filter( ‘the_content’, ‘strip_some_paragraphs’, 20 ); function strip_some_paragraphs( $content ) { $content = preg_replace( ‘/<p>(([\s]*)|[\s]*(<img[^>]*>|\[[^\]]*\])[\s]*)<\/p>/’, ‘$3’, $content ); return $content; } 2. Resources for Regular Expressions regular-expressions.info – Manual, Basic & Advanced Tutorials regexpal.com – on the fly regex tester, very … Read more

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

post_content with line breaks

I believe this should work: $getPost = get_the_content(); $postwithbreaks = wpautop( $getPost, true/false ); echo $postwithbreaks; The second argument in wpautop can be up to you whether it’s true of false, see the link below. It is described as follows: (bool) (Optional) If set, this will convert all remaining line breaks after paragraphing. Line breaks … Read more

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