The major issue is just that you have a positive lookbehind
but no capture group
so \1
or $1
isn’t a usable variable.
Fix your regex to provide the capture group: '/(?<=\<\/h3\>\n<p>)(.)/'
then reference as $1
.
ob_start();?>
<h3>Heading</h3>
<p>Paragraph</p>
<p>Paragraph2</p>
<?php
$search = ob_get_clean();
$result = preg_replace(
'/(?<=\<\/h3\>\n<p>)(.)/',
'<span class="dropcap">$1</span>', $search );
Related Posts:
- Change comments form title on a page by page basis
- append PHP function to the_content
- How to call function at the bottom of post using plugin?
- Change the site tagline (or similar) based on current page
- Removing “wpautop” (auto tags) only on certain pages?
- Get URL from shortcode tag
- How to debug this search & replace strings snippet?
- Create page template via functions.php?
- Extract links from content
- Get the_content surrounded by instead of
- How to Create custom block for displaying information in content section which act like shortcode
- How to bind each “the_content” elements to a custom variables
- Redirecting the lost password page request when using a custon login page
- Is there a way to have chunks of a page’s content expire?
- Display a list of users with avatar filterable with alphabets
- What do ++ and *+ mean?
- Remove “Insert from URL” link in Media upload – WP 3.5
- Cleaning up WordPress to improve performance?
- List of all theme customizer control types?
- Show the most popular post per week
- Add a class to links in the visual editor (how to get old dialog back)
- Hide custom image sizes from media library
- Change html structure of all img tags in WordPress
- Creating custom Woocommerce attribute taxonomies from a plugin
- Load post content into iframe
- wp_customize_image_control default value
- Overriding a theme redux file in child theme
- Widgets not showing in my custom theme
- How to display custom field on homepage
- Filter get_the_title to remove certain characters?
- Output 2 items within the Loop
- Get posts with at least one category in common with current post?
- Customizer: Output default value in Customizer CSS
- create a select input with menus created on a custom options page
- Custom filter in admin edit custom post type responding with invalid post type?
- Converting HTML Template to WordPress Theme
- Add data attribute to each li in menu
- Ajax category filtering products default show all
- Add a specific part of current category page url to shortcode
- How to pick the default selected value in wordpress dropdown?
- Print last modified date only on posts
- Customize position of social icons in upme plugin [closed]
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- Media Upload , file name changed automatically
- Change tinyMCE editor to allow marked content when pasting from Word
- Replace shortcode in substring
- Getting content from a referenced post
- What exactly do this function declared into functions.php file of a WP theme?
- How to make modifications only to certain elements of an HTML string on the server-side?
- customize wordpress database error page
- How to append to an array and return the results in a filter?
- How to add no follow to specific links?
- Basic wpdb update question
- Ajax search shows all results when user empties input?
- List post by title length
- WordPress widget and customize.php not working in Ubuntu16.04 VPS
- wrap a span tag around author’s post count
- Need help with pagination
- How do i wrap woocomerce attribute in list?
- WordPress the_content Page Load
- Editor capabilities – admin_init
- WP insert post Redirect after function has executed
- Create condition for Author bio Social Links
- How can I add diffrent editable text fields?
- Give ID to divs inside the loop
- Featured image in menu wordpres
- How to remove get_header From all single pages in wordpress with functions.php without plugin?
- Change lost password url to a mailto URL in WordPress
- Having trouble creating two shortcodes, one for logged in user and one for visitors
- How to edit post meta data before publishing the post it self wordpress?
- How can I update the price when someone enters postcode or zip code in woocommerce checkout page?
- How to change href of a Widget menu item link?
- Replace an array (with identical values) with another array in the_content
- Need help transforming echo to return for use with shortcode
- Reload page with a different shortcode when a user selects from a dropdown
- Noob question: want to remove the “site identity” logo for specific part of website only
- WordPress Ajax filter: Create two loops for different output styles?
- Redirect after login depending on the URL
- How to display custom seo title before the loop?
- How to remove title tag with this filter
- Real time notification on user profile after new comment
- How to add text before posts
- Add two or multiple functions in WordPress Post or Page
- str_replace not preserving whitespace
- How to associate dynamic PHP page for chosen WordPress tag?
- WordPress error on my website
- Add custom filter to register data in array
- Get terms of the posts with one query
- Woocommerce Price Text
- Limit Taxonomy Parents
- Best way to define a database with product codes and back-end support?
- wp_customize_image_control default value
- why is this content-template not showing any of my blog-entries?
- How to get the count for each taxonomy term
- dynamically filter by category via sub-menu
- How to add button to top of theme customizer?
- How can I add more code to this?
- Edit the Publish Widget Options
- New to WordPress & Freelancing [closed]
- How to change wp-admin and wp-login urls