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
- Unable to gather Image URL from Custom Post Type’s; Custom Meta Field
- How to keep custom post type related information
- What is the correct way that when creating a custom post type assign values to custom fields created with pods framework?
- when looping through custom post data not appearing
- How to avoid duplicate posts queried from custom meta?
- Custom Metabox Info Not Saving
- How can I query and sort custom-post type using WP_Query
- Metabox collapsed by default
- Meta query and compare “!=” not working as expected
- custom post types, custom fields and normalization
- Display Custom Field or Custom Taxonomy in front page /post/product
- 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?
- Orderby if between two meta fields
- How to add dynamic fields on wordpress custom post type page in admin section
- How to use posts as tabs in a custom page?
- How to access repeater field of a custom field?
- Filter posts by their related field’s custom field
- Custom Post Type Single Page and Archive Page redirects to Home Page
- Post Click Redirect to Custom URL instead of Single Post Page
- wp_insert_post deleting previous post custom meta
- How can I add a meta[] to my custom post type and search by term with the Rest API?
- Show posts from WP Custom Post Type selected from a field in a metabox
- Problem in moving cpt’s from local website to live website
- How can I fetch all the dates from custom fields from various different custom post types and show / list them at one place in ascending order?
- register_rest_field update_callback don’t work for $_FILES
- Query custom post type and custom field by URL parameters
- Creating an archive page or simple template to list all values of a custom field of specific post type listing
- Create Custom page with custom domain
- Where is get_post_meta value located?
- How to stop a permalink redirecting to a page whit same slug but different permalink
- How to convert Post Object Custom Field into Tags
- How do I query with multiple custom fields orderby in same column?
- PHP Warning with Custom Fields
- Custom meta fields not showing up in WP_Response Object via custom endpoint
- Query a Custom Post Type using SELECT that has ACF fields to compare dates
- I want to create a metabox under custom taxonomy
- Do not show child pages within a file page
- meta query multiple values for the same key
- Problem with multi checkboxes value in metabox?
- How can I register multiple custom post fields to json?
- Disable Sidebar on certain pages
- Sort custom post archives by a meta value from a different custom post type?
- Cannot save pages after migration
- filter using custom fields
- Show Post columns to specific users on condition
- Displaying Custom Fields from Custom Post Types [closed]
- Show posts from custom post type sorted by category/taxonomy on a one-pager/page
- Custom post types – meta_query: search lesson which starts sooner
- Sql Update CPT from publish to draft and particular custom field
- Ordering Post by Meta Key (Not Working)
- Post Filtered by Custom Field Value
- Adding a Section for Visitors
- Error when moving custom post type to bin
- Automatic Set Category For A Custom Post Type
- How to Disable option of meta field if that option is selected for any other post in custom post type?
- How to link custom field of two custom post types?
- How to make “single post” permalink maintain it’s sub-page structure
- How to replicate data storage and querying using WordPress. Custom posts/fields or Custom db tables?
- Filter custom WP_Query by first letter of a custom field – hopefully using Search and Filter Pro?
- CPT – Custom Text fields point to new url permalinks
- Autofill advanced custom field with user data
- Confused about where to store my data
- Advanced search form with multiple custom fields
- filter rest api post by a acf filed
- Query posts by multiple custom fields
- How to prepend text to custom field value A, but only if custom field value B matches a certain string?
- Enforce all custom posts have specific custom fields
- Simple Data picker meta box
- How to properly set a value to meta fields of a custom post type in WP-API/node-wpapi REST API?
- sorting in wp query based on custom field value
- Use WP Title instead of custom field to call
- PHP Notice: Unidentified index
- Custom taxonomy template for custom fields loop [closed]
- Meta_Query refuses to return results
- Sort loop by custom field from different post type
- Custom Fields with add_post_meta()
- Run query on specific admin options page and send results to select field in another function
- get_previous_post_link and get_next_post_link of custom post type that share custom field value
- Meta_query by date for Events archive
- Multi Photo Upload with Caption on Front End for Custom Post Type
- How to manage a custom post type archive as a page?
- How to manage a custom post type archive as a page?
- Custom post type that lets users create a set of posts?
- Include images from pages in wp search.php results in default wp search
- Add more custom fields when creating a new custom post type
- Search facility with directories
- check_admin_referer not working in custom meta box for custom post type
- Create Inclusions and exclusions
- 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
- Populate custom post type/custom fields from an external database
- Fixed custom fields depending on posttype/category
- Automatically assign posts with custom field to taxonomy term
- How do I extract the contents of a CPT’s custom field for all posts?
- What’s the most efficient way to get two queries based on an if statement?
- Attach several custom posts to one meta field
- Custom Field to post_title