Skip to content

Single Page Portfolios With WordPress

I recently needed to make an easily editable single page portfolio (this kind of thing) for a friend. As the budget was essentially nil, I headed over to ThemeForest and chose one of the awesomely designed HTML templates there, only spending about $10 and saving a ton of time in the process.

I then went about the usual porting HTML to WordPress, but I need some way of splitting up the various portfolio sections — about, “what I do” etc — into a separate page for each one so my friend could edit the About page and the about section would change, edit the “What I do” page and the what I do section would change and so on.

I had thought this would be a pain to do, but happily, I was wrong.

Using WP_Query (and not query_posts)I was able to output the contents of one page straight after the other. The code looked something like this:

<?php
$query = new WP_Query( 'page_id=1' );

$queryObject = new WP_Query($query);
// The Loop...
if ($queryObject->have_posts()) {
	while ($queryObject->have_posts()) {
		$queryObject->the_post();
		the_content();
		// the title and other styling can be done outside the loop
	}
}

// Reset Post Data
wp_reset_postdata();

?>

<!-- Some styling for the next section -->

<?php
$query = new WP_Query( 'page_id=2' ); //just change the ID

$queryObject = new WP_Query($query);
// The Loop...
if ($queryObject->have_posts()) {
	while ($queryObject->have_posts()) {
		$queryObject->the_post();
		the_content();
	}
}

// Reset Post Data
wp_reset_postdata();

?>

And so on and so forth for all the different pages — it was just a case of getting the page id and putting in a query every time I needed the actual content.

This is another case of simplicity winning the day — this could have been horribly complex, but it was literally a case of just changing one little bit.

Yay! 🎉 You made it to the end of the article!
Alex Denning

2 Comments
Most Voted
Newest Oldest
Inline Feedbacks
View all comments
Beau Bridges
January 30, 2012 8:25 pm

Thanks for the helpful tip Alex!

komiska
November 15, 2011 8:22 pm

AWESOME! thanks for this! i was alsoe sweating it, but now i can follow to use it for my own portfolio
THANK YOU!

Or start the conversation in our Facebook group for WordPress professionals. Find answers, share tips, and get help from other WordPress experts. Join now (it’s free)!

2
0
Would love your thoughts, please comment.x

Most Searched Articles

Best JavaScript Libraries and Frameworks: Try These 14 in 2024

In this post, we look at the best JavaScript libraries and frameworks to try out this year. Why? Well, with JavaScript being available in every web browser, this makes it the most accessible programming language of ...

20 Best Free WordPress Themes for 2024 (Responsive, Mobile-Ready, Beautiful)

If you're looking for only the best free WordPress themes in the market for this year, then you're in the right place. We have more than enough such themes for you right ...

12 Best WordPress Hosting Providers of 2024 Compared and Tested

Looking for the best WordPress hosting that you can actually afford? We did the testing for you. Here are 10+ best hosts on the market ...

Handpicked Articles

How to Make a WordPress Website: Ultimate Guide for All Users – Beginners, Intermediate, Advanced

Many people wonder how to make a WordPress website. They’ve heard about WordPress, its incredible popularity, excellent features and designs, and now they want to join the pack and build a WordPress website of their own. So, where does one get ...

How to Start an Ecommerce Business: Ultimate Guide for 2024

Is this going to be the year you learn how to start an eCommerce business from scratch? You’re certainly in the right place! This guide will give you a roadmap to getting from 0 to a fully functional eCommerce business. ...