Chapter 1 WordPress Filter Introduction In the first chapter of this series of tutorials, we entered the wonderful world of WordPress filter hooks, and learned the concept, working mechanism, when and how to use filter hooks.We have learned the following: What is a WordPress filter hook: a filter hook is a function between a database and a browser that reacts to data before outputting WordPress. WordPress has hundreds of filter hooks. As we learned in the tutorial, you can also use it in development (such as plug-ins
Part I: WordPress Action Hook Introduction We entered the world of WordPress action through a simple introduction.Since the whole system is really simple, it is not difficult to introduce it.We have learned the following seven key functions: add_action() allows us to add our own function remove_action() to an existing action hook. You can remove a function remove_all_actions() from an existing hook function and remove all the functions from an action hook
Wordpress only displays the specified articles on the home page by default. The following code allows archive pages such as category page, tab page, author page and date page to display the top articles in their range on the top just like the home page.Put the following code in functions. php under the current topic: add_filter ('the_posts','putStickyOnTop ');function putStickyOnTop( $posts ) { if(is_home…
By default, WordPress will display sub classified articles on the classification page. If you want to display only the classified articles, but not the articles in the sub classification, you can use the following code.In the main cycle of theme article archiving template, add: above: below:
Use the parameter parameter name to describe the order ascending ASC or descending DESC. The default is ASC.Limit - 1 indicates all, and 1+integer indicates the number to be displayed.Category A comma separated list of category IDs containing links from.Category_name The category to retrieve the link by name.Hide_invisible Whether to show or hide links marked as invisible.Accept 1 | true or 0 | false.The default value is 1 | true.show_u…
/*------------------------------------------------------------------------ * * Set the first picture of the article as the featured picture automatically/* ------------------------------------------------------------------------ */function autoset_featu
Take the featured picture the_post_thumbnail()//Without parameter ->; Thumbnail the_post_thumbnail( 'thumbnail' ); // Thumbnail (default 150px x 150px max) the_post_thumbnail( 'medium' ); // Medium resolution (default…
Add in the functions.php file, refresh the page, and then comment out,/* clear the database update record */global $wpdb$wpdb->query("DELETE FROM wp_options WHERE option_name = 'core_updater.lock'"); Or you can directly operate in the database, find the table wp_options, and then find the delete core_updater.l
WordPress global variable: $pagenow determines the background page location global $pagenow;print_r($pagenow); When I saw this online, I tried it for no good. function get_current_post_type() {global $post, $typenow, $current_screen;//we have a post so we can just get
My requirement is that when publishing an article, if the title is not set, the content will be intercepted at the beginning, and a plug-in will be found on the Internet, so I copied the core and customized the modification, but publishing the article on the wordpress app has no effect,https://cn.wordpress.org/plugins/autotitle-for-wordpress//*** Automatic title * @ return void */function auto_title() {
Add an image in the theme functions.php function file. Only the jpg format is suitable for compression. png is not easy to compress, but imagewebp can replace imagepng. However, the ie browser does not support the webp format. If imagejpeg is used instead of imagepng for compression, the image will lose transparency and become distorted if it is transparent. Therefore, compression can be selected, and gif is not easy to compress,There is no need to compress. If you use imagewebp to compress gif, I found that an error was reported when uploading
WordPress2020-11-08two thousand one hundred and twenty-one
Reading statistics is added to the functions.php file.//Article reading statistics function post_views_record() {if (is_singular()) {global $post; $post_ID=$post ->ID; if ($post_ID) {$post_views=(int) get_post_meta ($post_ID, 'views', true); if
WordPress2020-11-04three thousand two hundred and ninety-six