How to modify the query to exclude posts by slug?

You can get the post ID from the slug with the url_to_postid() function: $ID = url_to_postid(slug); then just exclude the ID from your query: query_posts(array(‘category_name’ => ‘Mycat’, ‘posts_per_page’ => -1, ‘post__not_in’ => $ID )); You can create an array of post IDs if you need to exclude multiple pages.

Problem with single-page for my custom post

Your code looks sound, so you should have a look at the code in your single.php template, as I suspect that there is something wrong in that template to why nothing is displayed. You should set debug to true in wp-config.php. This should help you locate your problem Secondly, your single-posttype.php is wrongly named. Your … Read more

Filter query_posts by tag slug on “Tag Archive” page (when tag is 2 or more words)

The single_tag_title() function returns the tag title while you need the tag slug or ID for use in query_posts(). This should get you started: if ( is_tag() ) { $tag = get_queried_object(); $tag_title = $tag->name; // Same as single_tag_title() $tag_slug = $tag->slug; $tag_id = $tag->term_id; } http://codex.wordpress.org/Class_Reference/WP_Query#Tag_Parameters

query_posts sort in multiple directions

OrderBy The query functions, like get_posts(), query_posts() call a new WP_Query inside – they’re just wrappers. The more important thing is what goes on in the class WP_Query. Specifically inside WP_Query -> get_posts(). When you add an orderby argument, then the following happens: WP checks if it set. If not, then it uses the $wpdb->posts.post_date … Read more

Replace query_posts with pre_get_posts

Without seeing the broken code it is hard to say, but your filter should look something like this: function pregp_wpse_97354($qry) { if (is_front_page() && is_main_query() && is_user_logged_in()) { $qry->set(‘cat’,2); $qry->set(‘posts_per_page’,5); $qry->set(‘orderby’,’date’); $qry->set(‘order’,’DESC’); } } add_action(‘pre_get_posts’,’pregp_wpse_97354′); You mentioned something about the user being logged in, which your code does not check for, but I threw that … Read more