Forum Replies Created

Viewing 15 replies - 661 through 675 (of 2,399 total)
  • Plugin Author John Havlik

    (@mtekk)

    This is very likely something your theme is doing then. Either it is calling bcn_display() multiple times on a page, or it is applying the tha_breadcrumb_navigation filter more than once (or doing both, which it should not be doing). Your best bet is to find where the theme is calling Breadcrumb NavXT and make your own version of that file in your child theme, ensuring only Breadcrumb NavXT is called once and where you want it to show up.

    Plugin Author John Havlik

    (@mtekk)

    Adjusting the layout/appearance of the breadcrumb trail requires adding the appropriate CSS to your theme’s (or child theme’s) style.css. I suggest testing potential styling rules with your web browser’s built in inspector tool. Once you find something you’re happy with, implement it in your style.css and verify the changes in your browser.

    Plugin Author John Havlik

    (@mtekk)

    As covered in the Breadcrumb NavXT documentation, the first parameter for bcn_display() will have it return a string rather than echo the content. Thus, you probably want to use bcn_display(true) instead of bcn_display().

    • This reply was modified 7 years, 4 months ago by John Havlik.
    Plugin Author John Havlik

    (@mtekk)

    How are you calling the breadcrumb trail (e.g. are you using the included Widget, or are you calling bcn_display()? I ask as what you are describing is not something Breadcrumb NavXT is doing by itself (something is calling it in two different locations for some reason).

    Plugin Author John Havlik

    (@mtekk)

    Breadcrumb NavXT uses the “Posts page” from Settings > Reading for the Blog breadcrumb URL. The easiest way to make this link to where you want is to update this setting in WordPress to link to the /blog page rather than /blog-old. If for some reason this is not feasible, you can write a filter for the bcn_breadcrumb_url hook and set the URL to what you want it to be.

    Plugin Author John Havlik

    (@mtekk)

    Don’t use breadcrumb_trail->add() as that function automatically adds the breadcrumb to then end of the breadcrumb trail (well it will show up before all of the other breadcrumbs). Instead, use something like:

    $new_breadcrumb = new bcn_breadcrumb('Verhuur', NULL, array('verhuur'), '/verhuur/');
    array_splice($breadcrumb_trail->breadcrumbs, -1, 0, $new_breadcrumb);

    Note that I have not tried executing the above, but I believe it should work (or close to working). Also, note that in the above use of array_splice the offset of -1 tells array_splice to start at the end of the array and count backwards.

    Plugin Author John Havlik

    (@mtekk)

    Internally, there is only one title in Breadcrumb NavXT for each breadcrumb. If you just want to shorten the title shown in the breadcrumb trail so things fit nicely in your layout, consider using CSS to shorten the title (see https://mtekk.us/archives/guides/trimming-breadcrumb-title-lengths-with-css/).

    Otherwise, there is another way of doing this that may help you do what you want. You could use bcn_template_tags to create your own template tag (either for the shortened or the un-shortened title). Then update your templates to use the new custom template tag.

    Plugin Author John Havlik

    (@mtekk)

    You can manually add breadcrumbs to the trail by hooking into the bcn_after_fill action. An example of adding a breadcrumb to the beginning of the trail is covered in this article: https://mtekk.us/archives/guides/add-a-static-breadcrumb-to-the-breadcrumb-trail/

    However, for what you want to do, you can’t use $breadcrumb_trail->add. Instead, you will want to use the PHP array_splice function to inject a new bcn_breadcrumb instance just before the last member of the $breadcrumb_trail->breadcrumbs array. You can check for the ID using $breadcrumb_trail->breadcrumbs[count($breadcrumb_trail->breadcrumbs)-2]->get_id(), though ensure you check the types as well to ensure it is of the correct type (e.g. post vs taxonomy, can retrieve the types array for a breadcrumb using the get_types() member function).

    Plugin Author John Havlik

    (@mtekk)

    Checking against the $id ensures you replace the title only for the page in question.

    There isn’t a $htitle parameter for the bcn_breadcrumb_title filter, so that won’t work. Changes made to the title using bcn_breadcrumb_title will affect both %title% and %htitle%, there isn’t really a way around this. %title% is literally %htitle% run through esc_attr() and strip_tags().

    For creating a special new title for hovers, I’d suggest creating your own custom breadcrumb template tag using the bcn_breadcrumb_tags filter. The documentation has a link to a simple example, you can use that as a starting point.

    Plugin Author John Havlik

    (@mtekk)

    @rom174: For the specific issue on the home page, it is very likely that your home template had ‘Home’ in it rather than %htitle%, that would cause the described behavior (it is also mentioned in the article you linked to under the ‘Consider the Following section).

    As for the actual problem you’re trying to solve, if you want to want to use a shorter title, this is the filter to use. However, the check against $type probably isn’t appropriate here, you are better off checking $id against the desired post ID. Extending this concept further, you can write an interface for interacting with postmeta to store/grab the shorter title. If you don’t want to write this yourself, there is the Breadcrumb NavXT Title Trixx premium extension that provides this functionality.

    Plugin Author John Havlik

    (@mtekk)

    Since pages can be the root for other post types (e.g. ‘page for posts’ in WordPress core, and root pages in Breadcrumb NavXT), the page post type is treated in a special manner in Breadcrumb NavXT. Breadcrumb NavXT, at least what is exposed by the settings page, only allows pages to follow a post parent hierarchy. If you want to have a hierarchical post type follow a taxonomy term based hierarchy, you probably want to create a Custom Post Type to do that.

    Plugin Author John Havlik

    (@mtekk)

    @rom174: I strongly caution against modifying any of the files that Breadcrumb NavXT ships with as these modifications will get wiped out when you update the plugin.

    I am confused as to how you were able to write a filter for bcn_breadcrumb_title and only affect the title showing up in the link title. The only way that should be possible is if you have a static title in the breadcrumb template (e.g. did not have %htitle% in your a tag). Can you provide more information as to what you did and what markup you are seeing being generated by Breadcrumb NavXT?

    Plugin Author John Havlik

    (@mtekk)

    Well, that’s odd. Based on the output, there are really only two things I can think of that would cause this. Either the unlinked template is missing the %htitle% tag, or the instance of the post that Breadcrumb NavXT gets is missing its title (e.g. tribe is doing something weird).

    To check for the first possibility, in the Breadcrumb NavXT settings page, can you look under the Post Types tab for the “Event Template (unlinked)” setting and see if it is different from the other custom post type unlinked templates?

    Plugin Author John Havlik

    (@mtekk)

    As far as I recall, Google does not recognize the current page as part of the breadcrumb trail (never shows up in SERPs). Google only detects breadcrumbs that have links (e.g. you need to enable the link current item option in Breadcrumb NavXT).

    Plugin Author John Havlik

    (@mtekk)

    Unfortunately, the actual code you’d use is highly specific to the intended use case and UI you are integrating into. In general, you’d do something like the following:

    add_filter('bcn_pick_post_term', 'my_bcn_pick_term_filter', 10, 4);
    function my_bcn_pick_term_filter($term, $id, $type, $taxonomy)
    {
    if($id === POST_IN_QUESTION)
    {
    //GET POST TERMS HERE
    //Set $term to desired term for post
    }
    return $term;
    }

    Note that there are items here that you will need to write (e.g. retrieving the terms for the post, dealing with the post in question check). This may even not be the way you want to do it (depending on how you’re dealing with the mapping).

Viewing 15 replies - 661 through 675 (of 2,399 total)