I'm probably doing this all wrong, and there'll be a much simpler solution. Basically, I'm trying to build a table of tour dates that'll be editable by someone with little technical knowledge, but can handle shortcodes. There's also some custom functions in the table (with regards to displaying the date, and having an expiring ticket link) that makes me want to avoid a clunky table plugin.
So here's the code I'm experimenting with, that's working apart from it's introducing a
tag for each new line of and separate short code.
I don't want to disable wpautop completely, as it's used widely throughout the website and elsewhere on the page that this table will be appearing on.
[tour_table tour_name="The Tour Name"]
[tour_table_line tour_date="2011-06-19" ticket_link="http://ticket.link/" venue="The Venue Name"]
[tour_table_line tour_date="2011-06-19" ticket_link="http://ticket.link/" venue="The Venue Name"]
[tour_table_line tour_date="2011-06-19" ticket_link="http://ticket.link/" venue="The Venue Name"]
[tour_table_line tour_date="2011-06-19" ticket_link="http://ticket.link/" venue="The Venue Name"]
[tour_table_line tour_date="2011-06-19" ticket_link="http://ticket.link/" venue="The Venue Name"]
[tour_table_line tour_date="2011-06-19" ticket_link="http://ticket.link/" venue="The Venue Name"]
[/table]
The parsing of the table is all handled in functions.php by the wrapping function tour_table() and the function [tour_table_line] which is executed inside a do_shortcode() function (from the wrapping function).
So the basic problem is that each new line is earning itself a new
tag, which is placing a massive space above the table.
If anyone has any more elegant solutions, or can help me get the functionality I'm looking for, I'd be very appreciative of your help.
If you need more detail, please let me know.
Edit to add functions (probably quite a bit of convoluted code in there:
function tour_table($atts,$content = null){
extract( shortcode_atts( array(
'tour_name' => '',
'anchor_table' => ''
), $atts ) );
if($anchor_table!=""){
$hid = "id=\"tourscrollto\"";
}else{
$hid = "";
}
$theoutput = "<h3 $hid style=\"text-align: left; font-weight: strong; font-size: 12pt; margin-top: 20px;\">";
$theoutput .= $tour_name;
$theoutput .= "</h3><table class=\"tourdates\" style=\"font-size: 10pt;\" width=\"100%\"><tbody>";
$theoutput .= do_shortcode($content);
$theoutput .= "</tbody></table>";
return $theoutput;
}
function tour_table_line($atts){
extract( shortcode_atts( array(
'tour_date' => '',
'ticket_link' => '',
'venue' => 'The Venue'
), $atts ) );
$date_original = $tour_date;
$date_unix = strtotime($tour_date);
$theoutput = "<tr><td>";
$theoutput .= date('D',$date_unix);
$theoutput .= "</td><td>";
$theoutput .= date('j M',$date_unix);
$theoutput .= "</td><td>";
$theoutput .= $venue;
$theoutput .= "</td><td>";
//$ticketlink = ticketlinkexpire($date_original,"<a href=\"$ticket_link\" target=\"_blank\">Buy Tickets</a>","");
//$theoutput .= $ticketlink;
$theoutput .= "</td></tr>";
return $theoutput;
}
add_shortcode( 'tour_table' , 'tour_table' );
add_shortcode( 'tour_table_line' , 'tour_table_line' );
$atts
are set (seeextract
)? Also: Have you triedremove_action()
for wp_autop at the beginning of the function andadd_action()
at it's end? Basically this just removes/adds the function to a global array.