Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extract the navigation menus into separate template parts. #17

Closed
bobbingwide opened this issue Nov 3, 2020 · 4 comments
Closed

Extract the navigation menus into separate template parts. #17

bobbingwide opened this issue Nov 3, 2020 · 4 comments
Assignees
Labels
enhancement New feature or request

Comments

@bobbingwide
Copy link
Owner

While developing the archive.html template file I decided to extract the navigation menus
into separate template parts.
I decided to try two methods.

For the footer menu I extracted the navigation into a footer-menu template part then added this to each template, 9 in all.

<!-- wp:template-part {"slug":"footer-menu","theme":"fizzie" "className":"footer-menu"} /-->

For the header-2-columns template part I'd extract the navigation into header-menu, including this template as an inner block. Fewer changes.

@bobbingwide bobbingwide added the enhancement New feature or request label Nov 3, 2020
@bobbingwide bobbingwide self-assigned this Nov 3, 2020
@bobbingwide
Copy link
Owner Author

bobbingwide commented Nov 5, 2020

Having extracted the navigation menus into separate template parts - commited as b442481 with no mention of this issue in the commit message - there's a problem in s.b/wp56 with the home page, which is displaying two footer menus.

I'd deleted all of the custom templates but not the custom template parts, except the footer-menu.

The footer-menu is being loaded in the front end with the following
code in the footer custom template part ( ID 561 ).

<!-- wp:template-part {"postId":978,"slug":"footer-menu","theme":""} /-->

In the block editor, when editing the footer, the menu is not being populated.
image

Q. How come it's not being loaded in the editor but is being loaded in the front end?

BTW. The problem does not occur for the header-menu since the custom template part header-2-columns has not been changed. Actually, that's a different problem.

@bobbingwide
Copy link
Owner Author

bobbingwide commented Nov 5, 2020

Q. How come it's not being loaded in the editor but is being loaded in the front end?

In the front end it's being loaded by fizzie_load_template_part_file_by_slug.
In the editor the request is:

https://s.b/wp56/wp-json/wp/v2/template-parts/978?context=edit&_locale=user

this returns the trashed post.

{"id":978,"date":"2020-11-02T16:52:49","date_gmt":"2020-11-02T16:52:49","guid":{"rendered":"https:\/\/s.b\/wp56\/?post_type=wp_template_part&#038;p=978","raw":"https:\/\/s.b\/wp56\/?post_type=wp_template_part&#038;p=978"},"modified":"2020-11-05T07:19:09","modified_gmt":"2020-11-05T07:19:09","password":"","slug":"footer-menu__trashed","status":"trash","type":"wp_template_part","link":"https:\/\/s.b\/wp56\/wp_template_part\/footer-menu__trashed\/","title":{"raw":"Footer menu","rendered":"Footer menu"},"content":{"raw":"","rendered":"","protected":false,"block_version":0},"template":"","meta":{"theme":"fizzie"},"_links":{"self":[{"href":"https:\/\/s.b\/wp56\/wp-json\/wp\/v2\/template-parts\/978"}],"collection":[{"href":"https:\/\/s.b\/wp56\/wp-json\/wp\/v2\/template-parts"}],"about":[{"href":"https:\/\/s.b\/wp56\/wp-json\/wp\/v2\/types\/wp_template_part"}],"version-history":[{"count":6,"href":"https:\/\/s.b\/wp56\/wp-json\/wp\/v2\/template-parts\/978\/revisions"}],"predecessor-version":[{"id":1027,"href":"https:\/\/s.b\/wp56\/wp-json\/wp\/v2\/template-parts\/978\/revisions\/1027"}],"wp:attachment":[{"href":"https:\/\/s.b\/wp56\/wp-json\/wp\/v2\/media?parent=978"}],"wp:action-publish":[{"href":"https:\/\/s.b\/wp56\/wp-json\/wp\/v2\/template-parts\/978"}],"wp:action-unfiltered-html":[{"href":"https:\/\/s.b\/wp56\/wp-json\/wp\/v2\/template-parts\/978"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}

It would appear there's no logic to find the template part from the theme's files when editing the wp_template_part CPT. Not sure how the Site Editor (beta) deals with this.

Workaround / fix

Delete the custom footer template part.

@bobbingwide
Copy link
Owner Author

The About menu item should link to the about page.
For the future, there should also be a Themes menu item linking to oik-themes.

@bobbingwide
Copy link
Owner Author

For the future, there should also be a Themes menu item linking to oik-themes.

The Themes menu item was implemented in #51

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant