• Resolved Guillermo

    (@guillermo77)


    How I can solve this?

    [10-Dec-2024 00:41:12 UTC] PHP Fatal error: Uncaught ArgumentCountError: Too few arguments to function jetpackme_exclude_related_post(), 1 passed in wp-includes/class-wp-hook.php on line 324 and exactly 2 expected in /wp-content/themes/generatepress_/functions.php:238

    function jetpackme_exclude_related_post( $exclude_post_ids, $post_id ) {
    // $post_id is the post we are currently getting related posts for

    $exclude_post_ids[] = 1037; // Exclude post_id 1037.
    $exclude_post_ids[] = 1038;// Also exclude post_id 1038.
    
    return $exclude_post_ids;

    }
    add_filter( ‘jetpack_relatedposts_filter_exclude_post_ids’, ‘jetpackme_exclude_related_post’, 20, 2 );

Viewing 4 replies - 1 through 4 (of 4 total)
  • Plugin Support Chatoxz (a11n)

    (@chatoxz)

    Hi there,

    To resolve the error, ensure that the function jetpackme_exclude_related_post is defined to accept two parameters. Your current function definition is correct, but make sure the filter add_filter is correctly implemented with the right number of arguments. Here’s the correct setup:

    function jetpackme_exclude_related_post( $exclude_post_ids, $post_id ) {
        $exclude_post_ids[] = 1037; // Exclude post_id 1037.
        $exclude_post_ids[] = 1038; // Also exclude post_id 1038.
    
        return $exclude_post_ids;
    }
    add_filter( 'jetpack_relatedposts_filter_exclude_post_ids', 'jetpackme_exclude_related_post', 20, 2 );
    

    Ensure that the add_filter line is correctly placed in your functions.php file and that no syntax errors exist elsewhere in the file.

    Cheers,

    Thread Starter Guillermo

    (@guillermo77)

    The two functions are the same, what do you think of add one if is single, because that fix my problem, or was temporary
    I also have some problem of sync, maybe that was the problem

    // excluir entradas en relacionado jetpack
    function jetpackme_exclude_related_post( $exclude_post_ids, $post_id ) {
    // $post_id is the post we are currently getting related posts for
    if( is_single()) {
    $exclude_post_ids[] = 8339; // Programa
    return $exclude_post_ids;
    }
    }
    add_filter( 'jetpack_relatedposts_filter_exclude_post_ids', 'jetpackme_exclude_related_post', 20, 2 );
    Plugin Support lastsplash (a11n)

    (@lastsplash)

    Hi @guillermo77

    Can you share the URL of your site so that we can look at sync issue?

    Plugin Contributor Stef (a11n)

    (@erania-pinnera)

    Hi there, @guillermo77,

    Do you have updates about that, do you still need help? We usually close inactive threads after one week of no movement, but we want to make sure we’re all set before marking it as solved. Thanks!

Viewing 4 replies - 1 through 4 (of 4 total)

The topic ‘PHP 8.4 and related post function’ is closed to new replies.