[英]How do I include a menu on every page on my Wordpress site?
I have a Wordpress site that uses an index.php that contains a menu structure that appears only on the index.我有一个 Wordpress 站点,该站点使用 index.php,其中包含仅出现在索引上的菜单结构。 I'd like to add that menu selection to each page.
我想将该菜单选择添加到每个页面。 The menu is executed with javascript.
使用 javascript 执行菜单。
<div class="filternav" id="maintabs">
<ul>
<li><a id="newsid" href="javascript:showonlyone('news');" title="View Latest Activity" class="active">Latest</a></li>
<li><a class="" id="outlineid" href="javascript:showonlyone('outline');" title="View Course Outline">Outline</a></li>
<li><a id="assignmentsid" href="javascript:showonlyone('assignments');" title="View Only Assignments" class="">Assignments</a></li>
<li><a class="" id="linkstextsid" href="javascript:showonlyone('linkstexts');" title="View Links & Media Resources">Resources</a></li>
<li><a id="peopleid" title="View by People" href="javascript:showonlyone('people');" class="mpix">f</a></li>
</ul>
</div>
Clicking "Outline" on the index.php page lists all posts categorized with that id.单击 index.php 页面上的“大纲”会列出所有按该 ID 分类的帖子。
Is there anyway to create href links on subpages to execute the javascript when the links are clicked on subpages.无论如何,在子页面上单击链接时,是否可以在子页面上创建 href 链接以执行 javascript。
The function is function 是
function showonlyone(thechosenone) {
$('div[name|="pane"]').each(function(index) {
if ($(this).attr("id") == thechosenone) {
$(".filternav a").removeClass("active");
$("#"+thechosenone+"id").addClass("active");
$(this).fadeIn(150);
}
else {
$(this).fadeOut(150);
}
});
}
I've tried adding these elements to the page.php我试过将这些元素添加到页面中。php
Is it your custom theme or are you editing some existing one?这是您的自定义主题还是您正在编辑一些现有主题? Check the WP template hierarchy docs .
检查WP 模板层次结构文档。 There is a list of PHP files with their backup template files.
有一个包含 PHP 个文件及其备份模板文件的列表。
If your theme contained only the index.php
, it would be sufficient to put your code only in there.如果您的主题仅包含
index.php
,则仅将您的代码放在那里就足够了。 Usually though you'd need to include it also in single.php
, page.php
, archive.php
, search.php
and home.php
(and probably more).通常,尽管您还需要将其包含在
single.php
、 page.php
、 archive.php
、 search.php
和home.php
(可能还有更多)中。
One of the possible approaches would be creating menu.php
file and then including it in all files needed using include() .一种可能的方法是创建
menu.php
文件,然后使用include()将其包含在所有需要的文件中。 Another option would be putting the menu to header.php
or footer.php
as these are already included in all files metioned.另一种选择是将菜单放入
header.php
或footer.php
,因为这些已包含在所有提到的文件中。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.