Tag Info

New answers tagged

0

I'd recommend installing a infinite scrolling plugin and just take a look at how they're doing it. Jetpack for example would be a good start since it's maintained by the WordPress authors or the plugin by Paul Irish, as Jordan has mentioned. https://wordpress.org/plugins/jetpack/ https://github.com/paulirish/infinite-scroll It's hard to help you otherwise ...


0

You would save the Ajax response to the database. Here are a few tutorials that might be helpful: Tutorial on Using Ajax in Wordpress Plugins How to Use Ajax for Data Insertion in WordPress How to Insert Data into Database using Ajax


-1

<script type="text/javascript"> var a = <?php echo $a=1; ?> // OR var a = <?php global $a; echo $a; ?> </script> We can directly use PHP variable in javascript as i showed in example If your php code and javascript code in same page then you can use first approach. Else your php code in different page and included it in current ...


0

i finally know why this code not work. as menstioned by Jorn Lund in the comment that jQuery(document).ready() will fail when script loaded async ( i still dont know is my code load async) but with in mind i change from jQuery(document).ready() to self execution function (function($){ alert("hello"); })(jQuery); and the code work very well on ...


0

I found that it was better for me to use the latest jQuery version (which WordPress loads by default) and to treat the incompatibility issue by modifying the JS plugin files that were incompatible with the latest jQuery version. Note: The reason I chose this solution is because in most cases, JS plugin incompatibility with newer jQuery versions is a result ...


0

It seems like you are following the tutorial from tutsplus "Slider to Your WordPress Theme" Coding looks correct but as @cybmeta already mentioned in the comment you need to set Featured Image for each slide to display in the slider properly. Details for Featured Image here also


1

Actually. This answer is the only correct answer. If you need jQuery for a certain script just add it as necessary in the jQuery array. wp_register_script( 'ytc-admin-scripts', YTC_URL . 'admin/admin-functions.js', array( 'jquery','jquery-ui-slider' ), '1.0');


1

If you want your code to look good you should properly format it first. Aside from that you are able to combine your AJAX (or to be exact your jQuery/javascript) into one block. Actually you should put it in a separate javascript file, but you can read all about that on the AJAX in Plugins on the Codex page (from where you got your code anyway) or in the WP ...


0

Update ... Here's the Final Code That Worked for Me This may not be perfect, but it seems to be working well for me with no errors. Feel free to add any suggestions for improvement if you have any. JS Code jQuery(document).ready(function($) { var count = 2; jQuery("#la-chooser").change(function() { loadArticlebyCat(this.value); }); ...


0

Your syntax for passing the settings array is incorrect and also you have not specified the name for the textarea in the settings array which is why it returns you an empty alert. Syntax from WordPress Codex: wp_editor( $content, $editor_id, $settings = array() ); $content (string) (required) - Initial content for the editor $editor_id (string) ...


1

Solved it by using a modal box instead of metabox, forcing the users to finish editing the plugin data, before submitting the regular changes to WP. //add_action( 'add_meta_boxes', array( $this, 'add_custom_metabox' ) ); add_action( 'media_buttons_context', array($this, 'add_custom_media_buttons' ) ); add_action( 'admin_footer', array($this, ...


1

As you mentioned in the comment, inside-context paragraphs will be just next to clicked anchor's parent, this code will work: $(".btn-context").on('click', function (event) { event.preventDefault(); $('.inside-context').removeClass('open'); $(this).parent().next('p.inside-context').addClass('open'); });


0

If I understand correctly you need the original form to display the values of what has just been posted. You also need the table to display 0 on values that haven't been calculated. At the moment the table calculates information perfectly with a submit refreshing the page. You can use the if(isset($_POST["fieldname"])){ variable you have above to do ...


1

ajaxSubmit isn't a core jQuery function. It seems that you have to either include a jQuery Plugin (like this), or rewrite your function to use a syntax like this one, using jQuery post() $.post(ajaxurl, data, function(response) { // responsefunction } or with the jQuery ajax() $.ajax({ url: ajaxurl, context: data }); Be sure that you have ...


0

You can get by post page id if (has_post_thumbnail($page_id) ): $image = wp_get_attachment_image_src( get_post_thumbnail_id($page_id), 'page-post-thumbnail' ); endif; $image_URI = $image[0]; echo $image_URI inside image src.


1

To translate something in your js you can use wp_localize_script() really handy : $translation_array = array( 'some_string' => __( 'Some string to translate' ), 'a_value' => '10' ); wp_localize_script( 'some_handle', 'object_name', $translation_array );


2

The jQuery library packed with WordPress, operates under noConflict mode. Means you can not use $ in your jQuery snippet/code. Either use jQuery instead of $. or use noConflict wrapper like this. <script type="text/javascript"> <!-- jQuery(document).ready(function($) { // your jquery function, you can use $ here. }); // ...


1

You could also remove all the breaks in your code. For example of: Instead of: function() doSomething() { //code goes here } Do something like this: function() doSomething() {//code goes here} Its annoying but it will allow you to still use WordPress' text editor.


4

The post editor is really not meant for inserting functional code like JavaScript into the page. Anything you put through the post editor will get run through wpautop() before output, which is what adds the paragraph tags -- even if you enter it via the Text mode. I'd suggest outputting your JavaScript via a hook on the page instead of via the post editor. ...



Top 50 recent answers are included