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 <!-- -->.

  • 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 Dec 10 '13 at 10:18
  • I want the shortcode to show the latest date. It outputs this <!--?php echo date("Y") ?--> – Ben Thompson Dec 10 '13 at 10:27
  • First of all, you should change it to return date("Y"); – Krzysiek Dróżdż Dec 10 '13 at 10:34

Your shortcode function is all wrong, should be:

function copyright_shortcode() {
    return date("Y");
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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