我可能做错了,会有一个更简单的解决方案。基本上,我正在尝试构建一个巡演日期表,该表可以由不懂技术的人编辑,但可以处理短代码。表中还有一些自定义函数(关于显示日期和过期票据链接),这让我想避免使用笨重的表插件。
这是我正在试验的代码,除了为每一行新代码和单独的短代码引入一个标记之外,它还可以工作。
我不想完全禁用wpautop,因为它在整个网站和该表将出现的页面上的其他地方都被广泛使用。
[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]
 表的解析都在函数中处理。通过包装函数tour\\u table()和在do\\u shortcode()函数内执行的函数[tour\\u table\\u line](来自包装函数)创建php。
因此,基本问题是,每一条新线都为自己赢得了一个新的标签,即在桌子上方放置一个巨大的空间。
如果有人有任何更优雅的解决方案,或者可以帮助我获得我想要的功能,我将非常感谢您的帮助。
如果你需要更多的细节,请告诉我。
编辑以添加函数(其中可能有相当多的复杂代码:
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\' );
 
                SO网友:markratledge
                我在函数中使用它。php,然后将代码放在编辑器中,我不想自动使用<!-- noformat on --> 和(<);!-- noformat off --> 线
   // <!-- noformat on --> and <!-- noformat off --> function
function newautop($text)
{
    $newtext = "";
    $pos = 0;
    $tags = array(\'<!-- noformat on -->\', \'<!-- noformat off -->\');
    $status = 0;
    while (!(($newpos = strpos($text, $tags[$status], $pos)) === FALSE))
    {
        $sub = substr($text, $pos, $newpos-$pos);
        if ($status)
            $newtext .= $sub;
        else
            $newtext .= convert_chars(wptexturize(wpautop($sub)));      //Apply both functions (faster)
        $pos = $newpos+strlen($tags[$status]);
        $status = $status?0:1;
    }
    $sub = substr($text, $pos, strlen($text)-$pos);
    if ($status)
        $newtext .= $sub;
    else
        $newtext .= convert_chars(wptexturize(wpautop($sub)));      //Apply both functions (faster)
    //To remove the tags
    $newtext = str_replace($tags[0], "", $newtext);
    $newtext = str_replace($tags[1], "", $newtext);
    return $newtext;
}
function newtexturize($text)
{
    return $text;   
}
function new_convert_chars($text)
{
    return $text;   
}
remove_filter(\'the_content\', \'wpautop\');
add_filter(\'the_content\', \'newautop\');
remove_filter(\'the_content\', \'wptexturize\');
add_filter(\'the_content\', \'newtexturize\');
remove_filter(\'the_content\', \'convert_chars\');
add_filter(\'the_content\', \'new_convert_chars\');