Wrap First Character after in a tag

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 );

Why can’t I use “%s” format value in the WordPress function checked?

Because the order of operations means you’re passing that variable into your checked function before the printf function is even being run, which is what’s parsing the enumerated variables. Here’s a possible solution haven’t tested it though: printf( ‘<input type=”checkbox” id=”%2$s” name=”%1$s[%2$s]” %3$s)’. ‘<label for=”%2$s”>%4$s</label>’ . ‘<hr />’, $args[‘option_name’], $args[‘name’], checked(“on”, $args[‘value’], false ), $args[‘description’] … Read more

WordPress Redirect: Default Password Reset URL [duplicate]

There is a filter to change the lost password url. Try this : add_filter( ‘lostpassword_url’, ‘my_lostpassword_url’, 10, 0 ); function my_lostpassword_url() { return site_url(‘/password-reset/’); } Note : You can place code in functions.php or make plugin (Recommended).

How to send user data in json format to another server when user register on wordpress site in PHP

Sending and receiving data in JSON format using POST method xhr = new XMLHttpRequest(); var url = “url”; xhr.open(“POST”, url, true); xhr.setRequestHeader(“Content-type”, “application/json”); xhr.onreadystatechange = function () { if (xhr.readyState == 4 && xhr.status == 200) { var json = JSON.parse(xhr.responseText); console.log(json.email + “, ” + json.password) } } var data = JSON.stringify({“email”:”[email protected]”,”password”:”101010″}); xhr.send(data); Sending … Read more

How to group 2 radio buttons in a widget?

The question does not call for WordPress, but it was long to include it in a comment, so here we go. If you want to group your radio buttons, you should specify a name for them. To assign a value, you should change the value property, unlike other form elements. So, let’s have a simple … Read more

Show Custom Taxonomy Title

You can use single_term_title(): <h3><?php single_term_title(); ?></h3> To hide it if there are no posts, use the if ( have_posts() ) : function: <?php if ( have_posts() ) : ?> <h3><?php single_term_title(); ?></h3> <?php endif; ?> If not an archive, you can use get_term_by() to get the term object for the term and then echo … Read more

get_page_by_title with an apostrophe in variable

Title Hello world!@#$%^*(),.;:\ will work but any title you enter containing ‘ ” < > & characters won’t work because in $content variable you have escaped HTML entities so Mal’s Post becomes Mal&#8217;s Post. To bypass it you can use sanitize_title function along with get_page_by_path. function shortcode_equipment($atts, $content = null) { $path = sanitize_title($content); $equipment … Read more

how to trace notice warning on core function is_page() & is_singular in class-wp-query.php

You can create your own custom error handler and add stack trace to your error log. set_error_handler(‘wpse_288408_handle_error’); function wpse_288408_handle_error( $errno, $errstr, $errfile, $errline ) { if( $errno === E_USER_NOTICE ) { $message=”You have an error notice: “%s” in file “%s” at line: “%s”.” ; $message = sprintf($message, $errstr, $errfile, $errline); error_log($message); error_log(wpse_288408_generate_stack_trace()); } } // … Read more

How to check If Oembed is empty or not

The wp_oembed_get() only works for supported oEmbed providers. The return value is also is a URL of false, as mentioned per codex: If $url is a valid url to a supported provider, the function returns the embed code provided to it from the oEmbed protocol. Otherwise, it will return false. Therefore, is the input is … Read more