How to check if I’m on the last page of posts?

The WP_Query object contains a max_num_pages field which contains how many pages of posts there are. You can compare the current page number with it. (This is how get_next_posts_link() does it.) global $wp_query; $current_page = $wp_query->get( ‘paged’ ); if ( ! $current_page ) { $current_page = 1; } if ( $current_page == $wp_query->max_num_pages ) { … Read more

Is there an easy way to make a meta box have the tabs like the Categories meta box has?

Here’s a very basic example.. /* Code assumes it will be in the theme functions.php file Update the enqueue path if using it elsewhere */ add_action( ‘add_meta_boxes_post’, ‘add_post_metabox’ ); function add_post_metabox() { wp_enqueue_script( ‘mytabs’, get_bloginfo( ‘stylesheet_directory’ ). ‘/mytabs.js’, array( ‘jquery-ui-tabs’ ) ); add_meta_box( ‘examplebox’ , __(‘Example box’), ‘my_example_metabox’, ‘post’, ‘side’, ‘core’/*,array()*/); } function my_example_metabox() { … Read more

Display All Products by Category with WooCommerce

Figured it out! The code below automatically lists all categories and each categories posts! $args = array( ‘number’ => $number, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘hide_empty’ => $hide_empty, ‘include’ => $ids ); $product_categories = get_terms( ‘product_cat’, $args ); $count = count($product_categories); if ( $count > 0 ){ foreach ( $product_categories as $product_category ) { … Read more

How To Get Parent Category Slug of Current Post

You will need to use the ID value returned by $category[0]->category_parent and pass it through get_term(). Example: $category = get_the_category(); $category_parent_id = $category[0]->category_parent; if ( $category_parent_id != 0 ) { $category_parent = get_term( $category_parent_id, ‘category’ ); $css_slug = $category_parent->slug; } else { $css_slug = $category[0]->slug; }

Get posts from sites in Multisite?

The WordPress function switch_to_blog() expects an integer as an input parameter. You can read more about it in the Codex: http://codex.wordpress.org/Function_Reference/switch_to_blog Please try this kind of structure instead: // Get the current blog id $original_blog_id = get_current_blog_id(); // All the blog_id’s to loop through $bids = array( 1, 2 ); foreach( $bids as $bid ) … Read more

Get the children of the parent category

You can’t just pass the string “parent” to get_categories. You have to pass the ID of the parent. $categories=get_categories( array( ‘parent’ => $cat->cat_ID ) ); Notice that there are two similar but not equal “get child” parameters that you can use. child_of (integer) Display all categories that are descendants (i.e. children & grandchildren) of the … Read more

WordPress Multisite – global categories

function __add_global_categories( $term_id ) { if ( get_current_blog_id() !== BLOG_ID_CURRENT_SITE || ( !$term = get_term( $term_id, ‘category’ ) ) ) return $term_id; // bail if ( !$term->parent || ( !$parent = get_term( $term->parent, ‘category’ ) ) ) $parent = null; global $wpdb; $blogs = $wpdb->get_col( “SELECT blog_id FROM {$wpdb->blogs} WHERE site_id = ‘{$wpdb->siteid}'” ); foreach … Read more

Only one category per post

Actually, I wrote a plugin for exactly that. http://wordpress.org/extend/plugins/radio-buttons-for-taxonomies/ In the plugin settings you define which taxonomies you’d like to apply this restriction to.

deneme bonusu veren sitelerbahis casinomakrobetceltabetpinbahispolobetpolobet girişpinbahis girişmakrobet girişpulibet girişmobilbahis girişkolaybet giriş