• Introduction to WordPress Filter

    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

    WordPress 2024-01-08 fifty-seven

  • WordPress Action Hook

    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 2024-01-08 fifty-two

  • WordPress allows archive pages such as categories and tags to display top articles

    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…

    WordPress 2023-12-13 eighty-five

  • How to exclude sub category articles from WordPress category page

    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:

    WordPress 2023-12-04 ninety-eight

  • Wodpress wp_list_bookmarks Output Friendly Links

    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…

    WordPress 2023-12-01 one hundred and seven

  • The first picture of a wordpress article is automatically set as a featured picture

    /*------------------------------------------------------------------------ * * Set the first picture of the article as the featured picture automatically/* ------------------------------------------------------------------------ */function autoset_featu

    WordPress 2023-02-18 five hundred and eighty-four

  • Wordpress takes the thumbnail and address after automatic clipping

    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…

    WordPress 2023-02-18 six hundred and seventy-eight

  • Wordpress upgrade prompts that another update is in progress

    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 2023-01-09 five hundred and sixty

  • Wordpress Upgrade Prompt ftp

    Add define ("FS_METHOD", "direct") in wp-config.php; define("FS_CHMOD_DIR", 0777); define("FS_CHMOD_FILE", 0777);

    WordPress 2023-01-09 three hundred and eighty

  • WordPress fetches the current background page position

    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

    WordPress 2022-09-21 seven hundred and twenty-three

  • Automatically set article title from content interception when publishing or modifying wordpress articles

    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() {

    WordPress 2022-09-17 seven hundred and forty-three

  • Wordpress uses strtotime to convert to timestamp. The time stamp differs by 8 hours

    Wordpress uses strtotime to convert timestamp to timestamp with a difference of 8 hours

    WordPress 2022-09-16 eight hundred and seven

  • WordPress turns off the default search function

    Add function close_search_query ($query, $error=true) {if (is_search()&&! Is_admin()) {$query ->is_search=false; $query ->query_vars [s]=false; $query ->query [s]=false; if ($er

    WordPress 2021-07-04 one thousand nine hundred and five

  • WordPress upload image compression

    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

    WordPress 2020-11-08 two thousand one hundred and twenty-one

  • WordPress article reading, visiting and browsing statistics

    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

    WordPress 2020-11-04 three thousand two hundred and ninety-six