You are trying to echo within a variable. You also have encapsulated PHP tags in the string as well. You need to concatenate just the functions themselves like this:
function default_content($content) {
global $post;
if ($post->post_type == 'my-custom-post-type') {
$content .= '<p style="text-align: center;"><strong>Custom Field Text here: '. get_post_meta( $post->ID, "custom-field-1", true ).'</strong></p>
<p style="text-align: center;"><a href="http://myblog.com/?checkout=" . get_post_meta( $post->ID, "custom-field-2", true )."">Link 01</a></p>';
}
return $content;
}
add_filter('the_content', 'default_content', 0);
Also you are calling global $post, so use $post->ID instead of get_the_ID().
Cheers!
Related Posts:
- Add filter menu to admin list of posts (of custom type) to filter posts by custom field values
- Is there any action filter/hook for validating a custom field before publishing the post?
- Filter WP_Query for posts having a certain meta-value
- Apply the_content filter to a custom field with multiple values
- Pass all custom fields through the same filter on post load?
- WP doesn’t show Array Custom Fields?
- Add new “Insert Into Post” button with another function
- Filter results with custom field values and dropdown
- Add meta data to the menu
- Archive sorting functions by custom fields (front-end)
- can you set a default value to a custom field
- Guest Author – How can I use custom fields to create guest author link?
- Change content before writing to database
- post meta data clearing on autosave
- WordPress Search Custom Meta Field Only
- How do I assign this filter to a variable? (Appending php & markup to the_content)
- Using custom fields in a filter hook
- Add an advert every nth Paragraph
- Add input field to ‘Pages > Edit Page’ through functions.php
- How to filter a dd/mm/yyyy date from a custom field in a query
- Auto-add paragraphs to custom field?
- Add description text under input field for new profile fields
- How to add a predefined custom field without using a plugin?
- Populate Custom Field Dropdown on Theme Install?
- Force hide custom field metaboxes
- Saving custom profile fields
- How to add content at the end of posts?
- Update posts after populating ACF field value [closed]
- How to validate custom field on lost password form before the user id field?
- how to put a custom field value in variable
- Auto Populate Custom Field with Complex Value That Increase by One?
- filtering custom post types via meta data drop down
- global function to apply filter to custom field
- Custom Metabox Not Saving
- Getting the ID of any image for use in functions.php
- Auto-remove custom field with no value on publish
- Display custom field values from posts on frontpage
- How to order posts by one custom field and filter them by another one?
- Filter multiple custom fields Values with Check boxes
- How to get categories with posts by custom field value?
- Redirect to another page using contact form 7? [closed]
- How to Wrote Simple Calculations by Using Custom Fields in Loop?
- Specific coditional usage [closed]
- Best filter to use for modifying custom fields on a post?
- How to display childrens custom fields?
- Hide custom fields when empty
- How to disable Edit Post and Allow only Custom Field?
- Access ACF fields within custom preview function?
- Sort posts by clicks on download button
- Let Users Filter Posts by Custom Fields
- Custom Theme Fields in Settings Menu – apply filters to one of those fields?
- Footnotes in custom fields
- Custom metabox not working
- How to change permalink on headlines in rss feeds?
- How to change order of posts in admin
- Stripping and/or altering the content of a custom field (video URL)
- How to query posts by month based on date custom field?
- Odd functions.php issue in WordPress
- Filter or order based on custom field
- How to show ACF fields in Gridbuilder custom block
- WP meta_query args not working in function
- User Filter Options on Archive Page
- How to add content with a filter when there’s no content in the editor
- change attachment custom field onChange event
- Filter and display a specific custom field value [closed]
- How to filter post using custom feild value in shortest and longest duration?
- Query Posts Via WordPress URL
- Create widget that filters posts on current page based on entered value
- Meta boxes not displayed, data isn’t being saved
- Calling Custom Field within Function wrapped with Divs.
- Get fields from metabox array
- Sort posts after filtering them through multiple taxonomies
- How to automatically create a custom field when a post is published?
- Set new url from custom post field
- How to pass value to add_filter wpcf7_form_tag from another function?
- How to edit the Tags within the image file URLs?
- What is the largest value you can store in a custom field (as meta data for a post)?
- How to retrieve the values of a sub-field in the first and last row of an (ACF) repeater inside function?
- How would I go about replacing this function in my child theme located in inc/template-tags.php
- edit_tag_form_fields is depricated but tag_edit_form_fields doesn’t work
- Retrieve a value from Yoast SEO to use to set a default twitter card image honoring overrides
- Where does this field get its value?
- Walker class for sub-menu with ACF fields
- Get image url using image id
- Can’t properly set the_title add_filter to show short_URL
- How to get correct value from checked()?
- Add_filter when value is no variable?
- Hide text if one custom field out of two is empty [closed]
- How to add_filter html template to middle of content
- Using abs() with custom field in orderby statement
- Set checkbox as checked by default in a metabox
- ACF form edit front end post title does not change permalink
- Can’t save custom field on registration page
- How to check if a PHP string is different than meta field?
- Prevent custom field from being updated after first publish
- Can’t save php string to a custom field
- (Woocommerce) Order by price when entering specific category
- How to list Category list in ACF Pro’s Select Field to choose from [closed]
- Unable to get specific value from post meta
- Filter an WordPress Function in (general-template.php)