March 2020
Beginner
660 pages
18h 28m
English
In this recipe, we used the WordPress loop inside the book archive template to display the list. We can also use it on a single book template to retrieve the data for a single book. In application development, we have to use the loop regularly to work with database results inside or outside theme files. Let's see how we can use the loop inside a plugin file without using it in a theme template. Use the following code to create a simple shortcode to display a list of books from a specific author:
add_shortcode('wpccp_chapter7_books_by_author','wpccp_chapter7_books_by_author');function wpccp_chapter7_books_by_author(){ $html = ''; $query = new WP_Query( array( 'author' => 1, 'post_type' => 'book' , 'post_status' => 'publish' ...Read now
Unlock full access