Skip to content

Instantly share code, notes, and snippets.

View clreed87's full-sized avatar

Christopher Reed clreed87

View GitHub Profile
@clreed87
clreed87 / functions.php
Last active February 12, 2018 03:43
Add support for status post format
<?php
// Do not include the opening php tag.
//* Add support for status post format
add_theme_support( ‘post-formats’, array(
‘status’,
) );
@clreed87
clreed87 / functions.php
Last active February 28, 2018 07:12
Remove post title for status posts
<?php
// Do not include the opening php tag.
//* Remove post title for status posts
add_filter( 'post_class', 'crt_remove_status_post_titles' );
function crt_remove_status_post_titles( $classes ) {
if ( has_post_format( 'status' ) ) {
$classes[] = 'hidetitle';
@clreed87
clreed87 / style.css
Created February 12, 2018 01:52
Remove post title for status posts
.hidetitle .entry-title {
display:none;
}
@clreed87
clreed87 / functions.php
Last active March 22, 2018 05:13
Remove post titles in RSS feed for status posts
<?php
// Do not include the opening php tag.
//* Remove post titles in RSS feed for status posts
add_filter( 'the_title_rss', 'crt_change_feed_post_title' );
function crt_change_feed_post_title( $title ) {
if ( has_post_format( 'status' ) ) {
$title = '';
@clreed87
clreed87 / functions.php
Last active February 12, 2018 03:42
Remove status post format from main query unless page is the status archive or an admin screen
<?php
// Do not include the opening php tag.
//* Remove status post format from main query unless page is the status archive or an admin screen
add_filter( 'pre_get_posts', 'crt_remove_status_format' );
function crt_remove_status_format( $query ) {
if ( ! is_tax( 'post_format', 'post-format-status' ) && ! is_search() && ! is_admin() && ! ( defined ( 'XMLRPC_REQUEST' ) && XMLRPC_REQUEST ) ) {
$tax_query = array( array(
@clreed87
clreed87 / functions.php
Last active May 26, 2018 04:55
Change post title to date if no title is provided
<?php
// Do not include the opening php tag.
//* Change post title to date if no title is provided
add_filter( 'wp_insert_post_data', 'crt_update_blank_title' );
function crt_update_blank_title( $data ) {
$title = $data['post_title'];
$post_type = $data['post_type'];
@clreed87
clreed87 / functions.php
Last active May 26, 2018 04:57
Populate image title, alt-text, caption, and description on upload
<?php
// Do not include the opening php tag.
// Populate image title, alt-text, caption, and description on upload
add_action( 'add_attachment', 'crt_set_image_meta' );
function crt_set_image_meta( $post_ID ) {
// Check if uploaded file is an image, else do nothing
if ( wp_attachment_is_image( $post_ID ) ) {
@clreed87
clreed87 / functions.php
Last active February 12, 2018 03:30
Do not trigger Jetpack Publicize if the post uses the 'status' post format
<?php
// Do not include the opening php tag.
//* Do not trigger Jetpack Publicize if the post uses the 'status' post format.
add_filter( 'publicize_should_publicize_published_post', 'crt_control_publicize', 10, 2 );
function crt_control_publicize( $should_publicize, $post ) {
// Return early if we don't have a post yet (it hasn't been saved as a draft)
if ( ! $post ) {