-
-
Save salcode/397467a9c282df992aef to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* Call Contests List By Shortcode | |
**********************************************/ | |
function vs_register_contest_shortcode ( $atts ) { | |
$output = '<ul>'; | |
$contest_atts = shortcode_atts( array( | |
'post_type' => 'contests', | |
'tax_query' => array( | |
array( | |
'taxonomy' => 'contest-status', | |
'field' => 'slug', | |
'terms' => 'current' | |
) | |
) | |
), $atts ); | |
$contests = new WP_Query( $contest_atts ); | |
if( $contests->have_posts() ) { | |
while( $contests->have_posts() ) { | |
$contests->the_post(); | |
echo "<li class=\"contest-".$contest_atts['terms']."\">".the_time('d/m/y')." :: <a href=\"'".get_permalink()."\" target=\"_blank\">".the_title()."</a></li>"; | |
} | |
} | |
else { | |
echo 'No contests found.'; | |
} | |
$output .= '</ul>'; | |
} | |
add_shortcode( 'contests', 'vs_register_contest_shortcode' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment