Skip to content

Instantly share code, notes, and snippets.

View Jursdotme's full-sized avatar

Rasmus Jürs Jursdotme

View GitHub Profile
@Jursdotme
Jursdotme / ACF Image Output
Created April 16, 2014 07:03
ACF Image Output
<?php
// Setup Image data
$id = get_field('topbillede');
$size = 'full'; // (thumbnail, medium, large, full or custom size)
$image_attributes = wp_get_attachment_image_src( $id, $size );
?>
<img src="<?php echo $image_attributes[0]; ?>" width="<?php echo $image_attributes[1]; ?>" height="<?php echo $image_attributes[2]; ?>">
@Jursdotme
Jursdotme / isotope-demo.php
Created April 23, 2014 12:56
Isotope setup for Toro
<?php
/*
Template Name: Isotope Test
*/
?>
<?php get_header();?>
<div class="container">
<div class="row">
@Jursdotme
Jursdotme / db.php
Created May 21, 2014 11:46
Use Live database on local Wordpress install.
// Use live database on local installation
<?php
// paste this in a (new) file, wp-content/db.php
add_filter ( 'pre_option_home', 'test_localhosts' );
add_filter ( 'pre_option_siteurl', 'test_localhosts' );
@Jursdotme
Jursdotme / submenu.php
Last active August 29, 2015 14:02
Wordpress Submenu
<?php
// use wp_list_pages to display Parent page and all child pages.
$ids = get_post_ancestors($page);
$parent = array_pop($ids);
if (empty($parent)) {
$parent = get_the_ID();
}
$args=array(
@Jursdotme
Jursdotme / Isotop.php
Last active August 29, 2015 14:04
Isotope Test Page
<?php
/*
Template Name: Isotope Test
*/
?>
<?php get_header();?>
<div class="container">
<div class="row">
@Jursdotme
Jursdotme / menu-shortcode.php
Created October 15, 2014 07:36
Shortcode to add menu
// Function that will return our Wordpress menu
function list_menu($atts, $content = null) {
extract(shortcode_atts(array(
'menu' => '',
'container' => 'div',
'container_class' => '',
'container_id' => '',
'menu_class' => 'menu',
'menu_id' => '',
'echo' => true,
@Jursdotme
Jursdotme / slugify.php
Created October 16, 2014 11:11
Slugify function
<?php function slugify($text)
{
// replace non letter or digits by -
$text = preg_replace('~[^\\pL\d]+~u', '-', $text);
// trim
$text = trim($text, '-');
// transliterate
$text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
@Jursdotme
Jursdotme / Email skabelon
Last active August 29, 2015 14:08
Standard Kontaktformular
<!DOCTYPE HTML PUBLIC "-//W3C//DTD XHTML 1.0 Transitional //EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html>
<head>
<title></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<style type="text/css">
@import url(https://fonts.googleapis.com/css?family=Roboto:400,400italic,700,700italic);
body {
margin: 0;
padding: 0;
@Jursdotme
Jursdotme / acf-functions.php
Last active August 29, 2015 14:09
Add custom field to Relationship field output
<?php function my_acf_relationship_result( $html, $post )
{
// add an image to each result
$field = get_field('varenummer', $post->ID);
if( $field )
{
$html = '<strong>' . $field . '</strong> - ' . $html;
}
@Jursdotme
Jursdotme / contact.php
Created December 19, 2014 08:07
random user
<?php
$json_url = "http://api.randomuser.me/?format=json&results=10";
$json = file_get_contents($json_url);
$links = json_decode($json, TRUE);
foreach($links['results'] as $key=>$val ){
$user_image_large = $val['user']['picture']['large'];
$user_image_medium = $val['user']['picture']['medium'];
$user_image_thumbnail = $val['user']['picture']['thumbnail'];
$user_firstname = ucfirst($val['user']['name']['first']);
$user_lastname = ucfirst($val['user']['name']['last']);