Community Forums › Forums › Archived Forums › General Discussion › How do you display CPT Archive page on another post or page?
- This topic has 4 replies, 2 voices, and was last updated 9 years, 4 months ago by Brad Dalton.
-
AuthorPosts
-
December 17, 2014 at 6:33 am #134740PFXMember
Hi - I have been trying to work out how to add/display the custom post type archive page at the bottom of a post and I managed to get this working by following this forum
which results in providing this code, which does the job
<?php query_posts('post_type=portfolio'); # Use WP_Query arguments accordingly
get_template_part('archive-portfolio');
wp_reset_query();
?>However, the only problem with this is that it breaks the layout of my post - I have the footer outside the wrapper to go full-width, but as soon as I include this archive page, it breaks this 'full-width' of the footer area. I know it is something to do with how things are looping on a page - but I can't see how I can correct this?
I am placing this code inside a Custom Hook Box to display at the end of the content on a custom post using CPTs.
Can anyone hint at where I may be going wrong? I have tried to read up on the wordpress codex threads but I am not confident in writing PHP code - so it helps to use snippets as above that do the job, but then figure out how to tweak it to fix in my theme?
Thanks
December 17, 2014 at 6:38 am #134742PFXMemberI should state that I can't show the web page of what I am trying to do because its not live, but an example of what I am trying to achieve is similar to this website:
http://www.scorchlondon.com/portfolio/motion-graphics-reel/
The portfolio archive page links to the post, and then at the bottom of the post the portfolio archive is displayed - which encourages the viewer to click to watch more videos. So I am trying to do the same - put the portfolio archive at the bottom of the post which I can do , but it breaks my footer layout from being full-width across the page and insteads forces it to only spread across the main content width - so something is effecting this.
Do I need to add code to the actual archive template page OR do I need to adjust the code I have placed in my Custom Hook Box which is displaying the archive template page?
thanks
December 17, 2014 at 8:49 am #134750Brad DaltonParticipantFirstly, never use query_posts.
I would hook in the genesis featured posts widget ( modified to display portfolio posts ) after the content.
December 17, 2014 at 9:22 am #134753PFXMemberThanks Brad.
Yes I have tried the Featured Posts and Pages widgets before I found this code. The widgets are ok, but then you lose the 'filterable' functionality of the archive page. It would be helpful to be able to place the archive page on a post or page elsewhere because it pulls in the styling and functionality ....
Is there a way of just adjusting the code to work within the Genesis Exec Pro theme without breaking the layout - obviously there is because this other company has done it, and I am just trying to figure out how it has been done so I can adopt a similar approach.
I find using the Custom Hook Boxes are great for placing content where you want on a page/post, so it would be useful to find a code snippet that would allow me to do this without breaking the layout of the site.
Is there a reason why we shouldn't use query_posts?
Thanks for your help!
December 20, 2014 at 5:39 am #134953Brad DaltonParticipant -
AuthorPosts
- The forum ‘General Discussion’ is closed to new topics and replies.