Your reply to gregory24 isn’t really explicit enough I’m afraid..
The reason you can display a FontAwesome icon without the if statement is only because this html <span class="fa fa-youtube">...</span>
is loaded into the DOM of you page meanwhile your $youtube_profile
variable is likely containing some value but your statement is wrong.
this should work if $youtube_profile
isn’t empty:
<?php
$youtube_profile = get_the_author_meta( 'youtube_profile' );
if ( !empty($youtube_profile) || $youtube_profile != '' ) {
echo '<span class="fa fa-youtube"><a href="'.esc_url($youtube_profile).'"></a</span> ';
}
?>
BUT..
you don’t need to check twice for the same thing:
!empty($youtube_profile)
AND $youtube_profile != ''
checks are the same
the most simple way would be to simply check it like this, no need of checking if not FALSE just check if TRUE
if ( $youtube_profile ) { ... }
Related Posts:
- Remove Actions/Filters added via Anonymous Functions
- opening links in new tab using – add_filter( ‘the_content’, ‘make_clickable’);
- How to add classes to images based on their categories?
- Use ‘add_theme_support’ instead of ‘add_custom_image_header’ In WordPress 3.4
- Compare post levels and user levels wishlist member
- Generating Responsive Background Image Sizes in PHP
- Change ul class=”children” for wp_list_pages?
- Target a certain page within wordpress backend (admin) i.e. Pages > About
- Set default options for inserting media
- Session is not starting
- Override a class function to include a custom template
- How to auto-update child posts whenever the parent post is updated?
- the_post_thumbnail fallback using hooks
- How to detect first visit of a user?
- Hide WYSIWYG editor on certain templates
- Disable shortlinks like ?p=1234 to prevent scraping
- Redirect a list of URLs to another URL, using functions.php
- Override woocommerce wc-class function
- WP_Remote_Get Not working
- Debugging with functions.php
- How to hide, and not to remove the attributes metabox?
- Getting first Image from post
- Combine two different filter callback functions
- How to limit character length in BuddyPress function output [closed]
- Ordering posts by publish date not working?
- Is possible add icon in title posts only in specific tag?
- Wp_schedule_event functions.php
- How to install Segment on WordPress without a plugin
- How to search using ajax for exact phrase or words in an input field?
- Can’t generate thumbnail images
- Dashboard widget custom positioning?
- Display tags that only appear in one category
- Need help “sanitizing” a custom function that pulls category slug into body class
- How to get data from an array using get_user_meta()
- Space Not Being Generated in HTML Output?
- How to display retweet count and likes in the meta above the excerpt
- Auto Generated HTML source code formatting
- Do not show on homepage functions.php code needed
- Get Comma Seperated Taxonomy Linked Terms and Last Child Separated By “&” Instead Of Comma
- How to remove a specific word at the beginning of the content and add it to the end of the content
- Programmatically add Yoast meta description after post save
- $_Get and &_REQUEST Index Undefined on Functions.php
- Exclude Category ID in function
- get_terms and meta_value results blank
- get_template_directory_uri() links to child theme not parent
- Functions Filter Question [closed]
- Remove attachment page for audio media type only
- Where to store credentials used in a function? [duplicate]
- get_template_directory() – references parent theme directory
- Function that prevents users from uploading photos more photos
- Dequeue scripts in IE7 only using functions.php
- Why I can’t load my JavaScripts using an hook inside my functions.php file?
- Featured Image keeps cropping
- Function Suddenly Stopped Working
- Prevent creating multiple image resizes in twentytwelve template
- Shortcode of a function
- Conditional function for excluding first image from content, not working
- How to add a shortcode to call a function
- How can I call a PHP function inside a hardcoded shortcode?
- WordPress comment_form() does not display actual comments
- Message notification for user
- Disable autosave with `function.php` for custom post wordpress?
- Create a CUstom Archive by Year, but just for a Single Category
- Is it possible to create a shortcode to link to a specific post/page where the tag is just an attribute?
- Different image using srcset function
- Save Meta when custom Taxonomy Saves
- How can I connect to a second database and still be able to use wp functions like get_post_types()?
- Display Script in Header When URL Variable Present
- Render metabox gallery in frontend
- Pagination not working – FrontPage
- how to check if an element in an html file exists in another html file? [closed]
- What is the earliest Hook a Script can use?
- Trying to change widgets h-tags
- I want to display the sku in the product pages of my EDD website
- Adding new Category does not refresh the backoffice
- Getting value of variable from functions.php and debugging it
- Why does echo on functions.php not yield result in source code?
- Child theme, how to cut the functions.php file into several classes?
- Assign IDs to headings in ACF using functions.php
- Redirect specific author posts to another url
- Child Theme not loading multiple stylesheets
- Show number of sold products but be first for less than 2
- How to retrieve image IDs from shortcode content?
- Class::$template_dir_path=get_template_directory();
- admin-ajax.php & my wp-admin folder url showing in header
- WordPress – Custom Nav menu for logged in users – Shopkeeper theme
- Change post count on tag/terms pages to 10
- How to wp_enqueue_script with html?
- Is it possible to change parameters of Parent theme function in the Child theme?
- Error function main() is a non-object to construct my Ajax.php
- java script error Uncaught SyntaxError: Unexpected token ILLEGAL
- Gravity Forms After Submission – GFFormsModel::update_lead_field_value?
- Fatal error after changes to functions.php, even with original file
- update_post_meta after form is submited
- Should I use `get_stylesheet_uri()` or `get_template_directory_uri()` when calling my CSS Stylesheet?
- new to javascript – using in instead of functions.php, not loading correctly
- Remove Disqus JavaScript from homepage
- Missing argument 2
- Get all users from role and add to dropdown (select) – wordpress, javascript
- WordPress enque the same script causes the setInterval not to work