Month: May 2017

wordpress

Listing all terms in taxonomy in alphabetic order with reference of alphabets

call shortcode [show_taxonomies] Add the following code in your function.php add_shortcode( ‘show_taxonomies’, ‘listing_taxonomies’ ); function listing_taxonomies(){ $terms = get_terms( array( ‘taxonomy’ => ‘writer’,  // taxonomy name ‘orderby’ => ‘name’, ‘hide_empty’ => false, ) ); $tax_list = array(); foreach ( $terms as $term ) { $name = strtolower($term->name); $slug = $term->slug; $first_letter = substr($name, 0, 1);…

wordpress

list terms in a given taxonomy

If we want to list all terms in a taxonomy “writer”: $writers= get_terms( array( ‘taxonomy’ => ‘writer’ ) ); print_r($writers); foreach($writers as $writer){ echo $writer->name.”<br />”; }  

css

Browser Specific styles inside stylesheet itself

style specific mozilla ======== @-moz-document url-prefix() { } style specific chrome ======== @media screen and (-webkit-min-device-pixel-ratio:0) { div{top:0;} }

wordpress

Hiding wp-config from all except our own IP

<files wp-config.php> order allow,deny deny from all # OURIP allow from OURIP </files>

css

Position change effect once hover on the div

Include below css in your stylesheet for hover for the div: .form_social img:hover { box-shadow: 0 10px 20px rgba(0,0,0,0.1); top: -10px; } .form_social img { width: 32px; margin-top: 3px; }

css

Bounce effect for a div once over the mouse on the div using CSS

Add class “bounce” for the div in which you need to add bounce effect, and include below css in your stylesheet: .bounce { display: inline-block; vertical-align: middle; -webkit-transform: translateZ(0); transform: translateZ(0); box-shadow: 0 0 1px rgba(0, 0, 0, 0); -webkit-backface-visibility: hidden; backface-visibility: hidden; -moz-osx-font-smoothing: grayscale; -webkit-transition-duration: 0.5s; transition-duration: 0.5s; } .bounce :hover, .bounce :focus,.bounce:active {…

wordpress

Limit the excerpt with characters in wordpress

function new_excerpt_length($length) { return 150; } add_filter(‘excerpt_length’, ‘new_excerpt_length’);

wordpress

Adding bulk amount of users to wordpress using code

In your function.php add folowing code with all users email ids in args array as one mail id in one line. Or you can split the same using commas. function add_user(){ $args = “sample1@sample.com sample2@sample.com sample3@sample.com “; $pieces=explode(“\n”, $args); foreach($pieces as $piece) { $username = $piece; //username $password = $piece; //password $email = $piece; //email…

wordpress

Adding a new wordpress user using code (function.php)

We can create new user in wordpress using function.php with wp_create_user function. $username =”user_john”; //username $password = “john_pass”; //password $mail =”sample@sample.com”; //email if ( !username_exists( $username )  && !email_exists( $mail ) ) { $user_id = wp_create_user( $username, $password, $mail ); $user = new WP_User( $user_id ); $user->set_role( ‘author’ ); //either of ‘administrator’, ‘subscriber’, ‘editor’, ‘author’,…

Php

How to get index values of an array using php

$topcom=array(‘color’=>’red’,’type’=>’box’,’height’=>’10px’,’weight’=>’2kg’); How to get the properties of this array and its values) foreach ($topcom as $eachindex => $eachvalue){ echo ‘$eachindex’ .”=>”. $eachvalue.”<br />”; }

Load More