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 |
|---|---|---|---|---|---|---|
11,356 | <p>Here's my very simple shortcode: </p>
<pre><code>function box_shortcode( $atts, $content = null ) {
extract( shortcode_atts( array(
'width' => 'auto',
'height' => 'auto',
), $atts ) );
return '<div class="boxy-box" style="width:'. $width .'; height:... | [
{
"answer_id": 11363,
"author": "keatch",
"author_id": 2727,
"author_profile": "https://wordpress.stackexchange.com/users/2727",
"pm_score": 3,
"selected": true,
"text": "<p>You can postpone the wp_autop filter. Wordpress has this filter enabled by default. And it is processing before th... | 2011/03/07 | [
"https://wordpress.stackexchange.com/questions/11356",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1869/"
] | Here's my very simple shortcode:
```
function box_shortcode( $atts, $content = null ) {
extract( shortcode_atts( array(
'width' => 'auto',
'height' => 'auto',
), $atts ) );
return '<div class="boxy-box" style="width:'. $width .'; height:'. $height .';" >'.do_shor... | You can postpone the wp\_autop filter. Wordpress has this filter enabled by default. And it is processing before the shortcode output.
```
remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 12);
```
Add this to your `functions.php` and check if the problem persist!
See a similar prob... |
11,367 | <p>This is a shortcode to add a question form in the <a href="http://wordpress.org/extend/plugins/question-and-answer-forum/" rel="nofollow">Question and Answer Forum plugin</a> for Wordpress:</p>
<pre><code>[question_form width=\'x\' bordercolor=\'x\' style=\'x\']question form title[/question_form]
</code></pre>
<p>... | [
{
"answer_id": 11372,
"author": "Dalton Rooney",
"author_id": 799,
"author_profile": "https://wordpress.stackexchange.com/users/799",
"pm_score": 3,
"selected": true,
"text": "<p>I think you're looking for the <code>do_shortcode()</code> function. It allows you to paste a shortcode direc... | 2011/03/07 | [
"https://wordpress.stackexchange.com/questions/11367",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/781/"
] | This is a shortcode to add a question form in the [Question and Answer Forum plugin](http://wordpress.org/extend/plugins/question-and-answer-forum/) for Wordpress:
```
[question_form width=\'x\' bordercolor=\'x\' style=\'x\']question form title[/question_form]
```
This short code calls this:
```
//allow short codes... | I think you're looking for the `do_shortcode()` function. It allows you to paste a shortcode directly into a template file.
<http://codex.wordpress.org/Function_Reference/do_shortcode> |
11,398 | <p>I'm getting a Javascript error on the wp-admin/post.php page
which prevents me from adding tags/editing the post's link.. pretty much everything with JS... anyway, the error is:</p>
<pre><code>> Error: d.delegate is not a function
> Source File:
> http://www.mysite.com/wp-admin/load-scripts.php?c=1&loa... | [
{
"answer_id": 12011,
"author": "schellack",
"author_id": 75,
"author_profile": "https://wordpress.stackexchange.com/users/75",
"pm_score": 0,
"selected": false,
"text": "<p>If you've verified that the error still occurs after disabling all plugins and switching back to the default/inclu... | 2011/03/07 | [
"https://wordpress.stackexchange.com/questions/11398",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3642/"
] | I'm getting a Javascript error on the wp-admin/post.php page
which prevents me from adding tags/editing the post's link.. pretty much everything with JS... anyway, the error is:
```
> Error: d.delegate is not a function
> Source File:
> http://www.mysite.com/wp-admin/load-scripts.php?c=1&load=hoverIntent,common,jquery... | I'd suggest disabling script concatenation and/or compression to see if that helps. You can do this by adding the following to the `wp-config.php` file:
```
define( 'CONCATENATE_SCRIPTS', false );
define( 'COMPRESS_SCRIPTS', false );
```
And maybe even script debugging to..
```
define( 'SCRIPT_DEBUG', true );
```
... |
11,403 | <p>I am trying to get an array of site users sorted by a custom meta value (an int).</p>
<p>I can query the users just fine and get them back to use in a foreach. I currently have the query results come back sorted already by display_name from the users table. I want it to sort by the custom usermeta value.</p>
<p>An... | [
{
"answer_id": 11407,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 1,
"selected": false,
"text": "<p>try :</p>\n\n<pre><code>global $wpdb;\n$gather_users = $wpdb->get_col(\"SELECT user_id FROM $wpdb->user... | 2011/03/07 | [
"https://wordpress.stackexchange.com/questions/11403",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3776/"
] | I am trying to get an array of site users sorted by a custom meta value (an int).
I can query the users just fine and get them back to use in a foreach. I currently have the query results come back sorted already by display\_name from the users table. I want it to sort by the custom usermeta value.
Any ideas on how t... | You won't get a proper sort on the `meta_value` column because the values stored there aren't treated as integer values, but you can use a method similar to how it was done it WordPress back when we were using `meta_value_num` to do sorting, which basically involved adding a number onto the front of the data.
```
func... |
11,415 | <p>I have a custom query and I am filtering out events by custom field: event-month. I simple filter our the events that dont have a month_number = to date("n");</p>
<p>Its a pretty great little query, but I need to orderby another custom field, event_date.</p>
<p>Do I need a custom function or something to get this... | [
{
"answer_id": 11438,
"author": "Marcin",
"author_id": 3768,
"author_profile": "https://wordpress.stackexchange.com/users/3768",
"pm_score": -1,
"selected": false,
"text": "<p>Remove 'meta_key' from params. It doesn't work in WP 3.1</p>\n"
},
{
"answer_id": 11454,
"author": "... | 2011/03/07 | [
"https://wordpress.stackexchange.com/questions/11415",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2755/"
] | I have a custom query and I am filtering out events by custom field: event-month. I simple filter our the events that dont have a month\_number = to date("n");
Its a pretty great little query, but I need to orderby another custom field, event\_date.
Do I need a custom function or something to get this done. I simply ... | Despite `meta_key` being deprecated, it is still required to get the orderby to work correctly.
First and foremost though, there's an error with your code, and that's in using `order_by` and not `orderby` (there's no underscore in the orderby arg).
Give this a shot and see how it works out for you.
```
$event_query ... |
11,416 | <p>I'm trying to exclude a category because I have a post that i have in multiple post. How do I like for example I have a post in the categories lastest news and pictures but I want to exclude latest news and show only the pictures name. I tried using $category = get_the_category(); echo $category[0]->cat_name; but t... | [
{
"answer_id": 11424,
"author": "Tom",
"author_id": 3482,
"author_profile": "https://wordpress.stackexchange.com/users/3482",
"pm_score": 1,
"selected": false,
"text": "<pre><code>$recentPosts = new WP_Query(); $recentPosts->query('cat=-3'); //-3 makes sure it shows all categories exc... | 2011/03/07 | [
"https://wordpress.stackexchange.com/questions/11416",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2635/"
] | I'm trying to exclude a category because I have a post that i have in multiple post. How do I like for example I have a post in the categories lastest news and pictures but I want to exclude latest news and show only the pictures name. I tried using $category = get\_the\_category(); echo $category[0]->cat\_name; but th... | actually I fingered it out this code worked.
```
<?php
//edit below for categories you want excluded
$exclude = array("Latest News", "Uncategorized");
//how do you want the list separated? just a space is okay
$separator = " | ";
//don't edit below here!
$new_the_category = '';
foreach((get_the_category()) as $categor... |
11,426 | <p>How can I get the slug of a page or post?</p>
| [
{
"answer_id": 11428,
"author": "Pippin",
"author_id": 2418,
"author_profile": "https://wordpress.stackexchange.com/users/2418",
"pm_score": 6,
"selected": true,
"text": "<p>Inside of your loop you can do:</p>\n\n<pre><code>\nglobal $post;\n\necho $post->post_name;\n\n</code></pre>\n"
... | 2011/03/08 | [
"https://wordpress.stackexchange.com/questions/11426",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3788/"
] | How can I get the slug of a page or post? | Inside of your loop you can do:
```
global $post;
echo $post->post_name;
``` |
11,427 | <p>How do I 301 redirect private pages, rather than 404 them? If a post is private, WordPress filters it out in the SQL query, so there are no $post variables to work with.</p>
<p>I'd like for this code to work, but doesn't:</p>
<pre><code>add_action('wp','redirect_stuffs', 0);
function redirect_stuffs(){
global $pos... | [
{
"answer_id": 11440,
"author": "fencepost",
"author_id": 458,
"author_profile": "https://wordpress.stackexchange.com/users/458",
"pm_score": 2,
"selected": false,
"text": "<p>It seems to me that you shouldn't return either 404 or 301 - you should return either 401 (Unauthorized / authen... | 2011/03/08 | [
"https://wordpress.stackexchange.com/questions/11427",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10/"
] | How do I 301 redirect private pages, rather than 404 them? If a post is private, WordPress filters it out in the SQL query, so there are no $post variables to work with.
I'd like for this code to work, but doesn't:
```
add_action('wp','redirect_stuffs', 0);
function redirect_stuffs(){
global $post;
if ( $post->po... | Sorry guys, I found my answer:
```
add_action('wp','redirect_stuffs', 0);
function redirect_stuffs(){
global $wpdb;
if ($wpdb->last_result[0]->post_status == "private" && !is_admin() ):
wp_redirect( home_url(), 301 );
exit();
endif;
}
```
Posts/Pages are removed from the sitemaps, but the pa... |
11,444 | <p>First of all, sorry if I'm making a mistake. I already <a href="https://serverfault.com/questions/244163/my-wordpress-site-always-displays-a-cached-version-of-its-homepage">asked this on the ServerFault forum</a>, but got no answers at the moment and I thought it would be a good idea to ask the question here, consid... | [
{
"answer_id": 14035,
"author": "laras126",
"author_id": 3040,
"author_profile": "https://wordpress.stackexchange.com/users/3040",
"pm_score": 1,
"selected": false,
"text": "<p>I had an issue like this and it was the WP Super Cache plugin. Try disabling it and if that works, check around... | 2011/03/08 | [
"https://wordpress.stackexchange.com/questions/11444",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3795/"
] | First of all, sorry if I'm making a mistake. I already [asked this on the ServerFault forum](https://serverfault.com/questions/244163/my-wordpress-site-always-displays-a-cached-version-of-its-homepage), but got no answers at the moment and I thought it would be a good idea to ask the question here, considering that it ... | Sounds like your expires headers are set to far in the future. ~~The following rules can be added to your .htaccess~~ Expires rules can be added to your Nginx server file to shorten the expires time down to 180 seconds.
```
location ~* \/[^\/]+\/(feed|\.xml|.html|.HTML)\/? {
expires 180;
}
```
I wo... |
11,451 | <p>Seem to be having a few issues with this project lately so sorry for spamming questions! I needed to give the category edit page in the admin a few additional fields to allow my client to manage them better. </p>
<p>The extra fields I added are 'Category Features' and 'Category Applications' and the following code ... | [
{
"answer_id": 14035,
"author": "laras126",
"author_id": 3040,
"author_profile": "https://wordpress.stackexchange.com/users/3040",
"pm_score": 1,
"selected": false,
"text": "<p>I had an issue like this and it was the WP Super Cache plugin. Try disabling it and if that works, check around... | 2011/03/08 | [
"https://wordpress.stackexchange.com/questions/11451",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/912/"
] | Seem to be having a few issues with this project lately so sorry for spamming questions! I needed to give the category edit page in the admin a few additional fields to allow my client to manage them better.
The extra fields I added are 'Category Features' and 'Category Applications' and the following code seems to b... | Sounds like your expires headers are set to far in the future. ~~The following rules can be added to your .htaccess~~ Expires rules can be added to your Nginx server file to shorten the expires time down to 180 seconds.
```
location ~* \/[^\/]+\/(feed|\.xml|.html|.HTML)\/? {
expires 180;
}
```
I wo... |
11,453 | <p>I have been working for many days on this. I want to assigned category to author. I have googled, found some tips and plugins but doesn't work with Wordpress 3.1. I just come up with my own idea. </p>
<p>I as admin will create a category for an author than define or put category slug name in their respective profil... | [
{
"answer_id": 11466,
"author": "t31os",
"author_id": 31073,
"author_profile": "https://wordpress.stackexchange.com/users/31073",
"pm_score": 2,
"selected": false,
"text": "<p>You seem to be mixing up <code>wp_list_categories</code> arguments with <code>wp_dropdown_categories</code>, so ... | 2011/03/08 | [
"https://wordpress.stackexchange.com/questions/11453",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3615/"
] | I have been working for many days on this. I want to assigned category to author. I have googled, found some tips and plugins but doesn't work with Wordpress 3.1. I just come up with my own idea.
I as admin will create a category for an author than define or put category slug name in their respective profile meta fie... | You seem to be mixing up `wp_list_categories` arguments with `wp_dropdown_categories`, so i've removed them from the code that follows, i've also assumed the include argument is suppose to refer to the currently selected item.
For ref:
* [wp\_dropdown\_categories](http://codex.wordpress.org/Function_Reference/wp_dro... |
11,459 | <p>i'd like to list my 10 most recent posts but from certain categories only -
anyone can tell me how to do this?</p>
<p>thanks</p>
| [
{
"answer_id": 11463,
"author": "anu",
"author_id": 490,
"author_profile": "https://wordpress.stackexchange.com/users/490",
"pm_score": 0,
"selected": false,
"text": "<p>Have a look at the category query parameters here:</p>\n\n<p><a href=\"http://codex.wordpress.org/Function_Reference/W... | 2011/03/08 | [
"https://wordpress.stackexchange.com/questions/11459",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3030/"
] | i'd like to list my 10 most recent posts but from certain categories only -
anyone can tell me how to do this?
thanks | simply add this above your loop
```
$args = array(
'posts_per_page' => 10,
'category__in' => array( 2, 6 ), //change and add the category ids here
'orderby' => 'date',
'order' => 'ASC')
query_posts($args);
```
and you can read more about query\_posts Parameters <http://codex.wordpress.org/Function_Re... |
11,467 | <p>I'm having problems setting up a single WordPress template page to display post data outside of the Loop. The page has a left sidebar in which I want to display post meta data, tags and navigation links to previous and next posts, followed by a main column with the post title and content:</p>
<pre><code><html&g... | [
{
"answer_id": 11463,
"author": "anu",
"author_id": 490,
"author_profile": "https://wordpress.stackexchange.com/users/490",
"pm_score": 0,
"selected": false,
"text": "<p>Have a look at the category query parameters here:</p>\n\n<p><a href=\"http://codex.wordpress.org/Function_Reference/W... | 2011/03/08 | [
"https://wordpress.stackexchange.com/questions/11467",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3796/"
] | I'm having problems setting up a single WordPress template page to display post data outside of the Loop. The page has a left sidebar in which I want to display post meta data, tags and navigation links to previous and next posts, followed by a main column with the post title and content:
```
<html>
<head>
<title>... | simply add this above your loop
```
$args = array(
'posts_per_page' => 10,
'category__in' => array( 2, 6 ), //change and add the category ids here
'orderby' => 'date',
'order' => 'ASC')
query_posts($args);
```
and you can read more about query\_posts Parameters <http://codex.wordpress.org/Function_Re... |
11,477 | <p>I am working with the <a href="http://www.qianqin.de/qtranslate/" rel="nofollow">qTranslate plugin</a> to create a multi-lingual website. The plugin does a great job of translation except for on the <code>next_posts_link</code> & <code>previous_posts_link</code> template tags. </p>
<p>When a user has selected a... | [
{
"answer_id": 11471,
"author": "t31os",
"author_id": 31073,
"author_profile": "https://wordpress.stackexchange.com/users/31073",
"pm_score": 3,
"selected": true,
"text": "<p>Do you have the excerpt field enabled in screen options?</p>\n\n<p><img src=\"https://i.stack.imgur.com/MSvpi.png... | 2011/03/08 | [
"https://wordpress.stackexchange.com/questions/11477",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3310/"
] | I am working with the [qTranslate plugin](http://www.qianqin.de/qtranslate/) to create a multi-lingual website. The plugin does a great job of translation except for on the `next_posts_link` & `previous_posts_link` template tags.
When a user has selected a different language the URL should change from:
<http://mysit... | Do you have the excerpt field enabled in screen options?

Screen options is in the top right-hand corner the screen, next to the help button (under the logout link). |
11,501 | <p>So I have been building a child theme for a site. Wanted to add post formats to a twentyten child theme. Now, the goal of my child theme is to copy over the absolute least amount of code/templates from the parent as possible. </p>
<p>I originally figured if I added additional post formats to a twentyten child th... | [
{
"answer_id": 11505,
"author": "Dougal Campbell",
"author_id": 65,
"author_profile": "https://wordpress.stackexchange.com/users/65",
"pm_score": 3,
"selected": true,
"text": "<p>Try bumping the priority of your hook, like so:</p>\n\n<pre><code>add_action( 'after_setup_theme', 'voodoochi... | 2011/03/08 | [
"https://wordpress.stackexchange.com/questions/11501",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3429/"
] | So I have been building a child theme for a site. Wanted to add post formats to a twentyten child theme. Now, the goal of my child theme is to copy over the absolute least amount of code/templates from the parent as possible.
I originally figured if I added additional post formats to a twentyten child theme, using a ... | Try bumping the priority of your hook, like so:
```
add_action( 'after_setup_theme', 'voodoochild_setup', 11 );
```
This will ensure that it *runs* after the TwentyTen formats setup, so that it gets the last laugh. That's how I do it on WordPreh.com. |
11,510 | <p>I'm using the_post_thumbnail(); (aka featured image) to show a news source logo. If I use that image, I'd like to output the name of the news source. For example:</p>
<p>if the_post_thumbnail is "new-york-times.jpg"
echo "New York Times"
elseif the_post_thumbnail is "cbs-news.jpg"
echo "CBS News"
etc...</p>
<p>An... | [
{
"answer_id": 11512,
"author": "Manzabar",
"author_id": 199,
"author_profile": "https://wordpress.stackexchange.com/users/199",
"pm_score": 0,
"selected": false,
"text": "<p>From a quick look at the Codex and some of the <a href=\"http://core.trac.wordpress.org/browser/tags/3.1/wp-inclu... | 2011/03/08 | [
"https://wordpress.stackexchange.com/questions/11510",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3711/"
] | I'm using the\_post\_thumbnail(); (aka featured image) to show a news source logo. If I use that image, I'd like to output the name of the news source. For example:
if the\_post\_thumbnail is "new-york-times.jpg"
echo "New York Times"
elseif the\_post\_thumbnail is "cbs-news.jpg"
echo "CBS News"
etc...
Any help writ... | If You need title from media use something like this:
```
<?php
$thumb = get_post(get_post_thumbnail_id());
echo $thumb->post_title;
``` |
11,525 | <p>I have a problem. My database server isn't working right. On a wiki, it gives an error, and on my wordpress site, the pages don't show up. I am wondering if WordPress caches the DB data in any way, and if so, how do I clear it. I am hoping that will either totally break it or clear it. I am able to disable plugins a... | [
{
"answer_id": 11512,
"author": "Manzabar",
"author_id": 199,
"author_profile": "https://wordpress.stackexchange.com/users/199",
"pm_score": 0,
"selected": false,
"text": "<p>From a quick look at the Codex and some of the <a href=\"http://core.trac.wordpress.org/browser/tags/3.1/wp-inclu... | 2011/03/08 | [
"https://wordpress.stackexchange.com/questions/11525",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/172/"
] | I have a problem. My database server isn't working right. On a wiki, it gives an error, and on my wordpress site, the pages don't show up. I am wondering if WordPress caches the DB data in any way, and if so, how do I clear it. I am hoping that will either totally break it or clear it. I am able to disable plugins and ... | If You need title from media use something like this:
```
<?php
$thumb = get_post(get_post_thumbnail_id());
echo $thumb->post_title;
``` |
11,531 | <p>It seems like stupid question. But, I can't figure it out :(.</p>
<p>I need to display button at home that goes to custom post_type's archive URL (archive-{post_type}.php). How do I do that?</p>
| [
{
"answer_id": 11537,
"author": "MikeSchinkel",
"author_id": 89,
"author_profile": "https://wordpress.stackexchange.com/users/89",
"pm_score": 6,
"selected": true,
"text": "<p>Hi <strong>@Silent:</strong></p>\n\n<p>Turns out there is a function in WordPress 3.1 that does exactly what you... | 2011/03/08 | [
"https://wordpress.stackexchange.com/questions/11531",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127/"
] | It seems like stupid question. But, I can't figure it out :(.
I need to display button at home that goes to custom post\_type's archive URL (archive-{post\_type}.php). How do I do that? | Hi **@Silent:**
Turns out there is a function in WordPress 3.1 that does exactly what you want and it is named `get_post_type_archive_link()`; here's how you'd call it *(assuming a custom post type named `'product'`):*
```
<a href="<?php echo get_post_type_archive_link('product'); ?>">Products</a>
```
Below is my p... |
11,532 | <p>I pretty much got my answer in my last question, but not quite. I was supposed to add one last code to my source and it would have worked but the person helping hasn't replied now and I don't know what to do :S</p>
<p><a href="https://wordpress.stackexchange.com/questions/11288/form-to-add-posts-to-custom-post-type... | [
{
"answer_id": 11537,
"author": "MikeSchinkel",
"author_id": 89,
"author_profile": "https://wordpress.stackexchange.com/users/89",
"pm_score": 6,
"selected": true,
"text": "<p>Hi <strong>@Silent:</strong></p>\n\n<p>Turns out there is a function in WordPress 3.1 that does exactly what you... | 2011/03/08 | [
"https://wordpress.stackexchange.com/questions/11532",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2415/"
] | I pretty much got my answer in my last question, but not quite. I was supposed to add one last code to my source and it would have worked but the person helping hasn't replied now and I don't know what to do :S
[Form to Add Posts to Custom Post Type](https://wordpress.stackexchange.com/questions/11288/form-to-add-post... | Hi **@Silent:**
Turns out there is a function in WordPress 3.1 that does exactly what you want and it is named `get_post_type_archive_link()`; here's how you'd call it *(assuming a custom post type named `'product'`):*
```
<a href="<?php echo get_post_type_archive_link('product'); ?>">Products</a>
```
Below is my p... |
11,544 | <p>I followed this method of <a href="http://johnford.is/programmatically-pull-attachments-from-wordpress-posts//" rel="nofollow">getting images from the media library</a>. </p>
<pre><code>// get the first image attached to the current post
function aldenta_get_post_image($size = 'thumbnail') {
global $post;
... | [
{
"answer_id": 50810,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>Use the <code>'offset'</code> parameter like in <a href=\"http://codex.wordpress.org/Template_Tags/get_posts\" rel=\"n... | 2011/03/09 | [
"https://wordpress.stackexchange.com/questions/11544",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3788/"
] | I followed this method of [getting images from the media library](http://johnford.is/programmatically-pull-attachments-from-wordpress-posts//).
```
// get the first image attached to the current post
function aldenta_get_post_image($size = 'thumbnail') {
global $post;
$photos = get_children( array('post_pare... | Use the `'offset'` parameter like in [`get_posts()`](http://codex.wordpress.org/Template_Tags/get_posts). You can take the number of the page you're on as value. |
11,547 | <p>I have added an image size with </p>
<pre><code>add_image_size('gallery-thumb', 48, 48);
</code></pre>
<p>Why when I do </p>
<pre><code>array_slice(wp_get_attachment_image_src($firstimg->ID, 'gallery-thumb'))
</code></pre>
<p>I get the link to the full sized image?</p>
<p><strong>UPDATE</strong></p>
<p>Some... | [
{
"answer_id": 11554,
"author": "scribu",
"author_id": 205,
"author_profile": "https://wordpress.stackexchange.com/users/205",
"pm_score": 4,
"selected": true,
"text": "<p>Does the 48x48 thumbnail file exist? If not, you can use a plugin like Regenerate Thumbnails.</p>\n"
},
{
"a... | 2011/03/09 | [
"https://wordpress.stackexchange.com/questions/11547",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3788/"
] | I have added an image size with
```
add_image_size('gallery-thumb', 48, 48);
```
Why when I do
```
array_slice(wp_get_attachment_image_src($firstimg->ID, 'gallery-thumb'))
```
I get the link to the full sized image?
**UPDATE**
Somehow it appears that even when I do
```
wp_get_attachment_image_src($photo->ID... | Does the 48x48 thumbnail file exist? If not, you can use a plugin like Regenerate Thumbnails. |
11,551 | <p>I'm creating a custom post type by adding the add_action( 'init', 'create_radiotalks' ); text to the functions.php page:</p>
<pre><code>add_action( 'init', 'create_radiotalks' );
function create_radiotalks() {
register_post_type( 'radiotalks',
array(
'labels' => array(
'name'... | [
{
"answer_id": 11553,
"author": "scribu",
"author_id": 205,
"author_profile": "https://wordpress.stackexchange.com/users/205",
"pm_score": 2,
"selected": false,
"text": "<p>By adding the 'taxonomies' argument:</p>\n\n<pre><code>'public' => true,\n'taxonomies' => array( 'category', ... | 2011/03/09 | [
"https://wordpress.stackexchange.com/questions/11551",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2815/"
] | I'm creating a custom post type by adding the add\_action( 'init', 'create\_radiotalks' ); text to the functions.php page:
```
add_action( 'init', 'create_radiotalks' );
function create_radiotalks() {
register_post_type( 'radiotalks',
array(
'labels' => array(
'name' => __( 'Radio ... | By adding the 'taxonomies' argument:
```
'public' => true,
'taxonomies' => array( 'category', 'post_tag' ),
``` |
11,561 | <p>I need some help with restyling my alternate widget areas. I've created some new widget areas, and placed one into the main content of my <strong>index.php</strong>. This works just fine, however i want to style it differently.</p>
<ul>
<li><strong>WordPress:</strong> 3.0.4</li>
<li><strong>Theme:</strong> Twenty T... | [
{
"answer_id": 11553,
"author": "scribu",
"author_id": 205,
"author_profile": "https://wordpress.stackexchange.com/users/205",
"pm_score": 2,
"selected": false,
"text": "<p>By adding the 'taxonomies' argument:</p>\n\n<pre><code>'public' => true,\n'taxonomies' => array( 'category', ... | 2011/03/09 | [
"https://wordpress.stackexchange.com/questions/11561",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3010/"
] | I need some help with restyling my alternate widget areas. I've created some new widget areas, and placed one into the main content of my **index.php**. This works just fine, however i want to style it differently.
* **WordPress:** 3.0.4
* **Theme:** Twenty Ten Child (twentyten-child)
* **Server:** Local/MAMP
I've tr... | By adding the 'taxonomies' argument:
```
'public' => true,
'taxonomies' => array( 'category', 'post_tag' ),
``` |
11,563 | <p>I am trying to upload java files to my WordPress blog but it does not let me upload any files with <code>.java</code> extension.</p>
<p>I get this error:</p>
<blockquote>
<p>".java” has failed to upload due to an error</p>
<p>File type does not meet security guidelines. Try another.</p>
</blockquote>
<p>How do ... | [
{
"answer_id": 11568,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>I found this nice function that does the trick</p>\n\n<pre><code><?php\nfunction addUploadMimes($mimes) {\... | 2011/03/09 | [
"https://wordpress.stackexchange.com/questions/11563",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1293/"
] | I am trying to upload java files to my WordPress blog but it does not let me upload any files with `.java` extension.
I get this error:
>
> ".java” has failed to upload due to an error
>
>
> File type does not meet security guidelines. Try another.
>
>
>
How do I add `.java` extension so that it allows me to u... | Use filter '[upload\_mimes](http://codex.wordpress.org/Plugin_API/Filter_Reference/upload_mimes)'.
```
<?php
add_filter('upload_mimes','add_java_files');
function add_java_files($mimes)
{
// Add file extension 'extension' with mime type 'mime/type'
$mimes['java'] = 'text/x-java-source';
return $mimes;... |
11,566 | <p>How do I test whether there are any images attached to a post? </p>
<p>I'm using the gallery shortcode, but I want to put it in a conditional so the surrounding styling isn't displayed if the gallery is empty.</p>
| [
{
"answer_id": 11567,
"author": "Roman",
"author_id": 3817,
"author_profile": "https://wordpress.stackexchange.com/users/3817",
"pm_score": 2,
"selected": true,
"text": "<p>You can check if an attachment for the given post exists with the get_posts function. This will create a new sql qu... | 2011/03/09 | [
"https://wordpress.stackexchange.com/questions/11566",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1118/"
] | How do I test whether there are any images attached to a post?
I'm using the gallery shortcode, but I want to put it in a conditional so the surrounding styling isn't displayed if the gallery is empty. | You can check if an attachment for the given post exists with the get\_posts function. This will create a new sql query - so there could be a performance issue.
```
// Util.class.php
class Util {
public static function has_attachments() {
$args = array(
'post_type' => 'attachment',
... |
11,578 | <p>Does anyone know if it's possible to change wp_link_pages, so that the title of each nextpage quicktag is used rather than numbers? I can't seem to find anything on this.</p>
<p>This is an example of how I'm using the quicktag: </p>
<p><code><!--nextpage--><!--pagetitle:Overview--></code></p>
<p>Using... | [
{
"answer_id": 11588,
"author": "t31os",
"author_id": 31073,
"author_profile": "https://wordpress.stackexchange.com/users/31073",
"pm_score": 3,
"selected": true,
"text": "<p>This is going to be kind of hackish, but it is possible using an alternate function.</p>\n\n<p>Add this to your t... | 2011/03/09 | [
"https://wordpress.stackexchange.com/questions/11578",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3362/"
] | Does anyone know if it's possible to change wp\_link\_pages, so that the title of each nextpage quicktag is used rather than numbers? I can't seem to find anything on this.
This is an example of how I'm using the quicktag:
`<!--nextpage--><!--pagetitle:Overview-->`
Using `wp_link_pages();` it displays/outputs; `Pag... | This is going to be kind of hackish, but it is possible using an alternate function.
Add this to your theme's **functions.php** file.
```
function wp_link_pages_titled($args = '') {
$defaults = array(
'before' => '<p>' . __('Pages:'),
'after' => '</p>',
'link_before' => '',
'link... |
11,582 | <p>What I want to achieve is an online listing catalog with a URL like this:</p>
<pre><code>www.example.com/drawing-tools/brand/type/material/color/
</code></pre>
<p>In this example, I have a custom post type named "drawing-tools" with 4 custom taxonomies for it: "brand", "type", "material", "color" </p>
<p>When a u... | [
{
"answer_id": 11598,
"author": "Taylor Dewey",
"author_id": 3832,
"author_profile": "https://wordpress.stackexchange.com/users/3832",
"pm_score": 2,
"selected": false,
"text": "<p>I believe WP 3.1 introduced a fix for what you're describing... from the codex:</p>\n\n<ul>\n<li>Custom Con... | 2011/03/09 | [
"https://wordpress.stackexchange.com/questions/11582",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3821/"
] | What I want to achieve is an online listing catalog with a URL like this:
```
www.example.com/drawing-tools/brand/type/material/color/
```
In this example, I have a custom post type named "drawing-tools" with 4 custom taxonomies for it: "brand", "type", "material", "color"
When a user access a URL like:
```
www.e... | The solution is fairly simple and I don't know why it took me so long to find it on the Codex. You must make use of the `$wp_query` class.
So, in the template, before calling the loop, set a variable to hold the returned data:
```
$vars = $wp_query->query_vars;
```
And then, check if the required taxonomies are set... |
11,594 | <p>I got frustrated with the number of "Like" plugins available, so I went straight to Facebook for a direct implementation. </p>
<p>I want my like button to look like how how its displayed on Techcrunch (example: <a href="http://techcrunch.com/2011/03/09/report-paypals-express-checkout-helps-bump-sales-by-18-percent/... | [
{
"answer_id": 31004,
"author": "Jeremy Love",
"author_id": 2635,
"author_profile": "https://wordpress.stackexchange.com/users/2635",
"pm_score": 0,
"selected": false,
"text": "<p>The only way to I can think of to get it to display 0 likes is if it doesnt have any likes at all, other wis... | 2011/03/09 | [
"https://wordpress.stackexchange.com/questions/11594",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1766/"
] | I got frustrated with the number of "Like" plugins available, so I went straight to Facebook for a direct implementation.
I want my like button to look like how how its displayed on Techcrunch (example: <http://techcrunch.com/2011/03/09/report-paypals-express-checkout-helps-bump-sales-by-18-percent/>) - Notice the Fa... | Unfortunately I do not think there is a way to do this. I believe I also read somewhere that modifying the Like button is against Facebook's Terms of Service, so I would suggest not trying to go that route.
Ultimately, Facebook decides what gets shown. You could set a background image under the like button with a litt... |
11,599 | <p>I was wondering if there is a way to edit the default field labels on a custom post, for example instead of the author field saying "author" have it say "keynote speaker" I found one solution listed below, but this obviously edits it across the entire backend.</p>
<pre><code>add_filter( 'gettext', 'change_author_to... | [
{
"answer_id": 11606,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 1,
"selected": false,
"text": "<p>I think your two filters are possible for parse strings and replace it.</p>\n\n<p>Hint: You can also see an exampl... | 2011/03/09 | [
"https://wordpress.stackexchange.com/questions/11599",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1388/"
] | I was wondering if there is a way to edit the default field labels on a custom post, for example instead of the author field saying "author" have it say "keynote speaker" I found one solution listed below, but this obviously edits it across the entire backend.
```
add_filter( 'gettext', 'change_author_to_keynote' );
a... | you can use:
```
add_filter('gettext','custom_author_lable');
function custom_author_lable( $input ) {
global $post_type;
if( is_admin() && 'your_post_type' == $post_type )
if ('Author' == $input || 'author' == $input)
return 'Keynote Speaker';
return $input;
}
```
just r... |
11,603 | <p>I am trying to use two loops on my page, one to get the current page's content and so on, and another to get all of the posts of a specific category.</p>
<p>When I do that, all of the tags for the current page disappears.</p>
<p>Here is my code,</p>
<p>Loop one:</p>
<pre><code><?php if (have_posts()) : ?>
... | [
{
"answer_id": 11604,
"author": "Odyss3us",
"author_id": 2632,
"author_profile": "https://wordpress.stackexchange.com/users/2632",
"pm_score": 2,
"selected": false,
"text": "<p>Sorry guys, stupid mistake, I forgot to reset the second loop using <code>wp_reset_query</code>, here is the wo... | 2011/03/09 | [
"https://wordpress.stackexchange.com/questions/11603",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2632/"
] | I am trying to use two loops on my page, one to get the current page's content and so on, and another to get all of the posts of a specific category.
When I do that, all of the tags for the current page disappears.
Here is my code,
Loop one:
```
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(... | Sorry guys, stupid mistake, I forgot to reset the second loop using `wp_reset_query`, here is the working code,
```
<?php query_posts(array('category_name' => 'test')); ?>
<?php if (have_posts()) : ?>
<?php while (have_posts()) : the_post(); ?>
<div><?php the_excerpt(); ?></div>
<?php endwhile; ?>
<?ph... |
11,611 | <p>Essentially what I'd like to do is have the same effect as the wp_list_authors tag, but instead of just listing the name or their post count, I want to be able to do a loop with the IDs. Ultimately I'd like have to a page with every author, with their name, description, avatar and link. I can figure out the specific... | [
{
"answer_id": 11614,
"author": "Manzabar",
"author_id": 199,
"author_profile": "https://wordpress.stackexchange.com/users/199",
"pm_score": 3,
"selected": true,
"text": "<p>Looks like you'll want to use <a href=\"http://codex.wordpress.org/Function_Reference/get_users\" rel=\"nofollow\"... | 2011/03/09 | [
"https://wordpress.stackexchange.com/questions/11611",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1388/"
] | Essentially what I'd like to do is have the same effect as the wp\_list\_authors tag, but instead of just listing the name or their post count, I want to be able to do a loop with the IDs. Ultimately I'd like have to a page with every author, with their name, description, avatar and link. I can figure out the specifics... | Looks like you'll want to use [get\_users](http://codex.wordpress.org/Function_Reference/get_users) and you might want to take a look at the source code behind [wp\_list\_authors](http://core.trac.wordpress.org/browser/tags/3.1/wp-includes/author-template.php#L271) to info on how to use it. |
11,615 | <p>Actually I want to include a file if the checkbox is checked </p>
<pre><code><?php
$checked = get_option('automatic') ? "checked='checked'" : "";
echo "<input type='checkbox' name='automatic' $checked />";
?>
if(get_option('automatic') == 'checked')) ( require_once 'myfile.php'; )
</code></pre>
<p>Thi... | [
{
"answer_id": 11617,
"author": "BigRedPimp",
"author_id": 3834,
"author_profile": "https://wordpress.stackexchange.com/users/3834",
"pm_score": 2,
"selected": false,
"text": "<pre><code><?php\necho \"<input type='checkbox' name='automatic' value='1' \".checked(1, get_option('autom... | 2011/03/09 | [
"https://wordpress.stackexchange.com/questions/11615",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3615/"
] | Actually I want to include a file if the checkbox is checked
```
<?php
$checked = get_option('automatic') ? "checked='checked'" : "";
echo "<input type='checkbox' name='automatic' $checked />";
?>
if(get_option('automatic') == 'checked')) ( require_once 'myfile.php'; )
```
This form is in a plugin option page | ```
<?php
echo "<input type='checkbox' name='automatic' value='1' ".checked(1, get_option('automatic'))." />";
if (get_option('automatic') === '1') { require_once 'myfile.php'; }
?>
``` |
11,619 | <p>I've taken this line from header.php of TwentyTen where its loading the custom menus...</p>
<pre><code><?php /* Our navigation menu.
If one isn't filled out, wp_nav_menu falls back to wp_page_menu.
The menu assiged to the primary position is the one used.
If none is assigned, the menu with the lowest ID is... | [
{
"answer_id": 11621,
"author": "Manzabar",
"author_id": 199,
"author_profile": "https://wordpress.stackexchange.com/users/199",
"pm_score": 2,
"selected": true,
"text": "<p>From looking at the <a href=\"http://codex.wordpress.org/Function_Reference/wp_nav_menu#Parameters\" rel=\"nofollo... | 2011/03/09 | [
"https://wordpress.stackexchange.com/questions/11619",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/366/"
] | I've taken this line from header.php of TwentyTen where its loading the custom menus...
```
<?php /* Our navigation menu.
If one isn't filled out, wp_nav_menu falls back to wp_page_menu.
The menu assiged to the primary position is the one used.
If none is assigned, the menu with the lowest ID is used. */ ?>
<?p... | From looking at the [Codex](http://codex.wordpress.org/Function_Reference/wp_nav_menu#Parameters), you should be able to just pass the fallback\_cb parameter as false to have wp\_nav\_menu return nothing. So something like:
```
<?php wp_nav_menu( array( 'container_class' => 'menu-header', 'theme_location' => 'primary'... |
11,625 | <p>I added a menu item to the Admin Bar that executes some Javascript to show debug information. The problem is that clicking this item also reloads the page. How can I prevent this?</p>
<p>I was trying to speed up my debug & dev stuff and wanted to add a class to my main wrapper div using jQuery. </p>
<h3>Step ... | [
{
"answer_id": 14293,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<h3>Solution:</h3>\n\n<p>Simply set <code>'href' => '#'</code> to link to a not defined anchor to avoid page reload... | 2011/03/10 | [
"https://wordpress.stackexchange.com/questions/11625",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/385/"
] | I added a menu item to the Admin Bar that executes some Javascript to show debug information. The problem is that clicking this item also reloads the page. How can I prevent this?
I was trying to speed up my debug & dev stuff and wanted to add a class to my main wrapper div using jQuery.
### Step 1:
Add styles to y... | If you `return false` in that Javascript function the click will not be propagated and the page will also not reload.
Even better, [you can specify a `onclick` attribute for a menu item](http://core.trac.wordpress.org/browser/tags/3.1.1/wp-includes/class-wp-admin-bar.php#L51). So you definition would become this:
```... |
11,628 | <p>I have another dumb question, but I can't get one thing :)</p>
<p>I've found this very good article on creating custom post types:</p>
<p><a href="http://thinkvitamin.com/code/create-your-first-wordpress-custom-post-type/" rel="nofollow">http://thinkvitamin.com/code/create-your-first-wordpress-custom-post-type/</a... | [
{
"answer_id": 11630,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<p>Take a look at how the rewrite $arg for your custom post type is. </p>\n\n<p>To get a better view of the output d... | 2011/03/10 | [
"https://wordpress.stackexchange.com/questions/11628",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1869/"
] | I have another dumb question, but I can't get one thing :)
I've found this very good article on creating custom post types:
<http://thinkvitamin.com/code/create-your-first-wordpress-custom-post-type/>
I'm not sure how Step 4 works.
This guys writes:
```
add_action("manage_posts_custom_column", "portfolio_custom_c... | The code from ThinkVitamin is right. I think the problem came from else where in your code.
Actually, the hook `manage_edit-${post_type}_columns` takes an argument `$columns` which is an array of all registered columns. To add a new column, just add a new element to this array, like this:
```
add_filter('manage_edit-... |
11,641 | <p>I read the wordpress codex and professional wordpress. It seems both use something like</p>
<pre><code>if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
</code></pre>
<p>to determine if the table exists. Is there any reason why <code>CREATE TABLE IF NOT EXISTS ( ... )</code> is not used? It ... | [
{
"answer_id": 11812,
"author": "edelwater",
"author_id": 576,
"author_profile": "https://wordpress.stackexchange.com/users/576",
"pm_score": 5,
"selected": true,
"text": "<p>If you use \"IF NOT EXISTS\" then the dbdelta script will not upgrade your database with delta's appeared after t... | 2011/03/10 | [
"https://wordpress.stackexchange.com/questions/11641",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3788/"
] | I read the wordpress codex and professional wordpress. It seems both use something like
```
if($wpdb->get_var("SHOW TABLES LIKE '$table_name'") != $table_name) {
```
to determine if the table exists. Is there any reason why `CREATE TABLE IF NOT EXISTS ( ... )` is not used? It will check and create the table in 1 que... | If you use "IF NOT EXISTS" then the dbdelta script will not upgrade your database with delta's appeared after the initial creation of the database.
(assuming you want to re-use the same sql script)
at least... that is what i think |
11,649 | <p>We're setting up a site to showcase a series of archival recordings. We have the custom post types sorted out thanks to all the help from this site (many, many thanks): </p>
<pre><code>add_action( 'init', 'create_radiotalks' );
function create_radiotalks() {
register_post_type( 'radiotalks',
array(
'la... | [
{
"answer_id": 11656,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": true,
"text": "<p>Add supports to your array like so</p>\n\n<pre><code>'supports' => array('title','editor','author','thumbna... | 2011/03/10 | [
"https://wordpress.stackexchange.com/questions/11649",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2815/"
] | We're setting up a site to showcase a series of archival recordings. We have the custom post types sorted out thanks to all the help from this site (many, many thanks):
```
add_action( 'init', 'create_radiotalks' );
function create_radiotalks() {
register_post_type( 'radiotalks',
array(
'labels' => array... | Add supports to your array like so
```
'supports' => array('title','editor','author','thumbnail','excerpt','comments')
```
As for the additional data per each recording if you need to filter or search by it the create a custom taxonomy if not then a custom fields would be just fine. |
11,651 | <p>I've noticed some bizarre behaviour in my WordPress installation. </p>
<p>For some photos, when I click "Edit Image", the full image is not displayed to me - just the area visible in the thumbnail. And yet, if you click "View Image", you can see the full image is actually there.</p>
<p><img src="https://i.stack.im... | [
{
"answer_id": 12626,
"author": "Michal Mau",
"author_id": 2110,
"author_profile": "https://wordpress.stackexchange.com/users/2110",
"pm_score": 2,
"selected": false,
"text": "<p>what you are describing here (cropped big size image in Edit Media screen) is a perfectly normal behavior whe... | 2011/03/10 | [
"https://wordpress.stackexchange.com/questions/11651",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1118/"
] | I've noticed some bizarre behaviour in my WordPress installation.
For some photos, when I click "Edit Image", the full image is not displayed to me - just the area visible in the thumbnail. And yet, if you click "View Image", you can see the full image is actually there.
 is a perfectly normal behavior when you use `Apply changes to: All image sizes` while cropping image and I believe the same thing could happen during upload when `$crop` param is set to `true` for all registered image sizes (similar to how [add\... |
11,652 | <p>I am using the Thesis theme with my WordPress multisite installation. I also changed the permalink settings from the Super Admin settings to remove <strong>/blog/</strong> from the path.</p>
<p>But now my menu links are broken. The permalink structure now is <strong>/%postname%/</strong> and my pages have the links... | [
{
"answer_id": 11971,
"author": "OleVik",
"author_id": 2983,
"author_profile": "https://wordpress.stackexchange.com/users/2983",
"pm_score": 2,
"selected": false,
"text": "<p>This seems like a broken .htaccess-file. I too have removed /blog/ as the permalink path, but it had/should have ... | 2011/03/10 | [
"https://wordpress.stackexchange.com/questions/11652",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1070/"
] | I am using the Thesis theme with my WordPress multisite installation. I also changed the permalink settings from the Super Admin settings to remove **/blog/** from the path.
But now my menu links are broken. The permalink structure now is **/%postname%/** and my pages have the links mydomain.com/about/, mydomain.com/c... | The solution posted [here](http://wordpress.org/support/topic/multisite-installed-on-aws-permalinks-not-working?replies=19) resolved the issue.
The links work as expected now even when I use custom permalink structures! |
11,662 | <p>Is there a way to fetch the URLs of <strong>ALL</strong> images in the media gallery?</p>
<p>I think this would be an easy way for a website to have a Pictures page that just pulls all of the images from the media gallery, granted it would only be necessary in certain scenarios.</p>
<p>I don't need instructions on... | [
{
"answer_id": 11828,
"author": "stffn",
"author_id": 1844,
"author_profile": "https://wordpress.stackexchange.com/users/1844",
"pm_score": 3,
"selected": false,
"text": "<pre><code><?php\n $attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'atta... | 2011/03/10 | [
"https://wordpress.stackexchange.com/questions/11662",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2415/"
] | Is there a way to fetch the URLs of **ALL** images in the media gallery?
I think this would be an easy way for a website to have a Pictures page that just pulls all of the images from the media gallery, granted it would only be necessary in certain scenarios.
I don't need instructions on how to create a Pictures page... | ```
$query_images_args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_status' => 'inherit',
'posts_per_page' => - 1,
);
$query_images = new WP_Query( $query_images_args );
$images = array();
foreach ( $query_images->posts as $image ) {
$images[] = wp_get_attachmen... |
11,664 | <p>It's an inconvenience to have to customize your theme just to use BuddyPress.</p>
<p>It'd be much nicer if it simply used the wordpress page system for example, to inject content into standard WP pages. This way no theme editing is necessary, just activate BP and go.</p>
<p>The idea would be that BuddyPress would ... | [
{
"answer_id": 11828,
"author": "stffn",
"author_id": 1844,
"author_profile": "https://wordpress.stackexchange.com/users/1844",
"pm_score": 3,
"selected": false,
"text": "<pre><code><?php\n $attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'atta... | 2011/03/10 | [
"https://wordpress.stackexchange.com/questions/11664",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1226/"
] | It's an inconvenience to have to customize your theme just to use BuddyPress.
It'd be much nicer if it simply used the wordpress page system for example, to inject content into standard WP pages. This way no theme editing is necessary, just activate BP and go.
The idea would be that BuddyPress would just work in Twen... | ```
$query_images_args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_status' => 'inherit',
'posts_per_page' => - 1,
);
$query_images = new WP_Query( $query_images_args );
$images = array();
foreach ( $query_images->posts as $image ) {
$images[] = wp_get_attachmen... |
11,667 | <p>On the site I am developing I have a few custom post types set up (Press Releases, Articles, Podcasts). I also have the Tag Cloud widget enabled in my sidebar.</p>
<p>I have tagged a post with 'Testtest', and I've also tagged a Press Release with 'Testtest'. The problem I have is when I click the 'Testtest' tag on ... | [
{
"answer_id": 11828,
"author": "stffn",
"author_id": 1844,
"author_profile": "https://wordpress.stackexchange.com/users/1844",
"pm_score": 3,
"selected": false,
"text": "<pre><code><?php\n $attachments = get_children( array('post_parent' => get_the_ID(), 'post_type' => 'atta... | 2011/03/10 | [
"https://wordpress.stackexchange.com/questions/11667",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3670/"
] | On the site I am developing I have a few custom post types set up (Press Releases, Articles, Podcasts). I also have the Tag Cloud widget enabled in my sidebar.
I have tagged a post with 'Testtest', and I've also tagged a Press Release with 'Testtest'. The problem I have is when I click the 'Testtest' tag on my tag clo... | ```
$query_images_args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'post_status' => 'inherit',
'posts_per_page' => - 1,
);
$query_images = new WP_Query( $query_images_args );
$images = array();
foreach ( $query_images->posts as $image ) {
$images[] = wp_get_attachmen... |
11,688 | <p>Is it possible to control the length of the content or excerpt for a specific query/loop?</p>
<p>I have come across the following code, but this changes the length for all excerpts, I want it focused on a specific custom query.</p>
<pre><code> add_filter('excerpt_length', 'my_excerpt_length');
function my_excer... | [
{
"answer_id": 11693,
"author": "Rev. Voodoo",
"author_id": 3429,
"author_profile": "https://wordpress.stackexchange.com/users/3429",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://wpengineer.com/1909/manage-multiple-excerpt-lengths/\" rel=\"nofollow\">http://wpengineer.c... | 2011/03/10 | [
"https://wordpress.stackexchange.com/questions/11688",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/784/"
] | Is it possible to control the length of the content or excerpt for a specific query/loop?
I have come across the following code, but this changes the length for all excerpts, I want it focused on a specific custom query.
```
add_filter('excerpt_length', 'my_excerpt_length');
function my_excerpt_length($length) {
... | Try this: <http://pippinspages.com/tutorials/better-wordpress-post-excerpt-revamped/> |
11,696 | <p>I am trying to use jQuery to display the comment-section of my Wordpress-pages, but without requiring that jQuery be present on all pages that allows comments. Basically, I need the following:</p>
<ol>
<li>A generic javascript implementation of the 'in view' jQuery-plugin (http://remysharp.com/2009/01/26/element-in... | [
{
"answer_id": 11699,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<h3>1. Register jQuery and the plugin within your head</h3>\n\n<pre><code>wp_register_script( 'jquery' );\nwp_register... | 2011/03/10 | [
"https://wordpress.stackexchange.com/questions/11696",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2983/"
] | I am trying to use jQuery to display the comment-section of my Wordpress-pages, but without requiring that jQuery be present on all pages that allows comments. Basically, I need the following:
1. A generic javascript implementation of the 'in view' jQuery-plugin (http://remysharp.com/2009/01/26/element-in-view-event-p... | After a LOT of googling, trying to find a solution at the same time as keeping up with the earthquake-situation in Japan, I found a way:
Two scripts for Wordpress
=========================
Using **wp\_enqueue\_script**, I added a DeferJS (<https://github.com/BorisMoore/DeferJS>), which allows scripts to be loaded onE... |
11,697 | <p>I have two custom post types: event and contact:</p>
<p><a href="http://acicafoc.josoroma.com/contactenos" rel="nofollow">http://acicafoc.josoroma.com/contactenos</a></p>
<p><a href="http://acicafoc.josoroma.com/eventos" rel="nofollow">http://acicafoc.josoroma.com/eventos</a></p>
<p>Both of them uses a custom tax... | [
{
"answer_id": 11701,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>Have you already look into what comes back from <code>$term-taxonomy</code>?</p>\n\n<p>Try this right before your q... | 2011/03/10 | [
"https://wordpress.stackexchange.com/questions/11697",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2011/"
] | I have two custom post types: event and contact:
<http://acicafoc.josoroma.com/contactenos>
<http://acicafoc.josoroma.com/eventos>
Both of them uses a custom taxonomy: country
I just created a template named: taxonomy-country.php
But I Need two separated templates, one for events who uses countries and another one... | You use get\_query\_var('post\_type') to set the post type in your args array
```
$args['post_type'] = get_query_var('post_type');
```
and also include the right loop part based on that for example:
```
if (get_query_var('post_type') == "event"){
get_template_part( 'loop', 'event' );
}else{
get_template_part... |
11,711 | <p>I have a child theme based on Twenty Ten.</p>
<p>I have split out the sidebar and secondary side bar so they can be used on different pages.</p>
<p>sidebar.php file:</p>
<pre><code><div id="primary" class="widget-area" role="complementary">
<ul class="xoxo">
<?php
/* When we call the d... | [
{
"answer_id": 11715,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 3,
"selected": true,
"text": "<p>try this instead <code><?php get_sidebar(2); ?></code></p>\n"
},
{
"answer_id": 13104,
"author": ... | 2011/03/10 | [
"https://wordpress.stackexchange.com/questions/11711",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2469/"
] | I have a child theme based on Twenty Ten.
I have split out the sidebar and secondary side bar so they can be used on different pages.
sidebar.php file:
```
<div id="primary" class="widget-area" role="complementary">
<ul class="xoxo">
<?php
/* When we call the dynamic_sidebar() function, it'll spit out
... | try this instead `<?php get_sidebar(2); ?>` |
11,717 | <p>does anybody know how to hook or filter the user-edit.php file so that an user's email address is disabled from editing akin to how the username is disabled ..??..</p>
<p>i can edit the core file (gasp) and include disabled="disabled" in the form and this works but i'm at a loss as to how to add the disable via hoo... | [
{
"answer_id": 12804,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": -1,
"selected": false,
"text": "<p>The hack given below has been tested with WordPress 3.1.</p>\n\n<p>Open <code>user-edit.php</code>, find:</p>\n\n... | 2011/03/10 | [
"https://wordpress.stackexchange.com/questions/11717",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | does anybody know how to hook or filter the user-edit.php file so that an user's email address is disabled from editing akin to how the username is disabled ..??..
i can edit the core file (gasp) and include disabled="disabled" in the form and this works but i'm at a loss as to how to add the disable via hook or filte... | The only correct solution
=========================
(*Other answers I see are faulty, vulnerable or incomplete. All of them can be bypassed.*)
[This plugin](https://wordpress.org/plugins/modify-profile-fields-dashboard-menu-buttons/) does correctly:
```
class DisableMailChange
{
public function __construct()
... |
11,722 | <p>I'd really love to be able to conditionally apply a CSS class to link elements of images embedded into posts, but I can't seem to figure this one out.</p>
<p>Basically what I'd like to achieve is to replace the default embedded image link that links the image to the full size version of itself to opening it in a co... | [
{
"answer_id": 11756,
"author": "t31os",
"author_id": 31073,
"author_profile": "https://wordpress.stackexchange.com/users/31073",
"pm_score": 3,
"selected": false,
"text": "<p>You can run a filter on <code>image_send_to_editor</code>, the filter runs inside the <code>get_image_send_to_ed... | 2011/03/10 | [
"https://wordpress.stackexchange.com/questions/11722",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3852/"
] | I'd really love to be able to conditionally apply a CSS class to link elements of images embedded into posts, but I can't seem to figure this one out.
Basically what I'd like to achieve is to replace the default embedded image link that links the image to the full size version of itself to opening it in a colorbox.
... | Thanks a LOT to user [t31os](https://wordpress.stackexchange.com/users/1468/t31os) for the tip on where to find my solution!
Also thanks to user [orionrush](https://wordpress.stackexchange.com/users/13551/orionrush) for pointing out a dumb mistake I had made! :)
Here's how I got what I wanted:
```
function add_color... |
11,724 | <p>For starters I am using this GREAT answer to achieve custom post types as well as a custom way to insert those post types into other pages, you can view that answer here:
<a href="https://wordpress.stackexchange.com/questions/5750/custom-field-meta-populated-by-dropdown-of-existing-posts/5778#5778">Custom field/meta... | [
{
"answer_id": 11727,
"author": "William",
"author_id": 3841,
"author_profile": "https://wordpress.stackexchange.com/users/3841",
"pm_score": 2,
"selected": true,
"text": "<p>Well, as always I feel like a dummy, but after searching the internet for hours and seeing that it seems like lot... | 2011/03/10 | [
"https://wordpress.stackexchange.com/questions/11724",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3841/"
] | For starters I am using this GREAT answer to achieve custom post types as well as a custom way to insert those post types into other pages, you can view that answer here:
[Custom field/meta populated by dropdown of existing posts?](https://wordpress.stackexchange.com/questions/5750/custom-field-meta-populated-by-dropdo... | Well, as always I feel like a dummy, but after searching the internet for hours and seeing that it seems like lots of people are having this question and I cant seem to find an an answer anywhere, I guess im not THAT slow!
the important code is something along these lines:
```
add_filter('wp_insert_post_data',array(_... |
11,731 | <p>I'm adding TinyMCE buttons to my plugin and they're working, but I only want these buttons to show up for a certain custom post type. I followed this tutorial if it helps:</p>
<p><a href="http://www.tutorialchip.com/wordpress/wordpress-shortcode-tinymce-button-tutorial-part-2/" rel="nofollow">http://www.tutorialchi... | [
{
"answer_id": 11733,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": true,
"text": "<p>If you followed that tutorial you linked then look at the function that registers the buttons:</p>\n\n<pre><co... | 2011/03/11 | [
"https://wordpress.stackexchange.com/questions/11731",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2415/"
] | I'm adding TinyMCE buttons to my plugin and they're working, but I only want these buttons to show up for a certain custom post type. I followed this tutorial if it helps:
<http://www.tutorialchip.com/wordpress/wordpress-shortcode-tinymce-button-tutorial-part-2/>
How can I have that check if they are editing/posting ... | If you followed that tutorial you linked then look at the function that registers the buttons:
```
function mylink_button() {
if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages'){
return;
}
if ( get_user_option('rich_editing') == 'true' ) {
add_filter( 'mce_external_plugins', 'a... |
11,738 | <p>I am having problems looking for info on the codex on how to query for child pages. It seems to be missing the reference for the available parameters</p>
| [
{
"answer_id": 11733,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": true,
"text": "<p>If you followed that tutorial you linked then look at the function that registers the buttons:</p>\n\n<pre><co... | 2011/03/11 | [
"https://wordpress.stackexchange.com/questions/11738",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3788/"
] | I am having problems looking for info on the codex on how to query for child pages. It seems to be missing the reference for the available parameters | If you followed that tutorial you linked then look at the function that registers the buttons:
```
function mylink_button() {
if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages'){
return;
}
if ( get_user_option('rich_editing') == 'true' ) {
add_filter( 'mce_external_plugins', 'a... |
11,741 | <p>I am designing a frontend for users, where they can submit an article/post from. But i am worrying if someone puts javascipt code, or SQL injection, or other malicious code. Is there a plugin or some sort of scripts which can help me to filter the post contents from security point of view.</p>
<p>I'll appriate if s... | [
{
"answer_id": 11733,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": true,
"text": "<p>If you followed that tutorial you linked then look at the function that registers the buttons:</p>\n\n<pre><co... | 2011/03/11 | [
"https://wordpress.stackexchange.com/questions/11741",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/958/"
] | I am designing a frontend for users, where they can submit an article/post from. But i am worrying if someone puts javascipt code, or SQL injection, or other malicious code. Is there a plugin or some sort of scripts which can help me to filter the post contents from security point of view.
I'll appriate if someone can... | If you followed that tutorial you linked then look at the function that registers the buttons:
```
function mylink_button() {
if ( ! current_user_can('edit_posts') && ! current_user_can('edit_pages'){
return;
}
if ( get_user_option('rich_editing') == 'true' ) {
add_filter( 'mce_external_plugins', 'a... |
11,749 | <p>I am just creating a simple contact form, but I notice that it seems to post to an invalid page. The url in the browser is correct but the title of the page is "Page not found"</p>
<p>on the top of the page</p>
<pre><code>$emailed = false;
if (isset($_POST['submit'])) {
wp_mail('example@example.com', $_POST['s... | [
{
"answer_id": 11754,
"author": "Tom",
"author_id": 3282,
"author_profile": "https://wordpress.stackexchange.com/users/3282",
"pm_score": 7,
"selected": true,
"text": "<p>I could be wrong, but I vaguely remember that: name, email get hijacked by WordPress to do post comments, if you rena... | 2011/03/11 | [
"https://wordpress.stackexchange.com/questions/11749",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3788/"
] | I am just creating a simple contact form, but I notice that it seems to post to an invalid page. The url in the browser is correct but the title of the page is "Page not found"
on the top of the page
```
$emailed = false;
if (isset($_POST['submit'])) {
wp_mail('example@example.com', $_POST['subject'], $_POST['con... | I could be wrong, but I vaguely remember that: name, email get hijacked by WordPress to do post comments, if you renamed the form elements to be contact-name and contact-email, do you get the same issue? |
11,758 | <p>I have created a custom post type and have attached some custom fields to it. Now I would like to the search that authors can perform on the custom post list screen (in the admin backend) to also be performed on the meta fields and not only look in the title and content as usual.</p>
<p>Where can I hook in and what... | [
{
"answer_id": 12356,
"author": "Stefano",
"author_id": 3875,
"author_profile": "https://wordpress.stackexchange.com/users/3875",
"pm_score": 7,
"selected": true,
"text": "<p>I solved filtering the query by adding the join on the postmeta table and changing the where clause.\ntips on fil... | 2011/03/11 | [
"https://wordpress.stackexchange.com/questions/11758",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3875/"
] | I have created a custom post type and have attached some custom fields to it. Now I would like to the search that authors can perform on the custom post list screen (in the admin backend) to also be performed on the meta fields and not only look in the title and content as usual.
Where can I hook in and what code I ha... | I solved filtering the query by adding the join on the postmeta table and changing the where clause.
tips on filtering the WHERE clause (often require regular expression search&replace) are [here on codex](http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_where):
```
add_filter( 'posts_join', 'segnalazioni_... |
11,761 | <p>Pretty new to WordPress functions, so apologies if this is basic stuff.</p>
<p>I've designed a parent theme that registers and enqueues two scripts like so:</p>
<pre><code> if ( !function_exists( 'scherzo_scripts' ) ) :
function scherzo_scripts() {
if (!is_admin()) {
wp_register_script( '... | [
{
"answer_id": 11771,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>functions.php file of the child theme is loaded before the functions.php of the parent theme so it's best to ... | 2011/03/11 | [
"https://wordpress.stackexchange.com/questions/11761",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | Pretty new to WordPress functions, so apologies if this is basic stuff.
I've designed a parent theme that registers and enqueues two scripts like so:
```
if ( !function_exists( 'scherzo_scripts' ) ) :
function scherzo_scripts() {
if (!is_admin()) {
wp_register_script( 'html5shiv', get_templ... | functions.php file of the child theme is loaded before the functions.php of the parent theme so it's best to run the code at the hook after both themes are loaded. At the earliest at `after_setup_theme` hook so Change:
```
add_action('init', 'scherzo_scripts');
```
to:
```
add_action('after_setup_theme', 'scherzo_... |
11,764 | <p>WP 3.1 has everyone excited, if somewhat confused, about post formats.</p>
<h3>Enabling new post formats</h3>
<p>The issue of enabling post formats has been covered at length. It's as simple as adding this line to functions.php: <code>add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );</code></p>
<h3>... | [
{
"answer_id": 11767,
"author": "Manzabar",
"author_id": 199,
"author_profile": "https://wordpress.stackexchange.com/users/199",
"pm_score": 2,
"selected": false,
"text": "<p>You can use <a href=\"http://codex.wordpress.org/Function_Reference/has_post_format\" rel=\"nofollow\">has_post_f... | 2011/03/11 | [
"https://wordpress.stackexchange.com/questions/11764",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3877/"
] | WP 3.1 has everyone excited, if somewhat confused, about post formats.
### Enabling new post formats
The issue of enabling post formats has been covered at length. It's as simple as adding this line to functions.php: `add_theme_support( 'post-formats', array( 'aside', 'gallery' ) );`
### Displaying Posts of a certai... | You have a lot of options for displaying using the "Post Formats" feature:
for example in an index.php loop you can decide what to show based on the post format
using [has\_post\_format()](http://codex.wordpress.org/Function_Reference/has_post_format) function :
```
if ( has_post_format( 'aside' )) {
... |
11,796 | <p>Part of my work is to create Wordpress websites. I usually work on my laptop until I have something good enough to be uploaded to the test server where the client reviews it.</p>
<p>I create a VirtualHost for every new project so I'm always working with a Wordpress installation in a domain that looks like <code>htt... | [
{
"answer_id": 45813,
"author": "Manimaran",
"author_id": 5515,
"author_profile": "https://wordpress.stackexchange.com/users/5515",
"pm_score": 1,
"selected": false,
"text": "<p>First you have to install <a href=\"http://wordpress.org/extend/plugins/peters-blog-url-shortcodes/\" rel=\"no... | 2011/03/11 | [
"https://wordpress.stackexchange.com/questions/11796",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52/"
] | Part of my work is to create Wordpress websites. I usually work on my laptop until I have something good enough to be uploaded to the test server where the client reviews it.
I create a VirtualHost for every new project so I'm always working with a Wordpress installation in a domain that looks like `http://local.examp... | I was also looking for a solution for this and I found simple one.
This is what you need to place into the URL field:
```
/index.php/internal-site-name
```

It works just fine!
Best Regards
Chris |
11,798 | <p>I am working on a site that will have up to 30 templates in it.</p>
<p>I don't want to have all those templates at the root of my theme folder cluttering up everything. </p>
<p>I know how I can modify the <code>get_page_templates()</code> function in the file <code>wp-admin/includes/theme.php</code> to make it sca... | [
{
"answer_id": 11802,
"author": "scribu",
"author_id": 205,
"author_profile": "https://wordpress.stackexchange.com/users/205",
"pm_score": 1,
"selected": false,
"text": "<p>There are a couple of tickets on this: <a href=\"http://core.trac.wordpress.org/ticket/13265\" rel=\"nofollow\">#13... | 2011/03/11 | [
"https://wordpress.stackexchange.com/questions/11798",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3885/"
] | I am working on a site that will have up to 30 templates in it.
I don't want to have all those templates at the root of my theme folder cluttering up everything.
I know how I can modify the `get_page_templates()` function in the file `wp-admin/includes/theme.php` to make it scan sub dirs in my theme folder. But I do... | That part is extremely rigid, see this [question about loading page templates from plugin directory](https://wordpress.stackexchange.com/questions/4136/is-there-a-wordpress-plugin-that-registers-a-plugin-file-as-a-custom-page-templat).
With current state of related code I would not bother spending time on this. Especi... |
11,821 | <pre><code><div class="menu">
<ul>
<?php wp_list_pages('exclude=&title_li='); ?>
</ul>
</div>
</code></pre>
<p>creates the following output...</p>
<pre><code><div class="menu">
<ul>
<li><a href="#">Page 1</a></li>
... | [
{
"answer_id": 11830,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 4,
"selected": true,
"text": "<p><strike>Phew! Bit more complex than I would've liked - if only the filter <code>page_css_class</code> passed... | 2011/03/12 | [
"https://wordpress.stackexchange.com/questions/11821",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3529/"
] | ```
<div class="menu">
<ul>
<?php wp_list_pages('exclude=&title_li='); ?>
</ul>
</div>
```
creates the following output...
```
<div class="menu">
<ul>
<li><a href="#">Page 1</a></li>
<li><a href="#">Page with Subpages</a>
<ul class="children">
<li><a hr... | Phew! Bit more complex than I would've liked - if only the filter `page_css_class` passed back `$args` it would save a lot of effort (may submit this to trac).
**Since 3.3** it's as easy as this!
```
function add_parent_class( $css_class, $page, $depth, $args )
{
if ( ! empty( $args['has_children'] ) )
$c... |
11,832 | <p>How are you?</p>
<p>I have a blog which have 20 authors. I want to write code to show the 5 author who have more posts.</p>
<p>like this:</p>
<p>Adam (10 Posts)
Khal (8 Posts)
Yous (5 Posts)
Moha (3 Posts)
Yousef (1 Post)</p>
<p>but I don't know how can do it that </p>
| [
{
"answer_id": 11834,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 4,
"selected": true,
"text": "<p>Are you using WordPress 3.1+? There's a nice <code>get_users()</code> function that'll do the trick! However... | 2011/03/12 | [
"https://wordpress.stackexchange.com/questions/11832",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2076/"
] | How are you?
I have a blog which have 20 authors. I want to write code to show the 5 author who have more posts.
like this:
Adam (10 Posts)
Khal (8 Posts)
Yous (5 Posts)
Moha (3 Posts)
Yousef (1 Post)
but I don't know how can do it that | Are you using WordPress 3.1+? There's a nice `get_users()` function that'll do the trick! However, you will need a little magic to boot:
```
add_action( 'pre_user_query', 'wpse_11832_pre_user_query' );
/**
* Adds "post_count" to the SELECT clause. Without this, the "post_count"
* property for users will be undefine... |
11,836 | <p>One of my wordpress blog is protected by the wordpress password plugin. however, I would like provide rss features. I found how to configure wordpress plugin to make rss work.
But, by default, it seems that all the content of a post is sent by the feed.
I would like to limit the information available by rss. Ideally... | [
{
"answer_id": 11834,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 4,
"selected": true,
"text": "<p>Are you using WordPress 3.1+? There's a nice <code>get_users()</code> function that'll do the trick! However... | 2011/03/12 | [
"https://wordpress.stackexchange.com/questions/11836",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3891/"
] | One of my wordpress blog is protected by the wordpress password plugin. however, I would like provide rss features. I found how to configure wordpress plugin to make rss work.
But, by default, it seems that all the content of a post is sent by the feed.
I would like to limit the information available by rss. Ideally, I... | Are you using WordPress 3.1+? There's a nice `get_users()` function that'll do the trick! However, you will need a little magic to boot:
```
add_action( 'pre_user_query', 'wpse_11832_pre_user_query' );
/**
* Adds "post_count" to the SELECT clause. Without this, the "post_count"
* property for users will be undefine... |
11,842 | <p>i have a custom post type 'events'. Each event (post) can have multiple dates. The dates (date, time, location) are stored as array. I need a <strong>query that creates a chronological list of all events</strong> from the meta data (events can occur multiple times). </p>
<p>The custom-meta-box looks like this:</p... | [
{
"answer_id": 11940,
"author": "farinspace",
"author_id": 466,
"author_profile": "https://wordpress.stackexchange.com/users/466",
"pm_score": 0,
"selected": false,
"text": "<p>Christoph,</p>\n\n<p>To create a main page which lists all (page > events) ... you would need to create your ow... | 2011/03/12 | [
"https://wordpress.stackexchange.com/questions/11842",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3480/"
] | i have a custom post type 'events'. Each event (post) can have multiple dates. The dates (date, time, location) are stored as array. I need a **query that creates a chronological list of all events** from the meta data (events can occur multiple times).
The custom-meta-box looks like this:
;
$my_query = new WP_Query('post_type=events&posts_per_page=-1&monthnum='.$today["mon"]);
$events=array();
while ($my_query->have_posts()) : $my_query->the_post();
$do_not_duplicate = $post->ID;
$meta = get_po... |
11,857 | <p>I have a 'media' category page that pumps in videos / image galleries. I'm looking to have a smaller size video display (vimeo / youtube) on the category page, and the full size video on the single page. </p>
<p>How do I change the size of the video embed on the fly for the both scenarios? </p>
<p>Here's the loop ... | [
{
"answer_id": 11933,
"author": "Dan Gayle",
"author_id": 10,
"author_profile": "https://wordpress.stackexchange.com/users/10",
"pm_score": -1,
"selected": false,
"text": "<p>If you use the embed shortcode, you can specify parameters</p>\n\n<pre><code>[embed width=\"200\"]http://www.fli... | 2011/03/12 | [
"https://wordpress.stackexchange.com/questions/11857",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3899/"
] | I have a 'media' category page that pumps in videos / image galleries. I'm looking to have a smaller size video display (vimeo / youtube) on the category page, and the full size video on the single page.
How do I change the size of the video embed on the fly for the both scenarios?
Here's the loop for selecting any... | The best solution here is to use the built-in filter for embed parameters:
```
<?php
function mytheme_embed_defaults( $defaults ) {
return array(
'width' => 100,
'height' => 100
);
}
add_filter( 'embed_defaults', 'mytheme_embed_defaults' );
?>
```
This code can be added to your theme's functions.php ... |
11,871 | <p>I'm using custom post types, but they don't appear on tag pages along with regular posts and i'd like to include both standard and custom post types on tag or category pages.</p>
<h3>What would be required before the loop to include all posts? (including custom type).</h3>
<p><strong>Updated:</strong><br />
To add, ... | [
{
"answer_id": 14578,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 3,
"selected": false,
"text": "<pre><code>function post_type_tags_fix($request) {\n if ( isset($request['tag']) && !isset($request['post_t... | 2011/03/13 | [
"https://wordpress.stackexchange.com/questions/11871",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3903/"
] | I'm using custom post types, but they don't appear on tag pages along with regular posts and i'd like to include both standard and custom post types on tag or category pages.
### What would be required before the loop to include all posts? (including custom type).
**Updated:**
To add, I found this code [here](http... | ```
function post_type_tags_fix($request) {
if ( isset($request['tag']) && !isset($request['post_type']) )
$request['post_type'] = 'any';
return $request;
}
add_filter('request', 'post_type_tags_fix');
```
You can alter the post type to your liking.
From this post.
[Custom post type tag archives don't wo... |
11,877 | <p>Now that wordpress 3.1 is out, where is the documentation for grouping custom post types together in the wp backend?</p>
| [
{
"answer_id": 37747,
"author": "Velvet Blues",
"author_id": 11498,
"author_profile": "https://wordpress.stackexchange.com/users/11498",
"pm_score": 4,
"selected": true,
"text": "<p>If you are wondering how to group multiple post types under one menu, you can easily do this with the <cod... | 2011/03/13 | [
"https://wordpress.stackexchange.com/questions/11877",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3361/"
] | Now that wordpress 3.1 is out, where is the documentation for grouping custom post types together in the wp backend? | If you are wondering how to group multiple post types under one menu, you can easily do this with the `show_in_menu` argument when setting up your menu. See below:
```
$args = array(
'public' => true,
'show_ui' => true,
'query_var' => true,
'rewrite' => true,
'capability_type' => 'post',
'hierarchical' => false... |
11,893 | <p>I'm using the twentyten theme with the bbpress plugin.
I have the following in my header.php (twentyten):</p>
<pre><code> <div id="masthead">
<div id="branding" role="banner">
<h1><a href="<?php get_site_url(); ?>">TaiwanTalk</a></h1>
</div... | [
{
"answer_id": 11897,
"author": "Lea Cohen",
"author_id": 373,
"author_profile": "https://wordpress.stackexchange.com/users/373",
"pm_score": 1,
"selected": false,
"text": "<p>The function is located in wp-includes/link-template.php. You can take a look at the code <a href=\"http://core.... | 2011/03/13 | [
"https://wordpress.stackexchange.com/questions/11893",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/781/"
] | I'm using the twentyten theme with the bbpress plugin.
I have the following in my header.php (twentyten):
```
<div id="masthead">
<div id="branding" role="banner">
<h1><a href="<?php get_site_url(); ?>">TaiwanTalk</a></h1>
</div><!-- #branding -->
<div id="access" role="navigati... | The functions that start with "get\_" return the value to what's calling it. So you would do `<a href="<?php echo get_site_url(); ?>">` instead to print out the URL. |
11,906 | <p>For some reason this custom field is not being shown in the page.</p>
<p>This is the template file:</p>
<pre><code><?php
/**
* Template Name: bbPress - Topics (Newest)
*
* @package bbPress
* @subpackage Theme
*/
?>
<?php get_header(); ?>
<div id="container">
<div i... | [
{
"answer_id": 11911,
"author": "Rob Williams",
"author_id": 3803,
"author_profile": "https://wordpress.stackexchange.com/users/3803",
"pm_score": 4,
"selected": true,
"text": "<p>You're doing it outside of The Loop there, so $post is undefined at that point. Put it above the <code>endwh... | 2011/03/13 | [
"https://wordpress.stackexchange.com/questions/11906",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/781/"
] | For some reason this custom field is not being shown in the page.
This is the template file:
```
<?php
/**
* Template Name: bbPress - Topics (Newest)
*
* @package bbPress
* @subpackage Theme
*/
?>
<?php get_header(); ?>
<div id="container">
<div id="content" role="main">
... | You're doing it outside of The Loop there, so $post is undefined at that point. Put it above the `endwhile` and it should work. |
11,910 | <p>I have created some pages (not post) in wordpress related to my college notes. </p>
<p>I would like to display a copyright message of the college on this pages, but I don't want do this manually every time.</p>
<p>So is there any plug-in or tweak available to achieve this?</p>
| [
{
"answer_id": 11912,
"author": "Rob Williams",
"author_id": 3803,
"author_profile": "https://wordpress.stackexchange.com/users/3803",
"pm_score": 3,
"selected": true,
"text": "<p>You could add a custom field to the pages you want to show the copyright on and have your page.php (or heade... | 2011/03/13 | [
"https://wordpress.stackexchange.com/questions/11910",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1293/"
] | I have created some pages (not post) in wordpress related to my college notes.
I would like to display a copyright message of the college on this pages, but I don't want do this manually every time.
So is there any plug-in or tweak available to achieve this? | You could add a custom field to the pages you want to show the copyright on and have your page.php (or header.php or index.php or whatever) look for it.
Example:
Set a custom field of "show\_copyright" to "1" in the page editor.
In your page.php, right above `<?php endwhile; endif; ?>`, add this:
```
<?php
if ( get... |
11,914 | <p>Hey! I have added a wp_loginout() to my header using a snippet in my functions.php:</p>
<pre><code> add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);
function add_login_logout_link($items, $args) {
ob_start();
wp_loginout('index.php');
$loginoutlink = ob_get_contents();
... | [
{
"answer_id": 11916,
"author": "Philip Arthur Moore",
"author_id": 3884,
"author_profile": "https://wordpress.stackexchange.com/users/3884",
"pm_score": 4,
"selected": true,
"text": "<p>See this <a href=\"https://wordpress.stackexchange.com/questions/2143/customizing-only-a-specific-men... | 2011/03/13 | [
"https://wordpress.stackexchange.com/questions/11914",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | Hey! I have added a wp\_loginout() to my header using a snippet in my functions.php:
```
add_filter('wp_nav_menu_items', 'add_login_logout_link', 10, 2);
function add_login_logout_link($items, $args) {
ob_start();
wp_loginout('index.php');
$loginoutlink = ob_get_contents();
ob_end_... | See this [related question](https://wordpress.stackexchange.com/questions/2143/customizing-only-a-specific-menu-using-the-wp-nav-menu-items-hook). I guess in your case you'd wrap your code in `if( $args->theme_location == 'primary-menu' )`. |
11,920 | <p>I am trying to do something similar to the above question. I am trying to make users post and upload images from front-end. I have already done the post form and its working.</p>
<p>I just followed and tried the answer posted by Robin I Knight <a href="https://wordpress.stackexchange.com/questions/11395/upload-post... | [
{
"answer_id": 11928,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 6,
"selected": true,
"text": "<p>If you are talking about the answer i posted <a href=\"https://wordpress.stackexchange.com/questions/11395/upl... | 2011/03/13 | [
"https://wordpress.stackexchange.com/questions/11920",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3913/"
] | I am trying to do something similar to the above question. I am trying to make users post and upload images from front-end. I have already done the post form and its working.
I just followed and tried the answer posted by Robin I Knight [upload-post-thumbnail-from-the-front-end](https://wordpress.stackexchange.com/que... | If you are talking about the answer i posted [here](https://wordpress.stackexchange.com/questions/11395/upload-post-thumbnail-from-the-front-end/11400#11400)
its simply uploading file in an iframe to achieve "Ajax like" submit.
Now if you already have a form that handles the post submit you can simply add the upload f... |
11,934 | <p>I'd like to be able to automatically uninstall certain plugins if they're detected (specifically Akismet and Hello Dolly), either by writing another plugin to do so or via my theme's functions.php file. Is that possible?</p>
| [
{
"answer_id": 11928,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 6,
"selected": true,
"text": "<p>If you are talking about the answer i posted <a href=\"https://wordpress.stackexchange.com/questions/11395/upl... | 2011/03/13 | [
"https://wordpress.stackexchange.com/questions/11934",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49/"
] | I'd like to be able to automatically uninstall certain plugins if they're detected (specifically Akismet and Hello Dolly), either by writing another plugin to do so or via my theme's functions.php file. Is that possible? | If you are talking about the answer i posted [here](https://wordpress.stackexchange.com/questions/11395/upload-post-thumbnail-from-the-front-end/11400#11400)
its simply uploading file in an iframe to achieve "Ajax like" submit.
Now if you already have a form that handles the post submit you can simply add the upload f... |
11,937 | <p>I love markdown, and I have the Wordpress <a href="http://wordpress.org/extend/plugins/markdown-for-wordpress-and-bbpress/" rel="nofollow noreferrer">markdown-for-wordpress-and-bbpress</a> parsing markdown in my posts and comments.</p>
<p>However, I've noticed that Wordpress saves the comments rendered in html for... | [
{
"answer_id": 11947,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 3,
"selected": true,
"text": "<p>This is a tricky one, but very doable.\nAfter looking at Mark's <a href=\"http://wordpress.org/extend/plugins/... | 2011/03/13 | [
"https://wordpress.stackexchange.com/questions/11937",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3919/"
] | I love markdown, and I have the Wordpress [markdown-for-wordpress-and-bbpress](http://wordpress.org/extend/plugins/markdown-for-wordpress-and-bbpress/) parsing markdown in my posts and comments.
However, I've noticed that Wordpress saves the comments rendered in html format. This makes it more difficult to go back and... | This is a tricky one, but very doable.
After looking at Mark's [Markdown on Save](http://wordpress.org/extend/plugins/markdown-on-save/) plugin which does the exact thing you want but for posts content instead of comments i started thinking, that saving the comment content as Markdown would be bad because you would hav... |
11,943 | <p>I want to list all terms of a specific taxonomy used in a category.</p>
<p>Like I have a taxonomy called 'Manufacturer' and a category 'Shoes'. Each post in this category has a term like 'Nike', 'Adidas' or 'Reebok' and of course there are some posts having the same term.</p>
<p>And on the archive page I want to l... | [
{
"answer_id": 11944,
"author": "J. Taylor",
"author_id": 3756,
"author_profile": "https://wordpress.stackexchange.com/users/3756",
"pm_score": 1,
"selected": false,
"text": "<p>This article might be helpful: <a href=\"http://www.leewillis.co.uk/wordpress-taxonomies-to-create-a-product-d... | 2011/03/13 | [
"https://wordpress.stackexchange.com/questions/11943",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I want to list all terms of a specific taxonomy used in a category.
Like I have a taxonomy called 'Manufacturer' and a category 'Shoes'. Each post in this category has a term like 'Nike', 'Adidas' or 'Reebok' and of course there are some posts having the same term.
And on the archive page I want to list all the terms... | Since you are in a category the your query will get the posts of that category, you only need to add 'posts\_per\_page' => -1 to that query so it will get you all the posts in that category and not the default "at most" number.
so something like:
```
query_posts( $query_string . '&posts_per_page=-1' );
```
this wi... |
11,945 | <ul>
<li>I have 2 customs post type : "Artist" and "Concert",</li>
<li>the "Concert" custom post type is the child of the "Artist" custom post type,</li>
<li>the "Artist" custom post type has a "genre" taxonomy.</li>
</ul>
<p>What I'm trying to do (for instance): list all the concerts which belong to artists of the "p... | [
{
"answer_id": 11946,
"author": "J. Taylor",
"author_id": 3756,
"author_profile": "https://wordpress.stackexchange.com/users/3756",
"pm_score": 0,
"selected": false,
"text": "<p>The parent page is stored in $post->post_parent</p>\n\n<p>So you can just grab the parent post that way, and t... | 2011/03/14 | [
"https://wordpress.stackexchange.com/questions/11945",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3925/"
] | * I have 2 customs post type : "Artist" and "Concert",
* the "Concert" custom post type is the child of the "Artist" custom post type,
* the "Artist" custom post type has a "genre" taxonomy.
What I'm trying to do (for instance): list all the concerts which belong to artists of the "pop" genre.
Here is the query of my... | >
> What I'm trying to do (for instance):
> list all the concerts which belong to
> artists of the "pop" genre.
>
>
>
You can do it in two steps:
```
// 1. Get all the pop artist IDs
$artist_ids = get_posts( array(
'fields' => 'ids',
'post_type' => 'artist',
'genre' => 'pop'
) );
// 2. Get all the concer... |
11,963 | <p>I'm trying to optimize my header and I was wondering which plugin would call jquery.
Is there a debugging tool to know which plugin is doing what in the header ?</p>
<p>Thanks !</p>
| [
{
"answer_id": 11965,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 3,
"selected": true,
"text": "<p>Plugins and themes tend to use <code>wp_enqueue_script()</code> to queue up scripts for the <code><head /... | 2011/03/14 | [
"https://wordpress.stackexchange.com/questions/11963",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3929/"
] | I'm trying to optimize my header and I was wondering which plugin would call jquery.
Is there a debugging tool to know which plugin is doing what in the header ?
Thanks ! | Plugins and themes tend to use `wp_enqueue_script()` to queue up scripts for the `<head />` of your theme.
I would rarely advise this, but since you only need to do it temporarily, you could modify WordPress core and run a debug backtrace for every call to this function.
In `wp-includes/functions.wp-scripts.php`, dro... |
11,972 | <p>WordPress has a built in function to display a list of all of your site’s authors. But there is no option to display their avatars, so all you really get is a text list that links to the author’s page, if you have an author.php file in your theme, that is.</p>
<p>thus turning the internet I found this nice tutorial... | [
{
"answer_id": 11988,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 1,
"selected": false,
"text": "<p>In your case you can save your time the trouble by using <a href=\"http://wordpress.org/extend/plugins/member... | 2011/03/14 | [
"https://wordpress.stackexchange.com/questions/11972",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3897/"
] | WordPress has a built in function to display a list of all of your site’s authors. But there is no option to display their avatars, so all you really get is a text list that links to the author’s page, if you have an author.php file in your theme, that is.
thus turning the internet I found this nice tutorial [bavotasa... | I have modified WP\_LIST\_AUTHORS to paginate. I don't know if its very sexy, and seems to require some sort of Caching plugin otherwise this particular page can start to load pretty slowly.
The full code of my paginated function is in this thread: [Modifying WP\_LIST\_AUTHOR Functions to output all users in a grid (... |
11,979 | <p>Is there a way to make Wordpress' "Remember Me" login checkbox work for a really long time, like a year? Currently I think it only works for a few days or a week max, usually I am not remembered.</p>
| [
{
"answer_id": 11983,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>Wordpress versions great than 2.4 store two cookies that set to expire in two weeks according to the <a href=\"htt... | 2011/03/14 | [
"https://wordpress.stackexchange.com/questions/11979",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/678/"
] | Is there a way to make Wordpress' "Remember Me" login checkbox work for a really long time, like a year? Currently I think it only works for a few days or a week max, usually I am not remembered. | >
> I think I'll wait for such a plugin
>
>
>
Save this code in a file named `set-cookie-expire.php` and upload it your plugins folder.
The plugin will give you the ability to set a time (in days) that cookies expire within the WordPress Settings admin.
```
<?php
/**
* Plugin Name: Set Cookie Expire
* Plugin ... |
11,993 | <p>I need to do check the inserted post for certain keywords and perform some functions depending on the keywords found.</p>
<p>is there a wordpress hook that executes "just before the post is inserted into the database" ? Or will i have to modify wordpress core ?</p>
<p>Also, i will need to prevent the post from bei... | [
{
"answer_id": 11995,
"author": "anu",
"author_id": 490,
"author_profile": "https://wordpress.stackexchange.com/users/490",
"pm_score": 2,
"selected": false,
"text": "<p>The hook is save_post:</p>\n\n<p><code>add_action('save_post', 'dosomething'), 10, 2);</code></p>\n"
},
{
"ans... | 2011/03/14 | [
"https://wordpress.stackexchange.com/questions/11993",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3933/"
] | I need to do check the inserted post for certain keywords and perform some functions depending on the keywords found.
is there a wordpress hook that executes "just before the post is inserted into the database" ? Or will i have to modify wordpress core ?
Also, i will need to prevent the post from being inserted into ... | Available actions:
1. **pre\_post\_update** - Runs just before a post or page is updated.
2. **publish\_post** - Runs when a post is published, or if it is edited and its status is "published".
3. **save\_post** - Runs whenever a post or page is created or updated, which could be from an import, post/page edit form, x... |
12,002 | <p><code><?php $post_type = get_post_type( $post->ID ); if $post_type == 'project' : echo 'Work'; ?></code></p>
<p>How can I make the above work? I want it so that if the post type is 'projects', then it echoes 'Work'.</p>
<p>Also, I want to add another <code>if post type is 'movies' then it echoes 'Film'</... | [
{
"answer_id": 12005,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>Why not use native labels that you set up for custom post type?</p>\n\n<pre><code>$post_type = get_post_type_object(... | 2011/03/14 | [
"https://wordpress.stackexchange.com/questions/12002",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3714/"
] | `<?php $post_type = get_post_type( $post->ID ); if $post_type == 'project' : echo 'Work'; ?>`
How can I make the above work? I want it so that if the post type is 'projects', then it echoes 'Work'.
Also, I want to add another `if post type is 'movies' then it echoes 'Film'` on top of that. | Well, as far as I can tell you've got a syntax error there. Try this:
```
<?php $post_type = get_post_type( $post->ID ); if ($post_type == 'project') echo 'Work'; ?>
```
Also, make sure to check out what eileen.carpenter said in the comment to your question. |
12,012 | <p>I've created a custom post type single template. I noticed that when I turn off comments, I get a notice that says "Comments are closed."</p>
<p>Looking at my comments.php, I get this little bit of code:</p>
<pre><code> <?php else : // or, if we don't have comments:
/* If there are no comments and... | [
{
"answer_id": 12019,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 3,
"selected": true,
"text": "<p>Add a post type check to the <code>if</code> clause;</p>\n\n<pre><code>if ( ! comments_open() && ! i... | 2011/03/14 | [
"https://wordpress.stackexchange.com/questions/12012",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3403/"
] | I've created a custom post type single template. I noticed that when I turn off comments, I get a notice that says "Comments are closed."
Looking at my comments.php, I get this little bit of code:
```
<?php else : // or, if we don't have comments:
/* If there are no comments and comments are closed,
... | Add a post type check to the `if` clause;
```
if ( ! comments_open() && ! is_page() && 'duka' != get_post_type() ) :
``` |
12,031 | <p>I am using the More Fields plugin which gives me the ability to create a date formatted YYYY/mm/dd and I want to convert that to be shown like: February 11, 2011</p>
<p>Is this possible?</p>
| [
{
"answer_id": 12037,
"author": "Marcin",
"author_id": 3768,
"author_profile": "https://wordpress.stackexchange.com/users/3768",
"pm_score": 0,
"selected": false,
"text": "<pre><code><?php\n$date = '2000/10/28';\n$a = preg_split ( '/\\//', $date );\necho date('F j, Y', mktime( 0, 0, 0... | 2011/03/14 | [
"https://wordpress.stackexchange.com/questions/12031",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2755/"
] | I am using the More Fields plugin which gives me the ability to create a date formatted YYYY/mm/dd and I want to convert that to be shown like: February 11, 2011
Is this possible? | Do you have issue with exactly converting or retrieval? Converting is trivial and is plain PHP:
```
date('F j, Y', strtotime($date));
```
For more complex and WordPress-specific way with localization support see [`date_i18n()`](http://codex.wordpress.org/Function_Reference/date_i18n) function. |
12,043 | <p>If I wanted to put the scripts that all my plugins use at the end of the page, where would I do this?
Using YSlow/Firebug it recommends this tactic.</p>
| [
{
"answer_id": 12046,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>One way - make use of queue. <a href=\"http://codex.wordpress.org/Function_Reference/wp_register_script\" rel=\"nofo... | 2011/03/14 | [
"https://wordpress.stackexchange.com/questions/12043",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/970/"
] | If I wanted to put the scripts that all my plugins use at the end of the page, where would I do this?
Using YSlow/Firebug it recommends this tactic. | The hook for registering the script in the footer is:
```
<?php
function my_init_method() {
wp_register_script( 'myscript', 'http://www.mydomain.com/js/myscript.js','','','true');
wp_enqueue_script( 'jquery' );
}
add_action('init', 'my_init_method');
?>
```
be sure to look at [this](http://codex.wordpre... |
12,077 | <p>I'm trying to run a fresh install on my server with WP 3.1. Problem is I'm getting errors after setting up the config. (attached image)</p>
<p>I've installed the previous versions of WP before and have had no trouble.</p>
<pre><code>nction weblog_ping($server = '', $path = '') { global $wp_version; include_once(AB... | [
{
"answer_id": 12079,
"author": "scribu",
"author_id": 205,
"author_profile": "https://wordpress.stackexchange.com/users/205",
"pm_score": 1,
"selected": false,
"text": "<p>It looks like one of the files is incomplete. Try copying all files over again.</p>\n"
},
{
"answer_id": 11... | 2011/03/14 | [
"https://wordpress.stackexchange.com/questions/12077",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I'm trying to run a fresh install on my server with WP 3.1. Problem is I'm getting errors after setting up the config. (attached image)
I've installed the previous versions of WP before and have had no trouble.
```
nction weblog_ping($server = '', $path = '') { global $wp_version; include_once(ABSPATH . WPINC . '/cla... | It looks like one of the files is incomplete. Try copying all files over again. |
12,078 | <p>I created theme options page using Settings API, everything works fine but I can't save options. I tried to figure it out where I missed something but I failed. Any idea what can cause this problem? </p>
<p>Here's code of my options page</p>
<pre><code><?php
/**
* This functions registers default options value... | [
{
"answer_id": 12121,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 3,
"selected": false,
"text": "<p>The problem is they <em>are</em> getting saved... it's just you're always saving the defaults!</p>\n\n<pre>... | 2011/03/15 | [
"https://wordpress.stackexchange.com/questions/12078",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/888/"
] | I created theme options page using Settings API, everything works fine but I can't save options. I tried to figure it out where I missed something but I failed. Any idea what can cause this problem?
Here's code of my options page
```
<?php
/**
* This functions registers default options values for Evolutionary theme... | **@Mamaduka:**
Here is why your settings aren't updating. Your validation function is wrong. To wit:
```
function ev_options_validate( $input ) {
$ev_options = get_option( 'theme_evolutionary_options' );
$valid_input = $ev_options;
$ev_options['color_scheme'] = array_key_exists( $ev_options['color_scheme... |
12,086 | <p>Fiddling around with a custom post type which is quite heavy modified.
Started doing some testing to see if I had broken some function, and realized that wordpress doesn't have a function that checks if a post has any content at all. Meaning, if I press "Add new" and just press publish, it won't say a word just save... | [
{
"answer_id": 12102,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 3,
"selected": true,
"text": "<p>When i needed a solution to the save \"problem\" i create an Ajax function to validate the fields and did some... | 2011/03/15 | [
"https://wordpress.stackexchange.com/questions/12086",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2830/"
] | Fiddling around with a custom post type which is quite heavy modified.
Started doing some testing to see if I had broken some function, and realized that wordpress doesn't have a function that checks if a post has any content at all. Meaning, if I press "Add new" and just press publish, it won't say a word just save th... | When i needed a solution to the save "problem" i create an Ajax function to validate the fields and did some minor JQuery hacks:
first we add our JavaScript to capture the submit/publish event and use it to submit our own ajax function before the actual submit
```
add_action('wp_print_scripts','my_publish_admin_hook... |
12,100 | <p>I'm writing a theme and adding a menu with several submenu pages. It works fine, except that I'm trying to use only one array to save all the settings into the database and this is causing some issues.</p>
<p>The problem is that when each submenu pages is saved, it only saves the values from that page to the array ... | [
{
"answer_id": 12114,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": true,
"text": "<p>Yep you are missing something, On your validate_options function you need to:</p>\n\n<ul>\n<li>get an array of... | 2011/03/15 | [
"https://wordpress.stackexchange.com/questions/12100",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3953/"
] | I'm writing a theme and adding a menu with several submenu pages. It works fine, except that I'm trying to use only one array to save all the settings into the database and this is causing some issues.
The problem is that when each submenu pages is saved, it only saves the values from that page to the array and remove... | Yep you are missing something, On your validate\_options function you need to:
* get an array of all existing options.
* update only the options your Submenu
page handles.
* return that array.
So something like:
```
function validate_options($input){
//do regular validation stuff
//...
//...
//get a... |
12,101 | <p>I am making <code>readme.html</code> file for a plugin with some detailed setup instruction that need to include screenshots.</p>
<p>As rest of UI I want it be consistent with WordPress style and so I looked at its own <code>readme.html</code>.</p>
<p>It includes stylesheet with relative path:</p>
<pre><code><... | [
{
"answer_id": 12114,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": true,
"text": "<p>Yep you are missing something, On your validate_options function you need to:</p>\n\n<ul>\n<li>get an array of... | 2011/03/15 | [
"https://wordpress.stackexchange.com/questions/12101",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/847/"
] | I am making `readme.html` file for a plugin with some detailed setup instruction that need to include screenshots.
As rest of UI I want it be consistent with WordPress style and so I looked at its own `readme.html`.
It includes stylesheet with relative path:
```
<link rel="stylesheet" href="wp-admin/css/install.css?... | Yep you are missing something, On your validate\_options function you need to:
* get an array of all existing options.
* update only the options your Submenu
page handles.
* return that array.
So something like:
```
function validate_options($input){
//do regular validation stuff
//...
//...
//get a... |
12,111 | <p>i've attached a local .flv video to my post (it was uploaded and is inside my mediapool).
my question: how can i display it inside my post? (the video player)</p>
<p>thanks</p>
| [
{
"answer_id": 12114,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": true,
"text": "<p>Yep you are missing something, On your validate_options function you need to:</p>\n\n<ul>\n<li>get an array of... | 2011/03/15 | [
"https://wordpress.stackexchange.com/questions/12111",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3030/"
] | i've attached a local .flv video to my post (it was uploaded and is inside my mediapool).
my question: how can i display it inside my post? (the video player)
thanks | Yep you are missing something, On your validate\_options function you need to:
* get an array of all existing options.
* update only the options your Submenu
page handles.
* return that array.
So something like:
```
function validate_options($input){
//do regular validation stuff
//...
//...
//get a... |
12,112 | <p>Hi I'm trying to use this plugin: <a href="http://wordpress.org/extend/plugins/wordpress-simple-website-screenshot/" rel="nofollow">http://wordpress.org/extend/plugins/wordpress-simple-website-screenshot/</a> </p>
<p>I am supposed to use the shortcode: <code>[screenshot url="www.example.com"]</code>
Because I am w... | [
{
"answer_id": 12115,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 3,
"selected": true,
"text": "<p>You're trying to execute PHP inside a string! Instead, concat the string;</p>\n\n<pre><code><?php echo do... | 2011/03/15 | [
"https://wordpress.stackexchange.com/questions/12112",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2188/"
] | Hi I'm trying to use this plugin: <http://wordpress.org/extend/plugins/wordpress-simple-website-screenshot/>
I am supposed to use the shortcode: `[screenshot url="www.example.com"]`
Because I am writing the code in the single.php file I am using:
`<?php echo do_shortcode( '[screenshot url="www.example.com"]' ); ?>... | You're trying to execute PHP inside a string! Instead, concat the string;
```
<?php echo do_shortcode( '[screenshot url="' . get_the_title() . '"]' ); ?>
``` |
12,123 | <p>I have no use in categorizing/tagging my posts with anything, at all, and it doesn't look very good to have every post say "filed under: uncategorized."</p>
<p>Is there any plugin to do this, or do I need to do some manual editing?</p>
| [
{
"answer_id": 12124,
"author": "Rev. Voodoo",
"author_id": 3429,
"author_profile": "https://wordpress.stackexchange.com/users/3429",
"pm_score": 0,
"selected": false,
"text": "<p>Well, from the post side, under screen options I believe you can hide the selection menus. Just for persona... | 2011/03/15 | [
"https://wordpress.stackexchange.com/questions/12123",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1728/"
] | I have no use in categorizing/tagging my posts with anything, at all, and it doesn't look very good to have every post say "filed under: uncategorized."
Is there any plugin to do this, or do I need to do some manual editing? | Why hack apart what's already there? If you remove the built in taxonomies, you'll end up **creating hiccups** in core code that expect them to be there!
You're **much** better off just editing your theme file(s), or filtering out categories on the front-end (ask if you need help on that).
For example, in your theme'... |
12,126 | <p>I am bit busy with developing one fashion website, currently (http://test-domain.zakirsajib.co.uk/), where I have images come from posts and when mouse will hover on any image, the corresponding post title and post excerpt will de displayed. Couldn't make it happen though :)</p>
<p>Any clue will be helpful.</p>
<p... | [
{
"answer_id": 12129,
"author": "Rev. Voodoo",
"author_id": 3429,
"author_profile": "https://wordpress.stackexchange.com/users/3429",
"pm_score": 1,
"selected": false,
"text": "<p>could you just set it up in the alt and title field for the image?</p>\n\n<pre><code>img src=\"whatev\" alt=... | 2011/03/15 | [
"https://wordpress.stackexchange.com/questions/12126",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2824/"
] | I am bit busy with developing one fashion website, currently (http://test-domain.zakirsajib.co.uk/), where I have images come from posts and when mouse will hover on any image, the corresponding post title and post excerpt will de displayed. Couldn't make it happen though :)
Any clue will be helpful.
Site is developi... | I think the php you'll need to put into your template is
```
<?php the_title();?>
```
and
```
<?php the_excerpt();?>
```
Wrapped up in whatever you are using to do the hover |
12,127 | <p>I'm currently implementing wp_nav_menu - all has gone well save for dynamic highlighting. The menu code looks like this (when home, which is a custom link, is selected): </p>
<pre><code><div class="menu-header">
<ul class="menu" id="menu-main-nav">
<li class="menu-item menu-item-type-custom menu-item... | [
{
"answer_id": 12138,
"author": "Arnold",
"author_id": 3283,
"author_profile": "https://wordpress.stackexchange.com/users/3283",
"pm_score": -1,
"selected": false,
"text": "<p>In my themes I make use of the custom menus. As a fall-back menu I use the following code in my functions.php:</... | 2011/03/15 | [
"https://wordpress.stackexchange.com/questions/12127",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3782/"
] | I'm currently implementing wp\_nav\_menu - all has gone well save for dynamic highlighting. The menu code looks like this (when home, which is a custom link, is selected):
```
<div class="menu-header">
<ul class="menu" id="menu-main-nav">
<li class="menu-item menu-item-type-custom menu-item-object-custom menu-item-12... | I achieved this with some jQuery:
```
$("#sidebar ul li").each(function () {
if ($(this).find("a").attr("href") == window.location.href) {
$(this).addClass("current-menu-item");
}
});
```
(My nav is in a div with the id 'sidebar', you will need to change the first selector).
It checks if the href... |
12,147 | <p>How do I output the current category title for each specific post?</p>
<pre><code> <?php query_posts('category_name=group&posts_per_page=10'); ?>
<?php if (have_posts()) : $counter = 0; ?>
<?php while (have_posts()) : the_post(); ?>
... | [
{
"answer_id": 12150,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 0,
"selected": false,
"text": "<p>Assuming that each post has only one child category then:</p>\n\n<pre><code>$parent_category_id = 12;\n <?... | 2011/03/15 | [
"https://wordpress.stackexchange.com/questions/12147",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3899/"
] | How do I output the current category title for each specific post?
```
<?php query_posts('category_name=group&posts_per_page=10'); ?>
<?php if (have_posts()) : $counter = 0; ?>
<?php while (have_posts()) : the_post(); ?>
<div <?php if($wp_query->current_p... | This is the simplest answer I could find so far:
$category = get\_the\_category(); echo $category[0]-> cat\_name; |
12,152 | <p>I want to show only today's or current date post in my blog.<br>
Here is my code but it's not working. </p>
<pre><code><?php
$day = date('j');
query_posts('day='.$day);
if (have_posts()) :
while (have_posts()) : the_post();
?>
<h3><a href="<?php the_permalink() ?>" rel="bookmark" tit... | [
{
"answer_id": 12215,
"author": "t31os",
"author_id": 31073,
"author_profile": "https://wordpress.stackexchange.com/users/31073",
"pm_score": 0,
"selected": false,
"text": "<p>I think you'll need to set the month and year also(possibly), see the <a href=\"http://codex.wordpress.org/Funct... | 2011/03/15 | [
"https://wordpress.stackexchange.com/questions/12152",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I want to show only today's or current date post in my blog.
Here is my code but it's not working.
```
<?php
$day = date('j');
query_posts('day='.$day);
if (have_posts()) :
while (have_posts()) : the_post();
?>
<h3><a href="<?php the_permalink() ?>" rel="bookmark" title="view: <?php the_title(); ?>"><?p... | This should do the trick:
```
<?php
$day = date('Ymd');
query_posts("m=$day");
```
The query arg `'m'` for WordPress will be interpreted as a year if it is four characters long, a month if 6, and a date if 8.
EDIT
----
You should probably add in the original query string just in case you're writing enough to need ... |
12,161 | <p>I have to get specific page content (like page(12))</p>
<p>I used that : </p>
<pre><code> <?php $id=47; $post = get_page($id); echo $post->post_content; ?>
</code></pre>
<p>Work nice execpt for compatibility with qtranslate it return french and english text</p>
<p>But the loop is fine, return only th... | [
{
"answer_id": 12162,
"author": "stffn",
"author_id": 1844,
"author_profile": "https://wordpress.stackexchange.com/users/1844",
"pm_score": 2,
"selected": false,
"text": "<p>You can use <code>get_page</code>, like so:</p>\n\n<p><a href=\"http://codex.wordpress.org/Function_Reference/get_... | 2011/03/15 | [
"https://wordpress.stackexchange.com/questions/12161",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3969/"
] | I have to get specific page content (like page(12))
I used that :
```
<?php $id=47; $post = get_page($id); echo $post->post_content; ?>
```
Work nice execpt for compatibility with qtranslate it return french and english text
But the loop is fine, return only the good language version
```
<?php if(have_posts()... | Here is the solution i have founs that work fine...the codex should be more specific about the apply\_filter ... used it all everytime
```
$id=47;
$post = get_page($id);
$content = apply_filters('the_content', $post->post_content);
echo $content;
```
But i have found a great place to ask question (HERE)! thanks guys... |
12,163 | <p>I have installed the <a href="http://wordpress.org/extend/plugins/google-analyticator/">Google Analyticator plugin</a> on my site. I am also using the <a href="http://wordpress.org/extend/plugins/mobilepress/">MobilePress plugin</a> to serve up a theme designed for non-smart-phone mobile browsers. I have set up <a h... | [
{
"answer_id": 12165,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 6,
"selected": true,
"text": "<p>When WordPress activates a plugin, it calls the <code>activate_plugin()</code> function. This function activates the ... | 2011/03/15 | [
"https://wordpress.stackexchange.com/questions/12163",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1756/"
] | I have installed the [Google Analyticator plugin](http://wordpress.org/extend/plugins/google-analyticator/) on my site. I am also using the [MobilePress plugin](http://wordpress.org/extend/plugins/mobilepress/) to serve up a theme designed for non-smart-phone mobile browsers. I have set up [Google Analytics for Mobile]... | When WordPress activates a plugin, it calls the `activate_plugin()` function. This function activates the plugin in a sandbox and redirects somewhere else on success. It's been used by a few authors to programmatically activate plugin dependencies.
There's another function, **[`deactivate_plugins()`](https://developer... |
12,171 | <p>Haven’t slept in about 30 hours now, can someone please help as the below code doesn’t work, it just displays all posts etc :|</p>
<pre><code><?php $args = array
(
'page' => array(139, 54)
);
$loopy = new WP_Query($args);
while ($loopy->have_posts()) : $loopy->the_post(); ?>
... | [
{
"answer_id": 12172,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p><code>page</code> is not an accepted parameter for WP_query , you can use <code>page_id</code> but that does... | 2011/03/16 | [
"https://wordpress.stackexchange.com/questions/12171",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18051/"
] | Haven’t slept in about 30 hours now, can someone please help as the below code doesn’t work, it just displays all posts etc :|
```
<?php $args = array
(
'page' => array(139, 54)
);
$loopy = new WP_Query($args);
while ($loopy->have_posts()) : $loopy->the_post(); ?>
<div class="item"><?php the_t... | `page` is not an accepted parameter for WP\_query , you can use `page_id` but that doesn't accept an array , only one specific ID, so just use `post__in` like this:
```
<?php $args = array(
'post__in' => array(139, 54)
);
$loopy = new WP_Query($args);
while ($loopy->have_posts()) : $loopy->the_post(); ?... |
12,177 | <p>[box id='1' text="some texte"]</p>
<p>the shortcode, at one point is outputting text</p>
<p>the html result is : <code></p> some text </p></code></p>
<p>There is an extra closing paragraph in the start and and opening at the end... WHY ?</p>
<p>where those come from ?.... any idea ?.. it screw my w3 ... | [
{
"answer_id": 12179,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 0,
"selected": false,
"text": "<p>Make sure there is a double line-break before <strong>and</strong> after the shortcode in the editor;</p>\n... | 2011/03/16 | [
"https://wordpress.stackexchange.com/questions/12177",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3969/"
] | [box id='1' text="some texte"]
the shortcode, at one point is outputting text
the html result is : `</p> some text </p>`
There is an extra closing paragraph in the start and and opening at the end... WHY ?
where those come from ?.... any idea ?.. it screw my w3 validation !
\*\* note i have found that... but look ... | I discover that it's a know bug, and will be fix in future release [Reference here](http://core.trac.wordpress.org/ticket/12061) So then, i used this code... not pretty, but do the magic !, thanks
```
$content = do_shortcode( shortcode_unautop( $content ) );
if ( '</p>' == substr( $content, 0, 4 )
and '<p>' == substr(... |
12,189 | <p>I recently learned that if you have WordPress.com Stats installed, you can take advantage of <code>stats_get_csv()</code> (Part of the <a href="http://wordpress.org/extend/plugins/stats/" rel="nofollow">WordPress.com Stats Plugin</a>).</p>
<pre><code><?php if ( function_exists('stats_get_csv') && $top_po... | [
{
"answer_id": 12191,
"author": "Lea Cohen",
"author_id": 373,
"author_profile": "https://wordpress.stackexchange.com/users/373",
"pm_score": 1,
"selected": false,
"text": "<p>As to the excluding pages, if you have only a few pages, you can do it <a href=\"http://wordpress.org/support/to... | 2011/03/16 | [
"https://wordpress.stackexchange.com/questions/12189",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3714/"
] | I recently learned that if you have WordPress.com Stats installed, you can take advantage of `stats_get_csv()` (Part of the [WordPress.com Stats Plugin](http://wordpress.org/extend/plugins/stats/)).
```
<?php if ( function_exists('stats_get_csv') && $top_posts = stats_get_csv('postviews', 'days=-1&limit=4') ) : ?>
... | The API returns the following columns when you query the `postviews` table:
* date
* post\_id
* post\_title
* post\_permalink
* views
For my blog the `post_id` column was either empty or `0` (for the homepage). So unless you have good values there, you will have to work from the `post_permalink` value and determine w... |
12,190 | <p>I log in and do all the administration over https in my wordpress blog (my own installation). When I publish something, I have the problem that the twitter plugins normally pick the current URL, with https:// instead of http:// (I'm currently using WP->Twitter).</p>
<p>When accessed over https:// my page issues som... | [
{
"answer_id": 12198,
"author": "Roman",
"author_id": 3817,
"author_profile": "https://wordpress.stackexchange.com/users/3817",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think that the publish-action in your twitter plugin is your problem. You probably have a twitter widget o... | 2011/03/16 | [
"https://wordpress.stackexchange.com/questions/12190",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7928/"
] | I log in and do all the administration over https in my wordpress blog (my own installation). When I publish something, I have the problem that the twitter plugins normally pick the current URL, with https:// instead of http:// (I'm currently using WP->Twitter).
When accessed over https:// my page issues some warning ... | I don't think that the publish-action in your twitter plugin is your problem. You probably have a twitter widget or something similar, which will display your twitter posts/status on your blog page.
Twitter access his API with a javascript library. Look in your sourcecode. In the HTML HEAD Element, you should see a c... |