How do I get the url slug inside the dashboard for a custom post type?
You can retrieve the permalink using get_permalink() To retrieve the edit link for a post, use: get_edit_post_link()
You can retrieve the permalink using get_permalink() To retrieve the edit link for a post, use: get_edit_post_link()
I’ve managed to workaround the problem. He’re the solution for further reference. 1) I have only 1 query var now: function return_vars( $vars ) { $vars[] = ‘filters’; return $vars; } 2) My rewrite rules changed to: add_rewrite_rule( ‘my-base/filters/([^\/]*)/([^&]*)/page/([0-9]{1,})/?’, ‘index.php?post_type=$matches[1]&filters=$matches[2]&paged=$matches[3]’, ‘top’); add_rewrite_rule( ‘my-base/filters/([^\/]*)/([^&]*)/?’, ‘index.php?post_type=$matches[1]&filters=$matches[2]’, ‘top’); Rule 1: handles pagination Rule 2: handles main page only … Read more
orderby should be e.g. meta_value or meta_value_num – various specific meta_type‘s are available – to order by meta data. Additionally a meta_key has to be set and present in the query. To be exact and to avoid misunderstandings, meta_key has to be the keyname of the field you’re sorting by. Take a closer look at … Read more
If you look for all products with same ‘product_cip’ value try this: $a=array( ‘post_type’ => ‘product’, ‘post_status’ => ‘publish’, ‘posts_per_page’ => – 1, ‘meta_query’ => array( array( ‘key’ => ‘product_cip’, ‘value’ => ‘some value’, ‘compare’=> ‘=’ ) ), ‘fields’ => ‘ids’ ); $b=get_posts($a); echo count($b); if you have get all products data $products_array=array(); foreach($b as … Read more
Try meta_query to get posts having theme_settings_post_show == true (for new posts) and theme_settings_post_show not set at all (for old posts): <?php $queryArguments = array( ‘posts_per_page’ => -1, ‘post_type’ => ‘post’, ‘meta_query’ => array( ‘relation’ => ‘OR’, // value is not set or true array( ‘key’ => ‘theme_settings_post_show’, ‘value’ => ”, // can be any … Read more
I finally fixed it: <?php $state_posts = array(); while ($query->have_posts()) { $query->the_post(); $state = get_post_meta(get_the_ID(), ‘state’, true); $state_posts[$state][] = $post; } wp_reset_query(); foreach ($state_posts as $state_post => $state_title) { ?> <h1 class=”state-name”><?php echo esc_html($state_post); ?></h1> <?php foreach ($state_title as $listing => $single_listing) { setup_postdata($single_listing); $post_id = $single_listing->ID; $title = get_the_title($post_id); $distance = facetwp_get_distance($post_id); $distance = … Read more
After a full investigation and a lot more debugging and code tempering I found out that using “date” as a meta field name generate a lot of “confusion” inside the wordrpess query itself as wordpress confuse the meta_query “date” field with the “date” itself, to avoid all this the solution is simply changing the name … Read more
There are few ways to solve this problem… 1. Don’t bother and use Relevansi (or some other similar plugin) You can often hear that using many plugins is a bad thing. It’s not entirely true. It’s bad only if these plugins have big impact on use of resources. In this case, Relevansi won’t cause such … Read more
If you haven’t gotten the answer to this yet, I found the answer by sifting through the source code. I was able to hook into the post save event by using: cmb2_save_{$object_type}_fields_{$cmb_id}. This hook fires whenever you save a certain object type with a specific metabox ID. So, in your case your $cmb_id is test_metabox, … Read more
Based on your code, hope you have already register your CPT(custom post type) providing valid label & arguments with function: register_post_type( ‘freebie’, $args ); Here is the complete code that, your custom meta box will be only visible to our “freebie” CPT with a input field to save demo url for this CPT posts. Add … Read more