Please make sure to update to WPML 4.3.4 before reporting any issue

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 12 replies, has 2 voices.

Last updated by Griff 7 years, 1 month ago.

Assigned support staff: Harshad.

Author Posts
September 17, 2012 at 3:50 pm #75571

Griff

We're able to get the "This post is also available in: Spanish" option to display at the top of individual blog posts but we'd like to have that be visible at the top of each post that's been translated when viewing the entire blog: hidden link

I've looked through the documentation and the past several pages of threads here in the forum but I can't seem to find instructions on how to do this.

Can someone point to a URL or a page in the documentation that explains it?

September 18, 2012 at 11:21 am #75687

Harshad

Dear Griff,

Please copy the following function to your theme's functions.php file

function icl_post_languages($pid){
  $languages = icl_get_languages('skip_missing=1');
  if(1 < count($languages)){
    echo __('This post is also available in: ');
    foreach($languages as $l){
	if (icl_object_id($pid,'post',false,$l['language_code'])){
      if(!$l['active']) $langs[] = '<a href="'.get_permalink(icl_object_id($pid,'post',false,$l['language_code'])).'">'.$l['translated_name'].'</a>';
	}
    }
    echo join(', ', $langs);
  }
}

Then in your blog summary page, give the call to function passing the post->ID parameter to it after the while loop like this:

<?php while (have_posts()) : the_post(); ?>
<? icl_post_languages($post->ID)?>
September 18, 2012 at 5:15 pm #75796

Griff

Harshad, I understand the first part re: the functions.php file but I don't understand where to make the changes for the blog summary page. Can you explain? I'm not much of a techie!

September 19, 2012 at 8:59 am #75895

Harshad

Dear Griff,

Can you please paste the php code of the page template which displays the blog summary page hidden link

September 19, 2012 at 5:44 pm #75980

Griff

I'm using the Atahualpa theme, version 3.7.9. I'm pretty sure the blog page uses the Main Index Template (index.php). If so, here's the code:

<?php
list($bfa_ata, $cols, $left_col, $left_col2, $right_col, $right_col2, $bfa_ata['h_blogtitle'], $bfa_ata['h_posttitle']) = bfa_get_options();
get_header();
extract($bfa_ata);
global $bfa_ata_postcount;
?>

<?php /* If there are any posts: */
if (have_posts()) : $bfa_ata_postcount = 0; /* Postcount needed for option "XX first posts full posts, rest excerpts" */ ?>

<?php // Deactivated since 3.6.5
# include 'hidden link';
// Uses the following static code instead: ?>
<?php bfa_next_previous_page_links('Top'); // For MULTI post pages if activated at ATO -> Next/Previous Navigation: ?>

<?php while (have_posts()) : the_post(); $bfa_ata_postcount++; ?>
<?php // Deactivated since 3.6.5
#include 'hidden link';
// Uses the following static code instead: ?>
<?php bfa_next_previous_post_links('Top'); // For SINGLE post pages if activated at ATO -> Next/Previous Navigation ?>
<?php /* Post Container starts here */
if ( function_exists('post_class') ) { ?>
<div <?php if ( is_page() ) { post_class('post'); } else { post_class(); } ?> id="post-<?php the_ID(); ?>">
<?php } else { ?>
<div class="<?php echo ( is_page() ? 'page ' : '' ) . 'post" id="post-'; the_ID(); ?>">
<?php } ?>
<?php bfa_post_kicker('<div class="post-kicker">','</div>'); ?>
<?php bfa_post_headline('<div class="post-headline">','</div>'); ?>
<?php bfa_post_byline('<div class="post-byline">','</div>'); ?>
<?php bfa_post_bodycopy('<div class="post-bodycopy clearfix">','</div>'); ?>
<?php bfa_post_pagination('<p class="post-pagination">'.__('Pages:','atahualpa').'','</p>'); ?>
<?php bfa_archives_page('<div class="archives-page">','</div>'); // Archives Pages. Displayed on a specific static page, if configured at ATO -> Archives Pages: ?>
<?php bfa_post_footer('<div class="post-footer">','</div>'); ?>
</div><!-- / Post -->

<?php endwhile; ?>

<?php // Deactivated since 3.6.5
# include 'hidden link';
// Uses the following static code instead: ?>
<?php bfa_next_previous_post_links('Middle'); // Displayed on SINGLE post pages if activated at ATO -> Next/Previous Navigation: ?>
<?php bfa_get_comments(); // Load Comments template (on single post pages, and static pages, if set on options page): ?>
<?php bfa_next_previous_post_links('Bottom'); // Displayed on SINGLE post pages if activated at ATO -> Next/Previous Navigation: ?>
<?php bfa_next_previous_page_links('Bottom'); // Displayed on MULTI post pages if activated at ATO -> Next/Previous Navigation: ?>

<?php /* END of: If there are any posts */
else : /* If there are no posts: */ ?>

<?php // Deactivated since 3.6.5
#include 'hidden link';
// Uses the following static code instead: ?>
<h2><?php _e('Not Found','atahualpa'); ?></h2>
<p><?php _e("Sorry, but you are looking for something that isn't here.","atahualpa"); ?></p>

<?php endif; /* END of: If there are no posts */ ?>

<?php get_footer(); ?>

September 20, 2012 at 5:17 am #76009

Harshad

Dear Griff,

You can add the code below
<?php while (have_posts()) : the_post(); $bfa_ata_postcount++; ?>
<? icl_post_languages($post->ID)?>

September 21, 2012 at 5:39 pm #76372

Griff

Where do I insert that code, Harshad? I tried it in two different places in the index.php file and it breaks the entire website.

September 22, 2012 at 7:56 am #76413

Harshad

Dear Griff,

Can you please send me your ftp and wp-admin details to my email address?

Please include this forum link for reference.

September 22, 2012 at 3:16 pm #76436

Griff

Thanks, Harshad. Email sent.

September 24, 2012 at 3:57 pm #76710

Harshad

Dear Griff,

Sorry for delay, I gave a try adding the code
<?php icl_post_languages($post->ID)?> to all possible files under functions folder, but its not displaying the text on blog page.

Can you please contact the theme developers, and get the exact filename to edit, so we can put the code into the same file.

Or is it another way to add the php code via theme options?

September 24, 2012 at 7:45 pm #76749

Griff

Harshad, the Atahualpa theme by BytesForAll is listed as one of those "tested by WPML team" on your Theme Compatibility page.
http://wpml.org/documentation/theme-compatibility/

so I was hoping that you knew what to do, as I'm confused.

I've started a new thread in their languages forum in hopes that they can help us:
hidden link

September 25, 2012 at 11:00 am #76863

Harshad

Dear Griff,

We were editing the same file, the problem was you blog page was not translated to spanish version, so the language option was not displayed.

Please check the blog page now.
hidden link

September 25, 2012 at 1:42 pm #76900

Griff

Thanks, Harshad. It never occurred to me that a page with no content on it (admin view) would have to be translated. Is that written in the documentation someplace? If so, please point me to the URL/page.

The topic ‘[Closed] Getting the language option to display on the blog page’ is closed to new replies.