Support » Plugin: Cactus Masonry Classic » Post Sorting

Viewing 5 replies - 1 through 5 (of 5 total)
  • Plugin Author cactus.cloud

    (@bortpress)

    Hey mshetzer,

    Do you have this sorting already functioning in WordPress, or are you starting a new site?

    Unless there is some metadata parameter which I am unaware of (which is very likely), I am not aware of any builtin capability for WordPress to sort posts by their featured image name. I’m pretty sure you can sort by featured image ID, but that may not correlate to the name.

    Cheers

    Thanks for the quick reply.
    I did this on another site for portfolios with the following, and I’m wondering if there could be a modification to do it here.

    Thanks for looking at this !!!
    Matt

    $archive_share = x_get_option( ‘x_integrity_portfolio_archive_post_sharing_enable’ );

    ?>

    <article id=”post-<?php the_ID(); ?>” <?php post_class(); ?>>
    <div class=”entry-featured”>
    <?php x_portfolio_item_featured_content(); ?>
    </div>
    <div class=”entry-wrap cf”>

    <?php if ( x_is_portfolio_item() ) : ?>

    <div class=”entry-info”>
    <header class=”entry-header”>
    <h1 class=”entry-title entry-title-portfolio”><?php the_title(); ?></h1>
    <?php x_integrity_entry_meta(); ?>
    </header>
    <?php x_get_view( ‘global’, ‘_content’, ‘the-content’ ); ?>
    </div>
    <div class=”entry-extra”>
    <?php x_portfolio_item_tags(); ?>
    <?php x_portfolio_item_project_link(); ?>
    <?php x_portfolio_item_social(); ?>
    </div>

    <?php else : ?>

    <header class=”entry-header”>
    <h2 class=”entry-title entry-title-portfolio”>
    ” title=”<?php echo esc_attr( sprintf( __( ‘Permalink to: “%s”‘, ‘__x__’ ), the_title_attribute( ‘echo=0’ ) ) ); ?>”><?php x_the_alternate_title(); ?>
    </h2>
    <?php if ( $archive_share == ‘1’ ) : ?>
    <?php x_portfolio_item_social(); ?>
    <?php endif; ?>
    </header>

    <?php endif; ?>

    </div>
    </article>

    Plugin Author cactus.cloud

    (@bortpress)

    Hey mshetzer,

    Sorry for my late reply. I can see that’s how your results are rendered, but I’d need to see where the query is made.

    If it is made using terms that are compatible with get_posts then I probably could incorporate the functionality into the plugin for you. But, I would need to see where they actually call the query to get the results.

    Cheers again

    I’m actually using a custom function in my child theme to generate the sort order I need. Is there any way I can reference this sort by using your plugin?

    You’re plug in is awesome, and this is just my last step for customization.

    Here is how I’m using it:
    http://www.shetzers.com/pictures/bald-eagle-pictures/

    Here is the function:

    function custom_sorting_function_featured_file($post_list, $sort_view_id, $orderBy, $query)
    {
    //create a map list with posts containing a feature image and another which does not
    $list_map_feature = array();
    foreach($post_list as $object_id)
    {
    $thumbnail_id = get_post_meta($object_id, ‘_thumbnail_id’, TRUE);

    if(empty($thumbnail_id))
    continue;

    $feature_post = get_post($object_id);

    $list_map_feature[$feature_post->post_title] = $feature_post->ID;
    }

    //sort the dates ascending
    asort($list_map_feature);

    $post_list = array_values($list_map_feature);

    return $post_list;
    }

    Plugin Author cactus.cloud

    (@bortpress)

    Nice shots.

    Okay, try this. If it works, I can add some parameters to make it standard in the next update.

    So, try replacing the args variable declaration of masonry-post-gallery.php starting at line 280 with this:

    //Set up query
    $args = array(	'posts_per_page' => -1,
    		'offset' => 0,
    		'meta_key' => '_thumbnail_id',
    		'orderby' => 'meta_value',
    		'order' => self::$a['post_order'],
    		'post_parent' => self::$a['post_parent_id'],
    		'tag' => self::$a['post_tag_slug'],
    		'post_type' => array_merge($post_type, explode(',', self::$a['custom_post_types']))
    );

    Tell me how you go.

Viewing 5 replies - 1 through 5 (of 5 total)
  • The topic ‘Post Sorting’ is closed to new replies.