Hey there karinlin,
How are you doing today?
Would you mind posting link to your site where I can see this with the first option set up for example and we can try to increase image size with some CSS.
Best regards,
Bojan
Hi Bojan, thanks for your quick reply. Here is my webpage: http://karintri.com/
I have now set it the default layout to centered.
The site layout is set to “Boxed layout with content width of 1218px”
Please let me now how to change the css.
Hey again karinlin,
Thanks for the link, I’ve checked your site and you should be able to achieve that by adding the following CSS code to Appearance -> Theme Options -> Design -> Custom CSS:
div#primary {
width: 100%;
}
div#primary .entry-content p span {
display: block;
width: 61.5763547%;
margin-left: auto;
margin-right: auto;
}
This should be the result http://screencast.com/t/ANo5GBlvF.
Hope this helps š
Cheers,
Bojan
Hi Bojan,
Thanks for your help. I tried to enter that code snippet into the Custom CSS, and it looks good on the first post. However, the following posts (after the full width picture) now have the text full width again? Same when you click into the post-pages, only the first one have the text centered.
Do you know how I could fix this? Thank you!
Hey again karinlin,
Sorry about that, that was completely my bad. When I checked that page the first time I saw that text inside p element is placed in span so I just assumed they all are and never actually scrolled down to check the rest.
After checking again there is no way we can target p elements that has only text and no image with just CSS since images are also placed in p elements so we’ll have to use some jQuery for this. Please try placing this at the end of your theme functions.php (Ideally you’d want to use child theme so you don’t lose changes when you update the theme):
<?php
add_action('wp_footer','my1_javascript_function');
function my1_javascript_function(){
?>
<script>
jQuery(function(){
;(function ($) {$(function () {$(".entry-content p").each(function() {var $me = $(this); if ($me.find("a img").length) return true; $me.closest("p").addClass("reducewidth"); } ); }); })(jQuery);
})
</script>
<?php
}
?>
This script will search for p elements that are not having img inside them and add class to those p elements which we can later use to reduce the width with CSS.
When done with that replace the CSS code I provided above with this one:
div#primary {
width: 100%;
}
.reducewidth {
width: 61.5763547%;
margin-left: auto;
margin-right: auto;
}
This should fix it on both blog and single post pages.
Hope this helps š
Cheers,
Bojan
Perfect, thank you so much!
Hi again,
Could you please help me with a little detail about the pictures? How do I set all the pictures to be centered, say in old posts where the width isn’t wide enough, I would like them centered. Now they are to the left.
Hey again,
Sure thing š
Can you just give me few examples (links) where this happens so I don’t have to search for it on your site? I tried looking but couldn’t find those images.
Best regards,
Bojan
Hey again,
Please try adding the following:
.single .entry-content p a img {
margin-left: auto;
margin-right: auto;
display: block;
}
This should center content images on your single post pages.
Best regards,
Bojan
Great, thanks for your help!
when ever internet speed is slow my template and theme cant uploaded clearly.its all interface get distracted [Non-WordPress website redacted]
Andrew Nevins
(@anevins)
WCLDN 2018 Contributor | Volunteer support