我刚刚更新到 Wordpress 3.5,但这使我的代码的一小部分崩溃了:有一个 php 文件,它通过 AJAX 加载了一个带有其画廊的特定帖子。
代码如下所示:
<?php
// Include WordPress
define('WP_USE_THEMES', false);
require('../../../../wp-load.php');
$id = $_POST['id'];
// query post with this identifier
query_posts('meta_key=identifier&meta_value='.$id);
if (have_posts()) :
while (have_posts()) : the_post();
// add content
$content = apply_filters('the_content', get_the_content());
echo '<div class="content-inner">'.$content.'</div>';
endwhile;
endif;
?>
该帖子包含一个 [gallery] 短代码。我已经使用以下代码构建了自己的 Wordpress 库:
remove_shortcode('gallery');
add_shortcode('gallery', 'parse_gallery_shortcode');
function parse_gallery_shortcode($atts) {
global $post;
extract(shortcode_atts(array(
'orderby' => 'menu_order ASC, ID ASC',
'id' => $post->ID,
'itemtag' => 'dl',
'icontag' => 'dt',
'captiontag' => 'dd',
'columns' => 3,
'size' => 'full',
'link' => 'file'
), $atts));
$args = array(
'post_type' => 'attachment',
'post_parent' => $id,
'numberposts' => -1,
'orderby' => $orderby
);
$images = get_posts($args);
print_r($images);
}
这适用于我网站上的所有其他画廊,但不适用于加载 ajax 的画廊。它已与 Wordpress 3.4 一起使用。
Wordpress 3.5 中是否有我忽略的变化?