Support » Themes and Templates » Help understanding template php – vantage_before & vantage_after??

Help understanding template php – vantage_before & vantage_after??

  • I have a general question to help me understand how this template works. For example, in the menu.php file the following code exists:

    <?php do_action( ‘vantage_before_masthead’ ); ?>

    I have a basic (very basic) understanding of php. What I don’t get is what the ‘vantage_before_masthead’ is referencing. Is this a method/function that has been defined elsewhere? If so, where and how does the browser know where to find it? These ‘vantage_before_…’ and ‘vantage_after_…’ are everywhere and I can’t seem to figure out what they are doing.

    Any help from anyone would be greatly appreciated!!

Viewing 2 replies - 1 through 2 (of 2 total)
  • Moderator Jose Castaneda



    It’s a hook that is used by the theme. That way you can modify output when using a child theme. 🙂

    Say for example you wanted to add some random CSS via PHP ( the Gods would wonder why? ) just before the masthead. You would use some code in your child theme’s functions file:

    add_action( 'vantage_before_masthead', 'child_css_masthead' );
    function child_css_masthead(){
      #masthead { color: blue; max-width: 80%; }
      #menu-primary { display: hidden; }
    <?php // end random styling

    Or you can even add some needed JavaScript if you needed. Some hooks are neat to have in themes. Makes working with them that much easier from a development point of view. 🙂

    Thanks, Jose! Do you (or anyone else) know where that ‘hook’ is defined? Using my original code example:

    <?php do_action( ‘vantage_before_masthead’ ); ?>

    I interpret this as “do the following action: ‘vantage_before_masthead'”. But in order for it to know what to do, doesn’t “vantage_before_masthead” have to be defined somewhere since this is obviously not a built in function? Maybe I am totally misunderstanding how this works. Or is this saying place “vantage” before “masthead”?

    I’m going to start learning php soon, but for now…

Viewing 2 replies - 1 through 2 (of 2 total)
  • The topic ‘Help understanding template php – vantage_before & vantage_after??’ is closed to new replies.