You should use Advanced Custom Fields. If I understand what you want to do correctly, you can add a Select Field with Radio Buttons, and then build conditional Page Link and Text (for the URL) Fields that appear based on the Select Field button.
You would then build an if/else statement in the code:
<?php if(get_field('page_link') == "internal"): ?>
<a href="https://wordpress.stackexchange.com/questions/147695/<?php the_field("internal_page_link'); ?>">Page Link</a>
<?php else: ?>
<a href="<?php get_field('external_page_link'); ?>">Page Link</a>
<?php endif; ?>
You can set the two options up to be conditional based on the selected button from select field.
Also note in this example, you should use get_field
for the Text field. This will return it as a string and not output text to html.
Related Posts:
- Add custom template ‘sub-page’ to Custom Post type?
- Displaying posts inside table having issues
- Custom post types & Pages hierarchy – Error 404
- How to Add Custom Fields to a Custom Post Type?
- Do_Shortcode not working for Embed
- Display custom post type and custom fields within a Bootstrap Carousel
- how to filter by last name for custom post
- Search that will look in custom field, post title and post content
- clients list using wordpress
- How to do a custom bookmarks post type?
- How do I add media to a custom post type?
- Using new WP_Query in shortcode in a custom field causes the main post content to not display
- WordPress query by multiple Custom fields and order by date
- Using ‘strtotime’ function to convert a custom-meta-box to a date-stamp
- add_meta_box: Datepicker like the one for postdate?
- Custom field losing p tags on display
- Using posts and postmeta table to store custom Address Book Plugin data
- Bulk edit custom excerpt text in WordPress
- Formatting custom meta box date from YYYY/MM/DD to a more readable alternative
- Getting a “Changes you made will be lost” dialog prompt on a custom post type page
- Frontend posting – everything saves other than checkboxes?
- Search Custom Post Type Custom Fields
- Saving repeated option values in a custom query
- Query Custom Post Types by date (custom field) range
- handling csv data with a custom post type
- How to remove slug metabox from custom post type’s page?
- Check if admin is editing page or custom post type
- Trying to edit the single page from a Custom Post
- Custom fields in Permalinks?
- query posts and custom post type with meta key
- Dynamically add / duplicate custom meta in custom post types
- Problem fields custom date, time, and checkbox
- Custom Post type and Custom Field WP_Query
- create a template page for a post
- Adding Show Less/More link to Custom Post Meta
- Sorting custom post type columns with external data and without meta values
- What is the recommended / best way to do this: Event calendar post/type in a block-based theme?
- WordPress Custom Fields Won’t Save
- Found 2 elements with non-unique id (#_ajax_nonce) and (#_wpnonce)
- Trouble with CPT Child 404
- Store CPT ‘Reviews’ average ratings to a WordPress DB table or to a DB custom table?
- Meta Query Not Returning Output Despite Having Matching Values
- Repeatable Fields Metabox with Textarea (or wp_editor)
- How to use TinyMCE Editor for one of my custom post meta field?
- How to display products name in a non-alphabetical order, in a custom field (taxonomy)?
- Displaying custom field according to date
- filter search custom field query
- How to add multiple markers on the google map, at a certain meta_key and meta_value
- Custom fields for custom post type
- Warning: Invalid argument supplied for foreach() [closed]
- Add additional field to custom post_type
- Multiple pages per post (not pagination)
- Sorting posts by custom field value in array
- How to conditionally add Custom Post Type to Front Page
- Custome fields not displayed
- Displaying custom fields for custom post type generate with Custom Post Type UI Plugin
- Display a post from custom post type only if all the selected taxonomies and custom field value matches the record
- How do I get_the_postID() for a custom post that uses ACF repeater field?
- How to populate a Gravity Forms Custom Post Field (dropdown type) with custom taxonomy terms? [closed]
- Render a Post or Page using the correct file
- Custom post type name and assigning custom taxonomy
- Custom post types, disable fields
- Best way to create a search for custom post type by custom field values
- Building a Portfolio and need some direction
- Need to have an archive widget which organizes and displays a custom post type using a custom date field
- custom post creation on front page – on submit a search is done
- Display Posts Query with IF function
- How to setup different permlalinks for posts and pages?
- Excerpt length: get first paragraph
- Custom PT, Taxonomys and wordpress query
- How can i loop through custom post type according to custom meta field?
- How to use get_post_custom_values to return the value of an array
- Problem with date comparison for custom fields
- CMS – User confusion when creating new page and having to select template and save first to see correct fields
- How do I disable the built-in editor and automatically configure the properties of new pages?
- Orderby meta_key/meta_value not displaying anything, am I overlooking anything?
- Creating a custom page post type just like the original “pages” post type using CPT UI
- Using OR relation in meta_query to check for a value before sorting by another
- How can I create a button that when clicked populates a div with a list of foods that are checked as a certain type of ACF?
- Sort custom post archives by a meta value from a different custom post type?
- Ordering Post by Meta Key (Not Working)
- Error when moving custom post type to bin
- Enforce all custom posts have specific custom fields
- Use WP Title instead of custom field to call
- Add more custom fields when creating a new custom post type
- How do I display specific custom posts, and how do I edit a post’s singular page?
- WP_posts (Not meta) extra custom field column show and change it in a custom post type
- What’s the most efficient way to get two queries based on an if statement?
- Custom Fields as Post Type Options
- How to get past and upcoming post by defining date in custom field?
- Selecting posts older than the current Unix epoch timestamp
- display some fields in custom post backend
- Query Distinct Taxonomies of Custom Post Type
- Excerpt for each post type and for is_front_page
- Select Menu for Custom post Type does not save
- “regular” pages not found after changing permalink
- loop through custom post-type with two meta_keys
- Allow authors to create article image
- Custom Post Type + Custom Meta Query Not Showing 2012 Posts
- Custom Sort Order for Custom Post Type Taxonomy