Link to home
Start Free TrialLog in
Avatar of andieje
andieje

asked on

Confused about wordpress 'the loop'

Hello

I have read this webpage about how the loop works in wordpress

http://blog.teamtreehouse.com/wordpress-loop-beginners-guide

How does wordpress know if it is displaying a single page or single post or multiple posts. Does the wordpress interface set something behind the scenes?

If it is a single page I presume the content i add in the wordpress text editor is stored in a database and retrieved by this call

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

	<h1><?php the_title() ;?></h1>	
	<?php the_content(); ?> <========HERE

<?php endwhile; else: ?>

	<p>Sorry, this page does not exist</p>

<?php endif; ?>

Open in new window


Lets say i was using one template for all of my website pages, and these pages were having their main content included through the template part above (which i believe gets copy from the database ), how would i have another page in the website that had additional content in the main section other than text , would i have to add the code to the template part above (probably in some if statement which checked the page?). Or would i do this with widgets somehow. In the default wordpress installation it looks like i can only drag widgets into something called primary. I was assuming you would be able to drag them into the main 'loop content' somehow

Thanks for your help.
If i wanted to add something else (other than simple text) to a web page which used the above template part for the main content of the webpage, how would i do it? Would i have to make a specific template just for that page which basically adds some extra code to that show above to generate the additional content
ASKER CERTIFIED SOLUTION
Avatar of uzzidesign
uzzidesign
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of andieje
andieje

ASKER

Sorry, you are right. I posted it late at night after a frustrating evening. I should have known better and I apologise for degrading the quality of the forum