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

Home Redirect Banners

Hi everyone

I'm facing a problem with the creation of a new site. In the hero section right after the header menu, I need to create a masonry of boxes with custom content that redirects to specific site pages. I need to avoid the owner of site to "destroy" divs and specific classes so I would not put it into the html editor of the home page. I want to create that section inside my home.php so the owner cannot modify it. The problem is how can I write page link into .php file without having to modify links everytime i move from local to live? It would be better if the link will be taken from the database so i could easily change it with sql queries

to better understand what i want to create i link you a image of the hero section

https://postimg.org/image/hc1m9vaa9/

That is my second site on wordpress and I still need to understand a lot of things especially when I move sites from local to live.

Thank you so much guys!

Have a great day

Andrea

Joel Bardsley
Joel Bardsley
31,248 Points

Hi Andrea,

Just so I can get a better understanding of what you're trying to achieve, will the pages in the masonry container always stay the same (same content, position etc) or will it be flexible to allow for future pages that haven't been made yet?

From what I can tell, I would lean towards using a wordpress loop inside your masonry container and have it generate the custom content (custom field) and page link (get_permalink) for each masonry item that way.

If you don't think that would work for you, or need further information of how I would implement it, please let me know and I'll be able to advise further.

3 Answers

Joel Bardsley
Joel Bardsley
31,248 Points

If you're absolutely certain the blocks will remain the same, and can ensure the page/post ids for these blocks would be the same between your local and live versions; instead of custom fields and a loop I'd suggest just echoing the permalink produced by the get_page_link function in your markup.

Hi Joel, thank you for your answer, from what I actually know, the blocks will remain always the same (position, content etc). So i need to create custom fields inside the page that I want to point to and then display them with a loop inside the container? I know how to do that for posts but for specific pages I cannot figure out how doin' it.

Thank you so much Joel for your precious tips, I have a lot of codex function's to learn and this one was exactly what I was lookin' for.

Have a nice day!