Search results sorted by post types

You can use filter posts_clauses For example: add_filter( ‘posts_clauses’, ‘post_query_order’, 20, 1 ); function post_query_order( $pieces ) { global $wpdb; $pieces[‘orderby’] = $wpdb->prefix.’posts.post_type ASC’; return $pieces; }

How to use shortcode attribute in separate function

To be able to use a variable that is essentially being created within the shortcode function, you’ll need to store it somewhere and then retrieve the value. WordPress does use global variables internally to store and carry across values, but I wouldn’t advise you do the same though. Read about the options API here. Pretty … Read more

Hide content editor for posts after approriate date

function disable_editor_for_old_posts_wpse_101106($post) { if (strtotime(‘-2 months’) > strtotime($post->post_date)) { remove_post_type_support(‘post’,’editor’); } } add_action(‘add_meta_boxes_post’, ‘disable_editor_for_old_posts_wpse_101106′); I couldn’t find a great hook for this but add_post_meta_boxes_* is early enough, and it passes the $post object to the callback. Basically the filter checks the post on the post edit screen and removes post type support based on the … Read more

Remove tags from the kses filter

The allowed tags are stored in $allowedposttags (located in /wp-includes/kses.php) as an array. For each element it looks something like this: $allowedposttags = array( ‘div’ => array( ‘align’ => true, ‘dir’ => true, ‘lang’ => true, ‘xml:lang’ => true, ) ); You can remove a single element of an array via unset unset($allowedposttags[‘div’]);

Are there Limitations on filter handles?

add_filter(‘some_base_handle’.sanitize_title($string), …) What he’s doing here is a variable filter handle, and while “sanitize_title” might not be exactly the correct function to use here, it really depends on what the possible values of $string are and what the source of that $string is. Variable filter names can be handy if you have a lot of … Read more

How To Get User Data in Callback Function for pre_user_nicename?

If anyone should be faced with this problem, check if you have defined a callback function to set the user_login on pre_user_login. This filter is applied inside the wp_insert_user()-function and produced a same username again. Therefore the nicename was changed by adding a “-2”. So, my problem was that I reset the user_logins again and … Read more

Replace a part of url generated by get_term_link

Yes, there is a hook “term_link” which you can use for this purpose. Here you can find documentation. https://codex.wordpress.org/Plugin_API/Filter_Reference/term_link so the solution will be like this add_filter(‘term_link’, ‘term_link_filter’, 10, 3); function term_link_filter( $url, $term, $taxonomy ) { $url= str_replace(‘listing-category/’, ‘jobs/?fwp_cate=”, $url); $url= rtrim($url, “https://wordpress.stackexchange.com/”); return $url . “#results”; }

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