Skip to content

Instantly share code, notes, and snippets.

Avatar

Brian Krogsgard krogsgard

View GitHub Profile
@krogsgard
krogsgard / woo-loop-image-wrap.php
Created Jun 29, 2012
WooCommerce insert wrapper around thumbnail images in loop
View woo-loop-image-wrap.php
<?php
/* This snippet removes the action that inserts thumbnails to products in teh loop
* and re-adds the function customized with our wrapper in it.
* It applies to all archives with products.
*
* @original plugin: WooCommerce
* @author of snippet: Brian Krogsard
*/
remove_action( 'woocommerce_before_shop_loop_item_title', 'woocommerce_template_loop_product_thumbnail', 10);
@krogsgard
krogsgard / wp-query-the-right-way.php
Last active Jan 4, 2021
sample custom WP_Query the right way
View wp-query-the-right-way.php
<?php
/*
* WP_Query happy dance
*
* this is a sample WP_Query the right way
*/
$args = array (
'post_type' => 'post',
@krogsgard
krogsgard / custom-field-advanced-body-class.php
Created Jun 20, 2012
add a body class based on a post's custom field value
View custom-field-advanced-body-class.php
<?php
// check for '_my_custom_field' meta key on pages and page parents and add a body class if meta value equals 'some-value'
add_filter('body_class','krogs_custom_field_body_class');
function krogs_custom_field_body_class( $classes ) {
global $post;
@krogsgard
krogsgard / wp-trim-words-example
Created Feb 23, 2012
Example query using wp_trim_words()
View wp-trim-words-example
<div class="info-box">
<?php $krogsquery = new WP_Query( array(
'post_type' => 'post',
'posts_per_page' => 3
)); ?>
<h3 class="info-headline">City News</h3>
<?php while($krogsquery->have_posts()) : $krogsquery->the_post(); ?>
@krogsgard
krogsgard / nav-styles.css
Last active Jun 11, 2019
_s theme navigation Javascript
View nav-styles.css
/* Small menu */
.menu-toggle {
display: none;
cursor: pointer;
}
@media screen and (max-width: 600px) {
.menu-toggle,
.main-navigation.toggled .nav-menu {
display: block;
@krogsgard
krogsgard / wp-cli-delete-comments-from-specific-post.sh
Created Apr 12, 2017
This WP CLI command deletes all comments on a post with ID of "123". You can do other things, like add a "status=spam" or whatever to the comment list command as well.
View wp-cli-delete-comments-from-specific-post.sh
wp comment delete $(wp comment list --post_id=123 --format=ids)
@krogsgard
krogsgard / list-terms-shortcode.php
Created Jun 24, 2012
shortcode list taxonomy terms
View list-terms-shortcode.php
<?php
/**
* Displays a list of terms for a specific taxonomy.
* Based on Justin Tadlock's [entry-terms] shortcode
* Added attribute to not link to the taxonomy
* using wp_get_object_terms() to do so
*
* @author Brian Krogsgard
*
* @access public
@krogsgard
krogsgard / sample-functions-child-theme.php
Last active Nov 2, 2018
jQuery for handling toggle functionality with wp_localize_script ( small_menu_vars.size ) and WordPress.
View sample-functions-child-theme.php
<?php
/**
* krogs_child_theme_new_menu_size function.
*
*/
add_filter( 'krogs_theme_small_menu_size', 'krogs_child_theme_new_menu_size' );
function krogs_child_theme_new_menu_size( $size ) {
$size = 450;
View roadmap.md

This is where we'll collect all the things that need doing on Post Status, in terms of overall goals for improving things. It is not a specific issue tracker, though issues may be referenced from here.

Site goals

Improve user experience!

Checkout and My Account

  • Improve Checkout flow to require fewer and appropriate fields
  • Improve layout of cart/checkout
  • Ensure as much is being auto-filled as possible to reduce barrier for existing customers
@krogsgard
krogsgard / register_rest_fields.php
Last active Sep 1, 2016
Add meta data for a CPT to the REST response. `wp-json/wp/v2/poststatus_partners?_embed`
View register_rest_fields.php
<?php
add_action( 'rest_api_init', function() {
register_rest_field(
array( 'poststatus_partners' ),
'partner_meta',
array(
'get_callback' => 'poststatus_get_restable_field_values_for_partner_meta',
'update_callback' => 'poststatus_update_restable_field_values_for_partner_meta',
'schema' => null,