AJAX search as you type? [duplicate]

I have developed an ajax search plugin a few weeks ago. There is a free version available at the wordpress plugin repository. Feel free to explore the source code 🙂 You can find it here: Ajax Search Lite There is also a commercial version, maybe you are interested: Ajax Search Pro You can check out … Read more

options creation for plugins

There are some functions associated with manipulating the variables found in the wp_options table. add_option(): Create a new value in the table. Example add_option(‘var_name’, ‘value’) will store option_name=”var_name” and option_value=”value”. add_option() is used only when saving a value for the first time. Has an autoload parameter. get_option(): Retrieve that value. Example: get_option(‘var_name’) will return the … Read more

Count posts by type including drafts and pending posts

It’s not necessary to use $wpdb, a simple get_posts can handle it. Check WP_Query for the full list of parameters. function count_user_posts_by_type( $userid, $post_type ) { $args = array( ‘numberposts’ => -1, ‘post_type’ => $post_type, ‘post_status’ => array( ‘publish’, ‘private’, ‘draft’, ‘pending’ ), ‘author’ => $userid ); $count_posts = count( get_posts( $args ) ); return … Read more

Custom Permalink Plugin and Current Page/Ancestor in Menus

You could add classes to wp_nav_menu via the nav_menu_css_class filter: function wpa83498_nav_class( $classes, $item ){ // if Shop is the current menu item being output // and we’re viewing a single product post type if( ‘Shop’ == $item->title && is_singular( ‘product’ ) ) $classes[] = ‘current-page-ancestor’; return $classes; } add_filter( ‘nav_menu_css_class’, ‘wpa83498_nav_class’, 10, 2 ); … Read more

Execute js files doesn’t seem to work

Just hook to wp_enqueue_scripts for both registering and enqueueing. You’ve registered with in_footer (last parameter in your code) true so what you need is: function print_my_royal_slider_script() { global $add_my_script; if ( ! $add_my_script ) return; wp_enqueue_script(‘my-script’); } add_action (‘wp_enqueue_scripts’, ‘print_my_royal_slider_script’); The problem is going to be with $add_my_script. That has to be set before wp_head … Read more