• Hi there,
    Using Code Snippets and Conditional Themes I expected I could switch themes using the following:

    // Switch to Twenty Sixteen theme when we being on page_id.
    Conditional_Themes_Manager::register( ‘twentyten’, function() {
    $id = get_the_ID();
    return ( $id== “153”);
    } );

    Other switches does work ,like
    // Switch to Twenty Sixteen theme when we being on 2015.
    Conditional_Themes_Manager::register( ‘twentyten’, function() {
    return ( date( ‘Y’ ) == 2015 );
    } );
    But the switch based on the page id does not.
    How can I get this to work properly?
    I also tried with code like
    global $wp_query;
    $postID = $wp_query->post->ID;
    return ( $postID == 153 );
    but it does not seems to listen to me ??

    https://www.ads-software.com/plugins/wp-conditional-themes/

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Nashwan D

    (@alex-ye)

    I haven’t think about this case!

    Because wp() function called after the ‘setup_theme’ action, your idea will not work.

    if you are using the Default Permalinks structure, you can use a code snippet like this one.

    Conditional_Themes_Manager::register( 'twentyten', function() {
    	return ( isset( $_GET['p'] ) && $_GET['p'] == 153 );
    } );

    I will make it possible in the next version. Thank you. ??

    Thread Starter minddigger

    (@minddigger)

    Hmmmm also tried that, but no response.
    It looks like something is blocking it.
    And sometimes unexpected (without any reason) the theme switch to the twentyten theme. Like it then reaches the code in Codesnippet.
    Very weard

    Plugin Author Nashwan D

    (@alex-ye)

    hmmm.. it works fine for me.
    Try to create another plugin file?

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘How can I switch using a page_id?’ is closed to new replies.