How to customize search result page title?

Within the wp_get_document_title() function we have: // If it’s a search, use a dynamic search results title. } elseif ( is_search() ) { /* translators: %s: search phrase */ $title[‘title’] = sprintf( __( ‘Search Results for “%s”’ ), get_search_query() ); so you could hook into the document_title_parts filter to adjust it to your neds. Example: … Read more

Organize functions.php

Doing this simply won’t make a significant performance difference, instead organize your customizations with clear headings so you can find and edit things faster later… in other words, organize for development in this case, not for the frontend. There are plenty of other optimizations that can be done with some research but this just isn’t … Read more

what is the meaning of settings_fields()

Via the Developer Reference (not the Codex) Output nonce, action, and option_page fields for a settings page. Here’s the source code for it function settings_fields($option_group) { echo “<input type=”hidden” name=”option_page” value=”” . esc_attr($option_group) . “” />”; echo ‘<input type=”hidden” name=”action” value=”update” />’; wp_nonce_field(“$option_group-options”); } so, it gives the form processor some info to work with … Read more

Return only top-level navigation items from a menu using wp_get_nav_menu_items

Let’s take a look at wp_get_nav_menu_items code reference. It takes two parameters: $menu – (int|string|WP_Term) (Required) Menu ID, slug, name, or object, $args – (array) (Optional) Arguments to pass to get_posts(). So we can use get_posts args in here… And if we want to get only top-level posts, then post_parent arg comes useful… So something … Read more

wp_delete_user with username

There is no way to do this with only one query. But to be honest – deleting user takes more than one query itself… You shouldn’t use custom SQL for that, because there are many things you could break this way… Always use WP functions, if they exists (what if some plugin logs every deleted … Read more

Show Video in Excerpt

filtering the_excerpt() If you remove_filter( ‘get_the_excerpt’, ‘wp_trim_excerpt’ ) and add your own get_the_excerpt filter you can do this. The default filter (wp_trim_excerpt()) can be found on line 2023 of /wp-includes/formatting.php if you want to just modify that. The extent of what you need to do is just modifying which tags are allowed in strip_tags(). overriding … Read more