X_breadcrumbs

Hi There,

how to automatically display the previous page in breadcrumbs? I have this:
__

elseif ( is_singular( 'depoimentos' ) ) {
            if ( $is_ltr ) {
              echo '<a href="' . 'http://www.dsc-curitiba.com/intercambio/' . '">' . __( '**depoimento intercâmbio**' ) . '</a>' . $delimiter . $current_before . $page_title . $current_after;
            } else {
              echo $current_before . $page_title . $current_after . $delimiter . '<a href="' . get_permalink( ) . '">' . __( '?' ) . '</a>';
            }

__
I want this to be automatically generated with the previous page name:

echo '<a href="' . 'http://www.dsc-curitiba.com/intercambio/' . '">' . __( '**depoimento intercâmbio**' ) . '</a>' .

Can you help with that?

Thanks

Hi There,

Are you trying to load next and previous page like for example the existing function on ethos post?
http://demo.theme.co/ethos-1/picking-the-perfect-wine-glasses/

If yes, the function you will need is this:
https://codex.wordpress.org/Function_Reference/get_adjacent_post

You can see out implementation on this file: wp-content\themes\x\framework\functions\global\content.php at around line 109 Entry Navigation.

You might want to check the following function too:
https://codex.wordpress.org/Function_Reference/get_previous_posts_link
https://codex.wordpress.org/Function_Reference/next_posts_link

Hope this helps,

Hi there,
thanks for the answer but my question was not clear, sorry. What I want is to show the name of the main page, where the post is, the same name that is in the menu, as shown in the image

Thanks again

Hi There,

The link seems to be custom post, correct? By default, breadcrumb should display the listing/parent page of the post. We need login credentials to access your site and investigate the structure of that page.

Hi There,
yes, it is.

it’s from function.php, lines 144-148:

elseif ( is_singular( 'depoimentos' ) ) {
            if ( $is_ltr ) {
              echo '<a href="' . 'http://www.dsc-curitiba.com/intercambio/' . '">' . __( 'depoimento intercâmbio' ) . '</a>' . $delimiter . $current_before . $page_title . $current_after;
            } else {
              echo $current_before . $page_title . $current_after . $delimiter . '<a href="' . get_permalink( ) . '">' . __( '?' ) . '</a>';
            }

thks

Hi there,

What’s the main issue again? Your code works

DEPOIMENTO INTERCÂMBIO > DEPOIMENTOS DOS INTERCAMBISTAS

It’s automatically added to depoimentos post type’s single pages. Or maybe I don’t understand how you’re trying to implement it, please provide more details.

I also checked the template hierarchy and it works, it follows the template-view standard of the theme.

Thanks!

Hi there,

yes the code is working but i want to change it to automatically display the name of the main page, that in this case is
DEPOIMENTO INTERCÂMBIO >…
Because, as you can see, i inserted the DEPOIMENTO INTERCÂMBIO in the code and when i change the language it continue displaying the same text.
I want to change that piece of code to automatically display this part - so when i change the language it will display the name in the other language, as the menu, as it is displaying the second part - that is the name of the post.

Thks :slight_smile:

Hi,

You can try the code below to change the text.

if( ICL_LANGUAGE_CODE == 'de') {
     $my_url = "http://www.dsc-curitiba.com/de/austauschprogramm/";
     $my_title = "uitwisselingsgetuigenis";
} else {
     $my_url = "http://www.dsc-curitiba.com/intercambio/";
     $my_title = "depoimento intercâmbio";
}

Then add it in the breadcrumbs like this

elseif ( is_singular( 'depoimentos' ) ) {
            if ( $is_ltr ) {
              echo '<a href="' . $my_url  . '">' .$my_title . '</a>' . $delimiter . $current_before . $page_title . $current_after;
            } else {
              echo $current_before . $page_title . $current_after . $delimiter . '<a href="' . get_permalink( ) . '">' . __( '?' ) . '</a>';
            }

Hope that helps.

Hi there,

i tried the code but now it is not displaying anything.

Any idea?

thanks

Hi there,

I added some correction to the code, please check it now.

Cheers!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.