Tag Info

New answers tagged

0

To all of you struggling to get custom scripts running from functions.php, here's how: WP v4.1.2 Th post is a custom template post I needed to load 3 JSs - parsleyjs.js, he.js (i18n), custom_JsScript.js I also wanted to have the CSS on a separate file Only load these for a specific post function donate_adding_scripts() { if (is_singular()) { global ...


0

What if you completely remove the loadDonateScripts function and just add the conditional before enqueuing the scripts like in the the following: function donate_adding_scripts() { if (is_single()) { global $post; if($post->ID=="8436"){ // only for post Id = 8436 wp_register_script('donateParsleyJs', get_template_directory_uri() . ...


1

jQuery is already loaded with WordPress, so you won't need <script src="//ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script> When using jQuery with WordPress, you'll likely require no-conflict wrappers : https://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_Wrappers There are likely JS errors ...


2

It's not showing because the .insertAfter() and .show() functions are called on resize events only, while mobile devices do not resize. They already load the page with their mobile sized. Just make sure you also run the code on the ready event: <script type="text/javascript"> /* to show back the left side bar back when the LEFT side bar is moved ...


0

The problem is not with the CSS but with HTML, the span element for percentage is nested within the overall discounts span class which has the days. So when you move discounts, it will move the whole container. Change the HTML code from this: <span id="discount4" class="discounts" style="display: block;"><br> 30% <span class="green">| 5PM ...


0

$('.follow-links a').toggle(); should be $this.toggle();.


0

Ahh, solved it with this! add_action( 'wp_head', 'jQuery_UI_Tabs' ); function jQuery_UI_Tabs() { if ( is_page_template('course-landing-page.php' ) ) { echo'<script> $(function() { $( "#tabs" ).tabs(); }); </script>'; }


0

If you're releasing this as a plugin, you absolutely must use the AJAX API. It's super easy: /** * Handle the request and return the result. */ function alumni_process_request() { global $wpdb; // All your processing code from your original question, except for loading WordPress! return $data; } /** * AJAX handler for the "alumni" action. ...


0

This may not be the exact answer to the problem. But it helped me to solved the very problem we are discussing. As using 'transport' => 'postMessage', I was not able to see previews lively. So I created new files using the following code at Github I just copy pasted this code. Verified it and then tweaked it according to my requirements. I know this is ...


0

I tried to get my head around this yesterday and I came pretty close solving this issue. But i gave up in the end, cause it was getting too complicated, when start thinking about all the tools, that you want to include/exclude. If you still wanna do this on your own, these two filters are your friend: attachment_fields_to_edit & ...


1

Try to add the code to the footer using add_action('wp_footer', 'front_js', 99); where 99 specifies the order in which the functions are executed. Now it should be executed after your scripts are loaded.


0

Instead of putting the code in function and hooking it to wp_footer. You can have another JS file stored in your plugin folder and enqueued it like other scripts you enqueued. OR <?php function front_js() { if ( wp_script_is( 'jquery', 'done' ) ) { ?> <script type="text/javascript"> $(document).ready(function(){ ...


0

Your code should be in an action callback function: function wpse186202_enqueue_scripts(){ wp_enqueue_script( 'stats', get_stylesheet_directory_uri() .'/js/t5-demo.js' , array( 'jquery' ), '1.0.0', true ); $categories = implode( ', ', wp_list_pluck( get_the_category( get_the_ID() ), 'name' ) ); $datatoBePassed = array( 'author' => ...


0

thanks alot @Antonie Guillien, it solved :D var $j = jQuery; function testClick(){ alert('Button Clicked'); } $j(document).ready(function() { /*$j('.my-button').click(function(){ alert('Button Clicked'); })*/ })


0

Unsure of WP version compatibility, but taken from the Soil plugin module clean-up.php for Roots. Use in your theme's functions.php or similar. function clean_script_tag($input) { $input = str_replace("type='text/javascript' ", '', $input); return str_replace("'", '"', $input); } add_filter('script_loader_tag', 'clean_script_tag');


0

The correct way of refreshing the content of the frame, as found in the WP core, is as below: if(wp.media.frame.content.get()!==null){ wp.media.frame.content.get().collection.props.set({ignore: (+ new Date())}); wp.media.frame.content.get().options.selection.reset(); }else{ wp.media.frame.library.props.set({ignore: (+ new Date())}); } You should ...


0

The comment form is generated from another domain via the iframe. While I was accessing the iframe using jQuery content() it returned me Permission denied to access. It means the Jetpack is Cross Site Scripting protected and you cannot edit the placeholder.



Top 50 recent answers are included