如何在另一个 PHP 代码中插入一个 PHP 代码?
我正在使用 WordPress。我很高兴看到代码,但我也有兴趣直接学习如何自己做 - 所以如果你知道我在哪里可以找到教程或可以给我信息,我将不胜感激!
我正在调用帖子并希望在 PHP 代码中包含 PHP 代码,这是用于主题选项面板的。
<?php
query_posts('cat=-51&posts_per_page=3&paged='.$paged);
if (have_posts()) :
?>
我想把 51 放在哪里:
<?php echo get_option('to_postc_home'); ?>
我想把 3 放在哪里:
<?php echo get_option('to_posti_home'); ?>
I'm using WordPress. I appreciate being shown the code, but this is one I am interested in straight out learning how to do myself too - so if you know where I can find a tutorial or can give me information I'd appreciate it!
I'm calling posts and want to include a PHP code within a PHP code, this is for a theme options panel.
<?php
query_posts('cat=-51&posts_per_page=3&paged='.$paged);
if (have_posts()) :
?>
Where the 51 is I want to put:
<?php echo get_option('to_postc_home'); ?>
Where the 3 is I want to put:
<?php echo get_option('to_posti_home'); ?>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
更多
发布评论
评论(6)
如果我的解释正确,这就是您所需要的,请使用串联运算符
.
使用这些函数代替纯文本,例如:'this is text'
与 <代码>'这个'.get_option('stuff').'文本'If I'm interpreting right, this is what you need, use the concatenation operator
.
to use those functions in place of plain text ex:'this is text'
versus'this '.get_option('stuff').' text'
要包含另一个文件中的 php 文件,请使用 include 函数
To include a php file from another file you use the include function
您可以在任何您想要的地方使用它
You can use it whereever you want
这称为字符串连接,当您将文字字符串
'cat=-51&posts_per_page=3&paged='
与变量 < 连接时,您已经在代码的第一行使用了它。代码>$分页。在 PHP 中,.
运算符可以执行此操作。因此,在您的代码中,您可以执行以下操作:
这将在您指定的位置注入函数调用的输出。
That is called string concatenation, and you are already using that on the first line of your code, when you concatenate the literal string
'cat=-51&posts_per_page=3&paged='
with the variable$paged
. In PHP, the.
operator does that.So, in your code, you can do this:
This will inject the output of the function calls at the places you indicated.