Announcement

Collapse
No announcement yet.

Help with functions code

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • Help with functions code

    I'm trying to use labels (check box) on blog post pages, so it's easy to control what offer we put after blog post. With the code below I'm basically trying to set a default... if is not X, Y, Z, place THIS BANNER.


    PHP Code:
    //ADD BANNER
    add_action'genesis_entry_footer''place_correct_banner' );
    function 
    place_correct_banner() {
    if ( 
    is_single () ) && if (! dynamik_has_label array ('structure''psychology')) {
    echo 
    do_shortcode'[fl_builder_insert_layout slug="optin-after-post"]' ); 


  • #2
    Unfortunately, there is no question, so ... not sure what´s intended and what the problem is.... Only thing I can guess from the code is that a third party plugin is involved (Beaver).

    sterdizzy I´d suggest you file a ticket with support staff from your My Account page and give them a possibility to log in and inspect your setup. These are usually not the problems we can solve here in forum.

    Comment


    • #3
      SiGa Then, let's forget about the shortcode for Beaver builder. My question is how can I create a function that says "Does NOT have DYNAMIK LABEL X, Y, Z"? I'm trying to target pages that don't have certain labels associated.

      PHP Code:
      //ADD BANNER
      add_action'genesis_entry_footer''place_correct_banner' );
      function 
      place_correct_banner() {
      if ( 
      is_single () ) && if (! dynamik_has_label array ('structure''psychology')) {
      ** 
      PLACE DEFAULT BANNER

      Comment


      • #4
        is_single () will not work on pages and that´s where the first problem starts if I blindly hand out code snippets and it doesn´t work (not talking about involved "structure" and "psychology" I don´t know anything about). Not sure if you´d even need that, as the labels are likely only available on single pages and posts anyway. Could try and guess a dozen times, including if it´s rather && or || in your case (in my opinion, your code currently says it has to have all three labels, else it won´t work). Hence ===> support, because support would SEE what needs to be seen.

        All I´d point to is that the second "if" isn´t necessary.

        Here´s a sample of Dynamik labels in use and maybe you can go from there:
        https://gist.github.com/srikat/8414387

        It´s either
        Code:
        if ( dynamik_has_label('leads') ...
        or
        Code:
        if ( !dynamik_has_label('leads') ...
        Last edited by SiGa; 01-09-2018, 03:41 PM.

        Comment


        • #5
          Thank you for your replies, let me try and explain a bit clearer.
          • I just want the function to execute ONLY on blog posts.
          • I have 3 labels based on content subject (each will have a unique banner)
          • If the blog post doesn't have one of those labels checked, I want it to default to a 4th banner.

          Based on the code you sent me.. I created a hook for 'after comments' (tried 'after entry' also) but didn't work.

          PHP Code:
          <?php
          function place_banner() {

              if ( 
          dynamik_has_label('structures') ) {
                  echo 
          do_shortcode'[fl_builder_insert_layout slug="structure-cta"]' );
              }
              elseif ( 
          dynamik_has_label('psychology') ) {
                  echo 
          do_shortcode'[fl_builder_insert_layout slug="psycholcta" type="fl-builder-template"]' );
              }
              elseif ( 
          dynamik_has_label('mindset') ) {
                  echo 
          do_shortcode'[fl_builder_insert_layout slug="mindsetcta" type="fl-builder-template"]' );
              }
              else {
                  echo 
          do_shortcode'[fl_builder_insert_layout slug="default_cta" type="fl-builder-template"]' );
              }
          }
          ?>
          Note: I pasted this code into a Dynamik Hook box.

          Does that make it easier to help me SiGa ?
          Last edited by sterdizzy; 01-10-2018, 03:58 PM. Reason: update the code

          Comment

          Working...
          X