Home>Support>Apply So filters on content for 404

Apply So filters on content for 404

Notice: This thread is over two years old; the information may be outdated. Please consider creating a new thread if you require free support. If you have an active SiteOrigin Premium license, you can email our premium support desk at [email protected].

So. I’m building a theme where the 404 information is handled as a regular page, and in the theme i have a setting for this which stores this page id.

In my 404.php i’m quering this page by this stored id, but I can’t get it to work with SO layout.

I’ve tried to force filtering through the_content with this code:

$page_id_404 = get_option('page-id-404');
if($page_id_404)
{
    $page = get_post($page_id_404);
    $content = $page->post_content;
    $content = apply_filters('the_content', $content);
    $content = str_replace(']]>', ']]>', $content);
    echo $content;
}

but with no luck. I guess this is happening since i’m kind of outside the loop. Any suggestion for how to solve this?
I could of course in my 404 maybe try do some kind of redirect to the created 404-page itself, but i would prefer to make it “right” :)

This is our free support forum. Replies can take several days. If you need fast email support, please purchase a SiteOrigin Premium license.

  1. 6 years, 5 months ago Alex S
    Hi, I Work Here

    Hi Linuzitac,

    Try the following PHP:

    $page_id_404 = get_option('page-id-404');
    if($page_id_404) {
        if ( class_exists( 'SiteOrigin_Panels' ) && get_post_meta( $page_id_404, 'panels_data', true ) ) {
    		echo SiteOrigin_Panels::renderer()->render( $page_id_404 );
    	} else {
    	    $page = get_post($page_id_404);
    	    $content = $page->post_content;
    	    $content = apply_filters('the_content', $content);
    	    $content = str_replace(']]>', ']]>', $content);
    	    echo $content;
    	}
    }
    

    How does that look? The above PHP will check if SiteOrigin Page Builder is enabled on your page and if it is, Siteorigin Page Builder will render the page builder layout.

Replies on this thread are closed. Please create a new thread if you have a question, or purchase a SiteOrigin Premium license if you need one-on-one email support.

Get The Most Out of SiteOrigin with SiteOrigin Premium

Find Out More