Hi @ehsanmn,
Use the pid parameter to exclude IDs from the list, see Parameters for more details.
I tested that with Both the parent post ID and attachment ID, but its not working.
I think because pid is for post_type=posts and does not work for attachments.
for showing attachments with wpp_get_mostpopular I added a snippet code to functions.php to show items that have inherit post_status (like attachments)
function wp8762_include_inherit_status( $where, $options ) {
return $where . " OR p.post_status = 'inherit'";
}
add_filter( 'wpp_query_where', 'wp8762_include_inherit_status', 10, 2 );
I think need a snippet code like this to add pid parameter for attachment IDs too.
I think because pid is for post_type=posts and does not work for attachments.
That’s not correct. The pid parameter works for all post types.
Please share your updated code here so I can see if there’s something that needs adjustments.
this is my code :
<?php
$amir_query = array (
'range' => 'custom',
'time_quantity' => 1,
'time_unit' => 'hour',
'order_by' => 'views',
'post_type' => 'attachment',
'limit' => 3,
'pid' => '4346',
'thumbnail_width' => 75,
'thumbnail_height' => 75,
'stats_views' => 1,
'post_html' => '
<div class="post"><figure class="post-thumb"><a href="{url}">{custom_thumb}</a></figure><div class="post_title"><h5><a href="{url}">{title}</a></h5></div></div>
',
);
if (function_exists('wpp_get_mostpopular'))
wpp_get_mostpopular($amir_query);
?>
Alright, finally had time to look into this.
Did some testing and found out that the problem is this wpp_query_where filter hook. Please change it to this and the pid parameter should work as intended:
function wp8762_include_inherit_status( $where, $options ) {
$where = str_replace("p.post_status = 'publish'", "(p.post_status = 'publish' OR p.post_status = 'inherit')", $where);
return $where;
}
add_filter( 'wpp_query_where', 'wp8762_include_inherit_status', 10, 2 );