0

我想在自定义帖子类型存档页面上列出字母表,并通过单击字母表中的字母链接到仅显示以该特定字母开头的帖子的 url。不一定担心做ajax风格或任何事情。只需一个简单的网址即可。

我在几年前开发的网站(http://glenwoodia.com/business-directory/)上拥有此功能,但那是使用大型企业目录插件。对于这个特定的站点,我只是使用带有自定义字段的自定义帖子类型。

我的完整循环目前看起来像这样:

    <?php
        $temp = $wp_query;
        $wp_query= null;
        $wp_query = new WP_Query();
        $wp_query->query('orderby=title'.'&order=ASC'.'&showposts=15'.'&post_type=businesses'.'&paged='.$paged);
    ?>

    <div class="content">
        <div class="main-area-wide">
            <div class="internal-wide">
                <div class="navigation-top">
                  <?php wp_pagenavi(); ?>
                </div>
                <div class="business-wrapper">
                    <h1>Business Directory</h1> 
                    <?php while ($wp_query->have_posts()) : $wp_query->the_post(); ?>
                        <div class="business">
                        <h3><?php the_title(); ?></h3>
                        <p><?php $key="address"; echo get_post_meta($post->ID, $key, true); ?><br />
                        <a href="<?php $key="website"; echo get_post_meta($post->ID, $key, true); ?>" target="_blank"><?php $key="website"; echo get_post_meta($post->ID, $key, true); ?></a><br />
                        <strong><?php $key="phone"; echo get_post_meta($post->ID, $key, true); ?></strong></p>
                        <p><?php $key="short_description"; echo get_post_meta($post->ID, $key, true); ?></p>
                    </div>
                    <?php endwhile; ?>
                </div>
                <div class="navigation-btm">
                  <?php wp_pagenavi(); ?>
                </div>
            </div>
        </div>
    </div>
4

1 回答 1

0

抱歉,这应该作为评论添加,但我没有代表这样做。无论如何,我相信这是您所需要的,最重要的是它已被很好地记录在案。我以前用过它,发现它很容易理解:

http://www.kathyisawesome.com/424/alphabetical-posts-glossary/

基本上相同的答案也发布在 Stack Exchange 中,请务必向下滚动到答案的 EDIT 部分,因为该部分解释了她在上面的答案中所做的使用分类法:

https://wordpress.stackexchange.com/questions/41660/how-to-build-a-directory-with-indexes-in-wordpress/

于 2013-09-24T22:24:30.413 回答