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:
<?php
switch_to_blog(23);
$args = array('post_type' => 'release-notes',
'suppress_filters' => 0,
'meta_query' => array(
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>';
//print_r($post);
//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
restore_current_blog();
?>
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?
switch_to_blog()
doesn't pass over permalinks for custom post types withget_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.