Posts

Showing posts from August, 2020

Get Template name by template file name shortcode for all files in wordpess

Page Template File Where we want to show template-full-width.php   <?php /**  * Template Name: Full Width Template  * Template Post Type: post, page  *  * @package WordPress  * @subpackage Twenty_Twenty  * @since Twenty Twenty 1.0  */ get_template_part( 'singular' ); Page Template File where from we get code singular.php <?php /**  * The template for displaying single posts and pages.  *  * @link https://developer.wordpress.org/themes/basics/template-hierarchy/  *  * @package WordPress  * @subpackage Twenty_Twenty  * @since Twenty Twenty 1.0  */ get_header(); ?> <main id="site-content" role="main"> <?php if ( have_posts() ) { while ( have_posts() ) { the_post(); get_template_part( 'template-parts/content', get_post_type() ); } } ?> </main><!-- #site-content --> <?php get_template_part( 'template-parts/footer-menus-widgets' ); ?> <?php get_footer...

How to show custom taxonomy (categories and tags) in Custom Post Type.

 <?php function custom_portfolio_type() { // Set UI labels for Custom Post Type     $labels = array(         'name'                => _x( 'Portfolios', 'Post Type General Name', 'modernizer' ),         'singular_name'       => _x( 'Portfolio', 'Post Type Singular Name', 'modernizer' ),         'menu_name'           => __( 'Portfolios', 'modernizer' ),         'parent_item_colon'   => __( 'Parent Movie', 'modernizer' ),         'all_items'           => __( 'All Portfolios', 'modernizer' ),         'view_item'           => __( 'View Portfolio', 'modernizer' ),         'add_new_item'        => __( 'Add New Portfolio', 'modernizer' ), ...

Registering your Custom Post Type using category

 /* * Creating a function to create our CPT */   function custom_post_type() {   // Set UI labels for Custom Post Type     $labels = array(         'name'                => _x( 'Page Top Post', 'Post Type General Name', 'twentytwenty' ),         'singular_name'       => _x( 'Page Post', 'Post Type Singular Name', 'twentytwenty' ),         'menu_name'           => __( 'All Page Top Post', 'twentytwenty' ),         'parent_item_colon'   => __( 'Parent Page Post', 'twentytwenty' ),         'all_items'           => __( 'Page Top Post', 'twentytwenty' ),         'view_item'           => __( 'View Page Post', 'twentytwenty' ),         'add_new_item'  ...

Add Post Custom type

 <?php add_action( 'wp_ajax_nopriv_action_job_apply', 'uouApplyItem' ); add_action( 'wp_ajax_action_job_apply', 'uouApplyItem' ); // Add New Post Type For job function omega_job_posttype() { global $shortname; register_post_type( 'job', array( 'labels' => array( 'name' => __( 'Job', 'omega'), 'singular_name' => __( 'Job', 'omega'), 'add_new' => __( 'Add New Job', 'omega'), 'add_new_item' => __( 'Add New Job', 'omega'), 'edit_item' => __( 'Edit Job', 'omega'), 'new_item' => __( 'Add New Job', 'omega'), 'view_item' => __( 'View Job', 'omega'), 'search_items' => __( 'Search Job',  'omega'), 'not_found' => __( 'No Job found',  'om...

All Product Show in loop Without any Categoery in Woo Commerce

  <ul class="row product-list">                        <?php $args = array( 'post_type' => 'product', 'posts_per_page' => -1 );     query_posts( $args ); while ( have_posts() ) : the_post();     //print_r($product); //Dump product info      $img_url = $image = wp_get_attachment_image_src( get_post_thumbnail_id( $loop->post->ID ), 'single-post-thumbnail' ); $link = $product->get_permalink();     ?>     <li class="col-lg-3 col-md-3 col-sm-3 col-xs-6 thumbnail">          <div class="caption"> <?php echo do_shortcode('<a href="'.$link.'" class="btn add-to-cart" title=" ">ADD TO CART</a>'); ?>  <?php echo do_shortcode('<a href="'.$link.'" class="btn view-details"title="">VIEW DETAILS...

BACK TO TOP SHORTCODE

  major faults wordpress developer uslu forget <!-- Go Top Back --> <script type="text/javascript"> // create the back to top button $('body').prepend('<a href="#" class="back-to-top">Back to Top</a>'); var amountScrolled = 300; $(window).scroll(function() { if ( $(window).scrollTop() > amountScrolled ) { $('a.back-to-top').fadeIn('slow'); } else { $('a.back-to-top').fadeOut('slow'); } }); $('a.back-to-top, a.simple-back-to-top').click(function() { $('html, body').animate({ scrollTop: 0 }, 700); return false; }); </script> a.back-to-top { display: none; width: 60px; height: 60px; text-indent: -9999px; position: fixed; z-index: 999; right: 20px; bottom: 20px; background: #27AE61 url("../images/up-arrow.png") no-repeat center 43%; -webkit-border-radius: 30px; -moz-border-radius: 30px; border-radius: 30px; } a:hover.back-to-t...

Show Menu in Wordpress using shortcode

 <?php  $defaults = array( 'theme_location'  => '', 'menu'            => 'MENU NAME', 'container'       => '', 'container_class' => '', 'container_id'    => '', 'menu_class'      => 'mwfoot-colinks', 'menu_id'         => '', 'echo'            => true, 'fallback_cb'     => 'wp_page_menu', 'before'          => '', 'after'           => '', 'link_before'     => '', 'link_after'      => '', 'items_wrap'      => '<ul id="nav" class="%2$s">%3$s</ul>', 'depth'           => 0, 'walker'          => '' ); $pages=wp_nav_menu( $defaults )...

DATE PICKER FOR ANY CODE WORDPRESS PHP ETC

  <link rel="stylesheet" href="http://code.jquery.com/ui/1.9.1/themes/base/jquery-ui.css" /> <script src="http://code.jquery.com/jquery-1.8.2.js"></script>    <script src="http://code.jquery.com/ui/1.9.1/jquery-ui.js"></script>    <script>    $(function(){        $( ".datepicker" ).datepicker();        $("#icon").click(function() {            $(".datepicker").datepicker( "show" );        })    });    </script> <input type="text" required name="issue_date" size='9' class="datepicker" value="<?php echo $value['issue_date']; ?>"/> <td><input type="text" required name="valid_up" size='9' class="datepicker" value="<?php echo $value['valid_up']; ?>"/></td>

Search Code in Word press

  <form role="search" method="get" id="searchform" class="searchform" action="<?php echo esc_url( home_url( '/' ) ); ?>"> <input class="srch-input form-control" value="" placeholder="Search" name="s" id="s" type="text"> <span class="input-group-addon srch-bg"> <button class="srch-btn" id="searchsubmit" value="" type="submit">                       <span class="fa fa-search"></span>                         </button>                       </span> </form> And this code to place in function.php file function my_search_form( $form ) { $form = '<form role="search" method="get...

How to show only on Home Page Not Show on Other Pages Wordpress

<?php if ( is_front_page() ) {    // This is the blog posts index    get_sidebar( 'blog' ); } else {    // This is not the blog posts index    get_sidebar(); } ?> Slider show only on Home Page Not Show on Other Pages <?php if ( is_front_page() ) {    // This is the blog posts index    echo do_shortcode( "[vtslider]" ); } ?>

All path in wordpress

<?php echo get_template_directory_uri(); ?> <?php bloginfo ('template_url'); ?> <?php echo get_site_url(); ?>/ <?php bloginfo(template_directory)?>

How to add Custom Testimonial Code and Shortcode

Function.php add_filter( 'widget_tag_cloud_args', 'twentysixteen_widget_tag_cloud_args' ); add_action( 'init', 'create_post_type' );function create_post_type() {  register_post_type( 'testimonial',    array(      'labels' => array(        'name' => __( 'Testimonial' ),        'singular_name' => __( 'testimonial' )      ),      'public' => true,      'has_archive' => true,    )  );} CUSTOMTEMPLATE.php <div class="carousel-inner">        <?php $args = array( 'posts_per_page' => -1, 'post_type' => 'testimonial' ); $i=0; $myposts = get_posts( $args ); foreach ( $myposts as $post ) : setup_postdata( $post ); ?>          <!-- Quote 1 -->          <div class="item <?php if($i==0) { ?> active <...

How to Show Posts in Even Odd Format 2 Wordpress

  <?php global $post; $args = array( 'numberposts' => 10, 'category_name' => 'before-after' ); $posts = get_posts( $args ); $i=1; foreach( $posts as $post ): setup_postdata($post); if($i%2){ //$i%2 ? 'odd':'even') ?><div class="row ba-bg">    <div class="col-md-4">    <div class="slide__text">    <div class="table-center">    <div class="table-cell">    <h3 class="gap-20"><?php the_title();?></h3>    <div class="gap-20"><?php the_excerpt(); ?></div>       </div>    </div>    </div>    <p class="gap-20">    </p>    </div>    <div class="col-md-8 gap-20"> <?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID, 'thumbnail...