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
- Random Default Avatar Function
- Hide wordpress field if data is empty in post!
- Combine two filters into a single call
- Remove a filter added by a plugin
- Trouble creating conditional PHP for nav menu items with children for custom Walker
- Setting custom canonical urls
- Handling Body class based on Template
- Only show search results with if current date is between two dates?
- Get_avatar filter?
- database interactions using OOP
- Customizer: Output default value in Customizer CSS
- How to add just one specific page to widget without plugin?
- Remove one value in dismissed_wp_pointers?
- WooCommerce Related Products by Attribute
- create a select input with menus created on a custom options page
- Taxonomy linked to pages
- Custom filter in admin edit custom post type responding with invalid post type?
- Add a class to the anchor tag on HTML5 gallery
- Nesting if statements to echo only one string based on what tag was filtered?
- How to properly loop through these external URLs to get them into the sitemap using this hook
- Input type search in Menu
- Output Buffering – Everything between wp_head and wp_print_footer_scripts?
- How do I Add HTML to the_excerpt() & the_content() Output?
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- Accessing data from a non-WP database/table within a page content
- add_action shortcut?
- WordPress blog post url on category page
- Modify Image Source With The_Content Filter?
- Showing content from one page on another
- Changing layout with wp_customise
- WP dynamic featured image – Can’t get second featured image url
- Converting HTML Template to WordPress Theme
- Extending the WP_Widget_Text class
- Is it acceptable to treat a filter like an action?
- Selectbox in admin panel function linking to CSS
- Can I install/embed WordPress on a ‘single page’?
- How can I remove a function that has been added to wordpress with add_filter?
- How to control WordPress image metadata (using Imagick)?
- Edit incorrect password message WordPress
- How do I add custom bulk actions to multiple custom post types?
- Add data attribute to each li in menu
- Show prices with tax in Woocommerce Mini Cart [closed]
- How to check if a meta value has already been assigned to any user?
- How to hide products that do not have an image from a slider carousel for an ecommerce webpage?
- Ajax category filtering products default show all
- Add a specific part of current category page url to shortcode
- Why does my callback function not work with this custom filter hook?
- Customize Theme comment template to Insert VoteUp and VoteDown buttons
- filter default query to show just selected level of child pages in wordpress
- Retrieve $_POST data submitted from external URL in WordPress(NOT API)
- Trying to build simple deposit code that hooks into woocommerce
- Contact Fom 7 – how to add custom HTML inside span.wpcf7-form-control-wrap AND IMMEDIATELY AFTER input.wpcf7-form-control?
- How to pick the default selected value in wordpress dropdown?
- Applying A Category to Existing Posts Where Page Title Matches Regex
- Add filter when image is uploaded?
- Add New User, extra fields which are required?
- Remove the first 5 characters of the_title and orderby that
- Remove a div from RSS feed
- Print last modified date only on posts
- user_profile_update_errors hook not executing
- Send an email to specific adress when button is clicked?
- How to add an arrow to menu items has submenus
- WordPress Gravatar filter is removing my custom attributes
- Customizer: active_callback and sanitize_callback incompatibility?
- Generating an nonce for Content Security Policy and all scripts – How to make it match/persist for each page load?
- Saving and Restoring a Canvas on A Individual User Basis
- Redirect specific user role to specific site after login?
- Send multiple attachments with wp_mail in PHP
- WordPress admin pointers tour bug?
- custom url rewrite for wordpress
- Extend plugin Class through functions.php
- Unique icons next to each WordPress menu item
- How to add a do_action on refreshing of WP customizer?
- Customize position of social icons in upme plugin [closed]
- Weird 404 URL Problem – domain name being placed at end of urls
- Extend PHP regex to cover “srcset” and “style” attributes
- How to get the value of input hidden html from text editor to custom page template?
- Make a list of sites for each user in WPMU – switch_to_blog (display in SITE_ID: 1)
- Menu jumping when calling it via PHP
- Output Video Download Link in template
- Modify custom field input data before creating a new post
- Output custom field value to post string
- Compare the old get_theme_mod($name) to the new get_theme_mod($name) return value
- Using $wpdb (WPDB class) ‘replace’ with multiple WHERE criteria problem
- Media Upload , file name changed automatically