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 trialEngelbert Ebalo
3,697 PointsWordPress 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
12,612 PointsHi Engelbert Ebalo you can output the ID of a post by using the following code:
<div id="post-<?php the_ID(); ?>">
Zac Gordon
Treehouse Guest TeacherHi,
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
Engelbert Ebalo
3,697 PointsEngelbert Ebalo
3,697 PointsHi 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?