Список игр (шорткод)
This commit is contained in:
parent
1c350dfe9f
commit
00a24c10eb
|
@ -1,4 +1,6 @@
|
|||
<?php
|
||||
require_once "shortcodes/gamelist.php";
|
||||
|
||||
function understrap_remove_scripts() {
|
||||
wp_dequeue_style( 'understrap-styles' );
|
||||
wp_deregister_style( 'understrap-styles' );
|
||||
|
@ -28,3 +30,5 @@ function add_child_theme_textdomain() {
|
|||
load_child_theme_textdomain( 'understrap-child', get_stylesheet_directory() . '/languages' );
|
||||
}
|
||||
add_action( 'after_setup_theme', 'add_child_theme_textdomain' );
|
||||
|
||||
add_shortcode('gamelist', 'gamelist');
|
||||
|
|
65
shortcodes/gamelist.php
Normal file
65
shortcodes/gamelist.php
Normal file
|
@ -0,0 +1,65 @@
|
|||
<?php
|
||||
|
||||
/**
|
||||
* Список игр.
|
||||
*/
|
||||
function gamelist($atts){
|
||||
$nominations = array(
|
||||
'main' => 'Основная номинация',
|
||||
'translations' => 'Переводы',
|
||||
'unranked' => 'Вне конкурса'
|
||||
);
|
||||
|
||||
$a = shortcode_atts( array(
|
||||
'category' => 'КРИЛ '.date('Y'),
|
||||
), $atts );
|
||||
$category = $a['category'];
|
||||
|
||||
$retval = '';
|
||||
$args = array(
|
||||
'numberposts' => -1,
|
||||
'post_status' => 'publish',
|
||||
'post_type' => 'game',
|
||||
'meta_key' => 'nomination',
|
||||
);
|
||||
foreach ($nominations as $nomination => $name) {
|
||||
$i = 1;
|
||||
// $args['category'] = $category;
|
||||
$args['meta_value'] = $nomination;
|
||||
$the_query = new WP_Query($args);
|
||||
if( $the_query->have_posts() ) {
|
||||
while( $the_query->have_posts() ) {
|
||||
$the_query->the_post();
|
||||
$retval .= '<h2>'.$name.'</h2>';
|
||||
$retval .= '<div class="games">';
|
||||
if ($i > 1) {
|
||||
$retval .= '<hr class="kril">';
|
||||
}
|
||||
$retval .= '<div class="kril-game">';
|
||||
$retval .= '<div class="kril-game-header"><div class="kril-game-title"><div class="kril-game-name">'.
|
||||
'<a name="game-'.$nomination.'-'.$i.'"></a>'.get_the_title().'</div><div class="kril-game-author">Авторы:'.
|
||||
get_field('authors').'</div></div>'.
|
||||
'<div class="kril-game-platform">Платформа: '.get_field('platform').'</div></div>'.
|
||||
'<div class="kril-game-info">'.
|
||||
'<p class="kril-game-pic">'.get_the_post_thumbnail().'</p>'.
|
||||
'<div class="kril-game-descr">'.get_the_content().'</div>';
|
||||
$online = get_field('link_online');
|
||||
$offline = get_field('link_offline');
|
||||
if (!empty($online) || !empty($offline)) {
|
||||
$retval .= '<div class="kril-links">';
|
||||
if (!empty($online)) {
|
||||
$retval .= get_field('link_online');
|
||||
}
|
||||
if (!empty($offline)) {
|
||||
$retval .= get_field('link_offline');
|
||||
}
|
||||
$retval .= '</div>';
|
||||
}
|
||||
$retval .= '</div>';
|
||||
$i++;
|
||||
}
|
||||
$retval .= '</div>';
|
||||
}
|
||||
}
|
||||
return $retval;
|
||||
}
|
Loading…
Reference in a new issue