This file contains hidden or 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 | |
| function switch_page_template() { | |
| global $post; | |
| // Checks if current post type is a page, rather than a post | |
| if (is_page()) | |
| { | |
| // Checks if page is parent, if yes, return | |
| if ($post->post_parent == 0) | |
| return true; | |
| else if ($post->post_parent != $post->ID) |
This file contains hidden or 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 | |
| // $the_query = new WP_Query( 'showposts=4' ); | |
| $the_query = new WP_query( | |
| array( | |
| 'posts_per_page' => 4, | |
| 'meta_key' => 'featured_facts', | |
| 'orderby' => 'meta_value_num date', | |
| 'order' => DESC | |
| ) | |
| ); |
This file contains hidden or 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
| function my_custom_search_filter( $query ) { | |
| if ( $query->is_search ) { | |
| $query->set( 'post_type', array('post','page') ); | |
| } | |
| return $query; | |
| } | |
| add_filter('pre_get_posts','my_custom_search_filter'); |
This file contains hidden or 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 | |
| /* | |
| * Paginate Advanced Custom Field repeater | |
| */ | |
| if( get_query_var('page') ) { | |
| $page = get_query_var( 'page' ); | |
| } else { | |
| $page = 1; | |
| } |
This file contains hidden or 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 | |
| // Sets the user's display name (always) to first name last name, when it's avail. | |
| add_action ('admin_head','make_display_name_f_name_last_name'); | |
| function make_display_name_f_name_last_name(){ | |
| $users = get_users(array('fields'=>'all')); | |
| foreach($users as $user){ | |
| $user = get_userdata($user->ID); |
This file contains hidden or 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
| # Restrict direct access to PHP files from theme or plugin directories | |
| # Place in root .htaccess file | |
| # Restrict direct access to PHP files from plugin directories | |
| RewriteCond %{REQUEST_URI} !^/wp-content/plugins/file/to/exclude\.php | |
| RewriteCond %{REQUEST_URI} !^/wp-content/plugins/directory/to/exclude/ | |
| RewriteRule wp-content/plugins/(.*\.php)$ - [R=404,L] |
This file contains hidden or 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
| define( 'DISALLOW_FILE_EDIT', true ); |
This file contains hidden or 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
| function custom_meta_box_markup() | |
| { | |
| // custom meta box markup goes here | |
| } | |
| function add_custom_meta_box() | |
| { | |
| add_meta_box("demo-meta-box", "Custom Meta Box", "custom_meta_box_markup", "post", "side", "high", null); | |
| } |
This file contains hidden or 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
| $groups = acf_get_local_field_groups(); | |
| $json = []; | |
| foreach ($groups as $group) { | |
| // Fetch the fields for the given group key | |
| $fields = acf_get_local_fields($group['key']); | |
| // Remove unecessary key value pair with key "ID" | |
| unset($group['ID']); |