This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!--Accordion Section--> | |
<?php | |
/* | |
* This is an example of ACF repeater field whose name is "Content Accordion" | |
* and has sub fields: "Accordion Title" & "Accordion Content" | |
*/ | |
$accordions = get_post_meta( get_the_ID(), 'content_accordion', TRUE ); | |
if ( $accordions ) { | |
?> | |
<div class="container"> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Hide given ACF fields on "my_cpt" post_type | |
function my_custom_function() { | |
global $current_screen; | |
if ( 'my_cpt' == $current_screen->post_type ) { | |
?> | |
<script> | |
(function () { | |
var x = document.querySelectorAll("a[data-key='field_5ea76a5ac9b48']"); | |
//change data-key as required |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// Update CSS within Admin Dashboard | |
function admin_style() { | |
wp_enqueue_style( 'admin-styles', get_template_directory_uri() . '/css/admin.min.css' ); | |
//change filename and/or url as required | |
} | |
add_action( 'admin_enqueue_scripts', 'admin_style' ); //load on admin pages | |
add_action('login_enqueue_scripts', 'admin_style'); //load on login page | |
?> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Add class to admin body if user is not an Administrator | |
if( ! current_user_can('administrator') ) { | |
add_filter( 'admin_body_class', 'rw_admin_only_body_class' ); | |
function rw_admin_only_body_class( $classes ) | |
{ | |
$classes = 'admin-readonly'; | |
return $classes; | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Disable ACF on Frontend | |
*/ | |
function disable_acf_on_frontend( $plugins ) { | |
if ( is_admin() ) { | |
return $plugins; | |
} | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//Remove white space at start and end and remove from ACF fields | |
function my_acf_update_value( $value, $post_id, $field ) { | |
if( is_string($value) ) { | |
$value = rtrim($value); | |
$value = ltrim($value); | |
$value = preg_replace('/ /', '', $value); | |
} | |
return $value; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//add custom notification in WP Admin | |
function general_admin_notice(){ | |
global $pagenow; | |
if ( $pagenow == 'post.php' ) { // add/edit pages/files as required | |
//add any custom message here | |
$current_user = wp_get_current_user(); | |
$user_name = $current_user->user_firstname; | |
echo '<div class="notice notice-warning"> | |
<p>Hey <strong>'. $user_name . '.</strong> You are awesome!</p> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
//add custom message box in Dashboard | |
add_action('wp_dashboard_setup', 'custom_dashboard_widgets'); | |
function custom_dashboard_widgets() { | |
wp_add_dashboard_widget('custom_dashboard_id', 'Custom Theme Support', 'custom_dashboard_message'); | |
} | |
function custom_dashboard_message() { | |
echo '<p>Welcome to your Awesome WordPress Theme.</p>'; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
* Remove WP Bloat | |
* Please Note: This removes WP bloat for better performance. Remove or add feaures as necessary | |
*/ | |
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10 ); | |
remove_action( 'template_redirect', 'wp_shortlink_header', 11 ); | |
remove_action('wp_head', 'rsd_link'); //removes EditURI/RSD (Really Simple Discovery) link. | |
remove_action('wp_head', 'wlwmanifest_link'); //removes wlwmanifest (Windows Live Writer) link. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/* | |
In this example, I've created custom post-types called "locations" and custom taxonomy called "state" | |
By default the generated permalink structure would look like this: | |
Locations: <base-url>/locations/<post-slug>/ | |
State: <base-url>/state/<taxonomy-slug>/ | |
But here is what I wanted: | |
1. Replace "locations" with "service-areas" in the permalink for locaitons. | |
2. Permalink structure for "locations" to be: <base-url>/service-areas/<state-slug>/<locations-slug> |
OlderNewer