Navigation überspringen

[Gelöst] Next / Previous Article

This support ticket is created vor 3 Jahren, 9 Monaten. There's a good chance that you are reading advice that it now obsolete.

This is the technical support forum for Toolset - a suite of plugins for developing WordPress sites without writing PHP.

Everyone can read this forum, but only Toolset clients can post in it. Toolset support works 6 days per week, 19 hours per day.

Sun Mon Tue Wed Thu Fri Sat
- 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 9:00 – 12:00 -
- 13:00 – 18:00 13:00 – 18:00 13:00 – 18:00 14:00 – 18:00 13:00 – 18:00 -

Supporter timezone: America/Jamaica (GMT-05:00)

Dieses Thema enthält 17 Antworten, hat 2 Stimmen.

Zuletzt aktualisiert von ThorstenS967 vor 3 Jahren, 8 Monaten.

Assistiert von: Shane.

Author
Artikel
#1998141

Hi,
how can I add a next and a previous button which should show the previous or next article for each article? Here is an example of an article, created in a CPT with csutom fields in Toolset: versteckter Link
So under the Article I would like to insert a previous / next article button. How can I achieve that?

Thanks
Thorsten

#1998215

Shane
Supporter

Sprachen: Englisch (English )

Zeitzone: America/Jamaica (GMT-05:00)

Hi Thorsten,

Thank you for getting in touch.

If you are displaying your posts with a custom content template then you can use the following shortcodes.
https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-554769

https://toolset.com/documentation/programmer-reference/views/views-shortcodes/#vf-554770

These should provide the Next and Previous post links for you to add to your individual articles.

Please let me know if this helps or if further clarification is needed on adding these.
Thanks,
Shane

#2000701

Hi Shane,

thanks you, it works.
But I have question regarding the articles. The articles are being displayed for different Post Types (different views):
versteckter Link
versteckter Link
versteckter Link
versteckter Link
versteckter Link
The articles template is a Template for all the different post types (views). Is there a way to display the previous/nex article buttons only for articles, which are being displayed in the last URL (versteckter Link -> click for example on "Bleibt in mir 1/2021" -> click on one of the articles, for example "Denn der Weg ist sonst zu weit für dich" -> scroll to the bottom and you will se the buttons)? Right now, the buttons are being displayed on all links (of course, it is the same articles template).
I tried this in the template, but it didn't work:

[wpv-conditional if="( '[wpv-post-type]' eq 'heft' )"]<div class="artikelLinksContainer"><span class="vorherigerArtikel">[wpv-post-previous-link format="%%LINK%%" link="" Vorheriger Artikel"]</span><span class="heftUebersicht"><a href="<em><u>versteckter Link</u></em>">Zur Heftübersicht</a></span><span class="naechsterArtikel">[wpv-post-next-link format="%%LINK%%" link="Nächster Artikel ""]</span></div>[/wpv-conditional]

Also right now you have (of cource) to click exactly on the link to jump to the next/previous arctice. How can I achieve, that the whole button is a link?
Thanks
Thorsten

#2000725

Shane
Supporter

Sprachen: Englisch (English )

Zeitzone: America/Jamaica (GMT-05:00)

Hi Thorsten,

I tried this in the template, but it didn't work:

I'm assuming here that you only want the pagination to appear on the "heft" Post Type only.

Can you point me in the direction to where I can get to a heft post type article?

Also right now you have (of cource) to click exactly on the link to jump to the next/previous arctice. How can I achieve, that the whole button is a link?

This won't be possible to do because the shortcodes generate the link on a whole, which means you are not able to wrap the entire button in a link.

I hope this clears things up for you a bit.

Thanks,
Shane

#2001609
CPTs_2.jpg
CPTs_1.jpg

Hi Shane,

There are several CPT's. Please see attached screenshots. They also have a relationship between each otherIf you would like to have access to the Backend, I can give you credentials.

Thanks
Thorsten

#2002097

Shane
Supporter

Sprachen: Englisch (English )

Zeitzone: America/Jamaica (GMT-05:00)

Hi Thorsten,

Just to understand this clearly, your pagination buttons are appearing on this post below.
versteckter Link

However you dont want it to, you only want it to appear on the Hefte post type. I checked the page again and saw that the pagination are no longer appearing.

Has the issue been resolved or are there still issues.

If so then you can provide me with the admin access so that I can have a further look for you.

I've enabled the private fields for you.

Thanks,
Shane

#2004327

Shane
Supporter

Sprachen: Englisch (English )

Zeitzone: America/Jamaica (GMT-05:00)

Hi Thorsten,

I'm a little confused.

Can you let me know where did you add this code below

[wpv-conditional if="( '[wpv-post-type]' eq 'heft' )"]<div class="artikelLinksContainer"><span class="vorherigerArtikel">[wpv-post-previous-link format="%%LINK%%" link="" Vorheriger Artikel"]</span><span class="heftUebersicht"><a href="<em><u>versteckter Link</u></em>">Zur Heftübersicht</a></span><span class="naechsterArtikel">[wpv-post-next-link format="%%LINK%%" link="Nächster Artikel ""]</span></div>[/wpv-conditional]

Also please send me a link to where you want the pagination to show up and another link to where it shouldn't show up. This way I can have a more structured approach to handling the issue for and hopefully get this one resolved soon.

Thanks,
Shane

#2004507

Hi Shane,
no problem: I deleted in the code

[wpv-conditional if="( '[wpv-post-type]' eq 'heft' )"]<div class="artikelLinksContainer"><span class="vorherigerArtikel">[wpv-post-previous-link format="%%LINK%%" link="" Vorheriger Artikel"]</span><span class="heftUebersicht"><a href="<em><u>versteckter Link</u></em>">Zur Heftübersicht</a></span><span class="naechsterArtikel">[wpv-post-next-link format="%%LINK%%" link="Nächster Artikel ""]</span></div>[/wpv-conditional]

the condition, because it didn't work. So, as I wrote in the private message, the actual code is in line 4, 9, 15 and 28 of the Content Template "Vorlage für Artikels":

<div class="artikelLinksContainer"><span class="vorherigerArtikel">[wpv-post-previous-link format="%%LINK%%" link="" Vorheriger Artikel"]</span><span class="heftUebersicht"><a href="<em><u>versteckter Link</u></em>">Zur Heftübersicht</a></span><span class="naechsterArtikel">[wpv-post-next-link format="%%LINK%%" link="Nächster Artikel ""]</span></div>

This is, where this code (the previous/next/back to articles links) should appear only:
versteckter Link (You have to click on one of the "virtual books" (Hefte), for example on "Bleibt in mir 4/2020". From there you can see all articles which belong to "Bleibt in mir 4/2020". So the links should only appear for the articles under versteckter Link .
The links should NOT appear in the articles under these links/categories:
versteckter Link
versteckter Link
versteckter Link
versteckter Link
I hope, it makes sense now.
Thanks
Thorsten

#2004553

Shane
Supporter

Sprachen: Englisch (English )

Zeitzone: America/Jamaica (GMT-05:00)

Hi Thorsten,

You want the pagination to appear only on this page.
versteckter Link

However this is a Page and from what I can see the template for this page is built using the Oxygen Builder. There isn't a Toolset content template attached to it.
The page does have the following view attached to it.
versteckter Link

If you add the Pagination links to this page then what will happen is that it will pagination through the items listen here.
versteckter Link

However if you want the pagination to only appear on this page then you will need to add the conditional statement to your oxygen template using the post id of the page, like this below.


[wpv-conditional if="( '[wpv-post-id]' eq '68' )"]<div class="artikelLinksContainer"><span class="vorherigerArtikel">[wpv-post-previous-link format="%%LINK%%" link="" Vorheriger Artikel"]</span><span class="heftUebersicht"><a href="<em><u>versteckter Link</u></em>">Zur Heftübersicht</a></span><span class="naechsterArtikel">[wpv-post-next-link format="%%LINK%%" link="Nächster Artikel ""]</span></div>[/wpv-conditional]

However if it is on the Table that you want the pagination on then it will need to be done in the view itself.
versteckter Link

So you will need to enable the pagination settings by scrolling to the top of the view page and use the screen options to enable the Pagination settings for the view.

From there you can go to the "Pagination and Sliders Settings " and setup the pagination options.

Finally to add the pagination controls you will need to use the Pagination buttons on the Loop Editor .

Please let me know if this helps.
Thanks,
Shane

#2005123
Article_with_Buttons.jpg
Article_CPT_2.jpg
Article_CPT_1.jpg

Hi Shane,
excuse me, I think there is still a misunderstanding.
The buttons for next/previous article are being displayed in the article directly (see attached screenshot "Article_with_Buttons"). I embedded the articles in the Content-Template "Vorlage für Artikels".
Attached you can find some screenshots. In the screenshots "Article_CPT_1.jpg" and "Article_CPT_2.jpg" you see an article in the backend from the "Artikels" CPT and the relationships to the author (Autor) and books (Hefte) for each article.
Now, the User in the frontend has different options to see an article. If you hover the menu entry "Artikel" in the Frontend you see the menu entires "Jahrgänge", "Themen", "Stichwörter", "Autoren" and "Artikelserien". From each of these menu entries you can reach out to the article(s). The article itself with the buttons (screenshot "Article_with_Buttons") are being rendered with the Oxygen Template "Artikel Template" which again renders the Content-Template "Vorlage für Artikels". So all articles are using this one Oxygen Template with the embedded Toolset Content-Template "Vorlage für Artikels". So what I want / the client wants is, that the the buttons in the articles are only being displayed if you reach out an article through the menu entry "Jahrgänge" -> click on an Heft (for example "Bleibt in mir 4/2020") -> and one of the articles.
For a better understanding I recorded a little video to show you, what I mean. You can download it here: versteckter Link
Thanks again,
Thorsten

#2005377

Shane
Supporter

Sprachen: Englisch (English )

Zeitzone: America/Jamaica (GMT-05:00)

Hi Thorsten,

Thank you for the video explanation.

Now I fully understand the issue at hand. Unfortunately it won't be possible to hide the buttons based on where the article is navigated from.

This is because all the articles are using the same exact template and they can be accessed from both the Jahrgänge menu option and from themen menu option. Essentially there are no differences between the articles themselves only how they are accessed.

We don't have a way to tell how the articles are being access, for e.g a breadcrumb so we won't be able to do a conditional for this at least not without some form of custom code that can check your browser's navigation history.

Unfortunately such custom coding is out of the scope of our support forum, so I wouldn't be able to provide much assistance with this.

So you won't be able to hide the pagination based on where the article is being navigated from.

Please let me know if this provides some clarity on why its not possible out of the box to achieve this.

Thanks,
Shane

#2007433

Hi Shane,
that's fine. I found another solution with Oxygen itself.
However, I want to insert a link in each article which belongs to a magazine ("Heft"). There is already a relationship between a Magazin and the article. I created a custom field from the type "URL" for the article CPT (the articles). Is it possible to pre fill that custom field with the permalink from the corresponding magazine? The magazine permalink is available in each magazine.
I want to make a link into each article that the user can jump back to the corresponding magazine.
Thanks
Thorsten

#2007535

Shane
Supporter

Sprachen: Englisch (English )

Zeitzone: America/Jamaica (GMT-05:00)

HI Thorsten,

This is possible to do however it will require some amount of custom coding to achieve, where you will need to retrieve the post URL when the Article CPT is being created and then insert this into the custom field for the article.

Are the articles being created on the frontend or backend ? All that is needed is for you to get the URL of the parent post into the child correct?

Please let me know.

Thanks,
Shane

#2011969
Heft_URL_3.jpg
Heft_URL_2.jpg
Heft_URL_1.jpg

Hi Shane,
the articles are being created in the backend (please see attached screenshot "Heft_URL_1.jpg"). "Artikel" and "Hefte" have a relationship. What I would like to have is to prefill the Heft_URL custom field from an article (see attached screenshot "Heft_URL_3.jpg") with the corresponding permalink of the "Heft" permalink (see attached screenshot "Heft_URL_2.jpg").
Is this possible?
Thank you
Thorsten

#2013775

Shane
Supporter

Sprachen: Englisch (English )

Zeitzone: America/Jamaica (GMT-05:00)

Hi Thorsten ,

With the post reference field you aren't able to do this.

In order to do this you will need to have a Post Relationship, this means that you will need to go to Toolset->Relationships and create the relationship.

This will then give you a new relationship field on your post types.

From there you can use this hook below to update the custom field.

add_action( 'toolset_association_created', 'refresh_cache_after_association_created', 10, 5 );
function refresh_cache_after_association_created( $association_slug, $parent_id, $child_id, $intermediary_id, $association_id ) {
    wpsc_delete_post_cache( $parent_id );
    wpsc_delete_post_cache( $child_id );
}

Are you working on the backend to create the posts if so then here is an example that should get this working for you.


add_action( 'toolset_association_created', 'update_with_parent_url', 10, 5 );
function update_with_parent_url( $association_slug, $parent_id, $child_id, $intermediary_id, $association_id ) {
 global $post;

if(get_post_type() == 'Artikel'){
$parent_link = get_post_permalink($parent_id);

update_post_meta($child_id,'wpcf-url', $parent_link);
}
}

Ofcourse this is a basic implementation which means, the code will only run on the Artikel CPT.

Assuming that Artikel is the child post in the relationship, i'm updating field url field with the URL of the Parent Hefte,

Please let me know if this provides a suitable example for you.

Thanks,
Shane