You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This seems to have stopped working with one of the more recent refactors, as this now returns 'wordpress_postType_view' which on the face of it seems much more ambiguous. How would you suggest rendering different content on the home page/ without doing something awful like hardcoding the bog home url path?
Modifying wordpress_homepage_view.xml and adding something like this to render an alternate template?
The layout handles changed in version 3 to more closely reflect WordPress. WordPress doesn't have a set homepage and sometimes it's the default post list and sometimes it's a static page. As a result the controller path (which generates the main layout handle) has changed.
There are many other layout handles applied though, so using one of those will allow you to apply different layout updates depending on if it's the archive for post_type=post (which is what used to be the homepage).
The best way to do this is to look at FishPig\WordPress\Controller\Action::addLayoutHandles. You can add the following to the top of that method to see all applied layout handles for the request:
echo '<pre>'; print_r($handles);exit;
Doing this shows:
wordpress_post_type_post_view
This is in the format: wordpress_post_type_{{POST_TYPE}}_view
So as you are looking for the post_type=post, this becomes:
wordpress_post_type_post_view
The wordpress_homepage_view layout handle is still set for this postType so you can use your approach by changing the template via the layout XML; that should work.
If you want to detect this in PHP, this approach won't help but what you can do is check the registry to see which postType is set.
if ($postType === $this->_coreRegistry->registry('wordpress_post_type')) {
if ($postType->getPostType() === 'post') {
echo 'This is the archive for post_type=post';
} else {
echo 'This is the archive for post_type=' . $postType->getPostType();
}
} else {
echo 'This is not a post type archive page.';
}
In prior versions of the module you could detect if the template rendering was the Homepage within a template with
if( $this->getRequest()->getFullActionName() == 'wordpress_homepage_view')
This seems to have stopped working with one of the more recent refactors, as this now returns 'wordpress_postType_view' which on the face of it seems much more ambiguous. How would you suggest rendering different content on the home page/ without doing something awful like hardcoding the bog home url path?
Modifying wordpress_homepage_view.xml and adding something like this to render an alternate template?
The text was updated successfully, but these errors were encountered: