I am trying to get a sidebar to appear correctly in Wordpress framework with some effort here but I am almost their but the sidebar needs to appear to the right of the text of the blog just beside the title to the far right
You can view the page in question here http://kvalixhu.digitalthinkersni.co.uk/blog/
Image for how I want it to display
https://nimbus.everhelper.me/client/notes/share/369625/9zqAVkxFA4iFRBTqA1E5mw20uuWOqgs8/
<?php
/**
* Template Name: BlogPosts
*/
get_header();
?>
<style>
#title_wrapper{
width:488px;
}
h2{
font-size:18px;
font-familly:verdana, arial, sans-serif;
line-height:16px;
display:inline;
padding:2px;
}
#dateinfo{
font-weight:bold;
}
</style>
<div id="main-content" class="main-content">
<?php
if (is_front_page()) {
get_template_part('featured-content');
}
?>
<div class="full-width page-header">
<div class="row">
<div class="column">
<h1>Blog</h1>
</div>
</div>
</div>
<div class="row show-for-medium-up">
<div class="column breadcrumb">
<?php
if (function_exists('yoast_breadcrumb')) {
//echo __('Home',TD) . ' > ';
yoast_breadcrumb('<span id="breadcrumbs">', '</span>');
}
?>
<?php
if (function_exists('bcn_display_list_multidim_children')) {
?><ul class="breadcrumbs">
<?php
bcn_display_list_multidim_children();
?>
</ul><?php
}
?>
</div>
</div>
<div class="row">
<div class="column small-12 product">
<?php
$logo = get_post_meta(get_the_ID(), 'logo', true);
?>
<div class="post-list" style="width:80%;">
<?php
$myposts = get_posts('numberposts=-1&offset=$debut');
foreach ($myposts as $post):
setup_postdata($post);
?>
<div id="dateInfo" style="float:right;">
<?php the_date('Y.m.j'); ?> |
<?php comments_number( '0 hozzászólás', '1 hozzászólás', '% hozzászólás' ); ?>.
</div>
<div id="title_wrapper">
<h2><?php the_title(); ?></h2>
</div>
<div class="thumbnail" style="float: left; margin: 10px">
<?php the_post_thumbnail( array( 395, 195 ) ); ?>
<div class="thumbnail-arrow"></div>
</div>
<!-- Display movie review contents -->
<div class="entry-content"><?php the_content(); ?></div>
<div>
<?php
endforeach;
?>
<div class="column small-6 product " style="float:right;">
<?php if (!function_exists('dynamic_sidebar') || !dynamic_sidebar('Right Sidebar')) : ?>
[ do default stuff if no widgets ]
<?php endif; ?>
</div>
<hr />
</div>
</div> </div>
</div>
<?php
get_footer();
?>
The first thing that you would want to do is move the "sidebar div" outside of the post-list div, and adding "float:left;" to the post-list div.
Also, add a width to the sidebar div with "width: 20%;" to make sure it fits.
The answer is a bit vague but hopefully you understand.
Hopefully this helps
Related
Blog Posts with Grid Layout even number columns doesn't display correctly .The problem occurs with 3 column layout also: for each group of 3 posts
<div class="main" role="main">
<div id="content" class="content full">
<div class="container">
<?php if(have_posts()) : ?>
<?php while(have_posts()) : the_post();
$title = get_the_title();?>
<div class="row">
<?php if ( has_post_thumbnail() ) { ?>
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
<a href="<?php echo esc_url(get_permalink(get_the_ID())) ?><?php
the_post_thumbnail('imic_600x400'); ?></a>
<?php } ?>
<?php if ( has_post_thumbnail() ) { ?><?php } ?>
<h3><a href=" <?php echo esc_url(get_permalink(get_the_ID())); ?>
<?php
echo esc_attr($title); ?>
</a>
</h3>
</div>
<?php endwhile; ?>
<!-- Pagination -->
<?php if(function_exists('imic_pagination')) { imic_pagination(); }
else { next_posts_link( 'Older Entries');
previous_posts_link( 'Newer Entries' ); } ?>
<?php endif;?>
</div>
<?php if(is_active_sidebar($pageSidebar)) { ?>
<!-- Sidebar -->
<div class="sidebar" id="sidebar-col">
<?php dynamic_sidebar($pageSidebar); ?>
</div>
<?php } ?>
</div>
</div>
</div>
Try changing the created HTML structure as follows (in Inspect Element view to verify it works):
<div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
</div><!--
--><div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
</div><!--
--><div class="col-xs-3 col-sm-3 col-md-3 col-lg-3">
</div>
(note the <!-- --> HTML comments)
If that solves the problem, try adding the HTML comments into your PHP code.
The reason for this behaviour is the resulting new line being interpreted as a "space" and thus the third item won't fit into the same row because of the added horizontal space.
You could also output the HTML-<div class="row">...</div> without line-breaks, eg. by concatenating the markup as one PHP string.
Sorry, I'm a complete newbie at this, My question may sound stupid to some.
I've taken over maintenance of a WordPress site done by another developer who's no longer reachable. I'm having trouble with getting the content to display properly on the following page https://www.covalin.com/product-category/boxes/metallic-boxes/, when I change the number of products to be shown on the page to anything higher than 9, then it pushes the footer to the middle of the page and shows products below the footer. I want to be able to all products under each subcategory. Please see the screenshots below in order to get an idea of the issue. Any guidance will be most appreaciated, I've spent hours trying to figure this out.
When I use the following CSS below, it partly solves the problem but creates another one where all of the content is scrollable but appears behind the footer.
CSS Code - used
.footer {
position: fixed;
bottom:0;
}
PHP Code which changes the number of products display, added by last dev:
/*---------- woo-product pagination number setting ------------*/
add_filter( 'loop_shop_per_page', 'new_loop_shop_per_page', 20 );
function new_loop_shop_per_page( $cols ) {
// $cols contains the current number of products per page based on the value
stored on Options -> Reading
// Return the number of products you wanna show per page.
$cols = 27; //I changed this from 27 to 9 for the page to display properly.
return $cols;
}
How the site looks like with 9 products on a page
How the site looks like with 27 products on a page
Updated - with footer.php file below
<?php
/**
* The template for displaying the footer
*
* Contains footer content and the closing of the #main and #page div elements.
*
* #package WordPress
* #subpackage Twenty_Fourteen
* #since Twenty Fourteen 1.0
*/
?>
<?php // Check if site turned to boxed version
$boxed = ''; $boxed_element = ''; $row_class = '';
if (get_option('site_layout')=='boxed') {$boxed = 'container'; $boxed_element = 'col-md-12 col-sm-12'; $row_class = 'row';}
?>
<?php if ($boxed && $boxed!='') { ?>
</div>
<div class='row'>
<?php } ?>
<?php if ( class_exists('Woocommerce') ): ?>
<?php if(is_shop() || is_product() && is_active_sidebar('footer-bottom-shop')): ?>
<?php if (!$boxed || $boxed=='') : ?><div class="container">
<div class="row"><?php endif; ?>
<div class="shop-bottom-sidebar col-xs-12 col-sm-12 col-md-12">
<?php dynamic_sidebar('footer-bottom-shop'); ?>
</div>
<?php if (!$boxed || $boxed=='') : ?></div>
</div><?php endif; ?>
<?php endif ?>
<?php endif ?>
<footer id="colophon" class="site-footer <?php echo esc_attr($boxed_element);?>">
<?php
if (get_option('site_footer_top_background_option') && get_option('site_footer_top_background_option')!=''){
$site_footer_top_background_option = get_option('site_footer_top_background_option');
}
else{$site_footer_top_background_option='';}
?>
<?php if(is_active_sidebar('footer-top-sidebar-1') || is_active_sidebar('footer-top-sidebar-2')): ?>
<div class="footer-top widget-area <?php echo esc_attr($row_class);?>" style="background:<?php echo esc_attr($site_footer_top_background_option); ?>;">
<?php if (!$boxed || $boxed=='') : ?><div class="container">
<div class="row"><?php endif; ?>
<div class="col-xs-12 col-sm-6 col-md-6 footertopsidebarone">
<?php if(is_active_sidebar('footer-top-sidebar-1')): ?>
<?php dynamic_sidebar('footer-top-sidebar-1'); ?>
<?php endif;?>
</div>
<div class="col-xs-12 col-sm-6 col-md-6 footertopsidebartwo">
<?php if(is_active_sidebar('footer-top-sidebar-2')): ?>
<?php dynamic_sidebar('footer-top-sidebar-2'); ?>
<?php endif;?>
</div>
<?php if (!$boxed || $boxed=='') : ?></div></div><?php endif; ?>
</div>
<?php endif; ?>
<?php
if (get_option('site_middle_background_option') && get_option('site_middle_background_option')!=''){
$site_middle_background_option = get_option('site_middle_background_option');
}
else{$site_middle_background_option='';}
?>
<div class="footer-middle widget-area <?php echo esc_attr($row_class);?>" style="background:<?php echo esc_attr($site_middle_background_option);?>">
<?php if (!$boxed || $boxed=='') : ?><div class="container">
<div class="row"><?php endif; ?>
<?php
if (get_option('footer_bg_img') && get_option('footer_bg_img')!=''){
$footer_bg_img_url = get_option('footer_bg_img');
}
else{$footer_bg_img_url='';}
if (get_option('footer_bg_img_position') && get_option('footer_bg_img_position')!=''){
$footer_bg_img_position = get_option('footer_bg_img_position');
switch($footer_bg_img_position){
case "right":
$storex_footer_bg_position='96%';
break;
case "left":
$storex_footer_bg_position='4%';
break;
}
}
else{$storex_footer_bg_position='';}
?>
<div class="fotter-bg-img" style="background: url(<?php echo esc_url($footer_bg_img_url)?>) no-repeat transparent; background-position:<?php echo esc_attr($storex_footer_bg_position)?> 90%">
<div class="col-xs-12 col-sm-6 col-md-3">
<?php if ( is_active_sidebar( 'footer-sidebar-1' ) ) : ?>
<?php dynamic_sidebar( 'footer-sidebar-1' ); ?>
<?php endif; ?>
</div>
<div class="col-xs-12 col-sm-6 col-md-3">
<?php if ( is_active_sidebar( 'footer-sidebar-2' ) ) : ?>
<?php dynamic_sidebar( 'footer-sidebar-2' ); ?>
<?php endif; ?>
</div>
<div class="col-xs-12 col-sm-6 col-md-3">
<?php if ( is_active_sidebar( 'footer-sidebar-3' ) ) : ?>
<?php dynamic_sidebar( 'footer-sidebar-3' ); ?>
<?php endif; ?>
</div>
<div class="col-xs-12 col-sm-6 col-md-3">
<?php if ( is_active_sidebar( 'footer-sidebar-4' ) ) : ?>
<?php dynamic_sidebar( 'footer-sidebar-4' ); ?>
<?php endif; ?>
</div>
</div>
<?php if (!$boxed || $boxed=='') : ?></div>
</div><?php endif; ?>
</div>
<?php
if (get_option('site_footer_bottom_background_option') && get_option('site_footer_bottom_background_option')!=''){
$site_bottom_background_option = get_option('site_footer_bottom_background_option');
}
else{$site_bottom_background_option='';}
?>
<div id="footer-bottom" style="background:<?php echo esc_attr($site_bottom_background_option); ?>;" class="<?php echo esc_attr($row_class);?> footer-bottom">
<?php if (!$boxed || $boxed=='') : ?><div class="container">
<div class="row"><?php endif; ?>
<div class="col-xs-12 col-sm-6 col-md-6">
<?php if (has_nav_menu('footer-nav')) : ?><!-- Footer navigation -->
<nav id="site-navigation-footer" class="footer-navigation">
<?php wp_nav_menu( array('theme_location' => 'footer-nav') ); ?>
</nav>
<?php endif; ?><!-- Footer navigation -->
<div class="site-info">
<?php $copyright = esc_attr(get_option('site_copyright'));
if ($copyright != '') {
echo esc_attr($copyright);
} else {
echo 'Storex © '.date('Y') .''.esc_html__(' Theme by Themes Zone. All rights reserved', 'storex');
}
?>
</div>
</div>
<div class="col-xs-12 col-sm-6 col-md-6">
<?php if ( is_active_sidebar( 'footer-bottom' ) ) : ?>
<?php dynamic_sidebar( 'footer-bottom' ); ?>
<?php endif; ?>
</div>
<?php if (!$boxed || $boxed=='') : ?></div>
</div><?php endif; ?>
</div>
</footer><!-- #colophon -->
<?php if ($boxed && $boxed!='') { ?>
</div>
<?php } ?>
</div><!-- #page -->
<script>
jQuery( document ).ready(function() {
jQuery('.quantity').append("<span class='qty-cus'>Qty</span>");
jQuery('.wc-forward').val('View Order');
jQuery('.update_cart').val('Update Order');
});
//review order table text changes
jQuery(window).on('load',function(){
setTimeout(function() { //calls click event after a certain time
jQuery('.cart-subtotal th').text('Order SubTotal');
}, 3000);
jQuery('.update_cart').val('Update Order');
jQuery('.page-template-special-offer .header-stripe h1.title').text('SPECIAL OFFERS');
jQuery('.product-description-wrapper > .quantity').remove();
});
var cloned_field = jQuery('.register p.form-row.full').clone();
jQuery('#custom_fax_no').append(cloned_field);
jQuery('.register p.form-row.full').eq(0).remove();
jQuery(window).scroll(function(){
var winScroll= jQuery(window).scrollTop();
console.log(winScroll);
if(winScroll>0){
jQuery('.header-top').addClass('sticky');
}else{
jQuery('.header-top').removeClass('sticky');
}
});
</script>
<?php wp_footer(); ?>
</body>
</html>
The issue is that you are not closing the <div> properly.
Currently it is like
<div id="page" class="hfeed site container">
<div class='row custom_header'>
<!-- some contents..... -->
</div>
<div class='row'>
<div id="main" class="site-main col-md-12 col-sm-12">
<!-- some contents..... -->
</div>
<div class='row'>
<footer id="colophon" class="site-footer col-md-12 col-sm-12">
<!-- some contents... -->
</footer>
</div>
</div>
</div>
It should be like,
<div id="page" class="hfeed site container">
<div class='row custom_header'>
<!-- some contents... -->
</div>
<div class='row'>
<div id="main" class="site-main col-md-12 col-sm-12">
<!-- some contents... -->
</div>
</div>
<div class='row'>
<footer id="colophon" class="site-footer col-md-12 col-sm-12">
<!-- some contents... -->
</footer>
</div>
</div>
There is no need to change the CSS.
I'm creating a Wordpress template from scratch and I am already in the process of adding sidebars. But I'm having a few problems with the sidebar positioning/placements.
What I want vs What I have
I'm not sure if I'm doing something wrong with the sidebar.php or with the container blocks.
But here's my css code:
/* Sidebar modules for boxing content */
.sdbrcont {
float: left;
background-color: black;
}
My sidebar.php code:
<div class="sdbrcont">
<?php if ( is_active_sidebar( 'left_sdbr' ) ) : ?>
<div id="primary-sidebar" class="primary-sidebar widget-area" role="complementary">
<?php dynamic_sidebar( 'left_sdbr' ); ?>
</div><!-- #primary-sidebar -->
<?php endif; ?>
</div>
and if the problem is on my index.php, here's the code:
<div class="row">
<?php get_sidebar( 'left-sdbr' ); ?>
<div id="contentcont">
<div class="blog-main">
<div class="blogtitle">
<p>PAKU SQUAD
<span class="subheader1">
BLOG
</span>
</p>
<hr>
</div>
<?php
if ( have_posts() ) : while ( have_posts() ) : the_post();
get_template_part( 'content', get_post_format() );
endwhile;?>
<nav>
<ul class="pager">
<li> <?php next_posts_link( 'Older Posts >>>' ); ?> </li>
<li> <?php previous_posts_link( '<<< Newer Posts' ); ?></li>
</ul>
</nav>
<?php
endif;
?>
</div> <!-- /.blog-main -->
</div>
</div> <!-- /.row -->
This is my firt time creating a wordpress template and I would really appreciate all the help I can get. Thank you in advance.
You need to pay attention to Layout grid system in bootstrap: http://getbootstrap.com/docs/4.0/layout/overview/
Because you need to determine the width of the container, else will be all the body.
<div class="container">
<div class="row">
<div class="col">
Sidebar
<div>
<div class="col">
Content
<div>
</div>
</div>
I'm working with Wordpress and Foundation Tabs.
Objective:
To display Wordpress posts from a specific category in vertical Foundation tabs.
I currently have a static version displayed here:
http://www.aos-engineering.com (Under Projects)
Problem:
On the page load, the first tab displayed is empty. However, when you click through the tabs, they display correctly.
Question
How do I display the fist tab item on the page load?
Here is a test page displaying the problem:
http://www.aos-engineering.com/test/
Code
<div class="full-width" id="projects">
<div class="row">
<div class="small-4 medium-3 large-3 columns">
<dl class="tabs vertical profile-tabs" data-tab>
<?php
$displayposts = new WP_Query();
$displayposts->query('category_name=Projects');
while ($displayposts->have_posts()) : $displayposts->the_post();
$tab_number = $displayposts->current_post + 1;
?>
<dd><?php the_title(); ?></dd>
<?php endwhile; ?>
</dl>
</div>
<div class="small-8 medium-9 large-9 columns">
<div class="tabs-head">Projects</div>
<div class="tabs-content">
<?php
while ($displayposts->have_posts()) : $displayposts->the_post();
$tab_number = $displayposts->current_post + 1;
?>
<div class="content" id="tab<?php echo $tab_number;?>">
<h2><?php the_title(); ?></h2>
<div class="row">
<div class="medium-9 large-9 columns">
<?php the_post_thumbnail(); ?>
<p><small><?php the_field('img_caption'); ?></small></p>
</div>
<div class="medium-3 large-3 columns">
<?php the_content(); ?>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
</div>
</div>
Please let me know if I can provide more information. Thank you in advance.
You need to have your code add the class active to the .tabs > dl and the .tabs-content > div you want displayed on page load.
Add this to the two lines after $tab_number = ... to have the first tab be the active tab on load:
$active_class = (1 == $tab_number) ? 'active' : '';
Then in the output:
<dd class="<?php echo $active_class;?>" ><a href=...
<div class="content <?php echo $active_class;?>"...
See the Foundation Tabs documentation for more details.
Hat tip CPILKO for the solution.
Here is how to display Wordpress posts from a specific category in vertical Foundation tabs.
To display your posts, simply add your category name
'category_name=YourCategoryName'
Solution
<div class="full-width" id="projects">
<div class="row">
<div class="small-4 medium-3 large-3 columns">
<dl class="tabs vertical profile-tabs" data-tab>
<?php
$displayposts = new WP_Query();
$displayposts->query('category_name=Projects');
while ($displayposts->have_posts()) : $displayposts->the_post();
$tab_number = $displayposts->current_post + 1;
$active_class = (1 == $tab_number) ? 'active' : '';
?>
<dd class="<?php echo $active_class;?>"><?php the_title(); ?></dd>
<?php endwhile; ?>
</dl>
</div>
<div class="small-8 medium-9 large-9 columns">
<div class="tabs-head">Projects</div>
<div class="tabs-content">
<?php
while ($displayposts->have_posts()) : $displayposts->the_post();
$tab_number = $displayposts->current_post + 1;
$active_class = (1 == $tab_number) ? 'active' : '';
?>
<div class="content <?php echo $active_class;?>" id="tab<?php echo $tab_number;?>">
<h2><?php the_title(); ?></h2>
<div class="row">
<div class="medium-9 large-9 columns">
<?php the_post_thumbnail(); ?>
<p><small>Show above: Huiit Zolars</small></p>
</div>
<div class="medium-3 large-3 columns">
<?php the_content(); ?>
</div>
</div>
</div>
<?php endwhile; ?>
</div>
</div>
</div>
So I've added them support for infinite scroll in my functions.php like so
add_theme_support( 'infinite-scroll', array(
'container' => 'content',
'footer' => 'page',
'posts_per_page' => 4
) );
Here's my template and loop, I added an arbitrary div with the id of 'content' just because jetpack apparently needs the containing div of your posts to be an ID, yet the infinite scroll still doesn't work.
<?php
/*
Template Name: News
*/
?>
<?php get_header(); ?>
<div class="main-content">
<div class="content-left">
<div id="content">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts('posts_per_page=&paged=' . $paged);
?>
<?php if (have_posts()) : while ( have_posts()) : the_post(); ?>
<div <?php post_class('clearfix') ?> id="post-<?php the_ID(); ?>">
<div class="entrywrapper">
<div class="entry">
<div class="bordertop">
<h2><?php the_title(); ?></h2>
</div> <!-- end div bordertop -->
<div class="aligncenter grey">
<?php the_time('M jS, Y') ?>
</div>
<div class="meta">
<span>Posted in :<?php the_category($separator = ' / '); ?></span>
<div class="clearfix"></div>
</div> <!-- end div meta -->
<?php global $more; $more = 0; ?>
<div class="figure">
<?php the_post_thumbnail(); ?>
</div> <!-- end div figure //centers thumbnail -->
<p class="firstparaph"> <?php the_field('main_post_meta'); ?></p>
<?php the_content('Continue Reading >'); ?>
<div class="centerm">
<?php comments_popup_link('No Comments', '1 Comment', '% Comments', 'comments-link', ''); ?>
</div>
<div class="postbreaker">* * *</div> <!-- end div entrybreaker -->
</div> <!-- end div entry -->
<div style="clear:both"></div>
</div> <!-- end div entrywrapper -->
<div style="clear:both"></div>
</div> <!-- end div post -->
<?php endwhile; endif; ?>
<div class="navigation">
<div class="next-posts"><?php next_posts_link('Older Posts') ?></div>
<div class="prev-posts"><?php previous_posts_link('Newer Posts') ?></div>
</div>
</div> <!-- end div ID content -->
</div> <!-- end div content-left -->
<div class="content-right">
<?php get_sidebar(); ?>
</div> <!-- end div content-right -->
<div style="clear:both;"></div>
</div> <!-- end div main-content -->
<?php get_footer(); ?>
Maybe try this:
In functions.php
function get_post_content() {
?>
<div <?php post_class('clearfix') ?> id="post-<?php the_ID(); ?>">
<div class="entrywrapper">
<div class="entry">
<div class="bordertop">
<h2><?php the_title(); ?></h2>
</div> <!-- end div bordertop -->
<div class="aligncenter grey">
<?php the_time('M jS, Y') ?>
</div>
<div class="meta">
<span>Posted in :<?php the_category($separator = ' / '); ?></span>
<div class="clearfix"></div>
</div> <!-- end div meta -->
<?php global $more; $more = 0; ?>
<div class="figure">
<?php the_post_thumbnail(); ?>
</div> <!-- end div figure //centers thumbnail -->
<p class="firstparaph"> <?php the_field('main_post_meta'); ?></p>
<?php the_content('Continue Reading >'); ?>
<div class="centerm">
<?php comments_popup_link('No Comments', '1 Comment', '% Comments', 'comments-link', ''); ?>
</div>
<div class="postbreaker">* * *</div> <!-- end div entrybreaker -->
</div> <!-- end div entry -->
<div style="clear:both"></div>
</div> <!-- end div entrywrapper -->
<div style="clear:both"></div>
</div> <!-- end div post -->
<?php
}
Then in your blog loop file:
<?php
/*
Template Name: News
*/
?>
<?php get_header(); ?>
<div class="main-content">
<div class="content-left">
<div id="content">
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts('posts_per_page=&paged=' . $paged);
?>
<?php if (have_posts()) : while ( have_posts()) : the_post(); ?>
<!-- MY EDIT IS HERE -->
get_post_content();
<?php endwhile; endif; ?>
<div class="navigation">
<div class="next-posts"><?php next_posts_link('Older Posts') ?></div>
<div class="prev-posts"><?php previous_posts_link('Newer Posts') ?></div>
</div>
</div> <!-- end div ID content -->
</div> <!-- end div content-left -->
<div class="content-right">
<?php get_sidebar(); ?>
</div> <!-- end div content-right -->
<div style="clear:both;"></div>
</div> <!-- end div main-content -->
<?php get_footer(); ?>