最新消息:雨落星辰是一个专注网站SEO优化、网站SEO诊断、搜索引擎研究、网络营销推广、网站策划运营及站长类的自媒体原创博客

categories - how can i display my posts alphabetically?

programmeradmin2浏览0评论

I want to order my posts alphabetically but I don't know how I can do it with my code. This is my code.

<div class="row">

        <div class="large-6 medium-12 small-12 columns">
            <h3>Elektrotechniek</h3>

            <?php query_posts('category_name=elektrotechniek');
            if (have_posts()) : while (have_posts()) : the_post(); ?>
                    <div class="row">
                        <div class="opleiding-blok">

                            <div class="large-6 medium-6 small-12 columns">
                                <div class="opleiding-image"><?php the_post_thumbnail(); ?></div>
                            </div>

                            <div class="large-6 medium-6 small-12 columns no-padding-left">
                                <div class="opleiding-content">
                                    <div class="opleiding-titel">
                                        <h5><?php the_title(); ?></h5>
                                    </div>
                                    <div class="opleiding-knop">
                                        <a href="<?php the_permalink() ?>" class="button-opleidingen groot" title="Lees verder">Meer Info...</a>
                                    </div>
                                </div>
                            </div>

                        </div>
                    </div>

            <?php endwhile;
            endif;
            wp_reset_query(); ?>

        </div>

</div>

can somebody help me, Thank you

I want to order my posts alphabetically but I don't know how I can do it with my code. This is my code.

<div class="row">

        <div class="large-6 medium-12 small-12 columns">
            <h3>Elektrotechniek</h3>

            <?php query_posts('category_name=elektrotechniek');
            if (have_posts()) : while (have_posts()) : the_post(); ?>
                    <div class="row">
                        <div class="opleiding-blok">

                            <div class="large-6 medium-6 small-12 columns">
                                <div class="opleiding-image"><?php the_post_thumbnail(); ?></div>
                            </div>

                            <div class="large-6 medium-6 small-12 columns no-padding-left">
                                <div class="opleiding-content">
                                    <div class="opleiding-titel">
                                        <h5><?php the_title(); ?></h5>
                                    </div>
                                    <div class="opleiding-knop">
                                        <a href="<?php the_permalink() ?>" class="button-opleidingen groot" title="Lees verder">Meer Info...</a>
                                    </div>
                                </div>
                            </div>

                        </div>
                    </div>

            <?php endwhile;
            endif;
            wp_reset_query(); ?>

        </div>

</div>

can somebody help me, Thank you

Share Improve this question edited Nov 3, 2020 at 8:22 joelschout asked Nov 3, 2020 at 8:16 joelschoutjoelschout 11 bronze badge
Add a comment  | 

1 Answer 1

Reset to default 1

Add both orderby and order query parameters.

Here is an excerpt of the PHP code you need:

$query_args = array(
    "category_name" => "elektrotechniek",
    "orderby" => "post_title",
    "order" => "ASC"
);

Use post_title in case you need to order your posts by title, or post_namein case you prefer to order your posts by slug. Any other field of the wp_posts table can be used to order the posts by.

If you don't add ASC as the order value, WordPress orders the posts in a descendant way.

发布评论

评论列表(0)

  1. 暂无评论