Monday, 25 January 2016
Sunday, 17 January 2016
wordpress Most important Links
Creating new page template
Copy and paste page.php from in your theame ,
and in top, just add :
Template Name: Home page
Eg:
* The template for displaying pages
* Template Name: Home page
* This is the template that displays all pages by default.
* Please note that this is the WordPress construct of pages and that
* other "pages" on your WordPress site will use a different template.
*
* @package WordPress
* @subpackage Twenty_Fifteen
* @since Twenty Fifteen 1.0
https://codex.wordpress.org/Page_Templates
Get Wordpress links
WordPress Directories:home_url()
Home URL
http://www.example.com
site_url()
Site directory URL
http://www.example.com or http://www.example.com/wordpress
admin_url()
Admin directory URL
http://www.example.com/wp-admin
includes_url()
Includes directory URL
http://www.example.com/wp-includes
content_url()
Content directory URL
http://www.example.com/wp-content
plugins_url()
Plugins directory URL
http://www.example.com/wp-content/plugins
theme_url()
Themes directory URL (#18302)
http://www.example.com/wp-content/themes
wp_upload_dir()
Upload directory URL (returns an array)
http://www.example.com/wp-content/uploads
Creating More Menu
https://codex.wordpress.org/Navigation_MenusNavigation Menus
. WordPress includes an easy to use mechanism for introducing customised navigation menus into a theme. In order to incorporate menu support into your theme, you need to add a few code segments to your theme files.
Function Reference
Register Navigation Menu
register_nav_menus()
register_nav_menu()
unregister_nav_menu()
Show Navigation Menu
has_nav_menu()
wp_nav_menu()
Contents
1 Function Reference
2 Register Menus
3 Display Menus on Theme
4 Menus Panel
5 External Resources
6 Related
Register Menus
Firstly, in your theme's functions.php, you need to write a function to register the names of your menus. (This is how they will appear in the Appearance -> Menus admin screen.) As an example, this menu would appear in the "Theme Locations" box as "Header Menu".
function register_my_menu() {
register_nav_menu('header-menu',__( 'Header Menu' )); }
add_action( 'init', 'register_my_menu' );
And this would make two menu options appear, header menu and extra menu -
function register_my_menus() {
register_nav_menus( array(
'header-menu' => __( 'Header Menu' ),
'extra-menu' => __( 'Extra Menu' ) ) ); }
add_action( 'init', 'register_my_menus' );
Get specific Pages
https://codex.wordpress.org/Function_Reference/is_front_page<?php is_front_page(); ?>
<?php if(is_front_page() || is_home() ) { ?>
<?php } ?>
Contact 7 page redirect url
put the code inon_sent_ok: "location.replace('http://errorfound.in/significance/?page_id=9');"
Nivo slider Defect
Warning : The permissions to the directory /home/username/sitename//wp-content/uploads/nivoslider4wp_files/ are invalid. Set them to 777 to be able to upload files.
First, the path is wrong on line 7 of file nivoslider4wp-panel.php. I changed it from:
$ns4wp_filesdir = ABSPATH.'/wp-content/uploads/nivoslider4wp_files/';
to:
$ns4wp_filesdir = ABSPATH.'wp-content/uploads/nivoslider4wp_files/';
Second, line 274 requires permissions 777 on the folder which is a MAJOR security issue. I changed it from:
<?php if (substr(decoct(fileperms($ns4wp_filesdir)),2) != '777') : ?>
to:
<?php if (substr(decoct(fileperms($ns4wp_filesdir)),2) < '755') : ?>
In my opinion these things need to be changed in the plugin core.
Create Dynamic Sidebar
Paste this code where you want to show..<?php // if ( dynamic_sidebar('sidebar-3') ) : else : endif; ?>
Paste this code in function.php
register_sidebar( array(
'name' => __( 'Secondary Widget Area', 'twentythirteen' ),
'id' => 'sidebar-2',
'description' => __( 'Appears on posts and pages in the sidebar.', 'twentythirteen' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => '</aside>',
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
Theme My Admin
FOR LOGIN PAGE
[theme-my-login default_action=login login_template=tml-login-form.php]
FOR REGISTER PAGE
[theme-my-login show_title=0 default_action=register register_template=tml-register-form.php]
FOR LOST PASSWORD PAGE
[theme-my-login show_title=0 default_action=lostpassword lostpassword_template=tml-lostpassword-form.php]But now I'm not able to replicate this strategy for the profile page.
I've created a WP page for the themed profile and I've putted this shortcode in it's content:
[theme-my-login default_action=profile profile_template=tml-profile-form.php]
Woo Commerce Shortcode
[woocommerce_cart] – shows the cart page[woocommerce_checkout] – shows the checkout page
[woocommerce_pay] – shows the checkout pay page
[woocommerce_thankyou] – shows the order received page
[woocommerce_order_tracking] – shows the order tracking form
[woocommerce_my_account] – shows the user account page
[woocommerce_edit_address] – shows the user account edit address page
[woocommerce_view_order] – shows the user account view order page
[woocommerce_change_password] – shows the change password page
[woocommerce_lost_password] – shows the lost password page
[woocommerce_logout] – shows the logout page
open link in a new window
click on Screen Options (top right), and check the box labelled Link Target under the Show advanced menu properties heading.
Now select the appropriate target for your custom link.
API's
Wonderfull API's
In computer programming, an application programming interface (API) is a set of routines, protocols, and tools for building software applications. An API expresses a software component in terms of its operations, inputs, outputs, and underlying types.
Paypal API
<!-----<!-----------Paypal Button Api Start----------------->
<script src="<?php echo $this->baseUrl() . "/"; ?>assets/myaccount/js/paypal-button.min.js?merchant=MERCHENT ID"
data-button="buynow"
data-name="My product"
data-amount="1.00"
async
></script>
<!-----------Paypal Button Api Ends----------------->
------Paypal Button Api Start----------------->
<script src="<?php echo $this->baseUrl() . "/"; ?>assets/myaccount/js/paypal-button.min.js?merchant=MERCHENT ID"
data-button="buynow"
data-name="My product"
data-amount="1.00"
async
></script>
<!-----------Paypal Button Api Ends----------------->
<script src="<?php echo $this->baseUrl() . "/"; ?>assets/myaccount/js/paypal-button.min.js?merchant=MERCHENT ID"
data-button="buynow"
data-name="My product"
data-amount="1.00"
async
></script>
<!-----------Paypal Button Api Ends----------------->
------Paypal Button Api Start----------------->
<script src="<?php echo $this->baseUrl() . "/"; ?>assets/myaccount/js/paypal-button.min.js?merchant=MERCHENT ID"
data-button="buynow"
data-name="My product"
data-amount="1.00"
async
></script>
<!-----------Paypal Button Api Ends----------------->
Login with facebook API
<!-----------Facebook Lofin with Facebook Start----------------->
<!-- Paste in header Starts ---->
<script>
// This is called with the results from from FB.getLoginStatus().
function statusChangeCallback(response) {
console.log('statusChangeCallback');
console.log(response);
// The response object is returned with a status field that lets the
// app know the current login status of the person.
// Full docs on the response object can be found in the documentation
// for FB.getLoginStatus().
if (response.status === 'connected') {
// Logged into your app and Facebook.
testAPI();
} else if (response.status === 'not_authorized') {
// The person is logged into Facebook, but not your app.
document.getElementById('status').innerHTML = 'Please log ' +
'into this app.';
} else {
// The person is not logged into Facebook, so we're not sure if
// they are logged into this app or not.
document.getElementById('status').innerHTML = 'Please log ' +
'into Facebook.';
}
}
// This function is called when someone finishes with the Login
// Button. See the onlogin handler attached to it in the sample
// code below.
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
window.fbAsyncInit = function() {
FB.init({
appId : 434485136717218,
cookie : true, // enable cookies to allow the server to access
// the session
xfbml : true, // parse social plugins on this page
version : 'v2.2' // use version 2.2
});
// Now that we've initialized the JavaScript SDK, we call
// FB.getLoginStatus(). This function gets the state of the
// person visiting this page and can return one of three states to
// the callback you provide. They can be:
//
// 1. Logged into your app ('connected')
// 2. Logged into Facebook, but not your app ('not_authorized')
// 3. Not logged into Facebook and can't tell if they are logged into
// your app or not.
//
// These three cases are handled in the callback function.
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
};
// Load the SDK asynchronously
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
// Here we run a very simple test of the Graph API after login is
// successful. See statusChangeCallback() for when this call is made.
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Successful login for: ' + response.name);
document.getElementById('status').innerHTML =
'Thanks for logging in, ' + response.name + '!';
});
}
</script>
<!-- Paste in header Ends ---->
<!-- Paste where you want to call button Starts ---->
<fb:login-button scope="public_profile,email" onlogin="checkLoginState();">
</fb:login-button>
<!-- Paste where you want to call button Ends ---->
<!-----------Facebook Lofin with Facebook Ends----------------->
<!-- Paste in header Starts ---->
<script>
// This is called with the results from from FB.getLoginStatus().
function statusChangeCallback(response) {
console.log('statusChangeCallback');
console.log(response);
// The response object is returned with a status field that lets the
// app know the current login status of the person.
// Full docs on the response object can be found in the documentation
// for FB.getLoginStatus().
if (response.status === 'connected') {
// Logged into your app and Facebook.
testAPI();
} else if (response.status === 'not_authorized') {
// The person is logged into Facebook, but not your app.
document.getElementById('status').innerHTML = 'Please log ' +
'into this app.';
} else {
// The person is not logged into Facebook, so we're not sure if
// they are logged into this app or not.
document.getElementById('status').innerHTML = 'Please log ' +
'into Facebook.';
}
}
// This function is called when someone finishes with the Login
// Button. See the onlogin handler attached to it in the sample
// code below.
function checkLoginState() {
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
}
window.fbAsyncInit = function() {
FB.init({
appId : 434485136717218,
cookie : true, // enable cookies to allow the server to access
// the session
xfbml : true, // parse social plugins on this page
version : 'v2.2' // use version 2.2
});
// Now that we've initialized the JavaScript SDK, we call
// FB.getLoginStatus(). This function gets the state of the
// person visiting this page and can return one of three states to
// the callback you provide. They can be:
//
// 1. Logged into your app ('connected')
// 2. Logged into Facebook, but not your app ('not_authorized')
// 3. Not logged into Facebook and can't tell if they are logged into
// your app or not.
//
// These three cases are handled in the callback function.
FB.getLoginStatus(function(response) {
statusChangeCallback(response);
});
};
// Load the SDK asynchronously
(function(d, s, id) {
var js, fjs = d.getElementsByTagName(s)[0];
if (d.getElementById(id)) return;
js = d.createElement(s); js.id = id;
js.src = "//connect.facebook.net/en_US/sdk.js";
fjs.parentNode.insertBefore(js, fjs);
}(document, 'script', 'facebook-jssdk'));
// Here we run a very simple test of the Graph API after login is
// successful. See statusChangeCallback() for when this call is made.
function testAPI() {
console.log('Welcome! Fetching your information.... ');
FB.api('/me', function(response) {
console.log('Successful login for: ' + response.name);
document.getElementById('status').innerHTML =
'Thanks for logging in, ' + response.name + '!';
});
}
</script>
<!-- Paste in header Ends ---->
<!-- Paste where you want to call button Starts ---->
<fb:login-button scope="public_profile,email" onlogin="checkLoginState();">
</fb:login-button>
<!-- Paste where you want to call button Ends ---->
<!-----------Facebook Lofin with Facebook Ends----------------->
Monday, 11 January 2016
Animation iHover is an impressive hover effects collection, powered by pure CSS3, no dependency, work well with Bootstrap 3!
http://gudh.github.io/ihover/dist/
Friday, 2 October 2015
Wordpress Dyanmic Page Calling Code (Most important code for Wordpress site)
Wordpress dyanmic page code
Post code
<?php if ( have_posts() ) : ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
.........................................................................
category id select
<?php if ( have_posts() ) : ?>
<?php query_posts('cat_ID=22'); ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
................................................................................
<?php
$args = array( 'posts_per_page' => 10,'category' => 4);
$lastposts = get_posts( $args );
foreach($lastposts as $post) : setup_postdata($post); ?>
<h3 style="text-transform: uppercase;
font-weight: 600;text-align:center;padding:10px"><?php the_title(); ?></h3>
<p style="font-size:16px;padding:0px 30px"><?php the_content(); ?></p>
<?php endforeach; ?>
.................................................
<?php
require('wp-blog-header.php');
?>
<?php query_posts('showposts=10&cat=4'); ?>
<?php while (have_posts()) : the_post(); ?>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<?php the_content(__('Read more'));?>
<?php endwhile;?>
.........................................................
<?php
$args = array( 'posts_per_page' => 10,'category' => 4);
$lastposts = get_posts( $args );
foreach($lastposts as $post) : setup_postdata($post); ?>
<?php the_title(); ?>
<?php the_excerpt(); ?>
<a href=”<?php the_permalink(); ?>”>Read more…</a>
<?php endforeach; ?>
,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,,
next and prv chose post select category
<ul>
<?php
global $post;
$args = array( 'posts_per_page' => 5, 'offset'=> 1, 'category' => 1 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<li>
<a href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
</li>
<?php endforeach; ?>
</ul>
.............................................................................................
ALL post calling code
<?php
$args = array( 'posts_per_page' => 3 );
$lastposts = get_posts( $args );
foreach($lastposts as $post) : setup_postdata($post); ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_content(); ?>
<?php endforeach; ?>
.....................................................................................
Select category all post display page
<?php
$args = array( 'posts_per_page' => 5,'category' => 24);
$lastposts = get_posts( $args );
foreach($lastposts as $post) : setup_postdata($post); ?>
<h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2>
<?php the_content(); ?>
<?php endforeach; ?>
..............................................................................................
<?php $the_query = new WP_Query( 'showposts=1' ); ?>
<?php while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
<li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></li>
<li><?php the_content(__('(more…)')); ?></li>
<?php endwhile;?>
........................................................................................
Calling image or any link
<?php bloginfo( 'template_url' ); ?>/
<?php bloginfo('template_directory'); ?>/
.........................................................................................
menu calling code
1. <?php wp_nav_menu( array( 'menu' => 'my')); ?> Note: my is name of menu
2. <?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
3. <a href="<?php echo home_url(); ?>">Home</a>
<?php wp_list_pages('title_li='); ?>
..............................................................................................
Sub menu calling code
<?php
$parent = get_post($post->post_parent);
if($parent->post_parent) {
$children = wp_list_pages("title_li=&child_of=".$parent->post_parent."&echo=0&depth=1");
} elseif ($post->post_parent) {
$children = wp_list_pages("title_li=&child_of=".$post->post_parent."&echo=0&depth=1");
} else {
$children = wp_list_pages("title_li=&child_of=".$post->ID."&echo=0&depth=1");
}
if ($children) { ?>
<?php echo $children; ?>
<?php } ?>
............................................................................................
categories menu calling code
<li><a href="<?php echo home_url(); ?>">Home</a></li>
<li><?php wp_list_categories('title_li=&'); ?></li>
......................................................................................
Side bar COde
<?php get_sidebar(); ?>
................................................................................
Search form code
<?php get_search_form(); ?>
............................................................................................
comments calling code
<?php comments_template(); ?>
.............................................................................................
Dynamic page create wordpress code
<?php
/*
Template Name: THE fruit display
*/
?>
<?php get_header(); ?>
In this place puting HTML css code
<?php get_footer(); ?>
........................................................................
Posting code index.php page
<?php if ( have_posts() ) : ?>
<?php twentyeleven_content_nav( 'nav-above' ); ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>
<?php the_content('Read the rest of this entry »'); ?>
<?php endwhile; ?>
<?php twentyeleven_content_nav( 'nav-below' ); ?>
<?php else : ?>
<article id="post-0" class="post no-results not-found">
<header class="entry-header">
<h1 class="entry-title"><?php _e( 'Nothing Found', 'twentyeleven' ); ?></h1>
</header><!-- .entry-header -->
<div class="entry-content">
<p><?php _e( 'Apologies, but no results were found for the requested archive. Perhaps searching will help find a related post.', 'twentyeleven' ); ?></p>
<?php get_search_form(); ?>
</div><!-- .entry-content -->
</article><!-- #post-0 -->
<?php endif; ?>
......................................................................................................................................
page .php file calling post code
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'page' ); ?>
<?php comments_template( '', true ); ?>
<?php endwhile; // end of the loop. ?>
.....................................................................................................................
Dynamic widget code and calling code
create widget code function.php file
<?php register_sidebar( array(
'name' => __( 'Showcase Sidebar', 'twentyeleven' ),
'id' => 'sidebar-2',
'description' => __( 'The sidebar for the optional Showcase Template', 'twentyeleven' ),
'before_widget' => '<aside id="%1$s" class="widget %2$s">',
'after_widget' => "</aside>",
'before_title' => '<h3 class="widget-title">',
'after_title' => '</h3>',
) );
?>
...................................................
calling widget code
<?php if ( is_active_sidebar( 'sidebar-6' ) ) : ?>
<div id="four" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar-6' ); ?>
</div><!-- #third .widget-area -->
<?php endif; ?>
................................................................................................................................
Call all page id wise
<a href="<?php echo get_page_link(40); ?>">Map</a>
Subscribe to:
Posts
(
Atom
)