How to List all Sidebars in a Metabox

Try this: <?php $sidebar_options = array(); $sidebars = $GLOBALS[‘wp_registered_sidebars’]; foreach ( $sidebars as $sidebar ){ $sidebar_options[] = array( ‘name’ => $sidebar[‘name’], ‘value’ => $sidebar[‘id’] ); } ?> This prints out( with my registered sidebars ): Array ( [0] => Array ( [name] => Language Menu [value] => sidebar-1 ) [1] => Array ( [name] => … Read more

Display Custom Taxonomy in Sidebar in Two Columns

As a follow up to @Rutwick Gangurde Answer, here’s an example. Notes: Put it in your functions.php file, call it in the template file. Alter the output by inspecting the $term inside the foreach loop Read the comments inside the function – function wpse25433_terms_list( $cat = array(‘categories’), $el=”li”, $echo = true ) { global $post; … Read more

taxonomy list display custom post count

What makes this annoying is that the count is a wp_term_taxonomy table. So the way to do this is a custom query: function wpse340250_term_count( WP_Term $term, $post_type) { $q_args = [ ‘post_type’ => $post_type, ‘nopaging’ => true, // no limit, pagination ‘fields’ => ‘ids’, // only return post id’s instead of full WP_Post objects will … Read more

Changing a function in function.php to a shortcode – for listing categories of only a certain post type

It looks like wp_list_categories($args) will output directly when you call it, which is why the output comes out in a weird place. and ideally what you need is to capture the output and return it, but luckily wp_list_categories allows you to do this with the ‘echo’ parameter. Try: $args[‘echo’] = FALSE; return wp_list_categories($args); Note the … Read more

Display list of Sub-Categories and the posts they contain, within one main Category

Question was answered on another site.. thank you! BTW, the code that accomplished what I needed was: $categories = get_categories(‘child_of=31’); foreach ($categories as $category) { //Display the sub category information using $category values like $category->cat_name echo ‘<h2>’.$category->name.'</h2>’; echo ‘<ul>’; foreach (get_posts(‘cat=”.$category->term_id) as $post) { setup_postdata( $post ); echo “<li><a href=”‘.get_permalink($post->ID).'”>’.get_the_title().'</a></li>’; } echo ‘</ul>’; }

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