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
| add_filter( 'post_class', 'post_class_example' ); | |
| function post_class_example( $classes ) { | |
| global $wp_query; | |
| if ( 0 == $wp_query->current_post ) { | |
| $classes[] = 'first-post'; | |
| } | |
| return $classes; | |
| } |
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
| add_filter( 'comment_form_default_fields', 'comment_form_default_fields_example' ); | |
| function comment_form_default_fields_example( $fields ) { | |
| unset( $fields['url'] ); | |
| return $fields; | |
| } |
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
| add_filter( 'login_message', 'login_message_example' ); | |
| function login_message_example( $message ) { | |
| $action = $_REQUEST['action']; | |
| if( $action == 'lostpassword' ) { | |
| $message = '<p class="message">Enter your email address, then check your inbox for the "reset password" link!</p>'; | |
| return $message; | |
| } | |
| return; | |
| } |
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
| ============Register Settings For a Plugin======= | |
| function myplugin_register_settings() { | |
| add_option( 'myplugin_option_name', 'This is my option value.'); | |
| register_setting( 'myplugin_options_group', 'myplugin_option_name', 'myplugin_callback' ); | |
| } | |
| add_action( 'admin_init', 'myplugin_register_settings' ); | |
| ============Creating an Options Page=========== |
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
| Step 1 – Registering the Settings Page====== | |
| //Admin Panel Settings | |
| //Register Settings Function | |
| function theme_settings_init(){ | |
| register_setting( 'theme_settings', 'theme_settings' ); | |
| } | |
| //Add settings to page menu | |
| function add_settings_page() { |
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 create_meta_desc() { | |
| global $post; | |
| if (!is_single()) { return; } | |
| $meta = strip_tags($post->post_content); | |
| $meta = strip_shortcodes($meta); | |
| $meta = str_replace(array("\n", "\r", "\t"), ' ', $meta); | |
| $meta = substr($meta, 0, 125); | |
| echo "<meta name='description' content='$meta' />"; | |
| } | |
| add_action('wp_head', 'create_meta_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
| To create option tree list item metabox=== | |
| array( | |
| 'label' => 'Team Social', | |
| 'id' => 'team_links', | |
| 'type' => 'list-item', | |
| 'section' => 'social_icons_setting', | |
| 'settings' => array( | |
| array( |
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 | |
| global $current_user; | |
| get_currentuserinfo(); | |
| if ($current_user->ID == '') { | |
| //show nothing to user | |
| } | |
| else { | |
| //write code to show menu here | |
| } |