Site icon Hip-Hop Website Design and Development

Associated put up with out plugin for customized put up sorts

I want some assist modifying this script. I’m attempting to additionally present associated posts by customized taxonomies and customized put up sorts.

//* Outline customized picture measurement for featured picture in Associated Posts
add_image_size( 'associated', 300, 0, true );


add_action( 'genesis_after_entry_content', 'child_related_posts' );
/**
 * Outputs associated posts with thumbnail
 *
 * @writer Nick the Geek
 * @url http://designsbynickthegeek.com/tutorials/related-posts-genesis
 * @international object $put up
 */
operate child_related_posts() {

    if ( is_singular ( ) ) {

        international $put up;

        $rely = 0;
        $postIDs = array( $post->ID );
        $associated = '';
        $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',
                                        'area'     => 'slug',
                                        'phrases'     => 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() ) {

                whereas ( $tag_query->have_posts() ) {

                    $tag_query->the_post();

                    // $img = genesis_get_image() ? genesis_get_image( array( 'measurement' => 'associated' ) ) : '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/photographs/associated.png" alt="' . get_the_title() . '" />';
                    $img = genesis_get_image( array( 'measurement' => 'associated' ) );

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

                    $postIDs[] = $post->ID;

                    $rely++;
                }
            }
        }

        if ( $rely <= 7 ) {

            $catIDs = array( );

            foreach ( $cats as $cat ) {

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

            }

            $showposts = 8 - $rely;

            $args = array(
                'category__in'          => $catIDs,
                'post__not_in'          => $postIDs,
                'showposts'             => $showposts,
                'ignore_sticky_posts'   => 1,
                'orderby'               => 'rand',
                'tax_query'             => array(
                                    array(
                                        'taxonomy'  => 'post_format',
                                        'area'     => 'slug',
                                        'phrases'     => 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() ) {

                whereas ( $cat_query->have_posts() ) {

                    $cat_query->the_post();

                    // $img = genesis_get_image() ? genesis_get_image( array( 'measurement' => 'associated' ) ) : '<img src="' . get_bloginfo( 'stylesheet_directory' ) . '/photographs/associated.png" alt="' . get_the_title() . '" />';
                    $img = genesis_get_image( array( 'measurement' => 'associated' ) );

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

        if ( $associated ) {

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

        }

        wp_reset_query();

    }
}

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

    if ( is_singular( 'put up' ) ) {

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

    }

}

Listed here are the put up sorts that I’ve:

1: put up (tags, classes)

2: custom_post_type: (4 customized taxonomies)

3: custom_post_type: (2 customized taxonomies)

4: custom_post_type: (1 customized taxonomies)

I used to be capable of make some changes by simply trying on the code and was capable of get customized put up sorts associated posts to point out up. Nonetheless, i’m certain that there’s somebody higher than I’m on the market who could make this work.