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 |
|---|---|---|---|---|---|---|
13,916 | <p>hey guys,
I couldn't find anything on the web. Is it possible to have custom template for the image attachement page. I wonder if it is possible to add a navigation to the image attachement page so people can easily navigate through a gallery.</p>
<p>Maybe it's even possible to add comments to each image?</p>
<p>e... | [
{
"answer_id": 13919,
"author": "goldenapples",
"author_id": 290,
"author_profile": "https://wordpress.stackexchange.com/users/290",
"pm_score": 3,
"selected": false,
"text": "<p>Short answer - Yes. </p>\n\n<p>Attachments are served by template files based on their mime-type, So if your ... | 2011/04/04 | [
"https://wordpress.stackexchange.com/questions/13916",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3529/"
] | hey guys,
I couldn't find anything on the web. Is it possible to have custom template for the image attachement page. I wonder if it is possible to add a navigation to the image attachement page so people can easily navigate through a gallery.
Maybe it's even possible to add comments to each image?
edit: Moreover is ... | WordPress supports several types of attachment templates. The function `get_attachment_template` in `wp-includes/theme.php` provides this support; it is called in `wp-includes/template-redirect.php`. If your theme includes `attachment.php` all of your attachments will be rendered with that template. If your theme also ... |
13,925 | <p>I need to display images and other content in the sidebar depending on a page. Pages are added dynamically and information that need to appear in the sidebar is different for each page. So I can't predict what will go where. So the idea was is to have a page's content as usual (with all the neccessary shortcodes) an... | [
{
"answer_id": 13926,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 0,
"selected": false,
"text": "<p>You can use conditional tags and do_shortcode.\n<a href=\"http://codex.wordpress.org/Function_Reference/do_shortcod... | 2011/04/04 | [
"https://wordpress.stackexchange.com/questions/13925",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1343/"
] | I need to display images and other content in the sidebar depending on a page. Pages are added dynamically and information that need to appear in the sidebar is different for each page. So I can't predict what will go where. So the idea was is to have a page's content as usual (with all the neccessary shortcodes) and t... | A shortcode handler doesn't have to return anything, it can just modify a global variable that you later read in your sidebar widget. If your sidebar is displayed after your post content (most likely if it's a right sidebar), you can do this without any problem. If your sidebar is displayed before the post content it i... |
13,944 | <p>Greetings,</p>
<p>I have a WP site with over than 150k pageviews /day.</p>
<p>It's running on a Intel Core i5 CPU 760 @ 2.80GHz, with Centos and 4 GB of RAM.</p>
<p>The problem is WP consumes too much RAM and after a while serve gets overloaded and RAM runs out. I've tried many Apache tweeks but nothing seems to ... | [
{
"answer_id": 13959,
"author": "edelwater",
"author_id": 576,
"author_profile": "https://wordpress.stackexchange.com/users/576",
"pm_score": 0,
"selected": false,
"text": "<p>Compare Nginx and Apache and make a choice: </p>\n\n<ul>\n<li><a href=\"http://www.webandblog.com/reviews/apache... | 2011/04/05 | [
"https://wordpress.stackexchange.com/questions/13944",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4445/"
] | Greetings,
I have a WP site with over than 150k pageviews /day.
It's running on a Intel Core i5 CPU 760 @ 2.80GHz, with Centos and 4 GB of RAM.
The problem is WP consumes too much RAM and after a while serve gets overloaded and RAM runs out. I've tried many Apache tweeks but nothing seems to work. After I restart Ap... | Souljacker,
I would first take a look at your plugins. **[Star Ratings for Reviews](http://plugins.trac.wordpress.org/browser/star-rating-for-reviews/trunk/star-rating.php?rev=66785)** hasn't been updated for over 3 years and looks like its real heavy on the db. I saw some raw sql with some INNER JOINS that look troub... |
13,962 | <p>I've created a site using wordpress and i moved that from localhost to new server.</p>
<p>The steps i've followed is just got backup of old db from localhost and uploaded them to the new server. Changed the WordPress address (URL) & Site address (URL) manually from phpmyadmin.</p>
<p>Moved all the files from l... | [
{
"answer_id": 13964,
"author": "MikeSchinkel",
"author_id": 89,
"author_profile": "https://wordpress.stackexchange.com/users/89",
"pm_score": 0,
"selected": false,
"text": "<p>Hi <strong>@kvijayhari:</strong></p>\n\n<p>You probably need to follow the instructions here about changing you... | 2011/04/05 | [
"https://wordpress.stackexchange.com/questions/13962",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4452/"
] | I've created a site using wordpress and i moved that from localhost to new server.
The steps i've followed is just got backup of old db from localhost and uploaded them to the new server. Changed the WordPress address (URL) & Site address (URL) manually from phpmyadmin.
Moved all the files from localhost to the serve... | I solved it myself..
It was issue in the windows server with wordpress 3.1 so i installed the Permalink fix pack @ [wordpress.org/extend/plugins/… .](http://wordpress.org/extend/plugins/permalink-fix-disable-canonical-redirects-pack/)
Now its working fine.. I've no issues linux server..
I've to dive into the thing t... |
13,968 | <p>I've been pulling my hair out on this one - I need to hard code in <code>wp_get_archives()</code> for a specific category into a template.</p>
<p>This post was useful:</p>
<p><a href="https://wordpress.stackexchange.com/questions/13288/category-specific-archive">Category Specific Archive</a></p>
<p>but, as with a... | [
{
"answer_id": 13980,
"author": "matpol",
"author_id": 4011,
"author_profile": "https://wordpress.stackexchange.com/users/4011",
"pm_score": 0,
"selected": false,
"text": "<p>Perhaps use query_posts to generate your query and then use a custom loop.</p>\n\n<p><a href=\"http://codex.wordp... | 2011/04/05 | [
"https://wordpress.stackexchange.com/questions/13968",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2685/"
] | I've been pulling my hair out on this one - I need to hard code in `wp_get_archives()` for a specific category into a template.
This post was useful:
[Category Specific Archive](https://wordpress.stackexchange.com/questions/13288/category-specific-archive)
but, as with all the plugins I've found so far, they don't w... | I did this in a relatively complicated way using a custom query. I did not know about Smart Archives Reloaded so I wrote code myself. But it works. Replace your category ID for "term\_taxonomy.term\_id"
```
<?php
global $wpdb, $wp_locale;
$query = "select YEAR(post_date) AS `ye... |
13,981 | <p>With our website, we want to make it so that if the site is about to go down, it instead displays a custom 503 (based on a server load limit set by us). Is there something that can handle this that is already built in, or a plugin that might help? </p>
<p><em>I know manual switching maintenance mode plugins are ava... | [
{
"answer_id": 13986,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>You can customize message for when database is down by drop-in <code>db-error.php</code> in <code>wp-content</code> ... | 2011/04/05 | [
"https://wordpress.stackexchange.com/questions/13981",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4453/"
] | With our website, we want to make it so that if the site is about to go down, it instead displays a custom 503 (based on a server load limit set by us). Is there something that can handle this that is already built in, or a plugin that might help?
*I know manual switching maintenance mode plugins are available but if... | If your system is on linux, you can read the actual server load from `/proc/loadavg`
For example:
```
$load = reset ( explode ( ' ' , file_get_contents('/proc/loadavg') ) );
if ($load > 3.14 )
{
// load too high,
header('HTTP/1.1 503 Service Temporarily Unavailable');
header('Status: 503 Service Tempora... |
14,002 | <p>for a small project i need to assign the <a href="http://wordpress.org/extend/plugins/the-events-calendar/" rel="nofollow">The Events Calendar</a> Plugin to an subpage but i've found no solution in the documentation.</p>
<p>Does anyone know if this is possible or has an idea to get it done?</p>
<p>Regards</p>
| [
{
"answer_id": 24855,
"author": "Michelle",
"author_id": 16,
"author_profile": "https://wordpress.stackexchange.com/users/16",
"pm_score": 0,
"selected": false,
"text": "<p>Do you mean you want to display the calendar on a sub page? If so you can use this shortcode on the page where you ... | 2011/04/05 | [
"https://wordpress.stackexchange.com/questions/14002",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4408/"
] | for a small project i need to assign the [The Events Calendar](http://wordpress.org/extend/plugins/the-events-calendar/) Plugin to an subpage but i've found no solution in the documentation.
Does anyone know if this is possible or has an idea to get it done?
Regards | Here's a basic page template for displaying an events calendar in grid form based on the grid template bundled with the plugin. Edit as necessary to match the styling and layout of your theme:
```
<?php
/**
* Template Name: Event Gridview
**/
global $spEvents;
$spEvents->loadDomainStylesScripts();
get_header();
qu... |
14,004 | <p>First a teeny bit of background... I have a custom post type where I'd like to use custom post statuses. Since custom post statuses <a href="http://www.usingenglish.com/forum/ask-teacher/4657-plural-word-status.html" rel="nofollow noreferrer">(stati/status/whatever)</a>, have not been fully implemented within the c... | [
{
"answer_id": 14011,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": true,
"text": "<p>First, you have nasty typo in <code>__contsruct</code>. :)</p>\n\n<p>Second, your hook timing is wrong. Related WP Ja... | 2011/04/05 | [
"https://wordpress.stackexchange.com/questions/14004",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2807/"
] | First a teeny bit of background... I have a custom post type where I'd like to use custom post statuses. Since custom post statuses [(stati/status/whatever)](http://www.usingenglish.com/forum/ask-teacher/4657-plural-word-status.html), have not been fully implemented within the core, I've decided to use the gettetext fi... | First, you have nasty typo in `__contsruct`. :)
Second, your hook timing is wrong. Related WP JavaScript is localized via `postL10n` object (you can see it echoed in page's source), that gets put together on `init` hook - way earlier then `admin_head` and your filter is not in place yet.
From quick test this should d... |
14,024 | <p>I'm going to be using add_role() and $role->add_cap() to set up a new custom role and attach a new capability to existing roles.</p>
<p>I'm wondering where the best place to do this is? Obviously I can do it straight inside functions.php and be done with it. But is this the best practice? Do I only need to do this ... | [
{
"answer_id": 14025,
"author": "Andy",
"author_id": 498,
"author_profile": "https://wordpress.stackexchange.com/users/498",
"pm_score": 3,
"selected": false,
"text": "<p>For plugins, I have had success using <code>plugins_loaded</code> for this. For themes, I would use <code>after_setup... | 2011/04/05 | [
"https://wordpress.stackexchange.com/questions/14024",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3687/"
] | I'm going to be using add\_role() and $role->add\_cap() to set up a new custom role and attach a new capability to existing roles.
I'm wondering where the best place to do this is? Obviously I can do it straight inside functions.php and be done with it. But is this the best practice? Do I only need to do this on admin... | When adding a role and capabilities you only need to run the code once since the roles and capabilities are saved to the database when using `add_role` or `->add_cap` functions so just like Andy said you can use `after_setup_theme` for this kind of action but add some kind of check so it only runs once, like [register\... |
14,037 | <p>Normal Wordpress Menu looks like:</p>
<blockquote>
<p>Home | Blog | About us | Contact</p>
</blockquote>
<p>But I've seen many pages with descriptions under these links:</p>
<blockquote>
<p>Home Page | Our Blogs | About us
| Contact<br>
....meet us...| read more| basic info| contact form... | [
{
"answer_id": 14039,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 8,
"selected": true,
"text": "<p>You need a custom walker for the nav menu.</p>\n\n<p>Basically, you add a parameter <code>'walker'</code> to the <a hre... | 2011/04/05 | [
"https://wordpress.stackexchange.com/questions/14037",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1869/"
] | Normal Wordpress Menu looks like:
>
> Home | Blog | About us | Contact
>
>
>
But I've seen many pages with descriptions under these links:
>
> Home Page | Our Blogs | About us
> | Contact
>
> ....meet us...| read more| basic info| contact form
>
>
>
How to achieve this?
(I want it to be core function ... | You need a custom walker for the nav menu.
Basically, you add a parameter `'walker'` to the [`wp_nav_menu()`](https://developer.wordpress.org/reference/functions/wp_nav_menu/) options and call an instance of an enhanced class:
```
wp_nav_menu(
array (
'menu' => 'main-menu',
'container' ... |
14,045 | <p>I'm writing a plugin for WordPress that dynamically generates content from a Google Documents Spreadsheet. Specifically, the plugin provides a shortcode that generates a good-looking staff list. It works, but there are two problems:</p>
<ol>
<li>Pages that use the shortcode load a little slow, because they have to ... | [
{
"answer_id": 14054,
"author": "petermolnar",
"author_id": 4209,
"author_profile": "https://wordpress.stackexchange.com/users/4209",
"pm_score": 0,
"selected": false,
"text": "<p>I see two ways</p>\n\n<p>If speed is important, than caching would solve both of your problems. If you can s... | 2011/04/06 | [
"https://wordpress.stackexchange.com/questions/14045",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4475/"
] | I'm writing a plugin for WordPress that dynamically generates content from a Google Documents Spreadsheet. Specifically, the plugin provides a shortcode that generates a good-looking staff list. It works, but there are two problems:
1. Pages that use the shortcode load a little slow, because they have to make multiple... | The `wp_posts` table has a `post_content_filtered` column that [plugins can use to cache expensive post content filters](http://lists.automattic.com/pipermail/wp-hackers/2005-April/000672.html). The idea is that when you display the page, you don't read `post_content` but you read `post_content_filtered`. This is nice,... |
14,063 | <p>Conditionally Including scripts whether js or css in xhtml document head...has been a generally tricky affair, especially if you want to enqueue something, based on a shortcode or custom meta field or a widget.</p>
<p>If you know that you need your script for sure,you would just do what the <a href="http://codex.wo... | [
{
"answer_id": 14070,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>For such stuff there is <code>wp_enqueue_scripts</code> action that fires early (priority 1) inside <code>wp_head</c... | 2011/04/06 | [
"https://wordpress.stackexchange.com/questions/14063",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3081/"
] | Conditionally Including scripts whether js or css in xhtml document head...has been a generally tricky affair, especially if you want to enqueue something, based on a shortcode or custom meta field or a widget.
If you know that you need your script for sure,you would just do what the [Wordpress Codex](http://codex.wor... | >
> To circumvent this, you can use `strpos()` with `the_posts` hook, which gets fired before wp\_head. But one of the drawbacks is that its an extra pass at the data.
>
>
>
You're essentially doing the same inside the callback you're hooking onto `wp_head`, i don't see the difference.. (please clarify if you thin... |
14,066 | <p>I'd like to be able to show sticky posts at the top of category pages. I'm using archive.php for my category page.</p>
<p>I'm using the code below to display sticky posts at the top of my category archive page followed by the rest of the posts within that category.</p>
<p>This works fine, until there are no sticky... | [
{
"answer_id": 14067,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Use <code>wp_reset_query()</code> after <code>query_posts()</code>. We have <a href=\"https://wordpress.stackexchange.... | 2011/04/06 | [
"https://wordpress.stackexchange.com/questions/14066",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4288/"
] | I'd like to be able to show sticky posts at the top of category pages. I'm using archive.php for my category page.
I'm using the code below to display sticky posts at the top of my category archive page followed by the rest of the posts within that category.
This works fine, until there are no sticky posts to display... | try to use a conditional statement to wrap the first loop, such as:
```
if( get_option('sticky_posts') ) : //only do the next part if sticky posts
```
add the corresponding `endif;` after the `endif;` of the first loop. |
14,090 | <p>I am currently developing my new theme over at testing.detailsofmylife.net and I am using a WooThemes template as my basic design. </p>
<p>I want to try and include their WooTabs widget as graphically I think it is quite appealing for displaying post data to visitors. I know a lot of you aren't fond of TimThumb but... | [
{
"answer_id": 14096,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": false,
"text": "<p>I would suggest using WordPress core image media management and thumbnail generation. Substituting TimThumb... | 2011/04/06 | [
"https://wordpress.stackexchange.com/questions/14090",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4485/"
] | I am currently developing my new theme over at testing.detailsofmylife.net and I am using a WooThemes template as my basic design.
I want to try and include their WooTabs widget as graphically I think it is quite appealing for displaying post data to visitors. I know a lot of you aren't fond of TimThumb but it is the... | The fact that some images work tells me that TimThumb is behaving fine.
If you go to the broken image url you will see that the error is 'no mime type specified' which tells me the issue is with the image rather than the script. I would suggest resaving the image and seeing if that fixes the problem.
For reference th... |
14,092 | <p>OK, I have an issue with <a href="http://downloads.wordpress.org/plugin/sidebar-generator.1.1.zip" rel="nofollow">Sidebar Generator Plugin</a>.</p>
<p>This plugin creates subpage called "Sidebars" in WP-Admin. The point is, it is created as a child of "Appearance" page.</p>
<p>And I don't want it here, I want "Sid... | [
{
"answer_id": 14096,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": false,
"text": "<p>I would suggest using WordPress core image media management and thumbnail generation. Substituting TimThumb... | 2011/04/06 | [
"https://wordpress.stackexchange.com/questions/14092",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1869/"
] | OK, I have an issue with [Sidebar Generator Plugin](http://downloads.wordpress.org/plugin/sidebar-generator.1.1.zip).
This plugin creates subpage called "Sidebars" in WP-Admin. The point is, it is created as a child of "Appearance" page.
And I don't want it here, I want "Sidebars" to be a subpage of my own Page named... | The fact that some images work tells me that TimThumb is behaving fine.
If you go to the broken image url you will see that the error is 'no mime type specified' which tells me the issue is with the image rather than the script. I would suggest resaving the image and seeing if that fixes the problem.
For reference th... |
14,097 | <p>When doing an automatic upgrade, I get this:</p>
<p>Downloading update from <a href="http://wordpress.org/wordpress-3.1.1.zip" rel="nofollow">http://wordpress.org/wordpress-3.1.1.zip</a>…</p>
<p>Unpacking the update…</p>
<p>Could not create directory.: /public_html</p>
<p>Installation Failed</p>
<p>All my wp fi... | [
{
"answer_id": 14096,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": false,
"text": "<p>I would suggest using WordPress core image media management and thumbnail generation. Substituting TimThumb... | 2011/04/06 | [
"https://wordpress.stackexchange.com/questions/14097",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4224/"
] | When doing an automatic upgrade, I get this:
Downloading update from <http://wordpress.org/wordpress-3.1.1.zip>…
Unpacking the update…
Could not create directory.: /public\_html
Installation Failed
All my wp files are in /public\_html and the directory already exists. The FTP user I am logging in as owns all the W... | The fact that some images work tells me that TimThumb is behaving fine.
If you go to the broken image url you will see that the error is 'no mime type specified' which tells me the issue is with the image rather than the script. I would suggest resaving the image and seeing if that fixes the problem.
For reference th... |
14,103 | <p>Just like the title states. I've added around 20+ custom fields into my wordpress site and only around 10 are showing in the drop down.</p>
<p>The custom fields are all functioning fine on the site side, but they just aren't showing up in the drop down.
<img src="https://i.stack.imgur.com/DRWUn.jpg" alt="enter imag... | [
{
"answer_id": 14117,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 2,
"selected": false,
"text": "<p>From the looks of things, you just have <em>way too many</em> custom fields. I would highly recommend creating a few... | 2011/04/06 | [
"https://wordpress.stackexchange.com/questions/14103",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1972/"
] | Just like the title states. I've added around 20+ custom fields into my wordpress site and only around 10 are showing in the drop down.
The custom fields are all functioning fine on the site side, but they just aren't showing up in the drop down.
 | There's a limit set inside the function that lists the meta data.
<http://core.trac.wordpress.org/browser/tags/3.1/wp-admin/includes/template.php#L512>
Run a filter on `postmeta_form_limit` to increase to your desired value, eg.
```
add_filter( 'postmeta_form_limit', 'meta_limit_increase' );
function meta_limit_incr... |
14,108 | <p>I have created custom post types that also have custom meta_boxes I've created. Currently, they save when I publish or update a post, but they don't save when I'm in draft mode making changes.</p>
<pre><code>add_action('save_post', 'save_details');
function save_details(){
if ( defined('DOING_AUTOSAVE') &&... | [
{
"answer_id": 14117,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 2,
"selected": false,
"text": "<p>From the looks of things, you just have <em>way too many</em> custom fields. I would highly recommend creating a few... | 2011/04/06 | [
"https://wordpress.stackexchange.com/questions/14108",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3577/"
] | I have created custom post types that also have custom meta\_boxes I've created. Currently, they save when I publish or update a post, but they don't save when I'm in draft mode making changes.
```
add_action('save_post', 'save_details');
function save_details(){
if ( defined('DOING_AUTOSAVE') && DOING_AUTOSAVE ) {
... | There's a limit set inside the function that lists the meta data.
<http://core.trac.wordpress.org/browser/tags/3.1/wp-admin/includes/template.php#L512>
Run a filter on `postmeta_form_limit` to increase to your desired value, eg.
```
add_filter( 'postmeta_form_limit', 'meta_limit_increase' );
function meta_limit_incr... |
14,120 | <p>I have a widget that shows all the post names. All the post names are "Chapter ## - Title"</p>
<p>I would like the php in the widget to remove the "Chapter 1 -" or "Chapter 12 -" for example so that just the part after the Chapter is left....</p>
| [
{
"answer_id": 14117,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 2,
"selected": false,
"text": "<p>From the looks of things, you just have <em>way too many</em> custom fields. I would highly recommend creating a few... | 2011/04/06 | [
"https://wordpress.stackexchange.com/questions/14120",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4088/"
] | I have a widget that shows all the post names. All the post names are "Chapter ## - Title"
I would like the php in the widget to remove the "Chapter 1 -" or "Chapter 12 -" for example so that just the part after the Chapter is left.... | There's a limit set inside the function that lists the meta data.
<http://core.trac.wordpress.org/browser/tags/3.1/wp-admin/includes/template.php#L512>
Run a filter on `postmeta_form_limit` to increase to your desired value, eg.
```
add_filter( 'postmeta_form_limit', 'meta_limit_increase' );
function meta_limit_incr... |
14,121 | <p>I'm using a custom post type with custom meta fields, but autosave and the "unsaved changes" dialog don't seem to be triggered for these custom meta fields. Autosave isn't as important to me as the unsaved changes dialog - is there a way to trigger it?</p>
<pre><code>function add_meta_boxes() {
add_meta_box('pl... | [
{
"answer_id": 14161,
"author": "Jan Fabry",
"author_id": 8,
"author_profile": "https://wordpress.stackexchange.com/users/8",
"pm_score": 3,
"selected": true,
"text": "<p>The code indeed <a href=\"http://core.trac.wordpress.org/browser/tags/3.1.1/wp-includes/js/autosave.dev.js#L30\" rel=... | 2011/04/06 | [
"https://wordpress.stackexchange.com/questions/14121",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1571/"
] | I'm using a custom post type with custom meta fields, but autosave and the "unsaved changes" dialog don't seem to be triggered for these custom meta fields. Autosave isn't as important to me as the unsaved changes dialog - is there a way to trigger it?
```
function add_meta_boxes() {
add_meta_box('places_location'... | The code indeed [only looks at the TinyMCE editor](http://core.trac.wordpress.org/browser/tags/3.1.1/wp-includes/js/autosave.dev.js#L30) or the title and content field if the editor is hidden:
```
window.onbeforeunload = function(){
var mce = typeof(tinyMCE) != 'undefined' ? tinyMCE.activeEditor : false, title, co... |
14,126 | <p>I was hoping it would be possible to save original images to a separate directory to the resized images so that they could be safely hidden but this seems to be too difficult.</p>
<p>So I am now asking if there are any ways of protecting original full-size images from public but still allow them to view the re-size... | [
{
"answer_id": 14131,
"author": "Wordpressor",
"author_id": 1869,
"author_profile": "https://wordpress.stackexchange.com/users/1869",
"pm_score": 1,
"selected": false,
"text": "<p>There's only one thing I know for sure - your images will be NEVER secure if you display their thumbnails ba... | 2011/04/06 | [
"https://wordpress.stackexchange.com/questions/14126",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4316/"
] | I was hoping it would be possible to save original images to a separate directory to the resized images so that they could be safely hidden but this seems to be too difficult.
So I am now asking if there are any ways of protecting original full-size images from public but still allow them to view the re-sized images.
... | I was looking for a way to do this and found this page... then I thought of putting this in a .htaccess file in the WordPress uploads folder and it works for me so far... any good?
```
<FilesMatch "\.jpg$">
order allow,deny
deny from all
</FilesMatch>
<FilesMatch "-[0-9]+x[0-9]+\.jpg$">
order allow,deny
... |
14,132 | <p>Hi to all I need to run this twice a day:</p>
<pre><code>UPDATE wp_posts SET post_content = REPLACE ( post_content, '[img]', '<img src="' );
UPDATE wp_posts SET post_content = REPLACE ( post_content, '[IMG]', '<img src="' );
UPDATE wp_posts SET post_content = REPLACE ( post_content, '[/img]', '" />' );
UPD... | [
{
"answer_id": 14131,
"author": "Wordpressor",
"author_id": 1869,
"author_profile": "https://wordpress.stackexchange.com/users/1869",
"pm_score": 1,
"selected": false,
"text": "<p>There's only one thing I know for sure - your images will be NEVER secure if you display their thumbnails ba... | 2011/04/07 | [
"https://wordpress.stackexchange.com/questions/14132",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4107/"
] | Hi to all I need to run this twice a day:
```
UPDATE wp_posts SET post_content = REPLACE ( post_content, '[img]', '<img src="' );
UPDATE wp_posts SET post_content = REPLACE ( post_content, '[IMG]', '<img src="' );
UPDATE wp_posts SET post_content = REPLACE ( post_content, '[/img]', '" />' );
UPDATE wp_posts SET post_c... | I was looking for a way to do this and found this page... then I thought of putting this in a .htaccess file in the WordPress uploads folder and it works for me so far... any good?
```
<FilesMatch "\.jpg$">
order allow,deny
deny from all
</FilesMatch>
<FilesMatch "-[0-9]+x[0-9]+\.jpg$">
order allow,deny
... |
14,135 | <p>I have a rating system where the user can enter a custom field of either "Stars" or "Hearts", but whichever one they choose they have to enter a value of 1 thru 5. Using wp_query, I can successfully sort by one of these custom fields, but I'm not sure how to sort by both. Here is the code I'm using to sort by one of... | [
{
"answer_id": 14138,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 1,
"selected": false,
"text": "<p>How about creating two custom fields:</p>\n\n<pre><code>rating_type = 'stars' or 'hearts'\nrating_score = 1-5... | 2011/04/07 | [
"https://wordpress.stackexchange.com/questions/14135",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/274/"
] | I have a rating system where the user can enter a custom field of either "Stars" or "Hearts", but whichever one they choose they have to enter a value of 1 thru 5. Using wp\_query, I can successfully sort by one of these custom fields, but I'm not sure how to sort by both. Here is the code I'm using to sort by one of t... | I had the same problem and could not find a way to make this work with wp\_query alone. Instead, I caught the posts\_clauses filter and stuck my order\_by there. This also meant doing a few joins.
Basically, you set a function to catch the posts\_clauses (or one of the more restrictive query filters; but let's just us... |
14,150 | <p>I'm trying to create links to the next and previous posts within a specific tag (on the post page itself), but I can't seem to find a plugin or source that does this. </p>
<p>I want to be able to something like this, appearing below the post.</p>
<pre><code>get_previous_link("tagname");
get_next_link("tagname");
<... | [
{
"answer_id": 14151,
"author": "Jan Fabry",
"author_id": 8,
"author_profile": "https://wordpress.stackexchange.com/users/8",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/get_adjacent_post\"><code>get_adjacent_post()</code></a>, wh... | 2011/04/07 | [
"https://wordpress.stackexchange.com/questions/14150",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2576/"
] | I'm trying to create links to the next and previous posts within a specific tag (on the post page itself), but I can't seem to find a plugin or source that does this.
I want to be able to something like this, appearing below the post.
```
get_previous_link("tagname");
get_next_link("tagname");
```
Anybody know of ... | [`get_adjacent_post()`](http://codex.wordpress.org/Function_Reference/get_adjacent_post), which is used by all functions that return a (link to) the next or previous post, only has a `$in_same_cat` argument, which looks at the categories the post is in, not the tags.
You could hook into the `get_[next|previous]_post_j... |
14,163 | <p>Each post has a lat/lng value attached to it via postmeta. I'm trying to grab all posts within a bounding lat/lng value. Here's the <code>get_posts</code> query:</p>
<pre><code>$posts = get_posts(array(
'posts_per_page' => 100,
'post_type' => 'place',
'post_status' => 'publish',
'meta_query... | [
{
"answer_id": 14178,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 4,
"selected": true,
"text": "<p>You can filter generated SQL and add precision parameters that you need.</p>\n\n<p>Enable filters for <code>get_posts... | 2011/04/07 | [
"https://wordpress.stackexchange.com/questions/14163",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1571/"
] | Each post has a lat/lng value attached to it via postmeta. I'm trying to grab all posts within a bounding lat/lng value. Here's the `get_posts` query:
```
$posts = get_posts(array(
'posts_per_page' => 100,
'post_type' => 'place',
'post_status' => 'publish',
'meta_query' => array(
array(
... | You can filter generated SQL and add precision parameters that you need.
Enable filters for `get_posts()` by adding following to query:
```
'suppress_filters' => false,
```
And:
```
add_filter('posts_where','cast_decimal_precision');
function cast_decimal_precision( $where ) {
return str_replace('DECIMAL','D... |
14,169 | <p>I see the following pattern over and over, <a href="https://wordpress.stackexchange.com/search?q=doing_autosave">on this site</a> and on other places:</p>
<pre><code>add_action( 'save_post', 'wpse14169_save_post' );
function wpse14169_save_post( $post_id )
{
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUT... | [
{
"answer_id": 14173,
"author": "John P Bloch",
"author_id": 11,
"author_profile": "https://wordpress.stackexchange.com/users/11",
"pm_score": 4,
"selected": true,
"text": "<p>The <code>'save_post'</code> action was <a href=\"http://core.trac.wordpress.org/browser/tags/2.0/wp-includes/fu... | 2011/04/07 | [
"https://wordpress.stackexchange.com/questions/14169",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8/"
] | I see the following pattern over and over, [on this site](https://wordpress.stackexchange.com/search?q=doing_autosave) and on other places:
```
add_action( 'save_post', 'wpse14169_save_post' );
function wpse14169_save_post( $post_id )
{
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return $post_id... | The `'save_post'` action was [added to core in 2.0](http://core.trac.wordpress.org/browser/tags/2.0/wp-includes/functions-post.php#L205), and has always been an action. Looking through the current autosave procedures, it doesn't appear to call the `'save_post'` action directly at any time.
So the short answer is, no. ... |
14,176 | <p>I'm getting a puzzling error when I var_dump on $menu_id in the code below...</p>
<p>First, the test code to create a custom menu on the fly and assign it to a registered menu location called "header-menu" (creates the menu but fails in assigning it to the theme's menu location)...</p>
<pre><code>$menu_id = wp_cre... | [
{
"answer_id": 14209,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 3,
"selected": true,
"text": "<p>I got that same error when i put the code you posted in my functions file so i wrapped it up in an if to run o... | 2011/04/07 | [
"https://wordpress.stackexchange.com/questions/14176",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/366/"
] | I'm getting a puzzling error when I var\_dump on $menu\_id in the code below...
First, the test code to create a custom menu on the fly and assign it to a registered menu location called "header-menu" (creates the menu but fails in assigning it to the theme's menu location)...
```
$menu_id = wp_create_nav_menu('my_te... | I got that same error when i put the code you posted in my functions file so i wrapped it up in an if to run only once and i get the menu id using get\_term\_by and i assign the menu location using set\_theme\_mod() so here is your very own function to assign a menu to a location:
```
function scotts_set_nav_menu($men... |
14,181 | <p>I have just managed to get my site running behind a Cloudfront distribution using the custom distribution API, but now i cannot login to the site using the standard old address (since i screwed around with DNS).
The way i have it hooked up is as follows:</p>
<p>backendblog - real server
blog - cloud front distribu... | [
{
"answer_id": 36500,
"author": "Andrew Shell",
"author_id": 7776,
"author_profile": "https://wordpress.stackexchange.com/users/7776",
"pm_score": 1,
"selected": false,
"text": "<p>I've been working on this exact same issue. What you need to do is have two domains. One for your backend... | 2011/04/07 | [
"https://wordpress.stackexchange.com/questions/14181",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4506/"
] | I have just managed to get my site running behind a Cloudfront distribution using the custom distribution API, but now i cannot login to the site using the standard old address (since i screwed around with DNS).
The way i have it hooked up is as follows:
backendblog - real server
blog - cloud front distribution told ... | I've been working on this exact same issue. What you need to do is have two domains. One for your backendblog and one that pointing at cloudfront. Your backendblog will be configured to serve up as itself (backendblog). In my test example I'm using my [blog](http://blog.andrewshell.org) as the backendblog.
If this wa... |
14,187 | <p>have a website (www.americanbankingnews.com) that gets 40,000-50,000 page views today. It's currently sitting on a dedicated quad-core Xeon server with 8GB of ram. The site is powered by WordPress and MySQL (sitting on the same server) and I'm currently using W3 Total Cache for page and MySQL query Caching.</p>
<p>... | [
{
"answer_id": 14189,
"author": "markratledge",
"author_id": 268,
"author_profile": "https://wordpress.stackexchange.com/users/268",
"pm_score": 2,
"selected": false,
"text": "<p>Lots of similar questions and answers:\n<a href=\"https://wordpress.stackexchange.com/search?q=mysql+optimize... | 2011/04/07 | [
"https://wordpress.stackexchange.com/questions/14187",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4510/"
] | have a website (www.americanbankingnews.com) that gets 40,000-50,000 page views today. It's currently sitting on a dedicated quad-core Xeon server with 8GB of ram. The site is powered by WordPress and MySQL (sitting on the same server) and I'm currently using W3 Total Cache for page and MySQL query Caching.
Unfortunat... | ### Hi Matthew Paulson,
I see your using W3 Total Cache but your database and object cache is set to disk. Caching objects and your database to disk can actually have a negative performance effect especially if your getting that much traffic.
You can read more about the effects on caching database and objects to disk... |
14,198 | <p>my situation: I have a frontpage which filters 12 thumbnails out of 24 (each thumbnail represents a post's featured image), and displays them. The user has the ability to hide whichever post he wants from the frontpage. </p>
<p>Let's say the user chooses to hide thumb #4, that means we now have thumb 1,2,3,5,6,7,8,... | [
{
"answer_id": 14199,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": false,
"text": "<blockquote>\n <p>I presume WordPress plugins are made by third parties.</p>\n</blockquote>\n\n<p>For the mom... | 2011/04/07 | [
"https://wordpress.stackexchange.com/questions/14198",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4513/"
] | my situation: I have a frontpage which filters 12 thumbnails out of 24 (each thumbnail represents a post's featured image), and displays them. The user has the ability to hide whichever post he wants from the frontpage.
Let's say the user chooses to hide thumb #4, that means we now have thumb 1,2,3,5,6,7,8,9,10,11,12... | >
> I presume WordPress plugins are made by third parties.
>
>
>
For the moment, yes; all except for "Hello Dolly!" and "Akismet", which are part of the core distribution.
>
> Do plugins have to be kept up to date
> with WordPress upgrades?
>
>
>
Certainly they *should* be; but they're not *required* to be ... |
14,205 | <p>I am using the code below to include jQuery in my Wordpress installation. I was previous calling the jQuery file using the standard HTML script but this was causing problems with a Wordpress plugin in IE9. When I use the wp_enqueue_script function, it solves the problem but then it breaks my custom Javascript file... | [
{
"answer_id": 14206,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>Multiple issues here:</p>\n\n<ul>\n<li>including external version of jQuery without deregistering version bundled wi... | 2011/04/07 | [
"https://wordpress.stackexchange.com/questions/14205",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1020/"
] | I am using the code below to include jQuery in my Wordpress installation. I was previous calling the jQuery file using the standard HTML script but this was causing problems with a Wordpress plugin in IE9. When I use the wp\_enqueue\_script function, it solves the problem but then it breaks my custom Javascript file wh... | 1) Only include scripts via wp\_head(). For your custom script, register and enqueue it as such:
```
function mytheme_custom_scripts() {
if ( ! is_admin() ) {
$scriptsrc = get_stylesheet_directory_uri() . '/js/';
wp_register_script( 'mytheme_custom', $scriptsrc . 'custom.js' );
wp_enque... |
14,218 | <p><strong>I have loop, wich create news feed, it looks like:</strong></p>
<p>(part of news template)</p>
<p>News.php
</p>
<pre><code> <div id="content">
<div class="scrollArea">
<?php query_posts('category_name=News');?>
<?php if (have_posts()) ... | [
{
"answer_id": 14246,
"author": "petermolnar",
"author_id": 4209,
"author_profile": "https://wordpress.stackexchange.com/users/4209",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Next_and_Previous_Links\" rel=\"nofollow\">http://codex.wordpress.org/N... | 2011/04/07 | [
"https://wordpress.stackexchange.com/questions/14218",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4519/"
] | **I have loop, wich create news feed, it looks like:**
(part of news template)
News.php
```
<div id="content">
<div class="scrollArea">
<?php query_posts('category_name=News');?>
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div class="n... | Use [comment\_form()](http://codex.wordpress.org/Function_Reference/comment_form) not a self made code. See the answers to [question 15179](https://wordpress.stackexchange.com/questions/15179/what-are-the-current-recommended-best-practices-for-comments-php/15201#15201) for a working example of a comments.php. |
14,230 | <p>I am setting up a site where there will be multiple users as Author, the owner doesn't want the authors to be able to view each others posts, since there are some meta fields with information he'd rather not have shared between the authors.</p>
<p>Is there a way to remove the ability to view other authors posts?</p... | [
{
"answer_id": 14237,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 1,
"selected": false,
"text": "<p>That is exactly what the default \"author\" role does.\n<a href=\"http://codex.wordpress.org/Roles_and_Capabilities... | 2011/04/08 | [
"https://wordpress.stackexchange.com/questions/14230",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4090/"
] | I am setting up a site where there will be multiple users as Author, the owner doesn't want the authors to be able to view each others posts, since there are some meta fields with information he'd rather not have shared between the authors.
Is there a way to remove the ability to view other authors posts?
Thanks,
Chu... | If you want to prevent a user with the "Author" role to view other users' posts in the overview screen (they won't be able to view the details anyway), you can add an extra filter on the author:
```
add_action( 'load-edit.php', 'wpse14230_load_edit' );
function wpse14230_load_edit()
{
add_action( 'request', 'wpse1... |
14,238 | <p>I've got an <code>if ($comment->user_id)</code> block to pick an default admin comment gravatar (different than a non-user's). But I'd still like this gravatar to be used if a user comments using their registered email, even if they comment while not logged in. What is the best way to test for this?</p>
<p><stro... | [
{
"answer_id": 14285,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>You can simplly check</p>\n\n<pre><code>if ($comment->user_id > 0){\n//comment by registered user\n}els... | 2011/04/08 | [
"https://wordpress.stackexchange.com/questions/14238",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4258/"
] | I've got an `if ($comment->user_id)` block to pick an default admin comment gravatar (different than a non-user's). But I'd still like this gravatar to be used if a user comments using their registered email, even if they comment while not logged in. What is the best way to test for this?
**EDIT**
I'm already using
... | ```
if ($comment->user_id || email_exists($comment->comment_author_email)){
//comment by registered user
$avatar = '/images/registered_user.png';
}else{
//comment by none registered user
$avatar = '/images/non_registered_user.png';
}
```
with
``... |
14,250 | <p>I want to be able to create custom login errors.</p>
<p>For instance if a user visits a restricted area without being logged in then I am redirecting to <code>wp-login.php?ref=access</code> and I would like to output <code>Restricted area, please login to continue.</code> or something similar.</p>
<p>Any idea how ... | [
{
"answer_id": 14252,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": true,
"text": "<p>From quick look at the login screen code (ouch):</p>\n\n<pre><code>add_action('login_head','ref_access');\n\nfunction... | 2011/04/08 | [
"https://wordpress.stackexchange.com/questions/14250",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4529/"
] | I want to be able to create custom login errors.
For instance if a user visits a restricted area without being logged in then I am redirecting to `wp-login.php?ref=access` and I would like to output `Restricted area, please login to continue.` or something similar.
Any idea how to do this. I found that there are filt... | From quick look at the login screen code (ouch):
```
add_action('login_head','ref_access');
function ref_access() {
global $error;
if( !empty($_GET['ref']) && 'access' == $_GET['ref'] )
$error = 'Restricted area, please login to continue.';
}
``` |
14,257 | <p>I just stepped into the concept of <strong>post formats</strong> and was wondering why there are two out of 3 functions from the post format "API" offer absolutely the same functionality. Consider the following two concepts (A vs. B):</p>
<pre><code>if ( have_posts() )
{
while ( have_posts() )
{
the... | [
{
"answer_id": 14261,
"author": "Drew Gourley",
"author_id": 4282,
"author_profile": "https://wordpress.stackexchange.com/users/4282",
"pm_score": 2,
"selected": false,
"text": "<p>Simple, has_post_format() returns a true/false (Boolean) value which is useful in IF statements, while get_... | 2011/04/08 | [
"https://wordpress.stackexchange.com/questions/14257",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/385/"
] | I just stepped into the concept of **post formats** and was wondering why there are two out of 3 functions from the post format "API" offer absolutely the same functionality. Consider the following two concepts (A vs. B):
```
if ( have_posts() )
{
while ( have_posts() )
{
the_post();
// A) has... | Edit
----
`has_post_format()` requires a string, `$format`, as the first parameter; which means that it can only be used to test for explicit post-format types:
```
if ( has_post_format( $format ) {
// Current post has the $format post format;
// do something
}
```
To determine if a post has *any* post form... |
14,266 | <p>I have a child-theme -> parent-theme setup, where I need to have stylesheet called generated.css loaded in addition to the style.css file added by the active child-theme. The generated.css file is residing in the parent-theme and is being dynamically generated and provided by the parent-theme..</p>
<p>I started out... | [
{
"answer_id": 14268,
"author": "Amit Singh",
"author_id": 4528,
"author_profile": "https://wordpress.stackexchange.com/users/4528",
"pm_score": 0,
"selected": false,
"text": "<p>you can simply enqueue the generated.css style. Use the following code in your child themes function.php file... | 2011/04/08 | [
"https://wordpress.stackexchange.com/questions/14266",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2071/"
] | I have a child-theme -> parent-theme setup, where I need to have stylesheet called generated.css loaded in addition to the style.css file added by the active child-theme. The generated.css file is residing in the parent-theme and is being dynamically generated and provided by the parent-theme..
I started out the obvio... | Absolutely!
Into functions.php, like you said. I'll call it cache\_busting\_styles because I like how it sounds.
First, you set up the style via wp\_enqueue\_style, then call it during the action hook wp\_print\_styles, Also, you'll want to set up a variable and pass it in there as the version number as well:
```
fu... |
14,269 | <p>I have placed and previously used WordPress source on my web server everything is up and running including the DB. I even can access the site's admin page but in the theme settings page (Appearance/Themes) I'm getting these errors. </p>
<pre><code>Warning: array_keys() [function.array-keys]: The first argument sho... | [
{
"answer_id": 14315,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 1,
"selected": false,
"text": "<p>Try exporting your WordPress data, installing a fresh copy of the latest version of WordPress (currently 3.... | 2011/04/08 | [
"https://wordpress.stackexchange.com/questions/14269",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4532/"
] | I have placed and previously used WordPress source on my web server everything is up and running including the DB. I even can access the site's admin page but in the theme settings page (Appearance/Themes) I'm getting these errors.
```
Warning: array_keys() [function.array-keys]: The first argument should be an array... | Try exporting your WordPress data, installing a fresh copy of the latest version of WordPress (currently 3.1.1), using a fresh database, and then re-importing your WordPress data. |
14,275 | <p>I can see <code>validate_user()</code> calls <code>sanitize_user()</code> with strict argument as true, which means uppercase letters are not allowed too.</p>
<p>In source code, I found this comment</p>
<pre><code>// If strict, reduce to ASCII for max portability.
if ( $strict )
$username = preg_replac... | [
{
"answer_id": 14278,
"author": "Drew Gourley",
"author_id": 4282,
"author_profile": "https://wordpress.stackexchange.com/users/4282",
"pm_score": 1,
"selected": false,
"text": "<p>Off hand, I suppose it would be so you can use validate_user's results in a URL or a $_GET string. I'm sure... | 2011/04/08 | [
"https://wordpress.stackexchange.com/questions/14275",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1521/"
] | I can see `validate_user()` calls `sanitize_user()` with strict argument as true, which means uppercase letters are not allowed too.
In source code, I found this comment
```
// If strict, reduce to ASCII for max portability.
if ( $strict )
$username = preg_replace( '|[^a-z0-9 _.\-@]|i', '', $username );
... | Uppercase characters are not blocked in usernames on single site setups.
Uppercase characters ARE blocked in usernames on multisite setups. The wpmu\_validate\_user\_signup function forces lowercase a-z and numbers 0-9 only. |
14,282 | <p>I've added a custom post type, which is working great; I've also added two metaboxes, which appear to work well, but the content in them always disappears after a few minutes.</p>
<p>If anyone could help out on this I would be eternally grateful, S.</p>
<p>//meta box code//</p>
<pre><code>add_action( 'admin_init'... | [
{
"answer_id": 14284,
"author": "Drew Gourley",
"author_id": 4282,
"author_profile": "https://wordpress.stackexchange.com/users/4282",
"pm_score": 0,
"selected": false,
"text": "<p>The only difference I see from what you are doing here and the function I use is that you are relying on gl... | 2011/04/08 | [
"https://wordpress.stackexchange.com/questions/14282",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3362/"
] | I've added a custom post type, which is working great; I've also added two metaboxes, which appear to work well, but the content in them always disappears after a few minutes.
If anyone could help out on this I would be eternally grateful, S.
//meta box code//
```
add_action( 'admin_init', 'add_custom_metabox' );
ad... | You need to check for `autosave` and avoid that , also check if you are in the right post type as `save_post` works on all posts:
```
function save_custom_details( $post_id ) {
global $post;
//skip auto save
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) {
return $post_id;
}
//chec... |
14,286 | <p>I have added a custom user role of super_poster, basically they make 20 posts and once they hit $postlimit get auto-moved back down to contributer level, the moving down and post counting works ok, my problem is that the wp system adds the user into "none" instead of into contributer role</p>
<pre><code>if ($count_... | [
{
"answer_id": 14322,
"author": "John P Bloch",
"author_id": 11,
"author_profile": "https://wordpress.stackexchange.com/users/11",
"pm_score": 2,
"selected": true,
"text": "<p>You might want to use <code>WP_User::set_role( 'contributor' )</code> instead. It unsets all current roles and s... | 2011/04/08 | [
"https://wordpress.stackexchange.com/questions/14286",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3710/"
] | I have added a custom user role of super\_poster, basically they make 20 posts and once they hit $postlimit get auto-moved back down to contributer level, the moving down and post counting works ok, my problem is that the wp system adds the user into "none" instead of into contributer role
```
if ($count_posts >= $pos... | You might want to use `WP_User::set_role( 'contributor' )` instead. It unsets all current roles and sets the new one (the argument) too.
So the above would be
```
if ($count_posts >= $postlimit) {
$current_user->set_role( 'contributor' );
}
``` |
14,300 | <p>i'm a little worried here.</p>
<p>I'm trying to redirect EVERYONE that access my site to a specific webpage, and nothing is working! Currently i'm trying this code:</p>
<pre><code>function redirect_this() {
wp_redirect( 'http://www.myawesomesite.com/here.html', 301 );
exit;
}
add_action('template_redirect'... | [
{
"answer_id": 14301,
"author": "Drew Gourley",
"author_id": 4282,
"author_profile": "https://wordpress.stackexchange.com/users/4282",
"pm_score": 0,
"selected": false,
"text": "<p>template_redirect is happening after the headers are sent, try hooking redirect_this into wp_loaded instead... | 2011/04/08 | [
"https://wordpress.stackexchange.com/questions/14300",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4538/"
] | i'm a little worried here.
I'm trying to redirect EVERYONE that access my site to a specific webpage, and nothing is working! Currently i'm trying this code:
```
function redirect_this() {
wp_redirect( 'http://www.myawesomesite.com/here.html', 301 );
exit;
}
add_action('template_redirect', 'redirect_this');
... | Better use a .htaccess redirect so you avoid even loading WP:
```
Options +FollowSymLinks
RewriteEngine on
RewriteRule (.*) http://www.newdomain.com [R=301,L]
```
If you want to keep the path after the domain, (e.g. www.olddomain.com/mypage -> www.newdomain.com/mypage) replace the last line with:
```
RewriteRule (.... |
14,305 | <p>I'm trying to create an image with a caption in a Page I'm working with. In the image options, I have it aligned right, with an image width of 220. Without the caption I have no problems, however with the addition of the caption it adds a div wrapper with an inline style width of 230px. The only way to fix this is b... | [
{
"answer_id": 14325,
"author": "John P Bloch",
"author_id": 11,
"author_profile": "https://wordpress.stackexchange.com/users/11",
"pm_score": 2,
"selected": false,
"text": "<p>Here's what you can do. There's a filter at the beginning of the shortcode execution function for the front end... | 2011/04/08 | [
"https://wordpress.stackexchange.com/questions/14305",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1769/"
] | I'm trying to create an image with a caption in a Page I'm working with. In the image options, I have it aligned right, with an image width of 220. Without the caption I have no problems, however with the addition of the caption it adds a div wrapper with an inline style width of 230px. The only way to fix this is by s... | Here's what you can do. There's a filter at the beginning of the shortcode execution function for the front end that will let you hijack the captions. Returning a non-empty value will stop execution of the shortcode, so if you just process the shortcode the way you want it to be processed and return that result, you ca... |
14,331 | <p>I have 2 custom post types 'bookmarks' and 'snippets' and a shared taxonomy 'tag'. I can generate a list of all terms in the taxonomy with get_terms(), but I can't figure out how to limit the list to the post type. What I'm basically looking for is something like this:</p>
<pre><code>get_terms(array('taxonomy' =>... | [
{
"answer_id": 14334,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": false,
"text": "<p>So it just happens that I needed something like that for a project I'm working on. I simply wrote a query to ... | 2011/04/09 | [
"https://wordpress.stackexchange.com/questions/14331",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4495/"
] | I have 2 custom post types 'bookmarks' and 'snippets' and a shared taxonomy 'tag'. I can generate a list of all terms in the taxonomy with get\_terms(), but I can't figure out how to limit the list to the post type. What I'm basically looking for is something like this:
```
get_terms(array('taxonomy' => 'tag', 'post_t... | Here is another way to do something similar, with one SQL query:
```
static public function get_terms_by_post_type( $taxonomies, $post_types ) {
global $wpdb;
$query = $wpdb->prepare(
"SELECT t.*, COUNT(*) from $wpdb->terms AS t
INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id
... |
14,337 | <p>I want to convert my site from Drupal to WordPress. I installed WordPress in a subdirectory so I can tweak it until I'm ready to delete drupal and move it to the root folder. After installing I cannot access the WP index in the subdirectory. I get this in firefox:</p>
<p>"The page isn't redirecting properly ... | [
{
"answer_id": 14334,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": false,
"text": "<p>So it just happens that I needed something like that for a project I'm working on. I simply wrote a query to ... | 2011/04/09 | [
"https://wordpress.stackexchange.com/questions/14337",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4335/"
] | I want to convert my site from Drupal to WordPress. I installed WordPress in a subdirectory so I can tweak it until I'm ready to delete drupal and move it to the root folder. After installing I cannot access the WP index in the subdirectory. I get this in firefox:
"The page isn't redirecting properly
Firefox has det... | Here is another way to do something similar, with one SQL query:
```
static public function get_terms_by_post_type( $taxonomies, $post_types ) {
global $wpdb;
$query = $wpdb->prepare(
"SELECT t.*, COUNT(*) from $wpdb->terms AS t
INNER JOIN $wpdb->term_taxonomy AS tt ON t.term_id = tt.term_id
... |
14,344 | <p>I was wondering if there was a way to prevent the addition of new categories into a taxonomy, essentially 'locking' the taxonomy.</p>
<p>I'm programatically registering a taxonomy and filling it with terms via functions.php and would like it so you cannot add anymore into it.</p>
<h2>The Vision, REALIZED...</h2>
... | [
{
"answer_id": 14350,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 3,
"selected": true,
"text": "<h3>Categories, Tags & Taxonomies</h3>\n\n<p>First i want to make this one clear: Everything is a <strong>Taxonomy</str... | 2011/04/09 | [
"https://wordpress.stackexchange.com/questions/14344",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4282/"
] | I was wondering if there was a way to prevent the addition of new categories into a taxonomy, essentially 'locking' the taxonomy.
I'm programatically registering a taxonomy and filling it with terms via functions.php and would like it so you cannot add anymore into it.
The Vision, REALIZED...
-----------------------
... | ### Categories, Tags & Taxonomies
First i want to make this one clear: Everything is a **Taxonomy**. Tags is a non-hierarchical, Categories a hierarchical and both are built-in taxonomies. Same goes for eg. post formats (aside, chat, etc.). It's the same concept as with post-types (post, page, attachment, nav\_menu\_i... |
14,347 | <p>I'm trying to build a contact form custom widget. So i would like to display a contact form with a WordPress widget and send a message.</p>
<p>No problem to display the form with my widget but when i click on the send button i can't retrieve my data. The isset($_POST['my_data']) doesn't work.</p>
<p>When I put my ... | [
{
"answer_id": 14348,
"author": "t31os",
"author_id": 31073,
"author_profile": "https://wordpress.stackexchange.com/users/31073",
"pm_score": 1,
"selected": false,
"text": "<p>I remember a support topic i read with regard to a problem when you use the name <code>name</code> for one of yo... | 2011/04/09 | [
"https://wordpress.stackexchange.com/questions/14347",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4552/"
] | I'm trying to build a contact form custom widget. So i would like to display a contact form with a WordPress widget and send a message.
No problem to display the form with my widget but when i click on the send button i can't retrieve my data. The isset($\_POST['my\_data']) doesn't work.
When I put my form code out o... | I remember a support topic i read with regard to a problem when you use the name `name` for one of your post fields, try prefixing your input names.
```
<input type="text" name="my-name" ...
```
And see if that helps..
### Follow-up #1
I performed a simple test inside a widget..
```
if( isset( $_POST ) ) {
p... |
14,349 | <p>In my stylesheet I'm hoping to use code like this...</p>
<pre><code>background-image: url(/wp-content/images/' . $category->cat_ID . '.jpg);
</code></pre>
<p>...to pull in a different background image for each category. So I'll have an image called 1.jpg and it'll show that image as the background to the li ele... | [
{
"answer_id": 14351,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<p>Stylesheets can hold only CSS.</p>\n\n<p>If you make use of the <a href=\"http://codex.wordpress.org/Function_Refer... | 2011/04/09 | [
"https://wordpress.stackexchange.com/questions/14349",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3471/"
] | In my stylesheet I'm hoping to use code like this...
```
background-image: url(/wp-content/images/' . $category->cat_ID . '.jpg);
```
...to pull in a different background image for each category. So I'll have an image called 1.jpg and it'll show that image as the background to the li element I'm trying to style for ... | Stylesheets can hold only CSS.
If you make use of the [`body_class()`](http://codex.wordpress.org/Function_Reference/body_class) function, then you get classes for nearly every request. You can then define those classes (ex. backgrounds) inside your stylesheet.
Add this inside your templates: `<body <?php body_class... |
14,354 | <p>I am using the </p>
<pre><code><?php wp_create_user( $username, $password, $email ); ?>
</code></pre>
<p>function in a contact form to create a subscriber when the user enters infomation on the contact form, thus in the background adding their email address to the database and giving them an account for site... | [
{
"answer_id": 14360,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": true,
"text": "<p>The function <code>wp_create_user</code> calls <code>wp_insert_user</code> which check to see if <code>$user... | 2011/04/09 | [
"https://wordpress.stackexchange.com/questions/14354",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2957/"
] | I am using the
```
<?php wp_create_user( $username, $password, $email ); ?>
```
function in a contact form to create a subscriber when the user enters infomation on the contact form, thus in the background adding their email address to the database and giving them an account for site access.
Does this way of doin... | The function `wp_create_user` calls `wp_insert_user` which check to see if `$username` and `$email` already exists and if so it returns a new WP\_Error so you wont have duplicate users in your database and it wont send the new user email more then once, but i'm not sure if that is the best way to do that. |
14,361 | <p>This is a common function that adds default text to all posts:</p>
<pre><code>add_filter( 'default_content', 'my_editor_content' );
function my_editor_content( $content ) {
$content = "default content goes here....";
return $content;
}
</code></pre>
<p>How would this be changed to add the default content o... | [
{
"answer_id": 14362,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 0,
"selected": false,
"text": "<p>You can globalize $post and check if it has the category you want: </p>\n\n<pre><code>add_filter( 'default_co... | 2011/04/09 | [
"https://wordpress.stackexchange.com/questions/14361",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/268/"
] | This is a common function that adds default text to all posts:
```
add_filter( 'default_content', 'my_editor_content' );
function my_editor_content( $content ) {
$content = "default content goes here....";
return $content;
}
```
How would this be changed to add the default content only to a post in one categ... | One possibility is this question/answer here by Jan Fabry, which asks for the default content in the process of creating the new post:
[Force category choice before creating new post?](https://wordpress.stackexchange.com/questions/14403/force-category-choice-before-creating-new-post)
I ended up using a Quicktag as a w... |
14,363 | <p>I have a page (not a blog post) I need to embed an iframe on (it's to "integrate" an external service's product catalog). I added the iframe code in the raw HTML editor and saved the page. I viewed the page, everything worked.</p>
<p>I went back to the editor and switched from raw HTML to the Visual editor tab, add... | [
{
"answer_id": 14379,
"author": "Dave Hunt",
"author_id": 1769,
"author_profile": "https://wordpress.stackexchange.com/users/1769",
"pm_score": 2,
"selected": false,
"text": "<p>The Wordpress editor has poor handling of iFrames or advanced HTML when switching between the HTML and Visual ... | 2011/04/09 | [
"https://wordpress.stackexchange.com/questions/14363",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4555/"
] | I have a page (not a blog post) I need to embed an iframe on (it's to "integrate" an external service's product catalog). I added the iframe code in the raw HTML editor and saved the page. I viewed the page, everything worked.
I went back to the editor and switched from raw HTML to the Visual editor tab, added a line ... | I've had this code in a custom local plugin for a while. Or you could just stick it in your theme's `functions.php`:
```
// Allow iframe in TinyMCE
function tinymce_add_iframe( $arr = array() ) {
$extra = 'iframe[id|class|title|style|align|frameborder|height|longdesc|marginheight|marginwidth|name|scrolling|src|width... |
14,376 | <p>I'm using CF7 to send some information to my email and everything's working fine, but I need to redirect the users to a different page after the email has been sent, by default the forms are sent to the same page via ajax, I was thinking about setting a hidden field with the page url but since the form submits async... | [
{
"answer_id": 14378,
"author": "Dave Hunt",
"author_id": 1769,
"author_profile": "https://wordpress.stackexchange.com/users/1769",
"pm_score": 2,
"selected": false,
"text": "<p>In your jQuery AJAX call you should add some javascript to redirect the page:</p>\n\n<pre><code>window.locatio... | 2011/04/09 | [
"https://wordpress.stackexchange.com/questions/14376",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3893/"
] | I'm using CF7 to send some information to my email and everything's working fine, but I need to redirect the users to a different page after the email has been sent, by default the forms are sent to the same page via ajax, I was thinking about setting a hidden field with the page url but since the form submits asynchro... | Got it, needed to add this to the additional settings option:
```
on_sent_ok: "location = 'http://www.url.com';"
``` |
14,382 | <p>After installing wordpress and some plugins i am getting this error when i create a sitemap. I realy have no idea what this is and how to solve. Any help would realy be appreciated!</p>
<blockquote>
<pre><code>Warning: file_put_contents(/home/ugywhzos/domains/mydomain.com/public_html/sitemap.xml) [function.file-put-... | [
{
"answer_id": 14385,
"author": "Evan Wondrasek",
"author_id": 3298,
"author_profile": "https://wordpress.stackexchange.com/users/3298",
"pm_score": 3,
"selected": true,
"text": "<p>If you already have the files <code>sitemap.xml</code> and (if you have gzip enabled in Simple Google Site... | 2011/04/09 | [
"https://wordpress.stackexchange.com/questions/14382",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2293/"
] | After installing wordpress and some plugins i am getting this error when i create a sitemap. I realy have no idea what this is and how to solve. Any help would realy be appreciated!
>
>
> ```
> Warning: file_put_contents(/home/ugywhzos/domains/mydomain.com/public_html/sitemap.xml) [function.file-put-contents]: faile... | If you already have the files `sitemap.xml` and (if you have gzip enabled in Simple Google Sitemap) `sitemap.xml.gz` in the root directory of your WordPress installation, try deleting them and create new empty files with the correct permissions for that plugin, then manually run the sitemap generator. If these files do... |
14,383 | <p>I have Multisite enabled and can only view my site with the <code>www</code>. When I try without the <code>www</code> it sends me to the sign-up page and says</p>
<blockquote>
<p>Registration has been disabled.</p>
</blockquote>
<pre><code>www.domain.com/portfolio <-- load correctly
domain.com/portfolio ... | [
{
"answer_id": 15778,
"author": "Azizur Rahman",
"author_id": 3797,
"author_profile": "https://wordpress.stackexchange.com/users/3797",
"pm_score": 1,
"selected": false,
"text": "<p>The answer is here:\n<a href=\"https://wordpress.stackexchange.com/questions/5874/domain-redirect-in-wordp... | 2011/04/09 | [
"https://wordpress.stackexchange.com/questions/14383",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I have Multisite enabled and can only view my site with the `www`. When I try without the `www` it sends me to the sign-up page and says
>
> Registration has been disabled.
>
>
>
```
www.domain.com/portfolio <-- load correctly
domain.com/portfolio <-- redirects to sign-up page
```
I've tried `NOBLOGREDIRE... | The answer is here:
[Domain redirect in Wordpress multisite](https://wordpress.stackexchange.com/questions/5874/domain-redirect-in-wordpress-multisite).
You need to use the domain mapping plugin.
<http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/>
A must read <http://ottopress.com/2010/wordpress-3-0-m... |
14,387 | <p>Hey Guys,
I'm using a meta box to store a bunch of page ID's. When I try to pass the page ID's to the post__in parameter of WP_Query it doesn't work becuase the metabox comes throug as a string, when it needs to be a comma separated integers.</p>
<p>So, say the "relatedpages" meta box contains: 55, 33, 22</p>
<pre... | [
{
"answer_id": 14389,
"author": "scribu",
"author_id": 205,
"author_profile": "https://wordpress.stackexchange.com/users/205",
"pm_score": 3,
"selected": true,
"text": "<pre><code>'post__in' => explode( ',', $relatedpages )\n</code></pre>\n"
},
{
"answer_id": 15043,
"... | 2011/04/10 | [
"https://wordpress.stackexchange.com/questions/14387",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4562/"
] | Hey Guys,
I'm using a meta box to store a bunch of page ID's. When I try to pass the page ID's to the post\_\_in parameter of WP\_Query it doesn't work becuase the metabox comes throug as a string, when it needs to be a comma separated integers.
So, say the "relatedpages" meta box contains: 55, 33, 22
```
$relatedpag... | ```
'post__in' => explode( ',', $relatedpages )
``` |
14,406 | <p>When a post is split on more pages TwentyTen theme use the native function <code>wp_link_pages</code> to display a navigation page bar at the end of post.</p>
<p>I am trying to style those elements for my theme, but unfortunately it seems that the current page number cannot be styled.</p>
<p>I imagine that I shoul... | [
{
"answer_id": 14411,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 0,
"selected": false,
"text": "<p>First, you need to provide a CSS class to target, which you can do using the arguments of <code>wp_link_pag... | 2011/04/10 | [
"https://wordpress.stackexchange.com/questions/14406",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36/"
] | When a post is split on more pages TwentyTen theme use the native function `wp_link_pages` to display a navigation page bar at the end of post.
I am trying to style those elements for my theme, but unfortunately it seems that the current page number cannot be styled.
I imagine that I should override the `wp_link_page... | Unfortunately, there is no way to do this just with native functions: WP is … request agnostic and produces always links to the current page (nav manus, list pages …).
Also, you cannot use a filter, because `wp_link_pages()` has no appropriate filter.
In my themes, I use an own function, based on [this code](http://p... |
14,421 | <p>Pretty self-explanatory. How does one add another user to this function for functions.php, i.e., user2, who will be shown different menu items than user1?</p>
<p>I tried adding another <code>if($current_user->user_login == 'user2')</code> condition, but no luck. User2 will have different admin rights, if that ma... | [
{
"answer_id": 14491,
"author": "t31os",
"author_id": 31073,
"author_profile": "https://wordpress.stackexchange.com/users/31073",
"pm_score": 2,
"selected": false,
"text": "<p>Can you not simply add an <code>or</code> into your conditional logic?</p>\n\n<pre><code>if( $current_user->u... | 2011/04/10 | [
"https://wordpress.stackexchange.com/questions/14421",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/268/"
] | Pretty self-explanatory. How does one add another user to this function for functions.php, i.e., user2, who will be shown different menu items than user1?
I tried adding another `if($current_user->user_login == 'user2')` condition, but no luck. User2 will have different admin rights, if that matters. But basically, I ... | Why not just add another if?
```
function remove_menus(){
global $menu;
global $current_user;
get_currentuserinfo();
//check first user
if($current_user->user_login == 'user1'){
$restricted = array(
__('Links'),
__('Comments'),
... |
14,430 | <p>I want to make minor css-changes based on the choice of the top (root) menu.</p>
<p>What's the proper way to handle this in WP?</p>
<p>//edit//
It's a website (pages), no blog, and basically, the colors of some links and some images should depend of the choosen top-menu-item.</p>
<p>Example, page-structure:</p>
... | [
{
"answer_id": 14436,
"author": "Mark",
"author_id": 4577,
"author_profile": "https://wordpress.stackexchange.com/users/4577",
"pm_score": 0,
"selected": false,
"text": "<p>If you are outputting the menu using wp_list_pages / categories or the built in menu builder, then each page or cat... | 2011/04/10 | [
"https://wordpress.stackexchange.com/questions/14430",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4569/"
] | I want to make minor css-changes based on the choice of the top (root) menu.
What's the proper way to handle this in WP?
//edit//
It's a website (pages), no blog, and basically, the colors of some links and some images should depend of the choosen top-menu-item.
Example, page-structure:
```
* Start
* Products
* ... | My answer adds a class to the `<body>` element via the `body_class` filter. This is probably the easiest way to apply extra formatting to any element on the page. The added classes are `wpse14430_products`, `wpse14430_services` or `wpse14430_contact` (based on the slugs of the top pages in your example).
Using `wp_nav... |
14,444 | <p>Since WP 3.1, it's been possible to use Tumblr-style <a href="http://codex.wordpress.org/Post_Formats">post formats</a>. I want to use the 'aside' option in a theme, but I want it to have a different title in the WP admin area. </p>
<p>So, for example, when a user is writing a post, they have the option for the pos... | [
{
"answer_id": 14452,
"author": "Ján Bočínec",
"author_id": 2515,
"author_profile": "https://wordpress.stackexchange.com/users/2515",
"pm_score": 4,
"selected": true,
"text": "<p>I think this is the only way for now. Put this in your <em>functions.php</em> in your theme folder or create ... | 2011/04/10 | [
"https://wordpress.stackexchange.com/questions/14444",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2666/"
] | Since WP 3.1, it's been possible to use Tumblr-style [post formats](http://codex.wordpress.org/Post_Formats). I want to use the 'aside' option in a theme, but I want it to have a different title in the WP admin area.
So, for example, when a user is writing a post, they have the option for the post to be, say, either ... | I think this is the only way for now. Put this in your *functions.php* in your theme folder or create a simple plugin:
```
function rename_post_formats( $safe_text ) {
if ( $safe_text == 'Aside' )
return 'Quick';
return $safe_text;
}
add_filter( 'esc_html', 'rename_post_formats' );
//rename Aside in ... |
14,445 | <p>I have a site that displays the content only to registered users.
Most of the content is available to all the users, but some of it is user specific (i.e. all users have that page, but each sees a it's own content which no one else can see).
Any idea as to how I can restrict(and display) specific content per specifi... | [
{
"answer_id": 14448,
"author": "onetrickpony",
"author_id": 1986,
"author_profile": "https://wordpress.stackexchange.com/users/1986",
"pm_score": 1,
"selected": false,
"text": "<p>Assuming this content is the usual post loop:</p>\n\n<pre><code>$current_user = wp_get_current_user();\nif(... | 2011/04/10 | [
"https://wordpress.stackexchange.com/questions/14445",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/395/"
] | I have a site that displays the content only to registered users.
Most of the content is available to all the users, but some of it is user specific (i.e. all users have that page, but each sees a it's own content which no one else can see).
Any idea as to how I can restrict(and display) specific content per specific u... | I had coded something like this a while back and i remember wanting to upload it to the plugin repository but never had the time, Basically it adds a meta box to the post or page edit screen and lets the user select specific users by name or roles and then it check using `the_content` filter, so here you go:
Update:
-... |
14,446 | <p>This is kind of a stupid question...</p>
<p>I scheduled a action to run every hour:</p>
<pre><code>if(!wp_next_scheduled('my_hourly_events'))
wp_schedule_event(time(), 'hourly', 'my_hourly_events');
add_action('my_hourly_events', 'the_function_to_run');
function the_function_to_run(){
echo 'it works!';
}
<... | [
{
"answer_id": 14462,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 6,
"selected": true,
"text": "<p>My favorite plugin for that is <a href=\"http://wordpress.org/extend/plugins/core-control/\">Core Control</a> which h... | 2011/04/10 | [
"https://wordpress.stackexchange.com/questions/14446",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1986/"
] | This is kind of a stupid question...
I scheduled a action to run every hour:
```
if(!wp_next_scheduled('my_hourly_events'))
wp_schedule_event(time(), 'hourly', 'my_hourly_events');
add_action('my_hourly_events', 'the_function_to_run');
function the_function_to_run(){
echo 'it works!';
}
```
How can I test i... | My favorite plugin for that is [Core Control](http://wordpress.org/extend/plugins/core-control/) which has very nice module for display of what is going in the cron - which events are set up, when are they next firing, etc.
On getting your hands dirty level see `_get_cron_array()`, which returns internal stored data f... |
14,469 | <p>Basically if you see the picture below there are 5 tab items in my groups page:</p>
<p><img src="https://i.stack.imgur.com/S7L7w.png" alt="Screenshot"></p>
<p>Now, I want to be able to remove some of them. I want to be able to remove "Members" and "Send Invites" (for instance).</p>
<p>This is on the frontend grou... | [
{
"answer_id": 14479,
"author": "Thomas Clayson",
"author_id": 4529,
"author_profile": "https://wordpress.stackexchange.com/users/4529",
"pm_score": 3,
"selected": true,
"text": "<p>Managed to crawl through the core code and find this function: </p>\n\n<p><code>bp_core_remove_subnav_item... | 2011/04/11 | [
"https://wordpress.stackexchange.com/questions/14469",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4529/"
] | Basically if you see the picture below there are 5 tab items in my groups page:

Now, I want to be able to remove some of them. I want to be able to remove "Members" and "Send Invites" (for instance).
This is on the frontend groups page. When you select a group and g... | Managed to crawl through the core code and find this function:
`bp_core_remove_subnav_item`
So you can do something like this:
```
function remove_group_options() {
global $bp;
bp_core_remove_subnav_item($bp->groups->slug, 'members');
bp_core_remove_subnav_item($bp->groups->slug, 'send-invites');
}
ad... |
14,492 | <p>I'd like to find an optimized, WP_Query-safe method for generating a dynamically-populated copyright statement for the bottom of my themes. That is to say, I'd like to check the date (by year) of my oldest and newest posts and then output something along the lines of</p>
<pre><code>[blog name] &copy; [oldest po... | [
{
"answer_id": 14494,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": true,
"text": "<p>Here's what I use:</p>\n\n<pre><code>function oenology_copyright() {\n global $wpdb;\n $copyright_date... | 2011/04/11 | [
"https://wordpress.stackexchange.com/questions/14492",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/61/"
] | I'd like to find an optimized, WP\_Query-safe method for generating a dynamically-populated copyright statement for the bottom of my themes. That is to say, I'd like to check the date (by year) of my oldest and newest posts and then output something along the lines of
```
[blog name] © [oldest post year]-[newest ... | Here's what I use:
```
function oenology_copyright() {
global $wpdb;
$copyright_dates = $wpdb->get_results("
SELECT
YEAR(min(post_date_gmt)) AS firstdate,
YEAR(max(post_date_gmt)) AS lastdate
FROM
$wpdb->posts
WHERE
post_status = 'publish'... |
14,500 | <p>is it possible to add extra fields via the functions.php script for attachments in wordpress?</p>
<p>Tried loads of examples but none seem to work. Worried an existing plugin might be affecting my attempts but its not clear if its even possible.</p>
<p>best, dan.</p>
| [
{
"answer_id": 14501,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 1,
"selected": false,
"text": "<p>You need to use the <code>update_post_meta()</code> (<a href=\"http://codex.wordpress.org/Function_Referenc... | 2011/04/11 | [
"https://wordpress.stackexchange.com/questions/14500",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3978/"
] | is it possible to add extra fields via the functions.php script for attachments in wordpress?
Tried loads of examples but none seem to work. Worried an existing plugin might be affecting my attempts but its not clear if its even possible.
best, dan. | [Here](http://wpveda.com/adding-custom-fields-to-wordpress-media-gallery-upload/) is a tutorial that shows how to add custom fields to the attachments/media gallery/thickbox/iframe/whatever-you-call it overlay.
I've successfully used it, but have not yet taken it much further by adding radio buttons/checkboxes/etc or... |
14,502 | <p>I have 7 posts, like this:</p>
<p>1<br/>
2<br/>
3<br/>
4 - this is the current post<br/>
5<br/>
6<br/>
7<br/></p>
<p>As noted, number four is the current post being displayed. I need to create a query that will allow me to display the previous 3 posts (by publication date) and also the three posts after. This can ... | [
{
"answer_id": 14514,
"author": "onetrickpony",
"author_id": 1986,
"author_profile": "https://wordpress.stackexchange.com/users/1986",
"pm_score": 2,
"selected": false,
"text": "<p>3 x <a href=\"http://codex.wordpress.org/Function_Reference/get_adjacent_post\" rel=\"nofollow\">get_adjace... | 2011/04/11 | [
"https://wordpress.stackexchange.com/questions/14502",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2418/"
] | I have 7 posts, like this:
1
2
3
4 - this is the current post
5
6
7
As noted, number four is the current post being displayed. I need to create a query that will allow me to display the previous 3 posts (by publication date) and also the three posts after. This can be done with two separate querie... | This can be done in a single query, though i can't speak specifically about how well this query will perform(i've not spent a great deal with Union queries - never had a need, till now)..
First, a function to select two sets of results, but using union to return them as a single result set.
```
function get_post_sibl... |
14,524 | <p>I'd like to make a grid view that can be used to list items with a thumbnail, a primary description heading, a subheading, and possibly pricing details. This will not necessarily be for eCommerce as initially there will be no shopping cart. Similar to a post, clicking on the item should take you to a full "post" for... | [
{
"answer_id": 14525,
"author": "Justin",
"author_id": 4600,
"author_profile": "https://wordpress.stackexchange.com/users/4600",
"pm_score": 1,
"selected": false,
"text": "<p>Check out this tutorial: <a href=\"http://designm.ag/tutorials/jquery-display-switch/\" rel=\"nofollow\">http://... | 2011/04/11 | [
"https://wordpress.stackexchange.com/questions/14524",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4576/"
] | I'd like to make a grid view that can be used to list items with a thumbnail, a primary description heading, a subheading, and possibly pricing details. This will not necessarily be for eCommerce as initially there will be no shopping cart. Similar to a post, clicking on the item should take you to a full "post" for th... | It's not that difficult at all its simply styling you category loop in to a table something like this:
```
<table>
<tr>
<th>Photo</th><th>Item Brand, Model</th><th>Description</th><th>PSI</th><th>GPM</th><th>RPM</th><th>HP</th><th>Stock No.</th>
</tr>
<?php
while (have_posts()){
the_po... |
14,527 | <p>I have a <code>category.php</code> page which redirects users to a certain template page if the article in the output is in a category. However, I am seeing that if I have say 10 articles,and only one is in the special category, then it redirects. Is there a way to modify my code to only say "if all of the posts are... | [
{
"answer_id": 14528,
"author": "Dave Hunt",
"author_id": 1769,
"author_profile": "https://wordpress.stackexchange.com/users/1769",
"pm_score": 0,
"selected": false,
"text": "<p>The easiest way to do this would be to add your current logic into The Loop, and each time the post is in the ... | 2011/03/24 | [
"https://wordpress.stackexchange.com/questions/14527",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1354/"
] | I have a `category.php` page which redirects users to a certain template page if the article in the output is in a category. However, I am seeing that if I have say 10 articles,and only one is in the special category, then it redirects. Is there a way to modify my code to only say "if all of the posts are only in this ... | Just create a template file called "category-ontario-ohs-reform-alerts.php". This way any time this category is displayed, your special template will be used. |
14,531 | <p>I'm using a loop in the sidebar of my site to show all the posts that are in that category.
Now I'd like to include a 'current_post' class to the current post that is being displayed to style that item in the list.</p>
<p>I've tried looking for conditional tags or this custom <a href="https://wordpress.stackexchang... | [
{
"answer_id": 14532,
"author": "Brooke.",
"author_id": 2204,
"author_profile": "https://wordpress.stackexchange.com/users/2204",
"pm_score": 1,
"selected": false,
"text": "<p>If you are using a loop you should be able to do something like this it is untested but should work. Loop for si... | 2011/04/12 | [
"https://wordpress.stackexchange.com/questions/14531",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4567/"
] | I'm using a loop in the sidebar of my site to show all the posts that are in that category.
Now I'd like to include a 'current\_post' class to the current post that is being displayed to style that item in the list.
I've tried looking for conditional tags or this custom [wp\_list\_post\_types function](https://wordpre... | You should be able to get the queried object id and use that for comparison inside your custom loop..
Before your existing loop code(what you have posted above), but obviously after the opening PHP tag..
```
global $wp_query;
$current_id = $wp_query->get_queried_object_id();
```
Then somewhere inside your custom WP... |
14,544 | <p>I'm finding a way to redirect to a sub-domain. Sub-domains contain instances of multiple languages, say for an example -:</p>
<p><code>http://mysite/?p=7694</code> </p>
<p>This is the English site and I want it to redirect to (when user selects particular language)</p>
<pre><code>http://chinese.mysite/?p=7694
</c... | [
{
"answer_id": 14545,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <a href=\"http://wordpress.org/extend/plugins/wordpress-subdomains/\" rel=\"nofollow\">WP Subdoma... | 2011/04/12 | [
"https://wordpress.stackexchange.com/questions/14544",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4532/"
] | I'm finding a way to redirect to a sub-domain. Sub-domains contain instances of multiple languages, say for an example -:
`http://mysite/?p=7694`
This is the English site and I want it to redirect to (when user selects particular language)
```
http://chinese.mysite/?p=7694
```
Is there a simple way of doing this ... | You can Use [qTranslate](http://wordpress.org/extend/plugins/qtranslate/), this WordPress plugin let you have an easy to use interface for managing a fully multilingual web site.
>
> One-Click-Switching between the
> languages - Change the language as
> easy as switching Choose one of 3
> Modes to make your URLs pret... |
14,554 | <p>I am looking for a way to remove theme, change theme button and WP version from the "right now" admin dashboard, but using only functions. Any help?</p>
| [
{
"answer_id": 14574,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": true,
"text": "<p>Ah, one of those things that seem easy until admin dashboard internals throw you into depths of despair. :)</p>\n\n<p... | 2011/04/12 | [
"https://wordpress.stackexchange.com/questions/14554",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4612/"
] | I am looking for a way to remove theme, change theme button and WP version from the "right now" admin dashboard, but using only functions. Any help? | Ah, one of those things that seem easy until admin dashboard internals throw you into depths of despair. :)
Basically there is no easy and intended way to do this, so need to get creative. My idea would be to override temporarily couple of capabilities that control parts of output and kill the rest with filters in tra... |
14,556 | <p>I'm trying to implement pagination on a category page. The pagination is working, but now for some reason the pagination plugin I'm using is noting one extra page of results, when that page is actually empty. </p>
<p>I'm pretty sure it doesn't have anything to do with the pagination plugin because I've seen reports... | [
{
"answer_id": 14566,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>You could try to use the more native <code>get_adjacent_posts()</code> function to see if the problem is the <code>... | 2011/04/12 | [
"https://wordpress.stackexchange.com/questions/14556",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4567/"
] | I'm trying to implement pagination on a category page. The pagination is working, but now for some reason the pagination plugin I'm using is noting one extra page of results, when that page is actually empty.
I'm pretty sure it doesn't have anything to do with the pagination plugin because I've seen reports of people... | I am not sure, but I have a guess that it is because you are using pagination and `offset` at the same time. Pagination might be calculated for whole set, but you are reducing set size with offset so number of pages becomes overestimated. |
14,558 | <p>I'm having a serious problem with the plugin <a href="http://wordpress.org/extend/plugins/custom-field-template/" rel="nofollow">Custom Field Template</a> in which applying a CFT based on the template name is not working (it's as if the Ajax used to load the template is breaking). I've tried getting help in the foru... | [
{
"answer_id": 14583,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 1,
"selected": false,
"text": "<p>This Plugin is <a href=\"http://plugins.svn.wordpress.org/custom-field-template/tags/1.8.3/custom-field-tem... | 2011/04/12 | [
"https://wordpress.stackexchange.com/questions/14558",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2685/"
] | I'm having a serious problem with the plugin [Custom Field Template](http://wordpress.org/extend/plugins/custom-field-template/) in which applying a CFT based on the template name is not working (it's as if the Ajax used to load the template is breaking). I've tried getting help in the forums but no response - seems to... | This Plugin is [loading quite a lot of scripts](http://plugins.svn.wordpress.org/custom-field-template/tags/1.8.3/custom-field-template.php):
```
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-form' );
wp_enqueue_script( 'date', '/' . PLUGINDIR . '/' . $plugin_dir . '/js/date.js', array('jquery') );
wp_enqu... |
14,585 | <p>The Goal: To replace the sidebar on all sites across my network with content loaded from a plugin, <em>across all themes.</em></p>
<p>I need a way of over-riding the sidebar/main widget area on all sites across my network.</p>
<p>I have written a plugin which generates the sidebar with a function call, but <strong... | [
{
"answer_id": 14662,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 1,
"selected": false,
"text": "<p>You should look into having your sidebars utilize the remove action function.</p>\n\n<p>Then you can remove a sideb... | 2011/04/12 | [
"https://wordpress.stackexchange.com/questions/14585",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3669/"
] | The Goal: To replace the sidebar on all sites across my network with content loaded from a plugin, *across all themes.*
I need a way of over-riding the sidebar/main widget area on all sites across my network.
I have written a plugin which generates the sidebar with a function call, but **how can I get this content to... | You should look into having your sidebars utilize the remove action function.
Then you can remove a sidebar and replace it in a function any number of ways.
For instance (this examples using a conditional based on a page called **some-page**.
```
function change_sidebar_yay() {
if ( is_single('some-page') ) {
... |
14,586 | <p>Is it possible to use the plus sign instead of the dash as the word delimiter in the url? And if so, how exactly would that be done?</p>
<p>e.g.: <code>www.example.com/some-title/</code> becomes <code>www.example.com/some+title/</code></p>
<p>Of course, ideally it would have to work with posts, pages and custom po... | [
{
"answer_id": 14588,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 1,
"selected": false,
"text": "<p>Mark Jaquith uses \"+\" as the search query string delimiter in his Nice Search Plugin. H<a href=\"http://p... | 2011/04/12 | [
"https://wordpress.stackexchange.com/questions/14586",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3821/"
] | Is it possible to use the plus sign instead of the dash as the word delimiter in the url? And if so, how exactly would that be done?
e.g.: `www.example.com/some-title/` becomes `www.example.com/some+title/`
Of course, ideally it would have to work with posts, pages and custom posts. | Mark Jaquith uses "+" as the search query string delimiter in his Nice Search Plugin. H[ere's what he does](http://plugins.svn.wordpress.org/nice-search/tags/0.3/nice-search.php):
```
function cws_nice_search_redirect() {
if ( is_search() && strpos( $_SERVER['REQUEST_URI'], '/wp-admin/' ) === false && strpos( $_SE... |
14,596 | <p>I'm creating my first wordpress plugin and I'm struggling to find the correct and best way to make sure jquery and my own JS file is included on my settings page of my plugin.</p>
<p>I do not need them to load anywhere else unless on my settings page.</p>
<p>What code and where do I put it in my plugin?</p>
<p>Th... | [
{
"answer_id": 14597,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": true,
"text": "<p>First use <code>add_options_page()</code> - shorter wrapper, better practice.</p>\n\n<p>Second you need to save its r... | 2011/04/12 | [
"https://wordpress.stackexchange.com/questions/14596",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4610/"
] | I'm creating my first wordpress plugin and I'm struggling to find the correct and best way to make sure jquery and my own JS file is included on my settings page of my plugin.
I do not need them to load anywhere else unless on my settings page.
What code and where do I put it in my plugin?
This is what I have so far... | First use `add_options_page()` - shorter wrapper, better practice.
Second you need to save its return in some (global or static) variable. That is often used thingie and confusingly referenced by different names in documentation. Global `$hook_suffix` holds such value for current page.
```
function create_admin_pages... |
14,614 | <p>Alright so I've got two navigation menus that I've registered with my theme:</p>
<pre><code><?php
if ( function_exists('register_sidebar') )
register_sidebar();
add_theme_support( 'menus' );
if ( function_exists('register_nav_menu') ) {
register_nav_menu( 'primary_nav', 'Primary Navigation');
regi... | [
{
"answer_id": 14616,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 4,
"selected": true,
"text": "<p>Try <code>theme_location</code> instead of <code>menu</code> in arguments. Too late here to look up specifics, but I ... | 2011/04/13 | [
"https://wordpress.stackexchange.com/questions/14614",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/304/"
] | Alright so I've got two navigation menus that I've registered with my theme:
```
<?php
if ( function_exists('register_sidebar') )
register_sidebar();
add_theme_support( 'menus' );
if ( function_exists('register_nav_menu') ) {
register_nav_menu( 'primary_nav', 'Primary Navigation');
register_nav_menu( 's... | Try `theme_location` instead of `menu` in arguments. Too late here to look up specifics, but I remember documentation/code being absolutely confusing about that. |
14,618 | <p>I have an index/parent page and there are few sub/chlid pages in Wordpress.</p>
<p>How to check which sub page is the first child, and which is last child?</p>
<p>Thanks a lot!</p>
| [
{
"answer_id": 14621,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>You can use <a href=\"http://codex.wordpress.org/Function_Reference/get_pages\" rel=\"nofollow noreferrer\"><... | 2011/04/13 | [
"https://wordpress.stackexchange.com/questions/14618",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I have an index/parent page and there are few sub/chlid pages in Wordpress.
How to check which sub page is the first child, and which is last child?
Thanks a lot! | You can use [**get\_pages()**](http://codex.wordpress.org/Function_Reference/get_pages) function to do that:
```
global $post;
$current_page_id = $post->ID;
//Sort by creation time:
$args = array(
'child_of' => $current_page_id,
'sort_order' => 'ASC',
'sort_column' => 'post_date',
'hierarchical' => 1,... |
14,637 | <p>I'm trying to get VideoJS plugin to work in a Widget. <br>
I tried to add a PHP widget and write, as it said in the manual: <br></p>
<pre><code>[video mp4="http://video-js.zencoder.com/oceans-clip.mp4"]
</code></pre>
<p>But it just shows the code as is, any ideas?</p>
| [
{
"answer_id": 14639,
"author": "anu",
"author_id": 490,
"author_profile": "https://wordpress.stackexchange.com/users/490",
"pm_score": 0,
"selected": false,
"text": "<p>You can't use a WordPress shortcode in PHP code. You'll need to find the corresponding function and use that.</p>\n"
... | 2011/04/13 | [
"https://wordpress.stackexchange.com/questions/14637",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3642/"
] | I'm trying to get VideoJS plugin to work in a Widget.
I tried to add a PHP widget and write, as it said in the manual:
```
[video mp4="http://video-js.zencoder.com/oceans-clip.mp4"]
```
But it just shows the code as is, any ideas? | To display shortcodes in widgets , use a regular text widget, and add this line to your theme's functions.php file:
```
// Use shortcodes in text widgets.
add_filter('widget_text', 'do_shortcode');
```
This tells WordPress to render the shortcodes in widgets.
and if you want to call your shortcode by php you can us... |
14,640 | <p>I have the following that works fine..</p>
<pre><code>elseif( get_post_type($post->ID) == 'press' ){the_title_attribute();}
</code></pre>
<p>However, i need the aforementioned title to be wrapped with a h2 tag.</p>
<p>Tried this but it just puts the h2 after the title...</p>
<pre><code>elseif( get_post_type($... | [
{
"answer_id": 14643,
"author": "t31os",
"author_id": 31073,
"author_profile": "https://wordpress.stackexchange.com/users/31073",
"pm_score": 1,
"selected": false,
"text": "<p>The <code>the_title_attribute</code> function already echoes, so you can't echo it's value, try this instead.</p... | 2011/04/13 | [
"https://wordpress.stackexchange.com/questions/14640",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4630/"
] | I have the following that works fine..
```
elseif( get_post_type($post->ID) == 'press' ){the_title_attribute();}
```
However, i need the aforementioned title to be wrapped with a h2 tag.
Tried this but it just puts the h2 after the title...
```
elseif( get_post_type($post->ID) == 'press' ){echo'<h2>'. the_title_at... | The `the_title_attribute()` template tag is intended *specifically* for outputting the Title formatted for use in an anchor tag `title` attribute. The `the_title()` and `get_the_title()` template tags are intended for general print/display of the Title.
I would recommend using `get_the_title()`, rather than `the_title... |
14,652 | <p>I have a hierarchical taxonomy called 'geographical locations'. It contains continents on a first level, and then the countries for each one. Example :</p>
<pre><code>Europe
- Ireland
- Spain
- Sweden
Asia
- Laos
- Thailand
- Vietnam
</code></pre>
<p>etc.</p>
<p>Using get_terms() I managed to output the full list... | [
{
"answer_id": 14653,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": -1,
"selected": false,
"text": "<p>Be sure that <code>hierarchical=true</code> is passed to your <a href=\"http://codex.wordpress.org/Functio... | 2011/04/13 | [
"https://wordpress.stackexchange.com/questions/14652",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1381/"
] | I have a hierarchical taxonomy called 'geographical locations'. It contains continents on a first level, and then the countries for each one. Example :
```
Europe
- Ireland
- Spain
- Sweden
Asia
- Laos
- Thailand
- Vietnam
```
etc.
Using get\_terms() I managed to output the full list of terms, but the continents ge... | Use `wp_list_categories` with the `'taxonomy' => 'taxonomy'` argument, it's built for creating hierarchical category lists but will also support using a custom taxonomy..
**Codex Example:**
[Display terms in a custom taxonomy](https://developer.wordpress.org/reference/functions/wp_list_categories/#comment-1168)
If... |
14,655 | <p>I got a pretty basic theme and just found out my <strong>style.css</strong> file doesn't get loaded into the <code><head></code>. I already searched around but can't find out, why it's not loading. </p>
<p>I inspected the <code>global $wp_styles</code> object already but couldn't find anything:</p>
<pre><cod... | [
{
"answer_id": 14659,
"author": "t31os",
"author_id": 31073,
"author_profile": "https://wordpress.stackexchange.com/users/31073",
"pm_score": 4,
"selected": false,
"text": "<p>Theme stylesheets aren't usually enqueued, they're normally loaded using..</p>\n\n<pre><code><link rel=\"styl... | 2011/04/13 | [
"https://wordpress.stackexchange.com/questions/14655",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/385/"
] | I got a pretty basic theme and just found out my **style.css** file doesn't get loaded into the `<head>`. I already searched around but can't find out, why it's not loading.
I inspected the `global $wp_styles` object already but couldn't find anything:
```
function style_test()
{
$wp_styles = new WP_Styles();
... | The *recommended* way to do it is by enqueue-ing style.css in the functions.php of the theme.
Add this to functions.php
```
/**
* Load CSS and JS the right way
*/
function myprefix_load_css_and_js() {
wp_enqueue_style( 'style', get_stylesheet_uri() );
}
add_action( 'wp_enqueue_scripts', 'myprefix_load_css_and_... |
14,670 | <p>I have a couple of pages on my WordPress site that need to run over SSL. I've installed the <a href="http://wordpress.org/extend/plugins/wordpress-https/" rel="nofollow">WordPress HTTPS</a> plugin and configured the pages to use SSL.</p>
<p>However, I'm still getting the error message that some of the items are com... | [
{
"answer_id": 14671,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>The stuff you quoted are merely namespace definitions. They are not active links, are never downloaded by browser an... | 2011/04/13 | [
"https://wordpress.stackexchange.com/questions/14670",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1165/"
] | I have a couple of pages on my WordPress site that need to run over SSL. I've installed the [WordPress HTTPS](http://wordpress.org/extend/plugins/wordpress-https/) plugin and configured the pages to use SSL.
However, I'm still getting the error message that some of the items are coming over unsecured and that is a con... | Do exactly what you're doing: view the source of the offending page, and do a text search for "http://". Anything with this protocol is "insecure", and needs to be swapped to https. Common offenders are stylesheets, javascript, and 3rd-party widgets.
If you can't find any problems in the source, try using [firebug's](... |
14,677 | <p>I need a method to automatically create pages (using <code><!--nextpage--></code>) in posts based on number of words. </p>
<p>For example... A post containing 1200 words should be broken down into 6 pages with page break coming after every 200 words. </p>
<p>I understand that I can do it manually. But this f... | [
{
"answer_id": 14689,
"author": "John P Bloch",
"author_id": 11,
"author_profile": "https://wordpress.stackexchange.com/users/11",
"pm_score": 2,
"selected": false,
"text": "<p>This is tough to do programmatically because of potential variations in html and how the tags balance. However,... | 2011/04/13 | [
"https://wordpress.stackexchange.com/questions/14677",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1945/"
] | I need a method to automatically create pages (using `<!--nextpage-->`) in posts based on number of words.
For example... A post containing 1200 words should be broken down into 6 pages with page break coming after every 200 words.
I understand that I can do it manually. But this functionality is needed for a site ... | This is tough to do programmatically because of potential variations in html and how the tags balance. However, if you were to try, here's how I'd suggest doing it.
First of all, WordPress sets up the post pagination in `setup_postdata()`, which is called at the end of `the_post()`. That means you need to get those `<... |
14,679 | <p>Most of us are used to installing plugins directly from the WordPress.org plugin repository. This is the "official" list of available add-ins, and everything hosted there is guaranteed to be GPL.</p>
<p>But occasionally developers will list beta releases and non-GPL plugins on their own sites. To install these, y... | [
{
"answer_id": 14689,
"author": "John P Bloch",
"author_id": 11,
"author_profile": "https://wordpress.stackexchange.com/users/11",
"pm_score": 2,
"selected": false,
"text": "<p>This is tough to do programmatically because of potential variations in html and how the tags balance. However,... | 2011/04/13 | [
"https://wordpress.stackexchange.com/questions/14679",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/46/"
] | Most of us are used to installing plugins directly from the WordPress.org plugin repository. This is the "official" list of available add-ins, and everything hosted there is guaranteed to be GPL.
But occasionally developers will list beta releases and non-GPL plugins on their own sites. To install these, you have to d... | This is tough to do programmatically because of potential variations in html and how the tags balance. However, if you were to try, here's how I'd suggest doing it.
First of all, WordPress sets up the post pagination in `setup_postdata()`, which is called at the end of `the_post()`. That means you need to get those `<... |
14,685 | <p>I have recently changed hosting of my WordPress site to <a href="http://vps.net/" rel="noreferrer">VPS.net</a>. I have moved all of my files and imported the database. Everything appeared to be fine until I clicked a link and noticed that all of my pages are bringing back a 404 except the homepage. </p>
<p>Site URL... | [
{
"answer_id": 14687,
"author": "MathSmath",
"author_id": 1537,
"author_profile": "https://wordpress.stackexchange.com/users/1537",
"pm_score": 0,
"selected": false,
"text": "<p>Do you get a web server 404 or a WordPress 404? If it's a web server 404, you most likely didn't copy the root... | 2011/04/13 | [
"https://wordpress.stackexchange.com/questions/14685",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4644/"
] | I have recently changed hosting of my WordPress site to [VPS.net](http://vps.net/). I have moved all of my files and imported the database. Everything appeared to be fine until I clicked a link and noticed that all of my pages are bringing back a 404 except the homepage.
Site URL is <http://inksquared.com> | I guess you get http://yoursite but not http://yoursite/anything
I had a similar problem and it worked when I changed
the `httpd.conf` from
```
AllowOverride None
```
to
```
AllowOverride All
```
It makes the `.htaccess` take effect. |
14,692 | <p>I have used Jeff Star's tutorial for creating my own custom login form <a href="http://digwp.com/2010/12/login-register-password-code/">http://digwp.com/2010/12/login-register-password-code/</a>. It works great, but I have one problem. On the reset password form, if someone enters their username incorrectly (so that... | [
{
"answer_id": 14696,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 5,
"selected": true,
"text": "<p>The code he posted in that tutorial (very nice BTW) post's the form to the build-in \"reset password\" module ... | 2011/04/13 | [
"https://wordpress.stackexchange.com/questions/14692",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2418/"
] | I have used Jeff Star's tutorial for creating my own custom login form <http://digwp.com/2010/12/login-register-password-code/>. It works great, but I have one problem. On the reset password form, if someone enters their username incorrectly (so that it doesn't verify), they get kicked to the default wp-login.php?actio... | The code he posted in that tutorial (very nice BTW) post's the form to the build-in "reset password" module which redirects to the login.php on error, but you can change that and build your own based on the original and add it to the template page, change:
```
<form method="post" action="<?php echo site_url('wp-login.... |
14,694 | <p>I am using the following code:</p>
<pre><code>register_setting(
'myplugin_options', //setting group name
'myplugin_options', //option name that will be stored in the database
'myplugin_validate_options'//optional callback function
);
function myplugin_validate_options($input) {
//how ca... | [
{
"answer_id": 24932,
"author": "pauloc",
"author_id": 7634,
"author_profile": "https://wordpress.stackexchange.com/users/7634",
"pm_score": 3,
"selected": false,
"text": "<p>The dirty and only way I've founded:</p>\n\n<pre><code>function myplugin_validate_options($input) {\n var_dump... | 2011/04/13 | [
"https://wordpress.stackexchange.com/questions/14694",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4647/"
] | I am using the following code:
```
register_setting(
'myplugin_options', //setting group name
'myplugin_options', //option name that will be stored in the database
'myplugin_validate_options'//optional callback function
);
function myplugin_validate_options($input) {
//how can i print $inp... | The dirty and only way I've founded:
```
function myplugin_validate_options($input) {
var_dump($input);
exit;
}
``` |
14,707 | <h3>Problem</h3>
<p>After realizing that post formats are <strike>pretty popular, but</strike> only a extremly rough drawn concept, i see that users will run into possible traps. </p>
<p>Post format ...</p>
<ul>
<li>uses post meta fields & user doesn't remember exact meta key name.</li>
<li>takes the link/embed... | [
{
"answer_id": 14711,
"author": "Drew Gourley",
"author_id": 4282,
"author_profile": "https://wordpress.stackexchange.com/users/4282",
"pm_score": 3,
"selected": true,
"text": "<p>I did something like this once, but when you clicked on a certain category (essentially the same) It certain... | 2011/04/14 | [
"https://wordpress.stackexchange.com/questions/14707",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/385/"
] | ### Problem
After realizing that post formats are pretty popular, but only a extremly rough drawn concept, i see that users will run into possible traps.
Post format ...
* uses post meta fields & user doesn't remember exact meta key name.
* takes the link/embed/whatever object from post editor & user inputs wrong d... | I did something like this once, but when you clicked on a certain category (essentially the same) It certainly isn't a true ajax solution, it just hides and reveals the div with the settings, but It is a solution which works. You'll definitely have to modify this for your needs, but if you have a grasp on jQuery, I'm s... |
14,723 | <p>I'm having the exact same problem described in this post: <a href="https://wordpress.stackexchange.com/questions/4732/add-actionwp-ajax-action-name-myfunction-problem">add_action('wp_ajax_[action name]', myfunction) problem</a></p>
<p>I set add_action('wp_ajax_my_function_call','my_ajax_function'). If I pri... | [
{
"answer_id": 14736,
"author": "John P Bloch",
"author_id": 11,
"author_profile": "https://wordpress.stackexchange.com/users/11",
"pm_score": 2,
"selected": false,
"text": "<p>There are only three explanations for why this isn't working:</p>\n\n<p>First, something could be unregistering... | 2011/04/14 | [
"https://wordpress.stackexchange.com/questions/14723",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4658/"
] | I'm having the exact same problem described in this post: [add\_action('wp\_ajax\_[action name]', myfunction) problem](https://wordpress.stackexchange.com/questions/4732/add-actionwp-ajax-action-name-myfunction-problem)
I set add\_action('wp\_ajax\_my\_function\_call','my\_ajax\_function'). If I print\_r($wp\_filter) ... | There are only three explanations for why this isn't working:
First, something could be unregistering your action. That doesn't seem very likely, though.
Second, your code never runs in the ajax initialization.
Third, the `wp_ajax_my_function_call` hook never runs.
I wouldn't worry about the possibility of the firs... |
14,727 | <p>How does one reduce the number of stored revision (e.g. 5 max) for post types that support revisions?</p>
| [
{
"answer_id": 14729,
"author": "Brooke.",
"author_id": 2204,
"author_profile": "https://wordpress.stackexchange.com/users/2204",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure of an automatic way but there is always running the MySQL Query <code>DELETE FROM wp_posts WHERE po... | 2011/04/14 | [
"https://wordpress.stackexchange.com/questions/14727",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36/"
] | How does one reduce the number of stored revision (e.g. 5 max) for post types that support revisions? | add to your wp-config.php file the following line:
```
// set max post revisions
define('WP_POST_REVISIONS', 5);
```
source: <http://codex.wordpress.org/Editing_wp-config.php#Post_Revisions> |
14,732 | <p>i am using <a href="http://betterwp.net/wordpress-plugins/bwp-minify/" rel="nofollow">better wordpress minify</a> plugin
but it breaks site due to one of css file </p>
<pre><code>http://www.mydomain.net/?mcsf_action=main_css&#038;ver=3.1.1
</code></pre>
<p>i would like to add it into exception list so that it... | [
{
"answer_id": 14733,
"author": "OddOneOut",
"author_id": 4663,
"author_profile": "https://wordpress.stackexchange.com/users/4663",
"pm_score": 2,
"selected": false,
"text": "<p>I'm the author of that plugin. I think you should post such question on WP.org's support forum or on my websit... | 2011/04/14 | [
"https://wordpress.stackexchange.com/questions/14732",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | i am using [better wordpress minify](http://betterwp.net/wordpress-plugins/bwp-minify/) plugin
but it breaks site due to one of css file
```
http://www.mydomain.net/?mcsf_action=main_css&ver=3.1.1
```
i would like to add it into exception list so that it ignores it
here's screen-shot for admin panel
<http:... | I'm the author of that plugin. I think you should post such question on WP.org's support forum or on my website so I can get to you faster. If not for the pingback from this site I wouldn't know you are asking this :).
About your issue, how did you enqueue that file? How does your minify URL look like when my plugin i... |
14,759 | <p>I need to add custom methods to the Xml-Rpc file and have found the following:</p>
<p><pre><code><br>
// Custom plugins
add_filter('xmlrpc_methods', 'custom_xmlrpc_methods');</p>
<p>function custom_xmlrpc_methods($methods)
{
$methods['myMethod'] = 'my_function';
return $methods;
}
</pre></code></p>
<p>Que... | [
{
"answer_id": 14760,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>This doesn't realyl have much to do with WordPress, just generic PHP and your personal preferences in coding.</p>\n\... | 2011/04/14 | [
"https://wordpress.stackexchange.com/questions/14759",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I need to add custom methods to the Xml-Rpc file and have found the following:
```
// Custom plugins
add_filter('xmlrpc_methods', 'custom_xmlrpc_methods');
```
function custom\_xmlrpc\_methods($methods)
{
$methods['myMethod'] = 'my\_function';
return $methods;
}
Questions:
* Is it possible to have the callback f... | >
> If I have lots of custom methods what
> is the best approach to handling this?
>
>
>
Instead of filtering `xmlrpc_methods`, you could extend the `wp_xmlrpc_server` class and set your class as default with the filter `wp_xmlrpc_server_class`.
```
// Webeo_XMLRPC.php
include_once(ABSPATH . WPINC . '/class-IXR.... |
14,770 | <p>I'm doing custom URL rewrites according to <a href="http://matty.co.za/2009/11/custom-url-rewrites-in-wordpress/comment-page-1/" rel="nofollow">this method</a> , which work beautifully. But as a result my regular post permalinks are broken. </p>
<p>So, I'm rewriting "/pagename/1232432" into "/pagename?param=1232432... | [
{
"answer_id": 14812,
"author": "Frederik Wordenskjold",
"author_id": 3653,
"author_profile": "https://wordpress.stackexchange.com/users/3653",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried to flush your permalinks? \nVisiting <code>Admin > Settings > Permalinks</cod... | 2011/04/14 | [
"https://wordpress.stackexchange.com/questions/14770",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I'm doing custom URL rewrites according to [this method](http://matty.co.za/2009/11/custom-url-rewrites-in-wordpress/comment-page-1/) , which work beautifully. But as a result my regular post permalinks are broken.
So, I'm rewriting "/pagename/1232432" into "/pagename?param=1232432" like this:
```
$wp_rewrite->a... | Well I solved it - in a rather unsatisfactory way - by explicitly re-defining the default posts rule in my own code. i.e.
```
$rewrite_keywords_structure = $wp_rewrite->root."/%year%/%monthnum%/%postname%/";
..etc..
```
I don't really understand why this is necessary, but there you go. |
14,791 | <p>I'm looking to display an image for all the "standard" post formats on my site. I have done some research on how to add quote, video, photo, etc and have been able to implement these images into the site but when it comes to the "standard" post type I get nothing!</p>
<p>I have done all the necessary steps in the f... | [
{
"answer_id": 14794,
"author": "AMcDermott",
"author_id": 4642,
"author_profile": "https://wordpress.stackexchange.com/users/4642",
"pm_score": 2,
"selected": false,
"text": "<p>Try this code instead of your block:</p>\n\n<pre><code><?php \n$format = get_post_format();\nif ( false ==... | 2011/04/14 | [
"https://wordpress.stackexchange.com/questions/14791",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I'm looking to display an image for all the "standard" post formats on my site. I have done some research on how to add quote, video, photo, etc and have been able to implement these images into the site but when it comes to the "standard" post type I get nothing!
I have done all the necessary steps in the functions.p... | Technically speaking, there is no "standard" Post Format. Rather, "standard" is simply the *default* - as in, no Post Format type is defined.
If no Post Format type is defined, `get_post_format()` simply returns `null`.
I would suggest re-factoring your code above, and re-naming your icon images using the exact Post ... |
14,801 | <p>I'm wondering <strong>what pitfalls</strong> <em>(if any?)</em> developers here have run into <strong>when distributing WordPress plugins</strong> via <a href="http://wordpress.org/extend/plugins/" rel="nofollow noreferrer">the WordPress plugin repository</a> <strong>that embed a SOAP client</strong> for accessing <... | [
{
"answer_id": 14794,
"author": "AMcDermott",
"author_id": 4642,
"author_profile": "https://wordpress.stackexchange.com/users/4642",
"pm_score": 2,
"selected": false,
"text": "<p>Try this code instead of your block:</p>\n\n<pre><code><?php \n$format = get_post_format();\nif ( false ==... | 2011/04/15 | [
"https://wordpress.stackexchange.com/questions/14801",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/89/"
] | I'm wondering **what pitfalls** *(if any?)* developers here have run into **when distributing WordPress plugins** via [the WordPress plugin repository](http://wordpress.org/extend/plugins/) **that embed a SOAP client** for accessing [SOAP web services](http://en.wikipedia.org/wiki/SOAP) for critical plugin features *(o... | Technically speaking, there is no "standard" Post Format. Rather, "standard" is simply the *default* - as in, no Post Format type is defined.
If no Post Format type is defined, `get_post_format()` simply returns `null`.
I would suggest re-factoring your code above, and re-naming your icon images using the exact Post ... |
14,805 | <p>Wondering if anyone can help.</p>
<p>I'm putting together a site which features music reviews, amongst other things. The set up is built on a custom post type and a number of associated taxonomies.</p>
<p><strong>Post type:</strong></p>
<ul>
<li>my_albumreviews</li>
</ul>
<p><strong>Taxonomies:</strong></p>
<ul... | [
{
"answer_id": 14794,
"author": "AMcDermott",
"author_id": 4642,
"author_profile": "https://wordpress.stackexchange.com/users/4642",
"pm_score": 2,
"selected": false,
"text": "<p>Try this code instead of your block:</p>\n\n<pre><code><?php \n$format = get_post_format();\nif ( false ==... | 2011/04/15 | [
"https://wordpress.stackexchange.com/questions/14805",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | Wondering if anyone can help.
I'm putting together a site which features music reviews, amongst other things. The set up is built on a custom post type and a number of associated taxonomies.
**Post type:**
* my\_albumreviews
**Taxonomies:**
* artist
* label
* release date
On a page displaying an album review ( `m... | Technically speaking, there is no "standard" Post Format. Rather, "standard" is simply the *default* - as in, no Post Format type is defined.
If no Post Format type is defined, `get_post_format()` simply returns `null`.
I would suggest re-factoring your code above, and re-naming your icon images using the exact Post ... |
14,822 | <p>I have to create a hundred of content pages that share the same structure.</p>
<p>For example:</p>
<pre><code>[Title] - [Subtitle]
[Description]
[Specs]
- [Spec-A]
- [Spec-B]
- [Spec-C]
[Features]
- [Image-A][Feature-A]
- [Image-A][Feature-B]
- [Image-A][Feature-C]
</code></pre>
<p>I would like to stor... | [
{
"answer_id": 14824,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 4,
"selected": true,
"text": "<p>You might want to consider creating a <strong>Custom Post Type</strong> for this product (I assume it's some... | 2011/04/15 | [
"https://wordpress.stackexchange.com/questions/14822",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36/"
] | I have to create a hundred of content pages that share the same structure.
For example:
```
[Title] - [Subtitle]
[Description]
[Specs]
- [Spec-A]
- [Spec-B]
- [Spec-C]
[Features]
- [Image-A][Feature-A]
- [Image-A][Feature-B]
- [Image-A][Feature-C]
```
I would like to store this information in some DB tab... | You might want to consider creating a **Custom Post Type** for this product (I assume it's some sort of product), and then adding custom metaboxes, that will store the custom data (specs, features, etc.) as metadata for each Post.
Then, your custom template file becomes "single-.php" (e.g. "single-product.php"), and y... |
14,837 | <p>Use case is somewhat simple - here goes:</p>
<ol>
<li>Five people share a single wordpress install - not multi-user </li>
<li>Each person blogs and puts their posts in a their own unique category</li>
<li>Each person has their own domain name</li>
<li>All domain names are pointed or parked to same WP install folde... | [
{
"answer_id": 14925,
"author": "MikeSchinkel",
"author_id": 89,
"author_profile": "https://wordpress.stackexchange.com/users/89",
"pm_score": 4,
"selected": true,
"text": "<p>Here's two different solutions <em>(editing the specifics for your use case)</em>:</p>\n<h2>Doing a Redirect:</h... | 2011/04/15 | [
"https://wordpress.stackexchange.com/questions/14837",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4696/"
] | Use case is somewhat simple - here goes:
1. Five people share a single wordpress install - not multi-user
2. Each person blogs and puts their posts in a their own unique category
3. Each person has their own domain name
4. All domain names are pointed or parked to same WP install folder
5. Each person's domain name on... | Here's two different solutions *(editing the specifics for your use case)*:
Doing a Redirect:
-----------------
1.) At the top of your `/wp-config.php` file add the following:
```
if ( is_yoursite_blogger_domain( $_SERVER['SERVER_NAME'] ) ) {
$domain = str_replace( 'www.', '', $_SERVER['SERVER_NAME'] );
define( ... |
14,839 | <p>I was searching for a way to automatically insert a custom field when publishing a custom post type. And I repeatedly found the same solution, from here:</p>
<p><a href="http://pippinspages.com/tutorials/publish-action-hook-for-custom-post-types/" rel="nofollow">http://pippinspages.com/tutorials/publish-action-hoo... | [
{
"answer_id": 14849,
"author": "BigToe",
"author_id": 3202,
"author_profile": "https://wordpress.stackexchange.com/users/3202",
"pm_score": 0,
"selected": false,
"text": "<p>While I'm not an expert, here's a couple of ideas:</p>\n\n<p>Have you tried update_post_meta instead of add_post_... | 2011/04/15 | [
"https://wordpress.stackexchange.com/questions/14839",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4698/"
] | I was searching for a way to automatically insert a custom field when publishing a custom post type. And I repeatedly found the same solution, from here:
<http://pippinspages.com/tutorials/publish-action-hook-for-custom-post-types/>
I've tried this and for some reason it's just not working for me. I have a custom pos... | There is no {$old\_status}*to*{$new\_status}\_{$post\_type} action hook. Examine the wp\_transition\_post\_status function to see what types of hooks you can use there.
Instead, just use the generic transition\_post\_status hook. It gets the old and new statuses (so you can examine the status for changes) and the $pos... |
14,840 | <p>I have a site that has pages being indexed in Google in the form...</p>
<pre><code>site.com/?p=1
site.com/?category_name=uncategorized
site.com/?author=1
site.com/?m=201103
</code></pre>
<p>And since the permalinks of the site have been set to postname since the site was created, I'm trying to determine how these ... | [
{
"answer_id": 14849,
"author": "BigToe",
"author_id": 3202,
"author_profile": "https://wordpress.stackexchange.com/users/3202",
"pm_score": 0,
"selected": false,
"text": "<p>While I'm not an expert, here's a couple of ideas:</p>\n\n<p>Have you tried update_post_meta instead of add_post_... | 2011/04/15 | [
"https://wordpress.stackexchange.com/questions/14840",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/366/"
] | I have a site that has pages being indexed in Google in the form...
```
site.com/?p=1
site.com/?category_name=uncategorized
site.com/?author=1
site.com/?m=201103
```
And since the permalinks of the site have been set to postname since the site was created, I'm trying to determine how these links are being created an... | There is no {$old\_status}*to*{$new\_status}\_{$post\_type} action hook. Examine the wp\_transition\_post\_status function to see what types of hooks you can use there.
Instead, just use the generic transition\_post\_status hook. It gets the old and new statuses (so you can examine the status for changes) and the $pos... |