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

the_content() printing site title after page/post title and before its content

The culprit was within an add_filter function. Commenting out the following removed the site title from above the page/post content: function add_post_content($content) { if(!is_feed() && !is_home()) { $content .= ‘<p>This article is copyright &copy; ‘.date(‘Y’).’&nbsp;’.bloginfo(‘name’).'</p>’; } return $content; } add_filter(‘the_content’, ‘add_post_content’); The first part, “This article is copyright (c)”, printed where you’d expect, but bloginfo(‘name’) … Read more

tech