Load page on slug that not exist (1 post)

  1. Danny de Haan
    Posted 2 years ago #

    Hi All,

    Maybe the title is some what cryptic, but i have a problem and tried already some things, but i can't figure out what i'm doing wrong. So the problem is the following.

    Our client have a front-page with a language choice. Language 1 is going to another website. And language 2 is going to http://example.com/de/home. We've already managed to add the /de/ to all the pages, but the page /de/ doesn't exist. Is done with a "hack" on the permalinks. But they don't want http://example.com/de/home to be the homepage, but http://example.com/de and that http://example.com/de/home is loaded into the page without the slug showing in the URL. I've already tried this:

    function Permalink_Prefix_Query_Vars( $query ) {
    		if( $query->is_main_query() ) {
    			if( trim( $_SERVER['REQUEST_URI'], '/' ) == $this->prefix ) {
    				$post = get_post( $this->alternative_home_page );
    				unset( $query->query );
    				unset( $query->query_vars['post_type'] );
    				unset( $query->query_vars['language_landingpage'] );
    				$query->query_vars['name'] = '';
    				$query->query_vars['pagename'] = $post->post_name;
    				$query->query['page'] = '';
    				$query->query['pagename'] = $post->post_name;
    				$query->queried_object = $post;
    				$query->queried_object_id = $this->alternative_home_page;
    		return $query;

    $this->prefix = 'de';
    $this->alternative_home_page = 22; /home/

    This function is called on the action 'parse_query'

    This is working, but is redirected to http://example.com/de/home which they don't want.

    Does someone have an idea about this?

    Thank you in advance!!

Topic Closed

This topic has been closed to new replies.

About this Topic