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

Modify the_content after the more tag

I think you can use the get_extended( $post ) function; that returns an array with different parts of the content. See this example which works inside the Loop: $content_arr = get_extended( get_the_content() ); var_dump( $content_arr ); echo $content_arr[‘main’]; //Display the part before the more tag

Post content being duplicated by the_content();

The problem is still present, but I’ve found a workaround for now. When I replaced echo apply_filters(‘the_content’, get_post_field(‘post_content’, $post_id)) with echo wpautop( get_the_content() ), it worked. I also stopped using the variable $post since I wasn’t accessing the global post variable. So that makes my code look like so: $state_posts = array(); while ($query->have_posts()) { … Read more

Format content value from DB outside of WordPress filters

There are a few filters and actions here that run. You’d need to look at the code and figure out what/how to utilize these. https://codex.wordpress.org/Function_Reference/wpautop https://codex.wordpress.org/Function_Reference/wptexturize https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content https://developer.wordpress.org/reference/functions/do_shortcode/ https://developer.wordpress.org/reference/functions/unescape_invalid_shortcodes/ https://developer.wordpress.org/reference/functions/get_shortcode_regex/

How to ignore or disable nextpage tag?

You can try to use the the_post filter, to override the content pagination, that takes place within the setup_postdata() function ( PHP 5.4+ ): /** * Ignore the <!–nextpage–> for content pagination. * * @see http://wordpress.stackexchange.com/a/183587/26350 */ add_action( ‘the_post’, function( $post ) { if ( false !== strpos( $post->post_content, ‘<!–nextpage–>’ ) ) { // Reset … Read more

Get link value only from the_content()?

You can scan the content to see whether it contains a link and then parse it to find the href attribute. There are many ways to do this, this example uses the built-in kses functionality, as demonstrated by Otto: $post_link = get_the_permalink(); if ( preg_match(‘/<a (.+?)>/’, get_the_content(), $match) ) { $link = array(); foreach ( … Read more

How to limit post content and remove image caption from it

Image captions in WordPress are actually shortcodes. Shortcodes are applied by the filter: $content = apply_filters(‘the_content’, $content); For example, WordPress creates the following code in your content when you enter an image caption: You need to still use apply_filters() in order to properly display content. (safe content display and all other shortcodes) If you don’t … Read more

Use the_content outside the loop

If you are trying to do it for the current page you are on you can just use this: global $post; $content = $post->post_content;` This will get the content for the current post instead of having to set the ID specifically.

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