get_pagination not working on a custom post type query (using WP_Query)

Pagination is only built “well” in non-custom post-types. Below, I’ll post an article with more detail about the more complex setup required for custom post-type pagination via the WP_Query() method. But to give the direct answer to your question, it’s not working because get_pagination() is not a method that belongs to the WP_Query() object, rather … Read more

Using WP_Query() in Magento shows error

__() is deprecated in magento. You may either manually delete it from the magento core files (& repeat this process again everytime you have a new install or you upgrade) or wait for magento developers to remove this. For wordpress, in the future when php 5.3 is much more common & wordpress breaks their backward … Read more

How to Order a list of taxonomies? orderby?

If you use the more generic get_terms you can include in the $args field all of the information to get the term or the children and specifically say what you want to order by and how you want it to be ordered. Ex. $termchildren = get_terms( “location”, array( ‘child_of’ => 4, ‘orderby’ => ‘name’, ‘order’ … Read more

How to check the array values, what WP_Query has brought to me?

Assuming you start with: $custom_query_args = array( ‘cat’ => 10, ‘post_per_page’ => 5 ); $custom_query = new WP_Query($custom_query_args); Then to answer your first question, you can see what is returned (for development/debugging) via: var_dump( $custom_query ); To output your query as a normal loop, you simply need to call a custom loop, using the have_posts() … Read more

Why posts array is empty?

You don’t need to add the % signs to the value. WordPress does that for you automatically on a LIKE or NOT LIKE comparison. You also don’t need to “sanitize” the parameter, it will be automatically escaped for SQL. See wp-includes/meta.php, around line 806 or so.

Default permalink structure causing Notice: Undefined property: WP_Query::$post

Finally I found what causing this problem, turns out it have to do with my pre_get_post hook. Because I using is_page to check the specific page, which is not appropriate. Here is what I did function check_page($wp_query){ if($wp_query->is_page(array(‘1′,’2′,’3’)) ){ //do something here } return $wp_query; } add_action( ‘pre_get_posts’, ‘check_page’ ); So my solution to this … Read more

Custom post type, custom taxonomy, query posts only from taxonomy (children of)

The problem was in not reading documentation carefully enough 😉 As it stands in http://codex.wordpress.org/Class_Reference/WP_Query in ‘tax_query’ part, “tax_query takes an array of tax query arguments arrays” so the correct part of code would be: $query_args = array( ‘post_type’ => ‘portfolio-type’, ‘paged’ => $paged, ‘tax_query’ => array( array( ‘taxonomy’ => ‘portfolio-category’, ‘field’ => ‘id’, ‘terms’ … Read more