Products
GG网络技术分享 2025-03-18 16:12 2
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:
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();
图片转代码服务由CSDN问答提供
感谢您的意见,我们尽快改进~
功能建议我需要将自己的自定义PHP脚本添加到我博客的所有Wordpress页面。</ p>
\\ n
我不是指将PHP添加到单个页面上(可以使用插件完成)。 </ p>
基本上,这就是我需要做的事情:</ p>
display的Wordpress脚本 帖子。</ li>
</ ul>
有人能告诉我最佳方式 要做到这一点?</ p>
这是我需要弄清楚的:</ p>
哪些Wordpress php文件处理 Wordpress
posts的显示(它是post-template.php吗?)</ p> </ li>
如何使用PHP获取帖子ID? 我发现这个页面说明了这可能是获取帖子ID的正确方法吗?</ p>
$ id = get_the_ID(); </ p> </ li> \\ n </ ul>
</ div>
for single post, it single.php
and to get post ID
$post = get_post();$id = $post->ID;
###
It depends on the theme. Very simple themes might use index.php
for all pages, others use single.php
for the display of single posts, and there are a lot more possibiites, also secondary templates (template parts) which are included in the primary templates and contain part of the post. Have a look in the theme folder.
Inside all of these, the posts are always inside \\\"the loop\\\". This page has the explanation and some useful examples: https://codex.wordpress.org/the_loop HTH
Demand feedback