New answers tagged

0

This is not a bug. If you look at the comment starting at line 2100 of wp/wp-includes/comment-template.php in the wp_list_comments function, you'll see that if the per_page argument is set and its value is different to that of the main wp_query, it'll perform a separate comment query and display those, instead of the ones you have sorted. To get around this ...


0

I think I have found a bug in wordpress, the thing that is causing the problem is the 'per_page' argument passed in wp_list_comments(). If it is set, then changes made to comments_array hook get reset or omitted later in the wp core. I am 90% sure it's a bug and I have reported it on wordpress trac.


1

Unfortunately there is now way to alter the markup of an existing block apart from wrapping it in additional markup: It receives the original block BlockEdit component and returns a new wrapped component. Source: https://developer.wordpress.org/block-editor/developers/filters/block-filters/#editor-blockedit To achieve what you want in the editor currently ...


1

If you can setup url query parameters and when user navigates to tagfillterPage page with wp_query it should work. https://examples.com/tagfillterPage/?filltertag=tagname $querytag = $_GET['filltertag']; $args = array( 'tag' => $querytag ); // Custom query. $query = new WP_Query( $args ); // Check that we have query results. if ( $query->...


0

The problem is that you're using term IDs in your URL, but that is incorrect. Use the term slug instead. For example, lets say we have a mytax term named helloworld with the term ID 1: example.com/cpt/?mytax=1 404 example.com/cpt/?mytax=helloworld a cpt archive filtered by the helloworld term


0

You should use : translate_user_role( __('some','textdomains ') ); example : add_role( 'wdcp_developer_role', translate_user_role( __('Developer',$this->textdomains ) ), array( 'read' => true, 'level_12' => true ) ); https://developer.wordpress.org/reference/functions/remove_role/ https://developer.wordpress.org/reference/functions/...


0

You'll find an appropriate filter in the get_terms function which is called by get_categories. See source code https://github.com/WordPress/WordPress/blob/master/wp-includes/taxonomy.php#L1247 We don't use any of the callback arguments in this case. We can use array_filter on the list of terms (WP_Term) objects. See https://developer.wordpress.org/reference/...


0

So after consulting on Facebook Advanced WordPress group, the advice was to create an object with setters and getters instead of using the declaring and getting variables in the global scope as shown in the code below: class MyPlugin { public $current_post_types; public function __construct() { add_filter('init', array($this, 'get_variables')); }...


0

Seeing as your aim is to improve loading on the front end, the best approach would be to simply not add the defer attribute when loading in the admin area, like so. add_filter( 'script_loader_tag', function ( $tag, $handle ) { if ( 'jquery-core' !== $handle ) { return $tag; } if ( ! is_admin() ) { $tag = str_replace( ' src', ' ...


1

I think I found answer to your question, it is: rest_{$this->post_type}_query filter hook. With this hook you are able to directly edit internal WP_Query parameter. For example, if you'd like to internally sort Posts by post_title by default, then you'd have to write something like this: function order_rest_post_by_post_title($args, $request) { $args['...


0

unfortunately, I can't write comments yet, I don't have enough reputation. first, the file path must be absolute. $filename = __DIR__.'/wp-content/uploads/2020/10/'. $months.'.pdf'; second, does the frontend browser handle file uploads? On JS or something else?


0

Change filter call add_filter('masthead','seasonal_site_header', 10, 2); function seasonal_site_header ($classes = '') { $hemisphere = 'northern'; $m = date('m'); $northern=array( 'summer' => array(6, 7, 8), 'fall' => array(9, 10, 11), 'winter' => array(12, 1, 2), 'spring' => array(3, 4, 5) ); foreach($$...


1

woocommcerce has this as a separate function wc_print_notices(); so just use that on your template pages. You don't need to echo or print it, just use it as is.


1

Try adding to functions.php function filter_movies( $query ) { if( !is_admin() && $query->is_main_query() && $query->get('post_type') == 'movie') { $tax_query = array( array( 'taxonomy' => 'period', 'field' => 'slug', 'terms' => 'current', ), ); $...


0

I achieved this with a couple filters: add_filter( 'query_vars', 'addnew_query_vars', 10, 1 ); function addnew_query_vars($vars) { $vars[] = 'r'; // var1 is the name of variable you want to add return $vars; } function redir_cat_match($a) { global $wp_query; if ($wp_query->is_main_query() && $wp_query->is_search()){ ...


0

This answer assumes you're running PHP 5.3 or above. Use the filter code below in-place of your code that you quoted above. Then simply update the variables provided so that it's sending to the correct email address and with the particular subject you'd like. add_filter( 'lostpassword_url', function () { $email_to = 'someone@yoursite.com'; $...


Top 50 recent answers are included