Skip to content

Instantly share code, notes, and snippets.

View coderaaron's full-sized avatar

Aaron Graham coderaaron

  • Washington University in St. Louis
  • St. Louis, MO
View GitHub Profile
mysql -e "SELECT c.post_title, c.post_content FROM wp_posts a, wp_postmeta b LEFT JOIN wp_posts c ON c.ID = b.meta_value WHERE a.post_type = 'nav_menu_item' AND b.meta_key = '_menu_item_object_id' AND a.ID = b.post_id ORDER BY a.menu_order" -u wp -pwp diso --xml > test.xml
sed -i -e $'s/&lt;/\</g' test.xml
sed -i -e $'s/&gt;/\>/g' test.xml
sed -i -e $'s/&quot;/\'/g' test.xml
sed -i -e $'s/&amp;/\&/g' test.xml
sed -i -e $'s/<!--[^>]*>//g' test.xml
sed -i -e $'s/<a[^>]*>//g' test.xml
sed -i -e $'s/<img[^>]*>//g' test.xml
sed -i -e $'s/<\/a>//g' test.xml
sed -i -e $'s/ id=\'[^\']*\'//g' test.xml
<?php
$the_query = new WP_Query( array(
'post_type' => 'items',
'tax_query' => array(
array (
'taxonomy' => 'washu_ppi_items_types',
'field' => 'slug',
'terms' => 'apartments',
)
),
sed -i '' -e $'s/&lt;/\</g' Diso\ v2.html && sed -i '' -e $'s/&gt;/\>/g' Diso\ v2.html && sed -i '' -e $'s/&quot;/\'/g' Diso\ v2.html
SELECT
c.post_title,
c.post_content
FROM
wp_posts a,
wp_postmeta b
LEFT JOIN
wp_posts c
ON
c.ID = b.meta_value
@coderaaron
coderaaron / gitmoji.sh
Created June 4, 2019 19:36
Use Emoji in Git commits
function gcap() {
git add . && git commit -m "$*" && git push
}
#bug
function gbug() {
gcap "🐛 BUG: $@"
}
#improvement
function gimp() {
gcap "↗️ IMPROVEMENT: $@"
@coderaaron
coderaaron / rendered-content.php
Last active March 13, 2020 02:34
Convert content with shortcodes to rendered HTML and update post
<?php
define( 'PPI_FOR_EXPORT', 1 );
$a = get_pages();
foreach( $a as $b ) {
$f = $b->ID;
$c = get_post_field( 'post_content', $f );
remove_filter('the_content', 'wpautop');
$d = apply_filters( 'the_content', $c );
$my_post = array(
@coderaaron
coderaaron / WP-page_order.sql
Created February 20, 2018 20:49
Get WordPres pages from database in menu order
SELECT
a.post_title title,
a.post_content content
FROM
(SELECT
m.post_title,
m.post_content,
m.ID,
m.post_parent,
m.menu_order as self_order,
@coderaaron
coderaaron / <multiple>.php
Created February 3, 2017 22:03
How to get a custom WP_Query in the global $post
global $ppi_query;
...
$ppi_query = new WP_Query( $args );
...
global $ppi_query;
global $post;
if ( $ppi_query ==null ) { $ppi_query = $wp_query; }
@coderaaron
coderaaron / <multiple>.php
Created February 3, 2017 22:00
Super-simple partials
require_once( WASHU_PPI_PLUGIN_DIR . 'templates/partials/ppi-loop.php' );
...
require( WASHU_PPI_PLUGIN_DIR . 'templates/partials/' . get_post_type() . '.php' );
@coderaaron
coderaaron / washu-people-places-items.php
Created February 3, 2017 21:58
Load template from theme first, fall back to plugin template
add_filter( 'template_include', array( self::$instance, 'ppi_load_single_template' ), 99 );
...
function ppi_load_single_template( $template ) {
...
if ( is_singular( 'things' ) ) {
// look in child or parent themes for template files first
if ( $theme_template = locate_template( 'single-items.php' ) ) {
$template = $theme_template;
} else {
$template = self::$directories['templates'] . 'single-items.php';