WordPress.org

Ready to get started?Download WordPress

Forums

[resolved] wp-mobile: pages do not display text (3 posts)

  1. kalico
    Member
    Posted 7 years ago #

    Just activated this plug in and I am thrilled! Just one problem -- my pages do not show correctly. Posts look fine, but pages don't display any content. I wonder if my theme is missing a hook or some vital code -- I created the theme myself, as a total novice. Any thoughts?

    Marci :)

  2. kalico
    Member
    Posted 7 years ago #

    I have been poring over the code, to no avail, and have found no similar issues posted in the support forum.

    I figure there is something about my Pages that is causing them not to display correctly using the mobile edition index template. But what?

    Most of my pages are assigned to a custom template, but according to the hierarchy, they should look for the index.php template eventually. And really, they are doing that -- they are using the index.php supplied by wp-mobile theme. But the content does not display -- all the links display (links to other pages), even a link to the page I am trying to view...and no next/previous links, which should not, because it is a page....all of this works perfectly, but the content of the page does not display.

    I admit my pages are relatively complex, and some should probably not even be displayed at all in a mobile environment. For example, some pages rely so heavily on a template that they have no content of their own apart from the template. I can work through that later, by suppressing those pages.

    But there ARE some pages that DO have content in them, which should display regardless of the template, and even these do not display content.

    I would love some direction here, this is the best thing since sliced bread otherwise, and deserves to be utilized!

    Thanks.....

  3. kalico
    Member
    Posted 7 years ago #

    RESOLVED

    I am pleased to report that I have resolved this problem. I was a little scared of the code, since I know next to nothing about developing for the mobile web but it turned out to be all in the theme files!

    In reading over the main theme page (index.php, which serves all posts and pages of the mobile site) I discovered that in all the conditional statements, there were lots of if !is_page() ("!" meaning "not") but never if is_page(). So I added it, and voila, I had page content!

    Here is what I did. For the sake of brevity, and because code never seems to come out quite right in the forum, and because I imagine there are various versions out there which might differ from mine, I will describe this in detail rather than try to get the code exactly right. Your mileage may vary. :)

    About line 61 in index.php of the wp-mobile theme, there begins an "if/else" code block. It begins "if is_category()"

    Scroll down a bit to the first "else if" statement, which is "else if is_day()". Before this, you need an else if statement for the conditional is_page.

    Because I am not a php pro, I just copied the "is_day" statement, starting with the "else" and ending with the "}" (which can be seen just before the next "else"). Then I pasted it above the existing "if is_day" conditional.

    I changed "is_day" to "is_page".

    Then I changed the rest of the statement to read like this:

    <h1><?php the_title(); ?></h1>
    <?php the_content(); ?>

    The actual code I inserted at line 61 looks like this:

    else if (is_page()) {
    ?>
    	<h1><?php the_title(); ?></h1>
    	<?php the_content(); ?>
    <?php
    	}

    That was it! I tested on my cell phone, running an old version of Openware, and the pages are showing just fine now. I also tested on an Openwave emulator, which was free. Check the list of emulators on this page for other phones: http://pc.dev.mobi/?q=node/71

    Caveats...

    As mentioned earlier, I do have some pages which are not really good for viewing on mobile. These are pages that rely completely on a page template for their content. If I open them in Manage>>Pages they are blank. In order for them to render well on a mobile device, they apparently need to have content, not just a template full of php code. This may or may not be true for everyone, it's just my experience so far.

    To resolve the issue of pages that should not be viewed by a mobile browser, I have simply changed the wp_list_pages template tag in index.php to exclude those pages. (see http://codex.wordpress.org/Template_Tags/wp_list_pages)

    I sure hope this helps someone else down the line. This is a sweet little plugin. I'm thrilled to finally make full use of it. Thanks to Alex King for the great work!

Topic Closed

This topic has been closed to new replies.

About this Topic