Skip to content

Instantly share code, notes, and snippets.

View mrwweb's full-sized avatar

Mark Root-Wiley mrwweb

View GitHub Profile
@mrwweb
mrwweb / fpw_bug.html
Created March 7, 2015 01:12
fpw problem html
<div class="wrap">
<div class="content-sidebar-wrap">
<main class="content facetwp-template" role="main" itemprop="mainContentOfPage" itemscope="itemscope" itemtype="http://schema.org/Blog">
<div class="archive-description cpt-archive-description">
<h1 class="archive-title">Resource Library</h1>
</div>
<article class="post-398 hai_resources type-hai_resources status-publish has-post-thumbnail entry" itemscope="itemscope" itemtype="http://schema.org/CreativeWork">
<a href="http://localhost/hai/resources/resource-1/" title="Resource #1"><img width="150" height="182" src="http://localhost/hai/wp-content/uploads/2014/10/Unknown1-150x182.jpeg" class="alignright post-image entry-image" alt="Unknown" itemprop="image" /></a>
<header class="entry-header">
<h1 class="entry-title" itemprop="headline"><a href="http://localhost/hai/resources/resource-1/" rel="bookmark">Resource #1</a></h1>
@mrwweb
mrwweb / fpw_debugging.php
Created March 7, 2015 01:13
I'm not seeing any output from these
<?php
add_filter( 'facetwp_pre_filtered_post_ids', 'my_facetwp_pre_filtered_post_ids', 10, 2 );
function my_facetwp_pre_filtered_post_ids( $post_ids, $class ) {
var_dump($post_ids,$class,'hello world');
}
add_filter( 'facetwp_facet_html', 'my_facetwp_facet_html', 10, 2 );
function my_facetwp_facet_html( $output, $params ) {
var_dump($output,$params);
}
@mrwweb
mrwweb / fpw_query_tweaks.php
Last active August 29, 2015 14:16
`DOING_AJAX` check added. Still doesn't work.
<?php
/* For query modification */
add_action( 'pre_get_posts', 'hai_resources_pre_get_posts' );
function hai_resources_pre_get_posts( $query ) {
// stop immediately if we're in the admin or not working with the main query
if( ( is_admin() && ( ! defined( 'DOING_AJAX' ) || ! DOING_AJAX ) ) || !$query->is_main_query() ) {
return;
}
@mrwweb
mrwweb / fpw_facets_genesis_sidebar.php
Created March 7, 2015 01:16
adding fpw facets via a genesis hook (this isn't working, they appear but show 0 results)
<?php
/* add custom sidebar content */
add_action( 'genesis_sidebar', 'hai_resource_library_sidebar' );
function hai_resource_library_sidebar() {
if( is_post_type_archive( 'hai_resources' ) && class_exists( 'FacetWP' ) ) {
echo '<h2>Filter & Search</h2>';
echo '<label>Search: ' . facetwp_display( 'facet', 'library_search' ) . '</label>';
echo 'Countries: ' . facetwp_display( 'facet', 'countries' );
echo 'Topic Areas: ' . facetwp_display( 'facet', 'topic_areas' );
}
{"facets":[{"label":"Categories","name":"categories","type":"checkboxes","source":"tax\/category","parent_term":"","orderby":"count","operator":"and","hierarchical":"no","ghosts":"no","preserve_ghosts":"no","count":"10"},{"label":"Countries","name":"countries","type":"checkboxes","source":"tax\/hai_countries","parent_term":"","orderby":"display_value","operator":"or","hierarchical":"no","ghosts":"yes","preserve_ghosts":"yes","count":"100"},{"label":"Topic Areas","name":"topic_areas","type":"checkboxes","source":"tax\/hai_topics","parent_term":"","orderby":"display_value","operator":"or","hierarchical":"no","ghosts":"yes","preserve_ghosts":"yes","count":"100"},{"label":"Library Search","name":"library_search","type":"search","search_engine":"library_search","placeholder":""}]}
@mrwweb
mrwweb / 1-before.html
Last active August 29, 2015 14:17
WordPress 4.1.1 TinyMCE Remove Formatting Test
<strong>Bold</strong>
<em>Italic</em>
<h2>Heading</h2>
<a href="#">Link</a>
<span style="text-decoration: underline;">Underline</span>
@mrwweb
mrwweb / fpw_read_more_ellipsis_filter_examples.php
Created May 1, 2015 17:11
Change or hide the "..." in the "Read More..." link in Feature a Page Widget 2.0.2
/**
* changes read more link from "Read More..." to "Read More!"
*
* @param string $ellipsis punctionation at end of read more link
*
* @return string new punctuation
*/
add_filter( 'fpw_read_more_ellipsis', 'fpw_change_read_more_ellipsis_to_exclamation' );
function fpw_change_read_more_ellipsis_to_exclamation() {
return '!';
<?php
/*
Plugin Name: A-Z the Tags
Description: Alphabetize the list of tag links
Version: 1.0
Plugin URL: http://wordpress.stackexchange.com/questions/144703/wordpress-the-tags-not-in-alphabetical-order
*/
add_filter( 'term_links-post_tag', 'aztt_sort_tags_alphabetically' );
function aztt_sort_tags_alphabetically( $tags ){
natcasesort( $tags );
@mrwweb
mrwweb / sticky_class_archives.php
Last active December 16, 2015 22:17
Add sticky class to posts in archives
<?php
function {prefix}_post_class( $classes ) {
if( is_archive() && is_sticky() ) {
$classes[] = 'sticky';
}
return $classes;
}
add_filter( 'post_class', '{prefix}_post_class' );
@mrwweb
mrwweb / prefixless_archive_titles.php
Created December 16, 2015 22:35
Simple category and other archive page titles in WordPress 4.1+
<?php
add_filter( 'get_the_archive_title', '{prefix}_cat_title' );
/**
* Remove "Category: " prefix from Category archive pages
*/
function {prefix}_cat_title( $title ) {
if( is_category() ) {
$title = single_cat_title( '', false );
}