WordPress 自定义帖子循环不起作用 - 不显示任何内容

发布于 2025-01-19 07:56:02 字数 1426 浏览 2 评论 0原文

我有一个定制的帖子类型,该类型使用Pods插件创建,标有“ Camere”复数和“ Camera”单数。

我将这个循环放置在页面上,但没有出现。 甚至没有锚标签中的文本。 如果我将帖子类型的名称更改为单数标签,则浏览器在循环之后也不会呈现代码(div“ servizi”),

<section class="small">
<h2>Le Nostre Camere</h2>
<div class="intro">
<?php echo do_shortcode('[pods field="intro_camere"]'); ?> 
</div>
<div class="lista_camere">
    <div class="lista_camere_item">
        <?php
            $args = array(
                'post_type' => 'Camere',
                'posts_per_page' => 3
            );
            $camere = new WP_Query( $args ); 

        if ( $camere->have_posts() ) : 

        while ( $camere->have_posts() ) : $camere->the_post(); ?>
            <div class="thumb">
                <?php the_thumbnail(); ?>
                </div>
                <h3><?php the_title(); ?></h3>
                <?php the_excerpt(); ?>
                <a href="<?php the_permalink(); ?>" class="button">Scopri di più</a>

            <?php endwhile; ?>

            <?php wp_reset_postdata(); ?>

            <?php endif; ?>
    </div>
</div>
<div class="servizi">
    <h2>Servizi</h2>
    <div class="lista_servizi">
    <?php echo pods_field_display( 'servizio' ); ?>
    </div>
</div>

我找不到问题,我的大脑正在融化

I have a custom post type created with Pods plugin labelled "Camere" plural and "Camera" singular.

I placed in my page this loop but nothing shows up.
Not even the the text in the anchor tag.
if I change the name of the post type to the singular label the browser doesn't render also the code after the loop (div "servizi")

<section class="small">
<h2>Le Nostre Camere</h2>
<div class="intro">
<?php echo do_shortcode('[pods field="intro_camere"]'); ?> 
</div>
<div class="lista_camere">
    <div class="lista_camere_item">
        <?php
            $args = array(
                'post_type' => 'Camere',
                'posts_per_page' => 3
            );
            $camere = new WP_Query( $args ); 

        if ( $camere->have_posts() ) : 

        while ( $camere->have_posts() ) : $camere->the_post(); ?>
            <div class="thumb">
                <?php the_thumbnail(); ?>
                </div>
                <h3><?php the_title(); ?></h3>
                <?php the_excerpt(); ?>
                <a href="<?php the_permalink(); ?>" class="button">Scopri di più</a>

            <?php endwhile; ?>

            <?php wp_reset_postdata(); ?>

            <?php endif; ?>
    </div>
</div>
<div class="servizi">
    <h2>Servizi</h2>
    <div class="lista_servizi">
    <?php echo pods_field_display( 'servizio' ); ?>
    </div>
</div>

I can't find what's wrong and my brain is melting lol

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文