How to differentiate the homepage structure from the category page structure in WordPress template?

If I understand you… Your theme may only have an index.php and a single.php but WordPress supports a much more complicated templating system, and you can control the formatting of different types of content just by creating files with the right names. In your case, I think that at least one of the files you … Read more

Add multiple orderby with pre get posts

You could try using the posts_orderby filter: add_filter(‘pre_get_posts’, ‘sort_arc’); function sort_arc($q) { if ($q->is_category() && $q->is_main_query()) { $q->set(‘meta_key’, ‘the-year’); add_filter(‘posts_orderby’, ‘custom_posts_orderby’); } return $q; } where function custom_posts_orderby($orderby) { global $wpdb; return $wpdb->postmeta.”.meta_value+0 DESC, “.$wpdb->posts .”.post_title ASC”; } takes care of the custom ordering. We use meta_value+0 from the meta_value_num definition in /wp-includes/query.php. Update: Here … Read more

output only if within a combination of two cats

Your query has some odd elements like ‘meta_value_num’ => ”, but it sounds to me like what you want is exactly what category__and does. $my_query_args = array( ‘posts_per_page’ => 10, ‘meta_key’ => ‘price’, ‘category__and’ => array($catid1,$catid2), ‘orderby’ => ‘meta_value_num’, ‘order’ => ‘asc’ ); Side note: your price meta key will not order in a way … Read more

Display one category and its suncategories

Instead of: $select = wp_dropdown_categories(‘show_option_none=Select category&show_count=1&orderby=name&echo=0’); put this: $select = wp_dropdown_categories(‘show_option_none=Select category&show_count=1&orderby=name&echo=0&child_of=” . $ID_OF_PARENT_CATEGORY); where $ID_OF_PARENT_CATEGORY is a variable holding the ID of parent category, from which you want to show the children. Showing parent That category WON”T show. To show it, you must do some greater hack (here I’ll show you only thing that … Read more

Posts of specific category on page and excluded from index.htm

1. CSS/HTML issues are off-topic for this site, per the FAQ. But, have you tried investigating with Firebug or Chrome’s dev tools? The answer is obvious in seconds. This page http://www.biz.uiowa.edu/bta/test/ has large headings because of .singular .entry-title { font-size: 2em; margin-bottom: 0.3em; } Since you are running a second loop on a singular page, … Read more

wp_dropdown_categories initial value

you can set the initial value of categories drop down by passing category id to selected parameter of wp_dropdown_categories function as shown in following code : wp_dropdown_categories( array( ‘child_of’ => 20, ‘selected’ => get_cat_ID( ‘Bedrooms’ ) ) ); For more information on this visit this code page.

PHP dynamical conditional post display

Your code is disjointed, but from the look of it you are passing an ID as the category_name value. The switch that would convert that to a name comes after the query. Move this, or something like it,… $link=$_GET[‘link’]; if ($link == ‘1’){ $category_name=”accomodatins”; } if ($link == ‘2’){ cat_switcher(); } if ($link == ‘3’){ … Read more

How can i show categories of custom post

Instead of wp_list_categories(‘orderby=name&include=3,5’); use get_categories function shown in following code to get categories from custom post type. <?php get_categories(‘post=faq&orderby=name&include=3,5’); ?> For more information visit this page.