Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8548041
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T13:24:12+00:00 2026-06-11T13:24:12+00:00

I’m running a wordpress blog with qtranslate. It’s using 3 languages. I created a

  • 0

I’m running a wordpress blog with qtranslate. It’s using 3 languages.

I created a custom Menu (price lists), which is saved to db using post_meta wp hooks.

I use simple logic to display list item, it worked perfectly when I was using only 1 language. But now that I added qtranslate I’m having problems.

Let me guide you through the resolution process so you better understand where I’m stuck!

So, I had this code:

        <?php
            if ( get_post_meta($post->ID, 'price_list_items_category1', true) ) :
                $pricelistline = explode("\n", get_post_meta($post->ID, 'price_list_items_category2', true));

                foreach($pricelistline as $value) {
                    $e = explode("|",$value);
                    echo "<li><p>" . $e[0] . " <span>" . $e[1] . "</span></p> <span class=\"listmenuprice\">" . $e[2] . "</span><div class=\"clearfloat\"></div><!-- Very Important --></li>\n";
                }
            endif;
        ?>

print_r for $pricelistline was:

Array ( [0] => [:en]Rhine Riesling1|0,75 l|9,50 € [1] => [:ge]ჩიხირთმა|100გ|10ლ [2] => [:ru]шоколад|100грамм|10 L )

Obviously my script was displaying all three languages at the same time… To fix this I read about qtranslate, and discovered that by using _e() qtranslate would take over the situation and display correct language and block unwanted ones.

So modified code:

        <?php
            if ( get_post_meta($post->ID, 'price_list_items_category1', true) ) :
                $pricelistline = explode("\n", get_post_meta($post->ID, 'price_list_items_category1', true));

                print_r($pricelistline);
                foreach($pricelistline as $value) {
                    $e = explode("|",$value);
                    _e( "<li><p>" . $e[0] . " <span>" . $e[1] . "</span></p> <span class=\"listmenuprice\">" . $e[2] . "</span><div class=\"clearfloat\"></div><!-- Very Important --></li>\n");
                }
            endif;
        ?>

Notice the difference here: _e( "<li><p>" . $e[0] . " <span>" . $e[1] . "</span></p> <span class=\"listmenuprice\">" . $e[2] . "</span><div class=\"clearfloat\"></div><!-- Very Important --></li>\n");

This seemed to have worked! as other language instances disappeared, so on English page I’d see only english version etc.

Problem is now I find some bogus html remaining when I view source.

HTML output looks like this now:

<ul class="listmenuitems" id="listingmenu_1">
<li><p>Rhine Riesling1 <span>0,75 l</span></p> <span class="listmenuprice">9,50 €
</span><div class="clearfloat"></div><!-- Very Important --></li>
<li><p><li><p>
</ul>

notice: <li><p><li><p> these are two opening elements of two remaining languages. My guess is something gets jammed in $e[1] on languages that are not displayed and this is why languages seem to work! but in reality there is some php error.

I did tail -f /var/log/apache2/error_log but I don’t see any php errors.

So what is going on here? can you please help? I just need to get rid of extra html elements. For the rest my modification seems to have worked!

Came out as a long post, but I hope I gave all the details.

Thanks for reading 🙂

var_dump

array(3) { [0]=> string(37) "[:en]Rhine Riesling1|0,75 l|9,50 € " [1]=> string(43) "[:ge]ჩიხირთმა|100გ|10ლ " [2]=> string(38) "[:ru]шоколад|100грамм|10 L" }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-11T13:24:13+00:00Added an answer on June 11, 2026 at 1:24 pm

    I don’t know how _e blocks out the other languages but it looks like it just drops when it finds a word in the wrong language, I suggest you do one of:

    Variant 1: don’t use foreach, but instead use fixed indexes for your array depending on language

    Variant 2: check the first letters of the array yourself to see if it matches the correct language and if yes use the old echo instead.

    Variant 3: find a function that just tells you if the language is the one you’re looking for and echo the output depending on that condition

    Update: looks like the function for Variant3 might be __ (that’s two underscores I think)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I have a French site that I want to parse, but am running into
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I would like to run a str_replace or preg_replace which looks for certain words
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.