$category_url = CategoryModel::where('url',$url)->first();$products = ProductModel::where('sub_category_id',$category_url['id']) ->orWhere('category_id',$category_url['id']) ->orWhere('parent_category_id',$category_url['id'])->get();
M
Tuesday, 19 November 2019
Thursday, 4 April 2019
Wednesday, 13 March 2019
conatact us page without plugin
http://wissamdandan.com/how-to-create-a-wordpress-contact-form-without-a-plugin/
https://wordpress.stackexchange.com/questions/299521/creating-a-contact-form-without-a-plugin
https://wordpress.stackexchange.com/questions/299521/creating-a-contact-form-without-a-plugin
Tuesday, 12 March 2019
login page using wordpress
<?php
/*Template Name:login
*/
get_header();
global $user_ID;
global $wpdb;
if(!$user_ID){
// user login logged out state
if($_POST){
$username = $wpdb->escape($_POST['username']);
$password =$wpdb->escape($_POST['password']);
$login_array = array();
$login_array['user_login'] = $username;
$login_array['user_password'] = $password;
$verify_user = wp_signon($login_array,true);
if(!is_wp_error($verify_user)){
echo "<script>window.location = '".site_url()."'</script>";
}else{
echo "invalid input";
}
}else{
}
?>
<form method="post">
<p>
<label for="username">username or email</label>
<input type="text" id="username" name="username" placeholder="username or email">
</p>
<p>
<label for="password">Password</label>
<input type="password" id="password" name="password" placeholder="password">
</p>
<p>
<button type="submit" name="btn_submit">Log In</button>
</p>
</form>
<?php
}else{
}
?>
<?php
get_footer();
?>
/*Template Name:login
*/
get_header();
global $user_ID;
global $wpdb;
if(!$user_ID){
// user login logged out state
if($_POST){
$username = $wpdb->escape($_POST['username']);
$password =$wpdb->escape($_POST['password']);
$login_array = array();
$login_array['user_login'] = $username;
$login_array['user_password'] = $password;
$verify_user = wp_signon($login_array,true);
if(!is_wp_error($verify_user)){
echo "<script>window.location = '".site_url()."'</script>";
}else{
echo "invalid input";
}
}else{
}
?>
<form method="post">
<p>
<label for="username">username or email</label>
<input type="text" id="username" name="username" placeholder="username or email">
</p>
<p>
<label for="password">Password</label>
<input type="password" id="password" name="password" placeholder="password">
</p>
<p>
<button type="submit" name="btn_submit">Log In</button>
</p>
</form>
<?php
}else{
}
?>
<?php
get_footer();
?>
wordpress custom theme development documentation
first downlaod wordpress kit
then extarct and copy this kit and paste on xammp or any local server example with xampp htdocs folder
or wamp www folder then open browser and type localhost with back slash with project name open wodpress configure before create a data base and use this databse file and step by step configure and log in dashboard simple open a default theme so i want a create theme and use
first html template copy and paste in wordpress to wp content then theme folder
create style.css file and index.php file and header and footer separate and screenshot.png i template
.Go to dashboard and apearnce and theme option and show on this template in theme and select the theme
dynamically call-
get_template_directory_uri()/source path;
for security- esc_uri(get_template_directory_uri());
header part dynamic
<!DOCTYPE html>
<html <?php language_attributes(); ?> class="no-js no-svg">
<meta charset="<?php bloginfo( 'charset' ); ?>">
for site title - <?php bloginfo('name') ?>
<title><?php bloginfo('name') ?> | <?php bloginfo('description') ?></title>
another process change title tag -
write on functions.php
add_theme_support('title-tag') and first use the function before end the head tag wp_head();
dynamic css and js -- >
css dynamic for wp_enquee_style($handle,$src,$ver,$media)
and for js wp_enquee_script()
wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); $Infooter if delacare true so this is footer otherwise called header when i declare false and blank
1st create a function in functions.php
example with-
function joy_enquee_scripts()
{
wp_enqueue_style($handle,$src,$deps,$ver,$media) //five parameter are not necessary 1st theree parameter is enough
$handle - this means wich file called id and file name this are uniq
$src - src function get_template_directory after path uri with concatenation
$deps -dependancy means arry this are optioanl
$ver - this are version
$media are optional
}
function flipmart_enqueue_scripts()
{
// Bootstrap Core CSS
wp_enqueue_style( 'bootstrap', get_template_directory_uri().'/assets/css/bootstrap.min.css', array(),
'3.2.0' );
wp_enqueue_style( 'main', get_template_directory_uri().'/assets/css/main.css', array(),
'3.2.0' );
wp_enqueue_style( 'font-awesome', get_template_directory_uri().'/assets/css/font-awesome.css', array(),'3.2.0' );
after get main style sheet which file manualy create when create theme -->
// main css file called theme style sheet
wp_enqueue_style('style',get_stylesheet_uri());
dynamically called js file
wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );
$handle - id or file name
$src= file source
$deps= dependency or array declare with out value just declare
$ver = verson in file name
$in_footer = default false .false means - call data in header and true means call from footer
for latest jquery automatically
wp_enqueue_script('jquery');
// script call
wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );
example-
wp_enqueue_script( 'bootstrap.min', get_template_directory_uri() . '/assets/js/bootstrap.min.js', array(), '3.2.0', true );
if when i declare false so script will show in header show bye view source page
}
add_action('wp_enqueue_scripts','flipmart_enqueue_scripts');
/* create navigation menu */
in declare in functions page ->
function register_my_menus() {
register_nav_menus(
array(
'header-menu' => 'Header Menu',
)
);
}
add_action( 'init', 'register_my_menus' );
then declare call the funtion in ui page
in menu class
<?php
wp_nav_menu(array(
'menu' => 'Header Menu',
'container' => 'ul',
'menu_class' => 'nav nav-tabs',
'echo' => true,
'fallback_cb' => 'wp_page_menu',
'items_wrap' => '<ul data-in="fadeInDown" data-out="fadeOutUp" id="%1$s" class="%2$s">%3$s</ul>',
'item_spacing' => 'preserve',
'depth' => 3,
));
?>
// slider dynamic for php -- >
<?php if(!empty($carousel)) { ?>
<ol class="carousel-indicators">
<?php $ctr = 0; foreach($carousel as $slider_data){?>
<li data-target="#carousel-example-generic" data-slide-to="<?php echo $ctr; ?>" class="<?php if($ctr==0){echo 'active';}?>"></li>
<?php $ctr++; } ?>
</ol>
<?php } ?>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<?php
if(!empty($carousel)) { $count = 0; foreach($carousel as $slider) { $count++; ?>
<div class="item <?= $count == 1? "active" : " " ?> "> <img src="<?= $slider['sliderImage'] ?>" class="img-responsive" alt="<?= $slider['sliderTitle'] ?>"/> </div>
<?php }} ?>
</div>
not empty use -->
<?php echo !empty($productDetails['relatedProducts'])? $productDetails['relatedProducts'] : ""; ?>
/* end */
/* create post */
1st declare functions upper page
add_theme_support('post-thumbnails');
functions.page how to create won post page
example with a gallery post --->
add_action('init', 'codex_slider_init'); //Define function --> this code will write on after ending function name as your choice
function codex_slider_init() //Define function name
{
$labels = array(
'name' => _x('sliders', 'post type general name', 'your-plugin-textdomain'), //Edit
'singular_name' => _x('slider', 'post type singular name', 'your-plugin-textdomain'), //Edit
'add_new' => 'Add New slider', //Edit
'all_items' => 'All sliders', //Edit
'edit_item' => 'Edit slider', //Edit
);
$args = array(
'labels' => $labels,
'description' => __('Description.', 'your-plugin-textdomain'),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array('slug' => 'slider'), //URL Friendly
'capability_type' => 'post', //Post or Page
'has_archive' => true,
'menu_position' => 5,
'supports' => array('title', 'editor', 'thumbnail'),
'menu_icon' => 'dashicons-admin-site' //Icon or Image Location
);
register_post_type('slider', $args); //URL Friendly
}
add_action('init', 'codex_slider_init'); //Define function
then how to call the post in ui template using loop
1st foreach loop delaration -->
<?php
$query_posts = new WP_Query(array(
'post_type' => 'gallary', //Post slug name here
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'ASC',
'posts_per_page' => -1 // -1 = display all
));
if($query_posts->have_posts()): //Check if posts available
$get_posts = $query_posts->get_posts();?>
<div class="container">
<?php foreach ($get_posts as $post):?>
<div class="col-md-4">
<figure class="effect-marley">
<img src="<?php echo get_the_post_thumbnail_url($post->ID);?>" alt="" class="img-responsive"/>
<figcaption>
<h4><?php echo get_the_title($post); ?></h4>
<p><?php the_content(); ?></p>
</figcaption>
</figure>
</div>
<?php endforeach;?>
</div>
<?php endif;?>
</div>
while loop declaration (using default post without own create cpt post page)-->
<?php
while (have_posts()): the_post();
?>
<div class="blog-post wow fadeInUp">
<h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
<?php the_content() ?>
</div>
<?php endwhile;?>
create ui template in page.php this page are automatically create a page
create ui template in single.php are own default post will be fetch
how to post data and fetch using acf pro plugin
1st install and active then
create page name or post name then identify when i will implement
and create field feth data using the_field('slug name') and echo get_field('slug name');
for loop used repeater field then collect repeater slug name eaxmple - in slider image
$slider= get_field('slider slug name');
then i will chek array and not empty likely -
if(arrary($variable name ) && !empty($variablename)):
foreach($variable name as $value):
<h1>echo $variablename['slug name '];
if index page acf data are not show when go to the settings-reading and Your homepage displays
and another ways is declare global $post in functions.php avobe
testimonial page 1st three div are active used custom field----->
<div id="carousel-reviews" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="item active">
<?php
wp_reset_postdata();
$testimonial = get_field('testimonial');
////var_dump($home)
if($testimonial )
{ $i=1;
foreach ($testimonial as $row1) { ?>
<div class="col-md-4 col-sm-6">
<div class="block-text rel zmin">
<a title="" href="#"><?php echo $row1['cont_title']?></a>
<p><?php echo $row1['content'] ?></p>
</div>
</div>
<?php if ($i%3==0 && $i!=count($testimonial)){?>
</div>
<div class="item">
<?php }
$i++;}
}
?>
</div>
</div>
<a class="left carousel-control" href="#carousel-reviews" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#carousel-reviews" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
four div loop in a row using acf pro ----->
<div class="container">
<?php
$faculty = get_field('faculty_content');
if (is_array($faculty) && !empty($faculty)):
$count = 0;
foreach ($faculty as $row) : $count++;
if ($count == 1 || $count % 4 == 1):
?>
<div class="row">
<?php
endif;
?>
<div class="col-sm-6 col-md-3 faculty-block">
<div class="wow fadeInUp " data-wow-delay="0.2s">
<img src="<?php echo $row['image'] ?>" class="img-responsive" alt=""/>
<div class="faculty-details">
<h6><?php echo $row['title'] ?></h6>
<p><?php echo $row['content'] ?></p>
<ul class="social-links">
<li><a href="#" target="_blank"><i class="fa fa-facebook"></i></a></li>
<li><a href="#" target="_blank"><i class="fa fa-google-plus"></i></a></li>
<li><a href="#" target="_blank"><i class="fa fa-linkedin"></i></a></li>
<li><a href="#" target="_blank"><i class="fa fa-twitter"></i></a></li>
</ul>
</div>
</div>
</div>
<?php
if ($count == count($faculty) || $count % 4 == 0):
?>
</div>
<?php
endif;
endforeach;
endif;
?>
<div class="row">
</div>
</div>
Footer page create a one page ---->
use in contact us
write on footer page in the above
first create custom field in contact page for footer then collect data this way
<?php
$contact_page_post = get_page_by_path("contact-us");
?>
and output data in footer page --->
for example in footer title
<?php the_field("about_title",$contact_page_post->ID); ?>
/*remove tool from admin dashboard use this code functions.php*/
function remove_tools_menu_from_dashboard( ){
remove_menu_page('tools.php');
}
add_action( 'admin_menu','remove_tools_menu_from_dashboard');
//function page in write this code
// Add theme support for Custom Logo.
add_theme_support( 'custom-logo', array(
'width' => 250,
'height' => 250,
'flex-width' => true,
) );
then ui page when logo are show
<?php the_custom_logo(); ?>
//end logo part
<----------------------------------woocommerce tutorial---------------------------------------------- --->
https://blog.templatetoaster.com/create-woocommerce-theme/
download woocommerce plugin then active and declare in functions.php write on
*woocommerce_theme_support function* -->
https://github.com/woocommerce/woocommerce/wiki/Declaring-WooCommerce-support-in-themes
https://docs.woocommerce.com/document/third-party-custom-theme-compatibility/
/*woocommerce theme support*/
function woocommerce_support() {
add_theme_support( 'woocommerce' );
}
add_action( 'after_setup_theme', 'woocommerce_support' );
Then page.php are duplicate and renamed in woocommerce.php
then under page.php means woocommerce.php when while condition have post are start an endif beteween
and this are paste or declare -- <?php woocommerce_content(); ?>
for woocommerce style get go the body tag then write <body <?php body_class() ?> >
then category style in ui
wocommerce dummy data download then goto tool option and wordpress downlaod
and import dummy data from wordpress importer option
note:--single shop page and category /shop page are gettting on same template (example woocommerce.php)
if two pages sidebar individual so that are be critical when this are problem are created when
Note: When creating woocommerce.php in your theme’s folder, you will not be able to override the woocommerce/archive-product.php custom template as woocommerce.php has priority over archive-product.php. This is intended to prevent display issues.(archive-product.php are not working when woocommerce.php file create)
Note:-- woocommerce.php are used when shop page and details page layout are same
copy template folder from woocommerce folder and paste on won theme and rename woocommerce
adventage is your template layout priority and function
when upgrade this plugin no problem bcoz copy this file your theme folder
/* get layout in archive-product.php*/
after get header complete i want to add side bar
div element then before tag end div
remove below pagination sidebar option
goto theme root folder then wpconfig ->wp_debug mode are true
then erro show and sidebar.php are not include this side then create sidebar.php file and solve it
then copy left-sidebar with div code from archive.php and paste on sidebar
then dynamic collect sidebar when start sidebar paste the sidebar do_action function when cut the sidebar html code
<?php
/**
* Hook: woocommerce_sidebar.
*
* @hooked woocommerce_get_sidebar - 10
*/
do_action( 'woocommerce_sidebar' );
?>
/* per row three product show */
search on google woocommerce product per row then go to documentation and choos custom theme
and copy the function and paste on functions.php
functions->
/**
* Change number or products per row to 3
*/
add_filter('loop_shop_columns', 'loop_columns', 999);
if (!function_exists('loop_columns')) {
function loop_columns() {
return 3; // 3 products per row
}
}
and change default div with or any style inspect element then copy class paste on theme style.css and you can modify your won style
/* changes add to cart button */
go to the woocommerce folder then loop folder add-to cart file then default add to cart button change
copy template add to cart div with layout and go to the add to cart file from loop
then within sprintf code are copy and paste on html add to cart and replace add to cart button
then save and change the add to cart style and color or any style change in css
/* add to cart button changes specific product example with cart and deal */
search on change woocommerce add cart button text change
https://hastech.company/tutorial/woocommerce/change-add-to-cart-button-text-in-woocommerce/
add_filter( 'woocommerce_product_add_to_cart_text', 'woo_custom_product_add_to_cart_text' ); // 2.1 +
function woo_custom_product_add_to_cart_text() {
global $product;
$product_type=$product->product_type;
switch ($product_type){
case 'external':
return__('Buy Product','woocommerce');
break;
case 'grouped':
return__('View products','woocommerce');
break;
case 'simple':
return__('Add to cart','woocommerce');
break;
case 'variable':
return__('Select options','woocommerce');
break;
deafult;
return__('Read more','woocommerce');
}
}
/**
* Change several of the breadcrumb defaults
*/
Remove default template class layout
and write the woocommerce function
<?php woocommerce_breadcrumb(); ?>
similar template style
search woocommerce_breadcrumb() then select change all things and copy this function
and paste on functions.php
add_filter( 'woocommerce_breadcrumb_defaults', 'flipmart_woocommerce_breadcrumbs' );
function flipmart_woocommerce_breadcrumbs() {
return array(
'delimiter' => ' / ',
'wrap_before' => ' <div class="breadcrumb-inner">
<ul class="list-inline list-unstyled">',
'wrap_after' => '</ul>
</div>',
'before' => '',
'after' => '',
'home' => _x( 'Home', 'breadcrumb', 'woocommerce' ),
);
}
declare this function and passing arguments
first downlaod wordpress kit
then extarct and copy this kit and paste on xammp or any local server example with xampp htdocs folder
or wamp www folder then open browser and type localhost with back slash with project name open wodpress configure before create a data base and use this databse file and step by step configure and log in dashboard simple open a default theme so i want a create theme and use
first html template copy and paste in wordpress to wp content then theme folder
create style.css file and index.php file and header and footer separate and screenshot.png i template
.Go to dashboard and apearnce and theme option and show on this template in theme and select the theme
dynamically call-
get_template_directory_uri()/source path;
for security- esc_uri(get_template_directory_uri());
header part dynamic
<!DOCTYPE html>
<html <?php language_attributes(); ?> class="no-js no-svg">
<meta charset="<?php bloginfo( 'charset' ); ?>">
for site title - <?php bloginfo('name') ?>
<title><?php bloginfo('name') ?> | <?php bloginfo('description') ?></title>
another process change title tag -
write on functions.php
add_theme_support('title-tag') and first use the function before end the head tag wp_head();
dynamic css and js -- >
css dynamic for wp_enquee_style($handle,$src,$ver,$media)
and for js wp_enquee_script()
wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); $Infooter if delacare true so this is footer otherwise called header when i declare false and blank
1st create a function in functions.php
example with-
function joy_enquee_scripts()
{
wp_enqueue_style($handle,$src,$deps,$ver,$media) //five parameter are not necessary 1st theree parameter is enough
$handle - this means wich file called id and file name this are uniq
$src - src function get_template_directory after path uri with concatenation
$deps -dependancy means arry this are optioanl
$ver - this are version
$media are optional
}
function flipmart_enqueue_scripts()
{
// Bootstrap Core CSS
wp_enqueue_style( 'bootstrap', get_template_directory_uri().'/assets/css/bootstrap.min.css', array(),
'3.2.0' );
wp_enqueue_style( 'main', get_template_directory_uri().'/assets/css/main.css', array(),
'3.2.0' );
wp_enqueue_style( 'font-awesome', get_template_directory_uri().'/assets/css/font-awesome.css', array(),'3.2.0' );
after get main style sheet which file manualy create when create theme -->
// main css file called theme style sheet
wp_enqueue_style('style',get_stylesheet_uri());
dynamically called js file
wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );
$handle - id or file name
$src= file source
$deps= dependency or array declare with out value just declare
$ver = verson in file name
$in_footer = default false .false means - call data in header and true means call from footer
for latest jquery automatically
wp_enqueue_script('jquery');
// script call
wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );
example-
wp_enqueue_script( 'bootstrap.min', get_template_directory_uri() . '/assets/js/bootstrap.min.js', array(), '3.2.0', true );
if when i declare false so script will show in header show bye view source page
}
add_action('wp_enqueue_scripts','flipmart_enqueue_scripts');
/* create navigation menu */
in declare in functions page ->
function register_my_menus() {
register_nav_menus(
array(
'header-menu' => 'Header Menu',
)
);
}
add_action( 'init', 'register_my_menus' );
then declare call the funtion in ui page
in menu class
<?php
wp_nav_menu(array(
'menu' => 'Header Menu',
'container' => 'ul',
'menu_class' => 'nav nav-tabs',
'echo' => true,
'fallback_cb' => 'wp_page_menu',
'items_wrap' => '<ul data-in="fadeInDown" data-out="fadeOutUp" id="%1$s" class="%2$s">%3$s</ul>',
'item_spacing' => 'preserve',
'depth' => 3,
));
?>
// slider dynamic for php -- >
<?php if(!empty($carousel)) { ?>
<ol class="carousel-indicators">
<?php $ctr = 0; foreach($carousel as $slider_data){?>
<li data-target="#carousel-example-generic" data-slide-to="<?php echo $ctr; ?>" class="<?php if($ctr==0){echo 'active';}?>"></li>
<?php $ctr++; } ?>
</ol>
<?php } ?>
<!-- Wrapper for slides -->
<div class="carousel-inner">
<?php
if(!empty($carousel)) { $count = 0; foreach($carousel as $slider) { $count++; ?>
<div class="item <?= $count == 1? "active" : " " ?> "> <img src="<?= $slider['sliderImage'] ?>" class="img-responsive" alt="<?= $slider['sliderTitle'] ?>"/> </div>
<?php }} ?>
</div>
not empty use -->
<?php echo !empty($productDetails['relatedProducts'])? $productDetails['relatedProducts'] : ""; ?>
/* end */
/* create post */
1st declare functions upper page
add_theme_support('post-thumbnails');
functions.page how to create won post page
example with a gallery post --->
add_action('init', 'codex_slider_init'); //Define function --> this code will write on after ending function name as your choice
function codex_slider_init() //Define function name
{
$labels = array(
'name' => _x('sliders', 'post type general name', 'your-plugin-textdomain'), //Edit
'singular_name' => _x('slider', 'post type singular name', 'your-plugin-textdomain'), //Edit
'add_new' => 'Add New slider', //Edit
'all_items' => 'All sliders', //Edit
'edit_item' => 'Edit slider', //Edit
);
$args = array(
'labels' => $labels,
'description' => __('Description.', 'your-plugin-textdomain'),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array('slug' => 'slider'), //URL Friendly
'capability_type' => 'post', //Post or Page
'has_archive' => true,
'menu_position' => 5,
'supports' => array('title', 'editor', 'thumbnail'),
'menu_icon' => 'dashicons-admin-site' //Icon or Image Location
);
register_post_type('slider', $args); //URL Friendly
}
add_action('init', 'codex_slider_init'); //Define function
then how to call the post in ui template using loop
1st foreach loop delaration -->
<?php
$query_posts = new WP_Query(array(
'post_type' => 'gallary', //Post slug name here
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'ASC',
'posts_per_page' => -1 // -1 = display all
));
if($query_posts->have_posts()): //Check if posts available
$get_posts = $query_posts->get_posts();?>
<div class="container">
<?php foreach ($get_posts as $post):?>
<div class="col-md-4">
<figure class="effect-marley">
<img src="<?php echo get_the_post_thumbnail_url($post->ID);?>" alt="" class="img-responsive"/>
<figcaption>
<h4><?php echo get_the_title($post); ?></h4>
<p><?php the_content(); ?></p>
</figcaption>
</figure>
</div>
<?php endforeach;?>
</div>
<?php endif;?>
</div>
while loop declaration (using default post without own create cpt post page)-->
<?php
while (have_posts()): the_post();
?>
<div class="blog-post wow fadeInUp">
<h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
<?php the_content() ?>
</div>
<?php endwhile;?>
create ui template in page.php this page are automatically create a page
create ui template in single.php are own default post will be fetch
how to post data and fetch using acf pro plugin
1st install and active then
create page name or post name then identify when i will implement
and create field feth data using the_field('slug name') and echo get_field('slug name');
for loop used repeater field then collect repeater slug name eaxmple - in slider image
$slider= get_field('slider slug name');
then i will chek array and not empty likely -
if(arrary($variable name ) && !empty($variablename)):
foreach($variable name as $value):
<h1>echo $variablename['slug name '];
if index page acf data are not show when go to the settings-reading and Your homepage displays
and another ways is declare global $post in functions.php avobe
testimonial page 1st three div are active used custom field----->
<div id="carousel-reviews" class="carousel slide" data-ride="carousel">
<div class="carousel-inner">
<div class="item active">
<?php
wp_reset_postdata();
$testimonial = get_field('testimonial');
////var_dump($home)
if($testimonial )
{ $i=1;
foreach ($testimonial as $row1) { ?>
<div class="col-md-4 col-sm-6">
<div class="block-text rel zmin">
<a title="" href="#"><?php echo $row1['cont_title']?></a>
<p><?php echo $row1['content'] ?></p>
</div>
</div>
<?php if ($i%3==0 && $i!=count($testimonial)){?>
</div>
<div class="item">
<?php }
$i++;}
}
?>
</div>
</div>
<a class="left carousel-control" href="#carousel-reviews" role="button" data-slide="prev">
<span class="glyphicon glyphicon-chevron-left"></span>
</a>
<a class="right carousel-control" href="#carousel-reviews" role="button" data-slide="next">
<span class="glyphicon glyphicon-chevron-right"></span>
</a>
</div>
four div loop in a row using acf pro ----->
<div class="container">
<?php
$faculty = get_field('faculty_content');
if (is_array($faculty) && !empty($faculty)):
$count = 0;
foreach ($faculty as $row) : $count++;
if ($count == 1 || $count % 4 == 1):
?>
<div class="row">
<?php
endif;
?>
<div class="col-sm-6 col-md-3 faculty-block">
<div class="wow fadeInUp " data-wow-delay="0.2s">
<img src="<?php echo $row['image'] ?>" class="img-responsive" alt=""/>
<div class="faculty-details">
<h6><?php echo $row['title'] ?></h6>
<p><?php echo $row['content'] ?></p>
<ul class="social-links">
<li><a href="#" target="_blank"><i class="fa fa-facebook"></i></a></li>
<li><a href="#" target="_blank"><i class="fa fa-google-plus"></i></a></li>
<li><a href="#" target="_blank"><i class="fa fa-linkedin"></i></a></li>
<li><a href="#" target="_blank"><i class="fa fa-twitter"></i></a></li>
</ul>
</div>
</div>
</div>
<?php
if ($count == count($faculty) || $count % 4 == 0):
?>
</div>
<?php
endif;
endforeach;
endif;
?>
<div class="row">
</div>
</div>
Footer page create a one page ---->
use in contact us
write on footer page in the above
first create custom field in contact page for footer then collect data this way
<?php
$contact_page_post = get_page_by_path("contact-us");
?>
and output data in footer page --->
for example in footer title
<?php the_field("about_title",$contact_page_post->ID); ?>
/*remove tool from admin dashboard use this code functions.php*/
function remove_tools_menu_from_dashboard( ){
remove_menu_page('tools.php');
}
add_action( 'admin_menu','remove_tools_menu_from_dashboard');
//function page in write this code
// Add theme support for Custom Logo.
add_theme_support( 'custom-logo', array(
'width' => 250,
'height' => 250,
'flex-width' => true,
) );
then ui page when logo are show
<?php the_custom_logo(); ?>
//end logo part
<----------------------------------woocommerce tutorial---------------------------------------------- --->
https://blog.templatetoaster.com/create-woocommerce-theme/
download woocommerce plugin then active and declare in functions.php write on
*woocommerce_theme_support function* -->
https://github.com/woocommerce/woocommerce/wiki/Declaring-WooCommerce-support-in-themes
https://docs.woocommerce.com/document/third-party-custom-theme-compatibility/
/*woocommerce theme support*/
function woocommerce_support() {
add_theme_support( 'woocommerce' );
}
add_action( 'after_setup_theme', 'woocommerce_support' );
Then page.php are duplicate and renamed in woocommerce.php
then under page.php means woocommerce.php when while condition have post are start an endif beteween
and this are paste or declare -- <?php woocommerce_content(); ?>
for woocommerce style get go the body tag then write <body <?php body_class() ?> >
then category style in ui
wocommerce dummy data download then goto tool option and wordpress downlaod
and import dummy data from wordpress importer option
note:--single shop page and category /shop page are gettting on same template (example woocommerce.php)
if two pages sidebar individual so that are be critical when this are problem are created when
Note: When creating woocommerce.php in your theme’s folder, you will not be able to override the woocommerce/archive-product.php custom template as woocommerce.php has priority over archive-product.php. This is intended to prevent display issues.(archive-product.php are not working when woocommerce.php file create)
Note:-- woocommerce.php are used when shop page and details page layout are same
copy template folder from woocommerce folder and paste on won theme and rename woocommerce
adventage is your template layout priority and function
when upgrade this plugin no problem bcoz copy this file your theme folder
/* get layout in archive-product.php*/
after get header complete i want to add side bar
div element then before tag end div
remove below pagination sidebar option
goto theme root folder then wpconfig ->wp_debug mode are true
then erro show and sidebar.php are not include this side then create sidebar.php file and solve it
then copy left-sidebar with div code from archive.php and paste on sidebar
then dynamic collect sidebar when start sidebar paste the sidebar do_action function when cut the sidebar html code
<?php
/**
* Hook: woocommerce_sidebar.
*
* @hooked woocommerce_get_sidebar - 10
*/
do_action( 'woocommerce_sidebar' );
?>
/* per row three product show */
search on google woocommerce product per row then go to documentation and choos custom theme
and copy the function and paste on functions.php
functions->
/**
* Change number or products per row to 3
*/
add_filter('loop_shop_columns', 'loop_columns', 999);
if (!function_exists('loop_columns')) {
function loop_columns() {
return 3; // 3 products per row
}
}
and change default div with or any style inspect element then copy class paste on theme style.css and you can modify your won style
/* changes add to cart button */
go to the woocommerce folder then loop folder add-to cart file then default add to cart button change
copy template add to cart div with layout and go to the add to cart file from loop
then within sprintf code are copy and paste on html add to cart and replace add to cart button
then save and change the add to cart style and color or any style change in css
/* add to cart button changes specific product example with cart and deal */
search on change woocommerce add cart button text change
https://hastech.company/tutorial/woocommerce/change-add-to-cart-button-text-in-woocommerce/
add_filter( 'woocommerce_product_add_to_cart_text', 'woo_custom_product_add_to_cart_text' ); // 2.1 +
function woo_custom_product_add_to_cart_text() {
global $product;
$product_type=$product->product_type;
switch ($product_type){
case 'external':
return__('Buy Product','woocommerce');
break;
case 'grouped':
return__('View products','woocommerce');
break;
case 'simple':
return__('Add to cart','woocommerce');
break;
case 'variable':
return__('Select options','woocommerce');
break;
deafult;
return__('Read more','woocommerce');
}
}
/**
* Change several of the breadcrumb defaults
*/
Remove default template class layout
and write the woocommerce function
<?php woocommerce_breadcrumb(); ?>
similar template style
search woocommerce_breadcrumb() then select change all things and copy this function
and paste on functions.php
add_filter( 'woocommerce_breadcrumb_defaults', 'flipmart_woocommerce_breadcrumbs' );
function flipmart_woocommerce_breadcrumbs() {
return array(
'delimiter' => ' / ',
'wrap_before' => ' <div class="breadcrumb-inner">
<ul class="list-inline list-unstyled">',
'wrap_after' => '</ul>
</div>',
'before' => '',
'after' => '',
'home' => _x( 'Home', 'breadcrumb', 'woocommerce' ),
);
}
declare this function and passing arguments
create registration page in wordpress using php
create registration form in wordpress
page createform create
template name
header footer collect and then form validation
then count ==0
then create table
<?php
/*Template Name:registration
*/
get_header();
global $wpdb;
/*form validation*/
if($_POST){
$username= $wpdb->escape($_POST['txtUsername']);
$email= $wpdb->escape($_POST['txtEmail']);
$password= $wpdb->escape($_POST['txtPassword']);
$Confirmpassword= $wpdb->escape($_POST['txtConfirmPassword']);
$error = array();
/*check no space username*/
if(strpos($username,' ') !==FALSE){
$error['username_space'] = "username has no space";
}
if(empty($username)){
$error ['$username_empty'] = "Nedded username must";
}
if(username_exists($username)){
$error['username_exists'] = "username already exists";
}
/*email or valid or not*/
if(!is_email($email)){
$error['email_valid'] = "Email has no valid value";
}
if(email_exists($email)){
$error['email_existence'] = "Email all ready exits";
}
/*password*/
if(strcmp($password, $Confirmpassword)!== 0){
$error['password'] = "not match";
}
if(count($error) == 0){
wp_create_user($username,$password,$email);
echo "user create successfully";
exit();
}else{
print_r($error);
}
// print_r($error);
}
?>
<form method="POST">
<p>
<label>Enter Username</label>
<div>
<input type="text" id="txtUsername" name="txtUsername" placeholder="enter Username">
</div>
</p>
<p>
<label >Enter Email</label>
<div>
<input type="email" id="txtEmail" name="txtEmail" placeholder="enter Email">
</div>
</p><p>
<label>Enter Password</label>
<div>
<input type="password" id="txtPassword" name="txtPassword" placeholder="enter Password">
</div>
</p>
<p>
<label >Enter Confirmpassword</label>
<div>
<input type="password" id="txtConfirmPassword" name="txtConfirmPassword" placeholder="enter Username">
</div>
</p>
<input type="submit" name="btnsubmit" value="submit">
</form>
<?php
get_footer();
?>
Sunday, 3 March 2019
WordPress custom theme development Tutorial
first downlaod wordpress from wordpress website
then extarct and copy this kit and paste on xammp or any local server example with xampp htdocs folder
or wamp www folder then open browser and type localhost with back slash with project name open wodpress configure before create a data base and use this databse file and step by step configure and log in dashboard simple open a default theme so i want a create theme and use
first html template copy and paste in wordpress to wp content then theme folder
create style.css file and index.php file and header and footer separate and screenshot.png i template
.Go to dashboard and appearance and theme option and show on this template in theme and select the theme
dynamically call-
get_template_directory_uri()/source path;
for secure- esc_uri(get_template_directory_uri());
header part dynamic
<!DOCTYPE html>
<html <?php language_attributes(); ?> class="no-js no-svg">
<meta charset="<?php bloginfo( 'charset' ); ?>">
for site title - <?php bloginfo('name') ?>
<title><?php bloginfo('name') ?> | <?php bloginfo('description') ?></title>
another process change title tag -
write on functions.php
add_theme_support('title-tag') and first use the function before end the head tag wp_head();
dynamic css and js
css dynamic for wp_enquee_style($handle,$src,$ver,$media)
and for js wp_enquee_script()
wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); $Infooter if delacare true so this is footer otherwise called header when i declare false and blank
1st create a function in functions.php
example with-
function joy_enquee_scripts()
{
wp_enqueue_style($handle,$src,$deps,$ver,$media) //five parameter are not necessary 1st theree parameter is enough
$handle - this means wich file called id and file name this are uniq
$src - src function get_template_directory after path uri with concatenation
$deps -dependancy means arry this are optioanl
$ver - this are version
$media are optional
}
function flipmart_enqueue_scripts()
{
// Bootstrap Core CSS
wp_enqueue_style( 'bootstrap', get_template_directory_uri().'/assets/css/bootstrap.min.css', array(),
'3.2.0' );
wp_enqueue_style( 'main', get_template_directory_uri().'/assets/css/main.css', array(),
'3.2.0' );
wp_enqueue_style( 'font-awesome', get_template_directory_uri().'/assets/css/font-awesome.css', array(),'3.2.0' );
after get main style sheet which file manualy create when create theme -->
main css file called theme style sheet
wp_enqueue_style('style',get_stylesheet_uri());
dynamically called js file
wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );
$handle - id or file name
$src= file source
$deps= dependency or array declare with out value just declare
$ver = verson in file name
$in_footer = default false .false means - call data in header and true means call from footer
for latest jquery from wordpress automatically added
wp_enqueue_script('jquery');
script call
wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );
example-
wp_enqueue_script( 'bootstrap.min', get_template_directory_uri() . '/assets/js/bootstrap.min.js', array(), '3.2.0', true );
if when i declare false so script will show in header show bye view source page
}
add_action('wp_enqueue_scripts','flipmart_enqueue_scripts');
create navigation menu
in declare in functions page ->
function register_my_menus() {
register_nav_menus(
array(
'header-menu' => 'Header Menu',
)
);
}
add_action( 'init', 'register_my_menus' );
then declare call the funtion in ui page
in menu class
<?php
wp_nav_menu(array(
'menu' => 'Header Menu',
'container' => 'ul',
'menu_class' => 'nav nav-tabs',
'echo' => true,
'fallback_cb' => 'wp_page_menu',
'items_wrap' => '<ul data-in="fadeInDown" data-out="fadeOutUp" id="%1$s" class="%2$s">%3$s</ul>',
'item_spacing' => 'preserve',
'depth' => 3,
));
?>
/* create post */
1st declare functions upper page
add_theme_support('post-thumbnails');
functions.page how to create won post page
example with a gallery post --->
add_action('init', 'codex_slider_init'); //Define function --> this code will write on after ending function name as your choice
function codex_slider_init() //Define function name
{
$labels = array(
'name' => _x('sliders', 'post type general name', 'your-plugin-textdomain'), //Edit
'singular_name' => _x('slider', 'post type singular name', 'your-plugin-textdomain'), //Edit
'add_new' => 'Add New slider', //Edit
'all_items' => 'All sliders', //Edit
'edit_item' => 'Edit slider', //Edit
);
$args = array(
'labels' => $labels,
'description' => __('Description.', 'your-plugin-textdomain'),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array('slug' => 'slider'), //URL Friendly
'capability_type' => 'post', //Post or Page
'has_archive' => true,
'menu_position' => 5,
'supports' => array('title', 'editor', 'thumbnail'),
'menu_icon' => 'dashicons-admin-site' //Icon or Image Location
);
register_post_type('slider', $args); //URL Friendly
}
add_action('init', 'codex_slider_init'); //Define function
then how to call the post in ui template using loop
1st foreach loop delaration -->
<?php
$query_posts = new WP_Query(array(
'post_type' => 'gallary', //Post slug name here
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'ASC',
'posts_per_page' => -1 // -1 = display all
));
if($query_posts->have_posts()): //Check if posts available
$get_posts = $query_posts->get_posts();?>
<div class="container">
<?php foreach ($get_posts as $post):?>
<div class="col-md-4">
<figure class="effect-marley">
<img src="<?php echo get_the_post_thumbnail_url($post->ID);?>" alt="" class="img-responsive"/>
<figcaption>
<h4><?php echo get_the_title($post); ?></h4>
<p><?php the_content(); ?></p>
</figcaption>
</figure>
</div>
<?php endforeach;?>
</div>
<?php endif;?>
</div>
while loop declaration (using default post without own create cpt post page)-->
<?php
while (have_posts()): the_post();
?>
<div class="blog-post wow fadeInUp">
<h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
<?php the_content() ?>
</div>
<?php endwhile;?>
create ui template in page.php this page are automatically create a page
create ui template in single.php are own default post will be fetch
how to post data and fetch using acf pro plugin
1st install and active then
create page name or post name then identify when i will implement
and create field feth data using the_field('slug name') and echo get_field('slug name');
for loop used repeater field then collect repeater slug name eaxmple - in slider image
$slider= get_field('slider slug name');
then i will chek array and not empty likely -
if(arrary($variable name ) && !empty($variablename)):
foreach($variable name as $value):
<h1>echo $variablename['slug name '];
if index page acf data are not show when go to the settings-reading and Your homepage displays
and another ways is declare global $post in functions.php avobe
first downlaod wordpress from wordpress website
then extarct and copy this kit and paste on xammp or any local server example with xampp htdocs folder
or wamp www folder then open browser and type localhost with back slash with project name open wodpress configure before create a data base and use this databse file and step by step configure and log in dashboard simple open a default theme so i want a create theme and use
first html template copy and paste in wordpress to wp content then theme folder
create style.css file and index.php file and header and footer separate and screenshot.png i template
.Go to dashboard and appearance and theme option and show on this template in theme and select the theme
dynamically call-
get_template_directory_uri()/source path;
for secure- esc_uri(get_template_directory_uri());
header part dynamic
<!DOCTYPE html>
<html <?php language_attributes(); ?> class="no-js no-svg">
<meta charset="<?php bloginfo( 'charset' ); ?>">
for site title - <?php bloginfo('name') ?>
<title><?php bloginfo('name') ?> | <?php bloginfo('description') ?></title>
another process change title tag -
write on functions.php
add_theme_support('title-tag') and first use the function before end the head tag wp_head();
dynamic css and js
css dynamic for wp_enquee_style($handle,$src,$ver,$media)
and for js wp_enquee_script()
wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); $Infooter if delacare true so this is footer otherwise called header when i declare false and blank
1st create a function in functions.php
example with-
function joy_enquee_scripts()
{
wp_enqueue_style($handle,$src,$deps,$ver,$media) //five parameter are not necessary 1st theree parameter is enough
$handle - this means wich file called id and file name this are uniq
$src - src function get_template_directory after path uri with concatenation
$deps -dependancy means arry this are optioanl
$ver - this are version
$media are optional
}
function flipmart_enqueue_scripts()
{
// Bootstrap Core CSS
wp_enqueue_style( 'bootstrap', get_template_directory_uri().'/assets/css/bootstrap.min.css', array(),
'3.2.0' );
wp_enqueue_style( 'main', get_template_directory_uri().'/assets/css/main.css', array(),
'3.2.0' );
wp_enqueue_style( 'font-awesome', get_template_directory_uri().'/assets/css/font-awesome.css', array(),'3.2.0' );
after get main style sheet which file manualy create when create theme -->
main css file called theme style sheet
wp_enqueue_style('style',get_stylesheet_uri());
dynamically called js file
wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer );
$handle - id or file name
$src= file source
$deps= dependency or array declare with out value just declare
$ver = verson in file name
$in_footer = default false .false means - call data in header and true means call from footer
for latest jquery from wordpress automatically added
wp_enqueue_script('jquery');
script call
wp_enqueue_script( 'script-name', get_template_directory_uri() . '/js/example.js', array(), '1.0.0', true );
example-
wp_enqueue_script( 'bootstrap.min', get_template_directory_uri() . '/assets/js/bootstrap.min.js', array(), '3.2.0', true );
if when i declare false so script will show in header show bye view source page
}
add_action('wp_enqueue_scripts','flipmart_enqueue_scripts');
create navigation menu
in declare in functions page ->
function register_my_menus() {
register_nav_menus(
array(
'header-menu' => 'Header Menu',
)
);
}
add_action( 'init', 'register_my_menus' );
then declare call the funtion in ui page
in menu class
<?php
wp_nav_menu(array(
'menu' => 'Header Menu',
'container' => 'ul',
'menu_class' => 'nav nav-tabs',
'echo' => true,
'fallback_cb' => 'wp_page_menu',
'items_wrap' => '<ul data-in="fadeInDown" data-out="fadeOutUp" id="%1$s" class="%2$s">%3$s</ul>',
'item_spacing' => 'preserve',
'depth' => 3,
));
?>
/* create post */
1st declare functions upper page
add_theme_support('post-thumbnails');
functions.page how to create won post page
example with a gallery post --->
add_action('init', 'codex_slider_init'); //Define function --> this code will write on after ending function name as your choice
function codex_slider_init() //Define function name
{
$labels = array(
'name' => _x('sliders', 'post type general name', 'your-plugin-textdomain'), //Edit
'singular_name' => _x('slider', 'post type singular name', 'your-plugin-textdomain'), //Edit
'add_new' => 'Add New slider', //Edit
'all_items' => 'All sliders', //Edit
'edit_item' => 'Edit slider', //Edit
);
$args = array(
'labels' => $labels,
'description' => __('Description.', 'your-plugin-textdomain'),
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'query_var' => true,
'rewrite' => array('slug' => 'slider'), //URL Friendly
'capability_type' => 'post', //Post or Page
'has_archive' => true,
'menu_position' => 5,
'supports' => array('title', 'editor', 'thumbnail'),
'menu_icon' => 'dashicons-admin-site' //Icon or Image Location
);
register_post_type('slider', $args); //URL Friendly
}
add_action('init', 'codex_slider_init'); //Define function
then how to call the post in ui template using loop
1st foreach loop delaration -->
<?php
$query_posts = new WP_Query(array(
'post_type' => 'gallary', //Post slug name here
'post_status' => 'publish',
'orderby' => 'date',
'order' => 'ASC',
'posts_per_page' => -1 // -1 = display all
));
if($query_posts->have_posts()): //Check if posts available
$get_posts = $query_posts->get_posts();?>
<div class="container">
<?php foreach ($get_posts as $post):?>
<div class="col-md-4">
<figure class="effect-marley">
<img src="<?php echo get_the_post_thumbnail_url($post->ID);?>" alt="" class="img-responsive"/>
<figcaption>
<h4><?php echo get_the_title($post); ?></h4>
<p><?php the_content(); ?></p>
</figcaption>
</figure>
</div>
<?php endforeach;?>
</div>
<?php endif;?>
</div>
while loop declaration (using default post without own create cpt post page)-->
<?php
while (have_posts()): the_post();
?>
<div class="blog-post wow fadeInUp">
<h1><a href="<?php the_permalink() ?>"><?php the_title(); ?></a></h1>
<?php the_content() ?>
</div>
<?php endwhile;?>
create ui template in page.php this page are automatically create a page
create ui template in single.php are own default post will be fetch
how to post data and fetch using acf pro plugin
1st install and active then
create page name or post name then identify when i will implement
and create field feth data using the_field('slug name') and echo get_field('slug name');
for loop used repeater field then collect repeater slug name eaxmple - in slider image
$slider= get_field('slider slug name');
then i will chek array and not empty likely -
if(arrary($variable name ) && !empty($variablename)):
foreach($variable name as $value):
<h1>echo $variablename['slug name '];
if index page acf data are not show when go to the settings-reading and Your homepage displays
and another ways is declare global $post in functions.php avobe
Subscribe to:
Posts (Atom)