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 |
|---|---|---|---|---|---|---|
12,201 | <p>Setting up a WP multisite instance - the client has an existing ontology / set of categories that they want to classify all content across the set of blogs. Also the desire is that any new categories would be added at the 'network blog' level and synced to the other blogs.</p>
<p>What's the best way of doing this?<... | [
{
"answer_id": 12440,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 5,
"selected": true,
"text": "<pre><code>function __add_global_categories( $term_id )\n{\n if ( get_current_blog_id() !== BLOG_ID_CURRENT_... | 2011/03/16 | [
"https://wordpress.stackexchange.com/questions/12201",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/490/"
] | Setting up a WP multisite instance - the client has an existing ontology / set of categories that they want to classify all content across the set of blogs. Also the desire is that any new categories would be added at the 'network blog' level and synced to the other blogs.
What's the best way of doing this? | ```
function __add_global_categories( $term_id )
{
if ( get_current_blog_id() !== BLOG_ID_CURRENT_SITE || ( !$term = get_term( $term_id, 'category' ) ) )
return $term_id; // bail
if ( !$term->parent || ( !$parent = get_term( $term->parent, 'category' ) ) )
$parent = null;
global $wpdb;
... |
12,204 | <p>When a new blog is created in a WP Multisite instance I want to be able to set the default theme and configuration options</p>
<ul>
<li><p>create 2 menus (main and secondary) and associate them with the 2 slots provided by the theme</p></li>
<li><p>set various theme options as defined on the theme option page</p></... | [
{
"answer_id": 12437,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 3,
"selected": true,
"text": "<p>The best hook I can find is <code>wpmu_new_blog</code> (line 1086, <code>wp-includes/ms-functions.php</code>... | 2011/03/16 | [
"https://wordpress.stackexchange.com/questions/12204",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/490/"
] | When a new blog is created in a WP Multisite instance I want to be able to set the default theme and configuration options
* create 2 menus (main and secondary) and associate them with the 2 slots provided by the theme
* set various theme options as defined on the theme option page
What's the best way to go about ach... | The best hook I can find is `wpmu_new_blog` (line 1086, `wp-includes/ms-functions.php`, `wpmu_create_blog()`) - it passes 6 arguments like so;
```
do_action( 'wpmu_new_blog', $blog_id, $user_id, $domain, $path, $site_id, $meta );
```
`$meta` is an array of initial site options, not to be confused with the options ge... |
12,206 | <p>After using this code:</p>
<pre><code>//Set custom featured image metabox
function customposttype_image_box() {
remove_meta_box('postimagediv', 'eezzyweb-webfolio', 'side');
add_meta_box('website_grid_view', __('Featured Image for grid view'), 'post_thumbnail_meta_box', 'eezzyweb-webfolio', 'side', 'low');
}... | [
{
"answer_id": 12233,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>You can use with <code>add_meta_box</code> the following arguments instead of...</p>\n\n<pre><code>'side' (context)... | 2011/03/16 | [
"https://wordpress.stackexchange.com/questions/12206",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2618/"
] | After using this code:
```
//Set custom featured image metabox
function customposttype_image_box() {
remove_meta_box('postimagediv', 'eezzyweb-webfolio', 'side');
add_meta_box('website_grid_view', __('Featured Image for grid view'), 'post_thumbnail_meta_box', 'eezzyweb-webfolio', 'side', 'low');
}
add_action('... | The `add_meta_box` code you've posted does certainly register the metabox to the bottom of the side area. If the box is shown in the center then i imagine it's because you've(at some point) moved the metabox, as can be done with any of the metaboxes(all drag and drop). WordPress remembers where you move boxes to, and o... |
12,217 | <p>Is there a simple or easy way to exclude all posts from a custom taxonomy in the loop? I've been looking high and low, and neither SE, SO or Google seem to have a straight answer. </p>
<p>I know it can be done via a WPDB query, but that just seems like massive rope to jump for something that should be fairly simple... | [
{
"answer_id": 12227,
"author": "adamf",
"author_id": 3989,
"author_profile": "https://wordpress.stackexchange.com/users/3989",
"pm_score": -1,
"selected": false,
"text": "<p>I use the \"RYO ‘Category Visibility’ WordPress Plugin\" that seems to work pretty well.</p>\n\n<p>You can decide... | 2011/03/16 | [
"https://wordpress.stackexchange.com/questions/12217",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3986/"
] | Is there a simple or easy way to exclude all posts from a custom taxonomy in the loop? I've been looking high and low, and neither SE, SO or Google seem to have a straight answer.
I know it can be done via a WPDB query, but that just seems like massive rope to jump for something that should be fairly simple. | You would want to use the `NOT EXISTS` operator along with passing the taxonomy slug, which tells the query not to include any of a chosen category from your custom taxonomy inside the loop.
To exclude all posts that are in the taxonomy "fruit" (regardless of fruit kind), here is the snippet:
```
$args = array(
'... |
12,239 | <p>I've been working away at a medium-size WordPress site. So far I've just been hosting the site on my local machine and showing it to internal consultants over our local network. Things are working well, and now it's time to show it off to the client. I've been using git all along, so pushing it to the dev server was... | [
{
"answer_id": 12244,
"author": "curtismchale",
"author_id": 141,
"author_profile": "https://wordpress.stackexchange.com/users/141",
"pm_score": 2,
"selected": false,
"text": "<p>This has been discussed a few times so I'd suggest going over these threads then asking about any gaps you st... | 2011/03/16 | [
"https://wordpress.stackexchange.com/questions/12239",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2984/"
] | I've been working away at a medium-size WordPress site. So far I've just been hosting the site on my local machine and showing it to internal consultants over our local network. Things are working well, and now it's time to show it off to the client. I've been using git all along, so pushing it to the dev server was a ... | Assuming your wp-config.php is already in place and in order:
* Step 1. Mysqldump your development database
* Step 2. Replace all instances of development.domain.com to production.domain.com^^
* Step 3. Login to MySQL, run a SOURCE command to import data e.g. `source /path/to/file`
^^ How to replace all instances of ... |
12,240 | <p>I've just installed XAMPP on Mac OSX and when trying to install a theme or plugin in WP admin, I'm getting this screen. I've never gotten this on my <em>shared</em> hosting account. how to get rid of it on localhost?</p>
<p><img src="https://i.stack.imgur.com/VgCRV.png" alt="WordPress challenge when installing new ... | [
{
"answer_id": 12243,
"author": "MikeSchinkel",
"author_id": 89,
"author_profile": "https://wordpress.stackexchange.com/users/89",
"pm_score": 3,
"selected": true,
"text": "<p>Have you tried updating the permissions for your WordPress files to 755 or 777?</p>\n\n<h2>UPDATE 1</h2>\n\n<p>T... | 2011/03/16 | [
"https://wordpress.stackexchange.com/questions/12240",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/366/"
] | I've just installed XAMPP on Mac OSX and when trying to install a theme or plugin in WP admin, I'm getting this screen. I've never gotten this on my *shared* hosting account. how to get rid of it on localhost?

![enter image descrip... | Have you tried updating the permissions for your WordPress files to 755 or 777?
UPDATE 1
--------
Thanks to @anu in the comments *(`~/Sites` assumes you put websites are in the Mac's default website directory):*
```
cd ~/Sites
sudo chmod -R 777 *
```
I just checked my `httpd.conf` file, which has the path `/Applic... |
12,252 | <p>I'm having a lot of trouble using php query_posts(array('category__and'=>array(1,3))) - it seems to be pulling anything that's in category 1 regardless of whether it's also in category 3 and I only want the posts if they exist in both categories. And ultimately, I need a bunch of OR statements anyway, so is there a... | [
{
"answer_id": 12243,
"author": "MikeSchinkel",
"author_id": 89,
"author_profile": "https://wordpress.stackexchange.com/users/89",
"pm_score": 3,
"selected": true,
"text": "<p>Have you tried updating the permissions for your WordPress files to 755 or 777?</p>\n\n<h2>UPDATE 1</h2>\n\n<p>T... | 2011/03/16 | [
"https://wordpress.stackexchange.com/questions/12252",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I'm having a lot of trouble using php query\_posts(array('category\_\_and'=>array(1,3))) - it seems to be pulling anything that's in category 1 regardless of whether it's also in category 3 and I only want the posts if they exist in both categories. And ultimately, I need a bunch of OR statements anyway, so is there a ... | Have you tried updating the permissions for your WordPress files to 755 or 777?
UPDATE 1
--------
Thanks to @anu in the comments *(`~/Sites` assumes you put websites are in the Mac's default website directory):*
```
cd ~/Sites
sudo chmod -R 777 *
```
I just checked my `httpd.conf` file, which has the path `/Applic... |
12,262 | <p>Under Reading Settings, I can specify how many blog posts to display on a page. However, I would like to customize this a bit. For example, I want to only display 2 posts on the "/" page, but 3 posts on "/page/2", "/page/3", etc. Any way to customize the homepage to display one less post than the other pages?</p>
| [
{
"answer_id": 12276,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>There is no option to change the number of posts per page, archive, tag or category from the admin but you ca... | 2011/03/17 | [
"https://wordpress.stackexchange.com/questions/12262",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | Under Reading Settings, I can specify how many blog posts to display on a page. However, I would like to customize this a bit. For example, I want to only display 2 posts on the "/" page, but 3 posts on "/page/2", "/page/3", etc. Any way to customize the homepage to display one less post than the other pages? | There is no option to change the number of posts per page, archive, tag or category from the admin but you can use [query\_posts()](http://codex.wordpress.org/Function_Reference/query_posts) `posts_per_page` to set the number.
for example in your theme's index.php file or if you are using a static page as your home\_pa... |
12,264 | <p>I am using the publish_post action to run some checks on a user after their post is published:</p>
<pre><code>$author_ID = ????
add_action('publish_post', 'rhb_check_current_user', 10, $author_ID);
</code></pre>
<p>How can I get the original author's ID?</p>
| [
{
"answer_id": 12276,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>There is no option to change the number of posts per page, archive, tag or category from the admin but you ca... | 2011/03/17 | [
"https://wordpress.stackexchange.com/questions/12264",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3525/"
] | I am using the publish\_post action to run some checks on a user after their post is published:
```
$author_ID = ????
add_action('publish_post', 'rhb_check_current_user', 10, $author_ID);
```
How can I get the original author's ID? | There is no option to change the number of posts per page, archive, tag or category from the admin but you can use [query\_posts()](http://codex.wordpress.org/Function_Reference/query_posts) `posts_per_page` to set the number.
for example in your theme's index.php file or if you are using a static page as your home\_pa... |
12,270 | <p>suppose you are viewing a single image from the gallery. You have both previous and next links there (for navigation).
but
is there a way to also show all the other images from the same gallery in the same page (for example i want to show other images from same gallery)</p>
<p>if there is a way then can anyone plea... | [
{
"answer_id": 12272,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 3,
"selected": true,
"text": "<p>At it's very simplest, add this to your theme's <code>attachment.php</code></p>\n\n<pre><code><?php do_sh... | 2011/03/17 | [
"https://wordpress.stackexchange.com/questions/12270",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4002/"
] | suppose you are viewing a single image from the gallery. You have both previous and next links there (for navigation).
but
is there a way to also show all the other images from the same gallery in the same page (for example i want to show other images from same gallery)
if there is a way then can anyone please provide... | At it's very simplest, add this to your theme's `attachment.php`
```
<?php do_shortcode('[gallery id="' . $post->post_parent . '"]'); ?>
``` |
12,274 | <p><strong>EDIT:</strong> I want to update one field (post_content) within a known record (id of 4) of a known table (wp_posts) in a new database (new_db). The update has to come from one field (post_content) within a known record (id of 5) of a known table (wp_posts) in the <em>old</em> database (old_db).
Is this pos... | [
{
"answer_id": 12278,
"author": "Peter",
"author_id": 653,
"author_profile": "https://wordpress.stackexchange.com/users/653",
"pm_score": 0,
"selected": false,
"text": "<p>It is possible what you want in an easy way. Have a look at <a href=\"http://spectacu.la/search-and-replace-for-word... | 2011/03/17 | [
"https://wordpress.stackexchange.com/questions/12274",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | **EDIT:** I want to update one field (post\_content) within a known record (id of 4) of a known table (wp\_posts) in a new database (new\_db). The update has to come from one field (post\_content) within a known record (id of 5) of a known table (wp\_posts) in the *old* database (old\_db).
Is this possible, or is somet... | Seems like trying to put "field X" into db.table.record.fieldY is too atomic, or requires a better magic wand than google can find. I've gone a head and just ripped the posts out wholesale and injected them into the new DB.
Here's how I did it. I hope it helps the next poor sod who finds himself in the same place I wa... |
12,281 | <p>I'm using the following to let the user login:</p>
<pre><code> <form name='loginform' id='loginform' action='<?php echo get_settings('siteurl')?>/wp-login.php' method='post'>
<label>User:</label><br />
<input type='text' name='log' id='user_logi... | [
{
"answer_id": 12283,
"author": "Rev. Voodoo",
"author_id": 3429,
"author_profile": "https://wordpress.stackexchange.com/users/3429",
"pm_score": 3,
"selected": true,
"text": "<p>I'm going to venture a guess here, and maybe someone more versed can back me up or set me straight </p>\n\n<... | 2011/03/17 | [
"https://wordpress.stackexchange.com/questions/12281",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/781/"
] | I'm using the following to let the user login:
```
<form name='loginform' id='loginform' action='<?php echo get_settings('siteurl')?>/wp-login.php' method='post'>
<label>User:</label><br />
<input type='text' name='log' id='user_login' class='input' tabindex='20' /><input type='s... | I'm going to venture a guess here, and maybe someone more versed can back me up or set me straight
But here:
```
<?php echo htmlspecialchars($_SERVER['REQUEST_URI'])?>'
```
Is the redirect value.... It is redirecting to the original url, wherever the user came from
If you swap that out for your home url with som... |
12,295 | <p>I'm in the midst of building a Wordpress Plugin that adds a custom post type, for which I'd like to include a default template to display. Essentially, this is an event management plugin, and the custom post type is for the Events. There's a handful of custom meta fields, as well as a child post type (Performances... | [
{
"answer_id": 12296,
"author": "Peter Rowell",
"author_id": 1958,
"author_profile": "https://wordpress.stackexchange.com/users/1958",
"pm_score": 3,
"selected": true,
"text": "<p>You might want to look at the routine that WP uses for this: <a href=\"http://codex.wordpress.org/Function_R... | 2011/03/17 | [
"https://wordpress.stackexchange.com/questions/12295",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3708/"
] | I'm in the midst of building a Wordpress Plugin that adds a custom post type, for which I'd like to include a default template to display. Essentially, this is an event management plugin, and the custom post type is for the Events. There's a handful of custom meta fields, as well as a child post type (Performances), so... | You might want to look at the routine that WP uses for this: [`locate_template()`](http://codex.wordpress.org/Function_Reference/locate_template). It is in `wp-includes/theme.php` and is called from a number of functions in that file. Those functions are used by `wp-includes/template-loader.php` to select the correct *... |
12,299 | <p>I know that <code>wp_head()</code> is important, but using it injects so much crap into the header. I'd like to get it out and just add manually the 2-3 line of code that I need.</p>
<p>But, there is certain code added by WordPress that I want to keep: </p>
<pre><code><meta name="description" content="" />
&... | [
{
"answer_id": 12300,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 4,
"selected": true,
"text": "<p>You can remove some of the header stuff with the following.</p>\n\n<pre><code>// remove unncessary header info\nfunc... | 2011/03/17 | [
"https://wordpress.stackexchange.com/questions/12299",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3969/"
] | I know that `wp_head()` is important, but using it injects so much crap into the header. I'd like to get it out and just add manually the 2-3 line of code that I need.
But, there is certain code added by WordPress that I want to keep:
```
<meta name="description" content="" />
<meta name="keywords" content="" />
<li... | You can remove some of the header stuff with the following.
```
// remove unncessary header info
function remove_header_info() {
remove_action('wp_head', 'rsd_link');
remove_action('wp_head', 'wlwmanifest_link');
remove_action('wp_head', 'wp_generator');
remove_action('wp_head', 'start_post_rel_link');... |
12,311 | <p>I've read about the WP enqueue_script() function, but if I wanted to use a newer version of jQuery than what my WP installation is using, can I load it through this & WP will use the latest version? or will it load both? or what will happen?</p>
<p>Thanks!</p>
| [
{
"answer_id": 12312,
"author": "scribu",
"author_id": 205,
"author_profile": "https://wordpress.stackexchange.com/users/205",
"pm_score": 3,
"selected": true,
"text": "<p>To replace the default jQuery url, do:</p>\n\n<pre><code>wp_deregister_script( 'jquery' );\nwp_register_script( 'jqu... | 2011/03/17 | [
"https://wordpress.stackexchange.com/questions/12311",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1839/"
] | I've read about the WP enqueue\_script() function, but if I wanted to use a newer version of jQuery than what my WP installation is using, can I load it through this & WP will use the latest version? or will it load both? or what will happen?
Thanks! | To replace the default jQuery url, do:
```
wp_deregister_script( 'jquery' );
wp_register_script( 'jquery', 'your custom url', ... );
```
Then call `wp_enqueue_script( 'jquery' );` as usual.
Note that various pages in the WP admin might not be compatible with never versions of jQuery, not to mention plugin scripts. |
12,316 | <p>I would like to display data from a post that has custom fields in a metabox. One of the fields is the URL for an image. How do I create an echo to display the image?</p>
<p>The other field I want to call is a link. I have one field for the URL and one field for the link text. How do I echo this to diplay the l... | [
{
"answer_id": 12319,
"author": "Jonathan Wold",
"author_id": 1766,
"author_profile": "https://wordpress.stackexchange.com/users/1766",
"pm_score": 2,
"selected": false,
"text": "<p>Within your Query loop, using your image URL as an example, put this:</p>\n\n<pre><code><?php $image_ur... | 2011/03/17 | [
"https://wordpress.stackexchange.com/questions/12316",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I would like to display data from a post that has custom fields in a metabox. One of the fields is the URL for an image. How do I create an echo to display the image?
The other field I want to call is a link. I have one field for the URL and one field for the link text. How do I echo this to diplay the link.
Thanks,
... | Within your Query loop, using your image URL as an example, put this:
```
<?php $image_url = get_post_meta($post->ID, 'image-url-field', true); ?>
```
Replace "image-url-field" with the name of your custom field.
Then, also within that same loop, do this:
```
<?php echo $image_url; ?>
```
Reference: <http://cod... |
12,320 | <p>I'm returning a custom hierarchal taxonomy via wp_get_object_terms.</p>
<p>The trouble is that the results are being ordered by name or count, neither of which are proving reliable. (I'm using a custom taxonomy for "Location" - City, State, Country - sometimes the State appears before the City)</p>
<p>Is there a w... | [
{
"answer_id": 12319,
"author": "Jonathan Wold",
"author_id": 1766,
"author_profile": "https://wordpress.stackexchange.com/users/1766",
"pm_score": 2,
"selected": false,
"text": "<p>Within your Query loop, using your image URL as an example, put this:</p>\n\n<pre><code><?php $image_ur... | 2011/03/17 | [
"https://wordpress.stackexchange.com/questions/12320",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1766/"
] | I'm returning a custom hierarchal taxonomy via wp\_get\_object\_terms.
The trouble is that the results are being ordered by name or count, neither of which are proving reliable. (I'm using a custom taxonomy for "Location" - City, State, Country - sometimes the State appears before the City)
Is there a way I can order... | Within your Query loop, using your image URL as an example, put this:
```
<?php $image_url = get_post_meta($post->ID, 'image-url-field', true); ?>
```
Replace "image-url-field" with the name of your custom field.
Then, also within that same loop, do this:
```
<?php echo $image_url; ?>
```
Reference: <http://cod... |
12,328 | <p>Is it possible to filter the posts or categories that XML-RPC users see in their mobile application?</p>
<p>I have a plugin that hooks into <code>pre_get_posts</code> and <code>list_terms_exclusions</code> to do what I need it to do. I've had requests to allow the same functionality on their mobile devices.</p>
| [
{
"answer_id": 12431,
"author": "Jonnybojangles",
"author_id": 2362,
"author_profile": "https://wordpress.stackexchange.com/users/2362",
"pm_score": 0,
"selected": false,
"text": "<p>I have not actually experimented with it myself but when I cracked open the xmlrpc.php file I noticed sev... | 2011/03/17 | [
"https://wordpress.stackexchange.com/questions/12328",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1511/"
] | Is it possible to filter the posts or categories that XML-RPC users see in their mobile application?
I have a plugin that hooks into `pre_get_posts` and `list_terms_exclusions` to do what I need it to do. I've had requests to allow the same functionality on their mobile devices. | Okay, so I discovered the answer to my question.
It is possible to filter the posts and categories that users see in their XML-RPC application. The `pre_get_posts` and `list_terms_exclusions` filters are called via the blogger.getRecentPosts XML-RPC method. Inside this function, it calls `wp_get_recent_posts` which us... |
12,339 | <p>After you have uploaded an attachment in Wordpress using the media upload screen, is there a hook or filter I can run after the image has been uploaded where I can get the path to the uploaded image so I can analyse it?</p>
<p>I am building a plugin that will analyse an image after it has been uploaded and then tag... | [
{
"answer_id": 12362,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>you have two filters you can use: <code>attachment_fields_to_save</code>\nwhich gets two paramaters ( $post, ... | 2011/03/18 | [
"https://wordpress.stackexchange.com/questions/12339",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1687/"
] | After you have uploaded an attachment in Wordpress using the media upload screen, is there a hook or filter I can run after the image has been uploaded where I can get the path to the uploaded image so I can analyse it?
I am building a plugin that will analyse an image after it has been uploaded and then tag the image... | Turns out I solved my own question with help from a colleague. The two filters that get called after media is uploaded or when media is being edited are; 'add\_attachment' and 'edit\_attachment'. Here is the code I am using, I then check to see if the attachment is an image (code omitted from example).
```
function an... |
12,351 | <p>Specifically, I'm talking about the following which gets added automatically:</p>
<p>1) <code><script type='text/javascript' src='http://mysite.com/wp-includes/js/l10n.js?ver=20101110'></script></code></p>
<p>2) <code><script type="text/javascript">
//<![CDATA[
var _wpcf7 = { cached: 1 };
//]... | [
{
"answer_id": 12350,
"author": "Wietse Venema",
"author_id": 3637,
"author_profile": "https://wordpress.stackexchange.com/users/3637",
"pm_score": 3,
"selected": true,
"text": "<p>You could use the <a href=\"http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/\" rel=\"nofoll... | 2011/03/18 | [
"https://wordpress.stackexchange.com/questions/12351",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3714/"
] | Specifically, I'm talking about the following which gets added automatically:
1) `<script type='text/javascript' src='http://mysite.com/wp-includes/js/l10n.js?ver=20101110'></script>`
2) `<script type="text/javascript">
//<![CDATA[
var _wpcf7 = { cached: 1 };
//]]>
</script>`
3) `<link rel="stylesheet" href="http:/... | You could use the [Domain Mapper](http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/ "Domain Mapper") plugin for this. Drawback being that you'd have manually configure each subblog. |
12,368 | <p>How do I change notification emails address from WordPress @mydomain.net to something else.</p>
<p>I want to do this because WordPress @mydomain.net ends up getting flagged as junk mail.</p>
<p>Thanks</p>
<p>Daniel</p>
| [
{
"answer_id": 12380,
"author": "John P Bloch",
"author_id": 11,
"author_profile": "https://wordpress.stackexchange.com/users/11",
"pm_score": 3,
"selected": false,
"text": "<p>There's a great plugin that does this for you called <a href=\"http://wordpress.org/extend/plugins/send-from/\"... | 2011/03/18 | [
"https://wordpress.stackexchange.com/questions/12368",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | How do I change notification emails address from WordPress @mydomain.net to something else.
I want to do this because WordPress @mydomain.net ends up getting flagged as junk mail.
Thanks
Daniel | I use a very similar approach like John P Bloch and Bainternet, just a little bit more flexible, so I don’t have to change the mail address for any client:
```
<?php # -*- coding: utf-8 -*-
/*
* Plugin Name: Filter System From Mail
* Description: Sets the WP from mail address to the first admin’s mail and the from n... |
12,369 | <p>I would really appreciate if you could help me :) I'm very stuck and don't know how to proceed.</p>
<p>I have a custom post type called <code>event</code> and 2 custom taxonomies registered for it:</p>
<ol>
<li><code>event_type</code> with tag-like functionality (ex. of event type: yoga, voice work)</li>
<li><code... | [
{
"answer_id": 12384,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>try using this fancy function that group the posts by term id that <a href=\"http://scribu.net/wordpress/sort... | 2011/03/18 | [
"https://wordpress.stackexchange.com/questions/12369",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1343/"
] | I would really appreciate if you could help me :) I'm very stuck and don't know how to proceed.
I have a custom post type called `event` and 2 custom taxonomies registered for it:
1. `event_type` with tag-like functionality (ex. of event type: yoga, voice work)
2. `event_location` with category-like functionality (ex... | I got a bit confused with this one. At the end I've decided not to group the events by `event_location` category and simplify the functionality.
What I have done instead is the following:
1. I detect what `event_type` events to display by looking at a URL. Then I display all the events of that `event_type` and order... |
12,370 | <p>I read several articles about configuring the WordPress editor. For example, <a href="http://wp-snippets.com/set-default-editor/">this snippet</a> shows how to permanently set the editor to HTML or WYSIWYG <em>for all contents</em>.</p>
<p>I'm wondering if it's possible to disable the WYSIWYG only when the user is ... | [
{
"answer_id": 12371,
"author": "Anh Tran",
"author_id": 2051,
"author_profile": "https://wordpress.stackexchange.com/users/2051",
"pm_score": 2,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code>add_filter( 'wp_default_editor', 'rw_default_editor' );\nfunction rw_default_editor... | 2011/03/18 | [
"https://wordpress.stackexchange.com/questions/12370",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4032/"
] | I read several articles about configuring the WordPress editor. For example, [this snippet](http://wp-snippets.com/set-default-editor/) shows how to permanently set the editor to HTML or WYSIWYG *for all contents*.
I'm wondering if it's possible to disable the WYSIWYG only when the user is creating a page, leaving it ... | The best way to do this is by adding 'user\_can\_richedit' filter, like so:
```
add_filter( 'user_can_richedit', 'patrick_user_can_richedit');
function patrick_user_can_richedit($c) {
global $post_type;
if ('page' == $post_type)
return false;
return $c;
}
```
Hope it's useful ;) |
12,372 | <p>In a situation where one has 20 posts per page. I would like to get the current page number in order to make some nice page links at the bottom. How do you get the current page. I tried this </p>
<pre><code><?php echo '(Page '.$page.' of '.$numpages.')'; ?>
</code></pre>
<p>and it just says page 1 of 1 on ev... | [
{
"answer_id": 12377,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 6,
"selected": true,
"text": "<p>When WordPress is using pagination like this, there's a query variable <code>$paged</code> that it keys on. So page 1... | 2011/03/18 | [
"https://wordpress.stackexchange.com/questions/12372",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2957/"
] | In a situation where one has 20 posts per page. I would like to get the current page number in order to make some nice page links at the bottom. How do you get the current page. I tried this
```
<?php echo '(Page '.$page.' of '.$numpages.')'; ?>
```
and it just says page 1 of 1 on every page.
Any ideas,
Marvellou... | When WordPress is using pagination like this, there's a query variable `$paged` that it keys on. So page 1 is `$paged=1` and page 15 is `$paged=15`.
You can get the value of this variable with the following code:
```
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
```
Getting the total number of pag... |
12,379 | <p>I am involved in a large migration from another CMS to WordPress. We have a copy of the database and have worked out how to extract the content and programmatically create WordPress posts from it using an instantiation of the <code>wpdb</code> class.</p>
<p>However, there are a couple of thousand images which we wo... | [
{
"answer_id": 12382,
"author": "John P Bloch",
"author_id": 11,
"author_profile": "https://wordpress.stackexchange.com/users/11",
"pm_score": 6,
"selected": true,
"text": "<p>There's actually a great function that will do all three of those things for you:</p>\n\n<pre><code>media_sidelo... | 2011/03/18 | [
"https://wordpress.stackexchange.com/questions/12379",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2877/"
] | I am involved in a large migration from another CMS to WordPress. We have a copy of the database and have worked out how to extract the content and programmatically create WordPress posts from it using an instantiation of the `wpdb` class.
However, there are a couple of thousand images which we would like to pull acro... | There's actually a great function that will do all three of those things for you:
```
media_sideload_image( $url, $post_id, $description );
```
The first argument is the remote url of the image you want to download. The second argument is the post id of the post to which you want to attach the image. The third argum... |
12,405 | <p>If you use the <code>[gallery]</code> tag at all you know that permalinks for image attachments end up like <code>blog.com/2011/03/18/post-permalink/attachment-permalink</code>.</p>
<p>The URL extension from the post permalink appears to be based on the attachment's title on first save. To my knowledge, however, th... | [
{
"answer_id": 12415,
"author": "jhdenham",
"author_id": 4044,
"author_profile": "https://wordpress.stackexchange.com/users/4044",
"pm_score": 1,
"selected": false,
"text": "<p>WordPress stores the original filename in the database as a unique identifier for the attachment. Unfortunately... | 2011/03/18 | [
"https://wordpress.stackexchange.com/questions/12405",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1860/"
] | If you use the `[gallery]` tag at all you know that permalinks for image attachments end up like `blog.com/2011/03/18/post-permalink/attachment-permalink`.
The URL extension from the post permalink appears to be based on the attachment's title on first save. To my knowledge, however, this permalink does not update whe... | This'll add a slug field to the edit attachment page, which'll allow you to independently change it when and how you choose to.
Drop it into a plugin or your theme's `functions.php`;
```
function wpse_12405_edit_attachment_name( $fields, $post ) {
$fields['post_name'] = array(
'label' => __( 'Slug' ),
... |
12,444 | <p>I've got problems getting pretty permalinks to work.</p>
<p>When changing the permalinks (e.g. to month/name), my .htaccess (in the wordpress directory - there is another one one level up) is changed like this:</p>
<pre><code>AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php
# BEGIN WordPress
<IfModule mod_... | [
{
"answer_id": 12465,
"author": "Ashfame",
"author_id": 1521,
"author_profile": "https://wordpress.stackexchange.com/users/1521",
"pm_score": 2,
"selected": false,
"text": "<p>Save your existing <code>.htaccess</code> file by renaming it to <code>backup.htaccess</code> & then re-save... | 2011/03/18 | [
"https://wordpress.stackexchange.com/questions/12444",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3943/"
] | I've got problems getting pretty permalinks to work.
When changing the permalinks (e.g. to month/name), my .htaccess (in the wordpress directory - there is another one one level up) is changed like this:
```
AddType x-mapp-php5 .php
AddHandler x-mapp-php5 .php
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine... | I've finally managed to track down the cause of the problem .. it was a Plugin that seems to have issues (Top Level Categories). I've looked into their documentation, but there is no indication that I would run into that problem. Hmmmm ...
At least it's working now! |
12,448 | <p>I will like to implement a few of the boilerplate template features in one of my instance WordPress.</p>
<p>I am trying to figure out how to exchange the regular jquery calls below</p>
<pre><code><script type='text/javascript' src='http:/.../wp-includes/js/jquery/jquery.js?ver=1.4.4'></script>
<scri... | [
{
"answer_id": 12450,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 5,
"selected": true,
"text": "<p>You should be loading jQuery with <code>wp_enqueue_script('jquery')</code> - that way, you won't end up with... | 2011/03/18 | [
"https://wordpress.stackexchange.com/questions/12448",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3536/"
] | I will like to implement a few of the boilerplate template features in one of my instance WordPress.
I am trying to figure out how to exchange the regular jquery calls below
```
<script type='text/javascript' src='http:/.../wp-includes/js/jquery/jquery.js?ver=1.4.4'></script>
<script type='text/javascript' src='http:... | You should be loading jQuery with `wp_enqueue_script('jquery')` - that way, you won't end up with multiple instances if plugins try to load it too.
To use Google CDN, place this in your `functions.php`;
```
wp_deregister_script( 'jquery' );
wp_register_script(
'jquery',
'https://ajax.googleapis.com/ajax/libs/... |
12,455 | <p>STEPS:</p>
<ol>
<li>Don't forget to use different id numbers in each accordion. For example: id="5" (1 to 10)</li>
<li>The title goes between the </li>
<li>The lyrics before the <br /></li>
<li><p>Place 2 accordions per posts (like the example below). Or they will mess up.</p>
<pre><code> <div class=... | [
{
"answer_id": 12480,
"author": "thelovebug",
"author_id": 4054,
"author_profile": "https://wordpress.stackexchange.com/users/4054",
"pm_score": 2,
"selected": true,
"text": "<p>What you're asking for is likely to be possible using a plugin to handle the shortcode. However, I cannot wor... | 2011/03/19 | [
"https://wordpress.stackexchange.com/questions/12455",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/781/"
] | STEPS:
1. Don't forget to use different id numbers in each accordion. For example: id="5" (1 to 10)
2. The title goes between the
3. The lyrics before the
4. Place 2 accordions per posts (like the example below). Or they will mess up.
```
<div class="basic" style="float:left;" id="5">
<a>T... | What you're asking for is likely to be possible using a plugin to handle the shortcode. However, I cannot work out from what you've posted what you're trying to achieve.
Can you be a bit more detailed in what you're trying to achieve? Rather than giving us the desired outcome, a bit of information on how to get there ... |
12,470 | <p>I like to create child plugin..</p>
<p>Explanation :-</p>
<p>I have one parent plugin named X. This will work independently (like other existing plugins).</p>
<p>Now I decided to add some extra features to that plugin X (think of it as an upgrade). So I want to create extra features by way of another plugin Y, wh... | [
{
"answer_id": 12477,
"author": "Ashfame",
"author_id": 1521,
"author_profile": "https://wordpress.stackexchange.com/users/1521",
"pm_score": 3,
"selected": false,
"text": "<p>Make some hooks in your parent plugin to which the child plugin can attach their own function. Also wrap the chi... | 2011/03/19 | [
"https://wordpress.stackexchange.com/questions/12470",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4022/"
] | I like to create child plugin..
Explanation :-
I have one parent plugin named X. This will work independently (like other existing plugins).
Now I decided to add some extra features to that plugin X (think of it as an upgrade). So I want to create extra features by way of another plugin Y, which will depend on (and ... | the Best way to do this is have your X plugin made with its own hooks for actions and filters so new plugins (in your case Y) could interact with plugin X's functions and data.
Defining your own hooks is fairly easy and simple.
Action Hook
-----------
from the codex:
>
> Actions are the hooks that the
> WordPress... |
12,485 | <p>I'm doing up a WordPress theme at the moment, and I want users to be able to add Google Analytics to their site by just adding their tracking code -- you know, the <code>UA-20149670-1</code> -type number thing.</p>
<p>At the moment I have all the Google Analytics JavaScript code sitting in the <code><head></c... | [
{
"answer_id": 12486,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 3,
"selected": true,
"text": "<p>Take the GA code from your header and wrap it in a function hooked to <code>wp_head</code>;</p>\n\n<pre><cod... | 2011/03/19 | [
"https://wordpress.stackexchange.com/questions/12485",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2666/"
] | I'm doing up a WordPress theme at the moment, and I want users to be able to add Google Analytics to their site by just adding their tracking code -- you know, the `UA-20149670-1` -type number thing.
At the moment I have all the Google Analytics JavaScript code sitting in the `<head>` of my pages, with the tracking co... | Take the GA code from your header and wrap it in a function hooked to `wp_head`;
```
function __analytics_head()
{
$options = get_option( 'themename_theme_options' );
if ( !empty( $options['analytics'] ) ) :
?>
<script type="text/javascript">
var _gaq = _gaq || [];
_gaq.push(['_setAccount', '<?php ... |
12,498 | <p>Why is it that one cannot get the excerpt by ID like with the title and most other elements.</p>
<p>eg. get_the_excerpt(ID). I know how to use it with the $post->post_excerpt function but that does not return part of the content if no excerpt was entered it simple returns nothing.</p>
<p>So what I am trying to do ... | [
{
"answer_id": 12503,
"author": "MikeSchinkel",
"author_id": 89,
"author_profile": "https://wordpress.stackexchange.com/users/89",
"pm_score": 5,
"selected": true,
"text": "<p>Hi <strong>@Robin I. Knight:</strong></p>\n\n<p>I view <code>get_the_excerpt()</code> as a function with legacy ... | 2011/03/19 | [
"https://wordpress.stackexchange.com/questions/12498",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2957/"
] | Why is it that one cannot get the excerpt by ID like with the title and most other elements.
eg. get\_the\_excerpt(ID). I know how to use it with the $post->post\_excerpt function but that does not return part of the content if no excerpt was entered it simple returns nothing.
So what I am trying to do is get the exc... | Hi **@Robin I. Knight:**
I view `get_the_excerpt()` as a function with legacy design. As WordPress usage has grown there are many newer use-cases where it doesn't fit but where the newer functions for getting different data do. One example is the now frequent use of an `$args` array of function options.
But it's easy... |
12,502 | <p>Is there a way to move the links such as Add New Appearance Comments into one menu </p>
| [
{
"answer_id": 12637,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 1,
"selected": false,
"text": "<p>It is not possible to \"move\" - you must unset the item and add new to your structure in the Admin Bar. See the l... | 2011/03/19 | [
"https://wordpress.stackexchange.com/questions/12502",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | Is there a way to move the links such as Add New Appearance Comments into one menu | Unset
-----
Here's an **example** of how to unset the comments link if the default status is 'closed' (offers 2 different approaches).
```
/**
* Disable 'Comments' link if default status is _closed_
*/
function remove_comments()
{
$default_comment_status = get_option( 'default_comment_status' );
if ( $def... |
12,512 | <p>I am trying to figure out how to write the code that will allow me to do the following with pages of a WordPress blog.</p>
<p>I need to have something where I specify which page ID's I want to list (about 15 total) and then give the user the ability to select which ones will be published or which ones will be a dra... | [
{
"answer_id": 12518,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": false,
"text": "<p>Here is a function that changes post status</p>\n\n<pre><code>/*\n$post_id - The ID of the post you'd like to... | 2011/03/19 | [
"https://wordpress.stackexchange.com/questions/12512",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I am trying to figure out how to write the code that will allow me to do the following with pages of a WordPress blog.
I need to have something where I specify which page ID's I want to list (about 15 total) and then give the user the ability to select which ones will be published or which ones will be a draft. This w... | A faster solution is:
```
$post = array( 'ID' => $post_id, 'post_status' => $status );
wp_update_post($post);
```
This way you don't have to get the post. |
12,513 | <p>I'm looking for a way to add some content to the top of the sidebar when it get's loaded.</p>
<p>I've tried hooking onto the get_sidebar action as <a href="http://codex.wordpress.org/Plugin_API/Action_Reference" rel="noreferrer">referenced here</a>, but it seems to override the sidebar call and load my function ins... | [
{
"answer_id": 12515,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p><code>get_sidebar</code> hook is called on the function that gets the sidebar template file so that's not the... | 2011/03/19 | [
"https://wordpress.stackexchange.com/questions/12513",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4065/"
] | I'm looking for a way to add some content to the top of the sidebar when it get's loaded.
I've tried hooking onto the get\_sidebar action as [referenced here](http://codex.wordpress.org/Plugin_API/Action_Reference), but it seems to override the sidebar call and load my function instead? Is there a better solution to d... | `get_sidebar` hook is called on the function that gets the sidebar template file so that's not the right way to go.
if you are not up to creating a widget you can convert your function to a shortcode and use it in the built-in text widget.
**How?** simple, you say your function is named `social_links` then add:
```
... |
12,516 | <p>We are Customising Wordpress Admin to build a biz application. WE are using Wordpress as a base to build our application. We used the Add Post page as Add Customer - customised some fields and we posted it to the db using wp_post . Now we want to add two more menu's like Add Vendor, Add Employees ( which should work... | [
{
"answer_id": 12515,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p><code>get_sidebar</code> hook is called on the function that gets the sidebar template file so that's not the... | 2011/03/19 | [
"https://wordpress.stackexchange.com/questions/12516",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | We are Customising Wordpress Admin to build a biz application. WE are using Wordpress as a base to build our application. We used the Add Post page as Add Customer - customised some fields and we posted it to the db using wp\_post . Now we want to add two more menu's like Add Vendor, Add Employees ( which should work v... | `get_sidebar` hook is called on the function that gets the sidebar template file so that's not the right way to go.
if you are not up to creating a widget you can convert your function to a shortcode and use it in the built-in text widget.
**How?** simple, you say your function is named `social_links` then add:
```
... |
12,530 | <p>I created some menus, and now I'm trying to set up a conditional construction with wp_nav_menu in header.php, but the behavior is not really as expected. I'm doing something like</p>
<pre><code><?php
if ( is_front_page() )
{
wp_nav_menu( array( 'container_class' => 'menu-header', 'menu' => '68' ));... | [
{
"answer_id": 12545,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>If you're using the <code>menu</code> parameter, you can also use the <code>name</code> or the <code>slug</code>. P... | 2011/03/20 | [
"https://wordpress.stackexchange.com/questions/12530",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I created some menus, and now I'm trying to set up a conditional construction with wp\_nav\_menu in header.php, but the behavior is not really as expected. I'm doing something like
```
<?php
if ( is_front_page() )
{
wp_nav_menu( array( 'container_class' => 'menu-header', 'menu' => '68' ));
}
elseif ( is_singl... | Ideally, you should be passing the "theme\_location" argument to wp\_nav\_menu().
Register your three menus in functions.php:
```
register_nav_menus( array(
'front_page' => 'Front Page Menu',
'single' => 'Single Post Menu',
'default' => 'Default Menu'
) );
```
Then, replace your code above with:
```... |
12,531 | <p>I'm using the following code to show one post in a page (Blog pages show at most is set to 1 post):</p>
<pre><code><?php
/**
* Template Name: Front Page
* @package WordPress
* @subpackage Prominent
* @since Prominent 1.0
*/
get_header(); ?>
<div id="tagline">
<div class="container">
&... | [
{
"answer_id": 57890,
"author": "its_me",
"author_id": 10691,
"author_profile": "https://wordpress.stackexchange.com/users/10691",
"pm_score": 0,
"selected": false,
"text": "<p>It appears like what you need is \"pagination\". Install <strong><a href=\"http://wordpress.org/extend/plugins/... | 2011/03/20 | [
"https://wordpress.stackexchange.com/questions/12531",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/781/"
] | I'm using the following code to show one post in a page (Blog pages show at most is set to 1 post):
```
<?php
/**
* Template Name: Front Page
* @package WordPress
* @subpackage Prominent
* @since Prominent 1.0
*/
get_header(); ?>
<div id="tagline">
<div class="container">
</div><!-- .container -->
</div><... | What you need are `$GLOBALS['wp_query']->max_num_pages` and [`get_pagenum_link()`](http://queryposts.com/function/get_pagenum_link/). Then you just have to compare `get_query_var( 'paged' )` with `max_num_pages` and create a link if they are not equal:
```
/**
* Link to last page of a paged archive.
*
* @param str... |
12,532 | <p>Usually facebook share gets an image from the site to post and shows it as thumbnails.</p>
<p>If you press the share this on facebook link in my test page it doesn't.</p>
<p>This is my test site: <a href="http://alexchen.info/taiwantalk/" rel="nofollow">http://alexchen.info/taiwantalk/</a></p>
<p>This is the code... | [
{
"answer_id": 12551,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 1,
"selected": false,
"text": "<p>You need to Add a image source meta tag to the head tag of your document.</p>\n\n<pre><code><link rel=\"im... | 2011/03/20 | [
"https://wordpress.stackexchange.com/questions/12532",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/781/"
] | Usually facebook share gets an image from the site to post and shows it as thumbnails.
If you press the share this on facebook link in my test page it doesn't.
This is my test site: <http://alexchen.info/taiwantalk/>
This is the code:
```
<?php
/**
* Template Name: Front Page
* @package WordPress
* @subpackage P... | `<meta property="og:image" content="http://alexchen.info/taiwantalk/wp-content/uploads/2011/03/cheating.png" />`
Visit <http://developers.facebook.com/docs/reference/plugins/like/> and see "Step 2 - Get Open Graph Tags"
There's also a lot of WP plugins out there that can help you to generate Open Graph tags. |
12,535 | <p>I want to build a plugin that grabs certain url params from the query string to build a new query string for the same page. I'm following the excellent the Professional WordPress Plugin Development book, but I'm not sure which hook to use for this action. Here is my action function:</p>
<pre><code>add_action( 'init... | [
{
"answer_id": 12544,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 5,
"selected": false,
"text": "<p>I'd say <code>template_redirect</code>. But take a look at the <a href=\"http://codex.wordpress.org/Plugin_API/Acti... | 2011/03/20 | [
"https://wordpress.stackexchange.com/questions/12535",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1341/"
] | I want to build a plugin that grabs certain url params from the query string to build a new query string for the same page. I'm following the excellent the Professional WordPress Plugin Development book, but I'm not sure which hook to use for this action. Here is my action function:
```
add_action( 'init', 'tccl_redir... | Like kaiser answered `template_redirect` hook is indeed appropriate for redirects.
Also you should use [`wp_redirect()`](http://codex.wordpress.org/Function_Reference/wp_redirect) function, rather than setting header. |
12,564 | <p>I was wondering how to display just the following buttons:</p>
<p>bold</p>
<p>italic</p>
<p>underline</p>
<p>unordered list</p>
<p>ordered list</p>
<p>insert link</p>
<p>unlik</p>
<p>blockquote</p>
<p>--
Thanks in advance.</p>
| [
{
"answer_id": 12565,
"author": "eileencodes",
"author_id": 1352,
"author_profile": "https://wordpress.stackexchange.com/users/1352",
"pm_score": 1,
"selected": false,
"text": "<p>With the tinyMCE advanced plugin you can control many aspects of the tinyMCE editor. You can add options, re... | 2011/03/20 | [
"https://wordpress.stackexchange.com/questions/12564",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2011/"
] | I was wondering how to display just the following buttons:
bold
italic
underline
unordered list
ordered list
insert link
unlik
blockquote
--
Thanks in advance. | Hi **@José Pablo Orozco Marín:**
If you are looking for how to code the custom buttons yourself, WordPress' Codex has a great example that shows you how:
* <http://codex.wordpress.org/TinyMCE_Custom_Buttons>
The example is complicated because it shows you how to add your own controls but if you are using the standar... |
12,570 | <p>Knowing that wordpress doesn't follow MVC pattern.
What is the best way in worpress to output plugin's result in a certain url.
lets say I would like to show "hello world" in main area under "www.example.com/show-hello-world" url.
thanks. hope question is clear!</p>
<p>more details:</p>
<p>Let's say url "example.c... | [
{
"answer_id": 12593,
"author": "scribu",
"author_id": 205,
"author_profile": "https://wordpress.stackexchange.com/users/205",
"pm_score": 3,
"selected": false,
"text": "<p>There are two steps:</p>\n\n<pre><code>function my_plugin_rewrite_rule() {\n global $wp;\n\n $wp->add_query_va... | 2011/03/20 | [
"https://wordpress.stackexchange.com/questions/12570",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4089/"
] | Knowing that wordpress doesn't follow MVC pattern.
What is the best way in worpress to output plugin's result in a certain url.
lets say I would like to show "hello world" in main area under "www.example.com/show-hello-world" url.
thanks. hope question is clear!
more details:
Let's say url "example.com/show-hello-wor... | There are two steps:
```
function my_plugin_rewrite_rule() {
global $wp;
$wp->add_query_var( 'show_hello_world' );
add_rewrite_rule( 'show-hello-world/?$', 'index.php?show_hello_world=1', 'top' );
}
add_action( 'init', 'my_plugin_rewrite_rule' );
```
That takes care of rewriting. Remember to flush the rewrite... |
12,573 | <p>I've tried to follow the example for <a href="http://codex.wordpress.org/Conditional_Tags" rel="nofollow">Testing for paginated Pages</a> but i don't know why it isn't working. i put it in the single.php file for post detection. i don't know why the page_test is broken. example code here:</p>
<pre><code><?php
ge... | [
{
"answer_id": 12574,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>You need to either add <code>global $wp_query;</code></p>\n\n<pre><code>global $wp_query;\n$page_test = $wp_q... | 2011/03/20 | [
"https://wordpress.stackexchange.com/questions/12573",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3603/"
] | I've tried to follow the example for [Testing for paginated Pages](http://codex.wordpress.org/Conditional_Tags) but i don't know why it isn't working. i put it in the single.php file for post detection. i don't know why the page\_test is broken. example code here:
```
<?php
get_header();
?>
<div id="content" clas... | the above solution i tried already.
Never mind, i solved it, even i don't know why. if some body knows...:
this:
```
// not working
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : false;
if ( $paged === false ) {
```
didn't worked, but this:
```
// works
$paged = get_query_var( 'page' ) ... |
12,578 | <p>I'm trying to build a little class to help build some simple input fields into a custom page in WordPress admin panel, here's what I've got:</p>
<pre><code><?php
class create_panel {
public $default_settings = Array('blog_banner_image' => 'main.jpg');
public function set_ref_name( $str ) {
$this->re... | [
{
"answer_id": 12586,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>Take a look at the <a href=\"http://codex.wordpress.org/Settings_API\" rel=\"nofollow\">Settings API</a> first. But... | 2011/03/20 | [
"https://wordpress.stackexchange.com/questions/12578",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7016/"
] | I'm trying to build a little class to help build some simple input fields into a custom page in WordPress admin panel, here's what I've got:
```
<?php
class create_panel {
public $default_settings = Array('blog_banner_image' => 'main.jpg');
public function set_ref_name( $str ) {
$this->ref_name = $str;
}
publ... | Take a look at the [Settings API](http://codex.wordpress.org/Settings_API) first. But maybe ["OptionTree"](http://wordpress.org/extend/plugins/option-tree/screenshots/) will help you even more. |
12,607 | <p>I messed up the settings with W3 Total Cache (tried to import all the media to my library, didn't work out well, broke all my links to every picture).
So I took my latest backup of the database, copy/paste the _post and _postmeta tables inside my phpmyadmin.
It brought back the links and pictures as expected, but no... | [
{
"answer_id": 12615,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>WordPress by default creates category archive that lists all of the category's posts, but if you want to do ... | 2011/03/21 | [
"https://wordpress.stackexchange.com/questions/12607",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3929/"
] | I messed up the settings with W3 Total Cache (tried to import all the media to my library, didn't work out well, broke all my links to every picture).
So I took my latest backup of the database, copy/paste the \_post and \_postmeta tables inside my phpmyadmin.
It brought back the links and pictures as expected, but now... | Sounds like you are looking for the functionality of [WordPress 3.0 Menus Subpanel](http://codex.wordpress.org/Appearance_Menus_SubPanel). In Dashboard go to 'Appearance' then 'Menus' and you can create a page that will show the posts from a specified category. |
12,613 | <p>I'm using <a href="http://www.fedmich.com/tools/facebook-and-digg-thumbnail-generator" rel="nofollow noreferrer">Facebook and Digg Thumbnail generator</a> and [FaceBook Share (New)],
<a href="http://www.appointy.com/web/facebookshare" rel="nofollow noreferrer">2</a></p>
<p>As you can see if the image is 100px the t... | [
{
"answer_id": 12615,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>WordPress by default creates category archive that lists all of the category's posts, but if you want to do ... | 2011/03/21 | [
"https://wordpress.stackexchange.com/questions/12613",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/781/"
] | I'm using [Facebook and Digg Thumbnail generator](http://www.fedmich.com/tools/facebook-and-digg-thumbnail-generator) and [FaceBook Share (New)],
[2](http://www.appointy.com/web/facebookshare)
As you can see if the image is 100px the thumbail is displayed when I press the share button:
. In Dashboard go to 'Appearance' then 'Menus' and you can create a page that will show the posts from a specified category. |
12,619 | <p>All theme styles are in style.css file.</p>
<p>Let's say first line looks like:</p>
<pre><code>body {
background-color: #fff;
}
</code></pre>
<p>Now, I've created an option in admin panel named body_bg. User types #000 there and I want the value in style.css to change.</p>
<p>How do I achieve that?</p>
<p>T... | [
{
"answer_id": 12615,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>WordPress by default creates category archive that lists all of the category's posts, but if you want to do ... | 2011/03/21 | [
"https://wordpress.stackexchange.com/questions/12619",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1869/"
] | All theme styles are in style.css file.
Let's say first line looks like:
```
body {
background-color: #fff;
}
```
Now, I've created an option in admin panel named body\_bg. User types #000 there and I want the value in style.css to change.
How do I achieve that?
The easiest way to me looks like I have to rena... | Sounds like you are looking for the functionality of [WordPress 3.0 Menus Subpanel](http://codex.wordpress.org/Appearance_Menus_SubPanel). In Dashboard go to 'Appearance' then 'Menus' and you can create a page that will show the posts from a specified category. |
12,627 | <p>Hi to all I'm trying to create an advanced control panel for my first Wordpress template but I'm not able to add a function that I will need.
The function that I'm trying to add is the possibility to choose the position of a DIV (left and bottom) via Admin Panel.
(Apologize me for my really bad english)</p>
<p>Here... | [
{
"answer_id": 12639,
"author": "Jeremy Boyd",
"author_id": 474,
"author_profile": "https://wordpress.stackexchange.com/users/474",
"pm_score": 2,
"selected": false,
"text": "<p>The style.css file is not a php file, thus it cannot execute php code. If you want to include those styles, yo... | 2011/03/21 | [
"https://wordpress.stackexchange.com/questions/12627",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4107/"
] | Hi to all I'm trying to create an advanced control panel for my first Wordpress template but I'm not able to add a function that I will need.
The function that I'm trying to add is the possibility to choose the position of a DIV (left and bottom) via Admin Panel.
(Apologize me for my really bad english)
Here is the co... | From the looks of it your adding php right in the css which will not work. You need to write to the css file itself or dump it right into the html as Jeremy said as I am writing this:)
Writing a new CSS file every time you make any changes can tax your system, but works well if your not making lots of dynamic changes ... |
12,634 | <p>Is there any hook for a tag page, so I can alter it's content before outputting?</p>
| [
{
"answer_id": 12647,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>Archive pages are not generated by some specific function, but are produced by processing template file from your th... | 2011/03/21 | [
"https://wordpress.stackexchange.com/questions/12634",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | Is there any hook for a tag page, so I can alter it's content before outputting? | There is a conditional called :
```
is_tag
```
//From the codex
```
is_tag();
// When any Tag archive page is being displayed.
is_tag('mild');
// When the archive page for tag with the slug of 'mild' is being displayed.
is_tag(array('sharp','mild','extreme'));
// Returns true when the tag archive being displayed ... |
12,654 | <p>I'd like <code>get_the_category_list</code> to only display one or two categories instead of <strong>all</strong> the categories associated with the post. Haven't been able to find any results.</p>
<pre><code><?php echo get_the_category_list(); ?>
</code></pre>
<p>Any help would be appreciated</p>
| [
{
"answer_id": 12656,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>Quick idea would be to pass some simple separator like comma and cut from the start of result till it.</p>\n\n<p>But... | 2011/03/21 | [
"https://wordpress.stackexchange.com/questions/12654",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3296/"
] | I'd like `get_the_category_list` to only display one or two categories instead of **all** the categories associated with the post. Haven't been able to find any results.
```
<?php echo get_the_category_list(); ?>
```
Any help would be appreciated | ```
$categories = get_the_category();
if ( ! empty( $categories ) ) {
echo '<a href="' . esc_url( get_category_link( $categories[0]->term_id ) ) . '">' . esc_html( $categories[0]->name ) . '</a>';
}
``` |
12,663 | <p>I have a custom post type for accessories. When you view the post it also shows related posts. It looks great, but it also shows the current post within related posts. </p>
<p>Is there a way to exclude the current post from the loop?</p>
<pre><code><div>
<?php
$category = get_the_category();
... | [
{
"answer_id": 12656,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>Quick idea would be to pass some simple separator like comma and cut from the start of result till it.</p>\n\n<p>But... | 2011/03/21 | [
"https://wordpress.stackexchange.com/questions/12663",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3296/"
] | I have a custom post type for accessories. When you view the post it also shows related posts. It looks great, but it also shows the current post within related posts.
Is there a way to exclude the current post from the loop?
```
<div>
<?php
$category = get_the_category();
$model = $category[1]->cat_na... | ```
$categories = get_the_category();
if ( ! empty( $categories ) ) {
echo '<a href="' . esc_url( get_category_link( $categories[0]->term_id ) ) . '">' . esc_html( $categories[0]->name ) . '</a>';
}
``` |
12,679 | <p>I'm trying to create a new wordpress template and inside it I added a Control Panel, inside this control panel there is an option that allows user to choose where he want's to place a on a map, I try to explain: user can set div's left and top attributes via control panel.
Now I know how to add an iframe that can s... | [
{
"answer_id": 12699,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 3,
"selected": true,
"text": "<p>If you look at Mystique theme (a great example of option panel with preview BTW) you can see that the main ide... | 2011/03/22 | [
"https://wordpress.stackexchange.com/questions/12679",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4107/"
] | I'm trying to create a new wordpress template and inside it I added a Control Panel, inside this control panel there is an option that allows user to choose where he want's to place a on a map, I try to explain: user can set div's left and top attributes via control panel.
Now I know how to add an iframe that can show ... | If you look at Mystique theme (a great example of option panel with preview BTW) you can see that the main idea is to lavrage the form fields OnChange or change() events to load the theme's preview with Jquery and a bit of ajax.
So you have one function to load by ajax the preview
```
function mystique_get_site_previ... |
12,684 | <p>I am looking for what params are passed to my filter function. Where can I find such info in the codex?</p>
<p><a href="http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content" rel="nofollow">http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content</a> didn't provide much info</p>
<p>I wanted ... | [
{
"answer_id": 12686,
"author": "goldenapples",
"author_id": 290,
"author_profile": "https://wordpress.stackexchange.com/users/290",
"pm_score": 4,
"selected": true,
"text": "<p>I don't think there are any additional parameters passed, per se, to <code>the_content</code>, but global vari... | 2011/03/22 | [
"https://wordpress.stackexchange.com/questions/12684",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3788/"
] | I am looking for what params are passed to my filter function. Where can I find such info in the codex?
<http://codex.wordpress.org/Plugin_API/Filter_Reference/the_content> didn't provide much info
I wanted to know if the post is a child of another | I don't think there are any additional parameters passed, per se, to `the_content`, but global variables like **$post** are accessible.
So something like this would work:
```
add_filter( 'the_content', 'check_for_post_parent' );
function check_for_post_parent($content) {
global $post;
if ($parent_id == $po... |
12,690 | <p>If I click on a category in my Wordpress blog, it displays an excerpt of all articles in the category, and finishes with a word that says "continue" which has no hyperlink.</p>
<p><a href="http://www.superlogical.net/category/computing/windows/internet-explorer/" rel="nofollow">Example here</a>.</p>
<p>How do I fi... | [
{
"answer_id": 12686,
"author": "goldenapples",
"author_id": 290,
"author_profile": "https://wordpress.stackexchange.com/users/290",
"pm_score": 4,
"selected": true,
"text": "<p>I don't think there are any additional parameters passed, per se, to <code>the_content</code>, but global vari... | 2011/03/22 | [
"https://wordpress.stackexchange.com/questions/12690",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3206/"
] | If I click on a category in my Wordpress blog, it displays an excerpt of all articles in the category, and finishes with a word that says "continue" which has no hyperlink.
[Example here](http://www.superlogical.net/category/computing/windows/internet-explorer/).
How do I fix this? | I don't think there are any additional parameters passed, per se, to `the_content`, but global variables like **$post** are accessible.
So something like this would work:
```
add_filter( 'the_content', 'check_for_post_parent' );
function check_for_post_parent($content) {
global $post;
if ($parent_id == $po... |
12,692 | <p>How do I add custom variables to the wordpress query without having to hit the database twice. In the example below I want to add some meta filters. All this code works fine but I have been running query_posts() to execute it. I want to be able to add to the query before it is run by default so I don't have to query... | [
{
"answer_id": 12693,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Hook into the action <code>'pre_get_posts'</code>.<br>\nExample:</p>\n\n<pre><code>add_action( 'pre_get_posts', 'no_st... | 2011/03/22 | [
"https://wordpress.stackexchange.com/questions/12692",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4093/"
] | How do I add custom variables to the wordpress query without having to hit the database twice. In the example below I want to add some meta filters. All this code works fine but I have been running query\_posts() to execute it. I want to be able to add to the query before it is run by default so I don't have to query t... | As toscho said, you can modify the query in the `pre_get_posts` hook. That hook gets the query object passed as an argument, so you don't have to read a global variable.
```
add_action( 'pre_get_posts', 'wpse12692_pre_get_posts' );
function wpse12692_pre_get_posts( &$wp_query )
{
if( isset( $_SESSION['size'] ) &&... |
12,713 | <p>i'm running my web in english and german using the WPML plugin.
my question:
when in english mode - is it possible getting the page_title() but in german?</p>
<p>thanks</p>
| [
{
"answer_id": 20519,
"author": "mike23",
"author_id": 1381,
"author_profile": "https://wordpress.stackexchange.com/users/1381",
"pm_score": 3,
"selected": true,
"text": "<p>Let's say the original language of your site is english, then when visiting a german post you would return the tit... | 2011/03/22 | [
"https://wordpress.stackexchange.com/questions/12713",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3030/"
] | i'm running my web in english and german using the WPML plugin.
my question:
when in english mode - is it possible getting the page\_title() but in german?
thanks | Let's say the original language of your site is english, then when visiting a german post you would return the title of the corresponding english post like that :
```
// Get the post ID of original post
$original_ID = icl_object_id( $post->ID, 'post', false, 'en' );
// Get original post title
$original_title = get_th... |
12,719 | <p><strong>Background</strong></p>
<p>I'm nearing the final stages of constructing my first fairly large WordPress site, and I'm now encountering some friction. For the most part, the site was developed on my local machine and I would push changes up to a staging server for review (<a href="https://wordpress.stackexch... | [
{
"answer_id": 12733,
"author": "editor",
"author_id": 1860,
"author_profile": "https://wordpress.stackexchange.com/users/1860",
"pm_score": 1,
"selected": false,
"text": "<p>I work on such an install and have <a href=\"https://wordpress.stackexchange.com/questions/12239/migrating-data-b... | 2011/03/22 | [
"https://wordpress.stackexchange.com/questions/12719",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2984/"
] | **Background**
I'm nearing the final stages of constructing my first fairly large WordPress site, and I'm now encountering some friction. For the most part, the site was developed on my local machine and I would push changes up to a staging server for review ([see this question for more background](https://wordpress.s... | I asked this question over a year ago, and during that time we've added more people to our team and developed a much larger number of sites in WordPress. I wanted to walk through our process in case it might help anyone else.
Everything in Git
=================
This was something I was doing even as I asked the quest... |
12,721 | <p>Would somebody mind postulating and possible reasons why their is an automated redirect on my homepage that adds /admin to the URL. </p>
<p>Please visit www.divethegap.com/update. You will see that it instantly redirects to /admin and does not load the page. There is a folder called admin that is not accessible to ... | [
{
"answer_id": 12722,
"author": "Jan Fabry",
"author_id": 8,
"author_profile": "https://wordpress.stackexchange.com/users/8",
"pm_score": 2,
"selected": false,
"text": "<p>If the redirect comes from WordPress code, you can find out who is calling <code>wp_redirect()</code> by hooking int... | 2011/03/22 | [
"https://wordpress.stackexchange.com/questions/12721",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2957/"
] | Would somebody mind postulating and possible reasons why their is an automated redirect on my homepage that adds /admin to the URL.
Please visit www.divethegap.com/update. You will see that it instantly redirects to /admin and does not load the page. There is a folder called admin that is not accessible to a user, bu... | By a process of elimination we have determined that the error was caused by the plugin REDIRECTION.
This plugin has now been removed.
I must point out that it was never used and certainly never set up to carry out that action. I can only imagine that somehow the creation of themed files must have had similar names t... |
12,723 | <p>I'm using <a href="https://wordpress.stackexchange.com/users/2487/bainternet">bainternet's</a> method for <a href="https://wordpress.stackexchange.com/questions/10424/create-multiple-search-functions-for-posts-custom-post-types-and-everything?tab=oldest#tab-top">searching custom post_types</a> and it works great. Ho... | [
{
"answer_id": 12728,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 5,
"selected": true,
"text": "<p>change </p>\n\n<pre><code><input type=\"hidden\" name=\"post_type\" value=\"software\" />\n</code></pre>... | 2011/03/22 | [
"https://wordpress.stackexchange.com/questions/12723",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3296/"
] | I'm using [bainternet's](https://wordpress.stackexchange.com/users/2487/bainternet) method for [searching custom post\_types](https://wordpress.stackexchange.com/questions/10424/create-multiple-search-functions-for-posts-custom-post-types-and-everything?tab=oldest#tab-top) and it works great. However, I've recently bee... | change
```
<input type="hidden" name="post_type" value="software" />
```
to
```
<input type="hidden" name="post_type[]" value="software" />
<input type="hidden" name="post_type[]" value="books" />
```
i have to run but this should work , just add as many hidden fields as you need for each post type |
12,729 | <p>I have a few plugins that I always set the configuration for exactly the same way. Every time I create a new site, the same plugins go in, and the same amount of time is needed to set them up.</p>
<p>Would it be possible to create a config file that overrides whatever wp_options are set per plugin?</p>
| [
{
"answer_id": 12730,
"author": "Ashfame",
"author_id": 1521,
"author_profile": "https://wordpress.stackexchange.com/users/1521",
"pm_score": 0,
"selected": false,
"text": "<p>Not sure if something like that is possible but a workaround would be to use a dummy database of default WP inst... | 2011/03/22 | [
"https://wordpress.stackexchange.com/questions/12729",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10/"
] | I have a few plugins that I always set the configuration for exactly the same way. Every time I create a new site, the same plugins go in, and the same amount of time is needed to set them up.
Would it be possible to create a config file that overrides whatever wp\_options are set per plugin? | You could check which options they add (look at the source code) and then simply write a function like this:
```
/*
Plugin Name: Mother of all plugins
Plugin URI: http://wordpress.org/extend/plugins/
Description: Offers the <code>$all_plugin_options;</code> var to access all predefined plugin options
Author: ... |
12,731 | <p>is it possible to hide the string: "Comments are disabled" from everywhere?</p>
<p>I mean also from posts list, and post page :)</p>
<p>Thanks :)</p>
<p>EDIT:</p>
<p>sorry, the theme is Journal Cruch by Site5.com</p>
<p>However I resolved using</p>
<pre><code>if (comments_open())
comments_popup_link();
</c... | [
{
"answer_id": 12740,
"author": "markratledge",
"author_id": 268,
"author_profile": "https://wordpress.stackexchange.com/users/268",
"pm_score": 1,
"selected": false,
"text": "<p>Try editing theme files and remove the php comments links, or add CSS to display:none to the comments div in ... | 2011/03/22 | [
"https://wordpress.stackexchange.com/questions/12731",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/343/"
] | is it possible to hide the string: "Comments are disabled" from everywhere?
I mean also from posts list, and post page :)
Thanks :)
EDIT:
sorry, the theme is Journal Cruch by Site5.com
However I resolved using
```
if (comments_open())
comments_popup_link();
```
where the comments are displayed, but I don't ... | Popup link takes five parameters.
```
comments_popup_link('No Comments','One Comment','Many Comments','CSSclass','Comments Disabled');
```
So you are on to the correct solution. Now just change the above strings to whatever you want them to be for each # of comments. Finally change 'Comments Disabled' to just `''`.... |
12,742 | <p>I'm trying to filter posts in a category by the year of the post's date. I also want to do this without being redirected to the year template so my ideal URL would be <a href="http://example.com/category/reports/2011/" rel="nofollow">http://example.com/category/reports/2011/</a> which would load the template file ca... | [
{
"answer_id": 12743,
"author": "John P Bloch",
"author_id": 11,
"author_profile": "https://wordpress.stackexchange.com/users/11",
"pm_score": 4,
"selected": true,
"text": "<p>This should work:</p>\n\n<pre><code>add_action( 'init', 'wpa12742_init' );\n\nfunction wpa12742_init(){\n add_r... | 2011/03/22 | [
"https://wordpress.stackexchange.com/questions/12742",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2744/"
] | I'm trying to filter posts in a category by the year of the post's date. I also want to do this without being redirected to the year template so my ideal URL would be <http://example.com/category/reports/2011/> which would load the template file category.php where I could then use query\_posts to include only the posts... | This should work:
```
add_action( 'init', 'wpa12742_init' );
function wpa12742_init(){
add_rewrite_rule( 'category/(.+?)/(\d{4})/?$', 'index.php?category_name=$matches[1]&year=$matches[2]', 'top' );
add_rewrite_rule( 'category/(.+?)/(\d{4})/page/(\d+)/?$', 'index.php?category_name=$matches[1]&year=$matches[2]&pag... |
12,744 | <p>hey guys,
i know there is something like
<code>if ( function_exists('')</code></p>
<p>is it possible to use that with <code>next_posts_link()</code> and <code>previous_posts_link()</code>.</p>
<p>The reason I'm asking that is that I have something like</p>
<pre><code><div class="navigation">
<div cl... | [
{
"answer_id": 12755,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>Take a look at my <a href=\"https://github.com/franz-josef-kaiser/Easy-Pagination-Deamon\" rel=\"nofollow\">(educat... | 2011/03/22 | [
"https://wordpress.stackexchange.com/questions/12744",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3529/"
] | hey guys,
i know there is something like
`if ( function_exists('')`
is it possible to use that with `next_posts_link()` and `previous_posts_link()`.
The reason I'm asking that is that I have something like
```
<div class="navigation">
<div class="next-posts"><?php next_posts_link('« older') ?></div>
<... | Check out this link:
<http://www.ericmmartin.com/conditional-pagepost-navigation-links-in-wordpress-redux/>
:) |
12,746 | <pre><code><?php echo get_the_term_list( $post->ID, 'people', 'People: ', ' ', '' ); ?>
</code></pre>
<p>returns something like this: </p>
<pre><code>People: <a href="person1">Person1</a>, <a href="person2">Person2</a>, ...
</code></pre>
<p>How can I make it return the same thing wi... | [
{
"answer_id": 12752,
"author": "Joe Hoyle",
"author_id": 150,
"author_profile": "https://wordpress.stackexchange.com/users/150",
"pm_score": 5,
"selected": true,
"text": "<p>It may be easier to just write the list manually, something like:</p>\n\n<pre><code><?php\n$terms = wp_get_pos... | 2011/03/22 | [
"https://wordpress.stackexchange.com/questions/12746",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2107/"
] | ```
<?php echo get_the_term_list( $post->ID, 'people', 'People: ', ' ', '' ); ?>
```
returns something like this:
```
People: <a href="person1">Person1</a>, <a href="person2">Person2</a>, ...
```
How can I make it return the same thing without links like this:
```
People: Person1, Person2
``` | It may be easier to just write the list manually, something like:
```
<?php
$terms = wp_get_post_tags( $post->ID );
//For custom taxonomy use this line below
//$terms = wp_get_object_terms( $post->ID, 'people' );
foreach( $terms as $term )
$term_names[] = $term->name;
echo implode( ', ', $term_names );
``` |
12,747 | <p>I've created a plugin that lets users build super-simple landing pages for mobile devices.</p>
<p>The pages my plugin creates are of a custom post type.</p>
<p>I want to provide users with an option to "disable all other plugins on this page", to prevent things like tweetmeme, facebook like buttons, and other thir... | [
{
"answer_id": 12750,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>There's an option that gives you back an array of all plugins in your blog.</p>\n\n<pre><code>print_r( (array) get_... | 2011/03/22 | [
"https://wordpress.stackexchange.com/questions/12747",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15/"
] | I've created a plugin that lets users build super-simple landing pages for mobile devices.
The pages my plugin creates are of a custom post type.
I want to provide users with an option to "disable all other plugins on this page", to prevent things like tweetmeme, facebook like buttons, and other third-party plugin ge... | There's an option that gives you back an array of all plugins in your blog.
```
print_r( (array) get_option( 'active_plugins' ) );
``` |
12,754 | <p>Is there a way to remove <code>wptexturize</code> only for a certain shortcode?</p>
| [
{
"answer_id": 13461,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 2,
"selected": false,
"text": "<p>Shortcodes run after the wptexturize function, so they shouldn't get processed by it anyway.</p>\n\n<p>wptexturize ... | 2011/03/22 | [
"https://wordpress.stackexchange.com/questions/12754",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2415/"
] | Is there a way to remove `wptexturize` only for a certain shortcode? | There is a clue in `wp-includes/formatting.php` in the function `wptexturize`:
```
$default_no_texturize_shortcodes = array('code');
...
$no_texturize_shortcodes = '(' . implode('|',
apply_filters('no_texturize_shortcodes', $default_no_texturize_shortcodes) ) . ')';
```
Try using this filter to add a shortcode t... |
12,760 | <p>I want to use a Regular Expression(regex) to test the value of a form's zipcode field on a WordPress page, then based upon those results either:</p>
<ul>
<li><p>Selectively assign/reveal price fields on the same page.</p>
<p><strong>or</strong></p></li>
<li><p>Selectively redirect user to a page having the result-... | [
{
"answer_id": 12761,
"author": "editor",
"author_id": 1860,
"author_profile": "https://wordpress.stackexchange.com/users/1860",
"pm_score": 1,
"selected": false,
"text": "<p>I think you've more or less got what you need. You've got a textfield in an HTML form. That form needs to sit in ... | 2011/03/22 | [
"https://wordpress.stackexchange.com/questions/12760",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I want to use a Regular Expression(regex) to test the value of a form's zipcode field on a WordPress page, then based upon those results either:
* Selectively assign/reveal price fields on the same page.
**or**
* Selectively redirect user to a page having the result-specific pricing.
Here's the regex and the js pseu... | I think you've more or less got what you need. You've got a textfield in an HTML form. That form needs to sit in a template file somewhere in a WordPress theme. This template file generates uncached pages.
Inside the PHP template for said template file, check the $\_POST (or [$\_REQUEST](http://php.net/manual/en/reser... |
12,777 | <p>I'm finding this string appended to the end of my URLs sometimes:</p>
<pre><code>/?doing_wp_cron
</code></pre>
<p>Does anyone know what it for? How can I remove it?</p>
| [
{
"answer_id": 12778,
"author": "scribu",
"author_id": 205,
"author_profile": "https://wordpress.stackexchange.com/users/205",
"pm_score": 5,
"selected": true,
"text": "<p>It's a sign that you have <code>ALTERNATE_WP_CRON</code> defined in your <code>wp-config.php</code></p>\n\n<p>In ord... | 2011/03/23 | [
"https://wordpress.stackexchange.com/questions/12777",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2115/"
] | I'm finding this string appended to the end of my URLs sometimes:
```
/?doing_wp_cron
```
Does anyone know what it for? How can I remove it? | It's a sign that you have `ALTERNATE_WP_CRON` defined in your `wp-config.php`
In order to do some background processing (like publishing scheduled posts), WordPress redirects you to the URL with `?doing_wp_cron` appended. |
12,784 | <p>I'm new to wordpress and trying to learn my way through from making a theme.
Right now I am using wp_nav_menu to generate my menu
My menu consists of pages and categories</p>
<p>However, the default generation of the menu looks like</p>
<pre><code><div id="navi">
<div class="menu-primary-container">
... | [
{
"answer_id": 12785,
"author": "zeo",
"author_id": 1241,
"author_profile": "https://wordpress.stackexchange.com/users/1241",
"pm_score": 1,
"selected": false,
"text": "<pre><code>function wp_nav_menu_remove_attributes( $menu ){\n return $menu = preg_replace('/ id=\\\"(.*)\\\" class=\... | 2011/03/23 | [
"https://wordpress.stackexchange.com/questions/12784",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4149/"
] | I'm new to wordpress and trying to learn my way through from making a theme.
Right now I am using wp\_nav\_menu to generate my menu
My menu consists of pages and categories
However, the default generation of the menu looks like
```
<div id="navi">
<div class="menu-primary-container">
<ul id="menu-primary" class="... | If you look in [the `wp_nav_menu()` function](http://core.trac.wordpress.org/browser/tags/3.1/wp-includes/nav-menu-template.php#L111), you see the items are written by [`walk_nav_menu_tree()`](http://core.trac.wordpress.org/browser/tags/3.1/wp-includes/nav-menu-template.php#L462), which calls [`Walker_Nav_Menu`](http:/... |
12,797 | <p>I have this code that returns list of post title as links, but when I add the 'orderby' and 'order' parameters - it returns results but 'orderby, order, rand' do not work, can anyone tell me what I'm doing wrong? Thanks!</p>
<pre><code><ul>
<?php $post; $cat_posts = get_posts(array('numberposts' => 1... | [
{
"answer_id": 12830,
"author": "dani",
"author_id": 3991,
"author_profile": "https://wordpress.stackexchange.com/users/3991",
"pm_score": 1,
"selected": false,
"text": "<p>Why don't you try to use <a href=\"http://codex.wordpress.org/Function_Reference/query_posts\" rel=\"nofollow\">que... | 2011/03/23 | [
"https://wordpress.stackexchange.com/questions/12797",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I have this code that returns list of post title as links, but when I add the 'orderby' and 'order' parameters - it returns results but 'orderby, order, rand' do not work, can anyone tell me what I'm doing wrong? Thanks!
```
<ul>
<?php $post; $cat_posts = get_posts(array('numberposts' => 10, 'orderby' => 'rand', 'o... | Yes, this is the correct syntax:
```
$args = array(
'orderby' => 'rand',
'order' => 'ASC'
);
query_posts( $args );
```
However plugins can keep this from working properly. Try disabling **ALL** plugins and see if that helps. Two known plugins which keep `orderby=rand` from working are `Post Type Order` an... |
12,798 | <p>Has anyone effectively integrated <a href="http://wordpress.org/extend/plugins/gd-star-rating/" rel="nofollow">GD star rating</a> and <a href="http://wordpress.org/extend/plugins/cubepoints/" rel="nofollow">Cube Points</a>?</p>
<p>From the documentation:</p>
<blockquote>
<p>Plugin Integration CubePoints can also... | [
{
"answer_id": 12830,
"author": "dani",
"author_id": 3991,
"author_profile": "https://wordpress.stackexchange.com/users/3991",
"pm_score": 1,
"selected": false,
"text": "<p>Why don't you try to use <a href=\"http://codex.wordpress.org/Function_Reference/query_posts\" rel=\"nofollow\">que... | 2011/03/23 | [
"https://wordpress.stackexchange.com/questions/12798",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/781/"
] | Has anyone effectively integrated [GD star rating](http://wordpress.org/extend/plugins/gd-star-rating/) and [Cube Points](http://wordpress.org/extend/plugins/cubepoints/)?
From the documentation:
>
> Plugin Integration CubePoints can also
> be easily integrated with other
> plugins. Other plugins can be coded
> s... | Yes, this is the correct syntax:
```
$args = array(
'orderby' => 'rand',
'order' => 'ASC'
);
query_posts( $args );
```
However plugins can keep this from working properly. Try disabling **ALL** plugins and see if that helps. Two known plugins which keep `orderby=rand` from working are `Post Type Order` an... |
12,808 | <p>I'm a bit confused about <code>wp_list_pages()</code> function.</p>
<p>Lets say I have 3 top level pages (with no parent) and each of them have some sub-pages: </p>
<ul>
<li>page 1 [sub-pages: 1.1, 1.2, 1.3]; </li>
<li>page 2 [sub-pages: 2.1, 2.2, 2.3]; </li>
<li>page 3 [sub-pages: 3.1, 3.2]</li>
</ul>
<p>What I'... | [
{
"answer_id": 12830,
"author": "dani",
"author_id": 3991,
"author_profile": "https://wordpress.stackexchange.com/users/3991",
"pm_score": 1,
"selected": false,
"text": "<p>Why don't you try to use <a href=\"http://codex.wordpress.org/Function_Reference/query_posts\" rel=\"nofollow\">que... | 2011/03/23 | [
"https://wordpress.stackexchange.com/questions/12808",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1343/"
] | I'm a bit confused about `wp_list_pages()` function.
Lets say I have 3 top level pages (with no parent) and each of them have some sub-pages:
* page 1 [sub-pages: 1.1, 1.2, 1.3];
* page 2 [sub-pages: 2.1, 2.2, 2.3];
* page 3 [sub-pages: 3.1, 3.2]
What I'm trying to do is to display top level pages 2 and 3 with all ... | Yes, this is the correct syntax:
```
$args = array(
'orderby' => 'rand',
'order' => 'ASC'
);
query_posts( $args );
```
However plugins can keep this from working properly. Try disabling **ALL** plugins and see if that helps. Two known plugins which keep `orderby=rand` from working are `Post Type Order` an... |
12,814 | <p>Got a custom field called <code>startDate</code> but its only on a few events. I was wondering if it isn't set for a post I could use <code>post_date</code> to generate the posts list?</p>
<pre><code>// if meta_key _postmeta.startDate isn't set get the rest by posts.post_date
query_posts(
array(
array(... | [
{
"answer_id": 12833,
"author": "Alex Older",
"author_id": 3365,
"author_profile": "https://wordpress.stackexchange.com/users/3365",
"pm_score": 0,
"selected": false,
"text": "<p>try something along the lines of:</p>\n\n<pre><code>$postedtime = get_post_meta($post->ID, 'startDate');\n... | 2011/03/23 | [
"https://wordpress.stackexchange.com/questions/12814",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3978/"
] | Got a custom field called `startDate` but its only on a few events. I was wondering if it isn't set for a post I could use `post_date` to generate the posts list?
```
// if meta_key _postmeta.startDate isn't set get the rest by posts.post_date
query_posts(
array(
array(
'posts_per_page' => 10,... | If you can explain it in SQL, you can query for it! There are three places where we want to change the default query:
```sql
SELECT wp_posts.*
FROM wp_posts
INNER JOIN wp_postmeta ON (wp_posts.ID = wp_postmeta.post_id)
WHERE 1=1
AND wp_posts.post_type = 'post'
AND (wp_posts.post_status = 'publish')
AND wp... |
12,821 | <p>How would one move the sharedaddy buttons included in Jetpack to be placed before a post's or page's content, rather than after it? I see that in <code>sharing-service.php</code> the function that prints the buttons is hooked to the_content filter hook: <code>add_filter( 'the_content', 'sharing_display', 19 );</code... | [
{
"answer_id": 12826,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": true,
"text": "<p>Basically it line 480 in sharing-service.php\nwhere it says:</p>\n\n<pre><code>return $text.$sharing_content;\... | 2011/03/23 | [
"https://wordpress.stackexchange.com/questions/12821",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49/"
] | How would one move the sharedaddy buttons included in Jetpack to be placed before a post's or page's content, rather than after it? I see that in `sharing-service.php` the function that prints the buttons is hooked to the\_content filter hook: `add_filter( 'the_content', 'sharing_display', 19 );`
I'm not sure what to ... | Basically it line 480 in sharing-service.php
where it says:
```
return $text.$sharing_content;
```
and it should be
```
return $sharing_content.$text;
```
now changing that file won't keep your changes on updates so you can copy that function (sharing\_display) to your functions.php and rename it to something di... |
12,824 | <p>I'm working on a migration from another CMS to WordPress. The old site had terrible SEO-unfriendly URLs in the format <code>http://example.com?lid=1234</code>.</p>
<p>We have imported all the posts from the old site into WordPress and are storing the <code>lid</code> as a custom field.</p>
<p>We would love the old... | [
{
"answer_id": 12837,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": true,
"text": "<p>here is an idea, first add <code>lid</code> to query_vars:</p>\n\n<pre><code>add_filter('query_vars', 'lid_que... | 2011/03/23 | [
"https://wordpress.stackexchange.com/questions/12824",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2877/"
] | I'm working on a migration from another CMS to WordPress. The old site had terrible SEO-unfriendly URLs in the format `http://example.com?lid=1234`.
We have imported all the posts from the old site into WordPress and are storing the `lid` as a custom field.
We would love the old URLs to still work if possible, but as... | here is an idea, first add `lid` to query\_vars:
```
add_filter('query_vars', 'lid_query_vars');
function lid_query_vars($vars) {
// add lid to the valid list of variables
$new_vars = array('lid');
$vars = $new_vars + $vars;
return $vars;
}
```
then use `parse_request` hook to create your redirect
`... |
12,844 | <p>How do I add classes in the wp_list_category , I know the wp_list_categories('title_li=');
generates classes , but I want to add a class in the parent category link</p>
<pre><code><ul>
<li><a href="#"> link1</a> </li>
<li><a href="#">link2 </a> </li>
<... | [
{
"answer_id": 12846,
"author": "PNMG",
"author_id": 1756,
"author_profile": "https://wordpress.stackexchange.com/users/1756",
"pm_score": 2,
"selected": false,
"text": "<p>I have gotten this to work mainly by reverse-engineering the <a href=\"http://anthologyoi.com/wordpress/plugins/wor... | 2011/03/23 | [
"https://wordpress.stackexchange.com/questions/12844",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2210/"
] | How do I add classes in the wp\_list\_category , I know the wp\_list\_categories('title\_li=');
generates classes , but I want to add a class in the parent category link
```
<ul>
<li><a href="#"> link1</a> </li>
<li><a href="#">link2 </a> </li>
<li><a href="#">link3 </a> <---how do I add a special class here... | jquery accordion accepts an option called header that allows you to provide a selector to designate the items you want to act as the accordion headers.
```
$('li.categories > ul').accordion({ header: 'li.categories > ul > li' });
```
--- |
12,863 | <p>How can I check if the current page is <code>wp-login.php</code> or <code>wp-signup.php</code> ?</p>
<p>Are there more elegant solutions than using <code>$_SERVER['REQUEST_URI']</code> ?</p>
| [
{
"answer_id": 12865,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 7,
"selected": true,
"text": "<p>Use the global <code>$pagenow</code>, which is a common global set by WordPress at runtime:</p>\n\n<pre><cod... | 2011/03/23 | [
"https://wordpress.stackexchange.com/questions/12863",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1986/"
] | How can I check if the current page is `wp-login.php` or `wp-signup.php` ?
Are there more elegant solutions than using `$_SERVER['REQUEST_URI']` ? | Use the global `$pagenow`, which is a common global set by WordPress at runtime:
```
if ( $GLOBALS['pagenow'] === 'wp-login.php' ) {
// We're on the login page!
}
```
You can also check the *type* of login page, for example registration:
```
if ( $GLOBALS['pagenow'] === 'wp-login.php' && ! empty( $_REQUEST['act... |
12,866 | <p>I've got a plugin that transfers some files over to the uploads folder of the site in which the plugin is installed.</p>
<p>It works fine, however, the images are not appearing in the Media Manager. I expect some database registration is involved.</p>
<p>Given the script below which copies the files into the direc... | [
{
"answer_id": 12872,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 3,
"selected": true,
"text": "<p>add this to your for each and $filename to each file,</p>\n\n<pre><code> $wp_filetype = wp_check_filetype(base... | 2011/03/23 | [
"https://wordpress.stackexchange.com/questions/12866",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/366/"
] | I've got a plugin that transfers some files over to the uploads folder of the site in which the plugin is installed.
It works fine, however, the images are not appearing in the Media Manager. I expect some database registration is involved.
Given the script below which copies the files into the directory, what comman... | add this to your for each and $filename to each file,
```
$wp_filetype = wp_check_filetype(basename($filename), null );
$attachment = array(
'post_mime_type' => $wp_filetype['type'],
'post_title' => preg_replace('/\.[^.]+$/', '', basename($filename)),
'post_content' => '',
'post_status' => 'inhe... |
12,871 | <p>Is there a way to get a path to the themes directory without the current theme in the path?</p>
<p>ie, in a standard WP install, I would want a reference to:</p>
<blockquote>
<p>C:\xampplite\htdocs\sitename/wp-content/themes/</p>
</blockquote>
<p>But the TEMPLATEPATH constant returns...</p>
<blockquote>
<p>C... | [
{
"answer_id": 12874,
"author": "Evan Yeung",
"author_id": 1878,
"author_profile": "https://wordpress.stackexchange.com/users/1878",
"pm_score": 2,
"selected": false,
"text": "<p>There is no THEMEPATH constant, but you can use the <code>get_theme_root_uri()</code> function to retrieve th... | 2011/03/23 | [
"https://wordpress.stackexchange.com/questions/12871",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/366/"
] | Is there a way to get a path to the themes directory without the current theme in the path?
ie, in a standard WP install, I would want a reference to:
>
> C:\xampplite\htdocs\sitename/wp-content/themes/
>
>
>
But the TEMPLATEPATH constant returns...
>
> C:\xampplite\htdocs\sitename/wp-content/themes/currentAct... | ```
dirname( STYLESHEETPATH );
```
That will return the theme directory.
**Never** assume `/wp-content/` below ABSPATH. I’m using often a different directory and domain for `wp-content` to enable cookieless requests to theme files. Bad plugins and themes break terribly in such cases.
### Addendum
Or use `get_them... |
12,884 | <p>On www.webhostingbreak.com I have custom post types for web hosting companies.
Their url is /hosting-directory/ and unfortunately, since then (aug2010), we've still got all those pages at PR0 and rankings overall have been terrible.</p>
<p>The only guess I have is that because visiting /hosting-directory/ causes a ... | [
{
"answer_id": 12885,
"author": "John P Bloch",
"author_id": 11,
"author_profile": "https://wordpress.stackexchange.com/users/11",
"pm_score": 2,
"selected": false,
"text": "<p>If you want to remove the slug you need to do one of two (2) things:</p>\n\n<ol>\n<li><p>Stop using custom post... | 2011/03/24 | [
"https://wordpress.stackexchange.com/questions/12884",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | On www.webhostingbreak.com I have custom post types for web hosting companies.
Their url is /hosting-directory/ and unfortunately, since then (aug2010), we've still got all those pages at PR0 and rankings overall have been terrible.
The only guess I have is that because visiting /hosting-directory/ causes a 404 error,... | If you want to remove the slug you need to do one of two (2) things:
1. Stop using custom post types because you don't seem to understand what they are or are meant to be used for. Use pages instead. They already do EXACTLY what you want to do, permalinks-wise.
2. Add a custom rewrite rule for each and every individua... |
12,892 | <p>This correctly sort posts by thumbs vote (<a href="http://wordpress.org/extend/plugins/gd-star-rating/" rel="nofollow">GD star rating</a> plugin):</p>
<pre><code><?php query_posts('gdsr_sort=thumbs&post_type=bbp_reply&posts_per_page=2&post_parent='.$post->ID); ?>
<?php while ( have_posts() )... | [
{
"answer_id": 12928,
"author": "Jan Fabry",
"author_id": 8,
"author_profile": "https://wordpress.stackexchange.com/users/8",
"pm_score": 3,
"selected": true,
"text": "<p>It seems <a href=\"http://plugins.trac.wordpress.org/browser/gd-star-rating/tags/1.9.7/code/blg/query.php#L76\" rel=\... | 2011/03/24 | [
"https://wordpress.stackexchange.com/questions/12892",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/781/"
] | This correctly sort posts by thumbs vote ([GD star rating](http://wordpress.org/extend/plugins/gd-star-rating/) plugin):
```
<?php query_posts('gdsr_sort=thumbs&post_type=bbp_reply&posts_per_page=2&post_parent='.$post->ID); ?>
<?php while ( have_posts() ) : the_post(); ?>
<h2><?php the_title(); ?></h2>
<?php ... | It seems [GD Star Rating uses `get_query_var()`](http://plugins.trac.wordpress.org/browser/gd-star-rating/tags/1.9.7/code/blg/query.php#L76) to read query variables, which only reads this global `$wp_query` variable. `query_posts()` overwrites the global `$wp_query` variable, so it works there, but creating a new `WP_Q... |
12,904 | <p>I really need some help, I dont know where else to turn with this request. I'd like to add a shortcode to one of my posts. The template tags get_next_post() and get_previous will not work for me since I dont want post navigation on each post page and I want to control where it displays. In a DIV in an HTML structure... | [
{
"answer_id": 12908,
"author": "zina",
"author_id": 1619,
"author_profile": "https://wordpress.stackexchange.com/users/1619",
"pm_score": 3,
"selected": true,
"text": "<p>this is very simple to do...</p>\n\n<pre><code> // next \nfunction next_shortcode($atts) {\n // global $pos... | 2011/03/24 | [
"https://wordpress.stackexchange.com/questions/12904",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4179/"
] | I really need some help, I dont know where else to turn with this request. I'd like to add a shortcode to one of my posts. The template tags get\_next\_post() and get\_previous will not work for me since I dont want post navigation on each post page and I want to control where it displays. In a DIV in an HTML structure... | this is very simple to do...
```
// next
function next_shortcode($atts) {
// global $post; -unnecessary
return '<div class="nav-next">'.next_post_link( '%link', '%title <span class="meta-nav">' . _x( '', 'Next post link', ' ' ) . '</span>',true ).'</div>';
}
add_s... |
12,910 | <p>I'm building a website that uses the <a href="http://wordpress.org/extend/plugins/gd-star-rating/" rel="nofollow">GD star rating plugin</a>.</p>
<p>Right now, I'm using the following code to retrieve two posts of the current page (a custom post type called <code>bbp_topic</code>) and sort them by vote:</p>
<pre><c... | [
{
"answer_id": 12911,
"author": "Lea Cohen",
"author_id": 373,
"author_profile": "https://wordpress.stackexchange.com/users/373",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried </p>\n\n<pre><code>gdsr_sort=rating&gdsr_order=desc\n</code></pre>\n"
},
{
"answer_id... | 2011/03/24 | [
"https://wordpress.stackexchange.com/questions/12910",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/781/"
] | I'm building a website that uses the [GD star rating plugin](http://wordpress.org/extend/plugins/gd-star-rating/).
Right now, I'm using the following code to retrieve two posts of the current page (a custom post type called `bbp_topic`) and sort them by vote:
```
<?php query_posts('gdsr_sort=thumbs&posts_per_page=2&p... | `gdsr_ftvmin=1` is probably the query parameter you need |
12,913 | <p>As the title says, i would like a nice bit of coding to stick in my functions that pre-loads any images that are attached to the next post.</p>
<p>This means that whilst my users are browsing, they page will load, but it will actually be loading the next page, so when you click-through, the images should already be... | [
{
"answer_id": 12911,
"author": "Lea Cohen",
"author_id": 373,
"author_profile": "https://wordpress.stackexchange.com/users/373",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried </p>\n\n<pre><code>gdsr_sort=rating&gdsr_order=desc\n</code></pre>\n"
},
{
"answer_id... | 2011/03/24 | [
"https://wordpress.stackexchange.com/questions/12913",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4181/"
] | As the title says, i would like a nice bit of coding to stick in my functions that pre-loads any images that are attached to the next post.
This means that whilst my users are browsing, they page will load, but it will actually be loading the next page, so when you click-through, the images should already be there and... | `gdsr_ftvmin=1` is probably the query parameter you need |
12,931 | <p>Some plugins use the <code>'template'</code>, <code>'option_template'</code> and <code>'option_stylesheet'</code> to dynamically serve (alternative) wordpress templates. For example, Nathan Rice's <code>ServeDefaultToIESix</code>.
For Example - </p>
<pre><code>add_filter('template', 'change_theme');
add_filter('op... | [
{
"answer_id": 12956,
"author": "AutoBlogged",
"author_id": 3973,
"author_profile": "https://wordpress.stackexchange.com/users/3973",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried hooking the template_directory filter? There are also hooks for each of the individual templa... | 2011/03/24 | [
"https://wordpress.stackexchange.com/questions/12931",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4182/"
] | Some plugins use the `'template'`, `'option_template'` and `'option_stylesheet'` to dynamically serve (alternative) wordpress templates. For example, Nathan Rice's `ServeDefaultToIESix`.
For Example -
```
add_filter('template', 'change_theme');
add_filter('option_template', 'change_theme');
add_filter('option_styles... | **You could also write your own simple get\_template\_part alias function:**
The following allows 3 subfolders for template parts that sit in a theme root folder named *devices*.
```
<?php
// STYLESHEETS
function print_device_styles( $client = 'desktop' )
{
$client = apply_filters( 'set_theme_clien... |
12,940 | <p>How do I completely remove widget support from a theme/plugin ?</p>
<p>Like removing the <em>appearance -> widgets page</em>, and prevent WP from loading widget classes and all widget-related stuff.</p>
| [
{
"answer_id": 12941,
"author": "Dillie-O",
"author_id": 1165,
"author_profile": "https://wordpress.stackexchange.com/users/1165",
"pm_score": 3,
"selected": true,
"text": "<p>One option would be to simply flush the widget code out of the sidebar.php file, as well as the header/footer/po... | 2011/03/24 | [
"https://wordpress.stackexchange.com/questions/12940",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1986/"
] | How do I completely remove widget support from a theme/plugin ?
Like removing the *appearance -> widgets page*, and prevent WP from loading widget classes and all widget-related stuff. | One option would be to simply flush the widget code out of the sidebar.php file, as well as the header/footer/post pages if they are using widgets.
However, take a peek at this code snippet (courtesy of [this site](http://justintadlock.com/archives/2009/03/06/disable-widget-areas-without-touching-theme-templates)), wh... |
12,970 | <p>I'm planing a custom post type functionality for my theme and need to be able to display more than just one <code>post_type</code> in a admin overview table. That request I imagine might look like <code>edit.php?post_type[]=theme_slide_nivo&post_type[]=theme_slide_other</code>. Haven't actually tried that but i'... | [
{
"answer_id": 12985,
"author": "Jan Fabry",
"author_id": 8,
"author_profile": "https://wordpress.stackexchange.com/users/8",
"pm_score": 3,
"selected": true,
"text": "<p>I tried it out to get an idea of the problems you will run into. The following code allows you to specify multiple po... | 2011/03/24 | [
"https://wordpress.stackexchange.com/questions/12970",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4192/"
] | I'm planing a custom post type functionality for my theme and need to be able to display more than just one `post_type` in a admin overview table. That request I imagine might look like `edit.php?post_type[]=theme_slide_nivo&post_type[]=theme_slide_other`. Haven't actually tried that but i'm pretty confident it won't w... | I tried it out to get an idea of the problems you will run into. The following code allows you to specify multiple post types with the `multi_post_type` parameter:
```
add_action( 'pre_get_posts', 'wpse12970_pre_get_posts' );
function wpse12970_pre_get_posts( &$wp_query )
{
if ( is_admin() && array_key_exists( 'mu... |
12,971 | <p>hey guys,
I really need you help with this one.</p>
<p>I'm using the subscribe2 Plugin (for email subscriptions).
I want to show the signup form as a widget. The plugin author recommends doing it the following way.</p>
<pre><code>$content = apply_filters('the_content', '<!--subscribe2-->');
$content = remove... | [
{
"answer_id": 12986,
"author": "hakre",
"author_id": 178,
"author_profile": "https://wordpress.stackexchange.com/users/178",
"pm_score": 1,
"selected": false,
"text": "<p>I think you have a little error in your code that will prevent it from working:</p>\n\n<pre><code>$content = apply_f... | 2011/03/24 | [
"https://wordpress.stackexchange.com/questions/12971",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3529/"
] | hey guys,
I really need you help with this one.
I'm using the subscribe2 Plugin (for email subscriptions).
I want to show the signup form as a widget. The plugin author recommends doing it the following way.
```
$content = apply_filters('the_content', '<!--subscribe2-->');
$content = remove_filter('the_content', 'pag... | Its extremely difficult to remove a filter that's added as part of an object. You have get the reference to the original object and pass that as part of the function to remove.
Luckily the filter was added at an unusual priority, so you will probably be safe removing all filters at priority 100:
```
remove_all_filter... |
12,984 | <p>I've just setup a new Blog for a friend and thought it's better to not give him Administrator Access right away as a precaution.</p>
<p>I created a new user as Editor therefore.</p>
<p>But then I saw that this user can not change the Theme Settings like Background and Header.</p>
<p>Is there an easy way to allow ... | [
{
"answer_id": 12993,
"author": "Chris",
"author_id": 1714,
"author_profile": "https://wordpress.stackexchange.com/users/1714",
"pm_score": 3,
"selected": false,
"text": "<p>Don't they need the \"edit_themes\" capability? You can use Justin Tadlocks plugin <a href=\"http://wordpress.org/... | 2011/03/24 | [
"https://wordpress.stackexchange.com/questions/12984",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/178/"
] | I've just setup a new Blog for a friend and thought it's better to not give him Administrator Access right away as a precaution.
I created a new user as Editor therefore.
But then I saw that this user can not change the Theme Settings like Background and Header.
Is there an easy way to allow the Editor Role to edit ... | you can add capabilities to the editor role using the role object and add\_cap from you functions.php
```
<?php
// get the the role object
$editor = get_role('editor');
// add $cap capability to this role object
$editor->add_cap('edit_theme_options');
?>
```
you can also remove capabilities:
```
$editor... |
13,020 | <p>What's the best way to use <code><?php the_post_thumbnail();?></code> in my loop <strong>BUT</strong> only show a thumbnail on the FIRST post? Meaning, only the first post in the loop will have it's image shown? </p>
<p><strong>Here is an example of a loop that shows the image for ALL posts:</strong></p>
<pr... | [
{
"answer_id": 13021,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>This code in your template will display the post thumbnail only for the first post:</p>\n\n<pre><code><?php \n !... | 2011/03/25 | [
"https://wordpress.stackexchange.com/questions/13020",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4194/"
] | What's the best way to use `<?php the_post_thumbnail();?>` in my loop **BUT** only show a thumbnail on the FIRST post? Meaning, only the first post in the loop will have it's image shown?
**Here is an example of a loop that shows the image for ALL posts:**
```
<!-- Start the Loop. -->
<?php if ( have_posts() ) : wh... | * add a variable before the loop (before the while), for example $first = true;
* add a check inside the loop for this variable
* after the use, change the flag
Code:
```
<!-- Start the Loop. -->
<?php $first = true; ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<!-- Display the Title as a... |
13,031 | <p>If I would export a WordPress database, posts and comments etc. are saved to an XML file.<br>
Would comment metadata be included in this XML file?</p>
<p>I.e. the table <code>wp_commentmeta</code>, mentioned here: <a href="http://codex.wordpress.org/Database_Description#Table:_wp_commentmeta" rel="nofollow">http://... | [
{
"answer_id": 13034,
"author": "Jan Fabry",
"author_id": 8,
"author_profile": "https://wordpress.stackexchange.com/users/8",
"pm_score": 1,
"selected": false,
"text": "<p>Looking at <a href=\"http://core.trac.wordpress.org/browser/tags/3.1/wp-admin/includes/export.php#L393\" rel=\"nofol... | 2011/03/25 | [
"https://wordpress.stackexchange.com/questions/13031",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4211/"
] | If I would export a WordPress database, posts and comments etc. are saved to an XML file.
Would comment metadata be included in this XML file?
I.e. the table `wp_commentmeta`, mentioned here: <http://codex.wordpress.org/Database_Description#Table:_wp_commentmeta>.
Here:
[The WordPress eXtended Rss (WXR) Export/... | My latest export from my blog (WP 3.3.1) now has the commentmeta in the XML. It's in this format:
```
<wp:comment>
<wp:comment_id>...</wp:comment_id>
...
<wp:comment_user_id>0</wp:comment_user_id>
**<wp:commentmeta>
<wp:meta_key>name_of_meta</wp:meta_key>
... |
13,032 | <p>I am trying to mimic the dashboard meta boxes UI in my WP plugin - the small metaboxes. I have already styled them and also the drag & drop feature works as I loaded the following script and style:</p>
<pre><code>wp_enqueue_style('dashboard');
wp_enqueue_script('dashboard');
</code></pre>
<p>However I also wou... | [
{
"answer_id": 13042,
"author": "t31os",
"author_id": 31073,
"author_profile": "https://wordpress.stackexchange.com/users/31073",
"pm_score": 3,
"selected": true,
"text": "<p>When ordering or closing metaboxes, those actions require nonces, add the following to your code and see if that ... | 2011/03/25 | [
"https://wordpress.stackexchange.com/questions/13032",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4212/"
] | I am trying to mimic the dashboard meta boxes UI in my WP plugin - the small metaboxes. I have already styled them and also the drag & drop feature works as I loaded the following script and style:
```
wp_enqueue_style('dashboard');
wp_enqueue_script('dashboard');
```
However I also would like to save my custom "pos... | When ordering or closing metaboxes, those actions require nonces, add the following to your code and see if that resolves the problem.
```
<?php wp_nonce_field('closedpostboxes', 'closedpostboxesnonce', false ); ?>
<?php wp_nonce_field('meta-box-order', 'meta-box-order-nonce', false ); ?>
```
**Additional:**
You sh... |
13,043 | <p>How can I use static flattr (button image hosted on my server) buttons on a wordpress 3.x installation using the flattr plug-in? Several people asked me to not load the flattr button from the flattr servers to prevent user tracking by flattr.</p>
<p>[Edit] As already mentioned, I was asked to change the way the fla... | [
{
"answer_id": 14253,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 2,
"selected": false,
"text": "<p>If I understand you correctly, you want to add the Flattr button to your posts but instead of using the Flattr Jav... | 2011/03/25 | [
"https://wordpress.stackexchange.com/questions/13043",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4215/"
] | How can I use static flattr (button image hosted on my server) buttons on a wordpress 3.x installation using the flattr plug-in? Several people asked me to not load the flattr button from the flattr servers to prevent user tracking by flattr.
[Edit] As already mentioned, I was asked to change the way the flattr plugin... | If I understand you correctly, you want to add the Flattr button to your posts but instead of using the Flattr JavaScript API you just want the button image to be saved on your server and go to your Flattr page when clicked.
I have embedded a working example into this answer and will provide the code and instructions ... |
13,044 | <p>For some reason a <code>title</code> attribute is not appended to <code>next_post_link</code> and <code>prev_post_link</code> calls in WordPress. How can I add one?</p>
| [
{
"answer_id": 13045,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 4,
"selected": true,
"text": "<h2>Update</h2>\n<p>As I deleted the Repo on GitHub, here's a new answer.</p>\n<pre><code>add_filter( 'previous_post_li... | 2011/03/25 | [
"https://wordpress.stackexchange.com/questions/13044",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4181/"
] | For some reason a `title` attribute is not appended to `next_post_link` and `prev_post_link` calls in WordPress. How can I add one? | Update
------
As I deleted the Repo on GitHub, here's a new answer.
```
add_filter( 'previous_post_link', 'wpse13044_adjacent_post_link_tooltip', 10, 2 );
add_filter( 'next_post_link', 'wpse13044_adjacent_post_link_tooltip', 10, 2 );
function wpse13044_adjacent_post_link_tooltip( $format, $link )
{
$previous = 'p... |
13,063 | <h2>People are often confused about how to get data from global objects/variables</h2>
<p><strong>Question:</strong> In which ways can you inspect global variables?</p>
<hr>
<p>This Q was written because it's needed pretty often over here at WA. I just wanted to have it as a fav to link over here (people often don't... | [
{
"answer_id": 13064,
"author": "scribu",
"author_id": 205,
"author_profile": "https://wordpress.stackexchange.com/users/205",
"pm_score": 4,
"selected": false,
"text": "<p>Or, if you're lazy, just install the <a href=\"http://wordpress.org/extend/plugins/debug-bar/\">Debug Bar</a> plugi... | 2011/03/25 | [
"https://wordpress.stackexchange.com/questions/13063",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/385/"
] | People are often confused about how to get data from global objects/variables
-----------------------------------------------------------------------------
**Question:** In which ways can you inspect global variables?
---
This Q was written because it's needed pretty often over here at WA. I just wanted to have it a... | ### How to inspect the data:
Use this to get an insight view of what you can use from the current request/wp\_query.
```
function inspect_wp_query()
{
echo '<pre>';
print_r($GLOBALS['wp_query']);
echo '</pre>';
}
// If you're looking at other variables you might need to use different hooks
// this can someti... |
13,068 | <p>I'm using this code to display my menu:</p>
<pre><code><?php
$menu_args = array(
'container' => '',
'menu_class' => '',
'menu_id' => 'main-menu',
);
wp_nav_menu($menu_args );
?>
</code></pre>
<p>It works totally fine, but I don't know how to get rid of a... | [
{
"answer_id": 13070,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 3,
"selected": true,
"text": "<p>you can use <code>nav_menu_css_class</code> filter hook to remove the classes:</p>\n\n<pre><code>add_filter('n... | 2011/03/25 | [
"https://wordpress.stackexchange.com/questions/13068",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1869/"
] | I'm using this code to display my menu:
```
<?php
$menu_args = array(
'container' => '',
'menu_class' => '',
'menu_id' => 'main-menu',
);
wp_nav_menu($menu_args );
?>
```
It works totally fine, but I don't know how to get rid of all these classes attached to every li in ... | you can use `nav_menu_css_class` filter hook to remove the classes:
```
add_filter('nav_menu_css_class' , 'my_nav_menu_remove_class' , 10 , 2);
function my_nav_menu_remove_class($classes, $item){
$my_class = array('menu-item-class');
return $my_class;
}
``` |
13,069 | <p>I recently updated a site and received the following error message: </p>
<blockquote>
<p>Fatal error: Call to undefined function wp() in /home/atlmp/public_html/wp-blog-header.php on line 14</p>
</blockquote>
<p>I checked the file and there doesn't seem to be any issues, so I can't figure out what's wrong?</p>
... | [
{
"answer_id": 13072,
"author": "marvinhagemeister",
"author_id": 3701,
"author_profile": "https://wordpress.stackexchange.com/users/3701",
"pm_score": 1,
"selected": false,
"text": "<p>To load WordPress it is enough to load \"wp-load.php\" like you did. I don't recognize the wp() functi... | 2011/03/25 | [
"https://wordpress.stackexchange.com/questions/13069",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101/"
] | I recently updated a site and received the following error message:
>
> Fatal error: Call to undefined function wp() in /home/atlmp/public\_html/wp-blog-header.php on line 14
>
>
>
I checked the file and there doesn't seem to be any issues, so I can't figure out what's wrong?
```
<?php
/**
* Loads the WordPres... | No need to go here and there. I was facing the same issue and here is the only solution [Fix wp-blog-header.php error](https://dailytechpakistan.com/how-to-fix-wp-blog-header-php-error-in-wordpress-website/) |
13,083 | <p>I am wanting to display the number order of a post. I tried using<code><?php the_ID(); ?></code> but this just displays the post ID and doesn't seem to do go in sequential order due to post revisions and whatnot.</p>
<p>Is there a way to to display if the post is #2 or #3 or #4 and so on?</p>
<p>Thanks!</p>... | [
{
"answer_id": 13095,
"author": "goldenapples",
"author_id": 290,
"author_profile": "https://wordpress.stackexchange.com/users/290",
"pm_score": 4,
"selected": true,
"text": "<p>Post ID's aren't meant to be sequential. To number your posts sequentially, you'd have to use a meta field. Th... | 2011/03/25 | [
"https://wordpress.stackexchange.com/questions/13083",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2289/"
] | I am wanting to display the number order of a post. I tried using`<?php the_ID(); ?>` but this just displays the post ID and doesn't seem to do go in sequential order due to post revisions and whatnot.
Is there a way to to display if the post is #2 or #3 or #4 and so on?
Thanks! | Post ID's aren't meant to be sequential. To number your posts sequentially, you'd have to use a meta field. There was discussion of this while back on this question:
[Change Permalinks Structure to a Sequential Number for Each Post?](https://wordpress.stackexchange.com/questions/1069/change-permalinks-structure-to-a-s... |
13,087 | <p>Here is what I'm doing:</p>
<pre><code>wp_logout();
var_dump(is_user_logged_in());
</code></pre>
<p>var_dump returns: </p>
<pre><code>bool(true)
</code></pre>
<p>Why is wp_logout() not logging me out?</p>
| [
{
"answer_id": 13093,
"author": "goldenapples",
"author_id": 290,
"author_profile": "https://wordpress.stackexchange.com/users/290",
"pm_score": 4,
"selected": true,
"text": "<p><strong>wp_logout()</strong> calls <a href=\"http://lab.yukei.net/wp-code/wp-includes/pluggable.php.source.htm... | 2011/03/25 | [
"https://wordpress.stackexchange.com/questions/13087",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4224/"
] | Here is what I'm doing:
```
wp_logout();
var_dump(is_user_logged_in());
```
var\_dump returns:
```
bool(true)
```
Why is wp\_logout() not logging me out? | **wp\_logout()** calls [clear\_auth\_cookie()](http://lab.yukei.net/wp-code/wp-includes/pluggable.php.source.html#l709;), which expires all authorization cookies set. It doesn't change the value of the global **$current\_user** variable. So technically you're still logged in for the duration of the script.
If you're u... |
13,090 | <p>I've got a routine (see below) that creates and inserts several widgets into the active theme's sidebars.</p>
<p>However, I need more control over either the order/index the are assigned (ie, one of my widgets need to be at the top of any other widgets in the sidebar) OR, I need to be able to specify a custom css n... | [
{
"answer_id": 13093,
"author": "goldenapples",
"author_id": 290,
"author_profile": "https://wordpress.stackexchange.com/users/290",
"pm_score": 4,
"selected": true,
"text": "<p><strong>wp_logout()</strong> calls <a href=\"http://lab.yukei.net/wp-code/wp-includes/pluggable.php.source.htm... | 2011/03/25 | [
"https://wordpress.stackexchange.com/questions/13090",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/366/"
] | I've got a routine (see below) that creates and inserts several widgets into the active theme's sidebars.
However, I need more control over either the order/index the are assigned (ie, one of my widgets need to be at the top of any other widgets in the sidebar) OR, I need to be able to specify a custom css name for th... | **wp\_logout()** calls [clear\_auth\_cookie()](http://lab.yukei.net/wp-code/wp-includes/pluggable.php.source.html#l709;), which expires all authorization cookies set. It doesn't change the value of the global **$current\_user** variable. So technically you're still logged in for the duration of the script.
If you're u... |