Tag Info

New answers tagged

0

I'd prefer to set this as a comment, but I can't due to my low reputation. In your processing code, try: function returnHash() { if (isset($_POST["flavors"])) { $flavors = json_decode($_POST["flavors"], true); print_r($flavors); } else { echo 'Not Set'; } die(); } add_action('wp_ajax_returnHash', 'returnHash'); ...


0

Filtrify doesn't actually use AJAX to get a new data set, it simply hides all of the elements which don't match your current filter. Because you already have a page displaying all books (for example) you are already pretty well set up to use Filtrify. The only extra step that you need to take is to add the data-genre attribute to each of your books (or ...


0

Wordpress and AJAX. First, you have to register and action, and link that action to a PHP function. In that function, you can use a custom WP_Query to return the posts for each genre. You will need to use javascript to create the avascript function executed when someone clicks and option from the dropdown, that function has to make a call to the action ...


1

I think you're looking for gform_enqueue_scripts which is simply a Gravity Forms specific version of the wp_enqueue_scripts hook. Either hook uses the wp_enqueue_script() function. That function can take a local script—usually using get_template_directory_uri() (theme), get_stylesheet_directory_uri() child theme), or plugins_url() (plugin) to reference the ...


0

Drop this into the file that is displaying the date (assuming you are using get_the_date): $month = date( 'F' ); $categoryIds = array(); $bannedMonth = 'September'; $bannedCategory = 13; $categoryArray = get_the_category(); foreach ( $categoryArray as $categoryObj ) { array_push( $categoryIds, $categoryObj->term_id ); } if ( $month != $bannedMonth ...


0

You are gonna need a PHP code like this, you can add it to the functions.php, or I would recommend creating a plugin. add_action('wp_ajax_nopriv_action_name', 'ajax_function'); add_action('wp_ajax_action_name', 'ajax_function'); function ajax_function(){ $post = get_post($_POST['post_id']); $response = array("content"=> apply_filters('the_content', ...


0

I think there is a 'more reliable' option. Relying on the menu item number is not garanteed to work if you migrate your code from development to production for example. If you turn the number into a setting it is getting better, but still not really good. An alternative could be to link to a non-existent anchor, like #olark, from your menu-item. This can be ...


1

You should solve your problem while moving toward a best practice while you're at it by using wp_enqueue_script(). This will likely solve your issues because it's domain agnostic. Start by moving your JS file(s) to a /js/ folder in your [child] theme or custom plugin. Then load your script like this... (snippets copied and adpated from Codex page). Theme ...


0

There is a item over these select boxes. In you css file search for element.style and remove it's position: relative; property. element.style { bottom: 0; left: 0; position: relative; top: auto; } That will fix this issue.


0

There are a few things going on with your functions.php file that may be the issue. You should be using wp_enqueue_scripts action to enqueue your script. The first parameter of wp_localize_script() should match the id of the file you've enqueued. You also need to add a no_priv version for your Ajax call if it needs to work for non-logged in users. Have a ...


0

Are there any Console js errors? The admin-ajax.php is Wordpress's built in way of dealing with ajax so you should probably do something like this, assuming .get() would also work: $.post(ajaxurl, data, function(response) { alert('Got this from the server: ' + response); }); http://codex.wordpress.org/AJAX_in_Plugins


0

Fixed: I have do it the right way, all the time. Now i found, that jquery was deregistered at the themes header.php file. I have deleted it and it works now.


4

Note that if any script in the header at all needs jQuery then it will bump it to header, regardless if it's changed to be enqueued for footer. So while changing it to be queued for footer makes sense it rarely works out when a lot of script stuff is going on.


-1

<?php function your_function() { echo '<p>This is inserted at the bottom</p>'; } add_action('wp_footer', 'my_function'); ?> You can use this hook. This is used to load the script in the footer try it let me know for any doubts.


1

Here is the problem If you try to register or enqueue an already registered handle with different parameters, the new parameters will be ignored. Instead, use wp_deregister_script() and register the script again with the new parameters. You will have to deregister jquery first, the register it again, but becareful because the empty string isn't ...


0

I am using this code, i Hope it helps you. function defer_parsing_of_js ( $url ) { if ( FALSE === strpos( $url, '.js' ) ) return $url; if ( strpos( $url, 'jquery.min.js' ) ) return $url; return "$url' defer='defer"; } add_filter( 'clean_url', 'defer_parsing_of_js', 11, 1 );


3

the console is firing this error: TypeError: $ is not a function Could be a few things: WordPress loads jQuery in no-conflict mode so you may need to use jQuery instead of $ when making your selections jQuery('your-selector) Be sure that jQuery has loaded before you set your interval. Based on what I can see you may be trying to access if before ...


2

Try to remove this from footer.php <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.1/jquery.min.js"></script> And One tip: Use wp_enqueue_script to load all JS on your web page.


6

You're mixing up the singular wp_enqueue_script, which adds a script, with the plural wp_enqueue_scripts which is an action and a function that triggers that action. I think you want function theme_scripts() { wp_enqueue_script( 'custom-script', get_template_directory_uri() . '/js/menu-fix.js', array('jquery'), '1.0', true); } ...


1

The dependencies are case-sensitive - you need array( 'jquery' ) (no uppercase Q).


0

You're removing the current menu item, and current menu page, however your CSS refers to these: .site-navigation li .current_page_item > a, .site-navigation li .current_page_ancestor > a, .site-navigation li .current-menu-item > a, .site-navigation li .current-menu-ancestor > a .current_page_ancestor and .current-menu-ancestor are not handled ...


0

Based on what I can see, it looks like your calling the create_map function incorrectly. add_shortcode() takes 2 parameters, the name of the shortcode and the function that gets rendered when called. The array you are passing is how to call a method inside of a class. You're basically saying call the create_map method from the hotSpot class. Assuming this ...


1

How to get a notification via Javascript when the left menu bar has been collapsed ? If you are taking about the admin menu bar and you want to get a notification when the that is closed and expanded, then watch thoroughly that, when admin menu bar is collapsed, a folded class is added to the body. You can get any notification according to that.


0

First of all the ajax code in WordPress is different from the normal ajax. Second, you don't add a Javascript into a function, however, it's a better practice to create a JS file and enqueue it. Here is how to do it: JS file: jQuery(document).ready(function($){ $('#input_1_2').change(function(){ jQuery.ajax({ ...


1

Do not use an external jQuery library, use the one that comes with WordPress. Use wp_enqueue_script to enqueue your scripts, like: wp_enqueue_script( 'jquery' ); Additionally be aware that WordPress sets the internal jQuery to noConflict() mode, more information about that here.


1

id="mySlide"is used twice in your markup. Just try removing slideExpr: '#mySlide' from your plugin options. Try using bloginfo('stylesheet_directory').



Top 50 recent answers are included