How to make WordPress background articles and pages display corresponding IDs?

4 minutes
three hundred and fifty-seven
zero
如何让WordPress后台文章和页面显示对应ID?

As the title says, today WordPress Tutorial to solve a common problem. What if I get the ID of the article or page?
stay WordPress Each category, article, and page has a unique ID. When using or developing themes, it may be necessary to obtain corresponding articles or Page ID For example, when presenting slides of featured articles, you need to obtain the ID of the corresponding article, etc.

Now I will teach you a way to quickly display the corresponding ID in the background article and page list.

As shown in the figure——

如何让WordPress后台文章和页面显示对应ID?

Add the following code to the functions.php file of the topic.

PS: The new version of the traveler theme already has this function, so it is unnecessary to add it. Please pay users to download the new experience.


 /*Display in article list and page list Article ID */
 function  suxingme_post_id_column (  $post_columns  )  {
 $beginning  =  array_slice (  $post_columns ,  zero  , one  ) ;
 $beginning [  'postid'  ]  =  __ (  'ID' ,  'suxingme'  ) ;
 $ending  =  array_slice (  $post_columns ,  one  ) ;
 $post_columns  =  array_merge (  $beginning ,  $ending  ) ;
 return  $post_columns ;
 }
 add_filter (  'manage_posts_columns' ,  'suxingme_post_id_column'  ) ; //Add Article List Page ID Title
 add_filter (  'manage_pages_columns' ,  'suxingme_post_id_column'  ) ; //Add Page List Page

 function  suxingme_posts_id_column (  $col ,  $val  )  {
 if (  $col  ==  'postid'  )  echo  $val ;
 }
 add_action (  'manage_posts_custom_column' ,  'suxingme_posts_id_column' ,  ten ,  two  ) ; //Add article list page ID column value
 add_action (  'manage_pages_custom_column' ,  'suxingme_posts_id_column' ,  ten ,  two  ) ; //Add Page List Page ID

 function  suxingme_posts_id_column_css ( )  {
 echo  '<style type="text/css">#postid { width: 50px; }</style>' ; //ID column width
 }
 add_action (  'admin_head-edit.php' ,  'suxingme_posts_id_column_css'  ) ;
This article is written by: Chief Editor Published on Software Development of Little Turkey , please indicate the source for reprinting: //hongchengtech.cn/blog/259.html
Kuke_WP editor
author

Related recommendations

One year ago (2023-11-27)

12 WordPress enterprise theme templates are recommended! WordPress can be built without writing code!, Wordpress setup

When many companies choose WordPress to build their websites, they often don't know which theme is easy to use. There are too many WordPress corporate themes in the market for everyone to choose, but they always hesitate to make a decision. Here we have carefully sorted out 12 WordPress corporate themes, covering all walks of life
four hundred and forty-eight
zero
One year ago (2023-11-27)

Inventory of WordPress themes on online course website (updated in 2020), free WordPress themes

To build an online education platform using the WordPress website building program, it is not only necessary to choose a better virtual host provider, but also the most important thing is to use a core online course plug-in, and a powerful WordPress theme can also improve students' learning experience. Learn more about WordPre
four hundred and forty-eight
zero
One year ago (2023-11-27)

Count the domestic excellent WordPress themes and wordpress excellent themes

WordPress originates from abroad, is easy to use, and is very popular, making more and more websites in China start to use WordPress website building programs. There are also many powerful experts or teams in China who have developed WordPress Chinese themes. This article details the outstanding WordPress themes in China. I Begin Theme
six hundred and thirty-eight
zero
One year ago (2023-11-27)

Best WordPress theme list in 2022 (free and paid), Wordpress resource network theme

When building a WordPress website, should you use a free theme or an advanced theme? What types of functions do you need, and how advanced do you want your website to be? These are all good questions. You need to explain before you spend money on WordPress topics. This is why we need to know all the details of the selected theme, and cover the topics from several
three hundred and ninety-five
zero

comment

0 people have participated in the review

Scan code to add WeChat

contact us

WeChat: Kuzhuti
Online consultation: