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 |
|---|---|---|---|---|---|---|
95,054 | <p>I am trying to use the following code to check for my custom field for a value of ZERO to then display my div</p>
<pre><code><?php
$mp_price_sort = get_post_meta('mp_product_price');
if ($mp_price_sort == '0') { ?>
<div><?php echo do_shortcode('[shortcodes]'.$mp_buy_button.'[/shortcodes]'); ?&g... | [
{
"answer_id": 95055,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 3,
"selected": true,
"text": "<p>You are using get_post_meta incorrectly, so it is returning FALSE every time. As PHP equates '0' and FALSE, yo... | 2013/04/08 | [
"https://wordpress.stackexchange.com/questions/95054",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24067/"
] | I am trying to use the following code to check for my custom field for a value of ZERO to then display my div
```
<?php
$mp_price_sort = get_post_meta('mp_product_price');
if ($mp_price_sort == '0') { ?>
<div><?php echo do_shortcode('[shortcodes]'.$mp_buy_button.'[/shortcodes]'); ?></div>
<?php } ?>
```
Howev... | You are using get\_post\_meta incorrectly, so it is returning FALSE every time. As PHP equates '0' and FALSE, your div will always be displayed.
The correct syntax for get\_post\_meta is:
```
<?php $meta_values = get_post_meta($post_id, $key, $single); ?>
```
where $post\_id is the only required argument. |
95,077 | <p>I realize that this seems to be a common problem and I've read through a lot of the posts but it's just not making sense. I was wondering if someone could take a look at my code.</p>
<p>What I am trying to do is build a home page that pulls posts from my custom post types into one loop. It's looking like almost ev... | [
{
"answer_id": 95083,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>For altering the main query, the preferred method is to use the <a href=\"http://codex.wordpress.org/Plugin_API/Acti... | 2013/04/09 | [
"https://wordpress.stackexchange.com/questions/95077",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27629/"
] | I realize that this seems to be a common problem and I've read through a lot of the posts but it's just not making sense. I was wondering if someone could take a look at my code.
What I am trying to do is build a home page that pulls posts from my custom post types into one loop. It's looking like almost every article... | For altering the main query, the preferred method is to use the [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) action rather than calling `query_posts` in the template. It's fairly safe to say at this point that any use of `query_posts` in the template is simply wrong, though sa... |
95,089 | <p>I'm currently working on a WordPress site and whenever in the admin I go the Appearance > Menus page I get the following error:</p>
<blockquote>
<p>ErrorException: Runtime Notice: Declaration of Walker_Nav_Menu_Edit::start_lvl() should be compatible with that of Walker_Nav_Menu::start_lvl() in wp-admin/includes/n... | [
{
"answer_id": 95098,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 6,
"selected": true,
"text": "<p>From <code>class Walker_Nav_Menu</code>:</p>\n\n<pre><code>function start_lvl( &$output, $depth = 0, $args = array(... | 2013/04/09 | [
"https://wordpress.stackexchange.com/questions/95089",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6616/"
] | I'm currently working on a WordPress site and whenever in the admin I go the Appearance > Menus page I get the following error:
>
> ErrorException: Runtime Notice: Declaration of Walker\_Nav\_Menu\_Edit::start\_lvl() should be compatible with that of Walker\_Nav\_Menu::start\_lvl() in wp-admin/includes/nav-menu.php l... | From `class Walker_Nav_Menu`:
```
function start_lvl( &$output, $depth = 0, $args = array() )
```
Your child class *must* use the same signature: three arguments, the first one passed by reference. Every difference will raise the error you got.
Note that `$args` defaults to an empty array, but you get an instance o... |
95,091 | <p>So I have created this widget which pulls a number of posts. And the query is being cached via transients. But I need the transient to be deleted whenever a post is saved so the query can be refreshed.</p>
<p>Have a look at this code snippet.</p>
<pre><code>add_action( 'save_post', 'delete_transient' );
function ... | [
{
"answer_id": 95093,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>So I came up with this hacky work around for now but it works.</p>\n\n<pre><code>add_action( 'save_post', 'delete_... | 2013/04/09 | [
"https://wordpress.stackexchange.com/questions/95091",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | So I have created this widget which pulls a number of posts. And the query is being cached via transients. But I need the transient to be deleted whenever a post is saved so the query can be refreshed.
Have a look at this code snippet.
```
add_action( 'save_post', 'delete_transient' );
function delete_transient() {
... | Use a widget cache and forget the actual number of active widgets.
In your widget add this to your method `widget()`:
```
public function widget( $args, $instance )
{
// get the cache
$cache = wp_cache_get( 'UNIQUE_WIDGET_IDENTIFIER', 'widget' );
if ( !is_array( $cache ) )
$cache = array();
... |
95,099 | <p>I am trying to make it so that I can output to the console in PHP. I have already installed FireFox with the FireBug and FirePHP addons.</p>
<p>I downloaded the 'FirePHPCore Server Library' from <a href="http://firephp.org/" rel="nofollow noreferrer">here</a> and I uploaded it into 'wp-content/themes/Jupiter/includ... | [
{
"answer_id": 95101,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 3,
"selected": true,
"text": "<p>I use it including the file (Match you actual file location):</p>\n\n<p><code>require '../../FirePHPCore/fb.php... | 2013/04/09 | [
"https://wordpress.stackexchange.com/questions/95099",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24655/"
] | I am trying to make it so that I can output to the console in PHP. I have already installed FireFox with the FireBug and FirePHP addons.
I downloaded the 'FirePHPCore Server Library' from [here](http://firephp.org/) and I uploaded it into 'wp-content/themes/Jupiter/includes' (my theme is called Jupiter).
Then, from w... | I use it including the file (Match you actual file location):
`require '../../FirePHPCore/fb.php';`
and then call by using
```
fb( $variable, 'Message Title');
```
Be sure that you've installed and activated the [FirePHP addon](https://addons.mozilla.org/en-US/firefox/addon/firephp/) on Firefox.
There's also a [W... |
95,125 | <p>I'm trying to setup upload for for attachments for my custom post form.</p>
<p>At first I add to my <code>form</code> tag <code>enctype="multipart/form-data"</code>
<p>For testing purposes I have two upload forms, but in future I'm gonna implement only one form and use jQuery to append as many forms as I want.</p>
... | [
{
"answer_id": 95133,
"author": "Rajeev Vyas",
"author_id": 6961,
"author_profile": "https://wordpress.stackexchange.com/users/6961",
"pm_score": 3,
"selected": true,
"text": "<p>May be you are not returning correctly from function, Try this,</p>\n\n<pre><code>function insert_attachment(... | 2013/04/09 | [
"https://wordpress.stackexchange.com/questions/95125",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29076/"
] | I'm trying to setup upload for for attachments for my custom post form.
At first I add to my `form` tag `enctype="multipart/form-data"`
For testing purposes I have two upload forms, but in future I'm gonna implement only one form and use jQuery to append as many forms as I want.
```
<fieldset class="images">
... | May be you are not returning correctly from function, Try this,
```
function insert_attachment($file_handler, $post_id, $setthumb=false) {
// check to make sure its a successful upload
// changes start
if ($_FILES[$file_handler]['error'] !== UPLOAD_ERR_OK) {
return __return_false();
}
// ch... |
95,126 | <p>i have been using this code to get all fields from a specific group:</p>
<pre><code><?php
$GroupOrPostSlug = 'acf_specialgroup';
//or insert the ID of your fields Group.
$groupID='';
global $wpdb;
if (empty($groupID))
{$groupID = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '$GroupOrPo... | [
{
"answer_id": 106002,
"author": "Dejan",
"author_id": 35141,
"author_profile": "https://wordpress.stackexchange.com/users/35141",
"pm_score": 3,
"selected": false,
"text": "<p>Thank you so much for your post, I spent half day to figure out how to get field names by their group.</p>\n\n<... | 2013/04/09 | [
"https://wordpress.stackexchange.com/questions/95126",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33667/"
] | i have been using this code to get all fields from a specific group:
```
<?php
$GroupOrPostSlug = 'acf_specialgroup';
//or insert the ID of your fields Group.
$groupID='';
global $wpdb;
if (empty($groupID))
{$groupID = $wpdb->get_var("SELECT ID FROM $wpdb->posts WHERE post_name = '$GroupOrPostSlug' ");}
if (empty($g... | Thank you so much for your post, I spent half day to figure out how to get field names by their group.
If you have field names, you can easily get their values: get\_field($field['name']);
**EXAMPLE HOW TO GET IMAGES FOR SLIDER**
```
<?php
//or insert the ID of your fields Group.
... |
95,139 | <p>Is there a way to display the WordPress register form on a custom page the way one would use <code><?php get_search_form( $echo ); ?></code> for a search form? If not how would one go about creating such a template? I would like to do this without Ajax btw. Any pointers/ideas are very welcome!</p>
| [
{
"answer_id": 95144,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 3,
"selected": true,
"text": "<p>Here is a function I've Used Before:</p>\n\n<pre><code>function registration_form_wpa95139(){\n if (is_user... | 2013/04/09 | [
"https://wordpress.stackexchange.com/questions/95139",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18937/"
] | Is there a way to display the WordPress register form on a custom page the way one would use `<?php get_search_form( $echo ); ?>` for a search form? If not how would one go about creating such a template? I would like to do this without Ajax btw. Any pointers/ideas are very welcome! | Here is a function I've Used Before:
```
function registration_form_wpa95139(){
if (is_user_logged_in()) return;
?>
<div class="Registration">
<div id="register-form">
<div class="title">
<h1><?php _e('Register your Account'); ?></h1>
<span><?php _e('Sign... |
95,147 | <p>My current <code><title></code> tags are like this:</p>
<blockquote>
<p>Blog post title | Site name</p>
</blockquote>
<p>How do I remove "Site name" so that the <code><title></code> tags will be like this:</p>
<blockquote>
<p>Blog post title</p>
</blockquote>
<p>Except, of course, on the front pa... | [
{
"answer_id": 95149,
"author": "CBeTJlu4ok",
"author_id": 29076,
"author_profile": "https://wordpress.stackexchange.com/users/29076",
"pm_score": -1,
"selected": false,
"text": "<pre><code><?php wp_title(false); ?>\n</code></pre>\n\n<p>Try this and also read more <a href=\"http://... | 2013/04/09 | [
"https://wordpress.stackexchange.com/questions/95147",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31187/"
] | My current `<title>` tags are like this:
>
> Blog post title | Site name
>
>
>
How do I remove "Site name" so that the `<title>` tags will be like this:
>
> Blog post title
>
>
>
Except, of course, on the front page, where the `<title>` tag should be:
>
> Site name
>
>
>
Please take into account that ... | The best (and easiest) thing to do is to use the `wp_title` *filter*.
First, clean up your call to `<?php wp_title(); ?>` in your template. Replace what you have with this:
```
wp_title( '|', true, 'right' );
```
Then, in `functions.php` (or in a child Theme `functions.php`; normal caveats apply), add the fol... |
95,161 | <p>This is the scenario:
I have multiple pages that all have a custom field named "Location"
Those pages all have child-pages with the custom field of "size_m2".</p>
<p>What I want is to do a normal meta_query to list all pages with let say "size_m2 >= 55", but only if the parent page have "Location == Stockholm".</p... | [
{
"answer_id": 95149,
"author": "CBeTJlu4ok",
"author_id": 29076,
"author_profile": "https://wordpress.stackexchange.com/users/29076",
"pm_score": -1,
"selected": false,
"text": "<pre><code><?php wp_title(false); ?>\n</code></pre>\n\n<p>Try this and also read more <a href=\"http://... | 2013/04/09 | [
"https://wordpress.stackexchange.com/questions/95161",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26980/"
] | This is the scenario:
I have multiple pages that all have a custom field named "Location"
Those pages all have child-pages with the custom field of "size\_m2".
What I want is to do a normal meta\_query to list all pages with let say "size\_m2 >= 55", but only if the parent page have "Location == Stockholm".
Do i need... | The best (and easiest) thing to do is to use the `wp_title` *filter*.
First, clean up your call to `<?php wp_title(); ?>` in your template. Replace what you have with this:
```
wp_title( '|', true, 'right' );
```
Then, in `functions.php` (or in a child Theme `functions.php`; normal caveats apply), add the fol... |
95,182 | <p>I'm new to wordpress and I'm currently converting an HTML/CSS site I made to wordpress to make it easier for my client to edit it from the admin panel.</p>
<p>I have provided 3 screenshots and I'll refer to them here.</p>
<p>The first screenshot shows how my website looks so far. It's using a template I made calle... | [
{
"answer_id": 95189,
"author": "user1606423",
"author_id": 19511,
"author_profile": "https://wordpress.stackexchange.com/users/19511",
"pm_score": 2,
"selected": false,
"text": "<p>These links should help you:\n<a href=\"http://codex.wordpress.org/The_Loop\" rel=\"nofollow\">http://code... | 2013/04/09 | [
"https://wordpress.stackexchange.com/questions/95182",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31205/"
] | I'm new to wordpress and I'm currently converting an HTML/CSS site I made to wordpress to make it easier for my client to edit it from the admin panel.
I have provided 3 screenshots and I'll refer to them here.
The first screenshot shows how my website looks so far. It's using a template I made called homepage.php (s... | These links should help you:
<http://codex.wordpress.org/The_Loop>
<http://codex.wordpress.org/Function_Reference/wp_get_nav_menu_items>
with this two techniks you can give your client the ability to change the content and the navigation. For these you have to edit your theme and insert the snippets on the placese yo... |
95,198 | <p>I created a custom post type with the following code:</p>
<pre><code>add_action('init', 'create_trans_career');
function create_trans_career() {
//Arguments to create post type.
$args = array(
'labels' => array(
'name' => __('Career', 'trans'),
'singular_name' => __... | [
{
"answer_id": 111987,
"author": "welbyaudry",
"author_id": 37260,
"author_profile": "https://wordpress.stackexchange.com/users/37260",
"pm_score": 3,
"selected": false,
"text": "<p>Add this to your functions.php:</p>\n\n<pre><code>/* Flush rewrite rules for custom post types. */\nadd_ac... | 2013/04/09 | [
"https://wordpress.stackexchange.com/questions/95198",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27914/"
] | I created a custom post type with the following code:
```
add_action('init', 'create_trans_career');
function create_trans_career() {
//Arguments to create post type.
$args = array(
'labels' => array(
'name' => __('Career', 'trans'),
'singular_name' => __('Career', 'trans'),
... | Add this to your functions.php:
```
/* Flush rewrite rules for custom post types. */
add_action( 'after_switch_theme', 'bt_flush_rewrite_rules' );
/* Flush your rewrite rules */
function bt_flush_rewrite_rules() {
flush_rewrite_rules();
}
```
Then change your theme to a different theme and then set it back aga... |
95,250 | <p>As the title says, I have a multi-site setup and the apperance is customized with child themes.</p>
<blockquote>
<p>The main site: <strong>themainsite.com</strong></p>
<p>Secondary site <strong>foo.com</strong></p>
</blockquote>
<p>When you look into the source code of foo.com, you see some URLs referencing to the m... | [
{
"answer_id": 95253,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 0,
"selected": false,
"text": "<p><strong>Note</strong>: I'm going for an answer, because for a comment this is quite too much text. With your ... | 2013/04/10 | [
"https://wordpress.stackexchange.com/questions/95250",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31039/"
] | As the title says, I have a multi-site setup and the apperance is customized with child themes.
>
> The main site: **themainsite.com**
>
>
> Secondary site **foo.com**
>
>
>
When you look into the source code of foo.com, you see some URLs referencing to the mainsite. Such as:
```
<link rel="stylesheet"
href="... | I fixed it with changing the multi-site setup from sub-folders to sub-domains. |
95,297 | <p>I know PHP well but I'm new to Wordpress. I got an incomplete Wordpress website. It has a static home page with an Aweber newsletter form. I tried digging into installed theme and in <code>home.php</code> I came across:</p>
<pre><code><div class="home-infobox">
<?php if ( is_active_sidebar( 'homepage-infob... | [
{
"answer_id": 95303,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>You are looking at, as the function name suggests, a <a href=\"http://codex.wordpress.org/Function_Reference/... | 2013/04/10 | [
"https://wordpress.stackexchange.com/questions/95297",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31259/"
] | I know PHP well but I'm new to Wordpress. I got an incomplete Wordpress website. It has a static home page with an Aweber newsletter form. I tried digging into installed theme and in `home.php` I came across:
```
<div class="home-infobox">
<?php if ( is_active_sidebar( 'homepage-infobox' ) ) : ?>
<?php dynamic_sid... | 1. The contents of `dynamic_sidebar` are pulled from the widgets associated with this "Sidebar" aka "Widget Area" in `wp-admin`, as @s\_ha\_dum answered. There is no template file for the sidebar itself. Visit `/wp-admin/widgets.php` under `Appearance` -> `Widgets` and find the widget area titled `homepage-infobox`. Yo... |
95,300 | <p>I'm working on airsoft website using woocommerce. One of my client's needs is to prevent a user to register if his name or mail is in a blacklist (I don't know yet if I'll use a csv file, a json or a simple array).</p>
<p>So I have to execute some validations before insert the user to the database. But I didn't suc... | [
{
"answer_id": 95313,
"author": "Kayo",
"author_id": 26994,
"author_profile": "https://wordpress.stackexchange.com/users/26994",
"pm_score": 0,
"selected": false,
"text": "<p>Perhaps use the user registration hook:\n<a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/user_re... | 2013/04/10 | [
"https://wordpress.stackexchange.com/questions/95300",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23524/"
] | I'm working on airsoft website using woocommerce. One of my client's needs is to prevent a user to register if his name or mail is in a blacklist (I don't know yet if I'll use a csv file, a json or a simple array).
So I have to execute some validations before insert the user to the database. But I didn't succeed in fi... | If you examine the wp\_insert\_user() function, you can see there are a myriad of filters and actions that are called throughout the process. The first is a filter called pre\_user\_login on the username.
Line 1304 of wp-includes/user.php:
```
$user_login = apply_filters('pre_user_login', $user_login);
```
You coul... |
95,318 | <p>I would like to move my large php functions out of the index or template files and into the function.php file. Would it be something like this?</p>
<pre><code>function grab_code(???) {
??? .= '<div>some HTML-PHP code I monkeyed together</div>';
return ????;
}
add_filter('???', 'grab_code');
<... | [
{
"answer_id": 95308,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>Each auto-draft gets its own ID, each revision, each nav item, page, custom post type …</p>\n\n<p>The actual ID of a po... | 2013/04/10 | [
"https://wordpress.stackexchange.com/questions/95318",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8514/"
] | I would like to move my large php functions out of the index or template files and into the function.php file. Would it be something like this?
```
function grab_code(???) {
??? .= '<div>some HTML-PHP code I monkeyed together</div>';
return ????;
}
add_filter('???', 'grab_code');
```
Then in the template ... | Each auto-draft gets its own ID, each revision, each nav item, page, custom post type …
The actual ID of a post should be irrelevant, this is really just needed for the database and ugly permalinks.
You cannot get the last 30 items by inspecting the post ID only.
Install a [REST API](https://wordpress.stackexchange.... |
95,341 | <p>I have a parent theme and a child theme, I would like to override the spanish .mo and .po files in the parent theme (or add them if they are not present in the parent theme) with the es_ES ones in my child theme. I added the folder with the modified mo and po files in the child theme with the same folder name as in ... | [
{
"answer_id": 199733,
"author": "jim.duck",
"author_id": 78337,
"author_profile": "https://wordpress.stackexchange.com/users/78337",
"pm_score": -1,
"selected": false,
"text": "<p>If you want to change more than just the stylesheet, your child theme can override any file in the parent t... | 2013/04/10 | [
"https://wordpress.stackexchange.com/questions/95341",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31279/"
] | I have a parent theme and a child theme, I would like to override the spanish .mo and .po files in the parent theme (or add them if they are not present in the parent theme) with the es\_ES ones in my child theme. I added the folder with the modified mo and po files in the child theme with the same folder name as in th... | ```
you may use this below code for your problem:
[1]: https://i.stack.imgur.com/5aX1D.png
```
or use below code:
```
add_action( 'after_setup_theme', function ()
{
load_theme_textdomain( 'your parent theme name', get_stylesheet_directory() . '/languages/' );
load_child_theme_textdomain( 'your child... |
95,346 | <p>I need to know if there exists a script or plugin that will add a button the "Settings > Media Settings" that will rebuild all thumbnails to match the current media size settings.</p>
<p>The problem this seeks to solve is when the site owner decides he/she would like different thumbnail and featured image sizes aft... | [
{
"answer_id": 199733,
"author": "jim.duck",
"author_id": 78337,
"author_profile": "https://wordpress.stackexchange.com/users/78337",
"pm_score": -1,
"selected": false,
"text": "<p>If you want to change more than just the stylesheet, your child theme can override any file in the parent t... | 2013/04/10 | [
"https://wordpress.stackexchange.com/questions/95346",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6620/"
] | I need to know if there exists a script or plugin that will add a button the "Settings > Media Settings" that will rebuild all thumbnails to match the current media size settings.
The problem this seeks to solve is when the site owner decides he/she would like different thumbnail and featured image sizes after having ... | ```
you may use this below code for your problem:
[1]: https://i.stack.imgur.com/5aX1D.png
```
or use below code:
```
add_action( 'after_setup_theme', function ()
{
load_theme_textdomain( 'your parent theme name', get_stylesheet_directory() . '/languages/' );
load_child_theme_textdomain( 'your child... |
95,354 | <p>i have this code to limit the comments per user. </p>
<pre><code><!-- #only one comment -->
<?php global $current_user,$post;
$usercomment = get_comments(array('author_email' => $current_user->user_email, 'post_id' => $post->ID));
if($usercomment) {
echo "Thank you!";
}
else {
comment_f... | [
{
"answer_id": 95356,
"author": "ekard9",
"author_id": 25867,
"author_profile": "https://wordpress.stackexchange.com/users/25867",
"pm_score": 0,
"selected": false,
"text": "<p><code>get_the_author_meta( 'customfield' )</code> should give you the information that you can use in your cond... | 2013/04/10 | [
"https://wordpress.stackexchange.com/questions/95354",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30792/"
] | i have this code to limit the comments per user.
```
<!-- #only one comment -->
<?php global $current_user,$post;
$usercomment = get_comments(array('author_email' => $current_user->user_email, 'post_id' => $post->ID));
if($usercomment) {
echo "Thank you!";
}
else {
comment_form();
}
?>
```
How can edit thi... | You can check the user meta for the key you want:
```
if ( get_user_meta('phone') !='' ) {
echo "Your phone is not set";
}
else {
comment_form();
}
``` |
95,420 | <p>When you are at the comments menu in wp-admin you only see 20 comments at the time, so if you want to delete alla comments you can <strong>ONLY</strong> mark the 20 comments you see on current page. It dosent mark comments that are on the next page.</p>
<p>Found a solution but dont know where to look for it</p>
<p... | [
{
"answer_id": 95470,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 1,
"selected": false,
"text": "<p>That value is set on a per user basis and saved as user meta. We can intercept and modify it to a fixed valu... | 2013/04/11 | [
"https://wordpress.stackexchange.com/questions/95420",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21256/"
] | When you are at the comments menu in wp-admin you only see 20 comments at the time, so if you want to delete alla comments you can **ONLY** mark the 20 comments you see on current page. It dosent mark comments that are on the next page.
Found a solution but dont know where to look for it
In WP-admin -> Screen layout ... | You can use
```
add_filter('edit_comments_per_page', 'return_999');
function return_999(){
return 999;
}
```
since the user options are filtered in the `WP_List_Table::get_items_per_page()` class method :
```
/**
* Get number of items to display on a single page
*
* @since 3.1.0
* @access protected
*
* @r... |
95,434 | <p>I am trying to create a new sidebar. For that I have used the following code:</p>
<p>In <code>functions.php</code></p>
<pre><code>if ( function_exists('register_sidebar') )
register_sidebar();
if ( function_exists ('register_sidebar')) {
register_sidebar ('sidebar-custom');
}
</code></pre>
<p>Then I created a f... | [
{
"answer_id": 95459,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>Two problems. To register the sidebar you need to pass a minimum of the 'id'.</p>\n\n<pre><code>if ( function... | 2013/04/11 | [
"https://wordpress.stackexchange.com/questions/95434",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28044/"
] | I am trying to create a new sidebar. For that I have used the following code:
In `functions.php`
```
if ( function_exists('register_sidebar') )
register_sidebar();
if ( function_exists ('register_sidebar')) {
register_sidebar ('sidebar-custom');
}
```
Then I created a file called `sidebar-custom.php`.The code for... | Register sidebar.
```
add_action( 'widgets_init', 'wpse_123456_widgets_init' );
function wpse_123456_widgets_init() {
$args = array(
'name' => __( 'Sidebar name', 'theme_text_domain' ),
'id' => 'unique-sidebar-id',
'description' => '',
'class' => '',
... |
95,464 | <p>I have built a Wordpress plugin that allows the user to export all pages, with their levels and urls, to a csv file. </p>
<p>The problem I have is that I keep getting error messages when trying to export the csv file:</p>
<blockquote>
<p>Warning: Cannot modify header information - headers already sent</p>
</blo... | [
{
"answer_id": 95465,
"author": "Rajeev Vyas",
"author_id": 6961,
"author_profile": "https://wordpress.stackexchange.com/users/6961",
"pm_score": 4,
"selected": true,
"text": "<p>Move your download/output code into admin_init hook. This hook is called before anything is output. It should... | 2013/04/11 | [
"https://wordpress.stackexchange.com/questions/95464",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3362/"
] | I have built a Wordpress plugin that allows the user to export all pages, with their levels and urls, to a csv file.
The problem I have is that I keep getting error messages when trying to export the csv file:
>
> Warning: Cannot modify header information - headers already sent
>
>
>
I have checked the config &... | Move your download/output code into admin\_init hook. This hook is called before anything is output. It should work.
```
<?php
/*
Plugin Name: Your Site's Functionality Plugin
Description: All of the important functionality of your site belongs in this.
Version: 0.1
License: GPL
Author: Your Name
Author URI: yoururl... |
95,469 | <p>I have a website made with wordpress which includes recipes. Now I would like to add the "photo" <code>hrecipe</code> Microformat tag in order to have a thumbnail on Google searches (<a href="http://support.google.com/webmasters/bin/answer.py?hl=en&answer=173379" rel="nofollow" title="hrecipe">hrecipe photo tag<... | [
{
"answer_id": 95488,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 3,
"selected": true,
"text": "<p>Use the filter <code>post_thumbnail_html</code>. The callback takes 5 parameters, the first (<code>$html</cod... | 2013/04/11 | [
"https://wordpress.stackexchange.com/questions/95469",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17691/"
] | I have a website made with wordpress which includes recipes. Now I would like to add the "photo" `hrecipe` Microformat tag in order to have a thumbnail on Google searches ([hrecipe photo tag](http://support.google.com/webmasters/bin/answer.py?hl=en&answer=173379 "hrecipe"))
My recipes pictures come from the featured i... | Use the filter `post_thumbnail_html`. The callback takes 5 parameters, the first (`$html`) is the one that's returned and that we modify, and the others can be helpful to build the modification.
```
add_filter( 'post_thumbnail_html', 'add_tag_to_featured_wpse_95469', 10, 5 );
function add_tag_to_featured_wpse_95469( ... |
95,490 | <p>on my site user profiles can be accessed on /user/xxx. Now i created a rewrite rule and all user links are handled on the template page. But how can i access the xxx(user) in the template file?
The page should display the profile of xxx.
Rewite rules:</p>
<pre><code>add_filter( 'query_vars', 'wpleet_rewrite_add_var... | [
{
"answer_id": 95488,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 3,
"selected": true,
"text": "<p>Use the filter <code>post_thumbnail_html</code>. The callback takes 5 parameters, the first (<code>$html</cod... | 2013/04/11 | [
"https://wordpress.stackexchange.com/questions/95490",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31336/"
] | on my site user profiles can be accessed on /user/xxx. Now i created a rewrite rule and all user links are handled on the template page. But how can i access the xxx(user) in the template file?
The page should display the profile of xxx.
Rewite rules:
```
add_filter( 'query_vars', 'wpleet_rewrite_add_var' );
function ... | Use the filter `post_thumbnail_html`. The callback takes 5 parameters, the first (`$html`) is the one that's returned and that we modify, and the others can be helpful to build the modification.
```
add_filter( 'post_thumbnail_html', 'add_tag_to_featured_wpse_95469', 10, 5 );
function add_tag_to_featured_wpse_95469( ... |
95,526 | <p>I have my custome theme in wordpress.This is the path of my custome theme.
<strong>C:\wamp\www\wordpress2\wp-content\themes\sscy1002\sscy1002</strong></p>
<p>I have created a Page in wordpress which contains some form elements. Here is my Page Code :</p>
<pre><code> <form action="<?php bloginfo('stylesheet_d... | [
{
"answer_id": 106844,
"author": "Shobhit",
"author_id": 35429,
"author_profile": "https://wordpress.stackexchange.com/users/35429",
"pm_score": -1,
"selected": false,
"text": "<p>Please replace form action path from <code><?php bloginfo('stylesheet_directory'); ?></code> to <code>... | 2013/04/12 | [
"https://wordpress.stackexchange.com/questions/95526",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26188/"
] | I have my custome theme in wordpress.This is the path of my custome theme.
**C:\wamp\www\wordpress2\wp-content\themes\sscy1002\sscy1002**
I have created a Page in wordpress which contains some form elements. Here is my Page Code :
```
<form action="<?php bloginfo('stylesheet_directory'); ?>/Query.php" enctype="multi... | You can try to use functions.php to handle the form submission and send the data via AJAX.
Add a hidden field in your form with the action to be taken (on functions.php):
```
<input type="hidden" name="action" value="save_contact"/>
```
In you footer.php add the jQuery code to handle the AJAX request:
```
jQuery('... |
95,535 | <p>I'm extending the search functionality by adding custom query vars to the search query object via <code>pre_get_posts</code> so that it'll be able to include tax_query and meta_query as search conditions. Everything works except when the query var <code>s</code> is empty, Wordpress redirects to the archive page whic... | [
{
"answer_id": 106844,
"author": "Shobhit",
"author_id": 35429,
"author_profile": "https://wordpress.stackexchange.com/users/35429",
"pm_score": -1,
"selected": false,
"text": "<p>Please replace form action path from <code><?php bloginfo('stylesheet_directory'); ?></code> to <code>... | 2013/04/12 | [
"https://wordpress.stackexchange.com/questions/95535",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6232/"
] | I'm extending the search functionality by adding custom query vars to the search query object via `pre_get_posts` so that it'll be able to include tax\_query and meta\_query as search conditions. Everything works except when the query var `s` is empty, Wordpress redirects to the archive page which is not ideal because ... | You can try to use functions.php to handle the form submission and send the data via AJAX.
Add a hidden field in your form with the action to be taken (on functions.php):
```
<input type="hidden" name="action" value="save_contact"/>
```
In you footer.php add the jQuery code to handle the AJAX request:
```
jQuery('... |
95,537 | <p>I am trying to include the new WP Media Uploader in a Custom Meta Box.</p>
<p>I found <a href="http://codestag.com/how-to-use-wordpress-3-5-media-uploader-in-theme-options/" rel="nofollow">this tutorial</a>.</p>
<p>However, I am looking for a way to limit the uploader to only accept certain types of files like 'ap... | [
{
"answer_id": 95539,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 1,
"selected": false,
"text": "<p>The file types that you have specified 'application/msword', 'application/vnd.ms-excel', 'application/pdf'... | 2013/04/12 | [
"https://wordpress.stackexchange.com/questions/95537",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27294/"
] | I am trying to include the new WP Media Uploader in a Custom Meta Box.
I found [this tutorial](http://codestag.com/how-to-use-wordpress-3-5-media-uploader-in-theme-options/).
However, I am looking for a way to limit the uploader to only accept certain types of files like 'application/msword', 'application/vnd.ms-exce... | The file types that you have specified 'application/msword', 'application/vnd.ms-excel', 'application/pdf' are already supported by media uploader.
To see the default supported mime file types, call [wp\_get\_mime\_types()](http://codex.wordpress.org/Function_Reference/wp_get_mime_types) function.
Use [upload\_mimes]... |
95,544 | <p>I need to display the total revenue of all orders for my products depending on if the logged-in user is the author of the product or not.</p>
<p>I can't use the Quantity field as a multiplier either because of the Gravity Forms add-on for Woocommerce processes it in to a meta_key/value field, same goes for the prod... | [
{
"answer_id": 95539,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 1,
"selected": false,
"text": "<p>The file types that you have specified 'application/msword', 'application/vnd.ms-excel', 'application/pdf'... | 2013/04/12 | [
"https://wordpress.stackexchange.com/questions/95544",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21104/"
] | I need to display the total revenue of all orders for my products depending on if the logged-in user is the author of the product or not.
I can't use the Quantity field as a multiplier either because of the Gravity Forms add-on for Woocommerce processes it in to a meta\_key/value field, same goes for the product ID re... | The file types that you have specified 'application/msword', 'application/vnd.ms-excel', 'application/pdf' are already supported by media uploader.
To see the default supported mime file types, call [wp\_get\_mime\_types()](http://codex.wordpress.org/Function_Reference/wp_get_mime_types) function.
Use [upload\_mimes]... |
95,557 | <p>I moved a WordPress site from one domain to another and there were a lot of white spaces that needed to be removed.</p>
<p>The only problem that is left are the following errors:</p>
<ul>
<li>PHP Notice: Undefined offset: 0 in /home/linguist/public_html/test/wp-includes/plugin.php on line 767 </li>
<li>PHP Notice... | [
{
"answer_id": 95561,
"author": "Balas",
"author_id": 17849,
"author_profile": "https://wordpress.stackexchange.com/users/17849",
"pm_score": -1,
"selected": false,
"text": "<p>PHP Warning: Cannot modify header information - headers already sent by (output started at /home/linguist/publi... | 2013/04/12 | [
"https://wordpress.stackexchange.com/questions/95557",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31377/"
] | I moved a WordPress site from one domain to another and there were a lot of white spaces that needed to be removed.
The only problem that is left are the following errors:
* PHP Notice: Undefined offset: 0 in /home/linguist/public\_html/test/wp-includes/plugin.php on line 767
* PHP Notice: Undefined offset: 0 in /hom... | Some code on your site registers a filter or an action with invalid arguments. The errors you see happen, because `add_action()` or `add_filter()` was called with a second argument that is not a string, an object or an array.
Examples:
```
add_action( 'wp_head', NULL );
add_filter( 'the_content', -1 );
```
Disable ... |
95,559 | <p>I've created a custom post type and on the admin page for that post type I want an image displayed that can act as a guide for the users uploading images. Is there a function that I can use to insert an image into the admin for just that custom post type.
(I have tried to Google this but all the results seem to be r... | [
{
"answer_id": 95561,
"author": "Balas",
"author_id": 17849,
"author_profile": "https://wordpress.stackexchange.com/users/17849",
"pm_score": -1,
"selected": false,
"text": "<p>PHP Warning: Cannot modify header information - headers already sent by (output started at /home/linguist/publi... | 2013/04/12 | [
"https://wordpress.stackexchange.com/questions/95559",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31382/"
] | I've created a custom post type and on the admin page for that post type I want an image displayed that can act as a guide for the users uploading images. Is there a function that I can use to insert an image into the admin for just that custom post type.
(I have tried to Google this but all the results seem to be rela... | Some code on your site registers a filter or an action with invalid arguments. The errors you see happen, because `add_action()` or `add_filter()` was called with a second argument that is not a string, an object or an array.
Examples:
```
add_action( 'wp_head', NULL );
add_filter( 'the_content', -1 );
```
Disable ... |
95,576 | <p>I Installed the plugin Simple Login Lockdown and since a couple of days ago the database is recording over 200 records by day.</p>
<p>I think that is not possible to have my site attacked by so many IP's </p>
<p>Do you think there is something wrong?</p>
| [
{
"answer_id": 95577,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": false,
"text": "<p>There is currently a <a href=\"http://www.siliconrepublic.com/strategy/item/32269-major-brute-force-attack/\" rel=\"no... | 2013/04/12 | [
"https://wordpress.stackexchange.com/questions/95576",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31391/"
] | I Installed the plugin Simple Login Lockdown and since a couple of days ago the database is recording over 200 records by day.
I think that is not possible to have my site attacked by so many IP's
Do you think there is something wrong? | There is currently a [botnet active, attacking WordPress and Joomla sites](http://www.siliconrepublic.com/strategy/item/32269-major-brute-force-attack/). And probably more. You *should* see more blocked logins. If you don’t, there is probably something wrong.
But be aware, blocking IP addresses doesn’t help against a ... |
95,592 | <p>I have a drop down menu which contains my custom login box...</p>
<pre><code><form name="loginform" id="loginform" action="<?php echo bloginfo('url') ?>/wp-login.php" method="post">
<p class="login-username">
<input placeholder="email address" type="text" style="text-align:right;" n... | [
{
"answer_id": 95577,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": false,
"text": "<p>There is currently a <a href=\"http://www.siliconrepublic.com/strategy/item/32269-major-brute-force-attack/\" rel=\"no... | 2013/04/12 | [
"https://wordpress.stackexchange.com/questions/95592",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10247/"
] | I have a drop down menu which contains my custom login box...
```
<form name="loginform" id="loginform" action="<?php echo bloginfo('url') ?>/wp-login.php" method="post">
<p class="login-username">
<input placeholder="email address" type="text" style="text-align:right;" name="log" id="user_login" class="in... | There is currently a [botnet active, attacking WordPress and Joomla sites](http://www.siliconrepublic.com/strategy/item/32269-major-brute-force-attack/). And probably more. You *should* see more blocked logins. If you don’t, there is probably something wrong.
But be aware, blocking IP addresses doesn’t help against a ... |
95,614 | <p>I am using this snippet to redirect failed logins to my custom page...</p>
<pre><code>add_action( 'wp_login_failed', 'my_front_end_login_fail' ); // hook failed login
function my_front_end_login_fail( $username ) {
$referrer = $_SERVER['HTTP_REFERER']; // where did the post submission come from?
// if ther... | [
{
"answer_id": 95617,
"author": "fightstarr20",
"author_id": 10247,
"author_profile": "https://wordpress.stackexchange.com/users/10247",
"pm_score": 1,
"selected": false,
"text": "<p>Managed to resolve this with the help of the following code from <a href=\"http://css.dzone.com/articles/... | 2013/04/12 | [
"https://wordpress.stackexchange.com/questions/95614",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10247/"
] | I am using this snippet to redirect failed logins to my custom page...
```
add_action( 'wp_login_failed', 'my_front_end_login_fail' ); // hook failed login
function my_front_end_login_fail( $username ) {
$referrer = $_SERVER['HTTP_REFERER']; // where did the post submission come from?
// if there's a valid re... | Managed to resolve this with the help of the following code from <http://css.dzone.com/articles/create-your-own-wordpress>
```
add_action( 'authenticate', 'pu_blank_login');
function pu_blank_login( $user ){
// check what page the login attempt is coming from
$referrer = $_SERVER['HTTP_REFERER'];
$error = ... |
95,630 | <p>I'm trying to get the count of published posts in a custom post type for the current user (to display on a profile page).</p>
<p>I found this here on the forums:</p>
<pre><code><?php
global $wp_query;
$curauth = $wp_query->get_queried_object();
$post_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->... | [
{
"answer_id": 95638,
"author": "Andrew Bartel",
"author_id": 17879,
"author_profile": "https://wordpress.stackexchange.com/users/17879",
"pm_score": 1,
"selected": false,
"text": "<p>You need to declare $wpdb as global as well, and use its prefix method.</p>\n\n<pre><code><?php\nglob... | 2013/04/12 | [
"https://wordpress.stackexchange.com/questions/95630",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23492/"
] | I'm trying to get the count of published posts in a custom post type for the current user (to display on a profile page).
I found this here on the forums:
```
<?php
global $wp_query;
$curauth = $wp_query->get_queried_object();
$post_count = $wpdb->get_var("SELECT COUNT(*) FROM $wpdb->posts WHERE post_author = '" . $c... | I'm posting a new answer because I found this thread while searching for the same thing and the solutions here weren't optimal.
The `post_type` argument can be a **string** or an **array** of post types.
```
function custom_count_posts_by_author($user_id, $post_type = array('post', 'page', 'custom_post_type'))
{
... |
95,632 | <p>I am using <code>delete_post</code> hook.</p>
<pre><code>add_action('delete_post', array($this, 'remove_audio_file')); // delete post event
</code></pre>
<p>(Using it inside the class).</p>
<p>When I delete a single post I have no problem retrieving its ID.</p>
<pre><code>global $post;
</code></pre>
<p>However,... | [
{
"answer_id": 96655,
"author": "user31412",
"author_id": 31412,
"author_profile": "https://wordpress.stackexchange.com/users/31412",
"pm_score": 0,
"selected": false,
"text": "<p>When deleting multiple items, $_GET['post'] becomes an array with numeric keys starting from 0. To access cu... | 2013/04/12 | [
"https://wordpress.stackexchange.com/questions/95632",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31412/"
] | I am using `delete_post` hook.
```
add_action('delete_post', array($this, 'remove_audio_file')); // delete post event
```
(Using it inside the class).
When I delete a single post I have no problem retrieving its ID.
```
global $post;
```
However, when I delete multiple posts (2 or more) `$post` becomes `NULL`.
C... | That's not how that hook is meant to be used:
```php
do_action( 'delete_post', int $postid, WP_Post $post )
```
<https://developer.wordpress.org/reference/hooks/delete_post/>
The action gives you the post ID and a post object.
So don't access `$_GET` or the global `$post` object, instead use the what the action gi... |
95,633 | <p>I am using the following snippet to control redirects after successful logins....</p>
<pre><code>add_action( 'wp_login', 'redirect_on_login' ); // hook failed login
function redirect_on_login() {
$referrer = $_SERVER['HTTP_REFERER'];
$homepage = get_option('siteurl');
if (strstr(... | [
{
"answer_id": 95639,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 3,
"selected": false,
"text": "<p>According to <a href=\"http://codex.wordpress.org/Function_Reference/wp_redirect\" rel=\"noreferrer\">the Codex ... | 2013/04/12 | [
"https://wordpress.stackexchange.com/questions/95633",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10247/"
] | I am using the following snippet to control redirects after successful logins....
```
add_action( 'wp_login', 'redirect_on_login' ); // hook failed login
function redirect_on_login() {
$referrer = $_SERVER['HTTP_REFERER'];
$homepage = get_option('siteurl');
if (strstr($referrer, 'in... | According to [the Codex page for `wp_redirect()`](http://codex.wordpress.org/Function_Reference/wp_redirect), you should follow your `wp_redirect()` calls with `exit`.
```
add_action( 'wp_login', 'redirect_on_login' ); // hook failed login
function redirect_on_login() {
$referrer = $_SERVER['HTTP_REFERER'];
$h... |
95,661 | <p>I am looking for some assistance in opening WordPress posts in the Bootstrap Modal.</p>
<p>Right now I have a home page with a grid that pull posts.</p>
<p>I have it setup so that each post is in a square box and linked to open the Bootstrap Modal window. </p>
<p>The modal window should pull the data from the pos... | [
{
"answer_id": 95759,
"author": "minemind",
"author_id": 31423,
"author_profile": "https://wordpress.stackexchange.com/users/31423",
"pm_score": 1,
"selected": false,
"text": "<p>This has been answered and this is how it was done:</p>\n\n<p>The grid and the modal window are in a loop. \n... | 2013/04/12 | [
"https://wordpress.stackexchange.com/questions/95661",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31423/"
] | I am looking for some assistance in opening WordPress posts in the Bootstrap Modal.
Right now I have a home page with a grid that pull posts.
I have it setup so that each post is in a square box and linked to open the Bootstrap Modal window.
The modal window should pull the data from the post which is clicked.
At ... | This has been answered and this is how it was done:
The grid and the modal window are in a loop.
I simply added `-<? the_ID(); ?>` to bot the `<a href>` calling the modal window. and to the `<div id>` for the modal window which somehow passes the post ID to the window allowing it to pull in the right information for ... |
95,671 | <p>Basically, every time I modify my functions.php file and reload it to the server my site "breaks" and nothing loads. As soon as I delete it, it starts working again. Now before anyone freaks out, I am using a child theme so I am not modifying the original theme.</p>
<p>Specifically what I'm trying to do is modify... | [
{
"answer_id": 95759,
"author": "minemind",
"author_id": 31423,
"author_profile": "https://wordpress.stackexchange.com/users/31423",
"pm_score": 1,
"selected": false,
"text": "<p>This has been answered and this is how it was done:</p>\n\n<p>The grid and the modal window are in a loop. \n... | 2013/04/13 | [
"https://wordpress.stackexchange.com/questions/95671",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31427/"
] | Basically, every time I modify my functions.php file and reload it to the server my site "breaks" and nothing loads. As soon as I delete it, it starts working again. Now before anyone freaks out, I am using a child theme so I am not modifying the original theme.
Specifically what I'm trying to do is modify the functio... | This has been answered and this is how it was done:
The grid and the modal window are in a loop.
I simply added `-<? the_ID(); ?>` to bot the `<a href>` calling the modal window. and to the `<div id>` for the modal window which somehow passes the post ID to the window allowing it to pull in the right information for ... |
95,699 | <p>I've been working on performance of my site using YSLOW, and noticed that Wordpress it outputting things in my document head that I know I don't need.</p>
<p>For example, I'm already calling jQuery 1.9 from the Google CDN, so I don't need the call to jQuery in wp-includes.</p>
<p>Also, a plugin is including a styl... | [
{
"answer_id": 95700,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": false,
"text": "<p>First: <strong>don't enqueue custom versions of WordPress core-bundled scripts</strong>, including (and <em... | 2013/04/13 | [
"https://wordpress.stackexchange.com/questions/95699",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1171/"
] | I've been working on performance of my site using YSLOW, and noticed that Wordpress it outputting things in my document head that I know I don't need.
For example, I'm already calling jQuery 1.9 from the Google CDN, so I don't need the call to jQuery in wp-includes.
Also, a plugin is including a stylesheet which I do... | First: **don't enqueue custom versions of WordPress core-bundled scripts**, including (and *especially*) jQuery.
Second, to answer your question: those Plugin scripts and stylesheets are *enqueued*, using [**`add_action()`**](http://codex.wordpress.org/Function_Reference/add_action), via a callback hooked into one of ... |
95,703 | <p>I've got a special query on my homepage that returns posts from a custom taxonomy.</p>
<p>I'm trying to apply this filter for it.</p>
<pre><code>add_filter( 'post_limits', 'my_post_limits' );
function my_post_limits( $limit ) {
if ( is_home() ) {
... | [
{
"answer_id": 95700,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": false,
"text": "<p>First: <strong>don't enqueue custom versions of WordPress core-bundled scripts</strong>, including (and <em... | 2013/04/13 | [
"https://wordpress.stackexchange.com/questions/95703",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12239/"
] | I've got a special query on my homepage that returns posts from a custom taxonomy.
I'm trying to apply this filter for it.
```
add_filter( 'post_limits', 'my_post_limits' );
function my_post_limits( $limit ) {
if ( is_home() ) {
return 'LIMIT 0, 3';... | First: **don't enqueue custom versions of WordPress core-bundled scripts**, including (and *especially*) jQuery.
Second, to answer your question: those Plugin scripts and stylesheets are *enqueued*, using [**`add_action()`**](http://codex.wordpress.org/Function_Reference/add_action), via a callback hooked into one of ... |
95,712 | <p>I moved my site from hosting provider A and domain name B to hosting provider X and domain name Y. I had Wordfence in the old site. I just installed it in the new site and ran a scan. Wordfence found the following change in wp-admin/includes/upgrade.php :</p>
<pre><code>279 @wp_mail($email, __('New WordPress Sit... | [
{
"answer_id": 97072,
"author": "markratledge",
"author_id": 268,
"author_profile": "https://wordpress.stackexchange.com/users/268",
"pm_score": 2,
"selected": false,
"text": "<p>Search the Trac for these kinds of core changes: </p>\n\n<ul>\n<li><a href=\"http://core.trac.wordpress.org/t... | 2013/04/13 | [
"https://wordpress.stackexchange.com/questions/95712",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11634/"
] | I moved my site from hosting provider A and domain name B to hosting provider X and domain name Y. I had Wordfence in the old site. I just installed it in the new site and ran a scan. Wordfence found the following change in wp-admin/includes/upgrade.php :
```
279 @wp_mail($email, __('New WordPress Site'), $message)... | Search the Trac for these kinds of core changes:
* [trac ticket #23291](http://core.trac.wordpress.org/ticket/23291) and
* [trac ticket #23291.2.diff](http://core.trac.wordpress.org/attachment/ticket/23291/23291.2.diff) |
95,769 | <p>I'm trying to figure out how to display the date that a post was last updated outside of the loop. I'm able to display the published date using <code>get_the_time()</code> but there doesn't seem to be a "loopless" function to get the date of the last update.</p>
<p>Does anyone know hot to do this?</p>
| [
{
"answer_id": 95789,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 3,
"selected": false,
"text": "<p>According to <a href=\"http://codex.wordpress.org/Function_Reference/get_the_time\" rel=\"noreferrer\">the Codex... | 2013/04/14 | [
"https://wordpress.stackexchange.com/questions/95769",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23492/"
] | I'm trying to figure out how to display the date that a post was last updated outside of the loop. I'm able to display the published date using `get_the_time()` but there doesn't seem to be a "loopless" function to get the date of the last update.
Does anyone know hot to do this? | It is unclear if you are looking for the last updated post or for the last updated date for some particular post. The answer by @PatJ assumes the former. To do the latter:
```
$qry = new WP_Query(array('p'=>1));
var_dump($qry->posts[0]->post_modified);
```
Or...
```
$date = $wpdb->get_var("SELECT post_modified FROM... |
95,797 | <p>I am creating a Custom Post Type using <code>register_post_type</code>. After running the function a new menu item appears in the Admin Panel. </p>
<p>Under this item there are menu items for <code>new_item</code> and <code>all_items</code>. Is there a way to get read of the these two options considering that I cre... | [
{
"answer_id": 95807,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/register_post_type#Arguments\" rel=\"nofollow norefer... | 2013/04/14 | [
"https://wordpress.stackexchange.com/questions/95797",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28658/"
] | I am creating a Custom Post Type using `register_post_type`. After running the function a new menu item appears in the Admin Panel.
Under this item there are menu items for `new_item` and `all_items`. Is there a way to get read of the these two options considering that I created a custom page to manage these posts. | You can manipulate the global variable `$submenu` and remove them. In normal circumstances, the index key values are `5` (All items) and `10` (New item). In this example, the post type is `portfolio`:
```
add_action( 'admin_init', 'remove_cpt_submenus_wpse_95797' );
function remove_cpt_submenus_wpse_95797()
{
glo... |
95,799 | <p>I was wondering whether it is possible to completely disable a function that is called in a parent theme's <code>functions.php</code> and if so, how? (Of course without deleting the function. Rather by adding something to <code>functions.php</code> of the child theme.)</p>
| [
{
"answer_id": 95813,
"author": "Jared Sulzdorf",
"author_id": 13306,
"author_profile": "https://wordpress.stackexchange.com/users/13306",
"pm_score": 0,
"selected": false,
"text": "<p>While it's difficult to know exactly how to do what you want without seeing code, this may help - <a hr... | 2013/04/14 | [
"https://wordpress.stackexchange.com/questions/95799",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16574/"
] | I was wondering whether it is possible to completely disable a function that is called in a parent theme's `functions.php` and if so, how? (Of course without deleting the function. Rather by adding something to `functions.php` of the child theme.) | Only under some circumstances.
1. If the parent theme's functions are wrapped in `function_exists` conditionals then you should be able to replace them. For example:
```
// Parent
if (!function_exists('p_wpse_95799')) {
function p_wpse_95799() {
//
}
}
```
If the child theme defines a function named `p_wps... |
95,824 | <p>After reading the following suggestions from <a href="https://wordpress.stackexchange.com/users/8/jan-fabry">Jan Fabry</a> regarding URL rewrite and the author slug I took the challenge in combining both solution in one.</p>
<ul>
<li><a href="https://wordpress.stackexchange.com/questions/17106/change-author-base-sl... | [
{
"answer_id": 95879,
"author": "diggy",
"author_id": 25765,
"author_profile": "https://wordpress.stackexchange.com/users/25765",
"pm_score": 3,
"selected": true,
"text": "<p>Edit: previous answer not working. Following solution does not provide sanitized nicknames, but should do the tri... | 2013/04/14 | [
"https://wordpress.stackexchange.com/questions/95824",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31501/"
] | After reading the following suggestions from [Jan Fabry](https://wordpress.stackexchange.com/users/8/jan-fabry) regarding URL rewrite and the author slug I took the challenge in combining both solution in one.
* [Change author base slug for different roles](https://wordpress.stackexchange.com/questions/17106/change-au... | Edit: previous answer not working. Following solution does not provide sanitized nicknames, but should do the trick:
```
$nn = urldecode($query_vars['author_name'] );
$author_id = $wpdb->get_var( $wpdb->prepare( "SELECT user_id FROM {$wpdb->usermeta} WHERE meta_key='nickname' AND meta_value = %s", $nn ) );
``... |
95,829 | <p>I have a custom post type of 'clients' and would like all images/files uploaded through the admin for these posts to go to a specific directory on my server, but everything else to stay as normal. Is this possible maybe using wp_upload_dir?</p>
| [
{
"answer_id": 95831,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 2,
"selected": false,
"text": "<p>You can add a filter to upload_dir. Here is a simple class I wrote to do this for a project. Use the <code>protec... | 2013/04/14 | [
"https://wordpress.stackexchange.com/questions/95829",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22448/"
] | I have a custom post type of 'clients' and would like all images/files uploaded through the admin for these posts to go to a specific directory on my server, but everything else to stay as normal. Is this possible maybe using wp\_upload\_dir? | You can add a filter to upload\_dir. Here is a simple class I wrote to do this for a project. Use the `protected $filter_path` variable to define the alternate uploads directory (\*will be relative to wp-content/uploads)
```
class UGC_Attachment {
protected $upload_dir;
protected $upload_url;
protected $fi... |
95,837 | <p>I'm trying to remove a menu item and tried several approaches, but have not had any luck. It was created from a FAQ plugin.</p>
<p>If I use this line: </p>
<pre><code>remove_menu_page( 'edit.php?post_type=question' );
</code></pre>
<p>It will remove the main menu, however I only want to remove two sub-menu items ... | [
{
"answer_id": 95842,
"author": "Ralf912",
"author_id": 16589,
"author_profile": "https://wordpress.stackexchange.com/users/16589",
"pm_score": 4,
"selected": true,
"text": "<pre><code>function remove_submenu() {\n\n remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=faq-topic&a... | 2013/04/15 | [
"https://wordpress.stackexchange.com/questions/95837",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31502/"
] | I'm trying to remove a menu item and tried several approaches, but have not had any luck. It was created from a FAQ plugin.
If I use this line:
```
remove_menu_page( 'edit.php?post_type=question' );
```
It will remove the main menu, however I only want to remove two sub-menu items contained inside that `edit.php?p... | ```
function remove_submenu() {
remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=faq-topic&post_type=question' );
remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=faq-tags&post_type=question' );
}
add_action( 'admin_menu', 'remove_submenu', 999 );
```
Please read the [Codex](http://codex.wor... |
95,846 | <p>I'm trying to create a "Start here" page on my blog.
I use a template for that, but the content for it is created using the "add new page" wizard in WordPress.</p>
<p>I know how I can display the most discussed posts (with most comments), but PHP doesn't work in pages. Of course I can just paste the code into the p... | [
{
"answer_id": 95842,
"author": "Ralf912",
"author_id": 16589,
"author_profile": "https://wordpress.stackexchange.com/users/16589",
"pm_score": 4,
"selected": true,
"text": "<pre><code>function remove_submenu() {\n\n remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=faq-topic&a... | 2013/04/15 | [
"https://wordpress.stackexchange.com/questions/95846",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6903/"
] | I'm trying to create a "Start here" page on my blog.
I use a template for that, but the content for it is created using the "add new page" wizard in WordPress.
I know how I can display the most discussed posts (with most comments), but PHP doesn't work in pages. Of course I can just paste the code into the page templa... | ```
function remove_submenu() {
remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=faq-topic&post_type=question' );
remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=faq-tags&post_type=question' );
}
add_action( 'admin_menu', 'remove_submenu', 999 );
```
Please read the [Codex](http://codex.wor... |
95,889 | <p>I currently have a code where, in my category.php, it checks if the specific category has subcategories, and if it does, show them using wp_list_categories.</p>
<p>I'd love to have these wp_list_categories to show thumbnails, so I created a new walker, but I cannot figure out how to show thumbnails.</p>
<p>I'd be ... | [
{
"answer_id": 95842,
"author": "Ralf912",
"author_id": 16589,
"author_profile": "https://wordpress.stackexchange.com/users/16589",
"pm_score": 4,
"selected": true,
"text": "<pre><code>function remove_submenu() {\n\n remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=faq-topic&a... | 2013/04/15 | [
"https://wordpress.stackexchange.com/questions/95889",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31532/"
] | I currently have a code where, in my category.php, it checks if the specific category has subcategories, and if it does, show them using wp\_list\_categories.
I'd love to have these wp\_list\_categories to show thumbnails, so I created a new walker, but I cannot figure out how to show thumbnails.
I'd be fine with hav... | ```
function remove_submenu() {
remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=faq-topic&post_type=question' );
remove_submenu_page( 'edit.php', 'edit-tags.php?taxonomy=faq-tags&post_type=question' );
}
add_action( 'admin_menu', 'remove_submenu', 999 );
```
Please read the [Codex](http://codex.wor... |
95,891 | <p>I have the following function that successfully uses form fields (IDs 13 and 18) from a Gravity Form (ID 18) as parameters within wp_query.
This displays a list of posts with specific taxonomy terms that match those chosen in the form:</p>
<pre><code>add_action("gform_after_submission_18", "set_post_content", 10, 2... | [
{
"answer_id": 96435,
"author": "webaware",
"author_id": 24260,
"author_profile": "https://wordpress.stackexchange.com/users/24260",
"pm_score": 1,
"selected": false,
"text": "<p>Just thinking on a Friday night (so untested), but:</p>\n\n<p>You are outputing the result directly to the pa... | 2013/04/15 | [
"https://wordpress.stackexchange.com/questions/95891",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31520/"
] | I have the following function that successfully uses form fields (IDs 13 and 18) from a Gravity Form (ID 18) as parameters within wp\_query.
This displays a list of posts with specific taxonomy terms that match those chosen in the form:
```
add_action("gform_after_submission_18", "set_post_content", 10, 2);
function s... | Just thinking on a Friday night (so untested), but:
You are outputing the result directly to the page. Of course it is going to display straight after the body tag. What you need to do is store that HTML snippet, and append/insert into the content using the\_content filter as s\_ha\_dum suggested.
This is untested, a... |
95,894 | <p>When checking get_defined_vars() on an empty template file my theme loads over 70000 lines of output. Before even including elements on a page all of this is loaded.</p>
<ol>
<li>Is this correct? </li>
<li>Is there any way to reduce it or remove unnecessary variables?</li>
<li>Do all wp_rewrite rules have to be ava... | [
{
"answer_id": 96435,
"author": "webaware",
"author_id": 24260,
"author_profile": "https://wordpress.stackexchange.com/users/24260",
"pm_score": 1,
"selected": false,
"text": "<p>Just thinking on a Friday night (so untested), but:</p>\n\n<p>You are outputing the result directly to the pa... | 2013/04/15 | [
"https://wordpress.stackexchange.com/questions/95894",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1426/"
] | When checking get\_defined\_vars() on an empty template file my theme loads over 70000 lines of output. Before even including elements on a page all of this is loaded.
1. Is this correct?
2. Is there any way to reduce it or remove unnecessary variables?
3. Do all wp\_rewrite rules have to be available for every page l... | Just thinking on a Friday night (so untested), but:
You are outputing the result directly to the page. Of course it is going to display straight after the body tag. What you need to do is store that HTML snippet, and append/insert into the content using the\_content filter as s\_ha\_dum suggested.
This is untested, a... |
95,920 | <p>By default WordPress pushes out a whole array of pages I don’t want or need - archive, author, blog, monthly, recent posts, categories, comments, attachment, taxenomies, search, search results, and probably a few others I’ve missed.</p>
<p>Most of the time I’m building regular broshure websites with no need for any... | [
{
"answer_id": 95923,
"author": "Johannes Pille",
"author_id": 9745,
"author_profile": "https://wordpress.stackexchange.com/users/9745",
"pm_score": 2,
"selected": false,
"text": "<p>Joost de Valk's <a href=\"http://wordpress.org/extend/plugins/wordpress-seo/\" rel=\"nofollow noreferrer\... | 2013/04/15 | [
"https://wordpress.stackexchange.com/questions/95920",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2937/"
] | By default WordPress pushes out a whole array of pages I don’t want or need - archive, author, blog, monthly, recent posts, categories, comments, attachment, taxenomies, search, search results, and probably a few others I’ve missed.
Most of the time I’m building regular broshure websites with no need for anything exce... | You could redirect anything that's not a page or admin to home via the `parse_query` action:
```
function wpa_parse_query( $query ){
if( ! is_admin() && ! $query->is_page() ) {
wp_redirect( home_url() );
exit;
}
}
add_action( 'parse_query', 'wpa_parse_query' );
```
If it's not an admin screen... |
95,958 | <p>I have few custom field assigned for each post, like:
"Club" with value "club1"
"Date" with value "date1"
and so on... </p>
<p>Now, I want to display from all the custom fields just those 2 " club" and "date".</p>
<p>This is my markup : </p>
<pre><code> <div class="meta-container"><?... | [
{
"answer_id": 95959,
"author": "Daniel",
"author_id": 9709,
"author_profile": "https://wordpress.stackexchange.com/users/9709",
"pm_score": 0,
"selected": false,
"text": "<p>Oddly enough, one of your tags is exactly what you need! You're looking for WordPress' get_post_meta function: \n... | 2013/04/15 | [
"https://wordpress.stackexchange.com/questions/95958",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12572/"
] | I have few custom field assigned for each post, like:
"Club" with value "club1"
"Date" with value "date1"
and so on...
Now, I want to display from all the custom fields just those 2 " club" and "date".
This is my markup :
```
<div class="meta-container"><?php the_meta(); ?></div>
```
The pr... | You should use [`get_post_meta()`](http://codex.wordpress.org/Function_Reference/get_post_meta) twice (Ref to your [other question](https://wordpress.stackexchange.com/questions/96008/problem-retrieving-specific-custom-meta)):
```
<?php
echo get_post_meta( get_the_ID(), 'club', true );
echo '<br />';
echo get_p... |
95,963 | <p>I have this code in the template file <code>header.php</code>:</p>
<pre><code><div class="dynamic-header">
<?php if(function_exists('show_media_header')){ show_media_header(); } ?>
</div>
</code></pre>
<p>I want to process that header info on all pages, except for homepage. How I can do this?... | [
{
"answer_id": 95986,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>You can combine multiple conditional statements:</p>\n\n<pre><code><?php \nif ( function_exists( 'show_media_header... | 2013/04/16 | [
"https://wordpress.stackexchange.com/questions/95963",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28556/"
] | I have this code in the template file `header.php`:
```
<div class="dynamic-header">
<?php if(function_exists('show_media_header')){ show_media_header(); } ?>
</div>
```
I want to process that header info on all pages, except for homepage. How I can do this? | You can combine multiple conditional statements:
```
<?php
if ( function_exists( 'show_media_header' )
and ! is_home() // list of newest blog posts
and ! is_front_page() // front page, might be a static page
)
{
show_media_header();
}
?>
```
You don’t need a separate file for that. |
95,964 | <p>Performed a bad import to my Wordpress install and decided to restore from the mqSQL backup (full export) I had made minutes earlier.</p>
<p>Dropped all tables in the database and then did an import from my .sql file.</p>
<p>I encounter the error below in PHPmyAdmin and find that only 22 of my 44 tables were impor... | [
{
"answer_id": 96022,
"author": "ckpepper02",
"author_id": 18404,
"author_profile": "https://wordpress.stackexchange.com/users/18404",
"pm_score": 0,
"selected": false,
"text": "<p>Is the <code><!DOCTYPE</code>... at the beginning of your sql statement? It's getting choked up trying t... | 2013/04/16 | [
"https://wordpress.stackexchange.com/questions/95964",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18228/"
] | Performed a bad import to my Wordpress install and decided to restore from the mqSQL backup (full export) I had made minutes earlier.
Dropped all tables in the database and then did an import from my .sql file.
I encounter the error below in PHPmyAdmin and find that only 22 of my 44 tables were imported, so I assume ... | Figured it out upon examining my SQL file. It begins as SQL, and near the end changes to PHP. For some reason the download got messed up and the SQL export began outputting the PHP of the PHPmyAdmin page I was on! (not even just the client side HTML, it was spitting out server side PHP).
Anyways, my backup is corrupt.... |
95,965 | <p>When inserting a gallery it adds the following shortcode:</p>
<pre><code>[gallery columns="6" ids="18,150,146,23,147,17,21,20,22"]
</code></pre>
<p>I would like it to automatically add link="file" as the last attribute, whenever a shortcode is added. Like so: </p>
<pre><code>[gallery columns="6" ids="18,150,146,2... | [
{
"answer_id": 95971,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": false,
"text": "<p>There is a new <code>shortcode_atts_{$shortcode}</code> filter in WordPress <code>3.6</code> according to <a h... | 2013/04/16 | [
"https://wordpress.stackexchange.com/questions/95965",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31560/"
] | When inserting a gallery it adds the following shortcode:
```
[gallery columns="6" ids="18,150,146,23,147,17,21,20,22"]
```
I would like it to automatically add link="file" as the last attribute, whenever a shortcode is added. Like so:
```
[gallery columns="6" ids="18,150,146,23,147,17,21,20,22" link="file"]
``` | You can hijack the shortcode handler and set the attribute to a value of your choice. Then call the native callback for this shortcode.
```
add_shortcode( 'gallery', 'file_gallery_shortcode' );
function file_gallery_shortcode( $atts )
{
$atts['link'] = 'file';
return gallery_shortcode( $atts );
}
``` |
95,996 | <p>I've got always the same problem. If I program a multisite for multilanguage purposes, I cannot find a way to not change the page links in every language.
I mean, suppose I've got a page named 'Activity' in the english version. Then got the Italian version, and the same page is called 'Attività'.
If I've got a man... | [
{
"answer_id": 95997,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 0,
"selected": false,
"text": "<p>Translate the title before you query for it:</p>\n\n<pre><code>get_page_by_title( __( 'Activity', 'your_text_domain' )... | 2013/04/16 | [
"https://wordpress.stackexchange.com/questions/95996",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10381/"
] | I've got always the same problem. If I program a multisite for multilanguage purposes, I cannot find a way to not change the page links in every language.
I mean, suppose I've got a page named 'Activity' in the english version. Then got the Italian version, and the same page is called 'Attività'.
If I've got a manual... | I've found out that another answer could be to just use the is\_page\_template tag.
Since I'm preatty sure that the NAME of the php template file that needs custom css and/or js will be the same through all the languages (both using the multisite way or things like WPML), I can say
```
if(is_page_template('that-page... |
95,999 | <p>I have a code in my functions.php that gives me a count of how many favorites a post has got. </p>
<pre><code>function wpfp_get_current_count() {
global $wpdb;
$current_post = get_the_ID();
$query = "SELECT post_id, meta_value, post_status FROM $wpdb->postmeta";
$query .= " LEFT JOIN $wpdb->posts ON post_id=$... | [
{
"answer_id": 96002,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 1,
"selected": true,
"text": "<p>You can simply do it by adding 300 when displaying count as shown in following code:</p>\n\n<pre><code><... | 2013/04/16 | [
"https://wordpress.stackexchange.com/questions/95999",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25508/"
] | I have a code in my functions.php that gives me a count of how many favorites a post has got.
```
function wpfp_get_current_count() {
global $wpdb;
$current_post = get_the_ID();
$query = "SELECT post_id, meta_value, post_status FROM $wpdb->postmeta";
$query .= " LEFT JOIN $wpdb->posts ON post_id=$wpdb->posts.ID";
$qu... | You can simply do it by adding 300 when displaying count as shown in following code:
```
<?php echo 'TOTAL POST VIEWS: ' .(intval(wpfp_get_current_count()) + 300); ?>
```
and instead of echoing that values in function return it as shown in following code:
```
function wpfp_get_current_count() {
global $wpdb;
$curre... |
96,026 | <p>All posts in my site have custom field with nextgen gallery ID. To display gallery I use this code:</p>
<pre><code>$gallery_id = get_post_meta( $post->ID, 'galerijos_id', true); // Get gallery id from custom field data
if( $gallery_id ){
echo '<div class="post-gallery">';
echo nggShowGallery( $galle... | [
{
"answer_id": 96133,
"author": "Paulius Jakštas",
"author_id": 28477,
"author_profile": "https://wordpress.stackexchange.com/users/28477",
"pm_score": 2,
"selected": false,
"text": "<p>After analyzing nextgen core files I have found solution to my problem. I hope it will be useful for s... | 2013/04/16 | [
"https://wordpress.stackexchange.com/questions/96026",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28477/"
] | All posts in my site have custom field with nextgen gallery ID. To display gallery I use this code:
```
$gallery_id = get_post_meta( $post->ID, 'galerijos_id', true); // Get gallery id from custom field data
if( $gallery_id ){
echo '<div class="post-gallery">';
echo nggShowGallery( $gallery_id ); // Display the... | After analyzing nextgen core files I have found solution to my problem. I hope it will be useful for somebody.
```
global $nggdb;
$get_gall_id = get_post_meta($post_id, 'galerijos_id', true);
$gall_ids = $nggdb->get_ids_from_gallery($get_gall_id);
$images = $nggdb->get_gallery($get_gall_id);
foreach ( $gall_ids as $... |
96,049 | <p>I am trying to set up code to submit a post to StumbleUpon, from my <a href="http://Rothmania.net" rel="nofollow">Rothmania</a> site. </p>
<p>The code reads <code>href="http://www.stumbleupon.com/submit?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>" alt="" title=""></code></p>
<p>an... | [
{
"answer_id": 96133,
"author": "Paulius Jakštas",
"author_id": 28477,
"author_profile": "https://wordpress.stackexchange.com/users/28477",
"pm_score": 2,
"selected": false,
"text": "<p>After analyzing nextgen core files I have found solution to my problem. I hope it will be useful for s... | 2013/04/16 | [
"https://wordpress.stackexchange.com/questions/96049",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/859/"
] | I am trying to set up code to submit a post to StumbleUpon, from my [Rothmania](http://Rothmania.net) site.
The code reads `href="http://www.stumbleupon.com/submit?url=<?php the_permalink(); ?>&title=<?php the_title(); ?>" alt="" title="">`
and when on a single post view, it pulls the info just fine, offering to sub... | After analyzing nextgen core files I have found solution to my problem. I hope it will be useful for somebody.
```
global $nggdb;
$get_gall_id = get_post_meta($post_id, 'galerijos_id', true);
$gall_ids = $nggdb->get_ids_from_gallery($get_gall_id);
$images = $nggdb->get_gallery($get_gall_id);
foreach ( $gall_ids as $... |
96,056 | <p>In the following snippet, when I add the <code>wp_enqueue_scripts call</code>, the page freezes.
What am I doing wrong?</p>
<pre><code>function my_enqueue_stuff() {
if ( is_front_page() ) {
wp_enqueue_style('style', get_template_directory_uri() . '/css/homepage.css', array(), null, 'all');
} else if ( is_pa... | [
{
"answer_id": 96133,
"author": "Paulius Jakštas",
"author_id": 28477,
"author_profile": "https://wordpress.stackexchange.com/users/28477",
"pm_score": 2,
"selected": false,
"text": "<p>After analyzing nextgen core files I have found solution to my problem. I hope it will be useful for s... | 2013/04/16 | [
"https://wordpress.stackexchange.com/questions/96056",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28952/"
] | In the following snippet, when I add the `wp_enqueue_scripts call`, the page freezes.
What am I doing wrong?
```
function my_enqueue_stuff() {
if ( is_front_page() ) {
wp_enqueue_style('style', get_template_directory_uri() . '/css/homepage.css', array(), null, 'all');
} else if ( is_page( 'corsi' ) ) {
wp_... | After analyzing nextgen core files I have found solution to my problem. I hope it will be useful for somebody.
```
global $nggdb;
$get_gall_id = get_post_meta($post_id, 'galerijos_id', true);
$gall_ids = $nggdb->get_ids_from_gallery($get_gall_id);
$images = $nggdb->get_gallery($get_gall_id);
foreach ( $gall_ids as $... |
96,062 | <p>I'm using wordpress for my company website but I want to remove the comments function completely so not just by unchecking a "alow comments" within every page.</p>
<p>I did some googeling and the said I was supposed to remove this line of code:</p>
<pre><code><?php comments_template(); // Get wp-comments.php te... | [
{
"answer_id": 96133,
"author": "Paulius Jakštas",
"author_id": 28477,
"author_profile": "https://wordpress.stackexchange.com/users/28477",
"pm_score": 2,
"selected": false,
"text": "<p>After analyzing nextgen core files I have found solution to my problem. I hope it will be useful for s... | 2013/04/16 | [
"https://wordpress.stackexchange.com/questions/96062",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31599/"
] | I'm using wordpress for my company website but I want to remove the comments function completely so not just by unchecking a "alow comments" within every page.
I did some googeling and the said I was supposed to remove this line of code:
```
<?php comments_template(); // Get wp-comments.php template ?>
```
And this... | After analyzing nextgen core files I have found solution to my problem. I hope it will be useful for somebody.
```
global $nggdb;
$get_gall_id = get_post_meta($post_id, 'galerijos_id', true);
$gall_ids = $nggdb->get_ids_from_gallery($get_gall_id);
$images = $nggdb->get_gallery($get_gall_id);
foreach ( $gall_ids as $... |
96,109 | <p><strong>UPDATE</strong></p>
<p>Initially I suspected this was related to the Wordpress framework I'm using (Genesis) or to my child theme functionality, but turns out that's not the case as I was able to get this to work in a test environment running on the same framework and child theme.</p>
<p>Possibly this is r... | [
{
"answer_id": 96110,
"author": "markratledge",
"author_id": 268,
"author_profile": "https://wordpress.stackexchange.com/users/268",
"pm_score": 2,
"selected": false,
"text": "<p>This works fine for me as <code>db-error.php</code> in wp-content:</p>\n\n<p><em>Delete the mailer block if y... | 2013/04/17 | [
"https://wordpress.stackexchange.com/questions/96109",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9748/"
] | **UPDATE**
Initially I suspected this was related to the Wordpress framework I'm using (Genesis) or to my child theme functionality, but turns out that's not the case as I was able to get this to work in a test environment running on the same framework and child theme.
Possibly this is related to the caching plugin I... | This works fine for me as `db-error.php` in wp-content:
*Delete the mailer block if you don't want it*
```
<?php header('HTTP/1.1 503 Service Temporarily Unavailable'); ?>
<?php
$to = "me@mysite.com";
$subject = "My Database is down";
$message = "My Database is down";
$headers = "MIME-Version: 1.0\n";
$headers ... |
96,125 | <p>I am currently working on adding options to the theme customizer. For the last two hours I have been trying to get the live preview working and I am trying figure out why my theme isn't loading the <code>theme-customizer.js</code> file needed for the live preview. </p>
<p>All of the options I have added to the them... | [
{
"answer_id": 96127,
"author": "dipali",
"author_id": 20711,
"author_profile": "https://wordpress.stackexchange.com/users/20711",
"pm_score": -1,
"selected": false,
"text": "<p>Try this</p>\n\n<pre><code>function mytheme_customize_preview_js() {\nwp_enqueue_script( 'mytheme-customizer',... | 2013/04/17 | [
"https://wordpress.stackexchange.com/questions/96125",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31618/"
] | I am currently working on adding options to the theme customizer. For the last two hours I have been trying to get the live preview working and I am trying figure out why my theme isn't loading the `theme-customizer.js` file needed for the live preview.
All of the options I have added to the theme-customizer work if ... | i think your script is loaded correctly, same function is used in twentytwelve ( but your script is inside the iframe) but i can be wrong (dont know excactly how your theme is construct, maybe it's a path related issue with multiple include)

to see ... |
96,139 | <p>What I am trying to achieve is to have one add-to-cart button that will add the selected quantity of multiple products, featured on the catalog page, into the basket.</p>
<p>Here is an image of what I aim to have:</p>
<p><img src="https://i.stack.imgur.com/IE9Lz.png" alt="example"></p>
<p>I've found the code that... | [
{
"answer_id": 96155,
"author": "generousdesigner",
"author_id": 31595,
"author_profile": "https://wordpress.stackexchange.com/users/31595",
"pm_score": 2,
"selected": false,
"text": "<p>Maybe the Grouped product type is for what you want.</p>\n\n<p>You can create a Grouped product and t... | 2013/04/17 | [
"https://wordpress.stackexchange.com/questions/96139",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31627/"
] | What I am trying to achieve is to have one add-to-cart button that will add the selected quantity of multiple products, featured on the catalog page, into the basket.
Here is an image of what I aim to have:

I've found the code that outputs the existing button has the f... | Maybe the Grouped product type is for what you want.
You can create a Grouped product and then add child products to it. A grouped product (with the child products) can be added by one click.
See [WooThemes docs](http://docs.woothemes.com/document/managing-products/#section-2).
**Edit:**
If it's not what you're loo... |
96,146 | <p>I'm trying to set multiple images (image A,B and C) from one folder (folder X) at random into the database as a default featured image when there's none one set. </p>
<p>So on the main page I have all posts with different featured images from folder X. After clicking on read later the featured image needs to be the... | [
{
"answer_id": 96152,
"author": "Noob Theory",
"author_id": 31195,
"author_profile": "https://wordpress.stackexchange.com/users/31195",
"pm_score": 1,
"selected": false,
"text": "<p>Im not sure about the random part. But to set a back up featured image if none is set just use</p>\n\n<pre... | 2013/04/17 | [
"https://wordpress.stackexchange.com/questions/96146",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20548/"
] | I'm trying to set multiple images (image A,B and C) from one folder (folder X) at random into the database as a default featured image when there's none one set.
So on the main page I have all posts with different featured images from folder X. After clicking on read later the featured image needs to be the same as t... | Thanks to @Noob Theory for helping me out on the first part.
Solution: Upload 'default headers' to 'media' and check their ID's. Use `array_rand` to randomize the ID's et voila, your done.
```
<?
function autoset_featured() {
$media_array = array(
'1611',
'1612',
'1613',
);
$media = $media_array[array_rand($media_arr... |
96,172 | <p>Using the following code <a href="https://wordpress.stackexchange.com/questions/71657/author-list-page-exclude-based-on-last-post-date">from this post</a> I thought I had found the answer to my problems of showing authors that have posted in the last 6 months. Unfortunately the way the function checks the date it on... | [
{
"answer_id": 96152,
"author": "Noob Theory",
"author_id": 31195,
"author_profile": "https://wordpress.stackexchange.com/users/31195",
"pm_score": 1,
"selected": false,
"text": "<p>Im not sure about the random part. But to set a back up featured image if none is set just use</p>\n\n<pre... | 2013/04/17 | [
"https://wordpress.stackexchange.com/questions/96172",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1859/"
] | Using the following code [from this post](https://wordpress.stackexchange.com/questions/71657/author-list-page-exclude-based-on-last-post-date) I thought I had found the answer to my problems of showing authors that have posted in the last 6 months. Unfortunately the way the function checks the date it only seems to bl... | Thanks to @Noob Theory for helping me out on the first part.
Solution: Upload 'default headers' to 'media' and check their ID's. Use `array_rand` to randomize the ID's et voila, your done.
```
<?
function autoset_featured() {
$media_array = array(
'1611',
'1612',
'1613',
);
$media = $media_array[array_rand($media_arr... |
96,197 | <p>I am developing a theme and I have called jquery along with other JS files from a theme-enqueue.php file. For some reason only the Jquery file that is hosted on googles servers is adding the theme URL into the URL path so it is not loading it and causing other JS files to not load properly. </p>
<p>The hook is done... | [
{
"answer_id": 96224,
"author": "Ralf912",
"author_id": 16589,
"author_profile": "https://wordpress.stackexchange.com/users/16589",
"pm_score": 3,
"selected": true,
"text": "<p>If you register a script with <code>wp_register_script()</code> it is not neccessary to pass all the options in... | 2013/04/17 | [
"https://wordpress.stackexchange.com/questions/96197",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31618/"
] | I am developing a theme and I have called jquery along with other JS files from a theme-enqueue.php file. For some reason only the Jquery file that is hosted on googles servers is adding the theme URL into the URL path so it is not loading it and causing other JS files to not load properly.
The hook is done properly ... | If you register a script with `wp_register_script()` it is not neccessary to pass all the options in `wp_enqueue_script()` again.
You can register the script in a central place and use the enqueueing it in diffenrent files.
```
functions.php
wp_register_script( 'theme_script', 'path/to/script.js', array( [dependencie... |
96,219 | <p>I'm currently using the code below to list sticky posts on my index.php.</p>
<p>However, when no sticky posts are present, its loading the latest posts (up to the number specified in "settings > reading > blog posts show at most <em>_</em> posts".</p>
<p>How can I alter the script so that if there are no sticky po... | [
{
"answer_id": 96220,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Ask for the existence of sticky posts, <em>before</em> you query the database:</p>\n\n<pre><code>$stickies = get_optio... | 2013/04/17 | [
"https://wordpress.stackexchange.com/questions/96219",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6620/"
] | I'm currently using the code below to list sticky posts on my index.php.
However, when no sticky posts are present, its loading the latest posts (up to the number specified in "settings > reading > blog posts show at most *\_* posts".
How can I alter the script so that if there are no sticky posts, it exits out of th... | That is because `get_option` will return an empty array if there are no sticky posts and the query will default to everything.
```
$sticky = get_option('sticky_posts');
if (!empty($sticky)) {
$args['post__in'] = $sticky;
$qry = new WP_Query(array('post__in' => $sticky));
if ($qry->have_posts()) :
while ($qr... |
96,227 | <p>I am developing a theme which has a different method of adding in content and so, the default install of Wordpress won't show any content because of this. I was wondering if it is possible to automatically import an XML file via means of an internal function and or hooks after the theme has been activated?</p>
<blo... | [
{
"answer_id": 96235,
"author": "chrisguitarguy",
"author_id": 6035,
"author_profile": "https://wordpress.stackexchange.com/users/6035",
"pm_score": 0,
"selected": false,
"text": "<p>There is no theme equivalent of <a href=\"http://codex.wordpress.org/Function_Reference/register_activati... | 2013/04/17 | [
"https://wordpress.stackexchange.com/questions/96227",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1687/"
] | I am developing a theme which has a different method of adding in content and so, the default install of Wordpress won't show any content because of this. I was wondering if it is possible to automatically import an XML file via means of an internal function and or hooks after the theme has been activated?
>
> **User... | Your question is a bit specific if you "only" want to automatically import some posts/pages. There are other ways to do this then using a XML export file.
If you have text-only posts, then you should use [LOAD DATA INFILE](http://dev.mysql.com/doc/refman/5.1/en/load-data.html). At first you have to export your posts.
... |
96,255 | <p>I'm trying to use categories to get all my posts (within a category-news) to go to the NEWS page on my site.</p>
<p>I've created the category 'news' with some posts and a 'category-news.php' file which is copied from category.php but I'm not sure how to get the posts to go to the news page.</p>
<p>I've tried follo... | [
{
"answer_id": 96235,
"author": "chrisguitarguy",
"author_id": 6035,
"author_profile": "https://wordpress.stackexchange.com/users/6035",
"pm_score": 0,
"selected": false,
"text": "<p>There is no theme equivalent of <a href=\"http://codex.wordpress.org/Function_Reference/register_activati... | 2013/04/18 | [
"https://wordpress.stackexchange.com/questions/96255",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31671/"
] | I'm trying to use categories to get all my posts (within a category-news) to go to the NEWS page on my site.
I've created the category 'news' with some posts and a 'category-news.php' file which is copied from category.php but I'm not sure how to get the posts to go to the news page.
I've tried following the steps fr... | Your question is a bit specific if you "only" want to automatically import some posts/pages. There are other ways to do this then using a XML export file.
If you have text-only posts, then you should use [LOAD DATA INFILE](http://dev.mysql.com/doc/refman/5.1/en/load-data.html). At first you have to export your posts.
... |
96,257 | <p>When I want to get a single row from a custom table of my WordPress database by providing a username through a function call, it does not work. When I mention the username in the <code>where</code> clause of the query, however, it works. Why is that?</p>
<p>I am using the following code:</p>
<pre><code>function gett... | [
{
"answer_id": 96260,
"author": "dipali",
"author_id": 20711,
"author_profile": "https://wordpress.stackexchange.com/users/20711",
"pm_score": 0,
"selected": false,
"text": "<p>Try this. </p>\n\n<pre><code>function gettingonly( $phl ) {\n\n global $wpdb;\n $mylink = $wpdb->get_... | 2013/04/18 | [
"https://wordpress.stackexchange.com/questions/96257",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31672/"
] | When I want to get a single row from a custom table of my WordPress database by providing a username through a function call, it does not work. When I mention the username in the `where` clause of the query, however, it works. Why is that?
I am using the following code:
```
function gettingonly($phl) {
global $w... | `$wpdb->wp_philosophy_philosopher` won't work here because it has not been defined. `$wpdb->table_name` works only with default tables.
You can create your own using:
```
$wpdb->philosophy_philosopher = $wpdb->prefix . "philosophy_philosopher";
```
Note that the `wp_` is just the table prefix and has been omitted ... |
96,268 | <p>Hello WordPress Users,</p>
<p>I'm stuck with a problem building my wordpress website and I can't figure out what to do about it. </p>
<p>Currently I'm showing 2 posts form the category 'News' at the page 'News'. At the bottom of this page I want a Prev/Next button that shows the next or previous 2 posts from the s... | [
{
"answer_id": 96284,
"author": "dipali",
"author_id": 20711,
"author_profile": "https://wordpress.stackexchange.com/users/20711",
"pm_score": 3,
"selected": true,
"text": "<p>Pass <code>Paged</code> into parameter array of <code>query_posts</code></p>\n\n<p>You should set <code>get_quer... | 2013/04/18 | [
"https://wordpress.stackexchange.com/questions/96268",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30688/"
] | Hello WordPress Users,
I'm stuck with a problem building my wordpress website and I can't figure out what to do about it.
Currently I'm showing 2 posts form the category 'News' at the page 'News'. At the bottom of this page I want a Prev/Next button that shows the next or previous 2 posts from the same category.
So... | Pass `Paged` into parameter array of `query_posts`
You should set `get_query_var( 'paged' );` if you want your query to work with pagination.
```
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args_news= array(
'cat' => 1,
'posts_per_page' => 2,
'orderby' => 'post_date',
... |
96,288 | <p>I use the following code for getting the authors of in my multi-author blog and order them by their post count. I want to order them by the date of their last post</p>
<pre><code>$authors = get_users('role=author&orderby=post_count&order=DESC');
</code></pre>
| [
{
"answer_id": 96292,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 4,
"selected": true,
"text": "<p>Put this in your <code>functions.php</code>:</p>\n\n<pre><code>function get_users_ordered_by_post_date($args =... | 2013/04/18 | [
"https://wordpress.stackexchange.com/questions/96288",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28467/"
] | I use the following code for getting the authors of in my multi-author blog and order them by their post count. I want to order them by the date of their last post
```
$authors = get_users('role=author&orderby=post_count&order=DESC');
``` | Put this in your `functions.php`:
```
function get_users_ordered_by_post_date($args = '') {
// Prepare arguments
if (is_string($args) && '' !== $args)
parse_str($args, $args);
$asc = (isset($args['order']) && 'ASC' === strtoupper($args['order']));
unset($args['orderby']);
unset($args['order... |
96,298 | <p>I am trying to enqueue a couple of js files using something like this code:</p>
<pre><code>function scripts_function()
{
wp_register_script('mapbox', 'http://api.tiles.mapbox.com/mapbox.js/v0.6.7/mapbox.js');
wp_enqueue_script('mapbox');
wp_register_script('myscript', plugins_url( 'my-js-file.js' , __... | [
{
"answer_id": 96299,
"author": "dipali",
"author_id": 20711,
"author_profile": "https://wordpress.stackexchange.com/users/20711",
"pm_score": 0,
"selected": false,
"text": "<p>Always have <code>wp_head()</code> just before the closing <code></head></code> tag of your theme, or yo... | 2013/04/18 | [
"https://wordpress.stackexchange.com/questions/96298",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31530/"
] | I am trying to enqueue a couple of js files using something like this code:
```
function scripts_function()
{
wp_register_script('mapbox', 'http://api.tiles.mapbox.com/mapbox.js/v0.6.7/mapbox.js');
wp_enqueue_script('mapbox');
wp_register_script('myscript', plugins_url( 'my-js-file.js' , __FILE__ ));
... | I'm not sure but it might have something to do with the `html5blank_protocol_relative()` function used by **HTML5 Blank Theme**.
You could try removing the filters at [L# 382 & 383 of the `functions.php` file](https://github.com/toddmotto/html5blank/blob/master/functions.php).
```
// Protocol relative URLs for enqueue... |
96,300 | <p>I am using a plugin that has this line of code to add an action from the <code>Eazyest_Frontend</code> class:</p>
<pre><code>add_action( 'eazyest_gallery_thumbnails', 'ezg_thumbnails',5);
</code></pre>
<p>I want to remove that and do something a bit different without editing the plugin. I thought this added to my ... | [
{
"answer_id": 96304,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 3,
"selected": false,
"text": "<p>Maybe I got you wrong, but why don't you just put the following line in your <code>functions.php</code>:</p>\... | 2013/04/18 | [
"https://wordpress.stackexchange.com/questions/96300",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7450/"
] | I am using a plugin that has this line of code to add an action from the `Eazyest_Frontend` class:
```
add_action( 'eazyest_gallery_thumbnails', 'ezg_thumbnails',5);
```
I want to remove that and do something a bit different without editing the plugin. I thought this added to my functions.php file might work:
```
g... | Maybe I got you wrong, but why don't you just put the following line in your `functions.php`:
```
remove_action('eazyest_gallery_thumbnails', 'ezg_thumbnails');
```
If you have a class function hooked to an action, you can use the class name instead of the class object:
```
remove_action(
'eazyest_gallery_thumb... |
96,311 | <p>I want to display the all the posts that are inside a certain subcategory in a specific order that I decide (this is because the category contains a list of tutorials and I want to decide how to list them).</p>
<p>How can I do that?</p>
<p>Is there any plugin that I can use? I just want to be able to set the order... | [
{
"answer_id": 96304,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 3,
"selected": false,
"text": "<p>Maybe I got you wrong, but why don't you just put the following line in your <code>functions.php</code>:</p>\... | 2013/04/18 | [
"https://wordpress.stackexchange.com/questions/96311",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15690/"
] | I want to display the all the posts that are inside a certain subcategory in a specific order that I decide (this is because the category contains a list of tutorials and I want to decide how to list them).
How can I do that?
Is there any plugin that I can use? I just want to be able to set the order when displaying ... | Maybe I got you wrong, but why don't you just put the following line in your `functions.php`:
```
remove_action('eazyest_gallery_thumbnails', 'ezg_thumbnails');
```
If you have a class function hooked to an action, you can use the class name instead of the class object:
```
remove_action(
'eazyest_gallery_thumb... |
96,324 | <p>I observed the inside the <code>wp_head</code> function in the source links of every <code>.css</code>, <code>.js</code> files a <code>?ver=1</code> (<em>or other number based on the file's/library version</em>) is added. How can I overwrite them, to remove them?</p>
<p>This issue I think is causing problems on the... | [
{
"answer_id": 96325,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 5,
"selected": true,
"text": "<p>You can hook into <code>style_loader_src</code> and <code>script_loader_src</code> and run <code>remove_query_arg( 'ver... | 2013/04/18 | [
"https://wordpress.stackexchange.com/questions/96324",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I observed the inside the `wp_head` function in the source links of every `.css`, `.js` files a `?ver=1` (*or other number based on the file's/library version*) is added. How can I overwrite them, to remove them?
This issue I think is causing problems on the cache manifest part. | You can hook into `style_loader_src` and `script_loader_src` and run `remove_query_arg( 'ver', $url )` on the URL:
```
<?php
/* Plugin Name: Remove version parameter for scripts and styles */
add_filter( 'style_loader_src', 't5_remove_version' );
add_filter( 'script_loader_src', 't5_remove_version' );
function t5_re... |
96,338 | <p>I want to use the <code>WP_Query()</code> class to filter some of my posts. The problem I am facing now is handling the taxonomy query. Normally, the <code>WP_Query()</code> only handle one relationship for <code>tax_query()</code> (either AND or OR), but what I need is mixed use of these relationships on the <code>... | [
{
"answer_id": 96383,
"author": "helenhousandi",
"author_id": 2226,
"author_profile": "https://wordpress.stackexchange.com/users/2226",
"pm_score": 4,
"selected": false,
"text": "<p>This can be done by using the term_taxonomy_id rather than the slug, which will effectively ignore whichev... | 2013/04/18 | [
"https://wordpress.stackexchange.com/questions/96338",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31705/"
] | I want to use the `WP_Query()` class to filter some of my posts. The problem I am facing now is handling the taxonomy query. Normally, the `WP_Query()` only handle one relationship for `tax_query()` (either AND or OR), but what I need is mixed use of these relationships on the `tax_query()`, how can achieve it?
eg
... | This can be done by using the term\_taxonomy\_id rather than the slug, which will effectively ignore whichever taxonomy is specified and just look at the unique term\_taxonomy\_id field. This will allow you to effectively be able to do a mixed relationship. You'd want to use an overall relation of AND and put all the t... |
96,357 | <p>I'm using <code>wp_mail()</code> to send an HTML email. But there's quite a lot of HTML code in the email, so rather than including all the code in my <code>wp_mail()</code> function, is it possible to have the code in a separate template and just include this template in the function? Here is what I have:</p>
<pre... | [
{
"answer_id": 96363,
"author": "ItayXD",
"author_id": 17674,
"author_profile": "https://wordpress.stackexchange.com/users/17674",
"pm_score": 3,
"selected": false,
"text": "<p>The function <code>get_template_part()</code> doesn't return the HTML but echo it (it uses <code>locate_templat... | 2013/04/18 | [
"https://wordpress.stackexchange.com/questions/96357",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22448/"
] | I'm using `wp_mail()` to send an HTML email. But there's quite a lot of HTML code in the email, so rather than including all the code in my `wp_mail()` function, is it possible to have the code in a separate template and just include this template in the function? Here is what I have:
```
<?php if ( isset( $_POST['sub... | Per my comment to your question, I believe the problem is that `include`ing files, whether directly or using `get_template_part` isn't likely to give you a string to pass to `$body` and that is going to cause errors in the code, or at the very least unespected behavior.
I would avoid reading files into memory and jus... |
96,361 | <p>I want to organize themes like:</p>
<ol>
<li><code>wp-content/themes/themeshop/theme1</code></li>
<li><code>wp-content/themes/themeshop/theme2</code></li>
<li><code>wp-content/themes/themeshop/theme3</code></li>
</ol>
<p>Now from my understanding, this organization works perfectly at the folder level. I dropped th... | [
{
"answer_id": 96687,
"author": "Ralf912",
"author_id": 16589,
"author_profile": "https://wordpress.stackexchange.com/users/16589",
"pm_score": 2,
"selected": false,
"text": "<p>I think you are looking for an action hook or a filter to exclude your themes from the standard list of themes... | 2013/04/18 | [
"https://wordpress.stackexchange.com/questions/96361",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5730/"
] | I want to organize themes like:
1. `wp-content/themes/themeshop/theme1`
2. `wp-content/themes/themeshop/theme2`
3. `wp-content/themes/themeshop/theme3`
Now from my understanding, this organization works perfectly at the folder level. I dropped themes in subdirectories and everything seems to work fine. Now is it poss... | [***Updated plugin version available at GitHub.***](https://github.com/brasofilo/ThemeCategories)
I first saw your Question at [[wp-hackers] list](http://wordpress-hackers.1065353.n5.nabble.com/Themes-inside-subdirectories-of-wp-content-themes-folder-td41204.html), and, after implementing the solution, was about to pu... |
96,369 | <p>I'm using the standard WordPress search form to search a custom post type. Here is my code:</p>
<pre><code><form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
<input type="hidden" name="post_type" value="attorney" />
<input type="text" value="" name="s" /&g... | [
{
"answer_id": 96519,
"author": "Jesse",
"author_id": 9145,
"author_profile": "https://wordpress.stackexchange.com/users/9145",
"pm_score": 3,
"selected": true,
"text": "<p>I didn't test the code below, but I guess it works.</p>\n\n<pre><code>/**\n * Search SQL filter for matching agains... | 2013/04/18 | [
"https://wordpress.stackexchange.com/questions/96369",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31712/"
] | I'm using the standard WordPress search form to search a custom post type. Here is my code:
```
<form role="search" method="get" id="searchform" action="<?php echo home_url( '/' ); ?>">
<input type="hidden" name="post_type" value="attorney" />
<input type="text" value="" name="s" />
<input type="submit" value="Search"... | I didn't test the code below, but I guess it works.
```
/**
* Search SQL filter for matching against post title only.
*/
function __search_by_title_only( $search, &$wp_query )
{
/*my solution */
if($_GET['post_type'] != 'attorney' )
return $search;
/*my solution*/
//please copy the rest ... |
96,370 | <p>Is there any possibility to pass some PHP variables in javascript so I can use them later?</p>
<p>Only in <code>single.php</code>.<br />
I heard about <code>wp_enqueue_scripts</code> but with that it is neccesary to declare a path to a JS file, but I don`t need one.</p>
| [
{
"answer_id": 96375,
"author": "Johannes Pille",
"author_id": 9745,
"author_profile": "https://wordpress.stackexchange.com/users/9745",
"pm_score": 6,
"selected": true,
"text": "<h2>Best practice method</h2>\n\n<p>Have a look at <a href=\"http://codex.wordpress.org/Function_Reference/wp... | 2013/04/18 | [
"https://wordpress.stackexchange.com/questions/96370",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31499/"
] | Is there any possibility to pass some PHP variables in javascript so I can use them later?
Only in `single.php`.
I heard about `wp_enqueue_scripts` but with that it is neccesary to declare a path to a JS file, but I don`t need one. | Best practice method
--------------------
Have a look at [`wp_localize_script`](http://codex.wordpress.org/Function_Reference/wp_localize_script), which is meant to do exactly that.
But it *does require previous usage of [`wp_enqueue_scripts`](http://codex.wordpress.org/Function_Reference/wp_enqueue_script)*, hence y... |
96,371 | <p>I have some problems adding the wpColorPicker to a Widget. Does anyone have a working sample? It only works when I click on 'Save' or reload the page, but when I drag a new widget to the area it will not activate. Anyone any ideas? Below you can find my code so far.</p>
<pre><code>class SampleWidget extends WP_Widg... | [
{
"answer_id": 96386,
"author": "Dwayne Charrington",
"author_id": 1687,
"author_profile": "https://wordpress.stackexchange.com/users/1687",
"pm_score": 2,
"selected": false,
"text": "<p>I think what you really want to be doing is binding to the \"sortstop\" event which is triggered afte... | 2013/04/18 | [
"https://wordpress.stackexchange.com/questions/96371",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8757/"
] | I have some problems adding the wpColorPicker to a Widget. Does anyone have a working sample? It only works when I click on 'Save' or reload the page, but when I drag a new widget to the area it will not activate. Anyone any ideas? Below you can find my code so far.
```
class SampleWidget extends WP_Widget
{
... | I think what you really want to be doing is binding to the "sortstop" event which is triggered after a widget is dropped into a droppable sidebar area.
```
jQuery('div.widgets-sortables').bind('sortstop', function(event,ui) {
// This javascript code within here will be run after you've dropped a sidebar widget
});... |
96,395 | <p>I have a plugin which generates a page automatically. Is there a way I can add functionality to this plugin which would allow me to set the meta description, keywords, and title for the page? I've looked into SEO plugins like Yoast and AIOSEO but I cannot seem to achieve the desired goal.</p>
<p>Here is the source ... | [
{
"answer_id": 96398,
"author": "Johannes Pille",
"author_id": 9745,
"author_profile": "https://wordpress.stackexchange.com/users/9745",
"pm_score": 1,
"selected": false,
"text": "<p><em>Theoretically</em>, you could hook into <a href=\"http://codex.wordpress.org/Plugin_API/Action_Refere... | 2013/04/19 | [
"https://wordpress.stackexchange.com/questions/96395",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31740/"
] | I have a plugin which generates a page automatically. Is there a way I can add functionality to this plugin which would allow me to set the meta description, keywords, and title for the page? I've looked into SEO plugins like Yoast and AIOSEO but I cannot seem to achieve the desired goal.
Here is the source **(UPDATED... | *Theoretically*, you could hook into [`wp_head`](http://codex.wordpress.org/Plugin_API/Action_Reference/wp_head) and `echo` your tags from within your callback:
```
function wpse_36395_meta_tags() {
echo '<meta name="description" content="Your Description" />';
}
add_action( 'wp_head', 'wpse_36395_meta_tags' );
`... |
96,404 | <p>I have a WordPress parent theme that uses a custom post type called <code>portfolio</code>, which I'd like to change to <code>property</code>.</p>
<p>I'd like to have all of the contextual elements changed to show <code>property</code> like, <code>"show properties"</code>, <code>"add new property"</code>, <code>"de... | [
{
"answer_id": 96405,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 3,
"selected": true,
"text": "<p><code>$wp_post_types</code> is a global array that holds <code>post_type</code> objects, which in turn have... | 2013/04/19 | [
"https://wordpress.stackexchange.com/questions/96404",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12478/"
] | I have a WordPress parent theme that uses a custom post type called `portfolio`, which I'd like to change to `property`.
I'd like to have all of the contextual elements changed to show `property` like, `"show properties"`, `"add new property"`, `"delete property"`, etc.
I know I can do this by updating the parent t... | `$wp_post_types` is a global array that holds `post_type` objects, which in turn have a `labels` property.
You can change `$wp_post_types[$post_type]->labels` after the parent theme has set the CPT.
Add higher priority to `init` hook.
Add the following code in your theme's `functions.php` file.
For more informati... |
96,406 | <p>Is there a way to remove published comments so they're hidden for logged out users?</p>
| [
{
"answer_id": 96409,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>Based on an <a href=\"http://wpengineer.com/2302/how-to-disable-comments-for-wordpress-pages-in-any-theme/\" rel=\"nof... | 2013/04/19 | [
"https://wordpress.stackexchange.com/questions/96406",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29218/"
] | Is there a way to remove published comments so they're hidden for logged out users? | I would recommend looking for all occurrences of `comments_template` in your theme and wrapping them in a `is_user_logged_in` condiational.
Example:
```
<?php
if (is_user_logged_in()) {
comments_template();
}
```
Alternatively, you can open up your theme's `comments.php` (or the equivalent, it's usually `commen... |
96,407 | <p>I am trying to figure out how to add a dropdown widget to the post page. The reason I ask is because I would like to be able to have a few different post classes that the user can select while making a post that they can select. </p>
<p>I figure I can use post_class and define a few different classes and allow the ... | [
{
"answer_id": 96414,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 1,
"selected": false,
"text": "<p>You can use <a href=\"http://codex.wordpress.org/Function_Reference/add_meta_box\" rel=\"nofollow\">meta b... | 2013/04/19 | [
"https://wordpress.stackexchange.com/questions/96407",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31618/"
] | I am trying to figure out how to add a dropdown widget to the post page. The reason I ask is because I would like to be able to have a few different post classes that the user can select while making a post that they can select.
I figure I can use post\_class and define a few different classes and allow the user to u... | Since this is very similar to post formats (see [post-formats](/questions/tagged/post-formats "show questions tagged 'post-formats'")) I would use a custom taxonomy.
That makes it easy to control the access level, and you get the meta box without writing extra code.
 ) : ?>
</code></pre>
<p>is showing default price we entered as product price (this price is excluding ... | [
{
"answer_id": 96411,
"author": "Bass Jobsen",
"author_id": 31759,
"author_profile": "https://wordpress.stackexchange.com/users/31759",
"pm_score": 4,
"selected": true,
"text": "<p>Try:</p>\n\n<pre><code> <?php echo woocommerce_price($product->get_price_including_tax()); ?>\n</c... | 2013/04/18 | [
"https://wordpress.stackexchange.com/questions/96410",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31753/"
] | Af first, I'm not a programmer. In Woocommerce I need to display both product prices, including tax and excluding tax. Code in price.php
```
<?php if ( $price_html = $product->get_price_html() ) : ?>
```
is showing default price we entered as product price (this price is excluding tax). I have a problem with display... | Try:
```
<?php echo woocommerce_price($product->get_price_including_tax()); ?>
``` |
96,417 | <p>I use the following to add Phone number,linked id etc Under the "Contact Info" in user profile. Now I have to add a filed under the "About the user". How can i do that?</p>
<pre><code>function my_new_contactmethods( $contactmethods ) {
$contactmethods['designation'] = 'Designation';
$contactmethods['linked_in'] = '... | [
{
"answer_id": 96411,
"author": "Bass Jobsen",
"author_id": 31759,
"author_profile": "https://wordpress.stackexchange.com/users/31759",
"pm_score": 4,
"selected": true,
"text": "<p>Try:</p>\n\n<pre><code> <?php echo woocommerce_price($product->get_price_including_tax()); ?>\n</c... | 2013/04/19 | [
"https://wordpress.stackexchange.com/questions/96417",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28044/"
] | I use the following to add Phone number,linked id etc Under the "Contact Info" in user profile. Now I have to add a filed under the "About the user". How can i do that?
```
function my_new_contactmethods( $contactmethods ) {
$contactmethods['designation'] = 'Designation';
$contactmethods['linked_in'] = 'Linked In';
$c... | Try:
```
<?php echo woocommerce_price($product->get_price_including_tax()); ?>
``` |
96,426 | <p>I am developing a simple child theme based on twentyeleven. But i notice twentyeleven has a showcase and sidebar template when you add a new page. How can i disable these templates from functions.php?
I want to show only the templates from the child theme</p>
<p>regards</p>
| [
{
"answer_id": 96986,
"author": "MikeSchinkel",
"author_id": 89,
"author_profile": "https://wordpress.stackexchange.com/users/89",
"pm_score": 2,
"selected": false,
"text": "<p>As @toscho mentioned it is tricky. But it is doable.</p>\n<p>Basically you need to find action hooks called bef... | 2013/04/19 | [
"https://wordpress.stackexchange.com/questions/96426",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9936/"
] | I am developing a simple child theme based on twentyeleven. But i notice twentyeleven has a showcase and sidebar template when you add a new page. How can i disable these templates from functions.php?
I want to show only the templates from the child theme
regards | As @toscho mentioned it is tricky. But it is doable.
Basically you need to find action hooks called before and after the template dropdown is generated and call `ob_start()` to initiate output buffering and `ob_get_clean()` to capture the buffered HTML. The `'submitpage_box'` and `'edit_page_form'` hooks will work for... |
96,444 | <p>I have three custom post types set up, <code>articles</code>, <code>videos</code> and <code>photos</code>.<br>
I am using standard categories for these post types, and sharing the categories across all post types.</p>
<p>I am trying to create a nav menu for each post type, listing the categories, that should follow... | [
{
"answer_id": 96448,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 4,
"selected": true,
"text": "<p>Put the following in your <code>functions.php</code>:</p>\n\n<pre><code>function wp_list_categories_for_post_t... | 2013/04/19 | [
"https://wordpress.stackexchange.com/questions/96444",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6681/"
] | I have three custom post types set up, `articles`, `videos` and `photos`.
I am using standard categories for these post types, and sharing the categories across all post types.
I am trying to create a nav menu for each post type, listing the categories, that should follow the following structure:
* Photos
+ Cat ... | Put the following in your `functions.php`:
```
function wp_list_categories_for_post_type($post_type, $args = '') {
$exclude = array();
// Check ALL categories for posts of given post type
foreach (get_categories() as $category) {
$posts = get_posts(array('post_type' => $post_type, 'category' => $c... |
96,447 | <p>If I insert multiple custom fields to my article, they get sorted in <em>"I don't know what"</em> way. So when I insert some multiple fields in an article and call those via</p>
<pre><code>$cf = get_post_custom();
foreach ($cf['ISSUU-configID'] as $key => $value) {
echo "<h4>" . $cf['ISSUU-configID'][$ke... | [
{
"answer_id": 96450,
"author": "Manny Fleurmond",
"author_id": 2234,
"author_profile": "https://wordpress.stackexchange.com/users/2234",
"pm_score": 1,
"selected": false,
"text": "<p>You can call custom fields individually via the <code>get_post_meta</code> function:</p>\n\n<pre><code>$... | 2013/04/19 | [
"https://wordpress.stackexchange.com/questions/96447",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10994/"
] | If I insert multiple custom fields to my article, they get sorted in *"I don't know what"* way. So when I insert some multiple fields in an article and call those via
```
$cf = get_post_custom();
foreach ($cf['ISSUU-configID'] as $key => $value) {
echo "<h4>" . $cf['ISSUU-configID'][$key] . "</h4>\n";
}
```
their ... | The SQL query triggered by `get_post_custom()` is in `update_meta_cache()` and it looks like this:
```
$wpdb->get_results(
$wpdb->prepare(
"SELECT $column, meta_key, meta_value FROM $table WHERE $column IN ($id_list)",
$meta_type
),
ARRAY_A
);
```
So there is no `ORDER BY` given.
Wit... |
96,471 | <p>I have this twitter share button that pulls 100 characters from the content of the post and its URL for the twitter share.</p>
<pre><code><a class="popup"
href="http://twitter.com/share?url=<?php
echo urlencode(get_permalink($post->ID));
?>&amp;text=<?php the_content_limit(100, ""... | [
{
"answer_id": 96473,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": true,
"text": "<p>You are sending <code>text</code> unencoded. <code>urlencode</code> that just like you do the permalink.</p>\n... | 2013/04/19 | [
"https://wordpress.stackexchange.com/questions/96471",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30939/"
] | I have this twitter share button that pulls 100 characters from the content of the post and its URL for the twitter share.
```
<a class="popup"
href="http://twitter.com/share?url=<?php
echo urlencode(get_permalink($post->ID));
?>&text=<?php the_content_limit(100, "");?>">
<img src="http://zitat... | You are sending `text` unencoded. `urlencode` that just like you do the permalink.
```
<a class="popup" href="http://twitter.com/share?url=<?php echo urlencode(get_permalink($post->ID)); ?>&text=<?php echo urlencode(the_content_limit(100, ""));?>"><img src="http://zitatezumnachdenken.com/wp-content/uploads/2013/04... |
96,472 | <p>I have a search form that I want to place in multiple pages (it will be in different header types) I do this by using the 'get search form' function. On my Search form I have radio sections listing two custom post types 'poster' and 'house'.</p>
<p>I have two different search pages for each post type. I want them t... | [
{
"answer_id": 96473,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": true,
"text": "<p>You are sending <code>text</code> unencoded. <code>urlencode</code> that just like you do the permalink.</p>\n... | 2013/04/19 | [
"https://wordpress.stackexchange.com/questions/96472",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28123/"
] | I have a search form that I want to place in multiple pages (it will be in different header types) I do this by using the 'get search form' function. On my Search form I have radio sections listing two custom post types 'poster' and 'house'.
I have two different search pages for each post type. I want them to be separ... | You are sending `text` unencoded. `urlencode` that just like you do the permalink.
```
<a class="popup" href="http://twitter.com/share?url=<?php echo urlencode(get_permalink($post->ID)); ?>&text=<?php echo urlencode(the_content_limit(100, ""));?>"><img src="http://zitatezumnachdenken.com/wp-content/uploads/2013/04... |
96,476 | <p>I am looking at my server settings and these are as follows:</p>
<blockquote>
<ul>
<li><p>WebDav : active</p></li>
<li><p>FastCGI : inactive</p></li>
<li><p>SSL support : active</p></li>
<li><p>Perl as Apache module : CGI-Programm</p></li>
<li><p>PHP module : CGI-Programm</p></li>
<li><p>Mem... | [
{
"answer_id": 96473,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": true,
"text": "<p>You are sending <code>text</code> unencoded. <code>urlencode</code> that just like you do the permalink.</p>\n... | 2013/04/19 | [
"https://wordpress.stackexchange.com/questions/96476",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30873/"
] | I am looking at my server settings and these are as follows:
>
> * WebDav : active
> * FastCGI : inactive
> * SSL support : active
> * Perl as Apache module : CGI-Programm
> * PHP module : CGI-Programm
> * Memory usage : 131072 kB
> * Process timeout : 60 seconds
> * Maximum simultaneous processes : 1024
>
>
>
Us... | You are sending `text` unencoded. `urlencode` that just like you do the permalink.
```
<a class="popup" href="http://twitter.com/share?url=<?php echo urlencode(get_permalink($post->ID)); ?>&text=<?php echo urlencode(the_content_limit(100, ""));?>"><img src="http://zitatezumnachdenken.com/wp-content/uploads/2013/04... |
96,503 | <p>I want to automatically add caption for each picture appears in the name of the image or the alternative text</p>
<p>example Caption add automatic</p>
<p><img src="https://i.stack.imgur.com/piYwF.png" alt="example"></p>
| [
{
"answer_id": 147535,
"author": "yuyazz",
"author_id": 52684,
"author_profile": "https://wordpress.stackexchange.com/users/52684",
"pm_score": -1,
"selected": false,
"text": "<p>To put in a plugin, these solutions came from eskimo and sam..\nwe simply select all the attachment where the... | 2013/04/19 | [
"https://wordpress.stackexchange.com/questions/96503",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30744/"
] | I want to automatically add caption for each picture appears in the name of the image or the alternative text
example Caption add automatic
 | You can add programmatically caption, alt, description every time you upload image at backend.
<https://brutalbusiness.com/automatically-set-the-wordpress-image-title-alt-text-other-meta/>
I tried myself this and worked nice as your expectation. This is for all your future upload images.
Try this and let me know.
`... |
96,510 | <p>I have a problem with the <code>update_post_meta</code> function.<br />
I have a user submitted value, which I pass via <code>$_POST</code> and then saving to post meta.</p>
<p>All is working fine, but when the value is <code>'0'</code> the post meta is not updated.</p>
<p>My code:</p>
<pre><code>$id = absint($_P... | [
{
"answer_id": 96536,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 2,
"selected": false,
"text": "<p><code>update_post_meta()</code> calls <code>update_metadata</code> which begins with this line:</p>\n... | 2013/04/19 | [
"https://wordpress.stackexchange.com/questions/96510",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25348/"
] | I have a problem with the `update_post_meta` function.
I have a user submitted value, which I pass via `$_POST` and then saving to post meta.
All is working fine, but when the value is `'0'` the post meta is not updated.
My code:
```
$id = absint($_POST['ex_id']);
$key = (string) $_POST['id'];
$value = (string) $... | `update_post_meta()` calls `update_metadata` which begins with this line:
```
if ( !$meta_type || !$meta_key )
return false;
```
I wrote a simple test (with a lot of cut & paste) to see how string values of 0 are evaluated (instead of looking it up in the PHP manual):
```
<?php
$meta_key = (string) 0;
if ( ! ... |
96,513 | <p>I am frustrated having to click on the "Upload Files" constantly instead of the first choice being Upload Files in posts editor....How can i make “Upload files” selected by default instead of "Media library"? </p>
<p><img src="https://i.stack.imgur.com/nIcMv.jpg" alt=""></p>
| [
{
"answer_id": 96517,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 4,
"selected": false,
"text": "<p>Add this to your functions.php, or preferably a <a href=\"http://justintadlock.com/archives/2011/02/02/creati... | 2013/04/19 | [
"https://wordpress.stackexchange.com/questions/96513",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29072/"
] | I am frustrated having to click on the "Upload Files" constantly instead of the first choice being Upload Files in posts editor....How can i make “Upload files” selected by default instead of "Media library"?
 | Add this to your functions.php, or preferably a [functionality plugin](http://justintadlock.com/archives/2011/02/02/creating-a-custom-functions-plugin-for-end-users).
```
add_action( 'admin_footer-post-new.php', 'media_manager_default' );
add_action( 'admin_footer-post.php', 'media_manager_default' );
function media_... |
96,545 | <p>this is a bit challenging for me:
I am using the great <a href="http://www.advancedcustomfields.com" rel="nofollow">Advanced Custom Field</a> plugin on my site to create different color scheme to each of my taxonomy.</p>
<p>I created a field called <strong>taxonomy_color</strong> and echoed out the color like so:</... | [
{
"answer_id": 100081,
"author": "ArleyM",
"author_id": 27541,
"author_profile": "https://wordpress.stackexchange.com/users/27541",
"pm_score": 0,
"selected": false,
"text": "<p>I think the <code>the_field</code> function will only get you so far. You could use the WordPress <a href=\"ht... | 2013/04/20 | [
"https://wordpress.stackexchange.com/questions/96545",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7730/"
] | this is a bit challenging for me:
I am using the great [Advanced Custom Field](http://www.advancedcustomfields.com) plugin on my site to create different color scheme to each of my taxonomy.
I created a field called **taxonomy\_color** and echoed out the color like so:
```
<h4 style="color: <?php the_field('taxonomy_... | **style.php** does not have access to the WP variables, loop and so on. If you'd want to do that, you would need to repeat at least some of the queries used on your main page, and you would also add a new request for the browser, as you'd have the separate file.
I would rather generate a class based on the colors, use... |