Why jquery option is not working when pass value using wp_localize_script?

My first guess is that the values aren’t the correct “type”. Meaning you might be passing string values when the script expects integers, so try converting the values to integers first. jQuery(document).ready(function(){ var newsPerPage = parseInt( newsbox_parameters.newsPerPage ); var newsTickerInterval = parseInt( newsbox_parameters.newsTickerInterval ); jQuery(“.news_list”).bootstrapNews({ newsPerPage: newsPerPage, autoplay: true, pauseOnHover: true, navigation: false, direction: ‘down’, … Read more

2 wordpress site same database

I would look into using HyperDB instead. This would allow you to pull data from several databases while one is replicated as the “master” database. http://wordpress.org/plugins/hyperdb/ From the description page of the plugin: It supports: Read and write servers (replication) Configurable priority for reading and writing Local and remote datacenters Private and public networks – … Read more

Using conditional staements to load plugins

figured it out… The main problem with the scripts so just wrapped them in this for each plugin: function my_enqueue_javascript() { if (is_page(‘page’)) { //Include Javascript library wp_enqueue_script(”, plugins_url( ‘/js/ajax.js’ , __FILE__ ) , array( ‘jquery’ )); // including ajax script in the plugin Myajax.ajaxurl wp_localize_script( ”, ‘MyAjax’, array( ‘ajaxurl’ => admin_url( ‘admin-ajax.php’))); } } … Read more

Fetch CSS of posts

It is very unlikely that you will be able to duplicate a look of a wordpress page just by applying the CSS directly to the content as the CSS usually depends on the structure of the HTML containing the content and not only on the content itself. But fetching the CSS by itself is easy, … Read more

Using $wpdb in a plugin, what sort of data does it return?

Check out the codex on wpdb. In your case, get_row returns the first row of the result set as an object. There’s no need for any mysqli_* functions when using $wpdb. if ( $result2 ) echo json_encode( $result2 ); And a heads up for SQL injection – use the prepare method: $wpdb->get_row( $wpdb->prepare( “SELECT * … Read more

Generate Own Custom CSS Button with icon

What you are seeing is from a short code, a shortcode that does not exist anymore. Since you’ve changed themes and seeing this, it means that that shortcode is defined in your previous theme’s functions.php What you’ll need to do is, look at your previous theme’s functions file, and locate where the shortcode is defined. … Read more

Why AJAX response 0!

First, don’t enqueue on the init action. Enqueue on the wp_enqueue_scripts action for the front end, or the admin_enqueue_scripts action for the back end. Second, the wp_ajax_* action will only work for logged in users. For non-logged in users, you must use the wp_ajax_nopriv_* action instead. If it needs to work for both, then you … Read more

Calling a class method instantiated by ajax call in wordpress [closed]

You class method need to be static to be access without initializing the class or public in order to access from the class itself without reference &. And the variable $this->itemsClass also need to be public. So the workaround is – class Plugin { public $itemsClass; function __construct() { add_action(‘wp_ajax_list_items’, array( $this, ‘list_items’ )); } … Read more