Developing an IP lookup function using an API

You’d have to use add_rewrite_rule so you can capture your desired url match and pass it on query_vars Something like; add_action(‘init’, function() { add_rewrite_rule(‘ip/(.+)/?$’,’index.php?ip_search=$matches[1]’,’top’); }); add_filter( ‘query_vars’, function( $vars ) { $vars[] = ‘ip_search’; return $vars; }); dont forget to flush the rewrite rule once you added your own rule, change the permalink settings back … Read more

How can I add a zip code service availability checker in WordPress without Woocommerce? [closed]

This is much simpler version of your question: Given a list of strings, how do I check the user input is in that list? You don’t need a special service or fancy software to do that, just make a big list of the zipcodes you support and use in_array. const $supported_zipcodes = [ ‘zipcode1…’, ‘zipcode2…’, … Read more

How to handle Ajax Calls, when using same shortcodes (with different parameters, e.g. ‘post-type’)?

The problem is that your JS needs to know the post type for each shortcode, but rather than looking at the shortcodes output, it looks at the main global kne_ajax_object, and since there is only one kne_ajax_object, there can only be one post type. Additionally, your javascript code only runs one time, and only makes … Read more

Using variable as shortcode parameter

The shortcode function behind that shortcode will need to be able to accept an argument so it can return your variable in the expected place. If this is a custom shortcode function you wrote, you’ll have to make that adjustment. If its a third party shortcode, you’ll need to look at their documentation and see … Read more

Trying to insert a div ID link into Woocommerce shortcode Pagination

A certain chatty AI found me a solution. add_action( ‘wp_footer’, ‘custom_pagination_script’ ); function custom_pagination_script() { ?> <script type=”text/javascript”> jQuery( document ).ready( function( $ ) { $( ‘.page-numbers a’ ).click( function( event ) { event.preventDefault(); var link = $( this ).attr( ‘href’ ); window.location = link + ‘#d3c-psf-products’; } ); } ); </script> <?php } add_action( … Read more