You’re trying to use PHP tags while inside a string:
'<img src="https://wordpress.stackexchange.com/questions/302344/<?php bloginfo("template_directory'); ?>/images/social/facebook-share.png" />'
You need to instead use concatenation:
'<img src="' . esc_url( get_bloginfo('template_directory') ) . '/images/social/facebook-share.png" />'
Or my personal favorite, sprintf()
:
sprintf(
'<img src="https://wordpress.stackexchange.com/questions/302344/%1$s/images/social/facebook-share.png" />',
esc_url( get_bloginfo('template_directory') )
);
Related Posts:
- Echo URL of large version of Featured Image
- Recent posts with featured image or fallback image with permalink
- Reprinting tags with all attributes
- Scrape external webpage for first image and add it to new post
- Redirect to another page using contact form 7? [closed]
- Only show first image in foreach loop
- Get the id of all images in a post
- Prepend to all image URLs with PHP, only for mobile devices
- Retrieve first image url from custom post with pagination
- bloginfo url in javascript
- Get the post ID and display the images
- Responsive Header for Phone
- Dynamic content based on a URL parameter
- Colon is Missing In My Website Url in WordPress
- How to change redirection route to a php page for making it only accessible by logged-in members?
- How to use $_GET function WordPress backend
- How to get next image with this code from same post?
- Unread Repeater field IMG alt not working
- PHP Array Returning [object Object]. Tried existing answers results with no luck
- foreach loop still echoes array
- Can’t upload image using media_sideload_image
- Upload multiple images to a Woocomerce product
- How to use thumbnail size of image if I’m only using src to get image
- Exclude posts based on meta value
- What is the alternative to “ when it comes to calling Media (image) files in the ‘attachment.php’ file?
- Extend PHP regex to cover “srcset” and “style” attributes
- Accessing an image folder inside public web directory
- get_children displaying images removed from the page
- Why is image hard cropping for one image using add_image_size not working?
- Enable custom logo upload if logo is not in header
- Why my image upload button is not working in wordpress widget area?
- My php header() function is not working [closed]
- Checking array against author id in loop
- How to make own crop image function for WordPress plugin
- “imagejpeg” function is not working in wordpress
- Display image from an external rss feed on wordpress without plugins
- Create custom permalinks to show Custom Post Type’s relationship?
- Search Query: how to construct a search string from two select elements?
- Get URL Parameters from referer
- Need help enqueueing webfonts
- WordPress automatically adds links to uploaded images
- Alter required message using comment form api
- WordPress function when file is uploaded, deleted or edited
- Advanced Custom Fields – display label and value only if value entered
- meaning of (array)function()
- Grouping posts by a custom meta value
- Download images from media library to computer in BULK?
- Three Questions with Twenty Eleven theme
- Why is $wp->request empty in WordPress 6.0?
- Get the URL of the page from which an ajax request has been launched within ajax callback
- How to check if the current page is at a specified path in the URL?
- wp_force_remove_style’ not found
- How to fix this warning:call_user_func_array() expects exactly 2 parameters, 1 given in D:\wamp\www\…….\wp-includes\class-wp-hook.php on line 286
- How can I access string value in an array?
- How to use if statement in an array? [closed]
- WordPress comment submit button substitutes/options
- How to loop through all the attached images in a post, and get their url one by one
- How to array only one key from another array
- Filtering a function’ output for a new continued function
- Which function crops images in wordpress?
- Division by zero error in image.php
- Resize image to specific dimension (X to Y ratio)
- How to pass a PHP $_GET variable and fetch/output it?
- Get html data with javascript to php array and store to wordpress database
- Does anyone know all parameters of get_comments()
- How can I automatically resize up images to fit into all of my registered image sizes
- How do I create a numbered list with PHP? [closed]
- Why is an array created in a function hooked to customize register populated when customizer is loaded but not when the front-end is loaded?
- Clickable image link sends people to wrong URL
- Post’s ID pattern?
- How to use array in function to get only value I want
- Only show image from custom field when present
- Error while setting role
- Get categories names as an array to use it in theme settings
- Timthumb.php image gallery not working on Multisite WordPress
- Upload non-featured image to image field
- How to get the last category name of a child category?
- How to say if meta_value is greater than 0 in an array?
- How to use two meta_compare in an array?
- Warning: in_array() null given in PHP function
- Where are the src and srcset sizes coming from?
- Foreach loop inside an array_merge
- HTML showing after PHP code in tag
- Loop over Array and get the distinct ids
- How to access or parse key/values that have “string”
- If Array Values Match Another Array’s Values, Then
- Remove empty terms from array, sort alphabetically, update back to repeating field
- WordPress loop by meta key that is an array? and how loop multiple arrays
- trying to get wp_get_attachment_url to output clickable link
- Conditional multidimensional arrays and array_map
- Change default gallery images – Currently they are displaying full size imagese
- How can I get all values from my array in a loop in php? [closed]
- Getting posts to exclude from array
- Get all posts as an array ID => Name
- Creating black and white copy of an image [closed]
- Filter by field with array value in ACF on WP REST API
- extract serialized array to use for wp-query
- Need to Modify a WordPress Shortcode with another wordpress shortcode
- Fetching Initials of the Commentator in the WordPress Website
- get users search not working with array