Wordpress sidebar goes wrong way in bootstrap - wordpress

Basically, i split up the page in 2 columns, and tried inserting sidebar code into the right one (span4). But for some reason, it keeps showing under span8
page code
<div class="row pull-right"><div class="span12" id="hdimg"></div></div>
<div class="row pull-right" id="pgg">
<div class="span8" id="pagecn">
<?php the_post(); ?>
<div id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<div class="entry-content">
<div class="ttl">
<?php if ( is_singular() ) {echo '<h1 class="entry-title">';} else {echo '<h2 class="entry-title">';} ?><a title="<?php printf( __('Read %s', 'blankslate'), the_title_attribute('echo=0') ); ?>" rel="bookmark"><?php the_title(); ?></a><?php if ( is_singular() ) {echo '</h1>';} else {echo '</h2>';} ?>
</div>
<div id="cn">
<?php the_content(); ?>
</div>
</div>
</div>
</div>
<div class="span4">
<?php if ( is_active_sidebar('primary-widget-area') ) : ?>
<div id="primary" class="widget-area">
<ul class="sid">
<?php dynamic_sidebar('primary-widget-area'); ?>
</ul>
</div>
<?php endif; ?>
</div>
</div>
</div>
<?php get_footer(); ?>
css for it
#hdimg {
width: 948px;
height:185px;
background-image: url(images/banner.jpg);
}
#pgg {
width:948px;
margin-top:4px;
background-color: white;
padding-top: 10px;
padding-bottom: 20px;
}
#cn {margin-top: 15px;}
link to see live
http://soloveich.com/project3/

#pgg {
width:948px;
margin-top:4px;
background-color: white;
padding-top: 10px;
padding-bottom: 20px;
}
Remove width
#pgg {
margin-top:4px;
background-color: white;
padding-top: 10px;
padding-bottom: 20px;
}
I see what you tried to do but you used it incorrectly - fix background in a different way
<div class="" id="hdimg"></div>
This is for your header - remove grid class
change #hdimg width to
hdimg { width: 960px !important; }

Related

Running the loop outside of wordpress

I know that this has been posted many times, but I have truly spent close to 60 hours trying to figure this out - this is not my strong point!
Im running wordpress, standard installation, no plugins or anything at this stage.
I am simply trying to display the most recent 3 posts from the blog, or if we could go one step further, most recent 3 from catx.
Here is my code, which I believe should work.
<?php
require '/home1/digita/public_html/articles/wp-load.php'; ?>
<section class="services blog sec-normal">
<div class="container">
<div class="service-wrap">
<div class="row">
<style>.wp-block-image {
max-width: 100%;
margin-bottom: 1em;
display: none;
}
a.more-link {
display: none;
}
.services .service-wrap .service-section a {
margin-top: 0px!important;
}
</style>
<?php if (have_posts()) :
while ( have_posts() ) : the_post();
?> <!-- ***** BLOG ***** -->
<div class="col-md-4" style="width: 30%;margin-top: -7%;margin-bottom: 10%;">
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail();
} ?>
<div class="service-section m-0" style="margin-top: 0.1%;">
<div class="title mt-0"><?php the_title(); ?></div>
<p class="subtitle"><?php the_content() ?> </p>
<hr>
Read more
</div>
</div>
<?php
// Stop the loop when all posts are displayed
endwhile;
// If no posts were found
else :
?>
<p>Sorry no posts matched your criteria.</p>
<?php
endif;
?>
</div>
</div>
</div>
</div>
</section>
The code does not return posts, and instead returns, "Sorry no posts matched your criteria." . Any advice?
Main query does not set it's data, because wp function did not run after wp-load.php in your code and main query must be set base on $_SERVER['REQUEST_URI'] that is a few complex.
But its good to use secondary query as simple way for your work:
<?php
require '/home1/digita/public_html/articles/wp-load.php';
$query = new WP_Query(array(
'post_type' => 'post',
));
?>
<section class="services blog sec-normal">
<div class="container">
<div class="service-wrap">
<div class="row">
<style>.wp-block-image {
max-width: 100%;
margin-bottom: 1em;
display: none;
}
a.more-link {
display: none;
}
.services .service-wrap .service-section a {
margin-top: 0px!important;
}
</style>
<?php if ($query->have_posts()) :
while ( $query->have_posts() ) : $query->the_post();
?> <!-- ***** BLOG ***** -->
<div class="col-md-4" style="width: 30%;margin-top: -7%;margin-bottom: 10%;">
<?php
if ( has_post_thumbnail() ) {
the_post_thumbnail();
} ?>
<div class="service-section m-0" style="margin-top: 0.1%;">
<div class="title mt-0"><?php the_title(); ?></div>
<p class="subtitle"><?php the_content() ?> </p>
<hr>
Read more
</div>
</div>
<?php
// Stop the loop when all posts are displayed
endwhile;
// If no posts were found
else :
?>
<p>Sorry no posts matched your criteria.</p>
<?php
endif;
?>
</div>
</div>
</div>
</div>
</section>

How can I make my flex-box buttons hover?

I have a flex box with several different buttons, namely, "Shop My Look," social icons, and a comment icon. I'd like them to hover to backgound-color: #ffff; (font) color: #f37761; and border color: #f37761. Applying the :hover doesn't do anything. Any thoughts?
You can find my issue on here: www.rachelclayton.co. It's on the homepage under each post in the post-meta area.
/* HTML */
<?php if(!is_single()) : ?>
<div class="read-more">
<?php esc_html_e( 'Continue Reading', 'alder' ); ?> <i class="fa fa-angle-right" aria-hidden="true"></i>
</div>
<div class="shop-social">
<div class="shop-my-look">
<?php esc_html_e( 'Shop My Look', 'alder' ); ?>
</div>
<?php if(!get_theme_mod('alder_post_share')) : ?>
<div class="post-share">
<a target="_blank" href="https://www.facebook.com/sharer/sharer.php?u=<?php the_permalink(); ?>"><i class="fa fa-facebook"></i></a>
<a target="_blank" href="https://twitter.com/intent/tweet?text=Check%20out%20this%20article:%20<?php print alder_social_title( get_the_title() ); ?>&url=<?php echo urlencode(the_permalink()); ?><?php if(get_theme_mod('alder_twitter')) : ?>&via=<?php echo esc_html(get_theme_mod('alder_twitter')); ?><?php endif; ?>"><i class="fa fa-twitter"></i></a>
<?php $pin_image = wp_get_attachment_url( get_post_thumbnail_id($post->ID)); ?>
<a data-pin-do="none" target="_blank" href="https://pinterest.com/pin/create/button/?url=<?php echo urlencode(the_permalink()); ?>&media=<?php echo esc_url($pin_image); ?>&description=<?php print alder_social_title( get_the_title() ); ?>"><i class="fa fa-pinterest"></i></a>
</div>
<?php endif; ?>
<?php if(!get_theme_mod('alder_post_comment_link')) : ?>
<div class="meta-comment">
<i class="fa fa-comment"></i>
</div>
<?php endif; ?>
</div>
<?php else : ?>
<?php if(!get_theme_mod('alder_post_share_author')) : ?>
<div class="meta-author">
<?php echo get_avatar( get_the_author_meta('email'), '60' ); ?><span class="by"><?php esc_html_e( 'by', 'alder' ); ?></span> <span class="vcard author"><span class="fn"><?php the_author_posts_link(); ?></span></span>
</div>
<?php endif; ?>
<?php endif; ?>
</div>
<?php if(!get_theme_mod('alder_post_related')) : ?>
<?php if(is_single()) : ?>
<?php get_template_part('inc/templates/post-related'); ?>
<?php endif; ?>
<?php endif; ?>
<?php comments_template( '', true ); ?>
<?php if(!get_theme_mod('alder_post_pagination_hide')) : ?>
<?php if(is_single()) : ?>
<?php get_template_part('inc/templates/post-pagination'); ?>
<?php endif; ?>
<?php endif; ?>
</article>
</div>
/* CSS */
}
.post-meta .shop-social {
display: flex;
clear: both;
}
.post-meta .shop-social .post-share a,
.post-meta .shop-social .meta-comment a {
margin-left: 10px;
}
.post-meta .shop-social .shop-my-look,
.post-meta .shop-social .post-share,
.post-meta .shop-social .meta-comment {
display: contents;
}
.post-meta .shop-social .shop-my-look a {
flex-grow: 3;
}
.post-meta .shop-social a {
background: #ffff;
border: 1px solid #dfdfdf;
color: #2e2e2e;
display: block;
font-size: 11.5px;
font-weight: 400;
height: 40px;
letter-spacing: 2px;
line-height: 40px;
width: 4em;
padding: 0 18px;
text-align: center;
text-transform: uppercase;
}
.post-meta .shop-my-look a {
font-size: 11px;
}
.post-meta .shop-social: hover {
background: #ffff;
border: 1px solid #eee;
color: #f37761;
}
In your CSS you have a space between the : and hover. This would cause the hover not to work.
I added hover through console and it works fine
.shop-my-look a:hover {
backgound-color: #ffff;
color: #f37761;
border color: #f37761.
}

wordpress Footer css doesn't work

Footer css appears right on every page except single.php page.. The browsers reads on every page in css:
#sidebar + #wrapper + #footer {
margin-left:18em;
}
but at full post page
#sidebar + #wrapper + #footer {
margin-left: 18em;
}
it doesn't work
Footer css
/* Footer */
#sidebar + #wrapper + #footer {
margin-left: 18em;
}
#media screen and (max-width: 1280px) {
#sidebar + #wrapper + #footer {
margin-left: 0;
}
}
#footer > .inner a {
border-bottom-color: rgba(255, 255, 255, 0.15);
}
#footer > .inner a:hover {
border-bottom-color: transparent;
}
#footer > .inner .menu {
font-size: 0.8em;
color: rgba(255, 255, 255, 0.15);
}
#header + #wrapper + #footer > .inner {
margin: 0 auto;
}
footer.php
<!-- Footer -->
<footer id="footer" class="wrapper style1-alt">
<div class="inner">
<ul class="menu">
<?php if ( ! dynamic_sidebar( 'footer_sidebar' ) ) : ?>
<li>© Untitled. All rights reserved.</li>
<?php endif; ?>
</ul>
</div>
</footer>
<!-- Scripts -->
<?php wp_footer(); ?>
</body>
</html>
single.php
<?php get_header(); ?>
<!-- Wrapper -->
<div id="wrapper">
<!-- One -->
<section id="one" class="wrapper style2 spotlights">
<?php while(have_posts()) : the_post(); ?>
<section>
<div class="content">
<div class="sin_content">
<h2><?php the_title(); ?></h2>
<?php echo do_shortcode("[easy_image_gallery]");
remove_filter( 'the_content', 'easy_image_gallery_append_to_content' ); ?>
</div>
<?php the_content(); ?>
</div>
</div>
</section>
<div class="wordpress_commentss-hd">
<div class="wordpress_commentss">
<?php comments_template(); ?>
</div>
</div>
<?php endwhile; ?>
</section>
</div>
<?php get_footer(); ?>
why it doesn't work on full posts pages while works fine on other pages?
Haha, found it :) You have one too many closing div's. Remove the one in single.php between:
remove_filter( 'the_content', 'easy_image_gallery_append_to_content' ); ?>
</div> <--- That one!
<?php the_content(); ?>

Why is my post being created inside another post? [ Wordpress ]

I know there is probably a solved question like this already, but I can't seem to find it.
I am just starting out so this may be a noob question, please bear with me ><
I am trying to display the top 3 recent posts on front-page.php of my site, the problem is that the post keeps being created within itself.
Here is the CSS involved.
.news-container{ background-color: #fff;
padding: 2em;
max-width: 600px;
heigth:300px;
text-align: left;
}
.has-thumbnail {
position: relative;
padding-left: 200px;
}
.post-thumbnail {
position:absolute;
top:0;
left:0;
}
article.post { border-bottom: 1px solid #bbbbbb;
margin-bottom: 3em;
}
article.post:last-of-type { border-bottom: none;
}
Here is the front-page.php code involved.
<div class="news-container">
<?php
$recentposts=get_posts('showposts=5');
if ($recentposts) {
foreach($recentposts as $post) {
setup_postdata($post);
?>
<article class="post <?php if ( has_post_thumbnail() ) { ?> has-thumbnail <?php } ?> ">
<div class="post-thumbnail">
<?php the_post_thumbnail('small-thumbnail'); ?>
</div>
<p><?php the_time('F j, Y'); ?>
<h3><?php the_title()?> </h3>
<p>
<?php echo get_the_excerpt(); ?>
Read more »
<br><br> <br><br> <br><br>
</p>
<?php
}
}
?>
</article>
</div>
Why is this happening? Thanks for reading this!
Try this updated code i think you not close all tags properly. This will solve your problem.
<div class="news-container">
<?php
$args = array('posts_per_page' => 5, 'post_type'=>'post' );
query_posts($args); $post_query = new WP_Query( $args );
while($post_query->have_posts()){ $post_query->the_post();
?>
<article class="post <?php if ( has_post_thumbnail() ) { ?> has-thumbnail <?php } ?> ">
<div class="post-thumbnail">
<?php the_post_thumbnail('small-thumbnail'); ?>
</div>
<p><?php the_time('F j, Y'); ?> </p>
<h3><?php the_title()?> </h3>
<p><?php echo get_the_excerpt(); ?>
Read more »
<br><br> <br><br> <br><br>
</p>
</article>
<?php } ?>
</div>
You can accomplish this with the WP Latest Posts Plugin: https://wordpress.org/plugins/wp-latest-posts/screenshots/

How to limit a user description to a certain amount of characters in a user list?

I'm changing the layout of my "users" page in a Wordpress website here
I would like to limit the numbers of characters of the description to a certain amount, in order to "equalize" the bio of each author (user).
Is it possible?
Here the template code:
<?php
/*
Template Name: Display Contributors and Authors
*/
$args = array(
'role' => 'contributor',
'orderby' => 'post_count',
'order' => 'DESC'
);
$contributors = get_users( $args );
?>
<?php get_header();?>
<div id="main">
<div id="primary" class="three-parts archive">
<div class="widget-title">
<?php the_title(); ?>
</div>
<div id="blog-list" class="blog-category">
<ul>
<?php
foreach($contributors as $contributor)
{
?>
<li style="margin-top: 10px; width:25%;">
<div class="blog-post-image">
<div class="image_fx5">
<a href=<?php echo get_author_posts_url( $contributor->ID ); ?>><?php echo get_avatar( $contributor->user_email, '128' ); ?></a>
</div>
</div>
<!--author-image-->
<div class="blog-post-title-box">
<div class="blog-post-title">
<h2>
<a href=<?php echo get_author_posts_url( $contributor->ID ); ?>><?php echo $contributor->display_name; ?></a>
</h2>
</div>
</div>
<!--author-name-->
<div class="blog-post-content" style="padding-bottom: 0px; text-align: justify;">
<?php echo $contributor->description; ?>
</div>
<div id="author-info" style="margin-top: 0px; padding-left: 0px; padding-right: 0px; border-bottom-width: 0px;">
<div id="author-desc" style="width: 100%;">
<ul class="author-social" style="padding-top: 0px;">
<?php if($contributor->facebook) { ?>
<li style="
margin-top: 0px;
padding-left: 0px;
padding-right: 0px;
height: 25px;
">
<a href="http://facebook.com/<?php echo $contributor->facebook; ?>" class="fb-social-icon" target="_blank">
</a>
</li>
<?php } ?>
<?php if($contributor->twitter) { ?>
<li style="
margin-top: 0px;
padding-left: 0px;
padding-right: 0px;
height: 25px;
">
<a href="https://twitter.com/<?php echo $contributor->twitter; ?>" class="twitter-social-icon" target="_blank">
</a>
</li>
<?php } ?>
<?php if($contributor->google) { ?>
<li style="
margin-top: 0px;
padding-left: 0px;
padding-right: 0px;
height: 25px;
">
<a href="http://plus.google.com/<?php echo $contributor->google; ?>?rel=author" class="google-social-icon" target="_blank">
</a>
</li>
<?php } ?>
<?php if($contributor->pinterest) { ?>
<li style="
margin-top: 0px;
padding-left: 0px;
padding-right: 0px;
height: 25px;
">
<a href="http://www.pinterest.com/<?php echo $contributor->pinterest; ?>?rel=author" class="pinterest-social-icon" target="_blank">
</a>
</li>
<?php } ?>
<?php if($contributor->instagram) { ?>
<li style="
margin-top: 0px;
padding-left: 0px;
padding-right: 0px;
height: 25px;
">
<a href="http://www.instagram.com/<?php echo $contributor->instagram; ?>?rel=author" class="instagram-social-icon" target="_blank">
</a>
</li>
<?php } ?>
</ul>
</div>
</div>
<!--author-desc-->
</li>
<?php } ?>
</ul>
</div>
</div>
<!--primary-->
<div id="secondary">
<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Category Sidebar')): endif; ?>
</div>
<!--secondary-->
</div>
<!--main-->
<?php get_footer(); ?>
Assuming you mean the description try...
<?php echo substr($contributor->description, 0, strpos($contributor->description, ' ', 150)); ?>
Which will return 150 (you can change this to what you like) characters and also make sure it finishes the last word as well.

Resources