How can I loop at a Specific Taxonomy from a custom post type?
How can I loop at a Specific Taxonomy from a custom post type?
How can I loop at a Specific Taxonomy from a custom post type?
<?php $totalprice_posts = get_posts(‘post_type=items&author=”.$thisauthorID.”&tag=’.$thispostID.’&numberposts=-1′); $totalprice_array = array(); foreach ($totalprice_posts as $post) { $productprice = get_post_meta($post->ID, “productprice”, true); $productquantity = get_post_meta($post->ID, “productquantity”, true); $totalproductprice = ($productprice * $productquantity); array_push($totalprice_array, $totalproductprice); } echo implode(‘,’, $totalprice_array); echo array_sum($totalprice_array); ?
Hmm…i might be getting you wrong, but do you know that WP comes with an AJAX callback framework that helps you with this, making calling your own callback file unneccessary?
I believe that your best option would be to create a single field and save all values in an array, something like this: Create more Meta Boxes as needed.
You can’t use it as-is because it will get double-serialized. So as per comment you unserialize it first and it will get serialized back when saved into option. $array = unserialize( $stuff ); update_option(‘my_options’, $array);
Looking at your code it looks perfectly fine. Although the more complex you make your query the more resources it is going to take and the longer it is going to take. You mention that your CPU usage rises to 80% which would be normal but how long is the usage holding at 80%? If … Read more
I have a plugin, Custom Taxonomy Sort, that allows you to sort taxonomy terms in any order that you might want. After installing the plugin, there will be an order field for each term. It will save these values as integers and will properly sort your taxonomy terms. By default, it will use the order … Read more
On the Codex page for wp_list_categories(), you can see the two following arguments that might help you: hide_empty: Toggles the display of categories with no posts. The default is true (hide empty categories). current_category: Allows you to force the current-cat CSS class to appear on uses of wp_list_categories() that are not on category archive pages. … Read more
This should display 5 posts per page (-1 for all of them on one page), with the post ID’s $value1 and $value2 being ignored. Ensure $value1 and $value2 are integers. $args = array( ‘numberposts’ => 5, ‘posts_per_page’ => get_option(‘posts_per_page’), ‘paged’ => $paged, ‘post__not_in’ => array( $value1, $value2 ) ); query_posts($args); EDIT – With the further … Read more
If I understand your question correctly, you would like to get all metadata for “products” across all posts. In other words, multiple posts have metadata with key “products” and you want to get those values. If this is correct, you should use get_post_custom_values, which is well documented in the codex: http://codex.wordpress.org/Function_Reference/get_post_custom_values. As a side note, … Read more