Support

Account

Home Forums General Issues Hypothetical : Using Flexible Content to Design Single-Post and Single-Page?

Solving

Hypothetical : Using Flexible Content to Design Single-Post and Single-Page?

  • I’ve been developing my own (not nearly as amazing) version of a theme that’s very much like the new Divi craze going on in the WordPress community.

    I’ve got lots of flexible content fields that are for the “Home” page, and can even code them (or a variant) up to do the “News” page.

    But I was considering making a feature where you could make pages called Single Post and Single Page. The theme would then pull from the layouts of THOSE pages for when it goes to display a post or page. I know I can do this PER post/page; but I need a way that lets me “theme” posts/pages at a higher level, so that unless it detects that it has local Flex Content it uses the layouts detected for from these other pages “Single Post” “Single Page”.

    Keep in mind these “layouts” would bookend the_content. That is, I’d have a “module” you’d drop in to display where you want the WYSIWYG of the actual post/page to come in at. I’m at an intellectual loss though how I would pull in the modules/flex-fields from other page setups, but then display the_content from the post/page you’re looking at.

    I guess I need a bit of a push. Just a nudge in the right direction. I think I could make the pages and then… pull their values in from their ID? I imagine the code wouldn’t be too complicated.

    Any thoughts/help are appreciated.

    ——————————————————-

    Talking through the problem some in the vacuum.

    Right now I have index.php

    index.php then includes sectionBuilder.php where I build most of the code for the page.

    sectionBuilder.php then includes rowBuilder.php where I have my flex-rows.

    I guess, given the Theme Hierarchy, I need to turn my attention to single.php and page.php

    From here I can use the method for Getting Values From Other Posts . I should then be able to make a variant of the sectionBuilder and rowBuilder that pulls from those other pages I make. I just won’t include that in the new “module” I write for including the_content.

    I think I can also do a thing towards the top of the file to see if we’re looking at a post or a page. Also I’ll need a way to get the ID of a page by it’s name (since the ID may be different each time I install the theme.

    ——————————————————-

    I … THINK I am on the right track. I’m trying to solve this before I get to the real problem. I’m still working on other code, but trying to wrap my head around this while it’s still a hypothetical.

  • I was out of comission due to some sickness. Apparently this was never seen by anyone. Ah well. I’ll plot along and see if I can figure it out.

  • It was probably see, just that no one had any input. There have been many topics started here about using ACF and flex fields, as well as other methods of using ACF as a page builder. I looked at this, but I can’t say that I understand what you’re trying to do. If I was building a page builder using ACF, which I’m actually thinking about, then I would require that any pages built with it use that builder. Getting some default “layout” post and trying to insert the content of the post into that layout is probably a lot more complicated. But to do this you’d need to filter all of the post content by creating your own “the_content” filter that runs whenever WP outputs content and alter it there.

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

You must be logged in to reply to this topic.