- Wordpress Web Application Development(Third Edition)
- Rakhitha Nimesh Ratnayake
- 230字
- 2021-07-09 19:52:16
Conventions
In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.
Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We can set additional parameters to the search query using $query->set function and restrict the search features to limited posts."
A block of code is set as follows:
add_action('pre_get_posts', 'search_restrictions');
function search_restrictions($query) {
if($query->is_search && $query->is_main_query() && !is_admin()){
$search_blocked_ids = array('24','100');
$search_allowed_types = array('wpwaf_topic','wpwaf_forum');
$query->set('post__not_in', $search_blocked_ids );
$query->set('post_type', $search_allowed_types );
}
return $query;
}
When we wish to draw your attention to a particular part of a code block, the relevant lines or items are set in bold:
add_action('pre_get_posts', 'search_restrictions');
function search_restrictions($query) {
if($query->is_search && $query->is_main_query() && !is_admin()){
$search_blocked_ids = array('24','100');
$search_allowed_types = array('wpwaf_topic','wpwaf_forum');
$query->set('post__not_in', $search_blocked_ids );
$query->set('post_type', $search_allowed_types );
}
return $query;
}
Any command-line input or output is written as follows:
select option_value from wp_users where option_name='wp_user_roles'
New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Clicking the Next button moves you to the next screen."