How can I learn to hack my WP sites with minimal PHP knowledge

16 replies
I want to be able to learn how to add text to the theme of my blog, add links at the top, bottom, side of the blog, and other minor hacks that I won't have to spend forever learning PHP to implement. Does anyone know of any resources that teaches PHP newbies how to hack WP code to add links, pics, text etc. ?

If was to try and learn only the PHP I need for WP modding purposes, what is the best book/online/offline resource you would recommend?

Cheers all,

IMil
#hack #knowledge #learn #minimal #php #sites
  • Profile picture of the author LisaRussell
    teach yourself- just start reading the code until you see patterns. if you don't know what something means, google it in quotation marks. good luck.
    {{ DiscussionBoard.errors[1017857].message }}
    • Profile picture of the author Steve Diamond
      @IMil: You really need little or no PHP knowledge to accomplish the kinds of changes you're talking about. What you need to know are HTML and CSS.

      In WP theme files, the PHP code provides the logical interface with the underpinnings of WP. But the HTML and the CSS do most of the work of displaying things.

      If you want to add things to an existing sidebar, you don't have to look inside the theme files at all. Go to the Widgets section of the Appearance menu and you can change the sidebar layouts around at will. You can add anything you like in a Text widget.

      To add things at the beginning or the end of each post, look in the theme files for the HTML that defines a post header (usually the H2 tag). Don't change the PHP. Just insert HTML in the spot where you want it.

      I hope this helps.

      Steve
      Signature
      Mindfulness training & coaching online
      Reduce stress | Stay focused | Keep positive and balanced
      {{ DiscussionBoard.errors[1018024].message }}
  • Profile picture of the author HomeBizNizz
    It's mostly HTML/CSS anyway with some WP PHP code bits...

    If you hack the plugins/WP core it will reset
    during a update of the WP core/plugin.

    I had to hack some plugins due to layout problems.
    A real pain in the ass.
    {{ DiscussionBoard.errors[1020138].message }}
  • Profile picture of the author aspiepower
    When I do this, I go into Appearance, Editor, then look round for the start/end of what are obvious programming blocks and then type *** when I can see that a code block, or section, or area seems to have finished.

    I then save that, refresh my page and look for where the *** turns up ... if it's in the right place I go back into the Editor and add what I wanted there. I use this to place advertising blocks mainly.

    Very crude, but it works
    Signature

    Real Work from Home Ideas:
    RealWAHOnline Writing with Little Reward │ ...

    {{ DiscussionBoard.errors[1022682].message }}
  • Profile picture of the author die()
    php is the easiest programming language there is. When I started with php, it was due to demand, and I was able to make my own custom site within 2 weeks. If I can do that, you can learn a little about WP!
    {{ DiscussionBoard.errors[1023487].message }}
  • Profile picture of the author inetmilionaire
    Thanks everyone. Anyone who knows of some online resources to do cool WP hacks with little knowledge would also be appreciated.
    {{ DiscussionBoard.errors[1036126].message }}
    • Profile picture of the author nontemplates
      Originally Posted by inetmilionaire View Post

      Thanks everyone. Anyone who knows of some online resources to do cool WP hacks with little knowledge would also be appreciated.
      I think your question is on the right track and it really wasn't answered. HTML and CSS does not get you all the way with Wordpress. there are also what i called "template tags". They included PHP but you really are not required to know php to use them.

      Besides tags as someone else suggested the PHP in Wordpress is not that hard. For example this might look complicated

      <?php include (ABSPATH . '/wp-content/plugins/dynamic-content-gallery-plugin/dynamic-gallery.php'); ?>
      </div>

      BUt all it is doing is including a file at that point in the theme that calls for a plugin. another example - the famous loop


      <?php if (have_posts()) : while (have_posts()) : the_post();

      endwhile; else: ?>


      <?php endif; ?>

      again looks complicated but all it does is look for a post finds it, moves to the next post finds it and if it doesn't find anymore posts it stops.

      Understanding these little snippets without even understanding the php in them makes a WORLD of difference. It gves you a control over your site that allows you to do almost anything you want. I'm doing a video series about this but didn't know if enough people were really interested.
      {{ DiscussionBoard.errors[1036464].message }}
  • Profile picture of the author haikuangel
    Hi From what I understand, its not a knowledge of PHP that is required to do the task but a good grasp of CSS and HTML. Most of the changes that you want to do for your pages are easy to create, these tweaks are manageable just brush up on your HTML and CSS coding and if you get confused there are several coding cheatsheets available on the web.
    {{ DiscussionBoard.errors[1036804].message }}
  • Profile picture of the author inetmilionaire
    nontemplates: you are right on the money. I don't really want to know the code in detail, but rather to spot snippets of code that will help me get an idea about what is going on in the code. If you are putting together a video series, then keep going! Like marketing suggests, my interest represents another hundred customers

    If my query also suggest some knowledge of CSS/HTML is required, then is there any coding tricks specific to Wordpress I may need? Maybe you could put that in your video series, too. To be able to add a string of text somewhere onscreen outside the normal widgets or tools, or to add a CPA offer or something useful like that, these are the little tricks I would like to be able to do.

    Ultimately its about knowing your code, but when I don't know where to start it kind of kills any desire to understand, especially with little time on my hands. I look forward to the offer on your vids.
    {{ DiscussionBoard.errors[1044069].message }}
  • Profile picture of the author rbabi18
    Learn some html and cascading style sheets (css) and you should be able to accomplish what you want.
    Signature

    Get Free Information on MI Bankruptcy

    {{ DiscussionBoard.errors[1044290].message }}
    • Profile picture of the author C A Perez
      Started 3+ months ago. Created my first website with google - yuck!

      Just created my second with WP. Mind you, three months ago I knew nothing about any of this: domains, HTML, hosting, CSS, etc. But by jumping in and trying something, and using Warrior Forums, Wordpress.org forums, and google to educate myself and correct my mistakes, I've done it! It may not be the best, but it's mine. I'll continue to tweak along the way.
      Thanks to everyone for your posts. I'm learning. I just did.
      Carlos
      {{ DiscussionBoard.errors[1046024].message }}
  • Profile picture of the author shadowpwner
    header.php footer.php

    If its in the wrong place, cut - paste to another place. Thats how I started learning.
    {{ DiscussionBoard.errors[1046433].message }}
    • Profile picture of the author LibertyUnc
      It really depends on what you want to do. From the sounds of it you would probably learn fastest by looking at what is there and trying to edit things.

      To put things in sidebars, try using the text widget and then placing your content within the text widget. That works well for most things.

      Just as a quick help/intro type piece:

      HTML is primarily made of pairs of tags, which contain particular things in them.

      Links:
      The "a" tag with the text or item to be linked contained within:
      HTML Code:
      <a href="your_url_here">words or image here</a>
      Images:
      The "img" tag, by itself.
      HTML Code:
      <img src="url_to_image_file_here" />
      Most content is within other types of tags:

      Paragraphs:
      The "p" tag:
      HTML Code:
      <p>This is a paragraph</p>
      The "div" tag:
      HTML Code:
      <div>This is a div, typically styled by css</div>
      The "table" tag:
      HTML Code:
      <table>
      <tr><td>row 1 column 1</td><td>row 1 column 2</td></tr>
      <tr><td>row 2 column 1</td><td>row 2 column 2</td></tr>
      </table>
      HTML Code:
      <tr></tr>
      contains one row in a table, which must contain at least one table data piece to be valid.

      HTML Code:
      <td></td>
      contains a table data section, which defines a column

      To begin, use the same number of
      HTML Code:
      <td></td>
      sections in each
      HTML Code:
      <tr></tr>
      section. To get more interesting tables, do a search for "colspan" and "rowspan" on the net.

      Ordered Lists:
      The "ol" tag:
      HTML Code:
      <ol>
      <li>List item 1</li>
      <li>List item 2</li>
      </ol>
      The Unordered List:
      The "ul" tag:
      HTML Code:
      <ul>
      <li>List item the first</li>
      <li>List item the second</li>
      </ul>
      With the above, seeing what is going on with a page can be much simpler.

      When looking at theme files, you can get fairly good mileage by simply ignoring the php and looking at the above tags, seeing what is in them, and figuring out where the piece you want to modify is.

      Also, take note of the heirarchy and page types.

      Wordpress looks for pages in the following order and most themes lack most of the following...so you need to know what file is serving up the page you are looking at:

      Pages listed to the left are used if provided, then those to the right are used if not. Everything leads back to index.php.

      Date Archives:
      date.php > archive.php > index.php

      Category Archives:
      category-#.php > category.php > archive.php > index.php

      Tag Archives:
      tag-SLUGNAME.php > tag.php > archive.php > index.php

      Author Archives:
      author.php > index.php

      Home Page:
      home.php > index.php

      "Page" pages:
      pagename.php > page.php > index.php

      Search result pages:
      search.php > index.php

      Page not found (404) pages:
      404.php > index.php

      Posts:
      single.php > index.php

      Image pages:
      image.php > attachment.php > single.php > index.php

      Video pages:
      video.php > attachment.php > single.php > index.php

      Audio pages:
      audio.php > attachment.php > single.php > index.php

      Application pages:
      application.php > attachment.php > single.php > index.php

      Finally, many themes use the following files:

      header.php:
      To draw the html
      HTML Code:
      <head> </head>
      section and sometimes a header and or left sidebar. It really depends on who wrote the theme. Personally, I only ever include
      HTML Code:
      <head>...</head><body>
      in it...and body only because I include theme options to stuff extra things such as javascript in the body tag.

      index.php (or one of the above files from the heirarchy )
      This normally does most of the work.

      footer.php
      Typically to display some end piece of the page...how much depends on the coder. My footers generally contain any bottom content that spans multiple columns above as well as the </body></html> and that is about it.

      For html and php, if you want to know what something is, I recommend:

      php.net (for php). Read the first couple chapters of the reference manual and you will be good to go for most things.

      w3.org (for html and css). Read the HTML specifications or just search for the tags you want more information about.
      {{ DiscussionBoard.errors[1047342].message }}
  • Profile picture of the author inetmilionaire
    LibertyUnc:
    Wow! Thanks!

    I am a bit of a deever with HTML, that is to say, I am competent enough to put together a decent sale-able page and hack code where I need to. CSS is my downfall - I do not know CSS links to HTML or its coding. Also I know nothing of PHP but die() says its easy - I am an x-hobby programmer so I reckon I should pick it up in a snap. I have a great book on PHP in a box somewhere that unfortunately has been buried due a recent move - bummer! Anyway I will go to w3.org and check out info on CSS so thanks for that reference.
    Your other references on the internal working of WP was definitely cool - I pasted this into a doc and will keep it handy when I look further into it.

    OK! Well my goals are 1. To learn how to put in a CPA ad in my WP blog; 2. Learn how to put that CPA ad in a position on my blog that is not 'automatic' (probably something to do with header/footer.php, and on the side is probably a widget); 3. To determine if I can put adsense into a theme that is not adsense activated. If anyone can answer this definitely, many blessings upon you.

    OK! Cheers everyone, esp. Liberty Unc, and L.U. I like your signature quote.
    {{ DiscussionBoard.errors[1054122].message }}
    • Profile picture of the author LibertyUnc
      Very welcome.

      I'm actually putting together a little wp plugin that will let people place a small snippet of code wherever they want (in posts, pages, index.php, etc. ) and have it serve up a specified (or rotated) offer in that spot.

      It's more to explain how to do it than anything, but I figured if I was going to go over the ins and outs of creating plugins I'd create something semi-useful.

      CSS is pretty simple, but can become a pain due to differences in browsers ( particularly ie ) and the sheer number of different attributes there are to remember.

      That said, it boils down to the following:

      Using id=, class=, and style=
      Most tags will accept an id, class, and/or style attribute.

      style="(attribute_list)" is meant for setting style information directly.

      class="(attribute_list)" is meant for creating a particular style that you will reuse where you want to

      id="(attribute_list)" is meant for the same thing as class, but it should be limited to one id per page so that it can be properly referenced via scripts.

      for example:
      HTML Code:
      <p style="font-weight: bold; text-decoration: underline; text-align: center;">some text</p>
      That would make "some text" centered inside of its containing block and show it as being bolded and underlined.

      If you created a <style></style> section inside of the html <head></head> tags ( or created a stylesheet and referenced it in the header ) then you could do this for the same effect:
      HTML Code:
      p.b-u-c {
      font-weight: bold;
      text-dectoration: underline;
      text-align: center;
      }
      <p class="b-u-c">some text</p>
      You could also simply use:
      HTML Code:
      .b-u-c { style information }
      Which would let you apply the class="b-u-c" to just about anything.

      The "." denotes that you reference it with class="".
      If you want to set an id, then you use # instead...
      HTML Code:
      div#b-u-c { style information here }
      
      <div id="b-u-c">The things in your div</div>
      Setting default styling for html entities
      Additionally, you can set default looks for things by simply setting up their tags.

      Perhaps you want all paragraphs to have 0.125 em of space above them. You could do the following:
      HTML Code:
      p {
      margin-top: 0.125em;
      }
      Once you see how it works it is simply a matter of becoming familiar with more tags, realizing which ones apply to which types of html tags, and then experimenting to get the look you want.
      {{ DiscussionBoard.errors[1065066].message }}
  • Profile picture of the author sunsoftsystem
    Install it in your local computer, just play with it you will get experience, it is an time consuming.
    {{ DiscussionBoard.errors[1089699].message }}

Trending Topics