Incorrect URLs for Learnpress Lessons in Search Results

Home Forums Product Support Forums Ajax Search Pro for WordPress Support Incorrect URLs for Learnpress Lessons in Search Results

This topic contains 7 replies, has 2 voices, and was last updated by Ernest Marcinko Ernest Marcinko 6 years, 11 months ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #12885
    sschoch
    sschoch
    Participant

    Hi, Ernest:

    Our Ops department has spent a lot of time trying to figure this out. They now think it’s an Ajax Search Pro issue, so I’m wondering if you can help.

    We have the Learnpress plugin installed, which adds the post types lp_lesson and lp_course to the site. Clicking the links for many of the lessons from the Search Results pages results in a 404 error.

    Here’s the problem. The actual URL of the lessons looks like this:

    /cb/help/nb360/course/<course_name>/lessons/<lesson_name>/ ‎

    However, the URL that Ajax Search Pro has on the Search Results pages is this:

    /cb/help/nb360/lessons/<lesson_name>/ ‎

    We have cleared the cache, disabled the CDN, and recreated the Ajax Search Pro index several times. The lesson links work properly in the Search Results then the links revert back to the incorrect URL later.

    Any ideas? I would like to set up a WebEx session and give you control of my screen. If you need access to the site, however, I can do that also.

    Thank you, Stephanie

    #12890
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Hi Stephanie,

    The plugin gets the URL directly from the WordPress core, using the get_the_title($id) call. That should return the correct URLs in all cases. I did some research, and found this topic regarding Learnpress: https://wordpress.org/support/topic/lessons-url-from-search-results-is-not-working/

    It’s a pretty similar issue, appears to be a bug in their plugin, but as a result of a limitation. From what I can see the developer explains that the lesson URLs are meant not to be working outside a course context, for some reason. I believe that is going to be the reason why the incorrect URL is returned.

    Even a bigger issue is that Ajax Search Pro cannot control post type links on the search results page, that is automatically parsed by them theme based on the post object ID (lesson ID). So even if there is a way to get the correct URLs, it has to be somehow edited into the search.php file in the theme directory, or maybe using the ‘post_type_link’ filter, but I’m not sure if those apply on that page.

    The live search result URLs can be changed very simply, but the results page is theme related territory unfortunately.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #12891
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    Addition:

    I’ve taken a very quick look at their plugin source, and the LP_Lesson class found in learnpress/inc/lesson/class-lp-lesson.php seems to be the one responsible for lesson object management. I’m not sure if this is helpful, but I believe it is possible to use it like this in the theme files:

    $l = new LP_Lesson( get_the_ID() );

    Now the $l variable holds the lesson post type object, and it has a ‘guid’ property, which might be the correct URL. So changing the result anchor link to:

    $l->post->guid

    or maybe

    $l->_item->guid

    ..should have an effect, or may even work, I’m not sure.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #13021
    sschoch
    sschoch
    Participant

    Hi, Ernest:

    I think you are saying to add this line to one of the theme’s files…

    $l = new LP_Lesson( get_the_ID() );

    …but I am not sure which file to put it in. HelpGuru has a number of PHP with the word “search” in them. Any additional context you can provide so I can find the correct location?

    And by “changing the result anchor link,” I think you mean an Ajax Search Pro setting, right?

    Please advise and thank you for any help you can provide.

    Thanks, Steph

    #13047
    sschoch
    sschoch
    Participant

    Hello, again:

    I have decided to abandon the idea of having the lessons appear in the Search Results page because, as you point out, the Learnpress authors did not design lessons to be opened outside of a course. So I was able to exclude them from the Ajax Search.

    But, I discovered another issue. The vertical search results properly show results from both sites in the multisite setup; however, only results from the Site 1 (the site where the search box resides) appear on the Search Results page and none of the results from Site 2. I’ve included a screenshot of the Logic & Behavior settings.

    I’ve tried using an index (making sure pages are indexed because Site 2 only has pages and not other post types) and not using an index, but can’t get results from Site 2 to show up on the Search Results pages. Is this also a theme problem?

    Attachments:
    You must be logged in to view attached files.
    #13052
    Ernest Marcinko
    Ernest Marcinko
    Keymaster

    It’s rather a WordPress core issue, not neccesarily related to the theme.
    At this point WordPress is not capable to display items from cross site on the search results page, it’s simply not supported. I have however found a possible solution, and built it into Ajax Search Pro, but then again it does not seem to work in all of the cases. It works with the built in themes, but not with others, sometimes not even with the built in ones.
    I’m not really sure why it does not work though, it seems that sometimes wordpress just ignores the post objects from the cross sites, and displays only the ones that exist on the current blog.

    If you want, I can take a direct look at the source, feel free to leave FTP and back-end access and I will try to debug through the search page and process.

    Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


    #13138
    sschoch
    sschoch
    Participant

    Hi, Ernest:

    After discussing the options, we have decided to disable the Search Results pages altogether and only use the vertical results under the search box.

    Thank you again for your timely responses and suggestions. You can close this ticket.

    Stephanie

    #13143
    Ernest Marcinko
    Ernest Marcinko
    Keymaster
    You cannot access this content. Best,
    Ernest Marcinko

    If you like my products, don't forget to rate them on codecanyon :)


Viewing 8 posts - 1 through 8 (of 8 total)

The topic ‘Incorrect URLs for Learnpress Lessons in Search Results’ is closed to new replies.