WordPress.org

Ready to get started?Download WordPress

Forums

Change page content at runtime (4 posts)

  1. nesar77
    Member
    Posted 5 months ago #

    Hi wpForum,

    I'd like to change a page content at runtime because qTranslate doesn't work fine on 3.7.1. So I'd like to change url or page content i.e.

    <?php
    					$language = $_GET['lang'];
    					if (!empty($language)) {
    						if (($language == 'en') ) {
    							 wp_redirect( 'http://url?page_id=996', 301 ); exit;
    										    }
    								}
    					?>

    Is it possible?

    Tia

  2. bcworkz
    Member
    Posted 5 months ago #

    I'm uncertain what you have in mind exactly. Perhaps Multilingual WordPress will give you ideas for an approach.

  3. nesar77
    Member
    Posted 5 months ago #

    Hi bcworkz,

    I'm using qTranslate plugin to translate pages and switch between different languages.

    qTranslate works fine but not on 3.7.1 so I'm not able to translate pages if they contains WP Pro Quiz shortcode .

    Is it possible to check language and redirect an url or change page content based on url parameter (i.e. &lang=de ) .

    Have you got any suggestions?

    Regards.

  4. bcworkz
    Member
    Posted 5 months ago #

    Yes, it's possible, but the specifics will vary by how your translations are implemented and how the current language is kept track of.

    For example, I could get the current language from get_locale() and then alter which content is queried by hooking 'pre_get_posts'. Your site may not track the current language that way, and the various translations may not be queryable that way.

    My limited understanding of qTranslate is the translations are stored in the same post. I imagine what is displayed on a page is filtered on output, and the language URL parameter is used somehow to determine what to filter out. The user's language preference is surely stored somewhere, perhaps a cookie. That setting could influence how permalinks are built.

    This is all speculation, a thorough investigation of the plugin would reveal what really needs to be done. Sorry I can't give you better advice.

Reply

You must log in to post.

About this Topic