• Error Report:

    Hello,

    I encountered an issue with the Job Postings plugin that seems to be related to the misuse of the is_singular function. The error message is as follows:

    wp-content/plugins/job-postings/class-job-postings.php:74
    
    Function is_singular was called incorrectly. Conditional query tags do not work before the query is run. Before then, they always return false. (This message was added in version 3.1.0.)

    It appears that the is_singular function is being called before the query is run, leading to incorrect behavior. This can be problematic as it causes the function to always return false in this context.

    Could you please look into this and provide a fix or guidance on how to resolve this issue?

    Thank you for your assistance.

    Best regards,
    Cedus

Viewing 1 replies (of 1 total)
  • Thread Starter cedus

    (@cedus)

    $jobs_selected_schema = get_option( 'jobs_selected_schema' );
    if( !$jobs_selected_schema || empty($jobs_selected_schema) || $jobs_selected_schema == "default" ){
    add_filter( 'wpseo_json_ld_output', array('Job_Postings','jp_disable_yoast_seo_schema'), 10, 1 );
    }elseif(!is_admin() && $jobs_selected_schema == "yoast_seo" /* && is_singular( 'jobs' ) */){
    add_filter( 'job-postings/disable_json_ld', array('Job_Postings', 'jp_disable_job_postings_schema'),10,2 );
    add_filter( 'wpseo_json_ld_output', array('Job_Postings','jp_disable_yoast_seo_schema'), 10, 1 );
    }

    add_action('deactivated_plugin', array('Job_Postings', 'set_deafult_on_yoast_deactivation') );

    }

    public static function jp_disable_yoast_seo_schema($data){
    if(!is_singular( 'jobs' )) return $data;
    $data = [];
    return $data;
    }

    public static function jp_disable_job_postings_schema($value, $job_id){
    if(!is_singular( 'jobs' )) return $value;
    return true;
    }

    This seems to fix the notice.

Viewing 1 replies (of 1 total)
  • You must be logged in to reply to this topic.