Skip to content

Instantly share code, notes, and snippets.

@lschatzkin
lschatzkin / limitcontent.php
Created October 27, 2016 21:53
WordPress limit the_content() length
<?php
$content = get_the_content('read more', true);
$content = substr($content,0,900);
$content = apply_filters('the_content', $content );
$content = $content . '<a href="'.get_permalink().'">(Read More...)</a>';
echo $content;
?>
@lschatzkin
lschatzkin / wp-url-bg.php
Last active May 30, 2016 17:38
wordpress background image from featured image
<?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
<header class="intro-header" style="background-image: url('<?=$url?>')">
@lschatzkin
lschatzkin / vimeo-embed.php
Created January 28, 2016 18:43
Embed vimeo via ACF using wp_oembed_get; custom field just holds id#
<?php
$video = get_post_meta($post->ID, "video_id", true);
while ( $video_query->have_posts() ) :
$video_query->the_post();
echo wp_oembed_get( 'https://vimeo.com/' . $video );
endwhile;
?>
@font-face {
font-family: Wendy;
src: local("Wendy"),
url(wendy.ttf);
}
@lschatzkin
lschatzkin / youtube.css
Created October 1, 2015 21:41
youtube video container css
.video-container {
position: relative;
padding-bottom: 56.25%;
padding-top: 30px; height: 0; overflow: hidden;
}
.video-container iframe,
.video-container object,
.video-container embed {
position: absolute;
@lschatzkin
lschatzkin / WP_Query-count
Created September 28, 2015 18:51
count number of posts in WP_Query results $post_count = $freereads_query->found_posts;
$my_query = new WP_Query($freereads_args);
$post_count = $my_query->found_posts;
git clean -f =>DELETES untracked WARNING!!!!!
git reflog -- summary with commit #, then:
GO BACK TO PREV COMMIT:
git reset ---hard <filename>
REMOVE COMMITTED:
git reset HEAD <file>
UN-ADD files => git reset FILE
RESTORE PREV VER OF 1 FILE=>
<?php
//Nature News loop, featured article with thumbnail
$args = array (
'posts_per_page' => '1',
'page_id' => '4444'
);
$query = new WP_Query( $args );
echo '<h3 class="title">The Title</h3>';
// The Loop
var viewportWidth = $(window).width();
if (viewportWidth < 481){ }
@lschatzkin
lschatzkin / external links
Created June 6, 2014 19:19
add target=_blank to all external links on a site