Use this.
get_post_meta($post->ID, 'custom-field-name', true);
Where custom-field-name is the name of the custom field. You will have to add your custom field name in place of custom-field-name.
Also to open link in new browser window/tab add target="_blank"
. Always use esc_url()
for URLs and esc_html()
when you want to display a value without working HTML.
$value = get_post_meta( $post->ID, 'Author Website', true );
if ( $value ) {
// Returns an empty string for invalid URLs
$url = esc_url( 'http://' . $value );
if ( '' !== $url ) {
$display = esc_html( $value );
print "<a href="https://wordpress.stackexchange.com/questions/159392/$url" target="_blank">$display</a>";
}
}
You should also store the protocol in the field, because some websites might not be available per http
, just per https
.
Related Posts:
- ORDER BY custom field value
- Best way to programmatically remove a category/term from a post
- display specific custom fields
- Add new “Insert Into Post” button with another function
- Multiple meta values for same meta_key adding on “Preview Changes” hit but not on saving or updating post
- How to add new custom page or post blocks?
- Can serialized arrays in DB be matched against serialized arrays with meta_query?
- Transients vs CRON +Custom Fields: Caching Data Per Post
- How to update serialized data in the user meta data
- Unable to save datetime custom meta field using update_post_meta() function
- Create a select drop down of available menus
- Best way to allow manageable social media URLS?
- Slow meta query with multi meta keys
- Custom Field Multiple Clauses
- Custom field values repeating
- Adding a custom field or metabox to the post-thumbnail widget?
- Using WP Query to search by multiple meta fields
- Get aggregate list of all custom fields for entire blog
- Send Multiple Custom Field Values Through the URL
- Sort by posts that have a featured image?
- WP_Query display next custom post from today’s date
- Can ordering post list by meta_value cause performance issue?
- $wp_query meta_key naming issue [closed]
- Meta_query and numeric comparison [closed]
- Title and post URL based on custom fields?
- Per site configuration
- Alternative to simple fields plugin?
- Custom User Profile Fields
- wp_editor not saving data, and text area showing html tags
- Get specific custom field keys from a post and put into an array
- Importing from XML is ignoring serialized custom field
- How to check for specific meta box value on front end and output accordingly
- Loop to display random posts only if a custom field matches category
- WP Query Returning All Posts
- WordPress User Profile Upload – If page is saved file reset
- How to add field above password section in profile page
- Dynamically fill a post custom field with post publish date
- Select multiple options in WordPress custom meta filed
- filtering custom post types via meta data drop down
- Get content from pages with same meta_key from Database
- How to add an extra field in a post and show it on the template
- Exclude images uploaded via meta boxes from WordPress gallery
- Front-end editing with custom fields?
- If meta key exists in get posts function otherwise create it
- How do i save and retrieve custom attachment meta?
- Show values of dynamically created custom meta keys
- List taxonomy term “Last Name” + “First Name” (taxonomy custom field) in a post loop
- Filter by custom field (meta_key) using JSON API
- Bulk append custom field to post content
- Pass current post title to a predefined link
- Migrating old posts to new wp, how to extrapolate infos from the post body to custom fields?
- shortcode in a custom metabox
- Vimeo thumbnails
- Importing WordPress Posts With Custom Meta Data As CSV Files Through PHPMyAdmin
- Woocommerce Retrieving custom field value from orders
- How can php be used to return data from custom fields in a post?
- If one meta key value is empty, try to get another meta key, and if both meta keys are empty show something else?
- Save attachment ID instead of URL in custom field
- Get meta field value of all catgories
- Displaying a custom field containing a list creates unwanted markup
- Output custom field as ul list
- Multiple Custom Field Query
- How to order posts by number of Vimeo Likes
- Displaying a video on the homepage via a custom field inside a php widget
- Change Page Order by Custom Field (Magic Fields)
- Custom Field is getting the value of another page/post instead of the current one?
- Custom Field Date Problem
- Approach to creating a site with this structure
- how to create meta key name in wp_usermeta table in database
- Display the output from Custom User Fields from a WordPress user profile on a WordPress Custom Page
- how to turn a link field into a button or link text
- Use value from ACF to populate other fields
- Dynamically populate query source in Elementor post widget
- Adding Facebook’s image and meta description retrieval capabilities to a WordPress post
- Why does my numeric meta query work only on one meta key and not the other?
- Show image depending on the number in the custom fields
- Show echo ready in single.php
- Save, update, get and sanitize post meta as HTML not plain
- query_posts -> get page_id from custom field
- author global display format
- Should I store arrays in custom fields or create custom tables?
- Problem saving meta data
- Term specific featured post on taxonomy archive pages
- Custom Meta Boxes and Fields for WordPress: Change directory upload based on user-edit page
- WP_query returns error when used for custom widget
- Saving metadata of related post on save_post
- Custom field value link title
- How to Order Posts by Custom Fields?
- Form fields based on custom fields
- added a meta box to post however when saving menu while debug on throws a warning
- How can i get the actor birthday by date?
- Post rating using Custom Field
- Inserting custom fields into new-post.php without using the Custom Fields Template plugin?
- woocommerce how in checkout to add my custom field check box, and when i check it hide the shipping adress and add tax 19% [closed]
- How can I attach files without using a plugin?
- Advanced Custom Fields for Header that are Editable from a Page [closed]
- Change Fields of Comments and make them searchable?
- Shortcode not picking up custom field
- Order by a meta field in query loop
- Conditional display based on ACF checkbox