• Resolved bergerlaw

    (@bergerlaw)


    For a query block with pagination, Permalink Manager appears to add an extra “/” that prevents the pagination from working. I have the “Force 404 on non-existing pagination pages” unchecked, but this doesn’t resolve the issue. Thanks for any help you can provide.

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

Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author Maciej Bis

    (@mbis)

    Hi @bergerlaw,

    Could you check if the issue still persists when “Trailing slashes” field field is set to default value in Permalink Manager settings?

    Best regards,
    Maciej

    Thread Starter bergerlaw

    (@bergerlaw)

    Thanks for the quick reply! It’s currently set to Use default settings.

    Thread Starter bergerlaw

    (@bergerlaw)

    If I set it to remove the trailing slash, the pagination works. Now the question is whether removing the slash creates any other problems.

    Plugin Author Maciej Bis

    (@mbis)

    After looking at the code of the Kadence Blocks plugin, I realized that the pagination links are filtered using the ‘paginate_links‘ filter. The problem here is that my plugin hooks into the same filter and forces the global trailing slashes setting although the pagination links are relative.

    This can easily fixed by excluding the pagination links with this code snippet:

    function pm_pagination_trailing_slashes( $permalink, $original_permalink ) {
    	return ( is_numeric( $original_permalink ) ) ? $original_permalink : $permalink;
    }
    add_filter( 'permalink_manager_control_trailing_slashes', 'pm_pagination_trailing_slashes', 10, 2 );
    • This reply was modified 10 months, 1 week ago by Maciej Bis.
    Thread Starter bergerlaw

    (@bergerlaw)

    The code throws the following error: An error of type E_ERROR was caused in line 97 of the file /nas/content/live/allcardsdev1/wp-content/themes/kadence-child/functions.php. Error message: Uncaught ArgumentCountError: Too few arguments to function pm_pagination_trailing_slashes(), 1 passed in /nas/content/live/allcardsdev1/wp-includes/class-wp-hook.php on line 326 and exactly 2 expected in /nas/content/live/allcardsdev1/wp-content/themes/kadence-child/functions.php:97
    Stack trace:
    #0 /nas/content/live/allcardsdev1/wp-includes/class-wp-hook.php(326): pm_pagination_trailing_slashes(‘https://allcard…’)
    #1 /nas/content/live/allcardsdev1/wp-includes/plugin.php(205): WP_Hook->apply_filters(‘https://allcard…’, Array)
    #2 /nas/content/live/allcardsdev1/wp-content/plugins/permalink-manager/includes/core/permalink-manager-core-functions.php(574): apply_filters(‘permalink_manag…’, ‘https://allcard…’, ‘https://allcard…’)
    #3 /nas/content/live/allcardsdev1/wp-includes/class-wp-hook.php(326): Permalink_Manager_Core_Functions::control_trailing_slashes(‘https://allcard…’)
    #4 /nas/content/live/allcardsdev1/wp-includes/plugin.php(205): WP_Hook->apply_filters(‘https://allcard…’, Array)
    #5 /nas/content/live/allcardsdev1/wp-content/plugins/permalink-manager/includes/core/permalink-manager-uri-functions-post.php(120): apply_filters(‘permalink_manag…’, ‘https://allcard…’, Object(WP_Post), ‘https://allcard…’)
    #6 /nas/content/live/allcardsdev1/wp-includes/class-wp-hook.php(326): Permalink_Manager_URI_Functions_Post::custom_post_permalinks(‘https://allcard…’, Object(WP_Post))
    #7 /nas/content/live/allcardsdev1/wp-includes/plugin.php(205): WP_Hook->apply_filters(‘https://allcard…’, Array)
    #8 /nas/content/live/allcardsdev1/wp-includes/link-template.php(308): apply_filters(‘post_link’, ‘https://allcard…’, Object(WP_Post), false)
    #9 /nas/content/live/allcardsdev1/wp-includes/link-template.php(158): get_permalink(Object(WP_Post), false)
    #10 /nas/content/live/allcardsdev1/wp-content/plugins/seo-by-rank-math/includes/replace-variables/class-post-variables.php(579): get_the_permalink(49769)
    #11 /nas/content/live/allcardsdev1/wp-content/plugins/seo-by-rank-math/includes/replace-variables/class-post-variables.php(108): RankMath\Replace_Variables\Post_Variables->get_url()
    #12 /nas/content/live/allcardsdev1/wp-content/plugins/seo-by-rank-math/includes/replace-variables/class-manager.php(171): RankMath\Replace_Variables\Post_Variables->setup_post_variables()
    #13 /nas/content/live/allcardsdev1/wp-includes/class-wp-hook.php(324): RankMath\Replace_Variables\Manager->setup(‘plugins.php’)
    #14 /nas/content/live/allcardsdev1/wp-includes/class-wp-hook.php(348): WP_Hook->apply_filters(NULL, Array)
    #15 /nas/content/live/allcardsdev1/wp-includes/plugin.php(517): WP_Hook->do_action(Array)
    #16 /nas/content/live/allcardsdev1/wp-admin/admin-header.php(118): do_action(‘admin_enqueue_s…’, ‘plugins.php’)
    #17 /nas/content/live/allcardsdev1/wp-admin/plugins.php(621): require_once(‘/nas/content/li…’)
    #18 {main}
    ?thrown

    Thread Starter bergerlaw

    (@bergerlaw)

    Thanks for this code, however, it generates an error: The code throws the following error: An error of type E_ERROR was caused in line 97 of the file /nas/content/live/allcardsdev1/wp-content/themes/kadence-child/functions.php. Error message: Uncaught ArgumentCountError: Too few arguments to function pm_pagination_trailing_slashes(), 1 passed in /nas/content/live/allcardsdev1/wp-includes/class-wp-hook.php on line 326 and exactly 2 expected in /nas/content/live/allcardsdev1/wp-content/themes/kadence-child/functions.php:97

    Plugin Author Maciej Bis

    (@mbis)

    The initial version was indeed incorrect. I fixed it here, but you probably did not get the message about the change.

    Please make sure that the last line is:

    add_filter( 'permalink_manager_control_trailing_slashes', 'pm_pagination_trailing_slashes', 10, 2 );

    and not the:

    add_filter( 'permalink_manager_control_trailing_slashes', 'pm_pagination_trailing_slashes', 10 );
    • This reply was modified 10 months, 1 week ago by Maciej Bis.
    Thread Starter bergerlaw

    (@bergerlaw)

    I think your last message is cut off, and I don’t see any difference in the code.

    Plugin Author Maciej Bis

    (@mbis)

    Sorry for the inconvenience, the only difference is in the end of the snippet.

    The incorrect version (the one that generates the PHP error) ends with:

    , 10 );

    but to make it working, it needs to end with “2” (this number indicates the number of arguments declared for hook).

    , 10, 2 );
    • This reply was modified 10 months, 1 week ago by Maciej Bis.
    Thread Starter bergerlaw

    (@bergerlaw)

    Thank you!

Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘Breaks Pagination in Kadence Theme’ is closed to new replies.