Skip to content

Instantly share code, notes, and snippets.

@adamlaki
adamlaki / main.css
Last active March 24, 2019 19:28
Style External Links in CSS
a[target="_blank"]:not([href*="pineco.de"])::after {
/* You can style it anyway you want... */
content: '';
display: inline-block;
background: transparent url(external-arrow.svg) no-repeat center center;
background-size: cover;
width: 1rem;
height: 1rem;
margin-left: 0.3rem;
}
@adamlaki
adamlaki / main.js
Created March 12, 2019 19:12
Contact Form 7 Thank You Page Redirects
document.addEventListener( 'wpcf7mailsent', function( event ) {
if ( '101' == event.detail.contactFormId ) {
location = 'https://www.example.com/thank-you-page-one/';
} else {
location = 'https://www.example.com/thank-you-page-two/';
}
}, false );
@adamlaki
adamlaki / functions.php
Created February 16, 2019 13:25
Add Page Slug to Body Class in WordPress
<?php
function pine_add_page_slug_body_class( $classes ) {
global $post;
if ( isset( $post ) ) {
$classes[] = 'page-' . $post->post_name;
}
return $classes;
@adamlaki
adamlaki / functions.php
Last active February 16, 2019 12:58
Change Jetpack's Infinite Scroll Button's Text
<?php
function cone_change_infinite_scroll_btn_text() {
if ( is_home() || is_archive() ) { ?>
<script type="text/javascript">
var textCaption = '';
if ( 'en-US' == $( 'html' ).attr( 'lang' ) ) {
textCaption = 'Load More Posts';
} else {
@adamlaki
adamlaki / functions.php
Last active January 20, 2019 16:36
How to Add Featured Image to RSS Feeds in WordPress - Add as an individual item
<?php
function pine_feed_add_image( ) {
global $post;
$output = '';
if( get_post_type() !== 'post' ) {
return;
}
@adamlaki
adamlaki / functions.php
Created January 20, 2019 16:30
How to Add Featured Image to RSS Feeds in WordPress - Add to the content body
<?php
function pine_post_thumbnails_in_feeds( $content ) {
global $post;
if( has_post_thumbnail( $post->ID ) ) {
$content = '<div>' . get_the_post_thumbnail( $post->ID, 'your-image-size' ) . '</div>' . $content;
}
return $content;
@adamlaki
adamlaki / main.css
Created December 26, 2018 08:09
How to Break Long Words with CSS
.break_long_text {
word-break: break-all;
word-break: break-word;
hyphens: auto;
}
@adamlaki
adamlaki / main.scss
Created December 26, 2018 07:56
Animating Gradient Background with CSS
.button {
display: inline-block;
color: #fff;
padding: 20px 30px;
text-transform: uppercase;
font-weight: 700;
border-radius: 3px;
cursor: pointer;
background-image: linear-gradient(45deg, #ffc459, #ff6638);
@adamlaki
adamlaki / functions.php
Last active December 15, 2018 13:17
Add Custom Columns To Post Type
<?php
// Add the Terms(s) columns to the snippets post type
function set_custom_edit_snippets_columns($columns) {
$columns['terms'] = __( 'Term(s)', 'pine' );
return $columns;
}
add_filter( 'manage_snippets_posts_columns', 'set_custom_edit_snippets_columns' );
// Add the data to the snippet's Term(s) column
@adamlaki
adamlaki / functions.php
Created December 15, 2018 11:16
Slugify Any Text in WordPress with sanitize_title() Function
<?php
$title = sanitize_title('Slugify Any Text in WordPress with sanitize_title() Function');
echo $title; // slugify-any-text-in-wordpress-with-sanitize_title-function