• Hi

    I am reading this:

    https://codex.www.ads-software.com/The_Loop_in_Action

    And a lot of the basics don;t make sense to me. i have been told once you understand one language (as in programming), others make sense more easily.

    I have been playing with WP for a while now and have a good understanding of css and HTML, but I was wondering if there is any tutorials I should do 9such as PHP) before trying to understand this further. When the author starts talking about if statements and the like I get lost.

Viewing 9 replies - 1 through 9 (of 9 total)
  • I just jumped in and started moving code around. It really helped me understand what the loop was, don’t know I could have understood it as well from just reading about it.

    The loop can be seen as the fuction of passing instructions to all content that is output as the result of a query.

    For example, If you put php code to show a link to a post’s category in “the loop” it will apply that code to every post that get’s called in the query. or, every post in the loop. All posts will show that link.

    Think of it this way:

    Say you had two queries on a single page, and one has such a category link in it’s loop, and the other query does not. The posts which are output by the first query have the category code “in the loop” but for the second query, that code is “outside” of it’s loop. So it won’t get applied to the posts which it outputs. Get it?

    You know if your code is in the loop by knowing what code for the loop looks like. the twenty ten theme actually says “end of the loop”. If you place code outside the loop code, it does not get applied to the posts that are output in the query. So the php to show the category link wouldn’t do anythng if outside the loop.

    Create an if statement, just put in category slugs that exist on your site.

    <?php if (in_category('category-slug')) { ?>
    
     this text will show up if the post is in this category
    
    <?php } ?>

    Can you tell me if that conditional code is to be used “in the loop”? I’ll tell you it goes in single.php. Can it do what it should do if it is outside the loop? can it go after the content is output? or should it go before? This text could have been code which could be applied according to the same conditional.

    give it a try, put it in and out of the loop and see.
    just don’t use a live site of course.

    let me know how it goes and we’ll get to the next assignment. I’m learning too:)

    Try reverse engineering. Choose an existing theme (lots of free themes out there) and tinker with it. That’s how I started with WordPress. ??

    If your experience is limited to html and css, php will indeed seem very hard to understand. Much php instruction assumes a knowledge of traditional programming languages and concepts, especially “Control Structures” such as the “if” you mentioned.

    I would recommend starting out with the most basic of Computer Programming concepts “courses” in whatever form (classroom, self-study, computer-based, book, web site, etc.) works best for you.

    It is not that difficult, but it does require some time and patience and thought to grasp. Unlike html and css, traditional programming languages allow the concept of Iteration: repeating a series of statements until a condition is met.

    It was true in 1971 when I first learned to program, and it is still true today.

    Thread Starter Unconformed

    (@unconformed)

    Hi guys

    thanks very much for your support.

    I have a site

    https://www.mylifeisagarden.com

    And I have a local version running so I am ok with all that stuuff (thank god that saves about ten hours right there).

    @deepbevel

    I will take a look, and try place in and outside of the loop as you mentioned.

    I need to look up EXACTLY what a query is. I know what it means (the software calls for instructions) but I don;t get it in the context.

    I can’t remeber what a lug is, I thought it was a sample of the main content, or something to do with a permalink. I’ll look it up.

    I’m still having problems grasping what the loop is doing in terms of a catogory. I know what a catogory is, I have used them correctly in my blog to display anything that relates to Spring garden updates. However I’m not sure how it would be used in multiple areas.

    @cadencehart

    Good point, I have a local setup at work and home. I’ll just start pulling code in and out to see what happens.

    @adiant

    thanks you, I will probably start with php tutorial and work backwards. Do you have any suggestions for a basic Programming concept ( a link to a website tutorial would be helpful, I am doing the self teaching thing for now. I may go off and do a proper course in PHP soon).

    Meanwhile, I have a really, really nasty javascript problem at work so I am off to do jquery tutorials (the plugin uses it). WISH ME LUCK!

    Thanks!

    In terms of a category, the loop uses categories as one of it’s criteria for a query (a search for posts). the loop says, “am I looking for posts in category 1, or catefory 2? or both? or am I not even supposed to concider categories?(all posts are in a category, but maybe there’s only 1?)
    So if the query returns a bunch of posts because they are in category 1, it’s because it was told to do so, by a repeating instruction in the query. ( I beleive that’s called an argument, but don’t quote me on that) If the instruction is placed outside the querry, it doesn’t get repeated for every post, and so doesn’t get exececuted as part of the queries “output”. In this case, the output being posts in category 1.

    I only have a working understanding of this, it’s limited and I may use some terminology wrong sometimes, but I really try not to. I’m not super clear on the real difference between the loop and a query, so I may mix them up in some of my babbling here.

    .

    I googled this:
    basic computer programming concepts php
    and found this:
    https://inpics.net/tutorials/php/loops.html
    which is probably what you are looking for: a combo intro to “logic and loops” (“if” and such) and php basics.

    thanks!

    Thread Starter Unconformed

    (@unconformed)

    thanks guys! I am learning about javascript which is giving me some fundamentals on programming too, but I will be back to do this tutorial.

    I am yet to play with the loop on my blog. I am not 100% sure how I can implement yet but I will know soon.

    Thread Starter Unconformed

    (@unconformed)

    heheh still no better off but not really focused there

Viewing 9 replies - 1 through 9 (of 9 total)
  • The topic ‘Need a poke in the correct direction’ is closed to new replies.