Code And Me - WordPress Code Snippet Repository
147 FOLLOWERS
CODE & ME is designed to make WordPress source codes available easier. Moreover, with CODE AND ME, we have tried to bring up an established community by which one can have an access to each others’ code library.
Code And Me - WordPress Code Snippet Repository
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
Code And Me - WordPress Code Snippet Repository
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
Code And Me - WordPress Code Snippet Repository
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
Code And Me - WordPress Code Snippet Repository
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
Code And Me - WordPress Code Snippet Repository
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
Code And Me - WordPress Code Snippet Repository
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
Code And Me - WordPress Code Snippet Repository
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
Code And Me - WordPress Code Snippet Repository
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
Code And Me - WordPress Code Snippet Repository
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
Code And Me - WordPress Code Snippet Repository
3y 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