Warning: Invalid argument supplied for foreach(). when creating a WP_query
Solved., little things matter. if ($termsArray) { foreach ( $termsArray as $term ) { $termsString .= $term->slug.’ ‘; } }
Solved., little things matter. if ($termsArray) { foreach ( $termsArray as $term ) { $termsString .= $term->slug.’ ‘; } }
reset to main loop doesnt work
I don’t think this is doable in a single WP API query. You just don’t sort whole set with single logic, you have logic changing halfway. I don’t think even SQL can express this. It is hard to advise without seeing specific circumstances (such as counts, pagination involved and so on), but my first thought … Read more
Convert your string of IDs into a proper array: $exclude_ids = get_field( ‘exclude_pages’ ); $exclude_array = explode( “,”, $exclude_ids ); Then pass $exclude_array as the value for post__not_in.
Orderby listing issue
WP_Query with ‘rand’, but equal number of posts from the taxonomy terms given
REST API: Limit Read Permissions for Default Endpoints
You can handle this with WordPress’s internal rewrites system by adding a rewrite endpoint: function wpd_cpage_endpoint() { add_rewrite_endpoint( ‘cpage’, EP_PERMALINK ); } add_action( ‘init’, ‘wpd_cpage_endpoint’ ); This will add extra rewrite rules enabling /cpage/n/ on the end of permalinks. You can then fetch the value on those requests with get_query_var( ‘cpage’ ). EDIT- This is … Read more
Search by post id in a specific page then auto-redirect to searched post
You should modify this fragment: // Define the query $args = array( ‘post_type’ => ‘fiction’, ‘booktype’ => $term->slug, ‘orderby’ => ‘name’, ‘order’ => ‘ASC’ );