Would like to be able to dynamically redirect my custom post to external url link that is in the custom url field in that post.
I am using the following:
$(window).attr('location', "<?php echo rwmb_meta( 'extrnl_url' )>;");
$(location).attr('href', "<?php echo rwmb_meta( 'extrnl_url' ) ?>;");
However this is not working. if I replace this <?php echo ?> with a fixed url, this script works. any help on this is greatly appreciated
Thanks for your reply,
What is my actual problem, is retrieving the url value from custom url field into the script?
I was following the <a href= <?php echo .. example from one of the topic in this forum.
I tried using MB view shortcode and $extrn_url in php, I can't seem to get the url value into the script.
Appreciate your help on this.
Just so you can understand more,
Field ID: extrn_url
I tried the following in PHP and nothing is being retrieve.
and I also tried the following code:
$value = rwmb_get_value ('extrn_url' , $_POST['post_id']);
also tried with rwmb_meta
Still no results.
[oxygen ct_sign_sha256='43a6a06eaad99a3ea156b2b8b4538c3fc993920929650b8dc077274a5437a2b2' data='custom_metabox_content' settings_path='affiliate_url' settings_page='' ]
Any help on this is greatly appreciated. Not sure where I go wrong.
Where did you add the PHP code to show the field value?
<?php echo rwmb_meta('extrn_url'); ?>
You should add it to the post template of the theme to show field value on the single post.
Refer to this documentation https://docs.metabox.io/displaying-fields/#using-code
I added this php code in oxygen template page using code block.
In case of using Oxygen Builder, please reach to them if you have any issues with installation, configuration, compatibility, or usage.
Refer to our support policy https://support.metabox.io/topic/support-policy/