Bumped by Community user
    Bumped by Community user
    Bumped by Community user
    Bumped by Community user
    Bumped by Community user
    Bumped by Community user
    Bumped by Community user
    Question Protected by Community
    Bumped by Community user
    Bumped by Community user
    Bumped by Community user
    Bumped by Community user
    Bumped by Community user
    Bumped by Community user
    Bumped by Community user
    Bumped by Community user
    Bumped by Community user
    Bumped by Community user
    Bumped by Community user
    Bumped by Community user
    Bumped by Community user
    Bumped by Community user
    Bumped by Community user
    Bumped by Community user
2 formatting and grammar
source | link
//* Define custom image size for featured image in Related Posts

add_image_size( 'related', 300, 0, true );

add_action( 'genesis_after_entry_content', 'child_related_posts' ); /** * Outputs related posts with thumbnail * * @author Nick the Geek * @url http://designsbynickthegeek.com/tutorials/related-posts-genesis * @global object $post */ function child_related_posts() {

if add_image_size( is_singular'related', (300, )0, )true {);

    global $post;

   add_action( $count'genesis_after_entry_content', ='child_related_posts' 0;);
  /**
 * $postIDsOutputs =related array(posts $post->IDwith );thumbnail
 *
 * @author $relatedNick =the '';Geek
    $tags =* wp_get_post_tags(@url $posthttp://designsbynickthegeek.com/tutorials/related->ID );posts-genesis
 * @global object $cats$post
 =*/
function wp_get_post_categorieschild_related_posts( $post->ID ); {

    if ( $tagsis_singular ( ) ) {

        foreach ( $tags as $tag )global {$post;

        $count = 0;
  $tagID[]      $postIDs = $tagarray( $post->term_id;>ID );
        $related = '';
        $tags = wp_get_post_tags( $post->ID );
        $cats = wp_get_post_categories( $post->ID );

        }if ( $tags ) {

            foreach ( $tags as $tag ) {

                $tagID[] = $tag->term_id;

            }

            $args = array(
                'tag__in'               => $tagID,
                'post__not_in'          => $postIDs,
                'showposts'             => 8,
                'ignore_sticky_posts'   => 1,
                'tax_query'             => array(
                    array(
                                        'taxonomy'  => 'post_format',
                                        'field'     => 'slug',
                                        'terms'     => array(
                                            'post-format-link',
                                            'post-format-status',
                                            'post-format-aside',
                                            'post-format-quote'
                                            ),
                                        'operator'  => 'NOT IN'
                    )
                )
            )
        );

            $tag_query = new WP_Query( $args );

            if ( $tag_query->have_posts() ) {

                while ( $tag_query->have_posts() ) {

                    $tag_query->the_post();

                    // $img = genesis_get_image() ? genesis_get_image( array( 'size' => 'related' ) ) : '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/related.png" alt="' . get_the_title() . '" />';
                    $img = genesis_get_image( array( 'size' => 'related' ) );

                    $related .= '<div class="related-post"><a href="' . get_permalink() . '" rel="bookmark" title="Permanent Link to' . get_the_title() . '">' . $img . get_the_title() . '</a></div>';

                    $postIDs[] = $post->ID;

                    $count++;
                }
            }
        }
    }

        if ( $count <= 7 ) {

            $catIDs = array( );

            foreach ( $cats as $cat ) {

                if ( 6 == $cat )
                    continue;
                $catIDs[] = $cat;

            }

            $showposts = 8 - $count;

            $args = array(
                'category__in'          => $catIDs,
                'post__not_in'          => $postIDs,
                'showposts'             => $showposts,
                'ignore_sticky_posts'   => 1,
                'orderby'               => 'rand',
                'tax_query'             => array(
                                    array(
                                        'taxonomy'  => 'post_format',
                                        'field'     => 'slug',
                                        'terms'     => array(
                                            'post-format-link',
                                            'post-format-status',
                                            'post-format-aside',
                                            'post-format-quote' ),
                                        'operator' => 'NOT IN'
                                    )
                )
            );

            $cat_query = new WP_Query( $args );

            if ( $cat_query->have_posts() ) {

                while ( $cat_query->have_posts() ) {

                    $cat_query->the_post();

                    // $img = genesis_get_image() ? genesis_get_image( array( 'size' => 'related' ) ) : '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/related.png" alt="' . get_the_title() . '" />';
                    $img = genesis_get_image( array( 'size' => 'related' ) );

                    $related .= '<div class="related-post"><a href="' . get_permalink() . '" rel="bookmark" title="Permanent Link to' . get_the_title() . '">' . $img . get_the_title() . '</a></div>';
                }
            }
        }
    }

        if ( $related ) {

            printf( '<div class="related"><h3 class="related-title">Related Posts</h3><div class="related-posts-list" data-columns>%s</div></div>', $related );

        }

        wp_reset_query();

    }
}

//* Enqueue and initialize wp_reset_queryjQuery Masonry script
add_action( 'wp_enqueue_scripts', 'sk_masonry_script' );
function sk_masonry_script() {

    if ( is_singular( 'post' ) ) {

        wp_enqueue_script( 'masonry-init', get_stylesheet_directory_uri().'/js/masonry-init.js', array( 'jquery-masonry' ), '1.0', true );

    }

}

}

//* Enqueue and initialize jQuery Masonry script add_action( 'wp_enqueue_scripts', 'sk_masonry_script' ); function sk_masonry_script() { Here are the post types that I have:

if ( is_singular( 'post' ) ) {

    wp_enqueue_script( 'masonry-init', get_stylesheet_directory_uri().'/js/masonry-init.js', array( 'jquery-masonry' ), '1.0', true );

}

1: post (tags, categories)

} 2: custom_post_type: (4 custom taxonomies)

Here are the post types that I have3: custom_post_type: (2 custom taxonomies)

1: post (tags, categories) 2: custom_post_type: (4 custom taxons) 3: custom_post_type: (2 custom taxons) 44: custom_post_type: (1 custom taxonstaxonomies)

//* Define custom image size for featured image in Related Posts

add_image_size( 'related', 300, 0, true );

add_action( 'genesis_after_entry_content', 'child_related_posts' ); /** * Outputs related posts with thumbnail * * @author Nick the Geek * @url http://designsbynickthegeek.com/tutorials/related-posts-genesis * @global object $post */ function child_related_posts() {

if ( is_singular ( ) ) {

    global $post;

    $count = 0;
    $postIDs = array( $post->ID );
    $related = '';
    $tags = wp_get_post_tags( $post->ID );
    $cats = wp_get_post_categories( $post->ID );

    if ( $tags ) {

        foreach ( $tags as $tag ) {

            $tagID[] = $tag->term_id;

        }

        $args = array(
            'tag__in'               => $tagID,
            'post__not_in'          => $postIDs,
            'showposts'             => 8,
            'ignore_sticky_posts'   => 1,
            'tax_query'             => array(
                array(
                                    'taxonomy'  => 'post_format',
                                    'field'     => 'slug',
                                    'terms'     => array(
                                        'post-format-link',
                                        'post-format-status',
                                        'post-format-aside',
                                        'post-format-quote'
                                        ),
                                    'operator'  => 'NOT IN'
                )
            )
        );

        $tag_query = new WP_Query( $args );

        if ( $tag_query->have_posts() ) {

            while ( $tag_query->have_posts() ) {

                $tag_query->the_post();

                // $img = genesis_get_image() ? genesis_get_image( array( 'size' => 'related' ) ) : '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/related.png" alt="' . get_the_title() . '" />';
                $img = genesis_get_image( array( 'size' => 'related' ) );

                $related .= '<div class="related-post"><a href="' . get_permalink() . '" rel="bookmark" title="Permanent Link to' . get_the_title() . '">' . $img . get_the_title() . '</a></div>';

                $postIDs[] = $post->ID;

                $count++;
            }
        }
    }

    if ( $count <= 7 ) {

        $catIDs = array( );

        foreach ( $cats as $cat ) {

            if ( 6 == $cat )
                continue;
            $catIDs[] = $cat;

        }

        $showposts = 8 - $count;

        $args = array(
            'category__in'          => $catIDs,
            'post__not_in'          => $postIDs,
            'showposts'             => $showposts,
            'ignore_sticky_posts'   => 1,
            'orderby'               => 'rand',
            'tax_query'             => array(
                                array(
                                    'taxonomy'  => 'post_format',
                                    'field'     => 'slug',
                                    'terms'     => array(
                                        'post-format-link',
                                        'post-format-status',
                                        'post-format-aside',
                                        'post-format-quote' ),
                                    'operator' => 'NOT IN'
                                )
            )
        );

        $cat_query = new WP_Query( $args );

        if ( $cat_query->have_posts() ) {

            while ( $cat_query->have_posts() ) {

                $cat_query->the_post();

                // $img = genesis_get_image() ? genesis_get_image( array( 'size' => 'related' ) ) : '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/related.png" alt="' . get_the_title() . '" />';
                $img = genesis_get_image( array( 'size' => 'related' ) );

                $related .= '<div class="related-post"><a href="' . get_permalink() . '" rel="bookmark" title="Permanent Link to' . get_the_title() . '">' . $img . get_the_title() . '</a></div>';
            }
        }
    }

    if ( $related ) {

        printf( '<div class="related"><h3 class="related-title">Related Posts</h3><div class="related-posts-list" data-columns>%s</div></div>', $related );

    }

    wp_reset_query();

}

}

//* Enqueue and initialize jQuery Masonry script add_action( 'wp_enqueue_scripts', 'sk_masonry_script' ); function sk_masonry_script() {

if ( is_singular( 'post' ) ) {

    wp_enqueue_script( 'masonry-init', get_stylesheet_directory_uri().'/js/masonry-init.js', array( 'jquery-masonry' ), '1.0', true );

}

}

Here are the post types that I have:

1: post (tags, categories) 2: custom_post_type: (4 custom taxons) 3: custom_post_type: (2 custom taxons) 4: custom_post_type: (1 custom taxons)

//* Define custom image size for featured image in Related Posts
add_image_size( 'related', 300, 0, true );


add_action( 'genesis_after_entry_content', 'child_related_posts' );
/**
 * Outputs related posts with thumbnail
 *
 * @author Nick the Geek
 * @url http://designsbynickthegeek.com/tutorials/related-posts-genesis
 * @global object $post
 */
function child_related_posts() {

    if ( is_singular ( ) ) {

        global $post;

        $count = 0;
        $postIDs = array( $post->ID );
        $related = '';
        $tags = wp_get_post_tags( $post->ID );
        $cats = wp_get_post_categories( $post->ID );

        if ( $tags ) {

            foreach ( $tags as $tag ) {

                $tagID[] = $tag->term_id;

            }

            $args = array(
                'tag__in'               => $tagID,
                'post__not_in'          => $postIDs,
                'showposts'             => 8,
                'ignore_sticky_posts'   => 1,
                'tax_query'             => array(
                    array(
                                        'taxonomy'  => 'post_format',
                                        'field'     => 'slug',
                                        'terms'     => array(
                                            'post-format-link',
                                            'post-format-status',
                                            'post-format-aside',
                                            'post-format-quote'
                                            ),
                                        'operator'  => 'NOT IN'
                    )
                )
            );

            $tag_query = new WP_Query( $args );

            if ( $tag_query->have_posts() ) {

                while ( $tag_query->have_posts() ) {

                    $tag_query->the_post();

                    // $img = genesis_get_image() ? genesis_get_image( array( 'size' => 'related' ) ) : '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/related.png" alt="' . get_the_title() . '" />';
                    $img = genesis_get_image( array( 'size' => 'related' ) );

                    $related .= '<div class="related-post"><a href="' . get_permalink() . '" rel="bookmark" title="Permanent Link to' . get_the_title() . '">' . $img . get_the_title() . '</a></div>';

                    $postIDs[] = $post->ID;

                    $count++;
                }
            }
        }

        if ( $count <= 7 ) {

            $catIDs = array( );

            foreach ( $cats as $cat ) {

                if ( 6 == $cat )
                    continue;
                $catIDs[] = $cat;

            }

            $showposts = 8 - $count;

            $args = array(
                'category__in'          => $catIDs,
                'post__not_in'          => $postIDs,
                'showposts'             => $showposts,
                'ignore_sticky_posts'   => 1,
                'orderby'               => 'rand',
                'tax_query'             => array(
                                    array(
                                        'taxonomy'  => 'post_format',
                                        'field'     => 'slug',
                                        'terms'     => array(
                                            'post-format-link',
                                            'post-format-status',
                                            'post-format-aside',
                                            'post-format-quote' ),
                                        'operator' => 'NOT IN'
                                    )
                )
            );

            $cat_query = new WP_Query( $args );

            if ( $cat_query->have_posts() ) {

                while ( $cat_query->have_posts() ) {

                    $cat_query->the_post();

                    // $img = genesis_get_image() ? genesis_get_image( array( 'size' => 'related' ) ) : '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/images/related.png" alt="' . get_the_title() . '" />';
                    $img = genesis_get_image( array( 'size' => 'related' ) );

                    $related .= '<div class="related-post"><a href="' . get_permalink() . '" rel="bookmark" title="Permanent Link to' . get_the_title() . '">' . $img . get_the_title() . '</a></div>';
                }
            }
        }

        if ( $related ) {

            printf( '<div class="related"><h3 class="related-title">Related Posts</h3><div class="related-posts-list" data-columns>%s</div></div>', $related );

        }

        wp_reset_query();

    }
}

//* Enqueue and initialize jQuery Masonry script
add_action( 'wp_enqueue_scripts', 'sk_masonry_script' );
function sk_masonry_script() {

    if ( is_singular( 'post' ) ) {

        wp_enqueue_script( 'masonry-init', get_stylesheet_directory_uri().'/js/masonry-init.js', array( 'jquery-masonry' ), '1.0', true );

    }

}

Here are the post types that I have:

1: post (tags, categories)

2: custom_post_type: (4 custom taxonomies)

3: custom_post_type: (2 custom taxonomies)

4: custom_post_type: (1 custom taxonomies)