Displaying Posts from Custom Post Types

You’re setting arguments for the main query in your pre_get_posts action, and then overwriting that query in the template by calling query_posts (which you should never use). If you want to exclude categories, do that in the same pre_get_posts action: add_action( ‘pre_get_posts’, ‘add_my_post_types_to_query’ ); function add_my_post_types_to_query( $query ) { if ( is_home() && $query->is_main_query() ){ … Read more

I am trying to hide a custom post type category to logged in users with Pre_Get_Posts

OK, so you have few mistakes in there. field can be term_id or slug, but not id. tax_query should be array of arrays and not an array. So here is fixed code: function exclude_category( $query ) { if ( is_user_logged_in() && $query->is_main_query() ) { $taxquery = array( array( ‘taxonomy’ => ‘project-type’, ‘field’ => ‘term_id’, ‘terms’ … Read more

How can I paginate this?

Well, I see three posts! 🙂 Just an idea, but maybe you only need to add the next/prev links? http://codex.wordpress.org/Function_Reference/posts_nav_link Edit: This (http://streakingpirates.com/pending/page/2) works for me, so I guess it must be the links you’re after!

How to get list of posts from permalinks?

There are several ways to achieve this, depending on the permalink structure of your posts. Assuming the post slug is part of the permalink structure, you can get the post slug from the post URL and fetch the corresponding post by using WP_Query with the name-parameter. Let’s assume the structure of the URLs is http://example.com/{post_slug}/. … Read more

Modify users.php query with multiple taxonomies

Because I’m also storing the user IDs against each company, office and team post object as user taxonomy I can reverse the query and only include the user IDs assigned to that specific post object. A similar thing to what has been done here – http://mywebsiteadvisor.com/learning/tutorials/building-simple-groups-plugin-for-wordpress-tutorial/step-5/ Only I’ve modified it to be a bit more … Read more