• Resolved revistausina

    (@revistausina)


    Hi everyone,

    Does any one know how to change position of related posts to the sidebar?

    I added to my post template .php file the following code:

    <?php echo do_shortcode([jetpack-related-posts]); ?>

    and also added to functions.php the code:

    
    function jetpackme_remove_rp() {
        if ( class_exists( 'Jetpack_RelatedPosts' ) ) {
            $jprp = Jetpack_RelatedPosts::init();
            $callback = array( $jprp, 'filter_add_target_to_dom' );
            remove_filter( 'the_content', $callback, 40 );
        }
    }
    add_filter( 'wp', 'jetpackme_remove_rp', 20 );

    But the page instead of showing the Related Posts on the sidebar, just says “Array”.

    I’m not sure why.

    Any help is really appreciated! Thanks

    The page I need help with: [log in to see the link]

Viewing 12 replies - 1 through 12 (of 12 total)
  • Plugin Contributor James Huff

    (@macmanx)

    That indeed should work. For the post template, try the full:

    if ( class_exists( 'Jetpack RelatedPosts' ) ) {
     
    echo do_shortcode( '[jetpack-related-posts]' );
    }

    If that doesn’t work, is your site using any custom post types or anything for content besides standard posts?

    Thread Starter revistausina

    (@revistausina)

    Thanks for the answer. Now instead of “Array”, a black line appeared.

    I’m using a post template that calls for this sidebar:

    ?>
    		<div id="secondary-recomenda" class="widget-area-recomenda" role="complementary-right">
    			<?php do_action( 'before_sidebar' ); ?>
    			<?php if ( ! dynamic_sidebar( 'recomenda' ) ) : ?>
    
    				<?php if ( class_exists( 'Jetpack RelatedPosts' ) ) {
     
    echo do_shortcode( '[jetpack-related-posts]' );
    } ?>
    
    			<?php endif; // end sidebar widget area ?>
    		</div><!-- #secondary .widget-area -->
    • This reply was modified 5 years, 6 months ago by revistausina.
    Plugin Contributor James Huff

    (@macmanx)

    Hm, that should indeed work. Please contact us via https://jetpack.com/contact-support/?rel=support so we can take a closer look.

    Thread Starter revistausina

    (@revistausina)

    THanks, it’s working now. I had some CSS that was hiding it by mistake.

    Thread Starter revistausina

    (@revistausina)

    Btw, do you know how I could make the related posts display one after the other?

    I tried to use clear: both, and display: block, but for some reason it’s not working. All four elements are squeezed right next to each other. Instead, I would like them to appear one after the other, but despite many changes on the CSS it hasn’t worked it out ??

    Plugin Support KokkieH

    (@kokkieh)

    Hi there,

    This is on the post, https://revistausina.com/pensamento/antimateria-o-universo-sem-espelho/, correct? I see the related posts underneath one another on that page. Have you managed to figure this out?

    If you still see them side by side, please check if clearing your browser cache makes any difference.

    Thread Starter revistausina

    (@revistausina)

    Hey KokkieH

    Yeah, I had figured it out, by changing from grid to list, but for some reason it changed back and now I cannot go to Customize and select grid. When I try to go to related posts tab at Customize, it says “Please visit a single post view to reveal the customization options”

    Any idea why?

    Thanks

    Plugin Contributor James Huff

    (@macmanx)

    We are aware of that issue, but don’t have a fix yet. You can follow along at https://github.com/Automattic/jetpack/issues/7726

    Thread Starter revistausina

    (@revistausina)

    Hi! I understand there is an issue with the visual customizer selector. But where in JetPack plugin can I change the settings to list instead of grid? Can I add something to my functions.php that does that?

    Thanks again

    Plugin Support KokkieH

    (@kokkieh)

    I don’t know of a way to do it by directly modifying the code, no.

    Have you tried the workaround as shown in the video at the link James linked to above? Go to the Customizer, and then in the Customizer click on any published post to view the single post in the Customizer preview. Then the options should become visible.

    Thread Starter revistausina

    (@revistausina)

    Yes, I have. But regardless of the post I select, it always says “Please visit a single post view to reveal the customization options”

    It’s really important for me to display it as a list, otherwise I won’t be able to use this feature anymore. I guess I will start looking for a way to change it by code. If anyone knows it, it will be very appreciated.

    Plugin Contributor James Huff

    (@macmanx)

    At the moment, the published work-around is the only option we have. If it’s not working under your current theme, it might work to at least set the option under a different theme (like Twenty Nineteen), then the option will still be set when you switch back to your preferred theme.

Viewing 12 replies - 1 through 12 (of 12 total)
  • The topic ‘Related posts on sidebar’ is closed to new replies.