• Resolved jacksghost

    (@jacksghost)


    I’m trying to use a very basic date shortcode on a page and the shortcode itself keeps displaying as text instead of displaying the date.

    I added this to my /functions.php page:

    function LongDate(){
    	return date(‘Y’);
    }
    add_shortcode(‘mylongdate’, ‘LongDate’);

    Then, I added [mylongdate] to my page in the editor and it will only display the actual shortcode [mylongdate] instead of the date. I tried adding the shortocde in both the Visual and Text tabs in the editor and that makes no difference.

    I am developing this site on a temp URL so I have not installed Jetpack yet. Does Jetpack have to be installed for shortcodes to work?

Viewing 2 replies - 1 through 2 (of 2 total)
  • schulte

    (@schulte)

    Hey jacksghost,

    I added a filter and removed some curly quotes. Give [long_date] a try!

    function my_long_date() {
    	return date('Y');
    }
    add_shortcode('long_date', 'my_long_date');
    add_filter('my_long_date', 'do_shortcode');
    Thread Starter jacksghost

    (@jacksghost)

    Hey schulte,

    Of all the silly things, it was the curly quotes. I believe I copy/pasted the function online and did not even notice the single quotes were curly. It works now with or without the add_filter line.

    Thanks!

Viewing 2 replies - 1 through 2 (of 2 total)

The topic ‘Shortcode Displaying as Text’ is closed to new replies.