Post List by category and under custom taxonomy

Your post list is repeating because in your WP_Query args you are fetching posts just from the category with ID “2”. In order to get posts from custom taxonomies you need to use a tax_query inside your WP_Query. You can read more about tax_query here: https://developer.wordpress.org/reference/classes/wp_query/#taxonomy-parameters I would do the following: $args = array( ‘post_type’ … Read more

Include parent page in list of child pages

You can get the parent with wp_get_post_parent_id(get_the_ID()), and store it in a new variable and do the same with the children and then just showcase them in any format you want. <?php $theParent = wp_get_post_parent_id(get_the_ID()); if ( $theParent->ID == 83 ) { ?> <div class=”parent”><?PHP echo get_the_title($theParent); ?></div> <ul class=”children”><?PHP wp_list_pages(array( ‘title_li’ => ”, ‘child_of’ … Read more

Retrieve array items without page ID

to get pages as array use get_pages() instead. now once we have a list we can check the size of list and split it. Let’s have an example: $allpages = get_pages( array( ‘child_of’ => $section_top_parent, ‘post_type’ => ‘section’, ‘depth’ => 1, ‘sort_order’ => ‘asc’ ) ); //check $allpages has any value if($allpages){ //calculate the array … Read more

Why are array_slice() and array_chunk() not working?

You need to do the slice on the results, not the arguments to the function. So: $arr = array( //$section_top_parent is the top parent of the custom post type “section” ‘child_of’ => $section_top_parent, ‘post_type’ => ‘section’, ‘title_li’ => NULL, ‘depth’ => 1, ‘sort_order’ => ‘asc’, ); $result = wp_list_pages($arr); $sliced = array_slice($result, 3, 5); wp_list_pages($sliced);

wp_list_pages two columns

I got everything working, but had to change my approach to get it working the way I wanted. Basically, the easiest approach (at least for me), was to create two menus…one for small screen sizes and one for larger ones. So, the code looks like: <!– Head –> <div id=”head”> <!– Nav –> <ul class=”nav”> … Read more

build child and anchestor three from post parent

So i got it working, by adding a filter: i added this before the wp_list_pages add_filter( ‘get_pages’, ‘check_propper_rank’, 10, 2 ); wp_list_pages( array( ‘post_type’ => ‘wiki-term’, ) ); and then created a new filter, to removed the ones that did’nt fit the rank. function check_propper_rank( $pages, $arguments ) { $user_rank = 100; foreach ( $pages … Read more

Manually adding current_page_parent to wp_list_pages()

By default wp_list_pages() uses the Walker_Page class to create the HTML list, and there’s a filter in there—page_css_class—for the CSS classes. You should be able to do something like this: /** * Filters the CSS classes. * * @param array $css_class The current CSS classes. Array of strings. * @param WP_Post $page The current page … Read more

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