Articles of filters

Custom search form to display users only

I’m trying to build a custom search form for one of my pages. I need the search form to be able to search for users. Not only will it need to search for users, but by first name, last name etc.. Something similar to this: The default WP search doesn’t allow for me to search […]

Disable widgets on specific posts

I run a horror related blog. Google is upset with me for displaying adsense in a sidebar widget for one specific post number (4603) that contains an article about an 18+ topic. How can I disable the widgets for a specific id?

Custom search page and search by title, content and tag

Can someone review my code , I need to know better solutions or any bug. Okey ! , I made a PHP file to get search results by parameters and search by title , content and tag PHP’s head look like: include(‘../../../../wp-config.php’); header(‘Content-type:text/html;charset=utf-8’); $keyword = $_GET[‘k’]; That I will bring search results by jQuery after. […]

Question about how do wordpress filters/actions work

I have a question that I’m curious. In WordPress we can add a filter or action like this code: add_filter($filter_Name, $function_will_be_hook); add_action($action_Name, $function_will_be_hook); We can pass some parameters into function_will_be_hook(). But how does WordPress know that these parameters are related to its filters/actions. Example: function my_the_content_filter($content) { $content .= “I added some additon content”; return […]

Sort Posts By Category?

Googled this for hours, cannot find a solution. On my theme you have a Browse page which pulls all the videos from the Custom Post Type I am working with. If a user makes 30 categories then id like for users to be able to sort the videos using the Category buttons listed at the […]

When to add_filter() to Custom Query

I have complicated query where I need to join multiple tables. I’m doing that via add_filter(‘posts_join’) – my question is, when and where do I add the filter so that it only applies to the custom query? My Custom Query $test = new WP_Query(array(‘post_type’ => ‘artcpt’, ‘posts_per_page’ => 10, ‘tax_query’ => array(array(‘taxonomy’ => ‘arttax’, ‘field’ […]

Hide posts of a certain category unless logged in

I want to hide posts belonging to a certain category unless logged in. I found some code(attached) in the codex that works great for the loop. But how to ensure the post pages are empty as well? function exclude_category($query) { if (!is_user_logged_in()) { $query->set(‘cat’, ‘-2’); } } add_action(‘pre_get_posts’, ‘exclude_category’);

WooCommerce Variable Product Price – Where is “From” text generated from?

The following code from github will add “- [max price]” to all variable products displayed in product archives. I am wondering how I could also remove the “From” text inside the same filter. add_filter(‘woocommerce_variable_price_html’, ‘custom_variation_price’, 10, 2); function custom_variation_price( $price, $product ) { $price = ”; if ( !$product->min_variation_price || $product->min_variation_price !== $product->max_variation_price ) $price […]

Sorting and limitation with pre_get_posts

This is my third question regarding WP queries and pre_get_posts (sorry about that) but I cant give up one step before the full success 🙂 So the story – my query is limiting front page posts to only those which have featured images. So far so good. My last goal is to sort those posts […]

How to change Woocommerce breadcrumbs content?

I want to customize the breadcrumbs directly from PHP. Some of the pages are generated dynamically and do not exist in the database, therefore i must automatically put them in the breadcrumbs with some sort of PHP script. I don’t need to change default stuff, like homepage url, separators, etc…but i actually need to manually […]