JS behavior differs depending on page tree [closed]
I fixed it by including the JS files in the header, so there’s an error in another plugin’s JS that’s causing the issue.
I fixed it by including the JS files in the header, so there’s an error in another plugin’s JS that’s causing the issue.
I’m not good at this, but it could be because Cufon is not included in WordPress? So, you are deregistrating a script that is not included.. http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_scripts_included_with_WordPress
You won’t be able to do it purely with Javascript (with or without jQuery) as the images are hosted server-side, and there’d be no way for a Javascript function to scan to see what’s available. What you could do is write a function to do it in functions.php and tie it to a shortcode, but … Read more
You must output the propper HTML to make it working. Specifically, the href-attribute needs to contain the URL and the title separated with the | sign, like <a href=”http://example.com/post-url|post-title” rel=”shareit” …. That will enable the script you’ve posted above use a concrete URL and title. As I don’t know you PHP code from your theme … Read more
Jquery is my favorite js library anything you can think of already has a plugin, in your case check out jQuery AlphaNumeric http://www.itgroup.com.ph/alphanumeric/
Here you go. add_action(‘init’, ‘register_custom_jquery’); function register_custom_jquery() { wp_deregister_script(‘jquery’); wp_register_script( ‘jquery’, ‘https://ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js’, array(), ‘1.6.1’ ); wp_register_script( ‘my-custom-script’, ‘http://example.com/js/script.js’, array(), ‘1.0’ ); } add_action(‘wp_enqueue_scripts’, ‘add_js_to_page’); function add_js_to_page() { wp_enqueue_script( ‘jquery’ ); wp_enqueue_script( ‘my-custom-script’ ); }
Your code is technically correct, though you should be doing ajax calls via the WordPress provided means. Also, your path to ajax-php.php will fail if WP isn’t installed in root. What does ajax-php.php contain and what are you expecting it to return? If you’re trying to use WordPress functions inside of that file, you need … Read more
I coded this up quickly, based on Scribu’s writeup on script loading, might work for you or provide a starting point. The plugin file: <?php /* Plugin Name: MO_expander_shortcode */ class MO_expander_shortcode { static $add_script; function init() { add_shortcode(‘moexpander’, array(__CLASS__, ‘handle_shortcode’)); add_action(‘wp_footer’, array(__CLASS__, ‘add_script’)); } function handle_shortcode($atts, $content = null) { self::$add_script = true; // … Read more
You want to use wp_enqueue_scripts, but you’ll probably first want to: Loop through the Posts Grep your shortcode Enqueue the script, if shortcode is found Rewind Posts That way, you only enqueue the script where necessary.
i always start every theme w/ some constants ` define(‘THEME’, get_bloginfo(‘stylesheet_directory’)); //or you could use this one: //define(‘THEME’, get_stylesheet_directory_uri()); define(‘IMAGES’, THEME . ‘/images’); ` and some others, but the point is that at any place in my code i can point to my theme’s image folder img src = “https://wordpress.stackexchange.com/questions/21398/<?php echo IMAGES .”/image.png’;?>”