我正在使用短代码终极灯箱创建查询.但是这在常规php页面中工作的唯一方法是将数据保存为字符串.所以我需要做的是创建我的查询,但不知何故在字符串中得到我的结果.
这是在我使用任何类型的PHP查询之前的作用:
<?php
$my_tabs = "<ul class='easybuttons'>
<li>[su_lightbox type='inline' src='#lightbox1']AT&T[/su_lightbox]</li>
<li>[su_lightbox type='inline' src='#lightbox2']Sprint[/su_lightbox]</li>
<li>[su_lightbox type='inline' src='#lightbox3']T-Mobile[/su_lightbox]</li>
</ul>";
echo do_shortcode( $my_tabs );
?>
Run Code Online (Sandbox Code Playgroud)
但我需要ATT,Sprint,T-Mobile才能充满活力.请记住,短代码只有在字符串中才有效.
那我怎么能在这个字符串中做一个while循环呢?我尝试使用运算符但没有工作.
$args = array('post_type' => 'services', 'category_name' => $childid, 'order_by' => 'the_title', 'order' => 'ASC');
query_posts($args);
// The Query
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
$my_tabs .= '<ul class="easybuttons">';
while ( $the_query->have_posts() ) {
$the_query->the_post();
$my_tabs .= '<li>[su_lightbox type="inline" src="#lightbox1"]' . get_the_title() . '</li>';
}
$my_tabs .= '</ul>';
} …
Run Code Online (Sandbox Code Playgroud)