• Resolved esilk

    (@esilk)


    I’m working with Pods to set up a “Projects” section on a website. I have everything set up with 3 categories of projects. I would like to have a main display page like this:

    Current Projects
    [list of Current Projects data from pods here]

    Coming Soon
    [list of Coming Soon projects data from pods here]

    Past Projects
    [list of Past Projects data from pods here]

    Here is the code I have now:

    <?php
    
    $params = array(
    
    );
    
    $project = new Pod(‘projects’, $params);
    $project->findRecords(‘ID ASC’);
    $total_projects = $project->getTotalRows();
    echo $total_projects;
    ?>
    
    <div class=”projects category”>
    <h1><?php echo get_cat_name(7); ?></h1>
    <p><?php echo category_description(7); ?></p>
    <?php if( $total_projects>0 ) : ?>
    <?php while ( $project->fetchRecord() ) : ?>
    <?php
    $project_cat = $project->get_field(‘category.name’);
    $project_name = $project->get_field(‘name’);
    $project_description = $project->get_field(‘short_description’);
    $post_id = $project->get_field(‘ID’);
    $image_id = get_post_thumbnail_id($post_id);
    $image = wp_get_attachment_image_src($image_id,’full’);
    $image_url = $image[0];
    ?>
    <div class=”col2″>
    <div class=”col2″>
    ” />
    </div>
    <div class=”col2″>
    <p class=”category”><?php echo $project_cat; ?></p>
    <h1 class=”proj”> <?php echo $project_name; ?> </h1>
    <div class=”proj-desc”> <?php echo $project_description; ?> </div>
    <p class=”more-link”>display( ‘permalink’ ); ?>”>Learn More</p>
    </div>
    </div>
    <?php endwhile ?>
    <?php endif ?>
    </div>

Viewing 1 replies (of 1 total)
  • Thread Starter esilk

    (@esilk)

    This is resolved. Here is the code I used:

    <div class="projects category">
    	<h1><?php echo get_cat_name(7); ?></h1>
    	<p><?php echo category_description(7); ?></p>
    		<?php $the_query = new WP_Query(array( 'post_type' => 'projects', 'category_name' => 'pod-current-projects', 'posts_per_page' => -1 )); ?>
    		<?php if ( $the_query->have_posts() ) : ?>
    		<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    		<div class="col2">
    		<div class="col2">
    			<?php if ( has_post_thumbnail() ) { ?>
    			<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_post_thumbnail('full', array('class' => 'alignnone')); ?></a>
    			<?php } ?>
    		</div>
    	<div class="col2">
    		<p class="category"><?php echo get_cat_name(7); ?> </p>
    		<h1 class="proj"><?php the_title(); ?></h1>
    		<div class="proj-desc"><?php the_field(short_description); ?></div>
    		<p class="more-link"><a href="<?php the_permalink() ?>">Learn More</a></p>
    	</div>
    	</div>
    	<?php endwhile; ?>
    	<?php else: ?>
    		<p>Sorry, no posts matched your criteria.</p>
    	<?php endif; ?>
    	<?php wp_reset_postdata(); ?>
    </div>
    <div class="projects category">
    	<h1><?php echo get_cat_name(6); ?></h1>
    	<p><?php echo category_description(6); ?></p>
    		<?php $the_query = new WP_Query(array( 'post_type' => 'projects', 'category_name' => 'pod-coming-soon', 'posts_per_page' => -1 )); ?>
    		<?php if ( $the_query->have_posts() ) : ?>
    		<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    		<div class="col2">
    		<div class="col2">
    			<?php if ( has_post_thumbnail() ) { ?>
    			<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_post_thumbnail('full', array('class' => 'alignnone')); ?></a>
    			<?php } ?>
    		</div>
    	<div class="col2">
    		<p class="category"><?php echo get_cat_name(6); ?> </p>
    		<h1 class="proj"><?php the_title(); ?></h1>
    		<div class="proj-desc"><?php the_field(short_description); ?></div>
    		<p class="more-link"><a href="<?php the_permalink() ?>">Learn More</a></p>
    	</div>
    	</div>
    	<?php endwhile; ?>
    	<?php else: ?>
    		<p>Sorry, no posts matched your criteria.</p>
    	<?php endif; ?>
    	<?php wp_reset_postdata(); ?>
    </div>
    <div class="projects category">
    	<h1><?php echo get_cat_name(8); ?></h1>
    	<p><?php echo category_description(8); ?></p>
    		<?php $the_query = new WP_Query(array( 'post_type' => 'projects', 'category_name' => 'pod-past-projects', 'posts_per_page' => -1 )); ?>
    		<?php if ( $the_query->have_posts() ) : ?>
    		<?php while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
    		<div class="col2">
    		<div class="col2">
    			<?php if ( has_post_thumbnail() ) { ?>
    			<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_post_thumbnail('full', array('class' => 'alignnone')); ?></a>
    			<?php } ?>
    		</div>
    	<div class="col2">
    		<p class="category"><?php echo get_cat_name(8); ?> </p>
    		<h1 class="proj"><?php the_title(); ?></h1>
    		<div class="proj-desc"><?php the_field(short_description); ?></div>
    		<p class="more-link"><a href="<?php the_permalink() ?>">Learn More</a></p>
    	</div>
    	</div>
    	<?php endwhile; ?>
    	<?php else: ?>
    		<p>Sorry, no posts matched your criteria.</p>
    	<?php endif; ?>
    	<?php wp_reset_postdata(); ?>
    </div>
Viewing 1 replies (of 1 total)

The topic ‘Display Pods data by category’ is closed to new replies.