如何将这段HTML码变成一个短码?(添加歌词并为div提供id)

时间:2011-03-19 作者:janoChen

步骤:

别忘了在每个手风琴中使用不同的身份证号码。例如:id=“5”(1到10)

  • 标题位于歌词之间,在每个帖子前放置2个手风琴(如下面的示例)。否则他们会搞砸的。

                <div class="basic" style="float:left;" id="5">
                    <a>There is one obvious advantage:</a>
                    <div>
                        <p>
                            You\'ve seen it coming!<br/>
                            Buy now and get nothing for free!<br/>
    
                            Well, at least no free beer. Perhaps a bear,<br/>
                            if you can afford it.
                        </p>
                    </div>
                    <a>Now that you\'ve got...</a>
                    <div>
                        <p>
                            your bear, you have to admit it!<br/>
    
                            No, we aren\'t selling bears.
                        </p>
                    </div>
                    <a>Rent one bear, ...</a>
                    <div>
                        <p>
                            get two for three beer.
                        </p>
                        <p>
    
                            And now, for something completely different.<br/>
                            And now, for something completely different.<br/>
                            And now, for something completely different.<br/>
                            And now, for something completely different.<br/>
                            And now, for something completely different.<br/>
                            And now, for something completely different.<br/>
    
                            And now, for something completely different.<br/>
                            And now, for something completely different.<br/>
                            Period.
                        </p>
                    </div>
            </div>
    
            <div class="basic" style="float:left;" id="6">
                    <a>There is one obvious advantage:</a>
                    <div>
                        <p>
                            You\'ve seen it coming!<br/>
                            Buy now and get nothing for free!<br/>
    
                            Well, at least no free beer. Perhaps a bear,<br/>
                            if you can afford it.
                        </p>
                    </div>
                    <a>Now that you\'ve got...</a>
                    <div>
                        <p>
                            your bear, you have to admit it!<br/>
    
                            No, we aren\'t selling bears.
                        </p>
                    </div>
                    <a>Rent one bear, ...</a>
                    <div>
                        <p>
                            get two for three beer.
                        </p>
                        <p>
    
                            And now, for something completely different.<br/>
                            And now, for something completely different.<br/>
                            And now, for something completely different.<br/>
                            And now, for something completely different.<br/>
                            And now, for something completely different.<br/>
                            And now, for something completely different.<br/>
    
                            And now, for something completely different.<br/>
                            And now, for something completely different.<br/>
                            Period.
                        </p>
                    </div>
            </div>
    
    我的客户说太复杂了。如何将其转换为短代码?

    EDIT

    这是一个jQuery手风琴,标题放在锚标签中,歌词放在中断标签之前,div的ID必须每次更改。

  • 2 个回复
    最合适的回答,由SO网友:thelovebug 整理而成

    您所要求的可能是使用插件来处理短代码。然而,我无法从你发布的内容中得出你想要实现的目标。

    你能更详细地描述一下你想要实现的目标吗?与其给我们期望的结果,不如提供一些关于如何实现这一目标的信息,这样可能会更有用。

    戴夫

    SO网友:helgatheviking

    我认为shortcode ultimate插件已经可以处理手风琴式的短代码了。

    http://wordpress.org/extend/plugins/shortcodes-ultimate/

    如果不是,也许这一个:

    http://wordpress.org/extend/plugins/j-shortcodes/

    结束

    相关推荐

    Nested Shortcode Detection

    如果您熟悉此代码<?php $pattern = get_shortcode_regex(); preg_match(\'/\'.$pattern.\'/s\', $posts[0]->post_content, $matches); if (is_array($matches) && $matches[2] == \'YOURSHORTCODE\') { //shortcode is being used }&#