proper template(s).
thanks very much for this, I have read the articles and get the concepts there, but can you place php snippets directly into a post or blog (in the text editor tab). I have tried this but it does not work. I am unclear what proper templates are and how you use these snippets to display the variable’s content on a page… thanks
but can you place php snippets directly into a post or blog (in the text editor tab).
No. PHP will be stripped out of posts and pages created this way.
Please review this article:
http://codex.wordpress.org/Pages#Page_Templates
ah – I tried writing the php snippet into the text editor of the page – I wondered why it didn’t work!
so, this is my solution
- write a php function (well copy one from a helpful web article)
- create a shortcode
- insert into your theme’s function.php file
- place it before the final ?> in the functions.php file
(copy and save your theme’s original functions.php so if something messes up you can put the original back in place)
this is my addition which creates a Welcome message naming the logged in user by adding the shortcode [welcome_user] to a post or page.
/**
* user display name - SR Feb 13
*/
function displayName () {
global $user_identity;
get_currentuserinfo();
echo "Welcome " . $user_identity;
}
/**
* create shortcode to display name on page - SR Feb 13
*/
add_shortcode('welcome_user', 'displayName');
I found out about creating short codes here
I am new to WP and to PHP, but am enjoying the flexibility and customization that WP offers. Please do comment on my attempts, there is much more I need to learn…