Skip to content

Instantly share code, notes, and snippets.

@JAW-Dev
JAW-Dev / wordpress-split-queried-posts-into-rows.php
Created April 29, 2016 09:28
WordPress - Split queried posts into rows
$query = new WP_Query(array(
'post_type' => 'post',
));
$posts_per_row = 2;
$post_counter = 0;
if( have_posts() ) :
while( $query->have_posts() ) :
$query->the_post();
if( ( ++$post_counter % $posts_per_row ) == 1 || $posts_per_row == 1 ) :
if( $post_counter > 1 ) :
@dcooney
dcooney / alm_remove_image_sizes.php
Last active February 10, 2017 06:26
alm_remove_image_sizes
<?php
// Add in your functions.php file
function alm_remove_image_sizes() {
global $alm_layouts;
remove_filter( 'after_setup_theme', array( $alm_layouts, 'alm_layouts_image_sizes' ) );
}
add_action( 'after_setup_theme', 'alm_remove_image_sizes', 1 ); // Set higher priority
$get_content = get_the_content();
$get_content = strip_tags($get_content);
$content_mini = substr($get_content, 0, 160);
echo $content_mini;
if (strlen($get_content) > 160) {
echo "...";
}
<meta name="title" content="<?php echo get_the_title(); ?>">
<meta name="description" content="<?php echo get_the_excerpt(); ?>">
<meta property='og:locale' content='en_US'/>
<meta property='og:type' content='article'/>
<meta property="og:title" content="<?php echo get_the_title(); ?>"/>
<meta property="og:url" content="<?php echo get_permalink(); ?>"/>
<meta property="og:site_name" content="<?php echo get_bloginfo('name'); ?>"/>
<meta property="og:image" content="<?php $image = wp_get_attachment_image_src(get_post_thumbnail_id()); echo $image[0]; ?>"/>
<meta property="og:description" content="<?php if(is_single()){echo get_the_excerpt();} else{echo get_bloginfo ( 'description' );} ?>"/>
<meta name="twitter:card" content="summary">
@mtigas
mtigas / nginx.conf
Last active March 20, 2025 14:14
Nginx configuration for securedrop.propublica.org. (Based on Ubuntu 13.10 / Nginx 1.4.1 default config.)
# This configuration file is provided on an "as is" basis,
# with no warranties or representations, and any use of it
# is at the user's own risk.
#
# You will need to edit domain name information, IP addresses for
# redirection (at the bottom), SSL certificate and key paths, and
# the "Public-Key-Pins" header. Search for any instance of "TODO".
user www-data;
worker_processes 4;
@plentz
plentz / nginx.conf
Last active May 28, 2026 05:18
Best nginx configuration for improved security(and performance)
# to generate your dhparam.pem file, run in the terminal
openssl dhparam -out /etc/nginx/ssl/dhparam.pem 2048
@pfig
pfig / mkfavicon.sh
Created February 12, 2012 12:01
Make a multi-resolution favicon.ico from a source image, using ImageMagick
#!/bin/bash
# from
# http://bergamini.org/computers/creating-favicon.ico-icon-files-with-imagemagick-convert.html
convert source-WxW.png -resize 256x256 -transparent white favicon-256.png
convert favicon-256.png -resize 16x16 favicon-16.png
convert favicon-256.png -resize 32x32 favicon-32.png
convert favicon-256.png -resize 64x64 favicon-64.png
convert favicon-256.png -resize 128x128 favicon-128.png
@scottmatthewman
scottmatthewman / Add post format to RSS entry title in WordPress 3.x
Created July 18, 2011 12:49
An example of how to tweak WordPress's RSS feed to prefix the title with the relevant post format ('Aside', 'Gallery', 'Video', etc.). Add to functions.php
function add_post_format_to_title_rss( $title )
{
$post_format = get_post_format();
if( false === $post_format )
return $title;
else {
$format_name = get_post_format_string($post_format);
return "{$format_name}: {$title}";
}
}