• Resolved Koli14

    (@koli14)


    Hi!

    Abstract:
    I want to create a different layout for a CPT which already has a single.php.

    The case:
    I have a Custom Post Type ‘Performances’. It has a Custom Field ‘Pictures’. I have a single-performance.php, to show all the information about a ‘Performance’.
    I also created a ‘Gallery’ page, which has an ACF Field: Relationship (with multiple values). In this Gallery page i list the ‘Performances’ featured image, and title, which are set in the ACF Relationship field.
    Now they are links to the ‘single-performance.php’, but i want to show just the Pictures of the ‘Performance’ if they click on them in the Gallery page, but i don’t find a solution for that.
    Any advice?
    Thanks: Kolos

Viewing 1 replies (of 1 total)
  • Thread Starter Koli14

    (@koli14)

    inside page-gallery.php something like that instead of permalink only
    add_query_arg( 'gallery_only', 'yes', get_permalink() );

    inside your plugin or functions.php add it to the public query variables

    function add_custom_query_var( $vars ){
      $vars[] = "gallery_only";
      return $vars;
    }
    add_filter( 'query_vars', 'add_custom_query_var' );

    inside single-performance.php get value that you pass when it come from page-gallery.php
    $my_gallery_only = get_query_var( 'gallery_only' );

    use after that if ($my_gallery_only == 'yes')
    to switch between your normal-all and gallery-only view

    Thanks to mediawerk!

Viewing 1 replies (of 1 total)
  • The topic ‘Creating two layout for the same CPT’ is closed to new replies.