Why are you using $wpdb? This is a simple query,
check the ACF docs for usage examples (https://www.advancedcustomfields.com/resources/query-posts-custom-fields/)
<?php
// args
$args = array(
'numberposts' => -1,
'post_type' => 'product'
);
// query
$the_query = new WP_Query($args);
?>
<?php if( $the_query->have_posts() ):?>
<ul>
<?php while( $the_query->have_posts() ) : $the_query->the_post();?>
<li>
<?php the_title();?> - <a href="https://wordpress.stackexchange.com/questions/285872/<?php the_field("product_url');?>"><?php the_field('product_url');?></a>
</li>
<?php endwhile;?>
</ul>
<?php endif;?>
<?php wp_reset_query();?>
Related Posts:
- Highlighting Sub topic in a post?
- Include data from custom table in WP_Query
- Prioritising and Ordering Posts By Category Name Using A Custom Loop
- Add to search posts query array with post IDS which will appear first
- Nested meta_query with multiple relation keys
- WP_Query vs get_posts
- What is the most efficient way of querying posts based on visits and date for current day?
- How can I save an array from a random post sequence for later use?
- When should you use wp_reset_postdata vs wp_reset_query?
- Limit search results to exact match
- Order posts by tags count?
- Add and in the header while looping over custom query in page template
- Which custom query am I in and how can I access its properties & methods?
- Get number of comments after modifying comment query
- Transient pagination not working properly
- How to speed up wp_query, took more 5s to run against 100k posts
- How do you query wordpress posts using a math formula between multiple meta field values?
- $wpdb->insert inserting two rows in database
- Custom Post order for homepage
- Get image of latest post from taxonomies/categories
- Page navigation doesn’t show when query category
- How To Get Some Data From WordPress Database Using WordPress $wpdb Query?
- Undefined WP_Query::has_posts()?
- Is it possible to dynamically get queried term AND taxonomy?
- Create ONE callback for all page templates, post filter queries + paginated pages, triggering pagination via AJAX
- How to start with post number x?
- Pull post meta with post_query?
- Create unique page without header.php for json feed
- How to access a query twice in different template files?
- Minimize database queries to user tables?
- Sub-loop / nested loops Best Practices
- Query all published post AND attachment with specific mime type
- Add quicklink to in the Admin posts page where I can query by a meta_key
- Get all products which have both product category
- unable to retrive parent page information
- Clean up WordPress code that repeats
- How to display user order by role
- How to use the query hook/filter?
- WP Query related posts by tags
- Order by summing multiple values
- How to list custom fields as headers and list all pages sharing that custom field under it?
- Order by empty custom field
- Cutom wp_query for geolocation search, pagination not working
- Check if loop has any categories?
- No results found from a $wpdb->get_results() query when trying to join more than one meta key query
- Query only the posts with a post format of “audio”
- pre_get_posts – Trying to get property of non-object warning
- WordPress query posts with multiple post_meta data
- Yoast primary category query modification
- Update query for wp_posts and wp_postmeta
- Is it possible to retrieve posts depending on meta_key LIKE condition? [duplicate]
- Write WP Query that selects posts that are part of the same two categories
- WP_User_Query orderby meta_val_num
- WP_Query custom order and pagination
- Custom wp_query – I’m getting ‘all’ post, not the specific post in the query
- Unable to paginate a custom page query
- Include one page/post into query which is already returning posts
- meta_query with array as value with multiple arrays
- Why doesn’t my WP Meta Query return any results?
- Disable (or limit) queries when certain content (or data) is not needed (or showed)
- How to make a query returning pages from multiple parents
- Filter products on category AND tag
- Pagination of custom page with custom fields query
- Query pages created by deleted users
- Exclude post from wp_query based on custom field boolean
- Get posts that match defined arrays of tags
- Doing $wpdb->get_results returns NULL, doing the same query in my DB returns correct value
- How to get meta key list efficiently?
- Order posts by tags count?
- Why pagination is not working with tax_query param?
- Strange results from WP_Query
- Is there a way to control both Order By and Order query parameters from one input field
- I need query_posts() to order results first by a meta value and then by post ID
- WP_Query & Duplicate entries
- return child post if available otherwise parent post
- Search has query that will return no results
- WP Query – Search in title or author_name
- URL to Post Archive of Custom Query
- Query by meta value (add a dropdown of all values)
- orderby in WP_QUERY – Use the order from the Dashboard
- Random posts in WP_Query when searching by tag
- Ordering Posts by parent category, name ascending
- Query posts in current category but not attachment format
- WP_Query always returning the last custom post
- How to query post into a complex slider
- wp_query – Modify $query to include duplicate content
- Optimising specific Query with ACF meta objects
- How to get several fields from wp_query?
- Combine privileged users array with my current query
- Horizontally paginate through sets of blog posts?
- Pagination not working with WP_Query (creates links but no page)
- Query custom post type by date field only working when two posts match the query
- meta_query dates from an array
- Switched from query_posts to wp_query, pagination no longer working
- Divide WP_Query posts by date & post type
- Query Posts by date range with fixed beginning and end
- query by meta value then date and not empty meta value
- New WordPress WP Query using posts from certain categories
- I need to get all categories from a WP_Query
- How to get posts that have certain meta key value and order based on another meta key’s value