Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9201767
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:05:53+00:00 2026-06-17T23:05:53+00:00

I am querying the terms in a custom taxonomy i have with the following

  • 0

I am querying the terms in a custom taxonomy i have with the following code:

<?php
  $term_slug    = get_query_var('term');
  $taxonomyName = get_query_var('taxonomy');
  $current_term = get_term_by('slug', $term_slug, $taxonomyName);
  $termchildren = get_term_children($current_term->term_id, $taxonomyName);
  foreach ($termchildren as $child) {
    $term = get_term_by('id', $child, $taxonomyName);
    
    echo '<li id="mid"><a href="#tab-' . $slug = $term->slug . '">' . $term->name . '</a></li>';
    
  }
?>

This is all working great! The problem I have is that I would like to order it by menu-order or something similar. At the moment they are in random order!

Can anyone suggest what I need to do?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:05:54+00:00Added an answer on June 17, 2026 at 11:05 pm

    Try to use get_terms function. Your code than would be like this (you can specifiy orderby and order arg)

    <?php
      $term_slug     = get_query_var('term');
      $taxonomy_name = get_query_var('taxonomy');
      $current_term  = get_term_by('slug', $term_slug, $taxonomy_name);
      if ( true === is_a( $current_term, 'WP_Term' ) ) {
          $args = array(
              'child_of' => $current_term->term_id,
              'orderby'  => 'id',
              'order'    => 'DESC'
          );
          $terms = get_terms($taxonomyName, $args);
          if ( true === is_array( $terms ) ) {
              foreach ($terms as $term) {
                  echo '<li id="mid"><a href="#tab-' . esc_attr( $term->slug ) . '">' . esc_html( $term->name ) . '</a></li>';
              }
          }
      }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ~300.000 row table; which includes technical terms; queried using PHP and
I have the following MySQL Query (querying wordpress db): SELECT wp_posts.ID, wp_posts.post_date, wp_posts.post_content, wp_posts.post_title,
I have the following program: public class RegexQueryExample { public static String[] terms =
Basically I'm querying a table like the following keywordId | keyword 1 abc 1
I have made the following search script but can only search one table column
Is there any difference in performance (in terms of inserting/updating & querying) a table
I have a Sql-Server-2008 database that I am querying from on the regular that
In PHP, which is quicker; using include('somefile.php') or querying a MySQL database with a
I have the following tables: TEAMS: ID Name ------ --------- 1 Giants 2 Yankees
does one perform better over the other in terms of indexing/quering etc ? e.g.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.