CSS positioning help - css

http://rent.neighborrow.com/items/herndon need help moving the need have tabs to the right
<div id="tabs" style="width:350px;height:50px;">
<ul style="width:320px;height:35px;">
<li>USERS Have</li>
<li>USERS Want</li>
</ul>
<div id="tabs-1" style="width:350px;height:50px;"">
<ul class="user_have_list" style="width:350px;height:50px;">
<?php if(count($approved_items)): ?>
<?php foreach($approved_items as $item): ?>
<?
//print_r($item);
?>
<li style="width:330px"><?= $html->link($item["items"]["item"], array("controller" => "items", "action" => "view", $item["items"]["id"])); ?></li>
<?php endforeach; ?>
<?php else: ?>
<li style="width:330px">Nothing Here</li>
<?php endif; ?>
</ul>
</div>
<div id="tabs-2" style="width:350px;height:50px;"">
<ul class="user_want_list">
<?php
//if($_SESSION[Auth][User][id]!="")
if(1==1)
{
if(count($requests)): ?>
<?php foreach($requests as $request): ?>
<li style="width:330px"><?= $html->link($request["Request"]["item"], array("controller" => "requests", "action" => "view", $request["Request"]["id"])); ?></li>
<?php endforeach; ?>
<?php else: ?>
<li style="width:330px">Nothing</li>
<?php endif; } ?>
</ul>
</div>
</div>

using firebug, I added float:right; inside the div='tabs'.is this what you want?
<div id="tabs" style="width:350px;height:50px;float:right;">

Related

How to add if else in ACF

<?php
$featured_posts = get_field('director');
if( $featured_posts ): ?>
<ul>
<?php foreach( $featured_posts as $featured_post ):?>
<div class="movies-series-director">
<a class="movies-series-director-thumbnails" href="<?php echo get_page_link($featured_post->ID);?>"> <img src="<?php echo get_the_post_thumbnail_url($featured_post->ID, 'thumbnail');?>"></a>
<div class="movies-series-director-title">
<h4> <?php echo $featured_post->post_title;?> </h4>
<b>Director</b>
</div>
</div>
<?php endforeach; ?>
</ul>
<?php endif; ?>
Guys how to output like this.
If has thumbnail then post thumbanil
else if no thumnail then print this this image (no image)
You want to check if the thumbnail is empty, and if there is no thumbnail, display a default image.
So you use get_the_post_thumbnail_url() and check if it is empty.
if ( empty(get_the_post_thumbnail_url( $featured_post->ID)) ):
echo 'https://your-default-image_url.jpg';
else:
echo get_the_post_thumbnail_url( $featured_post->ID, 'thumbnail' );
endif;
If you like it a bit more readable, your code can look like:
<ul>
<?php foreach( $featured_posts as $featured_post ):?>
<?php $featured_image = get_the_post_thumbnail_url($featured_post->ID, 'thumbnail') ?: 'https://your-default-image_url.jpg'; ?>
<div class="movies-series-director">
<a class="movies-series-director-thumbnails" href="<?php echo get_page_link($featured_post->ID);?>"> <img src="<?php echo $featured_image;?>"></a>
<div class="movies-series-director-title">
<h4> <?php echo $featured_post->post_title;?> </h4>
<b>Director</b>
</div>
</div>
<?php endforeach; ?>
</ul>
Here is your working code:
<?php
$featured_posts = get_field('director');
if( $featured_posts ): ?>
<ul>
<?php foreach( $featured_posts as $featured_post ):?>
<div class="movies-series-director">
<a class="movies-series-director-thumbnails" href="<?php echo get_page_link($featured_post->ID);?>"> <img src="<?php echo get_the_post_thumbnail_url($featured_post->ID, 'thumbnail');?>"></a>
<div class="movies-series-director-title">
<h4> <?php echo $featured_post->post_title;?> </h4>
<b>Director</b>
</div>
</div>
<?php endforeach; ?>
</ul>
<?php else: ?>
.... here your code for "else"
<?php endif; ?>

How to get custom post type data filter by custom taxonomy

Struggle to get all the records mapped by custom taxonomies.
I have registered a custom post type i.e. job_post and custom taxonomy i.e. countries. I wanted to show all job posts (having job_title, job_location, and permalink to specific job post) which are filtered by Countries (i.e. India & USA). I had Mapped almost 10 job posts under the India category and 18 job posts under the USA category.
I have displayed the records through toggle tabs (i.e. India and USA). I can fetch only one record by each category through the below code:
<section class="container container_filter">
<div class="filters filter-button-group">
<ul class="nav nav-tabs">
<?php
$terms= get_terms('countries');
foreach($terms as $cat_term)
{ ?>
<li><a data-toggle="tab" href="#<?php echo $cat_term->slug;?>"><?php echo $cat_term->name; ?></a></li>
<?php } ?>
</ul>
<div class="tab-content">
<?php
global $post;
$args= array('post_type'=> 'job_post', 'post_per_page' => -1);
$the_query = new WP_Query($args);
if($the_query->have_posts()):
while ($the_query->have_posts()) : $the_query->the_post();?>
<?php
$termsArray= get_the_terms(get_the_ID(), 'countries');
$term_id=$termsArray->id;
foreach ($termsArray as $term){
$termsSlug = $term->slug;
}
?>
<div id="<?php echo $termsSlug;?>" class="tab-pane fade">
<div class='col-md-6'>
<a class='job-card readmoreCustom' href='<?php the_permalink($term_id); ?>'>
<div class='content'>
<h3 class='title'><?php echo get_the_title($term_id) ?></h3>
<p class='job_location'><?php the_field('job_location'); ?></p>
</div>
<span class='more'>KNOW MORE<span class="readIcon"> > </span></span>
</a>
</div>
</div>
<?php
endwhile;
wp_reset_query();
?>
<?php else: ?>
<?php _e('Sorry, no jobs matches your criteria'); ?>
<?php endif; ?>
</div>
</div>
</section>
How can I fetch all the records from both categories under specific tabs? Help is appreciated.
<section class="container container_filter">
<div class="filters filter-button-group">
<ul class="nav nav-tabs">
<?php
$terms= get_terms('countries');
foreach($terms as $cat_term)
{ ?>
<li><a data-toggle="tab" href="#<?php echo $cat_term->slug;?>"><?php echo $cat_term->name; ?></a></li>
<?php } ?>
</ul>
<div class="tab-content">
<?php
global $post;
$args= array('post_type'=> 'job_post', 'post_per_page' => -1);
$the_query = new WP_Query($args);
if($the_query->have_posts()):
while ($the_query->have_posts()) : $the_query->the_post();?>
<?php
$termsArray= get_the_terms(get_the_ID(), 'countries');
$term_id=$termsArray[0]->term_id;
foreach ($termsArray as $term){
$termsSlug = $term->slug;
}
?>
<div id="<?php echo $termsSlug;?>" class="tab-pane fade">
<div class='col-md-6'>
<a class='job-card readmoreCustom' href='<?php the_permalink(); ?>'>
<div class='content'>
<h3 class='title'><?php echo get_the_title(); ?></h3>
<p class='job_location'><?php the_field('job_location'); ?></p>
</div>
<span class='more'>KNOW MORE<span class="readIcon"> > </span></span>
</a>
</div>
</div>
<?php
endwhile;
wp_reset_query();
?>
<?php else: ?>
<?php _e('Sorry, no jobs matches your criteria'); ?>
<?php endif; ?>
</div>
</div>
</section>
The below loop is fine if the post is in only 1 country but if it's in multiple counties the loop should be closed after div
foreach ($termsArray as $term){
$termsSlug = $term->slug;
}

Changing styles in Zend Framework 2 pagination

I am trying to replace the default style in Zend Framework 2's pagination to use Twitter Boostrap's pagination style. I am having trouble though with changing the style, as some of the elements are off and I don't know why. Here is my code:
<nav>
<ul class="pagination">
<?php if ($this->pageCount): ?>
<!-- Previous page link -->
<?php if (isset($this->previous)): ?>
<li class="previous"><a href="<?php echo $this->url($this->route, array('page' => $this->previous)); ?>">
<span aria-hidden="true">«</span></a></li>
<?php else: ?>
<li class="previous disabled">«</span>
<?php endif; ?>
<!-- Numbered page links -->
<?php foreach ($this->pagesInRange as $page): ?>
<?php if ($page != $this->current): ?>
<li class="active"><a href="<?php echo $this->url($this->route, array('page' => $page)); ?>">
<?php echo $page; ?>
</a></li>
<?php else: ?>
<?php echo $page; ?>
<?php endif; ?>
<?php endforeach; ?>
<!-- Next page link -->
<?php if (isset($this->next)): ?>
<li class="next"><a href="<?php echo $this->url($this->route, array('page' => $this->next)); ?>">
<span aria-hidden="true">»</span></a></li>
<?php else: ?>
<li class="next disabled">»</li
<?php endif; ?>
<?php endif; ?>
</ul>
</nav>
If it helps, here is a screenshot of what I am trying to say.
As you can see, the elements are off. Any help would be appreciated.
Thanks!
nevermind fixed it, was not using the right attributes.

Wordpress: No search results message

I've tried to separate search results by categories in 2 tabs. Everything works fine except showing the message "No results". This message is shown only when in both categories are nothing found. But when one tab has results and another hasn't - nothing is shown.
I'm looking for way to show "No results" for every tab. I mean, if nothing is found in cat 1 and some results found in cat 2 -> Show "No results" in Tab 1 and show results in Tab 2.
Any suggestions?
Code here:
<div id="tab-content1" class="tab-content">
<ul class="posts--group v-category-games">
<?php
global $post;
rewind_posts();
$query = new WP_Query(array(
'posts_per_page' => -1,
'cat' => 3,
's' => get_search_query(),
));
if (have_posts()) :
while ($query->have_posts()) : $query->the_post();
?>
<?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
<li>
<div class="post-item v-category-games v-with-image">
<div class="post-item--text">
<a class="post-item--text--name" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<span class="post-item--text--tagline">
<span><?php the_excerpt(); ?> </span>
<span> </span>
</span>
</div>
<div class="post-item--thumbnail">
<div class="post-thumbnail">
<div class="backgroundImage_1hK9M post-thumbnail--image" style="background-image: url('<?php echo $url; ?>');"></div>
<span></span>
<span></span>
</div>
</div>
</div>
</li>
<?php
endwhile;
?>
<?php
else :
echo "<div class='art_descr'><h2>No results in this category!</h2></div></center>";
endif;
wp_reset_postdata();
?>
</ul>
</div> <!-- #tab-content1 -->
<div id="tab-content2" class="tab-content">
<ul class="posts--group v-category-games">
<?php
global $post;
rewind_posts();
$query = new WP_Query(array(
'posts_per_page' => -1,
'cat' => 4,
's' => get_search_query(),
));
if (have_posts()) :
while ($query->have_posts()) : $query->the_post();
?>
<?php $url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) ); ?>
<li>
<div class="post-item v-category-games v-with-image">
<div class="post-item--circle">
<?php the_field('digest_number'); ?>
</div>
<div class="post-item--text no-margin">
<a class="post-item--text--name" href="<?php the_permalink(); ?>"><?php the_title(); ?></a>
<span class="post-item--text--tagline">
<span><p><?php the_field('short_description'); ?></p> </span>
<span> </span>
</span>
</div>
</div>
</li>
<?php
endwhile;
?>
<?php
else :
echo "<div class='art_descr'><h2>No results in this category!</h2></div></center>";
endif;
wp_reset_postdata();
?>
</ul>
</div> <!-- #tab-content2 -->
</div>
You can use your if (have_posts()) : on each loop to determine if to display or not...
if (have_posts()) :
//while loop
else:
echo '<h1>no posts found</h1>';
endif;

WordPress query posts into two Divs

I want to display my wordpress posts in a category in two divs. So for example:
<ul id="left">
<li class="post">POST 1</li>
<li class="post">POST 3</li>
<li class="post">POST 5</li>
<li class="post">POST 7</li>
</ul>
<ul id="right">
<li class="post">POST 2</li>
<li class="post">POST 4</li>
<li class="post">POST 6</li>
<li class="post">POST 8</li>
</ul>
So want I need to do is tell the query_posts to somehow start spitting out the first 4 posts oddly and then evenly for each div. I don't want to have two seperate WP_Queries as this is a category.php file and needs to have the default loop. Not quite sure how to do this.
Any help much appreciated.
I have not test this before, this is not the best way but a solution
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<?php
$count++;
if( $count % 2 ) {
$left_array[] = array( 'content' => get_the_content('more...') );
}
else {
$right_array[] = array( 'content' => get_the_content('more...') );
}
?>
<?php endwhile; ?>
<ul id="left">
<?php
foreach( $left_array as $post ) {
echo '<li class="post">'.$post['content'].'</li>';
}
?>
</ul>
<ul id="right">
<?php
foreach( $right_array as $post ) {
echo '<li class="post">'.$post['content'].'</li>';
}
?>
</ul>
<?php else : ?>
<?php endif; ?>
or the same idea, but another way:
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<ul id="left">
<?php
$count++;
if( $count % 2 ) {
}
else {
?>
<li class="post"><?php the_content('more...'); ?></li>
<?php
}
?>
</ul>
<ul id="right">
<?php
$count++;
if( $count % 2 ) {
?>
<li class="post"><?php the_content('more...'); ?></li>
<?php
}
?>
</ul>
<?php endwhile; ?>
<?php else : ?>
<?php endif; ?>
How about preconstructing the two lists: (I can't recall the WP query syntax, so it's pseudo-PHP:)
<?php
$list1 = array();
$list2 = array();
$i=0;
foreach($query_results as $res) {
if(($i++)&1) $list2[] = $res;
else $list1[] = $res;
}
?>
Now list1 contains the first, third, ... item and list2 contains the second, fourth, ...
You can then print them in the two divs as you wish.
(On a tangent: Does PHP have any succinct way to do what the above code does? Python has the stepped slicing syntax...)
If your goal is to have a two-column list of posts, it would be much easier to just output the posts in one list, and then use CSS to give the visual appearance of two columns using float, for instance:
width: 50%;
float: left;

Resources