This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For creating a new post types in wordpress admin panel we can use below function in init hook. | |
function theme_posttype() { | |
register_post_type('portfolio', array('label' => 'Works', | |
'description' => '', | |
'public' => true, | |
'show_ui' => true, | |
'show_in_menu' => true, | |
'capability_type' => 'page', | |
'hierarchical' => false, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
In javascript, to check a variable contain a valid data or not, we can use the below code. | |
var value; | |
if(value){ | |
// do something | |
} | |
If the variable doesn't contain a valid value it may have following 6 type of content. | |
This checking will valid if the variable is already defined. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This code will display all hooks used in a page for wordpress website. | |
$debug_tags = array(); | |
add_action( 'all', function ( $tag ) { | |
global $debug_tags; | |
if ( in_array( $tag, $debug_tags ) ) { | |
return; | |
} | |
echo "<pre>" . $tag . "</pre>"; | |
$debug_tags[] = $tag; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
For setting up the paypal checkout in woocommerce, we must have a paypal account. | |
The following are the steps to test paypal sandbox checkout in the woocommerce. | |
1. first we need to create a paypal account. | |
2. Then we goes to the https://developer.paypal.com/ page and check the sandbox area. Where we can see the buyer account and facilitator account. | |
3. Here we can add new buyer and facilitator account if required. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
if(isset($_POST['submit'])){ | |
var_dump($_POST); | |
} | |
?> | |
<form method="post"> | |
<input type="test" name="test"> | |
<input type="test2" name="test2"> | |
<div class="ttt" style="display: none;"> | |
<input type="j1" name="j1" value="ttt"> | |
<input type="j2" name="j2" value="yyy"> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
We can add new admin user by using below code. it will be helpfull if we forget the admin details of the website. | |
add_action('init', 'add_new_admin_user'); | |
function add_new_admin_user() { | |
$username = 'testuser'; | |
$email = '[email protected]'; | |
$password = 'password'; | |
$user_id = username_exists( $username ); | |
if ( !$user_id && email_exists($email) == false ) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Step: 1 | |
----------- | |
Download the WordPress i18n tools directory from SVN using the following command. | |
svn co http://develop.svn.wordpress.org/trunk/tools/ | |
It will be executed from the website root directory of wordpress. So your wordpress directory contain additional folder tools. | |
Step: 2 | |
------------- |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This function is used for getting the terms assinged for the post. This can bve used for the filter desing in the front like masonry | |
and isotop filtering in front end desing. | |
$terms = get_the_terms( $post->ID , array( 'taxonomy-name') ); | |
$cat_app = ''; | |
$cat_name = ''; | |
foreach ($terms as $key => $cat) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
To query a post type in the wordpress template or in wordpress fornt end. Please use the following code snippets. | |
$args = array( | |
'post_type' => 'post', | |
'post_per_page' => 5, | |
'order' => 'ASC', | |
); | |
$the_query = new WP_Query($args); |