New answers tagged

0

Improving on @hacksy's answer, I have used the same block of code but changing it to successfully search company name using the WP Job Manager plugin. function add_author_to_search($where) { global $wpdb; if( is_search() ) { // Check if a search is made $search = get_query_var('s'); $like = '%' . $wpdb->esc_like( $search ) . '%'; ...


0

For those who are looking for an answer - after trial and error i found the "if" statement i was looking for. Full code as follows: $variablename = get_field('dcfg_global_item_select'); if ( !empty( $variablename ) ) {?> <div class="container"> <?php foreach($variablename as $...


1

One issue, and this really isn't something you can fix, is that when viewing the page from the admin area, when editting the page, the template won't be listed as the active template, and saving changes could of course change the active template. There's much we can do there, the page template dropdown is generated from a function that scans theme files, ...


0

I finally got a chnace to play with @tomjnowell suggestion yesterday, and I ended up with the code below, which works: add_action( 'elementor/query/user_responsive1', function( $query ){ $language_level = get_user_meta(get_current_user_id(),'language_level',true); if ($language_level == 'A1' or $language_level == 'A2'){ $query->set( '...


0

All enabling Accessibility Mode does is add a class to the admin body. The styles and script behaviour change based on that class. So if you want to make accessibility mode the default, you can add that same class if the user hasn't set accessibility mode on or off: add_filter( 'admin_body_class', function( $classes ) { $widgets_access = ...


0

As Pat J noted this rather broad question and there's probably as many ways to get this done as there are developers. But perhaps you could get started by working on the following things, custom post type for events store the participant limit as post_meta for an event post another custom post type for registrations relate registration to an event with ...


0

You would not do this using SQL, and you don't need to. Use PHP instead. For example, this code adds a search parameter to the query, but the value changes depending if the user is logged in: add_action( 'elementor/query/article_video_together', function( \WP_Query $query ) { $foo = is_user_logged_in(); if ( true === $foo ) { $query->set( '...


0

From what I understand, you want people to be able to add multiple filters but the code above is only allowing one filter to be used at a time. If this assumption is true, you'll need to update your code to add to the meta_query array rather than replace it in each conditional block. For example. function ransom_filter_function() { $s = ...


1

register_setting() / unregister_setting() are used to let WordPress know that it should allow / remove a given setting name—to set up the "allowed options" list, etc. You're telling WordPress that the setting my_name will exist, and that it is allowed to be used by the Settings API. add_option() / delete_option() actually do the work of adding / ...


1

as of Wordpress 5.5 you can remove the prefix with this hook: add_filter('get_the_archive_title_prefix','__return_false');


1

A few changes to your code: Changed the action hook to wp_head. Removed the false 'pluggable' wrapping of your function. if ( ! function_exists( 'post_is_in_descendant_category' ) ) { function post_is_in_descendant_category( $cats, $_post = null ) { foreach ( (array) $cats as $cat ) { // get_term_children() accepts integer ID only ...


0

It's easier to understand if you break it down. The code in your question is exactly the the same as this: $message = sprintf( __( 'This action will let you pay a deposit of <span class="deposit-price">%s</span> for this product', 'yith-woocommerce-deposits-and-down-payments' ), wc_price( $deposit_value ) ); $message = apply_filters( '...


0

The function you were looking for (but didn't land until dec 2015), is set_url_scheme set_url_scheme( $url, 'https' ) ) Internally the function checks if is_ssl is true, will only set the url scheme if the passed url has a scheme.


0

Just use the the_post_thumbnail() function. It creates the image tag, adds srcset for you, and supports native lazy loading: the_post_thumbnail( 'medium', [ 'class' => 'productimage' ] );


0

You should be using string as attribute type, as in previous answer, and possibly set multiline attribute to true on Richtext and use multiline parameter in attributes, as explained here. https://developer.wordpress.org/block-editor/reference-guides/block-api/block-attributes/#html If you will be using multiline, be sure to set 'div.gray-bg' as selector in ...


0

Short Answer: When saving an attribute, always respect the attribute type. So if your attribute is of the array type, then save the value as an array, e.g. props.setAttributes( { innerContent: [ content ] } ). Longer Answer Your register_block_type() call is missing the editor_script parameter. See the block editor handbook for details, but basically, you ...


0

The original stylesheet is enqueued as openpos.bill.bootstrap wp_enqueue_style('openpos.bill.bootstrap', OPENPOS_URL.'/assets/css/bootstrap.css') // load my custom css after this one But you've set openpos.bill.style as the dependency: wp_enqueue_style('bill-screen-style', get_stylesheet_directory_uri() . '/include-parts-from-functions-php-file/frontend-...


Top 50 recent answers are included