Ask your WordPress questions! Pay money and get answers fast! Comodo Trusted Site Seal
Official PayPal Seal

Need help to customise Facet WP + Listify theme WordPress

  • SOLVED

Hi there,
I need some instructions on how to modify Facet WP filter panel that has been integrated into the Listify theme. I need to modify this using a Child theme that I have created. Copying file to child theme folders does not work because it is not a template file. See note from Listify dev below:

http://listify.astoundify.com/article/646-why-cant-i-override-this-file


There is a particular file as such:

/wp-content/themes/listify/inc/integrations/facetwp/class-facetwp-template.php

It contains class and Public functions like such. Please see sample below.

<?php

class Listify_FacetWP_Template extends Listify_FacetWP {

public function __construct() {
// Global template override
add_filter( 'template_include', array( $this, 'template_include' ) );
... ....

How do I customise the code in the file above using the child theme?

Answers (4)

2015-12-27

dimadin answers:

This is not tested as I have no time right now, but you should try something like this, maybe it needs little modifications which I can made on site that actually uses it. I based this on Listify 1.1.2 so you should change accordingly if there are changes in 1.2, and on example names that you can change too.

Note that this might be much simpler if I knew what exactly you want to change in Listify_FacetWP_Template and if that method can be overwritten by simpler hook.

1) Copy file /wp-content/themes/listify/inc/integrations/facetwp/class-facetwp-template.php to your child theme, just rename it (for example /wp-content/themes/child-theme/inc/integrations/facetwp/class-child-theme-facetwp-template.php).

2) Edit first line of you file so you change class name. For example, right now is

class Listify_FacetWP_Template extends Listify_FacetWP {

while you need child of Listify_FacetWP_Template

class Child_Theme_Listify_FacetWP_Template extends Listify_FacetWP_Template {

3) Edit any part of that new class; you might not need methods that you didn't change since they are inherited from parent class, just those that you have changed.

4) In your custom code, place something like this:


class Child_Theme_Listify_FacetWP_Template_Overwritter {
public function __construct() {
$this->listify_facetwp_parent_class = $GLOBALS[ 'listify_facetwp' ];

add_action( 'init', array( $this, 'remove_parent_init' ) );
}

public function remove_parent_init() {
remove_action( 'init', array( $this->listify_facetwp_parent_class, 'init' ), 12 );

add_action( 'init', array( $this, 'init' ), 12 );
}

// Copied and modified Listify_FacetWP::init()
public function init() {
require_once( get_stylesheet_directory() . '/inc/integrations/facetwp/class-child-theme-facetwp-template.php' );

$this->template = new Child_Theme_Listify_FacetWP_Template;

add_filter( 'facetwp_query_args', array( $this->listify_facetwp_parent_class, 'facetwp_query_args' ), 10, 2 );
add_filter( 'facetwp_template_html', array( $this->listify_facetwp_parent_class, 'facetwp_template_html' ), 10, 2 );
}
}

new Child_Theme_Listify_FacetWP_Template_Overwritter;


Then tell me what happens or contact me directly if this doesn't work and you want to give me access so I can make changes right on your server.


evosoon comments:

Thanks Dimadin. Making the above changes, it looks like it is recognising the new template file but now Facet WP is longer picking up any results any more.


dimadin comments:

I am note sure what that means, I think that we aren't touching that part, more explanation of that (before-after) is needed.

In any case, it's really painful and time wasting to have numerous messages over here when problem is complex and specific like your. I suggest that we do either some live chat or that I get access to exact application you have to see what is a problem and tell you. You can see mine other messages here if you have doubts if I am trustful.


evosoon comments:

HI Dimadin, ive messaged you.

2015-12-27

Abdelhadi Touil answers:

Hi.
Have you tried to copy that file from the parent theme to the child theme and make your change?
Make sure to create the same path in the child theme before copying the file to it.


evosoon comments:

Added extra note from Listify doc that says this cannot be done.


Abdelhadi Touil comments:

Thank you for explaining more.
In that link they say that there 3 options to try if you want to make change to a non template file, but the first option is what you can try: Use the existing filters/actions to modify the output (Especially filters).
Hope someone who has worked on Listify theme helps you.
Good luck.

2015-12-29

Romel Apuya answers:

Hi,

Is this problem still not solved?
Did you know that listify uses two facetwp? One is from the plugins .. if you did not actuvate the plugin it will use the default from the theme. The one from the plugin can be customized to your liking.
If you need more help. Add me on skype: rrapuya

Cheers,
Romel

2015-12-29

Arnav Joy answers:

is it done?