Mouse6541
Mouse6541

Reputation: 167

Wordpress custom post types for different styled paragraphs

My homepage has content that look's something like:

<section id="about">
    <p class="quote">
    </p>
    <div class="text">
        <h2></h2>
        <p></p>
    </div>
</section>

<section id="about-photo">
    <div class="image">
        <img src="" alt="">
    </div>
</section>

<section id="mission">
    <div class="text">
        <h2></h2>
        <p></p>
    </div>
</section>

I was wondering whether the way to reproduce this structure in a CMS would be to create custom post types. My reasoning is that I have different types of p tags (".quote", and a non-classified "p"). From all the examples that I've seen, however, it does not seem like custom post types get used this way. That is, using two separate fields for "paragraph-like" information.

Upvotes: 1

Views: 480

Answers (2)

nim
nim

Reputation: 507

you can do like below:

  • Create the custom post type with tag.
  • Add the number of post in this post type with unique tag name.
  • create the loop with all thie post type and in this loop set the condition like, if(post tag name == "about") { // you "about" style selection div }else if(post tag name == "about-photo"){ // you "about-photo" style selection div }else if(post tag name == "mission"){ // you "mission" style selection div }

Upvotes: 0

Siegfried Grimbeek
Siegfried Grimbeek

Reputation: 897

I did exactly this a while ago. If you do not mind paying a little bit for a great plugin.

Step 1: Get the advanced Custom Fields Plugin - Awesome for Custom fields and really simple to add to you template.

Step 2: Buy the repeater field plugin for Advanced Custom Fields

Step 3: Install plugins.

Step 4: Create the custom fields by creating a repeater field with two sub fields. The two sub fields should be paragraph and class. Be sure check the strip html setting for the class field.

Step 5: Add to template.

You can even make the class field a select list if you have predefined values.

Upvotes: 1

Related Questions