WordPress.org

Ready to get started?Download WordPress

Forums

Is possible to use function in is_page array? (2 posts)

  1. Machi
    Member
    Posted 5 years ago #

    Hi, I have small troubles today :).

    I need simple WP website in three languages (don't ask me why I don't want to use a language plugin) so I decided to create simple functions in functions.php:

    function jazyk($jazyk) {
    	if($jazyk=='en') { return 'Greek cummunity Brno'; }
    	elseif($jazyk=='gr') { return 'ΕΛΛΗΝΙΚΗ ΚΟΙΝΟΤΗΤΑ ΜΠΡΝΟ'; }
    	else { return 'Řecká obec Brno'; };
    	}
    
    function jazykid($jazykid) {
    	if($jazykid=='en') { return '12,13,14,15,16,17,18,19,20'; }
    	elseif($jazykid=='gr') { return '21,22,23,24,25,26,27,28,29'; }
    	else { return '3,4,5,6,7,8,9,10,11'; };
    	}

    and then I call these functions from header.php:

    if(is_page(array(jazykid('en')))) { echo jazyk('en'); } elseif(is_page(array(jazykid('gr')))) { echo jazyk('gr'); } else { echo jazyk(''); };

    But it doesn't work, when I use this:

    if(is_page(array(12,13,14,15,16,17,18,19,20))) { echo jazyk('en'); }

    it works fine.

    So my question is... is there any way how to use functions inside the array? Or how to create a global variable and use it instead of typing IDs manually again and again?

    Thanks a lot guys, Machi

  2. Machi
    Member
    Posted 5 years ago #

    Nobody knows? I still haven't figured it out :( pls

Topic Closed

This topic has been closed to new replies.

About this Topic