1 / 33

Wordpress Theme Hacks Nearly Anyone Can Do

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. How I Met Wordpress. THIS WAS ME For

eudora
Download Presentation

Wordpress Theme Hacks Nearly Anyone Can Do

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 CMSSystems 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 metonly 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_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 MyWP 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 whencertain 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

  21. Hacking with Conditional Tags Do “ABC” when “XYZ” Condition is met: <?php if (is_home()) { ?> 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” <?php if (is_home()) { ?> Show my home page text block<?php } elseif (is_single()) { ?> 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 <?php if (is_home()) { ?> Show my home page text block<?php } elseif (is_single()) { ?> Show my single post text block instead <?php else { ?> 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. <?php if (is home() || is_single() || is_category() || is_page() || is_archive() { ?> Show this text for all those conditions <?php } ?> 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 everywhereexcept where you don't want it... <?php if (is_home()) { } Else { ?> <p>Show this everywhere!</p> <?php } ?> 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 <? php if (is_home()) { wp_list_bookmarks(); } ?> 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_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 Linksto 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 '| <a href="'.admin_url("comment.php?action=cdc&c=$id").'">del</a> '; echo '| <a href="'.admin_url("comment.php?action=cdc&dt=spam&c=$id").'">spam</a>'; }} 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-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( "'", '&apos;', $incoming_comment['comment_content'] );return( $incoming_comment );} function plc_comment_display( $comment_to_display ) {$comment_to_display = str_replace( '&apos;', "'", $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-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/

  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

More Related