cscott5288
Forum Replies Created
-
Forum: Fixing WordPress
In reply to: nextgen gallery not showing up on pageHas anyone found a solution to this problem? I am having the same problem …
Forum: Themes and Templates
In reply to: Placing sidebar within the_contentI’m going to guess from the cricket sounds that this is absolutely impossible to do. O well.
Nvm, i’ve figured it all out pretty much. Surprisingly, the method I used works well! Although I had some improperly placed php delimeters in the above code I linked to.
I’m now at the point where the template is outputing the HTML where I want it to .. it’s just a matter tweaking the design. Thanks everyone for all your help, especially you alchymyth!
I spent quite a while coding the loop .. I used a lot of counters to make sure the HTML get’s put in the right spot… please don’t laugh when you see it.
I tried it out and, as I suspected, the template is all broken but at least there are no php errors (although there is PHP code being displayed on the page as text!).
Here is the index page containing the loop (which is probably coded improperly).
Here is the HTML I am looking to output (what it SHOULD look like).
I would really appreciate it if anyone could have a look at that code and tell me what I am doing wrong or if there is a better way I should be doing it. THANKS!!!
“do you have no buddies in the campus to discuss simple programming logic things like this?”
Nope. I’m a journalism major, not a coding/programming major and no one I work with on the paper has coding experience. I do appreciate the help from this forum though. My only real difficulty is in coding the main index loop.
But is my understanding of the foreach/while loop correct?
thanks again
Okay, I am now in the process of coding my entire front page on the hope that this code will work. I am throwing in tons of if statements and counters in both the while and for each loop because I have a need to place content and design elements in-between category blocks … it’s taking a lot of my time.
Basically, my understanding is that the foreach loop essentially sets up the while loop to only work through data for 1 category (and 5 posts within that category) each time. Then, during the second iteration of the foreach loop, the while loop goes through the data for the next category (and 5 posts within that category). And so on, up until all categories have been gone through.
When the while loop is finished with its data (and gone through all 5 loops), it goes back to the foreach which sets it up with new data (causing it to go through another set of 5 loops). Am I correct in this understanding?
Let’s say I had placed a counter variable ($i++) within the while loop for my own purposes. Would that counter reset during the second time the while loop is used (at the point that it starts on its second set of category and post data)? Or would the counter go up to 6 at the start of the second time the loop is used (seeing as it is that it already went through 5 for each post)?
Thanks alchymyth. I think I understand it now. I’ll try implementing it and let you know if it worked.
Thanks for the explanation alchymyth. That is how I thought it would work.
But my concern is this: Won’t the foreach loop continue outputing posts until it is completely finished with all posts, making it impossible to throw in a category link inbetween the posts that are in different categories? I’m sure you considered that and maybe that’s why you put wp_reset_query(); in there. But I still don’t understand exactly how that works.
Okay alchymyth, it all makes sense to me, except there is one thing I am unclear about.
how exactly does a while look work within a for each loop? I have difficulty following the logic in that.
Like how, at the end of each iteration of the while, does it end up going back to a new iteration of the foreach which takes it through another while?
I am being very abstract here but you are no doubt used to working with abstract coding concepts so I was hoping you would be able to clarify.
Thanks again alchymyth. This is no the first time you have helped me with a major problem. Do you have a website or blog I can follow? ??
Let me just make something clear, by saying ” I would like to use your code but I make it a rule to never use code that I don’t 100% understand.” I did not mean to imply that I don’t intend to use your code. I intend to! I just need help understanding it.
Thanks ahead!
Thanks soooooo much for your help alchy —
Okay, I sort of get what you are doing. But I have a few questions:
– what is “$cat->term_id” doing in the for each loop?
– the query_posts function is exactly what I needed! thanks for finding that for me.
– can you explain to me how exactly a while loop within a foreach loop works. That is what you have, correct? Does the foreach loop do its think for one variable, then run through the while loop, then go back to another variable and run through the while loop again? I just don’t get it. I stared at your code for a long time and I am just boggled. I would like to use your code but I make it a rule to never use code that I don’t 100% understand.I am very new to PHP and thinking REALLY hard abstractly … so I hope you can forgive me!
Okay, well I haven’t had any response so I’ve sort of taken things into my own hands.
Here is what I am in the process of doing, PLEASE STOP ME OR CORRECT ME IF WHAT I’M DOING IS NOT THE RIGHT WAY TO DO IT:
I’m going to set up an if condition within the loop that checks what the post_category (a property in the $post global variable) ID number is. If the post_category ID number is equal to the first category I want to display, I will execute ALL of the HTML/PHP (including divs, post titles, the excerpt, etc) for ALL the teasers I want to display (multiple teasers will be displayed after multiple while loops).
IF the post_category is not equal to the first category items I want to display, I will then throw the global $post variable into a variable. I will use a counter and switch statements that will cause the loop to throw $post into different variables, depending on what number the counter is up to (because I don’t want to rewrite the same variable every time).
And from there, you can probably induce where I plan to go. I know the above explanation might sound confusing .. it is kind of confusing to explain these sort of abstract things.
WHAT I DO NEED TO KNOW: Can I mess with the global $post variable by throwing them into different variables (during each loop) and re-using them later?
Does my plan make sense? This really is my first complicated PHP exercise. I really could use some help!
Forum: Themes and Templates
In reply to: why isn’t the is page function working for meYes but, I am looking to get a class generated based on a certain condition …
Forum: Fixing WordPress
In reply to: Trying to get custom fields meta data to display in template@1gr8
I have no idea what you just said
Forum: Fixing WordPress
In reply to: Trying to get custom fields meta data to display in templateBeen studying that guide an still can’t figure out what I am doing wrong. Appreciate any help ..