Dealing with variables with gettext function

You could just rename the labels associated with that post type. class News_Post_Type { const POST_TYPE = ‘post’; public static function init() { $post_obj = get_post_type_object(‘post’); $post_obj->labels->name = __(‘News Post’, ‘textdomain’); $post_obj->labels->singular_name = __(‘News Post’, ‘textdomain’); // You can continue to rename all the label properties, this is just an example } } add_action( ‘init’, … Read more

Post type cloud like tag cloud?

How about the wp_generate_tag_cloud() function? You’ll need to feed it $tags, which is an array of objects with the link and term_id, set something like this. $tags[]->link = $link; $tags[]->id = $tag->term_id; The term_id will only be used in the CSS…so don’t sweat that too much.

Ordering custom posts

The way I previously did this, was by adding a custom field to my CPTs, and ordering by that value when I fetched my posts with WP_Query. $myquery = new WP_Query( array( ‘post_type’ => ‘your_post_type’, ‘meta_key’ => ‘my_custom_field_name’, ‘orderby’ => ‘meta_value’ ) ); However, I believe if you add ‘page-attributes’ to your ‘supports’ parameter when … Read more

Loop doesn’t work in single-product.php page but works at normal page

A part of the problem was that “caller_get_posts” is deprecated, it is now “ignore_sticky_posts”. The main problem was this line “$post_type = $wp->query_vars[“product”];”, i removed this one and replaced the $post_type with ‘product’. This code works! <?php $tax = ‘product_category’; $tax_terms = get_terms($tax,’hide_empty=0′); if (is_array($tax_terms)) { foreach ($tax_terms as $tax_term) { $args=array( ‘post_type’ => ‘product’, … Read more