I got it to work by using the following code
function get_gas_options($a) {
$args = array(
'post_type' => 'fleet',
'orderby' => 'ID',
'post_status' => 'publish',
'order' => 'ASC',
'posts_per_page' => -1 // this will retrive all the post that is published
);
$result = new WP_Query( $args );
$title_list[''] = "Assign a Vehicle";
if ( $result-> have_posts() ) :
while ( $result->have_posts() ) : $result->the_post();
$title_list[get_the_ID()] = get_the_title();
endwhile;
endif;
wp_reset_postdata();
return $title_list;
}
Related Posts:
- Querying multiple values from a single key
- Using meta_query, how can i filter by a custom field and order by another one?
- Mixing regular and custom post types (with meta_query) on home page
- meta_query for keys that aren’t yet set
- Fail to compare dates in meta_query
- Order by & include array by specific post ids
- Get list of all registered post types slugs
- Get posts based on meta key/value
- How to create a wp_query that contains both meta_query and tax_query
- WP_Query() show posts that end later than today
- WP_Query orderby custom field then post_date in one query
- Filtering a WP_Query meta_query by numeric values isn’t working
- Ordering posts having multiple post-meta date fields
- Querying custom post type with 2 custom fields (date-range)
- Custom Queries: Joining On Meta Values From Two Custom Post Types
- How Can I save multiple records in same meta key?
- Get an array wich contains the post_name of every post that has the custom post_type “pelicula”
- Add first letter of titles to array, then compare arrays
- Query Custom Post Types with checkboxes
- WP_query – Filter by tax_query and meta_query using multiple select
- Create Array from custom post type to display a slider
- Is it possible to load a different sidebar in single.php based on a meta_query filter?
- Getting a custom post’s custom field based on another custom post’s custom field select
- Inefficient Query Confusion
- Check if user has comment on current post
- find custom post type post by searching its custom field with my string
- Get category if used in a custom post type
- WP_Query of custom post type sorted by meta_key has unexpected results
- Custom Query: If One Post Object Field Value Is The Same As Another
- get_terms() returns Trying to get property of non-object error for custom taxonomy
- Query for post and costom post_type in same category filtered by meta for post_type
- If meta_value of meta_key is less than today’s date update meta key
- fetch custom post by meta key if key value is does not know
- Create a WP_Query where if the first value of the first row is equal to the second compare other value
- How do I disply an array inside a custom post type?
- Custom Post Type Field Array parsing [closed]
- Getting custom post types to properly display alphabetically
- Query Posts, order by meta value
- WP_Meta_Query object with conditionals
- WordPress giving a 404 page when passing a year argument different than the current year
- Sorting by meta_key different to search criteria?
- Using WP meta query to show custom post types by a start and finish date
- Two queries – one with checkbox ticked, one without – comparing meta_query
- How can I loop at a Specific Taxonomy from a custom post type?
- Update value inside array update_post_meta
- How to order query results based on if a custom field has been populated, then the order by the date of the post?
- order the meta query results by 2 custom fields
- Custom archive page for custom taxonomy and pagination issue
- Order admin post list table by meta field, and have posts without the meta field always be at the end of the list
- Get an array of the number of post per year of a custom post type (WordPress)
- Dynamic template page calling shared taxonomies CPT or Plugin post type : how to clone taxonomy for plugin + set up dynamic shortcode
- Using OR relation in meta_query to check for a value before sorting by another
- Query when is one or several values
- Filter result of Custom Post Type using meta_query with ACF
- build child and anchestor three from post parent
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- Query posts by current ACF meta key value on single page as related posts
- meta query condition don’t work
- Custom query result empty on page 2
- Meta query and compare “!=” not working as expected
- meta_query Where the key value is stored as an array
- Orderby if between two meta fields
- How to select meta key in custom database query
- Use WP_query to match post types based on custom field values
- Show posts from WP Custom Post Type selected from a field in a metabox
- ACF meta_key and meta_value break loop
- meta query multiple values for the same key
- Sort custom post archives by a meta value from a different custom post type?
- Staggering featured post using ‘sticky’
- Custom post types – meta_query: search lesson which starts sooner
- post type => ‘any’ not applied my custom queries
- How to get the posts that my following users are liked?
- Meta_Query refuses to return results
- Sort loop by custom field from different post type
- Meta_query by date for Events archive
- If custom taxonomy exist on post?
- Not able to get my custom search result using meta_query and tax_query together?
- Meta query broken since 4.7.4 Update
- Convert Custom Post Data to Javascript Array for Autocomplete
- How to shows CPT which has specific meta key?
- Querying, storing, and using data from 2 separate custom post types
- Query events post type after current date and timezone
- Conditional posts in WP_query for search
- Trying to get custom post type attachment images to function in indexed array
- CPT and metabox: create multi checkbox by using array?
- Pulling in Related Posts based on Post Type array
- meta query always fails even if data is correct
- shortcode order for event custom post type
- Events with multiple event dates + permalink for each date
- WordPress custom field images not getting inserted into array
- Selecting posts older than the current Unix epoch timestamp
- Unable to get the upcoming events for custom post
- Filter RSS feed for custom post type to events for next 7 days only
- Meta-Box to add multiple items one at a time and on publish save all
- Custom Query With Multiple Meta Key Value
- Custom Post Type Author Array Problem
- Trying to combine multiple WordPress queries
- using post_type with meta_query
- Ordering by multiple meta keys – Custom post type
- taxonomy terms array not working