How can I add text over images on wordpress. I am using the Sydney theme and in the customization area and using the wp display images plugin , I managed to assign a single image per each page, is there anyway that I can also add text over these images?
I dont have access to the editor on the appearance section. is not possible to add this text to the images using just the CSS?
This is the code for displaying image below the header. You need to modify this code if you want add a text. Without changing this code you do cannot do.
Are you able to see the code in editor in admin panel?
<div class="sydney-hero-area">
<?php sydney_slider_template(); ?>
<div class="header-image">
<?php sydney_header_overlay(); ?>
<img class="header-inner" src="<?php header_image(); ?>" width="<?php echo esc_attr( get_custom_header()->width ); ?>" alt="<?php bloginfo('name'); ?>" title="<?php bloginfo('name'); ?>">
</div>
<?php sydney_header_video(); ?>
<?php do_action('sydney_inside_hero'); ?>
</div>
Try this style
.page-id-10 .header-image:before {
content: 'onze-klanten';
}
.page-id-8 .header-image:before {
content: 'werken-bij';
}
.page-id-206 .header-image:before {
content: 'Wie zijn wij';
}
.header-image:before {
display: block;
padding-top: 25%;
font-size: 45px;
text-align: center;
color: #fff;
}
.header-image {
position: relative;
}
Related
I'm attempting to build a theme in wordpress, but cannot figure out how to make the background image resize when resizing my browser window. When I get the image and set it to 'full', or any of the other preset sizes, I does not resize:
In my front-page-php:
<?php
// check if the post or page has a Featured Image assigned to it.
if ( has_post_thumbnail() ) {
// the_post_thumbnail();
$backgroundImg = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );?>
<header id="hero" style="background: url('<?php echo $backgroundImg[0]; ?>') no-repeat center center fixed;"></header>
<?php }
?>
and in my css file:
header {
max-width: 100vw;
height: 95vh;
background-size: cover;
}
And it just simply stays the same.. So thankful for any help!
There's an easier way to get the post's thumbnail url. Also, it'd be better to set the background-image property in the style attribute:
<?php
// check if the post or page has a Featured Image assigned to it.
if ( has_post_thumbnail() ) {
// the_post_thumbnail();
$backgroundImg = get_the_post_thumbnail_url($post->ID, 'full'); ?>
<header id="hero" style="background-image: url('<?= $backgroundImg; ?>');"></header>
<?php }
?>
& the CSS should be:
header {
max-width: 100vw;
height: 95vh;
background-size: cover;
background-repeat: no-repeat;
background-position: center;
background-attachment: fixed;
}
I have only just started using CSS and I've recently been working on a rather simpel site. I'm nearly done and most of the elements of my site seem to work except but I keep bumping into the same problems.
The first being the site's logo which appears in my header, for some reason it's ridiculously huge with the FF and IE browsers.
I have tried various containers but I have the feeling that I'm not implementing them in the correct way. I have done this as follows:
<header>
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<div class="row">
<div class="span3 no-left-margin">
<h1 id="homepage_logo">
<a class="brand" href="<?php echo esc_url( home_url( '/' ) ); ?>" title="<?php echo esc_attr( get_bloginfo( 'name', 'display' ) ); ?>" rel="home">
<img src="<?php echo BASE_URL ?>assets/img/logo.jpg
img {
max-width: 100%;
height: auto;
}
.item {
width: 150px;
height: 40px;
height: auto;
float: left;
margin: 3px;
padding: 3px;
} <--" alt="<?php _e("Mysite") ?>" title="<?php _e("Terugkeren naar de homepagina") ?>" />
The second problem I have is with inserting images in to my img slider/carousel.
I tried to implement the urls in various ways (as shown below) but they won't appear on the site.
<?php if (is_page('home')): ?>
<div id="homepage_slider" class="ts_slider">
<div id="slide1" class="ts_slide white_font">
<img class="slider_bg" src="<?php http://www.mysite.nl/wp-content/uploads/slider_4_bg.jpg ?>/"assets/img/slider_1_bg.jpg />
I hope someone can help me find the problem, thank you guys in advance.
I'm currently displaying a users profile picture in php and if they click on it, then it takes them through to their own profile. The image displays correctly and the link works, but the area of the link extends way beyond the picture and over a link nearby. How would I go about reducing the area of the anchor?
<?php } if ($searchuser == $username)
{ ?>
<a href="profile.php">
<?php } ?>
<div style="background-image: url('<?php echo $profilepic; ?> ')" class="user-pic"></div>
<?php if ($searchuser == $username)
{?>
</a>
div.user-pic {
margin: 0 auto;
width: 125px;
height: 125px;
border-radius: 50%;
background-repeat: no-repeat;
background-position: center center;
background-size: cover;
border: 0.09em solid white;
position: relative;
top: -60px;
padding: 0px;
z-index: -100;
}
Try with this:
php
<?php }
$show_user_link = false;
if ($searchuser == $username) {
$show_user_link = true;
}
?>
<div style="background-image: url('<?php echo $profilepic; ?>')" class="user-pic">
<?php if( $show_user_link ): ?>
<a class="user-link" href="profile.php">
</a>
<?php endif; ?>
</div>
css
div.user-pic {
position: relative;
}
a.user-link {
height: 125px;
width: 100%;
}
You put the anchor in within the div tag and then you could make div's position relative and anchor's width to 100%.
PS: You could try to use something like
<?php if(true): ?>
<strong> some html </strong>
<?php endif; ?>
when mixing php and html to make your code more readable.
--- EDIT
Ok, I understand, see if the new code is more helpfull now, the only thing I think that could go wrong is the height of the anchor in case it isnt fixed to 125px, say me if you have problems with it.
I am newbie to the WordPress. I want to make two sidebars. One in the left and another in the right hand side. I want to use twenty-eleven theme and then customise that. So any help will be highly appreciable.
Very Simple and easy way, first make a design with two sidebar, one on left and one on right, then call specific widgets on right and left side bar.
<?php dynamic_sidebar (''WIDGET AREA NAME); ?>
Put this in Index.php or home page
<div class="sidebar_left" id="sidebar_left">
<?php if ( is_active_sidebar( 'sidebar-left' ) ) : ?>
<div id="secondary" class="widget-area" role="complementary">
<?php dynamic_sidebar( 'sidebar-left' ); ?>
</div><!-- #secondary -->
<?php endif; ?>
</div>
and CSS for this is here
#sidebar_left{
float:left;
/*width: 303px;*/
border: 2px solid #A2A2A2;
display: block;
float: left;
height: auto;
margin: -532px 0 -62px -123px
padding: 0;
top: auto;
width: auto;
}
You should :
create a child theme of twenty-eleven
and add a widget area using register_sidebar
You will find a lot of tutorials for doing this, e.g. this one.
I am currently coding a Wordpress website. I have a sidebar and the main body for my blog posts. The sidebar currently has the following properties:
.nav{
width:25%;
height: 100%;
background: #FFF;
display:block;
float:left;
position:relative;
border-right:thin solid #C8C8C8;
}
and the main body for blog posts:
body {
font-family: Myriad Pro, Tahoma, arial, helvetica, sans-serif;
font-size:16px;
margin-left:20%;
margin-right:20%;
}
.post {
padding-left:10px;
border-left:thin solid #000000;
}
I am currently trying to add padding-left to .post so that there is a gap between the right border of the sidebar and the blog posts. However, this is not working (a gap is not created) for some reason. Nor is border-left (there is no border created; I tried removing the border-right property on the sidebar).
This is currently the code for index.php
<div id="blog">
<?php if(have_posts()) : ?><?php while(have_posts()) : the_post(); ?>
<div class = "sidebar">
<?php get_sidebar(); ?>
</div>
<div class="post">
<h3><?php the_title(); ?></h3>
<div class="entry">
<?php the_post_thumbnail(); ?>
<?php the_content(); ?>
<p class="postmetadata">
<?php _e('Filed under:'); ?> <?php the_category(', ') ?> <?php _e('by'); ?> <?php the_author(); ?><br />
<?php comments_popup_link('No Comments »', '1 Comment »', '% Comments »'); ?> <?php edit_post_link('Edit', ' | ', ''); ?>
</p>
</div>
</div>
How do I make padding-left and border-left work for the main blog posts?
Thanks!
Padding is applied within the element, so the border is on the other side of the padding. What you need is margin, which is applied outside of the element:
.post {
margin-left:10px;
border-left:thin solid #000000;
}
Here is an article explaining padding and margin in more detail.
This sounds like a conflict between the default Wordpress CSS and your themes CSS file(s). A quick hack is to add !important to the end of the CSS declarations as follows:
.post {
padding-left: 10px !important;
border-left: thin solid #000000 !important;
}
A long-term solution is to examine what CSS files are loaded (and in what order) and what selectors are being used. Excellent resource: http://codex.wordpress.org/CSS_Troubleshooting