New answers tagged

0

Try this, it changes the core Spacer block from the Design to the Media category in the insertor: function myprefixFilterSpacerCategory(settings, name) { if (name === "core/spacer") { // Object.assign can also be used instead of lodash.assign return lodash.assign({}, settings, { category: "media", }); } return ...


0

The body_class filter is called inside the function with the same name, which is supposed to be in your theme like this: <body <?php body_class(); ?>> Now, you don't make clear where your piece of code is called, but if it is not attached to wp_head or another hook inside the <head> tag of you page, you are adding a filter to a function ...


1

page_link is not going to work as even though you change what it shows or uses, that's not going to be detected when the URL is accessed -- which requires handling to parse it during the request. You could look at adding rewrites, or what is probably easier you could use try using something like this (or view their code to see how they do it): https://...


0

Nevermind, I've managed to solve it. For anyone interested, the problem was 'category__in' isn't support by custom post types so instead needed to edit the $args array to include 'tax_query'. $args = array( 'post_type' => 'libraries', 'tax_query' => array( array( 'taxonomy' => 'library_types', ...


1

HTTP headers are different than the HTML head. The meta tag you're looking to add (for the Twitter card) is actually a meta tag that gets place in the HTML head. So to achieve exactly what you're looking to do from a PHP "functions" file, you'd want to hook into wp_head instead. Like this: add_action('wp_head', function(){ echo '<meta name=&...


1

Maybe someone need it: I modified a bit the code of remove_object_filter in @gmazzap answer, to make it works with WP 4.7+: /** * Remove an object filter. * * @param string $tag Hook name. * @param string $class Class name. Use 'Closure' for anonymous functions. * @param string|void $method Method name. Leave empty ...


0

By javascript, You should replace the link on the last item with new one and change tag's attribute, data-slb-active, to "0". Please use the following javascript. jQuery("#gallery-1 .gallery-item:last-of-type a").attr("href", "https://herodevelopment.com.au/allbathroomgear/album/bathrooms/").attr("data-slb-...


0

Replace your code with the following: <?php $content = get_sub_field( 'wysiwyg' ); if ( function_exists( 'slb_activate' ) ) { $url_request = isset( $_SERVER['REQUEST_URI'] ) ? filter_var( wp_unslash( $_SERVER['REQUEST_URI'] ), FILTER_SANITIZE_STRING ) : ''; $url_path = wp_parse_url( $url_request, PHP_URL_PATH ); $url_path ...


2

What I would like to do is, when the user unselects all the terms in the filter it displays all the posts of my Custom Posts Type. In that case, then make the tax query optional: // In mysite_filter_function(), define $args like so: $tax_query = array( 'relation' => 'AND' ); if ( ! empty( $groups_terms ) ) { $tax_query[] = array( 'taxonomy' ...


1

Going by what @JacobPeattie said, that they are still set but empty you need to change the conditional login to check for empty. In our previous discussion I wrote this conditions if ((isset($_POST['categoryfilter1']) && !empty($_POST['categoryfilter1'])) && (isset($_POST['categoryfilter2']) && !empty($_POST['categoryfilter2']))) { ...


0

The issue is using isset() for the conditions: isset($_POST['categoryfilter1']) && isset($_POST['categoryfilter2']) Because those inputs are still part of the form their post variables will still be set, they'll just be empty. Using !empty() and empty() would be the way to go: if (isset($_POST['categoryfilter1']) && isset($_POST['...


1

The problem seems to be in the checks you are performing in the php function that handles the ajax reguest. The first if condition checks if both categoryfilter1 and categoryfilter2 properties are set the the $_POST, and then you have else. Your code will never enter else because, from what I can see, you will always have at least one categoryfilter set at a ...


1

This does the trick add_filter( 'body_class', 'order_class'); function order_class( $orderclasses ) { $user_id = get_current_user_id(); // The current user ID // Get the WC_Customer instance Object for the current user $customer = new WC_Customer( $user_id ); // Get the last WC_Order Object instance from current customer $...


0

Ok, I found a solution. I've found the filter excerpt_more that is used to show the string shown within the more link (if theme use standard WP functions). So, to achieve this, we need to hook the excerpt_more and use a lower priority of the one used by the theme. In my example, this add_filter('the_title', static function ($title) { return $title. '-...


0

What is amp? Is it tag or category or page? You should use standard wordpress functions like is_page() is_category() is_tag(). You can also use $wp->request. It will return the request URI. If the address is "http://example.com/slug1/slug2" it will return slug1/slug2 then use explode() function to split it. <?php $uri = $wp->request; $...


1

If you have code that must run before plugins are loaded, place it in a Must Use Plugin. This is just a PHP file placed in wp-content/mu-plugins/. Be aware that Must Use Plugins are activated just by existing.


Top 50 recent answers are included