I can’t test it now, but the following should work…
query_posts('post_type=sponsors&meta_key=_vof_sponsor_level&meta_value=Gold');
if (have_posts()) :
echo "<div class="imageshadow sponsorwidgetslides">";
while (have_posts()) : the_post();
if ( get_post_meta($post->ID, 'url', true) ) { ?>
<a href="https://wordpress.stackexchange.com/questions/39982/<?php echo get_post_meta($post->ID,"url',true); ?>"><?php the_post_thumbnail('sponsorwidget');?></a>
<?php } else {
the_post_thumbnail('sponsorwidget');
}
endwhile;
echo "</div><!--/.imageshadow-->";
echo "<a class="widgetlink" href="";
bloginfo("url');
echo "/sponsors'>View all Sponsors »</a>";
endif;
wp_reset_query();
I’ve not come across any problems with $post->ID, but from what Shane has just commented, you could change that to get_the_ID()
Related Posts:
- Individual Widgets per Page
- How to rename a custom field?
- How can I make wp-pagenavi work on a custom query built upon a form submission? [closed]
- Meta Query with AND & OR?
- Having different sidebar content for MANY pages?
- Get custom field values into the sidebar/widget?
- Best way to allow manageable social media URLS?
- Plugin similar to Taxonomy Drill-Down for custom fields?
- How do I query for a post by custom field?
- Count how many posts have a custom field set
- How do you create dynamic customised sections in WordPress?
- Upcoming Event: How do I sort database by custom date field, but ignore past dates?
- sort search results by custom fields using dropdown
- How can I sort homepage by a meta value?
- Creating a custom menu/widget area
- Loop to display random posts only if a custom field matches category
- Conditional custom field query
- Display only past events on that page using Visual Composer Grid Bulider
- Creating a widget with a number of custom fields
- Custom Field Create Bulk via SQL Query
- Create Pop-Up Box with Custom Field Content Inside the Loop
- query usermeta from custom field
- Is there any way to get all meta and standard columns for any WordPress object after searching based on meta key and value
- Order RSS content by an advanced custom field value
- How to display image inside container of custom made widget
- Want to make A CSS if meta key value is empty
- Alter main archive, to show posts with meta as last
- how to display a widget only on a page where the custom field is defined?
- Trying to reorder posts by custom field
- Limits, not all post are showen when querying for posts by view count
- Why orderbyb meta_value_num won’t affect the generated SQL Query order?
- Get post ids sorted by meta_key
- querying a custom field
- pre_get_posts : only get posts by wp_usermeta value
- Query post by date (stored custom field meta as yyyymmdd) and differentiate across 12 months
- How to query an out put value?
- What’s the best way to implement custom widgets on a per post basis?
- List custom queried terms in the edit-tags.php?taxonomy page
- Modify date query by URL parameter using pre_get_posts and $_GET
- Loop through incrementing custom fields
- Custom search SQL Query to add custom field in result
- Is there a way to dump all registered sidebar/widget?
- Display custom widget value in header.php
- Add custom data (field) to sidebar widgets for later display
- The best way to collision check in WP
- How to exclude custom fields from search queries?
- WP_Query () using taxonomy, custom post types
- How to query for posts with either one or another custom field
- Best way to sort estates and query them (for rent? yes/no. contains office space? yes/no)?
- Custom Query: query by post custom meta data
- Custom field outside the loop and inside an array
- Get array of posts based on custom field values
- Searching with Multiple (Parallel) Criteria on Custom Fields?
- How to query posts by month based on date custom field?
- Custom Field Date Problem
- Compare ACF date field (if exists) and post date and order DESC
- Problem with revisions only returning four results
- Search & column order by meta value in admin
- Dynamically populate query source in Elementor post widget
- searching by keywords in post’s metas or pagination links problem
- select user with all meta field and field value. I am use Below Query for this ,So any of know another way to fast query instead of below query?
- Create custom query for search?
- WP_query returns error when used for custom widget
- Add class from custom field into widget class
- Running a Gallery Shortcode in a Custom Fields Widget
- query specific posts according their custom fields, using sql SELECT
- Filter CPT based on meta box value using Flexible Posts widget?
- Meta_query not filtering posts
- Get multiple posts with some custom fields efficient
- How to add a prefix to existing custom fields over MYSQL query?
- Complex WP_Query Using Post Date And Post Meta
- I would like to display different text on different pages
- Only show content slideshow if “slideshow” custom field exists
- How to display search query as formatted text?
- Add fields to edit in custom widget
- Advanced Custom Fields: how do I check to see if a value is set in an field? [closed]
- WP_Query – Order results by meta value
- Add filter menu to admin list of posts (of custom type) to filter posts by custom field values
- getting all values for a custom field key (cross-post)
- How to add a custom field in the advanced menu properties?
- Custom query with orderby meta_value of custom field
- How to filter post listing (in WP dashboard posts listing) using a custom field (search functionality)?
- Using meta query (‘meta_query’) with a search query (‘s’)
- Can I exclude a post by meta key using pre_get_posts function?
- Add validation and error handling when saving custom fields?
- Query to sort a list by meta key first (if it exists), and show remaining posts without meta key ordered by title
- Show Custom Fields in Quick Edit
- Where are custom field values stored in the database
- Validating Custom Meta Box Values & Required Fields
- Max length of meta_value
- Add custom fields to wp native gallery settings
- How to fix missing custom fields after upgrading to WordPress 4.8.1?
- How to enable custom fields for pages (if not a bad practice)?
- How can I add extra attribute in the ‘Page Attribute’ section in wp-admin for pages?
- Is there a way to set default custom fields when creating a post?
- Custom post meta field effect on the performance on the post
- How to get custom post meta using REST API
- Custom field/meta populated by dropdown of existing posts?
- Difference between meta keys with _ and without _ [duplicate]
- Is there any action filter/hook for validating a custom field before publishing the post?