WordPress Categories in data-groups
Just remove the trailing comma with some good ole php before echoing it out. $thelist = rtrim($thelist, ‘,’);
Just remove the trailing comma with some good ole php before echoing it out. $thelist = rtrim($thelist, ‘,’);
In my opinion, you should avoid using common words like “images”. It can be confusing for the system. A previous post on SO nailed the use of images using Category ID. Here’s your edited code: <?php $your_category_ID = ‘1’ $query = new WP_Query( ‘cat=$your_category_ID’ ); if ( $query->have_posts() ) { while ( $query->have_posts() ) : … Read more
I got it to work by doing it this way if (is_admin() ){ $post_id = isset($_GET[‘post’]) ? $_GET[‘post’] : isset($_POST[‘post_ID’]) ; if( $post_id && in_category(‘audio’, $post_id) ){ add_action(‘admin_init’, ‘add_meta_boxes’, 1); } } The only problem with this method is that it won’t display the metabox until after you have published the post. The $post_id variable … Read more
In WordPress 4.1.1 at least, In the Menu editor, Categories > View All Tab shows empty categories.
As already stated, you should never use query_posts as it breaks the main query and many functionalities that other code and plugins rely on Note: This function isn’t meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is overly simplistic and … Read more
Try the code below. This is the Reference: WP_Query <?php $args = array( ‘post_type’ => ‘page’, ‘posts_per_page’ => 10, ‘category_name’ => ‘mycat’, ‘fields’ => ‘ids’ ); $data = get_posts($args); print_r($data);
The simple and quickest solution is showing categories list by using sitemap plugin with short-code. For example this plugin WP Sitemap Page. Install it and place shortcode on page. Second option is create page template for category list. Using wp_list_categories() Thanks
it’s been a long time, I had exact the same task and here is the solution $from = ($query->query_vars[‘posts_per_page’] * $paged) – ($query->query_vars[‘posts_per_page’] – 1); if(($query->query_vars[‘posts_per_page’] * $paged) <= ($query->found_posts)){ $to = ($query->query_vars[‘posts_per_page’] * $paged); }else{ $to = $query->found_posts; } if($from == $to){ $from_to = $from; }else{ $from_to = $from.’ – ‘.$to; } It’s not … Read more
0 isn’t a valid term ID in a tax query. Don’t add the category tax query parameters if the value is 0, which is equivalent to ignoring category. If you want only posts that are categorized (a category must be assigned, but it can be any category), then use the EXISTS operator. $tax_query = ”; … Read more
I don’t know if ther’s something similar to posts_per_category or “cat” => array( “5” => array(“posts_per_page” => “3”), but you can do it with conditionals, if you form an array with the posts ids. The problem I can see, is that you have to query all posts or set a limit by date for example, … Read more