STYLING
With a static navigation, the CSS you mentioned, won’t work. Use the simple HTML parameters:
#access a:link,
#access a:active,
#access a:visited{
font-weight: bold;
}
CODING
In my project, I used echo get_the_category_by_ID( 11 );
to echo the Category name of the cat_ID = 11. You can show the cat name by this. For page title you can use <?php echo get_page($id); ?>
. But get_page() is deprecated. So instead of these, I’d love to place a single query, and then would love to echo one by one from the array, using get_pages()
:
get_pages(): This function returns an array of pages that are in the blog, optionally constrained by parameters. This array is not tree-like (hierarchical).
<?php $args = array(
'sort_order' => 'ASC',
'sort_column' => 'post_title',
'hierarchical' => 1,
'exclude' => '', //if you want to exclude any specific page
'include' => '', //pass the IDs here
'parent' => -1,
'number' => '',
'offset' => 0,
'post_type' => 'page',
'post_status' => 'publish'
);
$get_all_my_pages = get_pages( $args );
?>
To use the output, var_dump the variable (<?php var_dump( $get_all_my_pages ); ?>
) and work with it. So the <li>
for page would be:
<ul>
<li><a href="https://wordpress.stackexchange.com/questions/109299/<?php echo $get_all_my_pages[0]["guid']; ?>" title="https://wordpress.stackexchange.com/questions/109299/<?php echo $get_all_my_pages[0]["post_title']; ?>"><?php echo $get_all_my_pages[0]['post_title']; ?></a></li> <!-- for the first page of the output array -->
<li><a href="<?php echo $get_all_my_pages[4]['guid']; ?>" title="<?php echo $get_all_my_pages[4]['post_title']; ?>"><?php echo $get_all_my_pages[4]['post_title']; ?></a></li> <!-- for the fourth page of the output array -->
</ul>
I din’t try the code, but things can be similar like this. And a similar thing can be done for categories too, with get_categories()
.
get_categories(): Returns an array of category objects matching the query parameters.
Please let me know whether it works…
Using only two queries your page will load faster. 🙂