Count posts for pagination
$wp_query->post_count is supposed to work exactly like that. To get the total number of posts that exist in the database, use $wp_query->found_posts
$wp_query->post_count is supposed to work exactly like that. To get the total number of posts that exist in the database, use $wp_query->found_posts
Bulk Post update_post_meta
$category_slug_array = array(‘slug_1’, ‘slug_2’, ‘slug_2’); //array of category slugs foreach($category_slug_array as $category_slug){ $my_categories[] = get_term_by( ‘slug’, $category_slug, ‘category’); //getting category object by slug } print_r($my_categories); //printing array of categories
filter posts based on menu_order
As I wrote I expected it to be something I overlooked and it was. If you replace esc_url( get_pagenum_link( $big ) ) with html_entity_decode( get_pagenum_link( $big ) ) it does what it needs to do.
Answering my own question seems weird, but here is how I was able to achieve it – function filter_posts_by_id($query) { if ( !is_admin() && is_post_type_archive(‘CPT_NAME’) && $query->is_main_query()) { $post_ids = $_GET[‘post_ids’]; if(!empty($post_ids)) { $pids = explode(‘,’,$_GET[‘post_ids’]); $query->set(‘post__in’, $pids); } } } add_action(‘pre_get_posts’, ‘filter_posts_by_id’); PHP’s predefined variable $_GET[‘parameter’] to get the query string PHP’s explode() to … Read more
EDIT : Sorry just read that you need a ‘OR’ in your query. I will update anwser soon. According to your question, you can try this code. // WP_Query arguments $args = array( ‘name’ => ‘test’, ‘author_name’ => ‘test’, ); // The Query $query = new WP_Query( $args ); // The Loop if ( $query->have_posts() … Read more
How to automatically pull an information from a form field onto an other page?
I was able to come up with a solution according to advice from the comments. Working code: function import_shows() { $olddb = new wpdb(constant(“DB_USER”),constant(“DB_PASSWORD”),”THE_DB”,constant(“DB_HOST”)); $sql = “SELECT * FROM shows”; $rows = $olddb->get_results($sql); foreach($rows as $obj) { error_log($obj->name); } return; }
Based on your code, if the url is: http://example.com/page/?eth=1&t=1 Then the resulting query will be: $tax_query_args = array( ‘relation’ => ‘OR’, array( ‘taxonomy’ => ‘filters’, ‘field’ => ‘slug’, ‘terms’ => array( ”, ‘twitter’, ”, ”, ”, ”, ”, ”, ”, ” ), ‘operator’ => ‘IN’ ), array( ‘taxonomy’ => ‘platform’, ‘field’ => ‘slug’, ‘terms’ => … Read more