WPML Root page title
-
The plugin loads the wrong title, but good link of Root page in custom post type.
I corrected this by changing the function do_root in class.bcn_breadcrumb_trail.php/** * A Breadcrumb Trail Filling Function * * Handles only the root page stuff for post types, including the "page for posts" * * @param string $type_str The type string variable * @param int $root_id The ID for the post type root * @param bool $is_paged Whether or not the current resource is on a page other than page 1 * @param bool $is_current_item Whether or not the breadcrumb being generated is the current item */ protected function do_root($type_str, $root_id, $is_paged = false, $is_current_item = true) { //Nothing to do for the page post type, exit early if($type_str === 'page') { return; } $frontpage_id = get_option('page_on_front'); //Retrieve the post for the root_id as we will need it eventually $bcn_post = get_post($root_id); //We'll have to check if this ID is valid, e.g. user has specified a posts page if($bcn_post instanceof WP_Post && $root_id > 0 && $root_id != $frontpage_id) { if ( defined('ICL_LANGUAGE_CODE') && function_exists('icl_object_id') ) { $current_id = icl_object_id( $root_id, get_post_type( $root_id ), true, ICL_LANGUAGE_CODE ); $titlewpml = get_the_title($current_id); }else{ $titlewpml = get_the_title($root_id); } //Place the breadcrumb in the trail, uses the constructor to set the title, template, and type, we get a pointer to it in return $breadcrumb = $this->add(new bcn_breadcrumb($titlewpml, $this->opt['Hpost_' . $type_str . '_template_no_anchor'], array($type_str . '-root', 'post', 'post-' . $type_str), null, $root_id)); //If we are at home, or any root page archive then we need to add the current item type if($is_current_item) { $breadcrumb->add_type('current-item'); } //If we're not on the current item we need to setup the anchor if(!$is_current_item || ($is_current_item && $this->opt['bcurrent_item_linked']) || ($is_paged && $this->opt['bpaged_display'])) { $breadcrumb->set_template($this->opt['Hpost_' . $type_str . '_template']); //Figure out the anchor for home page $breadcrumb->set_url(get_permalink($root_id)); } //Done with the "root", now on to the parents //If there is a parent post let's find it if($bcn_post->post_parent > 0 && $bcn_post->ID != $bcn_post->post_parent && $frontpage_id != $bcn_post->post_parent) { $this->post_parents($bcn_post->post_parent, $frontpage_id); } } }
But I know that this is not a good solution and I will lose changes when updating.
How to fix this error without interfering with the plugin files?
Viewing 5 replies - 1 through 5 (of 5 total)
Viewing 5 replies - 1 through 5 (of 5 total)
- The topic ‘WPML Root page title’ is closed to new replies.