如何在'includes / part2'之后加载'includes / part1'?
以下是示例代码:
<html>
<head>
</head>
<body>
<h1>Txt</h1>
<div>
<?php get_template_part('includes/part1'); ?>
</div>
<h1>Txt</h1>
<div>
<?php get_template_part('includes/part2'); ?>
</div>
</body>
</html>
这就是我在页面上的内容。 我希望浏览器首先加载'includes / part2'然后'include / part1'。
答案 0 :(得分:1)
同意没有任何背景,很难帮助你。
如果Bas Kuis方法不是您所需要的,那么也许这就是
您可以使用ob_start()在缓冲区中设置它,然后设置它,然后使用$ foo = ob_get_contents()将其设置为变量。最后使用echo $ foo回显结果。
ob_start();
get_template_part('includes/part');
$foo = ob_get_contents();
ob_clean();
echo $foo;
以下是使用php缓冲区
的示例但是我不太清楚你会从中获得什么。
答案 1 :(得分:-1)
您只需将其包含在页面底部即可:
<html>
<head>
</head>
<body>
<h1>Page</h1>
<p>Stuff</p>
</body>
</html>
<?php get_template_part('includes/part'); ?>
或.. ..
<html>
<head>
</head>
<body>
<h1>Page</h1>
<p>Stuff</p>
<div><?php get_template_part('includes/part'); ?></div>
</body>
</html>
如果那更相关。
如果你需要在dom完全加载并准备好操作后运行某些东西,你可以:
<html>
<head>
<script src="path/to/jquery.js"></script>
<script type="text/javascript">
$().ready(function(){
$.get("includes/part");
});
</script>
</head>
<body>
<h1>Page</h1>
<p>Stuff</p>
</body>
</html>
无论哪种方式 - 您都必须提供更多关于您尝试做的事情的背景信息。