I have this code and all the vars pull in but the latest news is not showing up. any ideas?
<div class="content">
<?php get_sidebar('field'); ?>
<?php
global $current_user;
get_currentuserinfo();
$user_info = get_userdata($current_user->ID);
if ( have_posts() && $user_info->user_level != 0) : while ( have_posts() ) : the_post(); ?>
<?php // get custom fields
$wt_email = get_post_meta($post->ID, 'wt_email', true);
$wt_feed = get_post_meta($post->ID, 'wt_website', true);
$wt_facebook = get_post_meta($post->ID, 'wt_facebook', true);
$wt_twitter = get_post_meta($post->ID, 'wt_twitter', true);
$wt_linkedin = get_post_meta($post->ID, 'wt_linkedin', true);
?>
<div class="entry">
<h1><?php the_title(); ?></h1>
<div class="body">
<?php the_content(); ?>
</div>
<div class="share">
<div class="links">
<h3>Links</h3>
<ul>
<?php if($wt_twitter) { ?><li>Twitter</li><?php } ?>
<?php if($wt_facebook) { ?><li>Facebook</li><?php } ?>
<?php if($wt_email) { ?><li>Email</li><?php } ?>
<?php if($wt_linkedin) { ?><li>Website</li><?php } ?>
</ul>
</div>
<?php endwhile; // End the loop. Whew. ?>
<div class="news">
<h3>Latest News</h3>
<ul>
<?php
// The Query
$loop = new WP_Query( array(
'category_name' => $wt_feed,
'order' => 'ASC',
'posts_per_page'=> 5
) );
// The Loop
if( $loop->have_posts() ) : while ( $loop->have_posts() ) : $loop->the_post();
echo '<li><a href="' . the_permalink() . '">';
the_title();
echo '</a></li>';
endwhile;
endif;
// Reset Query
wp_reset_query();
?>
</ul>
<?php
$args=array(
'category_name' => $wt_feed,
'type' => 'post'
);
$categories=get_categories($args);
if($wt_feed) { ?>Subscribe<?php } ?>
</div>
</div>
</div>
<?php else : ?>
<div class="entry">
<h1>Listing Private</h1>
<div class="body">
<p>You need to have a Member account view the details of this list. Request an account membership.</p>
</div>
</div>
<?php endif; ?>
<div class="clearfix"></div>
</div>
Whilst not an exact answer, have you tried adding:
error_reporting(E_ALL);
ini_set('display_errors', '1');
At the top of the page, to display any errors that might be occurring?
Related
I have a set_gallery function and I pass the set_args array to her. The set_args array always changes. I'm looking for a solution for deleting posts posted and so that the loop outputs posts with new parameters. How can this be realized? Thanks...
function set_gallery($set_args = '') { ?>
<?php if ($set_args == '') {
$args = array (
'post_type' => 'gallerys',
'posts_per_page' => '-1'
);
} else {
$args = $set_args;
} ?>
<?php $gallerys_posts = new WP_Query($args);
wp_reset_query();
if( $gallerys_posts->have_posts() ) :
while ( $gallerys_posts->have_posts() ) :
$gallerys_posts->the_post(); ?>
<div class="col-lg-4 col-md-4 col-sm-6 col-xs-12 shuffle-item filtered">
<div class="portfolio-item">
<a href="<?php echo get_permalink(get_the_id());?>">
<?php if ( get_the_post_thumbnail(get_the_id()) ) { ?>
<?php echo get_the_post_thumbnail( get_the_id(), array(620, 423 )); ?>
<?php } ?>
<div class="portfolio-overlay">
<div class="caption">
<?php the_title(); ?>
<span>
<?php echo get_the_content(); ?>
</span>
</div>
</div>
</a>
</div>
</div>
<?php endwhile; endif; wp_reset_query();?>
<?php }
I want to display a simple front page with 2 categories,
But when I enter 2 same code, the result is empty,
But one code, the result appears
I look like:
Title: chicken category
Content
Title: cow category
Content
I tried with a simple php code:
<h2 class="home1">10 Best Chicken</h2>
<div class="1"><?php query_posts('cat=9' . '&showposts=3'.'&paged='.$paged); ?></div>
<h2 class="home1">10 Best Cow</h2>
<div class="1"><?php query_posts('cat=10' . '&showposts=3'.'&paged='.$paged); ?></div>
How the best solution?
Don't use query_posts , use WP_Query instead
<?php get_header(); ?>
<?php if((is_home())&& ($paged < 1)) { ?>
<?php get_template_part( 'home-featured' ); ?>
<?php } ?>
<div class="wisata-konten">
<div class="container">
<div class="row">
<div class="col-md-12">
<?php if((is_home())&& ($paged > 1)) { ?>
<h1><?php bloginfo('name'); ?> - <?php if ( get_query_var('paged') ) { echo 'Halaman '. get_query_var('paged'); } ?></h1>
<?php } ?>
<div class="row"><div class="boxer2">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="col-md-4"><?php get_template_part( 'thumb' ); ?></div>
<?php endwhile; ?></div></div>
<?php fastestwp_pagenavi(); ?>
<?php else : ?>
<h2>Not Found</h2>Sorry, but you are looking for something that isn't here.
<?php endif; ?>
<h2 class="home1">Lombok Open Trip</h2>
<?php $args = array( 'cat' => 9 , 'posts_per_page' => 3 , 'paged' => $paged );
$the_query = new WP_Query( $args );
// The Loop
if ( $the_query->have_posts() ) {
echo '<ul>';
while ( $the_query->have_posts() ) {
$the_query->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
/* Restore original Post Data */
wp_reset_postdata();
} else {
// no posts found
}
?><h2 class="home1">Lombok Promo</h2><?php
$args2 = array( 'cat' => 10 , 'posts_per_page' => 3 , 'paged' => $paged );
$the_query2 = new WP_Query( $args2 );
// The Loop
if ( $the_query2->have_posts() ) {
echo '<ul>';
while ( $the_query2->have_posts() ) {
$the_query2->the_post();
echo '<li>' . get_the_title() . '</li>';
}
echo '</ul>';
/* Restore original Post Data */
wp_reset_postdata();
} else {
// no posts found
} ?>
<div class="wisata-testimoni">
<div class="container">
<div class="row">
<div class="col-md-12">
<div id="testimoni" class="carousel slide">
<div class="carousel-inner">
<?php fastestwp_comments(); ?>
</div>
</div>
<div class="tombol"><a class= "medium beli blue pull-right" href="<?php echo home_url() ; ?>/testimoni" >Lihat Semua Testimoni <span class="glyphicon glyphicon-thumbs-up"></span></a></div>
</div>
</div>
</div>
</div>
I want to create blog page with recent posts and pagination. Code below shows recent posts but pagination doesn't want to work.
<?php get_header(); ?>
<div class="container clearfix">
<div id="content" class="clearfix">
<?php
$postslist = get_posts('numberposts=-1&posts_per_page=5&order=DESC&orderby=date');
foreach ($postslist as $post) :
setup_postdata($post);
?>
<div class="entry">
<div class="recent-post-thumbnail">
<?php echo the_post_thumbnail($recent->ID, 'thumbnail'); ?>
</div>
<h3><?php the_title(); ?></h3>
<?php the_excerpt(); ?>
<h4>More ></h4>
</div>
<?php endforeach; ?>
</div> <!-- end content -->
<div class="kreska-pion"></div>
<div class="sidebar">
<?php get_sidebar(); ?>
</div>
</div>
<?php get_footer(); ?>
numberposts=6 replace this with post_per_page and let me know if It worked .
<?php
$postlist = get_posts( 'numberposts=-1&posts_per_page=5' );
$posts = array();
foreach ( $postlist as $post ) {
$posts[] += $post->ID;
}
$current = array_search( get_the_ID(), $posts );
$prevID = $posts[$current-1];
$nextID = $posts[$current+1];
?>
<?php
foreach ( $posts as $post ) : setup_postdata( $post ); ?>
<li>
<?php the_title(); ?>
</li>
<?php endforeach;
wp_reset_postdata();?>
<div class="navigation">
<?php if ( !empty( $prevID ) ): ?>
<div class="alignleft">
<a href="<?php echo get_permalink( $prevID ); ?>"
title="<?php echo get_the_title( $prevID ); ?>">Previous</a>
</div>
<?php endif;
if ( !empty( $nextID ) ): ?>
<div class="alignright">
<a href="<?php echo get_permalink( $nextID ); ?>"
title="<?php echo get_the_title( $nextID ); ?>">Next</a>
</div>
<?php endif; ?>
</div><!-- .navigation -->
I tried
<?php get_header(); ?>
<div class="container clearfix">
<div id="content" class="clearfix">
<?php
$args = array( 'post_per_page' = -1 );
$query= new WP_Query( $args );
var_dump( $query );
// The 2nd Loop
while ( $query->have_posts() ) {
$query->the_post();
echo '<li>' . get_the_title( $query->post->ID ) . '</li>';
}
// Restore original Post Data
wp_reset_postdata();
?>
<div class="vertical"></div>
<div class="sidebar">
<?php get_sidebar(); ?>
</div>
</div>
<?php wp_pagenavi(); ?>
<?php get_footer(); ?>
But it shows a blank page.
EDIT:
Here's what I did:
<?php get_header(); ?>
<div class="container clearfix">
<div id="content" class="clearfix">
<?php
$args = array( 'post_per_page' = -1 );
$query= new WP_Query( $args );
var_dump( $query );
wp_reset_postdata();
?>
<div class="vertical"></div>
<div class="sidebar">
<?php get_sidebar(); ?></div>
</div>
<?php wp_pagenavi(); ?>
<?php get_footer(); ?>
And it shows a blank page.
after adding the function of pagination to Functions.php and recall it in template-product-listing.php
there is nothing shown in result.
I have a big problom with this...
could you find and resolve the problem?
thnx
<article class="row">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div id="single-head" class="sixteen columns">
<h1><?php the_title(); ?></h1>
<?php if (has_excerpt()) { the_excerpt(); } ?>
</div>
<div class="row">
<nav id="portfolio-filters" class="sixteen columns">
<?php _e('Show All', 'ci_theme'); ?>
<?php
$args = array(
'hide_empty' => 0
);
$skills = get_terms('product-category', $args);
?>
<?php foreach ( $skills as $skill ) : ?>
<?php echo $skill->name; ?>
<?php endforeach; ?>
</nav><!-- /portfolio-filters -->
</div>
<div id="portfolio-items" class="row">
<?php $ci_product_query = new WP_Query('post_type=product&posts_per_page=4'); ?>
<?php if ( $ci_product_query-> have_posts() ) : while ( $ci_product_query->have_posts() ) : $ci_product_query->the_post(); ?>
<?php $item_skills = wp_get_object_terms($post->ID, 'product-category'); ?>
<article class="<?php ci_e_setting('product_columns'); ?> columns <?php foreach ( $item_skills as $item_skill ) : echo $item_skill->slug.' '; endforeach; ?> columns portfolio-item">
<a href="<?php echo get_permalink(); ?>" title="<?php echo esc_attr(get_the_title()); ?>" class="fb">
<?php the_post_thumbnail('ci_portfolio_slider', array('class'=>'scale-with-grid')); ?>
</a>
<div class="portfolio-desc">
<h3><?php the_title(); ?></h3>
<p class="desc"><?php echo mb_substr(get_the_excerpt(), 0, 70); ?>...</p>
</div>
</article><!-- /portfolio-item -->
<?php endwhile; endif; ?>
<?php wp_reset_postdata(); ?>
</div><!-- /portfolio-items -->
<?php get_template_part('part', 'call_to_action'); ?>
<?php endwhile; endif; ?>
<div class="pagination">
<?php wp_pagination(); ?>
</div>
</article>
if your sure there is a post_type called products and there is posts in it...
try:
<div id="portfolio-items" class="row">
<?php $ci_product_query = new WP_Query(array('post_type'=>'product', 'posts_per_page'=> 4); ?>
<?php if ( $ci_product_query-> have_posts() ) : while ( $ci_product_query->have_posts() ) : $ci_product_query->the_post(); ?>
You know you are starting a new wp_query for every post in have_posts() ? you might want to rethink what you are trying to achieve!
I'm still pretty new to PHP, and I'm having trouble getting this to work. What I want to do, is make the slide linked (if link is available). Otherwise, print the post thumbnail without the
Here's my code so far:
<?php // START SLIDER ?>
<div class="slider">
<ul class="rslides">
<?php $args = array( 'posts_per_page' => 0, 'post_type' => 'slide'); $alert = new WP_Query( $args ); ?>
<?php if( $alert->have_posts() ) { while( $alert->have_posts() ) { $alert->the_post(); ?>
<li><?php the_post_thumbnail('full'); ?><div class="caption"><p class="captiontitle"><?php the_title(); ?></p><p class="caption"><?php the_content(); ?></p></div></li>
<?php } } ?>
</ul>
</div>
<?php wp_reset_query(); ?>
<?php // END SLIDER ?>
I've done this before using the WP Custom fields, but I'm not sure how to apply it to my custom post type (called slider). Here's what I did for my Custom Field script:
<?php $slider_url = get_post_meta($post->ID, 'Slider_URL', true);
if ($slider_url) { ?>
LINKED SLIDE HERE
<?php } else { ?>
UNLINKED SLIDE HERE
<?php } ?>
<?php endwhile; ?>
<?php endif; // have_posts() ?>
Here's what I tried (when combining the two), but there's an error somewhere:
<?php // START SLIDER ?>
<div class="slider">
<ul class="rslides">
<?php $args = array( 'posts_per_page' => 0, 'post_type' => 'slide'); $alert = new WP_Query( $args ); ?>
<?php if( $alert->have_posts() ) { while( $alert->have_posts() ) { $alert->the_post(); ?>
<?php $slide_url = get_post_meta($post->ID, 'Slide_URL', true);
if ($slide_url) { ?>
<li><?php the_post_thumbnail('full'); ?><div class="caption"><p class="captiontitle"><?php the_title(); ?></p><p class="caption"><?php the_content(); ?></p></div></li>
<?php } else { ?>
<li><?php the_post_thumbnail('full'); ?><div class="caption"><p class="captiontitle"><?php the_title(); ?></p><p class="caption"><?php the_content(); ?></p></div></li>
<?php } } ?>
<?php endwhile; ?>
<?php endif; // have_posts() ?>
</ul>
</div>
<?php wp_reset_query(); ?>
<?php // END SLIDER ?>
If I'm correct in thinking, you just want to check if the link is there, before outputting, otherwise, just show the image. Try the following:
<?php // START SLIDER ?>
<div class="slider">
<ul class="rslides">
<?php $args = array( 'posts_per_page' => 0, 'post_type' => 'slide'); $alert = new WP_Query( $args ); ?>
<?php if( $alert->have_posts() ) { while( $alert->have_posts() ) { $alert->the_post(); ?>
<!-- Get a link -->
<?php $theLink = get_post_meta($post->ID, "_location", true); ?>
<li>
<!-- Check for a link -->
<?php if($theLink != ''): ?>
<a href="<?php echo $theLink; ?>" title="More Info">
<?php endif; ?>
<?php the_post_thumbnail('full'); ?>
<div class="caption">
<p class="captiontitle">
<?php the_title(); ?>
</p>
<p class="caption">
<?php the_content(); ?>
</p>
</div>
<!-- Close the link -->
<?php if($theLink != ''): ?>
</a>
<?php endif; ?>
</li>
<?php } } ?>
</ul>
</div>
<?php wp_reset_query(); ?>
<?php // END SLIDER ?>