How To Detect That Whether Your Website Is Access By A Mobile Or Not
You did get visitors via mobile but how you can keep a track of that. Well, using the following snippet below will let you detect that whether your website is access through mobile or not.
1 2 3 4 5 6 7 8 9 10 11 |
include('mobile_device_detect.php'); $mobile = mobile_device_detect(); if ($mobile==true) { // Edit this URL to point to the location you'd like to redirect to header( 'Location: http://your-website.com/?theme=Your_Mobile_Theme' ) ; } |
Snippet Source/Credit: WebDesignLedger.com
How To Display Categories Drop-Down Menu In WordPress
The following snippet will let you display categories drop-down menu in WordPress.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 |
<form action="<?php bloginfo('url'); ?>/" method="get" class="dropcats" > <?php $select = wp_dropdown_categories('show_option_none=Επιλέξτε Κατηγορία:&show_count=0&heirarchial=1&orderby=ID&echo=0'); $select = preg_replace("#<select([^>]*)>#", "<select$1 onchange='return this.form.submit()'>", $select); echo $select; ?> <noscript><input type="submit" value="View" /></noscript> </form> |
Snippet Source/Credit: Snipplr
How To Display WordPress Author RSS Feed On Author Pages Only
The following snippet will display the WordPress Author RSS feed on author pages only.
1 |
<?php if (is_author()) { ?><?php $author = get_userdata(get_query_var('author')); ?><link rel="alternate" type="application/rss+xml" title="<?php bloginfo('name'); ?> - <?php echo $author->display_name; ?>" href="<?php bloginfo('url'); ?>/author/<?php echo $author->user_nicename; ?>/feed/" /><?php echo "\n"; } ?> |
Snippet Source/Credit: Snipplr
How To Display Your Tags In A Dropdown Menu In WordPress
You did seen quite a time that you can display your categories in a dropdown menu format but what if you want the same for tags. In this, with the help of following snippet you will be able to display your tags in a dropdown menu in WordPress.
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 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 |
<?php function dropdown_tag_cloud( $args = '' ) { $defaults = array( 'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45, 'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC', 'exclude' => '', 'include' => '' ); $args = wp_parse_args( $args, $defaults ); $tags = get_tags( array_merge($args, array('orderby' => 'count', 'order' => 'DESC')) ); // Always query top tags if ( empty($tags) ) return; $return = dropdown_generate_tag_cloud( $tags, $args ); // Here's where those top tags get sorted according to $args if ( is_wp_error( $return ) ) return false; else echo apply_filters( 'dropdown_tag_cloud', $return, $args ); } function dropdown_generate_tag_cloud( $tags, $args = '' ) { global $wp_rewrite; $defaults = array( 'smallest' => 8, 'largest' => 22, 'unit' => 'pt', 'number' => 45, 'format' => 'flat', 'orderby' => 'name', 'order' => 'ASC' ); $args = wp_parse_args( $args, $defaults ); extract($args); if ( !$tags ) return; $counts = $tag_links = array(); foreach ( (array) $tags as $tag ) { $counts[$tag->name] = $tag->count; $tag_links[$tag->name] = get_tag_link( $tag->term_id ); if ( is_wp_error( $tag_links[$tag->name] ) ) return $tag_links[$tag->name]; $tag_ids[$tag->name] = $tag->term_id; } $min_count = min($counts); $spread = max($counts) - $min_count; if ( $spread <= 0 ) $spread = 1; $font_spread = $largest - $smallest; if ( $font_spread <= 0 ) $font_spread = 1; $font_step = $font_spread / $spread; // SQL cannot save you; this is a second (potentially different) sort on a subset of data. if ( 'name' == $orderby ) uksort($counts, 'strnatcasecmp'); else asort($counts); if ( 'DESC' == $order ) $counts = array_reverse( $counts, true ); $a = array(); $rel = ( is_object($wp_rewrite) && $wp_rewrite->using_permalinks() ) ? ' rel="tag"' : ''; foreach ( $counts as $tag => $count ) { $tag_id = $tag_ids[$tag]; $tag_link = clean_url($tag_links[$tag]); $tag = str_replace(' ', ' ', wp_specialchars( $tag )); $a[] = "\t<option value='$tag_link'>$tag ($count)</option>"; } switch ( $format ) : case 'array' : $return =& $a; break; case 'list' : $return = "<ul class='wp-tag-cloud'>\n\t<li>"; $return .= join("</li>\n\t<li>", $a); $return .= "</li>\n</ul>\n"; break; default : $return = join("\n", $a); break; endswitch; return apply_filters( 'dropdown_generate_tag_cloud', $return, $tags, $args ); } ?> /* "Now, to finalize your dropdown menu you have to open the theme file where you want the list to be displayed (i.e. sidebar.php) and insert the following code:" <select name="tag-dropdown" onchange="document.location.href=this.options[this.selectedIndex].value;"> <option value="#">Liste d'auteurs</option> <?php dropdown_tag_cloud('number=0&order=asc'); ?> </select> */ |
Snippet Source/Credit: WebDesignLedger.com
How To Exclude WordPress Categories On Secondary Front Pages
The following snippet will let you exclude WordPress categories on secondary front pages.
Note: You can change the number “4” below to whichever category you will want to exclude on secondary front pages.
1 2 3 4 5 6 7 |
<?php if ( is_home() ) { query_posts("paged=$paged&cat=-3"); } while (have_posts()) : the_post(); ?> |
Snippet Source/Credit: iamnotgoodartist.com
How To Get Category Slug In WordPress
The following snippet below will let you get category slug in WordPress.
1 2 3 4 5 6 7 8 9 |
if(is_category()) { $cat = get_query_var('cat'); $yourcat = get_category($cat); echo "the slug is" . $yourcat->slug; } |
Snippet Source/Credit: BestWPThemez.com