• Resolved leoahrens

    (@leoahrens)


    Hey hey!

    Sooooo I’m working on a new portfolio site powered with Jetpack. The template has a “Default” page template and a “Portfolio” page template. What the “Portfolio” page does is insert your standard content then adds an additional portfolio feed under the content.

    I want to replicate this inserted portfolio feed at the bottom of all my single post pages, “content-portfolio-single.php”

    What I have done is copy what I think is the proper code to call the posts and inserted it after the single post content. However it doesn’t fully work. It inserts a bunch of white space and links to the content but no images.

    This is the code I have inserted after the post content…

    
    <?php
    				if ( get_query_var( 'paged' ) ) :
    					$paged = get_query_var( 'paged' );
    				elseif ( get_query_var( 'page' ) ) :
    					$paged = get_query_var( 'page' );
    				else :
    					$paged = 1;
    				endif;
    
    				$posts_per_page = get_option( 'jetpack_portfolio_posts_per_page', '11' );
    				$args = array(
    					'post_type'      => 'jetpack-portfolio',
    					'posts_per_page' => $posts_per_page,
    					'paged'          => $paged,
    					'1'          	 => $paged,
    					'orderby'		 => 'rand'
    				);
    				$project_query = new WP_Query ( $args );
    				if ( post_type_exists( 'jetpack-portfolio' ) && $project_query -> have_posts() ) : 
    			?>
    
    				<div class="portfolio-wrapper">
    
    					<?php /* Start the Loop */ ?>
    					<?php while ( $project_query -> have_posts() ) : $project_query -> the_post();  ?>
    
    						<?php get_template_part( 'content', 'portfolio' ); ?>
    
        				<?php endwhile; ?>				
    				
    
    				</div><!-- .portfolio-wrapper -->
    			
    
    <?php
    					illustratr_paging_nav( $project_query->max_num_pages );
    					wp_reset_postdata();
    				?>
    <?php else : ?>
    
    			<?php endif; ?>

    I’m guessing somewhere in the query it is getting thrown off because it is a random page and not the “Portfolio” or “Home” page… I dunnno. I’m confused.

Viewing 4 replies - 1 through 4 (of 4 total)
  • Moderator James Huff

    (@macmanx)

    Volunteer Moderator

    I recommend asking Jetpack support about this at https://jetpack.com/contact-support/

    Thread Starter leoahrens

    (@leoahrens)

    Ok so, I sent the question off to Jetpack…

    However! After some messing around I’ve determined the code is calling the posts perfectly! It just doesn’t like the <div class="portfolio-wrapper"> class for some reason. Although this is the class that works on all other pages to order the post, it just doesn’t want to be told what to do on this page and comes out blank. If I change the div class, all the posts show up perfectly but without the css to put them in columns.

    Thread Starter leoahrens

    (@leoahrens)

    Alright soooooo, Jetpack support were like, yeah that’s a template issue not jetpack…

    Sooooooo…..I posted in the theme support but… you might be able to help me here.

    I’m starting to wonder if maybe this custom page template I made simply isn’t calling for the necessary jetpack script to apply the css or functions that style the content???

    Maybe I need to add something to these rules on the inc/jetpack.php file for this template?

    Thoughts?

    /**
     * Load Jetpack scripts.
     */
    function illustratr_jetpack_scripts() {
    	if ( is_post_type_archive( 'jetpack-portfolio' ) || is_tax( 'jetpack-portfolio-type' ) || is_tax( 'jetpack-portfolio-tag' ) || is_page_template( 'page-templates/portfolio-page.php' ) ) {
    		wp_enqueue_script( 'illustratr-portfolio', get_template_directory_uri() . '/js/portfolio.js', array( 'jquery', 'masonry' ), '20140325', true );
    	}
    	if ( is_singular() && 'jetpack-portfolio' == get_post_type() ) {
    		wp_enqueue_script( 'illustratr-portfolio-single', get_template_directory_uri() . '/js/portfolio-single.js', array( 'jquery', 'underscore' ), '20140328', true );
    	}
    
    	if ( is_page_template( 'page-templates/portfolio-page.php' ) ) {
    		wp_enqueue_script( 'illustratr-portfolio-page', get_template_directory_uri() . '/js/portfolio-page.js', array( 'jquery' ), '20140402', true );
    	}
    }
    add_action( 'wp_enqueue_scripts', 'illustratr_jetpack_scripts' );
    Thread Starter leoahrens

    (@leoahrens)

    Yup! I knew it.

    My custom template just wasn’t getting the necessary script!

    I injected it right into the template…

    <!-- CALLING FOR THE SCRIPT -->
    				wp_enqueue_script( 'illustratr-portfolio', get_template_directory_uri() . '/js/portfolio.js', array( 'jquery', 'masonry' ), '20140325', true );

    Damn it feels good to be a gangster.

Viewing 4 replies - 1 through 4 (of 4 total)
  • The topic ‘Inserting Jetpack portfolio’ is closed to new replies.