首先,我不是程序员,但我擅长剪切和粘贴。:)我想创建一个下拉列表来显示每一篇文章,我已经将其放入了我的函数中。php子主题文件使用以下代码:
function wpb_recentposts_dropdown() {
$string .= \'<select id="rpdropdown">
<option value="" selected>Select a Post<option>\';
$args = array( \'numberposts\' => \'5\', \'post_status\' => \'publish\' );
$recent_posts = wp_get_recent_posts($args);
foreach( $recent_posts as $recent ){
$string .= \'<option value="\' . get_permalink($recent["ID"]) . \'">\'
. $recent["post_title"].\'</option> \';
}
$string .= \'</select>
<script type="text/javascript"> var urlmenu =
document.getElementById( "rpdropdown" ); urlmenu.onchange =
function() {
window.open( this.options[ this.selectedIndex ].value, "_self" );
};
</script>\';
return $string;
}
add_shortcode(\'rp_dropdown\', \'wpb_recentposts_dropdown\');
add_filter(\'widget_text\',\'do_shortcode\');
我在我的小部件中使用了简短的代码【rp\\U下拉列表】,它可以正常工作。问题是它会显示每个类别的帖子。我需要它显示一个特定的类别,我也希望它是字母顺序。有人能告诉我如何用外行的话说做到这一点吗?非常感谢。