Use Shortcode on Custom Page

You should this way to handle ajax request. It’s the recommended way to make a ajax call in WordPress. my_function.js Update your jquery with this code. jQuery(document).ready(function($) { $(‘#submit_payment’).click(function(e){ e.preventDefault(); var str = $(“form[name=season-form]”).serialize(); //alert(str); $.ajax({ type: “POST”, url: ‘//www.example.com/wp-admin/admin-ajax.php’, data: str + ‘&action=confirmRequest’ }).done(function(data){ $(“#result”).html(data); }); }); }); ajax_request_handling Paste this in functions.php of … Read more

How can I extract or parse data from post contents’ shortcodes into an array?

Not really a WordPress question, but you can use the PHP function preg_match_all to extract all the text wrapped in [cs_text] tags like so: function wpse_265295_extract_cs_text( $subject ) { $pattern = “#\[cs_text\](.*?)\[/cs_text\]#s”; preg_match_all( $pattern, $subject, $matches ); return isset( $matches[1] ) ? $matches[1] : []; } If you’re looking to extract arbitrary shortcodes: if( ! … Read more

Check if Page=current user page via shortcode

I don’t know how you are assigning a page to the user, however you can develop a short-code as following: <?php function myFunction() { if({condition check}) { /*do ur stuff */ } else { /*do ur stuff */ } } add_shortcode(‘your_shortocde_string’, ‘myFunction’); ?> Define the function in functions.php You can call by using shortcode [your_shortcode_string] … Read more

Use ACF array values in shortcode

$atts[‘form_id’] contains the form_id that was passed with the Shortcode. You are searching for this form_id among the data that is held in the forms field. $forms is an array, and each item in the array is another array with your two keys: form_id and form_markup. So, for each item in $forms, you want to … Read more

Get not the full path

You might want to use the media_media_sideload_image() function. This function will fetch an image from a URL and upload it for you. Take a look into this custom function: function upload_image_from_url($image_url, $post_id, $title) { $img_name = basename ($image_url); global $wpdb; $query = “SELECT post_id FROM {$wpdb->postmeta} WHERE meta_value=”$img_name””; $id = $wpdb->get_var($query); if (is_numeric($id)) { return … Read more