Month: October 2016

General wordpress

Calling stylesheet of child theme

<?php function scriptschild() { wp_enqueue_style( ‘style’, get_stylesheet_directory_uri() . ‘/css/style.css’); } add_action( ‘wp_enqueue_scripts’, ‘scriptschild’ );

wordpress

Register a sidebar in wordpress

In functions.php add below code <?php register_sidebar(array( ‘name’ => ‘Right Sidebar’, // name of sidebar ‘id’            => ‘rightsidebar’, ‘before_widget’ => ‘<li>’, // style tag before this element ‘after_widget’ => ‘</li>’, ‘before_title’ => ‘<h2 class=”widgetTitle”>’,  // Title class , you can avoid these fields if you never want to be ‘after_title’ => ‘</h2>’, ));  ?>  …

wordpress

Menu registering and usage in WordPress

In functions.php add following code: Here we going to declare two menus header_menu, footer_menu <?php register_nav_menus( array(‘header_Menu’ => __( ‘Header Menu’, ‘themename’ ),’footer_menu’=> __( ‘Footer Menu’, ‘themename’ ) )); ?> Then you can call these menu anywhere as follows: <?php wp_nav_menu(array(‘theme_location’ => ‘header_Menu’)); ?>

wordpress

WordPress Plugin to help Digital products selling

Easy Digital Downloads – eCommerce Payments and Subscriptions made easy

Php

Cross domain issue in php

Use below code on the top of page with other domains URL. <?php header(“Access-Control-Allow-Origin: http://sample.com”); ?> If you want to add multiple cross domains add as follows: <?php $http_origin = $_SERVER[‘HTTP_ORIGIN’]; //To get current server  URL. $urls=array(‘http://sample1.com’,’http://sample2.com’);  //Provide all other doamins as elements of array if(in_array($http_origin,$urls)){ header(“Access-Control-Allow-Origin: $http_origin”); }?>  

wordpress

Creating custom taxonomy for WordPress to specific post type

Add below code inside function.php add_action( ‘init’, ‘taxonomy_create’); function taxonomy_create() { register_taxonomy( ‘imagecategories’, // category name ‘imageslider’,  // post type slug name array( ‘hierarchical’ => true, ‘label’ => ‘Image categories’  // label for that category ) ); }

General

Adding custom post type through functions

add_action( ‘init’, ‘create_posttype’ ); function create_posttype() { register_post_type( ‘imageslider’, array( ‘labels’ => array( ‘name’ => __( ‘Image Slider’ ), ‘singular_name’ => __( ‘Image slider’ ) ), ‘public’ => true, ‘has_archive’ => true, ‘rewrite’ => array(‘slug’ => ‘imageslider’), ‘supports’ => array( ‘title’, ‘editor’, ‘excerpt’, ‘author’, ‘thumbnail’, ‘comments’, ‘revisions’, ‘custom-fields’ ) ) ); }

css

Bootstrap usage using customize option?

You can customize bootstrap outer width, gutter width, number of columns from the bootstrap site and download the css and javascript. URL: http://getbootstrap.com/customize/ Here you need to specify the number of grid-columns in @grid-columns and gutter width in @grid-gutter-width under Grid system. Specify the container width by reducing gutter space in @container-large-desktop under Container sizes. If…

wordpress

How to create a wordpress theme?

Create a folder inside themes folder in wordpress directory. Add following mandatory files inside the theme. style.css index.php function.php Inside style.css at the top add following comments: /* Theme Name: themenamehere Theme URI: www.sample.com Author: author details Author URI: author website url Description: description about theme License: GNU General Public License v2 or later License…

wordpress

How to define css through javascript

Specify the class or id and add style as follows: For single style: $(‘.container’).css(‘height’, ’10px’); For multiple style for a div: $(‘.container’).css({‘font-size’ : ’10px’, ‘width’ : ’30px’, ‘height’ : ’10px’});

Load More