WordPress.org

Ready to get started?Download WordPress

Forums

Need someone to translate words into php code (2 posts)

  1. domiass
    Member
    Posted 1 year ago #

    Hey guys,

    I'll try to be as clear as I can because it's pretty difficult to write it down...
    Situation: I have WPML (multilingual site) plugin installed and it works perfectly but the problem is that I am using this theme which has custom posts such as Homepage Text and Homepage Boxes and those two posts that appear on my homepage do not have a possibility of translating content into other languages to have that Homepage Text and Boxes in different languages (that part of the WPML plugin just doesn't appear there). Homepage Text and Homepage Boxes, those two appear on the left side of wordpress - it's a part of menu, just like Links, Pages or Comments...

    I kind of came up with one way of solving this.

    I created a few more of these custom posts. Now I have:

    Homepage Text (home_text)
    Homepage Boxes (home_boxes)

    Homepage Text English (home_text_en)
    Homepage Boxes English (home_boxes_en)

    Homepage Text Russian (home_text_ru)
    Homepage Boxes Russian (home_boxes_ru)

    There are two pieces of code in index.php for these two custom post. I'll show you one:

    <div id="homepage-text">
        <?php query_posts(array(
    			'post_type'=>'home_text',
    			'orderby' => 'ASC'
    			));
    	?>
    	<?php if ( have_posts() ) while ( have_posts() ) : the_post();?>
    	<h2><?php the_title() ?></h2>
    	<?php the_content(); ?>
    	<?php endwhile; ?>
        </div><!-- /homepage-text -->

    After this, there's a similar code for Homepage Boxes...

    Way of solving: Writing a code which says: "if the address you are coming from says http://www.website.eu - use homepage text and boxes that are home_text and home_boxes; If it's http://www.website.com/EN - use home_text_en, and so on... I hope you get what I'm saying..

    Is here anyone who had enough time to read all of this and would be so kind and write me that piece of code that translates my words into php?

    Thank you in advance

    Domantas

    [No bumping. If it's that urgent, consider hiring someone.]

  2. domiass
    Member
    Posted 1 year ago #

    I've been googling a lot and the beggining of the code should probably look like this:

    if (condition that it's the main language directory)
      {
      register_post_type( 'home_text',
        array(
          'labels' => array(
            'name' => __( 'Homepage Text' ),
            'singular_name' => __( 'Homepage Text' )
          ),
          'public' => true,
    	  'supports' => array('title','editor')
    
        )
      );
      }
    elseif (condition that it's english language directory .com/en)
      {
      register_post_type( 'home_text_en',
        array(
          'labels' => array(
            'name' => __( 'Homepage Text English' ),
            'singular_name' => __( 'Homepage Text English' )
          ),
          'public' => true,
    	  'supports' => array('title','editor')
    
        )
      );
      }
    else
      {
      register_post_type( 'home_text_ru',
        array(
          'labels' => array(
            'name' => __( 'Homepage Text Russian' ),
            'singular_name' => __( 'Homepage Text Russian' )
          ),
          'public' => true,
    	  'supports' => array('title','editor')
    
        )
      );
      }

    So now my question is how to write conditions for those two?

    Thank you.

Topic Closed

This topic has been closed to new replies.

About this Topic