You are mixing html and php content. You should write it like this:
<?php
function thumbImg() {
if ( has_post_thumbnail() ) {
the_post_thumbnail( array(54,54) );
} else {
echo "<img src="https://wordpress.stackexchange.com/questions/216047/{$data["featured_img']}' alt="".get_the_title()."" />";
}
}
?>
This way, you don’t need to open and close again the php tag.
Related Posts:
- Modify previous and next text from pagination links
- Shortcode putting html such as
- Calling a method from functions.php on a click of a button
- How to redirect users to custom lostpassword page?
- How to change featured content to a different tag in WordPress Twenty Fourteen?
- Can I write ‘RewriteCond’ using ‘functions.php’?
- How do I create comment-reply-button using element not
- How to add 2 posts under another post? Formatting should be intact
- WordPress menu deletes when trying to add a hook
- Overriding a theme redux file in child theme
- Validate a users email address when using gmail to register
- Get widget settings function?
- How to check If Oembed is empty or not
- Making Quote Plugin more efficient
- Adding tawk.to code just before body tag on functions.php file
- allow subscribers to see private posts without plug in
- add_action shortcut?
- remove wp floating submenu in wp dashboard
- ACF: how do I get the fields and its values of a specific group?
- Fatal error: Uncaught Error: Call to undefined function test()
- Get page that displays all children of taxonomy parent
- Return a numerical function value in Customizer controls
- How can I get the values of my WordPress $wpdb query in Jquery?
- Function to capture a value and store it in a variable
- Adding a widget function into the php theme file
- My new button is in the wrong place
- Checking array against author id in loop
- theme_root returning a truncated URI
- Call to undefined method – Download Monitor
- How do I link a button I created in theme customizer to a function?
- Echo string and function?
- How to change menu labels
- Adding wrapper elements in the_date() like in the_title()?
- How to obtain the current website URL in my theme?
- Notify users only on post publish
- Plugin Generate Unexpected output during activation
- Remove Custom Divs from AMP pages
- Read array in php?
- Tell WP register script to load a script only when the entire page is loaded
- Is it possible to display a DIV to not logged in users and then change it for users who are logged in?
- PHP code for displaying WordPress posts in a static page not working
- Remove extract from function
- Undefined offset: 3 in custom function
- Changing the order of custom fields in the dashboard for Woocommerce variable products [closed]
- How to add data to a custom field at the wp_users table?
- How can I use custom menus with a Bootstrap WordPress theme?
- Fallback image URL if no featured image exists via a shortcode function
- Create special button on WP Tiny MCE Posts Editor for Shortcodes
- Deactivate a plugin on wp version
- Get the alt text of the image in a array
- making php value numeric
- the_post_thumbnail issues
- Some problems calling a function into sprintf() inside functions.php template file [closed]
- Make table disappear when fields are left blank?
- WP insert post Redirect after function has executed
- Unzip file in functions.php, and add it to cron
- Add Block Before Entry Title Using PHP
- How to assign page id with array in page_scheduled_event
- Uncaught TypeError: extract(): Argument #1 ($array) must be of type array, null given
- Dynamically populate parameter in Gravity Forms using PHP
- Store ajax data in PHP variable
- comment_post (if comment is approved OR $comment_approved === 1) not working?
- Cannot find the php_ini configuration file to find my error log to see why my code is not working
- How to Send Pingbacks for all Posts in WordPress?
- HTML comment cause issue in functions.php script root
- Programmatically add a product to the cart and set price to zero when buying from certain category
- I want to show cart items number if any or nothing, simple CART text
- Having trouble creating two shortcodes, one for logged in user and one for visitors
- How can i create a function tag in my plugin
- Including user data in “new user notification email”
- Reload page with a different shortcode when a user selects from a dropdown
- Refresh page after login with litespeed cache
- Return newly created category by code
- WordPress Ajax filter: Create two loops for different output styles?
- Woocommerce Add custom “Add to cart button” in single page with tags
- Hook into all password resets in WordPress and get password before hashing?
- How to call a function from functions.php with ajax?
- Set user status to absent on WordPress
- remove_action() not working in page template – Genesis
- How to sort (orderby) a query done by a template function before the ‘foreach’ loop?
- Dropdown menu on custom menu
- Showing wordpress latest post thumbnails in slider with auto increment
- How can the searchform.php know if it’s used on a registered sidebar id ‘sidebar-1’ or ‘sidebar-2’?
- My function echos only “array”
- Notify admin (by email) if post added with specific tag
- WordPress get_post_meta issue
- Woocommerce Price Text
- Limit Taxonomy Parents
- WordPress HTML Helper
- List sibling pages widget, exclude current page
- How to add button to top of theme customizer?
- ajax form function error
- Display custom meta box in my template file
- Send foreach $_post method to contact form 7 [closed]
- Simple Probléme in wordpress
- Options.php loop won’t show!
- Contact form with dynamic dropdown and filter
- Critical Error customiser
- Custom Admin Menu Report for Specific User ID
- how to create twitter card without plugin in wordpress website?