I created a custom field and would like to use its value as the href on a tag that would go on my footer.
The custom field is on the Settings > General area of the dashboard and I used add_settings_field() in order to create it.
So, for example, the value inserted in my custom field is "" and I would like that in my href. It would basically look like this:
<a href="CUSTOM FIELD VALUE GOES HERE">Click Here</a>
Is there any way to accomplish that?
I created a custom field and would like to use its value as the href on a tag that would go on my footer.
The custom field is on the Settings > General area of the dashboard and I used add_settings_field() in order to create it.
So, for example, the value inserted in my custom field is "https://www.google" and I would like that in my href. It would basically look like this:
<a href="CUSTOM FIELD VALUE GOES HERE">Click Here</a>
Is there any way to accomplish that?
To retrieve a value after using add_settings_field() you should use get_option().
So you could do something like this...
$value = esc_html(get_option('option_name'));
if ($value) {
echo '<a href="' . $value . '">Click Here</a>';
}
You just need to change option_name
to your field name. The code will grab the value and if it isn't false echo the link. Also added the escaping.
*Updated after OP gave more details