Support

Account

Home Forums Front-end Issues The_Field: On Main Blog Page

Solved

The_Field: On Main Blog Page

  • Can I get help please? I’d like to add two columns on either side of the main centre content container, and for some reason, they are only showing up on the page, when the rules specify “Post Type = is equal to = Post,” then the columns appear on every page that includes the Posts (via single.php).

    Now, I’ve tried different variations for getting these exact same fields to work on the main pages (main, being the Home page, other Pages, plus the Main Blog Page [index.php]), however they are not appearing.

    This is how each of the fields are being entered:

    <div class=”sidebar-content-left”><?php the_field(‘sidebar-content-left’); ?></div>
    <div class=”sidebar-content-right”><?php the_field(‘sidebar-content-right’); ?></div>

    *When entering: “Show this field group if:”
    “Page Template = Equal to = Default” ***EVERY page is Default; same “the_field” codes added to all page.php, single.php, index.php

    When it’s ==> “Page = Equal to = (The name of the actual Main Blog Page)” – Not displaying anything.

    **So why is it that this is only working through single.php, on the single post pages?

    Help!!

    • Elliot

    • January 7, 2014 at 10:05 am

    Hi @jenfixingstuff

    Please understand that the ‘location rules’ are used to display the field group on a specific edit screen in the back end. This does not always relate to the front end template.

    Can you please confirm that the location rules are working correctly in the back end?
    Do the field groups show up on the correct edit screens in the back end?

    Can you please clarify where the field groups are showing and what data you have entered. Perhaps a screenshot of the backend screen where you input the values?

    Thanks
    E

  • Hi, @elliot! Thanks very much for the fast reply, I really appreciate it!
    *Both fields are displaying on every back end Dashboard page and post page, just not [main blog page] on the front end, live site.

    Screenshots and code for everything, I hope this helps:

    1) Markup of the fields, for all Default Template pages (page.php), single post pages (single.php), and main blog page (index.php):
    1 Markup

    1B) Each of the fields have been coded like this:

    <div class="column-all-left">
       <div class="sidebar-categories"><?php get_sidebar(); ?></div>
       <div class="sidebar-content-left"><?php the_field('sidebar-content-left'); ?></div>
    </div>
    <div class="sidebar-content-right"><?php the_field('sidebar-content-right'); ?></div>
    <div class="content-default-center">

    CSS markup includes:

    div.column-all-left {background: burlywood; float: left; margin-right: 2%; width: 14%; padding: 0 2%; font-size: 80%; word-break: break-word; display: block;}
    .sidebar-content-right {background: burlywood; margin-left: 2%; float: right; width: 14%; padding: 0 2%; font-size: 80%;}
    .sidebar-content-left {background: yellowgreen;}
    div.content-default-center {background: burlywood; margin-left: auto; margin-right: auto; min-width: 56%; padding: 0 2%; overflow: hidden;}

    2) Setup of the custom fields, themselves (*I’ve tested the pages all using the same field names, plus using different field names just for the blog – still, same results):
    2 Fields Setup

    3) Fields displaying properly in back end Dashboard, for all pages and post pages, including blog page (blog page, displayed here):
    3 Back End Fields Visual

    4) All the pages, visually, in action! **Commentary added to the image…I hope I didn’t overcomplicate …I’m sure I have OCD πŸ˜€
    4 All Live Pages

    I’m really hoping, this is just a matter of me messing up in the CSS markup or something :s

    Thank you so much!!

    • Elliot

    • January 7, 2014 at 4:33 pm

    Hi @jenfixingstuff

    I don’t think this is an issue with CSS. In your ‘home page’ screenshot, I can see that there are only 2 columns. This is most likely because your home page is acting as the blog home page, correct?

    If so, the global $post object will not be the ‘page’ called ‘home’, it will be the first $post in the blog loop.

    You will need to find the $post_id of the home page, and then use that in your the_field calls. eg. in your home page template, edit the code to look like this:

    
    the_field('field_name', 123);
    

    where 123 is the ID of home page.

    Thanks
    E

  • My hero πŸ™‚
    Thanks very much, and I’m really impressed by your fast replies. One hundred times, thank you!!

Viewing 5 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic.

We use cookies to offer you a better browsing experience, analyze site traffic and personalize content. Read about how we use cookies and how you can control them in our Cookie Policy. If you continue to use this site, you consent to our use of cookies.