Adding Post Counts to Menu (Nav) Programmatically?

WordPress’ get_categories() function returns an array of category objects, each of which has a “count” property for the number of posts in that category. So something like this would get you a list of links to category pages: $categories = get_categories(); $markup = ‘<ul>’; foreach( $categories as $category ) { $catName = $category->category_nicename; $count = … Read more

How to open modal window when clicking a WP menu link?

Using bootstrap’s modal you could use this hook in your function.php file top do that: add_filter( ‘nav_menu_link_attributes’, ‘menu_atts’, 10, 3 ); function menu_atts( $atts, $item, $args ) { // The ID of the target menu item $menu_target = 24; // inspect $item if ($item->ID == $menu_target) { $atts[‘data-toggle’] = ‘modal’; $atts[‘data-target’] = ‘#IDofModal’; } return … Read more

List children of second level sub page

Is this what you are after? <?php if($post->post_parent) { // if $post has parent than it is “Second level” and show its children. $children = wp_list_pages(“child_of=”.$post->post_parent.”&echo=0″); } else { // else it’s a “Top level” so display children & grand children? $children = wp_list_pages(“child_of=”.$post->ID.”&echo=0″); } if ($children) { echo “<ul>$children</ul>”; } Source: http://codex.wordpress.org/Function_Reference/wp_list_pages#List_subpages_even_if_on_a_subpage

WordPress nav_menu_link_attributes Not Working

Whenever an attribute is empty WordPress filters decide just not to show the attribute so a simple test for this is the following: function menu_anchor_attributes ( $atts, $item, $args ) { $atts[‘data-menuanchor’] = ( ! empty( $item->attr_title ) ) ? $item->attr_title : ‘test’; return $atts; } add_filter( ‘nav_menu_link_attributes’, ‘menu_anchor_attributes’, 10, 3 ); This way, if … Read more

When add wordpress page in menu it converted in to custom link

The issue was in table structure of wp_post. The wp_posts table’s ID field is somehow lost it’s functionality of increment automatically. Means when new row use to add in the table then ID field suppose to increment by 1. But it was not happening after update. So I just edit table structure and make it … Read more

Links open only on new tab or window

Links open in new Tab or Window if the link <a> is added using target=”_blank” (either from HTML or JavaScript). I’ve just checked your site and saw only Twitter links open in new Tab / Window. Must be from the plugin you are using to generate the Twitter feed. Note: JQMIGRATE is installed by WordPress … Read more

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