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 6249445
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T13:14:23+00:00 2026-05-24T13:14:23+00:00

I think I’m repeating too much in the following if-statement: <?php $current_language = get_bloginfo(

  • 0

I think I’m repeating too much in the following if-statement:

<?php $current_language = get_bloginfo( 'language' ); ?>
<div id="next">
    <?php if ( $current_language == 'es-ES' ) : ?>
        <?php next_post_link( '%link', 'Proyecto Siguiente ' . _x( '', 'next post link', 'twentyten' ) . '' ); ?>
    <?php elseif ( $current_language == 'zh-TW' ) : ?>
        <?php next_post_link( '%link', '下一個項目 ' . _x( '', 'next post link', 'twentyten' ) . '' ); ?>
    <?php elseif ( $current_language == 'zh-CN' ) : ?>
        <?php next_post_link( '%link', '下一个项目 ' . _x( '', 'next post link', 'twentyten' ) . '' ); ?>
    <?php else : ?>
        <?php next_post_link( '%link', 'Next Project ' . _x( '', 'next post link', 'twentyten' ) . '' ); ?>
    <?php endif; ?>
</div>
<div id="prev">
    <?php if ( $current_language == 'es-ES' ) : ?>
        <?php previous_post_link( '%link', '' . _x( '', 'previous post link', 'twentyten' ) . ' Proyecto Anterior' ); ?>
    <?php elseif ( $current_language == 'zh-TW' ) : ?>
        <?php previous_post_link( '%link', '' . _x( '', 'previous post link', 'twentyten' ) . ' 上一個項目' ); ?>
    <?php elseif ( $current_language == 'zh-CN' ) : ?>
        <?php previous_post_link( '%link', '' . _x( '', 'previous post link', 'twentyten' ) . ' 上一个项目' ); ?>
    <?php else : ?>
        <?php previous_post_link( '%link', '' . _x( '', 'previous post link', 'twentyten' ) . ' Previous Project' ); ?>
    <?php endif; ?>
</div>

(The repetition of php tags is a WordPress convention I think).

I wonder if there’s a way of not repeating the previous_post_link and next_post_link functions?

  • 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-05-24T13:14:23+00:00Added an answer on May 24, 2026 at 1:14 pm

    Well, one thing is that you don’t have to wrap every line in <?php ... ?> tags. And since you’re repeating the same thing quite a lot, you could use an array instead:

    <div id="next">
    <?php 
    $current_language = get_bloginfo( 'language' ); 
    $translations = array( 
        'es-ES' => 'Proyecto Siguiente',
        'zh-TW' => '下一個項目',
        'zh-CN' => '下一个项目',
        'en-GB' => 'Next Project'
    );
    
    if( !isset( $translations[ $current_language ] ) ) {
        $current_language = 'en-GB';
    }
    
    next_post_link( '%link', $translations[ $current_language ].' ' . _x( '', 'next post link', 'twentyten' ) . '' ); 
    ?>
    

    If you’re translating every string in your app like this, it might be worth considering a more general system behind it like gettext.

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

Sidebar

Related Questions

Think about the following: Your ISP offers you a dynamic ip-address (for example 123.123.123.123).
link Im having trouble converting the html entites into html characters, (&# 8217;) i
Think of the following code: static int Main() { byte[] data = File.ReadAllBytes(anyfile); SomeMethod(data);
Think about the classic installation process, where you have a next button and when
Think of the following services on one box: SOCKS proxy HTTP proxy SSH service
Think about a rectangular div, which is split into 2 parts, each part is
Think of a equations system like the following: a* = b + f +
Think that you have a content div whether the content of a website is
I think, the following can't be done in Java. But I would be happy
Think: tiling my emacs window with eshells, a la xmonad. Is this possible? I

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.