wpsight / wpcasa

WPCasa WordPress Real Estate
https://wpcasa.com
GNU General Public License v2.0
42 stars 23 forks source link

Question How to remove those actions? #124

Closed Jimmi08 closed 2 months ago

Jimmi08 commented 3 months ago

Prerequisites

Description

I want to use wpcasa with Impreza theme. This theme has an advanced template system (based on Visual Bakery). I found that because of those actions I can not use it for a single listing template:

        add_action( 'loop_start', array( $this, 'template_listing_single' ) );
        add_action( 'loop_end', array( $this, 'template_listing_single' ) );

I tried to use remove_action() in the child theme - with init hook - but it was too soon.

Could you advise me how to do it? Maybe load it later? With init there is the error that the needed class does not exist yet.

Additional context

Thanks

codestylist commented 2 months ago

I'm sorry @Jimmi08 but I do not understand what you want to achieve or how I can help you. add_action() is a WordPress function so, you can just handle it with the WordPress tools. If remove_action() does not work for your needs, I have no idea how to help you.

Jimmi08 commented 2 months ago

I solved it. This is code if it is needed. Tested with Impreza theme only. Thanks for your reminder.

/* use Impreza template system */
if (!function_exists('remove_template_action'))
{
  function remove_template_action()
  {
    global $wpsight;
    remove_action('loop_start', array($wpsight->post_types, 'template_listing_single'));
    remove_action('loop_end', array($wpsight->post_types, 'template_listing_single'));
    remove_action('loop_start', array($wpsight->post_types, 'template_listing_archive'));
    remove_action('loop_end', array($wpsight->post_types, 'template_listing_archive'));
  }
}
add_action('init', 'remove_template_action');