How To Set Role And Capabilities In WordPress
Code And Me - WordPress Code Snippet Repository
by Editorial Staff
2y ago
The following snippet will let you set role and capabilities in WordPress. Add this capabilities for every custom post type. [edit_post] => "edit_{$capability_type}" [read_post] => "read_{$capability_type}" [delete_post] => "delete_{$capability_type}" [edit_posts] => "edit_{$capability_type}s" [edit_others_posts] => "edit_others_{$capability_type}s" [publish_posts] => "publish_{$capability_type}s" [read_private_posts] => "read_private_{$capability_type}s" [delete_posts] => "delete_{$capability_type}s" [dele ..read more
Visit website
How To Set WordPress Options As Value
Code And Me - WordPress Code Snippet Repository
by Editorial Staff
2y ago
The following snippet will let you set WordPress options as value. <?php global $options; foreach ($options as $value) { if (get_settings( $value['id'] ) === FALSE) { $$value['id'] = $value['std']; } else { $$value['id'] = get_settings( $value['id'] ); } } ?> The post How To Set WordPress Options As Value first appeared on Code & Me ..read more
Visit website
List Author Comments On Author Page
Code And Me - WordPress Code Snippet Repository
by Editorial Staff
2y ago
Using the following snippet, you will be able to list all the author comments on authors page. function wpse19316_author_comments( $length ) { $final_length = (int) $length; $author_comments = get_comments( array( 'ID' => $GLOBALS['authordata']->ID ) ); foreach ( $author_comments as $comment ) { $comment_length = sublen( $comment->comment_content ); $comment_excerpt = $comment->comment_content; if ( $comment_length > $final_length ) $comment_excerpt = substr( $comment->comment_content, $final_length ); echo $comment ..read more
Visit website
WordPress Display Page
Code And Me - WordPress Code Snippet Repository
by Editorial Staff
2y ago
Using the following snippet, you will put page directly into your page template. <?php $id = 1; // page ID to display $p = get_page($id); echo apply_filters('the_content', $p->post_content); ?> Snippet Source/Credit: Snipplr The post WordPress Display Page first appeared on Code & Me ..read more
Visit website
Removing WordPress Version From Head And Feeds
Code And Me - WordPress Code Snippet Repository
by Editorial Staff
2y ago
Using the following snippet, you will be able to remove WordPress version from head and feeds. function complete_version_removal() { return ''; } add_filter('the_generator', 'complete_version_removal'); Snippet Source/Credit: Snipplr The post Removing WordPress Version From Head And Feeds first appeared on Code & Me ..read more
Visit website
Delete WordPress Post Revisions
Code And Me - WordPress Code Snippet Repository
by Editorial Staff
2y ago
The snippet below will allow you to delete WordPress post revisions. $wpdb->query( " DELETE FROM $wpdb->posts WHERE post_type = 'revision' " ); Snippet Source/Credit: Hardeep Asrani The post Delete WordPress Post Revisions first appeared on Code & Me ..read more
Visit website
Showing Content For Logged In Users
Code And Me - WordPress Code Snippet Repository
by Editorial Staff
2y ago
The snippet below will let you show content for logged-in users. <?php add_shortcode("hide","hide_shortcode"); function hide_shortcode($x,$text=null){ if(!is_user_logged_in()){ return "You have to been registered and logged in to see this content"; }else{ return do_shortcode($text); } } ?> Snippet Source/Credit: Snipplr The post Showing Content For Logged In Users first appeared on Code & Me ..read more
Visit website
Disable WordPress Plugins Update
Code And Me - WordPress Code Snippet Repository
by Editorial Staff
2y ago
The snippet below will let you disable WordPress plugins update. remove_action( 'load-update-core.php', 'wp_update_plugins' ); add_filter( 'pre_site_transient_update_plugins', create_function( '$a', "return null;" ) ); Snippet Source/Credit: WP Snippets The post Disable WordPress Plugins Update first appeared on Code & Me ..read more
Visit website
Delete Link In Comments In Your WordPress Website
Code And Me - WordPress Code Snippet Repository
by Editorial Staff
2y ago
The snippet will let you delete link in comments in your WordPress website. function delete_comment_link($id) { if (current_user_can('edit_post')) { echo '| borrar '; echo '| spam'; } } Snippet Source/Credit: Snipplr The post Delete Link In Comments In Your WordPress Website first appeared on Code & Me ..read more
Visit website
Force Categories Widget To Show Empty Categories In WordPress
Code And Me - WordPress Code Snippet Repository
by Editorial Staff
2y ago
The snippet below will let you have force categories widget to show empty categories in WordPress. <?php add_filter( 'widget_categories_args', 'mytheme_widget_cat_args' ); function mytheme_widget_cat_args($cat_args) { // the default for "hide_empty" = 1, so $cat_args['hide_empty'] = 0; // we can override any other defaults here too return $cat_args; } ?> Snippet Source/Credit: WordPress Codex The post Force Categories Widget To Show Empty Categories In WordPress first appeared on Code & Me ..read more
Visit website

Follow Code And Me - WordPress Code Snippet Repository on FeedSpot

Continue with Google
Continue with Apple
OR