Last active
February 26, 2016 12:53
-
-
Save MasterHans/2dc9fd5a9f5c616deffe 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
<select name="event-dropdown" onchange='document.location.href=this.options[this.selectedIndex].value;'> | |
<option value=""><?php echo esc_attr('Выберите событие'); ?></option> | |
<?php | |
$categories= get_categories('child_of=10'); | |
foreach ($categories as $category) { | |
$option = '<option value="/category/archives/'.$category->category_nicename.'">'; | |
$option .= $category->cat_name; | |
$option .= ' ('.$category->category_count.')'; | |
$option .= '</option>'; | |
echo $option; | |
} | |
?> | |
</select> | |
$categories= get_categories('child_of='.get_query_var('cat')); | |
foreach($categories as $category) { | |
echo '<p>Category: <a href="' . get_category_link( $category->term_id ) . '" title="' . sprintf( __( "View all posts in %s" ), $category->name ) . '" ' . '>' . $category->name.'</a> </p> '; | |
echo '<p> Description:'. $category->description . '</p>'; | |
echo '<p> Post Count: '. $category->count . '</p>'; } | |
?> | |
$category = get_category_by_slug( 'category-name' ); | |
$args = array( | |
'type' => 'post', | |
'child_of' => $category->term_id, | |
'orderby' => 'name', | |
'order' => 'ASC', | |
'hide_empty' => FALSE, | |
'hierarchical' => 1, | |
'taxonomy' => 'category', | |
); | |
$child_categories = get_categories($args ); | |
$category_list = array(); | |
$category_list[] = $category->term_id; | |
if ( !empty ( $child_categories ) ){ | |
foreach ( $child_categories as $child_category ){ | |
$category_list[] = $child_category->term_id; | |
} | |
} | |
$posts_args = array( | |
'posts_per_page' => 10, | |
'cat' => $category->term_id, | |
'post_type' => 'post', | |
'post_status' => 'publish', | |
'suppress_filters' => true | |
); | |
$posts = new WP_Query ( $posts_args ); | |
if ( $posts->have_posts() ){ | |
while ( $posts->have_posts() ){ | |
$posts->the_post(); | |
$category_array = array(); | |
$post_categories = get_the_category ( get_the_ID() ); | |
if ( !empty ( $post_categories ) ){ | |
foreach ( $post_categories as $post_category ) { | |
$category_array[] = $post_category->term_id; | |
} | |
} | |
//Checks if post has an additional category | |
$result = array_diff( $category_array, $category_list ); | |
if ( empty ( $result ) ) { ?> | |
<li> | |
<a href="<?php the_permalink(); ?>" class="side-thumb" title="<?php the_title(); ?>"> dfdf<?php | |
if ( has_post_thumbnail() ){ | |
echo get_the_post_thumbnail(); | |
} | |
//Put your default icon code here | |
?> | |
</a> | |
</li> <?php | |
} | |
} | |
} | |
wp_reset_postdata(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment