Ambrosite Body Class Enhanced
When activated, this plugin causes the body_class template tag to output five additional classes. On single posts (is_single) : postname-[permalink slug] single-[category slug] parent-[parent category slug] (all parent and grandparent categories in a hierarchy of any depth) On pages (is_page) : pagename-[permalink slug] On category archives (is_archive and is_category) : parent-category-[parent category slug] (all parent and grandparent categories in a hierarchy of any depth) Custom Taxonomies As of version 1.3, the plugin now supports custom hierarchical taxonomies. The new body classes take the following form: On single posts (is_single) : single-[taxonomy]-[term slug] parent-[taxonomy]-[parent term slug] (all parent and grandparent terms in a hierarchy of any depth) On taxonomy archives (is_archive and is_tax) : parent-term-[parent term slug] (all parent and grandparent terms in a hierarchy of any depth) For single posts, the taxonomy name is included in the class name, because I felt it was important to be able to distinguish between taxonomies in cases where a post is assigned to more than one custom taxonomy, and when the same term might appear in two or more taxonomies. For example, suppose you had a real estate site with property listings in New York City, and you had two custom taxonomies defined: City and State. Then the classes would look like this: single-city-new-york single-state-new-york Multisite Support As of version 1.3, the plugin now supports multisite installations. If a multisite install is detected, the plugin will output the follow additional body class on every page of the site: site-[site ID] Examples If you have a post titled “Top 10 Decorating Ideas”, in category “Christmas”, with a parent category of “Holidays” and a grandparent category of “Calendar”, the additional body classes will be as follows: postname-top-10-decorating-ideas single-christmas parent-holidays parent-calendar Why is this useful? Because it enables you to style individual posts and pages, as well as entire categories of posts, using only CSS, without having to edit the template files or create new templates. Continuing the above example, if I wanted to give all of the posts in the Christmas category a green heading (to give them some extra holiday cheer), I could use a CSS selector like this: body.single-christmas h1 { color: green; } Going further, suppose I want to attach a background image of a Christmas tree ONLY to the “Top 10 Decorating Ideas” post: body.postname-top-10-decorating-ideas div.post { background: url('images/xmas_tree.gif') no-repeat left top; } What if I want all posts categorized under Holidays (Christmas, Thanksgiving, Easter, whatever) to have a sidebar with a gold border? body.parent-holidays div#sidebar, /* all posts assigned to a subcategory of Holidays */ body.single-holidays div#sidebar { /* any posts assigned directly to the Holidays category */ border: solid 2px gold; } These are just a few examples. If you are experienced in writing CSS selectors, you will find many more uses for the new body classes. For further discussion, check this support forum thread: https://wordpress.org/support/topic/393942
Top keywords
- category10×2.00%
- body9×1.80%
- parent9×1.80%
- posts9×1.80%
- slug8×1.60%
- classes5×1.00%
- grandparent5×1.00%
- single5×1.00%
- taxonomies5×1.00%
- taxonomy5×1.00%
- christmas4×0.80%
- custom4×0.80%
Head & Footer Code
Head & Footer Code plugin helps you add custom code snippets (JavaScript, CSS, or HTML) to the page even if you are not a programmer. It could be within the (site verification code for various services, custom styles, meta or Webfont link), right after opening (pixel tracking, analytics or heatmap code) or just before closing tag. Go to Tools → Head & Footer Code in WordPress Dashboard. Insert custom code to HEAD, BODY or FOOTER section (depending on what you have to do). All magic is done by hooking to WordPress hooks wp_head, wp_footer and wp_body_open. 💡 Trial Head & Footer Code plugin on a free dummy website before you add it on your project: Test It Now! Various code snippets are supported, including but not limited to: Google Analytics 4 Google Tag Manager Google Ads Conversion Lite Analytics Facebook/Meta Pixel Hotjar FullStory Google site verification Bing site verification Yandex site verification Alexa site verification Homepage in Blog Posts mode If your WordPress shows the latest blog posts on the homepage, you can also add specific code only for the homepage on Tools → Head & Footer Code (there will be section Head, body and footer code on Homepage in Blog Posts mode) Article specific code To insert custom code specific for individual article (post, page or custom post type), use article-specific Metabox while editing post/page/custom post type (check out Screenshots). There choose if that specific code appends to site-wide code defined on Tools → Head & Footer Code, or to replace it. Category specific code You can also define a Category specific code on each individual category. Other taxonomies (tag and custom taxonomy) do not have available their specific code, but for them a Global code is used instead. Video guide Do you need our support? If Head & Footer Code does not work on your project, please let us know by raising a new support ticket in the Community Forum and describe what does not works and how to reproduce the issue. We will make sure to resolve the issue as soon as possible. If you find Head & Footer Code useful for your project, please review plugin. Features Multisite and PHP 8.5 compatible! Set site-wide custom content for: head page section (before the ) body section (after the ) – Requires WordPress 5.2! footer page section (before the ) Homepage in Blog Posts mode: set homepage specific custom code for head, body and/or footer toggle homepage specific custom code on paged Homepage (page 2, 3, a nd so on) Set article specific custom code for: head page section (before the ) body section (after the ) – Requires WordPress 5.2! footer page section (before the ) Set category specific custom code for head, body and/or footer of the page Choose priority of printed custom code to head/body/footer sections (lower number mean far from and and closer to , higher number means closer to and and farther to ) Choose which post types will have enabled article specific head/body/footer fields Choose should article specific head/body/footer code be appended to site-wide code, or will replace site-wide code View on Posts/Pages/Custom Post Types listing if article has defined any article specific custom code Site-wide section is located under Tools > Head & Footer Code If you have set WP_DEBUG constant in wp-config.php to true, you’ll see site-wide and article specific entries in page source code wrapped to comments. [NEW] allow unprivileged user roles Editor and Author to manage article-specific code on single site and multisite (disabled by default) Data stored in database General settings (HEAD, BODY, FOOTER global code and priority, Homepage code and behaviour) saves in WordPress option auhfc_settings. Each post/page/custom post type specific HEAD, BODY and FOOTER code and behaviour saves to post meta _auhfc. Each category specific HEAD, BODY and FOOTER code and behaviour saves to taxonomy meta _auhfc. During the Uninstall process all these data has been deleted from the database. In case you wish to reinstall plugin, DO NOT UNINSTALL IT although Deactivate, then delete the directory /wp-content/plugins/head-footer-code and then reinstall plugin. Permissions on Multisite WordPress Access to Global: only Super Admin and Administrator Access to Article specific: Super Admin, Administrator; optional: Editor and Author Access to Category specific: only Super Admin and Administrator