This is searchable archive of our old support forums, which operated from 2012 - 2016. To find out how to get support for your current theme, please visit our support page.

Pass variable (slug) to template element

  • Creator
  • #25700

    Hi Jason, is it possible to pass a variable to a template. To be exact:
    Would it possible to add a custom field to each page (%my_portfolio_slug%) and use this value in the template elements?

    I have about 10 pages (& 10 portfolio categories), each with their custom text and dedicated (portfolio category) post slider.

    On the page template I use ‘content from the current page’ and a headline with %page_title%.
    I now place each portfolio slider on the ‘current page’.

    Would be nice (easy for markup changes) if I could place a ‘general’ portfolio post slider element on the template page and somehow inherit the portfolio slug from the page that calls the template. (like using %page_title% in a headline element).

    • This topic was modified 6 years, 5 months ago by vnp.
Viewing 2 replies - 1 through 2 (of 2 total)
  • Author
  • #25707
    Jason Bobich


    You can create custom element for the Layout Builder using the themeblvd_add_builder_element() function:

    Your custom element’s callback function I assume would display a post slider, and you’d feed arguments into it based on whatever criteria you want.

    It might help to look at how the themeblvd_post_slider() function works and what you can potentially pass in through the arguments array. /framework/includes/loop.php

    Since pages obviously don’t have anything to do with portfolios and there would be no inherent association, you’d have to come up with some creative way to handle this. For example, you could name all of your pages to have slugs that match the ID’s of certain portfolio terms you’ve created. Then, you’d pass the current page’s slug (i.e. post_name of the current global $post object) to the post slider function.

    Good luck!


    That’s a great function.
    Maybe passing the variables can be done with the custom fields on the page. I’ll check it out, thanks!

Viewing 2 replies - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.