• <?php
        $args = array('parent' => 6 );
        $pages = get_pages( $args );
        $stt = 1;
        foreach ($pages as $page_item) : ?>
           <li rel=<?php echo "tab".$stt; ?> >
               <a>'>
                  <span class="di-table-cell thumb">
                       <?php echo get_the_post_thumbnail( $page_item,       array(44,46) ); ?>
                  </span>
                  <span class="di-table-cell content">
                      <?php echo get_the_title( $page_item ); ?>
                  </span>
               </a>
    
    <?php
        $stt++;
        endforeach;
        wp_reset_postdata();
    ?>
Viewing 6 replies - 1 through 6 (of 6 total)
  • I don’t fully understand your question. Can you answer the following to help me?

    1. What are you trying to accomplish with the above code?
    2. How is it not working the way you expected it to?

    Thanks!

    Perhaps you could use the rest of the polylang functions like this:

    <?php
      global $post;
    
      $post_parent = 6;
      $parent = pll_get_post($post_parent,pll_current_language());
    
      $opts = array(
        'post_type' => 'page',
        'post_status' => 'publish',
        'post_parent' => 6,
        'lang' => pll_current_language()
      );
    
      $pages = new WP_Query($opts);
      while ($pages->have_posts()):
        $pages->the_post();
        // code from this point is like the loop
      ?>
    
      <?php
      endwhile;
      wp_reset_postdata();
    Thread Starter huanhip

    (@huanhip)

    #ditikos. But post_parent in different languages is so post_parent = 6 only understand one language only. Exemple:
    English with ID = 6;
    Spain with ID = 10;
    Help me!

    Thread Starter huanhip

    (@huanhip)

    #Alexandre Simard. I want to setup 2 language my website is in English and Spanish. I want to show posts from 2 languages.

    @huanhip
    you did not mention that you wanted to show BOTH the languages. In that case you need the first parent and its translation to be shown, regardless of the language you are in to, right?

    Otherwise the query above works, as long as you have connected your translations.

    If you want to show in BOTH spanish and english, knowing that 6 is the first language and 10 the second, then you do this:

    $ids = array(6,10);
    
      $opts = array(
        'post_type' => 'page',
        'post_status' => 'publish',
        'post_parent__in' => $ids,
        'posts_per_page' => -1
      );

    the rest stays the same.

    Thread Starter huanhip

    (@huanhip)

    oh! @ditikos. Tkanks you so much! I’m trying for another if clause, but it is quite lengthy. Your great plans!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘How to using "pll_get_post" show the internal page correct language’ is closed to new replies.