add partners

This commit is contained in:
Vasil Kolev 2014-10-14 18:24:01 +03:00 committed by Openfest
parent d5213d0e64
commit bcc2315a51
3 changed files with 53 additions and 11 deletions

View File

@ -6,7 +6,9 @@
</div> </div>
<div class="col2 sponsors"> <div class="col2 sponsors">
<?php echo do_shortcode( '[sponsors]' ); ?> <?php echo do_shortcode( '[sponsors]' ); ?>
<?php echo do_shortcode( '[partners]' ); ?>
</div> </div>
</section> </section>
<div class="separator"></div> <div class="separator"></div>

View File

@ -19,6 +19,7 @@ register_nav_menus(
function register_shortcodes(){ function register_shortcodes(){
add_shortcode('sh-latest-posts', 'sh_latest_posts'); add_shortcode('sh-latest-posts', 'sh_latest_posts');
add_shortcode('sponsors', 'sponsors_shortcode'); add_shortcode('sponsors', 'sponsors_shortcode');
add_shortcode('partners', 'partners_shortcode');
add_shortcode('transport', 'transport_shortcode'); add_shortcode('transport', 'transport_shortcode');
} }
@ -71,23 +72,59 @@ function sponsors_shortcode() {
ob_start(); ob_start();
if ( $sponsors->have_posts() ) : if ( $sponsors->have_posts() ) :
while ( $sponsors->have_posts() ) : $sponsors->the_post(); while ( $sponsors->have_posts() ) : $sponsors->the_post();
$custom = get_post_custom(); $custom = get_post_custom();
if (!empty ($custom['url'])) { if (empty($custom['partner'])) {
if (empty ($custom['url'])) {
echo '<a href="'.$custom['url'][0].'" target=_blank alt="'.get_the_title().'">'; echo '<a href="'.$custom['url'][0].'" target=_blank alt="'.get_the_title().'">';
} }
if ( has_post_thumbnail() ) { if ( has_post_thumbnail() ) {
the_post_thumbnail(); the_post_thumbnail();
} else { } else {
get_the_title(); get_the_title();
} }
if (!empty ($custom['url'])) { if (!empty ($custom['url'])) {
echo '</a>'; echo '</a>';
} }
}
endwhile;
endif;
endwhile; $result .= ob_get_contents();
endif; ob_end_clean();
return $result;
}
# Create shortcode for partners
function partners_shortcode() {
$result= '<h3>'.pll__('Партньори').'</h3>';
$sponsors_args = array( 'post_type' => 'sponsors', 'orderby' => 'rand' );
$sponsors = new WP_Query( $sponsors_args );
ob_start();
if ( $sponsors->have_posts() ) :
while ( $sponsors->have_posts() ) : $sponsors->the_post();
$custom = get_post_custom();
if (!empty($custom['partner'])) {
if (!empty ($custom['url'])) {
echo '<a href="'.$custom['url'][0].'" target=_blank alt="'.get_the_title().'">';
}
if ( has_post_thumbnail() ) {
the_post_thumbnail();
} else {
get_the_title();
}
if (!empty ($custom['url'])) {
echo '</a>';
}
}
endwhile;
endif;
$result .= ob_get_contents(); $result .= ob_get_contents();
ob_end_clean(); ob_end_clean();
@ -227,7 +264,7 @@ function transportation_posttype() {
} }
function openfest_home_page() { function openfest_home_page() {
if (empty($wp)) {return true;} ; if (empty($wp)) {return is_front_page();} ;
return !($wp->query_vars['pagename']=='home' || $wp->query_vars['pagename']=='home-2'); return !($wp->query_vars['pagename']=='home' || $wp->query_vars['pagename']=='home-2');
} }
@ -282,6 +319,7 @@ if (function_exists("pll_register_string")) {
pll_register_string('venue','Интерпред, София, България'); pll_register_string('venue','Интерпред, София, България');
pll_register_string('venue_w','Място'); pll_register_string('venue_w','Място');
pll_register_string('sponsors_w','Спонсори'); pll_register_string('sponsors_w','Спонсори');
pll_register_string('partners_w','Партньори');
pll_register_string('time','1-ви и 2-ри ноември 2014 г.'); pll_register_string('time','1-ви и 2-ри ноември 2014 г.');
pll_register_string('publishedon','Публикувано на'); pll_register_string('publishedon','Публикувано на');
pll_register_string('by_w','От'); pll_register_string('by_w','От');

View File

@ -4,5 +4,7 @@
<div class="separator"></div> <div class="separator"></div>
<?php echo do_shortcode( '[sponsors]' ); ?> <?php echo do_shortcode( '[sponsors]' ); ?>
<div class="separator"></div> <div class="separator"></div>
<?php echo do_shortcode( '[partners]' ); ?>
<div class="separator"></div>
<?php echo do_shortcode( '[transport]' ); ?> <?php echo do_shortcode( '[transport]' ); ?>
</div> </div>