Skip to content

Instantly share code, notes, and snippets.

View daviddarke's full-sized avatar
🚀

David Darke daviddarke

🚀
View GitHub Profile
add_action('wp_head', 'remove_one_wpseo_og', 1);
function remove_one_wpseo_og() {
global $post;
if( $post->post_type == 'shorthand_story' ){
remove_action( 'wpseo_head', array( $GLOBALS['wpseo_og'], 'opengraph' ), 30 );
}
}
<?php get_header();
if ( post_password_required( $post->ID ) ) {
echo get_the_password_form();
} else {
while ( have_posts() ) : the_post();
$meta = get_post_meta($post->ID);
?>
@daviddarke
daviddarke / gist:60b472cd85fefbdd44e9a4971a58a64a
Created November 22, 2017 15:33
Clear CPT archives when a CPT single is created or updated
$custom_post_types = array( "my_post" => "my_post");
$max_archive_pages = 0; // 0 == all archive page #s
function post_status( $new_status, $old_status, $post )
{
global $custom_post_types, $max_archive_pages;
if ( array_key_exists( $post->post_type, $custom_post_types ) && ( $new_status === "publish" || $old_status === "publish" ) )
{
@daviddarke
daviddarke / update.sh
Created April 2, 2017 21:27
Search and update all Wordpress composer sites
for d in *; do
if [[ -d $d ]]; then
if [ -f $d/wp-config.php ]; then
siteName=`basename "$d"`
# See if there is a composer file inside the site folder
if [ -f $d/composer.json ]; then
echo " - Updating $siteName"
# echo "Installing Capistrano"
# /home/vagrant/.rbenv/shims/gem install capistrano -q
#
# echo "Updating Composer"
# sudo composer self-update --quiet
echo "*/20 * * * * ~/cron-run.sh >> ~/cron.log 2>&1" >> ~/mycron
# cp /var/www/atomic-scotch-box/* ~/
@daviddarke
daviddarke / wp-cron
Created November 4, 2016 13:43
Add this cron job
*/1 * * * * wget http://www.domain.com/wp-cron.php?doing_wp_cron 2>&1 > /dev/nul
@daviddarke
daviddarke / wp-cron-disable
Last active November 4, 2016 13:29
Disable WP-CRON
define( 'DISABLE_WP_CRON', true );
@daviddarke
daviddarke / structured-data-include.php
Created October 4, 2016 08:25
Wordpress version of Google's structured data
<?php
$post_thumbnail_id = get_post_thumbnail_id($post->ID);
$post_thumbnail_url = wp_get_attachment_image_src( $post_thumbnail_id );
?>
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Article",
"mainEntityOfPage": {
"@type": "WebPage",
{% include 'jsonld/structured-data-single.twig' %}
@daviddarke
daviddarke / structured-data-single.twig
Last active September 23, 2016 09:04
Used for adding structured data to blog post in wordpress
<script type="application/ld+json">
{
"@context": "http://schema.org",
"@type": "Article",
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "{{post.link}}"
},
"headline": "{{ post.title }}",
"image": {