Get category from slug list

$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

URL to Post Archive of Custom Query

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

WP Query – Search in title or author_name

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

Trouble migrating custom post types from non-wordpress cms

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; }

Query by multiple custom taxonomies

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