strip_tags in get_the content

$content = get_the_content(); // regex (fixed) replacing ‘<embed>’ with ‘(embed )’ $content = preg_replace(“/<embed?[^>]+>/i”, “(embed) “, $content); // remove all tags $content = wp_strip_all_tags($content); echo $content; Edited according to the first comment: What you are trying to remove are not tags, these are HTML character entities. E. g., <p> was converted to &lt;p&gt; by WordPress …

Read more

How do I show current post content in the header?

The simplest solution is to call the_post() to setup the post data before calling the template functions. <?php if(have_posts()) : the_post(); ?> //your header code here <?php rewind_posts(); //to set the post pointer back to the beginning ?> <?php else : ?> //alternative header code here <?php endif; ?>

Extract a link in the_content()

You’re just looking in the wrong place: php > $txt=”<a href=”http://tumblr.everlane.com/page/4″>Everlane Tumblr</a>”; php > $matches = array(); php > echo preg_match_all(‘#\bhttps?://[^\s()<>]+(?:\([\w\d]+\)|([^[:punct:]\s]|/))#’, $txt, $matches); 1 php > print_r($matches); Array ( [0] => Array ( [0] => http://tumblr.everlane.com/page/4 ) [1] => Array ( [0] => 4 ) )

Remove images from the_content [duplicate]

Your function is not removing the p tags: they have not yet been added as get_the_content returns the unfiltered content. You can manually add the p tags using wpautop. $unfiltered = preg_replace(‘/<img[^>]+\>/i’, ”,get_the_content()); $filtered = wpautop($unfiltered); echo $filtered;

removing tags around img, iframes and also scripts

This should do it and also remove <p> tags from images that are linked. Why it removes it from only one <script> instance is hard to tell. Would have to see your website code to investigate further. // Remove p tags from images, scripts, and iframes. function remove_some_ptags( $content ) { $content = preg_replace(‘/<p>\s*(<a .*>)?\s*(<img …

Read more

WordPress adding content into different sections

Don’t do that! There are many other options to achieve this that are not hacky and messy. Here is what I would suggest. Overview First, create a child theme. This will allow you to make edits to your theme without losing them during an update. Once your child theme is setup, add a custom field …

Read more