hello everyone,
I added simple PHP code in the homepage template. To have one block of news headlines (from Blog section). It should be automatic: everytime I create a new post, it should appear on the homepage. Unfortunately, it doesnt pick up at all in second language the blog news first lines. But it does in default language. The code looks correct. I have played around, created, deleted a new post - no effect! It worked when I checked "sticky" post. But this is not what I want.
Here is the site: www.olivia.be It runs on Wordpress, languages are supported by WPML plugin.
Please, any help?
get_header();
?>
<div class="container clearfix">
<div class="homepage-content">
<?php
// start content output
// if ( have_posts()) : while ( have_posts()) : the_post();
// the_content();
// endwhile; endif;
// end content output
// JHL TODO:edit
?>
<div class="ten columns">
<?php // fr_FR nl_NL ?>
<?php
if (get_locale() == 'fr_FR'){
$page = get_page_by_title( "Top Nouvelles" );
echo apply_filters( 'the_content', $page->post_content );
}else if (get_locale()){
$page = get_page_by_title( "Top News" );
echo apply_filters( 'the_content', $page->post_content );
}
?>
</div>
<div class="five columns">
<?php
// get latest post
$args = array(
'post_type' => 'post',
'category__not_in' => '16',
'posts_per_page' => 5,
'post_status' => array('future', 'publish'),
'orderby' => 'post_date',
'order' => 'DESC',
);
$dd_query = new WP_Query( $args );
if ( $dd_query->have_posts() ) :
while ( $dd_query->have_posts() ) : $dd_query->the_post();?>
<div class="post-list-element">
<a href="<?php echo the_permalink();?>">
<div class="left"><?php echo the_title();?></div>
<!-- <div class="right"><span class="icon-calendar"></span><?php //echo the_date();?></div> -->
</a>
<!-- <div class="info"><?php echo the_excerpt();?></div> -->
</div>
<?php
endwhile;
endif;
// get latest donateurs post
/*$args = array(
'post_type' => 'post',
'category__in' => '16',
'posts_per_page' => 1,
'post_status' => array('future', 'publish'),
'orderby' => 'post_date',
'order' => 'DESC',
);
$dd_query = new WP_Query( $args );
if ( $dd_query->have_posts() ) :
while ( $dd_query->have_posts() ) : $dd_query->the_post();?>*/
/*<div class="post-list-element">
<a href="<?php echo the_permalink();?>">
<div class="left"><?php echo the_title();?></div>
<div class="right"><span class="icon-calendar"></span><?php echo the_date();?></div>
</a>
<div class="info"><?php echo the_excerpt();?></div>
</div>
<?php*/
/*endwhile;
endif;*/
?>
</div>
</div>
</div>
<?php
global $dd_sn;
$home_sections = ot_get_option( $dd_sn . 'home_sections', false );
if ( $home_sections ) {
$parity = 'even';
foreach ( $home_sections as $home_section ) {
if ( $parity == 'odd' ) {
$parity = 'even';
} else {
$parity = 'odd';
}
if ( ! isset( $home_section[ $dd_sn . 'module_blog_cat' ] ) ) {
$home_section[ $dd_sn . 'module_blog_cat' ] = 'all';
}
if ( ! isset( $home_section[ $dd_sn . 'module_causes_cat' ] ) ) {
$home_section[ $dd_sn . 'module_causes_cat' ] = 'all';
}
if ( ! isset( $home_section[ $dd_sn . 'module_post_width' ] ) ) {
$home_section[ $dd_sn . 'module_post_width' ] = 'one_fourth';
}
if ( 'tabs' == $home_section[ $dd_sn . 'module' ] ) {
dd_home_section_tabs( array( 'parity' => $parity, 'title' => $home_section['title'] ) );
} elseif ( 'causes' == $home_section[ $dd_sn . 'module' ] ) {
dd_home_section_causes( array( 'parity' => $parity, 'title' => $home_section['title'], 'amount' => $home_section[ $dd_sn . 'module_amount_posts'], 'category' => $home_section[ $dd_sn . 'module_causes_cat' ], 'post_width' => $home_section[ $dd_sn . 'module_post_width' ] ) );
} elseif ( 'news' == $home_section[ $dd_sn . 'module' ] ) {
dd_home_section_blog( array( 'parity' => $parity, 'title' => $home_section['title'], 'amount' => $home_section[ $dd_sn . 'module_amount_posts'], 'category' => $home_section[ $dd_sn . 'module_blog_cat' ], 'post_width' => $home_section[ $dd_sn . 'module_post_width' ] ) );
} elseif ( 'events' == $home_section[ $dd_sn . 'module' ] ) {
dd_home_section_events( array( 'parity' => $parity, 'title' => $home_section['title'], 'amount' => $home_section[ $dd_sn . 'module_amount_posts'] ) );
} elseif ( 'products' == $home_section[ $dd_sn . 'module' ] ) {
dd_home_section_products( array( 'parity' => $parity, 'title' => $home_section['title'], 'amount' => $home_section[ $dd_sn . 'module_amount_posts'] ) );
} elseif ( 'staff' == $home_section[ $dd_sn . 'module' ] ) {
dd_home_section_staff( array( 'parity' => $parity, 'title' => $home_section['title'], 'amount' => $home_section[ $dd_sn . 'module_amount_posts'] ) );
} elseif ( 'text' == $home_section[ $dd_sn . 'module' ] ) {
dd_home_section_text( array( 'parity' => $parity, 'title' => $home_section['title'], 'content' => $home_section[ $dd_sn . 'module_text_content'] ) );
} elseif ( 'sponsors' == $home_section[ $dd_sn . 'module' ] ) {
dd_home_section_sponsors( array( 'parity' => $parity, 'title' => $home_section['title'], 'amount' => $home_section[ $dd_sn . 'module_amount_posts'], 'post_width' => $home_section[ $dd_sn . 'module_post_width' ] ) );
} elseif ( 'events_no_cal' == $home_section[ $dd_sn . 'module' ] ) {
dd_home_section_events_no_cal( array( 'parity' => $parity, 'title' => $home_section['title'], 'amount' => $home_section[ $dd_sn . 'module_amount_posts'], 'category' => $home_section[ $dd_sn . 'module_causes_cat' ], 'post_width' => $home_section[ $dd_sn . 'module_post_width' ] ) );
}
}
} else {
/* Default */
// Disable footer slider
// dd_home_section_tabs( array( 'parity' => 'odd', 'title' => '' ) );
// dd_home_section_causes( array( 'parity' => 'even', 'title' => 'OUR CAUSES' ) );
// dd_home_section_blog( array( 'parity' => 'odd', 'title' => 'BLOG' ) );
// dd_home_section_events( array( 'parity' => 'even', 'title' => 'EVENTS' ) );
// dd_home_section_products( array( 'parity' => 'odd', 'title' => 'PRODUCTS' ) );
}
get_footer();
?>