将id添加到wordpress中的元素 [英] Add id to elements in wordpress

查看:24
本文介绍了将id添加到wordpress中的元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在一个 wordpress 网站上工作,现在很多元素都具有相同的 id,这使得自定义变得困难.

Im working on a wordpress site and right now a lot of elements has the same id which makes it difficult to customize.

现在我的解决方案是对所有元素添加更改,这是不可行的,困难的部分是我不确定如何为特定元素添加 ID.

Right now my solution is to add changes to all of the elements which isn't feasible, the difficult part is I am unsure of how to add an ID to the specific element.

我是在 css 文件中执行此操作还是以某种方式在 php 中进行编辑?

Do I do this in the css file or do I edit in php somehow?

或者是否可以使用某些插件或类似插件添加 ID?

Or is it possible to add an ID with some plugin or similar?

推荐答案

对此没有简单易行的答案.

There is no short or easy answer to this.

找出主题损坏的最佳方法是查看它包含的文件及其工作原理.我找不到你在评论中提到的 Cherry 主题,所以我可以看看.

The best way to figure out what's broken in your theme is by looking into the files it contains and how it works. I could not find the Cherry theme that you mentioned in your comment so that I could take a look.

当然,要了解正在发生的事情,您必须非常了解主题的编写方式.我想不出比 关于主题开发的 Codex 文章更好的起点.您可能会从网络搜索中获得更好的结果(取决于您如何最好地学习),例如 wp building a theme.我做到了,我得到了 thisthis 但我学得最好读;也许视频会帮助你更多.不幸的是,您真的无法消除这一步,而且需要时间.

Of course, to understand what's going on you're going to have to know a good amount about how themes are written. I can't suggest a better place to start than the Codex article on theme development. You may get better results (depending on how you learn best) from a web search for something like wp building a theme. I did and I got this and this but I learn best by reading; maybe videos will help you more. Unfortunately, you really won't be able to eliminate this step and it takes time.

您的主题很可能——如果它是以 WordPress 方式构建的——使用一系列包含的模板和 get_template() 调用.在您查找时,这可能就是您要查找的内容.我记得我第一次剖析 WP 主题是一项艰巨的任务,那时我已经是一名非常有经验的开发人员.不要气馁.

Your theme most likely -- if it has been built in the WordPress way -- uses a series of included templates with the get_template() call. As you're looking, this is probably what you want to look for. I remember the first time I dissected a WP theme it was a daunting task and I had already been a very experienced developer for a long time at that point. Don't be discouraged.

某些主题和插件使用操作和过滤器来允许修改其内容.如果您的主题做到了这一点,修改可能就像挂钩一些正确的主题一样简单.这仍然需要弄清楚要附加到哪些钩子上.

Some themes and plugins use actions and filters to allow modification of their content. If your theme does this, modification could be as easy as hooking on a few of the right ones. This will still require figuring out which hooks to attach to.

如果您将前 5 或 10 个分层子级直接指向典型页面(例如您的主页或您的博客页面.

I may be able to update this answer with something more specific if you point the first 5 or 10 hierarchical children directly below the <body> element in a typical page, like your home page or your blog page.

如果这看起来太复杂,您可能最好考虑聘请更熟悉 WordPress 主题修改的人来帮助您.

If this seems too complicated, you're probably best to consider hiring someone who is more familiar with WordPress theme modification to help you out.

这篇关于将id添加到wordpress中的元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆