In your modified code (inside your elseif) you have $thumb = the_post_thumbnail( 'medium' );
.
the_post_thumbnail function is not returning a URL, but the entire image.
When you just need to output the source of the image, you should use the_post_thumbnail_url
.
Related Posts:
- How to update custom fields when post is published?
- Block error message in foreach loop when looping through ACF field
- not outputting medium size image URL
- Hide a div if the fiels is empty
- Setting up a cron job to auto update a custom field
- Replace background image with post thumbnail in shortcode
- How to Call on WordPress Custom Fields without a Plugin
- Resize post thumbnail
- Inserting a class on before_widget if checkbox is checked
- Query on a repeater date (acf)
- How to put 2 php codes in functions.php without site crashing
- Generating 3 random numbers and saving them in database
- Where does php code to load data go?
- ACF – Can’t get custom post type by taxonomy
- What is the correct way to search 3 custom fields only in WordPress?
- How to add WordPress Featured image in tag ..?
- wp_get_nav_menu_items() with ACF
- Save custom field on WP_List_Table
- WordPress generate images size after upload
- Sum All the Post Meta of Published posts of Current Logged in user
- How do I get the value of a current user’s custom field?
- Add a default style if no Featured image is selected
- How to link all featured images to custom url in single.php for only non-logged-in users?
- Trying to retrieve meta values from three different meta keys and display in rows
- How to programmatically set existing image in media library the featured image for a post in wordpress
- Having trouble with customizing blog posts on the home page
- WP post meta – for loop inside for loop
- custom fields anchor points php
- How to link featured images in single.php for only non-logged-in users?
- Store custom field’s multiple values in one user meta key
- Get field in readable word
- WooCommerce multiple custom fields code
- Thumbnail wouldn’t scale to size properly
- When working with a post, almost all wp_postmeta are deleted
- What syntax is this? “{{post.price}}”
- Updating Lat and Lng of posts automatically gives sporadic results
- How to display custom field from a gallery thumbnail?
- WP_query meta_query slow with OR and DATES
- Get meta_query value by user meta array
- How to use something like meta_query but for fields?
- Getting a value from a custom field from a page that shares a parent with the current page
- get_post_thumbnail_id returns a negative number
- meta field for numerous links
- Custom fields changes the formatting of metabox input
- Include a custom field in mysql query
- Basic PHP question (displaying post title over thumbnail) [closed]
- Showing featured image of page’s child’s children page
- Display Content Based on Custom Field Value
- insert thumbnail image from php script
- Can’t put a hyperlink on Featured Post’s Image
- php if, else & custom fields – syntax error
- How to get the first letter from custom field?
- Meta box not saving spaces
- add class to background image
- divide custom field values in div every two values
- News and Featured image
- custom field meta-box with dropdown/autocomplete
- Showing custom field contents without listing description
- How to correctly add the featured immage (thumbnails) support in a WP theme? Why I can’t add a featured immage?
- How to exclude post from being queried based on custom meta value
- If custom field doesn’t exist, or exists and it’s true show title?
- How to link a word comprised of a custom field with another?
- Overwriting a Shortcode
- featured post as div background
- How to display thumbnail if post is assigned one otherwise not
- Custom field in title
- Post Thumbnail on Single (if elseif else)
- If Elseif Query
- How can I put a custom field as the link of a button shortcode?
- Outputting a custom field in PHP
- Sorting Meta Fields?
- Custom fields randomly stop working
- the_post_thumbnail unless video id is added
- Display selected parts from selected pages on the frontpage?
- Where can I find the code for the menu page meta boxes?
- How to echo a different field if another field is empty?
- Setting post thumbnail sizes in template file and functions.php
- How to use custom fields to replace top-level parent title with an image using wp_list_pages?
- PHP Puzzle: Unique Styles with PHP loop
- I want Page titles and excerpts to show up on home.php in certain order
- Posts sortable column not sorting properly for custom field numbers
- Search result page – display values from the result’s metaboxes
- Display custom meta box in my template file
- Query posts by custom fields (object post)
- ACF Date fileds to Age Convert [closed]
- Save custom field value to variable for conditional – why is this not working? [closed]
- Problem with custom user fields default value and retrieval
- Cannot Access ACF Field Values via my Plugin
- wordpress-plugin (widget) that performs a Neaby-search on the openstreetmap-endpoint: around x find y
- How to create advanced custom fields for backend content
- ACF block gutenberg aligncenter don’t work
- How to pull through page title depending on which radio button is selected on the specific page?
- Display WooCommerce Order Custom Field In Template (HPOS)
- How can I display a layout differently depending on whether the user is on Mobile or PC?
- hide “Open in New Tab” checkbox in link field
- Restricting Image Upload Sizes using ‘wp_handle_upload_prefilter’ – Stuck media progress bar when Featured Image?
- Want to add custom post type for facebook feed
- Exclude function for custom pages, exclude custom ACF fields
- Custom rest fields not loaded in rest api cpt response
- Display posts in correct month order using single date custom field