Skip to main content
6 votes
Accepted

How to create A-Z index listing for custom post types?

Ok, you just have to make a loop with first letter check. WordPress query will handle the post_title ASC order. EDIT : I use get_permalink() within the loop to get URL (https://developer.wordpress....
Elex's user avatar
  • 1,045
5 votes
Accepted

Number of items in a menu

I was curious and decided to check it out, regardless if it's relevant for a CSS problem ;-) I first peeked into the database tables to find more about the menu structure: Menu - building blocks ...
birgire's user avatar
  • 67.4k
5 votes

How to show a hierarchical terms list?

I used @popsi code that was working really well and I made it a more efficient and easy to read: /** * Recursively sort an array of taxonomy terms hierarchically. Child categories will be * placed ...
Pierre R's user avatar
  • 232
4 votes
Accepted

wp_dropdown_categories and custom taxonomy + custom post type

You can get your code to work the expected way by adding the following three arguments to your $args array which you pass to wp_dropdown_categories(): name — the select name as in <select name=&...
Sally CJ's user avatar
  • 39.3k
3 votes

How to create A-Z index listing for custom post types?

Try this function, I use it to create linkable A-Z index function nstrm_sd_do_az_loop() { global $page_slug; $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $...
Marcel Bootsman's user avatar
3 votes
Accepted

Get woocommerce catogry

It's not working because you didn't pass the Woocoomerce's Product category taxonomy. By default get_categories() function will returns all terms data of default category taxonomy, if you did't ...
GKS's user avatar
  • 1,306
3 votes
Accepted

Categories list loop - add separator every 3 categories

<?php $args=array( 'orderby' => 'name', 'order' => 'ASC', ) $count=1; // A $count variable ?> <?php foreach (get_categories( $args ) as $cat) : if($count%3==0) // This condition ...
Ranuka's user avatar
  • 1,794
3 votes
Accepted

TinyMCE - Add class to OL - selector doesn't seem to get parent OL,UL, just LI's (4.6.3)

I figured this out! I ended up running across this page today searching for something else and thought, THIS IS IT. I needed this property 'selector', because it seems like that guides what the ...
theaemarie's user avatar
3 votes

Get parent of current page

Try using get_post_ancestors. Here is how you can apply this in your case: <?php global $wp_query; $post = $wp_query->post; $ancestors = get_post_ancestors($post); if( empty($...
Sabbir Hasan's user avatar
  • 1,359
2 votes

Show template loaded

get_currentuserinfo is deprecated since 4.5.0! Use wp_get_current_user() instead. add_action('wp_head', 'show_template'); function show_template() { global $template; global $current_user; ...
Guga Alves's user avatar
2 votes
Accepted

Wordpress' visual editor messing up my (nested) lists (and other things as well)

Instead of using the "type" attribute, try adding a CSS class and styling that. <ol> <li>Number one</li> <li>Number two <ol class="lower-alpha"> ...
WebElaine's user avatar
  • 9,430
2 votes

How can I show the author's latest post with title?

As you already have the author's ID, you can create a new WP_Query and get the 3 latest posts of the Author. The following code will do the job for you, $getPosts = new WP_Query( array( "...
Anteraez's user avatar
  • 109
2 votes
Accepted

Get all sub-categories of a parent category

In reply to your updated code, you should know that the $post_terms = wp_get_object_terms() would only return categories that directly attached to the post, so I'd just use wp_list_categories() to get ...
Sally CJ's user avatar
  • 39.3k
2 votes
Accepted

how to wordpress When I click on the category link, subcategories appear

Here's how you get all top-level categories and loop them to create a list of links, $parent_categories = get_categories( array( 'fields' => 'id=>name', // other term data no needed here '...
Antti Koskinen's user avatar
1 vote

Categories list loop - add separator every year

I don't know what is the purpose of having each each categories for every month because WordPress has monthly archive. You can use it. However, it is possible that what you are going to do. I can't ...
Ranuka's user avatar
  • 1,794
1 vote
Accepted

Convert UL to dropdown list not working

@CharlieJustUs when you use Fiddle is automatically sets the $ variable for you. When your script tries to run on your site, that variable is not set, and it fails. Try this please. jQuery(...
Warwick's user avatar
  • 376
1 vote
Accepted

How to show a list of only categories (exclude subcategories)

$args = array( 'orderby' => 'name', 'order' => 'ASC', 'parent' => 0 ); $categories = get_categories($args); May this will help you. Refer this link
Parthavi Patel's user avatar
1 vote
Accepted

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 = [ '...
janw's user avatar
  • 1,018
1 vote
Accepted

line order number start numbering from second line (SOLVED)

What if you started your index at 1, instead of 0? Change: $i=0; To: $i=1; You might have checked, but you aren't having an CSS / layout issues, are you?
ChristopherJones's user avatar
1 vote
Accepted

Remove Order List Row Link in WooCommerce Admin?

Based on class-wc-admin-list-table-orders.php (order column on line 173) there doesn't seem to be a filter to change the markup. To circumvent this, perhaps you could add a js/jQuery script, to ...
Antti Koskinen's user avatar
1 vote
Accepted

Category list with postcount

You just need to use wp_list_categories function with param show_count set to true https://developer.wordpress.org/reference/functions/wp_list_categories/ wp_list_categories( array( 'show_count' =&...
Carlos Faria's user avatar
1 vote

List pages by custom field?

Function wp_list_pages() accepts arguments from get_pages() function. To list pages filtered by custom field use meta_key and meta_value in parameters array. A list of accepted parameters can be found ...
nmr's user avatar
  • 4,511
1 vote
Accepted

Posts as filtered list - expandable

The website you linked to appears to be using the Bootstrap framework in their theme design (based on what I saw from their source code). You can learn more about Bootstrap from their official website ...
jsmod's user avatar
  • 501
1 vote
Accepted

How can ι create my own (custom) WordPress table/list?

I'm not an expert on this but I did get into it a little recently. Take a look at this tutorial: http://wpengineer.com/2426/wp_list_table-a-step-by-step-guide/ Basically, you'll want to create a ...
Lime's user avatar
  • 128
1 vote

Exclude admin from user list

You could use user_can( $user_id, 'manage_options' ) to gauge the ids in the users array and unset($users->[$x]) the appropriate row. I would personally use $users = array(); foreach ($...
contemplator's user avatar
1 vote
Accepted

Create alphabetical Pagination for custom taxonomy?

In your code you are showing "A" for all the paginations and you also don't need to create link for every letters in English. I fixed them. And I also added a class here called selected to current ...
CodeMascot's user avatar
  • 4,527
1 vote
Accepted

How do i wrap woocomerce attribute in list?

global $product; $attributes = $product->get_attribute( 'pa_attribute_name' );
vol4ikman's user avatar
  • 352
1 vote
Accepted

List child pages alphabetically

Please change 'orderby' => 'the_title' to 'orderby' => 'title' then you will get the posts in alphabetical order.
Praveen's user avatar
  • 240
1 vote

Number of items in a menu

Thanks for the help birgire. That gave me a lot to think about. Eventually I have came up with a solution using a filter I can count the number of parents the menu has. The only problem with this ...
Self Designs's user avatar
1 vote

Output custom text field as unordered list

This is more about string and array manipulation with php than a WordPress related question. The proper way to do it would be using a repeater field instead of a single text input. Advanced Custom ...
Luis Sanz's user avatar
  • 756

Only top scored, non community-wiki answers of a minimum length are eligible