Select column name dynamically mySQL Query

I guess one could argue that this is somewhat wordpress related, because you are trying to get_results() from $wpdb, but like @MarkKaplun said your problem is that you are using the SQL wrong. Below code is an example on how to do it correct: $dr = $wpdb->get_results( $wpdb->prepare( “SELECT * FROM wp_shipping WHERE country = … Read more

Taxonomy filter under Polylang

I got it. With help from this answer: get all posts ID from a category $post_type_ids = get_posts(array( ‘numberposts’ => -1, // get all posts. ‘post_type’ => ‘texto’, ‘fields’ => ‘ids’, // Only get post IDs ));

Querying Advanced Custom Fields

Try using a meta_query in your $args. You are far more flexible this way. For the full reference of the possibilities check the Codex $args = array( ‘post_type’ => ‘Product’, ‘posts_per_page’ => -1, ‘orderby’ => ‘title’, ‘order’ => ‘ASC’, ‘meta_query’ => array( array( ‘key’ => ‘product_type’, ‘value’ => ‘Paper’, ‘compare’ => ‘=’, ) ) );

Query to view scheduled or draft post

First, don’t use query_posts(). Note: This function isn’t meant to be used by plugins or themes. As explained later, there are better, more performant options to alter the main query. query_posts() is overly simplistic and problematic way to modify main query of a page by replacing it with new instance of the query. http://codex.wordpress.org/Function_Reference/query_posts The … Read more

Order terms by count – missing terms

By default hide_empty is true for get_terms. So i guess you must be missing terms which do not have posts. Try this, <?php $terms = get_terms(“autorzy”, array(‘orderby’ => ‘count’, ‘order’ => ‘DESC’,’hide_empty’=>0 )); $count = count($terms); if ( $count > 0 ){ echo “<div>”; foreach ( $terms as $term ) { ?> <?php echo $term->name; … Read more