Skip to content

Instantly share code, notes, and snippets.

@moxdev
moxdev / query-order-taxonomy-title-asc.php
Created February 13, 2019 22:31
Display Taxonomy Posts in Ascending Alphabetical Order By Title #wp
add_action( 'pre_get_posts', 'quantum_custom_property_locations_query_order' );
/**
* Display Taxonomy Property Locations Page in Ascending Alphabetical Order By Title
*
* @link https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts
* @param object $query pre_get_posts WP_Query.
* @return void
*/
function quantum_custom_property_locations_query_order( $query ) {
if ( $query->is_tax( 'property_locations' ) && $query->is_main_query() ) {
@moxdev
moxdev / remove-no-type-radio-buttons-for-taxonomies.php
Created February 13, 2019 22:06
Remove option for no type from radio button for taxonomies plugin #wp #plugins
/**
* Remove option for no type from radio button for taxonomies plugin
*
* @link https://wordpress.org/plugins/radio-buttons-for-taxonomies/
*/
add_filter( 'radio_buttons_for_taxonomies_no_term_property_locations', '__return_FALSE' );
@moxdev
moxdev / remove-archive-from-title.php
Created February 13, 2019 21:58
Removes Archive from the Title of the Archive #wp
/**
* Removes 'Archive:' from title if taxonomy is 'property_locations'
* Used as H1 on Property Locations pages
*/
add_filter(
'get_the_archive_title',
function ( $title ) {
if ( is_tax( 'property_locations' ) ) {
$title = single_cat_title( '', false );
}
@moxdev
moxdev / display-cpt-with-tax-on-archive-page.php
Created February 13, 2019 21:50
Displaying Custom Post Types with Taxonomy on Archive page #wp
add_action( 'pre_get_posts', 'quantum_custom_property_archives' );
/**
* For displaying 'properties' custom post type on the 'property_location' taxonomy pages
* '-1' means unlimited number of custom posts will be displayed
* change '-1' to '5' to limit the number shown to 5 for pagination views
*
* @link https://wpsites.net/web-design/customize-archive-pages-conditionally-using-pre-get-posts/
* @param [type] $query Custom query.
* @return void
*/
@moxdev
moxdev / custom-tax-rewrite-rule.php
Created February 13, 2019 21:21
Custom Taxonomy URL Rewrite Rule #wp
add_action( 'init', 'custom_tax_rewrite_rule', 10, 0 );
/**
* Rewrites the Property Location's url to be '/$slug/'
* Example:
* http://quantum.test/index.php?property_locations=virginia rewrites to
* http://quantum.test/virginia/
*
* @return void
*/
function custom_tax_rewrite_rule() {
@moxdev
moxdev / remove-tax-slug-link.php
Last active February 13, 2019 21:33
Remove Taxonomy Slug From URL #wp
@moxdev
moxdev / _flickity.scss
Last active September 22, 2023 07:45
Home Page Carousel with Text - Flickity Based #wp #jsLibrary
/*! Flickity v2.1.2
https://flickity.metafizzy.co
---------------------------------------------- */
.flickity-enabled {
position: relative;
}
.flickity-enabled:focus {
outline: none;
@moxdev
moxdev / customizer.php
Last active February 14, 2019 17:24
WP Customizer Footer Logo #wp
// Add first
$wp_customize->get_setting( 'logo_icon' )->transport = 'postMessage';
// Add 2nd
/**
* Add a control to upload the Footer Logo.
* Add a setting for the site Footer Logo.
*/
@moxdev
moxdev / acf-contact-info.php
Last active February 13, 2019 21:51
ACF Contact Info #wp #acf
<?php
// Add this to functions.php acf options page
acf_add_options_sub_page(
array(
'page_title' => 'Contact Information',
'menu_title' => 'Contact Info',
'menu_slug' => 'contact-information',
'post_id' => 'contact-information',
@moxdev
moxdev / acf-options-page.php
Last active February 13, 2019 21:51
ACF Options Page Settings #wp #acf
<?php
/**
* Global Site Information
*/
if ( function_exists( 'acf_add_options_page' ) ) {
acf_add_options_page(
array(
'page_title' => 'Global Website Information',
'menu_title' => 'Site Global Info',