Home > Questions > Questions

Posts by onokazu

1 vote
0 answers
  • demo asked 2 years ago
1 vote
I’ve been looking for a Q&A plugin for wordpress for a few weeks now, researched about ...
  • demo asked 7 years ago
  • last active 7 years ago
5 votes

Usually you can just upload your plugin to the wp-content\plugins directory. if you dont have access to this directory via sftp I’m afraid you may be stuck.

NOTE: This answer was originally posted at StackOverflow.com by Toby Allen

  • Cindy answered 10 years ago
1 vote

For those unsure of how to use PDO (coming from the mysql_ functions), I made a very, very simple PDO wrapper that is a single file. It exists to show how easy it is to do all the common things applications need done. Works with PostgreSQL, MySQL, and SQLite.

Basically, read it while you read the manual to see how to put the PDO functions to use in real life to make it simple to store and retrieve values in the format you want.

I want a single column

$count = DB::column('SELECT COUNT(*) FROM `user`);

I want an array(key => value) results (i.e. for making a selectbox)

$pairs = DB::pairs('SELECT `id`, `username` FROM `user`);

I want a single row result

$user = DB::row('SELECT * FROM `user` WHERE `id` = ?', array($user_id));

I want an array of results

$banned_users = DB::fetch('SELECT * FROM `user` WHERE `banned` = ?', array(TRUE));

NOTE: This answer was originally posted at StackOverflow.com by Xeoncross

  • Mary answered 7 years ago
2 votes

The WP global variable $pagename should be available for you, I have just tried with the same setup you specified.

$pagename is defined in the file wp-includes/theme.php, inside the function get_page_template(), which is of course called before your page theme files are parsed, so it is available at any point inside your templates for pages.


  • Although it doesn’t appear to be documented, the $pagename var is only set if you use permalinks. I guess this is because if you don’t use them, WP doesn’t need the page slug, so it doesn’t set it up.

  • $pagename is not set if you use the page as a static front page.

  • This is the code inside /wp-includes/theme.php, which uses the solution you pointed out when $pagename can’t be set:

    $pagename = get_query_var('pagename');
    if ( !$pagename && $id > 0 ) {
    // If a static page is set as the front page, $pagename will not be set. Retrieve it from the queried object
    $post = $wp_query->get_queried_object();
    $pagename = $post->post_name;

NOTE: This answer was originally posted at StackOverflow.com by AJJ

  • Martha answered 9 years ago
  • last active 9 years ago
2 votes

Thanks again for choosing SabaiDiscuss as your preferred discussion tool!

Showing 7 results