Structure fixes and additions #1

Merged
plazmonii merged 11 commits from structure-fixes-and-additions into master 2014-10-05 20:21:53 +03:00
2 changed files with 35 additions and 19 deletions
Showing only changes of commit cb6ac254b6 - Show all commits

View File

@ -15,24 +15,7 @@
</div>
<div class="col2">
<h3>Спонсори</h3>
<?php
$sponsors_args = array( 'post_type' => 'sponsors', 'orderby' => 'rand' );
$sponsors = new WP_Query( $sponsors_args );
if ( $sponsors->have_posts() ) :
while ( $sponsors->have_posts() ) : $sponsors->the_post();
if ( has_post_thumbnail() ) {
?>
<a href="<?php the_permalink(); ?>"><?php the_post_thumbnail(); ?></a>
<?php
} else {
?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php
}
endwhile;
endif;
?>
<?php echo do_shortcode( '[sponsors]' ); ?>
</div>
</section>

View File

@ -179,4 +179,37 @@ function transportation_posttype() {
add_action( 'init', 'transportation_posttype' );
# Create shortcode for sponsors
function sponsors_shortcode() {
global $post;
$output = '';
$sponsors_args = array( 'post_type' => 'sponsors', 'orderby' => 'rand' );
$sponsors = new WP_Query( $sponsors_args );
if ( $sponsors->have_posts() ) :
while ( $sponsors->have_posts() ) : $sponsors->the_post();
if ( has_post_thumbnail() ) {
$output .= the_post_thumbnail();
} else {
$output .= get_the_title();
}
endwhile;
endif;
return $output;
}
# Register all shortcodes
function register_shortcodes(){
add_shortcode('sponsors', 'sponsors_shortcode');
}
add_action( 'init', 'register_shortcodes');
?>