Please make sure to update to WPML 4.3.5 and check our list of Known Issues before reporting

Hi, Amit here, I am the WPML Support Manager, our current ticket queue is high, update your WPML plugins and make sure you meet the minimal requirements for running WPML before reporting an issue please - many tickets are resolved doing that

Please look at our updated list of Known Issues and you can also use our support search to find helpful information and of course review our documentation before opening a ticket.

If you do need to open a ticket please make sure to provide us with all the needed information as described in this page

This is the technical support forum for WPML - the multilingual WordPress plugin.

Everyone can read, but only WPML clients can post here. WPML team is replying on the forum 6 days per week, 22 hours per day.

This topic contains 2 replies, has 2 voices.

Last updated by jin woo 5 years, 10 months ago.

Assigned support staff: Andrey.

Author Posts
January 23, 2014 at 8:27 am #326252

jin woo

I have our own theme and try to make it works with wpml.

There is a problem with links on (custom post type) Listing page.

if the default post link is like this
ex) abc.com/my-1st-custom-post

for japanes, it should be like this..
ex) abc.com/jp/my-1st-custom-post

But there is no /jp/ permalink on Listing page. just default link. But there is a footer widget on same page. the permalink works ok. there is /jp/ (another language link). the widget codes are from other theme (we just copied it to use quickly)

But it's still default language link (no /jp/) on Listing page.

Here is 2 codes. widget and Listing page. the permalink of widget works good but not Listing page.
used same <a href="<?php the_permalink() ?>....

Do I need to set up something for the permalink function for WPML? If so, is there any instruction?

===================== Widget codes (Works Good) =============================
function widget($args, $instance) {
$cache = wp_cache_get('widget_recent_jobs', 'widget');

if ( !is_array($cache) )
$cache = array();

if ( isset($cache[$args['widget_id']]) ) {
echo $cache[$args['widget_id']];
return;
}

ob_start();
extract($args);

$title = apply_filters('widget_title', empty($instance['title']) ? __('New Job Listings', APP_TD) : $instance['title'], $instance, $this->id_base);
if ( !$number = (int) $instance['number'] )
$number = 10;
else if ( $number < 1 )
$number = 1;
else if ( $number > 15 )
$number = 15;

$r = new WP_Query(array('showposts' => $number, 'nopaging' => 0, 'post_status' => 'publish', 'post_type' => 'job_listing', 'ignore_sticky_posts' => 1));
if ($r->have_posts()) :
?>
<?php echo $before_widget; ?>
<?php if ( $title ) echo $before_title . $title . $after_title; ?>

    <?php while ($r->have_posts()) : $r->the_post(); ?>

  • <a href="<?php the_permalink() ?>" title="<?php echo esc_attr(get_the_title() ? get_the_title() : get_the_ID()); ?>"><?php if ( get_the_title() ) the_title(); else the_ID(); ?></a>
  • <?php endwhile; ?>

<?php echo $after_widget; ?>
<?php
// Reset the global $the_post as this query will have stomped on it
wp_reset_postdata();

endif;

$cache[$args['widget_id']] = ob_get_flush();
wp_cache_set('widget_recent_jobs', $cache, 'widget');
}

==================================================

=================== Listing page codes (Permalinks Not working for another language..

while( have_posts() ) : the_post(); $post_id=get_the_ID();?>
<div class="row">
<div class="col-lg-12">
<div class="hidden-xs hidden-sm col-lg-1 resume_pic thumbnail">
<!--a href="<?php the_permalink(); ?>"><img src="<?php echo $th_url; ?>" ></a-->
<?php echo get_avatar( get_the_author_meta( 'ID' ), 'thumbnail' ); ?>
</div>

<div class="col-xs-12 col-lg-11">
<div class="col-xs-12 col-lg-12">
<a href="<?php the_permalink(); ?>" title="<?=get_the_title();?>" rel="bookmark" class="post-titles"><?=get_the_title();?></a>
</div>

<div class="col-xs-12 col-lg-12 post-meta">
<ul class="row">
<li class="col-xs-7 col-lg-3"><i class="fa fa-map-marker"><a>
<?php if(!kcm_gct_echo_return($post_id, (($this->postType == "job_listing") ? "city":"city"), "tax_no_class")) _e("No Area", "kcm_fr"); ?>
</a>
<?php if(current_user_can("administrator")){?>
<li class="hidden-xs hidden-sm col-lg-3"><i class="fa fa-signal"><a>
<?php echo " ".cnt_views( get_the_ID() )." ";
_e("HITs", "kcm_fr");?>
</a>
<?php }; ?>

<li class="col-xs-5 col-lg-3"><i class="fa fa-check"><a>
<?php if(!kcm_gct_echo_return($post_id, (($this->postType == "job_listing") ? "job_cat":"resume_category"), "tax_no_class")) _e("No Category", "kcm_fr"); ?>
</a>
<li class="hidden-xs hidden-sm col-lg-3"><i class="fa fa-clock-o"><a><span> <?php echo get_the_date();?></span></a>

<div class="hidden-xs hidden-sm btn-group btn-group-sm btn-group-justified">
<a href="<?php the_permalink(); ?>" class="btn btn-default btn-sm"><?php _e('Detail', 'kcm_fr'); ?></a>
<a href="#" class="btn btn-default kcm_brief" post-id="<?php echo $post_id;?>"><?php _e('Brief', 'kcm_fr'); ?></a>
<?php if (is_user_logged_in()) : $starred = (array) get_user_meta(get_current_user_id(), '_starred_jobs', true); //&& current_user_can('can_submit_resume') ?>
<?php if (!in_array(get_the_ID(), $starred)) : ?>
<a href="javascript:" post-id="<?=get_the_ID();?>" onclick="wishlist(this, true);" class="btn btn-default"><i class="fa fa-heart"> <?php _e('Save', 'kcm_fr') ?></a>
<?php else : ?>
<a href="javascript:" post-id="<?=get_the_ID();?>" onclick="wishlist(this, false);" class="btn btn-primary"><i class="fa fa-heart-o"> <?php _e('Unsave', 'kcm_fr') ?></a>
<?php endif; else: ?>
<script type="text/javascript"> function onNeedLogin(){ alert("Please Login before you save it.n(if you want to use "save", please login)"); }</script>
<a href="javascript:onNeedLogin();" class="btn btn-default"><i class="fa fa-heart"> <?php _e('Save', 'kcm_fr') ?></a>
<?php endif; ?>
</div> <!-- btn-group -->
</div><!-- post-meta -->

</div>

</div><!-- col-lg-12 -->
</div><!-- row -->
<hr/>

<?php
endwhile;
========================================================================

January 23, 2014 at 12:56 pm #326539

Andrey
Supporter

Languages: English (English ) Russian (Русский )

Timezone: Europe/Kiev (GMT+02:00)

Dear jin woo,

Thank you for contacting to us !

Please review documents for the developers :
http://wpml.org/documentation/support/wpml-coding-api/
http://wpml.org/documentation/support/creating-multilingual-wordpress-themes/language-dependent-ids/

You should try something like this :

<?php echo get_permalink(icl_object_id($id, 'post', false)); ?> 

http://codex.wordpress.org/Template_Tags/get_permalink

Thanks,
Andrey

January 24, 2014 at 2:43 am #326878

jin woo

works great! like charm