<?php // демо стили
wp_enqueue_style('dashicons'); ?>
<style>
.my-cat li {
float: left;
width: 31%;
text-align: center;
border: 1px solid;
margin: 1%;
list-style: none;
padding: 10px;
}
.my-cat h3 {
border-bottom: 1px solid;
}
.my-cat span {
width: 50%;
float: left;
}
</style>
<?php // сам код вывода
$cat_ids= get_all_category_ids();
foreach ($cat_ids as $cat_id) {
$args = array(
'numberposts' => 3,
'cat' => $cat_id,
'post_status' => 'publish'
);
echo "<h2>" . get_cat_name( $cat_id ) . "</h2>";
echo "<ul class='my-cat cat-" . $cat_id . "'>";
$posts = wp_get_recent_posts($args);
foreach( $posts as $post ){ ?>
<li class="my-post post-<?php echo $post['ID'] ?>">
<h3><a href="<?php echo get_permalink($post['ID']) ?>"><?php echo $post['post_title'] ?></a></h3>
<p><?php echo wp_trim_words($post['post_content'],22) ?></p>
<span class="dashicons dashicons-format-chat"><?php echo $post['comment_count']; ?></span>
<span class="dashicons dashicons-visibility">1777</span>
</li>
<?php }
echo "</ul>";
}
if(android) {
$blablabla = 'android';
} elseif (htc){
$blablabla = 'htc';
} else {
$blablabla = '';
}
get_header($blablabla);
get_template_part( 'single_template', $blablabla );
get_sidebar($blablabla);
get_footer($blablabla);
add_filter( 'gettext', 'theme_change_comment_field_names', 20, 3 );
/**
* Change comment form default field names.
*
* @link http://codex.wordpress.org/Plugin_API/Filter_Reference/gettext
*/
function theme_change_comment_field_names( $translated_text, $text, $domain ) {
if ( is_singular() ) {
switch ( $translated_text ) {
case 'Name' :
$translated_text = __( 'First Name', 'theme_text_domain' );
break;
case 'Email' :
$translated_text = __( 'Email Address', 'theme_text_domain' );
break;
}
}
return $translated_text;
}
add_action( 'wp_ajax_nopriv_my_action', 'my_action_callback' );