How to var dump urls for all posts
You can do this with the following WP CLI command: wp post list –field=url –post_type=post –posts_per_page=-1 –post_status=publish The result is each posts url on a new line
You can do this with the following WP CLI command: wp post list –field=url –post_type=post –posts_per_page=-1 –post_status=publish The result is each posts url on a new line
You could try this: function restricted_access() { if( ! is_user_logged_in() ) { global $wp_query; $wp_query->set_404(); status_header(404); } } add_action( ‘wp’, ‘restricted_access’ ); By default, always, if the user is not logged in it will give them the 404 page. The following two functions will keep non-admins out of your Admin Panel and will also hide … Read more
You’ll probably want filter out some parameters, change the order they’re displayed, etc – but this should get you started: $s = “/?s=Search&property_city=las-vegas&property_location=Nevada&min_price=20000&max_price=500000&beds=2&baths=3&min_area=1000&max_area=1000000&property_type=apartment&s=Search&apor=Any&apvr=Any&post_type=property”; parse_str($s,$parts); foreach ($parts as $key => $value) { $name = ucwords(str_replace(“_”,” “,$key)); echo “$name: $value<br />\n”; } You can probably just use foreach ($_REQUEST as $key => $value) { unless there’s a … Read more
You can pass an array of years to the tax_query (or use PHP range()). The default operator is IN – see https://developer.wordpress.org/reference/classes/wp_tax_query/__construct/#parameters $args = array( ‘tax_query’ => array( array( ‘taxonomy’ => ‘year’, ‘field’ => ‘name’, ‘terms’ => range($min_year, $max_year) ) ) );
Thanks to Brad Dalton at wpsites.net for getting me to the answer. Install Advanced Custom Fields plugin. Create a custom field called price, formatted as a number. Use the code below (based on Bill Erickson’s tutorial): add_action( ‘pre_get_posts’, ‘kr_change_posts_order’ ); function kr_change_posts_order( $query ) { if ( $query->is_main_query() && !is_admin() && !is_page() ) { $orderby … Read more
Perhaps you should try this: function rpm_pre_get_post($query){ if($query->is_main_query()){ $query->set(‘meta_query’, array( array( ‘key’ => ‘parent-project’, ‘value’ => ‘Metro-E’ ) ) ); } } add_action( ‘pre_get_posts’, ‘rpm_pre_get_post’, 9999 );
It’s hard to be sure without he error, but this part of code looks pretty weird: if ( is_post_type_archive( epl_all_post_types() == ‘true’ ) ) { is_post_type_archive gets one param and it should be post type or array of post types. But in your code you pass a logical statement in there (so true or false). … Read more
I’m not sure why you don’t want to use wp_Query? wp_Query is a very powerful function about retrieving various queries. First of all, pages in the blog do not relate with posts, so you won’t get any predefined post query for that page-template that you created. However there are a few ways to show post … Read more
I figured it out after adding the same code to a different site I run. It was working fine on that site with the same theme and mostly the same plugins. I narrowed it down to another function I made (thankfully it wasn’t another plugin). The other function was sorting something on the front end, … Read more
For what it’s worth, I just gave up on the ‘__not_in’ approach and went with the following somewhat sneaky solution: //Create the exclusion rule $new_tax_query = array( array( ‘taxonomy’ => ‘x_category’, ‘field’ => ‘slug’, ‘terms’ => array(‘y-slug’), ‘operator’ => ‘NOT IN’, ) ); //If there is already a tax_query, ‘AND’ our new rule with the … Read more