Filters and hooks - Qreatix
Qreatix and the Qreatix Pro plugin pass the values they are about to print through filters, so you can change them from a child theme without editing the plugin. Put the code in the functions.php of a child theme. See Child themes, template overrides and hooks for the child theme basics.
#Example
This code adds a sentence to the footer copyright line, sorts the portfolio archive grid by title, and turns the scroll top button off in code:
add_filter( 'qreatix_pro_copyright', function ( string $text ): string {
return $text . ' All rights reserved.';
} );
add_filter( 'qreatix_pro_portfolio_grid_query_args', function ( array $args ): array {
$args['orderby'] = 'title';
$args['order'] = 'ASC';
return $args;
} );
add_filter( 'qreatix_setting', function ( $value, string $key ) {
return 'scroll-top-button-toggle' === $key ? false : $value;
}, 20, 2 );
The copyright text still contains {year} when the filter runs. The plugin replaces it afterward.
#Theme Options values
qreatix_setting runs for every Theme Options value the theme reads. It receives the value and the setting id. The Qreatix Pro plugin hooks it at the default priority to turn stored image ids into URLs, so use priority 20 or later in your own callback.
#Text and content
Each filter receives the value that is about to print.
The copyright line, a string that still contains {year}.
An array with title_email, email, title_phone and phone.
An array with title, subtitle and shortcode for the call to action.
The headline of the 404 page.
Whether the extra links show on the 404 page. It starts as the value of Additional links on the Pages options page.
The title of the newsletter popup.
The subtitle of the newsletter popup.
The placeholder text of the search field.
The title of a page header.
The social links, as rows with social_text, social_icon and social_url.
The additional header icons, as rows with text, icon and url.
An array with alignment, background (an image URL), text, button_text and button_link.
An array with shortcode and image (a URL).
An array with heading, button_text and button_url for the Minimal list scene.
A logo URL. The filter also receives the Theme Options id the logo came from as a second argument.
Rows with a template that holds an Elementor template id.
An array with the text and color of a menu item badge. Both are sanitized after the filter runs.
#Sizes and colors
An array of integers with height, mobile_height, width, logo_mobile and logo_extra.
An array of colors keyed by the suffix of the CSS custom property, plus the scheme, which is default or dark.
#Query arguments
Each of these receives a WP_Query argument array:
qreatix_pro_blog_query_args,qreatix_pro_post_related_query_argsqreatix_pro_portfolio_grid_query_args,qreatix_pro_project_related_query_args,qreatix_pro_portfolio_filter_query_args(the Load more of the portfolio grid)qreatix_pro_career_list_query_argsqreatix_pro_search_posts_query_args,qreatix_pro_search_pages_query_args,qreatix_pro_search_portfolio_query_args,qreatix_pro_search_products_query_argsqreatix_pro_cf7_forms_query_args, the list of forms in the CF7 widget- One per front page scene that queries posts, named
qreatix_pro_<scene>_query_argswith the dashes of the scene key written as underscores, for exampleqreatix_pro_organic_slider_query_args. The Images gallery scene reads its own image list and has no query.
The Load more of the WebGL slider uses its scene filter, qreatix_pro_webgl_slider_query_args, so page 2 matches page 1.
#Visitor address
qreatix_pro_client_ip filters the address the like and view counters use. It is the server's REMOTE_ADDR by default. A site behind a proxy it trusts can return the forwarded address here.
#Actions
qreatix_templateprints a Pro template. It receives the template path and an array of variables. The theme fires it, and the plugin answers it. See Override a template.qreatix_breadcrumbsprints the breadcrumb trail in a page header.
Last updated
Was this article helpful?