qid int64 4 8.14M | question stringlengths 20 48.3k | answers list | date stringlengths 10 10 | metadata list | input stringlengths 12 45k | output stringlengths 2 31.8k |
|---|---|---|---|---|---|---|
40,675 | <p>I have a plugin that outputs username after login, I want it to display first name instead. Here is the code that does it.</p>
<pre><code> global $userdata,$user_identity;
get_currentuserinfo();
if ($userdata->ID>0) {
// User is logged in
echo '<div class="l... | [
{
"answer_id": 40669,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 6,
"selected": true,
"text": "<p>Add the <code>filemtime()</code> of your stylesheet as version parameter. Lets say, your default stylesheet is in <code... | 2012/01/30 | [
"https://wordpress.stackexchange.com/questions/40675",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12244/"
] | I have a plugin that outputs username after login, I want it to display first name instead. Here is the code that does it.
```
global $userdata,$user_identity;
get_currentuserinfo();
if ($userdata->ID>0) {
// User is logged in
echo '<div class="login">' . $before_widget... | Add the `filemtime()` of your stylesheet as version parameter. Lets say, your default stylesheet is in `css/default.css` and `css/default.min.css` ([not `style.css`](https://wordpress.stackexchange.com/a/111505/73)). When we register a stylesheet on `wp_loaded` ([not `init`](https://wordpress.stackexchange.com/a/67635/... |
40,686 | <p>I have files in my theme called <code>single-audio.php</code> and <code>single video.php</code>, but when I click on an audio post-format or video post-format wordpress uses the <code>index.php</code> instead of my <code>single-audio.php</code> or <code>single-video.php</code> files. Any ideas?</p>
| [
{
"answer_id": 40694,
"author": "rexposadas",
"author_id": 413,
"author_profile": "https://wordpress.stackexchange.com/users/413",
"pm_score": 0,
"selected": false,
"text": "<p>If I understand your question correctly, you would need to do the following: </p>\n\n<ol>\n<li>Add a new page v... | 2012/01/30 | [
"https://wordpress.stackexchange.com/questions/40686",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11186/"
] | I have files in my theme called `single-audio.php` and `single video.php`, but when I click on an audio post-format or video post-format wordpress uses the `index.php` instead of my `single-audio.php` or `single-video.php` files. Any ideas? | There is a huge difference between [Post Formats](http://codex.wordpress.org/Post_Formats) and [Post Types](http://codex.wordpress.org/Post_Types). I am assuming you are using post formats, which do not have a default template file for you to use.
What you can do though is use [`has_post_format()`](http://codex.wordpr... |
40,688 | <p>My plugin needs to introduce a number of interfaces to Wordpress for the public traffic. What is the best way of introducing new interfaces?</p>
| [
{
"answer_id": 40694,
"author": "rexposadas",
"author_id": 413,
"author_profile": "https://wordpress.stackexchange.com/users/413",
"pm_score": 0,
"selected": false,
"text": "<p>If I understand your question correctly, you would need to do the following: </p>\n\n<ol>\n<li>Add a new page v... | 2012/01/30 | [
"https://wordpress.stackexchange.com/questions/40688",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7898/"
] | My plugin needs to introduce a number of interfaces to Wordpress for the public traffic. What is the best way of introducing new interfaces? | There is a huge difference between [Post Formats](http://codex.wordpress.org/Post_Formats) and [Post Types](http://codex.wordpress.org/Post_Types). I am assuming you are using post formats, which do not have a default template file for you to use.
What you can do though is use [`has_post_format()`](http://codex.wordpr... |
40,699 | <p>I'm trying to display a table format of the top authors listed by the most recent posts. It should display the author, its avatar, the date, and the title of the post (with a link). </p>
<p>I have it listing the top authors along with the avatar. But it won't display the title of the post or the correct date. </... | [
{
"answer_id": 40702,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>Do a <code>WP_User_Query</code> and then go through the results:</p>\n\n<pre><code>$wp_user_search = new WP_User_Qu... | 2012/01/30 | [
"https://wordpress.stackexchange.com/questions/40699",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5175/"
] | I'm trying to display a table format of the top authors listed by the most recent posts. It should display the author, its avatar, the date, and the title of the post (with a link).
I have it listing the top authors along with the avatar. But it won't display the title of the post or the correct date.
Here's what I... | Update: To get around this, I changed it up. It's probably not an ideal fix but it gave me what I needed.
```
// Selects from tables wp_users and wp_posts, selecting published posts and ordering by its post_date, limited to 10
$querystr = "SELECT * from wp_users, wp_posts WHERE wp_users.ID = wp... |
40,706 | <p>I'm having a problem with updating the post_date in a custom function I've written.</p>
<p>I'm trying to change the "post_date" to my custom "meta_date" value.</p>
<p>Here is the function:</p>
<pre><code>function cfc_reset_postdate( $data, $postarr ) {
// If it is our form has not been submitted, so we dont want... | [
{
"answer_id": 40702,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>Do a <code>WP_User_Query</code> and then go through the results:</p>\n\n<pre><code>$wp_user_search = new WP_User_Qu... | 2012/01/31 | [
"https://wordpress.stackexchange.com/questions/40706",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12597/"
] | I'm having a problem with updating the post\_date in a custom function I've written.
I'm trying to change the "post\_date" to my custom "meta\_date" value.
Here is the function:
```
function cfc_reset_postdate( $data, $postarr ) {
// If it is our form has not been submitted, so we dont want to do anything
if(define... | Update: To get around this, I changed it up. It's probably not an ideal fix but it gave me what I needed.
```
// Selects from tables wp_users and wp_posts, selecting published posts and ordering by its post_date, limited to 10
$querystr = "SELECT * from wp_users, wp_posts WHERE wp_users.ID = wp... |
40,709 | <p>I'm at my wits end. I'm beginning a project that may involve using an action hook in WP that is not well-documented: edit_{$taxonomy}</p>
<p>I'm trying to determine exactly when this hook runs, so I just wrote a basic function with an echo for testing. Then, I added it to functions.php in a child theme. Invariably,... | [
{
"answer_id": 40723,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p><sup>Please have a read on how to work with filters and actions (I'm not repeating it here).</sup></p>\n\n<h3>The f... | 2012/01/31 | [
"https://wordpress.stackexchange.com/questions/40709",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12600/"
] | I'm at my wits end. I'm beginning a project that may involve using an action hook in WP that is not well-documented: edit\_{$taxonomy}
I'm trying to determine exactly when this hook runs, so I just wrote a basic function with an echo for testing. Then, I added it to functions.php in a child theme. Invariably, the line... | Please have a read on how to work with filters and actions (I'm not repeating it here).
### The filter in a theme or plugin
```
// inside /wp-includes/taxonomy.php on line 1586
$value = apply_filters("edit_{$taxonomy}_{$field}", $value, $term_id);
// inside some theme file that runs before - best on functions.php du... |
40,711 | <pre><code>Warning: Cannot modify header information - headers already sent by (output started at /forums/vb/search/searchcontroller/version.php:91) in /wp-includes/functions.php on line 862
</code></pre>
<p>I am not sure what this error means. Can someone help me out?</p>
<p>Line 862 from functions.php is...</p>
<p... | [
{
"answer_id": 40712,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Well, there is some output in <code>/forums/vb/search/searchcontroller/version.php:91</code>. An <code>echo</code>, an... | 2012/01/31 | [
"https://wordpress.stackexchange.com/questions/40711",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7877/"
] | ```
Warning: Cannot modify header information - headers already sent by (output started at /forums/vb/search/searchcontroller/version.php:91) in /wp-includes/functions.php on line 862
```
I am not sure what this error means. Can someone help me out?
Line 862 from functions.php is...
`setcookie( 'wp-settings-time-' ... | Well, there is some output in `/forums/vb/search/searchcontroller/version.php:91`. An `echo`, an empty line, an [UTF-8 BOM](http://en.wikipedia.org/wiki/Byte_order_mark#UTF-8) or something similar.
PHP sends the response headers *before* the output starts, and it sends those headers just *once*. So you cannot send a ... |
40,717 | <p>Using a self-hosted install updated to 3.3.1, when I go to the edit post screen, the editor is set to a height of 89953px. When I view source, I see the following lines in the markup for the post editor:</p>
<pre><code><iframe id="content_ifr" src='javascript:""' frameborder="0" allowtransparency="true" title="R... | [
{
"answer_id": 40718,
"author": "Matthew Boynes",
"author_id": 12324,
"author_profile": "https://wordpress.stackexchange.com/users/12324",
"pm_score": 2,
"selected": false,
"text": "<p>Goodness, that's pretty funny! Try clearing your cookies. Specifically, there should be a cookie named ... | 2012/01/31 | [
"https://wordpress.stackexchange.com/questions/40717",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12607/"
] | Using a self-hosted install updated to 3.3.1, when I go to the edit post screen, the editor is set to a height of 89953px. When I view source, I see the following lines in the markup for the post editor:
```
<iframe id="content_ifr" src='javascript:""' frameborder="0" allowtransparency="true" title="Rich Text Area Pre... | Well, as it turns out, the "size of the post box" setting under Writing Settings had been changed to 5000 lines. Putting it back at a sane number has fixed the issue. |
40,743 | <p>I'm researching this problem for <em>days</em> without any success... What I want is very simple: to see my custom taxonomy terms sorted by ID on the admin page. I can't believe that something this simple can't be accomplished without plugins.</p>
<p>(I already have a sortable custom column, but it would be importa... | [
{
"answer_id": 40749,
"author": "mor7ifer",
"author_id": 11740,
"author_profile": "https://wordpress.stackexchange.com/users/11740",
"pm_score": 0,
"selected": false,
"text": "<p>How about just using <code>get_terms( 'taxonomy-slug', array( 'orderby' => id,'hierarchical' => 1 ) );<... | 2012/01/31 | [
"https://wordpress.stackexchange.com/questions/40743",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12473/"
] | I'm researching this problem for *days* without any success... What I want is very simple: to see my custom taxonomy terms sorted by ID on the admin page. I can't believe that something this simple can't be accomplished without plugins.
(I already have a sortable custom column, but it would be important to set the *de... | You need to take a look at
>
> /core\_root/wp-admin/includes/class-wp-terms-list-table.php
>
>
>
and then add an extended class and make use of the [`WP_list_Table`](http://codex.wordpress.org/Class_Reference/WP_List_Table) Class and documentation. basically you're overriding the `order` and `orderby` in some cu... |
40,747 | <p>I'm running a site that only communicates over SSL/https so if I embed a youtube video using http I will get an error message saying the site is'nt fully secure. Is it possible to rewrite something so that WordPress accepts https and still auto embeds youtube links added to the content area? Cause now, when I try to... | [
{
"answer_id": 40998,
"author": "jfacemyer",
"author_id": 12660,
"author_profile": "https://wordpress.stackexchange.com/users/12660",
"pm_score": 1,
"selected": false,
"text": "<p>Youtube supports https urls for videos (just add the \"s\" into the regular url). However, they also state t... | 2012/01/31 | [
"https://wordpress.stackexchange.com/questions/40747",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1936/"
] | I'm running a site that only communicates over SSL/https so if I embed a youtube video using http I will get an error message saying the site is'nt fully secure. Is it possible to rewrite something so that WordPress accepts https and still auto embeds youtube links added to the content area? Cause now, when I try to em... | <http://core.trac.wordpress.org/ticket/18719> has a working patch now.
Edit: Plugin code to do similar until patch gets in:
```
wp_oembed_add_provider('#https://(www\.)?youtube.com/watch.*#i', 'http://youtube.com/oembed?scheme=https', true);
wp_oembed_add_provider('https://youtu.be/*', 'http://youtube.com/oembed?sche... |
40,753 | <p>Is there a good way to add a class of "parent" to list items that have children using wp_nav_menu?</p>
<p>I've found a couple of solutions online but non seem to have the desired effect.</p>
| [
{
"answer_id": 40768,
"author": "sanchothefat",
"author_id": 1733,
"author_profile": "https://wordpress.stackexchange.com/users/1733",
"pm_score": 1,
"selected": false,
"text": "<p>You can do it with a bit of regex and a custom menu walker although I've not tested this thoroughly:</p>\n\... | 2012/01/31 | [
"https://wordpress.stackexchange.com/questions/40753",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7999/"
] | Is there a good way to add a class of "parent" to list items that have children using wp\_nav\_menu?
I've found a couple of solutions online but non seem to have the desired effect. | This may not be the ideal solution, depending on what you need the class for, but you could add a "parent" class via JavaScript. The line below uses the jQuery [`:has()`](http://api.jquery.com/has-selector/) selector:
```
$('#nav-id').find('li:has(ul)').addClass('parent');
``` |
40,764 | <p>I've got an "event" custom post type, with a meta field is used for the event date. I've successfully created archive pages (year and month) based on the answer on a previous question (<a href="https://wordpress.stackexchange.com/questions/40200/archives-for-custom-post-type-based-on-a-date-meta-value">here</a>). No... | [
{
"answer_id": 40771,
"author": "Shane",
"author_id": 10555,
"author_profile": "https://wordpress.stackexchange.com/users/10555",
"pm_score": 3,
"selected": true,
"text": "<p>Have you looked at PHP's <a href=\"http://ca3.php.net/manual/en/function.date.php\" rel=\"nofollow\">date functio... | 2012/01/31 | [
"https://wordpress.stackexchange.com/questions/40764",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11516/"
] | I've got an "event" custom post type, with a meta field is used for the event date. I've successfully created archive pages (year and month) based on the answer on a previous question ([here](https://wordpress.stackexchange.com/questions/40200/archives-for-custom-post-type-based-on-a-date-meta-value)). Now, I'm trying ... | Have you looked at PHP's [date function](http://ca3.php.net/manual/en/function.date.php)?
A quick example :
```
$dates = $wpdb->get_col( /*your sql*/ );
if( $dates )
{
$archive_year = "";
foreach( $dates as $date )
{
$the_date = strtotime( $date );
$year = date( 'Y', $the... |
40,769 | <p>I have written a plugin which collects stats on document ready.</p>
<p>Keep in mind that my database table is already created.</p>
<p>I've added the following code to do the ajax code</p>
<pre><code>add_action( 'wp_head', 'zkr_stats_ajax' );
function zkr_stats_ajax(){
?>
<script type='text/javascrip... | [
{
"answer_id": 40778,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>The way you're using <code>$wpdb->prepare</code> doesn't help anything. You have to properly prepare the values ... | 2012/01/31 | [
"https://wordpress.stackexchange.com/questions/40769",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12625/"
] | I have written a plugin which collects stats on document ready.
Keep in mind that my database table is already created.
I've added the following code to do the ajax code
```
add_action( 'wp_head', 'zkr_stats_ajax' );
function zkr_stats_ajax(){
?>
<script type='text/javascript' >
jQuery(document).read... | The way you're using `$wpdb->prepare` doesn't help anything. You have to properly prepare the values and then add them like with `sprintf` as `%s` or `%d`.
Oh, and I don't believe "working with WP ajax for over a year.". In this case you would also know about the `nopriv` hooks for public usage :)
```
add_action( 'w... |
40,770 | <p>I've recently moved my fishkeeping "species profiles" over from a custom DB to a customised WordPress custom post type.</p>
<p>I did this by creating a PHP file which accessed the former database, extracted the appropriate information and inserted it into the WP database.</p>
<p>This has worked for all of the prof... | [
{
"answer_id": 40775,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": false,
"text": "<p>Have you read the <a href=\"http://codex.wordpress.org/Function_Reference/get_post_meta\" rel=\"nofollow\">... | 2012/01/31 | [
"https://wordpress.stackexchange.com/questions/40770",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6344/"
] | I've recently moved my fishkeeping "species profiles" over from a custom DB to a customised WordPress custom post type.
I did this by creating a PHP file which accessed the former database, extracted the appropriate information and inserted it into the WP database.
This has worked for all of the profiles and all atta... | See my comment on your question above. I just realized that if you're ending up with those special characters in the database, most likely you're not sanitizing the data before saving it into the database. Try running [`htmlentities()`](http://us.php.net/manual/en/function.htmlentities.php) over all the values that you... |
40,830 | <p>I need to "unhook" jQuery from my <code>wp_footer()</code> ... it's being called automatically and I'm looking for something I can add to functions.php which prevents it from being called a second time in the footer (since I need to call it in the header) </p>
<p><em>please no editorial comments about why calling i... | [
{
"answer_id": 40832,
"author": "krembo99",
"author_id": 13256,
"author_profile": "https://wordpress.stackexchange.com/users/13256",
"pm_score": 1,
"selected": false,
"text": "<p>the function to deregister any script is :</p>\n\n<pre><code>wp_deregister_script('jquery');\n</code></pre>\n... | 2012/02/01 | [
"https://wordpress.stackexchange.com/questions/40830",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2527/"
] | I need to "unhook" jQuery from my `wp_footer()` ... it's being called automatically and I'm looking for something I can add to functions.php which prevents it from being called a second time in the footer (since I need to call it in the header)
*please no editorial comments about why calling in the footer is better* | You don't want to *unregister* the script; that would make it *unavailable* to be enqueued. Rather, you want to *dequeue* the script.
You have two choices:
1. If you know the callback function through which `wp_enqueue_script( 'jquery' )` is called, you can simply call `remove_action( 'wp_footer', 'callback_function_... |
40,839 | <p>I am developing one project and in this project i have to display all the posts related to particular category name.</p>
<p>I have searched a lot but i haven't got any idea to implement this.</p>
<p>How can i do this so that i can display all the posts from particular category/term</p>
| [
{
"answer_id": 40842,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>That would depend on when and how exactly you want to use it - but generally speaking you can either use a custom ... | 2012/02/01 | [
"https://wordpress.stackexchange.com/questions/40839",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11693/"
] | I am developing one project and in this project i have to display all the posts related to particular category name.
I have searched a lot but i haven't got any idea to implement this.
How can i do this so that i can display all the posts from particular category/term | Just use `WP_Query()` to generate your custom query, [using the category parameters](http://codex.wordpress.org/Function_Reference/WP_Query#Category_Parameters).
Assuming you know (or know how to *get*) the ID of the specific category, as `$catid`:
```
<?php
$category_query_args = array(
'cat' => $catid
);
$cate... |
40,846 | <p>I have checked and read lot of post about one single issue that is far more complicated than it seems.</p>
<p>I have a website that uses a lot of videos taken from wwebsite as on the internet ^^ (services like youtube, vimeo, videobuzzy, etc) and we would like to generate on the fly a thumbnail of the embedded vide... | [
{
"answer_id": 40849,
"author": "Nilay Patel",
"author_id": 12618,
"author_profile": "https://wordpress.stackexchange.com/users/12618",
"pm_score": 2,
"selected": false,
"text": "<p>You can use this plugin <a href=\"http://www.daburna.de/blog/2006/12/13/wordpress-video-plugin/\" rel=\"no... | 2012/02/01 | [
"https://wordpress.stackexchange.com/questions/40846",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9458/"
] | I have checked and read lot of post about one single issue that is far more complicated than it seems.
I have a website that uses a lot of videos taken from wwebsite as on the internet ^^ (services like youtube, vimeo, videobuzzy, etc) and we would like to generate on the fly a thumbnail of the embedded video.
Each s... | You can use the oEmbed functionality baked into WordPress. Typically any video host on this list will return a thumbnail to you using oembed.
Here is a list of default providers that WordPress uses for auto embedding in the content area. I've included non-video sources as well for the convenience of others.
* <http:/... |
40,853 | <p>What are good themes to start from when creating a custom WordPress theme?</p>
<p>So far I have found:</p>
<ul>
<li><p><a href="http://html5reset.org/#wordpress" rel="nofollow">HTML5 Reset Theme</a></p></li>
<li><p><a href="http://constellationtheme.com/" rel="nofollow">Constellation Theme</a></p></li>
</ul>
| [
{
"answer_id": 40849,
"author": "Nilay Patel",
"author_id": 12618,
"author_profile": "https://wordpress.stackexchange.com/users/12618",
"pm_score": 2,
"selected": false,
"text": "<p>You can use this plugin <a href=\"http://www.daburna.de/blog/2006/12/13/wordpress-video-plugin/\" rel=\"no... | 2012/02/01 | [
"https://wordpress.stackexchange.com/questions/40853",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6194/"
] | What are good themes to start from when creating a custom WordPress theme?
So far I have found:
* [HTML5 Reset Theme](http://html5reset.org/#wordpress)
* [Constellation Theme](http://constellationtheme.com/) | You can use the oEmbed functionality baked into WordPress. Typically any video host on this list will return a thumbnail to you using oembed.
Here is a list of default providers that WordPress uses for auto embedding in the content area. I've included non-video sources as well for the convenience of others.
* <http:/... |
40,869 | <p>all</p>
<pre><code> As per my html theme structure i do not want to add my menu <ul><li> under <div>.
</code></pre>
<p>I am using </p>
<pre><code> <?php wp_nav_menu( array( 'menu_class' => 'tlm', 'theme_location' => 'primary-menu' ) ); ?>
</code></pre>
<p>By default this wrap ... | [
{
"answer_id": 40870,
"author": "Brian Fegter",
"author_id": 4793,
"author_profile": "https://wordpress.stackexchange.com/users/4793",
"pm_score": 3,
"selected": true,
"text": "<p>Set the container to be empty. :)</p>\n\n<pre><code>wp_nav_menu( array(\n 'menu_class' => 'tlm',\n ... | 2012/02/01 | [
"https://wordpress.stackexchange.com/questions/40869",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12261/"
] | all
```
As per my html theme structure i do not want to add my menu <ul><li> under <div>.
```
I am using
```
<?php wp_nav_menu( array( 'menu_class' => 'tlm', 'theme_location' => 'primary-menu' ) ); ?>
```
By default this wrap my menu with div.
like
```
<div class="menu-first-container"><ul class="tlm" i... | Set the container to be empty. :)
```
wp_nav_menu( array(
'menu_class' => 'tlm',
'theme_location' => 'primary-menu',
'container' => ''
) );
```
Please refer to the [function reference](http://codex.wordpress.org/Function_Reference/wp_nav_menu) to review all the arguments that you can pass to wp\_nav\_men... |
40,893 | <p>Each of our posts are reviews for individual games and we occasionally have to 'pause' the game by changing it from published to pending review. The problem is if the page is indexed by search engines, anyone trying to visit the link will get a 404, which is obviously not desired. I'd like to instead redirect to a l... | [
{
"answer_id": 40904,
"author": "Jared",
"author_id": 2415,
"author_profile": "https://wordpress.stackexchange.com/users/2415",
"pm_score": 3,
"selected": true,
"text": "<p><code>post_status</code> is part of the <code>$post</code> object which you can use to determine if it is published... | 2012/02/01 | [
"https://wordpress.stackexchange.com/questions/40893",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12476/"
] | Each of our posts are reviews for individual games and we occasionally have to 'pause' the game by changing it from published to pending review. The problem is if the page is indexed by search engines, anyone trying to visit the link will get a 404, which is obviously not desired. I'd like to instead redirect to a list... | `post_status` is part of the `$post` object which you can use to determine if it is published, a draft, pending, etc.
```
if( $post->post_status == 'pending' )
// do stuff
``` |
40,896 | <p>I'm completely starting over with a wordpress project that began a couple of weeks ago, and basically i'm totally discovering wordpress, so please bare with me.</p>
<p>I might be completely misunderstanding what has been coded until now, but I've been asked to generate a menu based on the "cutom-post-types" and the... | [
{
"answer_id": 40909,
"author": "mor7ifer",
"author_id": 11740,
"author_profile": "https://wordpress.stackexchange.com/users/11740",
"pm_score": 0,
"selected": false,
"text": "<p>My workaround for this was to just use custom links that linked to example.com/post-type-slug...it's not the ... | 2012/02/01 | [
"https://wordpress.stackexchange.com/questions/40896",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12246/"
] | I'm completely starting over with a wordpress project that began a couple of weeks ago, and basically i'm totally discovering wordpress, so please bare with me.
I might be completely misunderstanding what has been coded until now, but I've been asked to generate a menu based on the "cutom-post-types" and their respect... | Your best bet if you want them to show using the default drag and drop function is to register a custom taxonomy for the custom post type, <http://codex.wordpress.org/Function_Reference/register_taxonomy>.
You can also use the `taxonomies` parameter when you register your CPT function.
<http://codex.wordpress.org/Func... |
40,901 | <p>So I have a custom post type (people) with a related custom taxonomy (directory). Instead of editing a person and then choosing the related directory organizations I'd like to "edit" a directory org and choose the people that belong to it. Anyone know of a plugin that allows this?</p>
<p>I could build my own plug... | [
{
"answer_id": 61234,
"author": "Philip Downer",
"author_id": 947,
"author_profile": "https://wordpress.stackexchange.com/users/947",
"pm_score": 0,
"selected": false,
"text": "<p>I hope I'm understanding your question correctly here. But from what I can understand you'd like a way to se... | 2012/02/01 | [
"https://wordpress.stackexchange.com/questions/40901",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9911/"
] | So I have a custom post type (people) with a related custom taxonomy (directory). Instead of editing a person and then choosing the related directory organizations I'd like to "edit" a directory org and choose the people that belong to it. Anyone know of a plugin that allows this?
I could build my own plugin with an i... | I think the "Featured Post Manager" plugin will be closer to what you're looking for:
<http://wordpress.org/extend/plugins/featured-post-manager/screenshots/>
The language used is somewhat confusing, and it may not work for custom taxonomies (directories) or custom types (people), BUT you can probably take the code a... |
40,907 | <p>I'm having a problem with updating the <code>post_date</code> in a custom function I've written.</p>
<p>I'm trying to change the <code>post_date</code> to my custom <code>meta_date</code> value.</p>
<p>Here is the function:</p>
<pre><code>function cfc_reset_postdate( $data, $postarr ) {
// If it is our form has ... | [
{
"answer_id": 40910,
"author": "mor7ifer",
"author_id": 11740,
"author_profile": "https://wordpress.stackexchange.com/users/11740",
"pm_score": 3,
"selected": true,
"text": "<p>The issue is that you are using <code>get_post_meta()</code>, but since you're hooking <code>wp_insert_post_da... | 2012/02/01 | [
"https://wordpress.stackexchange.com/questions/40907",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12597/"
] | I'm having a problem with updating the `post_date` in a custom function I've written.
I'm trying to change the `post_date` to my custom `meta_date` value.
Here is the function:
```
function cfc_reset_postdate( $data, $postarr ) {
// If it is our form has not been submitted, so we dont want to do anything
if(defined... | The issue is that you are using `get_post_meta()`, but since you're hooking `wp_insert_post_data` you have not set the post meta yet (because the hook fires before the post is inserted into the database. You should be pulling from the metadata submission, and running through any filters you use for `update_post_meta()`... |
40,918 | <p>I am trying to use the following line of PHP code in one of my pages:</p>
<pre><code><input name="from" id="from" value="<?php echo $_GET['from'];?>" type="text" />
</code></pre>
<p>But instead of displaying an empty "from" input field (before typing anything into it), it displays <code><?php echo $... | [
{
"answer_id": 40920,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 0,
"selected": false,
"text": "<p>Are you trying to enter this form field/PHP output in the <em>post content</em>?</p>\n\n<p>If so, then: <st... | 2012/02/01 | [
"https://wordpress.stackexchange.com/questions/40918",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12658/"
] | I am trying to use the following line of PHP code in one of my pages:
```
<input name="from" id="from" value="<?php echo $_GET['from'];?>" type="text" />
```
But instead of displaying an empty "from" input field (before typing anything into it), it displays `<?php echo $_GET['from'];`.
Am I missing something?
Clar... | You can't use PHP in the WordPress back-end editor. Maybe with a plugin you can, but not out of the box.
The easiest solution for this is creating a shortcode. Then you can use something like `[input type="text" name"from"]` in your editor.
```
function input_func( $atts ) {
extract( shortcode_atts( array(
... |
40,927 | <p>Code in question here: <a href="http://pastebin.com/PN29WKNq" rel="nofollow">http://pastebin.com/PN29WKNq</a></p>
<p>It worked on the HTML page I tested it on. Its supposed to add "display: none" to the content divs and then add "display: block" when the appropriate tab is clicked. But it just changes to "display... | [
{
"answer_id": 40930,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 3,
"selected": true,
"text": "<p>WordPress automatically loads jQuery in \"no conflict\" mode so that it will be compatible with other libraries. This... | 2012/02/01 | [
"https://wordpress.stackexchange.com/questions/40927",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12051/"
] | Code in question here: <http://pastebin.com/PN29WKNq>
It worked on the HTML page I tested it on. Its supposed to add "display: none" to the content divs and then add "display: block" when the appropriate tab is clicked. But it just changes to "display: none" and never changes. | WordPress automatically loads jQuery in "no conflict" mode so that it will be compatible with other libraries. This means the `$` variable ***isn't used for jQuery*** within WordPress.
Rewrite your code to use the full jQuery keyword when you begin your closure like this:
```
jQuery(document).ready(function($) {
... |
40,944 | <p>So yeah, I'm a genius. I managed delete all my admin capabilities (thank you very much Membership plugin). I could restore them, ...if I had admin access, lol.</p>
<p>Anywhoo, how can I give all my capabilities back to admin? I have access to the database via PHPMyAdmin but have no idea where or what to add back to... | [
{
"answer_id": 40946,
"author": "Kyle",
"author_id": 12476,
"author_profile": "https://wordpress.stackexchange.com/users/12476",
"pm_score": 3,
"selected": false,
"text": "<p>It's the wp_capabilities in the usermeta table. Mine says:</p>\n\n<pre><code>a:1:{s:13:\"administrator\";s:1:\"1\... | 2012/02/02 | [
"https://wordpress.stackexchange.com/questions/40944",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11059/"
] | So yeah, I'm a genius. I managed delete all my admin capabilities (thank you very much Membership plugin). I could restore them, ...if I had admin access, lol.
Anywhoo, how can I give all my capabilities back to admin? I have access to the database via PHPMyAdmin but have no idea where or what to add back to the DB.
... | Ok, sorry for asking. I figured it out. But for future people, here's a suggestion.
Step 1 (BACKUP!!!!) - backup your database, if the next step screws you over and you don't have a backup it's your own fault.
Step 2 - Use PHPMyAdmin or similar tool to access your DB, find the wp\_usermeta table and then sort by user... |
40,947 | <p>I'd like to create a dynamic menu with a mix of static pages and custom post type archives that applies a class of "current" to the current tab. The example below uses 1) Static page set as Home 2) Static page 3) Custom post type archive 4) Static page for blog content.</p>
<p>Tried to edit the code from my previou... | [
{
"answer_id": 41020,
"author": "Caleb",
"author_id": 12597,
"author_profile": "https://wordpress.stackexchange.com/users/12597",
"pm_score": 1,
"selected": false,
"text": "<p>So I think you are asking how to dynamically highlight the tab of the page you are currently on. I did something... | 2012/02/02 | [
"https://wordpress.stackexchange.com/questions/40947",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5486/"
] | I'd like to create a dynamic menu with a mix of static pages and custom post type archives that applies a class of "current" to the current tab. The example below uses 1) Static page set as Home 2) Static page 3) Custom post type archive 4) Static page for blog content.
Tried to edit the code from my previous menu, bu... | So I think you are asking how to dynamically highlight the tab of the page you are currently on. I did something like this on my recent website project because I needed to highlight a certain tab when I was on a custom post type.
Here is some code you could use for your website:
```
function custom_tab_highlighting()... |
40,952 | <p>So you know how Drupal has functions in modules like Devel that allow you to output arrays in a nice format like <code>dsm($array)</code> or <code>krumo($array)</code>... Does WordPress have an equivalent or a nice way of displaying <code>print_r($array)</code>?</p>
| [
{
"answer_id": 40954,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": false,
"text": "<p>You can install and use <a href=\"http://kaloyan.info/krumo/\" rel=\"nofollow noreferrer\">Krumo</a> with WordPress... | 2012/02/02 | [
"https://wordpress.stackexchange.com/questions/40952",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10827/"
] | So you know how Drupal has functions in modules like Devel that allow you to output arrays in a nice format like `dsm($array)` or `krumo($array)`... Does WordPress have an equivalent or a nice way of displaying `print_r($array)`? | I created a Kint plugin that works really well. I also integrates with the Debug Bar plugin. You can download it at: <http://wordpress.org/extend/plugins/kint-debugger/>
There are a few functions to help you out with WordPress specific globals:
* `dump_wp_query()`
* `dump_wp()`
* `dump_post()`
For printing arrays in... |
40,959 | <p>I'm writing code from within a plugin and I'm attempting to create a two-part registration form. I'm using POST to determine if the first part of the form was submitted or not. Unfortunately, though, the POST data is not coming through. Here is what my form looks like:</p>
<pre><code><form action="<?php echo ... | [
{
"answer_id": 40954,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": false,
"text": "<p>You can install and use <a href=\"http://kaloyan.info/krumo/\" rel=\"nofollow noreferrer\">Krumo</a> with WordPress... | 2012/02/02 | [
"https://wordpress.stackexchange.com/questions/40959",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12224/"
] | I'm writing code from within a plugin and I'm attempting to create a two-part registration form. I'm using POST to determine if the first part of the form was submitted or not. Unfortunately, though, the POST data is not coming through. Here is what my form looks like:
```
<form action="<?php echo $_SERVER['REQUEST_UR... | I created a Kint plugin that works really well. I also integrates with the Debug Bar plugin. You can download it at: <http://wordpress.org/extend/plugins/kint-debugger/>
There are a few functions to help you out with WordPress specific globals:
* `dump_wp_query()`
* `dump_wp()`
* `dump_post()`
For printing arrays in... |
40,969 | <p>I have a WordPress website that has a category with two subcategories. </p>
<p>Now, how is it possible to show the content (the subcategories items/content) on the parent category?</p>
| [
{
"answer_id": 40976,
"author": "Michael",
"author_id": 4884,
"author_profile": "https://wordpress.stackexchange.com/users/4884",
"pm_score": 3,
"selected": true,
"text": "<p>One possibility:</p>\n\n<pre><code><?php \n $sub_cats = get_categories('parent=' . get_query_var('cat'));\n... | 2012/02/02 | [
"https://wordpress.stackexchange.com/questions/40969",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12676/"
] | I have a WordPress website that has a category with two subcategories.
Now, how is it possible to show the content (the subcategories items/content) on the parent category? | One possibility:
```
<?php
$sub_cats = get_categories('parent=' . get_query_var('cat'));
if( $sub_cats ) :
foreach( $sub_cats as $sub_cat ) :
$sub_query = new WP_Query( array(
'category__in' => array( $sub_cat->term_id ),
'posts_per_page' => -1)
... |
40,978 | <p>I have created some meta boxes of pages on the theme i'm working on.</p>
<p>The idea is to have a input field, then a button to upload files.</p>
<p>The meta box is working properly.</p>
<p>When I click on the button, it fires the thickbox.</p>
<p>This is working fine too.</p>
<p>Then I could upload a media or ... | [
{
"answer_id": 40976,
"author": "Michael",
"author_id": 4884,
"author_profile": "https://wordpress.stackexchange.com/users/4884",
"pm_score": 3,
"selected": true,
"text": "<p>One possibility:</p>\n\n<pre><code><?php \n $sub_cats = get_categories('parent=' . get_query_var('cat'));\n... | 2012/02/02 | [
"https://wordpress.stackexchange.com/questions/40978",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9458/"
] | I have created some meta boxes of pages on the theme i'm working on.
The idea is to have a input field, then a button to upload files.
The meta box is working properly.
When I click on the button, it fires the thickbox.
This is working fine too.
Then I could upload a media or choose a media for the library.
A lit... | One possibility:
```
<?php
$sub_cats = get_categories('parent=' . get_query_var('cat'));
if( $sub_cats ) :
foreach( $sub_cats as $sub_cat ) :
$sub_query = new WP_Query( array(
'category__in' => array( $sub_cat->term_id ),
'posts_per_page' => -1)
... |
40,983 | <p>I'm using wordpress multiste 3.3.1
I'm not gonna update it in the future. So I disabled all upgrade functions.</p>
<p>I want to remove the wordpress admin bar from both frontend as well as dashboard.</p>
<p>I can remove it from frontend using this code.</p>
<pre><code>add_action( 'init', 'disable_admin_bar', 1 );... | [
{
"answer_id": 40985,
"author": "Rev. Voodoo",
"author_id": 3429,
"author_profile": "https://wordpress.stackexchange.com/users/3429",
"pm_score": 3,
"selected": true,
"text": "<pre><code>if (!function_exists('disableAdminBar')) {\n\n function disableAdminBar(){\n\n remove_action( '... | 2012/02/02 | [
"https://wordpress.stackexchange.com/questions/40983",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5074/"
] | I'm using wordpress multiste 3.3.1
I'm not gonna update it in the future. So I disabled all upgrade functions.
I want to remove the wordpress admin bar from both frontend as well as dashboard.
I can remove it from frontend using this code.
```
add_action( 'init', 'disable_admin_bar', 1 );
function disable_admin_bar(... | ```
if (!function_exists('disableAdminBar')) {
function disableAdminBar(){
remove_action( 'admin_footer', 'wp_admin_bar_render', 1000 );
function remove_admin_bar_style_backend() {
echo '<style>body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }</style>';
}
... |
40,993 | <p>I have many custom templates for different post types, and I am manually inserting a social share bar inside the 'entry-meta' footer in each of those templates. I need a simple centralized way to disable the social share bar without hacking into the plugin. </p>
<p>Basically I have this setup so far: </p>
<p>In <s... | [
{
"answer_id": 41013,
"author": "Brian Fegter",
"author_id": 4793,
"author_profile": "https://wordpress.stackexchange.com/users/4793",
"pm_score": 1,
"selected": true,
"text": "<p>It's a bad practice to update an option on every page load. You should use a constant instead.</p>\n\n<pre><... | 2012/02/02 | [
"https://wordpress.stackexchange.com/questions/40993",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8105/"
] | I have many custom templates for different post types, and I am manually inserting a social share bar inside the 'entry-meta' footer in each of those templates. I need a simple centralized way to disable the social share bar without hacking into the plugin.
Basically I have this setup so far:
In **functions.php**:
... | It's a bad practice to update an option on every page load. You should use a constant instead.
```
define('SHOW_SOCIAL_BAR', true); //functions.php
if(SHOW_SOCIAL_BAR){
//Do Something
}
``` |
40,994 | <p>My favorite part of the Wordpress <a href="http://codex.wordpress.org/Template_Hierarchy">template hierarchy</a> is the ability to quickly create template files for pages by slug, without having to edit the page in Wordpress to select a template.</p>
<p>We can currently do this: </p>
<blockquote>
<p>page-{slug}.... | [
{
"answer_id": 41004,
"author": "Shane",
"author_id": 10555,
"author_profile": "https://wordpress.stackexchange.com/users/10555",
"pm_score": 2,
"selected": false,
"text": "<p>Following the <a href=\"http://codex.wordpress.org/images/1/18/Template_Hierarchy.png\" rel=\"nofollow\">Templat... | 2012/02/02 | [
"https://wordpress.stackexchange.com/questions/40994",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3564/"
] | My favorite part of the Wordpress [template hierarchy](http://codex.wordpress.org/Template_Hierarchy) is the ability to quickly create template files for pages by slug, without having to edit the page in Wordpress to select a template.
We can currently do this:
>
> page-{slug}.php
>
>
>
But I would like to be a... | A) The Base in Core
-------------------
As you can see [in the Codex](http://codex.wordpress.org/Template_Hierarchy#Single_Post_display) Template Hierarchy explanation, `single-{$post_type}.php` is already supported.
---
B) Extending the core Hierarchy
-------------------------------
Now there're gladly some filter... |
40,996 | <p>I have a client that wants the ability to remove or add a special offer from the front page of her website.</p>
<p>I thought of creating a custom loop using a featured image etc, which would display the latest special offer.</p>
<p>Her site is a PHP site right now without any WP functionality.</p>
<p>What is the ... | [
{
"answer_id": 41000,
"author": "Philip Downer",
"author_id": 947,
"author_profile": "https://wordpress.stackexchange.com/users/947",
"pm_score": 2,
"selected": true,
"text": "<p>You can require the wp-load.php file in the existing page...</p>\n\n<pre><code><?php require('wp-load.php'... | 2012/02/02 | [
"https://wordpress.stackexchange.com/questions/40996",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8678/"
] | I have a client that wants the ability to remove or add a special offer from the front page of her website.
I thought of creating a custom loop using a featured image etc, which would display the latest special offer.
Her site is a PHP site right now without any WP functionality.
What is the minimum installation tha... | You can require the wp-load.php file in the existing page...
```
<?php require('wp-load.php') ?>
```
This will basically load the WordPress installation and allow you to access each of the functions (and the loop) as you normally would. |
41,009 | <p>I am using an image tagging plugin that creates galleries based on image tags, but does not link back to the original post, which is something I am hoping to do.</p>
<p>I found this thread: '<a href="https://wordpress.stackexchange.com/questions/8051/get-the-post-attached-to-a-image-attachment">Get the post attache... | [
{
"answer_id": 41011,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 0,
"selected": false,
"text": "<p>Try combining <a href=\"http://codex.wordpress.org/Function_Reference/the_permalink\" rel=\"nofollow\"><cod... | 2012/02/02 | [
"https://wordpress.stackexchange.com/questions/41009",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5019/"
] | I am using an image tagging plugin that creates galleries based on image tags, but does not link back to the original post, which is something I am hoping to do.
I found this thread: '[Get the post attached to an image attachment](https://wordpress.stackexchange.com/questions/8051/get-the-post-attached-to-a-image-atta... | After some additional searching I was able to come across a function to generate the attachment ID here: <http://pippinsplugins.com/retrieve-attachment-id-from-image-url/>:
```
// retrieves the attachment ID from the file URL
function pippin_get_image_id($image_url) {
global $wpdb;
$prefix = $wpdb->prefix;
... |
41,012 | <p>I'm attempting to use actions to override function calls I currently have throughout a template (to make updating certain replicated sections easier). For example, in <code>archives.php</code> I have the following:</p>
<pre><code><?php get_header(); ?>
<?php roots_content_before(); ?>
<?php ... | [
{
"answer_id": 41014,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 5,
"selected": true,
"text": "<p>No, you don’t need output buffering in this case. As a rule of thumb: Don’t use output buffering unless you really have... | 2012/02/02 | [
"https://wordpress.stackexchange.com/questions/41012",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9605/"
] | I'm attempting to use actions to override function calls I currently have throughout a template (to make updating certain replicated sections easier). For example, in `archives.php` I have the following:
```
<?php get_header(); ?>
<?php roots_content_before(); ?>
<?php $page_for_posts = get_option( 'page_for_... | No, you don’t need output buffering in this case. As a rule of thumb: Don’t use output buffering unless you really have to.
Just imagine what happens if someone else uses output buffering too from a plugin and it crosses with yours:
```
// plugin
ob_start();
// later, you in your theme
ob_start();
// you call a fun... |
41,024 | <p>I'm struggling with understanding some things about CPTs and and could do with some help. I can see that taxonomies often need to be hierarchical, but can't see how/when a custom post type would be?</p>
<p>i.e I have a CPT called 'projects'. There is a taxonomy registered for this posttype called 'fields'. Under 'f... | [
{
"answer_id": 41026,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": false,
"text": "<p>When you have two content objects with a similar interface or shared properties, you have a good candidate for hierarc... | 2012/02/02 | [
"https://wordpress.stackexchange.com/questions/41024",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10755/"
] | I'm struggling with understanding some things about CPTs and and could do with some help. I can see that taxonomies often need to be hierarchical, but can't see how/when a custom post type would be?
i.e I have a CPT called 'projects'. There is a taxonomy registered for this posttype called 'fields'. Under 'fields' I h... | When you have two content objects with a similar interface or shared properties, you have a good candidate for hierarchical post types.
Take **places** as an example (see [this answer](https://wordpress.stackexchange.com/questions/36437/including-two-taxonomies-in-a-permalink-structure)):
* Asia
* Europe
+ Germany
... |
41,032 | <p>From my understanding (and before trial and error),</p>
<pre><code>wp_set_object_terms( 'post_id', 'add_this_term', 'in_this_taxonomy');
</code></pre>
<p>But from the Codex, apparently adding the term will overwrite any other terms that are set for that post and that taxonomy?</p>
<p>Is this right? What if the te... | [
{
"answer_id": 41043,
"author": "mor7ifer",
"author_id": 11740,
"author_profile": "https://wordpress.stackexchange.com/users/11740",
"pm_score": 1,
"selected": false,
"text": "<p>You can check to see what currently is in the term by using <a href=\"http://codex.wordpress.org/Function_Ref... | 2012/02/02 | [
"https://wordpress.stackexchange.com/questions/41032",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10099/"
] | From my understanding (and before trial and error),
```
wp_set_object_terms( 'post_id', 'add_this_term', 'in_this_taxonomy');
```
But from the Codex, apparently adding the term will overwrite any other terms that are set for that post and that taxonomy?
Is this right? What if the terms are nested? | `wp_set_object_terms()` has a fourth argument called `append`. Setting that to true during the call should add the term without unsetting the already set terms.
```
wp_set_object_terms( $post_id, 'add_this_term', 'in_this_taxonomy', true);
``` |
41,044 | <p>I am using contact form 7. I have successfully added to my page, Now I want to export the database onto a separate page with short code. I have the following code, but it results in the following error.</p>
<p><strong>\Code</strong></p>
<pre><code><?php
echo do_shortcode('[cfdb-html form="Contact form 1" show="... | [
{
"answer_id": 41050,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>The Codex page for <a href=\"http://codex.wordpress.org/Function_Reference/is_plugin_active\" rel=\"nofollow\"><cod... | 2012/02/03 | [
"https://wordpress.stackexchange.com/questions/41044",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7653/"
] | I am using contact form 7. I have successfully added to my page, Now I want to export the database onto a separate page with short code. I have the following code, but it results in the following error.
**\Code**
```
<?php
echo do_shortcode('[cfdb-html form="Contact form 1" show="Submitted,your-name"]${your-name}${yo... | The Codex page for [`is_plugin_active`](http://codex.wordpress.org/Function_Reference/is_plugin_active) explains what your problem is:
>
> NOTE: defined in wp-admin/includes/plugin.php, **so this is only available from within the admin pages**. If you want to use this function from within a template, you will need to... |
41,048 | <p>I am trying to use the same image fader in two different spots on my <a href="http://173.247.253.180/~andrewba/" rel="nofollow">testing site</a>. <strike>The one in the top banner works, and the one in the furthest right sidebar kind of works</strike>They both now do not work. However I believe that the answer below... | [
{
"answer_id": 41058,
"author": "Scott",
"author_id": 4610,
"author_profile": "https://wordpress.stackexchange.com/users/4610",
"pm_score": 0,
"selected": false,
"text": "<p>I've voted to close this as off topic but I kinda know the answer so will try my best to explain.</p>\n\n<p>If you... | 2012/02/03 | [
"https://wordpress.stackexchange.com/questions/41048",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10119/"
] | I am trying to use the same image fader in two different spots on my [testing site](http://173.247.253.180/~andrewba/). The one in the top banner works, and the one in the furthest right sidebar kind of worksThey both now do not work. However I believe that the answer below is more or less on the right track and it is ... | Based off of <https://stackoverflow.com/questions/7818525/jquery-image-rotator-with-multiple-instances-on-single-page> here is the code that eventually got it to work
**PHP**
*Top Banner*
```
<div id="top" class="rotator">
<ul>
<li class="show"><a href="1"><img src="http://173.247.253.180/~andrewba/image... |
41,054 | <p>I am wanting to create a page template file to display posts from a custom content type. I was working with this code I found from <a href="http://www.wpbeginner.com/wp-tutorials/how-to-create-a-custom-post-types-archive-page-in-wordpress/" rel="nofollow">this site</a>, but it renders nothing. Does anyone know what ... | [
{
"answer_id": 41056,
"author": "andresmijares",
"author_id": 4907,
"author_profile": "https://wordpress.stackexchange.com/users/4907",
"pm_score": 4,
"selected": true,
"text": "<p>You don't need to use a query, just create your tample and name single-YOURCUSTOMPOSTNAME.php, for more ref... | 2012/02/03 | [
"https://wordpress.stackexchange.com/questions/41054",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2883/"
] | I am wanting to create a page template file to display posts from a custom content type. I was working with this code I found from [this site](http://www.wpbeginner.com/wp-tutorials/how-to-create-a-custom-post-types-archive-page-in-wordpress/), but it renders nothing. Does anyone know what the problem is?
```
<?php /*... | You don't need to use a query, just create your tample and name single-YOURCUSTOMPOSTNAME.php, for more references take a look at:
* <http://codex.wordpress.org/Post_Types#Template_Files> |
41,069 | <p>It is possible to search for posts with a specific term by appending the URL with:</p>
<pre><code>?&term=abc
</code></pre>
<p>Is it possible to do the opposite and search excluding a specific term? Something like:</p>
<pre><code>?&term=NOTabc
</code></pre>
| [
{
"answer_id": 41100,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 5,
"selected": true,
"text": "<h1>The basic explanation</h1>\n\n<ol>\n<li>You have a template tag that is called <code>is_search()</code> to determin... | 2012/02/03 | [
"https://wordpress.stackexchange.com/questions/41069",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9340/"
] | It is possible to search for posts with a specific term by appending the URL with:
```
?&term=abc
```
Is it possible to do the opposite and search excluding a specific term? Something like:
```
?&term=NOTabc
``` | The basic explanation
=====================
1. You have a template tag that is called `is_search()` to determin if you're on a search page or not.
2. This then calls `get_search_template()` which basically is a wrapper function for `get_query_template('search')`.
3. When you look into the last function, then you'll se... |
41,078 | <p>I have one page for each author, but if the author doesn't have any posts I can't get its variables, because the loop is empty.
The page returns empty, no avatar, no info and stuff, the whole site is empty.</p>
<p>How do I get WordPress to pull out the author variable if there are no posts (what makes no author, bu... | [
{
"answer_id": 41106,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 3,
"selected": true,
"text": "<p>To access the author user object outside of the loop on an author archive, you can do the following:</p>\n\n<p... | 2012/02/03 | [
"https://wordpress.stackexchange.com/questions/41078",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10994/"
] | I have one page for each author, but if the author doesn't have any posts I can't get its variables, because the loop is empty.
The page returns empty, no avatar, no info and stuff, the whole site is empty.
How do I get WordPress to pull out the author variable if there are no posts (what makes no author, but i am on ... | To access the author user object outside of the loop on an author archive, you can do the following:
```
global $curauth;
$curauth = (isset($_GET['author_name'])) ? get_user_by('slug', $author_name) : get_userdata(intval($author));
echo 'This is the author page of '.$curauth->display_name;
``` |
41,079 | <p>I am using wordpress and I normally use:</p>
<pre><code>if (!is_user_logged_in()){
//something here
}
</code></pre>
<p>to detect if the wordpress user is logged in or now.</p>
<p>My problem is that I need to detect if the user is logged in to wordpress from a non-wordpress page.</p>
<p>My page is in the same ... | [
{
"answer_id": 41085,
"author": "Mere Development",
"author_id": 10755,
"author_profile": "https://wordpress.stackexchange.com/users/10755",
"pm_score": -1,
"selected": false,
"text": "<p>this is untested by me, but please have a look at this article: <a href=\"http://codex.wordpress.org... | 2012/02/03 | [
"https://wordpress.stackexchange.com/questions/41079",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12714/"
] | I am using wordpress and I normally use:
```
if (!is_user_logged_in()){
//something here
}
```
to detect if the wordpress user is logged in or now.
My problem is that I need to detect if the user is logged in to wordpress from a non-wordpress page.
My page is in the same directory as the other wordpress pages b... | Simply place
```
define( 'WP_USE_THEMES', false );
include 'wp-load.php';
```
on to of your template files (before *everything else*). This loads the whole WP core. |
41,091 | <p>I have written a custom walker that I am using with <code>wp_nav_menu</code> but I need to iterate through 4 custom classes, and I'm not sure how to do this. Basically, each menu-item <code><li></code> needs to be given a class of <code>color1</code>, <code>color2</code>, <code>color3</code> or <code>color4</c... | [
{
"answer_id": 41094,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Create a separate function:</p>\n\n<pre><code>function alternate()\n{\n static $i = 0;\n $args = func_get_args()... | 2012/02/03 | [
"https://wordpress.stackexchange.com/questions/41091",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1118/"
] | I have written a custom walker that I am using with `wp_nav_menu` but I need to iterate through 4 custom classes, and I'm not sure how to do this. Basically, each menu-item `<li>` needs to be given a class of `color1`, `color2`, `color3` or `color4`, cycling back to `color1`, lather, rinse, repeat, in that order.
Ordi... | Use a class variable to keep the 'index' of the colour you wish to display. Increment each time it's used, and check if it goes over, in which case set it back to 1.
```
class Salamander_Advent_Walker extends Walker_page {
private $color_idx = 1;
function start_el(&$output, $item, $depth, $args) {
if (... |
41,098 | <p>So I'm at my wit's end here. I've done this before plenty of times, but I think I have stared at this so much I am missing something.</p>
<ul>
<li><p>I basically have a custom post called locations. That custom post has a few fields which include address, and latitude and longitude.</p>
<ul>
<li>that lat/long are ... | [
{
"answer_id": 41094,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Create a separate function:</p>\n\n<pre><code>function alternate()\n{\n static $i = 0;\n $args = func_get_args()... | 2012/02/03 | [
"https://wordpress.stackexchange.com/questions/41098",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12721/"
] | So I'm at my wit's end here. I've done this before plenty of times, but I think I have stared at this so much I am missing something.
* I basically have a custom post called locations. That custom post has a few fields which include address, and latitude and longitude.
+ that lat/long are geocoded so they get automa... | Use a class variable to keep the 'index' of the colour you wish to display. Increment each time it's used, and check if it goes over, in which case set it back to 1.
```
class Salamander_Advent_Walker extends Walker_page {
private $color_idx = 1;
function start_el(&$output, $item, $depth, $args) {
if (... |
41,101 | <p>I'm migrating a Typepad install to a Wordpress subdomain, and most of the links will be broken. The rewrites work so that:</p>
<pre><code>http://mainsite.com/blogs
</code></pre>
<p>is rewritten to</p>
<pre><code>http://blogs.mainsite.com
</code></pre>
<p>If a full link with article information is passed, it is r... | [
{
"answer_id": 41102,
"author": "Scott",
"author_id": 4610,
"author_profile": "https://wordpress.stackexchange.com/users/4610",
"pm_score": 2,
"selected": true,
"text": "<p>You can try a plugin to do this:</p>\n\n<p><a href=\"http://wordpress.org/extend/plugins/smart-404/\" rel=\"nofollo... | 2012/02/03 | [
"https://wordpress.stackexchange.com/questions/41101",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12722/"
] | I'm migrating a Typepad install to a Wordpress subdomain, and most of the links will be broken. The rewrites work so that:
```
http://mainsite.com/blogs
```
is rewritten to
```
http://blogs.mainsite.com
```
If a full link with article information is passed, it is rewritten as such;
```
http://mainsite.com/blogs/... | You can try a plugin to do this:
<http://wordpress.org/extend/plugins/smart-404/>
Reads the page URL and tries to find a page/post that it might match and redirect to it.
Found out about this plugin from: <http://www.aebeta.com/web-hosting/seo/7-seo-friendly-404-plugin-for-wordpress.html> |
41,116 | <p>I'm using twitter bootstrap in my theme.
I'm trying to use bootstrap menu in my theme. But it use custom attributes like <code>data-toggle</code>.</p>
<p>Here is the full code.</p>
<pre><code><ul class="nav">
<li class="active"><a href="#">Home</a></li>
<li... | [
{
"answer_id": 41129,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 0,
"selected": false,
"text": "<p>See <a href=\"https://wordpress.stackexchange.com/a/40396/73\">this answer</a> for details: Look for <code>menu_item_p... | 2012/02/03 | [
"https://wordpress.stackexchange.com/questions/41116",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5074/"
] | I'm using twitter bootstrap in my theme.
I'm trying to use bootstrap menu in my theme. But it use custom attributes like `data-toggle`.
Here is the full code.
```
<ul class="nav">
<li class="active"><a href="#">Home</a></li>
<li><a href="#">Link</a></li>
<li><a href="#">Link</a></... | For a copy paste solution check this custom Walker out: <http://goodandorgreat.wordpress.com/2012/01/12/update-2-using-twitter-bootstrap-dropdown-menus-with-wordpress/>
It's missing one or two things like `data-toggle="dropdown"` and `<b class="caret"></b>`.
It should be quite easy to figure that out, but here's my m... |
41,126 | <p>I am trying to put together some functions in wordpress which will allow me to add a custom post type <em>and</em> associate a default category <em>and</em> post on the posts page. </p>
<p>So far I have been able to create a custom post type, and as far as I can tell I am associating a default category. However, th... | [
{
"answer_id": 41129,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 0,
"selected": false,
"text": "<p>See <a href=\"https://wordpress.stackexchange.com/a/40396/73\">this answer</a> for details: Look for <code>menu_item_p... | 2012/02/02 | [
"https://wordpress.stackexchange.com/questions/41126",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2883/"
] | I am trying to put together some functions in wordpress which will allow me to add a custom post type *and* associate a default category *and* post on the posts page.
So far I have been able to create a custom post type, and as far as I can tell I am associating a default category. However, the posts do not show up i... | For a copy paste solution check this custom Walker out: <http://goodandorgreat.wordpress.com/2012/01/12/update-2-using-twitter-bootstrap-dropdown-menus-with-wordpress/>
It's missing one or two things like `data-toggle="dropdown"` and `<b class="caret"></b>`.
It should be quite easy to figure that out, but here's my m... |
41,132 | <p>I would like to build a website that will let visitors register and get access to their own personal admin page.</p>
<p>So user #1 will input his login and password and get access to his admin page with his parameters. User #2 will see his own parameters, etc.</p>
<p>Is this possible using wordpress themes and plu... | [
{
"answer_id": 41135,
"author": "Evan Yeung",
"author_id": 1878,
"author_profile": "https://wordpress.stackexchange.com/users/1878",
"pm_score": 2,
"selected": false,
"text": "<p>I have done this in the past before, so I am reusing the code here. You will need to do some tweaking for it ... | 2012/02/03 | [
"https://wordpress.stackexchange.com/questions/41132",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1224/"
] | I would like to build a website that will let visitors register and get access to their own personal admin page.
So user #1 will input his login and password and get access to his admin page with his parameters. User #2 will see his own parameters, etc.
Is this possible using wordpress themes and plugins?
and if yes,... | I have done this in the past before, so I am reusing the code here. You will need to do some tweaking for it to mesh with your site. You will also need [Peter's Login Redirect](http://wordpress.org/extend/plugins/peters-login-redirect/) plugin.
*I did not explain the code because it would take too much time to work t... |
41,143 | <p>Does anyone know how I automatically add the URL of the uploaded image to a custom field?</p>
<p>In other words, When I upload a image I want the url to the image to get a custom field variable automatically so I dont have to add the URL manually to the custom field all the time.</p>
<p>I need a seamless integrati... | [
{
"answer_id": 41147,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>There's no need to store the URL in a custom field, the thumbnail id is already stored in a custom field under the ... | 2012/02/03 | [
"https://wordpress.stackexchange.com/questions/41143",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12727/"
] | Does anyone know how I automatically add the URL of the uploaded image to a custom field?
In other words, When I upload a image I want the url to the image to get a custom field variable automatically so I dont have to add the URL manually to the custom field all the time.
I need a seamless integration to make is use... | Here is the final code that adds the thumbnail url to a custom field named Image.
```
function w_thumbnail_src() {
if (has_post_thumbnail()) {
$thumb = wp_get_attachment_image_src(get_post_thumbnail_id(), 'emphasis');
return $thumb[0]; // thumbnail url
} else {
return ''; // or a defau... |
41,145 | <p>Following <a href="https://wordpress.stackexchange.com/questions/40587/shouldnt-this-be-easy-custom-post-type-custom-taxonomy-permalink">this answer</a>, I recently changed the permalink structure of a custom post type called 'Literature' to include the taxonomy term:</p>
<p>Old structure: <code>mysite.com/literatu... | [
{
"answer_id": 41149,
"author": "Brian Fegter",
"author_id": 4793,
"author_profile": "https://wordpress.stackexchange.com/users/4793",
"pm_score": 2,
"selected": false,
"text": "<p>I concur that you need to add a redirect. You can do this easily with the following function. I'm sure you ... | 2012/02/04 | [
"https://wordpress.stackexchange.com/questions/41145",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1063/"
] | Following [this answer](https://wordpress.stackexchange.com/questions/40587/shouldnt-this-be-easy-custom-post-type-custom-taxonomy-permalink), I recently changed the permalink structure of a custom post type called 'Literature' to include the taxonomy term:
Old structure: `mysite.com/literature/books/post_name`
New s... | I concur that you need to add a redirect. You can do this easily with the following function. I'm sure you will have to tweak it, but it's a good proof-of-concept.
```
add_action('parse_request', 'redirect_books_to_fiction', 0);
function redirect_books_to_fiction(){
global $wp;
if(preg_match_all('~literature\... |
41,152 | <p>I'm looking to insert a string of JavaScript variables AFTER the in_footer enqueued scripts. When I write the string via the wp_footer hook, they occur before the in_footer scripts. Is there another hook I can tie into that happens after those enqueued scripts have been written.</p>
| [
{
"answer_id": 41153,
"author": "mor7ifer",
"author_id": 11740,
"author_profile": "https://wordpress.stackexchange.com/users/11740",
"pm_score": 4,
"selected": true,
"text": "<p>If you change the priority on the hook to <code>wp_footer</code> you should be able to shift when it's called ... | 2012/02/04 | [
"https://wordpress.stackexchange.com/questions/41152",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3032/"
] | I'm looking to insert a string of JavaScript variables AFTER the in\_footer enqueued scripts. When I write the string via the wp\_footer hook, they occur before the in\_footer scripts. Is there another hook I can tie into that happens after those enqueued scripts have been written. | If you change the priority on the hook to `wp_footer` you should be able to shift when it's called in reference to the enqueue functions.
**Example:**
```
add_action('wp_footer', 'my_footer_hook', PHP_INT_MAX);
``` |
41,175 | <p>What is the best php method to extract all IDs from a query string and display them in a comma separated list?</p>
<p>I have a function that grabs specific posts from the database and am trying to enter those ID's into a new wp_query loop.</p>
<pre><code>Array (
[0] => stdClass Object (
[ID] => 1... | [
{
"answer_id": 41178,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 0,
"selected": false,
"text": "<p>This isn't really a WordPress question, but you could just use <code>array_map</code> to extract the IDs,... | 2012/02/04 | [
"https://wordpress.stackexchange.com/questions/41175",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1057/"
] | What is the best php method to extract all IDs from a query string and display them in a comma separated list?
I have a function that grabs specific posts from the database and am trying to enter those ID's into a new wp\_query loop.
```
Array (
[0] => stdClass Object (
[ID] => 162
[post_author] =... | `$string` will contain a comma separated list of IDs:
```
$ids = array();
foreach( $array as $post ) {
if( !in_array( $post->ID, $ids ) ) {
$ids[] = $post->ID;
}
}
$string = implode( ', ', $ids );
```
Note: This uses basically no wordpress, other than the post object...which is really just an object... |
41,190 | <p>I want to use jQuery Datepicker in my website. However when I use the same I get the following error.
Uncaught TypeError: Object # has no method 'datepicker'
I've googled on this for quite sometime. All of these say that the problem could be due to loading jquery twice. I have checked and this isn't the case.
I load... | [
{
"answer_id": 41226,
"author": "tollmanz",
"author_id": 4850,
"author_profile": "https://wordpress.stackexchange.com/users/4850",
"pm_score": 1,
"selected": false,
"text": "<p>This line shouldn't be in there:</p>\n\n<pre><code><script type=\"text/javascript\" src=\"http://xxxx/wp-inc... | 2012/02/04 | [
"https://wordpress.stackexchange.com/questions/41190",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12757/"
] | I want to use jQuery Datepicker in my website. However when I use the same I get the following error.
Uncaught TypeError: Object # has no method 'datepicker'
I've googled on this for quite sometime. All of these say that the problem could be due to loading jquery twice. I have checked and this isn't the case.
I load th... | This line shouldn't be in there:
```
<script type="text/javascript" src="http://xxxx/wp-includes/js/jquery/ui/jquery-ui.min.js"></script>
```
In a standard WordPress install, no such file exists. This makes me wonder how you are adding the scripts to the theme in the first place. Are you using `wp_enqueue_styles`? I... |
41,195 | <p>I am working on a blog where user can submit his/her story from the UI.</p>
<p>What I would like to happen is if a user submit his/her story it should be visible in the dashboard and i can get the attached document from the dashboard.
All i can think about getting only a notification and rest of all should be manag... | [
{
"answer_id": 41208,
"author": "Michelle",
"author_id": 16,
"author_profile": "https://wordpress.stackexchange.com/users/16",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://www.gravityforms.com\" rel=\"nofollow noreferrer\">Gravity Forms</a> works well for this. You can ... | 2012/02/04 | [
"https://wordpress.stackexchange.com/questions/41195",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9415/"
] | I am working on a blog where user can submit his/her story from the UI.
What I would like to happen is if a user submit his/her story it should be visible in the dashboard and i can get the attached document from the dashboard.
All i can think about getting only a notification and rest of all should be manageable from... | Before Header:
```
<?php
$post_id = $post->ID;
if ( isset( $_POST['html-upload'] ) && ! empty( $_FILES ) ) {
require_once( ABSPATH . 'wp-admin/includes/admin.php' );
$id = media_handle_upload( 'async-upload', $post_id ); //post id of Client Files page
unset( $_FILES );
if( is_w... |
41,207 | <p>I have two simple functions that load stuff using <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_style"><code>wp_enqueue_style()</code></a> and <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script"><code>wp_enqueue_script()</code></a>, something like these:</p>
<pre><code>func... | [
{
"answer_id": 41211,
"author": "mor7ifer",
"author_id": 11740,
"author_profile": "https://wordpress.stackexchange.com/users/11740",
"pm_score": 4,
"selected": false,
"text": "<p>If you use <a href=\"http://codex.wordpress.org/Function_Reference/get_current_screen\"><code>get_current_scr... | 2012/02/04 | [
"https://wordpress.stackexchange.com/questions/41207",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1869/"
] | I have two simple functions that load stuff using [`wp_enqueue_style()`](http://codex.wordpress.org/Function_Reference/wp_enqueue_style) and [`wp_enqueue_script()`](http://codex.wordpress.org/Function_Reference/wp_enqueue_script), something like these:
```
function admin_custom_css()
{ wp_enqueue_style( 'stylesheet_na... | `add_menu_page` and `add_submenu_page` both return the page's "hook suffix", which can be used to identify the page with certain hooks. As such, you can use that suffix in combination with the variable hooks `admin_print_styles-{$hook_suffix}` and `admin_print_scripts-{$hook_suffix}` to specifically target these pages.... |
41,215 | <p>I was just wondering if there was anyway to customize individual parts of the lists. So for instance if you go to my site at www.r3entertainment.org and check out the Features page, if you look at the top where it says Gaming's Most Memorable Moments.. is there a way for JUST the title link to be underlined and the ... | [
{
"answer_id": 41211,
"author": "mor7ifer",
"author_id": 11740,
"author_profile": "https://wordpress.stackexchange.com/users/11740",
"pm_score": 4,
"selected": false,
"text": "<p>If you use <a href=\"http://codex.wordpress.org/Function_Reference/get_current_screen\"><code>get_current_scr... | 2012/02/04 | [
"https://wordpress.stackexchange.com/questions/41215",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12764/"
] | I was just wondering if there was anyway to customize individual parts of the lists. So for instance if you go to my site at www.r3entertainment.org and check out the Features page, if you look at the top where it says Gaming's Most Memorable Moments.. is there a way for JUST the title link to be underlined and the aut... | `add_menu_page` and `add_submenu_page` both return the page's "hook suffix", which can be used to identify the page with certain hooks. As such, you can use that suffix in combination with the variable hooks `admin_print_styles-{$hook_suffix}` and `admin_print_scripts-{$hook_suffix}` to specifically target these pages.... |
41,221 | <p>i have a file i am including across site to index.php, single.php etc. </p>
<p>This file behaves really strage and acts like it not part of<br>
wordpress Enviroment meaning: </p>
<p>i get errors on get_bloginfo('template_url') and it won't<br>
get the values from my options page.</p>
<p>Any idea what this might... | [
{
"answer_id": 41251,
"author": "Timothée HENRY",
"author_id": 1224,
"author_profile": "https://wordpress.stackexchange.com/users/1224",
"pm_score": 1,
"selected": true,
"text": "<p>Ok, thanks to m0r7if3, I found the two pieces of information I was looking for:</p>\n\n<ul>\n<li>wordpress... | 2012/02/04 | [
"https://wordpress.stackexchange.com/questions/41221",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7990/"
] | i have a file i am including across site to index.php, single.php etc.
This file behaves really strage and acts like it not part of
wordpress Enviroment meaning:
i get errors on get\_bloginfo('template\_url') and it won't
get the values from my options page.
Any idea what this might happen?
**Here is the i... | Ok, thanks to m0r7if3, I found the two pieces of information I was looking for:
* wordpress multisite
* "Automatically create a new WordPress site in your Network associated with the user that is created." -> <http://www.gravityforms.com/add-ons/user-registration/> |
41,222 | <p>On the main page in WordPress all I want is the category to come before the title of the article posted. So for example if it's a Review, I'd like the article name to be Review: Super 8.</p>
<p>Okay so if you go to my site www.r3entertainment.org it displays the names of each of the articles on the main page. What ... | [
{
"answer_id": 41232,
"author": "Mere Development",
"author_id": 10755,
"author_profile": "https://wordpress.stackexchange.com/users/10755",
"pm_score": 1,
"selected": false,
"text": "<p>you've already had a comment about the lack of detail, so I'll try and guess what you want to do.</p>... | 2012/02/04 | [
"https://wordpress.stackexchange.com/questions/41222",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12764/"
] | On the main page in WordPress all I want is the category to come before the title of the article posted. So for example if it's a Review, I'd like the article name to be Review: Super 8.
Okay so if you go to my site www.r3entertainment.org it displays the names of each of the articles on the main page. What I want, is... | you've already had a comment about the lack of detail, so I'll try and guess what you want to do.
Assuming you're inside 'the loop' and your title is being echo'd out with:
```
<?php the_title(); ?>
```
..then the easiest way for you to show the title first is to do this:
```
<?php
$catobjarray = get_the_category... |
41,244 | <p>I'm using a customized version of the Twenty Eleven theme. I want to set a class on the <code>body</code> based on which random header image is displayed. Is there some function that allows me to get the name of the custom header image that will be displayed? My goal is to style the text / background / colors bas... | [
{
"answer_id": 41245,
"author": "Brian Fegter",
"author_id": 4793,
"author_profile": "https://wordpress.stackexchange.com/users/4793",
"pm_score": 4,
"selected": true,
"text": "<p>For the TwentyEleven theme, you can place this above your BODY tag in header.php. The theme will recognize t... | 2012/02/05 | [
"https://wordpress.stackexchange.com/questions/41244",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11735/"
] | I'm using a customized version of the Twenty Eleven theme. I want to set a class on the `body` based on which random header image is displayed. Is there some function that allows me to get the name of the custom header image that will be displayed? My goal is to style the text / background / colors based on the image b... | For the TwentyEleven theme, you can place this above your BODY tag in header.php. The theme will recognize that $header\_image is already set, so no other mods would be necessary.
```
$header_image = get_header_image();
$image = basename($header_image);
$image = explode('.',$image);
$class = 'header-image-'.$image[0];... |
41,262 | <p>Is it possible to redirect the user to the taxonomy page IF the search input matches the taxonomy name exactly?</p>
<p>For instance i have a taxonomy called "Actors". If someone put into the search field "Tom Hanks" instead of going to the regular search page, it would redirect them to the taxonomy page for Tom han... | [
{
"answer_id": 41286,
"author": "mor7ifer",
"author_id": 11740,
"author_profile": "https://wordpress.stackexchange.com/users/11740",
"pm_score": 2,
"selected": false,
"text": "<p>How about something along these lines?</p>\n\n<pre><code>$tax_args = array(\n 'public' => true\n);\n$ta... | 2012/02/05 | [
"https://wordpress.stackexchange.com/questions/41262",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1778/"
] | Is it possible to redirect the user to the taxonomy page IF the search input matches the taxonomy name exactly?
For instance i have a taxonomy called "Actors". If someone put into the search field "Tom Hanks" instead of going to the regular search page, it would redirect them to the taxonomy page for Tom hanks. | I only wanted to match tags in a single taxonomy, so I was able to simplify the code as follows. My taxonomy is 'post\_tag' -- just swap yours out as needed.
```
$i = 0;
$search_query = get_search_query();
$term = get_term_by( 'name', $search_query, 'post_tag' );
if( $term !== false ) {
$i++;
$single_result =... |
41,265 | <p>I'm using the CSV Importer plugin developed by dvkob. It works fine, may be because I upload only few posts each time (about 50). </p>
<p>What I need to know now, is how to add the meta data meta_value and meta_key. They should be inserted in the postmeta table. I'm a newbie in coding. </p>
<p>When importing dire... | [
{
"answer_id": 41270,
"author": "krembo99",
"author_id": 13256,
"author_profile": "https://wordpress.stackexchange.com/users/13256",
"pm_score": 1,
"selected": false,
"text": "<p>if you use the PHP-myadmin, you should EXPORT an sql dump of ALL your tables, and then IMPORT the same sql.</... | 2012/02/05 | [
"https://wordpress.stackexchange.com/questions/41265",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12791/"
] | I'm using the CSV Importer plugin developed by dvkob. It works fine, may be because I upload only few posts each time (about 50).
What I need to know now, is how to add the meta data meta\_value and meta\_key. They should be inserted in the postmeta table. I'm a newbie in coding.
When importing directly via php-mya... | if you use the PHP-myadmin, you should EXPORT an sql dump of ALL your tables, and then IMPORT the same sql.
If I understand correctly (and maybe I am wrong) you try to import CSV into an SQL dump .. that will not work in direct sql dump.
after you have the sql dump, use the following :
```
/**
UPDATE wp_option... |
41,272 | <p>In my gallery site i want to show other pictures under the current picture (in single post). I seen more codes but it i asks to specify the category, but i dont want want specify the category manually in the code I want the code itself to get the category ID or name.It would be much easier for me if i get full posts... | [
{
"answer_id": 41273,
"author": "Sufiyan Ghori",
"author_id": 12276,
"author_profile": "https://wordpress.stackexchange.com/users/12276",
"pm_score": 6,
"selected": true,
"text": "<p>The question has already been asked and the answer has been posted too,</p>\n\n<p><a href=\"https://wordp... | 2012/02/05 | [
"https://wordpress.stackexchange.com/questions/41272",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12124/"
] | In my gallery site i want to show other pictures under the current picture (in single post). I seen more codes but it i asks to specify the category, but i dont want want specify the category manually in the code I want the code itself to get the category ID or name.It would be much easier for me if i get full posts in... | The question has already been asked and the answer has been posted too,
[How to display related posts from same category?](https://wordpress.stackexchange.com/questions/30039/how-to-display-related-posts-from-same-category)
Add this code inside your single.php after a loop wherever you want to show related post,
```... |
41,284 | <p>I have a multisite network on WP 3.3.1. I now need to get all popular posts from across this network (preferably based on the amount of views).</p>
<p>Is this possible, and how do I do that?</p>
| [
{
"answer_id": 41316,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 3,
"selected": true,
"text": "<p>simple list all last post about the network, not the popular posts; for popular posts you must use an plugin or tra... | 2012/02/05 | [
"https://wordpress.stackexchange.com/questions/41284",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3497/"
] | I have a multisite network on WP 3.3.1. I now need to get all popular posts from across this network (preferably based on the amount of views).
Is this possible, and how do I do that? | simple list all last post about the network, not the popular posts; for popular posts you must use an plugin or track via Google Analytics etc.
```
<ul class='postlist no-mp'>
<?php
$blogs = $wpdb->get_results(
"SELECT blog_id,path FROM {$wpdb->blogs}
WHERE blog_id != {$wpdb->blogid}
AND site_id = '{$... |
41,323 | <p>I got some plugins that auto-generates custom fields. Does anyone know how to automatically remove empty custom fields from post when I press "publish"?</p>
<p>A check I can put in my <code>functions.php</code> that does a check and removes the custom field if there is no value?</p>
| [
{
"answer_id": 41328,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 2,
"selected": true,
"text": "<p>Demilio, unfortunately the WordPress API seems to assume that custom fields do not have an 'empty' value, ... | 2012/02/06 | [
"https://wordpress.stackexchange.com/questions/41323",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12727/"
] | I got some plugins that auto-generates custom fields. Does anyone know how to automatically remove empty custom fields from post when I press "publish"?
A check I can put in my `functions.php` that does a check and removes the custom field if there is no value? | Demilio, unfortunately the WordPress API seems to assume that custom fields do not have an 'empty' value, in the sense that [`update_post_meta`](http://codex.wordpress.org/Function_Reference/update_post_meta) and [`delete_post_meta`](http://codex.wordpress.org/Function_Reference/delete_post_meta), if given `''` as the ... |
41,329 | <p>Does anyone know how I can customise wp-activate.php?</p>
<p>It wraps the content in <code><div id="content" class="widecolumn"></code>, however in my theme the main wrapper is <code><div id="main"></code></p>
<p>Presumably, I could just style <code>div#content.widecolumn</code> to be identical to <cod... | [
{
"answer_id": 41330,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>The main problem here is: <code>wp-activate.php</code> includes your <code>header.php</code> but not the <code>functio... | 2012/02/06 | [
"https://wordpress.stackexchange.com/questions/41329",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11117/"
] | Does anyone know how I can customise wp-activate.php?
It wraps the content in `<div id="content" class="widecolumn">`, however in my theme the main wrapper is `<div id="main">`
Presumably, I could just style `div#content.widecolumn` to be identical to `div#main`. But I am curious if anyone knows how to customise this... | You are right, this is very hacky.
What I ending up doing was creating two new page templates **Register** and **Activate** and creating two new WordPress pages using those templates and then using a filter in my `functions.php` file to modify the behaviour one **wpmu\_signup\_user\_notification**.
Users will regist... |
41,335 | <p>The code below allow me to use a different CSS style to any page I declare</p>
<pre><code><body<?php if ( is_page(array('page1', 'page2', 'page3'))) {
echo ' class="myclass" '; } ?>>
</code></pre>
<p>for example I can use this css to page1 , page2 and page3:</p>
<pre><code>.myclass #content { backgrou... | [
{
"answer_id": 41337,
"author": "Tomas Buteler",
"author_id": 5552,
"author_profile": "https://wordpress.stackexchange.com/users/5552",
"pm_score": 0,
"selected": false,
"text": "<p>There's a wealth of options to choose from, actually, so there's bound to be a function that fits your nee... | 2012/02/06 | [
"https://wordpress.stackexchange.com/questions/41335",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12816/"
] | The code below allow me to use a different CSS style to any page I declare
```
<body<?php if ( is_page(array('page1', 'page2', 'page3'))) {
echo ' class="myclass" '; } ?>>
```
for example I can use this css to page1 , page2 and page3:
```
.myclass #content { background-color: #123456; }
.myclass #content p { color:... | Assuming that you're using parent page "photos" as a path.
It's good practice (and required by WordPress Theme Guidelines) to use `body_class()` function for output different classes, based on current page or post. Just insert this function in your theme.
```
<body <?php body_class(); ?>>
```
This function will add... |
41,342 | <p>I'm looking for a filter that provides the full page generated in WordPress - including the head section with meta tags, body, styling and dynamic content. the_content() and the_excerpt() do work only for the dynamic part and the request filter seems to work only for SQL queries (or not)?</p>
<p>I would like to fil... | [
{
"answer_id": 41349,
"author": "Anh Tran",
"author_id": 2051,
"author_profile": "https://wordpress.stackexchange.com/users/2051",
"pm_score": 1,
"selected": false,
"text": "<p>You can use <a href=\"http://codex.wordpress.org/HTTP_API\" rel=\"nofollow\">HTTP API</a> to get the content of... | 2012/02/06 | [
"https://wordpress.stackexchange.com/questions/41342",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11506/"
] | I'm looking for a filter that provides the full page generated in WordPress - including the head section with meta tags, body, styling and dynamic content. the\_content() and the\_excerpt() do work only for the dynamic part and the request filter seems to work only for SQL queries (or not)?
I would like to filter some... | You can use **output buffering** to accomplish this.
Add a high priority hook directly before the template is rendered:
```
add_action('template_redirect', 'foo_buffer_go', 0);
function foo_buffer_go(){
ob_start('foo_buffer_callback');
}
```
Add a shutdown hook with an extremely low priority.
```
add_action('s... |
41,348 | <p>I have created a simple frontend form to allow users to submit posts - similar to the tutorial here - <a href="http://voodoopress.com/how-to-post-from-your-front-end-with-no-plugin/" rel="nofollow"><strong>http://voodoopress.com/</strong></a> . I also have a couple of custom taxonomies which i have as text input b... | [
{
"answer_id": 41383,
"author": "mor7ifer",
"author_id": 11740,
"author_profile": "https://wordpress.stackexchange.com/users/11740",
"pm_score": 0,
"selected": false,
"text": "<p>I've spent a bit digging around on this and I think I've found your solution! It seems that <code>get_terms()... | 2012/02/06 | [
"https://wordpress.stackexchange.com/questions/41348",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12821/"
] | I have created a simple frontend form to allow users to submit posts - similar to the tutorial here - [**http://voodoopress.com/**](http://voodoopress.com/how-to-post-from-your-front-end-with-no-plugin/) . I also have a couple of custom taxonomies which i have as text input boxes on my form. This is all working but i w... | Ok not sure if this is the best method to use but it worked for me. I used a combition of [jquery-ui-autocomplete](http://jqueryui.com/demos/autocomplete/) - and the JSON API plugin
First download the required js files from the link above. I used jqueri-ui from the Google library
Install and activate JSON API plugin
... |
41,357 | <p>I had a working (test) blog, and during an update from 3.2.1 to 3.3.1 - something went wrong , I think the update did not finished..</p>
<p>Just before the Update, I have enabled a new theme (all functions and files made by me )</p>
<p>Since the update went wrong - I can not access my admin area (500 error) but th... | [
{
"answer_id": 41431,
"author": "boyska",
"author_id": 12843,
"author_profile": "https://wordpress.stackexchange.com/users/12843",
"pm_score": 0,
"selected": false,
"text": "<p>Are there plugin installed?\nit's easy to make a 500 error if some plugin does something bad inside an <code>if... | 2012/02/06 | [
"https://wordpress.stackexchange.com/questions/41357",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I had a working (test) blog, and during an update from 3.2.1 to 3.3.1 - something went wrong , I think the update did not finished..
Just before the Update, I have enabled a new theme (all functions and files made by me )
Since the update went wrong - I can not access my admin area (500 error) but the front end works... | In phpmyadmin search :
```
SELECT *
FROM wp_options
WHERE option_name = 'template'
OR option_name = 'stylesheet'
OR option_name = 'current_theme';
```
then :
```
UPDATE wp_options SET option_value = 'yourthemename' WHERE option_name = 'template';
UPDATE wp_options SET option_value = 'yourthemename' WHERE option_nam... |
41,360 | <p>This question I'm asking has been asked a thousand different ways, and I refuse to believe I'm the only one with a basic need here so here goes:</p>
<p>I'm taking a simple local install and putting it live. I've exported before, but it didn't seem to carry over any categories/settings/authors/etc. HOWEVER, that was... | [
{
"answer_id": 41361,
"author": "Alex Older",
"author_id": 3365,
"author_profile": "https://wordpress.stackexchange.com/users/3365",
"pm_score": 3,
"selected": true,
"text": "<p>Your easiest option is to just take a copy of your local database and import it to the server using phpmyadmin... | 2012/02/06 | [
"https://wordpress.stackexchange.com/questions/41360",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | This question I'm asking has been asked a thousand different ways, and I refuse to believe I'm the only one with a basic need here so here goes:
I'm taking a simple local install and putting it live. I've exported before, but it didn't seem to carry over any categories/settings/authors/etc. HOWEVER, that was almost a ... | Your easiest option is to just take a copy of your local database and import it to the server using phpmyadmin or similar.
You can then add these 2 options to your wp-config.php file to update the site URL.
```
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
```
That was you will... |
41,370 | <p>I need to generate a simple error message on a page by passing a variable through the URL.</p>
<p>The URL is structured as follows:</p>
<p><a href="http://site.com/parent-category/category/?error=pause" rel="noreferrer">http://site.com/parent-category/category/?error=pause</a></p>
<p>I'm sure it's the permalinks ... | [
{
"answer_id": 41373,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 5,
"selected": true,
"text": "<p>Try adding the variable to the WordPress' array of 'recognised query variables'...</p>\n\n<pre><code>add_f... | 2012/02/06 | [
"https://wordpress.stackexchange.com/questions/41370",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12476/"
] | I need to generate a simple error message on a page by passing a variable through the URL.
The URL is structured as follows:
<http://site.com/parent-category/category/?error=pause>
I'm sure it's the permalinks rewrite interfering, but I'm not sure how to resolve it. | Try adding the variable to the WordPress' array of 'recognised query variables'...
```
add_filter('query_vars', 'my_register_query_vars' );
function my_register_query_vars( $qvars ){
//Add query variable to $qvars array
$qvars[] = 'my_error';
return $qvars;
}
```
Then the value of 'my\_error' can be foun... |
41,371 | <p>So I have this blog that filters by category Then by city. Somewhere while creating the filtration I broke the pagination which seemed to work fine earlier. It doesn't work on my homepage where it should show all posts and goes to 404 in my archives. I'm using a custom link structure of <code>/%category%/%postname%/... | [
{
"answer_id": 41375,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 4,
"selected": true,
"text": "<p>The <code>posts_per_page</code> refers to how many posts per page, and not what page you are viewing. For ... | 2012/02/06 | [
"https://wordpress.stackexchange.com/questions/41371",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7355/"
] | So I have this blog that filters by category Then by city. Somewhere while creating the filtration I broke the pagination which seemed to work fine earlier. It doesn't work on my homepage where it should show all posts and goes to 404 in my archives. I'm using a custom link structure of `/%category%/%postname%/` and in... | The `posts_per_page` refers to how many posts per page, and not what page you are viewing. For that, you want to set the `paged` argument. See the [Codex on `WP_Query`](http://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters) and this [article by Scribu](http://scribu.net/wordpress/wp-pagenavi/right-w... |
41,390 | <p>I have <a href="https://wordpress.stackexchange.com/questions/41175/how-to-extract-all-id-variables-from-a-query-string">a function</a> that returns a comma separated list of post ids that a particular user can access. I want to use this list in a WP_Query loop.</p>
<p>The custom function:</p>
<pre><code>$array = ... | [
{
"answer_id": 41391,
"author": "Rob Vermeer",
"author_id": 11135,
"author_profile": "https://wordpress.stackexchange.com/users/11135",
"pm_score": 4,
"selected": true,
"text": "<p><code>$access_ids</code> is a string. <code>post__in</code> accepts an array.</p>\n\n<p>So instead of $acce... | 2012/02/06 | [
"https://wordpress.stackexchange.com/questions/41390",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1057/"
] | I have [a function](https://wordpress.stackexchange.com/questions/41175/how-to-extract-all-id-variables-from-a-query-string) that returns a comma separated list of post ids that a particular user can access. I want to use this list in a WP\_Query loop.
The custom function:
```
$array = user_albums();
foreach( $array ... | `$access_ids` is a string. `post__in` accepts an array.
So instead of $access\_ids you could use `'post__in'=> $ids` skipping the `$access_ids = implode( ', ', $ids );` all together. |
41,395 | <p>I'm use the code below to get the number of posts by a user and it works fine but it only includes published posts. How can I modify this code or use different code to have it include "future" post_status's or "drafts", for example.</p>
<pre><code><?php
$post_count = count_user_posts($curauth->ID);
echo '<... | [
{
"answer_id": 41397,
"author": "mor7ifer",
"author_id": 11740,
"author_profile": "https://wordpress.stackexchange.com/users/11740",
"pm_score": 3,
"selected": true,
"text": "<p>This will do what you want:</p>\n\n<pre><code>$args = array(\n 'author' => $curauth->ID,\n 'p... | 2012/02/06 | [
"https://wordpress.stackexchange.com/questions/41395",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12042/"
] | I'm use the code below to get the number of posts by a user and it works fine but it only includes published posts. How can I modify this code or use different code to have it include "future" post\_status's or "drafts", for example.
```
<?php
$post_count = count_user_posts($curauth->ID);
echo '<p>User post count is '... | This will do what you want:
```
$args = array(
'author' => $curauth->ID,
'post_status' => array(
'publish',
'pending',
'draft',
'future'
)
);
$posts = new WP_Query();
$post_count = $posts->found_posts;
```
It will include drafts, pending posts, published posts, and f... |
41,401 | <p>I am new to WordPress if someone will help me I will be very appreciate.</p>
<p>There is parameter ajax "true" but in docs. wasn't said how to implement Ajax using WP_List_Table Class?</p>
<pre><code>parent::__construct( array(
'singular' => 'user', //singular name of the listed records
... | [
{
"answer_id": 41407,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>Have you already taken <a href=\"http://codex.wordpress.org/Class_Reference/WP_List_Table#Methods\" rel=\"nofollow\... | 2012/02/06 | [
"https://wordpress.stackexchange.com/questions/41401",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12835/"
] | I am new to WordPress if someone will help me I will be very appreciate.
There is parameter ajax "true" but in docs. wasn't said how to implement Ajax using WP\_List\_Table Class?
```
parent::__construct( array(
'singular' => 'user', //singular name of the listed records
'plural' => 'u... | In the parent \_\_construct args if ajax is set to true the js\_vars will be output in the footer of the page.
```
/**
* Constructor. The child class should call this constructor from it's own constructor
*
* @param array $args An associative array with information about the current table
* @access... |
41,416 | <p>I made a test on GTmetrix.com and I got a pretty bad grade regarding the Page Speed (D or F).
The worse error is the following: </p>
<p><strong>Serve scaled images (grade F):</strong><br>
<em>some image URL</em> is resized in HTML or CSS from 1024x539 to 530x279. Serving a scaled image could save 70.3KiB (73% redu... | [
{
"answer_id": 41425,
"author": "Kyle",
"author_id": 12476,
"author_profile": "https://wordpress.stackexchange.com/users/12476",
"pm_score": 1,
"selected": false,
"text": "<p>The best way would be to resize them before uploading them. </p>\n\n<p>You could also try using this function to ... | 2012/02/06 | [
"https://wordpress.stackexchange.com/questions/41416",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7131/"
] | I made a test on GTmetrix.com and I got a pretty bad grade regarding the Page Speed (D or F).
The worse error is the following:
**Serve scaled images (grade F):**
*some image URL* is resized in HTML or CSS from 1024x539 to 530x279. Serving a scaled image could save 70.3KiB (73% reduction).
What should I do to get... | The best way would be to resize them before uploading them.
You could also try using this function to resize the image on the fly.
```
<?php
/*
* Resize images dynamically using wp built in functions
* Victor Teixeira
*
* php 5.2+
*
* Exemplo de uso:
*
* <?php
* $thumb = get_post_thumbnail_id();
* $imag... |
41,420 | <p>My WordPress website is now redirected to latest post by adding below function to <code>function.php</code></p>
<pre><code>add_action( 'template_redirect', 'redirect' );
function redirect() {
$args = array(
'numberposts' => 1,
'post_type' => 'seller',
'post_status' => 'publish');
$last ... | [
{
"answer_id": 41432,
"author": "Brooke.",
"author_id": 2204,
"author_profile": "https://wordpress.stackexchange.com/users/2204",
"pm_score": 2,
"selected": true,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/query_posts\" rel=\"nofollow\">Custom query loops</a> and... | 2012/02/06 | [
"https://wordpress.stackexchange.com/questions/41420",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8124/"
] | My WordPress website is now redirected to latest post by adding below function to `function.php`
```
add_action( 'template_redirect', 'redirect' );
function redirect() {
$args = array(
'numberposts' => 1,
'post_type' => 'seller',
'post_status' => 'publish');
$last = wp_get_recent_posts($args);
$las... | [Custom query loops](http://codex.wordpress.org/Function_Reference/query_posts) and [custom page templates](http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates) are your friends.
Ditch the redirect function and on your home page template do something like this:
```
<?php
$args = array(
'post_status... |
41,422 | <p>I want to add quicktags that do more than just add markup. For instance, I would like to add a quicktag to run a function do apply a js regex on the page content. How can I add a quicktag that executes a function?</p>
<p>To give a specific example, I would like to add a button that removes all markup tags in the e... | [
{
"answer_id": 41430,
"author": "boyska",
"author_id": 12843,
"author_profile": "https://wordpress.stackexchange.com/users/12843",
"pm_score": 0,
"selected": false,
"text": "<p>you should write a tinymce plugin, then load it (using tinymce advanced plugin)</p>\n"
},
{
"answer_id"... | 2012/02/06 | [
"https://wordpress.stackexchange.com/questions/41422",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/755/"
] | I want to add quicktags that do more than just add markup. For instance, I would like to add a quicktag to run a function do apply a js regex on the page content. How can I add a quicktag that executes a function?
To give a specific example, I would like to add a button that removes all markup tags in the entire post ... | Simple example that will add a Quicktag button that calls a Javascript function when it is clicked...
```
<?PHP
function _add_my_quicktags(){ ?>
<script type="text/javascript">
QTags.addButton( 'alert', 'Alert Button', simple_alert );
function simple_alert() {
alert('hello, example callba... |
41,427 | <p>I only want to display a subset of the buttons on the html editor button bar. What is the proper way to remove some of the quicktags? For intance I don't want it to offer "proofread".</p>
| [
{
"answer_id": 41428,
"author": "keatch",
"author_id": 2727,
"author_profile": "https://wordpress.stackexchange.com/users/2727",
"pm_score": 0,
"selected": false,
"text": "<p>You can use the <a href=\"http://wordpress.org/extend/plugins/tinymce-advanced/\" rel=\"nofollow\" title=\"TinyMC... | 2012/02/06 | [
"https://wordpress.stackexchange.com/questions/41427",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/755/"
] | I only want to display a subset of the buttons on the html editor button bar. What is the proper way to remove some of the quicktags? For intance I don't want it to offer "proofread". | You can achieve this using the [**`quicktag_settings`**](https://developer.wordpress.org/reference/hooks/quicktags_settings/) filter
```
function wpse41427_remove_quicktags( $qtInit ) {
$qtInit['buttons'] = 'strong,em,link,block,del,img,ul,ol,li,code,more,spell,close,fullscreen';
return $qtInit;
}
add_filter('... |
41,434 | <p>A follow up to a previous question found here <a href="https://wordpress.stackexchange.com/questions/6109/how-can-i-lock-down-an-old-wordpress-install-i-dont-intend-to-update">How can I lock down an old wordpress install I don't intend to update?</a></p>
<p>Same info still stands. WordPress install will (probab... | [
{
"answer_id": 41428,
"author": "keatch",
"author_id": 2727,
"author_profile": "https://wordpress.stackexchange.com/users/2727",
"pm_score": 0,
"selected": false,
"text": "<p>You can use the <a href=\"http://wordpress.org/extend/plugins/tinymce-advanced/\" rel=\"nofollow\" title=\"TinyMC... | 2012/02/07 | [
"https://wordpress.stackexchange.com/questions/41434",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1757/"
] | A follow up to a previous question found here [How can I lock down an old wordpress install I don't intend to update?](https://wordpress.stackexchange.com/questions/6109/how-can-i-lock-down-an-old-wordpress-install-i-dont-intend-to-update)
Same info still stands. WordPress install will (probably) not be updated. Never... | You can achieve this using the [**`quicktag_settings`**](https://developer.wordpress.org/reference/hooks/quicktags_settings/) filter
```
function wpse41427_remove_quicktags( $qtInit ) {
$qtInit['buttons'] = 'strong,em,link,block,del,img,ul,ol,li,code,more,spell,close,fullscreen';
return $qtInit;
}
add_filter('... |
41,456 | <p>I have a Development, Staging and Production workflow for my WordPress site. I am fairly strict about any structural work to be done on the site being done in Staging first, then migrated to Production.</p>
<p>I feel some changes may be better done on Production through the admin interface, such as a simple logo ch... | [
{
"answer_id": 41428,
"author": "keatch",
"author_id": 2727,
"author_profile": "https://wordpress.stackexchange.com/users/2727",
"pm_score": 0,
"selected": false,
"text": "<p>You can use the <a href=\"http://wordpress.org/extend/plugins/tinymce-advanced/\" rel=\"nofollow\" title=\"TinyMC... | 2012/02/07 | [
"https://wordpress.stackexchange.com/questions/41456",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2907/"
] | I have a Development, Staging and Production workflow for my WordPress site. I am fairly strict about any structural work to be done on the site being done in Staging first, then migrated to Production.
I feel some changes may be better done on Production through the admin interface, such as a simple logo change, and ... | You can achieve this using the [**`quicktag_settings`**](https://developer.wordpress.org/reference/hooks/quicktags_settings/) filter
```
function wpse41427_remove_quicktags( $qtInit ) {
$qtInit['buttons'] = 'strong,em,link,block,del,img,ul,ol,li,code,more,spell,close,fullscreen';
return $qtInit;
}
add_filter('... |
41,463 | <p>Jeditable is saving data to the file like:</p>
<pre><code>$('.edit_area').editable('http://www.example.com/save.php', {
type : 'textarea',
cancel : 'Cancel',
submit : 'OK',
indicator : '<img src="img/indicator.gif">',
tooltip : 'Click to edit...'
... | [
{
"answer_id": 41628,
"author": "Bohdan Hdal",
"author_id": 10380,
"author_profile": "https://wordpress.stackexchange.com/users/10380",
"pm_score": 1,
"selected": true,
"text": "<p>I found a solution for my question. This plugin works with url formatted like: </p>\n\n<pre><code>$('.edit_... | 2012/02/07 | [
"https://wordpress.stackexchange.com/questions/41463",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10380/"
] | Jeditable is saving data to the file like:
```
$('.edit_area').editable('http://www.example.com/save.php', {
type : 'textarea',
cancel : 'Cancel',
submit : 'OK',
indicator : '<img src="img/indicator.gif">',
tooltip : 'Click to edit...'
});`
```
How do I... | I found a solution for my question. This plugin works with url formatted like:
```
$('.edit_area').editable('<?php echo admin_url('admin-ajax.php'); ?>?action=youraction', {
type : 'textarea',
cancel : 'Cancel',
submit : 'OK',
indicator : '<img src="img/indicator.gif">',
tooltip ... |
41,496 | <p>I'm new to WordPress, and currently developing my first plugin and currently having difficulties.</p>
<p>How I can insert the add_filter action inside my submit function? I want the <code>add_filter</code> action to process after the user click the submit button.</p>
<p>I have try this but it didn't work.</p>
<pr... | [
{
"answer_id": 41499,
"author": "mor7ifer",
"author_id": 11740,
"author_profile": "https://wordpress.stackexchange.com/users/11740",
"pm_score": 2,
"selected": false,
"text": "<p>I think what you're ACTUALLY looking to do is to <a href=\"http://codex.wordpress.org/Function_Reference/appl... | 2012/02/07 | [
"https://wordpress.stackexchange.com/questions/41496",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12863/"
] | I'm new to WordPress, and currently developing my first plugin and currently having difficulties.
How I can insert the add\_filter action inside my submit function? I want the `add_filter` action to process after the user click the submit button.
I have try this but it didn't work.
```
if(isset($_POST['btn_submit'])... | I think what you're ACTUALLY looking to do is to [`apply_filters()`](http://codex.wordpress.org/Function_Reference/apply_filters). [`add_filter()`](http://codex.wordpress.org/Function_Reference/add_filter) registers a new filter, whereas [`apply_filters()`](http://codex.wordpress.org/Function_Reference/apply_filters) d... |
41,502 | <p>I have been using the following function to enqueue some CSS to my theme. However, they are used in the admin area as well:</p>
<pre><code>wp_enqueue_style(...)
</code></pre>
<p>I don't want them to be used in the admin area. Sadly I cannot find anything about that neither here nor on Google in combination with th... | [
{
"answer_id": 41503,
"author": "mor7ifer",
"author_id": 11740,
"author_profile": "https://wordpress.stackexchange.com/users/11740",
"pm_score": 1,
"selected": false,
"text": "<p>You can make your enquques conditional, for example: <code>if( !is_admin() ) { wp_enquque_style( 'my_style' )... | 2012/02/07 | [
"https://wordpress.stackexchange.com/questions/41502",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8335/"
] | I have been using the following function to enqueue some CSS to my theme. However, they are used in the admin area as well:
```
wp_enqueue_style(...)
```
I don't want them to be used in the admin area. Sadly I cannot find anything about that neither here nor on Google in combination with this function. The codex doe... | There are a couple of options. One is to wrap the enqueue in a check to see if it is the admin.
```
if(!is_admin())
wp_enqueue_style(....);
```
The other is wait to enqueue the style until template\_redirect.
```
function my_enqueue_styles() {
wp_enqueue_style(....);
}
add_action( 'template_redirect', ... |
41,507 | <p>How do I remove the link generated by the_tags?</p>
<p>This is what I use today: <code><?php the_tags( '', '', '' ); ?></code></p>
<p>That results in the tags assigned to the post. But I want to remove the link. Any idea? </p>
| [
{
"answer_id": 41508,
"author": "thenetimp",
"author_id": 12867,
"author_profile": "https://wordpress.stackexchange.com/users/12867",
"pm_score": 0,
"selected": false,
"text": "<p>Get the tag list, and then strip the tags.</p>\n\n<pre><code><?php\nif (is_single()) { the_post(); rewind... | 2012/02/07 | [
"https://wordpress.stackexchange.com/questions/41507",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12873/"
] | How do I remove the link generated by the\_tags?
This is what I use today: `<?php the_tags( '', '', '' ); ?>`
That results in the tags assigned to the post. But I want to remove the link. Any idea? | Use following code:
```
<?php
$posttags = get_the_tags();
if ($posttags) {
foreach($posttags as $tag) {
echo $tag->name . ' ';
}
}
?>
```
More details: <http://wpeden.com/tipsntuts/getting-list-of-tags-for-a-post/> |
41,516 | <p>How to retrieve all WordPress terms attached to the Post and Other Post type?
Assumed I don't know/don't care about the taxonomy, term name/term id etc, the only thing I know is post_id.
Thank you.</p>
| [
{
"answer_id": 41518,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 2,
"selected": false,
"text": "<p>There's a function specifically for this, it's called <a href=\"http://codex.wordpress.org/Function_Reference/wp_get_... | 2012/02/07 | [
"https://wordpress.stackexchange.com/questions/41516",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8534/"
] | How to retrieve all WordPress terms attached to the Post and Other Post type?
Assumed I don't know/don't care about the taxonomy, term name/term id etc, the only thing I know is post\_id.
Thank you. | There's a function specifically for this, it's called [`wp_get_post_terms()`](http://codex.wordpress.org/Function_Reference/wp_get_post_terms).
Unfortunately, you *do* need to care about the taxonomy. If you don't specify a taxonomy, it will return all of the "post\_tags" terms:
```
$terms = wp_get_post_terms( $post_... |
41,517 | <p>I have 7 meta fields for a custom post type in Wordpress. These 7 in particular are days of the week (Sunday thru Saturday) and have checkboxes for each. I've successfully gotten the checkbox to POST when the value is "On", however when I return to the edit page and try to deselect, the value stays the same in the d... | [
{
"answer_id": 41525,
"author": "Shane",
"author_id": 10555,
"author_profile": "https://wordpress.stackexchange.com/users/10555",
"pm_score": 2,
"selected": false,
"text": "<p>Unchecked checkboxes are not set in the $_POST, so you'd have to empty their meta field.</p>\n\n<p>Something lik... | 2012/02/07 | [
"https://wordpress.stackexchange.com/questions/41517",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12870/"
] | I have 7 meta fields for a custom post type in Wordpress. These 7 in particular are days of the week (Sunday thru Saturday) and have checkboxes for each. I've successfully gotten the checkbox to POST when the value is "On", however when I return to the edit page and try to deselect, the value stays the same in the data... | It appears the post meta is not being cleared for 'sunday' when the checkbox is unchecked.
```
If( isset($_POST['sunday']) ){
update_post_meta($post->ID, "sunday", $_POST["sunday"] );
}else{
delete_post_meta($post->ID, "sunday");
}
return $post;
```
Or you can set the value to false
```
If( isset($_POST['su... |
41,520 | <p>I would like to create a child theme based on the twentyeleven theme. I understand how to create my own styles.css file to work for my child theme.</p>
<p>I would also like to create my own custom</p>
<pre><code>header.php
index.php
footer.php
functions.php
</code></pre>
<p>files. My question is what information ... | [
{
"answer_id": 41522,
"author": "Shaon",
"author_id": 7805,
"author_profile": "https://wordpress.stackexchange.com/users/7805",
"pm_score": 4,
"selected": true,
"text": "<p>style.css is the one and only required file in a child theme. It provides the information header by which WordPress... | 2012/02/07 | [
"https://wordpress.stackexchange.com/questions/41520",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9574/"
] | I would like to create a child theme based on the twentyeleven theme. I understand how to create my own styles.css file to work for my child theme.
I would also like to create my own custom
```
header.php
index.php
footer.php
functions.php
```
files. My question is what information do I need to have placed in the h... | style.css is the one and only required file in a child theme. It provides the information header by which WordPress recognizes the child theme, and it replaces the style.css of the parent.
As with any WordPress theme, the information header must be at the top of the file, the only difference being that in a child them... |
41,527 | <p>I need a way to use get_terms and have it only grab the taxonomies of the current page. Example <a href="http://sitename.com/genre/hip_hop" rel="nofollow">http://sitename.com/genre/hip_hop</a> would only grab the taxonomies that also have the hip hop genre attached.</p>
<p>wp_get_object_terms almost works for me bu... | [
{
"answer_id": 41528,
"author": "Jared",
"author_id": 2415,
"author_profile": "https://wordpress.stackexchange.com/users/2415",
"pm_score": 3,
"selected": false,
"text": "<p>I think what you're looking for is <a href=\"http://codex.wordpress.org/Function_Reference/get_the_terms\" rel=\"n... | 2012/02/07 | [
"https://wordpress.stackexchange.com/questions/41527",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12838/"
] | I need a way to use get\_terms and have it only grab the taxonomies of the current page. Example <http://sitename.com/genre/hip_hop> would only grab the taxonomies that also have the hip hop genre attached.
wp\_get\_object\_terms almost works for me but wont loop the way get\_terms does.
Here is what I have right now... | I think what you're looking for is [`get_the_terms`](http://codex.wordpress.org/Function_Reference/get_the_terms), which you can specify a post ID and a taxonomy to retrieve the terms attached to it. |
41,534 | <p>Can someone please help me alter my coding to eliminate my problem? I am using this line before the loop:</p>
<pre><code><?php query_posts('cat=3&showposts='.get_option('posts_per_page')); ?>
</code></pre>
<p>for context:</p>
<pre><code><?php get_header(); ?>
<div id="page-wrap">
<d... | [
{
"answer_id": 41538,
"author": "fxfuture",
"author_id": 1063,
"author_profile": "https://wordpress.stackexchange.com/users/1063",
"pm_score": 2,
"selected": true,
"text": "<p>Try replacing your code with the following:</p>\n\n<pre><code>$wp_query = new WP_Query();\n$wp_query->query( ... | 2012/02/07 | [
"https://wordpress.stackexchange.com/questions/41534",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12875/"
] | Can someone please help me alter my coding to eliminate my problem? I am using this line before the loop:
```
<?php query_posts('cat=3&showposts='.get_option('posts_per_page')); ?>
```
for context:
```
<?php get_header(); ?>
<div id="page-wrap">
<div id="content">
<div class="post-wrap">
<?p... | Try replacing your code with the following:
```
$wp_query = new WP_Query();
$wp_query->query( array( 'cat' => '9', 'posts_per_page' => get_option( 'posts_per_page' )));
``` |
41,537 | <p>WordPress automatically adds the width and height attributes to [gallery] shortcode images.</p>
<p>How to delete these attributes? Something <a href="https://wordpress.stackexchange.com/questions/5568/filter-to-remove-image-dimension-attributes">like this</a> but for [gallery] output.</p>
| [
{
"answer_id": 41573,
"author": "Yoav Aner",
"author_id": 4741,
"author_profile": "https://wordpress.stackexchange.com/users/4741",
"pm_score": 1,
"selected": true,
"text": "<p>I can think of a couple of options:</p>\n\n<ol>\n<li><p>Create a new shortcode, e.g. my_gallery. You can copy t... | 2012/02/07 | [
"https://wordpress.stackexchange.com/questions/41537",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5645/"
] | WordPress automatically adds the width and height attributes to [gallery] shortcode images.
How to delete these attributes? Something [like this](https://wordpress.stackexchange.com/questions/5568/filter-to-remove-image-dimension-attributes) but for [gallery] output. | I can think of a couple of options:
1. Create a new shortcode, e.g. my\_gallery. You can copy the code in
`wp-includes/media.php`. Look for the code staring with
`add_shortcode('gallery', 'gallery_shortcode');` and then the actual
function. Rename / modify as needed. The actual img link is within
the `$link` variable
... |
41,540 | <p>I'm creating two different WP_Query objects, one for each of two different post types I'm using. In creating my output, I'd like to loop through one of the objects, and at the same time loop through the other object as well, so I can output pieces of them together. Here's an example of what I'd like to accomplish:</... | [
{
"answer_id": 41547,
"author": "Norcross",
"author_id": 403,
"author_profile": "https://wordpress.stackexchange.com/users/403",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure you can merge the two loops together, since there isn't anything to keep them separate from a data s... | 2012/02/07 | [
"https://wordpress.stackexchange.com/questions/41540",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49/"
] | I'm creating two different WP\_Query objects, one for each of two different post types I'm using. In creating my output, I'd like to loop through one of the objects, and at the same time loop through the other object as well, so I can output pieces of them together. Here's an example of what I'd like to accomplish:
``... | Go through each loop, storing the post object in an array. Then at the end combine them. (This is completely untested)
<https://gist.github.com/1762204> |
41,548 | <p>I need to find a way to list all categories - empty or not - in a hierarchial list - like wp_list_categories - also showing the slug, cat name and a link to edit in the admin.</p>
<p>Here is what I have so far:</p>
<pre><code>$args = array(
'orderby' => 'name',
'order' => 'ASC',
... | [
{
"answer_id": 41558,
"author": "Ole Henrik Skogstrøm",
"author_id": 11552,
"author_profile": "https://wordpress.stackexchange.com/users/11552",
"pm_score": -1,
"selected": false,
"text": "<p>Hmm I think you need to include <code>'hierarchical' => 1,</code> in your args list. Also you... | 2012/02/07 | [
"https://wordpress.stackexchange.com/questions/41548",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7968/"
] | I need to find a way to list all categories - empty or not - in a hierarchial list - like wp\_list\_categories - also showing the slug, cat name and a link to edit in the admin.
Here is what I have so far:
```
$args = array(
'orderby' => 'name',
'order' => 'ASC',
'hide_empty' => '0',
... | output as unordered list:
```
<?php
hierarchical_category_tree( 0 ); // the function call; 0 for all categories; or cat ID
function hierarchical_category_tree( $cat ) {
// wpse-41548 // alchymyth // a hierarchical list of all categories //
$next = get_categories('hide_empty=false&orderby=name&order=ASC&... |
41,560 | <p>Our current WordPress install has a few custom tables we've placed into the WP database that hold misc. information. We've created custom option pages for the WP admin panel for our WP admin users to be able to access the information from the DB through the admin.</p>
<p>One option we want is for users to be able t... | [
{
"answer_id": 41564,
"author": "Joshua",
"author_id": 10119,
"author_profile": "https://wordpress.stackexchange.com/users/10119",
"pm_score": 0,
"selected": false,
"text": "<p>Not sure about the permissioning, without more info, but you may want to try this: <a href=\"http://codex.wordp... | 2012/02/07 | [
"https://wordpress.stackexchange.com/questions/41560",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4976/"
] | Our current WordPress install has a few custom tables we've placed into the WP database that hold misc. information. We've created custom option pages for the WP admin panel for our WP admin users to be able to access the information from the DB through the admin.
One option we want is for users to be able to delete s... | I think the problem is that by just appending `?deleteUser=XX` you get an 'illegal' url, for example:
```
http://localhost/wordpress/wp-admin/edit.php?post_type=type&page=mypage?deleteUser=xxx
```
Instead, use WordPress' [`add_query_arg`](http://codex.wordpress.org/Function_Reference/add_query_arg):
```
$url = ... |
41,565 | <p>I'm trying to intercept the install themes routine in order to alert the user from the active theme. I'm cobbling together a crude javascript alert below. What are some other options? </p>
<pre><code>if ( is_admin() && $pagenow == 'theme-install.php' && $_GET['tab']=="upload"){
?>
<script type... | [
{
"answer_id": 43999,
"author": "Tom",
"author_id": 1014,
"author_profile": "https://wordpress.stackexchange.com/users/1014",
"pm_score": 2,
"selected": true,
"text": "<p>I'm usually a fan of doing this kind of work on the server-side since it's far too easy to circumvent JavaScript on t... | 2012/02/07 | [
"https://wordpress.stackexchange.com/questions/41565",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6620/"
] | I'm trying to intercept the install themes routine in order to alert the user from the active theme. I'm cobbling together a crude javascript alert below. What are some other options?
```
if ( is_admin() && $pagenow == 'theme-install.php' && $_GET['tab']=="upload"){
?>
<script type="text/javascript">
alert('Messa... | I'm usually a fan of doing this kind of work on the server-side since it's far too easy to circumvent JavaScript on the client-side with modern debugging tools, but this is a unique problem and this may fit your use case (depending on who your audience is).
Using pure JavaScript, you can do this:
* Create a JavaScrip... |
41,566 | <p>I added a contact form to the footer. Apparently it works fine in the main page, but if I go to any of the categories, lets say myblog.com/category/, the contact form is looking for submit.php at myblog.com/category/submit.php. Where I should put physically submit.php in order for contact form to find it in any cate... | [
{
"answer_id": 43999,
"author": "Tom",
"author_id": 1014,
"author_profile": "https://wordpress.stackexchange.com/users/1014",
"pm_score": 2,
"selected": true,
"text": "<p>I'm usually a fan of doing this kind of work on the server-side since it's far too easy to circumvent JavaScript on t... | 2012/02/07 | [
"https://wordpress.stackexchange.com/questions/41566",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7552/"
] | I added a contact form to the footer. Apparently it works fine in the main page, but if I go to any of the categories, lets say myblog.com/category/, the contact form is looking for submit.php at myblog.com/category/submit.php. Where I should put physically submit.php in order for contact form to find it in any categor... | I'm usually a fan of doing this kind of work on the server-side since it's far too easy to circumvent JavaScript on the client-side with modern debugging tools, but this is a unique problem and this may fit your use case (depending on who your audience is).
Using pure JavaScript, you can do this:
* Create a JavaScrip... |
41,587 | <p>Is there any way to create our own admin theme rather than the default one.
or do we have to override the default style sheets to get the desired look??</p>
| [
{
"answer_id": 41597,
"author": "icc97",
"author_id": 5433,
"author_profile": "https://wordpress.stackexchange.com/users/5433",
"pm_score": 0,
"selected": false,
"text": "<p>Yes, you definitely can create your own admin themes. The <a href=\"http://l33t.me/executive-admin/\" rel=\"nofoll... | 2012/02/08 | [
"https://wordpress.stackexchange.com/questions/41587",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5665/"
] | Is there any way to create our own admin theme rather than the default one.
or do we have to override the default style sheets to get the desired look?? | You'll want to add your own stylesheet, e.g.:
```
add_action('admin_head', 'custom_admin_style');
function custom_admin_style() {
wp_register_style( 'adminStylesheet', plugins_url('adminstylesheet.css', __FILE__) );
wp_enqueue_style('adminStylesheet');
}
```
You can then style the admin as you like. For UI c... |