Fastest way to loop through all posts?

“The Loop” is just a name given to the while (have_posts()): the_post(); loop used to iterate over an array of posts returned by WP_Query(). The other function used for querying posts is the get_posts() function, which returns a simple (non-extended) array which you can loop through with a foreach loop. I don’t think it matters … Read more

How to include admin-ajax when loading external javascript

What you need to do is register and/or enqueue your script and then use wp_localize_script to include a Javascript variable on your page. The Codex page has this example: wp_enqueue_script( ‘some_handle’ ); $translation_array = array( ‘some_string’ => __( ‘Some string to translate’ ), ‘a_value’ => ’10’ ); wp_localize_script( ‘some_handle’, ‘object_name’, $translation_array ); You can then … Read more

Sidebar Generator issue [closed]

the best option here if you want to use a plugin is to use the woo sidebars plugin which is from from woo themes, its also packaged in their free plugin woo dojo which has several free plugins, if your good with options framework by devin or smof and don’t mind using cmb meta boxes … Read more

How to remove action from plugin?

You want: remove_action(‘um_post_registration_approved_hook’, ‘um_post_registration_approved_hook’, 10, 2); … to run after the original add_action, but before the action triggers the function um_post_registration_approved_hook The easiest way to do this, but I haven’t tested it, might be to just give your removal an earlier priority on the same hook: add_action( ‘um_post_registration_approved_hook’, ‘remove_my_action’, 9 ); function remove_my_action(){ remove_action(‘um_post_registration_approved_hook’, ‘um_post_registration_approved_hook’, … Read more

How to make a plugin auto-add item to nav menu

this is the general gist of what you need to do, you’ll want to add some checks in here, make sure you get a valid menu returned, etc.. $locations = get_theme_mod( ‘nav_menu_locations’ ); $menu = wp_get_nav_menu_object( reset( $locations ) ); // get first item in menu locations array $menu_item_data = array( ‘menu-item-object-id’ => $your_page->ID, // … Read more

WooCommerce – Display product child categories from specific parent

The woocommerce function get_categories() is declared in abstract-wc-product.php, because it is based on the wordpress function get_the_term_list() there is no way to get only a specific branch of a category. This absolutely isn’t the same as the wordpress function get_categories(), you can see that it is woocommerce specific by how it’s used $product->get_categories(). Besides the … Read more