Skip to content

Instantly share code, notes, and snippets.

View oliwa's full-sized avatar

Oliver Hulisz oliwa

View GitHub Profile
@oliwa
oliwa / submenu-wp_nav_menu.php
Last active December 5, 2018 07:09
Submenus from wp_nav_menu
<?php wp_nav_menu( array(
'container' => '',
'menu' => 'primary-nav',
'submenu' => 11,
)); ?>
@oliwa
oliwa / functions.php
Last active December 5, 2018 07:09
add a class to next/prev post and posts links
<?php
// Add class to links generated by next_posts_link and previous_posts_link,
// see https://css-tricks.com/snippets/wordpress/add-class-to-links-generated-by-next_posts_link-and-previous_posts_link/
add_filter('next_posts_link_attributes', 'posts_link_attributes');
add_filter('previous_posts_link_attributes', 'posts_link_attributes');
function posts_link_attributes() {
return 'class="button"';
}
@oliwa
oliwa / wp-body-class.php
Last active December 5, 2018 07:09
add blog ID to body class
<?php
// add blog_ID class to the body tag, see http://zurb.com/forrst/posts/Wordpress_multisite_blog_class-dAb
add_action( 'body_class', 'wpmu_body_class' );
function wpmu_body_class( $class ) {
global $current_blog;
$class[] = 'site-lang-' . $current_blog-> blog_id;
return $class;
}
@oliwa
oliwa / index.html
Last active December 5, 2018 07:09
HTML5 Template
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title></title>
<link rel="stylesheet" type="text/css" href="styles.css">
</head>
<body>
<h1>Flexbox</h1>
<p>Test</p>
@oliwa
oliwa / default.css
Last active December 5, 2018 07:10
Default CSS with SVG support
img {
max-width: 100%;
height: auto;
}
img [src$=".svg"] {
max-width: auto;
width: 100%;
height: auto;
}
@oliwa
oliwa / multisite.php
Created November 19, 2015 10:04
WP Multisite Blog Conditional
<?php global $blog_id; ?>
<?php if( $blog_id == '1' /* Blog 1 */) { ?>
<p>Blog 1</p>
<?php } else if( $blog_id == '2' /* Blog 2 */) { ?>
<p>Blog 2</p>
<?php } else if( $blog_id == '3' /* Blog 3 */) { ?>
<p>Blog 3</p>
<?php } ?>
@oliwa
oliwa / snippet.php
Created November 19, 2015 10:04
Conditionals
<?php if(is_page('xy')) { ?>
// do something on the xy page
<?php } ?>
<?php if(!is_page('xy')) { ?>
// do something on every but the yx page
<?php } ?>
<?php if(is_page('xy') || is_page('xyz') ) { ?>
// do something on the xy and xyz page
@oliwa
oliwa / snippet.php
Created November 19, 2015 10:03
Environment Conditional
<!-- Environment -->
<?php if ($_SERVER['SERVER_ADDR']=="192.168.100.10"){ ?>
<!-- local, do something... -->
<?php } else { ?>
<!-- online, do something else... -->
<?php } ?>
@oliwa
oliwa / functions.php
Created November 19, 2015 10:02
changing default wordpres email settings
// changing default wordpres email settings
add_filter('wp_mail_from', 'new_mail_from');
add_filter('wp_mail_from_name', 'new_mail_from_name');
function new_mail_from($old) {
return '[email protected]';
}
function new_mail_from_name($old) {
return 'MAP BioPharma';
}
@oliwa
oliwa / snippet.php
Created November 19, 2015 09:59
Random Select
<!-- load a random image -->
<figure>
<img src="/images/visual-<?php echo(rand(1,5)); ?>" />
</figure>
<!-- Display random snippet -->
<?php
$snippet[] = '<h2>Snippet 1</p>';