I would like to have two different search results depending on the page, that the user is on.
I have duplicated how the previous search contents would display, added the extra code that I want the staff search to show, and then put an if statement around it.
If user is on page 'staff' -
then show this
Else
show this.
I cant seem to get the if-statement to work, any help would be appreciated.
EDIT
This is the original working code, before i put the IF statement in, to try and create another set of results for staff searching from a specific page.
<?php
if ( is_home() ) {
$paged = get_query_var( 'page' ) ? get_query_var( 'page' ) : get_query_var( 'paged' );
$args = array(
'showposts' => (int) get_option('trim_homepage_posts'),
'paged' => $paged,
'category__not_in' => (array) get_option('trim_exlcats_recent'),
);
query_posts( apply_filters( 'et_home_args', $args ) );
}
?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article class="entry post clearfix preownedSearch">
<h2 class="et_pt_portfolio_title"><?php the_title(); ?></h2>
<?php
$index_postinfo = get_option('trim_postinfo1');
if ( $index_postinfo ){
echo '<p class="meta">';
et_postinfo_meta( $index_postinfo, get_option('trim_date_format'), esc_html__('0 comments','Trim'), esc_html__('1 comment','Trim'), '% ' . esc_html__('comments','Trim') );
echo '</p>';
}
?>
<div class="post-content clearfix">
<?php
$thumb = '';
$width = apply_filters('et_image_width',260);
$height = apply_filters('et_image_height',170);
$classtext = '';
$titletext = get_the_title();
$thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext,false,'Entry');
$thumb = $thumbnail["thumb"];
?>
<?php if ( '' != $thumb && 'on' == get_option('trim_thumbnails_index') ) { ?>
<div class="featured_box filter">
<a href="<?php the_permalink(); ?>">
<?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?>
</a>
</div> <!-- end .featured_box -->
<?php } ?>
</div>
</article> <!-- end .post-->
<?php
endwhile;
if (function_exists('wp_pagenavi')) { wp_pagenavi(); }
else { get_template_part('includes/navigation','entry'); }
else:
get_template_part('includes/no-results','entry');
endif;
if ( is_home() ) wp_reset_query(); ?>
This is the coding after i've put the if-statement in -
<?php
if ( is_home() ) {
$paged = get_query_var( 'page' ) ? get_query_var( 'page' ) : get_query_var( 'paged' );
$args = array(
'showposts' => (int) get_option('trim_homepage_posts'),
'paged' => $paged,
'category__not_in' => (array) get_option('trim_exlcats_recent'),
);
query_posts( apply_filters( 'et_home_args', $args ) );
}
?>
<?php if (is_page('stock-managers')) { ?>
<article class="entry post clearfix preownedSearch">
<h2 class="et_pt_portfolio_title"><?php the_title(); ?><?php the_meta(); ?></h2>
<?php
$index_postinfo = get_option('trim_postinfo1');
if ( $index_postinfo ){
echo '<p class="meta">';
et_postinfo_meta( $index_postinfo, get_option('trim_date_format'), esc_html__('0 comments','Trim'), esc_html__('1 comment','Trim'), '% ' . esc_html__('comments','Trim') );
echo '</p>';
}
?>
<div class="post-content clearfix">
<?php
$thumb = '';
$width = apply_filters('et_image_width',260);
$height = apply_filters('et_image_height',170);
$classtext = '';
$titletext = get_the_title();
$thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext,false,'Entry');
$thumb = $thumbnail["thumb"];
?>
<?php if ( '' != $thumb && 'on' == get_option('trim_thumbnails_index') ) { ?>
<div class="featured_box filter">
<a href="<?php the_permalink(); ?>">
<?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?>
</a>
</div> <!-- end .featured_box -->
<?php } ?>
</div>
</article> <!-- end .post-->
<?php } else { ?>
<article class="entry post clearfix preownedSearch">
<h2 class="et_pt_portfolio_title"><?php the_title(); ?></h2>
<?php
$index_postinfo = get_option('trim_postinfo1');
if ( $index_postinfo ){
echo '<p class="meta">';
et_postinfo_meta( $index_postinfo, get_option('trim_date_format'), esc_html__('0 comments','Trim'), esc_html__('1 comment','Trim'), '% ' . esc_html__('comments','Trim') );
echo '</p>';
}
?>
<div class="post-content clearfix">
<?php
$thumb = '';
$width = apply_filters('et_image_width',260);
$height = apply_filters('et_image_height',170);
$classtext = '';
$titletext = get_the_title();
$thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext,false,'Entry');
$thumb = $thumbnail["thumb"];
?>
<?php if ( '' != $thumb && 'on' == get_option('trim_thumbnails_index') ) { ?>
<div class="featured_box filter">
<a href="<?php the_permalink(); ?>">
<?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?>
</a>
</div> <!-- end .featured_box -->
<?php } ?>
</div>
</article> <!-- end .post-->
<?php } endif; ?>
<?php
endwhile;
if (function_exists('wp_pagenavi')) { wp_pagenavi(); }
else { get_template_part('includes/navigation','entry'); }
else:
get_template_part('includes/no-results','entry');
endif;
if ( is_home() ) wp_reset_query(); ?>
Edit 2 Match
<?php
if ( is_home() ) {
$paged = get_query_var( 'page' ) ? get_query_var( 'page' ) : get_query_var( 'paged' );
$args = array(
'showposts' => (int) get_option('trim_homepage_posts'),
'paged' => $paged,
'category__not_in' => (array) get_option('trim_exlcats_recent'),
);
query_posts( apply_filters( 'et_home_args', $args ) );
}
?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php if ($post->post_name('stock-managers')) { ?>
<article class="entry post clearfix preownedSearch">
<h2 class="et_pt_portfolio_title"><?php the_title(); ?><?php the_meta(); ?></h2>
<?php
$index_postinfo = get_option('trim_postinfo1');
if ( $index_postinfo ){
echo '<p class="meta">';
et_postinfo_meta( $index_postinfo, get_option('trim_date_format'), esc_html__('0 comments','Trim'), esc_html__('1 comment','Trim'), '% ' . esc_html__('comments','Trim') );
echo '</p>';
}
?>
<div class="post-content clearfix">
<?php
$thumb = '';
$width = apply_filters('et_image_width',260);
$height = apply_filters('et_image_height',170);
$classtext = '';
$titletext = get_the_title();
$thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext,false,'Entry');
$thumb = $thumbnail["thumb"];
?>
<?php if ( '' != $thumb && 'on' == get_option('trim_thumbnails_index') ) { ?>
<div class="featured_box filter">
<a href="<?php the_permalink(); ?>">
<?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?>
</a>
</div> <!-- end .featured_box -->
<?php } ?>
</div>
</article> <!-- end .post-->
<?php else : ?>
<article class="entry post clearfix preownedSearch">
<h2 class="et_pt_portfolio_title"><?php the_title(); ?></h2>
<?php
$index_postinfo = get_option('trim_postinfo1');
if ( $index_postinfo ){
echo '<p class="meta">';
et_postinfo_meta( $index_postinfo, get_option('trim_date_format'), esc_html__('0 comments','Trim'), esc_html__('1 comment','Trim'), '% ' . esc_html__('comments','Trim') );
echo '</p>';
}
?>
<div class="post-content clearfix">
<?php
$thumb = '';
$width = apply_filters('et_image_width',260);
$height = apply_filters('et_image_height',170);
$classtext = '';
$titletext = get_the_title();
$thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext,false,'Entry');
$thumb = $thumbnail["thumb"];
?>
<?php if ( '' != $thumb && 'on' == get_option('trim_thumbnails_index') ) { ?>
<div class="featured_box filter">
<a href="<?php the_permalink(); ?>">
<?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?>
</a>
</div> <!-- end .featured_box -->
<?php } ?>
</div>
</article> <!-- end .post-->
<?php endif; ?>
<?php
endwhile;
if (function_exists('wp_pagenavi')) { wp_pagenavi(); }
else { get_template_part('includes/navigation','entry'); }
else:
get_template_part('includes/no-results','entry');
endif;
if ( is_home() ) wp_reset_query(); ?>
Your php Syntax is wrong.
PHP Syntax Check: Parse error: syntax error, unexpected 'endif' (T_ENDIF) in your code on line 7 <?php } endif;?> PHP Syntax Check: Errors parsing your code
With removing endif;you're good to go
<?php if (is_page('staff')) { ?>
<article class="entry post clearfix">
<-- Title / Thumbnail / Price / Description coding -->
</article>
<?php } else { ?>
<article class="entry post clearfix">
<-- Title / Thumbnail / Description coding -->
</article>
<?php } ?>
Learn more about PHP's Alternativ syntax
See explanation of using if(condition){}and if(condition):endif; at this answer
Edit:
If you're using is_page within the Loop, it'll be allways false /see Source.
Instead you could compare a chosen value (here it's staff) to any other field of your current post/page.
<?php if ( $post->post_name=='staff' ) { ?>
<article class="entry post clearfix">
<-- Title / Thumbnail / Price / Description coding -->
</article>
<?php } else { ?>
<article class="entry post clearfix">
<-- Title / Thumbnail / Description coding -->
</article>
<?php } ?>
Edit No.2:
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php if ($post->post_name('stock-managers')) { ?>
<article class="entry post clearfix preownedSearch">
</article> <!-- end .post-->
<?php else : ?>
<article class="entry post clearfix preownedSearch">
</article> <!-- end .post-->
<?php endif; ?>
<?php
endwhile;
?>
Related
The loop looks good and no errors but when i paginating the loop didn't works and not change the posts showed but the page/2 or page/3 is showed in the url and by these error in the loop the posts are showed 2 hours or more late.
Elsewhere my code is:
<div class="uk-grid contenido" id="contenido">
<div class="uk-width-1-6 uk-hidden-small uk-hidden-medium"></div>
<div class="uk-width-large-2-6 uk-width-small-1-1 uk-width-medium-1-2">
<button class="uk-button-primary" type="button">Al momento</button>
<hr class="uk-grid-divider">
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<article class="uk-article">
<h2 class="uk-article-title"><?php the_title(); ?></h2>
<p class="uk-article-Meta p4d"><?php the_time('l j'); ?> de <?php the_time('F'); ?> de <?php the_time('Y'); ?> - Hace <?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ); ?> | <?php $categories = get_the_category();
$separator = ','; $output = ''; if ( ! empty( $categories ) ) {foreach( $categories as $category ) {$output .= '' . esc_html( $category->name ) . '' . $separator; } echo trim( $output, $separator );} ?> | <?php if(function_exists('the_views')) { the_views(); } ?></p>
<p class="uk-article-lead"><?php echo substr(get_the_excerpt(), 0,130); ?>...<a class="more" href="<?php the_permalink(); ?>">(+)</a></p>
<div class="uk-thumbnail uk-thumbnail-large uk-overlay-hover uk-overlay-grayscale"><?php echo get_the_post_thumbnail($post->ID, 'articulo-normal-index'); ?></div>
<p class="uk-article-meta"><?php $categories = get_the_category();
$separator = ','; $output = ''; if ( ! empty( $categories ) ) {foreach( $categories as $category ) {$output .= '' . esc_html( $category->name ) . '' . $separator; } echo trim( $output, $separator );} ?> / <?php the_title(); ?></p>
<hr class="uk-article-divider">
</article>
<?php endwhile; ?>
<?php numeric_posts_nav(); ?>
<?php else : ?>
<p>Disculpa, no hay articulos</p>
<?php endif; ?>
</div>
<div class="separate uk-hidden-small uk-hidden-medium"></div>
<div class="uk-width-large-1-6 uk-hidden-small uk-width-medium-1-2 uk-block-muted min-padding">
<button class="uk-button-primary" type="button">Destacadas</button>
<hr class="uk-grid-divider">
<article class="uk-article uk-text-center">
<?php
global $post;
$args = array( 'numberposts' => 10, 'category_name' => 'destacada' );
$posts = get_posts( $args );
foreach( $posts as $post ): setup_postdata($post);
?>
<h2 class="uk-article-title-small uk-text-center"><?php the_title(); ?></h2>
<p class="uk-article-meta uk-text-center"><?php the_time('l j'); ?> de <?php the_time('F'); ?> de <?php the_time('Y'); ?> - Hace <?php echo human_time_diff( get_the_time('U'), current_time('timestamp') ); ?></p>
<div class="uk-thumbnail uk-thumbnail-medium uk-container-center"><?php echo get_the_post_thumbnail($post->ID, 'articulo-destacadas-sidebar'); ?></div>
<hr class="uk-article-divider">
</article>
<?php
endforeach;
?>
<div class="uk-text-center data-uk-lightbox"><?php dynamic_sidebar( 'anuncio-destacadas' ); ?></div>
</div>
<?php get_sidebar(); ?>
<div class="uk-width-1-6"></div>
</div>
this is my content.php I am trying to list 2 diffrent tag on my home page. 5 post from each tag. Example 5 tags from tag:Football down of it 5 tags from tag:Basketball and here is my content.php Thanks in advance.
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( has_post_thumbnail() ) : ?>
<div class="entry-thumb col-md-4 col-sm-4 col-xs-12">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" >
<?php the_post_thumbnail('home-thumb'); ?>
</a>
</div>
<?php $has_thumb = "col-md-8 col-sm-8 col-xs-12"; ?>
<?php else : ?>
<?php $has_thumb = ""; ?>
<?php endif; ?>
<div class="entry-summary <?php echo $has_thumb; ?>">
<header class="entry-header">
<?php the_title( sprintf( '<h1 class="entry-title">', esc_url( get_permalink() ) ), '</h1>' ); ?>
</header><!-- .entry-header -->
<div class="post-info">
<?php if ( 'post' == get_post_type() ) : ?>
<?php areview_posted_on(); ?>
<?php endif; ?>
<span class="cat-link">
<?php
$category = get_the_category();
if($category[0]){
echo '<i class="fa fa-folder"></i>' . esc_attr($category[0]->cat_name) . '';
}
?>
</span>
<?php if(function_exists('yasr_get_overall_rating') && function_exists('cfs') && ($cfs->get('show_stars') == 1)) {
echo do_shortcode('[yasr_overall_rating]');
} ?>
</div>
<?php the_excerpt(); ?>
</div><!-- .entry-content -->
<div class="buttons-area">
<?php if ( function_exists('cfs') && ($cfs->get('button_link') !='' ) && ($cfs->get('button_title') !='') && ($cfs->get('button_index') == 1) ) : ?>
<?php echo esc_html($cfs->get('button_title')); ?>
<?php endif; ?>
<?php echo __('Read more', 'areview'); ?>
</div>
You should loop the tags and do a query for each one, and for each post insert your existing HTML, like this:
<?php
$tags = array(
'Football',
'Basketball'
);
foreach ($tags as $tag) {
query_posts(array(
'post_type' => 'post'
'posts_per_page' => 5,
'tax_query' => array(
'taxonomy' => 'post_tag',
'field' => 'name',
'terms' => $tag
)
));
if (have_posts()) {
while(have_posts()) {
the_post();
?>
///.... insert your existing code here
<?php
}
}
wp_reset_query();
}
?>
Just don't forget to insert your existing html instead of the ///.... insert your existing code here block.
Try this
<div class="relatedposts">
<h3>Related posts</h3>
<?php
$args=array(
'post_status' => 'publish',
'tag' => 'football,basketball', //Tag slug
'posts_per_page'=>4, // Number of related posts to display.
);
$my_query = new wp_query( $args );
while( $my_query->have_posts() ) {
$my_query->the_post();
?>
<div class="relatedthumb">
<a rel="external" href="<? the_permalink()?>"><?php the_post_thumbnail(array(150,100)); ?><br />
<?php the_title(); ?>
</a>
</div>
<?php }
wp_reset_query();
?>
</div>
Thank you everyone!! Finally I got it using this code:
get_header(); ?>
<div id="primary" class="content-area">
<main id="main" class="site-main" role="main">
<?php if ( have_posts() ) : ?>
<?php /* Start the Loop */ ?>
<div class="relatedposts">
<h3 class="widget-title">Football</h3>
<div class="decoration-bar"></div><br>
<?php
$args=array(
'post_status' => 'publish',
'tag' => 'football', //Tag slug
'posts_per_page'=>5, // Number of related posts to display.
);
$my_query = new wp_query( $args );
while( $my_query->have_posts() ) {
$my_query->the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( has_post_thumbnail() ) : ?>
<div class="entry-thumb col-md-4 col-sm-4 col-xs-12">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" >
<?php the_post_thumbnail('home-thumb'); ?>
</a>
</div>
<?php $has_thumb = "col-md-8 col-sm-8 col-xs-12"; ?>
<?php else : ?>
<?php $has_thumb = ""; ?>
<?php endif; ?>
<div class="entry-summary <?php echo $has_thumb; ?>">
<header class="entry-header">
<?php the_title( sprintf( '<h1 class="entry-title">', esc_url( get_permalink() ) ), '</h1>' ); ?>
</header><!-- .entry-header -->
<div class="post-info">
<?php if ( 'post' == get_post_type() ) : ?>
<?php areview_posted_on(); ?>
<?php endif; ?>
<span class="cat-link">
<?php
$category = get_the_category();
if($category[0]){
echo '<i class="fa fa-folder"></i>' . esc_attr($category[0]->cat_name) . '';
}
?>
</span>
<?php if(function_exists('yasr_get_overall_rating') && function_exists('cfs') && ($cfs->get('show_stars') == 1)) {
echo do_shortcode('[yasr_overall_rating]');
} ?>
</div>
<?php the_excerpt(); ?>
</div><!-- .entry-content -->
<div class="buttons-area">
<?php if ( function_exists('cfs') && ($cfs->get('button_link') !='' ) && ($cfs->get('button_title') !='') && ($cfs->get('button_index') == 1) ) : ?>
<?php echo esc_html($cfs->get('button_title')); ?>
<?php endif; ?>
<?php echo __('Read more', 'areview'); ?>
</div>
</article>
<?php }
wp_reset_query();
?>
</div>
<center><h4 >---> More Posts <---</h4></center>
<div class="relatedposts">
<h3 class="widget-title">Basketball</h3>
<div class="decoration-bar"></div><br>
<?php
$args=array(
'post_status' => 'publish',
'tag' => 'basketball', //Tag slug
'posts_per_page'=>3, // Number of related posts to display.
);
$my_query = new wp_query( $args );
while( $my_query->have_posts() ) {
$my_query->the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( has_post_thumbnail() ) : ?>
<div class="entry-thumb col-md-4 col-sm-4 col-xs-12">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" >
<?php the_post_thumbnail('home-thumb'); ?>
</a>
</div>
<?php $has_thumb = "col-md-8 col-sm-8 col-xs-12"; ?>
<?php else : ?>
<?php $has_thumb = ""; ?>
<?php endif; ?>
<div class="entry-summary <?php echo $has_thumb; ?>">
<header class="entry-header">
<?php the_title( sprintf( '<h1 class="entry-title">', esc_url( get_permalink() ) ), '</h1>' ); ?>
</header><!-- .entry-header -->
<div class="post-info">
<?php if ( 'post' == get_post_type() ) : ?>
<?php areview_posted_on(); ?>
<?php endif; ?>
<span class="cat-link">
<?php
$category = get_the_category();
if($category[0]){
echo '<i class="fa fa-folder"></i>' . esc_attr($category[0]->cat_name) . '';
}
?>
</span>
<?php if(function_exists('yasr_get_overall_rating') && function_exists('cfs') && ($cfs->get('show_stars') == 1)) {
echo do_shortcode('[yasr_overall_rating]');
} ?>
</div>
<?php the_excerpt(); ?>
</div><!-- .entry-content -->
<div class="buttons-area">
<?php if ( function_exists('cfs') && ($cfs->get('button_link') !='' ) && ($cfs->get('button_title') !='') && ($cfs->get('button_index') == 1) ) : ?>
<?php echo esc_html($cfs->get('button_title')); ?>
<?php endif; ?>
<?php echo __('Read more', 'areview'); ?>
</div>
</article>
<?php }
wp_reset_query();
?>
</div>
<center><h4 >---> More Posts <---</h4></center>
<div class="relatedposts">
<h3 class="widget-title">Handball</h3>
<div class="decoration-bar"></div><br>
<?php
$args=array(
'post_status' => 'publish',
'tag' => 'handball', //Tag slug
'posts_per_page'=>2, // Number of related posts to display.
);
$my_query = new wp_query( $args );
while( $my_query->have_posts() ) {
$my_query->the_post();
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<?php if ( has_post_thumbnail() ) : ?>
<div class="entry-thumb col-md-4 col-sm-4 col-xs-12">
<a href="<?php the_permalink(); ?>" title="<?php the_title(); ?>" >
<?php the_post_thumbnail('home-thumb'); ?>
</a>
</div>
<?php $has_thumb = "col-md-8 col-sm-8 col-xs-12"; ?>
<?php else : ?>
<?php $has_thumb = ""; ?>
<?php endif; ?>
<div class="entry-summary <?php echo $has_thumb; ?>">
<header class="entry-header">
<?php the_title( sprintf( '<h1 class="entry-title">', esc_url( get_permalink() ) ), '</h1>' ); ?>
</header><!-- .entry-header -->
<div class="post-info">
<?php if ( 'post' == get_post_type() ) : ?>
<?php areview_posted_on(); ?>
<?php endif; ?>
<span class="cat-link">
<?php
$category = get_the_category();
if($category[0]){
echo '<i class="fa fa-folder"></i>' . esc_attr($category[0]->cat_name) . '';
}
?>
</span>
<?php if(function_exists('yasr_get_overall_rating') && function_exists('cfs') && ($cfs->get('show_stars') == 1)) {
echo do_shortcode('[yasr_overall_rating]');
} ?>
</div>
<?php the_excerpt(); ?>
</div><!-- .entry-content -->
<div class="buttons-area">
<?php if ( function_exists('cfs') && ($cfs->get('button_link') !='' ) && ($cfs->get('button_title') !='') && ($cfs->get('button_index') == 1) ) : ?>
<?php echo esc_html($cfs->get('button_title')); ?>
<?php endif; ?>
<?php echo __('Read more', 'areview'); ?>
</div>
</article>
<?php }
wp_reset_query();
?>
</div>
<center><h4 >---> More Posts <---</h4></center>
<?php else : ?>
<?php get_template_part( 'content', 'none' ); ?>
<?php endif; ?>
</main><!-- #main -->
</div><!-- #primary -->
<?php get_sidebar(); ?>
<?php get_footer(); ?>
I'm creating a custom theme, then a custom type, and when I try to put a (read more) link to the post, the anchor is not working. This is my code:
<main id="main" class="site-main" role="main">
<?php $temp_query = $wp_query;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args=array(
'caller_get_posts'=>1,
'post_type' => 'enfant',
'paged'=>$paged
);
$wp_query = new WP_Query($args);
?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post();
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID));
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="top-cont">
<h1 class="entry-title"><?php the_title(); ?></h1>
</header><!-- .entry-header -->
<div class="entry-content">
<!-- first one --> <img src="<?php echo $src[0];?>" />
<?php
$terms = get_the_terms($post->ID, 'maladies', '', ', ','');
if ( !empty( $terms ) ){
$numTerm = 0;
echo "<h3>Maladie : </h3>";
echo "<p>";
foreach( $terms as $term ) {
$numTerm++;
if ($numTerm == 1){
echo " ".$term->name;
}
else{
echo ", ".$term->name;
}
}
echo "</p><br/>";
}
?>
<!-- second one --> <a href="<?php the_permalink() ?>" >Lire plus ...</a>
<p><?php the_excerpt(); ?></p>
<?php
wp_link_pages( array(
'before' => '<div class="page-links">' . __( 'Pages:', 'adelia' ),
'after' => '</div>',
) );
?>
</div><!-- .entry-content -->
<div class="foot"></div>
<!--<?php edit_post_link( __( 'Edit', 'adelia' ), '<footer class="entry-meta"><span class="edit-link">', '</span></footer>' ); ?>-->
</article><!-- #post-## -->
<?php
// If comments are open or we have at least one comment, load up the comment template
/*if ( comments_open() || '0' != get_comments_number() )
comments_template();*/
?>
<?php endwhile; // end of the loop. ?>
both line commented are not working.
it is difficult to find out bug:
i have try something for you, hope it will works.
<main id="main" class="site-main" role="main">
<?php $temp_query = $wp_query;
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args=array(
'caller_get_posts'=>1,
'post_type' => 'enfant',
'paged'=>$paged
);
$wp_query = new WP_Query($args);
?>
<?php while ($wp_query->have_posts()) : $wp_query->the_post();
//$src = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID));
?>
<article id="post-<?php the_ID(); ?>" <?php post_class(); ?>>
<header class="top-cont">
<h1 class="entry-title"><?php the_title(); ?></h1>
</header><!-- .entry-header -->
<div class="entry-content">
<!-- first one --> <img src="<?php echo wp_get_attachment_image_src( get_post_thumbnail_id($post->ID));?>" />
<?php
$terms = get_the_terms($post->ID, 'maladies', '', ', ','');
if ( !empty( $terms ) ){
$numTerm = 0;
echo "<h3>Maladie : </h3>";
echo "<p>";
foreach( $terms as $term ) {
$numTerm++;
if ($numTerm == 1){
echo " ".$term->name;
}
else{
echo ", ".$term->name;
}
}
echo "</p><br/>";
}
?>
<!-- second one --> <a href="<?php the_permalink() ?>" >Lire plus ...</a>
<p><?php the_excerpt(); ?></p>
<?php
wp_link_pages( array(
'before' => '<div class="page-links">' . __( 'Pages:', 'adelia' ),
'after' => '</div>',
) );
?>
</div><!-- .entry-content -->
<div class="foot"></div>
<!--<?php edit_post_link( __( 'Edit', 'adelia' ), '<footer class="entry-meta"><span class="edit-link">', '</span></footer>' ); ?>-->
</article><!-- #post-## -->
<?php
// If comments are open or we have at least one comment, load up the comment template
/*if ( comments_open() || '0' != get_comments_number() )
comments_template();*/
?>
<?php endwhile; // end of the loop. ?>
Thanks.
I am trying to edit a blog archive page template that will hide all output unless a password is entered. Currently when "Password protected" is selected, it only hides content entered into the page and not the category output as well.
Apparently WordPress has a function reference called Post_Password_Required that should be wrapped around the category output in the template. This way if the blog template is called and is also password protected, WordPress will block all output until the password is entered.
http://codex.wordpress.org/Function_Reference/post_password_required
Now, after arbitrarily trying to figure out where to place this code in the page-blog.php and failing i'm wondering if anyone has a better idea of where to place it.
I'm using an Elegant Themes template and their support is balls on the issue. Telling me I need to find a plugin to do this and coping out to contact a 3rd party developer to fix this. Here is the code for the blog template for reference. I appreciate any help.
<?php
/*
Template Name: Investor
*/
?>
<?php if (is_front_page()) { ?>
<?php get_template_part('home'); ?>
<?php } else { ?>
<?php
$et_ptemplate_settings = array();
$et_ptemplate_settings = maybe_unserialize( get_post_meta($post->ID,'et_ptemplate_settings',true) );
$fullwidth = isset( $et_ptemplate_settings['et_fullwidthpage'] ) ? (bool) $et_ptemplate_settings['et_fullwidthpage'] : false;
$et_ptemplate_blogstyle = isset( $et_ptemplate_settings['et_ptemplate_blogstyle'] ) ? (bool) $et_ptemplate_settings['et_ptemplate_blogstyle'] : false;
$et_ptemplate_showthumb = isset( $et_ptemplate_settings['et_ptemplate_showthumb'] ) ? (bool) $et_ptemplate_settings['et_ptemplate_showthumb'] : false;
$blog_cats = isset( $et_ptemplate_settings['et_ptemplate_blogcats'] ) ? (array) $et_ptemplate_settings['et_ptemplate_blogcats'] : array();
$et_ptemplate_blog_perpage = isset( $et_ptemplate_settings['et_ptemplate_blog_perpage'] ) ? (int) $et_ptemplate_settings['et_ptemplate_blog_perpage'] : 10;
?>
<?php get_header(); ?>
<div id="content-left">
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class="entry post clearfix"<?php if ($fullwidth) echo ' style="padding-right: 10px;"'; ?>>
<?php $width = 140;
$height = 140;
$classtext = 'thumbnail alignleft';
$titletext = get_the_title();
$thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext);
$thumb = $thumbnail["thumb"]; ?>
<?php if($thumb <> '' && get_option('myproduct_page_thumbnails') == 'on') { ?>
<?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext , $width, $height, $classtext); ?>
<?php }; ?>
<?php the_content(); ?>
<?php wp_link_pages(array('before' => '<p><strong>Pages:</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
<div id="et_pt_blog">
<?php $cat_query = '';
if ( !empty($blog_cats) ) $cat_query = '&cat=' . implode(",", $blog_cats);
else echo '<!-- blog category is not selected -->'; ?>
<?php
$et_paged = is_front_page() ? get_query_var( 'page' ) : get_query_var( 'paged' );
?>
<?php query_posts("showposts=$et_ptemplate_blog_perpage&paged=" . $et_paged . $cat_query); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php if ( post_password_required() ) ?>
<div class="et_pt_blogentry clearfix">
<h2 class="et_pt_title"><?php the_title(); ?></h2>
<p class="et_pt_blogmeta"><?php esc_html_e('Posted','MyProduct'); ?> <?php esc_html_e('on','MyProduct'); ?> <?php the_time(get_option('myproduct_date_format')) ?>
<?php $thumb = '';
$width = 184;
$height = 184;
$classtext = '';
$titletext = get_the_title();
$thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext);
$thumb = $thumbnail["thumb"]; ?>
<?php if ( $thumb <> '' && !$et_ptemplate_showthumb ) { ?>
<div class="et_pt_thumb alignleft">
<?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?>
<span class="overlay"></span>
</div> <!-- end .thumb -->
<?php }; ?>
<?php if (!$et_ptemplate_blogstyle) { ?>
<p><?php truncate_post(550);?></p>
<span><?php esc_html_e('read more','MyProduct'); ?></span>
<?php } else { ?>
<?php
global $more;
$more = 0;
?>
<?php the_content(); ?>
<?php } ?>
</div> <!-- end .et_pt_blogentry -->
<?php endwhile; ?>
<div class="page-nav clearfix">
<?php if(function_exists('wp_pagenavi')) { wp_pagenavi(); }
else { ?>
<?php get_template_part('includes/navigation'); ?>
<?php } ?>
</div> <!-- end .entry -->
<?php else : ?>
<?php get_template_part('includes/no-results'); ?>
<?php endif; wp_reset_query(); ?>
</div> <!-- end #et_pt_blog -->
<?php edit_post_link(esc_html__('Edit this page','MyProduct')); ?>
<div class="clear"></div>
</div> <!-- end .post -->
<?php endwhile; endif; ?>
</div> <!-- end #content-left -->
<?php if (!$fullwidth) get_sidebar(); ?>
<?php get_footer(); ?>
<?php } ?>
http://jakeruesink.com/hermes/bosweb/web166/b1664/ipg.jakeruesinkcom/wp-content/uploads/et_temp/designfeature-23171_240x240.jpg
This link is obviously incorrect, but if you take out the "hermes/bosweb/web166/b1664/ipg.jakeruesinkcom/" then it works. For some reason wordpress is getting the wrong path for these images on my http://jakeruesink.com/project-page/
The following is the code for that page, but I'm not sure if that is what needs fixing.
<?php
/*
Template Name: Filterable Portfolio
*/
?>
<?php get_header(); ?>
<?php get_template_part('includes/breadcrumbs', 'page'); ?>
<h1 class="page_title"><?php the_title(); ?></h1>
<div id="content-area" class="fullwidth clearfix">
<div class="post-content">
<?php while ( have_posts() ) : the_post(); ?>
<?php the_content(); ?>
<?php wp_link_pages(array('before' => '<p><strong>'.esc_attr__('Pages','Flexible').':</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
<?php edit_post_link(esc_attr__('Edit this page','Flexible')); ?>
<?php endwhile; ?>
</div> <!-- end .post-content -->
<?php
$et_ptemplate_settings = array();
$et_ptemplate_settings = get_post_meta($post->ID,'et_ptemplate_settings',true);
$et_ptemplate_projectcats = isset( $et_ptemplate_settings['et_ptemplate_projectcats'] ) ? (array) $et_ptemplate_settings['et_ptemplate_projectcats'] : array();
$portfolio_args = array(
'post_type' => 'project',
'showposts' => -1,
'tax_query' => array(
array(
'taxonomy' => 'project_category',
'field' => 'id',
'terms' => $et_ptemplate_projectcats,
'operator' => 'IN'
)
)
);
if ( empty( $et_ptemplate_projectcats ) ) unset ( $portfolio_args['tax_query'] );
$portfolio_query = new WP_Query( apply_filters( 'et_home_portfolio_args', $portfolio_args ) );
$categories = get_terms( 'project_category', array( 'include' => $et_ptemplate_projectcats ) );
if ( $categories ){
echo '<ul id="et_portfolio_sort_links">';
echo '<li class="active">' . '' . __( 'All', 'Flexible' ) . '' . '</li>';
foreach ( $categories as $category ){
echo '<li>' . '' . esc_html( $category->name ) . '' . '</li>';
}
echo '</ul>';
}
?>
<div id="portfolio-grid" class="clearfix">
<?php
while ( $portfolio_query->have_posts() ) : $portfolio_query->the_post();
get_template_part( 'includes/entry', 'portfolio' );
endwhile;
wp_reset_postdata();
?>
</div> <!-- end #portfolio-grid -->
This is the code for the portfolio page:
<?php
/*
Template Name: Portfolio Page
*/
?>
<?php
$et_ptemplate_settings = array();
$et_ptemplate_settings = maybe_unserialize( get_post_meta($post->ID,'et_ptemplate_settings',true) );
$fullwidth = true;
$et_ptemplate_showtitle = isset( $et_ptemplate_settings['et_ptemplate_showtitle'] ) ? (bool)
$et_ptemplate_settings['et_ptemplate_showtitle'] : false;
$et_ptemplate_showdesc = isset( $et_ptemplate_settings['et_ptemplate_showdesc'] ) ? (bool)
$et_ptemplate_settings['et_ptemplate_showdesc'] : false;
$et_ptemplate_detect_portrait = isset( $et_ptemplate_settings['et_ptemplate_detect_portrait'] ) ? (bool)
$et_ptemplate_settings['et_ptemplate_detect_portrait'] : false;
$gallery_cats = isset( $et_ptemplate_settings['et_ptemplate_gallerycats'] ) ? (array)
$et_ptemplate_settings['et_ptemplate_gallerycats'] : array();
$et_ptemplate_gallery_perpage = isset( $et_ptemplate_settings['et_ptemplate_gallery_perpage'] ) ? (int)
$et_ptemplate_settings['et_ptemplate_gallery_perpage'] : 12;
$et_ptemplate_portfolio_size = isset( $et_ptemplate_settings['et_ptemplate_imagesize'] ) ? (int)
$et_ptemplate_settings['et_ptemplate_imagesize'] : 2;
$et_ptemplate_portfolio_class = '';
if ( $et_ptemplate_portfolio_size == 1 ) $et_ptemplate_portfolio_class = ' et_portfolio_small';
if ( $et_ptemplate_portfolio_size == 3 ) $et_ptemplate_portfolio_class = ' et_portfolio_large';
?>
<?php get_header(); ?>
<?php get_template_part('includes/breadcrumbs', 'page'); ?>
<div id="content-area" class="clearfix<?php if ( $fullwidth ) echo ' fullwidth'; ?>">
<div id="left-area">
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<article id="post-<?php the_ID(); ?>" <?php post_class('entry clearfix'); ?>>
<h1 class="page_title"><?php the_title(); ?></h1>
<?php
$thumb = '';
$width = apply_filters('et_blog_image_width',640);
$height = apply_filters('et_blog_image_height',320);
$classtext = '';
$titletext = get_the_title();
$thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext,false,'Blogimage');
$thumb = $thumbnail["thumb"];
?>
<?php if ( '' != $thumb && 'on' == et_get_option('flexible_page_thumbnails') ) { ?>
<div class="post-thumbnail">
<?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?>
</div> <!-- end .post-thumbnail -->
<?php } ?>
<div class="post-content">
<?php the_content(); ?>
<div id="et_pt_portfolio_gallery" class="clearfix responsive<?php echo $et_ptemplate_portfolio_class; ?>">
<?php $gallery_query = '';
$portfolio_count = 1;
$et_open_row = false;
if ( !empty($gallery_cats) ) $gallery_query = '&cat=' . implode(",", $gallery_cats);
else echo '<!-- gallery category is not selected -->'; ?>
<?php
global $wp_embed;
$et_videos_output = '';
$et_paged = is_front_page() ? get_query_var( 'page' ) : get_query_var( 'paged' );
?>
<?php query_posts("showposts=$et_ptemplate_gallery_perpage&paged=" . $et_paged . $gallery_query); ?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php $width = 260;
$height = 170;
if ( $et_ptemplate_portfolio_size == 1 ) {
$width = 140;
$height = 94;
$et_portrait_height = 170;
}
if ( $et_ptemplate_portfolio_size == 2 ) $et_portrait_height = 315;
if ( $et_ptemplate_portfolio_size == 3 ) {
$width = 430;
$height = 283;
$et_portrait_height = 860;
}
$et_auto_image_detection = false;
if ( has_post_thumbnail( $post->ID ) && $et_ptemplate_detect_portrait ) {
$wordpress_thumbnail = get_post( get_post_thumbnail_id($post->ID) );
$wordpress_thumbnail_url = $wordpress_thumbnail->guid;
if ( et_is_portrait($wordpress_thumbnail_url) ) $height = $et_portrait_height;
}
$titletext = get_the_title();
$et_portfolio_title = get_post_meta($post->ID,'et_portfolio_title',true) ? get_post_meta($post->ID,'et_portfolio_title',true) : get_the_title();
$et_videolink = get_post_meta($post->ID,'et_videolink',true) ? get_post_meta($post->ID,'et_videolink',true) : '';
if ( '' != $et_videolink ){
$et_video_id = 'et_video_post_' . $post->ID;
$et_videos_output .= '<div id="'. esc_attr( $et_video_id ) .'">' . $wp_embed->shortcode( '', $et_videolink ) . '</div>';
}
$thumbnail = get_thumbnail($width,$height,'',$titletext,$titletext,true,'et_portfolio');
$thumb = $thumbnail["thumb"];
if ( $et_ptemplate_detect_portrait && $thumbnail["use_timthumb"] && et_is_portrait($thumb) ) {
$height = $et_portrait_height;
} ?>
<?php if ( $portfolio_count == 1 || ( $et_ptemplate_portfolio_size == 2 && (!$fullwidth && ($portfolio_count+1) % 2 == 0) ) || ( $et_ptemplate_portfolio_size == 3 && (($portfolio_count+1) % 2 == 0) ) ) {
$et_open_row = true; ?>
<div class="et_pt_portfolio_row clearfix">
<?php } ?>
<div class="et_pt_portfolio_item">
<?php if ($et_ptemplate_showtitle) { ?>
<h2 class="et_pt_portfolio_title"><?php echo $et_portfolio_title; ?></h2>
<?php } ?>
<div class="et_pt_portfolio_entry<?php if ( $height == $et_portrait_height ) echo ' et_portrait_layout'; ?>">
<div class="et_pt_portfolio_image<?php if ($et_videolink <> '') echo ' et_video'; ?>">
<?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, ''); ?>
<span class="et_pt_portfolio_overlay"></span>
<a class="et_portfolio_zoom_icon fancybox" title="<?php the_title(); ?>"<?php if ($et_videolink == '') echo ' rel="portfolio"'; ?> href="<?php if ($et_videolink <> '') echo esc_url( '#' . $et_video_id ); else echo($thumbnail['fullpath']); ?>"><?php esc_html_e('Zoom in','Flexible'); ?></a>
<a class="et_portfolio_more_icon" href="<?php the_permalink(); ?>"><?php esc_html_e('Read more','Flexible'); ?></a>
</div> <!-- end .et_pt_portfolio_image -->
</div> <!-- end .et_pt_portfolio_entry -->
<?php if ($et_ptemplate_showdesc) { ?>
<p><?php truncate_post(90); ?></p>
<?php } ?>
</div> <!-- end .et_pt_portfolio_item -->
<?php if ( ($et_ptemplate_portfolio_size == 2 && !$fullwidth && $portfolio_count % 2 == 0) || ( $et_ptemplate_portfolio_size == 3 && ($portfolio_count % 2 == 0) ) ) {
$et_open_row = false; ?>
</div> <!-- end .et_pt_portfolio_row -->
<?php } ?>
<?php if ( ($et_ptemplate_portfolio_size == 2 && $fullwidth && $portfolio_count % 3 == 0) || ($et_ptemplate_portfolio_size == 1 && !$fullwidth && $portfolio_count % 3 == 0) || ($et_ptemplate_portfolio_size == 1 && $fullwidth && $portfolio_count % 5 == 0) ) { ?>
</div> <!-- end .et_pt_portfolio_row -->
<div class="et_pt_portfolio_row clearfix">
<?php $et_open_row = true; ?>
<?php } ?>
<?php $portfolio_count++;
endwhile; ?>
<?php if ( $et_open_row ) {
$et_open_row = false; ?>
</div> <!-- end .et_pt_portfolio_row -->
<?php } ?>
<div class="page-nav clearfix">
<?php if (function_exists('wp_pagenavi')) { wp_pagenavi(); }
else { ?>
<?php get_template_part('includes/navigation'); ?>
<?php } ?>
</div> <!-- end .entry -->
<?php else : ?>
<?php if ( $et_open_row ) {
$et_open_row = false; ?>
</div> <!-- end .et_pt_portfolio_row -->
<?php } ?>
<?php get_template_part('includes/no-results'); ?>
<?php endif; wp_reset_query(); ?>
<?php if ( $et_open_row ) {
$et_open_row = false; ?>
</div> <!-- end .et_pt_portfolio_row -->
<?php } ?>
<?php if ( '' != $et_videos_output ) echo '<div class="et_embedded_videos">' . $et_videos_output . '</div>'; ?>
</div> <!-- end #et_pt_portfolio_gallery -->
<?php wp_link_pages(array('before' => '<p><strong>'.esc_attr__('Pages','Flexible').':</strong> ', 'after' => '</p>', 'next_or_number' => 'number')); ?>
<?php edit_post_link(esc_attr__('Edit this page','Flexible')); ?>
</div> <!-- end .post-content -->
</article> <!-- end .entry -->
<?php endwhile; // end of the loop. ?>
</div> <!-- end #left_area -->
<?php if ( ! $fullwidth ) get_sidebar(); ?>
</div> <!-- end #content-area -->
<?php get_footer(); ?>
Here is the code for entry.php:
<article id="post-<?php the_ID(); ?>" <?php post_class('entry clearfix'); ?>>
<h2 class="title"><?php the_title(); ?></h2>
<?php
$thumb = '';
$width = apply_filters('et_blog_image_width',640);
$height = apply_filters('et_blog_image_height',320);
$classtext = '';
$titletext = get_the_title();
$thumbnail = get_thumbnail($width,$height,$classtext,$titletext,$titletext,false,'Blogimage');
$thumb = $thumbnail["thumb"];
?>
<?php if ( '' != $thumb && 'on' == et_get_option('flexible_thumbnails_index') ) { ?>
<div class="post-thumbnail">
<a href="<?php the_permalink(); ?>">
<?php print_thumbnail($thumb, $thumbnail["use_timthumb"], $titletext, $width, $height, $classtext); ?>
</a>
</div> <!-- end .post-thumbnail -->
<?php } ?>
<div class="post-content">
<?php
$index_postinfo = et_get_option('flexible_postinfo1');
if ( $index_postinfo ){
echo '<p class="meta-info">';
et_postinfo_meta( $index_postinfo, et_get_option('flexible_date_format'), esc_html__('0 comments','Flexible'), esc_html__('1 comment','Flexible'), '% ' . esc_html__('comments','Flexible') );
echo '</p>';
}
if ( 'on' == et_get_option('flexible_blog_style') ) the_content('');
else echo '<p>' . truncate_post(360,false) . '</p>';
?>
<?php esc_html_e( 'Read More', 'Flexible' ); ?>
</div> <!-- end .post-content -->