Say I have this in my static HTML/CSS page. How can I make the div class=”products” dynamic? How about the product headline, and the other div classes? Basically what I want to know is this: How can I make html elements with classes and id’s dynamic with php wordpress APIs built in, as well as the headlines and such?
Obviously in the backend (WP dashboard) all I want to do is supply a headline, img, content, price, etc..
All the tutorials I see are about blog post. This will not be a blog, although a blog page may be included later, the homepage is that of a normal site.
<div class="products">
<img src="#" alt="just an example">
<h2>Product Headline</h2>
<p> Content goes here </p>
<div class="product-call-to-action">
<div class="product-callLeft">
<p><span>$</span> 450</p>
</div>
<div class="product-callMiddle">
<p>Oct 10, 2014 | 3:14 PM</p>
</div>
<div class="product-callRight"> <a href="#" class="product-check-out" target="_blank">Buy Now</a></div>
</div>
Understanding this, will unlock all the answers to my questions I have in my mind building upon this foundation.
You don’t. You create different template pages in your theme which are designed to present different content in different ways.
So
single.php
shows a single blog post.page.php
shows a single page.archive.php
will be used to show a category of posts. Then add template files to display custom post types, custom page templates, archives for custom posts types etc etc all in different ways. Each template can have different HTML markup. That’s how you build up a custom theme.WordPress does the magic within The Loop, it ‘knows’ which template to use based on the frontend url being accessed and your permalink structure. The best thing for you to do is read up on the Template Hierarchy, if you are doing WordPress work you will find it massively useful;
http://codex.wordpress.org/images/9/96/wp-template-hierarchy.jpg
The only dynamic classes relate to this;
http://codex.wordpress.org/Function_Reference/body_class
This automatically assigns a series of classes to the body tag depending on the WordPress content being displayed allowing you to style the same markup differently using CSS specificity.
As diggy points out in the comments, you can get even finer control than the page-wide
body_class
by using the more specificpost_class
;http://codex.wordpress.org/Function_Reference/post_class
You’re going to want to explore custom post types. That’s the best way to handle your situation. Custom Post Types