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

The has_block function does not work on blogroll index views #14758

richtabor opened this Issue Apr 1, 2019 · 2 comments


None yet
3 participants
Copy link

richtabor commented Apr 1, 2019

Describe the bug
The has_block() function (link) from #9058 does not return true if a particular block is present on a blogroll index/archive/search view. The function does work as expected on a single page. Perhaps there's another way we should be checking for blocks that would function everywhere?

Expected behavior
The has_block() should return true if a block is included on a blogroll page.

Additional context

  • Tested on 5.1.1, as well as Gutenberg 5.3

This comment has been minimized.

Copy link

swissspidy commented Apr 2, 2019

What is your goal?

Worth keeping in mind the purpose of has_block(): to determine whether a $post or a string contains a specific block type. By default it checks the global $post object. If you want to know whether there are any blocks anywhere in the current archive view, you'd have to loop over all posts in the view and run has_block() for each of them.


This comment has been minimized.

Copy link

youknowriad commented Apr 18, 2019

I'm going to close as it has a good reply.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.