This thread is over two years old and may be outdated. Please create a new thread if you need help, or email us if you have an active Premium license.

Apply So filters on content for 404

7 years ago · Last reply by Alex S 7 years ago

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.

Need fast email support? Get SiteOrigin Premium

Replies

1
  1. Alex S Staff 7 years, 1 month ago

    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.

Have a different question or issue?

Start New Thread