Presentation is loading. Please wait.

Presentation is loading. Please wait.

Wordpress Theme Hacks Nearly Anyone Can Do Afraid you might "break something" by mucking around in your theme? With a little determination, and just a.

Similar presentations


Presentation on theme: "Wordpress Theme Hacks Nearly Anyone Can Do Afraid you might "break something" by mucking around in your theme? With a little determination, and just a."— Presentation transcript:

1 Wordpress Theme Hacks Nearly Anyone Can Do Afraid you might "break something" by mucking around in your theme? With a little determination, and just a few keystrokes - you'd be surprised how many things you can change on your own.

2 How I Met Wordpress THIS WAS ME For 10 LONG YEARS

3 In 1999 I was hired as a webmaster I was VERY loyal

4 Webmasters Did Everything HTML Javascript Graphics Technical Writing CGI/Perl Coding UNIX Shell Coding Create Online Tools Training

5 Open Source CMS I tried to introduce multiple Open Source CMS Systems to Automate my Job

6 Big Money Always Won

7 I Met Wordpress in 2004

8 I Thought They Were Wrong... So I kept using Wordpress on My Own... Sometimes instead of doing my real work.

9 Little Did I Know... In 2009 they outsourced the last of us... the last of the webmasters that is.

10 I Was Out of Work No Jobs. Unemployment. Couldn't Move. What Now?

11 Reinvention

12 Wordpress Theme Hacks Nearly Anyone Can Do You Will Need to: Use the Wordpress dashboard editor Know basic HTML Be able to Edit, Copy and Paste small amounts of PHP Code

13 Why Hack a Wordpress Theme? To stand out or look different create a look nobody else has To add functionality for the end user like, tweet, disqus To enhance the way content is displayed post meta, text, images, the_loop, navigation To customize specific pages search results, 404 Pages, archives, category & tags pages To show content only when conditions are met only on the home page, just singles posts, only tag pages, etc.

14 How Do I Edit My WP Theme? In WP dashboard: Appearance Editor Click on the page you want to edit:

15 What Are All Those Theme Pages? At Bare Minimum, Most WP Themes Have: index.php (home page + a whole lot more) single.php (single posts) page.php (paged pages – like your about page) comments.php (the comments block after content) header.php (before the content on EVERY page) footer.php (after the content on EVERY page) sidebar.php (what's in the sidebar) functions.php (special theme specific PHP code) style.css (text formatting and layout rules) Reference: http://codex.wordpress.org/Template_Hierarchyhttp://codex.wordpress.org/Template_Hierarchy

16 Which file does what? A page file (index, single, page) calls and loads other files for specific page content areas:

17 How Many Pages Could My WP Theme Have? The Bare Minimum index.php single.php page.php comments.php header.php footer.php functions.php sidebar.php style.css Optional Theme Pages archive.php (date based archives) search.php (search results) category.php (category pages) tag.php (tag pages) 404.php (not found errors) attachment.php (attachments) author.php (author page) loop.php (Wordpress 3.0+) Countless custom template files

18 Why Use Conditional Tags To do something only when certain conditions are met Examples: Show specific text or images Create custom adverts for specific uses Designate alternate layouts for certain pages Using plugins to do this slows down your site

19 Where can I use Conditional Tags? Conditions such as is_home with is_front_page, is_single, is_sticky, is_page, is_page_template, is_category, is_tag, is_author, work great in sections such as: index.php Header or Footer Sidebars the_loop Comments block

20 Very Specific Conditions Specify individual pages like is_single('hello') or in_category('5'), is_page_template('contact.php'), is_tag('ipod') or has_tag('ipod'), is_author('john-pratt'), is_date(), is_single(array('my-best-post', 'my-worst-post')) Specific category and tag pages Specific template pages Specific archive pages Specific post ID's Reference the Codex: http://codex.wordpress.org/Conditional_Tags http://codex.wordpress.org/Conditional_Tags

21 Hacking with Conditional Tags Do ABC when XYZ Condition is met: Show my big block of SEO keyword-laden text By replacing is_home with is_front_page, is_single, is_sticky, is_page, is_page_template, is_category, is_tag, is_author, is_date, is_archive, or is_attachment to make your message show up on nearly any WordPress page.

22 Having Multiple Conditions Do ABC when XYZ Condition is met, elseif single post page do DEF Show my home page text block Show my single post text block instead In this example we show custom text for the home page, or on single pages. If neither condition is met – we don't show any custom text.

23 Multiple Conditions Else Default Do ABC when XYZ Condition is met, elseif single post page do DEF, else show do default for all other instances Show my home page text block Show my single post text block instead Show my default text for all other conditions

24 Using Multiple Conditions Combine conditions on one statement to show the same thing in multiple places. Show this text for all those conditions The double-pipe or || in the code signifies OR, so WordPress knows, if this is home, or a single page, or a category page, or a page page, or an archive page – show the same thing for all.

25 Show Everywhere, Except... Use the concept in reverse to show everywhere except where you don't want it... Show this everywhere! In this example we show nothing when the home page is shown, else show it every other time.

26 Conditionally Use WP Functions Use a Conditional tag to force a WP Function Use conditional statements to do things like get_tags, get_category_parents, get_page_children, get_user_meta, and many more... Reference: http://codex.wordpress.org/Function_Referencehttp://codex.wordpress.org/Function_Reference

27 Hacking Your Comments Plugins like subscribe to comments or CommentLuv are great enhancements By modifying the text in comments.php, you can customize what your comments block says (or how it looks) By modifying some of the code, you can add (or remove functionality) Get rid of comment spam at the source

28 Add Delete and Spam Links to Your Comment Sections Add this code to your theme's functions.php file: function delete_comment_link($id) { if (current_user_can('edit_post')) { echo '| del '; echo '| spam '; } } Add this code to your comments.php where you want the links (usually add it in where you find edit_comment_link()): delete_comment_link(get_comment_ID()); Source: http://www.wprecipes.com/how-to-add-del-and-spam-buttons-to- your-commentshttp://www.wprecipes.com/how-to-add-del-and-spam-buttons-to- your-comments

29 Stop HTML Links in Comments Add this to your functions.php file, all links will be stripped: function plc_comment_post( $incoming_comment ) { $incoming_comment['comment_content'] = htmlspecialchars($incoming_comment['comment_content']); $incoming_comment['comment_content'] = str_replace( "'", ''', $incoming_comment['comment_content'] ); return( $incoming_comment ); } function plc_comment_display( $comment_to_display ) { $comment_to_display = str_replace( ''', "'", $comment_to_display ); return $comment_to_display; } add_filter('preprocess_comment', 'plc_comment_post', '', 1); add_filter('comment_text', 'plc_comment_display', '', 1); add_filter('comment_text_rss', 'plc_comment_display', '', 1); add_filter('comment_excerpt', 'plc_comment_display', '', 1); Reference: http://www.wprecipes.com/how-to-get-rid-of-links-in-your-commentshttp://www.wprecipes.com/how-to-get-rid-of-links-in-your-comments

30 Prevent Most Comment Spam Most Spammers use software or scripts that have no referrer. Require all comments come from a web browser to stop the spammers dead! Add this to your functions.php file: function check_referrer() { if (!isset($_SERVER['HTTP_REFERER']) || $_SERVER['HTTP_REFERER'] == ) { wp_die( __('enable referrers or go away') ); } } add_action('check_comment_flood', 'check_referrer'); Source: http://www.smashingmagazine.com/2009/07/23/10-wordpress- comments-hacks/http://www.smashingmagazine.com/2009/07/23/10-wordpress- comments-hacks/

31 Hacking Navigation Add things to your blog that will make it more usable and help readers find what they need Breadcrumb Plugins Related Posts Plugins Most Viewed / Popular Post Plugins Category Icons Plugins

32 Remove Next / Previous Links Replace with more common pagination links WP-Page Numbers Plugin WP-PageNavi Plugin

33 Q&A Find me: facebook.com/jtprattmedia www.jtprattmedia.com www.jtpratt.com/blog twitter.com/jtpratt wp-dir.com


Download ppt "Wordpress Theme Hacks Nearly Anyone Can Do Afraid you might "break something" by mucking around in your theme? With a little determination, and just a."

Similar presentations


Ads by Google