Skip to content

Instantly share code, notes, and snippets.

View aishahenderson's full-sized avatar
:octocat:
Building websites

Aisha Henderson aishahenderson

:octocat:
Building websites
View GitHub Profile
@aishahenderson
aishahenderson / save_post.php
Created June 7, 2018 20:23
WordPress Update and Save Post Dynamically
<?php
add_action( 'save_post', 'modify_post_content' );
function modify_post_content( ) {
$postArgs= array(
'post_type' => 'prime_activities',
'post_parent' => 0,
'date_query' => array(
array(
'after' => 'April 2nd, 2018',
@aishahenderson
aishahenderson / wp_update_post.php
Last active June 7, 2018 14:07
WP Update Post
<?php get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main">
<?php
$update_today = date("Y-m-d",mktime(0,0,0,date("m"),date("d"),date("Y")));
$postArgs= array(
@aishahenderson
aishahenderson / WPSearch-Exclude-Posts.php
Created June 1, 2018 17:24
WPSearch Exclude Posts After a Specified Time Period During Initial Indexing
<?php
function my_searchwp_indexer_unindexed_args( $args ) {
// TODO: customize $args in any way you'd like, see @link https://codex.wordpress.org/Template_Tags/get_posts
// Example 'after' => date('Y-m-d', strtotime('January 1, 2017' ))
$args['date_query'] = array(
'after' => date('Y-m-d', strtotime('-2 years' ))
);
return $args;
}
add_filter( 'searchwp_indexer_unindexed_args', 'my_searchwp_indexer_unindexed_args' );