Skip to content

Instantly share code, notes, and snippets.

View frankyonnetti's full-sized avatar

Frank Yonnetti frankyonnetti

View GitHub Profile
@frankyonnetti
frankyonnetti / WordPressMultisiteValetDriver.php
Last active February 17, 2021 00:19
Valet - WordPress Multisite ValetDriver #valet #nginx
<?php
/*
Valet driver for Wordpress Multisite
Usage: Drop this file into your ~/.valet/Drivers/ directory
*/
class WordPressMultisiteValetDriver extends WordPressValetDriver
{
@frankyonnetti
frankyonnetti / wordpress-wp-cli.md
Last active May 23, 2021 21:23
WordPress - wp-cli #wordpress #wp-cli
@frankyonnetti
frankyonnetti / wordpress-print_r-debug.php
Last active February 17, 2021 00:21
WordPress - print_r debug #wordpress #debug
<?php
echo '<pre>';
print_r($VAR);
echo '</pre>';
die;
?>
<?php echo '<pre>'; print_r($VAR); echo '</pre>'; ?>
@frankyonnetti
frankyonnetti / wordpress-print-styles.php
Last active February 17, 2021 00:22
WordPress - print styles #wordpress #styles
// functions.php
wp_enqueue_style( 'print-style', get_stylesheet_directory_uri() . '/style-print.css', false, '1.0.0', 'print' );
@frankyonnetti
frankyonnetti / wordpress-page-slug-body-class.php
Last active May 23, 2021 21:18
Wordpress - Page Slug Body Class #wordpress #class
<?php
/**
* Page Slug Body Class
*/
function add_slug_body_class( $classes ) {
global $post;
if (isset($post)) {
$classes[] = $post->post_type . '-' . $post->post_name;
}
@frankyonnetti
frankyonnetti / wordpress-get_categories.php
Last active February 17, 2021 00:23
WordPress - get_categories #wordpress #categories #terms
$taxonomy = 'concerts';
$queried_term = get_query_var($taxonomy);
$terms = get_terms($taxonomy, 'slug='.$queried_term);
if ($terms) {
echo '<ul>';
foreach($terms as $term) {
echo '<li><a href="'.get_term_link($term->slug, $taxonomy).'">'.$term->name.'</a></li>';
}
echo '</ul>';
}
@frankyonnetti
frankyonnetti / wordpress-ACF-expose-fields.php
Last active February 17, 2021 00:24
WordPress - ACF expose fields #wordpress #acf
<?php
$field_key = "field_582cd061fb8e4";
$field = get_field_object($field_key);
if( $field ) {
echo '<select name="' . $field['key'] . '">';
foreach( $field['choices'] as $k => $v ) {
echo '<option value="' . $k . '">' . $v . '</option>';
}
echo '</select>';
@frankyonnetti
frankyonnetti / wordpress--wp-config.php
Last active May 22, 2021 19:53
WordPress - wp-config #worpress #php
<?php
define('WP_DEBUG', true);
define('WP_DEBUG_DISPLAY', true);
define('SAVEQUERIES', true); // additional DB debug details
defined('DISALLOW_FILE_MODS') || define('DISALLOW_FILE_MODS',true); // Disable updates view
define('DB_NAME', '');
define('DB_USER', '');
@frankyonnetti
frankyonnetti / wordpress-shortcode.php
Last active February 17, 2021 00:25
WordPress Shortcode #wordpress #shortcode
<?php echo do_shortcode("[shortcode]"); ?>
@frankyonnetti
frankyonnetti / wordpress-if-blog-list-page.php
Last active February 17, 2021 00:26
WordPress - if blog list page #wordpress #list
<?php
/**
* https://codex.wordpress.org/Conditional_Tags#The_Blog_Page
* There is no conditional tag for the blog list page. You have to use
* both `is_home()` and `is_front_page()` to detect this page. You also
* have to use them in the right order to avoid bugs and to test every
* user configuration.
*/
if (is_front_page() && is_home()) {