Skip to content

Instantly share code, notes, and snippets.

@itzikbenh
itzikbenh / events_template.php
Last active January 9, 2020 20:35
Load WordPress posts via a custom API endpoint with pagination support.
<div class="posts-container">
<?php if ( $the_query->have_posts() ) : while ( $the_query->have_posts() ) : $the_query->the_post(); ?>
<div>
<?php
//Here we group events by event_date and put the date at the top.
$event_date = get_post_meta( $post->ID, 'event_date', true );
if ( $event_date != $date )
{
$event_date_formatted = date( 'l, F jS, Y', strtotime( $event_date ) );
echo "<p class='page-header'><strong>$event_date_formatted</strong></p>";
@BurlesonBrad
BurlesonBrad / move-proceed-to-checkout
Created October 18, 2015 21:44
Get the friggin' Proceed To Checkout button to the TOP of the page (not the bottom!!)
add_action( 'woocommerce_before_cart', 'move_proceed_button' );
function move_proceed_button( $checkout ) {
echo '<a href="' . esc_url( WC()->cart->get_checkout_url() ) . '" class="checkout-button button alt wc-forward" >' . __( 'Proceed to Checkout', 'woocommerce' ) . '</a>';
}
@jb510
jb510 / meanwhile.php
Last active August 29, 2015 14:20 — forked from kovshenin/meanwhile.php
<?php
add_filter( 'pre_comment_content', 'jb_xss_comment_overflow_protection');
function jb_xss_comment_overflow_protection( $content ) {
if ( strlen( $content ) > 64000 ) {
wp_die( 'Invalid comment.' );
}
return $content;
}
@kovshenin
kovshenin / meanwhile.php
Created April 27, 2015 16:18
meanwhile.php
<?php
add_filter( 'pre_comment_content', function( $content ) {
if ( strlen( $content ) > 64000 )
wp_die( 'Invalid comment.' );
return $content;
} );
@secretstache
secretstache / admin-body-class-home.php
Last active August 29, 2015 14:13
Adds a unique body class to the editor screen of a specific page, in this case the home page
add_filter( 'admin_body_class', 'ssm_home_admin_body_class' );
/*
* Adds a body class to target the home page edit screen
*
*/
function ssm_home_admin_body_class( $classes ) {
global $post;
$screen = get_current_screen();
$homepage = get_page_by_title( 'Home' );
@lmartins
lmartins / genesis_attr_add_class.php
Last active September 20, 2022 13:33 — forked from JiveDig/genesis_attr_add_class.php
Add classes and attributes to any element in Genesis
<?php
//* Add class to .site-container
add_filter('genesis_attr_site-container', 'jive_attributes_st_container');
function jive_attributes_st_container($attributes) {
$attributes['class'] .= ' st-container';
return $attributes;
}
//* Add class to .site-inner
add_action('genesis_before_sidebar_widget_area','rb_change_genesis_sidebar');
function rb_change_genesis_sidebar() {
if ( 'tribe_events' == get_post_type() ) {
remove_action( 'genesis_sidebar', 'ss_do_sidebar' ); // remove the Genesis simple sidebars sidebar (this is the one being used now, but if this plugin were deactivated...)
remove_action( 'genesis_sidebar', 'genesis_do_sidebar' ); //remove the default genesis sidebar
add_action( 'genesis_sidebar', 'rb_do_sidebar' ); //add an action hook to call the function for my custom sidebar
}
}
//Function to output my custom sidebar
@kloon
kloon / functions.php
Last active October 16, 2022 16:46
WooCommerce 2.1 variation price, revert to 2.0 format
/**
* Use WC 2.0 variable price format, now include sale price strikeout
*
* @param string $price
* @param object $product
* @return string
*/
function wc_wc20_variation_price_format( $price, $product ) {
// Main Price
$prices = array( $product->get_variation_price( 'min', true ), $product->get_variation_price( 'max', true ) );
@woogist
woogist / woocommerce-customer-order-csv-export-add-additional-columns.php
Created February 6, 2014 03:28
WooCommerce Customer/Order CSV Export: Add additional columns
<?php
// add custom column headers
function wc_csv_export_modify_column_headers( $column_headers ) {
$new_headers = array(
'column_1' => 'Column 1',
'column_2' => 'Column 2',
// add other column headers here in the format column_key => Column Name
);
@nairnwebdesign
nairnwebdesign / genesis-post-titles.php
Created December 28, 2013 07:35
Changing Genesis H1 Post Titles to H2
/*
Changing Genesis H1 Post Titles to H2
*/
add_filter( 'genesis_post_title_output', 'ac_post_title_output', 15 );
function ac_post_title_output( $title )
{ if ( is_home() || is_archive() )
$title = sprintf( '<h1 class="entry-title"><a href="' . get_permalink() . '">%s</a></h1>', apply_filters( 'genesis_post_title_text',get_the_title() ) );
return $title;