-
AuthorPosts
-
September 25, 2018 at 1:20 pm #1014173
Hi,
I have many portfolio items with lots of categories (see first link in private content)
Now it shows the breadcrumbs of the category hierarchy because I selected a main category in the breadcrumbs hierarchy.
When I leave the breadcrumb hierarchy on select this happens (see IST 720 in private content): it shows categories in the breadcrumb while this portfolio item doesn’t even have this categories like ‘Dosage systems’.
How is this possible?September 25, 2018 at 4:39 pm #1014274Hey (Email address hidden if logged out) ,
Can you give us temporary admin access to your website in the private content box below, so that we can have a closer look?
Best regards,
VictoriaSeptember 26, 2018 at 11:27 am #1014669It is working okay if I select a parent page in this area : https://imgur.com/u0c3nzn
But if I enable breadcrumbs in the theme settings it doesn’t work right and I have to modify every portfolio-item individually (selecting the parent page by hand). This will cost a lot of time. Is there an other way to make it work out.September 26, 2018 at 11:35 am #1014674Hi,
If you do not select a breadcrumb parent page a php session variable will be used to determine which page could be a parent page. The results may vary depending on which page the website visitor views first. If you want a constant breadcrumb (which does not use sessions to “guess” the right parent page based on previously visited pages) you need to select the breadcrumb parent manually.
Best regards,
PeterSeptember 26, 2018 at 11:49 am #1014680Isn’t there any option to set breadcrumb parent page in bulk?
September 26, 2018 at 2:18 pm #1014739Hi,
The easiest solution (and also the most flexible one) would be to use this plugin: https://wordpress.org/plugins/custom-field-bulk-editor/ to set the breadcrumb parent page for your portfolio entries.
Install and activate the plugin, then go to the wordpress admin panel > Portfolio Items > “Bulk Edit Fields”. If you want to select the same parent page for all portfolio items select all items from the list, otherwise select them by category or tag, etc.
Then scroll down to the “Set Custom Field Values For Checked Portfolio Items” section and enter into the “Custom Field Name:” option field on the left side the value “breadcrumb_parent” (without the quotes). Then add the page id of your breadcrumb parent page into the “Value” field on the right side (screenshot: blob:https://imgur.com/c8eab0e8-b438-4811-8bd9-5bf41703592d ). If you don’t know the id of the page this article: https://www.ostraining.com/blog/wordpress/how-to-find-the-page-id-in-wordpress/ will show you how to get it.
At least hit the blue “Save custom fields” button and you’re done. If you want to set different parent pages for different portfolio categories you need to repeat this procedure for each parent page, just select a different category, add the “breadcrumb_parent” value to the left field and insert a different page id on the right side, etc.
Best regards,
PeterSeptember 26, 2018 at 3:27 pm #1014785I did exactly what you said but it didn’t work out.
September 26, 2018 at 3:34 pm #1014793Hi,
Please create me an admin account and I’ll look into it.
Best regards,
PeterSeptember 26, 2018 at 4:20 pm #1014839Maybe I found another solution.
In pages you can select a range of pages and select Bulk actions > edit.
You can select the parent page for all those pages then.
In the portfolio items list I don’t get that option when I bulk edit. Is there a function to add this option to portfolio items as well?September 26, 2018 at 4:39 pm #1014863Hi,
No because portfolio entries are like posts and do not support “parent pages”. You can only assign categories and tags to them. The breadcrumb parent page option is a theme feature and not a standard wordpress feature which is supported by the bulk edit panel.
Best regards,
PeterSeptember 26, 2018 at 4:58 pm #1014871Hi,
If you just want to set one page as parent page you can also set the parent page by using this code – insert it into the child theme functions.php and replace 1000 with your parent page id:
function avia_modify_breadcrumb($trail) { $parent = get_post_meta(avia_get_the_ID(), 'breadcrumb_parent', true); if(get_post_type() === "portfolio") { if(empty($parent)) $parent = '1000'; $page = ""; $front = avia_get_option('frontpage'); if(empty($parent) && !current_theme_supports('avia_no_session_support') && session_id() && !empty($_SESSION['avia_portfolio'])) { $page = $_SESSION['avia_portfolio']; } else { $page = $parent; } if(!$page || $page == $front) { $args = array( 'post_type' => 'page', 'meta_query' => array( array( 'key' => '_avia_builder_shortcode_tree', 'value' => 'av_portfolio', 'compare' => 'LIKE' ) ) ); $query = new WP_Query( $args ); if($query->post_count == 1) { $page = $query->posts[0]->ID; } else if($query->post_count > 1) { foreach($query->posts as $entry) { if ($front != $entry->ID) { $page = $entry->ID; break; } } } } if($page) { if($page == $front) { $newtrail[0] = $trail[0]; $newtrail['trail_end'] = $trail['trail_end']; $trail = $newtrail; } else { $newtrail = avia_breadcrumbs_get_parents( $page, '' ); array_unshift($newtrail, $trail[0]); $newtrail['trail_end'] = $trail['trail_end']; $trail = $newtrail; } } } else if(get_post_type() === "post" && (is_category() || is_archive() || is_tag())) { $front = avia_get_option('frontpage'); $blog = !empty($parent) ? $parent : avia_get_option('blogpage'); if($front && $blog && $front != $blog) { $blog = '<a href="' . get_permalink( $blog ) . '" title="' . esc_attr( get_the_title( $blog ) ) . '">' . get_the_title( $blog ) . '</a>'; array_splice($trail, 1, 0, array($blog)); } } else if(get_post_type() === "post") { $front = avia_get_option('frontpage'); $blog = avia_get_option('blogpage'); $custom_blog = avia_get_option('blog_style') === 'custom' ? true : false; if(!$custom_blog) { if($blog == $front) { unset($trail[1]); } } else { if($blog != $front) { $blog = '<a href="' . get_permalink( $blog ) . '" title="' . esc_attr( get_the_title( $blog ) ) . '">' . get_the_title( $blog ) . '</a>'; array_splice($trail, 1, 0, array($blog)); } } } return $trail; } add_filter('avia_breadcrumbs_trail','avia_modify_breadcrumb');
I wouldn’t use this code if you plan to set different parent pages because it can be tedious to include a switch or if statement for each category, etc.
Best regards,
PeterSeptember 26, 2018 at 5:07 pm #1014878Hi
I made an admin account for you.
For example you can test to set the portfolio item ‘Mag het een pontje meer zijn’ to breadcrumb_parent ‘Bewegwijzering’.
For me it didn’t work out.September 26, 2018 at 5:45 pm #1014890Hi,
There was no breadcrumb set on the portfolio page. I now added a small snippet to your child theme
function av_breadcrumbs_shortcode( $atts ) { return avia_breadcrumbs(array('separator' => '/', 'richsnippet' => true)); } add_shortcode( 'bread_crumb', 'av_breadcrumbs_shortcode' );
so you can include it with a shortcode
[bread_crumb]
I added it to the portfolio item (link in private content) and the breadcrumb now contains the “Bewegwijzering” parent page.
Best regards,
PeterSeptember 26, 2018 at 6:40 pm #1014913Did you assigned the parent page through the plugin ‘Custom field bulk editor’?
In the theme settings I turned on show breadcrumbs now and removed the shortcode but the shortcode isn’t necessary now.
But if I assign the parent page through the plugin it still doesn’t work. That is my problem, not how to show breadcrumbs.I know how to assign a breadcrumb parent on the portfolio page individually but it needs to be done in bulk.
- This reply was modified 6 years, 1 month ago by Jarmo.
September 26, 2018 at 7:50 pm #1014968Hey!
Yes I used the plugin. I activated the custom field view (near the bottom of the editor page with the headline “Extra veden”) to check if the right value is set. You can test it yourself – first go to the editor page (see link in private field) – the value is set to 149 at the moment. Then go to the bulk editor, insert a different value and save the value. Then reload the editor page and the value should change on the editor page (“Extra veden” section).
Regards,
PeterSeptember 26, 2018 at 8:08 pm #1014974I did what you said, see this video: https://vimeo.com/291974932
The password is in the private content. What am I doing wrong???- This reply was modified 6 years, 1 month ago by Jarmo.
September 27, 2018 at 1:48 pm #1015279Did you watch the video?
September 27, 2018 at 3:15 pm #1015322Hi,
Yes, tbh I don’t know why it’s not working for you. It seems to be a plugin issue because it should not duplicate the field but overwrite the content.
In this case I’d recommend to set it manually or to use the code I posted here: https://kriesi.at/support/topic/breadcrumbs-according-to-session/#post-1014871
Another solution (if you don’t want to set the breadcrumb page for each post manually) would be to use a plugin like: https://wordpress.org/plugins/post-duplicator/ to duplicate the portfolio items. Then you just need to set up one item, click the “Duplicate post” button and it will copy the post content, including all custom fields (also the breadcrumb parent field) to a new entry. You then just need to alter the headline, images and content and you don’t need to care about the other option fields.
Best regards,
PeterSeptember 28, 2018 at 2:58 pm #1015758When I assign a ID to breadcrumb_parent, it creates a second breadcrumb_parent.
Is there an option to first remove all the breadcrumb_parent fields and adding them by assigning ID’s to items?September 28, 2018 at 4:48 pm #1015789Hi,
You could add this function to the child theme functions.php:
function avia_delete_all_breadcrumb_parent() { $args = array('posts_per_page' => -1, 'post_status' => 'any', 'post_type' => array('portfolio')); $articles= get_posts( $args ); foreach($articles as $article) { delete_post_meta($article->ID, 'breadcrumb_parent'); } } add_action('init','avia_delete_all_breadcrumb_parent');
to delete all post meta fields with the value breadcrumb_parent. Then reload your website and remove the function. Afterwards you can either try to use the plugin to set the post meta values again or you can use this code:
function avia_add_all_breadcrumb_parent() { $args = array('posts_per_page' => -1, 'post_status' => 'any', 'post_type' => array('portfolio')); $articles= get_posts( $args ); foreach($articles as $article) { update_post_meta($article->ID, 'breadcrumb_parent', 1980); } } add_action('init','avia_add_all_breadcrumb_parent');
to bulk update the breadcrumb page for all portfolio items. You just need to replace 1980 with your parent page id and reload the website. Afterwards I’d recommend to remove the function because of performance reasons (unnecessary code).
Best regards,
PeterOctober 1, 2018 at 10:49 am #1016549Ok I am gonna try this ;)
One extra question: How did you turn on the custom fields? In other sites I have I don’t see this checkbox in screen settings.October 1, 2018 at 10:55 am #1016552Hi,
You need to add it when the post type is registered (see https://codex.wordpress.org/Function_Reference/register_post_type – “supports” parameter). If you want to add custom fields support to portfolio items you can add this code to your child theme functions.php:
add_filter('avf_portfolio_cpt_args', 'avf_portfolio_cpt_args_mod'); function avf_portfolio_cpt_args_mod($args) { $args['supports'][] = 'custom-fields'; return $args; }
Best regards,
PeterOctober 2, 2018 at 10:04 am #1016955function avia_add_all_breadcrumb_parent() { $args = array('posts_per_page' => -1, 'post_status' => 'any', 'post_type' => array('portfolio')); $articles= get_posts( $args ); foreach($articles as $article) { update_post_meta($article->ID, 'breadcrumb_parent', 1980); } } add_action('init','avia_add_all_breadcrumb_parent');
Can I use this code for a specific category ID? That would solve my problem
October 4, 2018 at 4:22 am #1017661Hi,
Add the “tax_query” parameter to the query.
function avia_add_all_breadcrumb_parent() { $args = array('posts_per_page' => -1, 'post_status' => 'any', 'post_type' => array('portfolio'), 'tax_query' => array( array( 'taxonomy' => 'portfolio_entries', 'field' => 'term_taxonomy_id', 'terms' => array(26, 25, 24) ) )); $articles = new WP_Query( $args ); foreach($articles->posts as $article) { update_post_meta($article->ID, 'breadcrumb_parent', 1980); } wp_reset_postdata(); } add_action('wp_head','avia_add_all_breadcrumb_parent');
Replace the portfolio category ids in the “terms” parameter inside the “tax_query” with the id of the categories in your installation.
Best regards,
IsmaelOctober 4, 2018 at 9:52 am #1017785This solved my problem! Thanks!
October 4, 2018 at 3:07 pm #1017928Hi,
Great! Glad we could help!
Please take a moment to review our theme and show your support https://themeforest.net/downloads
Don’t forget to bookmark Enfold Documentation for future reference.Thank you for using Enfold :)
Best regards,
Ismael -
AuthorPosts
- The topic ‘Breadcrumbs according to session’ is closed to new replies.