• Resolved jefromcanada

    (@jefromcanada)


    We are successfully using your plugin to list people in alphabetical order. We needed to implement a custom sort order, since the data field we were sorting on is not structured (i.e. the “last name / first name” information is not in a standardized position within the string. Your plugin ensures that names are displayed correctly.

    So here’s the problem. Click on any of the links, and you will be taken to the correct post, where information about the person is shown. But above the post, you will see the “Next” and “Previous” links at the upper right corner. To a visitor, they assume that these Next and Previous links will display the details for the next or previous name from the list on the “summary” page. And in some cases, where the posts were created chronologically, the desired effect will be witnessed (but only by accident). However, if you start with “Arthur Hair” (the last person added to the list), what you will discover is the next or previous post from our WordPress site – with no regard to the filtering and sorting criteria that was used to display the list in the first place.

    Do you have a method of “knowing” which post should be displayed when the “Next” and “Previous” links are activated (i.e. using information about the filtering and sorting conditions displayed on the summary page)?

    I suppose a workaround would be to check the timestamps on the posts and artificially force these timestamps to be “chronologically ordered”. This would result in the Next and Previous links probably working as expected. However, once the beginning or end of the list was reached, there would be nothing prevent the Next and Previous links from continuing to deliver content – even though there is no more content available within the chosen filter.

    • This topic was modified 2 years, 9 months ago by jefromcanada.
    • This topic was modified 2 years, 9 months ago by jefromcanada.

    The page I need help with: [log in to see the link]

Viewing 15 replies - 1 through 15 (of 15 total)
  • Plugin Contributor zymeth25

    (@zymeth25)

    Well, given you do not want to delete those Next/Previous links, there is a solution.

    It is not possible for the plugin to alter the links without doing something very, very complicated. The thing is those links are generated by your theme and their sole purpose is to allow single step navigation across the list of blog posts. They use simple built-in WP functions to get links of previous and next posts. Meanwhile the only thing our plugin does here is provide a list of links to the posts of your choice; it does not control what happens once you navigate to any of these posts and as I have already mentioned changing it would be complicated.

    Looking at your site it is clear to me that the gunners represent a separate, defined set of data. Therefore you could create a custom post type for this data instead of having it mixed with all other regular posts, then set the LCP plugin to list only this custom post type. Your theme’s templates should be compatible with this solution, if not, it is easy to adapt it. The Next/Previous links should then cycle only within the post type currently viewed.

    Thread Starter jefromcanada

    (@jefromcanada)

    Thank you for your quick reply. Here is the shortcode we are using right now:

    [catlist name=”great-gunners” customfield_orderby=gunner_sort_code order=ASC numberposts=40 template=default ]

    Are you saying that if we created a new custom post type for “great-gunners” and referenced that in your shortcode instead of the name=”great-gunners” category, the standard WordPress “post” that displays each gunner would restrict itself to the specific custom post type? Or would we need to somehow “clone” that standard POST type to become a new GUNNER-POST type, and then change all the existing posts to the new post type?

    I found an article on the wpbeginner site about a plugin I could use to define the new post type. But, I really only want it to mimic what a standard post does (except perhaps for the way it displays the default image).

    By the way, I tried writing to the original plugin author a couple of years ago. I had to create a custom patch to the code to deal with an “issue” (I wouldn’t call it a bug) we had with your plugin, and I really think you’d benefit from adding that functionality to your plugin. I won’t elaborate here (off-topic) and I don’t want to fork your work simply to add this functionality because it’s really YOUR work. I’d love to discuss it and offer you my (terrible but functional) code so you can properly integrate it into your product.

    Plugin Contributor zymeth25

    (@zymeth25)

    Are you saying that if we created a new custom post type for “great-gunners” and referenced that in your shortcode instead of the name=”great-gunners” category, the standard WordPress “post” that displays each gunner would restrict itself to the specific custom post type? Or would we need to somehow “clone” that standard POST type to become a new GUNNER-POST type, and then change all the existing posts to the new post type?

    You would have to create this new post type and migrate (most probably by deleting old posts and creating new ones, but maybe there is a “convert” plugin for that) all great gunners to the new type. You could then use the post_type parameter instead of name as you suggested.

    I found an article on the wpbeginner site about a plugin I could use to define the new post type.

    Yes, there are a few plugins for that. Just pick the one that works best for you. And maybe also have a look at official WordPress docs about custom post types to get a good understanding of how they work.

    I’d love to discuss it and offer you my (terrible but functional) code so you can properly integrate it into your product.

    Great! Head over to our Github repo linked in the plugin’s description. You can then create a new Issue or go straight to Pull Requests and share your code there.

    Thread Starter jefromcanada

    (@jefromcanada)

    That’s the thing… I’m self-taught in PHP and have never used Github. Not sure how it’s done. That’s why I thought if we could communicate and I could pass you my code, YOU could clean it up (I used inline code because I didn’t know how to call it properly as a WordPress codex-compliant function) and integrate it properly.

    Here are two screen captures of the way your plugin worked before I modified it
    https://rca-arc.org/wp-content/uploads/2022/02/before-modifying-plugin.jpg

    and after modifying it
    https://rca-arc.org/wp-content/uploads/2022/02/after-modifying-plugin.jpg

    The issue was that when trying to use a full-html excerpt, sometimes the “cut-off point” would occur in the middle of an html tag. Because the tag didn’t terminate properly, any code that followed would not be aligned correctly. For all I know, you have added this correction (based on my original correspondence with the author) in a subsequent version, but I’ve been afraid to update since 0.84.1 because I didn’t want to lose my customized code.

    Plugin Contributor zymeth25

    (@zymeth25)

    So you are saying Fernando told you he had fixed it?

    Thread Starter jefromcanada

    (@jefromcanada)

    No, I’m saying I got no response.

    But, looking over my notes (I’m very old and my memory is failing), I realize the issue I was addressing was NOT directly with your plugin, but rather in the work done by Sundari Designs to make the plugin more attractive. He had created a number of custom templates, and the issue I had was with one of his templates, not with your plugin. I apologize for my confusion. However, in order to “trigger” my modifications to Sundari’s code, I needed to make a small addition to your code… I added a new excerpt type – so now there is excerpt=yes, excerpt=full and excerpt=custom. This last parameter is the one that is used in my modified version of Sundari’s template.

    I have now reached out again to Sundari to see if he is interested in fixing his template.

    So now that I know the issue is with his template, I’m wondering whether updating to the latest version of your plugin will still allow me to use his template modification, or whether that will be wiped out when I install your update. The modified templates are in the same folder within my child theme where you would normally place your default.php file (and where I have additional files installed, as per Sundari’s instructions).

    • This reply was modified 2 years, 9 months ago by jefromcanada.
    • This reply was modified 2 years, 9 months ago by jefromcanada.
    • This reply was modified 2 years, 9 months ago by jefromcanada.
    Plugin Contributor zymeth25

    (@zymeth25)

    Sundari followed the plugin’s documentation and put the template files in a child theme, so nothing will be lost on plugin updates.

    I can take a look at your modifications to the plugin (excerpt=custom).

    Thread Starter jefromcanada

    (@jefromcanada)

    I changed the file lcp_catlist.php. I don’t see a way to upload it to you through this thread. My modification begins on line 385. Let me know how to get it to you.

    I can also send you the changes I made to Sundari’s nothumb template so you can test how it works for yourself.

    Thread Starter jefromcanada

    (@jefromcanada)

    With respect to the matter at hand, I’ve begun to convert these Great Gunner posts to custom posts with the post_type=”greatgunners”. This does limit the list to ONLY the great gunners (when doing next/previous). Unfortunately, it is still apparently cycling through the list in chronological order rather than using the custom sort criteria.

    Does this mean I have to take the default page template and clone it for use by the Great Gunners list so that there is a special interpretation of Next and Previous links?

    Does your plugin have some sort of “page” template that implements Next/Previous sorting based on the sort criteria in your catlist shortcode?

    Plugin Contributor zymeth25

    (@zymeth25)

    I don’t see a way to upload it to you through this thread.

    Pastebin is arguably the best and simplest option but if you’d rather not paste it in the open I can arrange a different solution.

    You do not need a separate template for these posts. Since you are already creating new posts you can simply edit their publish dates to get the proper order. Added benefit being you will not have to use any custom ordering any more.

    • This reply was modified 2 years, 9 months ago by zymeth25.
    Thread Starter jefromcanada

    (@jefromcanada)

    I followed your suggestion to create a custom post type because editing the publish dates is not something I can easily teach other volunteers to do. Then I used a little known (and unsupported) 10-year-old plug-in (Ambrosite Next/Previous Post Link Plus) to help me create a customized version of the single.php template. It worked really well. It took me nearly 11 hours over the past two days to figure out how to do everything, but it is done.

    Take a look at https://rca-arc.org/heritage/great-gunners/ and follow any of the links to see what I ended up with.

    I really would like to share my improvements to your plugin and Sundari’s template with you. I think my posts use a non-displayed email address, so if you have access to it and want to reach out in person (I won’t abuse your contact info), I’m happy to share. I’ll be 70 years old soon, and don’t want this information to be lost to the world in case something happens to me.

    • This reply was modified 2 years, 9 months ago by jefromcanada.
    • This reply was modified 2 years, 9 months ago by jefromcanada.
    Plugin Contributor zymeth25

    (@zymeth25)

    Take a look at https://rca-arc.org/heritage/great-gunners/ and follow any of the links to see what I ended up with.

    Works much better now. Congrats!

    I wrote an email to an address available on this site. You can reach me by replying to it.

    Thread Starter jefromcanada

    (@jefromcanada)

    Well, that sucks. As I mentioned, I am a VOLUNTEER for this organization. I have access to the WordPress website, but not the the cpanel or any of the email accounts other than my own. To save money, the organization does not have any email addresses registered under their domain. Everyone in the organization uses their own “personal” gmail address. If you filled out the information form on that page, then your mail would have been sent to the person in charge of membership (I believe the current membership chairman is Garth Wigle). Anyway, I’ll have to write to him to ask him to forward your mail to me.

    When I contact Garth, what should I be asking him to look for (in terms of identifying which email came from you)? Did you mention my name? Did you use “zymeth25” anywhere?

    If you ever want to contact me directly, my businesses are:
    Safe and Secure Computing, JEM Software and SSDRAPIDHOST Webhosting Inc.

    I’ll hopefully be able to get the email from Garth and get back to you shortly.

    Thank you for all your assistance!

    EDIT: I’ve sent an email to Garth. Hopefully he didn’t throw away your email if he didn’t know what it was all about. We’ll see…

    • This reply was modified 2 years, 9 months ago by jefromcanada.
    • This reply was modified 2 years, 9 months ago by jefromcanada.
    Plugin Contributor zymeth25

    (@zymeth25)

    Well I just thought it would be simpler for you, I assumed you have full control of the website just like other people asking for help here.

    You can contact me at zymeth25[at]protonmail.con

    Thread Starter jefromcanada

    (@jefromcanada)

    I usually do request and am granted full control of websites I work on. Unfortunately in this case, the original author of the WordPress site also owns the hosting company and did not give the Royal Regiment of Canadian Artillery their own cpanel. Not only would he not grant me access to the cpanel (nor would I expect him to with all his other clients placed at additional risk by a “stranger” having the keys to the castle), he didn’t offer my anything beyond a [reluctant] administrative access to WordPress. Fortunately, I knew of the WordPress File Manager plugin that essentially gave me access to everything down to the /public_html folder. That was enough access to comfortably go along doing what I needed to do, but not enough access to directly access the database (I got access anyway using remote access tools and the passwords stored in the WordPress configuration files). Anyway, enough of that. Now that I have your email address, I will go ahead and send the code I altered. Again, please forgive the rudimentary PHP “skills”. You’ll probably need to improve and refactor the code to make it presentable for distribution. And if you need to know anything about my methodology that isn’t already explained in my embedded documentation, don’t be afraid to ask.

Viewing 15 replies - 1 through 15 (of 15 total)
  • The topic ‘How to deal with Next/Prev links on single post page’ is closed to new replies.