Recently my sites got hacked, forcing me to start rebuilding them from scratch. It's been ages since I spent time on them, so I don't even remember the plugins I'd installed and used. One of them, though, allowed the easy creation of ShortCodes and the "mapping" of text or, even better, HTML and CSS through them. I had used this extensively to style bits and pieces of the posts like in-post Notes, marked as...
[Note]Blah-blah...[/Note]
...adding a custom class "around" the text to allow for extra styling, or...
[AuthorOpinion=X]Blah-blah...[/AuthorOpinion]
...that slapped a whole bunch of DIVs and, depending on author class, a different image as well as "his/her opinion on some matter" (the "blah-blah's")...
...but, also...
[PostIntro=BlahBlah]
...that was "self-contained" and didn't need "closing", with the "Blah-Blah" styled in a more bold way. And a YouTube one. And some other "boxes" of the kind.
Now, I don't remember what plugin that was but, at the same time, since this functionality is supposedly easy to implement directly through WP, I'd prefer doing it "the manual way". Problem is, I've spent the better part of the last six hours copy-pasting code I couldn't make to work, for I suck @PHP.
I managed to make this work:
function postnote_function( $atts, $content = null ) {
return '<div class="note">' . $content . '</div>';
}
add_shortcode('note', 'postnote_function');
...but, for the life of me, I can't make the aforementioned "[Postintro=Blahblah]" work. Every example I saw uses arrays "to feed/pass parameters to functions", but I don't need different "parameters": I need the first paragraph. And, for some reason, no matter how much I prodded the code, it doesn't work for me.
At the moment, my latest non-working copy-paste was this:
function postintro_shortcode( $atts , $content = null ) {
// Attributes
$atts = shortcode_atts(
array(
'type' => '',
'icon' => '',
),
$atts,
'[postintro]'
);
// Return custom embed code
return '<div class="postintro">' . $content . '</div>';
}
add_shortcode( '[postintro]', 'postintro_shortcode' );
Any help? Anyone?