- This topic has 7 replies, 2 voices, and was last updated 5 years, 1 month ago by Tom.
March 25, 2016 at 4:21 am #181522Susanne Friedrich
Hi again Tom,
I am deeply into making GP and especially the blog add-on work for custom post types and in particular portfolio.
I am using the portfolio post type plugin, and the masonry layout and added this to my child theme functions to make the masonry layout work.
`add_filter( ‘generate_blog_masonry’,’generate_adjust_masonry’ );
function generate_adjust_masonry( $masonry )
if ( is_post_type_archive( ‘portfolio’ ) )
$masonry = ‘true’;
But now I find that the archive and the single does not show my categories or my tags or any of the meta.
This is visible in the regular posts, which uses the same archive.php template. What do I have to add to a child-theme archive-portfolio.php to make the categories and tags show?
Thanks for your awesome work!
March 25, 2016 at 10:43 am #181636TomLead DeveloperLead Developer
- This topic was modified 5 years, 4 months ago by Susanne Friedrich.
Those functions are built to only display within the “post” post type to prevent them from showing up in WooCommerce etc..
You can adjust this using these functions: https://gist.github.com/generatepress/4084f46ab0bd1c9f8c9e
The second function for generate_posted_on() will work in GP 1.3.29 and onwards.May 1, 2016 at 11:48 am #190820Susanne Friedrich
Hi Tom, thanks for your advice.
I tried to put these functions into my functions.php file of my child theme, but it did not make the metatags show up.Is there anything else I am missing?May 1, 2016 at 9:55 pm #190896TomLead DeveloperLead DeveloperMay 2, 2016 at 4:07 am #190961Susanne Friedrich
Hi Tom, yes here is the dev url: http://technifex.dreamhosters.com/portfolio/
I want them to show up in the archive and in the singleMay 2, 2016 at 11:16 am #191153TomLead DeveloperLead Developer
Ah, I neglected to remove an important part from generate_posted_on().
Go into /inc/template-tags.php and find the generate_posted_on() function.
Then remove this from the top of the function:
if ( 'post' !== get_post_type() ) return;
That should display the date for you.
For the categories, I think custom post types use different functions to display taxonomy information, so you would have to add your own functions in there: https://codex.wordpress.org/Function_Reference/get_the_term_listJune 21, 2016 at 6:14 pm #203671Susanne Friedrich
Hi Tom, Remember me?
I just wanted to report back that I have finally succeeded in doing all I needed with the Portfolio custom post type and thought I’d share it here with people who want to do the same:
My quest was to show both categories and tags for masonry portfolio posts and make it possible to filter the posts by category.
I also wanted to be able to show the current category, but was frustrated that I got the category posts in the generic archive template, not the portfolio template. Here’s how I made it work:
In my child theme I created an archive-portfolio.php template and a content-portfolio.php template.
In the archive-portfolio template I hardcoded the page title like so
(There is probably a more elegant way to do it, but it served the purpose for my needs.)
In content-portfolio.php I added this to show the tags (thanks for pointing me in that direction):
<?php echo get_the_term_list( $post->ID, 'portfolio_tag', 'tags: ', ', ' ); ?>
To show the categories I created a custom menu for my portfolio categories and added this in the header of archive-portfolio.php:
<? wp_nav_menu( array( 'theme_location' => 'portfolio-menu' ) ); ?>
Now the great thing I discovered was that I could duplicate the portfolio-archive.php and name it taxonomy.php and then I would get my category posts displayed with the Portfolio title instead of the archive title and keep my custom menu in the header. Not only that, but the custom menu for portfolio categories identified the current link item (category), so that I can style it to stand out and serve as a page title. Such a simple solution to something that I just could not figure out for the longest time!
Hope it will be useful for people who want to do something similar and thank you so much for all your help and support during the long incubation. Will post the site link when we launchJune 22, 2016 at 12:08 am #203707
- You must be logged in to reply to this topic.