WordPress: Adding a Portfolio
There are many portfolio plugins out there, some take more effort than others to implement and some have limited features. Im going to tell you about a solution I have stumbled upon that is relatively easy to implement, lightweight and feature full.
The first step is to download and install Portfolio Post Type from the WordPress repository here.
After this there will be a “Portfolio” Heading in the backend of your site. From here you can add, edit and delete your portfolio items. You can also add tags and categories and featured images to these and it works just like a regular WordPress Post.
Once that is done you can list off the Projects in your theme files with the regular post PHP loop as seen below:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<div class="projects"> <h2>OUR PORTFOLIO</h2> <? $wp_query = new WP_Query(array('post_type' => 'portfolio')); if (have_posts()) : while (have_posts()) : the_post(); ?> <div class="portfolio_item"> <h2><a href="<?php the_permalink();?>"><?php the_title();?></a></h2> <?php if ( has_post_thumbnail() ) { ?> <a href="<?php the_permalink(); ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_post_thumbnail(array(185,265)); ?></a> <?php }else{ ?> <img src="<?php bloginfo('url'); ?>/wp-content/themes/mytheme/images/project_img_1.jpg" alt="portfolio" width="178" height="87" /><!--The Path to Your Defualt Image--> <?php } ?> </div> <? endwhile; else: ?> <div> <p>No projects found.</p> </div> <? endif; ?> <div class="clr"></div> </div> |
Recent Comments