(Revised answer)
If I understand it properly, try these:
-
Define
$the_post
for each “property”:<?php $the_post = get_post(); ?> <div class="property-details"> <h2><?php the_title(); ?></h2> ... </div>
-
Then change the drop-down code to:
<select name="propname"> <?php $found = wp_list_filter( $the_query->posts, [ 'ID' => $the_post->ID ] ); if ( empty( $found ) ) : ?> <option selected><?php echo get_the_title( $the_post ); ?></option> <?php endif; if($the_query->have_posts()){ while($the_query->have_posts()) : $the_query->the_post(); ?> <option<?php selected( get_the_ID(), $the_post->ID ); ?>><?php the_title(); ?></option> <?php endwhile; } wp_reset_query(); ?> </select>
Related Posts:
- How to use a custom post type archive as front page?
- Combining queries with different arguments per post type
- How do you get the count of posts in an archive page?
- Mixing regular and custom post types (with meta_query) on home page
- How to make a WP_Query search with custom post types?
- $wp_query->queried_object->ID throws warning: Undefined property
- how to filter by last name for custom post
- The Operator “NOT IN” Does Not Work In tax_query
- Display Custom Post Type Fields
- Use WP_Query object inside a function
- WP_Query search custom posts meta date fields
- Get posts with tag all post types
- How to get_queried_object on multiple objects?
- How to get the parent’s taxonomy?
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- WordPress query by multiple Custom fields and order by date
- Help with hierarchical custom taxonomies and permalinks…almost there
- custom post type paging not working past page 3
- WP Query group/order by category name
- exclude custom post type by meta key in wp_query
- Query for custom posts with a specific tag slug
- WP_Query search posts by custom post type and custom taxonomy
- Unable to get post content from custom post type loop
- WP-Admin edit.php & post.php slowdown after import of 10k users
- WordPress Orderby Numeric Value Not Working
- How to call a custom post type with WP_query
- How to add pagination to wp_query [duplicate]
- WordPress custom loop filter by meta_key and value with serialize data
- Show one item per category of a custom post type
- Storing posts from query and accessing later via AJAX call
- Return one unique custom post type result when it shares a custom taxonomy in WP_QUERY?
- Mixing 2 custom post types with posts output in specific pattern
- Show only one post on custom post type archive
- How can I made custom taxonomies relationship?
- Why is this query not working? (Standard posts + custom post type)
- Pagination issue on category.php using custom post type query
- First custom field value (out of several) displayed twice after query
- How to get all tags of a custom post type by id
- Limiting posts_join, where, etc to a specific WP_Query object?
- How to make WP_Query not to show irrelevant posts?
- WP_query – Filter by tax_query and meta_query using multiple select
- Create a list of recent Custom Post Types posts
- Empty search input does not return all posts
- How to sort a WP_Query by a custom field AND ALSO filter by a different custom field
- Adding Multiple Post Types to Query [duplicate]
- Get current user id
- WP Query results showing posts outside of category ID
- tax_query (if the terms are empty)
- List latest post out of 2 custom post types
- How to count other posts not having specific taxonomy terms?
- Group by custom field value (start and end times)
- Running a custom query inside another cpt single and trying to grab a variable
- Get posts by category name
- WP_Meta_Query object with conditionals
- How to properly use Categories with Custom Post Types
- Problem while filtering by ‘category_name’
- Displaying Portfolio Filter by Category Order (alphabetically)
- Custom Post Type Query W/Category Dropdown
- Query for specific taxonomy that executes a particular loop depending on volume of posts?
- Create a Dropdown Selector and Redirect for a Custom Taxonomy in WordPress?
- How to order query results based on if a custom field has been populated, then the order by the date of the post?
- Pin posts to top of custom loop
- WP_Query get always custom post_type for first
- WP_Query – How To Query Only Custom Posts With No Children of Their Own?
- Foreach result into WP_query
- Query custom post type and custom field by URL parameters
- meta query multiple values for the same key
- Custom post types – meta_query: search lesson which starts sooner
- Wp Query sort order from custom MetaBox
- Custom Taxonomy – fields
- CPT Loop, include taxonomies and disclude others?
- Query posts based on user preferences
- CPT post doesnt shows tags and category on backend admin page
- Adding a nav menu for a custom post type
- How to use costum database table for custom post type
- Most efficient way of showing children posts?
- Querying, storing, and using data from 2 separate custom post types
- date_query won’t accept day parameter, but will accept month and year for a custom post
- How can I use WP_Query argument ‘Like %..%’?
- Dropdown switching subcategories portfolio
- Custom post type and custom taxonomies display
- WordPress custom post type
- Custom Post ‘Post Per Page’ Crashing Page?
- Custom post type single display is ommited
- Issue with permalinks for custom post type
- Query child posts on parents single.php?
- Paged within a custom content type template [duplicate]
- WordPress can only query up to 766
- Custom Post Query Combined with Conditional Tags
- Custom loop won’t work, can’t find problem
- Query by post type or category
- Get all custom_post_type posts + blog posts from one category in a single query
- Customising wordpress search and using $_GET[“s”]
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- How to exclude certain portfolios from a loop
- show the most recent date of all posts to display on front end
- Quering array of post types & pagination. Articles are repeating sometimes on different pages
- How can I show posts with the same tag?
- Load posts via AJAX without draft status
- WP Query – Can’t get posts with specific taxonomy