• How to change the behavior of the post_tags () method in the file /inc/blog/class-post-entry.php? I created a child theme and I want to override the method. Do not want to change the code in the parent theme. The following code does not work:

    function overload_method() {	
        require_once get_template_directory() . '/inc/blog/class-post-entry.php';	
    	if (! Class_exists ('Customify_Post_Entry')) {
    		class Customify_Post_Entry {
    			function post_tags() {
    				$html = 'custom text';
    				echo $html;
    			}
    		}
    		
    	}
    }
    add_action( 'init', 'overload_method' );
Viewing 2 replies - 1 through 2 (of 2 total)
  • Theme Author PressMaximum

    (@pressmaximum)

    Hi @wptricks

    Hope you are doing good today 🙂

    If the class in parent theme have if (! class_exists ( ‘Customify_Post_Entry’ ) ) : conditional wrapper then you can override in functions.php file of your child theme. If the parent one does not have class_exists wrapper then its not pluggable and could not be overridden by child them.

    Hope that helps! Feel free to post a reply if you need further assistance 🙂

    Thread Starter WPTricks.ru

    (@wptricks)

    Hi!

    I do not see (! class_exists ( ‘Customify_Post_Entry’ ) ) in the parent theme. How can I correctly change the output of a block of labels in a single posts? I want to remove the “Tagged” line with the icon on the left. Plus add “#” to each tag in list. But I do not want to change the code of the parent theme.

    Thank you in advance.

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

The topic ‘How to change class method in child theme?’ is closed to new replies.