the_post_thumbnail
is echoing content. You need get_the_post_thumbnail
instead. That is your problem.
I believe you should be able to swap this: $the_ad = the_post_thumbnail();
, for this: $the_ad = get_the_post_thumbnail();
Related Posts:
- Wp-query causing problems with the_content();
- WP Query group/order by category name
- Custom Taxonomy and tax_query Issue?
- Orderby CPT custom fields not working
- Is there a (preferable built-in) way to check what custom queries are used in a theme?
- Wp Meta Query does not work while simple Query Works
- Get next and prev item from custom WP_Query and Custom Post Type
- Error in WP Query. If variable is empty it is displaying previous post value
- Custom post type not being pulled in widget
- Get Posts in a Custom Post Type category
- Redirect after deleting post and keep track of pagination
- get_edit_post_link() not working as expected when passed id in plugin
- working Custom Post Type and Widget code no longer works when moved from functions.php to plugin
- How to query for posts (in hierarchical custom post type) that have children?
- Combine tax_query and meta_query in WP_Query
- Should unaltered default loop/query return a list of custom posts belonging to a custom taxonomy?
- WP_Query pagination using only numbers instead of /page/1 on URL
- How do I set the content for a post of a particular CPT?
- Uploaded image not appearing in custom post type
- Query for posts in 2 taxonomies
- How do I add a custom button to my “edit” list? ( edit.php?post_type= ) beside “Add New”
- How to add notification in the sidebar of the administration panel when a Custom post type is created? [duplicate]
- Parent / Child formatting in a list of post of a custom post type
- Custom Post Type get_post_type_archive_link( $post_type ) returns false
- How do I create an archive page for standard posts?
- How to have the right design for a custom post type without accessing themes
- Dynamic Custom Post Type Plugin
- Multiple post type queries (with specific arguments for each)
- Custom Post Type Loop within Shortcode
- How to Get Current Custom Post Type Selected Taxonomy Term (Not All Terms)
- Custom Post Type: Upload Multiple Images
- Combining sorted and random CPT
- How to add post_type=value when editing that post type in the WordPress admin?
- WP_Query: include custom post type only with specific meta value
- showing custom post types of a certain category only
- Filtering WP_Query Dynamically on the Front-End
- Getting template_include to work when allow_url_include is off?
- Query Multiple Custom Posts by Custom Fields
- Custom taxonomies relationship
- Custom Permalink to remove category word , keeping posts permalink with date?
- WP_Query orderby and tax_query
- Configuring a meta query with multiple post types that have the same relationship on a single page
- Different Ways to Query Custom Post Types?
- Possible to filter custom post type with multiple meta data?
- ACF in wordpress
- Theme independent plugin by using default page template
- Inefficient Query Confusion
- how to get this tax_query working?
- find custom post type post by searching its custom field with my string
- wordpress lists similar type of posts in a custom post type
- FacetWP paging custom wp_query
- Unable to format dates to put in event calendar
- Custom post type and custom taxonomy 404 on page 2
- Dynamic assign a custom template to custom post type posts
- Cannot get custom posts by category
- Custom post type in Custom widget – $listItem
- Convert Custom Table Data Based Plugin To Be Searchable
- list posts of two post types in a single template
- Make Next and Previous on single-$posttype.php use the same order as archive-$posttype.php
- Custom post-type custom query – show all posts
- Content in WP Editor displayed below CPT shortcode [duplicate]
- Change Text in Admin Panel
- WP Query: If field X is empty, show posts based on field Y
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- How to display the post using a shortcode in WordPress?
- Custom post type specific item design
- meta query condition don’t work
- Filter posts by their related field’s custom field
- Issue removing columns from admin table
- Custom post type category returns null
- Shortcode and get_template_part
- dynamic vue widget inside custom post
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- Query a Custom Post Type using SELECT that has ACF fields to compare dates
- Tell wordpress to show a single page instead of an archive page
- How to get post by meta value
- Wrapping an unknown amount of posts inside separate HTML Containers during WP_Query loop
- WP REST API Custom endpoint don’t work in my plugin
- How do I get all authors posts of a custom post type outside loop
- minimize wp_query call to database
- sorting in wp query based on custom field value
- Facing some Issues on Two Parts Custom Post Type Taxonomy Names
- WordPress loop add heading before first of type
- Only show current category post
- Remove Custom Capability
- Can I override the permalink/slug on creation
- Custom Post Type shows pagination (w/404) or posts_per_page query, but not both
- WP_Query for CPT with filter by another WP_Query
- Is it possible to add query parameters on the archive page?
- Query stopped working
- WP_Query and two custom fields returns no posts
- Custom Taxonomy Showing in WP Menu
- Storing/querying custom date data
- Query Posts From Multiple Post Types
- Custom Post-type not returning the right child_of
- Hide custom post type and use its slug in new plugin menu
- How do I hide single category post on my post page
- querying to custom field over ACF REST API
- Load posts via AJAX without draft status
- WP Query – Can’t get posts with specific taxonomy