I got this problem which my limited capabilities can´t handle. I tried to use the near solutions but does not work the way I expected.
In the post nav previous link I want to retrieve the thumbnail image link and text over the image and make the whole thing clickable and zoom in on it while hovering. Like in the end of http://swordandscale.com/sword-and-scale-episode-100/. But I only manage to get the text. Here is my function,
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<div class="container">
<div class="row">
<div class="col-xs-12 col-md-10 col-lg-8 col-lg-offset-2 col-md-offset-1">
<?php
if( have_posts() ):
while( have_posts() ): the_post();
sidekick_save_post_views( get_the_ID() );
get_template_part( 'template-parts/single', get_post_format() );
echo sidekick_post_navigation();
if ( comments_open() ):
comments_template();
endif;
endwhile;
endif;
?>
</div><!-- .col-xs-12 -->
</div><!-- .row -->
</div><!-- .container -->
</main>
</div><!-- #primary -->
/*
========================
SINGLE POST CUSTOM FUNCTIONS
========================
*/
function sidekick_post_navigation(){
$nav = '<div class="row">';
$prev = get_previous_post_link( '<div class="post-link-nav">%link</div>', '%title' );
$nav .= '<div class="col-xs-12 text-center">' . $prev . '</div>';
$next = get_next_post_link( '<div class="post-link-nav">%link</div>', '%title' );
$nav .= '<div class="col-xs-12 text-center">' . $next . '</div>';
$nav .= '</div>';
return $nav;
}
First thing you need to do is open your theme’s single.php file and add the following code inside the loop most likely after the_content() area:
<div id="cooler-nav" class="navigation">
<?php $prevPost = get_previous_post(true);
if($prevPost) {?>
<div class="nav-box previous">
<?php $prevthumbnail = get_the_post_thumbnail($prevPost->ID, array(100,100)
);?>
<?php previous_post_link('%link',"$prevthumbnail <p>%title</p>", TRUE); ?>
</div>
<?php } $nextPost = get_next_post(true);
if($nextPost) { ?>
<div class="nav-box next" style="float:right;">
<?php $nextthumbnail = get_the_post_thumbnail($nextPost->ID, array(100,100) );
} ?>
<?php next_post_link('%link',"$nextthumbnail <p>%title</p>", TRUE); ?>
</div>
<?php } ?>
</div><!--#cooler-nav div -->
Next thing you need to do is open your style.css file and add the following styles:
#cooler-nav{clear: both; height: 100px; margin: 0 0 70px;}
#cooler-nav .nav-box{background: #e9e9e9; padding: 10px;}
#cooler-nav img{float: left; margin: 0 10px 0 0;}
#cooler-nav p{margin: 0 10px; font-size: 12px; vertical-align: middle;}
#cooler-nav .previous{float: left; vertical-align: middle; width: 250px;
height: 100px;}
#cooler-nav .next{float: right; width: 250px;}
Feel free to change the styling to match it with your theme. Often our users like to style the code, so it makes it easier for them to tweak it. This is just basic styling which you should be able to customize easily.
If you want to change the thumbnail size, then simply change the array(100,100) to whatever you like.
hope that is usefull for you .
Related
I need to display my first two posts initially in two columns and the other three in three columns. See screenshot below:
This is what I have so far:
<section class="cases">
<div class="container">
<h4 class="title">Cases</h4>
<?php
$args = array(
'post_type' => 'cases',
'posts_per_page' => 5,
);
$the_query = new WP_Query( $args );
if ( $the_query -> have_posts() ):
?>
<div class="row">
<?php
while ( $the_query->have_posts() ): $the_query->the_post();
$slug = get_post_field( 'post_name', get_post() );
?>
<div class="col-sm-6">
<?php the_title(); ?>
<?php the_field('case_content') ?>
Bekijk de case
</div>
<?php endwhile; wp_reset_postdata();?>
</div>
<?php endif;?>
</div>
</section>
And this is what I end up with:
How to proceed from here?
Like explained in my comment I would recommend you to make the markup for all 6 elements the same and on the same level and then style them differently with css. Have a look at flexbox. You can make the first 2 elements 50% width and the others 33%. Use media queries to make them responsive.
Here is some basic example code:
.container {
display: flex;
flex-wrap: wrap;
margin: 0 auto;
max-width: 900px;
}
.item {
box-sizing: border-box;
border: 4px solid #fff;
background: #ddd;
flex: 1 1 50%;
min-height: 200px;
}
.item:nth-child(3),
.item:nth-child(4),
.item:nth-child(5) {
flex: 1 1 33%;
}
<div class="container">
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
<div class="item"></div>
</div>
This should be a good starting point to make this layout.
i have a menu in the left and i want the site-content resize by changing the screen size. actually like in https://myspace.com/
what i have now:
the menu in the left side. this is the code:
.main-navigation {
background-color: #000000;
border-left: 1px solid #cccccc;
display: block;
float: left;
font-family: "Open Sans Condensed", Helvetica, Arial, sans-serif;
font-weight: normal;
max-width: 50%;
position: absolute;
top: 85px;
width: 150px;
height: auto;
text-align: right;
text-transform: capitalize;
}
the site-content i putted margin-left 150px to put the content after the menu because if not, the content is under the menu. :
.blog .site-content,
.archive .site-content,
.search .site-content {
margin: 0 auto;
max-width: 885px;
position: relative;
left: 0px;
margin-left: 150px;
}
and the article that inside:
.blog .site-content .hentry,
.archive .site-content .hentry,
.search .site-content .hentry {
float: left;
margin: 0;
overflow: hidden;
width: 295px;
height: 295px;
}
the main-index is:
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php
/* Include the Post-Format-specific template for the content.
* If you want to override this in a child theme, then include a file
* called content-___.php (where ___ is the Post Format name) and that will be used instead.
*/
get_template_part( 'content', 'home' );
?>
<?php endwhile; ?>
<?php pictorico_paging_nav(); ?>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_footer(); ?>
the nav(menu) is in the header so the header:
<?php wp_head(); ?>
>
<header id="masthead" class="site-header" role="banner">
<div class="site-header-inner">
<div class="site-branding">
<h1 class="site-title"><?php bloginfo( 'name' ); ?></h1>
<h2 class="site-description"><?php bloginfo( 'description' ); ?></h2>
</div>
<nav id="site-navigation" class="main-navigation" role="navigation">
<h1 class="menu-toggle"><span class="screen-reader-text"><?php _e( 'Menu', 'pictorico' ); ?></span></h1>
<a class="skip-link screen-reader-text" href="#content"><?php _e( 'Skip to content', 'pictorico' ); ?></a>
<?php wp_nav_menu( array( 'theme_location' => 'primary' ) ); ?>
</nav><!-- #site-navigation -->
<div class="header-search">
<?php get_search_form(); ?>
</div>
</div>
</header><!-- #masthead -->
<?php if ( is_home() && pictorico_has_featured_posts( 1 ) ) : ?>
<?php get_template_part( 'content', 'featured' ); ?>
<?php elseif ( get_header_image() && ( is_home() || is_archive() || is_search() ) ) : ?>
<div class="hentry has-thumbnail">
<div class="entry-header">
<div class="header-image" style="background-image: url(<?php header_image(); ?>)">
<span class="screen-reader-text"><?php bloginfo( 'name' ); ?></span>
</div>
</div>
</div>
<?php endif; ?>
<div id="content" class="site-content">
It's a bit late to implement now, but next time look at something like Bootstrap or Zurb Foundation for frameworks that make it really fast to build responsive web apps. They take away the need for complicating things with media queries. Just a thought
Your content is not going to re-size because you have given it a fixed width (295px). Since you floated them, they should just re-arrange themselves based on how much room there is in site-content.
If you actually want the articles to re-size, give them percentage widths. Then, as site-content changes width, they will also.
If you want to keep the aspect ratio (height/width), then you need a wrapper that maintains the aspect ratio using % padding and put the content in it using postion: absolute. See, for example, Maintain the aspect ratio of a div with CSS.
I've looked this up and have found numerous similar issues - tried troubleshooting but couldn't work it out, I can't for the life of me figure out why the div is dropping below the blog post, pushing everything out. The sidebar should sit next to the blog post, i.e. 3/4 post, 1/4 sidebar. Instead the sidebar is pushed below the post. This happens to all posts regardless of images/text etc.... so it's not an image or text issue from what I gather.
http://pastestudios.com/buying-property-sydney/
<div id="pageHead">
<?php $blog_page_id = of_get_option('ttrust_blog_page'); ?>
<?php $blog_page = get_page($blog_page_id); ?>
<h1><?php echo $blog_page->post_title; ?></h1>
<?php $page_description = get_post_meta($blog_page_id, "_ttrust_page_description_value", true); ?>
<?php if ($page_description) : ?>
<p><?php echo $page_description; ?></p>
<?php endif; ?>
</div>
<div id="content" class="threeFourth clearfix">
<?php while (have_posts()) : the_post(); ?>
<div <?php post_class(); ?>>
<h1><a href="<?php the_permalink() ?>" rel="bookmark" ><?php the_title(); ?></a></h1>
<div class="meta clearfix">
<?php $post_show_author = of_get_option('ttrust_post_show_author'); ?>
<?php $post_show_date = of_get_option('ttrust_post_show_date'); ?>
<?php $post_show_category = of_get_option('ttrust_post_show_category'); ?>
<?php $post_show_comments = of_get_option('ttrust_post_show_comments'); ?>
<?php if($post_show_author || $post_show_date || $post_show_category){ _e('Posted ', 'themetrust'); } ?>
<?php if($post_show_author) { _e('by ', 'themetrust'); the_author_posts_link(); }?>
<?php if($post_show_date) { _e('on', 'themetrust'); ?> <?php the_time( 'M j, Y' ); } ?>
<?php if($post_show_category) { _e('in', 'themetrust'); ?> <?php the_category(', '); } ?>
<?php if(($post_show_author || $post_show_date || $post_show_category) && $post_show_comments){ echo " | "; } ?>
<?php if($post_show_comments) : ?>
<?php comments_number(__('No Comments', 'themetrust'), __('One Comment', 'themetrust'), __('% Comments', 'themetrust')); ?>
<?php endif; ?>
</div>
<?php if(of_get_option('ttrust_post_show_featured_image')) : ?>
<?php if(has_post_thumbnail()) : ?>
<?php if(of_get_option('ttrust_post_featured_img_size')=="large") : ?>
<?php the_post_thumbnail('ttrust_post_thumb_big', array('class' => 'postThumb', 'alt' => ''.get_the_title().'', 'title' => ''.get_the_title().'')); ?>
<?php else: ?>
<?php the_post_thumbnail('ttrust_post_thumb_small', array('class' => 'postThumb alignleft', 'alt' => ''.get_the_title().'', 'title' => ''.get_the_title().'')); ?>
<?php endif; ?>
<?php endif; ?>
<?php endif; ?>
<?php the_content(); ?>
<?php wp_link_pages( array( 'before' => '<div class="pagination clearfix">Pages: ', 'after' => '</div>' ) ); ?>
</div>
<?php comments_template('', true); ?>
<?php endwhile; ?>
</div>
<?php get_sidebar(); ?>
First, set box-sizing: border-box
Next, make #content and #sidebar equal to 100% width. Right now you have #content set at 100% and #sidebar set in pixels so, naturally, it will push your sidebar down.
Try something like:
* { box-sizing: border-box; }
#content {
width: 65%;
}
#sidebar {
width: 35%;
}
Your article area is 100% wide. So there is no space for sidebar. Try to adjust width and margins to make total 100. Something like following code.
#content {
width: 70%;
float: left;
margin-left: 3%;
}
#sidebar {
width: 22%;
float: right;
margin-right: 3%;
}
Your image at Blog page does not adjust with browser width. See it in smaller screen size. To make it adjustable and remove horizontal scrollbar at smaller resolutions, use following CSS code.
#content .alignleft,
#content img.alignleft {
max-width: 100%;
}
It looked like you may have been working on it while I had a look at it. At the time I was able to change width: 100%; to width: 720px; in your #content id and it seemed to work in getting the sidebar vertically aligned to top, side by side with your content area.
I also noticed you had multiple ids of the same name, #content in particular. Might want to clean up the css so you can look at it more clearly if you have any more problems. Happens to me all the time when I'm chasing a problem, my css gets out of control and I lose track of the changes I made to try and correct the problems.
I have a wordpress page with a login widget <div id='widget-sidebar' class='widgets_on_page'> above the forum content. I would like to float it to the right and have the forum title to align vertically on the left, like this:
The problem I am having is that the forum title is generated dynamically and so I can't place them in the same div.
Any ideas?
Here is the source code:
<div id="primary">
<div id="content" role="main">
<div id='widget-sidebar' class='widgets_on_page'>
<ul><li id="wp_sidebarlogin-2" class="widget widget_wp_sidebarlogin"><h2 class="widgettitle">Welcome Admin</h2><div class="avatar_container"><img src="http://localhost/wordpress/wp-content/plugins/user-avatar/user-avatar-pic.php?src=http://localhost/wordpress/wp-content/uploads/avatars/1/1344255249-bpfull.jpg&w=38&id=1&random=1344255249" alt="" class=" avatar avatar-38 photo user-1-avatar" width="38" height="38" /></div><ul class="pagenav"><li class="page_item">Dashboard</li><li class="page_item">Profile</li><li class="page_item">Logout</li></ul></li></ul>
</div><!-- widgets_on_page -->
<article id="post-2901" class="post-2901 forum type-forum status-publish hentry">
<header class="entry-header">
<h1 class="entry-title">NA Forum</h1>
</header><!-- .entry-header -->
Here is the part of my forum page template that I'm working with:
<div id="primary">
<div id="content" role="main">
<?php widgets_on_template("widget-sidebar"); ?>
<?php if ( have_posts() ) : ?>
<?php twentyeleven_content_nav( 'nav-above' ); ?>
<?php /* Start the Loop */ ?>
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', get_post_format() ); ?>
<?php endwhile; ?>
<?php twentyeleven_content_nav( 'nav-below' ); ?>
Using absolute positioning for the widget should work. Something like:
div#content {
position: relative;
}
div#widget-sidebar {
position: absolute;
top: 10px;
right: 10px;
}
If you don't care for IE7 you can align container vertically using display: table-cell;. As this is rendered as a table, it looses the ability to float. So you have to set a width explicitly on at least one of the elements.
CSS
div {
display: table-cell;
vertical-align: middle;
}
div:first-child {
width: 80%;
}
HTML
<div>
first line<br>
second line<br>
last line
</div>
<div>
just one line<br>
</div>
Fiddle
http://jsfiddle.net/y96hb/
the site is http://www.christopherwaller.com/wordpress/
if you take a look on the above site i'm trying to insert a link to a page on each of the images on a carousel, so if you click anywhere on the image it will navigate to a new page. I have created the link i want on the post title text (ie. Look 1, Look 2 etc . . .) by using
<h2 class="postitle"><?php the_title(); ?></h2>
but i can't for the life of me find the right PHP to create the same links on each of the carousel photos?
I'm still trying to get to grips with PHP if anyone could advise that would be great.thanks
this is the PHP
<div class="edit"><?php edit_post_link(); ?></div>
</div>
<div class="postcontent">
<?php
$content = $post->post_content;
$searchimages = '~<img [^>]* />~';
preg_match_all( $searchimages, $content, $pics );
$iNumberOfPics = count($pics[0]);
if ( $iNumberOfPics > 0 ) { ?>
<?php the_thumb('medium'); ?>
<?php } else { ?>
<div class="imgframe"></div>
<?php } ?>
<div class="post_content">
<h2 class="postitle"><?php the_title(); ?></h2>
<?php the_excerpt(); ?>
<?php wp_link_pages('<p class="pages"><strong>'.__('Pages:').'</strong> ', '</p>', 'number'); ?>
<div class="post_meta">
<div class="author"><?php the_author(); ?></div>
<div class="date_meta"><?php the_date(); ?></div>
<div class="category_meta"><?php the_category(', '); ?></div>
</div>
</div>
</div>
<div class="postbg_bottom"></div>
<div class="social_links">
<a class="read" title="Read the rest of this post" href="<?php the_permalink(); ?>">read more</a>
</div>
</div>
<?php endwhile ?>
<div class="navigation">
<div class="nxt_page"><?php previous_posts_link('New Entries »', 0); ?></div>
<div class="prv_page"><?php next_posts_link('« Old Entries', '0') ?></div>
</div>
<?php endif ?>
</div>
</div>
<!--CONTENT END-->
and the CSS
/* Easy Slider */
#slider ul, #slider li{margin:0;padding:0;list-style:none;}
#slider li, #slider2 li{ width:1000px;height:1100px;}
#nextBtn{display:block; width:13px; height:14px; position:relative; left:0px; top:0px; z- index:1000; right:120px; top:-718px; float:left; left:840px; margin-right:20px; }
#prevBtn{display:block; width:13px; height:14px; position:relative; left:300px; top:0px; z-index:1000; right:120px; top:-718px; float:left; left:-100px; margin-right:20px; }
#prevBtn{ left:-20px;}
#nextBtn a, #prevBtn a{ display:block;position:relative;width:13px;height:14px;
background:url(images/sl_left.png) no-repeat 0 0;}
#nextBtn a{ background:url(images/sl_right.png) no-repeat 0 0;}
.graphic, #prevBtn, #nextBtn{padding:0; display:block; overflow:hidden; text-indent:-8000px;}
/* Easy Slider END */
/*SLIDER END*/
You could try using the following instead of "the_thumb();"
add the following to your theme's 'functions.php'
// Add post thumbnail theme support
add_theme_support('post-thumbnails');
Then use the following to replace the 'the_thumb();'
if ( has_post_thumbnail() )
the_post_thumbnail();
I actually use this myself and created a plugin that links the post thumbnail to the post. It seems like you're trying to do the same kind of thing so I hope this works for you.
I understand you are using the PostThumb revisited plugin, correct? And if I read correctly, this plugin outputs a single picture with the_excerpt() . If that is the case, couldn't you just do this? :
<a href="<?php the_permalink();?>">
<?php the_excerpt(); ?>
</a>