Viewing 10 replies - 1 through 10 (of 10 total)
  • Plugin Author keesiemeijer

    (@keesiemeijer)

    Hi Atif Hanif

    Try it with this in your (child) theme’s functions.php file:

    add_filter( 'related_posts_by_taxonomy_shortcode_atts', 'rpbt_exclude_sticky' );
    add_filter( 'related_posts_by_taxonomy_widget_args', 'rpbt_exclude_sticky' );
    
    function rpbt_exclude_sticky( $args ) {
    	$sticky = get_option( 'sticky_posts' );
    	if ( !empty( $sticky ) ) {
    		$args['exclude_posts'] = $sticky;
    	}
    
    	return $args;
    }

    Thread Starter Atif Hanif

    (@atif-hanif)

    thaks but this code is not working…

    Plugin Author keesiemeijer

    (@keesiemeijer)

    Can you explain a little bit more.

    It shows related posts, but the sticky posts are not excluded?

    Thread Starter Atif Hanif

    (@atif-hanif)

    I want 1 previous post and 1 next post on current post.
    Check this link:
    at the bottom of the page below the video.

    Thread Starter Atif Hanif

    (@atif-hanif)

    I want 1 previous post and 1 next post on current post.
    Check this link:
    https://cheats4game.com/candy-crush-saga/level-1489/
    See below the video.

    Thread Starter Atif Hanif

    (@atif-hanif)

    I want 1 previous post and 1 next post on current post.

    Plugin Author keesiemeijer

    (@keesiemeijer)

    What have the previous and next post have to do with this plugin?

    How are you using this plugin? With the shortcode, widget or some other way?

    Thread Starter Atif Hanif

    (@atif-hanif)

    I am using this code with shortcode

    Plugin Author keesiemeijer

    (@keesiemeijer)

    Can you show me the shortcode you’re using?

    Thread Starter Atif Hanif

    (@atif-hanif)

    add_filter( 'the_content', 'add_related_posts_after_post_content' );
    function add_related_posts_after_post_content( $content ) {
    
        //check if it's a single post page.
        if ( is_single() ) {
    
            // check if we're inside the main loop
            if ( in_the_loop() && is_main_query() ) {
    
                // add your own attributes here (between the brackets [ ... ])
                $shortcode = '[related_posts_by_tax before_title="<h3 class=".rpbt_shortcode h3">" before_shortcode="<div class="rpbt_shortcode">" title="Related Posts" taxonomies="all" posts_per_page="5" order="DESC" orderby="post_date" format="links" after_shortcode="</div>" after_title="</h3>"]';
    
                // add the shortcode after the content
                $content = $content . $shortcode;
            }
        }
    
        return $content;
    }
Viewing 10 replies - 1 through 10 (of 10 total)
  • The topic ‘ignore sticky post’ is closed to new replies.