• I have a Custom Post Type called “Projects”. I have a page-projects.php that displays all of the projects. Then a single-projects.php to display a single project. Trouble is, I want the display for a single project to sort of be its own little mini sub site.

    I’ve set up the Projects Custom Post Type with Advanced Custom Fields PRO and using the Repeater type, I made it so users can enter in a title, slug and content for that internal page for each project.

    I tried using Anchor Tags (e.g., #home or #about) for each page, and hiding/showing tabs (these sub pages) with JQuery, but there’s a huge lag when the page first loads (assuming because of the huge burden placed by scripts loading from plugins). So the JQuery that will ultimately display the correct “page” indicated by the anchor tag takes a few seconds before it displays the right content. — not ideal.

    Do any of you have any ideas for me about the best way I can accomplish this functionality (i.e., sub pages on a custom post type’s single-[post] view)?

Viewing 2 replies - 1 through 2 (of 2 total)
  • Thread Starter jplwood

    (@jplwood)

    I actually changed my setup so I’m actually using native archive functionality for this “projects” custom post type. Now I have archive-projects.php and not page-projects.php.

    I know this is in Hacks — would love help doing this using Advanced Custom Fields, but am totally open to using native WP functionality to accomplish this.

    Thanks in advance!

    Moderator bcworkz

    (@bcworkz)

    WP themes and plugins have a bad habit of loading their scripts whether they are needed on the page or not. Unfortunately, changing this behavior is not always easy. If you know of scripts your post type will never use that are loaded anyway, you could dequeue the scripts after they are enqueued. It’d be better to not enqueue them to begin with, but doing so in way that is not lost after plugin updates may be impossible. This is good to do no matter what, just for the sake of faster page loads.

    One possible approach is to hide all content (except maybe for “Loading…” or similar) by default, then showing the proper content by script altering the appropriate page’s style. This assumes you think showing no content is better than showing the wrong content.

    A better variation would be to still hide all content by default according to the page’s external CSS, then have PHP determine the proper page to display (from cookie data for example), then output CSS to display that page in a head section style block. This should result in the content being displayed as soon as the browser receives it instead of waiting for scripts to load.

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Sub Pages on Custom Post Type with Advanced Custom Fields PRO’ is closed to new replies.