Skip to content

Instantly share code, notes, and snippets.

View alexx855's full-sized avatar
🔵
Stay safe and stay optimistic.

Alex Pedersen alexx855

🔵
Stay safe and stay optimistic.
View GitHub Profile
@alexx855
alexx855 / parent-template-inherit.php
Created May 21, 2017 19:43
Wordpress parent template inherit
<?php
function switch_page_template() {
global $post;
// Checks if current post type is a page, rather than a post
if (is_page())
{
// Checks if page is parent, if yes, return
if ($post->post_parent == 0)
@alexx855
alexx855 / crud-taxonomy-meta-wordpress.php
Created May 19, 2017 00:22
CRUD custom taxonomy meta wordpress
<?php
add_action( '{taxonomy}_add_form_fields', 'add_feature_group_field', 10, 2 );
function add_feature_group_field($taxonomy) {
global $meta_name;
?>
<div class="form-field">
<label for="meta_name">Meta Name</label>
<input name="meta_name" id="meta_name" type="text" value="<?php echo $meta_name; ?>" size="40" aria-required="true">
@alexx855
alexx855 / custom-menu-items.php
Created April 26, 2017 14:09
How to Add Custom Items to Specific WordPress Menus
<?php
add_filter( 'wp_nav_menu_items', 'your_custom_menu_item', 10, 2 );
function your_custom_menu_item ( $items, $args ) {
if (is_single() && $args->theme_location == 'primary') {
$items .= '<li>Show whatever</li>';
}
return $items;
}