• I made a post several days ago asking if there was a way to reconfigure the order in which the category links appear on the main page. Since then I’ve discovered that the order in which they are arranged in the database is irrelevant. It actually seems to load them alphabetically.
    This being the case, I’m assuming the query uses an “ORDER BY” to pull them up. does anybody know which PHP file contains this query? Thanks.

Viewing 6 replies - 1 through 6 (of 6 total)
  • template-functions-category.php

    read this https://wiki.www.ads-software.com/list_cats
    I think you’ll find what you need

    wp_list_cats(“sort_order=asc&sort_column=name”) should do the trick.

    Thread Starter njbair

    (@njbair)

    Well I guess there’s nothing WP can’t do ??
    Thanks all

    OK here’s a related question. The context is the narchives.php hack but I don’t think that is significant. If you are creating a page that lists post titles for each category you can set the category order to “asc” and “desc” but can you then define the sort order of the posts within each category (to desc or asc)?
    Andrew

    Andrew,
    Here’s how I did that:
    1. Install the following plugin
    <?php
    /*
    Plugin Name: The Content Category
    Plugin URI: https://www.ads-software.com/#
    Description: Give you the posts from just one category
    Author: Stewart Ugelow
    Author URI: https://www.ugelow.com/
    Version: 1.0
    */
    function the_content_cat ($template_file, $cat_id, $order) {
    $filepath = get_settings(‘siteurl’).”/”.$template_file.”?cat=$cat_id&order=$order”;
    include($filepath);
    }
    ?>
    2. Create a new file “foo.php” (i.e. whatever you want to call it) with the following:
    <?php
    /* Don’t remove this line. */
    require(‘./wp-blog-header.php’);
    ?>
    <?php if ($posts) : foreach ($posts as $post) : start_wp(); ?>
    //Your content goes here
    //In andrew’s case, it would
    //be something like:
    <?php the_title(); ?>
    <?php endforeach; else: ?>
    <?php _e(‘Sorry, no posts matched your criteria.’); ?>
    <?php endif; ?>
    3. From your main page, use the function from the plugin. If you wanted category #3 to be ascending, you would insert:
    <?php the_content_cat(‘foo.php’,3,”ASC”); ?>
    Hope this helps.
    –Stewart

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Category Links’ is closed to new replies.