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>
<div class="col2"> <div class="col2">
<h3>Спонсори</h3> <h3>Спонсори</h3>
<?php <?php echo do_shortcode( '[sponsors]' ); ?>
$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;
?>
</div> </div>
</section> </section>
@ -52,7 +35,7 @@
<h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4> <h4><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h4>
<p class="info">От <?php the_author(); ?> | Публикувано на <?php the_date(); ?> </p> <p class="info">От <?php the_author(); ?> | Публикувано на <?php the_date(); ?> </p>
<?php the_excerpt(); ?> <?php the_excerpt(); ?>
<a class="button" href="<?php the_permalink(); ?>">виж цялата новина</a> <a class="button" href="<?php the_permalink(); ?>">виж цялата новина</a>
</div> </div>
<?php <?php
endwhile; endwhile;

View File

@ -179,4 +179,37 @@ function transportation_posttype() {
add_action( 'init', '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');
?> ?>