How to keep track of when a vote is cast?

The following lines of code both store the IP address and time of vote, // $ip holds $_SERVER[‘REMOTE_ADDR’] $voted_IP[$ip] = time(); // Save IP and increase votes count update_post_meta($post_id, “voted_IP”, $voted_IP); The time a vote is cast is already being stored for you in the post_meta table for the given post the person is voting … Read more

Superfish Menu Not Loading

You might want to take a look at the wp_enqueue_script() documentation and modify your code to follow standard WordPress practice. Then look at your output and verify that your JS is being loaded.

JQuery prepend a function

The admin_menu hook is not for displaying the menu, it’s actually part of the menu construction process to figure out exactly what goes in the menu, and this is where you should be making calls to functions like add_submenu_page. So when this action is fired, nothing has been printed out yet, there’s no head/body tags … Read more

Adding numbers inside a span tag in nav menu [closed]

$(“#top .menu ul li”).each(function(i, el) { $(this).children(‘a’).prepend(“<span>” + (i+1) + “</span>”); }); or much better $(“#top2 .menu ul li”).each(function() { var $this = $(this); $this.children(‘a’).prepend(“<span>” + ($this.index()+1) + “</span>”); }); check this out for the difference… http://jsfiddle.net/reigel/aAYCt/

Sorting WP Auctions by date/price?

<a href=”https://wordpress.stackexchange.com/questions/77197/<?php bloginfo(“template_url’); ?>/auction_price.php”>Order by price</a> auction-price.php is inside the template directory. Then you can’t include wp-blog-header.php using require(‘./wp-blog-header.php’) inside template directory. Therefore do_shortcode() is not working without WordPress. The proper way to use ajax in WordPress is via admin-ajax.php Read More at Codex: http://codex.wordpress.org/AJAX_in_Plugins For example, in your functions.php: function wpse_77197_auction_price(){ echo do_shortcode(‘[wpa_list_widget mode=”list” … Read more

Showing All the Posts in the Loop

I created a fiddle for anyone that is interested HERE. Here is the javascript I used also to give the smooth scroll for an article container. // clicking the links in the article link container $(‘#article-links a’).click(function() { var $this = $(this); // save this instance of the click for access inside the loop // … Read more

Weirdness in jQuery supplied with WordPress

There is a difference with the version of jQuery supplied with WordPress as outline on the Codex page for wp_enqueue_script: Note: The jQuery library included with WordPress loads in “no conflict” mode. This is to prevent compatibility problems with other javascript libraries that WordPress can load. Change your script to reference the jQuery object with … Read more

Theme not calling Jquery properly

If you register a script with wp_register_script() it is not neccessary to pass all the options in wp_enqueue_script() again. You can register the script in a central place and use the enqueueing it in diffenrent files. functions.php wp_register_script( ‘theme_script’, ‘path/to/script.js’, array( [dependencies] ), ‘1.0’, true ); […] if ( $condition ) require_once ‘file1.php’; else require_once … Read more

wordpress widget missing jquery

Your first two problems: $ and jQuery is not defined. $ is just an alias for jQuery. Your first two problems are the same with different names. I think you do not write a plugin or a function in your functions.php. I think you put your code simply in the template file and expect that … Read more