WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've got something about this on the WPML support forums, but I figured I could ask here as well. Here's the important info: I'm running a WP Multisite setup with custom post types, custom fields, custom everything it seems. In a particular template file, I've got a secondary loop that's pulling a list of items from a different blog. From what I gathered, anything using the WP API should be filtered down to only the current language, but none of the WP_Query() functions I've got are doing so.

Relevant code:

$args = array('post_type' => 'release-notes',
    'suppress_filters' => 0,
    'meta_query' => array(
                'key' => 'related_products',
                'value' => $thisproduct,
                'compare' => 'LIKE'
$loop = new WP_Query($args);
if ($loop->have_posts()) {
    echo '<h2>Release Notes</h2>';
    while ( $loop->have_posts() ) : $loop->the_post();
        //echo '<pre>';
        //echo '</pre>';
        $post_link = ($post->post_name);
        echo '<p><a class="text-link" href="' . get_permalink() . '">' . get_the_title() . '</a></p>';
    endwhile; // foreach($posts
} // if ($results

The problem here is twofold: first, it's returning results from every language instead of the current language - the same post, three times (EN, FR, DE). Second, the result from get_permalink() is completely wrong - it's spitting out http://www.mysite.com/blog23name/postname instead of http://www.mysite.com/blog23name/lang/posttype/postname - the custom permalink shown on the 'edit post' page.

Any ideas?

share|improve this question

closed as off-topic by Pieter Goosen, cybmeta, kaiser Nov 22 '14 at 8:55

This question appears to be off-topic. The users who voted to close gave this specific reason:

If this question can be reworded to fit the rules in the help center, please edit the question.

IMO, it's not fair to ask premium plugin questions here... – brasofilo Jun 19 '12 at 3:20
"Not fair"? In what way? Why would there be a tag for WPML if it couldn't be asked here? Check the FAQ again, mate. It's licensed under the GPL (even the premium version), so technically I could post any relevant code chunks for others to look at for troubleshooting. That said, at least one of the issues is a core WordPress issue - switch_to_blog() doesn't pass over permalinks for custom post types with get_permalink() - making this a great place to ask about it. Thanks for the downvote, though, it's much more helpful than actually coming up with an answer to a 2 month old question. – SickHippie Jun 19 '12 at 3:43
Do they have a "free version"? If they do, sorry, I was not aware... If they don't, having a Tag doesn't excuse any GPL... – brasofilo Jun 19 '12 at 3:48
Yes, I should have taken it to the Meta before downvoting, now I cannot undo it. Thanks for claryfying, @Bainternet. SickHippie, looks like you haven't got an answer at their forum yet, hope some good soul, while revising old questions, stumbles upon this one and upvote it. Best regards and sorry for the mistake. – brasofilo Jun 19 '12 at 10:10
@brasofilo - no worries, mate. I was a bit overstressed yesterday, and apologize for my aggressive attitude. It was uncalled for, and I'm very sorry. – SickHippie Jun 19 '12 at 17:26
up vote 1 down vote accepted

My solution was to register the custom post types on the site where I'm calling it from, then in WPML's settings set them to translate. This is in WPML -> Translation Management -> Multilingual Content Setup, down at the bottom. I assume it works by tricking WP into using that site's rewrite/translate rules when it doesn't have the proper info from switch_to_blog().

share|improve this answer

Not the answer you're looking for? Browse other questions tagged or ask your own question.