Displaying links to all posts of the same category on the post page

I’ve not tested this, but the following is the method you shoulduse. Don’t use query_posts. $cats_of_post= get_the_category(); if($cats_of_post){ $cat_id = (int) $cats_of_post[‘0’]->term_id; $related = get_posts(array( ‘numberposts’ => 5, ‘category’ => $cat_id, ‘orderby’ => ‘post_date’, ‘order’ => ‘DESC’, ‘exclude’ => )); global $post; $temp_post = $post;?> <div class=”related-posts”> <?php if( $related ): ?> <ol> <?php foreach … Read more

wp_nav_menu not appearing correctly on category page

Don’t call Nav Menus by menu_id. Rather, define an explicit theme_location for each place in your Theme template at which you want to include a Nav Menu, and then use that theme_location as the parameter passed to wp_nav_menu(). In this case, you’ve defined a header-menu Theme location, so change this: <?php wp_nav_menu( array( ‘container_class’ => … Read more

Conditional category query breaking?

i’m not sure what you are trying to achieve w/ the $paged variable. seems like you could simplify your query though $posts_per_page = is_paged() ? 5 : 2; $args=array( ‘post_type’=>’post’, ‘category_name’ => ‘featured-content’, ‘posts_per_page’ => $posts_per_page ); $temp = $wp_query; $wp_query= null; $wp_query = new WP_Query($args); edit, adding an offset (and fixing syntax errors): $paged … Read more

the_category() doesn’t working in wp_query loop

the_category() only works for the “Category” taxonomy which doesn’t appear to be hooked to your custom post type. I see you’re registering a custom taxonomy. If you want to show the terms from that taxonomy that are assigned to the post, you’ll need to use the_terms() or get_the_terms(): the_terms( $post->ID, ‘fgaleri’, ”, ‘, ‘, ” … Read more

Category List with custom urls

get_categories() is handy function to get list of categories with all information such as id & name of each category etc. This code might work. The $category->term_id will return the unique id for each category and $category->name will return the name to display to user. <?php $args=array( ‘orderby’ => ‘name’, ‘order’ => ‘ASC’ ); $categories=get_categories($args); … Read more

Get post content intro text on category.php?

You’re using an old version of WordPress. Upgrade to 3.5 and you will no longer see that error. Here’s the function declaration for get_post in WP 3.4: function &get_post(&$post, $output = OBJECT, $filter=”raw”) Notice the ampersand in front of $post? That would mean the value is passed by reference. You can give the function a … Read more