[Resolved] Related Post in Generatepress Using WP Show Post Plugin?

Home Forums Support [Resolved] Related Post in Generatepress Using WP Show Post Plugin?

Home Forums Support Related Post in Generatepress Using WP Show Post Plugin?

Viewing 13 posts - 1 through 13 (of 13 total)
  • Author
    Posts
  • #1095367
    Suraj Katwal

    Actually I want to use WP Show Post plugin to display related posts in the single post after content.
    https://gpsites.co/merch/the-single-post/ ==> I was following the tutorial from the link. I didn’t understand the

    You will see in this line the ‘related‘ list name:

    $list = get_page_by_title( 'related', 'OBJECT', 'wp_show_posts' );

    What I have done until now.
    1. Install WPSP Plugin
    2. Added a New List.
    3. Used Hook to insert PHP Code.
    But got error.
    Thanks

    #1095657
    David
    Staff
    Customer Support

    Hi there,

    you need to create a WP Show Posts list, and the Title you give the list must be related

    #1096598
    Suraj Katwal

    Ya, I did it. Now I can show Related Posts but how to open all the links in a new tab?
    Thanks

    #1097168
    Tom
    Lead Developer
    Lead Developer

    You would have to use javascript for that at the moment:

    $( document ).on( 'click', '#wpsp-123 a', function(e) { 
        e.preventDefault(); 
        var url = $(this).attr('href'); 
        window.open(url, '_blank');
    });

    123 should be replaced with your list ID.

    #1097207
    Suraj Katwal

    The code is not working.
    WPSP List id 1002

    $( document ).on( 'click', '#wpsp-1002 a', function(e) { 
        e.preventDefault(); 
        var url = $(this).attr('href'); 
        window.open(url, '_blank');
    });

    What I did
    1. Elements > New Hook
    2. <script>Above Code</script>
    3. Settings > Hook > WP_Footer
    4. Display Rules > All Singular

    Thanks

    #1097213
    Suraj Katwal

    There was an error on Console
    Uncaught TypeError: $ is not a function
    So fixed the error with small tweak

    <script>
    	jQuery(function($){
    		$( document ).on( 'click', '#wpsp-1002 a', function(e) { 
        e.preventDefault(); 
        var url = $(this).attr('href'); 
        window.open(url, '_blank');
    });
    });
    </script>

    Thanks

    #1097382
    Tom
    Lead Developer
    Lead Developer

    Sorry about that! Glad it’s working πŸ™‚

    #1097672
    Suraj Katwal

    Yeah!!! Thank you for the wonderful support. πŸ™‚

    #1097955
    Tom
    Lead Developer
    Lead Developer

    No problem! πŸ™‚

    #1110711
    Suraj Katwal

    Now I am back with the tutorials on how to display related posts in GeneratePress Theme.
    I hope this will help other users.
    https://www.wplogout.com/display-related-posts-in-generatepress-theme/

    Thank you.

    #1110755
    Leo
    Staff
    Customer Support

    Thanks for sharing!

    #1266388
    Suraj Katwal

    Can I get the code to add related posts using tags? As we have code to display related posts using category.

    Thank You

    #1266467
    Suraj Katwal

    Got the code, Thanks

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