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 |
|---|---|---|---|---|---|---|
81,917 | <p>I am trying to build my first plugin but am receiving the following error:</p>
<blockquote>
<p>Warning: Cannot modify header information - headers already sent by (output started at <code>/wp-admin/includes/template.php:1642</code>) in <code>/wp-includes/pluggable.php</code> on line 876</p>
</blockquote>
<p>But ... | [
{
"answer_id": 81918,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 0,
"selected": false,
"text": "<p>It's most likely a space after the closing <code>?></code> tag. The WordPress Codex <a href=\"http://codex.wor... | 2013/01/17 | [
"https://wordpress.stackexchange.com/questions/81917",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10507/"
] | I am trying to build my first plugin but am receiving the following error:
>
> Warning: Cannot modify header information - headers already sent by (output started at `/wp-admin/includes/template.php:1642`) in `/wp-includes/pluggable.php` on line 876
>
>
>
But here's the thing: template.php isn't 1600 lines long a... | I'll guess your include is failing. If it's in the same directory as your main plugin file, try:
```
include( plugin_dir_path(__FILE__) . '/admin.php' );
``` |
81,939 | <p>I created a new post type named "Video".</p>
<p>When I create post for the post type, posts is ordered by <code>title ASC</code>.</p>
<p><strong>Is it possible to order posts by date DESC please ?</strong> </p>
<pre><code>register_post_type('Videos', array(
'labels' => array(
'name' => _x('Video... | [
{
"answer_id": 82018,
"author": "Pontus Abrahamsson",
"author_id": 16722,
"author_profile": "https://wordpress.stackexchange.com/users/16722",
"pm_score": 5,
"selected": true,
"text": "<p>Alright, You can just hook into the filter <a href=\"http://codex.wordpress.org/Plugin_API/Action_Re... | 2013/01/17 | [
"https://wordpress.stackexchange.com/questions/81939",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2000/"
] | I created a new post type named "Video".
When I create post for the post type, posts is ordered by `title ASC`.
**Is it possible to order posts by date DESC please ?**
```
register_post_type('Videos', array(
'labels' => array(
'name' => _x('Videos', 'post type general name'),
'singular_name' => ... | Alright, You can just hook into the filter [pre\_get\_posts](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) and check [is\_admin](http://codex.wordpress.org/Function_Reference/is_admin).
Put this in your theme or plugin:
```
function wpse_81939_post_types_admin_order( $wp_query ) {
if (is_adm... |
81,950 | <p>My <a href="http://demosite.co/reviews/" rel="nofollow">page in question is here.</a></p>
<p>I have tried to add a <code>comments.php</code> to my custom theme so I can remove the website field and so I could edit the default values of the fields and remove the labels. When I add a <code>comments.php</code> all of ... | [
{
"answer_id": 81956,
"author": "Rohit Pande",
"author_id": 21274,
"author_profile": "https://wordpress.stackexchange.com/users/21274",
"pm_score": 0,
"selected": false,
"text": "<p>There are multiple solutions for your question.</p>\n\n<ol>\n<li><p>Using the <code>CSS</code> trick</p>\n... | 2013/01/17 | [
"https://wordpress.stackexchange.com/questions/81950",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10666/"
] | My [page in question is here.](http://demosite.co/reviews/)
I have tried to add a `comments.php` to my custom theme so I can remove the website field and so I could edit the default values of the fields and remove the labels. When I add a `comments.php` all of my comments disappear and the comments are no longer funct... | A little late, but you could also add the following to your theme's functions.php file:
```
/** Comment Form Function Defaults */
add_filter('comment_form_defaults','my_comment_defaults');
function my_comment_defaults($defaults) {
global $user_identity, $id;
if ( isset($post_id) )
... |
81,951 | <p>Could you please help me with some code to get all recent comments for posts that are tagged with for example "XYZ"?</p>
<p>Thanks in advance, you guys are great!</p>
| [
{
"answer_id": 81956,
"author": "Rohit Pande",
"author_id": 21274,
"author_profile": "https://wordpress.stackexchange.com/users/21274",
"pm_score": 0,
"selected": false,
"text": "<p>There are multiple solutions for your question.</p>\n\n<ol>\n<li><p>Using the <code>CSS</code> trick</p>\n... | 2013/01/17 | [
"https://wordpress.stackexchange.com/questions/81951",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26145/"
] | Could you please help me with some code to get all recent comments for posts that are tagged with for example "XYZ"?
Thanks in advance, you guys are great! | A little late, but you could also add the following to your theme's functions.php file:
```
/** Comment Form Function Defaults */
add_filter('comment_form_defaults','my_comment_defaults');
function my_comment_defaults($defaults) {
global $user_identity, $id;
if ( isset($post_id) )
... |
81,958 | <p>I have a custom post type called 'seasons' and in there i have 3 categories (summer,winter and spring.)</p>
<p>I want to show 10 random post from the winter category on a page.</p>
<p>Please help.</p>
| [
{
"answer_id": 81956,
"author": "Rohit Pande",
"author_id": 21274,
"author_profile": "https://wordpress.stackexchange.com/users/21274",
"pm_score": 0,
"selected": false,
"text": "<p>There are multiple solutions for your question.</p>\n\n<ol>\n<li><p>Using the <code>CSS</code> trick</p>\n... | 2013/01/17 | [
"https://wordpress.stackexchange.com/questions/81958",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23833/"
] | I have a custom post type called 'seasons' and in there i have 3 categories (summer,winter and spring.)
I want to show 10 random post from the winter category on a page.
Please help. | A little late, but you could also add the following to your theme's functions.php file:
```
/** Comment Form Function Defaults */
add_filter('comment_form_defaults','my_comment_defaults');
function my_comment_defaults($defaults) {
global $user_identity, $id;
if ( isset($post_id) )
... |
81,972 | <p>My blog have many author. I can list all author.</p>
<p>All Author list:</p>
<pre><code><ul>
<?php wp_list_authors('exclude_admin=0&optioncount=1&show_fullname=1&hide_empty=1'); ?>
</ul>
</code></pre>
<p>But I want to sort in a special way.</p>
<p>For Example im currently viewing Te... | [
{
"answer_id": 81956,
"author": "Rohit Pande",
"author_id": 21274,
"author_profile": "https://wordpress.stackexchange.com/users/21274",
"pm_score": 0,
"selected": false,
"text": "<p>There are multiple solutions for your question.</p>\n\n<ol>\n<li><p>Using the <code>CSS</code> trick</p>\n... | 2013/01/17 | [
"https://wordpress.stackexchange.com/questions/81972",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25951/"
] | My blog have many author. I can list all author.
All Author list:
```
<ul>
<?php wp_list_authors('exclude_admin=0&optioncount=1&show_fullname=1&hide_empty=1'); ?>
</ul>
```
But I want to sort in a special way.
For Example im currently viewing Tech category page, I want a list of author with these id (3,10,12). I w... | A little late, but you could also add the following to your theme's functions.php file:
```
/** Comment Form Function Defaults */
add_filter('comment_form_defaults','my_comment_defaults');
function my_comment_defaults($defaults) {
global $user_identity, $id;
if ( isset($post_id) )
... |
81,974 | <p>I am using <a href="http://wordpress.org/extend/plugins/events-manager/" rel="nofollow">Event Manager</a> plugin. I want to use many of the shortcodes via php code. e.g [events_calendar]</p>
| [
{
"answer_id": 81975,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 3,
"selected": true,
"text": "<p>In general, you can do any shortcode with <code>do_shortcode()</code> (see <a href=\"http://codex.wordpres... | 2013/01/17 | [
"https://wordpress.stackexchange.com/questions/81974",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26188/"
] | I am using [Event Manager](http://wordpress.org/extend/plugins/events-manager/) plugin. I want to use many of the shortcodes via php code. e.g [events\_calendar] | In general, you can do any shortcode with `do_shortcode()` (see [codex](http://codex.wordpress.org/Function_Reference/do_shortcode)). But if they have a template function available, its probably best to use that.
```
echo do_shortcode('[events_calendar]');
``` |
81,976 | <p>I am having issue with WP_Query, My scenario:
a) Using <a href="http://wordpress.org/extend/plugins/countries/" rel="nofollow">http://wordpress.org/extend/plugins/countries/</a>
b) Using WP_Query to fetch countries and their codes only.
c) resetting query properly.
d) using custom post type
e) using meta boxes
f) us... | [
{
"answer_id": 81990,
"author": "WP Themes",
"author_id": 25649,
"author_profile": "https://wordpress.stackexchange.com/users/25649",
"pm_score": 0,
"selected": false,
"text": "<p>You don't need to check for custom post type to add meta boxes. You only need to specify which custom post t... | 2013/01/17 | [
"https://wordpress.stackexchange.com/questions/81976",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24599/"
] | I am having issue with WP\_Query, My scenario:
a) Using <http://wordpress.org/extend/plugins/countries/>
b) Using WP\_Query to fetch countries and their codes only.
c) resetting query properly.
d) using custom post type
e) using meta boxes
f) using get\_post\_type() to retrieve the custom post type.
Here is code snipp... | If you [look at the source](http://core.trac.wordpress.org/browser/tags/3.5/wp-includes/post.php#L1064) and the [Codex page](http://codex.wordpress.org/Function_Reference/get_post_type) for [`get_post_type`](http://codex.wordpress.org/Function_Reference/get_post_type) you will see that returns the type of the "current ... |
81,980 | <p>Currently I am working on a rating plugin. You can see the code I got so far below:</p>
<pre><code><?php if (function_exists('get_highest_rated')): ?>
<ul>
<?php get_highest_rated_tag(12, 'both', 0, 10); ?>
</ul>
<?php endif; ?>
</code></pre>
<p>But now it comes to a bit of php that I... | [
{
"answer_id": 81981,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/get_term_by\" rel=\"nofollow\">get_term_by()</a> might... | 2013/01/17 | [
"https://wordpress.stackexchange.com/questions/81980",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23149/"
] | Currently I am working on a rating plugin. You can see the code I got so far below:
```
<?php if (function_exists('get_highest_rated')): ?>
<ul>
<?php get_highest_rated_tag(12, 'both', 0, 10); ?>
</ul>
<?php endif; ?>
```
But now it comes to a bit of php that I simply can't find on the web so far, so I will ask you.... | [get\_term\_by()](http://codex.wordpress.org/Function_Reference/get_term_by) might help you here.
```
$tag = get_term_by('id', 12, 'post_tag'); //or whatever taxonomy you are using
echo $tag->name;
``` |
82,004 | <p>I have a sample code:</p>
<pre><code>function change_author_permalinks() {
global $wp_rewrite;
$wp_rewrite->author_base = 'u';
$wp_rewrite->author_structure = "/" . $wp_rewrite->author_base . '/%author%';
add_rewrite_rule('u/([^/]+)/?$', 'index.php?author_name=$matches[1]', 'top');
}
add_ac... | [
{
"answer_id": 82205,
"author": "helgatheviking",
"author_id": 6477,
"author_profile": "https://wordpress.stackexchange.com/users/6477",
"pm_score": 2,
"selected": false,
"text": "<p>This is what I did to change the author base:</p>\n\n<pre><code>// change base of author pages- need to s... | 2013/01/17 | [
"https://wordpress.stackexchange.com/questions/82004",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19179/"
] | I have a sample code:
```
function change_author_permalinks() {
global $wp_rewrite;
$wp_rewrite->author_base = 'u';
$wp_rewrite->author_structure = "/" . $wp_rewrite->author_base . '/%author%';
add_rewrite_rule('u/([^/]+)/?$', 'index.php?author_name=$matches[1]', 'top');
}
add_action('init','change_aut... | You're close, but you don't need the `add_rewrite_rule` call.
```
add_action('init', 'wpse82004_init');
function wpse82004_init()
{
global $wp_rewrite;
$wp_rewrite->author_base = 'u';
$wp_rewrite->author_structure = '/' . $wp_rewrite->author_base . '/%author%';
}
```
After that's in place, just re-save p... |
82,020 | <p>I have a custom meta box created using Rilwis meta box script(http://www.deluxeblogtips.com/meta-box/) inside my theme functions.php.</p>
<p>It has 2 text fields, one field is required to fetch results from api, so, it needs to be visible on the custom meta box.
But, the other field stores a serialized array which ... | [
{
"answer_id": 82205,
"author": "helgatheviking",
"author_id": 6477,
"author_profile": "https://wordpress.stackexchange.com/users/6477",
"pm_score": 2,
"selected": false,
"text": "<p>This is what I did to change the author base:</p>\n\n<pre><code>// change base of author pages- need to s... | 2013/01/17 | [
"https://wordpress.stackexchange.com/questions/82020",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26168/"
] | I have a custom meta box created using Rilwis meta box script(http://www.deluxeblogtips.com/meta-box/) inside my theme functions.php.
It has 2 text fields, one field is required to fetch results from api, so, it needs to be visible on the custom meta box.
But, the other field stores a serialized array which is the res... | You're close, but you don't need the `add_rewrite_rule` call.
```
add_action('init', 'wpse82004_init');
function wpse82004_init()
{
global $wp_rewrite;
$wp_rewrite->author_base = 'u';
$wp_rewrite->author_structure = '/' . $wp_rewrite->author_base . '/%author%';
}
```
After that's in place, just re-save p... |
82,032 | <p>I have a plugin that is conflicting with some default wordpress functions. In the post and page creating/edit areas. I only need my functions on my settings pages. I have the js file loading in admin, no problem.</p>
<p>Can I tell the script not to load unless I'm viewing the settings pages for my plug?</p>
| [
{
"answer_id": 82034,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 4,
"selected": true,
"text": "<p>You need to use a plugin page-specific script enqueue hook.</p>\n\n<h2>Edit</h2>\n\n<p>Best-practice method ... | 2013/01/17 | [
"https://wordpress.stackexchange.com/questions/82032",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8278/"
] | I have a plugin that is conflicting with some default wordpress functions. In the post and page creating/edit areas. I only need my functions on my settings pages. I have the js file loading in admin, no problem.
Can I tell the script not to load unless I'm viewing the settings pages for my plug? | You need to use a plugin page-specific script enqueue hook.
Edit
----
Best-practice method is to use `admin_enqueue_scripts-{hook}`, rather than `admin_print_scirpts-{hook}`. But, because you're targeting your own Plugin's admin page specifically, either one is perfectly fine.
The hook to avoid is the "global" `admi... |
82,046 | <p>The wordpress theme I bought has some jQuery UI styling included in its default CSS file. The problem is I have a plugin that uses jQuery UI and the theme's default CSS makes the plugin corrupted. I want the default jquery UI CSS file to override UI styling contained in my theme's CSS file.<br>
I see some people me... | [
{
"answer_id": 82059,
"author": "NW Tech",
"author_id": 5295,
"author_profile": "https://wordpress.stackexchange.com/users/5295",
"pm_score": 0,
"selected": false,
"text": "<p>You might be able to try something like this in your footer:</p>\n\n<pre><code><?php\nfunction my_scripts_met... | 2013/01/17 | [
"https://wordpress.stackexchange.com/questions/82046",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3235/"
] | The wordpress theme I bought has some jQuery UI styling included in its default CSS file. The problem is I have a plugin that uses jQuery UI and the theme's default CSS makes the plugin corrupted. I want the default jquery UI CSS file to override UI styling contained in my theme's CSS file.
I see some people mentio... | You want the plugins style sheet to over ride your themes style sheet conditionally ( on one page).
Dequeue your themes style sheet for a specific page conditionally.
```
add_action( 'wp_enqueue_scripts', 'remove_default_stylesheet', 25 );
function remove_default_stylesheet() {
if ( is_page( page id or slug) ) {
... |
82,054 | <p>I have the following function in my functions.php. I am trying to disable the admin from receiving emails every time a new user joins the site. However, the admin is still receiving emails. Is there something wrong with the function? And is this part of the WP options by any chance? I couldn't find the option anywhe... | [
{
"answer_id": 82059,
"author": "NW Tech",
"author_id": 5295,
"author_profile": "https://wordpress.stackexchange.com/users/5295",
"pm_score": 0,
"selected": false,
"text": "<p>You might be able to try something like this in your footer:</p>\n\n<pre><code><?php\nfunction my_scripts_met... | 2013/01/17 | [
"https://wordpress.stackexchange.com/questions/82054",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18320/"
] | I have the following function in my functions.php. I am trying to disable the admin from receiving emails every time a new user joins the site. However, the admin is still receiving emails. Is there something wrong with the function? And is this part of the WP options by any chance? I couldn't find the option anywhere.... | You want the plugins style sheet to over ride your themes style sheet conditionally ( on one page).
Dequeue your themes style sheet for a specific page conditionally.
```
add_action( 'wp_enqueue_scripts', 'remove_default_stylesheet', 25 );
function remove_default_stylesheet() {
if ( is_page( page id or slug) ) {
... |
82,072 | <p>I have no idea why this foreach it`s not running. When i post the article, only inserts once. Should make it at much as needed. Do you see any problem?</p>
<pre><code>$array_produse = array();
for($i=1; $i<=8; $i++)
{
$gramaj = isset($_POST['image'.$i.'_gramaj']) ? $_POST['image'.$i.'_gramaj'] : '';
$pre... | [
{
"answer_id": 82074,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 3,
"selected": true,
"text": "<p>Simply use a Custom Field with its name <a href=\"http://codex.wordpress.org/Function_Reference/add_post_meta... | 2013/01/17 | [
"https://wordpress.stackexchange.com/questions/82072",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26178/"
] | I have no idea why this foreach it`s not running. When i post the article, only inserts once. Should make it at much as needed. Do you see any problem?
```
$array_produse = array();
for($i=1; $i<=8; $i++)
{
$gramaj = isset($_POST['image'.$i.'_gramaj']) ? $_POST['image'.$i.'_gramaj'] : '';
$pret = isset($_POST[... | Simply use a Custom Field with its name [starting with an underscore](http://codex.wordpress.org/Function_Reference/add_post_meta#Making_a_.22Hidden.22_Custom_Field), so it won't show up in the CF meta box, eg, **`_field_name`** instead of `field_name`.
It will be hidden for all roles, but if you are manipulating its ... |
82,092 | <p>I'm running in to a bit of a problem.</p>
<p>I have a function called <code>get_press()</code>, it retrieves newest press items. It is inside of a plugin:</p>
<pre><code>class EWPress {
function __construct()
{
load_plugin_textdomain( 'ew', flase, dirname( plugin_basename( __FILE__ ) ) . '/lang' );... | [
{
"answer_id": 82242,
"author": "tr3online",
"author_id": 12203,
"author_profile": "https://wordpress.stackexchange.com/users/12203",
"pm_score": 0,
"selected": false,
"text": "<p>For some odd reason <code>WP_Query</code> is the culprit behind this issue. </p>\n\n<p>When doing an AJAX re... | 2013/01/18 | [
"https://wordpress.stackexchange.com/questions/82092",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12203/"
] | I'm running in to a bit of a problem.
I have a function called `get_press()`, it retrieves newest press items. It is inside of a plugin:
```
class EWPress {
function __construct()
{
load_plugin_textdomain( 'ew', flase, dirname( plugin_basename( __FILE__ ) ) . '/lang' );
add_action( 'wp_enqueu... | I believe Milo is right, it's probably a filter affecting this. Ajax requests look like admin requests (that is, `is_admin()` returns true), so it's possible that something is checking if `is_admin()` and adding the filter in those cases.
You can set `'suppress_filters' => true` in your args array and it will probably... |
82,095 | <p>I have the following script and enque function, and the site properly renders it in the html head, however when I click the link to the css and javascript files the i get a url not found, however the url is correct. I changed the permissions to 777 for all the folders so I am not sure why it cant see it. You can vie... | [
{
"answer_id": 82098,
"author": "webaware",
"author_id": 24260,
"author_profile": "https://wordpress.stackexchange.com/users/24260",
"pm_score": 3,
"selected": true,
"text": "<p>You have called your theme <code>mrskitson.caVersion#3</code>. Do you know what a hash symbol (<code>#</code>)... | 2013/01/18 | [
"https://wordpress.stackexchange.com/questions/82095",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7653/"
] | I have the following script and enque function, and the site properly renders it in the html head, however when I click the link to the css and javascript files the i get a url not found, however the url is correct. I changed the permissions to 777 for all the folders so I am not sure why it cant see it. You can view t... | You have called your theme `mrskitson.caVersion#3`. Do you know what a hash symbol (`#`) does in a URL? So, browsers are trying to load the script here:
`http://update.mrskitson.ca/wp-content/themes/mrskitson.caVersion`
And then jump down to an element with ID matching everything after the #.
Change the name of the ... |
82,101 | <p>I don't want to have the parent menu items of my site's nav menus linking to a separate page. For one thing I don't want to have a superfluous page. For another these links hobble site navigation for mobile users who can't "hover" over a link (to bring up the child items).</p>
<p>The best solution would be to disab... | [
{
"answer_id": 82103,
"author": "JCL1178",
"author_id": 6146,
"author_profile": "https://wordpress.stackexchange.com/users/6146",
"pm_score": 0,
"selected": false,
"text": "<p>I would simply create custom menu items with a javascript:void(0) as the href whenever a parent item is needed. ... | 2013/01/18 | [
"https://wordpress.stackexchange.com/questions/82101",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23086/"
] | I don't want to have the parent menu items of my site's nav menus linking to a separate page. For one thing I don't want to have a superfluous page. For another these links hobble site navigation for mobile users who can't "hover" over a link (to bring up the child items).
The best solution would be to disable the par... | Do not create fake URLs (`#`). This would be very bad for users with a screen reader: the are using a list of available links to browse your site. The same is true for `javascript:` links, they are not exactly elegant markup anyway.
You need two steps:
1. Mark the items with children before the walker starts.
2. Repl... |
82,104 | <p>Supposing I have an existing table(already created in dB) that handles user-registration (a plugin) and insert data using the $wpdB->insert like this:</p>
<pre><code> $success = $wpdb->insert(
$wpdb->mytable,
array(
'first_name' => $first_name,
'last_name' =&g... | [
{
"answer_id": 82108,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 3,
"selected": true,
"text": "<p>No, the column must exist before you insert data into it. Otherwise the query will fail.</p>\n\n<p>You should edit... | 2013/01/18 | [
"https://wordpress.stackexchange.com/questions/82104",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20972/"
] | Supposing I have an existing table(already created in dB) that handles user-registration (a plugin) and insert data using the $wpdB->insert like this:
```
$success = $wpdb->insert(
$wpdb->mytable,
array(
'first_name' => $first_name,
'last_name' => $last_name,
'em... | No, the column must exist before you insert data into it. Otherwise the query will fail.
You should edit your table creation SQL query to accommodate the new column. Then, run it through `dbDelta()` again. `dbDelta()` will compare your query and the table structure and only create the missing columns.
The best way to... |
82,105 | <p>This is the code to display popular post on front end, however the problem is the data is not saving from the back end. Like i want to show only 3 popular posts on front-end so i select the option 3 but its not saving. However when i pass the static value for <code>$popularpostcount</code> then this code works <cod... | [
{
"answer_id": 82111,
"author": "Klian",
"author_id": 4984,
"author_profile": "https://wordpress.stackexchange.com/users/4984",
"pm_score": 3,
"selected": true,
"text": "<p>Replace this line in <strong>form</strong> function:</p>\n\n<pre><code>echo \"<select name='popularpostcount' id... | 2013/01/18 | [
"https://wordpress.stackexchange.com/questions/82105",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17855/"
] | This is the code to display popular post on front end, however the problem is the data is not saving from the back end. Like i want to show only 3 popular posts on front-end so i select the option 3 but its not saving. However when i pass the static value for `$popularpostcount` then this code works `echo $this->popula... | Replace this line in **form** function:
```
echo "<select name='popularpostcount' id='popularpostcount'>";
```
with:
```
echo "<select name='".$this->get_field_name('popularpostcount')."' id='".$this->get_field_name('popularpostcount')."'>";
``` |
82,114 | <p>I have created a wordpress widget. It has a drop down in widget options. The dropdown contains "facebook" and "twitter". If admin selects "twitter", then twitter follower count is displayed inside the widget, similar case for facebook.</p>
<p>The count is displayed inside a div with id "social-count" using jquery. ... | [
{
"answer_id": 82111,
"author": "Klian",
"author_id": 4984,
"author_profile": "https://wordpress.stackexchange.com/users/4984",
"pm_score": 3,
"selected": true,
"text": "<p>Replace this line in <strong>form</strong> function:</p>\n\n<pre><code>echo \"<select name='popularpostcount' id... | 2013/01/18 | [
"https://wordpress.stackexchange.com/questions/82114",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11628/"
] | I have created a wordpress widget. It has a drop down in widget options. The dropdown contains "facebook" and "twitter". If admin selects "twitter", then twitter follower count is displayed inside the widget, similar case for facebook.
The count is displayed inside a div with id "social-count" using jquery. When page ... | Replace this line in **form** function:
```
echo "<select name='popularpostcount' id='popularpostcount'>";
```
with:
```
echo "<select name='".$this->get_field_name('popularpostcount')."' id='".$this->get_field_name('popularpostcount')."'>";
``` |
82,152 | <p>The login form on the page wp-login.php has a link at the bottom that says "Back to <em>website-name</em>"
This link always redirects to the home page I would like it to redirect to the page the user has come from.</p>
<p>I imagine this requires a hook added to functions.php but I'm not sure how and could not find ... | [
{
"answer_id": 82157,
"author": "Ahmad M",
"author_id": 12961,
"author_profile": "https://wordpress.stackexchange.com/users/12961",
"pm_score": 3,
"selected": true,
"text": "<p>You can achieve that using Javascript and <code>login_footer</code> action hook to change the <code>href</code>... | 2013/01/18 | [
"https://wordpress.stackexchange.com/questions/82152",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22502/"
] | The login form on the page wp-login.php has a link at the bottom that says "Back to *website-name*"
This link always redirects to the home page I would like it to redirect to the page the user has come from.
I imagine this requires a hook added to functions.php but I'm not sure how and could not find anything while se... | You can achieve that using Javascript and `login_footer` action hook to change the `href` attribute of the `Back to` link:
```
<?php
add_action('login_footer', 'ad_login_footer');
function ad_login_footer() {
$ref = wp_get_referer();
if ($ref) :
?>
<script type="text/javascript">
jQuery(document).ready(f... |
82,168 | <p>I want to be able to render post in two different styles (2 templates).</p>
<p>For example, let's say I have the post ID 133, I would like two URLS to access it and so it renders where different template would apply.</p>
<ul>
<li>lorem.com/render1/133</li>
<li>lorem.com/render2/1333</li>
</ul>
<p>for example... o... | [
{
"answer_id": 82157,
"author": "Ahmad M",
"author_id": 12961,
"author_profile": "https://wordpress.stackexchange.com/users/12961",
"pm_score": 3,
"selected": true,
"text": "<p>You can achieve that using Javascript and <code>login_footer</code> action hook to change the <code>href</code>... | 2013/01/18 | [
"https://wordpress.stackexchange.com/questions/82168",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10464/"
] | I want to be able to render post in two different styles (2 templates).
For example, let's say I have the post ID 133, I would like two URLS to access it and so it renders where different template would apply.
* lorem.com/render1/133
* lorem.com/render2/1333
for example... or it could be something like:
* lorem.com... | You can achieve that using Javascript and `login_footer` action hook to change the `href` attribute of the `Back to` link:
```
<?php
add_action('login_footer', 'ad_login_footer');
function ad_login_footer() {
$ref = wp_get_referer();
if ($ref) :
?>
<script type="text/javascript">
jQuery(document).ready(f... |
82,169 | <p>Hoping someone can point me in the direction of writing this in a more succinct way.</p>
<p>I'm working on my website, and want to display a total of 5 posts from the category 'general wonderings'.</p>
<p>The first post has different styling from the other 4. Please see code below,</p>
<p>Now, 2 problems... they ... | [
{
"answer_id": 82174,
"author": "Prasanna SP",
"author_id": 24975,
"author_profile": "https://wordpress.stackexchange.com/users/24975",
"pm_score": 2,
"selected": false,
"text": "<p>Use <code>offset=1</code> to exclude first post.</p>\n\n<pre><code>$args = array( 'category_name' => 'G... | 2013/01/18 | [
"https://wordpress.stackexchange.com/questions/82169",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13998/"
] | Hoping someone can point me in the direction of writing this in a more succinct way.
I'm working on my website, and want to display a total of 5 posts from the category 'general wonderings'.
The first post has different styling from the other 4. Please see code below,
Now, 2 problems... they way I've written it mean... | Use `offset=1` to exclude first post.
```
$args = array( 'category_name' => 'General Wonderings', 'posts_per_page' => 4, 'offset' => 1 );
``` |
82,194 | <p>I want to add a variable in the Menu, for passing a value in all my page.
The purpose is to retrieve a value for transport to another web site (from my website links) to the tracking, this value depends on the origin of the user.</p>
<p>eg of my menu :</p>
<pre><code>- Home = mylink/?partenaire=<?php
echo $myPa... | [
{
"answer_id": 82201,
"author": "helgatheviking",
"author_id": 6477,
"author_profile": "https://wordpress.stackexchange.com/users/6477",
"pm_score": 0,
"selected": false,
"text": "<p>See this answer on creating a custom menu Walker\n<a href=\"https://wordpress.stackexchange.com/a/14039/6... | 2013/01/18 | [
"https://wordpress.stackexchange.com/questions/82194",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26215/"
] | I want to add a variable in the Menu, for passing a value in all my page.
The purpose is to retrieve a value for transport to another web site (from my website links) to the tracking, this value depends on the origin of the user.
eg of my menu :
```
- Home = mylink/?partenaire=<?php
echo $myPartenaire;
?>
- About us... | You should never need a plugin to insert raw PHP code somewhere. There are always side effects you cannot see or fix easily.
Filter `wp_nav_menu_objects` instead, and add the parameter here to the URLs.
```
if ( ! empty ( $_GET['partenaire'] ) )
add_filter( 'wp_nav_menu_objects', 'wpse_82194_add_param' );
/**
... |
82,203 | <p>Is there a fast way to retrieve a specific post by a unique meta value? I could run a meta_query and then loop through the first value to get the post's ID, but I am wondering if there is any other that I am overlooking.</p>
<p>Is it possible to add a column to the wp_posts table? Or is there some other way to ad... | [
{
"answer_id": 87253,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<pre><code>function get_post_by_meta_value( $meta_key, $meta_value ) {\n $post_where = function ($where) use ( $meta... | 2013/01/18 | [
"https://wordpress.stackexchange.com/questions/82203",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6477/"
] | Is there a fast way to retrieve a specific post by a unique meta value? I could run a meta\_query and then loop through the first value to get the post's ID, but I am wondering if there is any other that I am overlooking.
Is it possible to add a column to the wp\_posts table? Or is there some other way to add a second... | I am just incredible stupid here as this can be easily done by a simple WP\_Query:
```
new WP_Query( array( 'post_type' => 'shop_order', 'meta_key' => $meta_key, 'meta_value' => $meta_value ) )
```
However, I decided to compare the actual generated SQL of the get\_posts() with a 'post\_where' filter solution which... |
82,207 | <p>We are using wordpress plugin contact form 7 and want to specify the width of the subject field (assume answer would apply to setting width of any field) and relocate the Your Email next to the Your Name field. Result would be Email and Name on one line, Subject full width underneath, Your Message underneath Subject... | [
{
"answer_id": 82267,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 1,
"selected": false,
"text": "<p>I din't try it, but have a try yourself:</p>\n\n<p>Contact Form 7 uses something like this:</p>\n\n<pre... | 2013/01/18 | [
"https://wordpress.stackexchange.com/questions/82207",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26221/"
] | We are using wordpress plugin contact form 7 and want to specify the width of the subject field (assume answer would apply to setting width of any field) and relocate the Your Email next to the Your Name field. Result would be Email and Name on one line, Subject full width underneath, Your Message underneath Subject.
T... | I din't try it, but have a try yourself:
Contact Form 7 uses something like this:
```
<p>Your Name (required)<br />
[text* your-name] </p>
```
Instead of using paragraph tag (`<p>`) use span (`<span>`), and some inline CSS, like:
```
<span style="width: 48%; float: left; position: relative;">Your Name (require... |
82,208 | <p>How do I get a post's ID? I know I can use the_ID(), but I have to use it in The Loop. How can I get the post's ID without the loop? Because I think using the loop just to find the post's ID will slow down my script. Maybe i'm wrong. Please help me :)</p>
<p>Thank you!</p>
| [
{
"answer_id": 82210,
"author": "Mateusz Hajdziony",
"author_id": 15865,
"author_profile": "https://wordpress.stackexchange.com/users/15865",
"pm_score": 0,
"selected": false,
"text": "<p>If you already have the post object saved as a variable somewhere (I assume that this is the case) y... | 2013/01/18 | [
"https://wordpress.stackexchange.com/questions/82208",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | How do I get a post's ID? I know I can use the\_ID(), but I have to use it in The Loop. How can I get the post's ID without the loop? Because I think using the loop just to find the post's ID will slow down my script. Maybe i'm wrong. Please help me :)
Thank you! | If you're on a singular page, sometime after `init` and all the query variables have all ben set up you can use `get_queried_object_id` or `get_queried_object`.
```
<?php
if (is_singular()) {
$post_id = get_queried_object_id();
// or get the whole object
$post = get_queried_object();
// or do the fir... |
82,211 | <p>I want to build an alert for users who visit my WordPress blog. Is there a conditional function like <code>is_home()</code> to detect if someone visits the blog the <strong>first time</strong>? I want to send the alert to every new user no matter on which site he entered.</p>
| [
{
"answer_id": 82215,
"author": "chrisguitarguy",
"author_id": 6035,
"author_profile": "https://wordpress.stackexchange.com/users/6035",
"pm_score": 4,
"selected": true,
"text": "<p>No, there's nothing in the core like that.</p>\n\n<p>You can set a cookie and do it simply enough (warning... | 2013/01/18 | [
"https://wordpress.stackexchange.com/questions/82211",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26222/"
] | I want to build an alert for users who visit my WordPress blog. Is there a conditional function like `is_home()` to detect if someone visits the blog the **first time**? I want to send the alert to every new user no matter on which site he entered. | No, there's nothing in the core like that.
You can set a cookie and do it simply enough (warning: untested code follows).
```
<?php
function is_first_time()
{
if (isset($_COOKIE['_wp_first_time']) || is_user_logged_in()) {
return false;
}
$domain = COOKIE_DOMAIN ? COOKIE_DOMAIN : $_SERVER['HTTP_H... |
82,217 | <p>The actual post type support categories and I want to add also support for tags. </p>
<p>I have this code: </p>
<pre><code>register_taxonomy(
'category_' . $slug,
array( $slug ),
array(
'hierarchical' => true,
'label' => "$slug Categories",
'singular_label' => "$slug C... | [
{
"answer_id": 82231,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": true,
"text": "<p>The categories your code creates is a custom taxonomy, not the default post <code>category</code> taxonomy.</p>\n\n<... | 2013/01/18 | [
"https://wordpress.stackexchange.com/questions/82217",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12572/"
] | The actual post type support categories and I want to add also support for tags.
I have this code:
```
register_taxonomy(
'category_' . $slug,
array( $slug ),
array(
'hierarchical' => true,
'label' => "$slug Categories",
'singular_label' => "$slug Category",
'rewrite' =>... | The categories your code creates is a custom taxonomy, not the default post `category` taxonomy.
Anyway, if you want to add support for the default post tags taxonomy, the name is `post_tag` and can be added via the `taxonomies` argument in your `$portfolio_args`:
```
$portfolio_args = array(
'taxonomies' => arra... |
82,225 | <p>I am running a backup of my website on Ubuntu 12.10 (apache+mysql). I can see properly admin and home page, but permalinks are not working (so urls like this are failing: localhost/page/.../).</p>
<p>What I did till now is:</p>
<p>1) Created file .htaccess via settings->permalinks with the content:</p>
<pre><cod... | [
{
"answer_id": 82231,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": true,
"text": "<p>The categories your code creates is a custom taxonomy, not the default post <code>category</code> taxonomy.</p>\n\n<... | 2013/01/18 | [
"https://wordpress.stackexchange.com/questions/82225",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25529/"
] | I am running a backup of my website on Ubuntu 12.10 (apache+mysql). I can see properly admin and home page, but permalinks are not working (so urls like this are failing: localhost/page/.../).
What I did till now is:
1) Created file .htaccess via settings->permalinks with the content:
```
# BEGIN WordPress
<IfModule... | The categories your code creates is a custom taxonomy, not the default post `category` taxonomy.
Anyway, if you want to add support for the default post tags taxonomy, the name is `post_tag` and can be added via the `taxonomies` argument in your `$portfolio_args`:
```
$portfolio_args = array(
'taxonomies' => arra... |
82,228 | <p><a href="http://codex.wordpress.org/CSS#WordPress_Generated_Classes" rel="nofollow">On WordPress Codex</a> there are these CSS styles listed. It's a quite big list of styles, but it seems they are doubled unnecessary.</p>
<p>It says:</p>
<blockquote>
<p>Each Theme should have these or similar styles in its style... | [
{
"answer_id": 82233,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>The <code>align*</code> and <code>caption</code> classes are generated by WordPress in shortcodes and image functions.... | 2013/01/18 | [
"https://wordpress.stackexchange.com/questions/82228",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25537/"
] | [On WordPress Codex](http://codex.wordpress.org/CSS#WordPress_Generated_Classes) there are these CSS styles listed. It's a quite big list of styles, but it seems they are doubled unnecessary.
It says:
>
> Each Theme should have these or similar styles in its style.css file
> to be able to display images and caption... | The most definitive and up to date answer about best practice can come probably only from the wordpress.org theme review team, and right now [they](http://codex.wordpress.org/Theme_Review#WordPress-Generated_CSS_Classes) are different from the codex. just quoting it here, but I'm sure it might change with time
>
> Th... |
82,239 | <p>Right now you can make your Display Name whatever you want, you can even impersonate an admin. Is it possible to make the Display Name unique?</p>
| [
{
"answer_id": 82252,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": false,
"text": "<p>As far as I'm aware, all you can do is filter the display name via <code>pre_user_display_name</code> and check if ... | 2013/01/18 | [
"https://wordpress.stackexchange.com/questions/82239",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4284/"
] | Right now you can make your Display Name whatever you want, you can even impersonate an admin. Is it possible to make the Display Name unique? | As far as I'm aware, all you can do is filter the display name via `pre_user_display_name` and check if it already exists. Unfortunately `WP_User_Query` doesn't support querying by `display_name`, so we also have to add to the `WHERE` clause via `pre_user_query`. Additionally, there is no elegant way I can think of to ... |
82,274 | <p>I have a reasonably fresh WordPress install on my Ubuntu Linux server and I uploaded an image to it for use in a blog post. I checked the path in WordPress settings and I checked the contents on the server:</p>
<pre><code>$ ls -l /srv/www/wp-uploads/blog.linformatronics.nl/2013/01
total 320
-rw-rw-r-- 1 www-data ww... | [
{
"answer_id": 82320,
"author": "Vincent P",
"author_id": 26136,
"author_profile": "https://wordpress.stackexchange.com/users/26136",
"pm_score": 1,
"selected": false,
"text": "<p>I think the problem is that you are storing your images in <code>/srv/www/wp-uploads/blog.linformatronics.nl... | 2013/01/19 | [
"https://wordpress.stackexchange.com/questions/82274",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24038/"
] | I have a reasonably fresh WordPress install on my Ubuntu Linux server and I uploaded an image to it for use in a blog post. I checked the path in WordPress settings and I checked the contents on the server:
```
$ ls -l /srv/www/wp-uploads/blog.linformatronics.nl/2013/01
total 320
-rw-rw-r-- 1 www-data www-data 22033 J... | I think the problem is that you are storing your images in `/srv/www/wp-uploads/blog.linformatronics.nl/2013/01` but your link to the image is <https://blog.linformatronics.nl/wp-uploads/2013/01/ccs5licence1.png>.
What you need to do is tell wordpress to store the images in `/srv/www/blog.linformatronics.nl/wp-uploads... |
82,297 | <p>I want to use Myanmar Unicode text on my blog. Unfortunatly, pseudo-Unicode Myanmar fonts are common. So, I am writing a plugin that will suround all Myanmar phrases with HTML span tags, and use css to select the proper font.</p>
<p>Everything works fine for content, comments, etc. However, after adding HTML using ... | [
{
"answer_id": 82298,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>You can convert them back simply using <a href=\"http://php.net/manual/de/function.htmlspecialchars.php\" rel=\"nof... | 2013/01/19 | [
"https://wordpress.stackexchange.com/questions/82297",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26243/"
] | I want to use Myanmar Unicode text on my blog. Unfortunatly, pseudo-Unicode Myanmar fonts are common. So, I am writing a plugin that will suround all Myanmar phrases with HTML span tags, and use css to select the proper font.
Everything works fine for content, comments, etc. However, after adding HTML using the the\_t... | Ok, I thought I'd post my final solution up here in case anyone else has the same problem. Basically, I have to add new hooks to my theme files, and then send the modified post title to those hooks.
My plugin code now looks like:
```
add_filter( 'the_html_safe_title', 'addThemSpansToPostTitles' );
function addThemSpa... |
82,312 | <p>I'm trying to make my widget titles two-colored; the first word white and the second one yellow. I have no idea how I can insert a span before the second word of every widget title so that I can put a color to the span.</p>
| [
{
"answer_id": 82314,
"author": "Nabil Kadimi",
"author_id": 17187,
"author_profile": "https://wordpress.stackexchange.com/users/17187",
"pm_score": 4,
"selected": true,
"text": "<pre class=\"lang-php prettyprint-override\"><code>/**\n * Wraps the first half of the provided string inside... | 2013/01/19 | [
"https://wordpress.stackexchange.com/questions/82312",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5776/"
] | I'm trying to make my widget titles two-colored; the first word white and the second one yellow. I have no idea how I can insert a span before the second word of every widget title so that I can put a color to the span. | ```php
/**
* Wraps the first half of the provided string inside a span with the class lol_class.
*
* @param string $title The string.
* @return string The modified string.
*/
function wpsa_82312_widget_title($title) {
// Cut the title into two halves.
$halves = explode(' ', $title, 2);
// ... |
82,329 | <p>I am looking for a guide or tool for inserting <a href="http://twitter.github.com/bootstrap/" rel="nofollow">bootstrap</a> in to <a href="https://github.com/automattic/_s" rel="nofollow">underscores</a> theme.
Booststrap is a CSS framework and Underscores theme is starter theme with ultra-minimal CSS.</p>
| [
{
"answer_id": 82314,
"author": "Nabil Kadimi",
"author_id": 17187,
"author_profile": "https://wordpress.stackexchange.com/users/17187",
"pm_score": 4,
"selected": true,
"text": "<pre class=\"lang-php prettyprint-override\"><code>/**\n * Wraps the first half of the provided string inside... | 2013/01/19 | [
"https://wordpress.stackexchange.com/questions/82329",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1372/"
] | I am looking for a guide or tool for inserting [bootstrap](http://twitter.github.com/bootstrap/) in to [underscores](https://github.com/automattic/_s) theme.
Booststrap is a CSS framework and Underscores theme is starter theme with ultra-minimal CSS. | ```php
/**
* Wraps the first half of the provided string inside a span with the class lol_class.
*
* @param string $title The string.
* @return string The modified string.
*/
function wpsa_82312_widget_title($title) {
// Cut the title into two halves.
$halves = explode(' ', $title, 2);
// ... |
82,332 | <p>I need to display on some specific pages some selected user meta data (not all), for some users.</p>
<p>On the <a href="http://codex.wordpress.org/Function_Reference/get_user_meta#Getting_all_meta_data" rel="nofollow">Wordpress Codex</a> page for the <code>get_user_meta()</code> function we have this example (user_... | [
{
"answer_id": 82335,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 3,
"selected": true,
"text": "<p>Here is the simplest shortcode that will do the job for you </p>\n\n<pre><code>add_shortcode('USER_META', 'use... | 2013/01/20 | [
"https://wordpress.stackexchange.com/questions/82332",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25187/"
] | I need to display on some specific pages some selected user meta data (not all), for some users.
On the [Wordpress Codex](http://codex.wordpress.org/Function_Reference/get_user_meta#Getting_all_meta_data) page for the `get_user_meta()` function we have this example (user\_id = 9):
```
<?php
$all_meta_for_user = get... | Here is the simplest shortcode that will do the job for you
```
add_shortcode('USER_META', 'user_meta_shortcode_handler');
/**
* User Meta Shortcode handler
* usage: [USER_META user_id=1 meta="first_name"]
* @param array $atts
* @param string $content
* @return stirng
*/
function user_meta_shortcode_handle... |
82,362 | <p>I recently tried to reorder the dashboard widgets by writing a plugin. I accomplished this:</p>
<p><a href="http://www.dumpt.com/img/viewer.php?file=zpu00nve8u2m7t89sy6m.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kQS5f.png" alt="enter image description here"></a></p>
<p>with the following c... | [
{
"answer_id": 82386,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<h2>Clearing things up</h2>\n\n<p>First, there's a slight misunderstanding. <code>wp_dashboard_setup</code> is an <em>... | 2013/01/20 | [
"https://wordpress.stackexchange.com/questions/82362",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26264/"
] | I recently tried to reorder the dashboard widgets by writing a plugin. I accomplished this:
[](http://www.dumpt.com/img/viewer.php?file=zpu00nve8u2m7t89sy6m.png)
with the following code:
```
<?php
/*
* Plugin Name: Custom Dashboard
* Description: ... | Whoop, I figured it out. :) Although I figured it out before **kaiser** answered my question, I would still like to thank him for is clear and awesome answer. Below you'll find the code I wrote to reorder the dashboard widgets.
```
<?php
/**
* Plugin Name: Custom Dashboard
* Description: Custom dashboard for Avare s... |
82,366 | <p>I have pages which are nested in 3 levels, i.e:</p>
<pre>www.example.com/cinema-in-our-country/our-festivals/first-festival-with-very-long-name</pre>
<p>As you can see the permalink gets quite long. If I go to the TinyMCE editor, write festival name and try to add a link on it to direct to that festival page, I ge... | [
{
"answer_id": 82367,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 0,
"selected": false,
"text": "<p>The dots aren't part of the link - they just mean that the link it too long to fit in the space, and so part of t... | 2013/01/20 | [
"https://wordpress.stackexchange.com/questions/82366",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26266/"
] | I have pages which are nested in 3 levels, i.e:
```
www.example.com/cinema-in-our-country/our-festivals/first-festival-with-very-long-name
```
As you can see the permalink gets quite long. If I go to the TinyMCE editor, write festival name and try to add a link on it to direct to that festival page, I get such genera... | Turn off all plugins, switch to TwentyTen [or - even better - this theme](https://github.com/toscho/Toscho-s-Mini-Theme). Then add another post with an ridiculously long title
```
Lopadotemachoselachogaleokranioleipsanodrimhypotrimmatosilphioparaomelitokatakechymenokichlepikossyphophattoperisteralek... |
82,372 | <p>Below there's the Wordpress code found in post-template.php for the wp_link_pages() function - this function generates a page navigation for posts or pages having the content split into multiple pages. </p>
<pre><code>function wp_link_pages($args = '') {
$defaults = array(
'before' => '<p>' . _... | [
{
"answer_id": 82375,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": true,
"text": "<p>There was a <a href=\"http://core.trac.wordpress.org/ticket/13578\" rel=\"nofollow\">trac ticket</a> requesting impro... | 2013/01/20 | [
"https://wordpress.stackexchange.com/questions/82372",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8421/"
] | Below there's the Wordpress code found in post-template.php for the wp\_link\_pages() function - this function generates a page navigation for posts or pages having the content split into multiple pages.
```
function wp_link_pages($args = '') {
$defaults = array(
'before' => '<p>' . __('Pages:'), 'after' ... | There was a [trac ticket](http://core.trac.wordpress.org/ticket/13578) requesting improvements to the function since it was inflexible, yet required for themes hosted in official repository. It had been resolved, adding much needed `wp_link_pages` and `wp_link_pages_link` filters, so now output can be cleanly modified ... |
82,379 | <p>Is there a filter hook which changes the number of available columns in gallery settings screen. I'm talking about the :</p>
<pre><code><label class="setting">
<span><?php _e('Columns'); ?></span>
<select class="columns" name="columns"
data-setting="columns">
&l... | [
{
"answer_id": 82381,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": true,
"text": "<h2>Short answer</h2>\n\n<p>Simple as things sometimes are: No this is not possible. The whole part is hard coded. </p>... | 2013/01/20 | [
"https://wordpress.stackexchange.com/questions/82379",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26270/"
] | Is there a filter hook which changes the number of available columns in gallery settings screen. I'm talking about the :
```
<label class="setting">
<span><?php _e('Columns'); ?></span>
<select class="columns" name="columns"
data-setting="columns">
<?php for ( $i = 1; $i <= 9; $i++ ) : ?>
... | Short answer
------------
Simple as things sometimes are: No this is not possible. The whole part is hard coded.
Long answer (not recommended to do so)
--------------------------------------
You could maybe jump into the `esc_html` and `attribute_escape` filters and just return empty there \*), but as those are pre... |
82,382 | <p>I'm using this great [tuts+ tutorial][1] for creating theme options page. It works great for me be beause I need to change background images of divs via css. It works great with one image but I dont know how to make it work with 2 images?</p>
<p>It would be a huge help if you can tell me what I'm doing wrong here?
... | [
{
"answer_id": 82389,
"author": "Jen",
"author_id": 17704,
"author_profile": "https://wordpress.stackexchange.com/users/17704",
"pm_score": 1,
"selected": true,
"text": "<p>I can't comment on your code, but you might find this link useful:</p>\n\n<p>Options Framework Theme:\n<a href=\"ht... | 2013/01/20 | [
"https://wordpress.stackexchange.com/questions/82382",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26273/"
] | I'm using this great [tuts+ tutorial][1] for creating theme options page. It works great for me be beause I need to change background images of divs via css. It works great with one image but I dont know how to make it work with 2 images?
It would be a huge help if you can tell me what I'm doing wrong here?
Thanks!
`... | I can't comment on your code, but you might find this link useful:
Options Framework Theme:
<http://wptheming.com/options-framework-theme/>
This is something you have to edit carefully, but it has pretty much every type of control you can think of in there. It also had the only working MCE Editor that I could find. I... |
82,399 | <p>I have several posts in an Microsoft Excel file (.csv/.xls). I want to know the appropriate format of the file to import into Wordpress.com. </p>
<p>Note: I do not need help to convert the csv format into xml. I just need to know the required format for feeding into Wordpress. Same approach should work for .org hos... | [
{
"answer_id": 82402,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": false,
"text": "<p>If you just need a known-good example of a WordPress XML import file, <a href=\"https://wpcom-themes.svn.au... | 2013/01/20 | [
"https://wordpress.stackexchange.com/questions/82399",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26280/"
] | I have several posts in an Microsoft Excel file (.csv/.xls). I want to know the appropriate format of the file to import into Wordpress.com.
Note: I do not need help to convert the csv format into xml. I just need to know the required format for feeding into Wordpress. Same approach should work for .org hosted blogs.... | Here is an import file where only a few settings are used (although you may be able to exclude even more), which successfully imports three posts (tested on WP 4.2.2):
```
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0"
xmlns:excerpt="http://wordpress.org/export/1.2/excerpt/"
xmlns:content="http://p... |
82,404 | <p>With the below two functions I can add a textarea custom user meta field named 'publications' to the user profile and save/update it:</p>
<pre><code>add_action( 'show_user_profile', 'extra_user_profile_fields' );
add_action( 'edit_user_profile', 'extra_user_profile_fields' );
function extra_user_profile_fields( $u... | [
{
"answer_id": 82405,
"author": "Muhammad Furqan",
"author_id": 25586,
"author_profile": "https://wordpress.stackexchange.com/users/25586",
"pm_score": 1,
"selected": false,
"text": "<p>Have a look at both functions <a href=\"http://codex.wordpress.org/Function_Reference/esc_attr\" rel=\... | 2013/01/20 | [
"https://wordpress.stackexchange.com/questions/82404",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25187/"
] | With the below two functions I can add a textarea custom user meta field named 'publications' to the user profile and save/update it:
```
add_action( 'show_user_profile', 'extra_user_profile_fields' );
add_action( 'edit_user_profile', 'extra_user_profile_fields' );
function extra_user_profile_fields( $user ) { ?>
<... | Finally I adopted this the second solution:
```
/* Display the selected user meta data with a shortcode */
add_shortcode('user_meta', 'user_meta_shortcode_handler');
/* usage: [user_meta user_id=1] */
function user_meta_shortcode_handler($atts,$content=null){ ?>
<?php
echo '<h3>Publications</h3>';
echo wpaut... |
82,407 | <p>I am very new to WordPress. I am trying to display a login form in the header section of my website. However, when I look at all of the files in my directory it is very overwhelming and I am afraid to touch anything.</p>
<p>Does anyone know of any good tutorials on the topic or perhaps shed some light on the issue... | [
{
"answer_id": 82410,
"author": "onetrickpony",
"author_id": 1986,
"author_profile": "https://wordpress.stackexchange.com/users/1986",
"pm_score": 3,
"selected": false,
"text": "<ol>\n<li><p>Create a template file within your child theme directory, let's say <code>login.php</code>. Put t... | 2013/01/20 | [
"https://wordpress.stackexchange.com/questions/82407",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26255/"
] | I am very new to WordPress. I am trying to display a login form in the header section of my website. However, when I look at all of the files in my directory it is very overwhelming and I am afraid to touch anything.
Does anyone know of any good tutorials on the topic or perhaps shed some light on the issue? | The login form is a simple html form sending username and password to wp-login.php. This is the simplest way to create a custom login form:
```
<?php
$redirect_to = '';
?>
<form name="loginform" id="loginform" action="<?php echo site_url( '/wp-login.php' ); ?>" method="post">
<p>Username: <input id="user_login" type="... |
82,424 | <p>In my Wordpress theme that I've currently been building I do not take advantage of the Wordpress Theme Customization API. As much as I would like too, I've invested far too much time into my own personal theme options framework for changing things.</p>
<p>This leads me to my question. How do I remove the blue, "Cus... | [
{
"answer_id": 82435,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 0,
"selected": false,
"text": "<p>There are <a href=\"http://core.trac.wordpress.org/browser/tags/3.5/wp-admin/includes/dashboard.php#L1257\" ... | 2013/01/21 | [
"https://wordpress.stackexchange.com/questions/82424",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1687/"
] | In my Wordpress theme that I've currently been building I do not take advantage of the Wordpress Theme Customization API. As much as I would like too, I've invested far too much time into my own personal theme options framework for changing things.
This leads me to my question. How do I remove the blue, "Customize You... | With the lastest version of WordPress (4.3) you can now natively remove the customizer's theme switch setting without resorting to CSS hacks.
```
/**
* Remove customizer options.
*
* @since 1.0.0
* @param object $wp_customize
*/
function ja_remove_customizer_options( $wp_customize ) {
//$wp_customize->remove_s... |
82,458 | <p>i have one WordPress blog/site and want to point/map more than one domain name hosted/parked on my server.</p>
<p>How do i do that <strong>*<em>without</strong> redirecting by .htaccess?</em>*</p>
<p>Edit</p>
<p>Im configure the related setting in cpanel or plesk in parked domain but wordpress dont recognized the... | [
{
"answer_id": 82472,
"author": "Oleg Butuzov",
"author_id": 14536,
"author_profile": "https://wordpress.stackexchange.com/users/14536",
"pm_score": 3,
"selected": true,
"text": "<p>You can use a predefined constants that points to site URL.</p>\n\n<p>(from <a href=\"http://codex.wordpre... | 2013/01/21 | [
"https://wordpress.stackexchange.com/questions/82458",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23025/"
] | i have one WordPress blog/site and want to point/map more than one domain name hosted/parked on my server.
How do i do that **\**without*** redirecting by .htaccess?\*
Edit
Im configure the related setting in cpanel or plesk in parked domain but wordpress dont recognized them. I want to know why cant i confure thet ... | You can use a predefined constants that points to site URL.
(from [Codex](http://codex.wordpress.org/Editing_wp-config.php#WordPress_address_.28URL.29))
```
define('WP_SITEURL', 'http://example.com/wordpress');
define('WP_HOME', 'http://example.com/wordpress');
```
Small example
```
define('WP_SITEURL', 'http:... |
82,467 | <p>I have been googling around but could not find the "add tag to post" api/codex. Does anyone know what it is ? Also, the "delete tag from post".</p>
<p>Thanks.</p>
| [
{
"answer_id": 82468,
"author": "Manny Fleurmond",
"author_id": 2234,
"author_profile": "https://wordpress.stackexchange.com/users/2234",
"pm_score": 3,
"selected": false,
"text": "<p>You would use the <a href=\"http://codex.wordpress.org/Function_Reference/wp_insert_term\" rel=\"nofollo... | 2013/01/21 | [
"https://wordpress.stackexchange.com/questions/82467",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24656/"
] | I have been googling around but could not find the "add tag to post" api/codex. Does anyone know what it is ? Also, the "delete tag from post".
Thanks. | You'll find an index of a good chunk of the WordPress API [here on codex](http://codex.wordpress.org/Function_Reference). The function you want is [wp\_set\_post\_tags()](http://codex.wordpress.org/Function_Reference/wp_set_post_tags), but follow the links from that page to related functions.
Edit: this should remove ... |
82,473 | <h2>Update</h2>
<p>I got it to fire using the following curl command:
<code>curl -H "Accept: application/json" -X POST http://localhost/wordpress/wp-admin/admin-ajax.php -d "action=vixo_wordpress_signon&data=banjometer" --trace -</code></p>
<p>Not really sure how to work out to get it to accept json, but hey...</... | [
{
"answer_id": 82482,
"author": "helgatheviking",
"author_id": 6477,
"author_profile": "https://wordpress.stackexchange.com/users/6477",
"pm_score": 1,
"selected": false,
"text": "<p>I don't know anything about CURL, but looking at admin-ajax.php you get a 0 either at the beginning becau... | 2013/01/21 | [
"https://wordpress.stackexchange.com/questions/82473",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26297/"
] | Update
------
I got it to fire using the following curl command:
`curl -H "Accept: application/json" -X POST http://localhost/wordpress/wp-admin/admin-ajax.php -d "action=vixo_wordpress_signon&data=banjometer" --trace -`
Not really sure how to work out to get it to accept json, but hey...
Original Question
---------... | You have nothing specific to do to "load" modified php code in Wordpress. All files are just loaded as is at execution time (ie when the HTTP request is processed by the server). You just have to verify that your plugin is active.
Your curl command is malformed. Use this instead :
```
curl -X POST http://localhost/wo... |
82,474 | <p>I created a child theme <strong>"my-theme"</strong> . In style.css I wrote nothing just the mandatory details I wrote there.</p>
<pre><code>/*
Theme Name: my-theme
Theme URI: http://example.com/
Description: Child theme for the Twenty Twelve theme
Author: Bhuvnesh
Author URI: http://example... | [
{
"answer_id": 82475,
"author": "Mike Madern",
"author_id": 24806,
"author_profile": "https://wordpress.stackexchange.com/users/24806",
"pm_score": 0,
"selected": false,
"text": "<p>In the <code>style.css</code> file of your child theme, you have a line <code>Template: my-theme</code>. T... | 2013/01/21 | [
"https://wordpress.stackexchange.com/questions/82474",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26188/"
] | I created a child theme **"my-theme"** . In style.css I wrote nothing just the mandatory details I wrote there.
```
/*
Theme Name: my-theme
Theme URI: http://example.com/
Description: Child theme for the Twenty Twelve theme
Author: Bhuvnesh
Author URI: http://example.com/about/
Template: ... | One does not simply throw `<link>` (CSS) or `<script>` tags into the `<head>` of a WordPress theme.
The right way to do it: Register, enqueue ... tadaa!
----------------------------------------------------
WordPress has the "Dependency API" for this task. It consists basically out of those public functions:
* [`wp_r... |
82,477 | <p>I want to add <strong>add_meta_box</strong> to specific <strong>page</strong> type like Page Template, Like Product Template.</p>
<p>I am using this article <a href="http://wp.smashingmagazine.com/2011/10/04/create-custom-post-meta-boxes-wordpress/" rel="noreferrer">http://wp.smashingmagazine.com/2011/10/04/create... | [
{
"answer_id": 82479,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 4,
"selected": true,
"text": "<p>If your custom page template filename is <code>foobar.php</code>, you can use <code>get_post_meta()</code>:<... | 2013/01/21 | [
"https://wordpress.stackexchange.com/questions/82477",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12261/"
] | I want to add **add\_meta\_box** to specific **page** type like Page Template, Like Product Template.
I am using this article <http://wp.smashingmagazine.com/2011/10/04/create-custom-post-meta-boxes-wordpress/> to try it. | If your custom page template filename is `foobar.php`, you can use `get_post_meta()`:
```
global $post;
if ( 'foobar.php' == get_post_meta( $post->ID, '_wp_page_template', true ) ) {
// The current page has the foobar template assigned
// do something
}
```
Personally, I like calling this inside my `add_meta... |
82,490 | <p>I'm having trouble understanding when you need to use <code>wp_register_script()</code>. Currently, I just use something like:</p>
<pre><code>add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
function enqueue() {
$handle = 'some-handle';
$js = 'http://example.com/my.js';
wp_register_scri... | [
{
"answer_id": 82492,
"author": "Mike Madern",
"author_id": 24806,
"author_profile": "https://wordpress.stackexchange.com/users/24806",
"pm_score": 7,
"selected": true,
"text": "<p>The <a href=\"http://codex.wordpress.org/Function_Reference/wp_register_script\"><code>wp_register_script()... | 2013/01/21 | [
"https://wordpress.stackexchange.com/questions/82490",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25472/"
] | I'm having trouble understanding when you need to use `wp_register_script()`. Currently, I just use something like:
```
add_action( 'admin_enqueue_scripts', array( $this, 'enqueue' ) );
function enqueue() {
$handle = 'some-handle';
$js = 'http://example.com/my.js';
wp_register_script( $handle, $js );
w... | The [`wp_register_script()` Codex page](http://codex.wordpress.org/Function_Reference/wp_register_script) literally says:
>
> A safe way of registering javascripts in WordPress for later use with `wp_enqueue_script()`.
>
>
>
This means, if you want to register your scripts, but not directly load them in your page... |
82,503 | <p><strong>Can't get options with $data['variable'].</strong></p>
<p><em>(I'm use SMOF - Slightly Modded Options Framework)</em></p>
<p>For example in the header.php (index.php, footer.php, etc.):</p>
<pre><code>global $data;
$logo_type = stripslashes( $data['type_logo'] );
</code></pre>
<p>and nothing happens, var... | [
{
"answer_id": 82504,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": false,
"text": "<p>This is actually a <strong>PHP</strong> question, and not a <strong>WordPress</strong> question.</p>\n\n<p>... | 2013/01/21 | [
"https://wordpress.stackexchange.com/questions/82503",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5716/"
] | **Can't get options with $data['variable'].**
*(I'm use SMOF - Slightly Modded Options Framework)*
For example in the header.php (index.php, footer.php, etc.):
```
global $data;
$logo_type = stripslashes( $data['type_logo'] );
```
and nothing happens, variable `$logo_type` contains nothing.
But if I use the same ... | This is actually a **PHP** question, and not a **WordPress** question.
The issue is that global variables don't pass through the `include()`/`require()` call from the template file into `header.php`.
The solution is to *define* `$data` after you *globalize* it.
Without knowing your options framework or your Theme sp... |
82,519 | <p>I have a menu for a website I am designing and there are parent and child elements...I was wondering if there was someway I could add an arrow to my navigation if the parent has a child element?</p>
<p>My navigation code looks like:</p>
<pre><code><div id="nav">
<ul>
<?php
wp... | [
{
"answer_id": 82968,
"author": "Rafael Marques",
"author_id": 25562,
"author_profile": "https://wordpress.stackexchange.com/users/25562",
"pm_score": 3,
"selected": true,
"text": "<h2>To add arrow for parent elements:</h2>\n<p><strong>jQuery + CSS Solution:</strong></p>\n<p>JQUERY:</p>\... | 2013/01/21 | [
"https://wordpress.stackexchange.com/questions/82519",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9820/"
] | I have a menu for a website I am designing and there are parent and child elements...I was wondering if there was someway I could add an arrow to my navigation if the parent has a child element?
My navigation code looks like:
```
<div id="nav">
<ul>
<?php
wp_list_pages("title_li=");
?>... | To add arrow for parent elements:
---------------------------------
**jQuery + CSS Solution:**
JQUERY:
```
jQuery(function($){
$(document).ready(function(){
$('ul.sub-menu').parent().addClass('drop-down'); // Add Sub-Menu Class to insert personalized style
$('li.drop-down > a:first-child').wrapInner('<span... |
82,520 | <p>I have a multisite installation running WP 3.5. My main site and a few other blogs on the network work fine. However, if I register a new user and site, that user gets the "You do not have sufficient permissions to access this page." error any time they try to visit the admin panel of the site. The front end of the ... | [
{
"answer_id": 82521,
"author": "cpilko",
"author_id": 7937,
"author_profile": "https://wordpress.stackexchange.com/users/7937",
"pm_score": 4,
"selected": true,
"text": "<p>I spent several hours of my Saturday looking for this error. I could not find a guide anywhere on the 'net that de... | 2013/01/21 | [
"https://wordpress.stackexchange.com/questions/82520",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7937/"
] | I have a multisite installation running WP 3.5. My main site and a few other blogs on the network work fine. However, if I register a new user and site, that user gets the "You do not have sufficient permissions to access this page." error any time they try to visit the admin panel of the site. The front end of the sit... | I spent several hours of my Saturday looking for this error. I could not find a guide anywhere on the 'net that described my eventual solution. Here is my solution.
In the WP core, the "You do not have sufficient permissions to access this page." error is generated at the end of `/wp-admin/includes/menu.php`. A `grep`... |
82,536 | <p>I'm creating a plugin that allows a user to use a shortcode. This shortcode depends on a bunch of javascript that needs to be present once the shortcode loads.</p>
<p>I'm having issues trying to decide when and where to load the javascript. Pieces of the code that the shortcode spits out are elements that need to b... | [
{
"answer_id": 82539,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/wp_enqueue_script\" rel=\"nofollow\"><code>wp_enqueue_sc... | 2013/01/21 | [
"https://wordpress.stackexchange.com/questions/82536",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9295/"
] | I'm creating a plugin that allows a user to use a shortcode. This shortcode depends on a bunch of javascript that needs to be present once the shortcode loads.
I'm having issues trying to decide when and where to load the javascript. Pieces of the code that the shortcode spits out are elements that need to be present,... | Use [`wp_enqueue_script`](http://codex.wordpress.org/Function_Reference/wp_enqueue_script) in your shortcode handler, in WordPress >= 3.3 it will be added to the page in the `wp_footer` action. Pass any data you need from PHP to JavaScript via [`wp_localize_script`](http://codex.wordpress.org/Function_Reference/wp_loca... |
82,542 | <p>I need to format a custom field in admin area (post edit) as a currency, eq: 12.000,00 , with user typing only the numbers, the , and . automatic. Ive searched arround, with no sucess.. Anyone? thank</p>
<p>The code i am trying to use to enqueue script in admin is</p>
<pre><code>function enqueue_admin() {
wp_... | [
{
"answer_id": 82548,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 0,
"selected": false,
"text": "<p>I think is better, that you add with a plugin a meta box for your price field. There is easy to filter and format ... | 2013/01/21 | [
"https://wordpress.stackexchange.com/questions/82542",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23576/"
] | I need to format a custom field in admin area (post edit) as a currency, eq: 12.000,00 , with user typing only the numbers, the , and . automatic. Ive searched arround, with no sucess.. Anyone? thank
The code i am trying to use to enqueue script in admin is
```
function enqueue_admin() {
wp_enqueue_script( 'jque... | if you want to process the field after submitting, php's [number\_format](http://php.net/manual/en/function.number-format.php) function is what you need:
```
$price = number_format( $number, 2, '.', ',' );
```
but if you want to change how the number is displayed as it's typed in, try [jQuery autoNumeric](http://www... |
82,552 | <p>I'm a little confused as to best practise for saving multi-select values in meta fields.</p>
<p>Assuming</p>
<pre><code><select multiple name="_casestudypost[]">
</code></pre>
<p>is my form field</p>
<p>if I store $_POST['_casestudypost'] in a meta_key of the same name? (which returns an array) - how can I... | [
{
"answer_id": 82585,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>An <code>IN</code> query is not a string comparison query. It is more like a bunch of <code>OR</code> statemen... | 2013/01/21 | [
"https://wordpress.stackexchange.com/questions/82552",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5578/"
] | I'm a little confused as to best practise for saving multi-select values in meta fields.
Assuming
```
<select multiple name="_casestudypost[]">
```
is my form field
if I store $\_POST['\_casestudypost'] in a meta\_key of the same name? (which returns an array) - how can I find out when 281 is in that array. I've t... | An `IN` query is not a string comparison query. It is more like a bunch of `OR` statements.
```
... WHERE tablename.animal IN ('cat','dog','ferret')
```
is going to be the same as
```
...WHERE tablename.animal = 'cat'
OR tablename.animal = 'dog'
OR tablename.animal = 'ferret'
```
`$_POST['_casestudyp... |
82,559 | <pre><code>function build_total_search_method( $atts ) {
$shorcode_php_function = include( dirname(__FILE__) . "/includes/total_search.php" );
return $shorcode_php_function;
}
add_shortcode( 'total_search', 'build_total_search_method' );
</code></pre>
<p>I've created a shortcode that returns an included PHP... | [
{
"answer_id": 82561,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 0,
"selected": false,
"text": "<p>you're getting the <code>1</code> from your include, meaning your include succeeded. if you want to assign the valu... | 2013/01/22 | [
"https://wordpress.stackexchange.com/questions/82559",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9295/"
] | ```
function build_total_search_method( $atts ) {
$shorcode_php_function = include( dirname(__FILE__) . "/includes/total_search.php" );
return $shorcode_php_function;
}
add_shortcode( 'total_search', 'build_total_search_method' );
```
I've created a shortcode that returns an included PHP file instead of a ... | You are returning the result of calling `include`. You want to grab the output of the included file and return than instead. Use [output](http://php.net/manual/en/function.ob-start.php) [buffering](http://php.net/manual/en/function.ob-get-clean.php) to do that.
```
function build_total_search_method( $atts ) {
ob... |
82,563 | <p>I'm doing a site in WP with dynamic and static content. I'd create the menu from the admin panel. I have 5 sections (Home, about, Boats, News(blog), contact). I'd create a custom post type with new taxonomies for the boats. What I want to do now is, display every new boat model as a sub menu of boats automatically. ... | [
{
"answer_id": 82567,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>You could achieve this with a <a href=\"http://codex.wordpress.org/Function_Reference/wp_nav_menu#Using_a_Custom_Wa... | 2013/01/22 | [
"https://wordpress.stackexchange.com/questions/82563",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26329/"
] | I'm doing a site in WP with dynamic and static content. I'd create the menu from the admin panel. I have 5 sections (Home, about, Boats, News(blog), contact). I'd create a custom post type with new taxonomies for the boats. What I want to do now is, display every new boat model as a sub menu of boats automatically. How... | You could achieve this with a [custom walker function](http://codex.wordpress.org/Function_Reference/wp_nav_menu#Using_a_Custom_Walker_Function), on your menu. a very simple example:
```
class Walker_WPA82563_Submenu extends Walker_Nav_Menu {
function end_el(&$output, $item, $depth=0, $args=array()) {
if( ... |
82,573 | <p>I've created a custom taxonomy called imagetags using the following code:</p>
<pre><code>// Register Custom Taxonomy
function custom_imagetags_taxonomy() {
$labels = array(
'name' => _x( 'Image Tags', 'Taxonomy General Name', 'text_domain' ),
'singular_name' => _x( 'Image T... | [
{
"answer_id": 82576,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": true,
"text": "<p>The issue is with the <code>post_status</code> argument of the default query generated for your taxonomy terms. If y... | 2013/01/22 | [
"https://wordpress.stackexchange.com/questions/82573",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8678/"
] | I've created a custom taxonomy called imagetags using the following code:
```
// Register Custom Taxonomy
function custom_imagetags_taxonomy() {
$labels = array(
'name' => _x( 'Image Tags', 'Taxonomy General Name', 'text_domain' ),
'singular_name' => _x( 'Image Tag', 'Taxonomy Singu... | The issue is with the `post_status` argument of the default query generated for your taxonomy terms. If you change the status via the `pre_get_posts` action to `inherit` or `any`, you can get attachments to show up.
**however**- is this the *correct* way to do this- I honestly don't know. This will show attachments to... |
82,577 | <p>I found out I was editing themes wrong, and that I should be using child themes, so I duplicated the theme I was using, and told it to inherit off of its parent. That's about the only thing I did, I was planning on going through and finding the code I didn't touch and removing those files, but I didn't get that far.... | [
{
"answer_id": 82576,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": true,
"text": "<p>The issue is with the <code>post_status</code> argument of the default query generated for your taxonomy terms. If y... | 2013/01/22 | [
"https://wordpress.stackexchange.com/questions/82577",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26356/"
] | I found out I was editing themes wrong, and that I should be using child themes, so I duplicated the theme I was using, and told it to inherit off of its parent. That's about the only thing I did, I was planning on going through and finding the code I didn't touch and removing those files, but I didn't get that far.
A... | The issue is with the `post_status` argument of the default query generated for your taxonomy terms. If you change the status via the `pre_get_posts` action to `inherit` or `any`, you can get attachments to show up.
**however**- is this the *correct* way to do this- I honestly don't know. This will show attachments to... |
82,578 | <p>I tried doing something like this:</p>
<pre><code>$user = $wpdb->get_row('
SELECT *
FROM ' . $wpdb->users . '
WHERE user_pass = "' . wp_hash_password('password') . '"'
);
</code></pre>
<p>But the <code>wp_hash_password</code> function generates a different string from the one in the database, i... | [
{
"answer_id": 82583,
"author": "PrivateUser",
"author_id": 5074,
"author_profile": "https://wordpress.stackexchange.com/users/5074",
"pm_score": 3,
"selected": false,
"text": "<h2>Password is not unique all the time.</h2>\n\n<p>According to <code>worst password</code> statistics, <code>... | 2013/01/22 | [
"https://wordpress.stackexchange.com/questions/82578",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3893/"
] | I tried doing something like this:
```
$user = $wpdb->get_row('
SELECT *
FROM ' . $wpdb->users . '
WHERE user_pass = "' . wp_hash_password('password') . '"'
);
```
But the `wp_hash_password` function generates a different string from the one in the database, is it possible?
What I'd like to do is have... | Here's what I ended up doing in case someone else need a similar functionality:
```
// Simple text password
$client_password = $_POST['client_pwd'];
$users = get_users();
// Iterate over all users and see if the password matches
foreach ($users as $user) {
// If it matches log the user in
if (wp_check_passwo... |
82,579 | <p>In front-page.php I have the following code:</p>
<pre><code><span class="amountOnline">
Online:
<?php echo $cbMain->GetInfo()['Players'] . '/' . $cbMain->GetInfo()['MaxPlayers']; ?>
</span>
</code></pre>
<p>Which is a function in functions.php that calls from <a href="https://gith... | [
{
"answer_id": 82583,
"author": "PrivateUser",
"author_id": 5074,
"author_profile": "https://wordpress.stackexchange.com/users/5074",
"pm_score": 3,
"selected": false,
"text": "<h2>Password is not unique all the time.</h2>\n\n<p>According to <code>worst password</code> statistics, <code>... | 2013/01/22 | [
"https://wordpress.stackexchange.com/questions/82579",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18311/"
] | In front-page.php I have the following code:
```
<span class="amountOnline">
Online:
<?php echo $cbMain->GetInfo()['Players'] . '/' . $cbMain->GetInfo()['MaxPlayers']; ?>
</span>
```
Which is a function in functions.php that calls from [this script](https://github.com/xPaw/PHP-Minecraft-Query/blob/master/M... | Here's what I ended up doing in case someone else need a similar functionality:
```
// Simple text password
$client_password = $_POST['client_pwd'];
$users = get_users();
// Iterate over all users and see if the password matches
foreach ($users as $user) {
// If it matches log the user in
if (wp_check_passwo... |
82,600 | <p>I've a custom/static "homepage.php" in my templates directory at my WordPress. Now I need to show differents "page excerpts" in my homepage, but I don't know what should be do it.</p>
<p>At this moment I've in my "functions.php" de following function:</p>
<pre><code>function excerpt_page() {
add_post_type_suppor... | [
{
"answer_id": 82583,
"author": "PrivateUser",
"author_id": 5074,
"author_profile": "https://wordpress.stackexchange.com/users/5074",
"pm_score": 3,
"selected": false,
"text": "<h2>Password is not unique all the time.</h2>\n\n<p>According to <code>worst password</code> statistics, <code>... | 2013/01/22 | [
"https://wordpress.stackexchange.com/questions/82600",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21121/"
] | I've a custom/static "homepage.php" in my templates directory at my WordPress. Now I need to show differents "page excerpts" in my homepage, but I don't know what should be do it.
At this moment I've in my "functions.php" de following function:
```
function excerpt_page() {
add_post_type_support( 'page', 'excerpt' ... | Here's what I ended up doing in case someone else need a similar functionality:
```
// Simple text password
$client_password = $_POST['client_pwd'];
$users = get_users();
// Iterate over all users and see if the password matches
foreach ($users as $user) {
// If it matches log the user in
if (wp_check_passwo... |
82,610 | <p>Hello am building a user generated content sharing theme</p>
<p>This is my code for video submission from front end </p>
<p>But this code only allows to add videos from a url </p>
<p>How can i allow them to upload videos and then attach it to post</p>
<p>Heres the code !</p>
<pre><code> <?php
/*
Template Na... | [
{
"answer_id": 82613,
"author": "Hasin Hayder",
"author_id": 12927,
"author_profile": "https://wordpress.stackexchange.com/users/12927",
"pm_score": -1,
"selected": false,
"text": "<p>Automattic, the people behind wordpress proveides a fantastic solution for uploading and embedding video... | 2013/01/22 | [
"https://wordpress.stackexchange.com/questions/82610",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22975/"
] | Hello am building a user generated content sharing theme
This is my code for video submission from front end
But this code only allows to add videos from a url
How can i allow them to upload videos and then attach it to post
Heres the code !
```
<?php
/*
Template Name: Submit Content video Template
*/
// if y... | You could use wp\_insert\_attachment to upload a video file into the media library and then attatch it to the newly created post.
See <http://codex.wordpress.org/Function_Reference/wp_insert_attachment>
But it would be wise to have a few conditional statements in place to at least check for video size and type otherw... |
82,654 | <p>I have the following code in functions.php to give me post format support and a custom post type 'photos'. But I would like the post formats to only apply to the 'photos' post type and not to the built-in 'posts' post type.</p>
<pre><code>add_theme_support( 'post-formats', array( 'image', 'chat', 'video', 'gallery'... | [
{
"answer_id": 82659,
"author": "diggy",
"author_id": 25765,
"author_profile": "https://wordpress.stackexchange.com/users/25765",
"pm_score": 3,
"selected": true,
"text": "<p>Try <a href=\"http://codex.wordpress.org/Function_Reference/remove_post_type_support\" rel=\"nofollow\"><code>rem... | 2013/01/22 | [
"https://wordpress.stackexchange.com/questions/82654",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7838/"
] | I have the following code in functions.php to give me post format support and a custom post type 'photos'. But I would like the post formats to only apply to the 'photos' post type and not to the built-in 'posts' post type.
```
add_theme_support( 'post-formats', array( 'image', 'chat', 'video', 'gallery' ) );
//custom... | Try [`remove_post_type_support`](http://codex.wordpress.org/Function_Reference/remove_post_type_support):
```
remove_post_type_support( 'post', 'post-formats' );
``` |
82,670 | <p>I've been working on developing a plugin that adds a widget that allows you to edit the content with a wysiwyg editor. I want to use the default wordpress editor by calling <code>wp_editor()</code>. I've seen people say you can't do this, and sure enough, it crashes when you try to update the widget content. </p>
<... | [
{
"answer_id": 82673,
"author": "Blackbam",
"author_id": 12035,
"author_profile": "https://wordpress.stackexchange.com/users/12035",
"pm_score": 1,
"selected": false,
"text": "<p>do not know the exact answer why wp_editor() is not working inside of widgets, but widgets have some restrict... | 2013/01/22 | [
"https://wordpress.stackexchange.com/questions/82670",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24836/"
] | I've been working on developing a plugin that adds a widget that allows you to edit the content with a wysiwyg editor. I want to use the default wordpress editor by calling `wp_editor()`. I've seen people say you can't do this, and sure enough, it crashes when you try to update the widget content.
Can anyone explain ... | Short answer: Because there is a hidden widget where the TinyMCE appears first.
Long answer (sorry, a very long answer):
Go to the [Codex and copy the example widget `Foo_Widget`](http://codex.wordpress.org/Widgets_API) to make sure we are talking about the same code. Now open your IDE (not an editor) and write a sho... |
82,682 | <p>I'm trying to add a copyright statement and footer menu to the footer area of my Twenty Ten child theme. So far I've created the child theme and added the copyright statement and footer menu to the footer.php file.</p>
<p>My code for the child footer.php file is:</p>
<pre><code><?php
/**
* The template for dis... | [
{
"answer_id": 82691,
"author": "Jessica",
"author_id": 26381,
"author_profile": "https://wordpress.stackexchange.com/users/26381",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried <code>display: inline</code>? </p>\n"
},
{
"answer_id": 82695,
"author": "Nerudo",
... | 2013/01/22 | [
"https://wordpress.stackexchange.com/questions/82682",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25121/"
] | I'm trying to add a copyright statement and footer menu to the footer area of my Twenty Ten child theme. So far I've created the child theme and added the copyright statement and footer menu to the footer.php file.
My code for the child footer.php file is:
```
<?php
/**
* The template for displaying the footer.
*
... | Assuming the menu has the structure
```
<div id="site-info">
Copyright (c) 2013 Acme Inc. All rights reserved.
<ul class='menu'>
<li> Privacy Policy</li>
<li>Terms and conditions</li>
</ul>
</div>
```
You will need to add the following css"
```
#site-info{
display: inline-block;
... |
82,684 | <p>I've got an issue with author's template. It works great and displays authors profiles as expected, but the issue is that you can see non-authors profiles also (contributors / subscribers, basically all registered users, including and admin) simply by substituting username in URL (www.mysite.com/author/subscribernam... | [
{
"answer_id": 82686,
"author": "diggy",
"author_id": 25765,
"author_profile": "https://wordpress.stackexchange.com/users/25765",
"pm_score": 0,
"selected": false,
"text": "<p>Here's a possible approach, to be implemented in <code>author.php</code>:</p>\n\n<pre><code><?php \n globa... | 2013/01/22 | [
"https://wordpress.stackexchange.com/questions/82684",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26378/"
] | I've got an issue with author's template. It works great and displays authors profiles as expected, but the issue is that you can see non-authors profiles also (contributors / subscribers, basically all registered users, including and admin) simply by substituting username in URL (www.mysite.com/author/subscribername).... | You're going to want to use the `author_template` filter to process this. Just to clarify, the filter's "author" means all users, it appears. I'm not sure why. This will be called while the backend is deciding which template page to use when showing a user's profile on your site. You need to add an `author-editor.php` ... |
82,710 | <p>I have been trying to figure out what is wrong with my code for a couple days now, and I can't seem to crack it. I am trying to follow <a href="https://developers.google.com/maps/articles/phpsqlajax_v3" rel="nofollow">this tutorial</a></p>
<p>I tried all three of the suggested methods to output the XML from my sql... | [
{
"answer_id": 83648,
"author": "Kelly Mann",
"author_id": 26386,
"author_profile": "https://wordpress.stackexchange.com/users/26386",
"pm_score": 1,
"selected": false,
"text": "<p>So I figured out the issue. I wasn't familiar enough with how urls are handled in XMLHttpRequest. I needed... | 2013/01/23 | [
"https://wordpress.stackexchange.com/questions/82710",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26386/"
] | I have been trying to figure out what is wrong with my code for a couple days now, and I can't seem to crack it. I am trying to follow [this tutorial](https://developers.google.com/maps/articles/phpsqlajax_v3)
I tried all three of the suggested methods to output the XML from my sql server, and I could only get it to w... | So I figured out the issue. I wasn't familiar enough with how urls are handled in XMLHttpRequest. I needed to change
```
downloadUrl("http://wp-content/themes/oxygen-child/phpsqlajax_genxml3.php", function(data) {
```
to
```
downloadUrl("http://www.theworldsflgiht.com/wp-content/themes/oxygen-child/phpsqlajax_gen... |
82,718 | <p>This question <a href="https://wordpress.stackexchange.com/questions/76871/how-to-use-iris-color-picker-on-front-end">here</a> is asking the same question as I am, but there were no adequate answers nor a selected correct answer so I am asking again hoping if I ask in a more coherent manner I might get a response.</... | [
{
"answer_id": 82722,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 5,
"selected": true,
"text": "<p>This drove me mad for a while, but I got it to work by adding them with the full arguments that are used in the admi... | 2013/01/23 | [
"https://wordpress.stackexchange.com/questions/82718",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1687/"
] | This question [here](https://wordpress.stackexchange.com/questions/76871/how-to-use-iris-color-picker-on-front-end) is asking the same question as I am, but there were no adequate answers nor a selected correct answer so I am asking again hoping if I ask in a more coherent manner I might get a response.
I am trying to... | This drove me mad for a while, but I got it to work by adding them with the full arguments that are used in the admin script loader rather than just referencing the handle. When I print the `$wp_scripts` global on the front end, `iris` and `wp-color-picker` are nowhere to be found, though all of their jQuery UI depende... |
82,726 | <p>I created a menu in wordpress in the Menus section of the backend is there any way to display the menu links with commas so it displays as <code>Link1, Link2, Link3, Link4</code>?</p>
| [
{
"answer_id": 82727,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 2,
"selected": false,
"text": "<p>Yes you can, when declaring your <code>wp_nav_menu</code> function you do it like so;</p>\n\n<pre><code>$defaults... | 2013/01/23 | [
"https://wordpress.stackexchange.com/questions/82726",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15330/"
] | I created a menu in wordpress in the Menus section of the backend is there any way to display the menu links with commas so it displays as `Link1, Link2, Link3, Link4`? | Use a very simple custom walker …
```
class WPSE_82726_Comma_Walker extends Walker
{
public function walk( $elements, $max_depth )
{
$list = array ();
foreach ( $elements as $item )
$list[] = "<a href='$item->url'>$item->title</a>";
return join( ', ', $list );
}
}
```... |
82,734 | <p>I have a code on my site that displays different headers for different post types using the <code>if ( get_post_type() == 'post type here' ) {</code> code </p>
<p>but is there a way i can do this for days of the week?</p>
<p>I want to create a calendar since i can't find an actual good calendar that works to my f... | [
{
"answer_id": 82727,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 2,
"selected": false,
"text": "<p>Yes you can, when declaring your <code>wp_nav_menu</code> function you do it like so;</p>\n\n<pre><code>$defaults... | 2013/01/23 | [
"https://wordpress.stackexchange.com/questions/82734",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20145/"
] | I have a code on my site that displays different headers for different post types using the `if ( get_post_type() == 'post type here' ) {` code
but is there a way i can do this for days of the week?
I want to create a calendar since i can't find an actual good calendar that works to my fits.
I want to create a list... | Use a very simple custom walker …
```
class WPSE_82726_Comma_Walker extends Walker
{
public function walk( $elements, $max_depth )
{
$list = array ();
foreach ( $elements as $item )
$list[] = "<a href='$item->url'>$item->title</a>";
return join( ', ', $list );
}
}
```... |
82,738 | <p>I'm trying to retrieve all the categories which are related to a specific post, using the <code>wp_get_post_categories()</code> function. The problem is that it is a custom post type, so I tried sending it in the $args array : </p>
<pre><code>wp_get_post_categories($id,array('post_type'=>'product'));
</code></p... | [
{
"answer_id": 82740,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 3,
"selected": true,
"text": "<p>Are you sure it a <code>category</code>, and not a custom <a href=\"http://codex.wordpress.org/Taxonomies\" rel... | 2013/01/23 | [
"https://wordpress.stackexchange.com/questions/82738",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11793/"
] | I'm trying to retrieve all the categories which are related to a specific post, using the `wp_get_post_categories()` function. The problem is that it is a custom post type, so I tried sending it in the $args array :
```
wp_get_post_categories($id,array('post_type'=>'product'));
```
but that returned an empty array ... | Are you sure it a `category`, and not a custom [taxonomy](http://codex.wordpress.org/Taxonomies)?
If it is a category try:
```
var_dump( wp_get_post_categories( $id ) );
```
or its equivalent since `category` is a taxonomy:
```
var_dump( wp_get_object_terms( $id, 'category' ) );
``` |
82,742 | <p>This is a code that I'm adapting from <a href="https://gist.github.com/2057532" rel="nofollow">https://gist.github.com/2057532</a>. The problem is that I'm not being able to save the content from the new fields that I created. I had checked the other questions here, but none helped me. Any idea where is the problem?... | [
{
"answer_id": 82750,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 1,
"selected": false,
"text": "<p>Could be that you are saving it wrong, change this:</p>\n\n<pre><code>if ( !empty( $new ) && $new != ... | 2013/01/23 | [
"https://wordpress.stackexchange.com/questions/82742",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9060/"
] | This is a code that I'm adapting from <https://gist.github.com/2057532>. The problem is that I'm not being able to save the content from the new fields that I created. I had checked the other questions here, but none helped me. Any idea where is the problem?
```
add_action('admin_init', 'slider_metabox_caption', 1);
f... | Using the following code allows you to retrieve the array.
```
foreach ($repeatable_fields as $v) {
}
```
Than you can access individual values with something like this:
```
<?php echo $v['text']; ?>
``` |
82,743 | <p>This <a href="http://wordpress.org/extend/plugins/gravity-forms-update-post/" rel="nofollow">third party add-on plugin</a> for Gravity Forms allows you to edit existing posts via the front end when you embed a form in your chosen template. </p>
<p>All you need to do is append the GET variable/parameter <code>?gform... | [
{
"answer_id": 82748,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>There is an API for exactly your use case: endpoints. <a href=\"https://wordpress.stackexchange.com/a/51450/73\" title... | 2013/01/23 | [
"https://wordpress.stackexchange.com/questions/82743",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13418/"
] | This [third party add-on plugin](http://wordpress.org/extend/plugins/gravity-forms-update-post/) for Gravity Forms allows you to edit existing posts via the front end when you embed a form in your chosen template.
All you need to do is append the GET variable/parameter `?gform_post_id=1` to the end of your URL which ... | The solution to my problem was to ultimately unhook the construct function on init within the plugin and then re-add the plugin construct function on the `wp` hook.
```
global $gform_update_post;
remove_action( 'init', array($gform_update_post, 'init'), 100 );
add_action( 'wp', array($gform_update_post, 'init'), 10... |
82,745 | <p>I have this code in my index.php file. I have a different template for a static home page, this is the blog page. I'm trying to exclude all posts with the category "new" which is tag_id "13"</p>
<pre><code><?php query_posts($query_string . '&cat=-13'); ?>
<?php if ( have_posts() ) : while ( have_posts(... | [
{
"answer_id": 82754,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 0,
"selected": false,
"text": "<p>The <code>$query_string</code> is probably not initialized or not declared as global variable. Try adding<... | 2013/01/23 | [
"https://wordpress.stackexchange.com/questions/82745",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26398/"
] | I have this code in my index.php file. I have a different template for a static home page, this is the blog page. I'm trying to exclude all posts with the category "new" which is tag\_id "13"
```
<?php query_posts($query_string . '&cat=-13'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<a h... | Don't use **`query_posts()`**. Use `pre_get_posts` instead:
```
function wpse82745_filter_pre_get_posts( $query ) {
// Only modify the main loop,
// and only in the blog posts index
if ( is_home() && $query->is_main_query() ) {
$query->set( 'category__not_in', array( '13' ) );
}
}
add_action( '... |
82,746 | <p>i want to make a single page site which has subpages with following structure</p>
<p>about us<br>
team<br>
-member1<br>
-member2<br>
contact<br></p>
<p>and i want the output to be like</p>
<pre><code><div class="about-us">
team content
</div>
<div class="team">
team content
<div class="su... | [
{
"answer_id": 82754,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 0,
"selected": false,
"text": "<p>The <code>$query_string</code> is probably not initialized or not declared as global variable. Try adding<... | 2013/01/23 | [
"https://wordpress.stackexchange.com/questions/82746",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26397/"
] | i want to make a single page site which has subpages with following structure
about us
team
-member1
-member2
contact
and i want the output to be like
```
<div class="about-us">
team content
</div>
<div class="team">
team content
<div class="subpages">
<div class="member1">
member... | Don't use **`query_posts()`**. Use `pre_get_posts` instead:
```
function wpse82745_filter_pre_get_posts( $query ) {
// Only modify the main loop,
// and only in the blog posts index
if ( is_home() && $query->is_main_query() ) {
$query->set( 'category__not_in', array( '13' ) );
}
}
add_action( '... |
82,761 | <p>I have a custom post type define below and I want to add a custom row action to allow me to 'update' the post via the admin panel</p>
<pre><code>class LeagueCpt
{
function __construct()
{
add_action( 'init', array(&$this,'registerLeagueCPT'));
add_filter('post_row_actions', array(&$t... | [
{
"answer_id": 94992,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 2,
"selected": false,
"text": "<p>You'd have to use the <code>$_GET</code> method. Here, I'm hooking in <code>admin_head-{$pagenow}</code>, de... | 2013/01/23 | [
"https://wordpress.stackexchange.com/questions/82761",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16267/"
] | I have a custom post type define below and I want to add a custom row action to allow me to 'update' the post via the admin panel
```
class LeagueCpt
{
function __construct()
{
add_action( 'init', array(&$this,'registerLeagueCPT'));
add_filter('post_row_actions', array(&$this,'post_row_actions'... | You'd have to use the `$_GET` method. Here, I'm hooking in `admin_head-{$pagenow}`, depending on your functionality maybe you'll need to hook in `load-{$pagenow}`.
Prefix your var names to not colide with any WordPress internals, in this case `my-update` for the action name:
```
edit.php?post_type=league&action=***my... |
82,766 | <p>I thought this would be a simple task, but I cannot find anything on google.</p>
<p>I would simply like to echo the meun_order value in my loop.</p>
<p>I tried this but it's not in the post_meta table, its in the post's table.</p>
<pre><code><?php echo get_post_meta($post->ID, 'menu_order', true); ?>
</c... | [
{
"answer_id": 82767,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 3,
"selected": true,
"text": "<p>You can't use <code>get_post_meta</code> since the <code>menu_order</code> is stored in the <code>posts</code> ... | 2013/01/23 | [
"https://wordpress.stackexchange.com/questions/82766",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11327/"
] | I thought this would be a simple task, but I cannot find anything on google.
I would simply like to echo the meun\_order value in my loop.
I tried this but it's not in the post\_meta table, its in the post's table.
```
<?php echo get_post_meta($post->ID, 'menu_order', true); ?>
```
Can anyone help please?
Thanks
... | You can't use `get_post_meta` since the `menu_order` is stored in the `posts` table, like you said. But you can set up an easy database query to get the value.
```
$menu_o = $wpdb->get_var( "SELECT menu_order FROM $wpdb->posts WHERE ID=" . $post->ID );
echo $menu_o;
``` |
82,776 | <p>Im running a rather large wpmu setup bloggersdelight.dk - from time to time, we need to reset the object cache when doing changes on the site. When we do this, things mess up. Option values from sites gets mixed together and homeurls for blogs redirects to wrong blogs etc.</p>
<p>This is the current object-cache.ph... | [
{
"answer_id": 82836,
"author": "Weston Ruter",
"author_id": 8521,
"author_profile": "https://wordpress.stackexchange.com/users/8521",
"pm_score": 1,
"selected": false,
"text": "<p>Are you running WordPress 3.5? If not, you should try upgrading because the stability of the blog-switching... | 2013/01/23 | [
"https://wordpress.stackexchange.com/questions/82776",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19082/"
] | Im running a rather large wpmu setup bloggersdelight.dk - from time to time, we need to reset the object cache when doing changes on the site. When we do this, things mess up. Option values from sites gets mixed together and homeurls for blogs redirects to wrong blogs etc.
This is the current object-cache.php im worki... | We upgraded to wordpress 3.5.1 and the latest version of object-cache.php this has now solved the problems. |
82,787 | <p>My problem is with <code>@package</code> and <code>@subpackage</code>.</p>
<p>I went to the suggested link (<a href="https://wordpress.stackexchange.com/questions/19278/what-are-the-package-and-subpackage-comment-for">What are the package and subpackage comment for?</a>). There I did not find anything I could apply... | [
{
"answer_id": 82788,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 1,
"selected": false,
"text": "<p>The <code>@package</code> specify packages to group classes or functions and defines into, also a theme for WordPr... | 2013/01/23 | [
"https://wordpress.stackexchange.com/questions/82787",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26419/"
] | My problem is with `@package` and `@subpackage`.
I went to the suggested link ([What are the package and subpackage comment for?](https://wordpress.stackexchange.com/questions/19278/what-are-the-package-and-subpackage-comment-for)). There I did not find anything I could apply to my problem but instead this answer:
“T... | Rule of thumb: is your code bundled (i.e. *packaged*) with whatever code indicated by `@package`? If no, then you are using an incorrect value for `@package`.
For the case of most Themes, this is easy:
* *Core-bundled* Themes use `@package: WordPress` and `@subpackage Theme-Name`, because they are packaged and distri... |
82,791 | <h1>Preface</h1>
<p>I've installed gravity forms, created a form and users are submitting data to my site.
What I want to do is show the data users are submitting to my site on one of my pages.</p>
<p>I know there's the <a href="http://wordpress.org/extend/plugins/gravity-forms-addons/" rel="noreferrer">Gravity Forms D... | [
{
"answer_id": 82916,
"author": "webaware",
"author_id": 24260,
"author_profile": "https://wordpress.stackexchange.com/users/24260",
"pm_score": 6,
"selected": true,
"text": "<p>You can look at the docs, but you'll probably end up reading the <em>real</em> documentation: the source code.... | 2013/01/23 | [
"https://wordpress.stackexchange.com/questions/82791",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15010/"
] | Preface
=======
I've installed gravity forms, created a form and users are submitting data to my site.
What I want to do is show the data users are submitting to my site on one of my pages.
I know there's the [Gravity Forms Directory](http://wordpress.org/extend/plugins/gravity-forms-addons/) plugin.
But this gives o... | You can look at the docs, but you'll probably end up reading the *real* documentation: the source code.
If you do, you'll find that:
* `GFFormsModel::get_leads($form_id)` returns a list of entries for a form (maybe you know that one already), where each item in the array is itself an array, an "[Entry object](http://... |
82,794 | <p>In my theme, I used this:</p>
<pre><code><div id="brickwall" data-brickinvert="<?php echo brickAlign(); ?>">
</code></pre>
<p>I put the code into functions.php:</p>
<pre><code>function brickAlign() {
$a = "true";
return $a;
}
</code></pre>
<p>Now in the child theme, I would like to change $a ... | [
{
"answer_id": 82916,
"author": "webaware",
"author_id": 24260,
"author_profile": "https://wordpress.stackexchange.com/users/24260",
"pm_score": 6,
"selected": true,
"text": "<p>You can look at the docs, but you'll probably end up reading the <em>real</em> documentation: the source code.... | 2013/01/23 | [
"https://wordpress.stackexchange.com/questions/82794",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17704/"
] | In my theme, I used this:
```
<div id="brickwall" data-brickinvert="<?php echo brickAlign(); ?>">
```
I put the code into functions.php:
```
function brickAlign() {
$a = "true";
return $a;
}
```
Now in the child theme, I would like to change $a to false.
Then in child theme my html would look like:
``... | You can look at the docs, but you'll probably end up reading the *real* documentation: the source code.
If you do, you'll find that:
* `GFFormsModel::get_leads($form_id)` returns a list of entries for a form (maybe you know that one already), where each item in the array is itself an array, an "[Entry object](http://... |
82,800 | <p>I want to hide the div class "navmain2" if the menu is empty. See code below:</p>
<pre><code><!-- Start main navigation -->
<div class="navmain2">
<div id="logo"></div>
<!-- Gets main menu by id -->
<span></span>
<?php
wp_nav_menu( array(
... | [
{
"answer_id": 82806,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 5,
"selected": true,
"text": "<p>Assign the menu to a string:</p>\n\n<pre><code>$menu = wp_nav_menu(\n array (\n 'echo' => FALSE,\n ... | 2013/01/23 | [
"https://wordpress.stackexchange.com/questions/82800",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21256/"
] | I want to hide the div class "navmain2" if the menu is empty. See code below:
```
<!-- Start main navigation -->
<div class="navmain2">
<div id="logo"></div>
<!-- Gets main menu by id -->
<span></span>
<?php
wp_nav_menu( array(
'menu' => 11,
'container' =>false,
... | Assign the menu to a string:
```
$menu = wp_nav_menu(
array (
'echo' => FALSE,
'fallback_cb' => '__return_false'
)
);
if ( ! empty ( $menu ) )
{
echo '<div class="navmain2">' . $menu . '</div>';
}
``` |
82,830 | <p>I have this custom field for a post:</p>
<pre><code>key: price
value: 2000
</code></pre>
<p>I've added this to my loop:</p>
<pre><code><div class="buyitnow"><?php $price = get_post_meta($post->ID, 'price', true);
if ( $price ) { ?>
Price: $<?php echo number_format($price ,",",",",","); ?>
<... | [
{
"answer_id": 82831,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 0,
"selected": false,
"text": "<p>If you haven't, you need to <em>globalize</em> the <code>$post</code> global variable:</p>\n\n<pre><code>gl... | 2013/01/23 | [
"https://wordpress.stackexchange.com/questions/82830",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26435/"
] | I have this custom field for a post:
```
key: price
value: 2000
```
I've added this to my loop:
```
<div class="buyitnow"><?php $price = get_post_meta($post->ID, 'price', true);
if ( $price ) { ?>
Price: $<?php echo number_format($price ,",",",",","); ?>
<?php } else {} ?></div>
```
But all I'm getting is:
```
P... | You have [`number_format`](http://php.net/manual/en/function.number-format.php) wrong. The second parameter should be a number and you have a string-- a comma. What you want is something like
```
echo number_format($price,2,",",",");
``` |
82,853 | <p>I've been developing a plugin where I wanted to create a table, styled and working just like Wordpress's native Post/Page tables.</p>
<p>Following the guide below, I was able to create the table and load my database. The only thing I cannot figure out to do is how to make one of the row contents "clickable". </p>... | [
{
"answer_id": 83081,
"author": "Latz",
"author_id": 13811,
"author_profile": "https://wordpress.stackexchange.com/users/13811",
"pm_score": 0,
"selected": false,
"text": "<p>If you mean the \"Quick Edit\" feature of the posts and comments tables: I'm working on a tutorial for this featu... | 2013/01/23 | [
"https://wordpress.stackexchange.com/questions/82853",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15209/"
] | I've been developing a plugin where I wanted to create a table, styled and working just like Wordpress's native Post/Page tables.
Following the guide below, I was able to create the table and load my database. The only thing I cannot figure out to do is how to make one of the row contents "clickable".
<http://wpengi... | The [`WP_List_Table` class](http://core.trac.wordpress.org/browser/tags/3.5.1//wp-admin/includes/class-wp-list-table.php#L0) ultimately uses the `single_row_columns` method to output each table cell. If we look at that method, we'll see this part:
```
...
elseif ( method_exists( $this, 'column_' . $column_name ) ) {
... |
82,860 | <p>I want to try and remove automatic <code><p></code> tag and <code><br></code> tag addition for my custom post type.</p>
<p>It looks like</p>
<pre><code>remove_filter( 'the_content', 'wpautop' );
</code></pre>
<p>will do this, but how would I make the change only for my chosen post type I've tried writ... | [
{
"answer_id": 82862,
"author": "user319940",
"author_id": 24044,
"author_profile": "https://wordpress.stackexchange.com/users/24044",
"pm_score": 4,
"selected": true,
"text": "<pre><code>remove_filter('the_content','wpautop');\n\n//decide when you want to apply the auto paragraph\n\nadd... | 2013/01/23 | [
"https://wordpress.stackexchange.com/questions/82860",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24044/"
] | I want to try and remove automatic `<p>` tag and `<br>` tag addition for my custom post type.
It looks like
```
remove_filter( 'the_content', 'wpautop' );
```
will do this, but how would I make the change only for my chosen post type I've tried writing a function for this, but it doesn't seem to work:
```
function... | ```
remove_filter('the_content','wpautop');
//decide when you want to apply the auto paragraph
add_filter('the_content','my_custom_formatting');
function my_custom_formatting($content){
if(get_post_type()=='my_custom_post') //if it does not work, you may want to pass the current post object to get_post_type
retu... |
82,873 | <p>I'm trying to remove the export.php page from WordPress admin menu -> tools
for a multisite so only the network admin could see it</p>
<p>I have the following code so far but can't get it to work.</p>
<pre><code>//***************************************************
// Remove export Page
//************************... | [
{
"answer_id": 82876,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 4,
"selected": true,
"text": "<p>Whenever in doubt about a WordPress function, consult the Codex: <a href=\"http://codex.wordpress.org/Functio... | 2013/01/24 | [
"https://wordpress.stackexchange.com/questions/82873",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17073/"
] | I'm trying to remove the export.php page from WordPress admin menu -> tools
for a multisite so only the network admin could see it
I have the following code so far but can't get it to work.
```
//***************************************************
// Remove export Page
//*********************************************... | Whenever in doubt about a WordPress function, consult the Codex: [Function\_Reference/remove\_menu\_page](http://codex.wordpress.org/Function_Reference/remove_menu_page).
The correct function is [`remove_submenu_page`](http://codex.wordpress.org/remove_submenu_page) hooked into `admin_menu`.
```
add_action( 'admin_me... |
82,902 | <p>The scenario is to run insert_post function every midnight (00:00) of local time. Must run daily on weekday.</p>
<pre><code>function add_daily_task(){
if((date('l', time()) != 'Saturday') || (date('l', time()) != 'Sunday')){
// insert post
}
}
if(!wp_next_scheduled( 'add_daily_task_schedule')){
... | [
{
"answer_id": 85029,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 1,
"selected": false,
"text": "<p>The function:</p>\n\n<pre><code>time()\n</code></pre>\n\n<p>gives the UNIX timestamp in the GMT timezone.</p>\... | 2013/01/24 | [
"https://wordpress.stackexchange.com/questions/82902",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16244/"
] | The scenario is to run insert\_post function every midnight (00:00) of local time. Must run daily on weekday.
```
function add_daily_task(){
if((date('l', time()) != 'Saturday') || (date('l', time()) != 'Sunday')){
// insert post
}
}
if(!wp_next_scheduled( 'add_daily_task_schedule')){
wp_schedule... | Not sure what is the question, but the use of `time()` is wrong as it will give you at best the local time of the server and not the local time of the site which takes into consideration the time zone configuration of WordPress.
The function that you should use is [current\_time](https://developer.wordpress.org/refere... |
82,905 | <p>After I added a post by <a href="http://codex.wordpress.org/Function_Reference/wp_insert_post" rel="nofollow">wp_insert_post();</a></p>
<p>Any callback after I added ? I need permalink of added post.</p>
<p>I have idea only search by title and post-type (I use custom post-type in my case), But any better function ... | [
{
"answer_id": 82907,
"author": "l2aelba",
"author_id": 6332,
"author_profile": "https://wordpress.stackexchange.com/users/6332",
"pm_score": 1,
"selected": false,
"text": "<p>Oh I found !</p>\n\n<pre><code>$post_id = wp_insert_post($arg); // return post ID\n</code></pre>\n"
},
{
... | 2013/01/24 | [
"https://wordpress.stackexchange.com/questions/82905",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6332/"
] | After I added a post by [wp\_insert\_post();](http://codex.wordpress.org/Function_Reference/wp_insert_post)
Any callback after I added ? I need permalink of added post.
I have idea only search by title and post-type (I use custom post-type in my case), But any better function ? | ```
$post_id = wp_insert_post( $arg ); #returns post ID
$permalink = get_permalink( $post_id ); #returns the permalink
```
Codex:
<http://codex.wordpress.org/Function_Reference/wp_insert_post> |
82,914 | <p>I'm developing my own theme and came up with an issue that' I am confused with. I have two files that I'm trying to figure out. <code>page.php</code> and <code>index.php</code>.</p>
<p>I know that page.php is used for pages, of course, but when trying to set up a 404 page, for example:</p>
<pre><code><?php if (... | [
{
"answer_id": 82917,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p>Index.php isn't for a specific page, and that's not how template files in themes work.</p>\n\n<p>You will nee... | 2013/01/24 | [
"https://wordpress.stackexchange.com/questions/82914",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18311/"
] | I'm developing my own theme and came up with an issue that' I am confused with. I have two files that I'm trying to figure out. `page.php` and `index.php`.
I know that page.php is used for pages, of course, but when trying to set up a 404 page, for example:
```
<?php if (have_posts()) : while (have_posts()) : the_pos... | Index.php isn't for a specific page, and that's not how template files in themes work.
You will need to understand the template heirarchy
<http://codex.wordpress.org/Template_Hierarchy>

>
> WordPress uses the Query String — information contained ... |
82,928 | <p>I use nextgen gallery in a multisite. How can I disable all scripts and styles?
These thing are loaded in the code of my site:</p>
<pre><code><link rel='stylesheet' id='NextGEN-css' href='http://mysite.com/wp-content/plugins/nextgen-gallery/css/nggallery.css?ver=1.0.0' type='text/css' media='screen' />
<... | [
{
"answer_id": 82930,
"author": "webaware",
"author_id": 24260,
"author_profile": "https://wordpress.stackexchange.com/users/24260",
"pm_score": 2,
"selected": true,
"text": "<p>This takes care of NextGEN's slideshow and CSS, as well as the Shutter script and CSS that it also enqueues by... | 2013/01/24 | [
"https://wordpress.stackexchange.com/questions/82928",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12508/"
] | I use nextgen gallery in a multisite. How can I disable all scripts and styles?
These thing are loaded in the code of my site:
```
<link rel='stylesheet' id='NextGEN-css' href='http://mysite.com/wp-content/plugins/nextgen-gallery/css/nggallery.css?ver=1.0.0' type='text/css' media='screen' />
<script type='text/javas... | This takes care of NextGEN's slideshow and CSS, as well as the Shutter script and CSS that it also enqueues by default.
```
add_action('wp_print_scripts', 'wpse_82982_removeScripts');
add_action('wp_print_styles', 'wpse_82982_removeStyles');
function wpse_82982_removeScripts() {
wp_dequeue_script('ngg-slideshow'... |
82,933 | <p>how can I make the script and style appear in my footer of my wp only when the shortcode is on a page or a post?</p>
| [
{
"answer_id": 82935,
"author": "helgatheviking",
"author_id": 6477,
"author_profile": "https://wordpress.stackexchange.com/users/6477",
"pm_score": 1,
"selected": false,
"text": "<p>This isn't based on shortcode detection, but you could try </p>\n\n<pre><code>// Add the Contact Form 7 s... | 2013/01/24 | [
"https://wordpress.stackexchange.com/questions/82933",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12508/"
] | how can I make the script and style appear in my footer of my wp only when the shortcode is on a page or a post? | This isn't based on shortcode detection, but you could try
```
// Add the Contact Form 7 scripts only on the contact page
function deregister_cf7_js() {
if ( !is_page('contact')) {
wp_deregister_script( 'contact-form-7');
}
}
add_action( 'wp_print_scripts', 'deregister_cf7_js' );
function deregister_... |
82,949 | <p>I'm trying to customize the default Woocommerce theme to my needs.</p>
<p>I have a product that comes in two variations:
it's wine, so variation A is a 6 bottle pack, and variation B is a 12 bottle wooden case.</p>
<p>I'd like to have a double input text field next to the product that will let me add them to the s... | [
{
"answer_id": 82962,
"author": "Steve",
"author_id": 23132,
"author_profile": "https://wordpress.stackexchange.com/users/23132",
"pm_score": 1,
"selected": false,
"text": "<p>If you're following the recommended process for customizing WooCommerce you should have copied all of the WooCom... | 2013/01/24 | [
"https://wordpress.stackexchange.com/questions/82949",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22547/"
] | I'm trying to customize the default Woocommerce theme to my needs.
I have a product that comes in two variations:
it's wine, so variation A is a 6 bottle pack, and variation B is a 12 bottle wooden case.
I'd like to have a double input text field next to the product that will let me add them to the shopping cart.
So... | Just an FYI to other people who found this: I was able to achieve this using Grouped products instead of Variants. Simply add the main product (the Wine, in this case) as a 'Grouped Product'. Then, add the 2 case sizes as simple product, and in the 'Advanced' tab, choose the Grouped product from the 'Grouping' dropdown... |
82,955 | <p>I would like to able to redirect to <code>get_bloginfo('url');</code> after reseting password.</p>
<p>But I cannot for life of me find any simple answer or function to do this.</p>
<p>Does anyone know if this is possible?</p>
<p>Thank
Josh</p>
| [
{
"answer_id": 83153,
"author": "Pontus Abrahamsson",
"author_id": 16722,
"author_profile": "https://wordpress.stackexchange.com/users/16722",
"pm_score": 4,
"selected": true,
"text": "<p>Here is a simple solution. Im hooking into <code>login_headerurl</code>. Maybe there is a better hoo... | 2013/01/24 | [
"https://wordpress.stackexchange.com/questions/82955",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11327/"
] | I would like to able to redirect to `get_bloginfo('url');` after reseting password.
But I cannot for life of me find any simple answer or function to do this.
Does anyone know if this is possible?
Thank
Josh | Here is a simple solution. Im hooking into `login_headerurl`. Maybe there is a better hook for this but it works, Put this in your functions.php:
```
function wpse_lost_password_redirect() {
// Check if have submitted
$confirm = ( isset($_GET['checkemail'] ) ? $_GET['checkemail'] : '' );
if( $confirm ) ... |
82,961 | <p>Hi guys :) I know there is the <code>wpmu_new_blog</code> action hook which enables us to perform an action when a new WPMU blog is created. Is there something similar to this which enables us to perform an action when a WPMU blog is deleted? Something which looks like this:</p>
<p><code>add_action('blog_deletion_h... | [
{
"answer_id": 82967,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 3,
"selected": true,
"text": "<p>Yes, inside <a href=\"http://core.trac.wordpress.org/browser/tags/3.5/wp-admin/includes/ms.php#L65\" rel=\"no... | 2013/01/24 | [
"https://wordpress.stackexchange.com/questions/82961",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26264/"
] | Hi guys :) I know there is the `wpmu_new_blog` action hook which enables us to perform an action when a new WPMU blog is created. Is there something similar to this which enables us to perform an action when a WPMU blog is deleted? Something which looks like this:
`add_action('blog_deletion_hook', 'function_to_perform... | Yes, inside [`/wp-admin/includes/ms.php`](http://core.trac.wordpress.org/browser/tags/3.5/wp-admin/includes/ms.php#L65) there is the action hook `delete_blog`.
This test prevents a blog deletion:
```
add_action( 'delete_blog', 'prevent_blog_delete_wpse_82961', 10, 2 );
/**
* @param int $blog_id Blog ID
* @param bool... |
82,982 | <p>I have uploaded a file as my main logo within the theme settings but would like a different logo on the main page. The theme I am using has a custom css option within the theme settings, can I use custom css to only change it on the front page and not the rest of the site?</p>
<p>Theme: <a href="http://demo.ghostpo... | [
{
"answer_id": 82967,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 3,
"selected": true,
"text": "<p>Yes, inside <a href=\"http://core.trac.wordpress.org/browser/tags/3.5/wp-admin/includes/ms.php#L65\" rel=\"no... | 2013/01/24 | [
"https://wordpress.stackexchange.com/questions/82982",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26480/"
] | I have uploaded a file as my main logo within the theme settings but would like a different logo on the main page. The theme I am using has a custom css option within the theme settings, can I use custom css to only change it on the front page and not the rest of the site?
Theme: <http://demo.ghostpool.com/?theme=boun... | Yes, inside [`/wp-admin/includes/ms.php`](http://core.trac.wordpress.org/browser/tags/3.5/wp-admin/includes/ms.php#L65) there is the action hook `delete_blog`.
This test prevents a blog deletion:
```
add_action( 'delete_blog', 'prevent_blog_delete_wpse_82961', 10, 2 );
/**
* @param int $blog_id Blog ID
* @param bool... |