• Hi!
    First of all, amazing plugin!

    I have a custom post type called “news” and I’m displaying the news posts in a carousel through the Loop on author archive.

    $args=array('post_type'=>'news','author'=>$author_id);
    $news_query = new WP_Query($args);
    ----
    <?php while ($news_query->have_posts()) : $news_query->the_post() ;?>

    My questions are:
    1.how can I add the Translation hint for each news post? The hint shows on the default single.php template bu doesn’t show when I use the above query and Loop. Is it possible to add (msls_filter_string() ) in a custom template?
    2. How can I get the translated post ID of the current post. Eg: if I have the post First_News_English, how can I get the First_News_Chinese ID?

    Thanks in advance!
    Norboo

    https://www.ads-software.com/plugins/multisite-language-switcher/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Dennis Ploetner

    (@realloc)

    Hi,

    1. There are some things I cannot know about your setup. What do you mean with custom-template? Is it a single-news.php file?

    2. MslsOptions::create()->get_arr(); should have what you are looking for…

    Cheers,
    Dennis.

    Thread Starter norboo

    (@norboo)

    Thanks Dennis!
    Sorry about the duplicate post!

    1. My template is archive-news.php
    I’m querying all the news posts and flipping through them on the same page using a Slider/Carousel

    2. Sorry, still can’t figure out how to use MslsOptions::create()->get_arr();
    Lets say we are on first slide which displays the NewsPost-English with the ID=x.
    How would I get the the ID=y, the ID of the translated post. Or even better, how can I create a link to NewsPost-Chinese(ID=y).

    My template looks something like this:

    <?php while ($news_query->have_posts()) : $news_query->the_post() ;?>
            <div class="slide" id="panel-<?php the_ID();?>">
                <div class="content">
                    <?php the_post_thumbnail('article-featured-image'); ?>
                    <h2><?php the_title();?></h2>
                    <?php the_content();?>    
    
                    <a href="">Link to Translation</a>
    
                </div>
            </div>
        <?php endwhile; ?>
    Plugin Author Dennis Ploetner

    (@realloc)

    No problem. ??

    MslsOptions::create()->get_arr(); works only in a single context. It is a factory. You can try something like this in your loop:

    $options = new MslsOptionsPost( get_the_ID() );
    $arr_of_IDs = $options->get_arr();

    Let me know,
    Dennis.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom Post Type query and translation hint’ is closed to new replies.