I have an interesting challenge that I’m coming up short on (I’m not a WordPress plugin developer). I am using a site that has OptimizePress as a theme. Optimizepress calls the_content
many times in building a page.
I want to include a little code snippet in the body of every page.
if ( function_exists( "transposh_widget" ) ) {
transposh_widget(array(), array(
'title' => 'Translation',
'widget_file' => 'flags/tpw_flags_css.php',
) );
}
That shows a couple of flags and lets you switch languages on the site. So I need a div set to fixed position / 0,0 (I can adjust later for looks) that has that in it.
Other than outputting something in the_content
, which seems to be the popular way to do this, what is the best way to achieve getting this on every page of a wordpress site?
Update
The code below started – here was my final code that output flags only in the top right corner of the site on every page.
<?php
/*
Plugin Name: Transposh Flags in Header
Description: Embed Transposh Header Code (in Footer of Page)
*/
function insert_my_footer() {
echo '<div style="display:block; top:30px; right: 50px; position: fixed; color:white;">';
if (function_exists("transposh_widget")) {
transposh_widget(array(),
array('title'=>'',
'widget_file' => 'flags/tpw_flags.php') );
}
echo '</div>';
}
add_action('wp_footer', 'insert_my_footer');
?>
OK, I’m not at all familiar with transposh_widget, so I don’t really know where or when you want this code to run. However, it’s easy to make a plugin that adds things to the bottom of a page, so perhaps you could try that.
Here’s a basic plugin to get you started:
To install this plugin, save it in your
/wp-content/plugins
directory (with appropriate ownership and permissions), and then activate it via the WordPress admin pages.