-1

I want to output the views block of collection_products which is filtered by a taxonomy term but it doesn't print anything when I tried the following code:

print views_embed_view('collection_products','block_1','sample-category-1');

attached is the views editing page. views editing page So what might be the problem?

2
  • 1
    Are you sure that sample-category-1 is the correct parameter? Depending on how you set everything up, it might be expecting a taxonomy id or something else instead? Is the contextual filter configured to hide results if nothing matches, change it to display all data, see what happens then. That allows you to discover what is wrong. Oct 8, 2017 at 15:41
  • Also you are loading the block, but your screenshot is of the page display, so it is not at all relevant to the question. Oct 8, 2017 at 15:42

1 Answer 1

1

Try to use $term->term_id instead of $term->name in views_embed_view()

You can get it programmatically by loading taxonomy term through taxonomy_term_load() function and passing it to views_embed_view() as a third argument

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.