I have a need to limit items in the media library for users without a specific capability. There are a lot of examples out there for how to limit...
I’d like to exclude posts on the homepage which are closed for comments. This works thanks to this: Show only posts which can be commented Now I’d like to...
Today I was thinking about how to differentiate queries, mainly to create an unique identifier. In the process I played around a bit, see below code. The main idea...
I need to adjust the main loop for all archive pages in the following way. I have registered a custom taxonomy “myposttypes”. Every single post is assigned to exactly...
So, I have a custom post type, ‘properties’. I’m using archive-properties.php, and need to set some parameters on the $query. I don’t want to use new WP_Query since I...
I’ve registered custom rewrite rules and query_vars to use for displaying a list of events based on ISO date format. For example when a user requests the URL, http://site.com/by-date/2013-04-04/,...
I have a function that sets posts_per_page option depending on the category viewed. I discovered and error which I can’t really understand: first this is how I get the...
I’m writing a custom function that allows the posts to be sorted based on a custom field. When the user submits the “sort by” form, the meta_key (as well...
I am trying to order the search results page of my site by a specific meta_key. The catch is I need to return all results even when there’s no...
I try to add tax query on pre_get_posts hook using following code : // Add custom posts to main query (archive and home) add_action( 'pre_get_posts', 'add_post_types_to_query' ); function add_post_types_to_query(...