How To Show All Custom Fields For Each WordPress Posts
Using the following snippet, you will be able to show all custom fields for each of WordPress posts.
1 2 3 4 5 6 7 8 9 10 11 12 |
add_action( 'all_admin_notices', 'wpsnipp_show_all_custom_fields' ); function wpsnipp_show_all_custom_fields() { if ( isset( $_GET['post'] ) ) { $post_id = absint( $_GET['post'] ); ?> <div id="message" class="updated"> <h3>All post meta:</h3> <xmp><?php print_r( get_post_meta( $post_id ) ); ?></xmp> </div> <?php } } |
Snippet Source/Credit: WPSnipp
How To Show Or Hide Widgets On Specific WordPress Pages
Using the following snippet, you will be able to show or hide widgets on specific WordPress pages.
1 2 3 4 5 6 7 8 |
add_filter( 'widget_display_callback', 'hide_widget_pages', 10, 3 ); function hide_widget_pages( $instance, $widget, $args ) { if ( $widget->id_base == 'pages' ) { // change 'pages' to widget name if ( !is_page( 'contact' ) ) { // change page name return false; } } } |
Snippet Source/Credit: WPSnipp
WordPress Display Page
Using the following snippet, you will put page directly into your page template.
1 2 3 4 5 |
<?php $id = 1; // page ID to display $p = get_page($id); echo apply_filters('the_content', $p->post_content); ?> |
Snippet Source/Credit: Snipplr
WordPress Login Screen
The following snippet will let you change login logo, login URL and login title.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
// Change login logo function custom_login_logo() { echo '<style type="text/css">h1 a { background: url('.get_bloginfo('template_directory').'http://cdn.css-tricks.com/images/logo-login.gif) 50% 50% no-repeat !important; }</style>'; } add_action('login_head', 'custom_login_logo'); // Change logo URL function change_wp_login_url() { return bloginfo('url'); } add_filter('login_headerurl', 'change_wp_login_url'); // Change login title function change_wp_login_title() { return get_option('blogname'); } add_filter('login_headertitle', 'change_wp_login_title'); |
Snippet Source/Credit: CSS-Tricks
How To Rewrite pagination slug in WordPress
The following snippet will let you rewrite pagination slug in WordPress.
1 2 3 4 5 6 7 |
function custom_pagination_base() { global $wp_rewrite; $wp_rewrite->pagination_base = 'p'; $wp_rewrite->flush_rules(); } add_action('init', 'custom_pagination_base', 1); |
Snippet Source/Credit: Snipplr