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 |
|---|---|---|---|---|---|---|
27,088 | <p>I need a duplicate of <code>index.php</code>, but slightly modified. I added a "vote it up" plugin. So, I want the user to select how to display posts - by new or by popular. I know what to add to second <code>index.php</code>, but how to create a second <code>index.php</code>, thats the problem. </p>
| [
{
"answer_id": 27086,
"author": "Evan Yeung",
"author_id": 1878,
"author_profile": "https://wordpress.stackexchange.com/users/1878",
"pm_score": 1,
"selected": false,
"text": "<p>Try changing your <code>display_url_info</code> function to </p>\n\n<pre><code><?php\nadd_filter('beernews... | 2011/08/27 | [
"https://wordpress.stackexchange.com/questions/27088",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8196/"
] | I need a duplicate of `index.php`, but slightly modified. I added a "vote it up" plugin. So, I want the user to select how to display posts - by new or by popular. I know what to add to second `index.php`, but how to create a second `index.php`, thats the problem. | Try changing your `display_url_info` function to
```
<?php
add_filter('beernews-child-theme_post', 'display_url_info');
function display_url_info() {
// usually needed
global $basic_metabox;
$basic = $basic_metabox->the_meta();
if($basic['post_link_url']) {
echo $basic['post_link_url'];
... |
27,096 | <p><strong>* edit *</strong> - Pretty new to wordpress here and I've been working on getting post-thumbnails working using featured images...My goal is to quickly apply the featured image as a post thumbnail, regardless of which theme I am using....I've been editing the Twenty Eleven theme and it seems that the featur... | [
{
"answer_id": 27086,
"author": "Evan Yeung",
"author_id": 1878,
"author_profile": "https://wordpress.stackexchange.com/users/1878",
"pm_score": 1,
"selected": false,
"text": "<p>Try changing your <code>display_url_info</code> function to </p>\n\n<pre><code><?php\nadd_filter('beernews... | 2011/08/28 | [
"https://wordpress.stackexchange.com/questions/27096",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6559/"
] | **\* edit \*** - Pretty new to wordpress here and I've been working on getting post-thumbnails working using featured images...My goal is to quickly apply the featured image as a post thumbnail, regardless of which theme I am using....I've been editing the Twenty Eleven theme and it seems that the featured images only ... | Try changing your `display_url_info` function to
```
<?php
add_filter('beernews-child-theme_post', 'display_url_info');
function display_url_info() {
// usually needed
global $basic_metabox;
$basic = $basic_metabox->the_meta();
if($basic['post_link_url']) {
echo $basic['post_link_url'];
... |
27,098 | <p>I am using the GD Star plugin to monitor what people are rating the apps located on my site, <a href="http://tablified.com" rel="nofollow">http://tablified.com</a>. I want to place the widgets (the ones that tell me which of the apps are top rated) side by side but unfortunately I can only place the widgets on top o... | [
{
"answer_id": 27086,
"author": "Evan Yeung",
"author_id": 1878,
"author_profile": "https://wordpress.stackexchange.com/users/1878",
"pm_score": 1,
"selected": false,
"text": "<p>Try changing your <code>display_url_info</code> function to </p>\n\n<pre><code><?php\nadd_filter('beernews... | 2011/08/28 | [
"https://wordpress.stackexchange.com/questions/27098",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8203/"
] | I am using the GD Star plugin to monitor what people are rating the apps located on my site, <http://tablified.com>. I want to place the widgets (the ones that tell me which of the apps are top rated) side by side but unfortunately I can only place the widgets on top of each other. Is there any way I can force them to ... | Try changing your `display_url_info` function to
```
<?php
add_filter('beernews-child-theme_post', 'display_url_info');
function display_url_info() {
// usually needed
global $basic_metabox;
$basic = $basic_metabox->the_meta();
if($basic['post_link_url']) {
echo $basic['post_link_url'];
... |
27,102 | <p>I can't get <code>get_next_posts_link</code> to work. shouldn't his code work?</p>
<pre><code><?php echo get_next_posts_link(); ?>
</code></pre>
<p>Well, I am trying to get next 5 posts, any idea how?</p>
<p>EDIT:
Accroding to:</p>
<pre><code><?php next_post_link('<strong>%link</strong>', '... | [
{
"answer_id": 27110,
"author": "Jeremy Jared",
"author_id": 5339,
"author_profile": "https://wordpress.stackexchange.com/users/5339",
"pm_score": 2,
"selected": false,
"text": "<p>Use this for a <strong>link to previous posts with directional arrows</strong>:</p>\n\n<pre><code><?php ... | 2011/08/28 | [
"https://wordpress.stackexchange.com/questions/27102",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5031/"
] | I can't get `get_next_posts_link` to work. shouldn't his code work?
```
<?php echo get_next_posts_link(); ?>
```
Well, I am trying to get next 5 posts, any idea how?
EDIT:
Accroding to:
```
<?php next_post_link('<strong>%link</strong>', '%title', TRUE); ?>
```
Should show me a link to next post in the same cate... | Use this for a **link to previous posts with directional arrows**:
```
<?php previous_post_link(); ?>
```
Or this for a **link to previous posts that without "*<<*"**:
```
<?php previous_post_link('<strong>%link</strong>'); ?>
```
The code needs to be inside the loop. |
27,104 | <p>1) My site has posts, and 2 custom post types (news & essays)
2) They all share normal categories like sports & health (no custom taxanomy involved)
3) Using the generic category.php template, how do I make it so this template handles all categories while displaying all content falling under it regardless of... | [
{
"answer_id": 27108,
"author": "Michal Mau",
"author_id": 2110,
"author_profile": "https://wordpress.stackexchange.com/users/2110",
"pm_score": 4,
"selected": true,
"text": "<p>Take a look at the <a href=\"http://codex.wordpress.org/Function_Reference/query_posts\">query_posts()</a> fun... | 2011/08/28 | [
"https://wordpress.stackexchange.com/questions/27104",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8216/"
] | 1) My site has posts, and 2 custom post types (news & essays)
2) They all share normal categories like sports & health (no custom taxanomy involved)
3) Using the generic category.php template, how do I make it so this template handles all categories while displaying all content falling under it regardless of content po... | Take a look at the [query\_posts()](http://codex.wordpress.org/Function_Reference/query_posts) function - your amigo for altering the main/default query. You want to call global `$wp_query` beforehand to alter the original query instead of replacing it.
Something like this should do the trick for you. Put the first fo... |
27,115 | <p>I'm developing a theme settings panel for a new wordpress theme that have an option to exclude categories from being shown in the loop. I managed to get the main functionality to work, using a mutilselect box and saving the values as array ...</p>
<pre><code><?php $cats = get_categories('hide_empty=0&orderby... | [
{
"answer_id": 27131,
"author": "chrisguitarguy",
"author_id": 6035,
"author_profile": "https://wordpress.stackexchange.com/users/6035",
"pm_score": 3,
"selected": true,
"text": "<p>I'm assuming your <code>$selected</code> variable contains an array of values for the currently selected i... | 2011/08/28 | [
"https://wordpress.stackexchange.com/questions/27115",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8220/"
] | I'm developing a theme settings panel for a new wordpress theme that have an option to exclude categories from being shown in the loop. I managed to get the main functionality to work, using a mutilselect box and saving the values as array ...
```
<?php $cats = get_categories('hide_empty=0&orderby=name'); ?>
<select n... | I'm assuming your `$selected` variable contains an array of values for the currently selected items?
You can't use selected in this case (with multi select boxes) because it only compares two strings. It won't test to see if the value is in an array. Instead, use a ternary statement and [`in_array()`](http://php.net/m... |
27,116 | <p>I tried tplacing this:</p>
<pre><code> <?php $count = count($custom_posts); ?>
<h2><?php echo $count; ?></h2>
</code></pre>
<p>at the end of the loop:</p>
<pre><code> <?php if ( bbp_get_forum_title() == 'Test Forum 1' ) : ?>
<?php $custom_posts = new WP_Que... | [
{
"answer_id": 27117,
"author": "Manny Fleurmond",
"author_id": 2234,
"author_profile": "https://wordpress.stackexchange.com/users/2234",
"pm_score": 8,
"selected": true,
"text": "<p>Correct way of getting the total number of posts is:</p>\n\n<pre><code><?php $count = $custom_posts-&g... | 2011/08/28 | [
"https://wordpress.stackexchange.com/questions/27116",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/781/"
] | I tried tplacing this:
```
<?php $count = count($custom_posts); ?>
<h2><?php echo $count; ?></h2>
```
at the end of the loop:
```
<?php if ( bbp_get_forum_title() == 'Test Forum 1' ) : ?>
<?php $custom_posts = new WP_Query(); ?>
<?php $custom_posts->query('post_type=blocks&loca... | Correct way of getting the total number of posts is:
```
<?php $count = $custom_posts->found_posts; ?>
```
<http://codex.wordpress.org/Class_Reference/WP_Query#Properties>
Edit: acknowledging @Kresimir Pendic's answer as probably correct. `post_count` is the count of posts for that particular page, while `found_pos... |
27,119 | <p>A lot of my theme's image pages are ranking on Google. I'd like to remove these pages entirely from my theme so they no longer rank. When a user hits these image pages the content is taken out of context and looks very confusing.</p>
<p>Here is an example of a ranking image page: <a href="http://www.barbadospropert... | [
{
"answer_id": 27129,
"author": "Jeremy Jared",
"author_id": 5339,
"author_profile": "https://wordpress.stackexchange.com/users/5339",
"pm_score": 0,
"selected": false,
"text": "<p>There are a few options you can choose. Depending on how your theme is set up. </p>\n\n<p>If I understand y... | 2011/08/28 | [
"https://wordpress.stackexchange.com/questions/27119",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1341/"
] | A lot of my theme's image pages are ranking on Google. I'd like to remove these pages entirely from my theme so they no longer rank. When a user hits these image pages the content is taken out of context and looks very confusing.
Here is an example of a ranking image page: <http://www.barbadospropertylist.com/2011/08/... | Google is finding those pages because you're linking to them. Most likely this happens when you use the media uploader and hit the "insert into post" button. Unless you tell it otherwise, WP will link to the attachment page intead of the image file. So head to your pages and remove the links to attachment pages.
I wou... |
27,120 | <p>I'm using custom post types in WordPress 3.0 (now 3.0.1) to setup a custom directory system, but can't seem to find how to list out the categories under the custom taxonomy similar to how you'd use the <code>wp_list_categories</code> for normal posts. Anyone know how you'd do this on a page? Thanks!</p>
<p>I've see... | [
{
"answer_id": 27121,
"author": "Jan Fabry",
"author_id": 8,
"author_profile": "https://wordpress.stackexchange.com/users/8",
"pm_score": 2,
"selected": false,
"text": "<p>Are you sure you called <code>register_taxonomy</code> before you called <code>wp_list_categories</code>? <code>regi... | 2010/07/30 | [
"https://wordpress.stackexchange.com/questions/27120",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I'm using custom post types in WordPress 3.0 (now 3.0.1) to setup a custom directory system, but can't seem to find how to list out the categories under the custom taxonomy similar to how you'd use the `wp_list_categories` for normal posts. Anyone know how you'd do this on a page? Thanks!
I've seen suggestions for opt... | Are you sure you called `register_taxonomy` before you called `wp_list_categories`? `register_taxonomy` should be called in the `init` action hook, your template code (I assume you use it there) after that. |
27,141 | <p>Is there a way to query posts which <strong>do not</strong> have tags assigned to them?</p>
<pre><code>query_posts('tag='tag_exmaple'&posts_per_page=-1');
</code></pre>
<p>Ty very much!</p>
| [
{
"answer_id": 27143,
"author": "tollmanz",
"author_id": 4850,
"author_profile": "https://wordpress.stackexchange.com/users/4850",
"pm_score": 0,
"selected": false,
"text": "<p>You could get an array of all of the tag ids and send it to the \"tag__not_in\" parameter. Not the most elegant... | 2011/08/28 | [
"https://wordpress.stackexchange.com/questions/27141",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2979/"
] | Is there a way to query posts which **do not** have tags assigned to them?
```
query_posts('tag='tag_exmaple'&posts_per_page=-1');
```
Ty very much! | Either use the `tag_not_in` parameter if you have the tag id and if not then you can use `tax_query` parameter like so:
```
$tag_to_exclude = 'example_tag';
$args = array(
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'post_tag',
'field' => 'slug',
'term... |
27,144 | <p>Do you guys know any way I could automatically pick up strings from .xml files and store them in a .po / .pot file, just like PoEdit does with the ones from .php files?</p>
<p>The XML structure looks like this:</p>
<pre><code><?xml version="1.0" encoding="iso-8859-1"?>
<options>
<page id="content"... | [
{
"answer_id": 27143,
"author": "tollmanz",
"author_id": 4850,
"author_profile": "https://wordpress.stackexchange.com/users/4850",
"pm_score": 0,
"selected": false,
"text": "<p>You could get an array of all of the tag ids and send it to the \"tag__not_in\" parameter. Not the most elegant... | 2011/08/28 | [
"https://wordpress.stackexchange.com/questions/27144",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1986/"
] | Do you guys know any way I could automatically pick up strings from .xml files and store them in a .po / .pot file, just like PoEdit does with the ones from .php files?
The XML structure looks like this:
```
<?xml version="1.0" encoding="iso-8859-1"?>
<options>
<page id="content" label="Content Options" icon="4">
... | Either use the `tag_not_in` parameter if you have the tag id and if not then you can use `tax_query` parameter like so:
```
$tag_to_exclude = 'example_tag';
$args = array(
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'post_tag',
'field' => 'slug',
'term... |
27,158 | <p>From few months I am digging into wordpress for multiple category search options, and finally came up with this.</p>
<p>I just found that wordpress allows multiple tags, which means that if in your URL you type this</p>
<pre><code>http://yourblog.com/tag/tag1+tag2
</code></pre>
<p>then it will return all your pos... | [
{
"answer_id": 27331,
"author": "Anh Tran",
"author_id": 2051,
"author_profile": "https://wordpress.stackexchange.com/users/2051",
"pm_score": 1,
"selected": false,
"text": "<p>Try this: <code>http://yourblog.com/?s=html&cat[]=114&cat[]=115</code></p>\n\n<p>BTW, why don't you use... | 2011/08/29 | [
"https://wordpress.stackexchange.com/questions/27158",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1743/"
] | From few months I am digging into wordpress for multiple category search options, and finally came up with this.
I just found that wordpress allows multiple tags, which means that if in your URL you type this
```
http://yourblog.com/tag/tag1+tag2
```
then it will return all your posts with having tags, tag1 **AND**... | The problem is that in a url the '+' sign is equivalent to a space so that's how PHP sees it.
If you use an action on `parse_request` you can make this work like so:
```
add_action( 'parse_request', 'category_search_logic', 11 );
function category_search_logic( $query ) {
if ( ! isset( $query->query_vars[ 'cat' ... |
27,168 | <p>i want to display all posts as well as count the days of the post since it was published</p>
<pre><code>if ($pageposts):
foreach ($pageposts as $post):
setup_postdata($post);
echo '<p>';
the_title();
echo '</p>';
endforeach;
endif;
</code></pre>
<p>Output should be something lik... | [
{
"answer_id": 27169,
"author": "petermolnar",
"author_id": 4209,
"author_profile": "https://wordpress.stackexchange.com/users/4209",
"pm_score": 0,
"selected": false,
"text": "<p>There's a small thread in <a href=\"http://wordpress.org/support/topic/automatically-delete-posts-after-x-nu... | 2011/08/29 | [
"https://wordpress.stackexchange.com/questions/27168",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8008/"
] | i want to display all posts as well as count the days of the post since it was published
```
if ($pageposts):
foreach ($pageposts as $post):
setup_postdata($post);
echo '<p>';
the_title();
echo '</p>';
endforeach;
endif;
```
Output should be something like this
Post Title1 - This post is pub... | Use <http://wordpress.org/extend/plugins/simple-expires/> |
27,175 | <p>I am developing a plugin, but during the activation phrase I am constantly facing bugs. However there is no easy way to display error messages, since echoing stuff would result in 'unexpacted output' error. I tried the admin_message hook but it doesn't work. How can I alert the user if some stage of the activation h... | [
{
"answer_id": 27261,
"author": "Domingos Freitas",
"author_id": 8268,
"author_profile": "https://wordpress.stackexchange.com/users/8268",
"pm_score": 4,
"selected": true,
"text": "<p>For testing purposes you can use the log system (php_error.log):</p>\n\n<pre><code>error_log('Plugin act... | 2011/08/29 | [
"https://wordpress.stackexchange.com/questions/27175",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6858/"
] | I am developing a plugin, but during the activation phrase I am constantly facing bugs. However there is no easy way to display error messages, since echoing stuff would result in 'unexpacted output' error. I tried the admin\_message hook but it doesn't work. How can I alert the user if some stage of the activation has... | For testing purposes you can use the log system (php\_error.log):
```
error_log('Plugin activated', 0);
// Check for DB table existance
if(!$this->hasDBTable()){
error_log('Database not present', 0);
if($this->createCELabelsDBTables()){
error_log('Database was created.', 0);
} else {
error... |
27,177 | <p>I'm developing a simple plugin for letting a user insert a post from the frontend.</p>
<p>I have a shortcode [add-post] which a user can put on any page, say, for eg. My Wall Page</p>
<p>Now on My Wall Page a simple form comes up which has a title field, a content field and a category select field so that user can... | [
{
"answer_id": 27196,
"author": "helenhousandi",
"author_id": 2226,
"author_profile": "https://wordpress.stackexchange.com/users/2226",
"pm_score": 3,
"selected": true,
"text": "<p>You don't need to hook into an action for a shortcode - adding the shortcode using <code>add_shortcode()</c... | 2011/08/29 | [
"https://wordpress.stackexchange.com/questions/27177",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7767/"
] | I'm developing a simple plugin for letting a user insert a post from the frontend.
I have a shortcode [add-post] which a user can put on any page, say, for eg. My Wall Page
Now on My Wall Page a simple form comes up which has a title field, a content field and a category select field so that user can choose which cat... | You don't need to hook into an action for a shortcode - adding the shortcode using `add_shortcode()` will make it run when you call `the_content()`. That said, your function for your shortcode needs to **return** your output, not just echo it outright. Otherwise you will find that your form will appear much earlier tha... |
27,183 | <p>Both function returns date and time. What's the difference between them? Do you have any example? Thanks.</p>
| [
{
"answer_id": 27186,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": false,
"text": "<p>The <code>the_date()</code> template tag only outputs the post date once per occurrence; thus, if two or mo... | 2011/08/29 | [
"https://wordpress.stackexchange.com/questions/27183",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8242/"
] | Both function returns date and time. What's the difference between them? Do you have any example? Thanks. | They are, very similar but with some nuances:
```
function get_the_date( $d = '' ) {
global $post;
$the_date = '';
if ( '' == $d )
$the_date .= mysql2date(get_option('date_format'), $post->post_date);
else
$the_date .= mysql2date($d, $post->post_date);
return apply_filters('get_th... |
27,184 | <p>Many people report problems with pagination of custom queries or custom post type archives: url/page/2 produces a 404 even though all the setup is correct. </p>
<p>Many end up figuring out that this is occurring because the posts_per_page of their custom loop is less than the maximum posts per page setting in the a... | [
{
"answer_id": 28624,
"author": "Maciej Kuś",
"author_id": 8682,
"author_profile": "https://wordpress.stackexchange.com/users/8682",
"pm_score": 1,
"selected": false,
"text": "<p>I assume you have a custom post type: publication</p>\n\n<p>in functions.php place that code:</p>\n\n<pre><co... | 2011/08/29 | [
"https://wordpress.stackexchange.com/questions/27184",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3564/"
] | Many people report problems with pagination of custom queries or custom post type archives: url/page/2 produces a 404 even though all the setup is correct.
Many end up figuring out that this is occurring because the posts\_per\_page of their custom loop is less than the maximum posts per page setting in the admin, wh... | I assume you have a custom post type: publication
in functions.php place that code:
```
function mk_parse_query($query) {
if ($query->query_vars['post_type'] == 'publication')) {
set_query_var( 'posts_per_page', 5 );
}
}
if( !is_admin() ) {
add_filter('parse_query','mk_parse_query');
}
```
Similar c... |
27,204 | <p>The answers to <a href="https://wordpress.stackexchange.com/questions/578/adding-a-taxonomy-filter-to-admin-list-for-a-custom-post-type">this question</a> give excellent instructions for adding filters to the admin edit.php screen for custom post types. But they don't explain how to remove the existing filters on da... | [
{
"answer_id": 27242,
"author": "mfields",
"author_id": 11019,
"author_profile": "https://wordpress.stackexchange.com/users/11019",
"pm_score": 1,
"selected": false,
"text": "<p>I looked at this recently and couldn't really find a way other than hiding them via css.</p>\n"
},
{
"... | 2011/08/29 | [
"https://wordpress.stackexchange.com/questions/27204",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7381/"
] | The answers to [this question](https://wordpress.stackexchange.com/questions/578/adding-a-taxonomy-filter-to-admin-list-for-a-custom-post-type) give excellent instructions for adding filters to the admin edit.php screen for custom post types. But they don't explain how to remove the existing filters on date and categor... | To remove the dates:
```
function my_remove_date_filter( $months ) {
global $typenow; // use this to restrict it to a particular post type
if ( $typenow == 'post' ) {
return array(); // return an empty array
}
return $months; // otherwise return the original for other post types
}
add_filter('m... |
27,207 | <p>I am using a theme that comes with several different font stylings for headers and text. However there is no simple way to apply these classes inside the editor. How can I enable a drop down similar to TinyMCE that allows me to select text and apply a class/style to it in order to have my marketing and sales departm... | [
{
"answer_id": 27242,
"author": "mfields",
"author_id": 11019,
"author_profile": "https://wordpress.stackexchange.com/users/11019",
"pm_score": 1,
"selected": false,
"text": "<p>I looked at this recently and couldn't really find a way other than hiding them via css.</p>\n"
},
{
"... | 2011/08/29 | [
"https://wordpress.stackexchange.com/questions/27207",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8039/"
] | I am using a theme that comes with several different font stylings for headers and text. However there is no simple way to apply these classes inside the editor. How can I enable a drop down similar to TinyMCE that allows me to select text and apply a class/style to it in order to have my marketing and sales department... | To remove the dates:
```
function my_remove_date_filter( $months ) {
global $typenow; // use this to restrict it to a particular post type
if ( $typenow == 'post' ) {
return array(); // return an empty array
}
return $months; // otherwise return the original for other post types
}
add_filter('m... |
27,214 | <p>I'm having a small issue with one of my queries here. I cannot increase my wordpress memory limit as long as hostgator sets it to 64mb. I'm not sure if its possible to reduce the amount of memory used making some changes to my code, here is the code I'm using to query users from a specific role and displaying their ... | [
{
"answer_id": 27216,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<h3>Call author data</h3>\n\n<p>You could change your multiple <code>get_the_author_meta()</code> calls against a sing... | 2011/08/29 | [
"https://wordpress.stackexchange.com/questions/27214",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4248/"
] | I'm having a small issue with one of my queries here. I cannot increase my wordpress memory limit as long as hostgator sets it to 64mb. I'm not sure if its possible to reduce the amount of memory used making some changes to my code, here is the code I'm using to query users from a specific role and displaying their nam... | In your example, you are getting all the fields in the get\_users call, but you are only really using the ID and display\_name fields. So you can save some memory by forcing get\_users to only get the fields you need.
```
$users = get_users(array(
'role'=>'s2member_level3',
'fields'=>array('ID', 'display_name'),
... |
27,215 | <p>I searched on different Marketplaces so far, but haven't found anything that wouldn't take me hours or even days to make a wordpress theme from. </p>
<h3>Here's the list of things I need:</h3>
<p><strong>1.</strong> Slider or some photo gallery. Something fancy, eyecatching.</p>
<p><strong>2.</strong> (Ajax?) Con... | [
{
"answer_id": 27216,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<h3>Call author data</h3>\n\n<p>You could change your multiple <code>get_the_author_meta()</code> calls against a sing... | 2011/08/29 | [
"https://wordpress.stackexchange.com/questions/27215",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/385/"
] | I searched on different Marketplaces so far, but haven't found anything that wouldn't take me hours or even days to make a wordpress theme from.
### Here's the list of things I need:
**1.** Slider or some photo gallery. Something fancy, eyecatching.
**2.** (Ajax?) Contact Form (minor issue - got some small plugin c... | In your example, you are getting all the fields in the get\_users call, but you are only really using the ID and display\_name fields. So you can save some memory by forcing get\_users to only get the fields you need.
```
$users = get_users(array(
'role'=>'s2member_level3',
'fields'=>array('ID', 'display_name'),
... |
27,232 | <p>I want to serve a dynamically-generated PDF with a "File Transfer" header </p>
<pre><code>header('Content-Description: File Transfer');
</code></pre>
<p>However, before I generate the document I need to verify the user's login and credentials. </p>
<pre><code>if(is_user_logged_in()){
$currentUser = wp_get_c... | [
{
"answer_id": 27233,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>There are multiple approaches to do such:</p>\n\n<ul>\n<li>page template</li>\n<li>Ajax action</li>\n<li>custom hand... | 2011/08/29 | [
"https://wordpress.stackexchange.com/questions/27232",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8257/"
] | I want to serve a dynamically-generated PDF with a "File Transfer" header
```
header('Content-Description: File Transfer');
```
However, before I generate the document I need to verify the user's login and credentials.
```
if(is_user_logged_in()){
$currentUser = wp_get_current_user();
$userLogin = $curr... | I think you mean the [`Content-Disposition`](https://www.rfc-editor.org/rfc/rfc6266) header.
I recently did a very similar thing for a client. My weapon of choice: custom rewrite rules.
First, add the rewrite:
```
<?php
add_action( 'init', 'wpse27232_add_rewrite' );
/**
* Adds the rewrite rule for the download.
* ... |
27,234 | <p>My writer has a tendency to add extra newlines (Enter key) and spaces (space bar) at the ends of posts. Sometimes this results in inches of extra whitespace onscreen!</p>
<p>Is there a way I can make sure extra trailing whitespace is removed when he hits "Update" in the Wordpress post editor?</p>
| [
{
"answer_id": 27236,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 4,
"selected": true,
"text": "<p>Quick guess would be:</p>\n\n<pre><code>add_filter('content_save_pre', 'trim');\n</code></pre>\n\n<p>Add to <code>fun... | 2011/08/29 | [
"https://wordpress.stackexchange.com/questions/27234",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8256/"
] | My writer has a tendency to add extra newlines (Enter key) and spaces (space bar) at the ends of posts. Sometimes this results in inches of extra whitespace onscreen!
Is there a way I can make sure extra trailing whitespace is removed when he hits "Update" in the Wordpress post editor? | Quick guess would be:
```
add_filter('content_save_pre', 'trim');
```
Add to `functions.php` of theme or wherever is appropriate in your site. |
27,248 | <p>How can I prevent my plugin updates from clobbering the user edits and file additions in a particular subdirectory of my plugin?</p>
<p>I wrote a syntax highlighting plugin that makes use of GeSHi. A sub folder of the plugin is GeSHi itself. Many users will want to customize / edit the language files within GeSHi.<... | [
{
"answer_id": 27249,
"author": "chrisguitarguy",
"author_id": 6035,
"author_profile": "https://wordpress.stackexchange.com/users/6035",
"pm_score": 1,
"selected": false,
"text": "<p>Don't allow your users to add files or edit your files.</p>\n\n<p>Instead, use things like <code>do_actio... | 2011/08/30 | [
"https://wordpress.stackexchange.com/questions/27248",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7102/"
] | How can I prevent my plugin updates from clobbering the user edits and file additions in a particular subdirectory of my plugin?
I wrote a syntax highlighting plugin that makes use of GeSHi. A sub folder of the plugin is GeSHi itself. Many users will want to customize / edit the language files within GeSHi.
Specifica... | Don't allow your users to add files or edit your files.
Instead, use things like `do_action` and `apply_filters` like the WordPress core does.
I'm not familiar with GeSHi, but I would suggest you figure out where in the class it loads the file required for the language. Modify the file path so it looks something like... |
27,264 | <p>I want to create a custom menu in the style below, can this be done? The code in brackets needs to grab the actual page content for each page.</p>
<pre><code><div class="menu-button-(page-name)">
<a href="(page-link)">(page-name)</a>
</div>
</code></pre>
<p>How can I use that one small bit ... | [
{
"answer_id": 27249,
"author": "chrisguitarguy",
"author_id": 6035,
"author_profile": "https://wordpress.stackexchange.com/users/6035",
"pm_score": 1,
"selected": false,
"text": "<p>Don't allow your users to add files or edit your files.</p>\n\n<p>Instead, use things like <code>do_actio... | 2011/08/30 | [
"https://wordpress.stackexchange.com/questions/27264",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4588/"
] | I want to create a custom menu in the style below, can this be done? The code in brackets needs to grab the actual page content for each page.
```
<div class="menu-button-(page-name)">
<a href="(page-link)">(page-name)</a>
</div>
```
How can I use that one small bit of code to create my menu? That code should genera... | Don't allow your users to add files or edit your files.
Instead, use things like `do_action` and `apply_filters` like the WordPress core does.
I'm not familiar with GeSHi, but I would suggest you figure out where in the class it loads the file required for the language. Modify the file path so it looks something like... |
27,275 | <p>I have a plugin that has a top level menu and subsequent submenus. Each one of these pages are going to need their own css and javascript. My code at the moment is:</p>
<pre><code>//main menu
add_menu_page( "My Business", "My Business", "contributor", "fbusiness", array($fmb_admin, "get_page"));
//sub menus
add_sub... | [
{
"answer_id": 27276,
"author": "Dunhamzzz",
"author_id": 3669,
"author_profile": "https://wordpress.stackexchange.com/users/3669",
"pm_score": 2,
"selected": false,
"text": "<p>Use the <code>admin_head</code> hook and just echo out what you need to:</p>\n\n<pre><code>function my_admin_h... | 2011/08/30 | [
"https://wordpress.stackexchange.com/questions/27275",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8404/"
] | I have a plugin that has a top level menu and subsequent submenus. Each one of these pages are going to need their own css and javascript. My code at the moment is:
```
//main menu
add_menu_page( "My Business", "My Business", "contributor", "fbusiness", array($fmb_admin, "get_page"));
//sub menus
add_submenu_page("fat... | Sorry for the late reply on this but here is the answer. In order to have custom css for each of my sub-menu admin pages my code needs to be like this:
```
//main menu
add_menu_page( "My Business", "My Business", "contributor", "site-business", array($fmb_admin, "get_page"));
//sub menus
$page = add_submenu_page(... |
27,323 | <pre><code> $response = wp_remote_post( 'ssl://securesite.com', array(
'method' => 'POST',
'body' => $string, // variable is set
'timeout' => apply_filters( 'http_request_timeout', 15),
'sslverify' => true
));
error_log(print_r($response, TRUE));
if ( is_wp_e... | [
{
"answer_id": 27322,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 5,
"selected": false,
"text": "<p>File manipulation and shell scripting is not often what you do <strong>with</strong> WordPress. At most something yo... | 2011/08/30 | [
"https://wordpress.stackexchange.com/questions/27323",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8286/"
] | ```
$response = wp_remote_post( 'ssl://securesite.com', array(
'method' => 'POST',
'body' => $string, // variable is set
'timeout' => apply_filters( 'http_request_timeout', 15),
'sslverify' => true
));
error_log(print_r($response, TRUE));
if ( is_wp_error($response) ) {... | If I were to hire a WordPress developer, my wish list would look like this:
* Knows HTML and CSS inside and out;
* Has at least a basic grasp of JavaScript;
* Knows their way around PHP, and produces beautiful code (clean, consistent, [DRY](http://en.wikipedia.org/wiki/Don%27t_repeat_yourself))
* Has a good grasp of d... |
27,335 | <p>The only trick here: It is not my blog, I know how to do it using php in my blog. I want to find the id of a post on another wordpress blog through the internet. Does this information 'leak' somewhere, is it possible to be found by a third party?</p>
| [
{
"answer_id": 27337,
"author": "Devin Humbert",
"author_id": 7949,
"author_profile": "https://wordpress.stackexchange.com/users/7949",
"pm_score": 2,
"selected": true,
"text": "<p>Most themes that I've seen use the post ID as the ID of the wrapping div for a post on the home page, archi... | 2011/08/31 | [
"https://wordpress.stackexchange.com/questions/27335",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8293/"
] | The only trick here: It is not my blog, I know how to do it using php in my blog. I want to find the id of a post on another wordpress blog through the internet. Does this information 'leak' somewhere, is it possible to be found by a third party? | Most themes that I've seen use the post ID as the ID of the wrapping div for a post on the home page, archives, single post, etc. For example:
```
<div id="post-1920" class="post [...]">post content and meta</div>
```
So you could parse that with a regex or using something like [Simple HTML DOM](http://simplehtmldom... |
27,355 | <p>I believe that Wordpress will try to find a suitable URL if you enter a wrong one. So I have a page <a href="http://www.example.com/products/" rel="nofollow">http://www.example.com/products/</a> and by mistake I enter <a href="http://www.example.com/prods/" rel="nofollow">http://www.example.com/prods/</a> Wordpress ... | [
{
"answer_id": 27363,
"author": "Jeremy Jared",
"author_id": 5339,
"author_profile": "https://wordpress.stackexchange.com/users/5339",
"pm_score": 1,
"selected": false,
"text": "<p>WordPress doesn't automatically suggest pages when a 404 occurs. Many themes have a 404.php template file t... | 2011/08/31 | [
"https://wordpress.stackexchange.com/questions/27355",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5804/"
] | I believe that Wordpress will try to find a suitable URL if you enter a wrong one. So I have a page <http://www.example.com/products/> and by mistake I enter <http://www.example.com/prods/> Wordpress will probably automatically redirect.
I think that it is similar to the Multiviews option in apache. Can the Wordpress... | WordPress doesn't automatically suggest pages when a 404 occurs. Many themes have a 404.php template file that can effect what happens when an incorrect URL is entered. Maybe your theme has a 404 page. If you don't want it to interfere, you could try deleting the 404.php.
**REVISION:**
OK, I understand your request n... |
27,357 | <p>We have multiple wordpress sites and need to update the wp-config for w3 total cache. We have to append <code>define('WP_CACHE', true);</code> into the wp-config.php file. Is it possible to do this via ssh. I don't want to have to go in and open each config file and add it myself.</p>
<p>Your help will be much appr... | [
{
"answer_id": 27358,
"author": "drcelus",
"author_id": 8303,
"author_profile": "https://wordpress.stackexchange.com/users/8303",
"pm_score": 1,
"selected": false,
"text": "<p>This commands prepends a line at the beggining of <em>yourfile</em></p>\n\n<pre><code>sed -i 1i\"define('WP_CACH... | 2011/08/31 | [
"https://wordpress.stackexchange.com/questions/27357",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25519/"
] | We have multiple wordpress sites and need to update the wp-config for w3 total cache. We have to append `define('WP_CACHE', true);` into the wp-config.php file. Is it possible to do this via ssh. I don't want to have to go in and open each config file and add it myself.
Your help will be much appreciated. | This commands prepends a line at the beggining of *yourfile*
```
sed -i 1i"define('WP_CACHE', true);" yourfile
```
To look for many files named wp-config.php and prepend the same text, type this in the shell:
```
for i in $(find . -name wp-config.php)
do
sed -i 1i"define('<?php WP_CACHE', true); ?>" $i
done
```
... |
27,364 | <p>is this possible for 2 taxonomy and 2 terms</p>
<pre><code> $querystr = "
SELECT *
FROM $wpdb->posts
LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxon... | [
{
"answer_id": 27368,
"author": "kevin",
"author_id": 1997,
"author_profile": "https://wordpress.stackexchange.com/users/1997",
"pm_score": 0,
"selected": false,
"text": "<p>Here's a function i used to do a query with 2 custom taxonomies and 2 terms:</p>\n\n<p>in <strong><code>functions.... | 2011/08/31 | [
"https://wordpress.stackexchange.com/questions/27364",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8008/"
] | is this possible for 2 taxonomy and 2 terms
```
$querystr = "
SELECT *
FROM $wpdb->posts
LEFT JOIN $wpdb->term_relationships ON($wpdb->posts.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->term_taxonomy ON($wpdb->term_relationships.term_taxonomy_id = $wpdb->term_taxonomy.term_taxonomy_id)
LEFT JOIN $w... | I believe you can just use the WP\_Query method to query the database with a `tax_query` like so:
```
$my_query_args = array(
'post_type' => 'shows',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'location',
'field' => 'slug',
'terms' => 'ca... |
27,366 | <p>This is my first attempt at creating a child theme based off the WP twentyeleven theme.</p>
<p>To begin with, I am using MAMP on my mac and have the following directory structure:</p>
<pre><code> applications/MAMP/htdocs/mysite/wp-content/themes/twentyeleven/style.css
... | [
{
"answer_id": 27373,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 0,
"selected": false,
"text": "<p>Since:</p>\n\n<ol>\n<li>Twenty Eleven renders properly</li>\n<li>Your Child Theme is visible in <code>Dashb... | 2011/08/31 | [
"https://wordpress.stackexchange.com/questions/27366",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1053/"
] | This is my first attempt at creating a child theme based off the WP twentyeleven theme.
To begin with, I am using MAMP on my mac and have the following directory structure:
```
applications/MAMP/htdocs/mysite/wp-content/themes/twentyeleven/style.css
/mytwentyeleven/s... | your @import doesn't look malformed. this is what i have on a live site that is running a twenty eleven child theme.
```
/*
Theme Name: A Twenty Eleven Child Theme
Description: my child theme
Author: helgatheviking
Template: twentyeleven
Version: 1.0
*/
/* Reset browser defaults */
@import url('../twentyeleven/st... |
27,376 | <p>I am trying to add a functionality to mark a post's attachment id as a background image. Basically, I would like to replicate the post thumbnail functionality: in the image attachment details, the user would click on a "Use as post background" link / button, and that image would be set as the post background.</p>
<... | [
{
"answer_id": 27380,
"author": "kevin",
"author_id": 1997,
"author_profile": "https://wordpress.stackexchange.com/users/1997",
"pm_score": 0,
"selected": false,
"text": "<p>Here's how i did it:</p>\n\n<p>1- i created a post with a custom field name <code>bg-pic</code> and as a value i e... | 2011/08/31 | [
"https://wordpress.stackexchange.com/questions/27376",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3765/"
] | I am trying to add a functionality to mark a post's attachment id as a background image. Basically, I would like to replicate the post thumbnail functionality: in the image attachment details, the user would click on a "Use as post background" link / button, and that image would be set as the post background.
I've bee... | You could use the plugin "Custom Field Template" to replace standard custom fields with a much easier to use interface, that also allows you to use checkboxes, selects, textareas with tinymce, and file uploads among others.
Then the client would just upload the image through that field and you use
```
<?php
$bg = ... |
27,379 | <p>I'm displaying a lit of tags when they have a description. I'd like to sort them by name instead of by post quantity. Is there a way to do this?</p>
<pre><code><?php
$tags = get_tags();
if ($tags) {
foreach ($tags as $tag) {
if ($tag->description) {
echo '<dt><a href=... | [
{
"answer_id": 27515,
"author": "Jeremy Jared",
"author_id": 5339,
"author_profile": "https://wordpress.stackexchange.com/users/5339",
"pm_score": 0,
"selected": false,
"text": "<p>Try adding this code to your functions.php file as provided by <a href=\"https://stackoverflow.com/users/24... | 2011/08/31 | [
"https://wordpress.stackexchange.com/questions/27379",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3296/"
] | I'm displaying a lit of tags when they have a description. I'd like to sort them by name instead of by post quantity. Is there a way to do this?
```
<?php
$tags = get_tags();
if ($tags) {
foreach ($tags as $tag) {
if ($tag->description) {
echo '<dt><a href="' . get_tag_link( $tag->term... | Don't include %category% anywhere in your custom permalink string, then it won't need the
"attachment" text. Also, don't use numeric slugs for the page/post name. Same basic problem occurs there. |
27,385 | <p>I have a brilliant idea and since WordPress already takes care of some of the work, I just need to find a good method to make this work.</p>
<p>I am working on a project that needs to be responsive to all devices, whether a desktop PC or mobile gadget. Thus, I want the images to also be responsive, meaning that mob... | [
{
"answer_id": 27390,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": false,
"text": "<p>Step 1:</p>\n\n<p>Define two custom image sizes, e.g.:</p>\n\n<pre><code><?php\nadd_image_size( 'normal-... | 2011/08/31 | [
"https://wordpress.stackexchange.com/questions/27385",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6000/"
] | I have a brilliant idea and since WordPress already takes care of some of the work, I just need to find a good method to make this work.
I am working on a project that needs to be responsive to all devices, whether a desktop PC or mobile gadget. Thus, I want the images to also be responsive, meaning that mobile device... | Step 1:
Define two custom image sizes, e.g.:
```
<?php
add_image_size( 'normal-thumbnail', 400, 300, false ); // Default image size
add_image_size( 'mobile-device-thumbnail', 200, 150, false ); // Mobile-device image size
?>
```
Step 2:
Implement your chosen means to determine client. There are several ways, and w... |
27,386 | <p>I've been trying to utilize either <code>WP_Query</code> or <code>get_posts</code> to pull out the most recent post that's both in a specific category and of a specific post format.</p>
<pre><code><?php
$singargs = array(
'numberposts' => 1,
'tax_query' => array(
'relation' => 'AND',
array(
... | [
{
"answer_id": 27404,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 1,
"selected": false,
"text": "<p>Two problems i see:\nchange <code>aside</code> to <code>post-format-aside</code> \nand since you are using fo... | 2011/08/31 | [
"https://wordpress.stackexchange.com/questions/27386",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8315/"
] | I've been trying to utilize either `WP_Query` or `get_posts` to pull out the most recent post that's both in a specific category and of a specific post format.
```
<?php
$singargs = array(
'numberposts' => 1,
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'category',
'field' =... | Two problems i see:
change `aside` to `post-format-aside`
and since you are using foreach loop change `new WP_Query( $singargs );` to `get_posts( $singargs );` so your code sould look like this:
```
<?php
$singargs = array(
'numberposts' => 1,
'tax_query' => array(
'relation' => 'AND',
array(
'taxono... |
27,395 | <p>I want to remove the automatic paragraph tag that goes around my excerpts, which are being outputted by a custom function. I'd really appreciate if you could tell me what to add to my code.</p>
<p>I'm using this custom function for excerpts:</p>
<pre><code> // Default length (by WordPress)
public static $lengt... | [
{
"answer_id": 27394,
"author": "helenhousandi",
"author_id": 2226,
"author_profile": "https://wordpress.stackexchange.com/users/2226",
"pm_score": 1,
"selected": false,
"text": "<p>You could create a custom metabox with those items as custom fields and then either remove support for the... | 2011/08/31 | [
"https://wordpress.stackexchange.com/questions/27395",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5205/"
] | I want to remove the automatic paragraph tag that goes around my excerpts, which are being outputted by a custom function. I'd really appreciate if you could tell me what to add to my code.
I'm using this custom function for excerpts:
```
// Default length (by WordPress)
public static $length = 25;
// So you c... | You could create a custom metabox with those items as custom fields and then either remove support for the editor or hide it with CSS. Then output the post meta instead on the front end. Be aware that if you remove support for the editor, you'll have funky behavior with media attachments.
**Edit:** If you need a plugi... |
27,401 | <p>I installed a syntax highlighter plugin so I could post and highlight code snippets.</p>
<p>My problem is wordpress is converting special characters in my code (e.g. from <code>&</code> to <code>&amp;</code>), when I really just want it to leave my code alone.</p>
| [
{
"answer_id": 27402,
"author": "Jeremy Jared",
"author_id": 5339,
"author_profile": "https://wordpress.stackexchange.com/users/5339",
"pm_score": 2,
"selected": false,
"text": "<p>I tracked this solution down from the WordPress Trac ticket found here:\n<a href=\"http://core.trac.wordpre... | 2011/08/31 | [
"https://wordpress.stackexchange.com/questions/27401",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8320/"
] | I installed a syntax highlighter plugin so I could post and highlight code snippets.
My problem is wordpress is converting special characters in my code (e.g. from `&` to `&`), when I really just want it to leave my code alone. | I tracked this solution down from the WordPress Trac ticket found here:
<http://core.trac.wordpress.org/ticket/6969>
The solutions seems to be to add this to your functions.php file:
```
<?php
function foobar_run_shortcode( $content ) {
global $shortcode_tags;
// Backup current registered shortcodes and cle... |
27,416 | <p>When I am logged in, there is a gray admin bar on top. My theme layout got distorted by the bar. How to solve the layout problem? Is there a function that can detect user is logged in or not, or use CSS can solve the problem ?</p>
<p>The theme demo is at: <a href="http://raptor.hk/dev/theme" rel="nofollow noreferre... | [
{
"answer_id": 27417,
"author": "Jeremy Jared",
"author_id": 5339,
"author_profile": "https://wordpress.stackexchange.com/users/5339",
"pm_score": 2,
"selected": false,
"text": "<p>The admin bar only shows up if you're logged in. If you don't like it at the top, you can always move it to... | 2011/09/01 | [
"https://wordpress.stackexchange.com/questions/27416",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3608/"
] | When I am logged in, there is a gray admin bar on top. My theme layout got distorted by the bar. How to solve the layout problem? Is there a function that can detect user is logged in or not, or use CSS can solve the problem ?
The theme demo is at: <http://raptor.hk/dev/theme> and below is the screenshot when the gray... | The top bar of your theme is also positioned absolutely, so it doesn't know to come down. You can use `is_admin_bar_showing()` to check to see if it's showing, and then I'd probably just inject some styles using `wp_head` to move it down, since it's very little CSS.
All told, you'd get something in your theme's `funct... |
27,442 | <p>I use Magic Fields a lot to give my clients and users the ability to upload specific content to their websites. Is there a way to call images by their size? At the moment I just put out the images, the persons uploads. But right now I need a solution that gets a specific size from the uploaded picture. </p>
<p>I kn... | [
{
"answer_id": 27467,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 0,
"selected": false,
"text": "<p>Without knowing anything about how the Magic Fields Plugin works specifically:</p>\n\n<ol>\n<li>If Magic Fi... | 2011/09/01 | [
"https://wordpress.stackexchange.com/questions/27442",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7753/"
] | I use Magic Fields a lot to give my clients and users the ability to upload specific content to their websites. Is there a way to call images by their size? At the moment I just put out the images, the persons uploads. But right now I need a solution that gets a specific size from the uploaded picture.
I know that Ma... | Magic fields doesn't necessarily attach images to posts when uploaded via the WP image uploader, and it's not so simple to get the ID associated with an image. The plugin has its own function to retrieve different sizes:
```
$image_attributes = "w=250&h=150&zc=c&q=90"; // 250x150px, crop to center, quality 90
echo get... |
27,446 | <p>Hello i started from Bainternet solution in this post: <a href="https://wordpress.stackexchange.com/questions/15546/dont-publish-custom-post-type-post-if-a-meta-data-field-isnt-valid">don't publish custom post type post if a meta data field isn't valid</a></p>
<p>I made a plugin to make categories and tags ... | [
{
"answer_id": 27450,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>The JavaScript function is a bit wrong, its catching the form submit instead of the button click change it to... | 2011/09/01 | [
"https://wordpress.stackexchange.com/questions/27446",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8164/"
] | Hello i started from Bainternet solution in this post: [don't publish custom post type post if a meta data field isn't valid](https://wordpress.stackexchange.com/questions/15546/dont-publish-custom-post-type-post-if-a-meta-data-field-isnt-valid)
I made a plugin to make categories and tags required.
The validation wor... | The JavaScript function is a bit wrong, its catching the form submit instead of the button click change it to this:
```
function my_publish_admin_hook(){
if(is_admin())
{
echo"
<script language=\"javascript\" type=\"text/javascript\">
jQuery(document).ready(function() {
jQuer... |
27,451 | <p>I'm making image gallery plugin and I'm not sure what is the best way to store data in WordPress. Plugin can contain multiple gallery instances with some options and each gallery contains images with options. Gallery can be added to site using simple shortcode, something like this: [mygallery id="gallery1"].</p>
<p... | [
{
"answer_id": 27450,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>The JavaScript function is a bit wrong, its catching the form submit instead of the button click change it to... | 2011/09/01 | [
"https://wordpress.stackexchange.com/questions/27451",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8331/"
] | I'm making image gallery plugin and I'm not sure what is the best way to store data in WordPress. Plugin can contain multiple gallery instances with some options and each gallery contains images with options. Gallery can be added to site using simple shortcode, something like this: [mygallery id="gallery1"].
So should... | The JavaScript function is a bit wrong, its catching the form submit instead of the button click change it to this:
```
function my_publish_admin_hook(){
if(is_admin())
{
echo"
<script language=\"javascript\" type=\"text/javascript\">
jQuery(document).ready(function() {
jQuer... |
27,458 | <p>I'm trying to build website using wordpress.</p>
<p>There are tons of usable plugins, but instead of trying them all one by one id rather ask someone who can suggest me the one that would fit my needs.</p>
<p>The website is for small company who sells car scales.</p>
<p>I need multilanguage support(for 3languages... | [
{
"answer_id": 27450,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>The JavaScript function is a bit wrong, its catching the form submit instead of the button click change it to... | 2011/09/01 | [
"https://wordpress.stackexchange.com/questions/27458",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8336/"
] | I'm trying to build website using wordpress.
There are tons of usable plugins, but instead of trying them all one by one id rather ask someone who can suggest me the one that would fit my needs.
The website is for small company who sells car scales.
I need multilanguage support(for 3languages) A plugin for displayin... | The JavaScript function is a bit wrong, its catching the form submit instead of the button click change it to this:
```
function my_publish_admin_hook(){
if(is_admin())
{
echo"
<script language=\"javascript\" type=\"text/javascript\">
jQuery(document).ready(function() {
jQuer... |
27,464 | <p>I am fairly new to Wordpress and I am currently designing a template for a client of our company. However, I need to assign a specific id to the last comment of a post. </p>
<p>Basically I have my own function that is called on the callback of <code>wp_list_comments()</code>.
this is due to the fact that I have a v... | [
{
"answer_id": 27465,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": true,
"text": "<p>I guess you use the comments loop(?). If so, you could </p>\n\n<h3>Possibility A</h3>\n\n<p><code>count</code> the c... | 2011/09/01 | [
"https://wordpress.stackexchange.com/questions/27464",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8335/"
] | I am fairly new to Wordpress and I am currently designing a template for a client of our company. However, I need to assign a specific id to the last comment of a post.
Basically I have my own function that is called on the callback of `wp_list_comments()`.
this is due to the fact that I have a very customised commen... | I guess you use the comments loop(?). If so, you could
### Possibility A
`count` the comments first, set `$i = 0;` before the loop and `$i++` at the beginning/inside the loop and then attach your needed id when `if ( $count < $i ) $css\_id = "id='last-comment'".
### Possibility B
You could take the comments object... |
27,476 | <p>If I have to change a number of posts to pages, does this require anything more complex that setting the post-type to page on the table wp_posts? Do any other settings need to be changed.</p>
<p>Is it better to use a plugin like Convert Post Types or Vice Versa instead? I have a number of posts that I like being ab... | [
{
"answer_id": 27548,
"author": "Mohit Bumb",
"author_id": 8184,
"author_profile": "https://wordpress.stackexchange.com/users/8184",
"pm_score": 3,
"selected": true,
"text": "<p>Yes Its Possible Just Simply Run This Query Once \nIf You're Not Developer Then Don't to Anything \nJust Simpl... | 2011/09/01 | [
"https://wordpress.stackexchange.com/questions/27476",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4756/"
] | If I have to change a number of posts to pages, does this require anything more complex that setting the post-type to page on the table wp\_posts? Do any other settings need to be changed.
Is it better to use a plugin like Convert Post Types or Vice Versa instead? I have a number of posts that I like being able to cat... | Yes Its Possible Just Simply Run This Query Once
If You're Not Developer Then Don't to Anything
Just Simply log in to your cpanel->open phpmyadmin->There is maybe one or more database you've to find which one is wordpress database (click on database and where all table names starts with "wp\_" its your Wordpress Data... |
27,495 | <p>When I just click search, wordpress takes me to the 404 page. I'd like to just have a search template (maybe a page) that does search. Can anyone help?</p>
<p><strong>UPDATE:</strong></p>
<p>I created a custom search page (<a href="http://pastebin.com/PXrS7tsB" rel="nofollow">link</a>), and changed things around i... | [
{
"answer_id": 27499,
"author": "Drai",
"author_id": 7318,
"author_profile": "https://wordpress.stackexchange.com/users/7318",
"pm_score": 0,
"selected": false,
"text": "<p>Check to see that you have a search.php (results page) and searchform.php(code of the search box). could be somethi... | 2011/09/01 | [
"https://wordpress.stackexchange.com/questions/27495",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7457/"
] | When I just click search, wordpress takes me to the 404 page. I'd like to just have a search template (maybe a page) that does search. Can anyone help?
**UPDATE:**
I created a custom search page ([link](http://pastebin.com/PXrS7tsB)), and changed things around in my header file to reflect the custom search page, howe... | I feel bad for answering my own question on here, but here's what I did.
I created a custom search template, a custom `searchform.php` and changed my `header.php` to reflect my custom search page.
What I did is rename the search box names to `search` instead of `s` to get around WordPress automatically running `searc... |
27,497 | <p>I'm using the following inside the <a href="http://codex.wordpress.org/Function_Reference/wp_nav_menu"><code>wp_nav_menu</code></a> function to create a select dropdown menu where each menu item is an option in the select dropdown...</p>
<pre><code>'items_wrap' => '<select>%3$s</select>'
'before' ... | [
{
"answer_id": 27498,
"author": "onetrickpony",
"author_id": 1986,
"author_profile": "https://wordpress.stackexchange.com/users/1986",
"pm_score": 6,
"selected": true,
"text": "<p>You can't do this with wp_nav_menu, because it outputs list items, and you'll generate invalid markup with y... | 2011/09/01 | [
"https://wordpress.stackexchange.com/questions/27497",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8084/"
] | I'm using the following inside the [`wp_nav_menu`](http://codex.wordpress.org/Function_Reference/wp_nav_menu) function to create a select dropdown menu where each menu item is an option in the select dropdown...
```
'items_wrap' => '<select>%3$s</select>'
'before' => '<option value="">'
'after' => '</option>'... | You can't do this with wp\_nav\_menu, because it outputs list items, and you'll generate invalid markup with your code.
Try using [wp\_get\_nav\_menu\_items()](http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items) instead.
---
A quick solution for a drop down menu with a custom walker:
```
class Wal... |
27,507 | <p>I've written a small widget that uses JS for setting up some tabs in the settings panel. Is there a way to re-trigger the tab JS when the widget is done saving?</p>
<p>Looking at the WP <a href="https://core.trac.wordpress.org/browser/tags/3.2.1/wp-admin/js/widgets.dev.js#L230" rel="nofollow">JS source</a> it doesn... | [
{
"answer_id": 27508,
"author": "onetrickpony",
"author_id": 1986,
"author_profile": "https://wordpress.stackexchange.com/users/1986",
"pm_score": 3,
"selected": true,
"text": "<p>Put your javascript code inside the widget form, and it will be triggered whenever the widget is refreshed.<... | 2011/09/01 | [
"https://wordpress.stackexchange.com/questions/27507",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8351/"
] | I've written a small widget that uses JS for setting up some tabs in the settings panel. Is there a way to re-trigger the tab JS when the widget is done saving?
Looking at the WP [JS source](https://core.trac.wordpress.org/browser/tags/3.2.1/wp-admin/js/widgets.dev.js#L230) it doesn't look like it, as it simply blows ... | Put your javascript code inside the widget form, and it will be triggered whenever the widget is refreshed.
If you're tabs are hooked on a click event, a better way would be to use [`$.delegate`](http://api.jquery.com/delegate/) on the widget instance wrapper. That way you don't need to include the js inside every wid... |
27,518 | <p>I'm using Register Plus Redux plugin to augment a registration form with custom metadata fields. These fields display at the bottom of each user record detail page and they can be retrieved with get_the_author_meta.</p>
<p>In addition, I'm able to create columns in the User panel (the list view) and to make these c... | [
{
"answer_id": 27527,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>I'm not sure it's possible, maybe by modifying the query via <code>pre_user_query</code>. here's a quick and dirty ... | 2011/09/02 | [
"https://wordpress.stackexchange.com/questions/27518",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8361/"
] | I'm using Register Plus Redux plugin to augment a registration form with custom metadata fields. These fields display at the bottom of each user record detail page and they can be retrieved with get\_the\_author\_meta.
In addition, I'm able to create columns in the User panel (the list view) and to make these columns ... | My first answer was completely off-mark and I'm completely rewriting it...
But thanks to Milo's hint, I found the solution here:
<http://wordpress.mcdspot.com/2011/05/24/search-admin-user-list-on-first-and-last-names/>
After adapting it, this works for me with 'facebook' and 'twitter' `author_meta`.
```
add_actio... |
27,525 | <p>I planned to develop wordpress themes commercially.. I just want to know the easy method to add plugins to my wordpress theme which I am developing.. can any one suggest me the simple steps.. and I need possible methods that I can use effectively..</p>
| [
{
"answer_id": 27528,
"author": "perfwill",
"author_id": 8365,
"author_profile": "https://wordpress.stackexchange.com/users/8365",
"pm_score": 0,
"selected": false,
"text": "<p>The simplest solution is just to use normal wordpress plugins ^^. Writing a specialized plugin system for your ... | 2011/09/02 | [
"https://wordpress.stackexchange.com/questions/27525",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8364/"
] | I planned to develop wordpress themes commercially.. I just want to know the easy method to add plugins to my wordpress theme which I am developing.. can any one suggest me the simple steps.. and I need possible methods that I can use effectively.. | You can always include the files of the plugins in your theme *functions.php* file. Of course you should put it into some reasonable structure to not get your theme bloated with the files and the code :).
* <https://stackoverflow.com/questions/6974006/wordpress-package-plugin-with-theme>
* [How to bundle a plugin with... |
27,526 | <p>How do I use <code>$wpdb->insert</code> to insert multiple rows. Here is my code.</p>
<pre><code>for($i=0; $i<=$urlCount; $i++) {
$stat = $wpdb->insert(
'WP_URLS',
array(
'POSTID' => $post->ID,
'URL' => $_POST['url'.$i]
)
);
}
</code></pre>
... | [
{
"answer_id": 27528,
"author": "perfwill",
"author_id": 8365,
"author_profile": "https://wordpress.stackexchange.com/users/8365",
"pm_score": 0,
"selected": false,
"text": "<p>The simplest solution is just to use normal wordpress plugins ^^. Writing a specialized plugin system for your ... | 2011/09/02 | [
"https://wordpress.stackexchange.com/questions/27526",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8129/"
] | How do I use `$wpdb->insert` to insert multiple rows. Here is my code.
```
for($i=0; $i<=$urlCount; $i++) {
$stat = $wpdb->insert(
'WP_URLS',
array(
'POSTID' => $post->ID,
'URL' => $_POST['url'.$i]
)
);
}
```
This code works only for the first insert (ie, when... | You can always include the files of the plugins in your theme *functions.php* file. Of course you should put it into some reasonable structure to not get your theme bloated with the files and the code :).
* <https://stackoverflow.com/questions/6974006/wordpress-package-plugin-with-theme>
* [How to bundle a plugin with... |
27,530 | <p>I've been at this for hours so maybe someone here can help :)</p>
<p>Basically I have a fancybox gallery that loads images attached to a post. As you can see below, I want to echo either the image's caption or alt title into the fancybox window. Currently it works, but it only shows the alt and caption for <strong>... | [
{
"answer_id": 27537,
"author": "drebabels",
"author_id": 5395,
"author_profile": "https://wordpress.stackexchange.com/users/5395",
"pm_score": 2,
"selected": false,
"text": "<p>Your problem is with your foreach loops... here:</p>\n\n<pre><code> if ($images) {\n foreach($images as $im... | 2011/09/02 | [
"https://wordpress.stackexchange.com/questions/27530",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4999/"
] | I've been at this for hours so maybe someone here can help :)
Basically I have a fancybox gallery that loads images attached to a post. As you can see below, I want to echo either the image's caption or alt title into the fancybox window. Currently it works, but it only shows the alt and caption for **one** of the ima... | Ok so I went with an easier alternative. I left fancybox alone so it's still pulling the `title` attribute of the image but I've just changed how the title is being added to the images from WordPress. So instead of using the title from the WP image, It's using the alt or caption, depending on which one I go with. Done ... |
27,543 | <p>I am using <strong>WordPress</strong> with <a href="http://wordpress.org/extend/plugins/nextgen-gallery/" rel="nofollow"><strong>Nextgen Gallery</strong></a> by Alex Rabe for quite sometime. Once upon a time I had a good amount galleries in my website which were used in many posts through nextgen gallery shortcode. ... | [
{
"answer_id": 27551,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>If your galleries are <code>attachment</code> post types(?), then you could simply modify my \"<a href=\"https://gi... | 2011/09/02 | [
"https://wordpress.stackexchange.com/questions/27543",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8371/"
] | I am using **WordPress** with [**Nextgen Gallery**](http://wordpress.org/extend/plugins/nextgen-gallery/) by Alex Rabe for quite sometime. Once upon a time I had a good amount galleries in my website which were used in many posts through nextgen gallery shortcode. But for quality enhancement I have deleted many posts b... | Goto `wp_postmeta(TABLE)-> meta_key(COLUMN)->gallery_id(value)` has some value in `meta_value(COLUMN)` against your `post_id(COLUMN in this table)` |
27,546 | <p>i'm creating a wordpress theme and i am utilizing some scripts that use jQuery. It was working fine, until i enabled a particular plugin, named 'Paid Downloads'.</p>
<p>This actually made all of jquery dependencies not working anymore. So, i am thinking, that maybe i am doing something wrong. For instance, i am usi... | [
{
"answer_id": 27549,
"author": "Mamaduka",
"author_id": 888,
"author_profile": "https://wordpress.stackexchange.com/users/888",
"pm_score": 4,
"selected": true,
"text": "<p>Try and call method `prettyPhoto' when DOM is ready, replace your code:</p>\n\n<pre><code>jQuery.noConflict()\n\nj... | 2011/09/02 | [
"https://wordpress.stackexchange.com/questions/27546",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6329/"
] | i'm creating a wordpress theme and i am utilizing some scripts that use jQuery. It was working fine, until i enabled a particular plugin, named 'Paid Downloads'.
This actually made all of jquery dependencies not working anymore. So, i am thinking, that maybe i am doing something wrong. For instance, i am using prettyP... | Try and call method `prettyPhoto' when DOM is ready, replace your code:
```
jQuery.noConflict()
jQuery(function(){
jQuery("a[rel^='prettyPhoto']").prettyPhoto();
});
```
with this:
```
jQuery(document).ready(function($) {
$("a[rel^='prettyPhoto']").prettyPhoto();
});
```
Also 'Paid Downloads' plugins enque... |
27,569 | <p>I've tried for many hours to style my searchform. I managed to get it all done after some research. I even managed to get the text highlighted when on focus using javascript (no idea if there's a non-javascript solution as well).
anyways, I've been googling around and trying out all sorts of things (e.g. playing aro... | [
{
"answer_id": 27573,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>they're using <a href=\"http://www.w3schools.com/css3/css3_transitions.asp\" rel=\"nofollow\">CSS3 transitions</a>.<... | 2011/09/02 | [
"https://wordpress.stackexchange.com/questions/27569",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6903/"
] | I've tried for many hours to style my searchform. I managed to get it all done after some research. I even managed to get the text highlighted when on focus using javascript (no idea if there's a non-javascript solution as well).
anyways, I've been googling around and trying out all sorts of things (e.g. playing around... | they're using [CSS3 transitions](http://www.w3schools.com/css3/css3_transitions.asp).
```
<style type="text/css">
#s {
float: right;
-webkit-transition-duration: 400ms;
-webkit-transition-property: width, background;
-webkit-transition-timing-function: ease;
-moz-transition-duration: 400ms;
-mo... |
27,571 | <p>I am trying to add some code to a theme that will allow the user to change the logo or have some text instead. I managed to find some code that otto posted to do the file upload.</p>
<p>I have added what I thought was how to add the other fields but they do not save for some reason and I am sure it is something ver... | [
{
"answer_id": 27573,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>they're using <a href=\"http://www.w3schools.com/css3/css3_transitions.asp\" rel=\"nofollow\">CSS3 transitions</a>.<... | 2011/09/02 | [
"https://wordpress.stackexchange.com/questions/27571",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6224/"
] | I am trying to add some code to a theme that will allow the user to change the logo or have some text instead. I managed to find some code that otto posted to do the file upload.
I have added what I thought was how to add the other fields but they do not save for some reason and I am sure it is something very simple I... | they're using [CSS3 transitions](http://www.w3schools.com/css3/css3_transitions.asp).
```
<style type="text/css">
#s {
float: right;
-webkit-transition-duration: 400ms;
-webkit-transition-property: width, background;
-webkit-transition-timing-function: ease;
-moz-transition-duration: 400ms;
-mo... |
27,579 | <p>I have this setting in function.php</p>
<pre><code>add_image_size( 'thumbnail-gallery', 185, 185, true );
</code></pre>
<p>It will display a square picture.</p>
<p>Everything is fine before I regenerate new size using "Regenerate Thumbnails" plugin.</p>
<p>After the process finished, the <code><?php the_post_... | [
{
"answer_id": 27581,
"author": "Roman",
"author_id": 3817,
"author_profile": "https://wordpress.stackexchange.com/users/3817",
"pm_score": 1,
"selected": false,
"text": "<p>Look at the <code>wp-content/uploads/</code> directory. Does your cropped image exists there? (e.g. <code>myimage-... | 2011/09/02 | [
"https://wordpress.stackexchange.com/questions/27579",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1993/"
] | I have this setting in function.php
```
add_image_size( 'thumbnail-gallery', 185, 185, true );
```
It will display a square picture.
Everything is fine before I regenerate new size using "Regenerate Thumbnails" plugin.
After the process finished, the `<?php the_post_thumbnail( 'thumbnail-gallery' ); ?>` will retur... | Look at the `wp-content/uploads/` directory. Does your cropped image exists there? (e.g. `myimage-185x185.jpg`). If not, you could try to call `add_image_size()` on the `init` action hook.
**functions.php**
```
function wpse27579_addImageSizes() {
add_image_size('thumbnail-gallery', 185, 185, true);
}
add_action(... |
27,585 | <p>I'm using <code>add_action( 'wp', 'do_something_once_per_page' );</code> and, well, it's not doing it just once but twice. What's interesting is that within <code>do_something_once_per_page( $wp ){ }</code> I'm globalizing <code>$post</code> and it's two different posts!</p>
<p>The way I'm noticing this is with add... | [
{
"answer_id": 27599,
"author": "goldenapples",
"author_id": 290,
"author_profile": "https://wordpress.stackexchange.com/users/290",
"pm_score": 3,
"selected": true,
"text": "<p>Check the source for your page. I'm guessing that your source code includes a <code><link rel=\"next\"><... | 2011/09/02 | [
"https://wordpress.stackexchange.com/questions/27585",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3687/"
] | I'm using `add_action( 'wp', 'do_something_once_per_page' );` and, well, it's not doing it just once but twice. What's interesting is that within `do_something_once_per_page( $wp ){ }` I'm globalizing `$post` and it's two different posts!
The way I'm noticing this is with add\_user\_meta(). Essentially I'm using this ... | Check the source for your page. I'm guessing that your source code includes a `<link rel="next">` in the header, as WordPress injects by default, and Firefox is prefetching the "next" page in order to cache it.
Try this to remove that link from your header:
```
remove_action('wp_head', 'adjacent_posts_rel_link_wp_hea... |
27,625 | <p>Here's the Google Plus One script I've been using:</p>
<pre><code><g:plusone a href="<?php echo urlencode(get_permalink($post->ID)); ?>"></g:plusone>
</code></pre>
<p>Worked fine until it didn't. Now it's returning a red Plus One button with a bunch of suggestions to correct the error, none of... | [
{
"answer_id": 27629,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 0,
"selected": false,
"text": "<p>Google +1 is very easy to add to your site, you only need 2 things for a basic button.</p>\n\n<p><strong>1.</strong... | 2011/09/03 | [
"https://wordpress.stackexchange.com/questions/27625",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5486/"
] | Here's the Google Plus One script I've been using:
```
<g:plusone a href="<?php echo urlencode(get_permalink($post->ID)); ?>"></g:plusone>
```
Worked fine until it didn't. Now it's returning a red Plus One button with a bunch of suggestions to correct the error, none of which apply.
Tried out the Plus One plugin, w... | Here's the answer, courtesy of a sympathetic Google employee:
```
<g:plusone a href="<?php echo get_permalink($post->ID); ?>"></g:plusone>
``` |
27,632 | <p>I've created a super simple contact page template, just content and a contact form, like so:</p>
<pre><code><?php
/*
Template Name: Contact
*/
?>
<?php while (have_posts()) : the_post(); ?>
<div id="blockcontact">
<?php the_content(); ?>
<form id="contactform" method... | [
{
"answer_id": 27634,
"author": "Jeremy Jared",
"author_id": 5339,
"author_profile": "https://wordpress.stackexchange.com/users/5339",
"pm_score": 1,
"selected": false,
"text": "<p>Couldn't you use the custom form like this:</p>\n\n<p><strong>STEP ONE:</strong></p>\n\n<p>Open a Text edit... | 2011/09/03 | [
"https://wordpress.stackexchange.com/questions/27632",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8400/"
] | I've created a super simple contact page template, just content and a contact form, like so:
```
<?php
/*
Template Name: Contact
*/
?>
<?php while (have_posts()) : the_post(); ?>
<div id="blockcontact">
<?php the_content(); ?>
<form id="contactform" method="post" action="<?php bloginfo('template_... | Couldn't you use the custom form like this:
**STEP ONE:**
Open a Text editor and paste your form content-
```
<?php
// Custom Contact Form
?>
<div id="my-ccf">
<form id="contactform" method="post" action="<?php bloginfo('template_directory'); ?>/_assets/submitemail.php">
<input name="user" type="text" value="Na... |
27,644 | <p>I'm trying to build a custom query that will return all posts that <strong>DON'T</strong> have the associated post meta. I'm not quite sure how to do this...here is what I am working with, and for your reference "score" is a custom column that I have added to the posts table. </p>
<pre><code> $querystr = "
... | [
{
"answer_id": 27648,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>You have to do a join or a subquery:</p>\n\n<pre><code>$querystr = \"\nSELECT $wpdb->posts.ID \nFROM $wpdb->po... | 2011/09/03 | [
"https://wordpress.stackexchange.com/questions/27644",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7772/"
] | I'm trying to build a custom query that will return all posts that **DON'T** have the associated post meta. I'm not quite sure how to do this...here is what I am working with, and for your reference "score" is a custom column that I have added to the posts table.
```
$querystr = "
SELECT $wpdb->posts.ID
... | You have to do a join or a subquery:
```
$querystr = "
SELECT $wpdb->posts.ID
FROM $wpdb->posts
WHERE $wpdb->posts.post_type = 'post'
AND $wpdb->posts.post_date < NOW()
AND $wpdb->posts.ID NOT IN
( SELECT DISTINCT post_id FROM $wpdb->postmeta WHERE meta_key = '_social_' )
ORDER BY $wpdb->posts.score DESC
LIMIT 1;
";
... |
27,668 | <p>I've created 6 different custom post types, each with their own archive. I've also created a page with the same name as the custom post type, and a sub-page called 'About' for each.</p>
<p>For some reason, I'm only able to access the About page under one Custom Post Type, even though I've checked to make sure the c... | [
{
"answer_id": 27673,
"author": "128KB",
"author_id": 8413,
"author_profile": "https://wordpress.stackexchange.com/users/8413",
"pm_score": 1,
"selected": false,
"text": "<p>Haven't experienced this problem, but just looking into it a little bit I realized that you're capitalizing the pa... | 2011/09/04 | [
"https://wordpress.stackexchange.com/questions/27668",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6389/"
] | I've created 6 different custom post types, each with their own archive. I've also created a page with the same name as the custom post type, and a sub-page called 'About' for each.
For some reason, I'm only able to access the About page under one Custom Post Type, even though I've checked to make sure the code in `fu... | Haven't experienced this problem, but just looking into it a little bit I realized that you're capitalizing the page URL somehow.
[The same link with a capital D works just fine.](http://test.isthispavilion.com/Darya/about/)
[Oliver link is doing the same thing, and a capital O fixes it](http://test.isthispavilion.c... |
27,672 | <p>I have a rather annoying problem with my commentlist. After trying out a lot and playing around with the CSS stylesheet I don't think this is a CSS problem anymore which is why I decided to post here and ask, because I really have no clue what's wrong.</p>
<p>So, I want to "highlight" author comments.
I'm using "li... | [
{
"answer_id": 27678,
"author": "Roman",
"author_id": 3817,
"author_profile": "https://wordpress.stackexchange.com/users/3817",
"pm_score": 2,
"selected": false,
"text": "<p>Read the comments in your linked forum post on wordpress.com. It's just CSS. You are styling the elements based on... | 2011/09/04 | [
"https://wordpress.stackexchange.com/questions/27672",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6903/"
] | I have a rather annoying problem with my commentlist. After trying out a lot and playing around with the CSS stylesheet I don't think this is a CSS problem anymore which is why I decided to post here and ask, because I really have no clue what's wrong.
So, I want to "highlight" author comments.
I'm using "li.bypostaut... | I finally got how to do it and this helped me to understand it immediately, so I'm posting this so that other users with the same problem can understand what to do more clearly, too (hopefully):
```
li.comment-author-yourname{/*own style*/}
li.comment-author-yourname ul li{/*others' styles*/}
li.comment-author-yournam... |
27,700 | <p>i would like to add an image above the post title... in the old days i would change that directly in wordpress code but thats not very affective.. you know, upgrades and such.</p>
<p>is ther a way using add_meta_box or some othere way to add a box directly above the post title?</p>
<p>tried this
<a href="https://... | [
{
"answer_id": 27708,
"author": "chrisguitarguy",
"author_id": 6035,
"author_profile": "https://wordpress.stackexchange.com/users/6035",
"pm_score": 1,
"selected": false,
"text": "<p>My answer is assuming you mean in the admin area on the post editing screen.</p>\n\n<p>Unfortunately ther... | 2011/09/04 | [
"https://wordpress.stackexchange.com/questions/27700",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7990/"
] | i would like to add an image above the post title... in the old days i would change that directly in wordpress code but thats not very affective.. you know, upgrades and such.
is ther a way using add\_meta\_box or some othere way to add a box directly above the post title?
tried this
[Priority of Meta Box for Custom... | The only *real* chance you got is to hook into `admin_notices`, which is above the post-new.php page title & icon:
```
function wpse27700_above_title_content()
{
?>
<style>
/*
You might need to attach some styles here,
to not get into the admin notices styles
*/
</style>
<h1>TEST</h... |
27,704 | <p>I want to add some content (slider) only on the home page. I don't want it to apear on the other pages. I am trying following:</p>
<pre><code><?php if(is_home()) { ?>
<div>
...
<div>
} ?>
</code></pre>
<p>But the content still appears on the second page (in pagination). How can i show some con... | [
{
"answer_id": 27705,
"author": "Jeremy Jared",
"author_id": 5339,
"author_profile": "https://wordpress.stackexchange.com/users/5339",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried <code><?php if(is_front_page()) { ?></code> I believe this is for using with sites tha... | 2011/09/04 | [
"https://wordpress.stackexchange.com/questions/27704",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6908/"
] | I want to add some content (slider) only on the home page. I don't want it to apear on the other pages. I am trying following:
```
<?php if(is_home()) { ?>
<div>
...
<div>
} ?>
```
But the content still appears on the second page (in pagination). How can i show some content to homepage only, so that id does not appe... | ```
<?php if(is_home() && !is_paged()) { ?>
```
<http://codex.wordpress.org/Conditional_Tags> |
27,710 | <p>On my archive page, the_excerpt() does not display content before the more tag, but a cut of the post's full content. I'm obliged to fulfill the "Excerpt" in the post editor which will override it. How to force the_excerpt() to show only the content before the more tag?</p>
| [
{
"answer_id": 27705,
"author": "Jeremy Jared",
"author_id": 5339,
"author_profile": "https://wordpress.stackexchange.com/users/5339",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried <code><?php if(is_front_page()) { ?></code> I believe this is for using with sites tha... | 2011/09/04 | [
"https://wordpress.stackexchange.com/questions/27710",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8424/"
] | On my archive page, the\_excerpt() does not display content before the more tag, but a cut of the post's full content. I'm obliged to fulfill the "Excerpt" in the post editor which will override it. How to force the\_excerpt() to show only the content before the more tag? | ```
<?php if(is_home() && !is_paged()) { ?>
```
<http://codex.wordpress.org/Conditional_Tags> |
27,715 | <p>I have a WP network setup running the latest versions of WP and Buddypress. I want to set up ~40 users with blogs, and have created these blogs using the Batch Create plugin, but now when I try to visit one of these folders, eg burkphysics.com/elizabethf, it redirects to burkphysics.com. All sites, even sites I crea... | [
{
"answer_id": 27734,
"author": "PrivateUser",
"author_id": 5074,
"author_profile": "https://wordpress.stackexchange.com/users/5074",
"pm_score": 1,
"selected": true,
"text": "<p>Since you installed wordpress in a sub directory called \"wordpress\" you should try changing your last rewri... | 2011/09/05 | [
"https://wordpress.stackexchange.com/questions/27715",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7879/"
] | I have a WP network setup running the latest versions of WP and Buddypress. I want to set up ~40 users with blogs, and have created these blogs using the Batch Create plugin, but now when I try to visit one of these folders, eg burkphysics.com/elizabethf, it redirects to burkphysics.com. All sites, even sites I create ... | Since you installed wordpress in a sub directory called "wordpress" you should try changing your last rewrite rule like this.
```
RewriteRule . /wordpress/index.php [L]
``` |
27,740 | <p>I want to restrict the width to a maximum of 600px for images uploaded using the "full size" image option in WP posts/pages section.</p>
<p>I've tried two methods:</p>
<p><strong>Method 1:</strong></p>
<p>Adding the following to style.css of the theme:</p>
<pre><code>.post img {
max-width: 600px; /* Adjust this ... | [
{
"answer_id": 27719,
"author": "anmari",
"author_id": 3569,
"author_profile": "https://wordpress.stackexchange.com/users/3569",
"pm_score": 2,
"selected": false,
"text": "<p>No,</p>\n\n<p>only the options that are specifically loaded with autoload set to true</p>\n\n<p>See <a href=\"htt... | 2011/09/05 | [
"https://wordpress.stackexchange.com/questions/27740",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8221/"
] | I want to restrict the width to a maximum of 600px for images uploaded using the "full size" image option in WP posts/pages section.
I've tried two methods:
**Method 1:**
Adding the following to style.css of the theme:
```
.post img {
max-width: 600px; /* Adjust this value according to your content area size*/
heig... | Yes, sort of. When the [`get_option`](http://codex.wordpress.org/Function_Reference/get_option) call is made, WordPress runs a function called `wp_load_alloptions`, which either grabs a cached copy of all autoloaded options or loads all those options into the cache. Then `wp_load_alloptions` returns an array of all the... |
27,754 | <p>I have a navigation menu that I hard-coded into a recent theme that I developed. Now, it would be a lot easier (and more customizable) to just build this navigation menu using the intrinsic <code>wp_list_pages()</code> function via the wordpress administration panel. There is one catch though. Some of the drop-downs... | [
{
"answer_id": 28473,
"author": "PrivateUser",
"author_id": 5074,
"author_profile": "https://wordpress.stackexchange.com/users/5074",
"pm_score": 0,
"selected": false,
"text": "<p>Install <a href=\"http://wordpress.org/extend/plugins/ozh-admin-drop-down-menu/\" rel=\"nofollow\">this plug... | 2011/09/05 | [
"https://wordpress.stackexchange.com/questions/27754",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8427/"
] | I have a navigation menu that I hard-coded into a recent theme that I developed. Now, it would be a lot easier (and more customizable) to just build this navigation menu using the intrinsic `wp_list_pages()` function via the wordpress administration panel. There is one catch though. Some of the drop-downs have an image... | This can be done easily with CSS. I would use the default wp\_nav\_menu() function to do the heavy lifting for you and build your menus under Appearance->Menus. If you click on screen options there is a checkbox under advanced menu properties called CSS Classes. Check that box.
When you add a new menu item, you can de... |
27,756 | <p>I'd like to limit registration to some of my sites based on the email domain of the user. For example, I only want people with <code>@gmail.com</code> emails to register.</p>
<p>How would I do this?</p>
| [
{
"answer_id": 28473,
"author": "PrivateUser",
"author_id": 5074,
"author_profile": "https://wordpress.stackexchange.com/users/5074",
"pm_score": 0,
"selected": false,
"text": "<p>Install <a href=\"http://wordpress.org/extend/plugins/ozh-admin-drop-down-menu/\" rel=\"nofollow\">this plug... | 2011/09/05 | [
"https://wordpress.stackexchange.com/questions/27756",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7988/"
] | I'd like to limit registration to some of my sites based on the email domain of the user. For example, I only want people with `@gmail.com` emails to register.
How would I do this? | This can be done easily with CSS. I would use the default wp\_nav\_menu() function to do the heavy lifting for you and build your menus under Appearance->Menus. If you click on screen options there is a checkbox under advanced menu properties called CSS Classes. Check that box.
When you add a new menu item, you can de... |
27,772 | <p>I have a shortcode that iterates through a list of custom post types and, as part of displaying them, creates a block.
In HTML5, it is illegal to have a style block outside the header (maybe in other versions too, but we are using HTML5).</p>
<p>I am looking for a way that my shortcode can insert its block into t... | [
{
"answer_id": 27773,
"author": "Jeremy Jared",
"author_id": 5339,
"author_profile": "https://wordpress.stackexchange.com/users/5339",
"pm_score": 0,
"selected": false,
"text": "<p>Couldn't you you save your shortcode as a file? </p>\n\n<p><strong>Example:</strong> \nOpen a blank text do... | 2011/09/05 | [
"https://wordpress.stackexchange.com/questions/27772",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5067/"
] | I have a shortcode that iterates through a list of custom post types and, as part of displaying them, creates a block.
In HTML5, it is illegal to have a style block outside the header (maybe in other versions too, but we are using HTML5).
I am looking for a way that my shortcode can insert its block into the head.
Any... | hook `the_posts` and inspect each post to see if your shortcode is present, you can use `wp_enqueue_style` at that point if it is. maybe a bit of regex to check for the presence of the shortcode is the way to go, unfortunately i'm not very good with regex!
```
function wpse27772_has_shortcode($posts) {
if ( empty(... |
27,777 | <p>My Wordpress theme has a lot of .js scripts running and it takes plenty of time to load them all one by one. I would love to use a script loader like <a href="http://headjs.com/" rel="nofollow">HeadJS</a> or
<a href="http://yepnopejs.com/" rel="nofollow">yepnopejs</a> to speed things up.</p>
<p>But... what about w... | [
{
"answer_id": 27773,
"author": "Jeremy Jared",
"author_id": 5339,
"author_profile": "https://wordpress.stackexchange.com/users/5339",
"pm_score": 0,
"selected": false,
"text": "<p>Couldn't you you save your shortcode as a file? </p>\n\n<p><strong>Example:</strong> \nOpen a blank text do... | 2011/09/05 | [
"https://wordpress.stackexchange.com/questions/27777",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1869/"
] | My Wordpress theme has a lot of .js scripts running and it takes plenty of time to load them all one by one. I would love to use a script loader like [HeadJS](http://headjs.com/) or
[yepnopejs](http://yepnopejs.com/) to speed things up.
But... what about wp\_enqueue\_script? I'm using it to load every single script (... | hook `the_posts` and inspect each post to see if your shortcode is present, you can use `wp_enqueue_style` at that point if it is. maybe a bit of regex to check for the presence of the shortcode is the way to go, unfortunately i'm not very good with regex!
```
function wpse27772_has_shortcode($posts) {
if ( empty(... |
27,781 | <p>I want to submit comments via ajax. CLick the comment submit button, comments gets posted via jquery's ajax method and the result ("Awaiting moderation...") is displayed on the page. </p>
<p>I went into the scripts.js file and added a click handler for the button. It validates and then does an ajax submit but this ... | [
{
"answer_id": 27802,
"author": "Niraj Chauhan",
"author_id": 1743,
"author_profile": "https://wordpress.stackexchange.com/users/1743",
"pm_score": 1,
"selected": false,
"text": "<p>You can use some plugins to get the AJAX work</p>\n\n<p><a href=\"http://wordpress.org/extend/plugins/ajax... | 2011/09/06 | [
"https://wordpress.stackexchange.com/questions/27781",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4176/"
] | I want to submit comments via ajax. CLick the comment submit button, comments gets posted via jquery's ajax method and the result ("Awaiting moderation...") is displayed on the page.
I went into the scripts.js file and added a click handler for the button. It validates and then does an ajax submit but this is not wor... | you might find these links handy if you're going to code it yourself
<http://byronyasgur.wordpress.com/2011/06/27/frontend-forward-facing-ajax-in-wordpress/>
<http://www.garyc40.com/2010/03/5-tips-for-using-ajax-in-wordpress/>
I am fairly sure your URL is wrong **url: "../wp-comments-post.php"** - ajax in wordpress h... |
27,789 | <p>I am looking at moving my WordPress site from localhost on my mac (MAMP – htdocs directory) to online hosting that is using cPanel.</p>
<p>When I log into my cPanel online, I am presented with my home directory that includes the following directories:</p>
<pre><code>1) public_html
2) www
</code></pre>
<p>My que... | [
{
"answer_id": 27793,
"author": "Joshua",
"author_id": 7105,
"author_profile": "https://wordpress.stackexchange.com/users/7105",
"pm_score": 2,
"selected": false,
"text": "<p>To answer your first question, in mosts hosts the www and public_html folders are the same, one just links to the... | 2011/09/06 | [
"https://wordpress.stackexchange.com/questions/27789",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1053/"
] | I am looking at moving my WordPress site from localhost on my mac (MAMP – htdocs directory) to online hosting that is using cPanel.
When I log into my cPanel online, I am presented with my home directory that includes the following directories:
```
1) public_html
2) www
```
My question is, what is the equivalent ... | To answer your first question, in mosts hosts the www and public\_html folders are the same, one just links to the other. To make things simple, start with the public\_html folder. There is usually what is called a *symlink* between the two, pretty much like an alias or a shortcut.
Now for the second question on movin... |
27,806 | <p>I have this template file called Events. The purpose of this file is just to display the latest post with custom type Event. I have solved it with a very ugly solution. There must be a simpler and more correct way to do this. If you check my code im sure you understand what im trying to accomplish :)</p>
<p>Thanks ... | [
{
"answer_id": 27810,
"author": "anmari",
"author_id": 3569,
"author_profile": "https://wordpress.stackexchange.com/users/3569",
"pm_score": 0,
"selected": false,
"text": "<p>You do not need to do anything other than register your post type appropriately: \nSee <a href=\"http://codex.wor... | 2011/09/06 | [
"https://wordpress.stackexchange.com/questions/27806",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6992/"
] | I have this template file called Events. The purpose of this file is just to display the latest post with custom type Event. I have solved it with a very ugly solution. There must be a simpler and more correct way to do this. If you check my code im sure you understand what im trying to accomplish :)
Thanks in advance... | If you want to use the proper archive page (e.g. `example.com/events`), make sure that you register your custom post type with `'has_archive' => true` and then create an `archive-events.php` in your theme (changing `events` to whatever you've named your CPT).
To show just the latest post, put the following before you ... |
27,816 | <p>I have a php file in my template directory which generates some data from a database. I only want this data to be accessable for my wordpress users.</p>
<p>I tried by using this line of code but it gives me an error saying "headers already sent".</p>
<p>What is wrong? Or is there any other way to solve this?</p>
... | [
{
"answer_id": 27817,
"author": "Tom",
"author_id": 3482,
"author_profile": "https://wordpress.stackexchange.com/users/3482",
"pm_score": 2,
"selected": true,
"text": "<p>Since the file is in your theme directory, Wordpress may not want the user to \"directly\" access it. Why not create ... | 2011/09/06 | [
"https://wordpress.stackexchange.com/questions/27816",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6992/"
] | I have a php file in my template directory which generates some data from a database. I only want this data to be accessable for my wordpress users.
I tried by using this line of code but it gives me an error saying "headers already sent".
What is wrong? Or is there any other way to solve this?
```
<?php
require_o... | Since the file is in your theme directory, Wordpress may not want the user to "directly" access it. Why not create a Page in wordpress, assign a Template Name to your PHP page and then assign that to the new page created in wordpress. For example, you would have a new page called "Members Only" and its template is "php... |
27,832 | <p>I have another database which stores post's IDs and I want do display them using WP_query to use the WP default pagination. I'm using <em>orderby => none</em> to preserve the original order, but the result reorders them by IDs.</p>
<pre><code>$ids = array (60, 23, 78, 46, 105, 130)
$args = array (
'posts_per_p... | [
{
"answer_id": 27834,
"author": "Mamaduka",
"author_id": 888,
"author_profile": "https://wordpress.stackexchange.com/users/888",
"pm_score": 1,
"selected": false,
"text": "<p>Try following snippet:</p>\n\n<pre><code>$ids = array (60, 23, 78, 46, 105, 130)\n\n$args = array (\n 'posts_p... | 2011/09/06 | [
"https://wordpress.stackexchange.com/questions/27832",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6725/"
] | I have another database which stores post's IDs and I want do display them using WP\_query to use the WP default pagination. I'm using *orderby => none* to preserve the original order, but the result reorders them by IDs.
```
$ids = array (60, 23, 78, 46, 105, 130)
$args = array (
'posts_per_page' => -1,
'pos... | You can order them manually after the query is complete:
```
$ids = array (60, 23, 78, 46, 105, 130)
$args = array (
'posts_per_page' => -1,
'post__in' => $ids,
'orderby' => 'none'
);
$query = new WP_Query ( $args );
$ordered_posts = array();
foreach($ids as $rpid)
foreach($query->posts as $index => $f... |
27,835 | <p>This one has been bugging me for a while. I've used Verve Meta Boxes plugin to add a date field to a custom post type I created, and I would like to somehow order by this field when using <code>query_posts</code> in PHP. What's the best way to do this? I haven't been able to figure out a way that didn't involve comp... | [
{
"answer_id": 27910,
"author": "CookieMonster",
"author_id": 8131,
"author_profile": "https://wordpress.stackexchange.com/users/8131",
"pm_score": 1,
"selected": false,
"text": "<p>I found the following solution:</p>\n\n<pre><code>SELECT wposts . *\n FROM $wpdb->posts wpos... | 2011/09/06 | [
"https://wordpress.stackexchange.com/questions/27835",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8131/"
] | This one has been bugging me for a while. I've used Verve Meta Boxes plugin to add a date field to a custom post type I created, and I would like to somehow order by this field when using `query_posts` in PHP. What's the best way to do this? I haven't been able to figure out a way that didn't involve complicated custom... | I found the following solution:
```
SELECT wposts . *
FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
WHERE wposts.ID = wpostmeta.post_id
AND wpostmeta.meta_key = 'datum'
AND wposts.post_type = 'optredens'
AND wposts.post_status = 'publish'
... |
27,856 | <p>Is there an action_hook or something similar that could help me achieve this?</p>
<p>I tried adding markup in a PHP string variable and just fired off an email with the <code>wp_mail()</code> function like so:</p>
<pre><code>$email_to = 'someaddress@gmail.com';
$email_subject = 'Email subject';
$email_body = "<... | [
{
"answer_id": 27858,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 7,
"selected": true,
"text": "<p>from <a href=\"http://codex.wordpress.org/Function_Reference/wp_mail\" rel=\"noreferrer\">wp_mail codex page</a>:</p... | 2011/09/06 | [
"https://wordpress.stackexchange.com/questions/27856",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2123/"
] | Is there an action\_hook or something similar that could help me achieve this?
I tried adding markup in a PHP string variable and just fired off an email with the `wp_mail()` function like so:
```
$email_to = 'someaddress@gmail.com';
$email_subject = 'Email subject';
$email_body = "<html><body><h1>Hello World!</h1></... | from [wp\_mail codex page](http://codex.wordpress.org/Function_Reference/wp_mail):
>
> The default content type is 'text/plain' which does not allow using HTML. However, you can set the content type of the email by using the 'wp\_mail\_content\_type' filter.
>
>
>
```
// In theme's functions.php or plug-in code:
... |
27,861 | <p>From the codex</p>
<pre><code>is_active_sidebar( $index ); ?>
Parameters
$index
(mixed) (required) Sidebar name, id or number.
</code></pre>
<p>When i try any of my sidebar names it doesnt work; yet when I put in random numbers 1,2 and 3 guessing that my sidebars are numbered that way and it works, but t... | [
{
"answer_id": 27865,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>Straight from the php docBlock:</p>\n\n<pre><code>@param mixed $index Sidebar name, id or number to check\n</code><... | 2011/09/06 | [
"https://wordpress.stackexchange.com/questions/27861",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6169/"
] | From the codex
```
is_active_sidebar( $index ); ?>
Parameters
$index
(mixed) (required) Sidebar name, id or number.
```
When i try any of my sidebar names it doesnt work; yet when I put in random numbers 1,2 and 3 guessing that my sidebars are numbered that way and it works, but this is not reliable. There is... | Found a solution to the problem. I added a line of code id => 'my-sidebar-id' to the register\_sidebar array so now i know the sidebar ID. There may be another way of doing it but this method seems to work fine for me now anyway.
```
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Right ... |
27,870 | <p>Hey all i am trying to find the section within the edit.php page where it populates the table with all my current pages. What i want to do is add another colum to the table in order to launch a side page for changing a picture.</p>
<p><img src="https://i.stack.imgur.com/YAcgz.jpg" alt="enter image description here"... | [
{
"answer_id": 27881,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 2,
"selected": false,
"text": "<p>Also an tutorial with an solution for page and post to add thumbnail in a column: <a href=\"http://wpengineer.com/... | 2011/09/07 | [
"https://wordpress.stackexchange.com/questions/27870",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8469/"
] | Hey all i am trying to find the section within the edit.php page where it populates the table with all my current pages. What i want to do is add another colum to the table in order to launch a side page for changing a picture.

Could anyone point me... | Here is how i did it:
```
/****** Add Thumbnails in Manage Posts/Pages List ******/
if ( !function_exists('AddThumbColumn') && function_exists('add_theme_support') ) {
// for post and page
add_theme_support('post-thumbnails', array( 'post', 'page' ) );
function AddThumbColumn($cols) {
$cols['thumbn... |
27,871 | <p>I'm having some hard-time with with WordPress permalinks. WordPress 3.1 seems to force url redirection, ex:</p>
<p>This is the correct post url:</p>
<pre><code>http://www.mysite.com/test/1/mypost.html
</code></pre>
<p>If I go to any of the url's below WordPress is redirecting me to the url above</p>
<pre><code>h... | [
{
"answer_id": 27872,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": -1,
"selected": false,
"text": "<p><strong>This answer doesn't work!</strong></p>\n\n<p>I don't remove it to avoid similar wrong answer. I'll delete... | 2011/09/05 | [
"https://wordpress.stackexchange.com/questions/27871",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8433/"
] | I'm having some hard-time with with WordPress permalinks. WordPress 3.1 seems to force url redirection, ex:
This is the correct post url:
```
http://www.mysite.com/test/1/mypost.html
```
If I go to any of the url's below WordPress is redirecting me to the url above
```
http://www.mysite.com/test/1/mypost-teste21.h... | First, I'll say it's beyond me why you'd want to do this, I really don't think it's a good idea, but in any case...
If you look in `/wp-includes/canonical.php`, you'll see how WP is fighting you on this. The only way I'm aware of to get around it is to go looking for the post yourself based on the post id query var (w... |
27,873 | <p>I've got a buddy who's trying to organize his recipe blog and would love to have an archive page that displays his recipes broken up by broad subject areas (read: categories) and then have the recipes listed alphabetically under each section (similar to <a href="http://www.icancookthat.org/p/recipe-index.html" rel="... | [
{
"answer_id": 27872,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": -1,
"selected": false,
"text": "<p><strong>This answer doesn't work!</strong></p>\n\n<p>I don't remove it to avoid similar wrong answer. I'll delete... | 2011/09/07 | [
"https://wordpress.stackexchange.com/questions/27873",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/61/"
] | I've got a buddy who's trying to organize his recipe blog and would love to have an archive page that displays his recipes broken up by broad subject areas (read: categories) and then have the recipes listed alphabetically under each section (similar to [this](http://www.icancookthat.org/p/recipe-index.html)).
Do I ne... | First, I'll say it's beyond me why you'd want to do this, I really don't think it's a good idea, but in any case...
If you look in `/wp-includes/canonical.php`, you'll see how WP is fighting you on this. The only way I'm aware of to get around it is to go looking for the post yourself based on the post id query var (w... |
27,882 | <p>Been all over looking for the best way to do this.</p>
<p>I want to get the ID of the latest post of a certain post_type.</p>
<p>How can I do this in the cheapest way possible (by cheapest I mean using the least queries, and no loops or post rewinding)?</p>
<p>Surely there is a quick method?</p>
| [
{
"answer_id": 27883,
"author": "Scott",
"author_id": 4610,
"author_profile": "https://wordpress.stackexchange.com/users/4610",
"pm_score": 6,
"selected": true,
"text": "<pre><code>$latest_cpt = get_posts(\"post_type=yourcpt&numberposts=1\");\necho $latest_cpt[0]->ID\n</code></pre... | 2011/09/07 | [
"https://wordpress.stackexchange.com/questions/27882",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6068/"
] | Been all over looking for the best way to do this.
I want to get the ID of the latest post of a certain post\_type.
How can I do this in the cheapest way possible (by cheapest I mean using the least queries, and no loops or post rewinding)?
Surely there is a quick method? | ```
$latest_cpt = get_posts("post_type=yourcpt&numberposts=1");
echo $latest_cpt[0]->ID
```
The only cheaper way than above, I can think of, would be to write your own SQL query to just return the one post and only the column ID. |
27,891 | <p>I built a plugin for my company, which basically goes to tube sites, scrapes them for content, and posts them automatically in whatever state is defined (publish, draft, future, etc).</p>
<p>Now, everything goes well when I manually add a post through the plugin:
it opens a cURL to the sites, grabs the videos and e... | [
{
"answer_id": 28031,
"author": "Weston Ruter",
"author_id": 8521,
"author_profile": "https://wordpress.stackexchange.com/users/8521",
"pm_score": 2,
"selected": false,
"text": "<p>I just encountered this very same problem. I was trying to do <code>wp_insert_post()</code> from within a c... | 2011/09/07 | [
"https://wordpress.stackexchange.com/questions/27891",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7760/"
] | I built a plugin for my company, which basically goes to tube sites, scrapes them for content, and posts them automatically in whatever state is defined (publish, draft, future, etc).
Now, everything goes well when I manually add a post through the plugin:
it opens a cURL to the sites, grabs the videos and embeds, tak... | Well, I've found my own solution, thanks weston, but I believe mine is a bit easier :)
from the function which calls to insert post, you do the following for simplicity's sake:
```
kses_remove_filters();
wp_insert_post( $post );
kses_init_filters();
```
And voila! there's a new post. |
27,909 | <p>Is it possible to retrieve post entry for a custom post type by tag, I have been trying with the following code, however it just locks me into a infinte loop.</p>
<pre><code><aside class="supporting_images">
<?php /*<?php if($post->ID == 241) : echo apply_filters('the_content', '[slideshow=3]'); ... | [
{
"answer_id": 27919,
"author": "spencersokol",
"author_id": 6922,
"author_profile": "https://wordpress.stackexchange.com/users/6922",
"pm_score": 3,
"selected": true,
"text": "<p>You'll need to setup the post for the query by changing the following line to get rid of the infinite loop.<... | 2011/09/07 | [
"https://wordpress.stackexchange.com/questions/27909",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6964/"
] | Is it possible to retrieve post entry for a custom post type by tag, I have been trying with the following code, however it just locks me into a infinte loop.
```
<aside class="supporting_images">
<?php /*<?php if($post->ID == 241) : echo apply_filters('the_content', '[slideshow=3]'); endif; ?>
<?php the_post... | You'll need to setup the post for the query by changing the following line to get rid of the infinite loop.
`<?php while ($query->have_posts()) : $query->the_post(); ?>`
If your looking for a custom post type, you'll need to specify that in the query arguments:
`<?php $query = new WP_Query( array( "post-type" => "yo... |
27,914 | <p>Currently I have successfully added a row of shortcode buttons to the TinyMCE editor in WordPress. The problem is, only admins can see the row, and I need contributors and editors to see it too. I have checked the Codex for add_action and add_filter and I can't see any specific arguments to indicate user roles or an... | [
{
"answer_id": 27916,
"author": "byronyasgur",
"author_id": 6169,
"author_profile": "https://wordpress.stackexchange.com/users/6169",
"pm_score": 0,
"selected": false,
"text": "<p>My solution would be to first try out the plugin TinyMCE Advanced instead - it is fantastic and give you ver... | 2011/09/07 | [
"https://wordpress.stackexchange.com/questions/27914",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/274/"
] | Currently I have successfully added a row of shortcode buttons to the TinyMCE editor in WordPress. The problem is, only admins can see the row, and I need contributors and editors to see it too. I have checked the Codex for add\_action and add\_filter and I can't see any specific arguments to indicate user roles or any... | Your if statement wants the user to be able to posts AND pages, which only applies to admins and editors by default. Are you sure editors cannot see the buttons? If you want anybody who can edit posts to see the buttons (e.g. authors and contributors) take out the check for `edit_pages` or make it an or statement (whic... |
27,929 | <p>I am trying to use my own styles.css for inside the body of the visual editor for my pages. However, when i add</p>
<pre><code>add_editor_style('styles.css');
</code></pre>
<p>to the functions.php page it doesnt change anything (font color, boldness, etc) inside the body of the visual editor.</p>
<p>I use firebug... | [
{
"answer_id": 27930,
"author": "helenhousandi",
"author_id": 2226,
"author_profile": "https://wordpress.stackexchange.com/users/2226",
"pm_score": 3,
"selected": true,
"text": "<p>You don't have to specify a file for the editor style. Just use <code>add_editor_style();</code> in your <c... | 2011/09/07 | [
"https://wordpress.stackexchange.com/questions/27929",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8469/"
] | I am trying to use my own styles.css for inside the body of the visual editor for my pages. However, when i add
```
add_editor_style('styles.css');
```
to the functions.php page it doesnt change anything (font color, boldness, etc) inside the body of the visual editor.
I use firebug and check to see if it even load... | You don't have to specify a file for the editor style. Just use `add_editor_style();` in your `functions.php`, and then create a file called `editor-style.css` in your theme folder. You may want to look at some examples (e.g. Twenty Eleven) for some of the TinyMCE-specific rules, which **is** the stock visual editor yo... |
27,933 | <p>I'm having a problem with the_excerpt and can not find the answer anywhere...
I simply want to allow links to be clickable when they are displayed via the_excerpt! There has to be a function for this, rather than relying on a plugin. But I can't find it and the advanced excerpt plugins are so complex that I am una... | [
{
"answer_id": 27939,
"author": "Jeremy Jared",
"author_id": 5339,
"author_profile": "https://wordpress.stackexchange.com/users/5339",
"pm_score": 5,
"selected": true,
"text": "<p>You can use the script I found here:\n<a href=\"http://aaronrussell.co.uk/legacy/improving-wordpress-the_exc... | 2011/09/07 | [
"https://wordpress.stackexchange.com/questions/27933",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5205/"
] | I'm having a problem with the\_excerpt and can not find the answer anywhere...
I simply want to allow links to be clickable when they are displayed via the\_excerpt! There has to be a function for this, rather than relying on a plugin. But I can't find it and the advanced excerpt plugins are so complex that I am unable... | You can use the script I found here:
<http://aaronrussell.co.uk/legacy/improving-wordpress-the_excerpt/>
I've modified it to show links in the excerpt, and removed some of the other functions:
```
<?php
function keep_my_links($text) {
global $post;
if ( '' == $text ) {
$text = get_the_content('');
$text = a... |
27,936 | <p>A small and possibly simple consultation.
I'm loading pages via Ajax like this:</p>
<pre><code>jQuery("div.menu a").addClass("ajax");
var hash = window.location.hash.substr(1);
var href = jQuery('.ajax').each(function(){
var href = jQuery(this).attr('href');
if(hash==href.substr(0,href.length-5)){
... | [
{
"answer_id": 41882,
"author": "Michael Watts",
"author_id": 12993,
"author_profile": "https://wordpress.stackexchange.com/users/12993",
"pm_score": 1,
"selected": false,
"text": "<pre><code>//data stores the ajax response\nvar matches = data.match(/<title>(.*?)<\\/title>/);... | 2011/09/07 | [
"https://wordpress.stackexchange.com/questions/27936",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4451/"
] | A small and possibly simple consultation.
I'm loading pages via Ajax like this:
```
jQuery("div.menu a").addClass("ajax");
var hash = window.location.hash.substr(1);
var href = jQuery('.ajax').each(function(){
var href = jQuery(this).attr('href');
if(hash==href.substr(0,href.length-5)){
var toLoad... | ```
//data stores the ajax response
var matches = data.match(/<title>(.*?)<\/title>/);
var pageTitle = matches[1];
document.title = pageTitle;
``` |
27,941 | <p>Trying to get a post to show up at <a href="http://beernews.org/supporter/rare-beer-club/" rel="nofollow">http://beernews.org/supporter/rare-beer-club/</a> but am getting 404 instead. An example of what the page should look like is: <a href="http://beernews.org/brewery/5-rabbit-brewery/" rel="nofollow">http://beerne... | [
{
"answer_id": 27942,
"author": "Adam",
"author_id": 1697,
"author_profile": "https://wordpress.stackexchange.com/users/1697",
"pm_score": 1,
"selected": false,
"text": "<p>Nevermind. For some reason, I had to go to my permalinks page and click 'Save Changes' for this to show up. It is b... | 2011/09/07 | [
"https://wordpress.stackexchange.com/questions/27941",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1697/"
] | Trying to get a post to show up at <http://beernews.org/supporter/rare-beer-club/> but am getting 404 instead. An example of what the page should look like is: <http://beernews.org/brewery/5-rabbit-brewery/>. When I do a search, it shows up as an excerpt in the results. Just can't get the template single-supporter.php ... | Nevermind. For some reason, I had to go to my permalinks page and click 'Save Changes' for this to show up. It is bewildering. |
27,950 | <p>I have been working on a plugin for Wordpress, that updates an XML file with elements from the post. I have used a third party plugin to create the field for the XML, and so far that is working.</p>
<p>I am having a lot of trouble with the XML and the hook itself. I am using a DomDocument example from php4every1.co... | [
{
"answer_id": 27956,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": true,
"text": "<p>The 1 character output error is probably because you have a single space before <code><?php</code> or after <code... | 2011/09/07 | [
"https://wordpress.stackexchange.com/questions/27950",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8485/"
] | I have been working on a plugin for Wordpress, that updates an XML file with elements from the post. I have used a third party plugin to create the field for the XML, and so far that is working.
I am having a lot of trouble with the XML and the hook itself. I am using a DomDocument example from php4every1.com, and tha... | The 1 character output error is probably because you have a single space before `<?php` or after `?>`.
As far as it not doing anything, where is the fruits.xml file? this line:
```
$xml->load('fruits.xml');
```
in this context is looking for the file at:
```
/your/server/path/to/wp-admin/fruits.xml
```
Which I a... |
27,953 | <p>I'm trying to load a script from <code>functions.php</code> just when I'm on the front page. I set a static page called "home" in the reading options.</p>
<p>The home page loads the <code>front-page.php</code> template correctly but the conditional script loading doesn't work.</p>
<p>This is what I have in my <cod... | [
{
"answer_id": 27954,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": true,
"text": "<p>If you are doing this directly in <code>functions.php</code> you are doing it wrong. It is too early for conditional ... | 2011/09/07 | [
"https://wordpress.stackexchange.com/questions/27953",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8496/"
] | I'm trying to load a script from `functions.php` just when I'm on the front page. I set a static page called "home" in the reading options.
The home page loads the `front-page.php` template correctly but the conditional script loading doesn't work.
This is what I have in my `functions.php` file:
```
wp_register_scri... | If you are doing this directly in `functions.php` you are doing it wrong. It is too early for conditional tags to work.
This should be hooked to `wp_enqueue_scripts`, see [`wp_enqueue_script()`](http://codex.wordpress.org/Function_Reference/wp_enqueue_script) docs. |
27,962 | <p>I'm pretty new to WP, so please forgive any stupid questions and/or coding!</p>
<p>I'm using the following code in my index.php file to include content from another page:</p>
<pre><code><div id="tm-container">
<?php
$page = get_page_by_title('Today\'s Menu');
$content... | [
{
"answer_id": 27965,
"author": "helenhousandi",
"author_id": 2226,
"author_profile": "https://wordpress.stackexchange.com/users/2226",
"pm_score": 0,
"selected": false,
"text": "<p>Well, since you've got a <code>$content</code> variable, why not try the PHP function <code>substr()</code... | 2011/09/08 | [
"https://wordpress.stackexchange.com/questions/27962",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8497/"
] | I'm pretty new to WP, so please forgive any stupid questions and/or coding!
I'm using the following code in my index.php file to include content from another page:
```
<div id="tm-container">
<?php
$page = get_page_by_title('Today\'s Menu');
$content = apply_filters('the_content'... | Okay, I worked it out - fudging it slightly, but it works. I kept everything as is, and added `overflow:hidden` on `#tm-container`, then moved the page link outside `#tm-container`.
The biggest problem was that the contributing page contained a menu with many paragraph breaks, which meant that I was going to be unabl... |
27,981 | <p>i am trying to exclude multiple post thumbnails from attachments.</p>
<p>i have the following thumbnails setup in my functions.php:</p>
<pre><code>$thumb = new MultiPostThumbnails(array(
'label' => 'Client Logo',
'id' => 'client-logo',
'post_type' => 'clients'
)
);
$thumb = new MultiPostT... | [
{
"answer_id": 28023,
"author": "koskoz",
"author_id": 6938,
"author_profile": "https://wordpress.stackexchange.com/users/6938",
"pm_score": 0,
"selected": false,
"text": "<p>I've only modified the 'exclude' line. It's not tested but it should work.</p>\n\n<pre><code><?php\n $thu... | 2011/09/08 | [
"https://wordpress.stackexchange.com/questions/27981",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8338/"
] | i am trying to exclude multiple post thumbnails from attachments.
i have the following thumbnails setup in my functions.php:
```
$thumb = new MultiPostThumbnails(array(
'label' => 'Client Logo',
'id' => 'client-logo',
'post_type' => 'clients'
)
);
$thumb = new MultiPostThumbnails(array(
'label' =... | ```
$thumb_id = get_post_thumbnail_id(get_the_ID());
$bg_id = MultiPostThumbnails::get_post_thumbnail_id('work', 'background-image', $post->ID);
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $post->ID,
'exclude'... |
27,986 | <p>It seems that my contact form's ajax javascript and the custom.js that I'm using for my drop-down navigation are interfering with each other.
The contact form's ajax fuction will only work properly if I won't call the "custom.js" in the header.
Furthermore I've had troubles using some jquery sliders, too, ... | [
{
"answer_id": 28023,
"author": "koskoz",
"author_id": 6938,
"author_profile": "https://wordpress.stackexchange.com/users/6938",
"pm_score": 0,
"selected": false,
"text": "<p>I've only modified the 'exclude' line. It's not tested but it should work.</p>\n\n<pre><code><?php\n $thu... | 2011/09/08 | [
"https://wordpress.stackexchange.com/questions/27986",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6903/"
] | It seems that my contact form's ajax javascript and the custom.js that I'm using for my drop-down navigation are interfering with each other.
The contact form's ajax fuction will only work properly if I won't call the "custom.js" in the header.
Furthermore I've had troubles using some jquery sliders, too, because somet... | ```
$thumb_id = get_post_thumbnail_id(get_the_ID());
$bg_id = MultiPostThumbnails::get_post_thumbnail_id('work', 'background-image', $post->ID);
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $post->ID,
'exclude'... |
28,005 | <p>I'm trying to add a specific role to manage my custom post types and I'm stuck at the very beginning.</p>
<p>I've added <code>add_role()</code> to the functions.php file as following:</p>
<pre><code>add_role('resourcerer', 'Resourcerer', array('read_internal_jobs'));
</code></pre>
<p>and created a user with that ... | [
{
"answer_id": 28010,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": true,
"text": "<p>That's because the \"normal\" capabilites that are needed to login are missing. You should simply load the capabilit... | 2011/09/08 | [
"https://wordpress.stackexchange.com/questions/28005",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1343/"
] | I'm trying to add a specific role to manage my custom post types and I'm stuck at the very beginning.
I've added `add_role()` to the functions.php file as following:
```
add_role('resourcerer', 'Resourcerer', array('read_internal_jobs'));
```
and created a user with that role. However, when I try to login with a ne... | That's because the "normal" capabilites that are needed to login are missing. You should simply load the capabilites of some default role and attach them to your custom role before using it on a user.
---
**EDIT:** Solution from @dashalune (OP):
```
add_role('resourcerer', 'Resourcerer');
$role =& get_role('resourc... |
28,021 | <p>Why I'm doing this you might ask? I'm developing a website for a business with a portfolio where the gallery items are posts. These posts are populated through custom fields and category selections, nothing else.</p>
<p>For each item, there could be a title/content or not, it depends on the item in question and tha... | [
{
"answer_id": 28217,
"author": "farinspace",
"author_id": 466,
"author_profile": "https://wordpress.stackexchange.com/users/466",
"pm_score": 0,
"selected": false,
"text": "<p>A quick and dirty solution would be to use javascript/jQuery ... do some detection to check which post type it ... | 2011/09/08 | [
"https://wordpress.stackexchange.com/questions/28021",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1517/"
] | Why I'm doing this you might ask? I'm developing a website for a business with a portfolio where the gallery items are posts. These posts are populated through custom fields and category selections, nothing else.
For each item, there could be a title/content or not, it depends on the item in question and that's entire... | If the post content, title and excerpt are empty [WordPress will prevent the insertion of the post](http://core.trac.wordpress.org/browser/tags/3.2.1/wp-includes/post.php#L2450). You can trick WordPress by first filtering the input array so empty values are set to something else, and then later resetting these values b... |
28,039 | <p>Where do I place the PHP code to insert or not insert a menu item based upon some condition, i.e. value of another PHP variable like so:</p>
<pre><code>$listItem = '';
<?php if ($condition)
{
$listItem = '<li id="menu-item-44" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-4... | [
{
"answer_id": 28059,
"author": "GavinR",
"author_id": 2001,
"author_profile": "https://wordpress.stackexchange.com/users/2001",
"pm_score": 1,
"selected": false,
"text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items\" rel=\"nofollow\">wp_get_nav_m... | 2011/09/08 | [
"https://wordpress.stackexchange.com/questions/28039",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7012/"
] | Where do I place the PHP code to insert or not insert a menu item based upon some condition, i.e. value of another PHP variable like so:
```
$listItem = '';
<?php if ($condition)
{
$listItem = '<li id="menu-item-44" class="menu-item menu-item-type-taxonomy menu-item-object-category menu-item-44"><a title="Our Rea... | Use [wp\_get\_nav\_menu\_items](http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items) to iterate through the menu items, modifying the one that you want to in the loop. See the [example code here](http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items#Examples) for more information. |
28,057 | <p>i want get the "issue-cover" from archive page list, i done it. but it will cant get the meta value when i update/add new a post to the archice page.</p>
<pre class="lang-php prettyprint-override"><code><div class="monthly_archive">
<?php $values = get_post_custom_values("issue-cover");
if (... | [
{
"answer_id": 28061,
"author": "tollmanz",
"author_id": 4850,
"author_profile": "https://wordpress.stackexchange.com/users/4850",
"pm_score": 0,
"selected": false,
"text": "<p>Try sending the post id to the function:</p>\n\n<p><code>$values = get_post_custom_values(\"issue-cover\", $pos... | 2011/09/09 | [
"https://wordpress.stackexchange.com/questions/28057",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7331/"
] | i want get the "issue-cover" from archive page list, i done it. but it will cant get the meta value when i update/add new a post to the archice page.
```php
<div class="monthly_archive">
<?php $values = get_post_custom_values("issue-cover");
if (isset($values[0])) {
?>
<a target="_blank" href... | Just wondering why you are using $values = get\_post\_custom\_values("issue-cover"); so many times. You are missing the post->ID argument as the second parameter. You only need to define this variable once and then use it over and over.
I'm also wondering why you don't use post-thumbnails to solve this. There are two... |