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:
- Most efficient way to add javascript file to specific post and/or pages?
- How to automatically apply woocommerce product title to all product images alt tags?
- How to make an meta_query optional?
- Add custom field to attachments in a specific category
- How to upload imagick resource to media in wordpress
- How can update custom meta for all posts
- Unique key for each row in a repeater field
- Adding featured image via PHP
- WordPress loop specific thumbnail size
- get_post_custom single array
- Make custom field meta not display if there is not data in it
- fallback image for featured image
- Display All Post Attachments and Assign Class to the Last Image?
- How to make thumbnail image fit into a div where image dimentions are completely different?
- How to stop featured image thumbnail [set as background image] on blog index page just repeating same image across all posts
- Trying to add attribute to my posts’ featured image
- Recent posts with featured image or fallback image with permalink
- Custom profile field with birthday. Troubles with
- PHP variable = get_the_post_thumbnail_url outputting without slashes
- wordpress allow user to edit user profile with custom fields
- Store multiple custom field as post meta per post(css, js, html, 2 link) [closed]
- How to VAR_DUMP a $variable during checkout process (Is my product meta callable?)
- Automatic Shortcode Creation with Custom Fields [closed]
- How would an if statement surrounding a custom field with two variables (holding values) look like?
- post thumbnail, conditions, else wont work
- height should be set to auto to avoid pixelation in the post thumbnail function
- How to combine 2 php functions into one function with a custom field
- Saving zero in meta box
- Three Questions with Twenty Eleven theme
- Display related posts without a plugin
- How to check if a PHP string is different than meta field?
- Why does this update_post_meta function not delete the custom field itself?
- WordPress function and string as variable?
- Only show image from custom field when present
- Hide Heading if ACF Field is empty
- Custom meta box values are not getting saved for my custom post type
- WP_Query: getting posts where custom field exists
- Creating an image from a custom field
- User Meta Value not echoing despite Var_Dump Showing correct string
- WordPress loop by meta key that is an array? and how loop multiple arrays
- WP All Import / Update stock quantity from multiple XML files
- Concatenate Custom Field Value & HTML Value
- Else/If Statement to Display Photo Descriptions
- `update_post_meta` not working anymore
- Define category ID using get_post_meta
- How to replace URL protocol using PHP?
- Call featured image url
- Hide a div when a custom field is empty
- Adding custom url to readmore link using get_permalink()
- Filter unique custom field value based on custom taxonomy category or other custom field
- Add “alt” Attribute to GD Star Rating Tags
- Display background color or image with custom meta box?
- custom header text
- Trying to change featured image from 180×180 to full width on home page
- Can ‘Custom Field’ data be inserted into this Short Code?
- Query pulling a single post per month
- Add custom fields from different posts
- Adding a custom meta field with default NULL value which is not selectable
- Order category posts by last word of custom field
- I can’t set image ad fatured programatically
- Products listing check if meta checkbox is checked
- How to update custom fields when post is published?
- Block error message in foreach loop when looping through ACF field
- Hide a div if the fiels is empty
- Inserting a class on before_widget if checkbox is checked
- How to put 2 php codes in functions.php without site crashing
- What is the correct way to search 3 custom fields only in WordPress?
- wp_get_nav_menu_items() with ACF
- WordPress generate images size after upload
- How do I get the value of a current user’s custom field?
- Add a default style if no Featured image is selected
- Having trouble with customizing blog posts on the home page
- How to display custom field from a gallery thumbnail?
- 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
- Custom fields changes the formatting of metabox input
- Basic PHP question (displaying post title over thumbnail) [closed]
- Display Content Based on Custom Field Value
- insert thumbnail image from php script
- If custom field doesn’t exist, or exists and it’s true show title?
- Custom field in title
- How can I put a custom field as the link of a button shortcode?
- Outputting a custom field in PHP
- Custom fields randomly stop working
- 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
- I want Page titles and excerpts to show up on home.php in certain order
- Metadata on the WP_Post object
- Appending an ACF custom field to the page title
- Remove default Image Sizes
- Displaying custom meta box value in a custom post page
- How do you create a front end form that enables the editing of member-specific custom fields in WordPress?
- Search custom post type posts only by meta fields?
- How to pass value to add_filter wpcf7_form_tag from another function?
- fetch from an external api call and display results in page
- Problem with custom user fields default value and retrieval
- Cannot Access ACF Field Values via my Plugin
- hide “Open in New Tab” checkbox in link field
- Custom rest fields not loaded in rest api cpt response