Include or exclude any content from any page within your WordPress site.
<?php if ( is_cart() ) { echo "Content to display on a specific page; in this case it's the cart page"; }else{ echo "Content to exclude from a specific page; in this case it's the cart page"; }; ?>
Now to use this peace of code just change the
( is_cart()
to the page you want it to work with for example:
( is_page()
the word page being object
Ajax Woocommerce cart icon with number and total
Place in your functions.php file or custom function file, this ajax function auto updates cart Icon count and total when Add to cart button is pushed
Changing Rest Api Prefix to help to secure your website
WP URL for the endpoints contain the prefix as well as a namespace. Here is an example endpoint
That will fetch the details of all posts. The above example, “wp-json” is the rest url prefix while the “wp/v2” is the namespace.
If you don’t like the default base prefix and want to change it from ‘wp-json’ to something more beautiful, the code below will help you. In the code below, I have changed the base prefix from ‘wp-json’ to ‘api’.
/** * Modify url base from wp-json to 'api' */ add_filter( 'rest_url_prefix', 'dp_api_slug'); function dp_api_slug( $slug ) { return 'api'; }
you can change the return ‘api’; to return ‘any-custom-prefix’;.
Once you put the above code in your theme’s functions.php or in a plugin, Please visit the Dashboard->Settings->Change your permalinks( You can restore it after saving again, we need to change it at least once to flush the rewrite rules ).
So your URL example will look like the following: