/**
* Add page templates.
*
* @param array $templates The list of page templates
*
* @return array $templates The modified list of page templates
*/
function sf_add_page_template_to_dropdown( $templates ) {
$templates[ plugin_dir_path( __FILE__ ) . 'templates/page-template.php' ] = __( 'Page Template From Plugin', 'text-domain' );
return $templates;
}
add_filter( 'theme_page_templates', 'pt_add_page_template_to_dropdown' );
How to deploy a create react app to Github pages
1. Add homepage
Open your package.json file present inside your react app and add homepage
property.
"homepage":"https://yourusername.github.io/repository-name"
replace the above url with your github username and repository name.
2. Install gh-pages
Next, we need to install a package called gh-pages.
npm install --save-dev gh-pages
3. Deploy script
It’s time to add a deploy script commands in our package.json file.
"scripts":{
"predeploy": "npm run build",
"deploy": "gh-pages -d build",
}
Now in your terminal run npm run deploy
4. Setup source to gh-pages branch.
Once you successfully deployed open your GitHub code repository and click on settings tab if you scroll down you can see a GitHub Pages then choose a branch to gh-pages.

That’s it now you can see your react app URL like in the above image.
Add Additional File Types to be Uploaded in WordPress
function my_myme_types( $mime_types ) {
$mime_types['svg'] = 'image/svg+xml'; //Adding svg extension
$mime_types['psd'] = 'image/vnd.adobe.photoshop'; //Adding photoshop files
return $mime_types;
}
add_filter( 'upload_mimes', 'my_myme_types', 1, 1 );
Reinitialize Owl Carousel 1
$( ".owl-fade-slider .owl-carousel" ).data( 'owlCarousel' ).reinit( {
transitionStyle: "fade",
autoPlay: 4000
} );
Redirecting HTTP to HTTPS
RewriteEngine On
RewriteCond %{SERVER_PORT} 80
RewriteRule ^(.*)$ https://www.yourdomain.com/$1 [R,L]
Remove WP Generator Meta Tag
Put in functions.php file in your theme:
/**
* Remove WP Generator Meta Tag
*/
function wp_98_remove_generator_meta_tag() {
remove_action( 'wp_head', 'wp_generator' );
}
add_action( 'init', 'wp_98_remove_generator_meta_tag' );
Seeking You
What you seek is seeking you
Page Slug as Body Class
/*
* Page Slug as Body Class
*/
function add_slug_to_body_class( $classes ) {
global $post;
if ( isset( $post ) ) {
$classes[] = $post->post_type . '-' . $post->post_name;
}
return $classes;
}
add_filter( 'body_class', 'add_slug_to_body_class' );
Add Page Template Column on Admin Page Table
/*
* Add Page Template Column on Admin Page Table
*/
function asiq_page_column_views( $defaults ) {
$defaults['page-layout'] = __( 'Template' );
return $defaults;
}
add_filter( 'manage_pages_columns', 'asiq_page_column_views' );
function asiq_page_custom_column_views( $column_name, $id ) {
if ( $column_name === 'page-layout' ) {
$set_template = get_post_meta( get_the_ID(), '_wp_page_template', true );
if ( $set_template == 'default' ) {
echo 'Default';
}
$templates = get_page_templates();
ksort( $templates );
foreach ( array_keys( $templates ) as $template ) {
if ( $set_template == $templates[ $template ] ) {
echo $template;
}
}
}
}
add_action( 'manage_pages_custom_column', 'asiq_page_custom_column_views', 5, 2 );
Remove Related Products WooCommerce
/**
* Remove related products output
*/
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20 );
add_filter('woocommerce_product_related_posts_query', '__return_empty_array', 100);