Skip to content

Instantly share code, notes, and snippets.

@stompweb
stompweb / pagination.php
Created June 28, 2012 19:05
WordPress Pagination
<div id="content">
<h1>Ice Creams</h1>
<?php
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$args = array(
'posts_per_page' => 5,
@stompweb
stompweb / filter-events.php
Created June 29, 2012 14:27
Filter events pre_get_posts
// Function to display only upcoming events for Sugar Events Calendar on the main Events archive.
function sc_filter_events( $query ) {
if( is_post_type_archive('sc_event') && (!is_admin()) && ($query->is_main_query()) ) {
$meta = array(
array(
'key' => 'sc_event_date_time',
'value' => time(),
<?php get_header(); ?>
<div class="wrapper">
<div class="full">
<?php hm_the_messages( 'lost-password' ) ?>
<?php if ($_GET["message"] == 'success') { ?>
@stompweb
stompweb / gist:11321145
Last active August 29, 2015 14:00
Change menu classes
<?php
function register_my_page() {
global $my_page;
$my_page = add_menu_page( 'My Page', 'My Page', 'edit_pages', 'my_page.php', 'my_page_hook', 'dashicons-groups', 4 );
}
add_action('admin_menu', 'register_my_page');
function highlight_different_menu($parent_file){
<?php
function s17_redirect_single_posts() {
if (is_single() {
wp_redirect( home_url( '/news/' ), 301 )
exit;
}
}
<?php
function woocommerce_free_delivery_fragment( $fragments ) {
global $woocommerce;
ob_start(); ?>
<div class="promo">Show Promo Area</div>
<?php
@stompweb
stompweb / add_image_size
Created July 4, 2015 09:16
add_image_size
<?php add_image_size( 'front-page-blog', 500, 500 ); ?>
<?php add_image_size( 'blog-image-cropped', 800, 600, true ); ?>
<?php
function stomp_mime_types($mimes) {
$mimes['svg'] = 'image/svg+xml';
return $mimes;
}
add_filter('upload_mimes', 'stomp_mime_types');
How do you add fragments on initial load, such as menus?
How do you use forms to update posts / users?
How do you do authentication so only logged in users can update posts / users