Pass WordPress variable to the next page

If it is working with a literal string (“example”) but not with the variable, we can assume that the issue is with your variable. You haven’t provided all of the code for that section of index.php, but as it is I do not think you can expect that variable to hold anything. First, you are … Read more

Is there a way to fetch the category of a page when using wp_list_pages?

You can get an array of pages using get_pages() and then for each page retrieve categories using wp_get_object_terms. Your code may look like this: $args = array( ‘post_type’ => ‘board-meeting’, ‘post_status’ => ‘publish’ ); $pages = get_pages($args); if ( ! empty( $pages ) ) { echo ‘<ul>’; foreach($pages as $page){ $cats = wp_get_object_terms( $page->ID, ‘category’ … Read more

Get only children category name

For this specific question, Try this $categories = get_the_category($id); foreach($categories as $category){ if($category->parent != 0){ // Display it here echo ‘<a href=”‘ . esc_url( get_category_link( $category->term_id ) ) . ‘”>’ . esc_html( $category->name ) . ‘</a>’; } }

Retrieving Categories based on the first character of the name

Found a solution. I found a function that answered my question. Here is the function: function get_category_by_letter($letter) { $args=array( ‘orderby’ => ‘name’, ‘order’ => ‘ASC’, ‘hide_empty’ => 0); $categories=get_categories($args); foreach($categories as $category) { $catname = $category->name; $first_letter = substr(strip_tags($catname), 0 , 1); if(strcasecmp($first_letter,$letter) != 0) continue; else { $cats[] = $category->term_id; $cats[] = $category->name; } … Read more

List non-empty categories from a custom post type

This will end up being a little convoluted since the taxonomy just describes a relationship that may belong to any of the post types, so there’s not a direct data link for what you’re trying to fetch. But you could do something like this (untested), which could be a fairly heavy query if you’re doing … Read more