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 7726799
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:18:17+00:00 2026-06-01T05:18:17+00:00

I have a wordpress loop that pulls all of my data from a table…

  • 0

I have a wordpress loop that pulls all of my data from a table…

            $query = new WP_Query( $args );// The Loop
                $i = 0; $i = -1;

while ( $query->have_posts() )
{
$i++;
$query->the_post();
if ( $keys = get_post_custom_keys() )
{
    echo "<div class='clearfix card-prod ".($i==0?'first':'')."'><div class='top-dets'><span class='card-title'>";
    echo the_title();
    echo "</span>";



    $order_value = get_post_custom_values('order');
    foreach ( $order_value as $key => $value ) {
    echo  $value ;}


// Network query 
    $network_value = get_post_custom_values('srchnetwork');
    foreach ( $network_value as $key => $value ) {
    echo '<span class="srch-val-">'. $value . '</span>'; }

// Pricing Query
    $pricing_value = get_post_custom_values('srchpricing');
    foreach ( $pricing_value as $key => $value ) {
    echo '<span class="srch-val-1">'. $value . '</span>'; }

// Setup Query
    $setup_value = get_post_custom_values('srchsetupfee');
    foreach ( $setup_value as $key => $value ) {
    echo '<span class="srch-val-2">'. $value . '</span>'; }

// Services Query
    $services_value = get_post_custom_values('srchservices');
    foreach ( $services_value as $key => $value ) {
    echo '<span class="srch-val-3">'. $value . '</span></div>'; }

// Big Card Query
    $bigcard_value = get_post_custom_values('bigcard');
    foreach ( $bigcard_value as $key => $value ) {
    echo '<img src="wp-content/themes/cafc/images/cards/'. $value . '" />'; }


echo '<img src="wp-content/themes/cafc/images/top-choice.jpg" alt="Top Choice" class="topchoice">';
echo the_excerpt()."</div>";    

    }
}

my variable $order_value pulls a numberic value from the database in the order they should be listed in…

Is it possible to sort my results based on this value?

$order_value = get_post_custom_values('order');
    foreach ( $order_value as $key => $value ) {
    echo  $value ;}

Taking @David Nguyen advice I pasted in the code to this…

$args = array('orderby' => 'meta_value_num', 'meta_key' => 'order', 'order' => 'DESC',
            'meta_query' => array(
            array(
                'key' => $customkey,
                'value' => $customvalue,
                'compare' => '='
            ),
            array(
                'key' => $customkey1,
                'value' => $customvalue1,
                'compare' => '='
            )
            )
            );

Only it doesnt seem to work…

  • 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-01T05:18:18+00:00Added an answer on June 1, 2026 at 5:18 am

    Add this to your args in WP_Query:

    'orderby' => 'meta_value_num', 'meta_key' => 'order', 'order' => 'DESC'

    http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to setup a loop in Wordpress that will show all posts from
well I have a wordpress loop in wich I want to query posts from
i have a wordpress based website. I have a standard wordpress loop that executes
I have created a category template in Wordpress for all posts that are in
I have written a loop in wordpress that loops through the post titles and
I have some code: ... reader.loop(0, callback) ... (from here http://breakingcode.wordpress.com/2010/04/02/using-impacketpcapy-with-python-2-6-on-windows/ ) How this
I have a json object that I'm loading from wordpress using the JSON API
In wordpress, I have the loop.php file. There I can see the 'read more'
I have a wordpress theme that I like to duplicate. To make things easier
I have a Wordpress site which has post ratings stored in the wp_ratings table,

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.