Ajax call theme functions from front

I think that your problem is ajaxurl is not available for your script. Try to defined that varibale before your js code is loaded. The best way is using wp_localize_script: The PHP: add_action( ‘wp_enqueue_scripts’, ‘cyb_enqueue_scripts’ ); function cyb_enqueue_scripts() { //Change the key and url with yours wp_register_script(‘my-js’, get_stylesheet_directory_uri(). ‘/js/my-js.js’, array( ‘jquery’ ) ); wp_enqueue_script(‘my-js’); //Localize … Read more

WP_Remote_Get Not working

The very concept of HTTP API is to make sure transport will be done. It basically uses 5 different transport methods and it chooses the best one according to your server config. So it’s unlikely a compatibility issue with wp_remote_get() and your server. Plus if WP is not loaded, adding an action won’t help, it … Read more

Why is my Gutenberg block returning an error after initial save?

The main issue in your code is with these two attributes which use the exact same selector (the first span element in your block content): checkListItemOne: { type: ‘string’, source: ‘html’, selector: ‘span’ // same as below }, checkListItemTwo: { type: ‘string’, source: ‘html’, selector: ‘span’ // same as above } Which means the block … Read more

$user_id vs. is_user_logged_in()

Well it wouldn’t always work unless you global $user_id. is_user_logged_in will however work without that extra line of code. The speed improvement is most likely so small it’s less than the speed improvement between single and double quotes and not even worth thinking about. Also $user_id variable may disappear in a new version and would … Read more

How to break down importing of feeds

You can try using wp cron functions, programing a feed import every 10 minutes or so, until you have nothing left in queue. Example code: <?php register_activation_hook( __FILE__, ‘wp1903_schedule_cron’ ); function wp1903_schedule_cron() { $counter = 0; $feeds = array( ‘http://example.com/feed1’, ‘http://example.com/feed2’, ‘http://example.com/feed3’, ‘http://example.com/feed4’ ); foreach ($feeds as $feed) { $counter++; // schedule every 10 mins … Read more

Highlight Current Tag in wp_tag_cloud

When you are in a tag template, a body class is added with term-{termID}, so you can hook in “wp_generate_tag_cloud_data” to check if class is present and add custom class to the tag 😉 function tribalpixel_tag_cloud_class_active($tags_data) { $body_class = get_body_class(); foreach ($tags_data as $key => $tag) { if(in_array(‘term-‘.$tag[‘id’], $body_class)) { $tags_data[$key][‘class’] = $tags_data[$key][‘class’] .” active-tag”; … Read more

enqueue multiple Google fonts with multiple weights and styles (italic)

Adding Multiple Google fonts in WordPress Standard Way function adding_theme_css_js(){ wp_enqueue_style(“adding-google-fonts”, all_google_fonts()); } add_action(“wp_enqueue_scripts”,”adding_theme_css_js”); function all_google_fonts() { $fonts = array( “Open+Sans:400,300”, “Raleway:400,600” ); $fonts_collection = add_query_arg(array( “family”=>urlencode(implode(“|”,$fonts)), “subset”=>”latin” ),’https://fonts.googleapis.com/css’); return $fonts_collection; }