Custom nav walker: How to acces the $args parameter?

WordPress Walkers aren’t using constructors. They are started up with walk() method which is passed arguments as third argument (confusingly not reflected in method signature). You can capture it into your object’s property with something like this: class Args_Walker extends Walker { public function walk( $elements, $max_depth ) { // we could declare above, but … Read more

How to query if meta_key does exist or not?

Adding a NOT EXISTS clause should force LEFT JOINs: ‘meta_query’ => array( ‘relation’ => ‘OR’, array(‘key’ => ‘file_gallery’, ‘value’ => ‘1’, ‘compare’ => ‘!=’), array(‘key’ => ‘file_gallery’, ‘compare’ => ‘NOT EXISTS’), ),

paginate_links() Change the order of links

You cannot do this with the default paginate_links() functions. Looking at the source code, there are no filters from which you can change the layout as you wish ALTERNATIVE SOLUTIONS Although you cannot do this by default, it doesn’t mean that you cannot get your desired output. Here is a couple of options to explore … Read more

Apply wordpress filter checking category

Thanks for the response David. I found the solution. I added the following code in functions.php add_filter(‘get_the_excerpt’, ‘process_excerpt’); function process_excerpt($param) { global $post; if(in_category(‘MY-CATEGORY-SLUG’,$post)) return ‘adding some data’.$param; else return $param; } This fixed my issue.

Remove comments validation (remove filter?)

If you take a look in source the condition for this message is get_option(‘require_name_email’). You can control it in Settings > Discussion > Comment author must fill out name and e-mail. The programmatic way could be add_filter( ‘pre_option_require_name_email’, ‘__return_null’ );

Problem with Class, Filters and Callbacks

Here’s a slightly modified version of your code snippet: add_action( ‘login_head’, [ ‘WPSE_Admin’, ‘plugin_setup’ ] ); class WPSE_Admin { public static function plugin_setup() { add_filter( ‘login_headerurl’, [ ‘WPSE_Admin’, ‘the_logo_url’ ] ); } public function the_logo_url() { return get_bloginfo(‘url’); } } The filter callbacks must be public, not private. The reason for this is that apply_filters()/apply_filters_ref_array() … Read more

Shorten the title length

Try this. First check if the original string length is less than or equal to passed in length, and if so, we ignore the $after parameter : function the_titlesmall($before=””, $after=””, $echo = true, $length = false) { $title = get_the_title(); if( strlen($title) <= $length ) $after=””; if ( $length && is_numeric($length) ) { $title = … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)