Hi,
The whole idea is that i input a post date on the NL version of the post. Normally i should do this also for the FR & EN version of the post. But to do this only once i would like to order the posts of the FR and EN version with the publication date of the NL version.
Example:
This is the correct NL post order: http://www.aspbluesquare.be/category/referenties/bedrijfsevenementen/
This is the EN version:
http://www.aspbluesquare.be/en/category/references-en/corporate-events/
As you can see, the order of the EN is different because the published date is not the same one as the NL version. So i would like to list it as the NL version. Is there any way to order the FR & EN version with the published date of the NL version?
This is the code I have for the moment:
<div class="archive-references">
<?php $posts = query_posts( $query_string . '&order=desc' ); ?>
<?php if( $posts ) : ?>
<?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
<div <?php post_class() ?>>
<div class="archive-pict01">
<div class="archive-pict01-glow"></div>
<div class="archive-pict01-label">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
</div>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_post_thumbnail(); ?></a>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
I would also like to do this with the LED TV on top of the page. Also here it should list the most 10 recent posts by the published NL date.
This is the code:
<div class="slideshow">
<?php
$postslist = get_posts('numberposts=10&order=DESC&orderby=date&category=74');
foreach ($postslist as $post) :
setup_postdata($post);
?>
<div class="slide-part">
<div id="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>">
<div class="img-glow"></div>
<?php the_post_thumbnail(); ?></a>
</div>
<?php endforeach; ?>
</div>
rilwis answers:
Hi
Put this code in functions.php file of your theme:
// re-order by main language
add_action('wp_head', 'rw_reorder');
function rw_reorder() {
global $wp_query;
if (!is_category()) return;
if (!preg_match('#(/en/|/fr/)#', $_SERVER['REQUEST_URI']) && isset($_GET['lang'])) return;
$post_dates = array();
foreach ($wp_query->posts as $p) {
$id = icl_object_id($p->ID, 'post', false, 'en');
$post_dates[] = get_post_field('post_date', $id);
}
array_multisort($post_dates, SORT_DESC, $wp_query->posts);
}
and in the files where you display categories in EN, FR, replace the loop with the following code:
<div class="archive-references">
<?php if (have_posts()): while (have_posts()): the_post(); ?>
<?php global $post; $o_ID = icl_object_id($post->ID, 'post', false, 'nl'); ?>
<div <?php post_class() ?>>
<div class="archive-pict01">
<div class="archive-pict01-glow"></div>
<div class="archive-pict01-label">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
</div>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php echo get_the_post_thumbnail($o_ID); ?></a>
</div>
</div>
<?php endwhile; ?>
<?php endif; ?>
</div>
Filip Van Reeth comments:
Hi,
not quite correct:
NL: http://www.aspbluesquare.be/category/referenties/bedrijfsevenementen/
FR: http://www.aspbluesquare.be/fr/category/references-fr/evenements-societes/
I have a feeling you are gonna find it ;-)
Filip Van Reeth comments:
Hi,
Can you pick this up again from last friday?
We were almost there.
Thanks for the quick response.
Sébastien | French WordpressDesigner answers:
why not change the date simply ?
Filip Van Reeth comments:
because otherwise we have to input the date 3 times. Once on the NL, FR & EN version. It's a lot of work for 300 refs we have to input?
Sébastien | French WordpressDesigner comments:
At the first time we add a custom field for each post. This field contain the date of the original post (in your case the NL post)
// backwards compatible
add_action('admin_init', 'myplugin_add_custom_box', 1);
/* Do something with the data entered */
add_action('admin_init', 'myplugin_save_postdata');
/* Adds a box to the main column on the Post and Page edit screens */
function myplugin_add_custom_box() {
add_meta_box( 'myplugin_sectionid', __( 'Date of original post', 'myplugin_textdomain' ), 'myplugin_inner_custom_box', 'post' );
add_meta_box( 'myplugin_sectionid', __( 'Date of original post', 'myplugin_textdomain' ), 'myplugin_inner_custom_box', 'page' );
}
/* Prints the box content */
function myplugin_inner_custom_box() {
//date of original post
global $post;
$ID_fr = icl_object_id($post->ID, 'post', false, 'nl');
$post_infos = get_post($ID_fr);
$original_date = $post_infos->post_date;
// Use nonce for verification
wp_nonce_field( plugin_basename(__FILE__), 'myplugin_noncename' );
// The actual fields for data entry
echo '<label for="myplugin_new_field">' . __("Original date", 'myplugin_textdomain' ) . '</label> ';
echo '<input readonly type="text" id= "myplugin_new_field" name="myplugin_new_field" value="'.$original_date.'" size="35" />';
}
/* When the post is saved, saves our custom data */
function myplugin_save_postdata( $post_id ) {
// verify this came from the our screen and with proper authorization,
// because save_post can be triggered at other times
if ( !wp_verify_nonce( $_POST['myplugin_noncename'], plugin_basename(__FILE__) )) {
return $post_id;
}
// verify if this is an auto save routine. If it is our form has not been submitted, so we dont want
// to do anything
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE )
return $post_id;
// Check permissions
if ( 'page' == $_POST['post_type'] ) {
if ( !current_user_can( 'edit_page', $post_id ) )
return $post_id;
} else {
if ( !current_user_can( 'edit_post', $post_id ) )
return $post_id;
}
// OK, we're authenticated: we need to find and save the data
$mydata = $_POST['myplugin_new_field'];
// Do something with $mydata
// probably using add_post_meta(), update_post_meta(), or
// a custom table (see Further Reading section below)
return $mydata;
}
In your category.php for example, you can now classified your post by NL-date
You must use this query :
query_posts( $query_string . '&order=DESC&meta_key=original_publication_date&orderby=meta_value' );
:-)
Sébastien | French WordpressDesigner comments:
the first code is in functions.php
Filip Van Reeth comments:
It gives the page but no refs.
Can you change this code so i just have to copy paste it.
For the category_references_en.php:
<div class="archive-references">
<?php $posts = query_posts( $query_string . '&orderby=title&order=asc' ); ?>
<?php if( $posts ) : ?>
<?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
<?php global $post; $o_ID = icl_object_id($post->ID, 'post', false, 'nl'); ?>
<div <?php post_class() ?>>
<div class="archive-pict01">
<div class="archive-pict01-glow"></div>
<div class="archive-pict01-label">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
</div>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php echo get_the_post_thumbnail($o_ID); ?></a>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
For the LED TV:
<div class="slideshow">
<?php
$postslist = get_posts('numberposts=10&order=DESC&orderby=date&category=84');
foreach ($postslist as $post) :
setup_postdata($post);
?>
<?php global $post; $o_ID = icl_object_id($post->ID, 'post', false, 'nl'); ?>
<div class="slide-part">
<div id="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><div class="img-glow"></div><?php echo get_the_post_thumbnail($o_ID); ?></a>
</div>
<?php endforeach; ?>
</div>
Thanks for the quick response.
Sébastien | French WordpressDesigner comments:
the code for For the category_references_en.php will be :
<div class="archive-references">
<?php $posts = query_posts( $query_string . '&order=ASC&meta_key=original_publication_date&orderby=meta_value' ); ?>
<?php if( $posts ) : ?>
<?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
<?php global $post; $o_ID = icl_object_id($post->ID, 'post', false, 'nl'); ?>
<div <?php post_class() ?>>
<div class="archive-pict01">
<div class="archive-pict01-glow"></div>
<div class="archive-pict01-label">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
</div>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php echo get_the_post_thumbnail($o_ID); ?></a>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
For the LED TV:
<div class="slideshow">
<?php
$postslist = get_posts('numberposts=10&order=DESC&orderby=date&category=84');
foreach ($postslist as $post) :
setup_postdata($post);
?>
<?php global $post; $o_ID = icl_object_id($post->ID, 'post', false, 'nl'); ?>
<div class="slide-part">
<div id="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><div class="img-glow"></div><?php echo get_the_post_thumbnail($o_ID); ?></a>
</div>
<?php endforeach; ?>
</div>
the 2nd code wille be
<div class="slideshow">
<?php
$postlist = query_posts('order=DESC&meta_key=original_publication_date&orderby=meta_value&numberposts=10&category=84' );
if( $postlist ) : ?>
<?php foreach( $postlist as $post ) : setup_postdata( $post ); ?>
<?php global $post; $o_ID = icl_object_id($post->ID, 'post', false, 'nl'); ?>
<div class="slide-part">
<div id="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><div class="img-glow"></div><?php echo get_the_post_thumbnail($o_ID); ?></a>
</div>
<?php endforeach; ?>
</div>
Sébastien | French WordpressDesigner comments:
arf, a mistake in my precedent message.
The first code wille be <div class="archive-references">
<?php $posts = query_posts( $query_string . '&order=ASC&meta_key=original_publication_date&orderby=meta_value' ); ?>
<?php if( $posts ) : ?>
<?php foreach( $posts as $post ) : setup_postdata( $post ); ?>
<?php global $post; $o_ID = icl_object_id($post->ID, 'post', false, 'nl'); ?>
<div <?php post_class() ?>>
<div class="archive-pict01">
<div class="archive-pict01-glow"></div>
<div class="archive-pict01-label">
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a>
</div>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php echo get_the_post_thumbnail($o_ID); ?></a>
</div>
</div>
<?php endforeach; ?>
<?php endif; ?>
</div>
and the second code wille be
<div class="slideshow">
<?php
$postlist = query_posts('order=DESC&meta_key=original_publication_date&orderby=meta_value&numberposts=10&category=84' );
if( $postlist ) : ?>
<?php foreach( $postlist as $post ) : setup_postdata( $post ); ?>
<?php global $post; $o_ID = icl_object_id($post->ID, 'post', false, 'nl'); ?>
<div class="slide-part">
<div id="title"><a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><?php the_title(); ?></a></div>
<a href="<?php the_permalink() ?>" rel="bookmark" title="Permanent Link to <?php the_title_attribute(); ?>"><div class="img-glow"></div><?php echo get_the_post_thumbnail($o_ID); ?></a>
</div>
<?php endforeach; ?>
</div>
Rashid Aliyev answers:
Why You Do Not use qTranslate?
You can Use Custom field on each page and link it's value with other page.
Filip Van Reeth comments:
We would like to do this native with PHP & WP.
Can you help us out?
Rashid Aliyev comments:
Yes. Can try to help. Why You call Permalinks with different links?
Multilanguage tool is easy way to do all your works. Or there is 3 differend independed databases?
You can get publish date of <strong>post id</strong> of main lanuage and whow it on other languages.
Filip Van Reeth comments:
Can you give it a shot?
Thanks for the quick response.
Rashid Aliyev comments:
Yap: [LINK href="http://www.qianqin.de/qtranslate/"]http://www.qianqin.de/qtranslate/[/LINK] - The easiest plugin for multilanguagin. It's not only for posts. It's can make multilanguage your interface too.The Plugin Called <strong>qTranslate</strong>. I used (and using) it on My Web page and in other my multilanguage projects. Plugin easiest way to do all you need, instead of any programming (especially, if You do not shure).
The sample sites: [LINK href="http://www.guensh.im"]http://www.guensh.im[/LINK] , http://bakdisp.az and much more...