Query posts from category based on a filter most favorited

query_posts accepts custom query variable as arguments. So assuming that adding ?sort_by=most_favourites to an url alters the sort order to sort by the most favourites (i.e. you’ve set sort_by as a recognised WordPress query variable, and setting it sorts the returned posts accordingly) then, try: $args = array( ‘cat’ => $cat_lists[$i], ‘showposts’ => intval(get_theme_option_by(‘bn_list_per_item’, 6 … Read more

Rewrite a category

You cannot use the same term for a category, page, tag as they need to be unique. When you do, you’ll get a number next to the slug To fix them you’ll need to fix the tag or page slug otherwise edit the category slug last http://wordpresssites.net/links/how-to-edit-change-fix-duplicate-category-slugs-in-wordpress/

Hiding a Categories content on just the Homepage ‘Posts’?

Okay, it sounds like you’ll want to modify the primary Loop using query_posts(), but only on the Site Front Page. I don’t think TwentyTen includes a front-page.php template file, so we’ll modify index.php directly. Add the following code to index.php, anywhere before the Loop output: <?php // Determine if we’re on the site Front Page … Read more

How to Exclude post from a category

To exclude a category you’ll need to modify the query that’s running. Do this using the query_posts() function: http://codex.wordpress.org/Function_Reference/query_posts First, you’ll need to get the ID of the category you want to exclude: $exclude_category = get_term_by(‘name’, ‘collage’, ‘category’); Then you’ll need add the category exclusion to the query, and pass the new query to query_posts: … Read more

If statement for catergories

<?php $current_user = wp_get_current_user(); if ( is_category( ‘Cars’ ) && 0 == $current_user->ID ) { ?> <!– HTML markup here –> <?php } else { ?> <!– other HTML markup here –> <?php } ?> ID will be 0 in the $current_user object, if the user isn’t logged in. Related reading: is_category wp_get_current_user EDIT Try … Read more

add text to the top of category page

May I suggest using one plugin that I use for my sites ( I am a web-developer)? I Use Extra category content plugin (http://www.greatwpplugins.com/extra-category-content/) if I want to put any kind of content (text, image, link, etc) before the post listing in a category. Just install the plugin, edit a category to add some extra … Read more

How do you add a category to a post in code

There’s the wp_update_post(), also. According to categories, please refer to the documentation. Categories need to be passed as an array of integers that match the category IDs in the database. This is the case even where only one category is assigned to the post. So, it would be something like: $post = get_post($i = $post_id); … Read more