Skip to content

Instantly share code, notes, and snippets.

@stafmans
stafmans / 0_reuse_code.js
Last active August 29, 2015 14:19
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@stafmans
stafmans / index.html
Last active April 1, 2016 12:56
sublime:HTML: embedded CSS style
<style type="text/css">
body {
color:red;
}
</style>
@stafmans
stafmans / PHP: wordpress custom functions.php
Created October 6, 2013 09:57
Don't know yet how to collect it in a better way, but here I have some guidelines and information collected on making en using custom functions within Wordpress.
This Gist: collected material on use of custom functions in Wordpress
Goal: find best practices to be flexible without 'touching' core files and hence keep maintainability.
***********************************************************************
Greg Reindels approach: http://www.gregreindel.com/wordpress-custom-functions-file/
"At times you may need to add code to your themes functions.php file. I personally like to keep my functions file and other theme files as clean and organized as possible."
Step 1) Create a folder within your child theme named “lib”
@stafmans
stafmans / PHP: enqueue on themelevel.php
Last active December 24, 2015 18:09
This gist is used to enqueue styles and scripts in wordpress on a themelevel. It should be placed in a custom or childtheme functions.php file.
<?php
// Enqueue scripts and styles - themelevel
// wp_enqueue_scripts is the hook for frontend (wp3.3)
// LET OP! wp_enqueue_style() is NIET hetzelfde als wp_enqueue_styles
// De 1e is een functie, de 2e is een hook
// some examples to modify are already in this snippet
// naar keuze kan je script en styles scheiden over 2 functies, is netter
function mytheme_enqueue() {
//googlefonts examples 1 font
@stafmans
stafmans / PHP: enqueue on pagelevel.php
Last active December 24, 2015 18:09
This gist is used for enqueueing styles and scripts in the header of a custom wordpress page. It is in the form of a Custom Wordpress Page Template in which the code should be placed between the templatename and the call of the header.php.
<?php
/*
Template Name: My Page
*/
?>
<?php
// Enqueue scripts and styles - pagelevel
// wp_head is the hook for the pageheader
// some examples to modify are already in this snippet
@stafmans
stafmans / style.css
Last active December 24, 2015 03:09
sublime:CSS: Font-Face gebruik
body {
font-family: 'MyFontFamily', Fallback, sans-serif;
}
/* If you don't want to inject an <i> tag or simply can't? If you run into this case,
you can still use Font Awesome glyphs! All you need to do is use the :before pseudo-element
of the element you want to use and set its content and font-family. */
div.github:before {
content: "\f09b";
@stafmans
stafmans / style.css
Last active December 24, 2015 03:09
sublime:CSS: Font-Face declaratie
/*Volgens http://css-tricks.com/snippets/css/using-font-face/
probably best use from fonts.css */
@font-face {
font-family: 'MyWebFont';
src: url('webfont.eot'); /* IE9 Compat Modes */
src: url('webfont.eot?#iefix') format('embedded-opentype'), /* IE6-IE8 */
url('webfont.woff') format('woff'), /* Modern Browsers */
url('webfont.ttf') format('truetype'), /* Safari, Android, iOS */
url('webfont.svg#svgFontName') format('svg'); /* Legacy iOS */
}
@stafmans
stafmans / @wp sticky menu.md
Last active December 23, 2015 18:39
Sticky Menu on Genesis site.

##How to Add a Sticky Menu to the Top of Your Website

You might be wondering what a sticky menu is … and the answer is simple. When you scroll down the page of a website, you’ll see a navigation menu that literally sticks to the top of the screen. This is a great way to provide access to important pages on your website regardless of where your viewer is on the page.

####ADD A STICKY MENU

There are only a few steps required to create a sticky menu for your site. First you’ll need to download the Genesis Sample theme as you’ll need it to follow the steps below. If you are using one of our StudioPress themes or a custom Genesis theme, this will merely serve as guidance.

To get started, create a custom menu and head to Appearance > Menus > Manage Locations and assign your menu to the Secondary Navigation Theme Location.

@stafmans
stafmans / PHP: searchfield or date in WPmenu.php
Last active December 23, 2015 08:29
Little PHP and CSS snippets to place a searchfield and or date field in the Wordpress navigation menu.
<?php
// Here is a great code snippet I found on WP Recipes that will allow you to add a search bar to your nav menu. Add that to your functions.php file and make sure that your custom menu has been saved and added to your site and a search bar will now appear in your menu.
add_filter('wp_nav_menu_items','add_search_box', 10, 2);
function add_search_box($items, $args) {
ob_start();
get_search_form();
$searchform = ob_get_contents();
@stafmans
stafmans / PHP: wordpress substr() functie.php
Last active December 22, 2015 14:09
Gebruik als alternatief van the_content() in de wordpress loop om de lengte van weer te geven artikelen te bepalen.
bron: http://www.wpdoctor.com/tutorials/understanding-wordpress-the_content-function/
What if I don’t want to use the <!–more–> tag to shorten the content?
There is a simple hack that can be used to define a set length for the_content, without having to insert a <!–more–> tag every time you only want to show an excerpt. This can be useful if you’ve already written hundreds of posts, or if your new theme isn’t displaying things how you’d like.
To do this, we’ll use the php function ‘substr’. This function takes 3 parameters as follows:
<?php substr($string, $start, $length);?></strong>