WAP capability | Permalink redirect to function | Post-content enhancement
-
Hi everyone!
Unfortunately the search didn’t help me too much since I do not really know what to search for.
I have this idea to also serve my latest post as a wml file to make this available to old WAP-capable phones (wikipedia).
So I started to make a php-file that puts out a wml for this task. But well it didn’t work as expected.First problem: I get this error message when opening up the php-file directly:
Warning: session_start(): Cannot send session cache limiter – headers already sent […]
Thus I assume it would be best to have a function that I can put in my theme’s functions.php that creates my file once it is demanded, right?
But how do I create such virtual files (I know WordPress does so with the robot.txt)?Second problem: I need a url that triggers the function.
For example: If someone goes to “https://www.mysite.com/wap” the function should be triggered and the virtual file should be sended.Third problem (probably the easiest): Since these old phones cannot handle images and are only capable of very basic mark-up I want to fetch only the text of a post without any formatting nor images (no caption, no h2, no nothing). How do I do that?
This is what I have so far. Hacked together from different sources. I currently resides in my theme folder. I put this here just to get you the idea of what I’m trying to do:
<?php header('text/vnd.wap.wml;charset=utf-8'); echo "<?xml version=\"1.0\" encoding=\"UTF-8\" ?>"; require('../../../wp-config.php'); /** * Extract the base path out of the current path */ function hide_server_url( $path ) { $site_url = get_site_url(); if (substr($path, 0, strlen($site_url)) != $site_url) return $path; $trimmed = substr($path, strlen($site_url)); while (substr($trimmed,0,1) == '/') $trimmed = substr($trimmed,1); while (substr($trimmed, strlen($trimmed)-1) == '/') $trimmed = substr($trimmed, 0, strlen($trimmed)-1); return $trimmed; } ?> <!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.3//EN" "https://www.wapforum.org/DTD/wml13.dtd"> <wml> <card id="home" title="Econore"> <img src="library/images/econore.wbmp" /> <p>WELCOME<br />The News:</p> <?php query_posts('post_type=page&showposts=1&orderby=menu_order&post_status=publish'); while (have_posts()) : the_post(); ?> <page id="<?php the_ID(); ?>" path="<?php echo hide_server_url(get_permalink()); ?>" template="<?php echo get_post_meta($post->ID,'_wp_page_template',true); ?>"> <h1><![CDATA[<?php echo $post->post_title; ?>]]></h1> <p><![CDATA[<?php echo $post->post_content; ?>]]></p> </page> <?php endwhile; wp_reset_query(); ?> </card> </wml>
- The topic ‘WAP capability | Permalink redirect to function | Post-content enhancement’ is closed to new replies.