Code & Me
WordPress Code Snippet Repository
  • Home
  • Featured
  • Recently Added
  • About
  • Contact

Displaying Twitter Feeds In WordPress

July 12, 2021 By Editorial Staff in WordPress No Comments Tags: Code, Code Snippet, Snippet, WordPress, WordPress Snippet, WordPress Snippets

Using the following snippet will result in displaying Twitter feed in WordPress.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
include_once(ABSPATH . WPINC . '/feed.php');
$rss = fetch_feed('https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=smashingmag');
$maxitems = $rss->get_item_quantity(3);
$rss_items = $rss->get_items(0, $maxitems);
?>
<ul>
<?php if ($maxitems == 0) echo '<li>No items.</li>';
else
// Loop through each feed item and display each item as a hyperlink.
foreach ( $rss_items as $item ) : ?>
<li>
<a href='<?php echo $item->get_permalink(); ?>'>
<?php echo $item->get_title(); ?>
</a>
</li>
<?php endforeach; ?>
</ul>

Snippet Source/Credit: Smashing Magazine

Creating Database For Your WordPress Website

July 4, 2021 By Editorial Staff in Featured, WordPress No Comments Tags: Code, Code Snippet, Snippet, WordPress, WordPress Snippet, WordPress Snippets

Using the following snippet, you will be able to create database for WordPress.

1
2
CREATE SCHEMA `your_db_name` ;
GRANT ALL PRIVILEGES ON your_db_name.* TO 'your_user_name'@'localhost' IDENTIFIED BY 'your_password';

Snippet Source/Credit: Snipplr

How To Obfuscate Email Addresses Automatically

May 28, 2021 By Editorial Staff in WordPress No Comments Tags: Code, Code Snippet, Snippet, WordPress, WordPress Snippet, WordPress Snippets

Using the following snippet, you will be able to obfuscate email addresses automatically.

1
<?php antispambot('name@email.com',1 ) ?>

Snippet Source/Credit: WordPress Codex

How To Make Term Edition Easier In WordPress

May 21, 2021 By Editorial Staff in Featured, WordPress No Comments Tags: Code, Code Snippet, Snippet, WordPress, WordPress Snippet, WordPress Snippets

Using the following snippet, you will be able to make term edition easier in WordPress.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
if ( !function_exists('edit_term_link') ) {
  function edit_term_link( $link = '', $before = '',
      $after = '', $term = null ) {
    if ( $term == null ) {
      global $wp_query;
      $term = $wp_query->get_queried_object();
    }
    $tax = get_taxonomy( $term->taxonomy );
    if ( !current_user_can($tax->cap->edit_terms) )
      return;
    if ( empty($link) )
      $link = __('Edit This');
    $link = '<a href="' . get_edit_tag_link( $term->term_id,
        $term->taxonomy ) . '" title="' . $link . '">' . $link . '</a>';
    echo $before .
       apply_filters( 'edit_term_link', $link, $term->term_id ) . $after;
  }
}
Once saved, add the following line of snippet on any category, tag or taxonomy template:
<?php edit_term_link(); ?>

Snippet Source/Credit: Joost de Valk

How To Disable All Plugins Update In WordPress

May 14, 2021 By Editorial Staff in Featured, WordPress No Comments Tags: Code, Code Snippet, Snippet, WordPress, WordPress Snippet, WordPress Snippets

Using the following snippet, you will be able to disable all plugins update in WordPress.

1
2
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

Creating A Database For Your WordPress Website

May 7, 2021 By Editorial Staff in Featured, WordPress No Comments Tags: Code, Code Snippet, Snippet, WordPress, WordPress Snippet, WordPress Snippets

Using the following snippet, you will be able to create a database for your WordPress website with an ease.

1
2
CREATE SCHEMA `your_db_name` ;
GRANT ALL PRIVILEGES ON your_db_name.* TO 'your_user_name'@'localhost' IDENTIFIED BY 'your_password';

Snippet Source/Credit: Snipplr

Displaying Twitter Feed In WordPress

April 30, 2021 By Editorial Staff in WordPress No Comments Tags: Code, Code Snippet, Snippet, WordPress, WordPress Snippet, WordPress Snippets

Using the following snippet below, you will be able to display Twitter feed for your WordPress website.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
<?php
include_once(ABSPATH . WPINC . '/feed.php');
$rss = fetch_feed('https://api.twitter.com/1/statuses/user_timeline.rss?screen_name=smashingmag');
$maxitems = $rss->get_item_quantity(3);
$rss_items = $rss->get_items(0, $maxitems);
?>
<ul>
<?php if ($maxitems == 0) echo '<li>No items.</li>';
else
// Loop through each feed item and display each item as a hyperlink.
foreach ( $rss_items as $item ) : ?>
<li>
<a href='<?php echo $item->get_permalink(); ?>'>
<?php echo $item->get_title(); ?>
</a>
</li>
<?php endforeach; ?>
</ul>

Snippet Source/Credit: Smashing Magazine

How To Have Your WordPress Website Login Form Setup

April 23, 2021 By Editorial Staff in WordPress No Comments Tags: Code, Code Snippet, Snippet, WordPress, WordPress Snippet, WordPress Snippets

The following snippet will let you setup your WordPress website login form.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
function user_login_form(){ ?>
<form id="loginform" action="<? echo site_url('wp-login.php', 'login_post') ?>" method="post">
    <ul id="login_list">
        <li>
         <label for="user_login">Username / Email Address
         <input type="text" name="log" id="user_login" class="input round" value="<?php echo esc_attr($user_login); ?>" />
            </label>
        </li>
        <li>
         <label for="user_pass">Password
         <input type="password" name="pwd" id="user_pass" class="input round" value=""  />
            </label>
        </li>
        <? do_action('login_form'); ?>
        <li class="rememberme-check-box">
            <input name="rememberme" type="checkbox" id="rememberme" value="forever" />&nbsp;Remember you?
            <input type="hidden" name="redirect_to" value="<?php echo esc_attr(get_option('home')); ?>/?action=user" />
        </li>
        <li class="submit">
            <a href="<? echo get_option('home'); ?>/?action=user" title="Lost your password? Reset it here..." class="button" id="password-reset">
                Forgot Your Password?
            </a>
            <input class="button" type="submit" id="signin" value="Sign In" />
        </li>
    </ul>
</form>
<? }

Removing WordPress Dashboard Widget

April 16, 2021 By Editorial Staff in WordPress No Comments Tags: Code, Code Snippet, Snippet, WordPress, WordPress Snippet, WordPress Snippets

Using the following snippet, you will be able to remove your WordPress dashboard widget.

1
2
3
4
5
6
function remove_dashboard_widgets() {
global$wp_meta_boxes;
unset($wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins']);
unset($wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary']);
}
add_action('wp_dashboard_setup', 'remove_dashboard_widgets');

Snippet Source/Credit: WP Guru

Removing WordPress Dashboard News Feed

April 9, 2021 By Editorial Staff in WordPress No Comments Tags: Code, Code Snippet, Snippet, WordPress, WordPress Snippet, WordPress Snippets

Using the following snippet, you will be able to remove WordPress dashboard news feed.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
add_action('wp_dashboard_setup', 'my_dashboard_widgets');
function my_dashboard_widgets() {
     global $wp_meta_boxes;
     // remove unnecessary widgets
     // var_dump( $wp_meta_boxes['dashboard'] ); // use to get all the widget IDs
     unset(
          $wp_meta_boxes['dashboard']['normal']['core']['dashboard_plugins'],
          $wp_meta_boxes['dashboard']['side']['core']['dashboard_secondary'],
          $wp_meta_boxes['dashboard']['side']['core']['dashboard_primary']
     );
     // add a custom dashboard widget
     wp_add_dashboard_widget( 'dashboard_custom_feed', 'News from 10up', 'dashboard_custom_feed_output' ); //add new RSS feed output
}
function dashboard_custom_feed_output() {
     echo '<div class="rss-widget">';
     wp_widget_rss_output(array(
          'url' => 'http://www.get10up.com/feed',
          'title' => 'What\'s up at 10up',
          'items' => 2,
          'show_summary' => 1,
          'show_author' => 0,
          'show_date' => 1,
     ));
     echo "</div>";
}

Snippet Source/Credit: Smashing Magazine

< 1 2 3 4 5 >»

Recently Added Snippets

  • How To Set Role And Capabilities In WordPress
  • How To Set WordPress Options As Value
  • List Author Comments On Author Page
  • WordPress Display Page
  • Removing WordPress Version From Head And Feeds

Search The Snippet

Featured Snippets

  • How To Set WordPress Options As Value
  • WordPress Display Page
  • Removing WordPress Version From Head And Feeds
  • Delete Link In Comments In Your WordPress Website
  • Creating Database For Your WordPress Website
Code & Me
  • About
  • Recently Added
  • Advertise
  • Terms
  • Privacy Policy
  • Contact
© 2014-19 CodeAndMe.
Proud Member Of G2One Network Family.

↑ Back to top