I’m working on a wordpress website, which has to use the Divi theme. For some reasons they’ve enabled offsetting the blog posts from the modules frontend, but they don’t do it for portfolio items. There’s a page on my site which should contain all the case studies and it basicly looks like that:
So, what I basicly did was that I’ve put on the first row the latest portfolio item, then I put on the second row two more portfolio items which I offset by 1 post, 3rd row is my testimonials content. My question is about the 4th row – I need to offset the portfolio items by 3 posts and I have to have pagination. The problem is that the moment I offset the items the pagination stops working. I tried gathering snippets and info all around the internet, but nothing seems to work. Here is what I’ve tried:
// Native conditional tag only works on page load. Data update needs $conditional_tags data
$is_front_page = et_fb_conditional_tag( 'is_front_page', $conditional_tags );
$is_search = et_fb_conditional_tag( 'is_search', $conditional_tags );
$offset_number = 3;
// Prepare query arguments
$query_args = array(
'posts_per_page' => (int) $args['posts_number'],
'post_type' => 'project',
'post_status' => 'publish',
);
// Conditionally get paged data
if ( defined( 'DOING_AJAX' ) && isset( $current_page[ 'paged'] ) ) {
$et_paged = intval( $current_page[ 'paged' ] );
} else {
$et_paged = $is_front_page ? get_query_var( 'page' ) : get_query_var( 'paged' );
$query_args['offset'] = ( ( $paged - 1 ) * intval( $posts_number ) ) + intval( $offset_number );
}
The portfolio items get offsetted by 3 posts, but when I click older entries it doesn’t work and I’m still shown the same items from the first page (offsetted by 3). Here is a pastebin of the whole module’s code.
2
Answers
Nobody wanted to help me, so I had to read wordpress documentations for 2 days, but it was worth it, I've managed to learn many new stuff! Here's the code if someone ever needs it:
And in my childs function.php:
Cheers!
You just need to use blog module to do this!
Set it on "Projects".
Good Luck!