Text only version of website [closed]

If you wanted to remove all colorful text from your site, you could use a global CSS rule, as in

* {color:black !important; background-color:white !important}

which should turn all text to black on white background. (The ‘*” should apply to all CSS elements.) That wouldn’t get rid of images or other things, so you might add this for images

img {display:none !important;}

And then add additional elements as needed.

The problem with this is that it would affect the entire site, so you would need to have a way to change the theme on the fly just for the text-only users. That’s not easy to do, I think.

Maybe create another WP installation that uses the same database, but set up a theme for that new site that adds the above CSS and others as needed. The new site would be at https://www.example.com/textonly , for example. You’d also need to copy the plugins folder to the new site.

Probably some additional tweaks needed, but that might get you started.

Added

As I think about the duplicate site/same database idea, with the duplicate site using a different theme, there might be an issue.

The active theme is stored in wp-options table (I think), so a shared database couldn’t have a different theme.

So you would need to use a hook to change the theme name (and location) during the very first part of the page load process. You would still need a separate install with the shared database, but the hook would load a different theme.

Perhaps function that uses a hook that would change the theme name (and location) is all that is needed. The hook would look at the page’s query parameter (say https://www.example.com/some-page?theme=textonly )and inspect the ‘theme’ query parameter to decide which theme to load.

I don’t think that a query parameter that specifies a theme name is available in WP core – although that would be a great idea; very useful for testing new themes on an active site, which some people would like to do.

But perhaps my random thoughts might get you going into a direction that will meet your needs. I’d be interested in other thoughts about this.

Added More

So, digging around possible hooks, I came up with the ‘setup_theme‘ hook, in the wp-settings.php around line 407. A bit later in that file (around line 438) (line numbers are there from my copy/paste from the code):

// Load the functions for the active theme, for both parent and child theme if applicable.
439 if ( ! wp_installing() || 'wp-activate.php' === $pagenow ) {
440         if ( TEMPLATEPATH !== STYLESHEETPATH && file_exists( STYLESHEETPATH . '/functions.php' ) )
441                 include( STYLESHEETPATH . '/functions.php' );
442         if ( file_exists( TEMPLATEPATH . '/functions.php' ) )
443                 include( TEMPLATEPATH . '/functions.php' );
444 }

So, it would seem that by changing the TEMPLATEPATH and STYLESHEETPATH constants, we could change the theme being used.

So, psuedocode:

add_action('setup_theme', 'my_use_different_theme');
function my_use_different_theme() {
  TEMPLATEPATH = "path/to/the/other/theme/templates';
  STYLESHEETPATH = "path/to/the/other/theme/styles";
return;
}

Might allow you to create a function that would add the action if the query parameter contained a value like ‘theme=newtheme‘, where ‘newtheme‘ is name of the theme you want to use. Psuedocode:

$themename = "get/the/query/value";
if ($themename =='newtheme') {
  add_action('setup_theme', 'my_use_different_theme');
}

which would call our ‘my_use_different_theme‘ function if the query parameter for the page was theme=newtheme .