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 |
|---|---|---|---|---|---|---|
137,408 | <p>I'm using add_submenu_page() function to add some options to my plugin. On Linux hosting everything works like it should, on Windows hosting those 5 sub-menus have same link somehow and when I click on them page just reloads. What can be issue? Both hosts are using same PHP version. Here is the code</p>
<pre><code>... | [
{
"answer_id": 137418,
"author": "Ryan Bayne",
"author_id": 35010,
"author_profile": "https://wordpress.stackexchange.com/users/35010",
"pm_score": 0,
"selected": false,
"text": "<p>Sounds to me like the hooked function that calls the page file itself is the same for all five uses of add... | 2014/03/09 | [
"https://wordpress.stackexchange.com/questions/137408",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28694/"
] | I'm using add\_submenu\_page() function to add some options to my plugin. On Linux hosting everything works like it should, on Windows hosting those 5 sub-menus have same link somehow and when I click on them page just reloads. What can be issue? Both hosts are using same PHP version. Here is the code
```
$this->page_... | Sounds to me like the hooked function that calls the page file itself is the same for all five uses of add\_submenu\_page(). Hard to tell without the code.
```
<?php add_submenu_page( $parent_slug, $page_title, $menu_title, $capability, $menu_slug, $function ); ?>
```
The $function variable should be different for a... |
137,427 | <p>I can't get my translations to work in my theme. Here is what I have</p>
<p>In functions.php, I have:</p>
<pre><code>load_theme_textdomain( 'transparent', get_template_directory_uri() .'/languages' );
</code></pre>
<p>I have </p>
<blockquote>
<p>.../theme/languages/transparent-en_US.po,</p>
</blockquote>
<p>w... | [
{
"answer_id": 137472,
"author": "Ruben Bristian",
"author_id": 30805,
"author_profile": "https://wordpress.stackexchange.com/users/30805",
"pm_score": 2,
"selected": false,
"text": "<p>Don't use <strong>get_template_directory_uri()</strong>. Use <strong>get_template_directory()</strong>... | 2014/03/10 | [
"https://wordpress.stackexchange.com/questions/137427",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3206/"
] | I can't get my translations to work in my theme. Here is what I have
In functions.php, I have:
```
load_theme_textdomain( 'transparent', get_template_directory_uri() .'/languages' );
```
I have
>
> .../theme/languages/transparent-en\_US.po,
>
>
>
which contains:
```
# English translations for Transparent pa... | After inspecting your theme, this is what I came up with. I've taken the liberty to include Ruben's solution as well to make this answer as complete as possible.
There are several problems here:
Number 1. `load_theme_textdomain( 'transparent', get_template_directory_uri() .'/languages' );`
should be:
```
funct... |
137,428 | <p>I have a page which has a <a href="https://jqueryui.com/tabs/" rel="nofollow">jquery tab function</a> to output the list of pages that are the children of this page (Bio, Archives, Contact). </p>
<p>However I am trying to make a conditional in the foreach loop to no avail. </p>
<pre><code><?php // get_posts fun... | [
{
"answer_id": 137472,
"author": "Ruben Bristian",
"author_id": 30805,
"author_profile": "https://wordpress.stackexchange.com/users/30805",
"pm_score": 2,
"selected": false,
"text": "<p>Don't use <strong>get_template_directory_uri()</strong>. Use <strong>get_template_directory()</strong>... | 2014/03/10 | [
"https://wordpress.stackexchange.com/questions/137428",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32287/"
] | I have a page which has a [jquery tab function](https://jqueryui.com/tabs/) to output the list of pages that are the children of this page (Bio, Archives, Contact).
However I am trying to make a conditional in the foreach loop to no avail.
```
<?php // get_posts function: http://codex.wordpress.org/Template_Tags/ge... | After inspecting your theme, this is what I came up with. I've taken the liberty to include Ruben's solution as well to make this answer as complete as possible.
There are several problems here:
Number 1. `load_theme_textdomain( 'transparent', get_template_directory_uri() .'/languages' );`
should be:
```
funct... |
137,450 | <p>I have to achieve something on which I don't know how to approach it.</p>
<p><strong>Base of the issue:</strong></p>
<p>There's a bunch of data in another DB that I have to import into WP which so far wasn't possible due to them being multiple arrays that have to be repeated into fields(Advanced Custom Fields). As... | [
{
"answer_id": 137472,
"author": "Ruben Bristian",
"author_id": 30805,
"author_profile": "https://wordpress.stackexchange.com/users/30805",
"pm_score": 2,
"selected": false,
"text": "<p>Don't use <strong>get_template_directory_uri()</strong>. Use <strong>get_template_directory()</strong>... | 2014/03/10 | [
"https://wordpress.stackexchange.com/questions/137450",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48416/"
] | I have to achieve something on which I don't know how to approach it.
**Base of the issue:**
There's a bunch of data in another DB that I have to import into WP which so far wasn't possible due to them being multiple arrays that have to be repeated into fields(Advanced Custom Fields). As far as my research has gone I... | After inspecting your theme, this is what I came up with. I've taken the liberty to include Ruben's solution as well to make this answer as complete as possible.
There are several problems here:
Number 1. `load_theme_textdomain( 'transparent', get_template_directory_uri() .'/languages' );`
should be:
```
funct... |
137,457 | <p>I'm working on a plugin to use gettext in posts and pages content. </p>
<p>I'm trying to get all published posts and pages in order scan them for translatable strings, but I cannot figure out how to do it.</p>
<p>This is what I'm trying:</p>
<pre><code>$pages = $wpdb->query('SELECT * FROM wp_posts WHERE post_s... | [
{
"answer_id": 137460,
"author": "user48752",
"author_id": 48752,
"author_profile": "https://wordpress.stackexchange.com/users/48752",
"pm_score": 0,
"selected": false,
"text": "<p>Try this,</p>\n<pre><code>global $wpdb;\n\n$posts = $wpdb->get_results( $wpdb->prepare("SELECT *... | 2014/03/10 | [
"https://wordpress.stackexchange.com/questions/137457",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2488/"
] | I'm working on a plugin to use gettext in posts and pages content.
I'm trying to get all published posts and pages in order scan them for translatable strings, but I cannot figure out how to do it.
This is what I'm trying:
```
$pages = $wpdb->query('SELECT * FROM wp_posts WHERE post_status = "publish"');
foreach ( ... | Don't use pure SQL if you don't have to. WordPress provides a useful and relatively solid class for retrieving post data. Use it.
```
$args = array(
'post_type' => array('post','page'),
'post_status' => 'publish',
'posts_per_page' => -1,
'ignore_sticky_posts' => true,
);
$qry = new WP_Query($args);
// Show pos... |
137,547 | <p>I'm working on a plugin needing to return avatars a specific way. If the user exists in the wp_users table the code is run else a different set of code is run if the user is not in the wp_users table. I cannot use the username_exist and am tinkering now with the idea of using the user_status value of 0.</p>
<p>From... | [
{
"answer_id": 137551,
"author": "Rajeev Vyas",
"author_id": 6961,
"author_profile": "https://wordpress.stackexchange.com/users/6961",
"pm_score": 1,
"selected": false,
"text": "<pre><code>$blogusers = get_users();\nforeach ($blogusers as $user) {\n if($user->user_status=='0'){\n ... | 2014/03/11 | [
"https://wordpress.stackexchange.com/questions/137547",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47326/"
] | I'm working on a plugin needing to return avatars a specific way. If the user exists in the wp\_users table the code is run else a different set of code is run if the user is not in the wp\_users table. I cannot use the username\_exist and am tinkering now with the idea of using the user\_status value of 0.
From the C... | ```
$blogusers = get_users();
foreach ($blogusers as $user) {
if($user->user_status=='0'){
//do something
}
else{
// do something else
}
}
``` |
137,563 | <p>I'm having problems with jQuery and a plugin, the console error says jQuery is not defined. What I don't understand is it only fails when I load it to the production server, on my local dev installation it worked perfectly.</p>
<blockquote>
<p>ReferenceError: jQuery is not defined. </p>
</blockquote>
<p>The pl... | [
{
"answer_id": 137569,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 3,
"selected": true,
"text": "<p>Your code doesn't work because of a fundamental ordering problem.</p>\n\n<p>You're hooking into wp_footer. Then you... | 2014/03/11 | [
"https://wordpress.stackexchange.com/questions/137563",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45362/"
] | I'm having problems with jQuery and a plugin, the console error says jQuery is not defined. What I don't understand is it only fails when I load it to the production server, on my local dev installation it worked perfectly.
>
> ReferenceError: jQuery is not defined.
>
>
>
The plugin code:
```
add_filter( 'wp_fo... | Your code doesn't work because of a fundamental ordering problem.
You're hooking into wp\_footer. Then you're registering a script and enqueueing it. Finally, you echo some code.
Here's the problem, the act of enqueueing a script does not cause an echo of the script code immediately. Enqueueing does just what it says... |
137,571 | <p>I found a WordPress hook called "<a href="http://make.wordpress.org/core/2012/12/01/more-hooks-on-the-edit-screen/"><code>edit_form_after_title</code></a>" to add a text box after the title.</p>
<p>How can I use this hook to display the excerpt after the title while creating a new post?</p>
| [
{
"answer_id": 150092,
"author": "OzzyCzech",
"author_id": 12545,
"author_profile": "https://wordpress.stackexchange.com/users/12545",
"pm_score": 3,
"selected": false,
"text": "<p>It's simple, just unregister <code>postexcerpt</code> box first then add another one on the top. </p>\n\n<p... | 2014/03/11 | [
"https://wordpress.stackexchange.com/questions/137571",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48786/"
] | I found a WordPress hook called "[`edit_form_after_title`](http://make.wordpress.org/core/2012/12/01/more-hooks-on-the-edit-screen/)" to add a text box after the title.
How can I use this hook to display the excerpt after the title while creating a new post? | It's simple, just unregister `postexcerpt` box first then add another one on the top.
Here is my code
```
add_action(
'admin_menu', function () {
remove_meta_box('postexcerpt', 'post', 'normal');
}, 999
);
add_action('edit_form_after_title', 'post_excerpt_meta_box');
``` |
137,651 | <p>I am just trying to create a plugin that will add some JS to the header and custom CSs. I have this below but it adds the css wrong and shows as JS. This is first plugin i have attempted.</p>
<pre><code><?php
/**
* Plugin Name: mmoore5553 Simple Range Slider
* Plugin URI: mailto:mmoore5553@gmail.com
* Descrip... | [
{
"answer_id": 137652,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p><code>wp_enqueue_script</code> is for… scripts. You want <a href=\"https://codex.wordpress.org/Function_Reference/w... | 2014/03/12 | [
"https://wordpress.stackexchange.com/questions/137651",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48825/"
] | I am just trying to create a plugin that will add some JS to the header and custom CSs. I have this below but it adds the css wrong and shows as JS. This is first plugin i have attempted.
```
<?php
/**
* Plugin Name: mmoore5553 Simple Range Slider
* Plugin URI: mailto:mmoore5553@gmail.com
* Description: Simple Rang... | `wp_enqueue_script` is for… scripts. You want [`wp_enqueue_style`](https://codex.wordpress.org/Function_Reference/wp_enqueue_style) (and [`wp_register_style`](http://codex.wordpress.org/Function_Reference/wp_register_style)) for stylesheets.
Also note that you can enqueue as many things as you'd like in a single funct... |
137,667 | <p>I want to let the user of my plugin define html tags to use before and after the text output by the shortcode, so I am using parameters where they can enter the tags. However the tags are being converted to html entities. I therefore resorted to using html_entity_decode(), is this good practice?</p>
<pre><code> ... | [
{
"answer_id": 137669,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 1,
"selected": false,
"text": "<p>When I create shortcodes that accept html tags i only take the tag name, meaning that if the tag is <code>&l... | 2014/03/12 | [
"https://wordpress.stackexchange.com/questions/137667",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5844/"
] | I want to let the user of my plugin define html tags to use before and after the text output by the shortcode, so I am using parameters where they can enter the tags. However the tags are being converted to html entities. I therefore resorted to using html\_entity\_decode(), is this good practice?
```
extract( sho... | When I create shortcodes that accept html tags i only take the tag name, meaning that if the tag is `<h3>` then i ask the user to enter `h3` and i add the `<`, `</` and `>` in the shortcode handler ex:
```
extract( shortcode_atts( array(
'count' => -1,
'category_name' => '',
'q_tag' => 'h3'... |
137,681 | <p>I would like to show my WordPress blog's title as "Dummit foote 4.2.4". But I am getting all capitals as "DUMMIT FOOTE 4.2.4"</p>
<p>What should I do to change this?</p>
<p>I do not see any editor case in my dashboard.</p>
<p><img src="https://i.stack.imgur.com/gX9wU.png" alt="enter image description here"></p>
... | [
{
"answer_id": 137682,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>It is in your stylesheet </p>\n\n<pre><code>.entry-title {\n font-size: 33px;\n font-weight: 300;\n line... | 2014/03/12 | [
"https://wordpress.stackexchange.com/questions/137681",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/158101/"
] | I would like to show my WordPress blog's title as "Dummit foote 4.2.4". But I am getting all capitals as "DUMMIT FOOTE 4.2.4"
What should I do to change this?
I do not see any editor case in my dashboard.

It was mentioned that i should change some... | It is in your stylesheet
```
.entry-title {
font-size: 33px;
font-weight: 300;
line-height: 1.0909090909;
margin-bottom: 12px;
margin: 0 0 12px 0;
text-transform: uppercase;
}
```
You need to remove text-transform: uppercase; |
137,688 | <p>That's a freaking bad practice I must say. Spent last two hours finding a solution to remove actions and filters added via Anonymous functions. </p>
<p>This is the code used on a Parent Theme, and I need to remove it.</p>
<pre><code>/**
* Add custom columns to admin comments grid
* * Rate that user set.
*/
ad... | [
{
"answer_id": 138962,
"author": "tivnet",
"author_id": 28961,
"author_profile": "https://wordpress.stackexchange.com/users/28961",
"pm_score": 2,
"selected": false,
"text": "<p>What if you add your filter, with the priority 11, so it goes after? That's ugly, but might work in your case.... | 2014/03/12 | [
"https://wordpress.stackexchange.com/questions/137688",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26991/"
] | That's a freaking bad practice I must say. Spent last two hours finding a solution to remove actions and filters added via Anonymous functions.
This is the code used on a Parent Theme, and I need to remove it.
```
/**
* Add custom columns to admin comments grid
* * Rate that user set.
*/
add_filter( 'manage_edit... | The problem is that you can't distinguish form an anonymous function and another, so yes, it is possible to remove a closure (i.e. anonymous function) but **if more than one closure act on same filter at same priority you have to make a choice, remove them all, ore remove only one** (without knowing exactly which).
I'... |
137,697 | <p>As a noob I dont understand a lot of SQL injections but I need to be save so I have read that I have to use wpdb->prepare to make sure the data is stored correct.</p>
<p>At this moment I use the $wpdb->update() query so I need some help to transform this into an save query with $wpdb->prepare().</p>
<pre><code>$wp... | [
{
"answer_id": 137705,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 3,
"selected": true,
"text": "<p>When you look at the <a href=\"https://codex.wordpress.org/Class_Reference/wpdb#UPDATE_rows\" rel=\"nofollow\">Code... | 2014/03/12 | [
"https://wordpress.stackexchange.com/questions/137697",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47687/"
] | As a noob I dont understand a lot of SQL injections but I need to be save so I have read that I have to use wpdb->prepare to make sure the data is stored correct.
At this moment I use the $wpdb->update() query so I need some help to transform this into an save query with $wpdb->prepare().
```
$wpdb->update('custom_ta... | When you look at the [Codex article on `$wpdb`](https://codex.wordpress.org/Class_Reference/wpdb#UPDATE_rows), then you will see that your current usage is correct. The last argument
```
array( '%s', '%d', '%s' )
```
already indicates that there is something like `sprintf/printf` going on in the background.
The `$w... |
137,700 | <p>I know this code is incorrect, but it's a basis of what I am trying to achieve.</p>
<p>I am parsing an xml feed via PHP and running a foreach loop to get a value from a specific key.</p>
<p>Here is the snippet I am using:</p>
<pre><code>$feed = file_get_contents("https://www.feedurl.com/xml"); // Feed URL
$xml = ... | [
{
"answer_id": 137705,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 3,
"selected": true,
"text": "<p>When you look at the <a href=\"https://codex.wordpress.org/Class_Reference/wpdb#UPDATE_rows\" rel=\"nofollow\">Code... | 2014/03/12 | [
"https://wordpress.stackexchange.com/questions/137700",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28389/"
] | I know this code is incorrect, but it's a basis of what I am trying to achieve.
I am parsing an xml feed via PHP and running a foreach loop to get a value from a specific key.
Here is the snippet I am using:
```
$feed = file_get_contents("https://www.feedurl.com/xml"); // Feed URL
$xml = new SimpleXmlElement($feed);... | When you look at the [Codex article on `$wpdb`](https://codex.wordpress.org/Class_Reference/wpdb#UPDATE_rows), then you will see that your current usage is correct. The last argument
```
array( '%s', '%d', '%s' )
```
already indicates that there is something like `sprintf/printf` going on in the background.
The `$w... |
137,704 | <p>I want to retrieve an array with the posts of a certain user for a custom post type category.</p>
<p>However, get_posts($arg) returns ALL posts of this custom post type, although I specified the post_author</p>
<pre><code><?php $pages = get_posts(array('post_type' => 'profile','post_author' => $post->... | [
{
"answer_id": 137706,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>As it is totally unclear where <code>$post->post_author</code> comes from, the most likely issue is, that you a... | 2014/03/12 | [
"https://wordpress.stackexchange.com/questions/137704",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48847/"
] | I want to retrieve an array with the posts of a certain user for a custom post type category.
However, get\_posts($arg) returns ALL posts of this custom post type, although I specified the post\_author
```
<?php $pages = get_posts(array('post_type' => 'profile','post_author' => $post->post_author)); ?>
<?php var_du... | [`post_author`](http://codex.wordpress.org/Template_Tags/get_posts#Parameters) is not a valid parameter for `get_posts`. You really need to look at `WP_Query`'s argument list to see that, as `get_posts()` is really [just a wrapper around that class](https://core.trac.wordpress.org/browser/tags/3.8.1/src/wp-includes/pos... |
137,715 | <p>I have got the following code in a javascript(jquery) file called custom.js:</p>
<pre><code> var gapinvite = new Date();
gapinvite = new Date(2014, 06 - 1, 2);
$('.days').countdown({
until: gapinvite,
layout: '{dn} {dl}',
/* Set your timezone */
timezone: +7
});
<... | [
{
"answer_id": 137718,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 2,
"selected": true,
"text": "<p>If you want to re-instantiate your countdown timer only after the date has been changed and saved, then, somethin... | 2014/03/12 | [
"https://wordpress.stackexchange.com/questions/137715",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47174/"
] | I have got the following code in a javascript(jquery) file called custom.js:
```
var gapinvite = new Date();
gapinvite = new Date(2014, 06 - 1, 2);
$('.days').countdown({
until: gapinvite,
layout: '{dn} {dl}',
/* Set your timezone */
timezone: +7
});
```
1.Now i wan... | If you want to re-instantiate your countdown timer only after the date has been changed and saved, then, something to the effect of:
```
//In your custom.js file....
//make sure your localized data is a dependency of your custom.js file so you have proper scope to local data
jQuery(document).ready(function($){
va... |
137,725 | <p>I know that I can use the following filters to enable processing of shortcodes in Text Widgets:</p>
<pre><code>add_filter( 'widget_text', 'shortcode_unautop');
add_filter( 'widget_text', 'do_shortcode');
</code></pre>
<p>How can I only whitelist a few specific shortcodes for processing, but not just process every ... | [
{
"answer_id": 137737,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 3,
"selected": true,
"text": "<pre><code>add_filter( 'widget_text', 'wpse_137725_shortcode_whitelist' );\n\n/**\n * Apply only whitelisted s... | 2014/03/12 | [
"https://wordpress.stackexchange.com/questions/137725",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16666/"
] | I know that I can use the following filters to enable processing of shortcodes in Text Widgets:
```
add_filter( 'widget_text', 'shortcode_unautop');
add_filter( 'widget_text', 'do_shortcode');
```
How can I only whitelist a few specific shortcodes for processing, but not just process every shortcode? | ```
add_filter( 'widget_text', 'wpse_137725_shortcode_whitelist' );
/**
* Apply only whitelisted shortcode to content.
*
* @link http://wordpress.stackexchange.com/q/137725/1685
*
* @param string $text
* @return string
*/
function wpse_137725_shortcode_whitelist( $text ) {
static $whitelist = array(
... |
137,732 | <p>I create a single page website and use only anchors (#) on main menu items.</p>
<p>Now, I need to include a second page on the website and keep the same menu.</p>
<p>I'm using roots theme. Then, I'm building menu using:</p>
<pre><code>wp_nav_menu(array('theme_location' => 'primary_navigation'));
</code></pre>... | [
{
"answer_id": 137736,
"author": "gdaniel",
"author_id": 30984,
"author_profile": "https://wordpress.stackexchange.com/users/30984",
"pm_score": 4,
"selected": true,
"text": "<p>In your template you can check whether you're on the front-page or not and then echo out a different menu.</p>... | 2014/03/12 | [
"https://wordpress.stackexchange.com/questions/137732",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38553/"
] | I create a single page website and use only anchors (#) on main menu items.
Now, I need to include a second page on the website and keep the same menu.
I'm using roots theme. Then, I'm building menu using:
```
wp_nav_menu(array('theme_location' => 'primary_navigation'));
```
But how to change items url from, for ... | In your template you can check whether you're on the front-page or not and then echo out a different menu.
For example:
```
if(is_front_page() || is_home()){
wp_nav_menu(array('theme_location' => 'primary_navigation'));
}else{
wp_nav_menu(array('theme_location' => 'secondary_navigation'));
}
```
You would als... |
137,738 | <p>Whenever adding an empty line between paragraphs using TinyMCE, the <code>&nbsp;</code> character entity is added. </p>
<p>How can I strip the content of all instances of this character whenever an author updates their post (<code>save_post</code>)?</p>
| [
{
"answer_id": 137739,
"author": "Christine Cooper",
"author_id": 24875,
"author_profile": "https://wordpress.stackexchange.com/users/24875",
"pm_score": 4,
"selected": true,
"text": "<p>Figured it out, hooking into <code>content_save_pre</code>:</p>\n\n<pre><code>function remove_empty_l... | 2014/03/12 | [
"https://wordpress.stackexchange.com/questions/137738",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24875/"
] | Whenever adding an empty line between paragraphs using TinyMCE, the ` ` character entity is added.
How can I strip the content of all instances of this character whenever an author updates their post (`save_post`)? | Figured it out, hooking into `content_save_pre`:
```
function remove_empty_lines( $content ){
// replace empty lines
$content = preg_replace("/ /", "", $content);
return $content;
}
add_action('content_save_pre', 'remove_empty_lines');
``` |
137,792 | <p>I have a page that loads a lot of featured items in a grid. There are up to 56 images loading, and it does have a bit of a delay.
This is the code as it runs now:</p>
<pre><code>if( count( $postslist ) > 0 ) {
foreach ($postslist as $post) : setup_postdata($post);
?>
<div class='oneCell'>
<... | [
{
"answer_id": 140802,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 1,
"selected": false,
"text": "<p>It is quite difficult to understand what you have done. One of my concerns is using <code>get_the_post_... | 2014/03/13 | [
"https://wordpress.stackexchange.com/questions/137792",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48870/"
] | I have a page that loads a lot of featured items in a grid. There are up to 56 images loading, and it does have a bit of a delay.
This is the code as it runs now:
```
if( count( $postslist ) > 0 ) {
foreach ($postslist as $post) : setup_postdata($post);
?>
<div class='oneCell'>
<?php
$image = get_the_p... | The answer is **eager loading** or **cache** or both.
Eager loading
-------------
Have a look to this pseudo-code:
```
$ids = get_ids_from_a_db_table();
foreach ( $ids as $id ) {
$row = get_row_from_foreign_table_using( $id );
echo "Row title for the ID: $id is $row->title";
}
```
If the number of `$ids` is `n... |
137,808 | <ol>
<li>I have a <strong>custom post type</strong> called "link"</li>
<li>I have a <strong>custom taxonomy</strong> for this post type called "link-category"</li>
<li>I have a <strong>template file</strong> for this taxonomy, "taxonomy-link-category.php"</li>
<li>I need the template to display the posts of the selecte... | [
{
"answer_id": 137810,
"author": "jdm2112",
"author_id": 45202,
"author_profile": "https://wordpress.stackexchange.com/users/45202",
"pm_score": 1,
"selected": false,
"text": "<p>Yes. But I'm afraid I am misunderstanding your intent.</p>\n\n<p>Have you tried: </p>\n\n<pre><code>$args = ... | 2014/03/13 | [
"https://wordpress.stackexchange.com/questions/137808",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40679/"
] | 1. I have a **custom post type** called "link"
2. I have a **custom taxonomy** for this post type called "link-category"
3. I have a **template file** for this taxonomy, "taxonomy-link-category.php"
4. I need the template to display the posts of the selected link category in **alphabetical order**
**EDIT**: On the LIN... | Use the [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) action to modify the query before it is run. Place this in your theme's `functions.php`:
```
function wpd_tax_alpha( $query ) {
if ( $query->is_tax('link-category') && $query->is_main_query() ) {
$query->set( 'o... |
137,822 | <p>How would I be able to insert data into the post meta table? I know how querying and wpdb works but I have no idea how I can just insert it into the table.</p>
<p>I have these two fields I want to insert ID and Title where Title should become a new post in my Custom Post type Company and ID should be the Content of... | [
{
"answer_id": 137826,
"author": "Praveen",
"author_id": 26393,
"author_profile": "https://wordpress.stackexchange.com/users/26393",
"pm_score": 1,
"selected": false,
"text": "<p>You can execute any query as follows and check for success , Let me know if it works.</p>\n\n<p>Praveen</p>\n... | 2014/03/13 | [
"https://wordpress.stackexchange.com/questions/137822",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48416/"
] | How would I be able to insert data into the post meta table? I know how querying and wpdb works but I have no idea how I can just insert it into the table.
I have these two fields I want to insert ID and Title where Title should become a new post in my Custom Post type Company and ID should be the Content of it. I unf... | You do not need to use the `post_meta` here, as all the Information is available in `posts`.
To insert a new post, use `wp_insert_post( $post )`, and pass the arguments to your `$post`-array. This function can return a `WP_Error`-object for Error handling (if the second argument is set to `true`, returns 0 on error if... |
137,845 | <p>As i want to manage the NULL fields in my db and wordpress functions doesn't allow to do so, i will need to dynamically generate a query depending on the situation. The problem is that i don't know how to pass a variable number of fields as second argument! this is what i've been tr but it returns an "Empty query" e... | [
{
"answer_id": 137826,
"author": "Praveen",
"author_id": 26393,
"author_profile": "https://wordpress.stackexchange.com/users/26393",
"pm_score": 1,
"selected": false,
"text": "<p>You can execute any query as follows and check for success , Let me know if it works.</p>\n\n<p>Praveen</p>\n... | 2014/03/13 | [
"https://wordpress.stackexchange.com/questions/137845",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44452/"
] | As i want to manage the NULL fields in my db and wordpress functions doesn't allow to do so, i will need to dynamically generate a query depending on the situation. The problem is that i don't know how to pass a variable number of fields as second argument! this is what i've been tr but it returns an "Empty query" erro... | You do not need to use the `post_meta` here, as all the Information is available in `posts`.
To insert a new post, use `wp_insert_post( $post )`, and pass the arguments to your `$post`-array. This function can return a `WP_Error`-object for Error handling (if the second argument is set to `true`, returns 0 on error if... |
137,879 | <p>I'm showing posts of the term 'football' belonging to the taxonomy 'section', and everything works perfectly but
Where can I specify the number of posts I want to show? </p>
<p>just like this: 'showposts' => 3</p>
<p>I do not know where to put it</p>
<pre><code> $myquery['tax_query'] = array(
... | [
{
"answer_id": 137884,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 0,
"selected": false,
"text": "<p>You want <code>posts_per_page</code> instead:</p>\n\n<pre><code>$myquery = array(\n 'posts_per_page' =&... | 2014/03/13 | [
"https://wordpress.stackexchange.com/questions/137879",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48707/"
] | I'm showing posts of the term 'football' belonging to the taxonomy 'section', and everything works perfectly but
Where can I specify the number of posts I want to show?
just like this: 'showposts' => 3
I do not know where to put it
```
$myquery['tax_query'] = array(
array(
... | Never user `query_posts`, under any circumstances. Use `WP_Query` instead, which is how query\_posts works internally, but without the trickery and downsides.
You'll also find that the WP\_Query documentation gives you explanations for every parameter, including what you are trying to do:
>
> **posts\_per\_page (int... |
137,886 | <p>I'm trying to include selectivizr.js inside conditional comments. What am I doing wrong here?</p>
<pre><code><!DOCTYPE html>
<html class="no-js" <?php language_attributes(); ?>>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>... | [
{
"answer_id": 137887,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>Change</p>\n<pre><code><!--[if (gte IE 6)&(lte IE 8)]>\n <?php\n function blarg(){\n ... | 2014/03/13 | [
"https://wordpress.stackexchange.com/questions/137886",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37239/"
] | I'm trying to include selectivizr.js inside conditional comments. What am I doing wrong here?
```
<!DOCTYPE html>
<html class="no-js" <?php language_attributes(); ?>>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title><?php wp_title('|', true, 'right'); ?></title>
<meta ... | Change
```
<!--[if (gte IE 6)&(lte IE 8)]>
<?php
function blarg(){
wp_enqueue_script('selectivizr', get_template_directory_uri() . 'assets/js/vendor/selectivizr.js');
}
add_action('wp_enqueue_scripts', 'blarg', 101);
?>
<![endif]-->
```
to
```
<!--[if (gte IE 6)&(lte IE 8)]>
<script src="<?... |
137,893 | <p>There is a Wordpress function called wp_remove_object_terms that unfortunatly doesn't seem to work.</p>
<p>I am trying to achieve the same ends using the following</p>
<pre><code> $post_terms = wp_get_object_terms( $post_id, $taxonomy );
if( $post_terms ){
if(($key = array... | [
{
"answer_id": 137899,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>Your issue is last argument in <a href=\"http://queryposts.com/function/wp_set_object_terms/\" rel=\"nofollow\"><co... | 2014/03/13 | [
"https://wordpress.stackexchange.com/questions/137893",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48927/"
] | There is a Wordpress function called wp\_remove\_object\_terms that unfortunatly doesn't seem to work.
I am trying to achieve the same ends using the following
```
$post_terms = wp_get_object_terms( $post_id, $taxonomy );
if( $post_terms ){
if(($key = array_search($term_id, $p... | Your issue is last argument in [`wp_set_object_terms()`](http://queryposts.com/function/wp_set_object_terms/) call. You are setting `$append` to `true`, so it essentially checks if input is already present and does nothing else.
You want it set to `false` (which is also default) so that terms are *forced* to be same a... |
137,951 | <p>I want to give my editors access to a settings page to a plugin I've installed on their website. As of now, it's only visible to Administrators.</p>
<p>The plugin I'm using is uTubeVideo Gallery, and there is no option to give users other than administrators access.</p>
<p>In his admin.php I found these lines, whi... | [
{
"answer_id": 137952,
"author": "Laukik Patel",
"author_id": 48891,
"author_profile": "https://wordpress.stackexchange.com/users/48891",
"pm_score": 0,
"selected": false,
"text": "<p>Try with</p>\n\n<pre><code>public function addMenus()\n{\n add_menu_page('uTubeVideo', 'uTubeVideo', '... | 2014/03/14 | [
"https://wordpress.stackexchange.com/questions/137951",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16605/"
] | I want to give my editors access to a settings page to a plugin I've installed on their website. As of now, it's only visible to Administrators.
The plugin I'm using is uTubeVideo Gallery, and there is no option to give users other than administrators access.
In his admin.php I found these lines, which I know creates... | The `manage_options` argument you see in both function calls is a capability. That particular capability makes the page accessible [only to administrators](https://codex.wordpress.org/Roles_and_Capabilities#Administrator).
To make this work, you could change that to [one of the editor capabilities](https://codex.wordp... |
137,953 | <p>You do not have sufficient permissions to access this page. This is the error i am facing while making my own plugin.Actually, i want to link to another page.</p>
<p>Wordpress version is 3.8.1
I made a plugin that shows the following display(the index page of my crud plugin)
<img src="https://i.stack.imgur.com/gwxN... | [
{
"answer_id": 137952,
"author": "Laukik Patel",
"author_id": 48891,
"author_profile": "https://wordpress.stackexchange.com/users/48891",
"pm_score": 0,
"selected": false,
"text": "<p>Try with</p>\n\n<pre><code>public function addMenus()\n{\n add_menu_page('uTubeVideo', 'uTubeVideo', '... | 2014/03/14 | [
"https://wordpress.stackexchange.com/questions/137953",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48960/"
] | You do not have sufficient permissions to access this page. This is the error i am facing while making my own plugin.Actually, i want to link to another page.
Wordpress version is 3.8.1
I made a plugin that shows the following display(the index page of my crud plugin)
.
To make this work, you could change that to [one of the editor capabilities](https://codex.wordp... |
137,968 | <p>I'd already come across a case where Wordpress added <code><p></code> tags. However now I'm dealing with the opposite situation. When I add [] shortcodes inside <code><p></code> tags WordPress automatically removes <code><p></code> tags.</p>
<pre><code><p>[anyshortcode]Hello World[/anyshortc... | [
{
"answer_id": 138009,
"author": "Jack",
"author_id": 44253,
"author_profile": "https://wordpress.stackexchange.com/users/44253",
"pm_score": -1,
"selected": false,
"text": "<p>Append this to your functions.php file within your theme's folder. </p>\n\n<pre><code>remove_filter( 'the_co... | 2014/03/14 | [
"https://wordpress.stackexchange.com/questions/137968",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2488/"
] | I'd already come across a case where Wordpress added `<p>` tags. However now I'm dealing with the opposite situation. When I add [] shortcodes inside `<p>` tags WordPress automatically removes `<p>` tags.
```
<p>[anyshortcode]Hello World[/anyshortcode]</p>
```
Becomes:
```
Hello World
```
Adding dir="ltr" to `<p>... | This is pretty much what Foxsk8 mentioned in a comment, so credit should go to him, but these additional instructions will be useful. The WordPress plugin called [TinyMCE Advanced](https://wordpress.org/plugins/tinymce-advanced/) will solve your problem.
This plugin comes with an option inside `Settings > TinyMCE Adva... |
137,986 | <p>With WordPress 3.9 coming soon it's bringing along TinyMCE 4.0. I'm running my plugins and functions through some testing and found that one of my functions seems broken / not working with the new TinyMCE</p>
<pre><code>function myformatTinyMCE( $in )
{
$in['theme_advanced_buttons1'] = 'bold';
$in['theme_adv... | [
{
"answer_id": 138018,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 3,
"selected": false,
"text": "<p>One change is that:</p>\n\n<p><code>theme_advanced_buttons1</code> is going to be changed to:</p>\n\n<p><co... | 2014/03/14 | [
"https://wordpress.stackexchange.com/questions/137986",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7355/"
] | With WordPress 3.9 coming soon it's bringing along TinyMCE 4.0. I'm running my plugins and functions through some testing and found that one of my functions seems broken / not working with the new TinyMCE
```
function myformatTinyMCE( $in )
{
$in['theme_advanced_buttons1'] = 'bold';
$in['theme_advanced_buttons... | The strings was new, not more for your requirements.
This is the new content of the hook.
```
array (
'selector' => '#content',
'resize' => 'vertical',
'menubar' => false,
'wpautop' => true,
'indent' => false,
'toolbar1' => 'template,|,bold,italic,strikethrough,bullist,numlist,blockquote,hr,alignleft,alig... |
137,987 | <p>Ok here's the scenario:
I have added a custom section to an existing theme so that it shows up in the theme customization page (customize.php).
The problem I am having is that I don't know how to notify wordpress when changes are made in my custom control. I guess I am missing something in my code because it should... | [
{
"answer_id": 138018,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 3,
"selected": false,
"text": "<p>One change is that:</p>\n\n<p><code>theme_advanced_buttons1</code> is going to be changed to:</p>\n\n<p><co... | 2014/03/14 | [
"https://wordpress.stackexchange.com/questions/137987",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48976/"
] | Ok here's the scenario:
I have added a custom section to an existing theme so that it shows up in the theme customization page (customize.php).
The problem I am having is that I don't know how to notify wordpress when changes are made in my custom control. I guess I am missing something in my code because it should do... | The strings was new, not more for your requirements.
This is the new content of the hook.
```
array (
'selector' => '#content',
'resize' => 'vertical',
'menubar' => false,
'wpautop' => true,
'indent' => false,
'toolbar1' => 'template,|,bold,italic,strikethrough,bullist,numlist,blockquote,hr,alignleft,alig... |
137,993 | <p>I am using the following code to display my custom taxonomy slugs. However it is only displaying the first category and not all the related categories. I know this is fairly simple and is to do with [0] but I can't figure out how to change it.</p>
<pre><code>$getslugid = wp_get_post_terms( $post->ID, 'opd_taggal... | [
{
"answer_id": 137995,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 3,
"selected": true,
"text": "<p>This is more of a PHP question, but the solution is simple - you need to use a <a href=\"http://de3.php.net/man... | 2014/03/14 | [
"https://wordpress.stackexchange.com/questions/137993",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45403/"
] | I am using the following code to display my custom taxonomy slugs. However it is only displaying the first category and not all the related categories. I know this is fairly simple and is to do with [0] but I can't figure out how to change it.
```
$getslugid = wp_get_post_terms( $post->ID, 'opd_taggallery' );
$getslu... | This is more of a PHP question, but the solution is simple - you need to use a [`foreach`](http://de3.php.net/manual/en/control-structures.foreach.php)-loop on `$getslug`, because you just echo the slug of the first taxonomy.
The function `wp_get_post_terms()` does not return a single object, but an array of objects. ... |
137,998 | <p>I have a simple shortcode like this....</p>
<pre><code>function myshortcode( $attributes, $content = null ) {
extract( shortcode_atts( array(
'class' => ''
), $attributes ) );
return 'This is the content : ' . $content . ';
}
add_shortcode('my_shortcode', 'myshortcode');
</code></pre>
... | [
{
"answer_id": 137995,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 3,
"selected": true,
"text": "<p>This is more of a PHP question, but the solution is simple - you need to use a <a href=\"http://de3.php.net/man... | 2014/03/14 | [
"https://wordpress.stackexchange.com/questions/137998",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10247/"
] | I have a simple shortcode like this....
```
function myshortcode( $attributes, $content = null ) {
extract( shortcode_atts( array(
'class' => ''
), $attributes ) );
return 'This is the content : ' . $content . ';
}
add_shortcode('my_shortcode', 'myshortcode');
```
This works great and if I... | This is more of a PHP question, but the solution is simple - you need to use a [`foreach`](http://de3.php.net/manual/en/control-structures.foreach.php)-loop on `$getslug`, because you just echo the slug of the first taxonomy.
The function `wp_get_post_terms()` does not return a single object, but an array of objects. ... |
138,001 | <p>I recently completed a WP site for a client and they would like to be able have some static pages added to the site that do not have the header, footer and navigation on it. These pages would then be brought in to various other sites using an iFrame. Being fairly new to WP, I am not exactly sure how to make this hap... | [
{
"answer_id": 137995,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 3,
"selected": true,
"text": "<p>This is more of a PHP question, but the solution is simple - you need to use a <a href=\"http://de3.php.net/man... | 2014/03/14 | [
"https://wordpress.stackexchange.com/questions/138001",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48611/"
] | I recently completed a WP site for a client and they would like to be able have some static pages added to the site that do not have the header, footer and navigation on it. These pages would then be brought in to various other sites using an iFrame. Being fairly new to WP, I am not exactly sure how to make this happen... | This is more of a PHP question, but the solution is simple - you need to use a [`foreach`](http://de3.php.net/manual/en/control-structures.foreach.php)-loop on `$getslug`, because you just echo the slug of the first taxonomy.
The function `wp_get_post_terms()` does not return a single object, but an array of objects. ... |
138,054 | <p>I have very simple file with one line:</p>
<pre><code>echo file_get_contents( get_template_directory_uri().'/scheduler.php' );
</code></pre>
<p>This file is called by cpanel cron using php -q. When I put full link without get_template_directory_uri function everything works fine, with this function cron returns Ca... | [
{
"answer_id": 138057,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 1,
"selected": false,
"text": "<p>Because you need to load WordPress first!</p>\n\n<pre><code>require 'path/to/wordpress/wp-load.php';\n</co... | 2014/03/15 | [
"https://wordpress.stackexchange.com/questions/138054",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28694/"
] | I have very simple file with one line:
```
echo file_get_contents( get_template_directory_uri().'/scheduler.php' );
```
This file is called by cpanel cron using php -q. When I put full link without get\_template\_directory\_uri function everything works fine, with this function cron returns Call to undefined functio... | When you run things on the CLI (which is pretty much where Cronjob and [runwhen](http://code.dogmap.org/runwhen/) jobs are running), then you don't have access to some things like some server or request variable contents, etc. What you need to do is fire up WP Core. Else you won't have access to the full WP API.
One m... |
138,068 | <p>I am a WP beginner and see the potential of the "Meta Box" plugin (<a href="http://wordpress.org/plugins/meta-box/" rel="nofollow">http://wordpress.org/plugins/meta-box/</a>). I have already activated the plugin. So far I managed to upload the demo.php and to display the various meta boxes in the blog post window.</... | [
{
"answer_id": 138149,
"author": "Max",
"author_id": 49034,
"author_profile": "https://wordpress.stackexchange.com/users/49034",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"http://wptheming.com/2010/08/custom-metabox-for-post-type/\" rel=\"nofollow\">This tutorial</a> might b... | 2014/03/15 | [
"https://wordpress.stackexchange.com/questions/138068",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48132/"
] | I am a WP beginner and see the potential of the "Meta Box" plugin (<http://wordpress.org/plugins/meta-box/>). I have already activated the plugin. So far I managed to upload the demo.php and to display the various meta boxes in the blog post window.
I have already read the documentation, but still I don't know how to ... | In this instance you would need to find the hook into the specific metabox and add your custom post type to its `pages` array, for example:
```
$meta_boxes['test_metabox'] = array(
'id' => 'test_metabox',
'title' => 'Test Metabox',
'pages' => array('post','page','artists'), //list custom post types here!
... |
138,088 | <p>I find it annoying that functions like <code>get_user_meta</code> or <code>get_post_meta</code> will return an array if the meta key exists or false if it doesn't. This means I need to do a check like so:</p>
<pre><code>$meta = get_post_meta($id, $meta_key);
if ($meta) {
foreach ($meta as $value) {
// .... | [
{
"answer_id": 138089,
"author": "M Miller",
"author_id": 42675,
"author_profile": "https://wordpress.stackexchange.com/users/42675",
"pm_score": 1,
"selected": false,
"text": "<p>I normalize the output of these functions using this logic:</p>\n\n<ol>\n<li>Cast the value to an array. If ... | 2014/03/16 | [
"https://wordpress.stackexchange.com/questions/138088",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/42675/"
] | I find it annoying that functions like `get_user_meta` or `get_post_meta` will return an array if the meta key exists or false if it doesn't. This means I need to do a check like so:
```
$meta = get_post_meta($id, $meta_key);
if ($meta) {
foreach ($meta as $value) {
// ...
}
}
```
I was hoping for a ... | I normalize the output of these functions using this logic:
1. Cast the value to an array. If it is not an array already, it will be converted to an array with one element, which is the value it was, e.g. `(array) false` becomes `array (false)`.
2. Use `array_filter`, which, when not passed a callable, simply filters ... |
138,097 | <p>I'd like to be able to filter my sidebar widgets (tag cloud, category, archive) to only show those tags/categories/months that apply to a given author on the author template.</p>
<p>What is the correct way to filter or modify these widgets? I found <a href="http://codex.wordpress.org/Plugin_API/Filter_Reference#Wid... | [
{
"answer_id": 138552,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>There is no built in way to do this, and I don't know that it's been tried before. That being said, the tools are... | 2014/03/16 | [
"https://wordpress.stackexchange.com/questions/138097",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12870/"
] | I'd like to be able to filter my sidebar widgets (tag cloud, category, archive) to only show those tags/categories/months that apply to a given author on the author template.
What is the correct way to filter or modify these widgets? I found [this page](http://codex.wordpress.org/Plugin_API/Filter_Reference#Widgets) i... | It's a bit unwieldy to just grab all posts by an author and filter through them to only return a category list. If you wish to use the default widgets in the sidebar and have them filtered by the author only on the author template then I'd suggest using the following approach.
First, filter the tag and category widge... |
138,098 | <p>How can I add favicon to my WordPress site in both front end, and admin panel. I've tried many ways, but failed.</p>
<p>I know, to show favicon the code is:</p>
<pre><code><link rel="shortcut icon" href="images/favicon.ico" />
</code></pre>
<p>How can I implement it?</p>
| [
{
"answer_id": 138099,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 4,
"selected": true,
"text": "<h1>Update</h1>\n\n<p>The following workaround is necessary for users who are using WordPress <strong>olde... | 2014/03/16 | [
"https://wordpress.stackexchange.com/questions/138098",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22728/"
] | How can I add favicon to my WordPress site in both front end, and admin panel. I've tried many ways, but failed.
I know, to show favicon the code is:
```
<link rel="shortcut icon" href="images/favicon.ico" />
```
How can I implement it? | Update
======
The following workaround is necessary for users who are using WordPress **older than version 4.4**. If you are using WordPress v4.4+ then you don't need to go for such an extensive work-around. Simply follow the Usman Siddiqui's answer, and it's *that* easy.
Actual Answer
=============
You can add a fa... |
138,101 | <p>I created a Custom Post Type, and here's the entire code:</p>
<pre><code>// Register Custom Post Type
function wrestler_register() {
$labels = array(
'name' => _x( 'Wrestlers', 'Post Type General Name', 'text_domain' ),
'singular_name' => _x( 'Wrestler', 'Post Type Si... | [
{
"answer_id": 138103,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 2,
"selected": true,
"text": "<p>For some reason wordpress don't honor <a href=\"http://codex.wordpress.org/Template_Hierarchy\" rel=\"no... | 2014/03/16 | [
"https://wordpress.stackexchange.com/questions/138101",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33233/"
] | I created a Custom Post Type, and here's the entire code:
```
// Register Custom Post Type
function wrestler_register() {
$labels = array(
'name' => _x( 'Wrestlers', 'Post Type General Name', 'text_domain' ),
'singular_name' => _x( 'Wrestler', 'Post Type Singular Name', 'text_... | For some reason wordpress don't honor [Template\_Hierarchy](http://codex.wordpress.org/Template_Hierarchy). The best way to get around this problem is to "force" wordpress to use the custom single.php template that you created. To accomplish that, add the following function underneath your CPT.
```
/* Information ... |
138,136 | <p>I'm trying to enqueue my "scripts.js" located at the root folder of my child theme. I don't understand why the following code (located in "functions.php") doesn't work:</p>
<pre><code>function enqueue_scripts() {
if ( ! is_admin() ) {
$scriptsrc = bloginfo('stylesheet_directory') . '/scripts.js';
wp_re... | [
{
"answer_id": 138145,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 0,
"selected": false,
"text": "<p>The reason your function does not work is because you use <code>bloginfo</code> in variable assignment. The <code>... | 2014/03/16 | [
"https://wordpress.stackexchange.com/questions/138136",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11634/"
] | I'm trying to enqueue my "scripts.js" located at the root folder of my child theme. I don't understand why the following code (located in "functions.php") doesn't work:
```
function enqueue_scripts() {
if ( ! is_admin() ) {
$scriptsrc = bloginfo('stylesheet_directory') . '/scripts.js';
wp_register_script(... | Technically, your problem (as already pointed out) is that you are using a function that `echo`s instead of `return`s your path. However, the use of `bloginfo`/`get_bloginfo` to retrieve theme directory paths is long since discouraged.
>
> * '**stylesheet\_url'** - Displays the primary CSS (usually
> *style.css*) fi... |
138,144 | <p>I added the following code to my <code>functions.php</code>:</p>
<pre><code>if(!function_exists('bi_frontend_scripts')) {
function bi_frontend_scripts() {
wp_enqueue_script('jquery');
// I originally wanted to do:
wp_enqueue_script('jQuery.bxSlider', get_bloginfo('template_url').'/script... | [
{
"answer_id": 138147,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 4,
"selected": true,
"text": "<p>Your code is correct, though I would not add the callback if the function name has already been used. If some... | 2014/03/16 | [
"https://wordpress.stackexchange.com/questions/138144",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31527/"
] | I added the following code to my `functions.php`:
```
if(!function_exists('bi_frontend_scripts')) {
function bi_frontend_scripts() {
wp_enqueue_script('jquery');
// I originally wanted to do:
wp_enqueue_script('jQuery.bxSlider', get_bloginfo('template_url').'/scripts/jquery.bxslider/jquery.... | Your code is correct, though I would not add the callback if the function name has already been used. If someone else has used the name you don't know what you might be adding.
```
if(!function_exists('bi_frontend_scripts')) {
function bi_frontend_scripts() {
wp_enqueue_script('jquery');
// I origi... |
138,167 | <p>I've been following <a href="http://code.tutsplus.com/tutorials/guide-to-creating-your-own-wordpress-editor-buttons--wp-30182" rel="noreferrer">a tutorial</a> on Tuts+ (linked from the WordPress Codex) on how to interact with the TinyMCE editor to add buttons. Following the example code on that article, I have a JS ... | [
{
"answer_id": 138169,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 3,
"selected": false,
"text": "<h2>Add Dashicon</h2>\n\n<p>All buttons inside the TinyMCE have a class, also your custom button. Include (use <code... | 2014/03/16 | [
"https://wordpress.stackexchange.com/questions/138167",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10238/"
] | I've been following [a tutorial](http://code.tutsplus.com/tutorials/guide-to-creating-your-own-wordpress-editor-buttons--wp-30182) on Tuts+ (linked from the WordPress Codex) on how to interact with the TinyMCE editor to add buttons. Following the example code on that article, I have a JS file which adds the buttons to ... | To style the icons using the Dashicons CSS files that are already loaded in the WP dashboard requires adding some extra CSS. In the latest beta of Wordpress (3.9), TinyMCE 4.0 is used so I'm not sure this will work on earlier versions (however a modified version may suit, adjusting for the different classes outputted b... |
138,172 | <p>Hi I am adding options to WP Customize.</p>
<p>Mostly everything works, but One of my variable is not refreshed in the preview window.</p>
<pre><code>$wp_customize->add_setting('checkbox', array(
'capability' => 'edit_theme_options',
'default' => false,
));
$wp_customize->add_contr... | [
{
"answer_id": 138174,
"author": "MBL",
"author_id": 10238,
"author_profile": "https://wordpress.stackexchange.com/users/10238",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried explicitly adding the <code>'transport'</code> option when you call <code>$wp_customize->add_se... | 2014/03/16 | [
"https://wordpress.stackexchange.com/questions/138172",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43506/"
] | Hi I am adding options to WP Customize.
Mostly everything works, but One of my variable is not refreshed in the preview window.
```
$wp_customize->add_setting('checkbox', array(
'capability' => 'edit_theme_options',
'default' => false,
));
$wp_customize->add_control('checkbox_control', array(
... | A likely reason you are not able to see the change in the preview is that your `coming-soon.php` template doesn't include the requisite `wp_head()` an `wp_footer()` calls being made. If you look at your browser's DOM, you should actually see that a secondary `iframe` is getting created behind the visible `iframe`. Howe... |
138,206 | <p>WORDPRESS VERSION: 3.8.1
PHP version: 5.3</p>
<p>I have a trouble with wordpress posts. How can I remove the auto P tags added?
This is my final html code:</p>
<pre><code><div class="one_half_style_4_last">
<p>
<p>
<ul class="list-green">
<p>
<h4 class="\"pattern-bg-title-grey\""&... | [
{
"answer_id": 138223,
"author": "MBL",
"author_id": 10238,
"author_profile": "https://wordpress.stackexchange.com/users/10238",
"pm_score": 1,
"selected": false,
"text": "<p>The WordPress implementation of the TinyMCE editor <a href=\"https://codex.wordpress.org/TinyMCE#Automatic_use_of... | 2014/03/17 | [
"https://wordpress.stackexchange.com/questions/138206",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44526/"
] | WORDPRESS VERSION: 3.8.1
PHP version: 5.3
I have a trouble with wordpress posts. How can I remove the auto P tags added?
This is my final html code:
```
<div class="one_half_style_4_last">
<p>
<p>
<ul class="list-green">
<p>
<h4 class="\"pattern-bg-title-grey\"">
<span>Livelli Vip</span>
</h4>
<div class="su-table ta... | Ok.... I fixed the second trouble!
The problem was a option in this plugin: SEO Smart Links
I disabled this field: Prevent linking in heading tags (h1,h2,h3,h4,h5,h6) |
138,209 | <p>In my code <code>add_post_meta</code> is ignoring the button around it and is executing anyway. Why is this so?</p>
<p>I've tried the following:</p>
<pre><code><input type="submit" value="Test" id="submit">
$thisid = wp_insert_post ( $post, true);
if(!isset($_POST['submit'])){
if ( is_wp_erro... | [
{
"answer_id": 138223,
"author": "MBL",
"author_id": 10238,
"author_profile": "https://wordpress.stackexchange.com/users/10238",
"pm_score": 1,
"selected": false,
"text": "<p>The WordPress implementation of the TinyMCE editor <a href=\"https://codex.wordpress.org/TinyMCE#Automatic_use_of... | 2014/03/17 | [
"https://wordpress.stackexchange.com/questions/138209",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48416/"
] | In my code `add_post_meta` is ignoring the button around it and is executing anyway. Why is this so?
I've tried the following:
```
<input type="submit" value="Test" id="submit">
$thisid = wp_insert_post ( $post, true);
if(!isset($_POST['submit'])){
if ( is_wp_error($thisid) ) {
return get_... | Ok.... I fixed the second trouble!
The problem was a option in this plugin: SEO Smart Links
I disabled this field: Prevent linking in heading tags (h1,h2,h3,h4,h5,h6) |
138,212 | <p>I'm trying to query wordpress post by using <code>query_posts</code> and trying to save them in an array so that I get retrieve the post from array. This is what I'm doing,</p>
<pre><code> $posts =array();
$args = array('posts_per_page' =>3,'cat' => 3 );
$posts[] = query_posts( $args );
global... | [
{
"answer_id": 138218,
"author": "Ahmad Saad",
"author_id": 49071,
"author_profile": "https://wordpress.stackexchange.com/users/49071",
"pm_score": 1,
"selected": false,
"text": "<p>try to use get_posts instead , as I read in <a href=\"http://codex.wordpress.org/Function_Reference/query_... | 2014/03/17 | [
"https://wordpress.stackexchange.com/questions/138212",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48752/"
] | I'm trying to query wordpress post by using `query_posts` and trying to save them in an array so that I get retrieve the post from array. This is what I'm doing,
```
$posts =array();
$args = array('posts_per_page' =>3,'cat' => 3 );
$posts[] = query_posts( $args );
global $post;
if ( ! empty($posts... | try to use get\_posts instead , as I read in <http://codex.wordpress.org/Function_Reference/query_posts>
you can use this code:
```
global $post;
$args = array('posts_per_page' =>3,'category' => 3 );
$myposts = get_posts( $args );
foreach( $myposts as $post ) :
setup_postdata($post);
the_title()
endforeach;
wp... |
138,243 | <p>i was wondering: it seems a translation must be a translation from english. I mean, the starting file is in english, then you do translations from that.</p>
<p>But what if say, I'm Italian? So the base language is Italian and the others are translations from Italian? Because it's just this: i'd like to have the ori... | [
{
"answer_id": 138249,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 2,
"selected": false,
"text": "<p>Basically all themes out there are written in English, and localizations strings will look something li... | 2014/03/17 | [
"https://wordpress.stackexchange.com/questions/138243",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10381/"
] | i was wondering: it seems a translation must be a translation from english. I mean, the starting file is in english, then you do translations from that.
But what if say, I'm Italian? So the base language is Italian and the others are translations from Italian? Because it's just this: i'd like to have the original PO f... | Ok, I just add an answer to my own question to clarify all the story and solutions.
This also serves for other lang-related issues.
So, what I've got:
* A native multisite installation
* Every site represent a different language
* Every site has it's own theme, child of the main language
* The main language is italia... |
138,251 | <p>I was trying to create a Option Theme Page for my theme and I wasn't able. <br>
Today I found the <a href="http://wptheming.com/options-framework-theme/" rel="nofollow">Option Theme Framework</a> but after some time I really can't understand how to use it. <br>
In particular, I'm able to create a new "field" but I ... | [
{
"answer_id": 138289,
"author": "Bass Jobsen",
"author_id": 31759,
"author_profile": "https://wordpress.stackexchange.com/users/31759",
"pm_score": 0,
"selected": false,
"text": "<p>You have to create a file options.php in your theme's drectory. You can find an example of such a file he... | 2014/03/17 | [
"https://wordpress.stackexchange.com/questions/138251",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47959/"
] | I was trying to create a Option Theme Page for my theme and I wasn't able.
Today I found the [Option Theme Framework](http://wptheming.com/options-framework-theme/) but after some time I really can't understand how to use it.
In particular, I'm able to create a new "field" but I cant'use it.
For example, I ... | I'm pretty sure there is an example in the [Options Framework sample theme](https://github.com/devinsays/options-framework-theme) on how to create a color field. How you use the option data in your theme is a different matter. You can print CSS in the header via `wp_head` hook and use PHP that way. I'm relatively certa... |
138,261 | <p>I'm trying to make a AJAX request on my theme.</p>
<p>I already know wordpress handle AJAX very well, but not directly on theme file. It uses admin-ajax.php for this.</p>
<p>I working on this for a long time and really don't know where to put the code.</p>
<p>I know there need to put information in admin-ajax.php... | [
{
"answer_id": 138289,
"author": "Bass Jobsen",
"author_id": 31759,
"author_profile": "https://wordpress.stackexchange.com/users/31759",
"pm_score": 0,
"selected": false,
"text": "<p>You have to create a file options.php in your theme's drectory. You can find an example of such a file he... | 2014/03/17 | [
"https://wordpress.stackexchange.com/questions/138261",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44779/"
] | I'm trying to make a AJAX request on my theme.
I already know wordpress handle AJAX very well, but not directly on theme file. It uses admin-ajax.php for this.
I working on this for a long time and really don't know where to put the code.
I know there need to put information in admin-ajax.php, function.php and have ... | I'm pretty sure there is an example in the [Options Framework sample theme](https://github.com/devinsays/options-framework-theme) on how to create a color field. How you use the option data in your theme is a different matter. You can print CSS in the header via `wp_head` hook and use PHP that way. I'm relatively certa... |
138,264 | <p>I'm a little bit confused, why I can't include all the terms in tax_query automatically?</p>
<p><strong>My code:</strong></p>
<pre><code>'tax_query' => array(
array(
'taxonomy' => 'city',
'field' => 'slug',
'terms' => array( nyc, boston, london ),
)
)
</code></pre>
... | [
{
"answer_id": 138269,
"author": "Eric Holmes",
"author_id": 23454,
"author_profile": "https://wordpress.stackexchange.com/users/23454",
"pm_score": 1,
"selected": false,
"text": "<p>Firstly, don't use <code>query_posts</code>. Create a new <a href=\"http://codex.wordpress.org/Class_Refe... | 2014/03/17 | [
"https://wordpress.stackexchange.com/questions/138264",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23841/"
] | I'm a little bit confused, why I can't include all the terms in tax\_query automatically?
**My code:**
```
'tax_query' => array(
array(
'taxonomy' => 'city',
'field' => 'slug',
'terms' => array( nyc, boston, london ),
)
)
```
What If I've dozens of cities? Isn't it uncool to add... | Unless you have posts that *don't* have a city aren't you essentially querying all your posts? Anyway, Eric Holmes is correct that you should be using [`WP_Query`](http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters) in lieu of `query_posts()`.
That said, you can get a list of all the terms in a ta... |
138,267 | <p>I was wondering if anyone could help my by explaining if it is possible to enqueue a javascript file only if for example homepage.php is included.</p>
<p>what i have tried to do inside homepage.php:</p>
<pre><code>class homepage_js {
static $add_script;
static function init() {
add_action('init', array(__CLAS... | [
{
"answer_id": 138268,
"author": "Eric Holmes",
"author_id": 23454,
"author_profile": "https://wordpress.stackexchange.com/users/23454",
"pm_score": 0,
"selected": false,
"text": "<p>The most obvious solution that comes to mind, is actually en-queueing the script within the file needed, ... | 2014/03/17 | [
"https://wordpress.stackexchange.com/questions/138267",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48413/"
] | I was wondering if anyone could help my by explaining if it is possible to enqueue a javascript file only if for example homepage.php is included.
what i have tried to do inside homepage.php:
```
class homepage_js {
static $add_script;
static function init() {
add_action('init', array(__CLASS__, 'register_script... | While you can approach it with "what template is loaded", WP isn't engineered for such logic. Template load is *result* of logic processing, not the other way around.
You should check out [Conditional Tags](https://codex.wordpress.org/Conditional_Tags) and determine which logical check applies to your situation.
Othe... |
138,273 | <p>For the editor I would just like to display Pages, Posts, Media and Menus. Is there a way of doing this with the functions file or similar?</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 138276,
"author": "Sean Henderson",
"author_id": 40807,
"author_profile": "https://wordpress.stackexchange.com/users/40807",
"pm_score": 2,
"selected": false,
"text": "<p>If you just want to remove the menu options, you can use the remove_menu_page function in your functio... | 2014/03/17 | [
"https://wordpress.stackexchange.com/questions/138273",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36334/"
] | For the editor I would just like to display Pages, Posts, Media and Menus. Is there a way of doing this with the functions file or similar?
Thanks in advance. | If you just want to remove the menu options, you can use the remove\_menu\_page function in your functions.php file
[remove\_menu\_page](https://codex.wordpress.org/Function_Reference/remove_menu_page)
Add this code to functions.php:
```
function remove_menus(){
remove_menu_page( 'index.php' ); ... |
138,281 | <p>I'm writing a WP plugin that might be called on any page using a simple function call:<code>getDeck(Deck_id)</code> - and i'd like to add my javascript files on pages where this function is called ONLY, as opposed to having it on every page...</p>
<p>What do I do?</p>
| [
{
"answer_id": 138276,
"author": "Sean Henderson",
"author_id": 40807,
"author_profile": "https://wordpress.stackexchange.com/users/40807",
"pm_score": 2,
"selected": false,
"text": "<p>If you just want to remove the menu options, you can use the remove_menu_page function in your functio... | 2014/03/17 | [
"https://wordpress.stackexchange.com/questions/138281",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30662/"
] | I'm writing a WP plugin that might be called on any page using a simple function call:`getDeck(Deck_id)` - and i'd like to add my javascript files on pages where this function is called ONLY, as opposed to having it on every page...
What do I do? | If you just want to remove the menu options, you can use the remove\_menu\_page function in your functions.php file
[remove\_menu\_page](https://codex.wordpress.org/Function_Reference/remove_menu_page)
Add this code to functions.php:
```
function remove_menus(){
remove_menu_page( 'index.php' ); ... |
138,300 | <p>When I call <a href="https://developer.wordpress.org/reference/functions/switch_to_blog/" rel="nofollow noreferrer"><code>switch_to_blog()</code></a> with a blog id, I don’t know whether that blog actually exists. The function returns always <code>true</code>.</p>
<p>Test case:</p>
<pre class="lang-php prettyprint-o... | [
{
"answer_id": 138307,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 5,
"selected": true,
"text": "<p>@G.M.’s idea to cache the check has lead me to the following helper function. I’ve put it into the global namespace to... | 2014/03/18 | [
"https://wordpress.stackexchange.com/questions/138300",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/73/"
] | When I call [`switch_to_blog()`](https://developer.wordpress.org/reference/functions/switch_to_blog/) with a blog id, I don’t know whether that blog actually exists. The function returns always `true`.
Test case:
```php
switch_to_blog(PHP_INT_MAX);
$post = get_post(1);
restore_current_blog();
```
This will result i... | @G.M.’s idea to cache the check has lead me to the following helper function. I’ve put it into the global namespace to have it available everywhere.
The function doesn’t say anything about the blog status, just if it exists and is not marked as deleted. The database query is very fast (0.0001 seconds) and runs just on... |
138,359 | <p>I have created a mailer template for my my single post.</p>
<p>I can view the mailer version of my post using a url variable <code>?mailer</code></p>
<p>I've configured the above using the code below within my <strong>single.php</strong>...</p>
<pre><code>if ( isset($_GET["mailer"]) ) {
get_template_part( ... | [
{
"answer_id": 138371,
"author": "James Kemp",
"author_id": 10681,
"author_profile": "https://wordpress.stackexchange.com/users/10681",
"pm_score": 0,
"selected": false,
"text": "<p>When editing your post, click \"Preview post\". This will take you to a URL with a query string. You shoul... | 2014/03/18 | [
"https://wordpress.stackexchange.com/questions/138359",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11327/"
] | I have created a mailer template for my my single post.
I can view the mailer version of my post using a url variable `?mailer`
I've configured the above using the code below within my **single.php**...
```
if ( isset($_GET["mailer"]) ) {
get_template_part( 'mailer/template', 'post' );
} else {
/**
* @packa... | First, don't use `query_posts()`.
>
> Note: **This function isn't meant to be used by plugins or themes**. As
> explained later, there are better, more performant options to alter
> the main query. **query\_posts() is overly simplistic and problematic** way
> to modify main query of a page by replacing it with new... |
138,362 | <p>The Below syntax removes the "Related products" from appearing on the Single Product page, but what does the 20 stand for ?</p>
<pre><code>remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);
</code></pre>
<p>Thanks.</p>
| [
{
"answer_id": 138366,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>$priority\n (int) (optional) The priority of the function (as defined when the functi... | 2014/03/18 | [
"https://wordpress.stackexchange.com/questions/138362",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26393/"
] | The Below syntax removes the "Related products" from appearing on the Single Product page, but what does the 20 stand for ?
```
remove_action( 'woocommerce_after_single_product_summary', 'woocommerce_output_related_products', 20);
```
Thanks. | 20 is the priority. To remove, must use the same priority as the one that was set in the add\_action. |
138,373 | <p>I run an events company whose website uses a custom post type system for posts (blog), events and tickets all stored as CPT's in the DB.</p>
<p>On the guestlist (which counts 'ticket' custom posts if the event [post] number == current post) I would like to implement a "New Customer" tag to prompt the host to look o... | [
{
"answer_id": 138374,
"author": "helgatheviking",
"author_id": 6477,
"author_profile": "https://wordpress.stackexchange.com/users/6477",
"pm_score": 2,
"selected": false,
"text": "<p>This will query all the ticket posts and update a <code>_ticket_date</code> field. However, I'm not yet ... | 2014/03/18 | [
"https://wordpress.stackexchange.com/questions/138373",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47618/"
] | I run an events company whose website uses a custom post type system for posts (blog), events and tickets all stored as CPT's in the DB.
On the guestlist (which counts 'ticket' custom posts if the event [post] number == current post) I would like to implement a "New Customer" tag to prompt the host to look out for the... | So,
I got round this by actually putting the function to add the meta data on the event pages themselves (in event-single.php). This means that you are not held by the date of the event at the time of the ticket being created should, for example, you change the date of the event. Each time the page is accessed the dat... |
138,385 | <p>I see a lot of plugins using this approach to add a new hook, e.g.</p>
<pre><code>add_action('init', function() {
add_action('SOME_LATER_HOOK', xxx);
add_filter('SOME_LATER_FILTER', yyy);
});
</code></pre>
<p>Why they don't just add the hook directly? I see there are no benefit anyway, e.g. performance</p>
... | [
{
"answer_id": 138390,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>If necessary it is easier to remove one function from <code>init</code> than two (or maybe fifty) from all over.</p... | 2014/03/18 | [
"https://wordpress.stackexchange.com/questions/138385",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16037/"
] | I see a lot of plugins using this approach to add a new hook, e.g.
```
add_action('init', function() {
add_action('SOME_LATER_HOOK', xxx);
add_filter('SOME_LATER_FILTER', yyy);
});
```
Why they don't just add the hook directly? I see there are no benefit anyway, e.g. performance
Why not just
```
add_action('... | If necessary it is easier to remove one function from `init` than two (or maybe fifty) from all over.
It is commonly recommended to not run anything before `init` hook in general, so that's typical starting point even when it isn't forced by *required* technical implications. |
138,395 | <p>I understand you can add extra CSS on top of the parent theme, but how do you remove PHP code from functions.php?</p>
<p>I want to remove the <code>Masonry plugin</code> in <code>twentyfourteen</code> theme, and have located the piece of code on <code>line 254</code>.</p>
<pre><code> if ( is_active_sidebar( 'si... | [
{
"answer_id": 138398,
"author": "kraftner",
"author_id": 47733,
"author_profile": "https://wordpress.stackexchange.com/users/47733",
"pm_score": 2,
"selected": true,
"text": "<p>You can't actually \"remove\" PHP code from the parent theme. What you can do is undo things done there.</p>\... | 2014/03/18 | [
"https://wordpress.stackexchange.com/questions/138395",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48075/"
] | I understand you can add extra CSS on top of the parent theme, but how do you remove PHP code from functions.php?
I want to remove the `Masonry plugin` in `twentyfourteen` theme, and have located the piece of code on `line 254`.
```
if ( is_active_sidebar( 'sidebar-3' ) ) {
wp_enqueue_script( 'jquery-masonry'... | You can't actually "remove" PHP code from the parent theme. What you can do is undo things done there.
The counterpart of `wp_enqueue_script` is `wp_dequeue_script`.
If you put this in your `functions.php` it should remove the `Masonry Plugin` (untested)
```
add_action( 'wp_print_scripts', 'de_script', 100 );
funct... |
138,435 | <p>I've seen this question posted before but not exactly trying to achieve what I want.</p>
<p>Basically what I want is:
If user is not logged in AND is on -this page- OR -this page- OR -this page,
redirect him to -this page- (which is a custom registration page)</p>
<p>I'm tweaking this piece of code, but it's not w... | [
{
"answer_id": 138445,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 4,
"selected": true,
"text": "<p>Your function is fine, but <code>'get_header'</code> it's too late.</p>\n\n<p>Use <code>template_redirect</cod... | 2014/03/19 | [
"https://wordpress.stackexchange.com/questions/138435",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43941/"
] | I've seen this question posted before but not exactly trying to achieve what I want.
Basically what I want is:
If user is not logged in AND is on -this page- OR -this page- OR -this page,
redirect him to -this page- (which is a custom registration page)
I'm tweaking this piece of code, but it's not working. I'll appr... | Your function is fine, but `'get_header'` it's too late.
Use `template_redirect` instead:
```
add_action( 'template_redirect', function() {
if ( is_user_logged_in() || ! is_page() ) return;
$restricted = array( 250, 253 ); // all your restricted pages
if ( in_array( get_queried_object_id(), $restricted ) ) {... |
138,437 | <p>I have already asked a similar question at stackoverflow (<a href="https://stackoverflow.com/questions/22492292/add-filter-in-wordpress-how-do-i-know-if-it-is-run">https://stackoverflow.com/questions/22492292/add-filter-in-wordpress-how-do-i-know-if-it-is-run</a>), but maybe that was the wrong place?</p>
<p>As you ... | [
{
"answer_id": 138712,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 2,
"selected": true,
"text": "<p><code>wp_nav_menu_items</code> aren't mentioned in the codex, so there are no concrete description on ho... | 2014/03/19 | [
"https://wordpress.stackexchange.com/questions/138437",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49151/"
] | I have already asked a similar question at stackoverflow (<https://stackoverflow.com/questions/22492292/add-filter-in-wordpress-how-do-i-know-if-it-is-run>), but maybe that was the wrong place?
As you can see there I am trying to add a search box in the way I have seen recommended:
```
add_filter('wp_nav_menu_items',... | `wp_nav_menu_items` aren't mentioned in the codex, so there are no concrete description on how to use it.
`wp_nav_menu_items` can be found on line 347 in
>
> wp-includes/nav-menu-template.php
>
>
>
```
$items = apply_filters( 'wp_nav_menu_items', $items, $args );
```
within `wp_nav_menu`.
In the [codex](htt... |
138,442 | <p>(I have found some links to customising an initial install like <a href="https://wordpress.stackexchange.com/questions/30659/repeatable-configuration-package">this one</a> and <a href="https://wordpress.stackexchange.com/questions/1714/initialization-script-for-standard-aspects-of-a-wordpress-website/9680#9680">this... | [
{
"answer_id": 138586,
"author": "davidgo",
"author_id": 49155,
"author_profile": "https://wordpress.stackexchange.com/users/49155",
"pm_score": 2,
"selected": false,
"text": "<p>I worked out an easy and elegant way to solve this problem - After doing the installation I can simply use CU... | 2014/03/19 | [
"https://wordpress.stackexchange.com/questions/138442",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49155/"
] | (I have found some links to customising an initial install like [this one](https://wordpress.stackexchange.com/questions/30659/repeatable-configuration-package) and [this one](https://wordpress.stackexchange.com/questions/1714/initialization-script-for-standard-aspects-of-a-wordpress-website/9680#9680), but unless I'm ... | I'd highly recommend [WP-CLI](http://wp-cli.org/) for such tasks. It is a tool that allows installation and configuration of WordPress on the command line.
What you are trying could easily be done:
```
wp core download
wp core config --dbname=<dbname> --dbuser=<dbuser> --dbpass=<dbpass>
wp core install --url=<url> --... |
138,454 | <p>My problem is in my wordpress site only default permalinks is working.. When I change permalinks all pages become not found.. only home page is showing.</p>
<p>When I change permalinks to postname .htaccess content change to</p>
<pre><code># BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBa... | [
{
"answer_id": 138912,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 1,
"selected": false,
"text": "<p>GoDaddy is unique among hosts that I've seen in that the changes you make to .htaccess files don't take place imme... | 2014/03/19 | [
"https://wordpress.stackexchange.com/questions/138454",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49162/"
] | My problem is in my wordpress site only default permalinks is working.. When I change permalinks all pages become not found.. only home page is showing.
When I change permalinks to postname .htaccess content change to
```
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.ph... | GoDaddy is unique among hosts that I've seen in that the changes you make to .htaccess files don't take place immediately. They use some caching system for them in some manner.
Turn on the permalinks and wait a day. It's worked for me in the past when I used to be hosted there. |
138,470 | <p>I'm trying to display a <code>WP_List_table</code> inside a metabox. The metabox is for a custom taxonomy called <code>service</code> which is registered to a custom post type called <code>office</code>. The table columns contain input fields which manipulate the taxonomy and allow me to link additional data to each... | [
{
"answer_id": 140997,
"author": "user2242022",
"author_id": 50241,
"author_profile": "https://wordpress.stackexchange.com/users/50241",
"pm_score": 3,
"selected": true,
"text": "<p>You just need to override the function <code>display_tablenav()</code> with a blank function in you parent... | 2014/03/19 | [
"https://wordpress.stackexchange.com/questions/138470",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8482/"
] | I'm trying to display a `WP_List_table` inside a metabox. The metabox is for a custom taxonomy called `service` which is registered to a custom post type called `office`. The table columns contain input fields which manipulate the taxonomy and allow me to link additional data to each individual taxonomy term. I don't t... | You just need to override the function `display_tablenav()` with a blank function in you parent class.
It is explained [here](http://lukeberndt.com/2012/wp_list_table-and-an-extra-nonce/). |
138,473 | <p>I'm following <a href="http://www.smartinsights.com/google-analytics/optimisation-google-analytics/ab-testing-in-wordpress-with-google-analytics-site-experiments/" rel="noreferrer">this tutorial</a> on adding Google Content Experiments code to <code>header.php</code>.</p>
<p>I added the following code to <code>head... | [
{
"answer_id": 138484,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 3,
"selected": false,
"text": "<p>A simpler solution will be to pass the <code>title</code> or the <code>slug</code> as argument in <a href=\"h... | 2014/03/19 | [
"https://wordpress.stackexchange.com/questions/138473",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3206/"
] | I'm following [this tutorial](http://www.smartinsights.com/google-analytics/optimisation-google-analytics/ab-testing-in-wordpress-with-google-analytics-site-experiments/) on adding Google Content Experiments code to `header.php`.
I added the following code to `header.php`:
```
<?php if (is_page('346') ):?>
<!-- G... | you can use this for
```
<?php
global $post;
if( $post->ID == 346) { ?>
<!-- do your stuff here -->
<?php } ?>
```
you can use this anywhere either in header or anywhere else. |
138,483 | <p>I want to add </p>
<pre><code>[one_third][responsive]
<a href="http://weburl.com/lifestyle">
<img class="aligncenter size-full wp-image-176" alt="courses" src="http://weburl.com/img/buttons/courses.png" width="310" height="109" /></a>
[/responsive][/one_third]
[one_third][responsive]
<a href="h... | [
{
"answer_id": 138484,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 3,
"selected": false,
"text": "<p>A simpler solution will be to pass the <code>title</code> or the <code>slug</code> as argument in <a href=\"h... | 2014/03/19 | [
"https://wordpress.stackexchange.com/questions/138483",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47613/"
] | I want to add
```
[one_third][responsive]
<a href="http://weburl.com/lifestyle">
<img class="aligncenter size-full wp-image-176" alt="courses" src="http://weburl.com/img/buttons/courses.png" width="310" height="109" /></a>
[/responsive][/one_third]
[one_third][responsive]
<a href="http://weburl.com/answers/landing-pa... | you can use this for
```
<?php
global $post;
if( $post->ID == 346) { ?>
<!-- do your stuff here -->
<?php } ?>
```
you can use this anywhere either in header or anywhere else. |
138,529 | <p>I'm trying to create a post slider, but I'm stuck at this point.</p>
<p>I have created a taxonomy named 'slideshow' and a custom post type 'slider'. In this custom post type 'slider' , I have assigned a taxonomy 'slideshow'</p>
<p><img src="https://i.stack.imgur.com/8uGt0.png" alt="enter image description here"><... | [
{
"answer_id": 138532,
"author": "JohnG",
"author_id": 14194,
"author_profile": "https://wordpress.stackexchange.com/users/14194",
"pm_score": 1,
"selected": false,
"text": "<p>I don't have enough rep to comment, but what does your actual query look like?</p>\n\n<p><strong>Edit</strong>:... | 2014/03/19 | [
"https://wordpress.stackexchange.com/questions/138529",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49200/"
] | I'm trying to create a post slider, but I'm stuck at this point.
I have created a taxonomy named 'slideshow' and a custom post type 'slider'. In this custom post type 'slider' , I have assigned a taxonomy 'slideshow'

This working fine, but no matte... | I don't have enough rep to comment, but what does your actual query look like?
**Edit**: I haven't been able to test it, but I think this will work
```
$args = array(
'post_type' => 'slider',
'meta_key' => '_thumbnail_id', // only pull sliders with images
'tax_query' => array(
... |
138,531 | <p>I need to delete some <code>postmeta</code> when deleting taxonomy terms from the backend. Before deleting the <code>term</code>, I need to retrieve the postmeta's <code>meka_key</code> and the term <code>id</code> that is going to be deleted. Use the term <code>id</code> to perform some tasks and then delete the <c... | [
{
"answer_id": 138533,
"author": "passatgt",
"author_id": 8038,
"author_profile": "https://wordpress.stackexchange.com/users/8038",
"pm_score": 2,
"selected": false,
"text": "<p>Actually, you can use multiple actions, at least this is what at the end of the wp_delete_term function, which... | 2014/03/19 | [
"https://wordpress.stackexchange.com/questions/138531",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14128/"
] | I need to delete some `postmeta` when deleting taxonomy terms from the backend. Before deleting the `term`, I need to retrieve the postmeta's `meka_key` and the term `id` that is going to be deleted. Use the term `id` to perform some tasks and then delete the `postmeta` and `term`.
I already tried using the action hoo... | Actually, you can use multiple actions, at least this is what at the end of the wp\_delete\_term function, which runs when you click Delete on a taxonomy term:
```
do_action( 'delete_term_taxonomy', $tt_id );
do_action( 'deleted_term_taxonomy', $tt_id );
do_action( 'delete_term', $term, $tt_id, $taxonomy, $deleted_ter... |
138,539 | <p>I have an array containting these values (including the apostrohpes):</p>
<pre><code>'course_3202','course_3201','course_3200','course_3199'
</code></pre>
<p>I try to fetch results from these values in postmeta-table.</p>
<pre><code>SELECT * FROM wp_postmeta WHERE meta_key IN (%s) and meta_value=1
</code></pre>
... | [
{
"answer_id": 138540,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>You need to have your replacement placeholders matching the number of values in your array, and then you can ... | 2014/03/19 | [
"https://wordpress.stackexchange.com/questions/138539",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38848/"
] | I have an array containting these values (including the apostrohpes):
```
'course_3202','course_3201','course_3200','course_3199'
```
I try to fetch results from these values in postmeta-table.
```
SELECT * FROM wp_postmeta WHERE meta_key IN (%s) and meta_value=1
```
I get no result (*yes, there is data and I sho... | You need to have your replacement placeholders matching the number of values in your array, and then you can use the array as one of the `prepare` arguments.
Proof of concept:
```
$a = array('course_3202','course_3201','course_3200','course_3199');
$b = array_fill(0,count($a),'%s');
$b = implode(',',$b);
$sql = "S... |
138,550 | <p>I'm trying hook the customizer_preview_init action in order to trigger live preview of the changes I'm making in the customizer. However, my first test is failing. I'm just trying to get an alert to fire inside the .js</p>
<p>Any ideas what I'm doing wrong?</p>
<pre><code>//Add customizer.php to admin:
if ( is_adm... | [
{
"answer_id": 138554,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>I wrote a quick plugin to reproduce your problem with a nearly vanilla multisite/network install, running the plug... | 2014/03/19 | [
"https://wordpress.stackexchange.com/questions/138550",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6620/"
] | I'm trying hook the customizer\_preview\_init action in order to trigger live preview of the changes I'm making in the customizer. However, my first test is failing. I'm just trying to get an alert to fire inside the .js
Any ideas what I'm doing wrong?
```
//Add customizer.php to admin:
if ( is_admin() ) :
require_on... | The issue in this case has to do with how I added the customize.php script. I was loading it inside an is\_admin() check (see updated question above where I have included that code branch).
After reading [Otto's post](http://ottopress.com/2012/how-to-leverage-the-theme-customizer-in-your-own-themes/), I realized that... |
138,590 | <p>I am trying to programmatically manipulate the selection of Payment Method between BACS and a No Payment required option. My client wants the ability to Request for Quote only, so I've extended woocommerce actions and filters, and provided a method to request quote through the cart system. If the user has requested ... | [
{
"answer_id": 138598,
"author": "passatgt",
"author_id": 8038,
"author_profile": "https://wordpress.stackexchange.com/users/8038",
"pm_score": 3,
"selected": true,
"text": "<p>Theres a filter called woocommerce_available_payment_gateways:</p>\n\n<pre><code>add_filter('woocommerce_availa... | 2014/03/20 | [
"https://wordpress.stackexchange.com/questions/138590",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49219/"
] | I am trying to programmatically manipulate the selection of Payment Method between BACS and a No Payment required option. My client wants the ability to Request for Quote only, so I've extended woocommerce actions and filters, and provided a method to request quote through the cart system. If the user has requested a q... | Theres a filter called woocommerce\_available\_payment\_gateways:
```
add_filter('woocommerce_available_payment_gateways','filter_gateways',1);
function filter_gateways($gateways){
global $woocommerce;
//Remove a specific payment option
unset($gateways['paypal']);
return $gateways;
}
```
I'm ... |
138,604 | <p>I am trying to get all the Custom Post Types Registered either by theme or plugin, but no method is working.</p>
<pre><code>$postargs = array(
'public' => true,
'_builtin' => false
);
$postoutput = 'names';
$postoperator = 'and';
$post_types = get_post_types( $postargs, 'names', 'and' );
/// Mai... | [
{
"answer_id": 138598,
"author": "passatgt",
"author_id": 8038,
"author_profile": "https://wordpress.stackexchange.com/users/8038",
"pm_score": 3,
"selected": true,
"text": "<p>Theres a filter called woocommerce_available_payment_gateways:</p>\n\n<pre><code>add_filter('woocommerce_availa... | 2014/03/20 | [
"https://wordpress.stackexchange.com/questions/138604",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48957/"
] | I am trying to get all the Custom Post Types Registered either by theme or plugin, but no method is working.
```
$postargs = array(
'public' => true,
'_builtin' => false
);
$postoutput = 'names';
$postoperator = 'and';
$post_types = get_post_types( $postargs, 'names', 'and' );
/// Main Loop Start
foreach... | Theres a filter called woocommerce\_available\_payment\_gateways:
```
add_filter('woocommerce_available_payment_gateways','filter_gateways',1);
function filter_gateways($gateways){
global $woocommerce;
//Remove a specific payment option
unset($gateways['paypal']);
return $gateways;
}
```
I'm ... |
138,609 | <p>I have a page called "Blog" which uses "Default Template" (index.php). It has a featured image. I want to display this image, but when I use get_post_thumbnail_id(), inside or outside the loop, I get the thumbnail of the first post on my blog, not the one of my "Blog" page.</p>
<p>Just in case, in Settings > Readin... | [
{
"answer_id": 138598,
"author": "passatgt",
"author_id": 8038,
"author_profile": "https://wordpress.stackexchange.com/users/8038",
"pm_score": 3,
"selected": true,
"text": "<p>Theres a filter called woocommerce_available_payment_gateways:</p>\n\n<pre><code>add_filter('woocommerce_availa... | 2014/03/20 | [
"https://wordpress.stackexchange.com/questions/138609",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11634/"
] | I have a page called "Blog" which uses "Default Template" (index.php). It has a featured image. I want to display this image, but when I use get\_post\_thumbnail\_id(), inside or outside the loop, I get the thumbnail of the first post on my blog, not the one of my "Blog" page.
Just in case, in Settings > Reading, Post... | Theres a filter called woocommerce\_available\_payment\_gateways:
```
add_filter('woocommerce_available_payment_gateways','filter_gateways',1);
function filter_gateways($gateways){
global $woocommerce;
//Remove a specific payment option
unset($gateways['paypal']);
return $gateways;
}
```
I'm ... |
138,613 | <p>So I have queried out some data from another DB and obviously they're not a <code>post</code> which means I can't use the standard <code>permalink</code> to link them to an existing page with it's <code>post type</code>.
So I thought that if WP could just generate an let's say "artificial" post ID to link to a certa... | [
{
"answer_id": 138616,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 0,
"selected": false,
"text": "<p>What you should do is to create a CPT as a container for displaying your data. For each of the CPT \"post... | 2014/03/20 | [
"https://wordpress.stackexchange.com/questions/138613",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48416/"
] | So I have queried out some data from another DB and obviously they're not a `post` which means I can't use the standard `permalink` to link them to an existing page with it's `post type`.
So I thought that if WP could just generate an let's say "artificial" post ID to link to a certain generated page like any other `cu... | [Add a rewrite rule](http://codex.wordpress.org/Rewrite_API/add_rewrite_rule) and [extra query vars](http://codex.wordpress.org/Plugin_API/Filter_Reference/query_vars) to handle incoming requests, direct the rewrite rule to a single `page` post type, create a [custom page template](http://codex.wordpress.org/Page_Templ... |
138,631 | <p>I've created the plugin that adds custom post type and custom taxonomis for this post type. Templates for the post type and the taxonomies are located in plugin folder. Now I need to add sidebar for the post type and taxonomies pages.
I have the following code to add template for archives page:</p>
<pre><code>// Fi... | [
{
"answer_id": 138623,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 0,
"selected": false,
"text": "<p>Yes, you can delete plugin file via FTP, WordPress will recognize that file is missed and will show you a mes... | 2014/03/20 | [
"https://wordpress.stackexchange.com/questions/138631",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27233/"
] | I've created the plugin that adds custom post type and custom taxonomis for this post type. Templates for the post type and the taxonomies are located in plugin folder. Now I need to add sidebar for the post type and taxonomies pages.
I have the following code to add template for archives page:
```
// Filter the archi... | In ***almost all cases*** you can simply delete the plugin and it will be switched off automatically, and in fact that is advice I've given many times to help reel in broken sites. The same is true for themes.
*Some* plugins are actually more complicated than that and require additional steps. Notably, the caching plu... |
138,648 | <p>I'm trying to move an existing Bedrock based multisite instance to nginx and am having difficulty getting a set of nginx rules to mimic the original .htaccess. Bedrock places the crux of the files in a wp/ subdirectory, but the urls still need to be accessible from the root domain.</p>
<p>The .htaccess is here as f... | [
{
"answer_id": 139224,
"author": "etc",
"author_id": 49488,
"author_profile": "https://wordpress.stackexchange.com/users/49488",
"pm_score": 1,
"selected": true,
"text": "<pre><code>rewrite /wp-admin$ $scheme://$host$uri/ last;\nrewrite ^/(wp-.*.php)$ /wp/$1 last;\nrewrite ^/(wp-(content... | 2014/03/20 | [
"https://wordpress.stackexchange.com/questions/138648",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49488/"
] | I'm trying to move an existing Bedrock based multisite instance to nginx and am having difficulty getting a set of nginx rules to mimic the original .htaccess. Bedrock places the crux of the files in a wp/ subdirectory, but the urls still need to be accessible from the root domain.
The .htaccess is here as follows:
`... | ```
rewrite /wp-admin$ $scheme://$host$uri/ last;
rewrite ^/(wp-.*.php)$ /wp/$1 last;
rewrite ^/(wp-(content|admin|includes).*) /wp/$1 last;
```
These are the equivalent rewrite rules that you need. Note, when you use this rewrite, you no longer have to set the site\_url as /wp
I need to finish up some testing but w... |
138,695 | <p>I am trying to change the login logo URL and hover title. I am using the code below but <code>return bloginfo('url');</code> and <code>return bloginfo('name');</code> aren't outputting the desired <code>href</code> and <code>title</code>. I'm also using a child theme if that matters at all. What do I need to use ins... | [
{
"answer_id": 138696,
"author": "MBL",
"author_id": 10238,
"author_profile": "https://wordpress.stackexchange.com/users/10238",
"pm_score": 5,
"selected": true,
"text": "<p>Try these filters instead</p>\n\n<pre><code>// changing the logo link from wordpress.org to your site\nfunction mb... | 2014/03/21 | [
"https://wordpress.stackexchange.com/questions/138695",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18320/"
] | I am trying to change the login logo URL and hover title. I am using the code below but `return bloginfo('url');` and `return bloginfo('name');` aren't outputting the desired `href` and `title`. I'm also using a child theme if that matters at all. What do I need to use instead of `return bloginfo('url');` and `return b... | Try these filters instead
```
// changing the logo link from wordpress.org to your site
function mb_login_url() { return home_url(); }
add_filter( 'login_headerurl', 'mb_login_url' );
// changing the alt text on the logo to show your site name
function mb_login_title() { return get_option( 'blogname' ); }
add_filter... |
138,715 | <p>I use wordpress in a lan with wamp. I can correctly see the lan from client pcs. It works perfectly with non wordpress websites so i don't think it's a lan setting problem. Is there any particular setting i should set in wordpress? Actually, it loads correctly, but without JS and CSS. </p>
<p>UPDATE, here's how CSS... | [
{
"answer_id": 138832,
"author": "Mariano",
"author_id": 44452,
"author_profile": "https://wordpress.stackexchange.com/users/44452",
"pm_score": 2,
"selected": false,
"text": "<p>finally i solved it...this was a very annoying problem!\njust enter your db and change in wp_option:\n- siteu... | 2014/03/21 | [
"https://wordpress.stackexchange.com/questions/138715",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44452/"
] | I use wordpress in a lan with wamp. I can correctly see the lan from client pcs. It works perfectly with non wordpress websites so i don't think it's a lan setting problem. Is there any particular setting i should set in wordpress? Actually, it loads correctly, but without JS and CSS.
UPDATE, here's how CSS and JS ar... | finally i solved it...this was a very annoying problem!
just enter your db and change in wp\_option:
- siteurl: from localhost server's lan ip
- home: from localhost server's lan ip
that's it! :) |
138,739 | <p>I am trying to connect to a database in the function.php using mysqli. The code seems to run fine when it is not on a separate php file not on wordpress. But when I run it on wordpress I get "Connect failed: No connection could be made because the target machine actively refused it." I am not sure if wordpress is pr... | [
{
"answer_id": 138744,
"author": "Ziad",
"author_id": 34792,
"author_profile": "https://wordpress.stackexchange.com/users/34792",
"pm_score": 0,
"selected": false,
"text": "<p>Did you read this: <a href=\"https://codex.wordpress.org/Custom_Queries\" rel=\"nofollow\">https://codex.wordpre... | 2014/03/21 | [
"https://wordpress.stackexchange.com/questions/138739",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43161/"
] | I am trying to connect to a database in the function.php using mysqli. The code seems to run fine when it is not on a separate php file not on wordpress. But when I run it on wordpress I get "Connect failed: No connection could be made because the target machine actively refused it." I am not sure if wordpress is preve... | Since version 3.9 (that will be released soon, actually in beta 2) WordPress will use mysqli to connect to database (3.9- versions use mysql) so you can actually use new wpdb instances and helper function to connect externa values from WordPress.
What I suggest is to configure external database using constants in `wp-... |
138,751 | <p>Is it possible to set the image quality based on the image size? I'd like to have better image quality for larger images (80) - and worse for small thumbnails (30).</p>
<p>I was expecting a parameter at <code>add_size</code> to control that - but there is none. </p>
<p>If it matters: I'm using ImageMagick. </p>
| [
{
"answer_id": 138775,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 3,
"selected": false,
"text": "<p>Note upfront: Below answer isn't finished and is not tested, but I ain´t got enough time left, so I'll leave this ... | 2014/03/21 | [
"https://wordpress.stackexchange.com/questions/138751",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37945/"
] | Is it possible to set the image quality based on the image size? I'd like to have better image quality for larger images (80) - and worse for small thumbnails (30).
I was expecting a parameter at `add_size` to control that - but there is none.
If it matters: I'm using ImageMagick. | The only time setting the quality really matters is right before the image is saved or streamed (for the editor). Both of these have the "image\_editor\_save\_pre" filter there, passing it the instance of the image editor. So you can use that to modify the image in any way you like, including setting the quality.
So, ... |
138,781 | <p>I'm building the sorting functionality for a custom post type, and I have a custom meta value for "Featured" posts. This value is set when you tick the checkbox, otherwise it is not set.</p>
<p>Using the default <code>orderby=meta_value</code> with <code>meta_key=featured</code> makes it so that the screen only dis... | [
{
"answer_id": 138794,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 4,
"selected": true,
"text": "<h2>Completely edited after first publish</h2>\n<p>The problem is that to order for a meta value, WordPress need ... | 2014/03/21 | [
"https://wordpress.stackexchange.com/questions/138781",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19105/"
] | I'm building the sorting functionality for a custom post type, and I have a custom meta value for "Featured" posts. This value is set when you tick the checkbox, otherwise it is not set.
Using the default `orderby=meta_value` with `meta_key=featured` makes it so that the screen only displays posts that have the meta k... | Completely edited after first publish
-------------------------------------
The problem is that to order for a meta value, WordPress need to `'meta_key'` in query is set to something.
But if you set `'meta_key'` to something, then WordPress will add something like
```
AND ( wp_postmeta.meta_key = 'the_meta_key' )
``... |
138,783 | <p>I want to list all the external links of my posts in a single place/file. How can I achieve this?</p>
<ul>
<li><p>Is it possible to achieve this via a plugin?</p></li>
<li><p>Is it possible to achieve this with a built-in wordpress api?</p></li>
<li><p>Is it possible to achieve this via some free 3rd party tool?</p... | [
{
"answer_id": 138817,
"author": "Sudeep K Rana",
"author_id": 47179,
"author_profile": "https://wordpress.stackexchange.com/users/47179",
"pm_score": 2,
"selected": false,
"text": "<p>Create a page with the name links. <code>Pages >> Add New</code> into your wordpress panel. Just ... | 2014/03/21 | [
"https://wordpress.stackexchange.com/questions/138783",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48380/"
] | I want to list all the external links of my posts in a single place/file. How can I achieve this?
* Is it possible to achieve this via a plugin?
* Is it possible to achieve this with a built-in wordpress api?
* Is it possible to achieve this via some free 3rd party tool?
What approach should be followed for achieving... | The above code had pagination concerns when I wanted to parse each and every page. So, building on the above, plus a kicker to search for links without 'nofollow' attributes, I came up with the following:
```
<ol>
<?php
global $post;
//Write Site URL below.
//Don't write http:// or anything like that. just domain.c... |
138,812 | <p>I found the following snippet will displays the number of Custom Post Types published in Dashboard's At A Glance widget, like this:</p>
<p><img src="https://i.stack.imgur.com/K0ujY.png" alt="At A Glance"></p>
<p>Is there a way to turn that "81 Wrestlers" text to a link to the post types list. Here's the code:</p>
... | [
{
"answer_id": 138823,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": false,
"text": "<p>Here is the function that I use to display CPT in the \"At a glance\" widget</p>\n\n<pre><code>add_acti... | 2014/03/22 | [
"https://wordpress.stackexchange.com/questions/138812",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33233/"
] | I found the following snippet will displays the number of Custom Post Types published in Dashboard's At A Glance widget, like this:

Is there a way to turn that "81 Wrestlers" text to a link to the post types list. Here's the code:
```
add_filter( 'dashboard_glance_... | Okay, so I used this code to only display "wrestler" post type & it worked. I mixed mine & Pieter Goosen's code to get this out:
```
add_filter( 'dashboard_glance_items', 'custom_glance_items', 10, 1 );
function custom_glance_items( $items = array() ) {
$post_types = array( 'wrestler' );
foreach( $post_types a... |
138,839 | <p>I am using wordpress 3.8. I am using <code>comment_form();</code> I need to display a <code>success message</code> on successfully posted comment on blog. How to do this? </p>
| [
{
"answer_id": 138859,
"author": "item251",
"author_id": 49334,
"author_profile": "https://wordpress.stackexchange.com/users/49334",
"pm_score": 1,
"selected": false,
"text": "<p>Try this: <a href=\"http://wordpress.org/plugins/wp-ajaxify-comments/\" rel=\"nofollow\">http://wordpress.org... | 2014/03/22 | [
"https://wordpress.stackexchange.com/questions/138839",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47390/"
] | I am using wordpress 3.8. I am using `comment_form();` I need to display a `success message` on successfully posted comment on blog. How to do this? | Without Ajax or plugins. Add to function.php:
```
add_action( 'set_comment_cookies', function( $comment, $user ) {
setcookie( 'ta_comment_wait_approval', '1' );
}, 10, 2 );
add_action( 'init', function() {
if( $_COOKIE['ta_comment_wait_approval'] === '1' ) {
setcookie( 'ta_comment_wait_approval', null... |
138,842 | <p>This is a function loaded by the parent theme. Through the child theme, I want to change this function to say <code>is_single</code> instead of <code>is_singular</code>. What would be the correct way to achieve this?</p>
<pre><code>add_action('wp_head', 'dt_specific_enqueues');
function dt_specific_enqueues() {
... | [
{
"answer_id": 138843,
"author": "Sudeep K Rana",
"author_id": 47179,
"author_profile": "https://wordpress.stackexchange.com/users/47179",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <code>remove_action</code> to remove a particular action done by your parent theme (within ... | 2014/03/22 | [
"https://wordpress.stackexchange.com/questions/138842",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18320/"
] | This is a function loaded by the parent theme. Through the child theme, I want to change this function to say `is_single` instead of `is_singular`. What would be the correct way to achieve this?
```
add_action('wp_head', 'dt_specific_enqueues');
function dt_specific_enqueues() {
if (is_singular()) {
wp_en... | The parent theme's `functions.php` will load automatically. You don't need to "read" it, and you don't want to "hack" it either manually, which will be overwritten, or programatically, which is very resource intensive.
Your theme is enqueueing the script on the `wp_head` action. You just need to remove that callback ... |
138,853 | <p>This question extents the question <a href="https://wordpress.stackexchange.com/questions/21765/redirect-to-custom-url-when-registration-fails">Redirect to custom url when registration fails?</a>:</p>
<p>In his comment He Shiming noted..</p>
<blockquote>
<p>that to redirect the user on a successful registration,... | [
{
"answer_id": 138843,
"author": "Sudeep K Rana",
"author_id": 47179,
"author_profile": "https://wordpress.stackexchange.com/users/47179",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <code>remove_action</code> to remove a particular action done by your parent theme (within ... | 2014/03/22 | [
"https://wordpress.stackexchange.com/questions/138853",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48847/"
] | This question extents the question [Redirect to custom url when registration fails?](https://wordpress.stackexchange.com/questions/21765/redirect-to-custom-url-when-registration-fails):
In his comment He Shiming noted..
>
> that to redirect the user on a successful registration, one has to `add_action` for `login_he... | The parent theme's `functions.php` will load automatically. You don't need to "read" it, and you don't want to "hack" it either manually, which will be overwritten, or programatically, which is very resource intensive.
Your theme is enqueueing the script on the `wp_head` action. You just need to remove that callback ... |
138,854 | <p>I am using:</p>
<pre><code>echo get_avatar(get_the_author_id(), 30);
</code></pre>
<p>Which works, however i am getting this notice to use:</p>
<pre><code>echo get_avatar(get_the_author_meta(), 30);
</code></pre>
<p>Which doesn't display the authors Gravatar image, just the Gravatar default image.</p>
<blockquo... | [
{
"answer_id": 138855,
"author": "Brad Dalton",
"author_id": 9884,
"author_profile": "https://wordpress.stackexchange.com/users/9884",
"pm_score": 2,
"selected": false,
"text": "<p>When looking at the source of <a href=\"http://queryposts.com/function/get_avatar/\" rel=\"nofollow\"><code... | 2014/03/22 | [
"https://wordpress.stackexchange.com/questions/138854",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9884/"
] | I am using:
```
echo get_avatar(get_the_author_id(), 30);
```
Which works, however i am getting this notice to use:
```
echo get_avatar(get_the_author_meta(), 30);
```
Which doesn't display the authors Gravatar image, just the Gravatar default image.
>
> `**Notice:** get_the_author_ID is deprecated since versio... | When looking at the source of [`get_avatar()`](http://queryposts.com/function/get_avatar/), you can see that it takes *either* `ID` *or* `email` as 1st argument:
```
get_avatar( $id_or_email, $size = '96', $default = '', $alt = false );
```
The source of [`get_the_author_meta()`](http://queryposts.com/function/get_t... |
138,930 | <p>I have a plugin that sends data to a server as part of a <code>transition_post_status</code> action. The server sends a response each time. I want to keep a log of these responses (permanently) that I can display in a table to the user somewhere, like so:</p>
<pre><code>Date | Response
------------------
1/1 | OK
... | [
{
"answer_id": 138938,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>It is not clear exactly what you are doing. For example, I am not sure what the data is that you are saving ... | 2014/03/23 | [
"https://wordpress.stackexchange.com/questions/138930",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26709/"
] | I have a plugin that sends data to a server as part of a `transition_post_status` action. The server sends a response each time. I want to keep a log of these responses (permanently) that I can display in a table to the user somewhere, like so:
```
Date | Response
------------------
1/1 | OK
1/2 | Status code 2
```... | It is not clear exactly what you are doing. For example, I am not sure what the data is that you are saving or where/when it needs to be displayed, but it sounds like you need:
1. [The Transients API](https://codex.wordpress.org/Transients_API)
2. [Or the Options API](https://codex.wordpress.org/Options_API)
However,... |
138,967 | <p>WordPress 3.7 introduced <a href="http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters" rel="nofollow">'date_query' argument for <code>WP_Query</code></a>.</p>
<p>That's pretty useful and allow very complex date-based queries, however something strange happen when using <code>WP_Query</code> conditio... | [
{
"answer_id": 138969,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>The values retrieved by the <code>is_date()</code>, <code>is_day(),</code> etc. methods are set inside the ... | 2014/03/23 | [
"https://wordpress.stackexchange.com/questions/138967",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35541/"
] | WordPress 3.7 introduced ['date\_query' argument for `WP_Query`](http://codex.wordpress.org/Class_Reference/WP_Query#Date_Parameters).
That's pretty useful and allow very complex date-based queries, however something strange happen when using `WP_Query` conditional methods on query using that argument.
Example:
```
... | I'll try to make some order, and focus all my thoughts in a answer instead of commenting the 2 good answers by **@s\_ha\_dum** and **@kaiser** (I upvoted both).
First we need to specify that in WordPress there are 2 types of queries, **main** and **secondaries**.
Both are instances of same class, `WP_Query` but first... |
138,976 | <p>In my current plugin, I am picking up the <code>order by</code> column as user input. So I thought of using <code>wpdb->prepare</code> to escape it.</p>
<pre><code>$wpdb->get_results($wpdb->prepare("Select id from $wpdb->posts order by %s %s", $order_by_col, $order_by);
</code></pre>
<p>This is not wor... | [
{
"answer_id": 138980,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 4,
"selected": true,
"text": "<p>You can't use <code>prepare</code> for column names, and you can't really use it for the sort order either. <... | 2014/03/24 | [
"https://wordpress.stackexchange.com/questions/138976",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24579/"
] | In my current plugin, I am picking up the `order by` column as user input. So I thought of using `wpdb->prepare` to escape it.
```
$wpdb->get_results($wpdb->prepare("Select id from $wpdb->posts order by %s %s", $order_by_col, $order_by);
```
This is not working because it gets turned into
```
select id from wp_post... | You can't use `prepare` for column names, and you can't really use it for the sort order either. `prepare` will always quote the string. You will need to swap in the values yourself. Rather than try to "sanitize" the data, I'd use a white-list approach.
```
$orderby = array(
'date' => 'post_date',
// etc
);
$sorto... |
138,978 | <p>I am pulling data from an external web service into a custom post type. This data includes images. How can I create an image gallery, add some existing attachments to it, and associate it with a post?</p>
<p>What I was hoping to find is something like a <code>set_post_gallery</code> counterpart to the <code>get_pos... | [
{
"answer_id": 139008,
"author": "Jörn Lund",
"author_id": 35723,
"author_profile": "https://wordpress.stackexchange.com/users/35723",
"pm_score": 3,
"selected": true,
"text": "<p>When you just have raw image files, that you want to assign to a post, <a href=\"http://codex.wordpress.org/... | 2014/03/24 | [
"https://wordpress.stackexchange.com/questions/138978",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34557/"
] | I am pulling data from an external web service into a custom post type. This data includes images. How can I create an image gallery, add some existing attachments to it, and associate it with a post?
What I was hoping to find is something like a `set_post_gallery` counterpart to the `get_post_gallery` function, but I... | When you just have raw image files, that you want to assign to a post, [`wp_insert_attachment`](http://codex.wordpress.org/Function_Reference/wp_insert_attachment) will do the job.
With attachments already present in your database you can use [`wp_update_post`](http://codex.wordpress.org/Function_Reference/wp_update_... |
138,982 | <p>I am new in WordPress plugin development.
This is my core PHP and HTML code</p>
<p><strong>create-table.html</strong></p>
<pre><code> <form method="post" action="function.php">
<input type="text" name="table_name">
<input type="submit" name="create">
</form>
</code></pre>
<p><... | [
{
"answer_id": 138984,
"author": "Rajeev Vyas",
"author_id": 6961,
"author_profile": "https://wordpress.stackexchange.com/users/6961",
"pm_score": 3,
"selected": true,
"text": "<p><a href=\"http://codex.wordpress.org/Creating_Tables_with_Plugins\" rel=\"nofollow\">Creating Tables with pl... | 2014/03/24 | [
"https://wordpress.stackexchange.com/questions/138982",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49216/"
] | I am new in WordPress plugin development.
This is my core PHP and HTML code
**create-table.html**
```
<form method="post" action="function.php">
<input type="text" name="table_name">
<input type="submit" name="create">
</form>
```
**function.php**
```
if(isset($_POST['create'])
{
$table-name=$_POST['... | [Creating Tables with plugin](http://codex.wordpress.org/Creating_Tables_with_Plugins) This page shows how to work with tables in plugins. Example on that page includes table creation during installation of plugin. But it can be dynamically used also to create table. See below.
```
if(isset($_POST['create'])
{
$table_... |
138,987 | <p>I have rewritten my taxonomy url to the name of my posts type 'filter'. </p>
<p>Because I have done this, my pagination does not work anymore on the url:</p>
<p><a href="http://www.website.com/filter/term-name/" rel="nofollow">http://www.website.com/filter/term-name/</a></p>
<p>So if I visit </p>
<p><a href="htt... | [
{
"answer_id": 139382,
"author": "Kumar",
"author_id": 32466,
"author_profile": "https://wordpress.stackexchange.com/users/32466",
"pm_score": 1,
"selected": false,
"text": "<p>While looking for a solution I got this post: <a href=\"http://someweblog.com/wordpress-custom-taxonomy-with-sa... | 2014/03/24 | [
"https://wordpress.stackexchange.com/questions/138987",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25834/"
] | I have rewritten my taxonomy url to the name of my posts type 'filter'.
Because I have done this, my pagination does not work anymore on the url:
<http://www.website.com/filter/term-name/>
So if I visit
<http://www.website.com/filter/term-name/page/2>
I get a 404
I think this is because Wordpress sees filter no... | While looking for a solution I got this post: [Taxonomies with same slug as CPT](http://someweblog.com/wordpress-custom-taxonomy-with-same-slug-as-custom-post-type/)
So basically you need to add custom rewrite rules, I haven't tested the solution but I guess it will work out for you.
```
/* Register CPT
*/
function w... |
138,996 | <p>I followed <a href="https://wordpress.stackexchange.com/questions/65797/failed-to-connect-to-ftp-server-127-0-0-1-21"></a><a href="https://wordpress.stackexchange.com/questions/65797/failed-to-connect-to-ftp-server-127-0-0-1-21">Failed to connect to FTP Server 127.0.0.1/:21</a></p>
<p>And was able to solve that pro... | [
{
"answer_id": 139028,
"author": "Shoaib Chikate",
"author_id": 49396,
"author_profile": "https://wordpress.stackexchange.com/users/49396",
"pm_score": 1,
"selected": false,
"text": "<p>Back up the config file before making a change;</p>\n\n<pre><code>sudo cp /etc/vsftpd.conf /etc/vsftpd... | 2014/03/24 | [
"https://wordpress.stackexchange.com/questions/138996",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49396/"
] | I followed [Failed to connect to FTP Server 127.0.0.1/:21](https://wordpress.stackexchange.com/questions/65797/failed-to-connect-to-ftp-server-127-0-0-1-21)
And was able to solve that problem. But now when I try to upload the theme then I get username and password failure.
I have added following lines in wp-config.ph... | if you do not want to (or you cannot) change permissions on wp-content so your web server has write permissions, then add this to your wp-config.php file:
```
define('FS_METHOD', 'direct');
``` |
138,999 | <p>I'm trying to show post categories for some breadcrumbs. At the moment, I have this:</p>
<pre><code>the_category(' / ', 'multiple');
</code></pre>
<p>But for some reason, it is stating the parent category twice (I only want <code>parent > child</code>):</p>
<pre><code>FASHION / DAILY FASHION CANDY / FASHION
</... | [
{
"answer_id": 139004,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 2,
"selected": true,
"text": "<p>If you select both categories for the post <code>the_category()</code> will display both and using <code>multi... | 2014/03/24 | [
"https://wordpress.stackexchange.com/questions/138999",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33541/"
] | I'm trying to show post categories for some breadcrumbs. At the moment, I have this:
```
the_category(' / ', 'multiple');
```
But for some reason, it is stating the parent category twice (I only want `parent > child`):
```
FASHION / DAILY FASHION CANDY / FASHION
```
It should really be:
```
FASHION / DAILY FASHI... | If you select both categories for the post `the_category()` will display both and using `multiple` will make the child category display the parent relationship, so you will have the parent twice. If you want to display a link to the parent category and a link to child category select only the child category for the pos... |
139,015 | <p>I'm writing a plugins that renders json data from an API request and I need to implement an infinite scroll in a content page.</p>
<p>The problem is when I render the content with an ajax call, it renders all the page instead.</p>
<p>This is what I have done so far:</p>
<pre><code>function enable_pagination() {
... | [
{
"answer_id": 139522,
"author": "Marc Dingena",
"author_id": 28660,
"author_profile": "https://wordpress.stackexchange.com/users/28660",
"pm_score": 0,
"selected": false,
"text": "<p>Your current code requests the entire page which comes back as <code>response</code>.</p>\n\n<pre><code>... | 2014/03/24 | [
"https://wordpress.stackexchange.com/questions/139015",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49410/"
] | I'm writing a plugins that renders json data from an API request and I need to implement an infinite scroll in a content page.
The problem is when I render the content with an ajax call, it renders all the page instead.
This is what I have done so far:
```
function enable_pagination() {
jQuery(function($) {
... | Your code is a bit complex, so I can't post a full-working code, but a proof of concept, then adapt to your code is up to you.
So, Ajax in WordPress should be used via [Ajax API](http://codex.wordpress.org/AJAX_in_Plugins), instead to send a request to same url, that of course print header, and other stuff, simply sen... |
139,018 | <p>my code should show popular posts where the meta key "slider" isn't empty. Have anyone an idea why it doesn't work?</p>
<p>The problem is that this code only shows posts with a slider image. But it ignores the sorting.</p>
<pre><code>$values = array(
'numberposts' => 10,
'orderby' => 'meta_value_num',
... | [
{
"answer_id": 139522,
"author": "Marc Dingena",
"author_id": 28660,
"author_profile": "https://wordpress.stackexchange.com/users/28660",
"pm_score": 0,
"selected": false,
"text": "<p>Your current code requests the entire page which comes back as <code>response</code>.</p>\n\n<pre><code>... | 2014/03/24 | [
"https://wordpress.stackexchange.com/questions/139018",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33235/"
] | my code should show popular posts where the meta key "slider" isn't empty. Have anyone an idea why it doesn't work?
The problem is that this code only shows posts with a slider image. But it ignores the sorting.
```
$values = array(
'numberposts' => 10,
'orderby' => 'meta_value_num',
'meta_key' => 'count_views'... | Your code is a bit complex, so I can't post a full-working code, but a proof of concept, then adapt to your code is up to you.
So, Ajax in WordPress should be used via [Ajax API](http://codex.wordpress.org/AJAX_in_Plugins), instead to send a request to same url, that of course print header, and other stuff, simply sen... |
139,041 | <p>I'm trying to run disable auto p filter on only my home page. In my functions.php file, I added this snippet:</p>
<pre><code>function removeP(){
if ( is_page( 4 ) ) {
remove_filter('the_content', 'wpautop');
}
}
add_action( 'after_setup_theme', 'removeP' );
</code></pre>
<p>It does not remove the ... | [
{
"answer_id": 139042,
"author": "Zach Russell",
"author_id": 30778,
"author_profile": "https://wordpress.stackexchange.com/users/30778",
"pm_score": 1,
"selected": false,
"text": "<p>change <code>if ( is_page( 4 ))</code> to <code>if (is_home() )</code> so:</p>\n\n<pre><code>function re... | 2014/03/24 | [
"https://wordpress.stackexchange.com/questions/139041",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38553/"
] | I'm trying to run disable auto p filter on only my home page. In my functions.php file, I added this snippet:
```
function removeP(){
if ( is_page( 4 ) ) {
remove_filter('the_content', 'wpautop');
}
}
add_action( 'after_setup_theme', 'removeP' );
```
It does not remove the filter on the homepage. | You're calling it on the wrong hook, and you're calling the wrong [conditional function](https://codex.wordpress.org/Conditional_Tags) to test.
When the `after_setup_theme` hook is fired, WordPress hasn't finished processing wether you're on a page or a homepage yet.
You should also ***never*** pass in hardcoded post... |
139,051 | <p>The following code works perfectly to show all the categories for a custom post type. However when there are no categories it echos 'No Categories'. How would I remove this?</p>
<pre><code> <?php //Category Display for Custom Post type - Video
$customPostTaxonomies = ge... | [
{
"answer_id": 139057,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": true,
"text": "<p>I believe that what you want is <code>show_option_none</code></p>\n\n<blockquote>\n <p><code>show_option_non... | 2014/03/24 | [
"https://wordpress.stackexchange.com/questions/139051",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45403/"
] | The following code works perfectly to show all the categories for a custom post type. However when there are no categories it echos 'No Categories'. How would I remove this?
```
<?php //Category Display for Custom Post type - Video
$customPostTaxonomies = get_object_taxonomies('... | I believe that what you want is `show_option_none`
>
> `show_option_none`
>
> (string) Set the text to show when no categories are listed. Defaults to "No categories".
>
>
> <http://codex.wordpress.org/Template_Tags/wp_list_categories#Parameters>
>
>
>
Proof of concept:
```
$args = array('include'=>123,'sh... |