how to list all subdomain in wordpress multiuser

take a look at this plugin : Multi-Site Site List Shortcode or if you prefer a snippet then: $blog_list = get_blog_list( 0, ‘all’ ); if (count($blog_list) > 1){ echo ‘<ul>’; foreach ($blog_list AS $blog) { echo ‘<li>Blog ‘.$blog[‘blog_id’].’: ‘.$blog[‘domain’].$blog[‘path’].'</li>’; } echo ‘</ul>’ }

show posts under subcategory only when in that subcategory

If you use the follow code: <?php $cats = get_categories(‘child_of=6’); foreach ($cats as $cat) : $this_category = get_category($cat); $args = array( ‘category__in’ => array($cat->term_id) ); $my_query = new WP_Query($args); if ($my_query->have_posts()) : ?> <li><a href=”https://wordpress.stackexchange.com/questions/41725/<?php echo get_category_link($cat); ?>”><?php echo $cat->name; ?></a> <?php if ($this_category->category_parent != 0) { ?> <ul class=”children”> <?php while ($my_query->have_posts()) : $my_query->the_post(); … Read more

Adding class to last list item? Not WP generated

I can only see achieving this by first building an array, then looping over it – I can’t find anything in APC’s docs about checking if it’s the last iteration of the_repeater_field: $images = array(); while ( the_repeater_field( ‘homepage_service’ ) ) $images[] = get_sub_field( ‘service_image’ ); if ( $images ) { $image_last = array_pop( $images … Read more

Apply class to every third list item? [duplicate]

add a simple counter and conditional check: $pages = get_pages(‘child_of=10’); $counter = 1; if ($pages) { echo ‘<ul class=”projectthumbs”>’; foreach ($pages as $page) { if ($counter == 3){ $class=” class=”YOUR_CLASS””; $counter = 1 }else{ $class=””; $counter = $counter +1; } echo ‘<li’.$class.’><a href=”‘.get_permalink($page->ID).'”>’; echo get_the_post_thumbnail($page->ID); echo ‘<span class=”projectthumbtitle”>’; echo get_the_title($page->ID); echo ‘</span>’; echo ‘</a></li>’; } … Read more

List custom field values ​​in alphabetical order without repetition

You could do a custom SQL query: global $wpdb; $query = “SELECT DISTINCT meta_value FROM $wpdb->postmeta WHERE meta_key = ‘director’ ORDER BY meta_value;”; $directors = $wpdb->get_results( $query ); foreach( $directors as $director ) : echo $director->meta_value; endforeach; one thing to note here though is that since you’re not querying the associated posts, you could get … Read more

List of all entries of custom-post-type: Add year-parameter?

I’ve modified above function somewhat function get_event_list( $latest = true, $order=”ASC”, $return = false, $year ) { // Pass year i.e $year $enddate = strtotime($year.”-12-31″); // year’s last date $startdate = strtotime( ($year-1).”-12-31″); year’s first date $yesterday = array($startdate, $enddate ); // Fetch posts between these dates $compare=”BETWEEN”;// Between above two dates $current_year=””; $args = … Read more

Display A list of Admins

Use get_users function it allows you to query user by role. For contributors, $contributors = get_users(‘role=contributors’); foreach($contributors as $contributors){ // do something with contributors } For Admins, $admins = get_users(‘role=admin’); foreach($admins as $admins){ // do something with admins } replace role=* with your desired roles.

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)