使用AJAX

时间:2017-03-26 13:48:41

标签: javascript php ajax wordpress advanced-custom-fields

请指教....

我使用本教程创建过滤器分类:https://www.bobz.co/blog/demo-filter-wordpress-posts-custom-taxonomy-term-ajax/

它回应了我的所有代码,但当我点击某些标签时,它只停止显示我的图像。

我在模板中使用ACF图库代码。

<?php 
$images = get_field('gallery');
if( $images ): ?>
    <ul>
        <?php foreach( $images as $image ): ?>
            <li>
                <a href="<?php echo $image['url']; ?>">
                     <img src="<?php echo $image['sizes']['thumbnail']; ?>" alt="<?php echo $image['alt']; ?>" />
                </a>
                <p><?php echo $image['caption']; ?></p>
            </li>
        <?php endforeach; ?>
    </ul>
<?php endif; ?>

我检查ajax过滤器帖子文件并尝试编辑代码,但仍然没有这样做,请你帮我解决。

当我点击“TAGS”

时,我希望画廊能够显示某些帖子
    $output  = '<h2><a href="'.get_permalink().'">'. get_the_title() . '</a></h2>';
    $output .= get_the_excerpt();


    $result = 'success';

  endwhile; else:
    $output = '<h2>No posts found</h2>';
    $result = 'fail';
  endif;

1 个答案:

答案 0 :(得分:1)

除非看到它,否则我们无法说出最新情况。

此外,如果您想从当前页面获取ACF字段,则必须传递帖子ID。所以,它可能会帮助你猜测而不是调试你的问题。

$images = get_field('gallery', $post_id);

$ post_id应该是您要显示的特定帖子的ID。

希望这可以解决你现在的问题。

如果您向我们提供更多详细信息,我们可以更轻松地查看和检查问题。

由于