Call the content help

According to their site: This is not an error. in our template we have coded if content exist then the_content function call otherwise skip the_content function. So it’s necessary to add some text in the page content area then you can use your page builder plugin and the error should be gone. Not the best … Read more

Remove P tag from images if aligncenter class is set

it should work like this. function filter_ptags_on_images($content) { $content = preg_replace(‘/<p>\s*?((<a.*?>)?<img[^>]+class=”[^\”]*aligncenter[^\”]*”.*?>(<\/a>)?)?\s*<\/p>/’, ‘$1’, $content); return $content; } it filters if the img tag has the class aligncenter and any class.

after setup_postdata, the_content() only displays text before the read more tag

Check out the examples on the setup_postdata Codex page. You must pass a reference to the global $post, it won’t work with any other variable. global $post; // make sure we’re working with the global. $post = $get_train; // or assign get_post result directly to $post. setup_postdata( $post ); // this must be the global … Read more

Looking to limit the number of characters on my post page

The normal way to do this would be to use the_excerpt() instead of the_content() in your archive templates, then use this filter the change the number of words that appear in the excerpt: function wpse_280633_excerpt_length() { return 20; } add_filter( ‘excerpt_length’, ‘wpse_280633_excerpt_length’ ); If you want to stick with what you’ve got and not apply … Read more

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

auto link word link in content

If I understand correctly … first of all you need to match everything inside paragraphs using regex. $content = “<p>some text which includes test1 and test2 etc</p>”; preg_match_all(“/<\s*p[^>]*>([^<]*)<\s*\/\s*p\s*>/”, $content); then you can use your code.