Skip to content
View in the app

A better way to browse. Learn more.

Web Designer Forum

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Categories to show in the top nav

Featured Replies

Hello friends,

 

In my blog if i want the categories to apeear at the top navigation where the pages are and the pages in the categories area can it be done

 

 

 

this is navigation code

<div id="nav">

<div class="search"><?php include (TEMPLATEPATH . '/searchform.php'); ?></div> <!-- Closes Search -->

<?php function get_the_pa_ges() {
 global $wpdb;
 if ( ! $these_pages = wp_cache_get('these_pages', 'pages') ) {
    $these_pages = $wpdb->get_results('select ID, post_title from '. $wpdb->posts .' where post_status = "publish" and post_type = "page" order by ID');

  }
 return $these_pages;
}

function list_all_pages(){

$all_pages = get_the_pa_ges ();
foreach ($all_pages as $thats_all){
$the_page_id = $thats_all->ID;

if (is_page($the_page_id)) {
 $addclass = ' class="current_page"';
 } else {
 $addclass = '';
 }
$output .= '<li' . $addclass . '><a href="'.get_permalink($thats_all->ID).'" title="'.$thats_all->post_title.'"><span>'.$thats_all->post_title.'</span></a></li>';
}

return $output;
}
?>
<ul>
<?php

if (is_home()) {
 $addclass = ' class="current_page"';
 } else {
 $addclass = '';
 }
echo "<li" . $addclass . "><a href='" . get_option('home') . "' title='Home'><span>Home</span></a></li>";
echo list_all_pages();?>
</ul>

<div class="cleared"></div>
</div> <!-- Closes Nav -->

 

and this is the categories code in sidebar.php

 

 

<ul><li>
<h2>Categories</h2>
<ul>
 <?php wp_list_categories('show_count=0&title_li='); ?>
</ul>
</li>

</ul>

 

 

my bloglink

Why don't you just swap the codes?

  • Author

Why don't you just swap the codes?

 

 

but i have many categories how will that fit at the top? thats my concern

 

 

or do i need a seperate function for categories?

 

 

 

just found this tutorial oncategories dropdown

 

 

If you have more than 4 top level categories, I recommend doing a drop-down menu. The tutorial you've found will do.

Create an account or sign in to comment

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.