Tagged: 

Viewing 10 posts - 1 through 10 (of 10 total)
  • Author
    Posts
  • #1228100

    Hi.

    I set 4 posts to Sticky Posts. They are not displaying first on my posts page:

    Blog Page: https://blgenvironmental.com/blog/

    Sticky Posts: https://www.screencast.com/t/aKIisfbYr5Is

    Please advise on why my sticky posts are not displaying FIRST.

    • This topic was modified 4 years, 5 months ago by kurson.
    #1228552

    Hey kurson,

    Please have a look at the following thread:
    https://kriesi.at/support/topic/sticky-posts-in-grid-and-masonry-layouts/

    If you need further assistance please let us know.

    Best regards,
    Victoria

    #1229028

    That is WAY too long and confusing with several branch off conversations. By the end if the thread I couldn’t understand if this was about showing or hiding sticky plugins or removing duplicate posts…etc…

    ….

    Can you please just provide a simple answer like…This cannot be done in this mode, use this other mode

    OR

    Just provide code for an MU plugin that I can upload and use.

    Thanks.

    #1230187

    Hi,

    Sorry for the delay. We added this snippet in the functions.php file to adjust the posts query of the masonry element.

    add_filter('avia_masonry_entries_query', 'avia_masonry_entries_query_mod', 10, 2);
    function avia_masonry_entries_query_mod($query, $params) {
    	$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'] = 6;
    	$query['orderby'] = 'post__in'; // sort items based on the post__in value
    	return $query;
    }
    

    The sticky posts now display in the first page.

    Thank you for your patience.

    Best regards,
    Ismael

    #1231965

    HI.

    I appreciate the code.

    Q: Can I create an MU plugin for your code so it doesn’t get lost in future updates?

    If yes do I wrap your code with

    <?php

    YOUR CODE
    ?>

    Or do I need to do something else to your code to make ready as an MU plugin?

    A new issue may have been introduced inadvertently though.

    All posts should display on my posts page, beginning with the sticky posts. HOWEVER Only a limited number of my posts are now listed over 2 pages.

    I have 36 posts. Only 9 are displaying now.

    Q: is the new code applied interfering with my viewing all posts? If yes, can you please resolve this. If not, what may be causing this?

    • This reply was modified 4 years, 5 months ago by kurson.
    #1233354

    Hi,

    Sorry for the delay.

    1.) This might not be possible because MU plugins are loaded before the theme, so the filter doesn’t exist yet. You have to add it in the child theme’s functions.php file.

    2.) The filter limits the number of posts to 6 but it can be adjusted if necessary. Just look for the following line and adjust the value.

    $query['posts_per_page'] = 6;
    

    Best regards,
    Ismael

    #1236135

    Hi.

    If I add the code in the child theme’s functions.php file I receive the following error

    Your PHP code changes were rolled back due to an error on line 50 of file wp-content/themes/enfold/functions.php. Please fix and try saving again.

    Cannot redeclare avia_masonry_entries_query_mod() (previously declared in wp-content/themes/enfold-child/functions.php:15)

    Screenshot: https://tinyurl.com/y28daryj

    SIDE NOTE: When I activate the child theme, it looks NOTHING like the parent theme. I wouldn’t be able to use the child if it doesn’t mirror the parent settings save for the changes applied to functions.php. (I’m switching the site back t the parent theme)

    Note: If I choose grid view to avoid this issue altogether, How do I hide the following elements?

    Screenshot: https://www.awesomescreenshot.com/image/5140731/e81b62fb541def424ea854728301d889

    Notice: I have Blog Post Comment Count and Blog post Date set to do not display but they still display on the grid.

    Screenshot: https://tinyurl.com/yy8c5oxu

    Side Note 2: Appearances…customize breaks using the Enfold Theme. Screenshot: https://tinyurl.com/y36kxkla

    Please review notes in full and advise.

    • This reply was modified 4 years, 4 months ago by kurson.
    #1237196

    Hi,

    Cannot redeclare avia_masonry_entries_query_mod() (previously declared in wp-content/themes/enfold-child/functions.php:15)

    This just means that you added the avia_masonry_entries_query_mod function twice. Please make sure to remove the previous function before adding it in the child theme’s functions.php file.

    When I activate the child theme, it looks NOTHING like the parent theme.

    You have to import the parent theme options after activating the child theme. Please check the documentation for more info.

    // https://kriesi.at/documentation/enfold/child-theme/#toggle-id-4

    If you have any additional questions at this time we kindly ask that you open them up in a separate thread. The longer threads get in the forum, they become more difficult to support as they tend to drift off topic and they also make it troublesome for users trying to search for solutions. Keeping threads relevant to their original inquiry ensures that we can keep better track of what has been resolved and that users can more effectively find answers to similar issues they might be experiencing.

    Thanks!

    Best regards,
    Ismael

    #1237275

    Hi.

    This was not addressed:

    Note: If I choose grid view to avoid this issue altogether, How do I hide the following elements?

    Screenshot: https://www.awesomescreenshot.com/image/5140731/e81b62fb541def424ea854728301d889

    Notice: I have Blog Post Comment Count and Blog post Date set to do not display but they still display on the grid.

    Screenshot: https://tinyurl.com/yy8c5oxu

    How do I hide this section?

    #1237664

    Hi,

    We would really appreciate it if you will open these questions on a separate thread, to avoid confusion. Thank you for your patience.

    Best regards,
    Ismael

Viewing 10 posts - 1 through 10 (of 10 total)
  • You must be logged in to reply to this topic.