Skip to content

Instantly share code, notes, and snippets.

View stefanledin's full-sized avatar

Stefan Ledin stefanledin

View GitHub Profile
<div class="toolbox-item"><h3 class="active">Filtrera journalhändelser <span class="icon-chevrondown"></span></h3> <div class="toolbox-item_content toolbox-item_content--expanded"><div class="toolbox-item_content--row"><div class="w-100"><label for="show-all" class="toolbox-filter-label">Visa alla</label></div> <div class="flex-shrink-1"><div class="form-check form-check-inline"><input type="checkbox" id="show-all" class="form-check-input"></div></div></div> <div class="toolbox-item_content--row level-2"><div class="w-100"><h3 class="active">
Besök
<span class="form-check-label"></span><span class="icon-chevrondown"></span></h3> <div class="toolbox-item_content toolbox-item_content--expanded"><div class="toolbox-item_content--row no-border"><div class="w-100"><label for="entry_type-1" class="toolbox-filter-label">Alla</label></div> <div class="flex-shrink-1"><div class="form-check form-check-inline"><span class="form-check-label"></span> <input id="entry_type-1" type="
var results = [
{
answer: "2",
question: "12"
},
{
answer: "1",
question: "13"
},
{
export const pageQuery = graphql`
query($slug: String) {
allWordpressPost(sort: {order: ASC, fields: date}) {
edges {
node {
featured_media {
localFile {
childImageSharp {
fluid(sizes: "(min-width: 1280px) 327px, (min-width: 768px) 39vw, 81vw") {
src
<?php
add_action( 'pre_get_posts', function( $query ) {
if ( ! is_admin() && is_post_type_archive( 'articles' ) ) {
$query->set('posts_per_page', 1);
}
} );
<?php
/*
Template name: My custom archive page
*/
$posts = new WP_Query( array(
'post_type' => 'articles',
'posts_per_page' => 1,
'paged' => ( get_query_var( 'paged' ) ) ? absint( get_query_var( 'paged' ) ) : 1
) );
<template>
<div>
<ul v-if="posts">
<li v-for="post in posts" v-bind:key="post.id">{{ post.title }}</li>
</ul>
</div>
</template>
<script>
import axios from 'axios';
<?php
add_filter('img_caption_shortcode', function( $output, $attr, $content ) {
return '<figure>' . $content . '<figcaption>' . $attr['caption'] . '</figcaption></figure>';
}, 10, 3);
importScripts('https://storage.googleapis.com/workbox-cdn/releases/3.6.1/workbox-sw.js');
if (workbox) {
const cacheName = 'my-site-cache';
workbox.routing.registerRoute(
'/',
workbox.strategies.networkFirst({
cacheName
})
<?php
/**
* Register the custom taxonomy.
*/
add_action( 'init', 'register_taxonomy_article_type' );
function register_taxonomy_article_type() {
register_taxonomy( 'article_type', 'post', array(
'label' => 'Article type',
'hierarchical' => true,
<?php
/**
* Custom image sizes
*/
add_image_size('my-custom-image-size', 768, null, false);
add_filter( 'image_size_names_choose', function( $sizes ) {
// Remove build in sizes
unset($sizes['thumbnail']);
unset($sizes['medium']);