这是我在WordPress模板的PHP文件中包含一些变量的代码.实际上它是Warp Framework的warp/config.php的精简复制品.
<?php
return array(
'month' => 'Current month',
'year' => 'Current year'
);
Run Code Online (Sandbox Code Playgroud)
是否可以用实际的PHP日期输出替换Current month和发送Current year文本?
我知道如何将PHP日期实现到PHP页面,但我不知道如何将它放在这里.
我有以下代码:
$args = array(
's' => 'Apple',
'cat' => 80,
'posts_per_page' => -1,
'orderby' => date,
'order' => desc,
);
$query = new WP_Query( $args );
echo $query->found_posts.'<br /><br />';
if ( $query->have_posts() ) {
while ( $query->have_posts() ) { $query->the_post();
echo the_time("Y.m.d"); echo ': '; echo the_title(); echo '<br />';
}
}
Run Code Online (Sandbox Code Playgroud)
它在类别 80 中搜索包含“Apple”一词的任何帖子,然后成功输出此类帖子的列表,例如
2
2016.10.10: Apple pie
2016.10.01: Apple juice
Run Code Online (Sandbox Code Playgroud)
如果我还想显示包含“Banana”一词的所有帖子,那么我只需重复代码并's' => 'Apple'替换为's' => 'Banana'并得到类似的内容
1
2016.10.05: Banana fresh
Run Code Online (Sandbox Code Playgroud)
非常简单,直到我想使用单个列表输出两个搜索结果,例如
3 …Run Code Online (Sandbox Code Playgroud) 源 DIV 元素必须出现在目标 DIV 中。
有一种 jQueryappendTo方法似乎可以为我做到这一点。
例如:
<div class="source">Move Me</div>
<div class="destination"></div>
jQuery(document).ready(function(){
jQuery('.source').contents().appendTo('.destination')
});
Run Code Online (Sandbox Code Playgroud)
但实际上它只是将源的内容移动到目标 DIV 中,将空的源 DIV 保留在原来的位置:这是演示这一点的JSFiddle。
所以,而不是
<div class="destination">
<div class="source">Move Me</div>
</div>
Run Code Online (Sandbox Code Playgroud)
该appendTo结果只是
<div class="source"></div>
<div class="destination">Move Me</div>
Run Code Online (Sandbox Code Playgroud)
有没有办法实现
<div class="destination">
<div class="source">Move Me</div>
</div>
Run Code Online (Sandbox Code Playgroud)
没有额外的包装元素?