I have 2 area of post to show in each page.
first is on the widget (it's on the top of each page).
second is on the posts area (it show below the widget).
It's separated queries. article on the widget is another query and article on the posts area is main query.
So,I don't want it to have same article in both area (not duplicate) and articles on the widget are random to show.
I would like to use the article id which i got from the widget to modify the main query.
For example: i have article id number 1 , 4 and 10 and i would like to use it to modify the main query to make it not load that article id to show.
I got $array_widgetId
from another file which has a loop to show the article in the widget(another query) and i set it to global variable and define it in this file which is used for show the article in the posts area(main query here) and also modify the main query to exclude that article id from loading.
while(have_posts()){
the_post();
//article to show in the posts area.
}
How can i reach my point to make it doesn't have duplicate article in both area without using pre_get_posts
?
because i have tried to pass the array of widget id to use in function.php
but it's not possible.
More information: I have many file to make this thing work(may be that's why it make me so confused to maintain).
I have one file to loop article to generate column.
"_posts.php" in warp framework layout
$column_order = $this['config']->get('multicolumns_order', 1);
$colcount = is_front_page() ? $this['config']->get('multicolumns', 1) : 1;
$widget_id (this array contains id of article which show on the widget kit)
while (have_posts()) {
the_post();
if (isset($widget_id) && !in_array($post->ID, $widget_id)) {
if ($column_order == 0) {
// order down
if ($row >= $rows) {
$column++;
$row = 0;
$rows = ceil(($count - $i) / ($colcount - $column));
}
$row++;
} else {
// order across
$column = $i % $colcount;
}
if (!isset($columns[$column])) {
$columns[$column] = '';
}
$columns[$column] .= $this->render('_post', array('is_column_item' => ($colcount > 1)));
$i++;
if ($i == $default_posts_per_page) {
break 1; // break out 'while' loop level
}
}
}
// render columns
if ($count = count($columns)) {
echo '<div class="uk-grid" data-uk-grid-match data-uk-grid-margin>';
for ($i = 0; $i < $count; $i++) {
echo '<div class="uk-width-medium-1-' . $count . '">' .
$columns[$i] . '</div>';
}
echo '</div>';
}else{
// generate standard column
}
Above code will generate column following setting in backend. After this, it will call "_post.php" and that "_post.php" will contain the HTML tag of my custom layout.