Child pages not affected by orderby

post_parent should be the ID of the post parent, not the slug. Apart from that, your code should work. If not, look for any posts_* filters or pre_get_posts actions that might influence your custom query EDIT Something else I have missed, $args is already an array, so you do not need to add it another … Read more

Get the child category ID of current category

Use get_terms with parent argument to get only direct children of a term. Use wp_list_pluck to extract an array of term IDs that can be passed to a query. $args = array( ‘parent’ => get_queried_object_id(), ); $terms = get_terms( ‘category’, $args ); $term_ids = wp_list_pluck( $terms, ‘term_id’ ); Also uses get_queried_object_id to get the ID … Read more

WP_Query for products always returns empty

Your arguments should look like this : $args = array( ‘post_type’ => ‘product’, // No need for an array since you only query one post type ‘posts_per_page’ => 3, ‘tax_query’=>array( // The taxonomy query array( ‘taxonomy’ => ‘product_cat’, ‘field’ => ‘term_id’, // Can be omitted, default parameter, can also be ‘slug’ or ‘name’ (name should … Read more

Display recent posts on another site

I’m not sure what you’re doing with the above script, but here are some random suggestions: Avoid using the root user, for security reasons create another database user with less powers. Avoid using deprecated mysql_* calls. Use WP_Query() or get_posts() instead of hardcoded SQL queries. Use global $wpdb object if you really must use hardcoded … Read more

Add URL Rewrite Rule To WordPress

First you need to register your expected variables. Something similar to: function my_rewrite() { add_rewrite_tag(‘%ct_city%’, ‘([^&]+)’); add_rewrite_tag(‘%country%’, ‘([^&]+)’); } add_action(‘init’, ‘my_rewrite’, 10, 0); Then you need to create the rule which will redirect to your abm page. Note that you will need to discover your abm‘s ID, since you will need to pass it in … Read more