• Hi!

    Typical me, I’m never totally satisfied with the stock site. With this project, I’m trying to add a portfolio gallery at the bottom of all my single post pages, “content-portfolio-single.php” So I’ve taken some code from the “Portfolio Template Page” and inserted it at the bottom. As seen at the bottom of this code..

    content-portfolio-single.php page…

    <?php
    /**
     * @package Illustratr
     */
    
    // Access global variable directly to adjust the content width for portfolio single page
    if ( isset( $GLOBALS['content_width'] ) ) {
    	$GLOBALS['content_width'] = 1100;
    }
    ?>
    
    <article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
    
    	<header class="entry-header" style="margin-top: 60px;">
    		<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
    
    	<!--	<?php echo get_the_term_list( $post->ID, 'jetpack-portfolio-type', '<span class="portfolio-entry-meta">', _x(', ', 'Used between list items, there is a space after the comma.', 'illustratr' ), '</span>' ); ?>
    		
    		
    	</header><!-- .entry-header -->
    
    	<div class="entry-content">
    		<?php the_content(); ?>
    		<?php
    			wp_link_pages( array(
    				'before'   => '<div class="page-links clear">',
    				'after'    => '</div>',
    				'pagelink' => '<span class="page-link">%</span>',
    			) );
    		?>
    	</div><!-- .entry-content -->
    
    	
    
    	<footer class="entry-meta">
    		<?php
    			/* translators: used between list items, there is a space after the comma */
    			$tags_list = get_the_term_list( $post->ID, 'jetpack-portfolio-tag', '', __( ', ', 'illustratr' ) );
    			if ( $tags_list ) :
    		?>
    			<span class="tags-links"><?php printf( __( 'Tagged %1$s', 'illustratr' ), $tags_list ); ?></span>
    		<?php endif; ?>
    
    	  <?php if ( ! post_password_required() && ( comments_open() || '0' != get_comments_number() ) ) : ?>
    			<span class="comments-link"><?php comments_popup_link( __( 'Leave a comment', 'illustratr' ), __( '1 Comment', 'illustratr' ), __( '% Comments', 'illustratr' ) ); ?></span>
    		<?php endif; ?> 
    
    		<?php edit_post_link( __( 'Edit', 'illustratr' ), '<span class="edit-link">', '</span>' ); ?>
    	</footer><!-- .entry-meta -->
    </article><!-- #post-## -->
    
    <!-- INSERT TO CALL PORTFOLIO GALLERY -->
    	
    	
    	
    	
    
    <?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,
    					'orderby'		 => 'rand'
    				);
    				$project_query = new WP_Query ( $args );
    				if ( post_type_exists( 'jetpack-portfolio' ) && $project_query -> have_posts() ) : 
    			?>
    
     
    				
    				
    				<div class="replacement-portfolio-wrapper"><!-- .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’ve determined the code i’ve inserted will query 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 manipulate the portfolio layout. Instead it comes out blank. If I change the div class, all the posts show up perfectly but without the css to put them in columns.

    The link below is an example of a page I would like to add a portfolio gallery to after the content… I have replaced the problematic ‘.portfolio-wrapper’ div with ‘.replacement-portfolio-wrapper’ so the content actually shows up, however, without the proper css.

    https://leoahrens.com/portfolio/deep-cuts/

    If you look at the homepage, that is what it is supposed to look like.

    Any help is greatly appreciated!!!!

    The page I need help with: [log in to see the link]

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter leoahrens

    (@leoahrens)

    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' );
    sacredpath

    (@sacredpath)

    Automattic Happiness Engineer

    If the portfolio section on the single pages comes out right when you change the CSS class, I would try creating a new CSS class and then add that class to the CSS rule that styles the section on the main page. I would also look at the existing styling for the front page section and make sure that there isn’t something in that class that is causing an issue.

    Does the html for your added portfolio project section show up in the page source?

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Portfolio-Wrapper issues…’ is closed to new replies.