You get the error because you try to call php inside php. Try to use this snippet and see what is different:
<?php
if(get_field('post_image'))
{
echo '<img src="'. get_field('post_image') .'" />';
}
else {
echo '<img src="' . get_bloginfo('template_url') . '/images/images/default.jpg" />';
}
?>
Also pay attention that bloginfo
immediately prints value, when get_bloginfo
returns it.
Related Posts:
- How do I change/modify the_post_thumbnail(); html output?
- Add custom HTML to posts page
- Converting HTML Template to WordPress Theme
- Customize position of social icons in upme plugin [closed]
- How to get the value of input hidden html from text editor to custom page template?
- How do I add a custom css to all posts without affecting homepage css? [closed]
- Add data-id attribute to child page links
- Clickable image link sends people to wrong URL
- Displaying images outside the content
- Hide A Class and Add Custom HTML Code Using WordPress
- Configure WordPress to Use Responsive Image Rendering
- How to use data URL in WordPress?
- How to include different html tags in the header for different pages?
- Multisite – Display different header content based on which site is accessed
- How do I routinely extract the thumbnail of the most recent post?
- My customizer’s setting doesn’t set to the default and needed to click the control’s “Default” button before it’ll be set
- Gallery requires a featured image but does not show it in posts/pages
- Save Option on Database
- How to remove the intro animation which appears during the load up of some WordPress themes? [closed]
- Add multiple HTML attributes to an Elementor button
- Theme currently showing thumbnails, how to show full size?
- WordPress automatically adds tags when pasting code, how to stop it?
- Add HTML Attributes To Anchor Tags In `wp_list_categories()` Function
- Placing raw HTML inside a WordPress shortcode
- How to only show page id as body class?
- Validate Uploaded Image using WordPress’ Built-in Functions?
- How to create and work with custom data / tables (i.e., for arbitrary data)?
- How do I implement a .diff changeset from core.trac.wordpress.org locally?
- Get most recent media upload
- PHP can I add line numbers to file_get_contents()
- How to get 2 or multiple custom post types in wordpress functions.php
- Slide in Panel WordPress Post
- Shortcode content output but not in correct place
- IMG src weird behaviour inside a single post loop
- Convert all images to PNG on file upload
- Escape post image attachments added to template
- Multiple choice in a custom taxonomy
- Correct syntax to html php conversion
- An unwanted inline style is added to my body tag
- How to properly insert a link to a template in WordPress?
- Auto crop images in WordPress
- Display post image with fancybox
- Upload Image in a WordPress page using PHP
- Displaying theme options in css
- Show post in slider
- Add itemprop Schema.org Markup to li Elements in wp_nav_menu
- Creating bulk posts with Youtube videos
- How to get media objects
- PHP code to call image Caption, Alternative Text, and Decription?
- Removing unneccessary p-tags (Not every p)
- Random Default Avatar Function
- Echo URL of large version of Featured Image
- How can I hide Home in my menu in a specific page?
- WordPress automatically adding html tag around PHP code
- How do I let users upload files to a chosen location?
- Missing sidebar parameter “fix” – before_content
- Change the URL of an image from wp_get_attachment_image_src except in the frontpage
- Get different images for mobile and desktop with php, advanced custom fields without using js and ajax
- How Display Posts on category
- Hide wordpress field if data is empty in post!
- How to get specific image in media library with php
- How to get the POST TITLE using the POST ID?
- Change the site tagline (or similar) based on current page
- hover image appears below placeholder instead of overlayed
- Trouble creating conditional PHP for nav menu items with children for custom Walker
- HTML tags in bloginfo description
- Setting custom canonical urls
- Only show search results with if current date is between two dates?
- database interactions using OOP
- Customizer: Output default value in Customizer CSS
- ACF page while loop breaks footer while loop
- How to add just one specific page to widget without plugin?
- Remove one value in dismissed_wp_pointers?
- create a select input with menus created on a custom options page
- Taxonomy linked to pages
- Getting a specific post values to another div or modal
- Add a class to the anchor tag on HTML5 gallery
- Transferring working local PHP site to wordpress – with database (MySQL)
- add_image_size for header_image
- Add custom url to featured image
- Get image’s size name from it’s dimension
- Cannot display or echo alt text on featured image
- Create another “Display Site Title and Tagline” checkbox, “Header Text Color” setting and control
- how to remove metadata from the posts of my blog?
- Load a page into a div with Ajax
- Recent posts with featured image or fallback image with permalink
- Accessing data from a non-WP database/table within a page content
- My form action url is being prepended with a directory that does not exists
- WordPress blog post url on category page
- Best practice for migration friendly images in posts/pages?
- Where in PHP do I move title and meta (date) to bottom of each blog section?
- Changing layout with wp_customise
- WP dynamic featured image – Can’t get second featured image url
- Extending the WP_Widget_Text class
- Set the background to a default image if there isn’t a specified “featured image”
- Multiple options not staying selected after saving
- Using the echo command adds unwanted br tags to source
- custom fields wordpress
- Selectbox in admin panel function linking to CSS
- Mass update excerpt