WordPress function

  • WordPress functions: global variables $post, $page, $paged and $pages, etc

    WordPress has many built-in global variables, such as $post, $page, $paged and $pages. Almost all the data generated by WordPress can be found in the global variables. Reasonable use of these variables can bring a lot of convenience to WordPress development. How to use global variables Accessing global variables in WordPress If you want to access a global variable in your code, the first thing to do is to declare the variable as global: Global $variable; In addition, each global variable of WordPress can also be obtained through the corresponding...

    Technical Articles 02/03/2021
  • WordPress function: determine the type of page, such as home page, article page, search page

    WordPress is composed of home page, article page, search page and 404 page. When you want to show, hide, replace and load some content on a special page, you need to use page judgment function to judge. For example, in the article page and only when some content is displayed in the article page, you can use the function is_single() judgment. WordPress has rich built-in page judgment functions. The output of the judgment functions listed below is true under any conditions. In addition, these functions can accept parameters. Administrator panel...

    Technical Articles 02/03/2021
  • WordPress function: get the general settings of blog_ bloginfo()、bloginfo()

    Function get_ Bloginfo() and bloginfo(), which can obtain information in WordPress user profile and general settings, such as blog title, blog address URL, WordPress version, etc. get_ Bloginfo() returns a string to call. Bloginfo() has echo property and can be output immediately. Function usage Function parameters $show (string) (optional) keyword to name the information you want. Default: name 'name' - returns the blog title set in Settings > general. This data can be downloaded from WP_ Options is retrieved from "blogname" in the table. 'description '- returns the subtitle set...

    Technical Articles 02/03/2021
  • WordPress function: page title tag acquisition, WP_ get_ document_ title()、wp_ Title () and title tag

    The title tag of WordPress is used to define the page title, WP_ get_ document_ title()、wp_ Both title () and title tag can get the title tag of WordPress. But note that as the WordPress version iterates, WP_ Title () has been abandoned. At present, the main function used is WP_ get_ document_ title()。 wp_ get_ document_ title() Basic usage WordPress version 4.4.0 started, adding a new function WP_ get_ document_ Title (), you only need to add the code above to the topic header.php Before the / head label...

    Technical Articles 02/03/2021