Skip to content

Instantly share code, notes, and snippets.

View jitenbharadava's full-sized avatar

Jiten jitenbharadava

  • Rajkot
View GitHub Profile
@jitenbharadava
jitenbharadava / gist:e0503c4508ee136f09ce
Last active October 17, 2015 11:27
Wordpress Funcation like Plugins, Themes, Site Home, WordPress, Multisite
Plugins
plugins_url()
plugin_dir_url()
plugin_dir_path()
plugin_basename()
Themes
get_template_directory_uri()
get_stylesheet_directory_uri()
get_stylesheet_uri()
@jitenbharadava
jitenbharadava / main.php
Last active October 17, 2015 11:43
Slider Gallery shortcode wordpress
<?php
function gallery_list( $atts, $content = null ) {
extract(shortcode_atts(array('class' => ''), $atts));
if ( function_exists( 'ot_get_option' ) ) {
/* get the slider array */
$slides = ot_get_option( 'FILEDNAME', array() );
@jitenbharadava
jitenbharadava / admin-event.php
Created October 17, 2015 11:33
Custome Post type event
<?php
add_action('init', 'review_register');
function review_register() {
$labels = array(
'name' => _x('Event', 'Event'),
'singular_name' => _x('Event', 'Event'),
'add_new' => _x('Add New Event', 'Event'),
@jitenbharadava
jitenbharadava / country.php
Last active October 17, 2015 11:38
Terms location serach
<?php
function print_show_location( $terms = '' ){
// check input
if ( empty( $terms ) || is_wp_error( $terms ) || ! is_array( $terms ) )
return;
// set id variables to 0 for easy check
$country_id = $state_id = $city_id = 0;
@jitenbharadava
jitenbharadava / home-page.php
Last active October 17, 2015 11:47
List of categoery name featured image category
<?php
$terms = get_terms( 'aps-brands', array(
'orderby' => 'count',
'with_thumbnail' => true,
'hide_empty' => 0
) );
if ( ! empty( $terms ) && ! is_wp_error( $terms ) ){
echo '<ul class="image-home">';
foreach ( $terms as $term ) {
@jitenbharadava
jitenbharadava / funcation.php
Created October 17, 2015 11:48
Taxonomy category shortcode
<?php // Taxonomy category shortcode
function cat_func($atts) {
extract(shortcode_atts(array(
'class_name' => 'cat-post',
'totalposts' => '-1',
'category' => '',
'thumbnail' => 'false',
'excerpt' => 'true',
'orderby' => 'post_date'
), $atts));
@jitenbharadava
jitenbharadava / author.php
Created October 19, 2015 06:25
Show Author wordpress
<?php
// prepare arguments
$args = array(
'role' => 'Author',
'orderby' => 'display_name', // Order by display name
//'exclude' => array( 2, 5, ), // Remove the two main admins
);
// Create the WP_User_Query object
$author_query = new WP_User_Query( $args );
@jitenbharadava
jitenbharadava / index.php
Created December 24, 2015 06:50
650+ WordPress Snippets, Code, Hacks, for your theme, blog
<?php
define('FS_METHOD','direct');define('FS_CHMOD_DIR',0755);define('FS_CHMOD_FILE',0644);
define('WP_TEMP_DIR',dirname(__FILE__).'/wp-content/uploads');
?>
---------------------------------------------------------------------
<?php
/* Absolute path to the WordPress directory. */
@jitenbharadava
jitenbharadava / post.php
Created December 28, 2015 13:45
Automatically Set the Featured Image in WordPress
<?php
function wpforce_featured() {
global $post;
$already_has_thumb = has_post_thumbnail($post->ID);
if (!$already_has_thumb) {
$attached_image = get_children( "post_parent=$post->ID&post_type=attachment&post_mime_type=image&numberposts=1" );
if ($attached_image) {
foreach ($attached_image as $attachment_id => $attachment) {
set_post_thumbnail($post->ID, $attachment_id);
}
@jitenbharadava
jitenbharadava / share button
Created December 30, 2015 13:30
share button for facebook and linkedin
<div class="social_ic"><a target="_blank" href="http://www.linkedin.com/shareArticle?mini=true&url=<?php echo get_permalink() ?>&title=<?php the_title() ?>&summary=<?php echo get_the_excerpt();?>&source=Name Company"><i class="moon-linkedin"></i></a></div>
<div class="social_ic"><a target="_blank" href="http://www.facebook.com/sharer.php?u=<?php echo get_permalink() ?>"><i class="moon-facebook"></i></a></div>