cat 链接的循环不循环 WordPress 网站

发布于 2024-11-03 14:18:39 字数 3398 浏览 1 评论 0原文

我有这段代码,所有变量都已加入,但最新消息没有显示。有什么想法吗?

<div class="content">
    <?php get_sidebar('field'); ?>
    <?php
    global $current_user;
    get_currentuserinfo();
    $user_info = get_userdata($current_user->ID);

    if ( have_posts() && $user_info->user_level != 0) : while ( have_posts() ) : the_post(); ?>

    <?php // get custom fields
    $wt_email = get_post_meta($post->ID, 'wt_email', true);
    $wt_feed = get_post_meta($post->ID, 'wt_website', true);
    $wt_facebook = get_post_meta($post->ID, 'wt_facebook', true);
    $wt_twitter = get_post_meta($post->ID, 'wt_twitter', true);
    $wt_linkedin = get_post_meta($post->ID, 'wt_linkedin', true);
    ?>

    <div class="entry">
    <h1><?php the_title(); ?></h1>
    <div class="body">
    <?php the_content(); ?>
    </div>
    <div class="share">
        <div class="links">
            <h3>Links</h3>
            <ul>
                <?php if($wt_twitter) { ?><li><a href="http://<?php print $wt_twitter; ?>">Twitter</a></li><?php } ?>
                <?php if($wt_facebook) { ?><li><a href="http://<?php print $wt_facebook; ?>">Facebook</a></li><?php } ?>
                <?php if($wt_email) { ?><li><a href="mailto:<?php print $wt_email; ?>">Email</a></li><?php } ?>
                <?php if($wt_linkedin) { ?><li><a href="http://<?php print $wt_linkedin; ?>">Website</a></li><?php } ?>
            </ul>
            </div>
<?php endwhile; // End the loop. Whew. ?>
        <div class="news">
            <h3>Latest News</h3>
            <ul>
                <?php
                // The Query
                $loop = new WP_Query( array( 
                    'category_name' => $wt_feed, 
                    'order' => 'ASC', 
                    'posts_per_page'=> 5
                ) );

                // The Loop
                if( $loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post();
                    echo '<li><a href="' . the_permalink() . '">';
                        the_title(); 
                    echo '</a></li>';
                endwhile;
                endif;

                // Reset Query
                wp_reset_query();
                ?>
            </ul>
            <?php 
            $args=array(
              'category_name'       => $wt_feed,
              'type'                => 'post'
              );
            $categories=get_categories($args);

            if($wt_feed) { ?><a href="/<?php print $categories->slug; ?>/feed" class="subscribe">Subscribe</a><?php } ?>
        </div>
    </div>
    </div>

    <?php else : ?>
    <div class="entry">
    <h1>Listing Private</h1>
    <div class="body">
    <p>You need to have a Member account view the details of this list. Request an account membership.</p>
    </div>
    </div>

    <?php endif; ?>

<div class="clearfix"></div>
</div>

I have this code and all the vars pull in but the latest news is not showing up. any ideas?

<div class="content">
    <?php get_sidebar('field'); ?>
    <?php
    global $current_user;
    get_currentuserinfo();
    $user_info = get_userdata($current_user->ID);

    if ( have_posts() && $user_info->user_level != 0) : while ( have_posts() ) : the_post(); ?>

    <?php // get custom fields
    $wt_email = get_post_meta($post->ID, 'wt_email', true);
    $wt_feed = get_post_meta($post->ID, 'wt_website', true);
    $wt_facebook = get_post_meta($post->ID, 'wt_facebook', true);
    $wt_twitter = get_post_meta($post->ID, 'wt_twitter', true);
    $wt_linkedin = get_post_meta($post->ID, 'wt_linkedin', true);
    ?>

    <div class="entry">
    <h1><?php the_title(); ?></h1>
    <div class="body">
    <?php the_content(); ?>
    </div>
    <div class="share">
        <div class="links">
            <h3>Links</h3>
            <ul>
                <?php if($wt_twitter) { ?><li><a href="http://<?php print $wt_twitter; ?>">Twitter</a></li><?php } ?>
                <?php if($wt_facebook) { ?><li><a href="http://<?php print $wt_facebook; ?>">Facebook</a></li><?php } ?>
                <?php if($wt_email) { ?><li><a href="mailto:<?php print $wt_email; ?>">Email</a></li><?php } ?>
                <?php if($wt_linkedin) { ?><li><a href="http://<?php print $wt_linkedin; ?>">Website</a></li><?php } ?>
            </ul>
            </div>
<?php endwhile; // End the loop. Whew. ?>
        <div class="news">
            <h3>Latest News</h3>
            <ul>
                <?php
                // The Query
                $loop = new WP_Query( array( 
                    'category_name' => $wt_feed, 
                    'order' => 'ASC', 
                    'posts_per_page'=> 5
                ) );

                // The Loop
                if( $loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post();
                    echo '<li><a href="' . the_permalink() . '">';
                        the_title(); 
                    echo '</a></li>';
                endwhile;
                endif;

                // Reset Query
                wp_reset_query();
                ?>
            </ul>
            <?php 
            $args=array(
              'category_name'       => $wt_feed,
              'type'                => 'post'
              );
            $categories=get_categories($args);

            if($wt_feed) { ?><a href="/<?php print $categories->slug; ?>/feed" class="subscribe">Subscribe</a><?php } ?>
        </div>
    </div>
    </div>

    <?php else : ?>
    <div class="entry">
    <h1>Listing Private</h1>
    <div class="body">
    <p>You need to have a Member account view the details of this list. Request an account membership.</p>
    </div>
    </div>

    <?php endif; ?>

<div class="clearfix"></div>
</div>

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

┼── 2024-11-10 14:18:39

虽然不是确切的答案,但您是否尝试添加:

error_reporting(E_ALL);
ini_set('display_errors', '1');

在页面顶部,以显示可能发生的任何错误?

Whilst not an exact answer, have you tried adding:

error_reporting(E_ALL);
ini_set('display_errors', '1');

At the top of the page, to display any errors that might be occurring?

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文