Shortcodes in Simple Pages

I successfully created my own shortcode to display in Simple Pages. It works when the shortcode just displays simple text, and lets me put PHP/HTML in the shortcode, but when I go to view the page/page source, all of the PHP tags are commented out. This also happens for some basic Omeka shortcodes. I have HTML filtering turned off in the Security settings.

Possibly related issue: on my Plugins page, there’s no “Configure” button for Simple Pages.

Omeka version: 2.6.1
Simple Pages version: 3.1.1

Can you clarify what’s happening, particularly the part about it also happening for some of the basic shortcodes? I’m not quite sure what you’re putting in the page and what’s getting stripped or commented out.

I don’t know exactly what’s happening with the basic shortcodes, but I can clarify for the one I wrote:

A simple shortcode like

    public function simpleshort($args, $view)
    	return 'Basic shortcode';


successfully returns that text, but a more complicated one like

	public function complicated($args, $view)
    	$y = "yay";
    	return '<p> Here is some text <?php $y?>!';


only displays “Here is some text !” and in the source it shows

<p> Here is some text <!--?php $y?-->!</p>

It coming out inside comments is a little odd, I’m not sure what’s happening there.

At any rate, you can’t usefully output PHP code in a shortcode anyway. Your code needs to execute inside the shortcode function and return whatever output it’s supposed to directly.

In your example you’d want to do something like

return "<p>Here is some text $y !</p>";

You’re right, I was trying to put the PHP in the HTML instead of vice versa. I switched it up and it works great! Thank you so much.

This topic was automatically closed after 250 days. New replies are no longer allowed.