This file contains 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
Htaccess file is used to redirect the url rewriting and also for making the SEO friendly URL. | |
Commomly used htaccess codes are listed below. | |
RewriteEngine on # This is to make the rewrite engin ON | |
RewriteCond and RewriteRule: => are the commonly used commands to write the htaccess codes. | |
"RewriteRule" :- It will redirect the current url to the required url. | |
"RewriteRule ^test/?$ test.php [NC,L] " # it will redirect to the test to the test.php |
This file contains 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
1) You can use the .htaccess file to increase the file upload size of the server. | |
Add below codes in the server .htaccess file of the site | |
php_value upload_max_filesize 128M | |
php_value post_max_size 128M | |
php_value max_execution_time 300 | |
php_value max_input_time 300 | |
2)if htaccess trick does't work you edit the php.ini file of the server. |
This file contains 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 need to add the below code in between <IfModule mod_rewrite.c> | |
# Rewrite HTTP to HTTPS | |
RewriteCond %{HTTPS} !=on | |
RewriteRule ^(.*) https://%{SERVER_NAME}/$1 [R,L] | |
The above code will load the https url instead of http |
This file contains 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
You can use two methods for adding the new meta field to Rest API. By using register_meta() function and register_rest_field() function. | |
1)register_meta() function. | |
By using this function you can add additional meta key to API response by adding the 'show_in_rest' => true, parameter to arguments. | |
eg: | |
$object_type = 'post'; | |
$args1 = array( // Validate and sanitize the meta value. | |
// Note: currently (4.7) one of 'string', 'boolean', 'integer', | |
// 'number' must be used as 'type'. The default is 'string'. |
This file contains 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
You can use the register_rest_field() function to add additional meta key to the REST API | |
eg: | |
add_action( 'rest_api_init', 'create_api_posts_meta_field' ); | |
function create_api_posts_meta_field() { | |
// register_rest_field ( 'name-of-post-type', 'name-of-field-to-return', array-of-callbacks-and-schema() ) | |
register_rest_field( 'post', 'banner_image', array( | |
'get_callback' => 'get_post_meta_for_api', |
This file contains 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 create custom end point by using the register_rest_route() function. This function is need to call in rest_api_init hooks. | |
For this function register_rest_route(), the first argument is namespace, 2nd one is resource path or resource base and 3rd one is array option. | |
In array optuion we specify what method the end point can use and what call back is happen when an end point is matched. | |
/** | |
* This is our callback function that embeds our phrase in a WP_REST_Response | |
*/ | |
function prefix_get_endpoint_phrase() { |
This file contains 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); |
This file contains 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 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 | |
------------- |
OlderNewer