The get_post_meta function returns an empty string if the key has not yet been set. That means the unused fields are going to result in $link having a value of ”, NOT a value of NULL.
The isset function returns TRUE if the variable exists and has value other than NULL. As $link is not NULL (it’s ”), isset will return TRUE and your code will run.
Perhaps you should use empty instead of isset, although for some reason, I typically use the following:
if (isset($link) && $link != '')
Related Posts:
- How to display Yoast SEO meta description in archive template for each post instead of the_excerpt()? [closed]
- Get ID of a page containing secondary loop in content
- How to add “time” data this?
- Next and Previous loop
- How to hook into container
- Output meta into arrays
- value of metadata is null wrong use of if statement
- Sending mail not working correctly
- using update_user_meta to rank users
- Check value of post meta within IF statement
- Best way to check if a post with specific meta exists
- WP update_post_meta link loop
- Humanmade | Custom meta box class: How to display a repeatable meta box group?
- Display articles related to a custom field on a page
- Redirect loop when trying to login to /wp-admin/ [duplicate]
- How can I custom order the results from wp_list_categories?
- When and Why is is_singular(‘my_cpt’) true while in_the_loop() is false?
- Display all authors and their only one latest post
- Remove comma from last item output from loop
- Getting page ID inside loop
- Page template not displaying
- How to show just private posts in loop
- How to paginate this custom loop? [duplicate]
- Can I use both a custom excerpt and a trimmed excerpt?
- Select data from database and list it in Loop (WordPress)
- How to get_template_part using AJAX?
- wp alchemy multiple image uploader output images to template
- Running a loop with a custom query string on a custom page template
- I’ve been out of the loop since 2.8. What did I miss?
- Loop first six posts in carousel, next eight in grid
- Converting a dynamic piece of code using WordPress Loop into a static one using Post ID
- Infinite blog loop
- One custom loop with condition to check child posts
- Loop get_theme_mod
- Move sticky posts down in main loop
- Why only one post (and no pagination) on this variation of the loop?
- Loop in Related Posts WordPress
- Template structure
- The Loop – mixed ASC and DESC order
- Filter the_posts doesn’t work on search page
- Custom Loop Using Shortcode in Custom Page Template
- Listing subpages title and content and styling the first iteration differently
- Latest Post Styled Different Than other Posts
- ACF custom field in [closed]
- Split wordpress loop to multiple layouts
- WordPress: Loop Help
- Woocommerce: How to display product price [closed]
- Update status of all posts in a category
- Enabling users to control custom loop’s query
- Loop counter style
- Can I add generic numbering HTML classes to items as a loop runs?
- Add “showing posts x to x of y” in custom post type paginated loop
- Custom Post Type on Homepage – Studiopress Genesis Framework
- New loop vs widget
- Display a single category in blog section
- Query Nopaging action not having effect
- Yoast taking over my WordPress title tag [closed]
- Pagination broken after using 2 loops to show content
- Getting page slug
- How to get pagination to work with 2 wordpress loops
- Exclude page from loop results
- How is WordPress changing the content markup?
- Inserting CPT and static content at every X post, is this possible?
- Get most recent post for every term in a given taxonomy type
- Filtering by multiple conditions in the loop
- loop through posts and display inserted media and post title as a link
- Custom Blog Loop on Home Page
- Exceprt not displaying
- Add File Attachment Name and URL into Javascript
- Open Graph in Index Loop
- Using is_page_template inside loop
- How to add custom checkboxes from loop to WooCommerce product variation options?
- Archive: Lists itself
- Please tell how to stop the category from showing up on posts
- How to show the last article in a different way in my blog?
- Can’t limit posts_per_page in loop
- Slug is changing when I use WP_Query in a metabox of a post
- How to fix pagination for custom loops?
- Check to see if a field is within an array in twig
- Custom loop not working in singular.php, working in other pages
- Strange problem with wp_get_attachment_image_src database (db) query count
- Archive sorted by month – separate
- One page loop issue with posts
- Can’t print out returned value
- change the_content images for different sizes (Desktop, tablet, mobile)?
- Get query result before posts are displayed?
- WordPress Group By Problem
- Home page loop with pagination problem
- why get_post_meta is returning 0?
- WooCommerce custom loop pagination on front page
- Eliminate duplicates in a foreach loop [closed]
- Tag custom loop show posts
- get_page() unlike Loop returns the post content without html tags. How can I fix this?
- Problem with ms-thumb-frame-selected class in Master Slider
- I want the first post on my home page to be lengthier than the rest (example included)
- Loop with Custom Post Type Taxonomies and Interstitial Code
- Question about custom plugin
- loop mix my child-category and parent-category
- How can you make it so the comment box shows on some pages or posts but not all?
- Use Base-URL with Query-Loop