0

Using SMOF as a backend admin and trying to include a shortcode in the text field for inclusion in the footer.

I am generaing the shortcode as

// Add Shortcode
function copyright_shortcode() {
    // Code
    return '<?php echo date("Y") ?>';
}
add_shortcode( 'copyright', 'copyright_shortcode' );

and calling the data from the SMOF options panel as so

<?php global $data; echo do_shortcode($data['footer_text']); ?>

The footer is generating the text from the field however, it is putting the shortcode data in <!-- -->.

3
  • Can you explain this part: return '<?php echo date("Y") ?>';? Do you want the shortcode to output some PHP code? What's the output of echo $data['footer_text'];?
    – birgire
    Commented Dec 10, 2013 at 10:18
  • I want the shortcode to show the latest date. It outputs this <!--?php echo date("Y") ?--> Commented Dec 10, 2013 at 10:27
  • First of all, you should change it to return date("Y"); Commented Dec 10, 2013 at 10:34

1 Answer 1

2

Your shortcode function is all wrong, should be:

function copyright_shortcode() {
    return date("Y");
}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.