-
AuthorPosts
-
April 14, 2022 at 8:20 am #1348339
Hi,
Although the portfolio items don’t show the author of the items themselves, I noticed that the author (i.e. creator) does show up in the search results, which is a bit stange if for example the webmaster name is shown instead of the website owner’s name.
So I added this to the child theme functions.php to be able to change the author on those items:
// ***** Add filter for author to portfolio items (galleries) *****/ add_filter('avf_portfolio_cpt_args', 'avf_portfolio_add_cpt_args', 1); function avf_portfolio_add_cpt_args($args) { $args['hierarchical'] = true; $args['supports'] = array('title','thumbnail','excerpt','editor','comments', 'page-attributes','author'); return $args; }
So far so good, I can now change the author of the portfolio items so they show in the search results like they should.
Today however I noticed that if the above code is kept there, the previous-next buttons (navigation) on portfolio items disappear, so I had to comment the above code out again.While this is no problem in itself (the author being changed already and stored in the database), I am curious how and why this code can interfere with the portfolio navigation buttons (they continue to work on blog posts though).
Thanks for clarifying!
Rob
April 15, 2022 at 5:36 am #1348478Hey Rob,
Thank you for the inquiry.
The code above should not affect the post navigation. Are you using the Advance Layout Builder for the portfolio items? Did you add or use full width elements ( color section, grid row )? By default, the navigation will not display when a full width element is added to the post. But you can alter that rule by using this filter in the functions.php file.
function avf_post_nav_settings_mod( array $settings ){ if( in_array( $settings['type'], array( 'post', 'portfolio' ) ) ){ $settings['is_fullwidth'] = false; } return $settings; } add_filter( 'avf_post_nav_settings', 'avf_post_nav_settings_mod', 10, 1 );
Best regards,
IsmaelApril 15, 2022 at 7:00 am #1348479Hi Ismael,
Thanks for your reaction, but I don’t know if that is the issue here. My portfolio items are done with ALB editor, just a single full width column and a masonry gallery below it. The navigation is fine with portfolio items, but disappears when the author code is added. Blog post navigation remains fine, with or without the author field code.
Dev site access in private so you can see for yourself.
Kind regards,
Rob- This reply was modified 2 years, 7 months ago by rob2701.
April 18, 2022 at 4:44 am #1348661Hi,
Thank you for the info.
The issue is with the following line, which sets the post type to be hierarchical or enables setting a parent post.
// $args['hierarchical'] = true;
We removed that line and edited the filter a bit. The post navigation still works and the portfolio items now support the author option.
Best regards,
IsmaelApril 18, 2022 at 7:53 am #1348668Hi Ismael,
That works perfectly now with your changes, thank you for your time and work! Much appreciated.
Have a good day,
Rob
April 18, 2022 at 11:39 am #1348676Hi,
Great, I’m glad that Ismael could help you out. Please let us know if you should need any further help on the topic or if we can close it.
Best regards,
RikardApril 18, 2022 at 12:17 pm #1348677Hi Rikard,
All solved, can be closed, thanks.
For anyone else looking to add the author field to portfolio items, here is Ismael’s change:
// ***** Add filter for author field to portfolio items *****/ add_filter('avf_portfolio_cpt_args', 'avf_portfolio_add_cpt_args', 1); function avf_portfolio_add_cpt_args($args) { $args['supports'][] = 'author'; return $args; }
Rob
- This reply was modified 2 years, 7 months ago by rob2701.
April 19, 2022 at 10:15 am #1348747 -
AuthorPosts
- The topic ‘Portfolio author and portfolio navigation’ is closed to new replies.