Customize search_filter($query) function

OK. I have changed $query->set(‘orderby’, ‘type’) function search_filter($query) { if ($query->is_search && !is_admin()) { $query->set(‘post_type’, array(‘post’,’forums’)); $query->set(‘category_name’, ‘my-zen’); $query->set(‘orderby’, ‘date’); $query->set(‘order’, ‘ASC’); } return $query; } add_filter(‘pre_get_posts’,’search_filter’); Now, I don’t have any Error critical, but it doesn’t work. What is wrong in my code?

how do I include wp_enqueue_style correctly?

you are trying to enqueue stylesheets before wp_enqueue_scripts hook is fired. WordPress recommends registering and enqueuing scripts and styles on the wp_enqueue_scripts hook to ensure they are loaded correctly. In your functions.php, you are enqueueing the stylesheet preload-style using the wp_enqueue_style function outside the wp_enqueue_scripts action hook, causing the error. To resolve this, you need … Read more

My account page, don’t show the complete “Registration form”

By default, it shows like this, but if you want to add more options like “Name, Phone number, Email” option in the registration form, you have to follow these two simple tips:- Step 1: Enable the Customer Registration Option Step 2: Add Custom Code in Functions.php File function wooc_extra_register_fields() { ?> <p class=”form-row form-row-wide”> <label … Read more

Loop through categores and posts of a custom post type in WordPress?

You can try this code logic and see if it works. // Get all categories $category_args = array( ‘orderby’ => ‘name’, ‘order’ => “ASC”, ); $categories = get_categories( $category_args ); // Get all Categories // Loop through each category foreach ($categories as $category) { // Display the category title echo ‘<h2>’ . $category->name . ‘</h2>’; … Read more