Skip to content

Instantly share code, notes, and snippets.

View samikeijonen's full-sized avatar
🏠
Working from home

Sami Keijonen samikeijonen

🏠
Working from home
View GitHub Profile
<!DOCTYPE html>
<html>
<head>
<title>Semantic HTML</title>
</head>
<body>
<header>
<nav>
<ul>
<?php
function valteri_pre_get_posts( $query ) {
// Show only posts from 'blogi' category.
if ( ! is_admin() && $query->is_main_query() && is_home() ) {
// Get Finnish ID.
$lang_fi = get_term_by( 'slug', 'fi', 'language' );
$id_fi = $lang_fi->term_id;
// Get Swedish ID.
$lang_sv = get_term_by( 'slug', 'sv', 'language' );
@samikeijonen
samikeijonen / translate-only-terms.php
Last active December 10, 2017 20:43
Translate only terms from taxonomy "contact_area" when filterin "contact" post type posts. Posts are not translates at all because they only have name, email, and phone number.
<?php
$terms = get_terms( array(
'taxonomy' => 'contact_area',
'hide_empty' => false, // Other than default language don't have any posts.
'orderby' => 'name',
'lang' => function_exists( 'pll_current_language' ) ? pll_current_language() : '',
) );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ) :
foreach ( $terms as $term ) :
@samikeijonen
samikeijonen / fashion.md
Last active November 16, 2017 19:59
Gutenberg block in front-end

Single post without sidebar on the left or right

Single posts should not have sidebar on the left or right because blocks can go wider than "base" content.

Color scheme

User can select colors for some blocks. For example user can select button background color and text color. Theme should use max. 4-5 colors for everything. Color contrast needs to meet AA level 4.5:1 for all elements.

Wide and full width

@samikeijonen
samikeijonen / fetch-rest-api.js
Last active April 30, 2021 10:47
Using Fetch API and REST API
/*
* Load contacts and filter by categories.
*/
( function() {
'use strict';
// Variables.
const filterForm = document.getElementById( 'filter-contacts' );
const contactWrapper = document.getElementById( 'contact-section' );
const htmlOutput = document.getElementById( 'js-contact-replace' );
/**
* Get social sharing links.
*
* @link: http://sharingbuttons.io/
*
* @since 1.0.0
*/
function valteri_get_social_links() {
$output = '';
$output .= '<ul class="social-sharing">';
@samikeijonen
samikeijonen / checathlon-old-pink-color.css
Last active April 14, 2017 12:18
Checathlon theme old pink color. You can put these styles in child theme style.css or in the Customizer additional CSS section.
.highlight-color,
.jetpack-testimonial .entry-inner .icon,
.before-footer-widgets-wrapper .icon,
.checathlon_widget_pricing .icon {
color: #ff1654;
}
a,
a:visited {
color: #ff1654;
@samikeijonen
samikeijonen / che-plus.css
Last active March 13, 2017 21:15
Checathlon Plus Additional CSS
.site-header {
padding-top: 1rem;
padding-bottom: 1rem;
}
.main-navigation a {
text-transform: none;
}
.page-title.text-italic,