Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)
  • ahmedr83

    (@ahmedr83)

    @eliasgdj Thank you for testing ??

    I forgot to mention that a child theme is used in this case (Not sure if you used a child theme for your testing), Sorry about that. So define that custom function in Flatsome child theme > function.php. I did test again and it worked well when defined in child theme > function.php.

    The functions defined in the parent theme are Pluggable functions, which is why they are wrapped with if ( !function_exists() ). The child theme functions are loaded before the parent theme functions, which is why the custom code works, as it should, when defined in child theme > functions.php. However, for some reason, if the same custom code is defined in Code Snippets, it does not work.

    Here is a good example of Pluggable Functions

    Please note that the custom function only removes the product “thumbnails” that appear when you hover over the right/left navigation arrows. The custom function does not remove the right/left navigation arrows.

    • This reply was modified 3 years ago by ahmedr83.
    • This reply was modified 3 years ago by ahmedr83.
    ahmedr83

    (@ahmedr83)

    @eliasgdj

    Regarding “use hooks”, Flatsome does use hooks and more get added as we go along. Unfortunately, at the moment, there’s no hooks for this case scenario ??

    Regarding “Flatsome is not well programmed”, I disagree with you. Yes, improvements can be made but that goes for all themes and plugins.

    In any case, you’re missing the point. All we want to know is, why does the custom function not work in the plugin (Code Snippets) but works well in function.php?

    If you don’t know why, that’s ok ??

    ahmedr83

    (@ahmedr83)

    Hello @eliasgdj ??

    These are the functions (from Flatsome theme php file) that @mitchellk wants to manipulate ?

    if(!function_exists('flatsome_next_post_link_product')) {
      function flatsome_next_post_link_product() {
          global $post;
          $next_post = get_next_post(true,'','product_cat');
          if ( is_a( $next_post , 'WP_Post' ) ) { ?>
             <li class="prod-dropdown has-dropdown">
                   <a href="<?php echo get_the_permalink( $next_post->ID ); ?>"  rel="next" class="button icon is-outline circle">
                      <?php echo get_flatsome_icon('icon-angle-left'); ?>
                  </a>
                  <div class="nav-dropdown">
                    <a title="<?php echo get_the_title( $next_post->ID ); ?>" href="<?php echo get_the_permalink( $next_post->ID ); ?>">
                    <?php echo get_the_post_thumbnail($next_post->ID, apply_filters( 'woocommerce_gallery_thumbnail_size', 'woocommerce_gallery_thumbnail' )) ?></a>
                  </div>
              </li>
          <?php }
      }
    }
    
    if(!function_exists('flatsome_previous_post_link_product')) {
      function flatsome_previous_post_link_product() {
          global $post;
          $prev_post = get_previous_post(true,'','product_cat');
          if ( is_a( $prev_post , 'WP_Post' ) ) { ?>
             <li class="prod-dropdown has-dropdown">
                   <a href="<?php echo get_the_permalink( $prev_post->ID ); ?>" rel="next" class="button icon is-outline circle">
                      <?php echo get_flatsome_icon('icon-angle-right'); ?>
                  </a>
                  <div class="nav-dropdown">
                      <a title="<?php echo get_the_title( $prev_post->ID ); ?>" href="<?php echo get_the_permalink( $prev_post->ID ); ?>">
                      <?php echo get_the_post_thumbnail($prev_post->ID, apply_filters( 'woocommerce_gallery_thumbnail_size', 'woocommerce_gallery_thumbnail' )) ?></a>
                  </div>
              </li>
          <?php }
      }
    }

    As you can see, the original functions from Flatsome are already wrapped in !function_exists('flatsome_previous_post_link_product'), which allows users to override them.

    However, your plugin seems to not recognise the !function_exists('flatsome_previous_post_link_product') from the theme file, which is why @mitchellk needs to wrap his own custom code in !function_exists('flatsome_previous_post_link_product'). This is not good as his custom code can now be overwritten.

    Removing the custom code from your plugin and placing it (without the !function_exists('flatsome_previous_post_link_product')) in function.php, works as it should.

    I hope I’ve explained the issue clearly.

    Hi @aazztech,

    Has this issue “Can’t Customize Single Listing Page” been resolved yet?
    My Single Listing Page always go’s to my blog page.

    Thanks

Viewing 4 replies - 1 through 4 (of 4 total)