Need to turn this php into WP shortcode

Init your shortcode add_shortcode(‘shortcode_ald_crp’, ‘myshortcode_echo_ald_crp’); The function what you want: function myshortcode_echo_ald_crp() { ob_start(); if ( function_exists( ‘echo_ald_crp’ ) ) echo_ald_crp(); return ob_get_clean(); } you call you shortcode in a post like this: [shortcode_ald_crp] Or into the php code: echo do_shortcode(‘[shortcode_ald_crp]’); UPDATE Change the function add_shortcode shortcode_ald_crp for myshortcode_echo_ald_crp

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

Output custom post shortcode. Help spot the error.

You’re resetting the value of $output each time you go through the loop: foreach ($row as $post) { // etc. $output=”<div class=”col-md-6 event-item”>”; // Here $output // etc. } That $output assignment is resetting the value of $output to ‘<div class=”col-md-6 event-item”>’, throwing out everything that had been appended to it. You’re also returning $output … Read more