Skip to content

Instantly share code, notes, and snippets.

Avatar
🎯
Focusing

Mahesh Waghmare maheshwaghmare

🎯
Focusing
View GitHub Profile
@maheshwaghmare
maheshwaghmare / show-post-navigation.php
Last active Sep 18, 2020
WordPress - Show the (next and previous) navigation for post, page and custom post types (CPT). Use `[show_post_navigation]`
View show-post-navigation.php
<?php
/**
* Show the (next and previous) navigation for post, page and custom post types (CPT).
*
* @example [show_post_navigation]
*
* @todo Change the `prefix_` and with your own unique prefix.
*
* @since 1.0.0
*/
@maheshwaghmare
maheshwaghmare / rss-feed-shortcode.php
Created Sep 4, 2020
Show WordPress RSS Feed with Shortcode. E.g. [show_rss_feed url="https://maheshwaghmare.com/feed/"]
View rss-feed-shortcode.php
<?php
/**
* Show RSS feed with Shortcode.
*
* @example [show_rss_feed url="https://maheshwaghmare.com/feed/"]
*
* @todo Change the `prefix_` and with your own unique prefix.
*
* @since 1.0.0
*/
@maheshwaghmare
maheshwaghmare / add-post-type-to-feed.php
Created Sep 4, 2020
WordPress: Add custom post types into the feed.
View add-post-type-to-feed.php
<?php
/**
* Add Custom Post Types (CPT) to feeds
*
* @todo Change the `prefix_` and with your own unique prefix.
*
* @since 1.0.0
*
* @return object
*/
@maheshwaghmare
maheshwaghmare / child-pages-list.php
Created Sep 3, 2020
List all the pages in list with `[child_pages_list]` shortcode in WordPress.
View child-pages-list.php
<?php
add_shortcode( 'child_pages_list', function() {
$args = array(
'post_parent' => get_the_ID(),
'post_type' => get_post_type(),
);
$posts = get_children( $args );
ob_start();
@maheshwaghmare
maheshwaghmare / pluign-get-deactivate-link.php
Created Aug 16, 2020
WordPress get plugin deactivate link.
View pluign-get-deactivate-link.php
@maheshwaghmare
maheshwaghmare / copy-as-html.php
Created Aug 2, 2020
Copy anything to Clipboard: Allow to copy as HTML. See https://maheshwaghmare.com/?p=8138
View copy-as-html.php
<?php
/**
* Allow to copy as HTML.
*
* @todo Change the `prefix_` and with your own unique prefix.
*
* @since 1.0.0
*
* @return mixed
*/
@maheshwaghmare
maheshwaghmare / sample-plugin.php
Created Jul 18, 2020
Sample Plugin - Create new user role and new post type and allow to create the custom post type with those users who have that specific user role.
View sample-plugin.php
<?php
<?php
/**
* Plugin name: Sample Plugin
*/
/**
* User Role Specific Post Type
*
* @package User Role Specific Post Type
@maheshwaghmare
maheshwaghmare / add-tag-in-rest-field.php
Created Jul 16, 2020
WP Portfolio - Add tags in UI grid
View add-tag-in-rest-field.php
<?php
add_action( 'rest_api_init', 'wp_portfolio_add_rest_field' );
/**
* Add Rest Field
*
* @since 1.0.0
* @return void
*/
function wp_portfolio_add_rest_field() {
@maheshwaghmare
maheshwaghmare / .htaccess
Created Jul 14, 2020 — forked from Zodiac1978/.htaccess
Make your Website faster - a safe htaccess way
View .htaccess
#
# Sources:
# http://stackoverflow.com/questions/7704624/how-can-i-use-gzip-compression-for-css-and-js-files-on-my-websites
# http://codex.wordpress.org/Output_Compression
# http://www.perun.net/2009/06/06/wordpress-websites-beschleuinigen-4-ein-zwischenergebnis/#comment-61086
# http://www.smashingmagazine.com/smashing-book-1/performance-optimization-for-websites-part-2-of-2/
# http://gtmetrix.com/configure-entity-tags-etags.html
# http://de.slideshare.net/walterebert/die-htaccessrichtignutzenwchh2014
# http://de.slideshare.net/walterebert/mehr-performance-fr-wordpress
# https://andreashecht-blog.de/4183/
@maheshwaghmare
maheshwaghmare / add-current-post-updated-year.php
Created Jul 6, 2020
WordPress SEO - Register current post updated year as a custom tag or variable in to the Yoast SEO plugin. We can use the %%post_updated_year%% into the title. Read more at https://maheshwaghmare.com/doc/yoast-seo-custom-template-variable/
View add-current-post-updated-year.php
<?php
if( ! function_exists( 'prefix_yoast_register_post_updated_year' ) ) :
/**
* Register Current Post Publish Year
*
* @todo Change the `prefix_` with your own custom prefix.
* @since 1.0.0
* @return void
*/
function prefix_yoast_register_post_updated_year() {
You can’t perform that action at this time.