WordPress CPT Numbered Pagination - wordpress

I have a custom post type in WordPress.
The mobile archive page is a slider through ALL the posts.
The desktop archive page is a normal archive page, with numbered navigation and only shows 6 posts per page.
I see to have this working, however on the desktop, there should only be 3 pages, but instead, there are 4 pages, and the fourth page is empty.
I'm baffled as to what I've done wrong, so if anyone can take a look, that would be brill.
Thank you
archive-projects.php:
<?php
if ( !have_posts() ) {
// If no posts match the query
get_template_part( '404' );
return;
}
get_header();
?>
<div class="container">
<div class="content-area mobile" id="mobile-projects-slider">
<?php
$args = array(
'post_type' => 'projects',
'order-by' => 'date',
'order' => 'des',
'posts_per_page' => -1
);
$the_query = new WP_Query( $args );
if($the_query->have_posts() ) :
while ( $the_query->have_posts() ) :
$the_query->the_post();
?>
<article <?php post_class( 'entry entry-archive' ); ?> data-aos="fade">
<?php $backgroundImg = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' ); ?>
<div class="entry-image">
<a href="<?php the_permalink(); ?>">
<div class="post-image" style="background-image: url('<?php echo $backgroundImg[0]; ?>')"></div>
</a>
</div>
<div class="entry-content">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
See More
</div>
</article>
<?php
endwhile;
wp_reset_postdata();
else:
endif;
?>
</div>
<div class="content-area desktop" id="desktop-projects">
<?php
$args = array(
'post_type' => 'projects',
'order-by' => 'date',
'order' => 'des',
'paged' => $paged,
'posts_per_page' => 6
);
$the_query = new WP_Query( $args );
if($the_query->have_posts() ) :
while ( $the_query->have_posts() ) :
$the_query->the_post();
?>
<article <?php post_class( 'entry entry-archive' ); ?> data-aos="fade">
<?php $backgroundImg = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' ); ?>
<div class="entry-image">
<a href="<?php the_permalink(); ?>">
<div class="post-image" style="background-image: url('<?php echo $backgroundImg[0]; ?>')"></div>
</a>
</div>
<div class="entry-content">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
See More
</div>
</article>
<?php
endwhile;
wp_reset_postdata();
else:
endif;
?>
<?php
get_template_part( '_template-parts/page-navigation' );
?>
</div>
<!-- <div class="aside"> -->
<?php /* get_sidebar(); */ ?>
<!-- </div> -->
</div>
<?php
get_footer();
page-navigation.php:
<?php if ( is_singular() ) : ?>
<?php if( get_post_type() == 'projects' ) { ?>
<div id="navigation" data-aos="fade">
<div class="pagination pagination-singular">
<?php if ( get_next_post() ) { ?>
<div class="nav-next"><?php next_post_link( '%link', 'Previous Project' ) ?></div>
<?php } ?>
<?php if ( get_previous_post() ) { ?>
<div class="nav-previous"><?php previous_post_link( '%link', 'Next Project' ) ?></div>
<?php } ?>
</div>
</div>
<?php } else { ?>
<div id="navigation" data-aos="fade">
<div class="pagination pagination-singular">
<?php if ( get_next_post() ) { ?>
<div class="nav-next"><?php next_post_link( '%link', 'Previous Post' ) ?></div>
<?php } ?>
<?php if ( get_previous_post() ) { ?>
<div class="nav-previous"><?php previous_post_link( '%link', 'Next Post' ) ?></div>
<?php } ?>
</div>
</div>
<?php } ?>
<?php else : ?>
<?php
aa_numeric_posts_nav();
// located in includes > functions > theme-functions.php
?>
<?php endif; ?>
aa_posts_nav_function():
function aa_numeric_posts_nav() {
if( is_singular() )
return;
global $wp_query;
// $paged = 0;
/** Stop execution if there's only 1 page */
if( $wp_query->max_num_pages <= 1 )
return;
$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
$max = intval( $wp_query->max_num_pages );
/** Add current page to the array */
if ( $paged >= 1 )
$links[] = $paged;
/** Add the pages around the current page to the array */
if ( $paged >= 3 ) {
$links[] = $paged - 1;
$links[] = $paged - 2;
}
//
if ( ( $paged + 2 ) <= $max ) {
$links[] = $paged + 2;
$links[] = $paged + 1;
}
echo '<div id="navigation"><ul class="pagination numbered-pagination">' . "\n";
/** Previous Post Link */
if ( get_previous_posts_link() )
printf( '<li class="nav-prev">%s</li>' . "\n", get_previous_posts_link() );
/** Link to first page, plus ellipses if necessary */
if ( ! in_array( 1, $links ) ) {
$class = 1 == $paged ? ' class="active"' : '';
printf( '<li%s>%s</li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
if ( ! in_array( 2, $links ) )
echo '<li>…</li>';
}
/** Link to current page, plus 2 pages in either direction if necessary */
sort( $links );
foreach ( (array) $links as $link ) {
$class = $paged == $link ? ' class="active"' : '';
printf( '<li%s>%s</li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
}
/** Link to last page, plus ellipses if necessary */
if ( ! in_array( $max, $links ) ) {
if ( ! in_array( $max - 1, $links ) )
echo '<li>…</li>' . "\n";
$class = $paged == $max ? ' class="active"' : '';
printf( '<li%s>%s</li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
}
/** Next Post Link */
if ( get_next_posts_link() )
printf( '<li class="nav-next">%s</li>' . "\n", get_next_posts_link() );
echo '</ul></div>' . "\n";
}

Fixed it. I removed the WP_Query completely for the desktop version (in archive- and added it using a separate function. This is what I have now and works:
archive-projects.php
<?php
if ( !have_posts() ) {
// If no posts match the query
get_template_part( '404' );
return;
}
get_header();
?>
<div class="container">
<div class="content-area mobile" id="mobile-projects-slider">
<?php
$args = array(
'post_type' => 'projects',
'order-by' => 'date',
'order' => 'des',
'posts_per_page' => -1
);
$the_query = new WP_Query( $args );
if($the_query->have_posts() ) :
while ( $the_query->have_posts() ) :
$the_query->the_post();
?>
<article <?php post_class( 'entry entry-archive' ); ?> data-aos="fade">
<?php $backgroundImg = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' ); ?>
<div class="entry-image">
<a href="<?php the_permalink(); ?>">
<div class="post-image" style="background-image: url('<?php echo $backgroundImg[0]; ?>')"></div>
</a>
</div>
<div class="entry-content">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
See More
</div>
</article>
<?php
endwhile;
wp_reset_postdata();
else:
endif;
?>
</div>
<div class="content-area desktop" id="desktop-projects">
<?php
if(have_posts() ) :
while ( have_posts() ) : the_post();
?>
<article <?php post_class( 'entry entry-archive' ); ?> data-aos="fade">
<?php $backgroundImg = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' ); ?>
<div class="entry-image">
<a href="<?php the_permalink(); ?>">
<div class="post-image" style="background-image: url('<?php echo $backgroundImg[0]; ?>')"></div>
</a>
</div>
<div class="entry-content">
<?php the_title( '<h1 class="entry-title">', '</h1>' ); ?>
See More
</div>
</article>
<?php
endwhile;
wp_reset_postdata();
else:
echo '<h2>No posts found!</h2>';
endif;
aa_numeric_posts_nav();
?>
</div>
<!-- <div class="aside"> -->
<?php /* get_sidebar(); */ ?>
<!-- </div> -->
</div>
<?php
get_footer();
aa_numeric_posts_nav(); function
function aa_numeric_posts_nav() {
if( is_singular() )
return;
global $wp_query;
// $paged = 0;
/** Stop execution if there's only 1 page */
if( $wp_query->max_num_pages <= 1 )
return;
$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
$max = intval( $wp_query->max_num_pages );
/** Add current page to the array */
if ( $paged >= 1 )
$links[] = $paged;
/** Add the pages around the current page to the array */
if ( $paged >= 3 ) {
$links[] = $paged - 1;
$links[] = $paged - 2;
}
//
if ( ( $paged + 2 ) <= $max ) {
$links[] = $paged + 2;
$links[] = $paged + 1;
}
echo '<div id="navigation"><ul class="pagination numbered-pagination">' . "\n";
/** Previous Post Link */
if ( get_previous_posts_link() )
printf( '<li class="nav-prev">%s</li>' . "\n", get_previous_posts_link() );
/** Link to first page, plus ellipses if necessary */
if ( ! in_array( 1, $links ) ) {
$class = 1 == $paged ? ' class="active"' : '';
printf( '<li%s>%s</li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
if ( ! in_array( 2, $links ) )
echo '<li>…</li>';
}
/** Link to current page, plus 2 pages in either direction if necessary */
sort( $links );
foreach ( (array) $links as $link ) {
$class = $paged == $link ? ' class="active"' : '';
printf( '<li%s>%s</li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
}
/** Link to last page, plus ellipses if necessary */
if ( ! in_array( $max, $links ) ) {
if ( ! in_array( $max - 1, $links ) )
echo '<li>…</li>' . "\n";
$class = $paged == $max ? ' class="active"' : '';
printf( '<li%s>%s</li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
}
/** Next Post Link */
if ( get_next_posts_link() )
printf( '<li class="nav-next">%s</li>' . "\n", get_next_posts_link() );
echo '</ul></div>' . "\n";
}
function for posts per page CPT for my desktop:
function aa_order_cpt( $query ) {
// exit out if it's the admin or it isn't the main query
if ( is_admin() || ! $query->is_main_query() ) {
return;
}
// order category archives by title in ascending order
if ( is_archive() ) {
$query->set( 'order' , 'desc' );
$query->set( 'orderby', 'date');
$query->set('posts_per_page', 6 );
}
return;
}
add_action( 'pre_get_posts', 'aa_order_cpt', 1 );

Related

Pagination does not display WP Query

I can't seem to get my pagination working.
I have been through many similar questions on Stack Overflow and tried to modify it but nothing seems to work.
EDIT - I'm trying to get numbered pagination - I'm not even sure the
examples I have tried are numbered.
My code without any attempts is
<section id="blog-posts" class="latest-blog-posts full-width standard-padding">
<div class="full-width-inner">
<div class="the-posts">
<?php
// Define our WP Query Parameters
$the_query = new WP_Query( 'posts_per_page=9' ); ?>
<?php
// Start our WP Query
while ($the_query -> have_posts()) : $the_query -> the_post();
// Display the Post Title with Hyperlink
?>
<div class="post">
<div class="post-thumb">
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<img src="<?php echo $image[0]; ?>" alt="" />
</div>
<h2 class="post-title-teaser"><?php the_title(); ?></h2>
<div class="post-date-preview"><p><?php echo get_the_date(); ?></p></div>
<div class="post-excerpt"><?php
the_excerpt(); ?></div>
<div class="elc-button post-button"><a class="read-on elc-button" aria-label="read more of the article about '<?php the_title(); ?>'" href="<?php the_permalink() ?>">Read More</a></div>
</div>
<?php
// Repeat the process and reset once it hits the limit
endwhile;
wp_reset_postdata();
?>
</div>
</div>
</section>
My latest attempts at adding pagination are
<section id="blog-posts" class="latest-blog-posts full-width standard-padding">
<div class="full-width-inner">
<div class="the-posts">
<?php
if ( ! function_exists( 'pagination' ) ) :
function pagination( $paged = '', $max_page = '' ) {
$big = 999999999; // need an unlikely integer
if( ! $paged ) {
$paged = get_query_var('paged');
}
if( ! $max_page ) {
global $wp_query;
$max_page = isset( $wp_query->max_num_pages ) ? $wp_query->max_num_pages : 1;
}
echo paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, $paged ),
'total' => $max_page,
'mid_size' => 1,
'prev_text' => __( '«' ),
'next_text' => __( '»' ),
'type' => 'list'
) );
}
endif;
?>
<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'post_status' => 'publish',
'orderby' => 'publish_date',
'order' => 'DESC',
'paged' => $paged,
'posts_per_page' => 12
);
$loop = new WP_Query( $args );
if ( $loop->have_posts() ) :
while ( $loop->have_posts() ) :
?>
<div class="post">
<div class="post-thumb">
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<img src="<?php echo $image[0]; ?>" alt="" />
</div>
<h2 class="post-title-teaser"><?php the_title(); ?></h2>
<div class="post-date-preview"><p><?php echo get_the_date(); ?></p></div>
<div class="post-excerpt"><?php
the_excerpt(); ?></div>
<div class="elc-button post-button"><a class="read-on elc-button" aria-label="read more of the article about '<?php the_title(); ?>'" href="<?php the_permalink() ?>">Read More</a></div>
</div>
<?php
// Repeat the process and reset once it hits the limit
endwhile;
pagination( $paged, $loop->max_num_pages); // Pagination Function
endif;
wp_reset_postdata();
?>
</div>
</div>
</section>
The truth is I didn't know if the initial portion (the if function) should be part of the PHP template or in functions PHP but I tried both
I have also tried this
<div class="the-posts">
<?php
// WP_Query arguments
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'post_status' => array( 'publish' ),
'nopaging' => false,
'posts_per_page' => '9',
'order' => 'DESC',
'orderby' => 'date',
'paged' => $paged
);
// The Query
$query = new WP_Query( $args );
// The Loop
if ( $query->have_posts() ) {
while ( $query->have_posts() ) { ?>
<div class="post">
<div class="post-thumb">
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<img src="<?php echo $image[0]; ?>" alt="" />
</div>
<h2 class="post-title-teaser"><?php the_title(); ?></h2>
<div class="post-date-preview"><p><?php echo get_the_date(); ?></p></div>
<div class="post-excerpt"><?php
the_excerpt(); ?></div>
<div class="elc-button post-button"><a class="read-on elc-button" aria-label="read more of the article about '<?php the_title(); ?>'" href="<?php the_permalink() ?>">Read More</a></div>
</div>
<?php }
} else {
// no posts found
}
echo paginate_links( array(
'base' => str_replace( 999999999, '%#%', esc_url( get_pagenum_link( 999999999 ) ) ),
'total' => $query->max_num_pages,
'current' => max( 1, get_query_var( 'paged' ) ),
'format' => '?paged=%#%',
'show_all' => false,
'type' => 'plain',
) );
// Restore original Post Data
wp_reset_postdata();
?>
</div>
But the page won't load and eventually, I get a 503
This kind of thing isn't my forte so I tried all the examples but nothing seemed to work
Any help would be greatly appreciated
need to check the PHP error log details for help, also you can comments out the template part by part, to find out the error happen on which part exactly.
Okay so after trying for days, I actually got it working not long after posting this like so
<section id="blog-posts" class="latest-blog-posts full-width standard-padding">
<div class="full-width-inner">
<div class="the-posts">
<?php
$paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1;
$args = array(
'posts_per_page' => 6,
'paged' => $paged
);
$custom_query = new WP_Query( $args );
while($custom_query->have_posts()) :
$custom_query->the_post();
?>
<div class="post">
<div class="post-thumb">
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<img src="<?php echo $image[0]; ?>" alt="" />
</div>
<h2 class="post-title-teaser"><?php the_title(); ?></h2>
<div class="post-date-preview"><p><?php echo get_the_date(); ?></p></div>
<div class="post-excerpt"><?php
the_excerpt(); ?></div>
<div class="elc-button post-button"><a class="read-on elc-button" aria-label="read more of the article about '<?php the_title(); ?>'" href="<?php the_permalink() ?>">Read More</a></div>
</div>
<?php endwhile; ?>
</div>
<?php if (function_exists("pagination")) {
pagination($custom_query->max_num_pages);
} ?>
</div>
</div>
</section>
Functions.php
// numbered pagination
function pagination($pages = '', $range = 4)
{
$showitems = ($range * 2)+1;
global $paged;
if(empty($paged)) $paged = 1;
if($pages == '')
{
global $wp_query;
$pages = $wp_query->max_num_pages;
if(!$pages)
{
$pages = 1;
}
}
if(1 != $pages)
{
echo "<div class=\"pagination\">";
if($paged > 2 && $paged > $range+1 && $showitems < $pages) echo "<a href='".get_pagenum_link(1)."'>« First</a>";
if($paged > 1 && $showitems < $pages) echo "<a href='".get_pagenum_link($paged - 1)."'>‹ Previous</a>";
for ($i=1; $i <= $pages; $i++)
{
if (1 != $pages &&( !($i >= $paged+$range+1 || $i <= $paged-$range-1) || $pages <= $showitems ))
{
echo ($paged == $i)? "<span class=\"current\">".$i."</span>":"".$i."";
}
}
if ($paged < $pages && $showitems < $pages) echo "Next ›";
if ($paged < $pages-1 && $paged+$range-1 < $pages && $showitems < $pages) echo "<a href='".get_pagenum_link($pages)."'>Last »</a>";
echo "</div>\n";
}
}
Thanks to this article
https://www.evan-herman.com/how-to-add-numeric-wordpress-pagination/#.Yxy4S-zML2I

Display child terms if there are posts on custom taxonomy template

I have a piece of code that shows child terms of a custom taxonomy of the current parent term in the taxonomy-term.php template file. I want to display html only when there are child terms present. Now the heading 2 is displayed even when there are no child terms. Here is the code:
<?php
$term_children = get_terms('onderwerp', array( 'parent' => get_queried_object_id(),));
if ( ! is_wp_error( $terms ) || ($term_children->count != 0) ) { ?>
<section>
<h2>Ik heb een vraag over:</h2>
<div class="onderwerp-links">
<?php
foreach ( $term_children as $child ) { ?>
<?php $img = get_term_meta( $term->term_id, 'ndftm_img', true ); ?>
<a href="<?php echo esc_url( get_term_link( $child ) ) ?>" style="background-image: url(<?php echo $img; ?>)">
<span><?php echo $child->name; ?></span>
</a><?php
}
?>
</div>
</section>
<?php
}
?>
I fixed it by adding
'hide_empty' => true
in the get terms array
and making the if statement like this:
if ( ! empty($term_children) )
Here's the code:
<?php
$term_children = get_terms('onderwerp', array( 'parent' => get_queried_object_id(), 'hide_empty' => true ));
if ( ! empty($term_children) ) { ?>
<section>
<h2>Ik heb een vraag over:</h2>
<div class="onderwerp-links">
<?php
foreach ( $term_children as $child ) { ?>
<?php $img = get_term_meta( $term->term_id, 'ndftm_img', true ); ?>
<a href="<?php echo esc_url( get_term_link( $child ) ) ?>" style="background-image: url(<?php echo $img; ?>)">
<span><?php echo $child->name; ?></span>
</a><?php
}
?>
</div>
</section>
<?php
}
?>

Change header template from Divi theme

I have this template(header.php). Now i'm working on a site, and i want to to some changes in this template. According to this template i get 2 menu locations, but i want to change the order of them.
<!DOCTYPE html>
<html <?php language_attributes(); ?>>
<head>
<meta charset="<?php bloginfo( 'charset' ); ?>" />
<?php
elegant_description();
elegant_keywords();
elegant_canonical();
/**
* Fires in the head, before {#see wp_head()} is called. This action can be used to
* insert elements into the beginning of the head before any styles or scripts.
*
* #since 1.0
*/
do_action( 'et_head_meta' );
$template_directory_uri = get_template_directory_uri();
?>
<link rel="pingback" href="<?php bloginfo('pingback_url'); ?>" />
<script type="text/javascript">
document.documentElement.className = 'js';
</script>
<?php wp_head(); ?>
</head>
<body <?php body_class(); ?>>
<?php
$product_tour_enabled = et_builder_is_product_tour_enabled();
$page_container_style = $product_tour_enabled ? ' style="padding-top: 0px;"' : ''; ?>
<div id="page-container"<?php echo et_core_intentionally_unescaped( $page_container_style, 'fixed_string' ); ?>>
<?php
if ( $product_tour_enabled || is_page_template( 'page-template-blank.php' ) ) {
return;
}
$et_secondary_nav_items = et_divi_get_top_nav_items();
$et_phone_number = $et_secondary_nav_items->phone_number;
$et_email = $et_secondary_nav_items->email;
$et_contact_info_defined = $et_secondary_nav_items->contact_info_defined;
$show_header_social_icons = $et_secondary_nav_items->show_header_social_icons;
$et_secondary_nav = $et_secondary_nav_items->secondary_nav;
$et_top_info_defined = $et_secondary_nav_items->top_info_defined;
$et_slide_header = 'slide' === et_get_option( 'header_style', 'left' ) || 'fullscreen' === et_get_option( 'header_style', 'left' ) ? true : false;
?>
<?php if ( $et_top_info_defined && ! $et_slide_header || is_customize_preview() ) : ?>
<?php ob_start(); ?>
<div id="top-header"<?php echo $et_top_info_defined ? '' : 'style="display: none;"'; ?>>
<div class="container clearfix">
<?php if ( $et_contact_info_defined ) : ?>
<div id="et-info">
<?php if ( '' !== ( $et_phone_number = et_get_option( 'phone_number' ) ) ) : ?>
<span id="et-info-phone"><?php echo et_core_esc_previously( et_sanitize_html_input_text( $et_phone_number ) ); ?></span>
<?php endif; ?>
<?php if ( '' !== ( $et_email = et_get_option( 'header_email' ) ) ) : ?>
<span id="et-info-email"><?php echo esc_html( $et_email ); ?></span>
<?php endif; ?>
<?php
if ( true === $show_header_social_icons ) {
get_template_part( 'includes/social_icons', 'header' );
} ?>
</div> <!-- #et-info -->
<?php endif; // true === $et_contact_info_defined ?>
<div id="et-secondary-menu">
<?php
if ( ! $et_contact_info_defined && true === $show_header_social_icons ) {
get_template_part( 'includes/social_icons', 'header' );
} else if ( $et_contact_info_defined && true === $show_header_social_icons ) {
ob_start();
get_template_part( 'includes/social_icons', 'header' );
$duplicate_social_icons = ob_get_contents();
ob_end_clean();
printf(
'<div class="et_duplicate_social_icons">
%1$s
</div>',
et_core_esc_previously( $duplicate_social_icons )
);
}
if ( '' !== $et_secondary_nav ) {
echo et_core_esc_wp( $et_secondary_nav );
}
et_show_cart_total();
?>
</div> <!-- #et-secondary-menu -->
</div> <!-- .container -->
</div> <!-- #top-header -->
<?php
$top_header = ob_get_clean();
/**
* Filters the HTML output for the top header.
*
* #since 3.10
*
* #param string $top_header
*/
echo et_core_intentionally_unescaped( apply_filters( 'et_html_top_header', $top_header ), 'html' );
?>
<?php endif; // true ==== $et_top_info_defined ?>
<?php if ( $et_slide_header || is_customize_preview() ) : ?>
<?php ob_start(); ?>
<div class="et_slide_in_menu_container">
<?php if ( 'fullscreen' === et_get_option( 'header_style', 'left' ) || is_customize_preview() ) { ?>
<span class="mobile_menu_bar et_toggle_fullscreen_menu"></span>
<?php } ?>
<?php
if ( $et_contact_info_defined || true === $show_header_social_icons || false !== et_get_option( 'show_search_icon', true ) || class_exists( 'woocommerce' ) || is_customize_preview() ) { ?>
<div class="et_slide_menu_top">
<?php if ( 'fullscreen' === et_get_option( 'header_style', 'left' ) ) { ?>
<div class="et_pb_top_menu_inner">
<?php } ?>
<?php }
if ( true === $show_header_social_icons ) {
get_template_part( 'includes/social_icons', 'header' );
}
et_show_cart_total();
?>
<?php if ( false !== et_get_option( 'show_search_icon', true ) || is_customize_preview() ) : ?>
<?php if ( 'fullscreen' !== et_get_option( 'header_style', 'left' ) ) { ?>
<div class="clear"></div>
<?php } ?>
<form role="search" method="get" class="et-search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<?php
printf( '<input type="search" class="et-search-field" placeholder="%1$s" value="%2$s" name="s" title="%3$s" />',
esc_attr__( 'Search …', 'Divi' ),
get_search_query(),
esc_attr__( 'Search for:', 'Divi' )
);
?>
<button type="submit" id="searchsubmit_header"></button>
</form>
<?php endif; // true === et_get_option( 'show_search_icon', false ) ?>
<?php if ( $et_contact_info_defined ) : ?>
<div id="et-info">
<?php if ( '' !== ( $et_phone_number = et_get_option( 'phone_number' ) ) ) : ?>
<span id="et-info-phone"><?php echo et_core_esc_previously( et_sanitize_html_input_text( $et_phone_number ) ); ?></span>
<?php endif; ?>
<?php if ( '' !== ( $et_email = et_get_option( 'header_email' ) ) ) : ?>
<span id="et-info-email"><?php echo esc_html( $et_email ); ?></span>
<?php endif; ?>
</div> <!-- #et-info -->
<?php endif; // true === $et_contact_info_defined ?>
<?php if ( $et_contact_info_defined || true === $show_header_social_icons || false !== et_get_option( 'show_search_icon', true ) || class_exists( 'woocommerce' ) || is_customize_preview() ) { ?>
<?php if ( 'fullscreen' === et_get_option( 'header_style', 'left' ) ) { ?>
</div> <!-- .et_pb_top_menu_inner -->
<?php } ?>
</div> <!-- .et_slide_menu_top -->
<?php } ?>
<div class="et_pb_fullscreen_nav_container">
<?php
$slide_nav = '';
$slide_menu_class = 'et_mobile_menu';
$slide_nav = wp_nav_menu( array( 'theme_location' => 'primary-menu', 'container' => '', 'fallback_cb' => '', 'echo' => false, 'items_wrap' => '%3$s' ) );
$slide_nav .= wp_nav_menu( array( 'theme_location' => 'secondary-menu', 'container' => '', 'fallback_cb' => '', 'echo' => false, 'items_wrap' => '%3$s' ) );
?>
<ul id="mobile_menu_slide" class="<?php echo esc_attr( $slide_menu_class ); ?>">
<?php
if ( '' === $slide_nav ) :
?>
<?php if ( 'on' === et_get_option( 'divi_home_link' ) ) { ?>
<li <?php if ( is_home() ) echo( 'class="current_page_item"' ); ?>><?php esc_html_e( 'Home', 'Divi' ); ?></li>
<?php }; ?>
<?php show_page_menu( $slide_menu_class, false, false ); ?>
<?php show_categories_menu( $slide_menu_class, false ); ?>
<?php
else :
echo et_core_esc_wp( $slide_nav ) ;
endif;
?>
</ul>
</div>
</div>
<?php
$slide_header = ob_get_clean();
/**
* Filters the HTML output for the slide header.
*
* #since 3.10
*
* #param string $top_header
*/
echo et_core_intentionally_unescaped( apply_filters( 'et_html_slide_header', $slide_header ), 'html' );
?>
<?php endif; // true ==== $et_slide_header ?>
<?php ob_start(); ?>
<header id="main-header" data-height-onload="<?php echo esc_attr( et_get_option( 'menu_height', '66' ) ); ?>">
<div class="container clearfix et_menu_container">
<?php
$logo = ( $user_logo = et_get_option( 'divi_logo' ) ) && ! empty( $user_logo )
? $user_logo
: $template_directory_uri . '/images/logo.png';
ob_start();
?>
<div class="logo_container">
<span class="logo_helper"></span>
<a href="<?php echo esc_url( home_url( '/' ) ); ?>">
<img src="<?php echo esc_attr( $logo ); ?>" alt="<?php echo esc_attr( get_bloginfo( 'name' ) ); ?>" id="logo" data-height-percentage="<?php echo esc_attr( et_get_option( 'logo_height', '54' ) ); ?>" />
</a>
</div>
<?php
$logo_container = ob_get_clean();
/**
* Filters the HTML output for the logo container.
*
* #since 3.10
*
* #param string $logo_container
*/
echo et_core_intentionally_unescaped( apply_filters( 'et_html_logo_container', $logo_container ), 'html' );
?>
<div id="et-top-navigation" data-height="<?php echo esc_attr( et_get_option( 'menu_height', '66' ) ); ?>" data-fixed-height="<?php echo esc_attr( et_get_option( 'minimized_menu_height', '40' ) ); ?>">
<?php if ( ! $et_slide_header || is_customize_preview() ) : ?>
<nav id="top-menu-nav">
<?php
$menuClass = 'nav';
if ( 'on' === et_get_option( 'divi_disable_toptier' ) ) $menuClass .= ' et_disable_top_tier';
$primaryNav = '';
$primaryNav = wp_nav_menu( array( 'theme_location' => 'primary-menu', 'container' => '', 'fallback_cb' => '', 'menu_class' => $menuClass, 'menu_id' => 'top-menu', 'echo' => false ) );
if ( empty( $primaryNav ) ) :
?>
<ul id="top-menu" class="<?php echo esc_attr( $menuClass ); ?>">
<?php if ( 'on' === et_get_option( 'divi_home_link' ) ) { ?>
<li <?php if ( is_home() ) echo( 'class="current_page_item"' ); ?>><?php esc_html_e( 'Home', 'Divi' ); ?></li>
<?php }; ?>
<?php show_page_menu( $menuClass, false, false ); ?>
<?php show_categories_menu( $menuClass, false ); ?>
</ul>
<?php
else :
echo et_core_esc_wp( $primaryNav );
endif;
?>
</nav>
<?php endif; ?>
<?php
if ( ! $et_top_info_defined && ( ! $et_slide_header || is_customize_preview() ) ) {
et_show_cart_total( array(
'no_text' => true,
) );
}
?>
<?php if ( $et_slide_header || is_customize_preview() ) : ?>
<span class="mobile_menu_bar et_pb_header_toggle et_toggle_<?php echo esc_attr( et_get_option( 'header_style', 'left' ) ); ?>_menu"></span>
<?php endif; ?>
<?php if ( ( false !== et_get_option( 'show_search_icon', true ) && ! $et_slide_header ) || is_customize_preview() ) : ?>
<div id="et_top_search">
<span id="et_search_icon"></span>
</div>
<?php endif; // true === et_get_option( 'show_search_icon', false ) ?>
<?php
/**
* Fires at the end of the 'et-top-navigation' element, just before its closing tag.
*
* #since 1.0
*/
do_action( 'et_header_top' );
?>
</div> <!-- #et-top-navigation -->
</div> <!-- .container -->
<div class="et_search_outer">
<div class="container et_search_form_container">
<form role="search" method="get" class="et-search-form" action="<?php echo esc_url( home_url( '/' ) ); ?>">
<?php
printf( '<input type="search" class="et-search-field" placeholder="%1$s" value="%2$s" name="s" title="%3$s" />',
esc_attr__( 'Search …', 'Divi' ),
get_search_query(),
esc_attr__( 'Search for:', 'Divi' )
);
?>
</form>
<span class="et_close_search_field"></span>
</div>
</div>
</header> <!-- #main-header -->
<?php
$main_header = ob_get_clean();
/**
* Filters the HTML output for the main header.
*
* #since 3.10
*
* #param string $main_header
*/
echo et_core_intentionally_unescaped( apply_filters( 'et_html_main_header', $main_header ), 'html' );
?>
<div id="et-main-area">
<?php
/**
* Fires after the header, before the main content is output.
*
* #since 3.10
*/
do_action( 'et_before_main_content' );
In practice the secondary menu appears first, before primary menu. How to change the ordering for displaying:
FIRST: Primary menu;
SECOND: Secondary menu;
Who knows how could i change the order, for displaying the same order that i described above?
First of all, it is not advisable to change the order of the menu in the DIVI theme. Just rearranging the code will collapse the header.
So it is better to register a new Navigation Menu and then use it where you wanted.
Before making any changes to the theme files, make sure you are using Divi Child Theme. If you don't have one, You can download it here (Divi Child Theme Download Link)
Then you can copy your header.php file from Divi theme folder and paste it into the Child theme folder.
To register a custom menu, use the below code in the Functions.php file.
function wpb_custom_new_menu() {
register_nav_menu('my-custom-menu',__( 'My Custom Menu' ));
}
add_action( 'init', 'wpb_custom_new_menu' );
Now go to Appearance -> Menus and create a New Menu and assign it as "My Custom Menu".
To add this menu to the header, Add the below code in header.php where you want to display the menu.
'my-custom-menu',
'container_class' => 'custom-menu-class' ) );
?>
Then you can use the .custom_menu_class CSS class to style the menu.

wp pagination dont show in homepage

Now i tried to go pdf-market.ir/?paged=2 but it's show 404 Error !
check site, site search
i 1day tried to solve this problem but don't succed.
my codes for loop in index.php
<ul class="page_result">
<?php
//$paged = (get_query_var('page')) ? get_query_var('page') : 1;
$args = array(
'post_type' => 'product',
'stock' => 1,
'posts_per_page' => 16,
'orderby' => 'date',
'order' => 'DESC',
'paged' => 1,
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?>
<div class="bookbox">
<a id="id-<?php the_id(); ?>" href="<?php the_permalink(); ?>" title="<?php the_title(); ?>">
<div class="bookbox-img">
<?php if (has_post_thumbnail( $loop->post->ID )) echo get_the_post_thumbnail($loop->post->ID, 'shop_catalog'); else echo '<img src="'.woocommerce_placeholder_img_src().'" alt="Placeholder" style="margin-left: -20px" width="200px" height="200px" />'; ?>
</div>
</a>
<div class="bookbox-bookname"><a data-tooltip="<?php the_title(); ?>" class="bookname tooltip" href="<?php the_permalink(); ?>"><?php the_title(); ?></a></div>
<?php $mid_var = get_post_meta($post->ID, 'پدیداورنده',true);
if(isset($mid_var) && !empty($mid_var)) : ?>
<div class="bookbox-dtibook"><span class="garyYekan10">پدیدآورنده:</span>
<?php echo get_post_meta($post->ID, 'پدیداورنده',true); ?>
</div><?php endif; ?>
<?php $mid_var = get_post_meta($post->ID, 'ناشر',true);
if(isset($mid_var) && !empty($mid_var)) : ?>
<div class="bookbox-dtibook"><span class="garyYekan10">ناشر: </span>
<?php echo get_post_meta($post->ID, 'ناشر',true); ?>
</div>
<?php endif; ?>
<?php $mid_var = get_post_meta($post->ID, 'نوبت چاپ',true);
if(isset($mid_var) && !empty($mid_var)) : ?>
<div class="bookbox-dtibook"><span class="garyYekan10">نوبت چاپ:</span>
<?php echo get_post_meta($post->ID, 'نوبت چاپ',true); ?>
</div>
<?php endif; ?>
<div class="bookbox-price"><span class="garytahoma8">قیمت: </span> <?php woocommerce_template_loop_price() ?> </div>
<?php $mid_var = get_post_meta($post->ID, 'موجودی',true);
if(isset($mid_var) && !empty($mid_var)) : ?>
<div class="bookbox-price"><span class="garytahoma8">موجودی: </span><span class="fontgreen10">
<?php echo get_post_meta($post->ID, 'موجودی',true); ?>
</span> </div><?php endif; ?>
<a alt="مشخصات کتاب" href="<?php the_permalink(); ?>"><div title="مشخصات کتاب" alt="مشخصات کتاب" class="bookbox-bookinfo"></div></a>
<a alt="خرید کتاب" href="<?php the_permalink(); ?>&add-to-cart=<?php the_id(); ?>">
<div alt="خرید کتاب" class="bookbox-addcart"></div>
</a>
</div>
<?php endwhile; ?>
<?php wp_reset_postdata(); ?>
</ul>
<div class="pagination">
<?php
wp_pagination(); ?>
</div>
and my code in function.php > pagination
<?php
function wp_pagination() {
global $wp_query;
$big = 12345678;
$page_format = paginate_links( array(
'base' => str_replace( $big, '%#%', esc_url( get_pagenum_link( $big ) ) ),
'format' => '?paged=%#%',
'current' => max( 1, get_query_var('paged') ),
'total' => $wp_query->max_num_pages,
'type' => 'array'
) );
if( is_array($page_format) ) {
$paged = ( get_query_var('paged') == 0 ) ? 1 : get_query_var('paged');
echo '<div><ul>';
foreach ( $page_format as $page ) {
echo "<li>$page</li>";
}
echo '</ul></div>';
}
}
?>
this is all...
in searches and archives is show pagination but
in home page and example:site.com dont show pagination and it's place just free and no code...
Try this code this will work for you
<?php
global $query_string;
query_posts($query_string . "post_type=product&post_status=publish&posts_per_page=16");
if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php the_title(); ?>
<?php endwhile;
endif; ?>
<?php pagination_numeric_posts_nav(); ?>
<?php wp_reset_query(); ?>
Put this code in your functions.php file.
function pagination_numeric_posts_nav() {
if( is_singular() )
return;
global $wp_query;
/** Stop execution if there's only 1 page */
if( $wp_query->max_num_pages <= 1 )
return;
$paged = get_query_var( 'paged' ) ? absint( get_query_var( 'paged' ) ) : 1;
$max = intval( $wp_query->max_num_pages );
/** Add current page to the array */
if ( $paged >= 1 )
$links[] = $paged;
/** Add the pages around the current page to the array */
if ( $paged >= 3 ) {
$links[] = $paged - 1;
$links[] = $paged - 2;
}
if ( ( $paged + 2 ) <= $max ) {
$links[] = $paged + 2;
$links[] = $paged + 1;
}
echo '<div class=""><ul class="pagination">' . "\n";
/** Previous Post Link */
if ( get_previous_posts_link() )
printf( '<li>%s</li>' . "\n", get_previous_posts_link() );
/** Link to first page, plus ellipses if necessary */
if ( ! in_array( 1, $links ) ) {
$class = 1 == $paged ? ' class="active"' : '';
printf( '<li%s>%s</li>' . "\n", $class, esc_url( get_pagenum_link( 1 ) ), '1' );
if ( ! in_array( 2, $links ) )
echo '<li>…</li>';
}
/** Link to current page, plus 2 pages in either direction if necessary */
sort( $links );
foreach ( (array) $links as $link ) {
$class = $paged == $link ? ' class="active"' : '';
printf( '<li%s>%s</li>' . "\n", $class, esc_url( get_pagenum_link( $link ) ), $link );
}
/** Link to last page, plus ellipses if necessary */
if ( ! in_array( $max, $links ) ) {
if ( ! in_array( $max - 1, $links ) )
echo '<li>…</li>' . "\n";
$class = $paged == $max ? ' class="active"' : '';
printf( '<li%s>%s</li>' . "\n", $class, esc_url( get_pagenum_link( $max ) ), $max );
}
/** Next Post Link */
if ( get_next_posts_link() )
printf( '<li>%s</li>' . "\n", get_next_posts_link() );
echo '</ul></div>' . "\n";
}
css for pagination.
.navigation li a,
.navigation li a:hover,
.navigation li.active a,
.navigation li.disabled {
color: #fff;
text-decoration:none;
}
.navigation li {
display: inline;
}
.navigation li a,
.navigation li a:hover,
.navigation li.active a,
.navigation li.disabled {
background-color: #6FB7E9;
border-radius: 3px;
cursor: pointer;
padding: 12px;
padding: 0.75rem;
}
.navigation li a:hover,
.navigation li.active a {
background-color: #3C8DC5;
}
I hope this will work for you

Wordpress seeking the full hosting absolute link instead of the domain's path

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 -->

Resources