Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I've been trying tons of things for the last 2 days. I'm at a standstill now. I read a ton of posts here but nothing has worked yet.

I have a CPT 'artists'. This CPT contains a custom field checkbox called Featured Artists 'ecpt_featured_artist'. Within the Genesis Grid Loop on the Artists archive page 'artists-archive.php' I am able to target the Featured Artist like this:

$featuredartist = get_post_meta($post->ID, 'ecpt_featured_artist', true); ?>
<?php if( $featuredartist ) {
    echo '<div class="featured-ribbon"><a href="';
    echo get_permalink();
    echo '"><img src="image-link-here" alt="Featured Artist Ribbon"></a></div>';
}

I'm currently using Bill Erickson's code to put the artists-archive in a grid... like this:

    function be_archive_post_class( $classes ) {
    $classes[] = 'one-fourth';
    global $wp_query;
    if( 0 == $wp_query->current_post || 0 == $wp_query->current_post % 4 )
        $classes[] = 'first';
    return $classes;
}
add_filter( 'post_class', 'be_archive_post_class' );

What i'm trying to accomplish: I want to query ONLY post with the checkbox checked, and display them in the Genesis Grid, on a page called Featured Artists. Right now i'm attempting to do that via a page template. If there is a better way altogether to accomplish this, I'm open to suggestions.

Right now, I can't even query the posts properly. My last failed attempt looked like this:

add_action('genesis_loop', 'gt_custom_loop');
function gt_custom_loop() {
global $paged;

    $args = array(
    'post_type' => 'artists',
    'key' => 'ecpt_featured_artist',
    'compare' => '=',
    'type' => 'CHAR',
    'value' => 1,
    );
    // Accepts WP_Query args 
    // (http://codex.wordpress.org/Class_Reference/WP_Query)
    genesis_custom_loop( $args );

}

Any help appreciated!

EDIT: I've reduced it down to minimal code ONLY in my functions.php file, with the page using the default page template.

This code now 404's me on my 'page' Featured Artists:

add_action( 'pre_get_posts', 'pw_filter_query' );
function pw_filter_query ( $query ) {
    if( $query->is_page('featured-artists')) {
    $query->set('post_type', 'artists');
    }   
}

What is going on!?

share|improve this question
add comment

1 Answer

Well I don't know anything about genesis, but if it does indeed use WP_Query args, then your args array should be something like:

 $args = array(
    'post_type' => 'artists',
    'meta_key' => 'ecpt_featured_artist',
    'meta_value' => 1,
    );
share|improve this answer
    
Using your args in the code I have above returned "Sorry, no posts matched your criteria." I'm lost. –  JiveDig Feb 22 '13 at 1:12
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.