Skip to content

Instantly share code, notes, and snippets.

@jamiemitchell
jamiemitchell / remove-custom-post-type-slug-from-permalinks.php
Created November 21, 2017 22:04 — forked from kellenmace/remove-custom-post-type-slug-from-permalinks.php
Remove custom post type slug from permalinks in WordPress
<?php
/**
* Remove the slug from published post permalinks. Only affect our custom post type, though.
*/
function gp_remove_cpt_slug( $post_link, $post, $leavename ) {
if ( 'race' != $post->post_type || 'publish' != $post->post_status ) {
return $post_link;
}
@jamiemitchell
jamiemitchell / wp-query-ref.php
Created November 21, 2017 10:17 — forked from luetkemj/wp-query-ref.php
WP: Query $args
<?php
/**
* WordPress Query Comprehensive Reference
* Compiled by luetkemj - luetkemj.com
*
* CODEX: http://codex.wordpress.org/Class_Reference/WP_Query#Parameters
* Source: https://core.trac.wordpress.org/browser/tags/3.9/src/wp-includes/query.php
*/
$args = array(
function custom_post_type_link($permalink, $post, $leavename) {
if (!gettype($post) == 'post') {
return $permalink;
}
switch ($post->post_type) {
case 'slug':
$permalink = get_home_url() . '/' . $post->post_name . '/';
break;
}
@jamiemitchell
jamiemitchell / basicLoop.php
Created November 20, 2017 01:55 — forked from twentyfortysix/basicLoop.php
WP - basic loop
if ( have_posts() ) :
while ( have_posts() ) : the_post();
endwhile;
endif;
@jamiemitchell
jamiemitchell / acf-taxonomy-depth.php
Created November 19, 2017 05:07 — forked from WazzaJB/acf-taxonomy-depth.php
Advanced Custom Fields Taxonomy Depth Location Rule
<?php
//ADD RULE TO SECTION
add_filter('acf/location/rule_types', 'acf_location_rules_types');
function acf_location_rules_types( $choices )
{
$choices['Other']['taxonomy_depth'] = 'Taxonomy Depth';
return $choices;
}
//MATCHING OPERATORS
@jamiemitchell
jamiemitchell / wp_loop_query
Created November 19, 2017 00:14
wp_loop_query
<?php
$term = get_queried_object(); //Получаю текущий обьект запроса
// Узнаю текущий id рубрики
$term_id = $term->term_id;
?>
<?php
$args = array(
'post_type' => 'product',
'product_category' => $term->slug,
@jamiemitchell
jamiemitchell / sidebar-services.php
Created November 18, 2017 07:22 — forked from webpalych/sidebar-services.php
термины и дочерние посты
<ul>
<?php
$tax = 'services_cat';
$args = array(
'taxonomy' => $tax,
'hide_empty' => false,
);
$terms = get_terms( $args );
@jamiemitchell
jamiemitchell / functions.php
Created November 6, 2017 19:49 — forked from etasi/functions.php
Genesis: Display a Fixed Mini Header when Scrolling down in Genesis
add_action( 'genesis_after_header', 'sk_mini_fixed_header' );
/**
* Mini header with a logo image at left and menu at right.
*
* @author Sridhar Katakam
* @link http://sridharkatakam.com/
*/
function sk_mini_fixed_header() { ?>
<div class="mini-header">
<div class="wrap">
@jamiemitchell
jamiemitchell / functions.php
Created October 31, 2017 18:48 — forked from lukecav/functions.php
Hide prices on the shop & category page in WooCommerce and remove add to cart but replace with a view product button
// First, remove Add to Cart Button
remove_action( 'woocommerce_after_shop_loop_item', 'woocommerce_template_loop_add_to_cart', 10 );
// Second, add View Product Button
add_action( 'woocommerce_after_shop_loop_item', 'woocommerce_view_product_button', 10);
function woocommerce_view_product_button() {
global $product;
@jamiemitchell
jamiemitchell / function.php
Created October 27, 2017 00:58 — forked from neilgee/function.php
Off Screen Content with Genesis Theme
<?php
// Enqueue scripts and styles
add_action( 'wp_enqueue_scripts', 'themeprefix_enqueue_scripts_styles' );
function themeprefix_enqueue_scripts_styles() {
wp_enqueue_style( 'themeprefix-ionicons', '//code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css', array(), CHILD_THEME_VERSION );
wp_enqueue_script( 'themeprefix-offscreen', get_stylesheet_directory_uri() . '/js/offscreen.js', array( 'jquery' ), '1.0.0', true );
}