如何在所有WordPress帖子中插入PHP代码

I need to add my own custom PHP script to all Wordpress pages of my blog.

I am not referring to adding PHP onto a single page (which can be done with a plugin).

Essentially, this is what I need to do:

  • Add a snippet of code directly to Wordpress script that handles display of posts.
  • The snippet needs to be able to grab a ID of the post.

Can someone show me the best way to do this?

This is what I need to figure out:

  • Which of the Wordpress php files handles the display of the Wordpress posts (is it post-template.php by any chance?)

  • How to grab the Post ID using PHP? I found the page which says this could be the possible way, is that correct way of getting the Post ID?

    $id = get_the_ID();

查看全部
donglang9880
donglang9880
2017/07/25 00:06
  • wordpress
  • php
  • 点赞
  • 收藏
  • 回答
    私信
满意答案
查看全部

2个回复