Skip to content

Instantly share code, notes, and snippets.

View rajendra89's full-sized avatar

Rajendra Rijal rajendra89

View GitHub Profile
add_action( 'woocommerce_product_options_general_product_data', 'wc_custom_add_custom_fields' );
function wc_custom_add_custom_fields() {
// Print a custom text field
woocommerce_wp_text_input( array(
'id' => '_custom_text_field1',
'label' => 'Name',
'description' => ' Field, you can write your Name.',
'desc_tip' => 'true',
'placeholder' => 'Ram'
) );
add_action( 'woocommerce_product_options_general_product_data', 'wc_custom_add_custom_fields' );
function wc_custom_add_custom_fields() {
// Print a custom text field
woocommerce_wp_text_input( array(
'id' => '_custom_text_field1',
'label' => 'Name',
'description' => ' Field, you can write your Name.',
'desc_tip' => 'true',
'placeholder' => 'Ram'
) );
[text* your-name placeholder "Your name here"]
[email* your-email placeholder "Your email here"]
[textarea your-message placeholder "Your message here"]
[submit "Send"]
$args_blog=array(
'post_type'=>'blog',
'posts_per_page'=>'5', //for getting all posts
'order'=>'ASC', //last input first output
'orderby'=>'menu_order', //according to field
$args_blog=array(
'post_type'=>'blog',
'posts_per_page'=>'5', //for getting only 5 posts
'order'=>'ASC', //last input first output
'orderby'=>'menu_order', //according to field
$args_blog=array(
'post_type'=>'blog',
'posts_per_page'=>'5', //for getting only 5 posts
'order'=>'ASC', //last input first output
'orderby'=>'menu_order', //according to field
if you want to disply all post then replace 5 by -1
<?php
/*
Template Name: idc_projects
*/
?>
<?php get_header(); ?>
<!-- Get header content -->
<!-- banner-image -->
<div class="banner-image" style="background: linear-gradient(rgba(0,0,0,0.6),rgba(0,0,0,0.6)), url('<?php echo get_field('idc_projects_img')['url']; ?>');">
<div class="container">
@rajendra89
rajendra89 / functions.php
Created May 15, 2017 06:27
Change the Excerpt Length
function excerpt_length_example( $words ) {
return 15;
}
add_filter( 'excerpt_length', 'excerpt_length_example' );
@rajendra89
rajendra89 / display.php
Last active May 26, 2017 06:47
accessing page content through loop
siteURL/wp-admin/post.php?post=37&action=edit
Here, 37 is page ID.
<?php $the_query = new WP_Query( 'page_id=37' );
while ($the_query -> have_posts()) : $the_query -> the_post(); ?>
//Content Area.
@rajendra89
rajendra89 / functions.php
Created May 27, 2017 11:19
Change the Excerpt Length
function excerpt_length_example( $words ) {
return 15;
}
add_filter( 'excerpt_length', 'excerpt_length_example' );