This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // sort by date field showing events after today | |
| function dmc_training_cpt_pre_get_posts( $query ) { | |
| if ( is_admin() || ! $query->is_main_query() ) { return; | |
| } | |
| if ( is_post_type_archive( 'dmc-offer' ) ) | |
| { | |
| $date_now = date( 'Y-m-d H:i' ); | |
| $query->set( 'posts_per_page', -1 ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Shortcode to insert ACF dmc_pullquotes repeater field content from current post. | |
| * | |
| * @param array $atts chooses row to use in the dmc_pullquotes repeater | |
| * @param string $content null | |
| * | |
| * @return string the pullquote content wrapped in a container class | |
| */ | |
| function dmc_acf_pullquote_shortcode( $atts, $content = null ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # rsync wp uploads directory from staging to current site | |
| getups() { | |
| current=${PWD##*/} | |
| cd ~/Sites/$current/wp-content/uploads | |
| rsync -avzW --progress --exclude '*.pdf' $current-s:~/www/wp-content/uploads/* . | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Preload ACF key from wp-config.php into database | |
| function anchor_acf_auto_set_license_keys() { | |
| // Check if ACF is running and ACF Pro key found in wp-config.php | |
| if ( class_exists('acf') && defined('ACF_PRO_KEY') ) { | |
| $save = array( | |
| 'key' => ACF_PRO_KEY, | |
| 'url' => home_url() | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| function anchor_prep { | |
| mkdir ~/scripts | |
| read -p $'\e[31mDatabase name\e[0m: ' dbname | |
| read -p $'\e[31mDatabase password\e[0m: ' dbpw | |
| echo -e "dbpw=$dbpw\ndbuser=$dbname\ndbname=$dbname\nmysqldump --user=\$dbuser --password=\$dbpw --no-create-db --databases \$dbname > ~/public/wp-content/mysql.sql" > ~/scripts/db_backup.sh | |
| chmod +x ~/scripts/db_backup.sh | |
| mkdir ~/downloads | |
| cd ~/downloads | |
| read -p $'\e[31mWP Engine download link\e[0m: ' downloadlink | |
| wget $downloadlink |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| https://wordpress.stackexchange.com/a/224482/131 | |
| #!/bin/bash | |
| FILES=*.txt | |
| for f in $FILES | |
| do | |
| echo "Processing $f file..." | |
| # TEXTFILE = $f | |
| # take action on each file. $f store current file name | |
| # cat $TEXTFILE |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Updating WP-Core on multiple sites: | |
| find /home/*/public_html -name "wp-admin" -execdir /home/wp core update --allow-root \; | |
| Updating plugins on multiple sites: | |
| find /home/*/public_html -name "wp-admin" -execdir /home/wp plugin update-all --allow-root \; | |
| Found here: https://wordpress.stackexchange.com/questions/267592/changing-the-wp-cli-cache-folder |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Example use: bipsum 4 pages | |
| bipsum(){ | |
| curl "https://baconipsum.com/api/?type=meat-and-filler¶s=5&format=html" | wp post generate --post_type=$2 --count=$1 --post_content; | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| global $wpdb; | |
| $dmc_mnm_child_id = $product->get_id(); | |
| $querystr = " | |
| SELECT * | |
| FROM $wpdb->postmeta | |
| WHERE $wpdb->postmeta.meta_key = '_mnm_data' | |
| AND $wpdb->postmeta.meta_value LIKE '%{$dmc_mnm_child_id}%' | |
| "; | |
| $pageposts = $wpdb->get_results( $querystr, OBJECT ); |