Recursos de la lección 6 del móludo 3 del curso
Condicionales para desplegar diferentes clases de acuerdo al tipo de navegación
add_filter( 'nav_menu_link_attributes', 'class_main_nav', 10, 3);
function class_main_nav ($atts, $item, $args) {
if ( $args->theme_location == 'header-menu' || $args->theme_location == 'social-menu'):
$class = 'nav-link nav__link t-black';
elseif ( $args->theme_location == 'footer-menu' ):
$class = 'nav-link nav__link t-white';
endif;
$atts['class'] = $class;
return $atts;
}
Crear custom post type desde código, aprenderemos a utilizarlo en la próxima lección
add_action( 'init', 'nombre_funcion' );
function nombre_funcion() {
$labels = array(
'name' => _x( '', '' ),
'singular_name' => _x( 'Destacada', 'post type singular name', '' ),
'menu_name' => _x( '', 'admin menu', '' ),
'name_admin_bar' => _x( '', 'add new on admin bar', '' ),
'add_new' => _x( 'Agregar nueva', 'book', '' ),
'add_new_item' => __( 'Agregar nueva Destacada', '' ),
'new_item' => __( 'Nuevas ', '' ),
'edit_item' => __( 'Editar ', '' ),
'view_item' => __( 'Ver ', '' ),
'all_items' => __( 'Todas las ', '' ),
'search_items' => __( 'Buscar ', '' ),
'parent_item_colon' => __( 'Parent :', '' ),
'not_found' => __( 'No found.', '' ),
'not_found_in_trash' => __( 'No found in Trash.', '' )
);
$args = array(
'labels' => $labels,
'description' => __( 'Description.', '' ),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array( 'slug' => '' ),
'capability_type' => 'post',
'menu_icon' => 'dashicons-star-filled',
'has_archive' => true,
'hierarchical' => false,
'menu_position' => 6,
'supports' => array( 'title', 'thumbnail' ),
'taxonomies' => array( 'category' ),
);
register_post_type( '', $args );
}