Closed. This question is off-topic. It is not currently accepting answers.
Want to improve this question? Update the question so it's on-topic for Stack Overflow.
Closed 9 years ago.
Improve this question
How to apply css style to a wordpress article without being administrator?
I've found plenty of information on google, but none that apply to my case because:
I'm not an administrator of the site so changing the theme, the global stylesheet, or hacking the php to allow html style tags is unfortunately not an option.
I only want to change the style of only some articles, so even if I had the authorization I'm not interested in changing the default stylesheet.
Currently, the only solution I've found is using style attributes html tags of interest, but it is error prone and doesn't scale well.
Any suggestion on including css style rules either inline or from an external url?
In my experience, style tags within posts do work (testing in WP 3.5.1 using the text editor).
However, you have to be cunning with the styling to make sure you override the defaults. An easy way to do this is with the important notation:
<style type="text/css" scoped>
* {
color:red!important;
}
</style>
<h1> hello </h1>
All the content of the post ("hello", in this case) appears red.
The use of the scoped attribute means the styles only apply to the blog post, not the whole page.
Are you talking about changing your specific posts that you create only?
If so, I'm guessing you only have access to the posts in question and therefore it would make it very difficult for you to do anything scalable.
You said you can't change the stylesheets or change the default stylesheet but if you could then you could wrap all the articles you want the specific styling on inside their own div with an id name of your choice. This would then automatically change all elements inside post with your div id and would scale across all pages you create without the need of re-defining the rules every time, for example:
<div id="antoines-article">
All your content
</div>
Your only other option is to use inline styles
<div style="background-color: green">All your content</div>
or by adding this before your post content (bare in mind however that this is only allowed by default to Administrator and Editor roles)
<style>
div { background-color: green; }
</style>
The difference here is that the first rule would only change the div it is attached to while the second would change all your divs to green.
This still may not be what you are after but I'm afraid from what you've said you are pretty limited with your options.
In addition using the !important tag after most css definitions will overwrite CSS styles from stylesheets if you find something wont change for you. For example
div { background-color: green !important; }
In addition, you could ask the webmaster of your site to setup specific page templates with different CSS styles loaded which you could then hook onto.
Related
I am creating a plugin for my theme to customize it, But when I use PHP and I edit the style of main page when using post request, and I don't believe WP AJAX system is a way way to edit style of main page with hooks?
And can I create short codes in my theme, or can I only create it in plugin???
In the case of Wordpress, which is a CMS for web projects, styling is mainly done via writing CSS code and rendering that in the web-browser.
How to apply a styling
Inline
You can do inline styling (unadvisable), example:
<input type="text" value="something" style="color: red;">
The reason this is generally not a desirable practice is that you would always have to add the styling to each element you want to apply it at. This is a problem, because if you have a consistent styling, applied at liked 10 000 elements and then you intend to change it, you will have to apply it at every 10 000 instances of its inline definition.
You may still use inline styling at some point, but you should avoid doing so unless you are absolutely sure that it's adequate for the given problem you solve.
Style tags
You can also add a style tag to your page, which is better than inline styling in general, but it's more difficult to reuse it than a css file. Example:
<style type="text/css">
input.red {color: red;}
</style>
<input type="text" value="something" class="red">
css files
You could create a file like style.css, move your styling from style tags there and create a link tag, as
<link rel="stylesheet" href="styles/style.css">
Note that the code above assumes that there is a styles folder where you store your css files and that your style.css is inside that folder. This is a generally accepted practice about styling, which is a very popular approach.
There are some technologies violating this separation of CSS from structure, like ReactJS, which has a different approach for this stuff, but, if you do not use those SPA approaches (and at least while you learn Javascript and CSS it is a good idea to avoid them), then this is an advisable practice.
The approach
In all cases I will assume that you have a CSS file that you want to append to your head tag at styles/style.css. If you have some differences in your dev environment, then you of course will need to rely on what your environment is like.
Modifying a theme
You can modify your theme whenever you want to do so, it's available on source-code level. However, if it's a theme that is not customly made by you and you intend to use its new versions in the future, then it's advisable to avoid changing the source-code of your theme.
However, at the point when the HTML is generated and particularly the head tag, you can add the link tag as described earlier. As a matter of fact you can add it inside the body tag as well.
Modifying the plugin
If you use a plugin and some HTML is generated there that is applied to the page, you can easily add your link tag to that as well. However, if you are doing some AJAX requests and you determine whether you need the styling at that level, then you will need your Javascript to add a link tag to the head, example:
function addLink(path) {
document.querySelector('head').innerHTML += `<link rel="stylesheet" href="${path}">`;
}
However, this is to be avoided if you know in advance that your file will always be needed. If you want to dynamically change the styling by adding some stuff to it, then you can call the function above, passing the desired path.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions concerning problems with code you've written must describe the specific problem — and include valid code to reproduce it — in the question itself. See SSCCE.org for guidance.
Closed 9 years ago.
Improve this question
I created a solution, stuck in jquery ui to do some slider bars which work and look great.
I popped an accordion onto a page and the CSS for it is awful. But I have no idea how to replace it with my own CSS, as it seems to use an absolute TON of CSS classes and overriding them all seems very messy.
Presumably picking and choosing styles and themes with JQuery UI is a common task, is there a best practice for this?
I'm thinking perhaps you can get the individual component CSS and pre-compile it or similar. But there seem to be many common CSS styles that are applied by jquery ui.
For example, an accordion has these classes automatically applied:
ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content-active
I can see that two contain the word 'accordion' and so you can imagine 'overriding' (or should that be removing the code from the jqueryui css and putting it into my own css class?) them without issue, but the others are buried in jquery ui and overriding them globally would likely cause issues.
My goal is to completely customise the accordion control with my own CSS while not affecting any other jquery ui component.
You need to re-declare the same in your stylesheet at the end of all the other styles and set to your custom values that you want to override. After doing that, re-declare that css file at the end of the page. Hope this helps.
If you want to keep the original style as it is then wrap one div around your accordion and inherit the css as you want. Anytime you can remove that class from div to get the default jquery accordion. like:
<div class='someClass'>
<div class='ui-accordion-content ui-helper-reset ui-widget-content ui-corner-bottom ui-accordion-content-active'></div>
</div>
CSS would be like this:
.someClass .ui-accordion-content { /* your necessary styles */ }
Both above answers seem to fit your needs, in the interest of completeness though you could also over-ride the css using jQuery simply picking out the elements that you're not happy with, e.g.
$(".ui-accordion-content").css("color", "#FFF");
Might be simpler than digging it out in the jquery-ui css or re-declaring if you're only looking to change one or two items.
I am making a theme for a website managed by plone using diazo and at least parts of twitter-bootstrap. Personally I'm not all too happy about that combination, but it was requested that way.
Now I was informed the other day that there will be some portlets that suppose to come in their own design, styled in an editor insinde plone (the editor seem to write the styles straight into the html). Meaning no further theming should be applied but bootstrap css recognizes the pattern and hijacks it anyway.
I tried to block that by using a form of <notheme css:if-content=".theStaticPortlet" /> but ended up having the theme blocked on the entire site whenever a container like this was found.
Is there a way of excluding a specific container/class from being bothered by the theme while everything around it stays themed like before?
With lesscss you can do something like that:
.theStaticPortlet {
// put your specific portlet css here
}
:not(.theStaticPortlet) {
// copy or import all your regular site css here
}
From what I understand your question is purely about Bootstrap and its CSS interfering with Plone markup. Exactly which styles are being applied on your portlet? I'd bet it has to do with the DL/DT/DD tags. If so you could use Diazo to replace those with DIVs or some other neutral tags - on Bootstrap's understanding, of course.
in my <head> tags, ive placed the location of bootstrap.css
if i place <div class="container"> it creates a fixed width.
what i wanted to happen is manipulate the default values of the container width by importing another set of stylesheet.
another scenario is, if i placed a span8 how do i put background colors on it without actually editing the bootstrap.css rather, customize it using a new stylesheet.
does putting 2 stylesheet possible? then inherit / manipulate all values in the bootstrap.css in a new stylesheet?
i apologize if my explanation aren't that clear. its kinda hard to express verbally what i wanted to happen. :)
When you add a second stylesheet, you can override rules of the first one. Just make sure you add them to your html page in the right order.
If you want to make sure a rule won't be overridden you can add !important to it. Example:
.example {
color: red !important;
}
Yes it is possible. That is what the "Cascading" part of CSS is. Short answer is to add your own style sheet after the bootstrap.css and before the responsive.css and your styles will be used because they are the latest definition, i.e. the rules "cascade" down.
Long answer is take a look at the docs. There's a lot to learn there if you have the time.
Also have a look at the bootstrap customization page
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about programming within the scope defined in the help center.
Closed 7 years ago.
Improve this question
I'm just wondering if display:none is affecting my sites seo as I have for certain keywords dropped rank in google over the past few days since implementing this into a new homepage re-design.
I am using wordpress and displaying random post images on the homepage, getting the excerpt and hiding it using display:none and when a user hovers the image it displays the excerpt as a tooltip.
I have read a few conflicting articles on this and watched Matt Cutts youtube video but that doesnt really give me an answer for the way I have implemented it.
So I am hoping someone on here can give me a bit more insight as to whether it is not good seo practice or doesn't make much difference?
Thanks
The Google bot don't care about CSS display:none, what the googlebot see is your html source. whatever is hidden with css is visible on the html source.
There are secondary checks for your CSS files, that check if you have any display: none; on your css If you have there is some sort of checks on what is hidden (links, chunks of keywords, etc.). If you are found to hide keywords or links you will be punished :)
Other common check is the css for your links, things like a {display: none;} or a {color: #ffffff;} will raise a flag. in the last one a check to determinate the background color of body or any container is done.
Matt Cutts will not tell you exactly how it works because it is a huge task that so far had big failures as css sometimes get complicated and you require a lot of checking.
There is just simple red flags on a site if there is a display:none;
As a side note if you have a style block on your html (<style type="text/css"> .some-class {display: none;}</style>) or a div with the style on it (<div style="display:none;">keyword</div>), Googlebot will pick that faster as it is visible on your html source.
You mention that you had implemented this into a new homepage re-design, and I wonder if you had given a time for Google to pick the changes on your site ? Remember that you can make improvements on your site but googlebot will see them 'who knows when'
Although you apply display:none style to your element, it doesn't matter with seo because your element dom still exist and what seo looks for is the dom and its content, not UI.
What i understand from your problem, is that google might black listing your website links. As hidden text/div are considered as Black Hat SEO technique and hurt your website very much.
I don't claim to be an SEO expert, but generally speaking if you're trying to fool the site crawlers (by hiding tons of keywords) that's bad for SEO because you're likely to get blacklisted. If you hide content because it helps user interface, shouldn't be any negative effects. Since it's an automated process, err on the side of caution generally because, for example, if you're blacklisted you can't argue your case for including every city name in the lower half of the state in a hidden div.
Crawlers are apparently not very good with JavaScript (and many users have JS disabled anyways) so perhaps have the content shown by default then hide it with JS/CSS hover.
.keywords
{
visibility:hidden;
}
<div class="keywords">
keyword 1
keyword 2
keyword 3
keyword 4
</div>
or better :
.keywords
{
display:none;
}
<div class="keywords">
keyword 1
keyword 2
keyword 3
keyword 4
</div>