WordPress Plugin development Call to undefined function jQuery()

You need specify jquery as a dependency of your custom script, setting the 3rd parameter of wp_enqueue_script() to array(‘jquery’), like this: wp_enqueue_script( ‘yourCustomScript’, plugins_url(‘js/yourCustomScript.js’, __FILE__), array(‘jquery’), ‘1.0.0’, false ); Change the path to point to your custom-script file As to your last question, the answer is affirmative. You need a .js file. Basically WP needs … Read more

Comment form vaildation

Ok, I’ve worked this out. You need to copy the complete first section of the `comment_form()’ from wp core. This is the code <?php function comment_form( $args = array(), $post_id = null ) { if ( null === $post_id ) $post_id = get_the_ID(); else $id = $post_id; $commenter = wp_get_current_commenter(); $user = wp_get_current_user(); $user_identity = … Read more

WordPress REST endpoint not able to reach with jQuery

First, lets fix your endpoint: function wpc_ylp_rest_videos( ) { $myObj->name = “John”; $myObj->age = 30; $myObj->city = “New York”; $myJSON = json_encode($myObj); echo $myJSON; } There are a few problems here: callbacks for REST API endpoints are meant to return their data, like shortcodes. The REST API does the JSON encoding, you’re not meant to … Read more

Appending anchor tag to next post

You can alter the links for next_post_link and previous_post_link with a filter. function alter_npppl_wpse_100919($link) { return preg_replace(‘/href=”https://wordpress.stackexchange.com/questions/100919/([^”]+)”https://wordpress.stackexchange.com/”,’href=”$1#something”‘,$link); } add_filter(‘next_post_link’,’alter_npppl_wpse_100919′); add_filter(‘previous_post_link’,’alter_npppl_wpse_100919′); The URL you get will be the default URL plus #content. If your site is generating /page/2/ then the final URL will be /page/2/#content. If you don’t want that trailing slash– the one before the … Read more

JS completely stopped loading but Files are found

You’re testing if it’s NOT the home page (your news page) before outputting your block of javascript, so your quicksand code never gets output to page: if (!is_home() || !is_front_page()) { I don’t see any code anywhere that creates the nivo slider. This block needs to reference jQuery, not $: $(document).ready(function(){ $(“.anyClass”).jCarouselLite({ auto: 800, speed: … Read more

Script dependencies for post.js

Because of the dependency handling built into the script registration system you should only need … wp_enqueue_script(‘post’); … to load all of the required scripts, which is exactly what the Core does. But just loading the scripts isn’t going to make everything work. That form is actually loaded by wp-admin/post.php, which requires wp-admin/admin.php which includes … Read more

WordPress Google Maps in Custom Theme

Enqueue your script and use wp_localize_script to pass data. function wpd_scripts() { wp_enqueue_script( ‘wpd_script’, get_stylesheet_directory_uri() . ‘/js/script.js’, null, null, false ); wp_localize_script( ‘wpd_script’, ‘WPD’, array( ‘stylesheet_dir’ => get_stylesheet_directory_uri() ) ); } add_action( ‘wp_enqueue_scripts’, ‘wpd_scripts’ ); You can then use WPD.stylesheet_dir in your script to get the value you set in PHP. var marker_url = WPD.stylesheet_dir … Read more