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

Reusable Dynamic Taxonomy Shortcode

Ok, I figured out the solution and have it working to where I can swap out the attribute for the shortcode with any taxonomy available associated with every post type: function custom_taxonomy_list_shortcode( $atts ) { $atts = shortcode_atts( array( ‘term’ => ‘location’, //Set whatever default taxonomy you like ), $atts ); global $post; $custom_taxonomy = … Read more