OminoMichelin
Member
If you're invoking your shortcode in a WordPress template file, even if it's in a region of HTML and not PHP, use do_shortcode() function:
Code:<?php echo do_shortcode("[name_of_shortcode_here]"); ?>
https://developer.wordpress.org/reference/functions/do_shortcode/
If you're invoking your shortcode within another shortcode or within the same shortcode WordPress has trouble rendering that. This makes creating embeddable-shortcodes (e.g., like an accordion within an accordion, or maybe in your case, a grid within a grid) difficult.
Otherwise at least how your function is written looks fine. If the option above still doesn't work, try declaring your variable as a string first. You can try changing your $output line to two lines and do:
Code:$output =''; $output .= '<a class= "il-bando" href="'.the_permalink().'"><div class="grid-item"><span class="span">'.the_title().'</span></div></a>';
That shouldn't change anything, but who knows.
One small HTML point is wrapping your <div> in an <a>. You can do this with HTML5 and it's been common practice for many years now, but you can't with HTML4/transitional and older. That could contribute to your issue if your doctype is set as anything other than HTML5, but I don't think that problem would manifest itself in the way you're describing.
.
My case is actually a grid within an accordion :/. I'll experiment some more, I really want this to work, one way or another.
EDIT: to clarify, it doesn't work even without nesting the shortcodes.
EDIT part too: Ok so, I'm using siteorigin widget to compose the pages. I figured it might lead to problems with this particular endeavour, so I tried to disable it, just for one page. As a result, it still prints all the links and titles one after another, without formatting, AND it also prints the queried posts, which is beyond me as to why it's doing that.
Fun times.