Tagged: blog grid, enfold, sticky posts
-
AuthorPosts
-
March 17, 2019 at 12:41 pm #1079577
Hi there,
On the homepage of my Korfball Club (https://kvtelstar.nl) I use an Avia blog grid by the category ‘algemeen nieuwsbericht’. Sometimes a post has to be sticky, but it doesn’t stay on the 1ste position. I have researched the topics but haven’t found a solution. Can you help me?March 19, 2019 at 6:06 pm #1080419Hey Maureen,
Please post us your login credentials (in the “private data” field), so we can take a look at your backend.
- Install and activate ” Temporary Login Without Password “.
- Go to ” Users > Temporary Logins ” on the left-side menu.
- Click ” Create New “.
- Add the email address for the account ( you can use (Email address hidden if logged out) ), as well as the ” Role ” making that the highest possible and the expiry about four days
( do be sure that we have enough time to debug ). - Click ” Submit “.
- You’ll now have a temporary account. Please provide us here in the private section the URL, so we can login and help you out.
When your issue is fixed, you can always remove the plugin!
If you prefer to not use the plugin, you can manually create a admin user and post the login credentials in the “private data” field.Best regards,
NikkoMarch 20, 2019 at 5:24 pm #1080929Hereby your new login information.
March 21, 2019 at 2:16 pm #1081399Hi Maureen van Goethem,
Can you try adding this css code in functions.php of your child theme?
add_filter('avia_feature_image_slider_query', 'avia_feature_image_slider_query_mod', 10, 1); function avia_feature_image_slider_query_mod($query) { $query['posts_per_page'] = 1; $query['post__in'] = get_option( 'sticky_posts' ); $query['ignore_sticky_posts'] = 1; return $query; }
I tried adding it but I’m prevented from doing so and get this error:
Communicatie met de site niet mogelijk om te controleren op fouten, de PHP aanpassing is teruggedraaid. De PHP-bestandswijziging moet op een andere manier worden gewijzigd, bijvoorbeeld door SFTP te gebruiken.
Best regards,
NikkoMarch 21, 2019 at 2:32 pm #1081406CSS code added to functions.php but still no sticky post on position no. 1.
In related-posts.php I see this:
$my_query = get_posts(
array(
‘tag__in’ => $tag_ids,
‘post_type’ => get_post_type($this_id),
‘showposts’=>$postcount, ‘ignore_sticky_posts’=>1,
‘orderby’=>’rand’,
‘post__not_in’ => array($this_id))
);Has that something to do with this?
- This reply was modified 5 years, 9 months ago by Maureen van Goethem.
March 23, 2019 at 8:08 am #1082082Hi Maureen van Goethem,
No, it has nothing to do with it and only affects related posts.
Try the solution in this thread: https://kriesi.at/support/topic/sticky-posts-in-b-og-grid/#post-692059
just replace:$query['posts_per_page'] = 6;
with
$query['posts_per_page'] = 8;
Best regards,
NikkoMarch 25, 2019 at 1:09 pm #1082641The code works; I see sticky post on 1st position, but… now I see 6 posts instead of 8 on the homepage. So I made 3 columns instead of 4, which is my favorite.
And I see 6 on https://www.kvtelstar.nl/nieuws/ instead of 15 and pagination is gone.- This reply was modified 5 years, 9 months ago by Maureen van Goethem.
March 26, 2019 at 12:35 am #1082907Hi Maureen van Goethem,
If you replace the 6 on this code to 8:
$query['posts_per_page'] = 6;
It should be changed to 8.
Do you still need sticky posts on https://www.kvtelstar.nl/nieuws/ ? or just on the frontpage?Best regards,
NikkoMarch 26, 2019 at 10:57 am #1083040I already have changed that yesterday
And I need a sticky post only on the homepage.
Now I see 7 on the homepage and 7 on https://www.kvtelstar.nl/nieuws/. Here it should be all news posts and pagination.- This reply was modified 5 years, 9 months ago by Maureen van Goethem.
March 27, 2019 at 4:54 am #1083374Hi Maureen van Goethem,
Try to use this code instead:
add_filter('avia_post_slide_query', 'avia_post_slide_query_mod', 10, 2); function avia_post_slide_query_mod($query, $params) { if( is_front_page() ) { $include = array(); $sticky = get_option( 'sticky_posts' ); $args = array( 'taxonomy' => $params['taxonomy'], 'post__not_in' => $sticky, ); $posts = get_posts( $args ); foreach($posts as $post) { $include[] = $post->ID; } $include = array_merge($sticky, $include); // convert values of the $include from string to int function sti($n) { settype($n, 'int'); return $n ; } $include = array_map("sti", $include); $query['post__in'] = $include; $query['posts_per_page'] = 8; $query['orderby'] = 'post__in'; // sort items based on the post__in value } return $query; }
Best regards,
NikkoMarch 27, 2019 at 11:13 am #1083511An error
Parse error: syntax error, unexpected ‘=’, expecting ‘)’ in /var/www/vhosts/kvtelstar.nl/httpdocs/wp-content/themes/enfold-child/functions.php on line 25
March 28, 2019 at 1:33 am #1083851Hi Maureen van Goethem,
Can you try doing this instead, please add:
if( is_front_page() ) {
below this code:
function avia_post_slide_query_mod($query, $params) {
then add this code:
}
just above:
return $query;
Best regards,
NikkoMarch 28, 2019 at 6:58 pm #1084224Like this:
// add_filter(‘avia_post_slide_query’, ‘avia_post_slide_query_mod’, 10, 2);
function avia_post_slide_query_mod($query, $params) {
if( is_front_page() ) {if( is_front_page() ) {
$include = array();
$sticky = get_option( ‘sticky_posts’ );$args = array(
‘taxonomy’ => $params[‘taxonomy’],
‘post__not_in’ => $sticky,
);
$posts = get_posts( $args );foreach($posts as $post) {
$include[] = $post->ID;
}$include = array_merge($sticky, $include);
// convert values of the $include from string to int
function sti($n)
{
settype($n, ‘int’);
return $n ;
}$include = array_map(“sti”, $include);
$query[‘post__in’] = $include;
$query[‘posts_per_page’] = 8;
$query[‘orderby’] = ‘post__in’; // sort items based on the post__in value
}
}
return $query;
}March 28, 2019 at 7:12 pm #1084227Parse error: syntax error, unexpected ‘=’, expecting ‘)’ in /var/www/vhosts/kvtelstar.nl/httpdocs/wp-content/themes/enfold-child/functions.php on line 26
I transfered the old functions.php file and now it show still 7 on the homepage.
March 29, 2019 at 11:17 am #1084526Hi Maureen van Goethem,
I’m not really sure why that’s causing errors, since I have tried this on my end.
Can you give us ftp access? we’ll try to modify it then post the changes made if it works properly.Best regards,
NikkoApril 15, 2019 at 11:19 am #1090919I’m sorry. Due to some very personal matters I wasn’t able to response earlier. I hereby send you my ftp access (from filezilla).
April 16, 2019 at 11:50 am #1091387Hi Maureen van Goethem,
No worries, I tried the details above using Filezilla however I could not get access.
I tried both ftp and sftp.Best regards,
NikkoApril 16, 2019 at 11:58 am #1091389This is the only information I have, greetings, Maureen
April 16, 2019 at 2:30 pm #1091446Hi Maureen,
I’m still getting the same error, I put a screenshot in private content.
Can you provide us something where we can access files, like a cpanel? just change the password once we have fixed the issue.Best regards,
NikkoApril 16, 2019 at 2:48 pm #1091450can you try this password
April 16, 2019 at 4:21 pm #1091500Hi Maureen,
Thanks it works, I have added this code in your functions.php:
add_filter('avia_post_slide_query', 'avia_post_slide_query_mod', 10, 2); function avia_post_slide_query_mod($query, $params) { if( is_front_page() ) { $include = array(); $sticky = get_option( 'sticky_posts' ); if(empty($terms[0]) || is_null($terms[0]) || $terms[0] === "null") { $term_args = array( 'taxonomy' => $params['taxonomy'], 'hide_empty' => true ); $allTax = AviaHelper::get_terms( $term_args ); $terms = array(); foreach( $allTax as $tax ) { $terms[] = $tax->term_id; } } $args = array( 'post_type' => $params['post_type'], 'offset' => $params['offset'], 'posts_per_page' => 8, 'post__not_in' => $sticky, 'tax_query' => array( array( 'taxonomy' => $params['taxonomy'], 'field' => 'id', 'terms' => $terms, 'operator' => 'IN' ) ) ); $posts = get_posts( $args ); foreach($posts as $post) { $include[] = $post->ID; } $include = array_merge($sticky, $include); // convert values of the $include from string to int function sti($n) { settype($n, 'int'); return $n ; } $include = array_map("sti", $include); $query['post__in'] = $include; $query['posts_per_page'] = 8; $query['orderby'] = 'post__in'; // sort items based on the post__in value } return $query; }
Let us know if you need further assistance.
Best regards,
NikkoApril 16, 2019 at 4:38 pm #1091552I see that you did all that, but…. I see 7 posts on the homepage and not 8!
April 16, 2019 at 5:12 pm #1091594Hi Maureen,
I see 8 on my end.
I have posted a screenshot in private content on how it looks on my end.
Tested it with icognito browser also to make sure it’s not logged in.
Maybe you’ll need to flush out the cache.Best regards,
NikkoApril 16, 2019 at 5:41 pm #1091605Okay. Well I think I must delete my cache of my browser. I’ll look at it tomorrow! Thank you so far!!!
April 17, 2019 at 6:36 am #1091806Hi Maureen,
Thanks for the update, we’ll leave the thread open in case you should need any further help on the topic.
Best regards,
RikardApril 23, 2019 at 11:21 pm #1093763All is well!
Thank you!!!April 24, 2019 at 3:43 am #1093807Hi Maureen van Goethem,
Glad that we could help :)
Thanks for using Enfold and have a great day!Best regards,
Nikko -
AuthorPosts
- The topic ‘Sticky posts by category in blog grid’ is closed to new replies.