WordPress.org

Ready to get started?Download WordPress

Forums

[closed] Grid Layout Problem: Pinboard Theme (3 posts)

  1. Aidorm
    Member
    Posted 8 months ago #

    Hi!

    I'm currently using Pinboard Theme by One Design and its a great theme for my website project.

    I'm customizing a page that displays only all images. I was able to get some help here and got to the point where I can show all the posts with attached images. However the page won't display the posts in a grid like layout with two columns like its supposed to do in the theme's normal portfolio page.

    Here's the code I'm using for the custom page:

    <?php
    /*
    Template Name: Custom Visual Page Template
    */
    get_header(); ?>
    <?php $pinboard_page_template = 'template-portfolio-right-sidebar.php'; ?>
    	<?php get_sidebar( 'wide' ); ?>
    	<?php get_sidebar( 'boxes' ); ?>
    <div id="container">
    	<section id="content" class="column twothirdcol">
    		<h2>Quotes with Visuals</h2>
    			<?php echo '<hr/>'; ?>
    			<?php
    			$args = array(
    				'post_type' => 'attachment',
    				'post_status' => 'inherit',
    				'post_mime_type' => 'image/jpeg',
    				'fields' => 'id=>parent',
    				'cat' => pinboard_get_option( 'portfolio_cat' ),
    				'posts_per_page' => get_option ('posts_per_page'),
    				'paged' => max( 1, get_query_var( 'paged' ) )
    			);
    			// get all attachment IDs and their parent post IDs.
    			$images = new WP_Query( $args );
    			if ( $images->have_posts() ) :
    			// get attachments parent post IDs
    			$parents = wp_list_pluck( $images->posts, 'post_parent' );
    			// remove duplicates and non attached images (parent == 0)
    			$parents = array_filter( array_unique( $parents ) );
    			// query for posts with images
    			$args = array(
    				'cat' => pinboard_get_option( 'portfolio_cat' ),
    				'posts_per_page' => get_option ('posts_per_page'),
    				'paged' => max( 1, get_query_var( 'paged' ) ),
    				'post__in' => $parents
    			);
    			$posts_with_images = new WP_Query( $args );
    			?>
    			<?php if ( $posts_with_images->have_posts() ) : ?>
    				<div class="entries">
    					<?php while ( $posts_with_images->have_posts() ) : $posts_with_images->the_post(); ?>
    						<?php get_template_part( 'content', 'customimage' ); ?>
    					<?php endwhile ?>
    				</div>
    				<?php pinboard_posts_nav(); ?>
    			<?php endif; ?>
    			<?php endif; ?>
    			<?php wp_reset_postdata(); ?>
    	<!-- if ( $images->have_posts() )   -->
    	</section><!-- #content -->
    	<?php if( ( 'no-sidebars' != pinboard_get_option( 'layout' ) ) && ( 'full-width' != pinboard_get_option( 'layout' ) ) ) : ?>
    	<?php get_sidebar(); ?>
    	<?php endif; ?>
    	<div class="clear"></div>
    </div>
    <!-- #container -->
    <?php get_footer(); ?>

    My content-customimage.php looks like this one:

    <article <?php post_class(); ?> id="post-<?php the_ID(); ?>">
    	<div class="entry">
    		<?php if( ( 'full-width' != pinboard_get_option( 'layout' ) && ! is_category( pinboard_get_option( 'portfolio_cat' ) ) && ! ( is_category() && cat_is_ancestor_of( pinboard_get_option( 'portfolio_cat' ), get_queried_object() ) ) ) || pinboard_is_teaser() ) : ?>
    			<?php pinboard_post_image(); ?>
    		<?php endif; ?>
    		<div class="entry-container">
    			<?php if( ( 'full-width' == pinboard_get_option( 'layout' ) || is_category( pinboard_get_option( 'portfolio_cat' ) ) || ( is_category() && cat_is_ancestor_of( pinboard_get_option( 'portfolio_cat' ), get_queried_object() ) ) ) && ! pinboard_is_teaser() ) : ?>
    				<?php pinboard_post_image(); ?><a href="<?php the_permalink(); ?>" rel="bookmark" title="<?php the_title_attribute(); ?>"><?php the_title(); ?></a>
    			<?php endif; ?>
    			<div class="clear"></div>
    			<div align="right">
    				<a href="<?php get_category_link( $category_id );?>"><?php single_cat_title(); ?></a>
    			</div>
    			<?php echo '<hr/>'; ?>
    		</div><!-- .entry-container -->
    		<?php if( 'full-width' != pinboard_get_option( 'layout' ) && ! is_category( pinboard_get_option( 'portfolio_cat' ) ) && ! ( is_category() && cat_is_ancestor_of( pinboard_get_option( 'portfolio_cat' ), get_queried_object() ) ) ) : ?>
    			<?php pinboard_entry_meta(); ?>
    		<?php endif; ?>
    	</div><!-- .entry -->
    </article><!-- .post -->

    And the Normal Template Portfolio that displays the posts in the correct grid like layout looks like this:

    <?php
    /*
    Template Name: Portfolio, Right Sidebar
    */
    ?><?php get_header(); ?>
    	<?php global $pinboard_page_template; ?>
    	<?php $pinboard_page_template = 'template-portfolio-right-sidebar.php'; ?>
    	<?php if( pinboard_get_option( 'location' ) ) : ?>
    		<?php pinboard_current_location(); ?>
    	<?php endif; ?>
    	<div id="container">
    		<section id="content" class="column twothirdcol">
    			<?php pinboard_category_filter( pinboard_get_option( 'portfolio_cat' ) ); ?>
    			<?php $args = array( 'cat' => pinboard_get_option( 'portfolio_cat' ), 'posts_per_page' => get_option( 'posts_per_page' ), 'paged' => max( 1, get_query_var( 'paged' ) ) ); ?>
    			<?php global $wp_query, $wp_the_query; ?>
    			<?php $wp_query = new WP_Query( $args ); ?>
    			<?php if( $wp_query->have_posts() ) : ?>
    				<div class="entries">
    					<?php while( $wp_query->have_posts() ) : $wp_query->the_post(); ?>
    						<?php get_template_part( 'content', get_post_format() ); ?>
    					<?php endwhile; ?>
    				</div><!-- .entries -->
    				<?php pinboard_posts_nav(); ?>
    			<?php else : ?>
    				<?php pinboard_404(); ?>
    			<?php endif; ?>
    			<?php wp_reset_postdata(); ?>
    			<?php $wp_query = $wp_the_query; ?>
    		</section><!-- #content -->
    		<?php get_sidebar(); ?>
    		<div class="clear"></div>
    	</div><!-- #container -->
    <?php get_footer(); ?>

    Can anyone help me out? I tried modifying the three but I can't display the posts in a grid like layout. I'm still kinda noob in coding.

    Thanks in advance!

  2. alchymyth
    The Sweeper & Moderator
    Posted 8 months ago #

    ideally, post in your theme's forum at http://wordpress.org/support/theme/pinboard/#postform

  3. Aidorm
    Member
    Posted 8 months ago #

    ok thanks! i'll just copy and paste it to the theme's forum.

    [continued at http://wordpress.org/support/topic/grid-layout-problem-pinboard-theme-1?replies=1 ]

Topic Closed

This topic has been closed to new replies.

About this Topic