Last active
December 17, 2015 20:38
Kodsnuttar från blogginlägget som visar hur du kan markera menyval som aktivt när besökaren är inne på ett enskilt inlägg i en Custom Post Type.
http://www.webbgaraget.se/2013/05/30/markera-menyval-som-aktivt-nar-besokaren-ar-inne-pa-en-custom-post-type/
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
add_action( | |
'init', | |
function () | |
{ | |
// Vår meny | |
register_nav_menu( 'main-menu', 'Huvudmeny' ); | |
// Custom Post Type för event | |
$labels = array( | |
'name' => 'Events', | |
'singular_name' => 'Event', | |
'all_items' => 'All Events', | |
'add_new_item' => 'Add Event', | |
'edit_item' => 'Edit Event', | |
'new_item' => 'New Event', | |
'view_item' => 'View Event', | |
'search_items' => 'Search Events', | |
'not_found' => 'No events found', | |
'not_found_in_trash' => 'No events found in trash', | |
); | |
register_post_type( | |
'event', | |
array( | |
'labels' => $labels, | |
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail' ), | |
'public' => true, | |
) | |
); | |
} | |
); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!DOCTYPE html> | |
<html lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title><?php bloginfo( 'title' ); ?></title> | |
<?php | |
wp_enqueue_style( 'wptemp', '/wp-content/themes/webbgaraget/style.css' ); | |
wp_head(); | |
?> | |
</head> | |
<body <?php body_class(); ?>> | |
<header> | |
<h1>Markera menyval i singelsidor för Custom Post Types</h1> | |
<p>Meny:</p> | |
<nav> | |
<?php wp_nav_menu( array( 'theme_location' => 'main-menu' ) ); ?> | |
</nav> | |
</header> | |
<section role="main"> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Theme Name: Markera menyval för CPT | |
Theme URI: | |
Description: Visar hur du på två olika sätt kan markera menyval vid visning av custom post types | |
Author: Webbgaraget | |
Author URI: http://www.webbgaraget.se/ | |
Version: 1.0 | |
*/ | |
.current-menu-item a, | |
.single-event .menu-item.events { | |
font-weight: bold; | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
Theme Name: Markera menyval för CPT | |
Theme URI: | |
Description: Visar hur du på två olika sätt kan markera menyval vid visning av custom post types | |
Author: Webbgaraget | |
Author URI: http://www.webbgaraget.se/ | |
Version: 1.0 | |
*/ | |
.current-menu-item a { | |
font-weight: bold; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment