Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

WordPress From Bootstrap to WordPress Create Bootstrap Styled Theme Templates Creating a Portfolio Single Page

Engelbert Ebalo
Engelbert Ebalo
3,697 Points

WordPress Theme: Link to Portfolio List

So in the video, Zac Gordon shows us how to link to the Portfolio list page by hard coding the ID of the gallery. He did not talk about how to dynamically create that. Anyone know how?

2 Answers

Caroline Hagan
Caroline Hagan
12,612 Points

Hi Engelbert Ebalo you can output the ID of a post by using the following code:

<div id="post-<?php the_ID(); ?>">
Engelbert Ebalo
Engelbert Ebalo
3,697 Points

Hi Caroline, thanks for the response. I have tried this method as well but it is only the ID of the post, not the actual gallery. any thoughts on that?

Zac Gordon
STAFF
Zac Gordon
Treehouse Guest Teacher

Hi,

There is not a way to dynamically figure out the ID of your portfolio page without going into the WordPress admin area to look for it in the URL.

If you think about it, you can either use the slug of a page or the ID of a page to link to it. Since the slug can change, the ID is more reliable. However, you can also use the slug of the URL instead.

Hope this helps