How to run ajax in WordPress Post?

I believe one of the comments should fix your issue given how you mentioned that the code works outside of WordPress, which does in fact appear to be a problem with your references to $ instead of jQuery. Also, i have written a post on this exact topic with step by step instruction, you can … Read more

Active class for my flexslider in WordPress

This code here is the problem- $(‘.slider-menu li’).on(‘click’, function(e) { e.preventDefault(); var slide_index = $(‘a’, this).attr(‘href’).substr(6) – 1; $homeSlider.flexslider(slide_index); return false; // IE9 hack }); In your html, you’re setting your IDs to slide plus the attachment ID, then telling flexslider to animate to that slide. Except flexslider is expecting a slide position (1st slide, … Read more

How to add a custiomized javascipt into a template

Register the script first, then ask WP to enqueue it : function add_my_script() { wp_register_script(‘av_s’, get_template_directory_uri() . ‘/js/av_s.js’, array(‘jquery’)); wp_register_script(‘jquery’, ‘//ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js’, array(‘jquery’),’1′, true); wp_enqueue_script(‘av_s’); wp_enqueue_script(‘jquery’); } add_action( ‘wp_enqueue_scripts’, ‘add_my_script’ ); Returns in <head>: <script type=”text/javascript” src=”https://wordpress.stackexchange.com/questions/184882/{sitename}/wp-content/themes/twentytwelve/js/av_s.js?ver={version}”></script>