Q: How do I get the 'display id' ($display_id) of a view display so that I can pass it to views_embed_view() when programmatically showing a view?
A: View display ids follow a pattern like page_1, page_2, block_1, block_2 etc., depending on the display type - they do not follow the display's title (I spent a lot of time trying to plug in variations of the display name with no success!) The documentation for views_embed_view() does not explain what the display id is or where it comes from....
There is a simple way to figure out what it is. Navigate to your view in the Views UI, make sure your display is active by clicking on it and then hover your mouse over one of its settings (for example, its title) - the display id will now be displayed at the bottom of the browser as part of the link url, for example:
Here 'page_1' is the display id and can be passed to views_embed_view() as follows:
print views_embed_view('user_horses', 'page_1');
So, you can either get it this way, or just guess it if you manage to remember the page_1, page_2, block_1, block_2...... pattern (which I can never do even though it's very simple!).
Did you find this post helpful? If so, we'd love to hear from you in our comments! If you found it really useful we'd love a link from your Blog-Web Site, to us!
I was looking all over for this!