• I have a local site that my plugin is working great on. I moved it to a hosted site and now the plugin does not work. I have a filter hook for $the_content where is add to the content of a page.

    I have this in my themes function.php file
    add_filter( ‘the_content’, ‘errorcode_post’);

    I have this code in another file:
    function errorcode_post( $content ) {

    global $error;
    global $mfg1;

    require_once(‘BTSErrorLookupMessages.php’);

    $new_content = “”;

    remove_filter( ‘the_content’, ‘errorcode_post’ );

    if( is_page(‘Error Code Lookup’) && is_singular() && is_main_query() ) {

    if (empty($_GET[‘btserror’]) && empty($_GET[‘mfg’])) {
    gravity_form(‘error_codes’, false, false, false, ”, false);
    //$new_content .= ‘[myshortcode]’;
    $new_content .= CUSTOMER_MESSAGE;
    //$new_content .= “Error” . $error . “
    “;
    $new_content .= find_error2( $error, $mfg1 );
    //$new_content .= ‘MFG = ‘ . $mfg1 . ‘
    ‘;
    //$new_content .= ‘Error = ‘ . $error;
    }
    else {
    //wp_enqueue_script(‘bts-error-codes’);
    $new_content .= find_error2( $_GET[‘btserror’], $_GET[‘mfg’] );
    //$new_content .= ‘MFG = ‘ . $_GET[‘mfg’] . ‘
    ‘;
    //$new_content .= ‘Error = ‘ . $_GET[‘btserror’];
    }
    }
    $content .= $new_content;

    //echo $new_content;

    return $content;

    }

    The function is being called but the $new_content does nothing and my gravity form is being displayed at the beginning of the page before the head. Not sure why moving it to a hosted site would cause this issue.

    Thanks in advance.
    ab

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

    (@ab000)

    Looks like the Yoast SEO plugin is causing the add_filter($the_content, ‘errorcode_post’) not to work properly. It calls the errorccode_post function but doesn’t pass the_content to the function, hence none of my additions to the content were not showing up. Not sure what I am doing wrong but disabling the yoast plugin fixes it.

Viewing 1 replies (of 1 total)
  • The topic ‘$the_content filter not working’ is closed to new replies.