Skip to main content
deleted 52 characters in body
Source Link

It´s easy:

Here is my code:

query_posts(array( 
        'post_type' => 'directors',
        'posts_per_page' => -1,
        'order'    => 'ASC',
        'orderby'  => 'director_weight',
        'meta_key' => 'director_weight'
) );

The main detail is: include meta_key, my code didn´t order unless meta_key is included, and that's all:

Here is the full code of a list of directors pictures order by director_weight:

<?php 
    query_posts(array( 
        'post_type' => 'directors',
        'posts_per_page' => -1,
        'order'    => 'ASC',
        'orderby'  => 'director_weight',
        'meta_key' => 'director_weight'
    ) );
    while (have_posts()) : the_post();
        $directorImg = get_field('director_imagen');
?>  
    <li <?php echo get_field('director_weight') ?>>
        <img src="<?php echo get_field('director_imagen') ?>">
    </li>
<?php
    endwhile;
    wp_reset_query();
?>

order_by custom fiel wordpress

It´s easy:

Here is my code:

query_posts(array( 
        'post_type' => 'directors',
        'posts_per_page' => -1,
        'order'    => 'ASC',
        'orderby'  => 'director_weight',
        'meta_key' => 'director_weight'
) );

The main detail is: include meta_key, my code didn´t order unless meta_key is included, and that's all:

Here is the full code of a list of directors pictures order by director_weight:

<?php 
    query_posts(array( 
        'post_type' => 'directors',
        'posts_per_page' => -1,
        'order'    => 'ASC',
        'orderby'  => 'director_weight',
        'meta_key' => 'director_weight'
    ) );
    while (have_posts()) : the_post();
        $directorImg = get_field('director_imagen');
?>  
    <li <?php echo get_field('director_weight') ?>>
        <img src="<?php echo get_field('director_imagen') ?>">
    </li>
<?php
    endwhile;
    wp_reset_query();
?>

order_by custom fiel wordpress

It´s easy:

Here is my code:

query_posts(array( 
        'post_type' => 'directors',
        'posts_per_page' => -1,
        'order'    => 'ASC',
        'orderby'  => 'director_weight',
        'meta_key' => 'director_weight'
) );

The main detail is: include meta_key, my code didn´t order unless meta_key is included, and that's all:

Here is the full code of a list of directors pictures order by director_weight:

<?php 
    query_posts(array( 
        'post_type' => 'directors',
        'posts_per_page' => -1,
        'order'    => 'ASC',
        'orderby'  => 'director_weight',
        'meta_key' => 'director_weight'
    ) );
    while (have_posts()) : the_post();
?>  
    <li <?php echo get_field('director_weight') ?>>
        <img src="<?php echo get_field('director_imagen') ?>">
    </li>
<?php
    endwhile;
    wp_reset_query();
?>

order_by custom fiel wordpress

Source Link

It´s easy:

Here is my code:

query_posts(array( 
        'post_type' => 'directors',
        'posts_per_page' => -1,
        'order'    => 'ASC',
        'orderby'  => 'director_weight',
        'meta_key' => 'director_weight'
) );

The main detail is: include meta_key, my code didn´t order unless meta_key is included, and that's all:

Here is the full code of a list of directors pictures order by director_weight:

<?php 
    query_posts(array( 
        'post_type' => 'directors',
        'posts_per_page' => -1,
        'order'    => 'ASC',
        'orderby'  => 'director_weight',
        'meta_key' => 'director_weight'
    ) );
    while (have_posts()) : the_post();
        $directorImg = get_field('director_imagen');
?>  
    <li <?php echo get_field('director_weight') ?>>
        <img src="<?php echo get_field('director_imagen') ?>">
    </li>
<?php
    endwhile;
    wp_reset_query();
?>

order_by custom fiel wordpress