Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1653 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Favorite WordPress functions

Thread title: Favorite WordPress functions
Reply    
    Thread tools Search this thread Display Modes  
10-14-2010, 07:04 PM
#1
Jordan is offline Jordan
Jordan's Avatar
Status: #pugs {display: block;}
Join date: Jan 2007
Location: Chicago
Expertise: CSS, HTML, PHP
Software: Sublime Text 2
 
Posts: 1,187
iTrader: 7 / 100%
 

Jordan is on a distinguished road

  Old  Favorite WordPress functions

I've been trying to replace more and more of my plugins with functions as well as just finding really useful snippets to customize it..

What are some of your favorite snippets that you've been using?


Mine are:

Disables the textarea for 'post' view. Comes in handy if you've got a setup that utilize only custom fields in various post types.
Code:
add_action('init', 'remove_textarea');

function remove_textarea() {
    remove_post_type_support( 'post', 'editor' );
}
Modifies the back-end footer to display text and links of your choice.
Code:
function modify_footer_admin () {
  echo 'Created by <a href="">Link</a>';
  echo ' Powered by<a href="http://WordPress.org">WordPress</a>.';
}
add_filter('admin_footer_text', 'modify_footer_admin');
If you're making some tweaks and don't want the users to see and/or if you have a WordPress site on a live server that you don't want visitors seeing yet you can toss this up. Replaces any need for a "maintenance mode" plugin.
Code:
function maintenance_mode() {
  if ( !current_user_can( 'edit_themes' ) || !is_user_logged_in() ) {
    die('Maintenance.');
  }
}
add_action('get_header', 'maintenance_mode');

12-12-2010, 10:12 PM
#2
lethal7 is offline lethal7
Status: I'm new around here
Join date: Sep 2007
Location:
Expertise:
Software:
 
Posts: 12
iTrader: 0 / 0%
 

lethal7 is on a distinguished road

  Old

These are really useful! learning php atm.

Reply With Quote
12-31-2010, 05:33 AM
#3
Morning is offline Morning
Status: Junior Member
Join date: Nov 2010
Location: Alabama, USA
Expertise: web design, writing, proofread
Software: HomeSite, Paint Shop Pro
 
Posts: 50
iTrader: 0 / 0%
 

Morning is an unknown quantity at this point

  Old

It never occurred to me to replace plugins with functions. I find the plugins handy things and quite convenient, personally. Still, it does seem useful to be able to write the functions that do similar things.

Reply With Quote
12-31-2010, 07:19 AM
#4
KewL is offline KewL
Status: OG
Join date: Apr 2006
Location: California
Expertise: Design, Music, Xhtml, Css
Software: Photoshop, Coda, FL Studio
 
Posts: 2,007
iTrader: 11 / 100%
 

KewL is an unknown quantity at this point

  Old

Just the basics.

Featured Images:
Code:
<?php the_post_thumbnail( 'full' ); ?>
Code:
add_theme_support( 'post-thumbnails' );
Widget Ready Sidebar:
Code:
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?><?php endif; ?>
Code:
if ( function_exists('register_sidebar') ) {
	register_sidebar(array(
		'before_widget' => '<li class="sidelist">',
		'after_widget' => '</li>',
		'before_title' => '<h3>',
		'after_title' => '</h3>',
	));
}
Ohh here's a little trick to make a page thats a redirect through the control panel. Just make a black page with the title:
Code:
<a href="url here">Page Name</a>

Reply    


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed