Skip to content

Instantly share code, notes, and snippets.

@stompweb
stompweb / rewrite.php
Created March 13, 2017 14:47
Login rewrite
<?php
hm_add_rewrite_rule(
array(
'rewrite' => '^login/?$',
'template' => 'templates/login.php',
'query' => 'posts_per_page=1',
'title_callback' => function() {
return 'Login | ' . get_bloginfo( 'title' );
},
'post_query_properties' => array( 'is_home' => false, 'is_page' => false, 'login' => true ),
@stompweb
stompweb / yoast_breadcrumbs_learndash.php
Created March 4, 2017 10:03
Yoast breadcrumbs for LearnDash
<?php
function stomp_filter_learndash_yoast_breadcrumbs( $links ) {
$course_label = 'Courses';
$labels = get_option( 'learndash_custom_label_settings' );
if ( ! empty( $labels['courses'] ) ) {
$course_label = sanitize_text_field( $labels['courses'] );
}
if ( is_singular( 'sfwd-lessons' ) ) {
<?php
function get_items_by_ids( $post_type = 'post', $post_ids = '' ) {
$items = new WP_Query([
'post_status' => 'publish',
'post_type' => $post_type,
'showposts' => 100,
'post__in' => $post_ids,
'orderby' => 'post__in',
<?php
// parts/results/filters
?>
<div class="filters">
<div class="facets">
<h3>Category</h3>
<?php echo facetwp_display( 'facet', 'categories' ); ?>
<?php get_header(); ?>
<?php get_template_part( 'parts/header/archive' ); ?>
<div class="container">
<section class="listings">
<div class="facetwp-template">
@stompweb
stompweb / search.php
Last active October 10, 2016 12:24 — forked from anonymous/search.php
<?php
$args = array(
'posts_per_page' => 5,
'orderby' => 'post_title',
'order' => 'ASC',
'post_type' => 'tour',
'post_status' => 'publish',
'paged' => $paged
);
@stompweb
stompweb / users.php
Created October 7, 2016 15:19
Shop Roles
<?php
/**
* Add custom member role, created with the same capability as customer.
*/
function courtauld_add_member_role() {
if ( true == get_option( 'member_role_added_7_oct' ) ) {
return;
}
@stompweb
stompweb / order.php
Created September 27, 2016 15:57
Order Classs
<?php
class Order {
public $_order;
public function __construct( $order_id ) {
if ( empty( $order_id ) ) {
throw new Exception( '$order_id empty' );
<?php if($post_fields['places_of_interest']): ?>
<h2>Places of Interest</h2
<?php echo $post_fields['places_of_interest_introduction']; ?>
<?php
foreach($post_fields['places_of_interest'] as $post):
setup_postdata($post);
@stompweb
stompweb / backdrop-test.php
Created September 17, 2016 14:26
Backdrop Test
<?php
function exp_add_notifications( $post_id, $post ) {
if ( 'auto-save' == $post->post_status || 'auto-draft' == $post->post_status ) {
return;
}
$message = get_the_title( $post_id ) . ' was added.';