WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] [closed] setting different static home pages for different themes (5 posts)

  1. jmusgrave918
    Member
    Posted 1 year ago #

    http://www.chocolatefountainproductions.com

    i am using a different theme for desktop and mobile site (m.choc...)

    I am using the mobile switcher plugin to detect mobile devices and automatically implement my mobile theme.

    What i want to do is show a different type of home page for each theme.

    for example the desktop version shows a static home page.

    but when accessed from a mobile device it automatically implements my mobile theme and i to display my latest posts as the home page

    how can i accomplish this? any help would be greatly appreciated!

  2. David Beja
    Member
    Posted 1 year ago #

    Hi jmusgrave918,

    My suggestion would be to change what is shown on front page in functions.php of each theme.

    For example, in the desktop version you would add something like this (in functions.php of desktop theme):

    add_action( 'after_setup_theme', 'change_theme_frontpage' );
    function change_theme_frontpage() {
    	$frontpage = get_page(2);   // 2 is the id of the page you want to show
    	update_option('show_on_front', 'page');    // show on front a static page
    	update_option('page_on_front', $frontpage->ID);
    }

    And in the functions.php of the mobile theme:

    add_action( 'after_setup_theme', 'change_theme_frontpage' );
    function change_theme_frontpage() {
    	update_option('show_on_front', 'posts');    // show on front latest posts
    }
  3. jmusgrave918
    Member
    Posted 1 year ago #

    thanks!

  4. mikemelchiot
    Member
    Posted 1 year ago #

    Hi,

    I have a bit like the same problem but I'm using a parallax theme for my desktop theme.
    Because of that, I don't have a static homepage, neither a blog on my homepage.

    When I only put in the code into my functions.php of my mobile theme, it will overwrite the main settings for my desktop theme, where none are selected.

    Website is; http://steenbergenco.nl/

    I removed the code but can replace it anytime.

    Hope someone could help.

    Mike

  5. esmi
    Forum Moderator
    Posted 1 year ago #

    @ikemelchiot: As per the Forum Welcome, please post your own topic.

Topic Closed

This topic has been closed to new replies.

About this Topic