For general post queries, use WP_Query or get_posts(). any idea how to fix? if ( is_category( 'category-slug' ) ) : query_posts( array( 'category_name' => 'my-category-slug', 'posts_per_page' => -1 ) ); endif; The same precautions apply when using -1. What I was able to find was running query by category number, but this is not dynamic enough for me as I would like to run query on page title which this contact form
DoublyLinkedList Implementation Java Word to describe object that can be physically passed through 5 Favorite Letters Taxing GoFundMe Donations Can I reset a CSS property rather than overriding it? DoublyLinkedList Implementation Java How to connect two parabolic paths in TikZ? What should I do about this security issue?
Your example can also be used: // The Query $query = new WP_Query( 'category_name=staff,news' ); // The Loop ! Any insights on how to achieve this would be great. Writing to multiple files with cat What different frame materials have been used? Wordpress Get Category Id Lucene analytics index constantly loads HDD Mountainering with 6 y.o.
Simple geometry. Category__not_in Before deciding to use query_posts(), be sure to understand the drawbacks. If you need to run custom queries, make use of WP_Query. What difficulty would the Roman Empire have besieging a fantasy kingdom's 49m wall?
Or is it? Post__not_in won't return posts for category with spaces0Wordpress WP_QUERY with Category and Meta_key0WordPress | WP_Query issue with meta_query0WP_Query with specific category0WordPress targetting specific post category on specific page0Disable Specific Categories By ID Skip to toolbar About WordPress About WordPress WordPress.org Documentation Support Forums Feedback Search Log In current community chat Stack Overflow Meta Stack Overflow your communities Sign up or log in to Three Dots inside Round
Why does unique_ptr instantiation compile to larger binary than raw pointer? This will definitely depend on how your category slugs are named in comparison to the titles, but it's something that I have used with success in the past. Category_name Wordpress Possible values are 'IN', 'NOT IN', 'AND'. ), array( 'taxonomy' => 'actor', 'field' => 'id', 'terms' => array( 103, 115, 206 ), 'include_children' => false, 'operator' => 'NOT IN' ) ), Get_posts Wordpress What difficulty would the Roman Empire have besieging a fantasy kingdom's 49m wall?
It is strongly recommended that you use the ‘pre_get_posts' action instead, and alter the main query by checking is_main_query(). weblink What game did I see in Verona, Italy? Note the captialization. //'author' - Order by author. //'title' - Order by title. //'date' - Order by date. //'modified' - Order by last modified date. //'parent' - Order by post/page parent See the note further below on caveats for details. Wp_query Category_name
share|improve this answer edited Mar 27 '15 at 11:54 answered Aug 20 '14 at 7:07 jnhghy - Jantea Alexandru 1,5481127 add a comment| up vote 0 down vote Show Posts From First assign the variable, then concatenate and then run it. Note that the global $post object holds infos about the main query (in case of a single post template, as single.php) while the local $post in the loop is about the his comment is here more stack exchange communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed
Skip to note content You must log in to vote on the helpfulness of this noteVote results for this note: 0You must log in to vote on the helpfulness of this movies) ), 'post_status' => array( //(string / array) - use post status. In this case, all posts belong to category 1 and tagged as "apples" and "oranges" are returned. See is_category().
If you do need to pass category names, then you should use a tax_query which do accept names passed to the terms parameter You can pass the following with your parameters asked 4 years ago viewed 5173 times active 4 years ago Upcoming Events 2016 Community Moderator Election ends in 6 days Blog How We Make Money at Stack Overflow: 2016 Edition Rather use category-slug instead. When you do this, WordPress ignores the other parameters it receives via the URL (such as page number or category).
How fast is Time running in Majora's Mask? Return just the child Pages. 'post__in' => array(1,2,3), //(array) - use post ids. This is not necessarily a problem, especially if you're dealing with a smaller blog-based site. The ‘parse_query' and the ‘pre_get_posts' filters are also available to modify the internal $query object that is used to generate the SQL to query the database.
Top ↑Pagination #Pagination Pagination won't work correctly, unless you set the ‘paged' query var appropriately: adding the paged parameter Top ↑Additional SQL Queries #Additional SQL Queries If you use query_posts within unless, i misunderstood your code and this is a secondary loop? The WP_Query object will generate a new SQL query using your parameters. asked 1 year ago viewed 1448 times active 9 months ago Upcoming Events 2016 Community Moderator Election ends in 6 days Blog How We Make Money at Stack Overflow: 2016 Edition
words), but can bunexpected for numbers (e.g. 1, 3, 34, 4, 56, 6, etc, rather than 1, 3, 4, 6, 34, 56 as yomight naturally expect). //'meta_value_num' - Order by numeric