Support » Plugin: Seriously Simple Podcasting » Clicking tag or author results in "Nothing found"

Viewing 6 replies - 1 through 6 (of 6 total)
  • Plugin Contributor Hugh Lashbrooke

    (@hlashbrooke)

    The reason for this is that, by default, WordPress only shows posts on those pages and not any other post type. In this case you will be using the podcast post type so it won’t show on that page. To work around this you will need to add a bit of custom code to make sure your podcast episodes show on those pages. This snippet should work for you – I haven’t tested it, but if you paste this into your theme’s functions.php file then it will add your podcast episodes to the author pages and the tag archives:

    add_action( 'pre_get_posts, 'show_podcast_episodes_in_archives', 10, 1 );
    function show_podcast_episodes_in_archives ( $query ) {
    
      if ( is_admin() || ! $query->is_main_query() ) {
        return;
      }
    
      if( is_author() || is_tax( 'post_tag' ) ) {
        $post_types = ssp_post_types();
        if( ! empty( $post_types ) ) {
          if( ! in_array( 'post', $post_types ) {
            $post_types[] = 'post';
          }
          $query->set( 'post_type', $post_types );
        }
      }
    
    }

    Hope that helps!

    If you need further customisation assistance I recommend finding a WordPress developer to help you with anything more.

    Cheers,
    Hugh

    Thread Starter Oskar Modig

    (@punchlinern)

    Thanks for your assistance, but it doesn’t work.
    When I added you code the entire site goes down. I get a blank page wherever I try to browse.

    Thread Starter Oskar Modig

    (@punchlinern)

    Oh, there was a missing quote in the first row.

    Thread Starter Oskar Modig

    (@punchlinern)

    Sorry for spamming this thread. Adding a quote to the first row didn’t help. I still get the blank page.

    I tried commenting different parts of the code, and my page rendered when I commented the row
    if( ! in_array( 'post', $post_types ) {
    (and the closing bracket after the array push).
    Do you have any idea why?

    I got this to work by adding an is_tag() to the code:

    add_action( 'pre_get_posts', 'show_podcast_episodes_in_archives', 10, 1 );
    function show_podcast_episodes_in_archives ( $query ) {
    
      if ( is_admin() || ! $query->is_main_query() ) {
        return;
      }
    
      if( is_author() || is_tax( 'post_tag' ) ||  is_tag()  ) {
        $post_types = ssp_post_types();
        if( ! empty( $post_types ) ) {
            $post_types[] = 'podcast';
          $query->set( 'post_type', $post_types );
        }
      }
    
    }
    Thread Starter Oskar Modig

    (@punchlinern)

    Thank you adastra! That did it!

Viewing 6 replies - 1 through 6 (of 6 total)
  • The topic ‘Clicking tag or author results in "Nothing found"’ is closed to new replies.