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
// functions.php | |
function my_ajax_scripts() { | |
wp_enqueue_script( | |
'my-ajax-script', | |
get_stylesheet_directory_uri() . '/my-ajax.js', // your JS file | |
array('jquery'), | |
null, | |
true | |
); |
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
// You can place this anywhere (header, sidebar, template file): | |
<form role="search" method="get" class="search-form" action="<?php echo home_url( '/' ); ?>"> | |
<label> | |
<span class="screen-reader-text">Search for:</span> | |
<input type="search" class="search-field" placeholder="Search …" value="<?php echo get_search_query(); ?>" name="s" /> | |
</label> | |
<button type="submit" class="search-submit">Search</button> | |
</form> |
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
<?php | |
/** | |
* Comments Template for WordPress posts | |
* Shows threaded comments up to 10 levels | |
*/ | |
if ( post_password_required() ) { | |
return; // Don't show comments if post is password protected | |
} | |
if ( comments_open() || get_comments_number() ) : ?> |
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
<?php | |
/** | |
* Plugin Name: Auto-Mention Parent Commenter | |
* Description: Automatically prepends @username when replying to a comment, works with or without threaded comments enabled. | |
* Author: Sajal Sarkar | |
* Version: 1.0 | |
*/ | |
/** | |
* Prepend @username to replies before saving the comment. |
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
<?php | |
/** | |
* Register 'layout' query var and add rewrite rule for pretty URLs. | |
*/ | |
function my_register_query_vars( $vars ) { | |
$vars[] = 'layout'; // Allows ?layout= or /layout/ | |
return $vars; | |
} | |
add_filter( 'query_vars', 'my_register_query_vars' ); |
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
# Adding Custom Columns in WordPress Admin List Tables | |
This gist shows how to add custom columns to the WordPress admin list table for: | |
- **Posts** | |
- **Pages** | |
- **Custom Post Types (CPTs)** | |
- **Categories** | |
- **Tags** | |
- **Custom Taxonomies** |
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
<?php | |
/** | |
* Plugin Name: Custom General Settings Fields | |
* Description: Adds a custom section and fields to Settings > General, with proper nonce, sanitization, and escaping. | |
* Version: 1.0 | |
* Author: Sajal Sarkar | |
*/ | |
/** |
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
<?php | |
/** | |
* Plugin Name: Custom User Contact Fields | |
* Description: Adds extra contact fields to user profiles. | |
* Version: 1.0 | |
* Author: Sajal Sarkar | |
*/ | |
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
<?php | |
/** | |
* Plugin Name: Custom User Profile Fields | |
* Description: Adds custom fields to user profiles in the WordPress admin. | |
* Version: 1.0 | |
* Author: Sajal Sarkar | |
*/ | |
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
<?php | |
/** | |
* Plugin Name: Taxonomy Meta Example | |
* Description: Adds custom meta fields to taxonomy terms (categories or tags) with nonce protection. | |
* Version: 1.1 | |
* Author: Sajal Sarkar | |
*/ | |
/** |