WordPress WP_ Settings
The snippet let you set some WordPress directories / paths directly to the server name.
1 2 3 4 5 6 7 |
define('WP_SITEURL', 'http://' . $_SERVER['SERVER_NAME'] . '/wordpress'); define('WP_HOME', 'http://' . $_SERVER['SERVER_NAME']); define('WP_CONTENT_DIR', $_SERVER['DOCUMENT_ROOT'] . '/wp-content'); define('WP_CONTENT_URL', 'http://' . $_SERVER['SERVER_NAME'] . '/wp-content'); |
Source: Snipplr
List current post taxonomies and terms
The following snippet will let you list current post taxonomies and terms
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 |
//To list FULL custom taxonomy <?php $taxonomy = 'replace_this_with_taxonomy_name'; $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>'; } ?> //To list ONLY custom taxonomy associated with post: //non-linking, list only: <?php $terms = wp_get_post_terms($post->ID,'replace_this_with_taxonomy_name'); $count = count($terms); if ( $count > 0 ){ echo "<ul>"; foreach ( $terms as $term ) { echo '<li><a href="'.get_term_link($term->slug, 'replace_this_with_taxonomy_name').'">'. $term->name . "</a></li>"; } echo "</ul>"; }?> //links to taxonomy archive: <?php $terms = wp_get_post_terms($post->ID,'replace_this_with_taxonomy_name'); $count = count($terms); if ( $count > 0 ){ echo "<ul>"; foreach ( $terms as $term ) { echo '<li><a href="'.get_term_link($term->slug, 'replace_this_with_taxonomy_name').'">'. $term->name . "</a></li>"; } echo "</ul>"; }?> |
Source: Snipplr
Stop directory index browsing
The following snippet will stop directory index browsing
1 |
Options All -Indexes |
Source: Ubuntuguide
Access Request URI for template reuse
The following snippet will let you access request URI for template reuse
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<?php switch ($wp->request) { case 'directory': get_template_part('content', 'directory'); break; case 'history': get_template_part('content', 'history'); break; default: get_template_part('content', 'default'); }; ?> |
Source: Kovshenin
Change user password in mySQL
The following snippet will let you change user password in mySQL
1 |
UPDATE wp_users SET user_pass = MD5( 'new_password' ) WHERE user_login = 'user_login_name'; |
Source: Snipplr
WordPress default CSS
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 |
.alignnone { margin: 5px 20px 20px 0; } .aligncenter, div.aligncenter { display:block; margin: 5px auto 5px auto; } .alignright { float:right; margin: 5px 0 20px 20px; } .alignleft { float:left; margin: 5px 20px 20px 0; } .aligncenter { display: block; margin: 5px auto 5px auto; } a img.alignright { float:right; margin: 5px 0 20px 20px; } a img.alignnone { margin: 5px 20px 20px 0; } a img.alignleft { float:left; margin: 5px 20px 20px 0; } a img.aligncenter { display: block; margin-left: auto; margin-right: auto } .wp-caption { background: #fff; border: 1px solid #f0f0f0; max-width: 96%; /* Image does not overflow the content area */ padding: 5px 3px 10px; text-align: center; } .wp-caption.alignnone { margin: 5px 20px 20px 0; } .wp-caption.alignleft { margin: 5px 20px 20px 0; } .wp-caption.alignright { margin: 5px 0 20px 20px; } .wp-caption img { border: 0 none; height: auto; margin:0; max-width: 98.5%; padding:0; width: auto; } .wp-caption p.wp-caption-text { font-size:11px; line-height:17px; margin:0; padding:0 4px 5px; } |
Source: WordPressAPI
Form standard WordPress comment
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 |
<div id="respond"> <!-- START TITLE LEAVE A REPLY --> <h2 id="leave-reply">Lascia un commento</h2> <!-- END TITLE LEAVE A REPLY --> <?php if ( get_option('comment_registration') && !$user_ID ) : ?> <!-- START MESSAGE REQUEST REGISTRATION COMMENTS --> <p><?php printf(__('Devi eseguire il <a href="%s">login</a> per inserire un commento.', 'yiw'), get_option('siteurl') . '/wp-login.php?redirect_to=' . urlencode(get_permalink())); ?></p> <!-- END MESSAGE REQUEST REGISTRATION COMMENTS --> <?php else : ?> <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform"> <?php if ( $user_ID ) : ?> <p><?php printf(__('Sei loggato come <a href="%1$s">%2$s</a>.', 'yiw'), get_option('siteurl') . '/wp-admin/profile.php', $user_identity); ?> <a href="<?php echo wp_logout_url(get_permalink()); ?>" title="<?php _e('Log out da questo account', 'yiw'); ?>"><?php _e('Log out »', 'yiw'); ?></a></p> <?php endif; ?> <textarea name="comment" id="comment" cols="100%" rows="10" tabindex="1"></textarea> <?php if ( !$user_ID ) : ?> <p> <label for="author">Nome <?php if ($req) _e(" (richiesto)", 'yiw'); ?></label> </p> <p> <input type="text" name="author" id="author" value="<?php echo $comment_author; ?>" tabindex="2" /> </p> <p> <label for="email">Mail <?php if ($req) _e(" (richiesto)", 'yiw'); ?></label> </p> <p> <input type="text" name="email" id="email" value="<?php echo $comment_author_email; ?>" tabindex="3" /> </p> <p> <label for="url">Website</label> </p> <p> <input type="text" name="url" id="url" value="<?php echo $comment_author_url; ?>" tabindex="4" /> </p> <?php endif; ?> <p> <input name="submit" type="submit" id="submit" tabindex="5" value="Invia Commento" /> <?php comment_id_fields(); ?> </p> <?php do_action('comment_form', $post->ID); ?> </form> <?php endif; ?> </div><!-- #respond --> |
Source: Snipplr