Extract links inside embed tags in WordPress

No need to use regex. WordPress has a handy function to strip shortcodes from a string. Use strip_shortcodes( $content ). So in your case, $content = “”; $your_clean _url = strip_shortcodes( $content ); echo $your_clean_url; // should output https://www.youtube.com/watch?v=Z9QbYZh1YXY EDIT Here’s a function (tested) that will remove your “unwanted” shortcode, and any other one. function … Read more

Apply a filter str_replace on specific caracters array in the_content()

You could obtain what you need like this: function str_replace_special_caracter($content) { // My array of special caracters to get <sup> $specialCaracters = array(‘®’, ‘™’); foreach( $specialCaracters as $character ){ $content = preg_replace( ‘@(‘ . preg_quote( $character, ‘@’ ) . ‘)@i’, “<sup>\\1</sup>”, $content ); } // Return return $content; } add_filter( ‘the_content’, ‘str_replace_special_caracter’, 99 );

Insert wp_query after the_content with plugin (filter the_content won’t work)

You should remove your hook before query. function wpse_288691_add_query_after_content( $content ) { $ouptut=””; remove_filter( ‘the_content’, ‘wpse_288691_add_query_after_content’ ); // Do your *** WP_Query *** and assign result to $ouptut. // Reset query by executing `wp_reset_query`. add_filter( ‘the_content’, ‘wpse_288691_add_query_after_content’ ); return $content . $ouptut; } add_filter( ‘the_content’, ‘wpse_288691_add_query_after_content’ ); Do not echo anything inside the filter, only … Read more

use a Thumbnail size in post

You can use regex if you want to display it on all existing posts. WordPress add a wp-image-ATTACHMENT_ID class on images. We can use it to find the attachment_id then grab the new url. For example here, with medium size. wp_get_attachment_image_src : https://developer.wordpress.org/reference/functions/wp_get_attachment_image_src/ We apply this filter to the content to update the display of … Read more

get the_content by ID and save the result to one array

You can use get_the_content() to fetch the post content, e.g.: $content = get_the_content( $post_id ); Then you can pass it through the_content filter and json encode However, based on your comments, it looks like you’re creating an endpoint for AJAX calls that returns post content. Don’t bother! WordPress comes with one out of the box! … Read more

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