Skip to content

Instantly share code, notes, and snippets.

Avatar

Aaron Graham coderaaron

  • Washington University in St. Louis
  • St. Louis, MO
View GitHub Profile
View DisO.sh
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
View content_to_description.php
<?php
$the_query = new WP_Query( array(
'post_type' => 'items',
'tax_query' => array(
array (
'taxonomy' => 'washu_ppi_items_types',
'field' => 'slug',
'terms' => 'apartments',
)
),
View sed.sh
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
View WP-pages_menu_order.sql
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 Jun 4, 2019
Use Emoji in Git commits
View gitmoji.sh
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 Mar 13, 2020
Convert content with shortcodes to rendered HTML and update post
View rendered-content.php
<?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 Feb 20, 2018
Get WordPres pages from database in menu order
View WP-page_order.sql
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 Feb 3, 2017
How to get a custom WP_Query in the global $post
View <multiple>.php
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 Feb 3, 2017
Super-simple partials
View <multiple>.php
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 Feb 3, 2017
Load template from theme first, fall back to plugin template
View washu-people-places-items.php
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';