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 |
|---|---|---|---|---|---|---|
93,798 | <p>I'm trying to show the last 5 posts from a specific category, which will be linked to a function so i can insert the shortcode in a Wordpress page. The code i have is as below, it does everything i need (although i want to add featured image too) except it does not show posts from a specific category.</p>
<p>I've t... | [
{
"answer_id": 93801,
"author": "seravifer9",
"author_id": 30656,
"author_profile": "https://wordpress.stackexchange.com/users/30656",
"pm_score": 1,
"selected": false,
"text": "<p>You can add the text from the file comments.php</p>\n\n<pre><code> <?php\n // Do not delete these ... | 2013/03/28 | [
"https://wordpress.stackexchange.com/questions/93798",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26686/"
] | I'm trying to show the last 5 posts from a specific category, which will be linked to a function so i can insert the shortcode in a Wordpress page. The code i have is as below, it does everything i need (although i want to add featured image too) except it does not show posts from a specific category.
I've tried numer... | You should **not** edit the Wordpress core files!
If you have `comment_id_fields()` in your comments template, like this:
```
<p class="form-submit">
<input name="submit" type="submit" id="<?php echo esc_attr( $args['id_submit'] ); ?>"
value="<?php e... |
93,830 | <p>I'm sure this is a simple oversight but I cannot seem to narrow it down:</p>
<pre><code> global $wpdb;
$tablename = $wpdb->prefix . "icrm_folders";
$sql = $wpdb->prepare( "SELECT * FROM %s", $tablename );
//$sql results in SELECT * FROM 'wp_icrm_folders'
$result = $wpdb->get_results( $sql );
</code></p... | [
{
"answer_id": 93836,
"author": "Adi",
"author_id": 27912,
"author_profile": "https://wordpress.stackexchange.com/users/27912",
"pm_score": 1,
"selected": false,
"text": "<p>I think that you are not write the query in proper way. So here is just little example may be it help you.</p>\n\n... | 2013/03/29 | [
"https://wordpress.stackexchange.com/questions/93830",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23754/"
] | I'm sure this is a simple oversight but I cannot seem to narrow it down:
```
global $wpdb;
$tablename = $wpdb->prefix . "icrm_folders";
$sql = $wpdb->prepare( "SELECT * FROM %s", $tablename );
//$sql results in SELECT * FROM 'wp_icrm_folders'
$result = $wpdb->get_results( $sql );
```
This seems to result in not... | Don't use `$wpdb->prepare` with table names. `prepare` will quote your table names that will result in incorrect SQL.
It is unnecessary overhead as well. Your table name should never, and in your case isn't, be user-supplied data. You have no need to escape it. 'prepare' is for use on user-supplied data, such as data... |
93,835 | <p>Friends I need help.</p>
<p>Am extending the Mayashop theme for a friend & I ran into a problem.</p>
<p>Created a custom post type named watchdog, created a taxonomy for it called watchdog-brand ... now the single-watchdog.php template is working just fine but I can't seem to find the appropriate template for ... | [
{
"answer_id": 93837,
"author": "Marc Dingena",
"author_id": 28660,
"author_profile": "https://wordpress.stackexchange.com/users/28660",
"pm_score": 0,
"selected": false,
"text": "<p>Try <code>taxonomy-watchdog-brand.php</code> instead.</p>\n"
},
{
"answer_id": 93948,
"author... | 2013/03/29 | [
"https://wordpress.stackexchange.com/questions/93835",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30677/"
] | Friends I need help.
Am extending the Mayashop theme for a friend & I ran into a problem.
Created a custom post type named watchdog, created a taxonomy for it called watchdog-brand ... now the single-watchdog.php template is working just fine but I can't seem to find the appropriate template for the term itself listi... | Turned out to be an internal mayashop function in the taxonomy.php page that checks for two particular taxonomies if found populates their pages it not returns to the index.php
added my condition & all is well now, Thanks
```
<?php
/**
* @package WordPress
* @subpackage Impero
* @since Impero 1.0
*/
... |
93,853 | <p>First, I have a static page for homepage and for blog page too. I created a custom box for pages to setup unique background image for the pages. My idea is working on all page templates, but on blog page something wrong.</p>
<p><strong>header.php is same on all page</strong></p>
<pre><code><head>
{...}
<?... | [
{
"answer_id": 93914,
"author": "hepii110",
"author_id": 30713,
"author_profile": "https://wordpress.stackexchange.com/users/30713",
"pm_score": 0,
"selected": false,
"text": "<p>change</p>\n\n<pre><code>$values = get_post_custom( $post->ID ); \n</code></pre>\n\n<p>to</p>\n\n<pre><cod... | 2013/03/29 | [
"https://wordpress.stackexchange.com/questions/93853",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28731/"
] | First, I have a static page for homepage and for blog page too. I created a custom box for pages to setup unique background image for the pages. My idea is working on all page templates, but on blog page something wrong.
**header.php is same on all page**
```
<head>
{...}
<?php $values = get_post_custom( $post->ID );... | The basic problem is that there is no variable `$post` in your `header.php`. That variable might exist in the [**global** scope](http://php.net/manual/en/language.variables.scope.php "PHP manual: Variable scope"), but your code operates in a function scope of `load_template()` which was called by `get_header()`.
So yo... |
93,862 | <p>I've just upgraded wordpress to 3.5 version and I noticed that TinyMCE Advanced Editor is not as tall as before. </p>
<p>How can I change default tinyMCE height?</p>
<p><strong>UPDATE</strong></p>
<p>This is the screenshot of section I want to render higher than the default</p>
<p><img src="https://i.stack.imgur... | [
{
"answer_id": 93876,
"author": "Circle B",
"author_id": 15404,
"author_profile": "https://wordpress.stackexchange.com/users/15404",
"pm_score": 0,
"selected": false,
"text": "<p>To increase the height of the actual editing area of the WYSIWYG, add this code to the functions.php file:</p... | 2013/03/29 | [
"https://wordpress.stackexchange.com/questions/93862",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3990/"
] | I've just upgraded wordpress to 3.5 version and I noticed that TinyMCE Advanced Editor is not as tall as before.
How can I change default tinyMCE height?
**UPDATE**
This is the screenshot of section I want to render higher than the default
 | @frabiacca:
I'm not sure if you meant the toolbar menu, like Circle B showed or the height of the writing place. If it's the latter you can :
* do it easily by gragging the bottom right corner or the textarea or clicking on the fullscreen button of the editor :D
* do it programmatically
[codex.wordpress.org/TinyMCE]... |
93,868 | <p>How do you extract the url from :</p>
<pre><code>$url = get_the_term_list($post->ID, 'nom-origin')
</code></pre>
<p>I have tried many things but i just don't get it. The only solution i got was this but i know it's just too messy :</p>
<pre><code>$url = get_the_term_list($post->ID, 'nom-origin');//,'<h3&... | [
{
"answer_id": 93870,
"author": "Manny Fleurmond",
"author_id": 2234,
"author_profile": "https://wordpress.stackexchange.com/users/2234",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/get_term_link\" rel=\"nofollow\"><code>get_term_... | 2013/03/29 | [
"https://wordpress.stackexchange.com/questions/93868",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30691/"
] | How do you extract the url from :
```
$url = get_the_term_list($post->ID, 'nom-origin')
```
I have tried many things but i just don't get it. The only solution i got was this but i know it's just too messy :
```
$url = get_the_term_list($post->ID, 'nom-origin');//,'<h3>Job Category:</h3> ', ', ', '' );
$url_tmp1 = ... | [`get_term_link`](http://codex.wordpress.org/Function_Reference/get_term_link) gives you the link of a particular taxonomy term.
```
$terms = get_object_terms( $post->ID, 'nom-origin' );
$urls = array();
foreach( $terms as $term )
{
$url[] = get_term_link( $term->slug, 'nom-origin' );
//Or do whatever you want... |
93,878 | <p>I'm trying to install a wordpress installation where the DB will sit on a MySQL cluster (Galera/Percona XtraDB Cluster) and connected through HAProxy. </p>
<p>Everything outside of the Wordpress install seems to work fine. Using the mysql client to connect to the database with a username and password works just fin... | [
{
"answer_id": 93870,
"author": "Manny Fleurmond",
"author_id": 2234,
"author_profile": "https://wordpress.stackexchange.com/users/2234",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/get_term_link\" rel=\"nofollow\"><code>get_term_... | 2013/03/29 | [
"https://wordpress.stackexchange.com/questions/93878",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30694/"
] | I'm trying to install a wordpress installation where the DB will sit on a MySQL cluster (Galera/Percona XtraDB Cluster) and connected through HAProxy.
Everything outside of the Wordpress install seems to work fine. Using the mysql client to connect to the database with a username and password works just fine. The Wor... | [`get_term_link`](http://codex.wordpress.org/Function_Reference/get_term_link) gives you the link of a particular taxonomy term.
```
$terms = get_object_terms( $post->ID, 'nom-origin' );
$urls = array();
foreach( $terms as $term )
{
$url[] = get_term_link( $term->slug, 'nom-origin' );
//Or do whatever you want... |
93,883 | <p>My goal is to not use a separate blog page but end up with a structure like this...</p>
<p><a href="http://domain.tld/page/comments/" rel="nofollow">http://domain.tld/page/comments/</a></p>
<p>I believe I can do this with the Cornerstone plugin ~ [ <a href="http://wordpress.org/extend/plugins/cornerstone/" rel="no... | [
{
"answer_id": 93870,
"author": "Manny Fleurmond",
"author_id": 2234,
"author_profile": "https://wordpress.stackexchange.com/users/2234",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/get_term_link\" rel=\"nofollow\"><code>get_term_... | 2013/03/29 | [
"https://wordpress.stackexchange.com/questions/93883",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30696/"
] | My goal is to not use a separate blog page but end up with a structure like this...
<http://domain.tld/page/comments/>
I believe I can do this with the Cornerstone plugin ~ [ <http://wordpress.org/extend/plugins/cornerstone/> ] ~ but I can’t figure out the alternative loop code and how I replace the loop in Genesis w... | [`get_term_link`](http://codex.wordpress.org/Function_Reference/get_term_link) gives you the link of a particular taxonomy term.
```
$terms = get_object_terms( $post->ID, 'nom-origin' );
$urls = array();
foreach( $terms as $term )
{
$url[] = get_term_link( $term->slug, 'nom-origin' );
//Or do whatever you want... |
93,888 | <p>Hello wordpress users,</p>
<p>I'm stuck with a problem while running 2 self made Wordpress plugins.
I'll use the following code :</p>
<pre><code>define('PLUGIN_URL', plugin_dir_url( __FILE__ ));
add_action( 'admin_enqueue_scripts', 'plugin_load_js_and_css' );
function plugin_load_js_and_css() {
wp_registe... | [
{
"answer_id": 93889,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": false,
"text": "<p>When you register a plugin option page you get a hook from the registration function:</p>\n<pre><code>$hook = add_menu... | 2013/03/29 | [
"https://wordpress.stackexchange.com/questions/93888",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30688/"
] | Hello wordpress users,
I'm stuck with a problem while running 2 self made Wordpress plugins.
I'll use the following code :
```
define('PLUGIN_URL', plugin_dir_url( __FILE__ ));
add_action( 'admin_enqueue_scripts', 'plugin_load_js_and_css' );
function plugin_load_js_and_css() {
wp_register_style( 'plugin.css'... | When you register a plugin option page you get a hook from the registration function:
```
$hook = add_menu_page(
'T5 Demo', // page title
'T5 Demo', // menu title
'manage_options', // capability
't5-demo', // menu slug
'my_render_page' // callback function
);
```
Use this ho... |
93,890 | <p>I need to delete old edits and autosave, they have grown overtime, and are not needed anymore, seeing this post: </p>
<p><a href="https://wordpress.stackexchange.com/a/67228/27148">https://wordpress.stackexchange.com/a/67228/27148</a></p>
<p>it states:</p>
<blockquote>
<p>If you have no use for the post revisio... | [
{
"answer_id": 93893,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": true,
"text": "<p>You'll need to <a href=\"http://codex.wordpress.org/Editing_wp-config.php#Post_Revisions\" rel=\"nofollow\">... | 2013/03/29 | [
"https://wordpress.stackexchange.com/questions/93890",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27148/"
] | I need to delete old edits and autosave, they have grown overtime, and are not needed anymore, seeing this post:
<https://wordpress.stackexchange.com/a/67228/27148>
it states:
>
> If you have no use for the post revisions and autosaves then disable them in wp-config and WordPress will clean them up on its own
>
>... | You'll need to [edit `wp-config.php`](http://codex.wordpress.org/Editing_wp-config.php#Post_Revisions).
To set posts to retain a set number of revisions:
```
define('WP_POST_REVISIONS', 3);
```
To disable post revisions completely:
```
define('WP_POST_REVISIONS', false );
``` |
93,900 | <p>I'm using a custom theme, developed from Boilerplate (some time ago). I noticed that the header images work fine when set statically, but fail to appear when set to random. I tried switching themes, and realized the same issue happens with Boilerplate, as well as Twentytwelve. Twentyten worked though, so I copied it... | [
{
"answer_id": 93893,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": true,
"text": "<p>You'll need to <a href=\"http://codex.wordpress.org/Editing_wp-config.php#Post_Revisions\" rel=\"nofollow\">... | 2013/03/29 | [
"https://wordpress.stackexchange.com/questions/93900",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30704/"
] | I'm using a custom theme, developed from Boilerplate (some time ago). I noticed that the header images work fine when set statically, but fail to appear when set to random. I tried switching themes, and realized the same issue happens with Boilerplate, as well as Twentytwelve. Twentyten worked though, so I copied its c... | You'll need to [edit `wp-config.php`](http://codex.wordpress.org/Editing_wp-config.php#Post_Revisions).
To set posts to retain a set number of revisions:
```
define('WP_POST_REVISIONS', 3);
```
To disable post revisions completely:
```
define('WP_POST_REVISIONS', false );
``` |
93,909 | <p>We have added a custom rewrite_rule to our site to allow for a pretty inbound link to be parsed and handled properly. Links are constructed as <code>domain.com/meetings/faculty/someIDnumber</code></p>
<pre><code>add_action( "init", "pleasing_permalinks" );
function pleasing_permalinks() {
add_rewrite_tag( '%ha... | [
{
"answer_id": 93910,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried using the first index rather than the second?</p>\n\n<pre><code>'index.php?p=1598&hash=$ma... | 2013/03/29 | [
"https://wordpress.stackexchange.com/questions/93909",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6146/"
] | We have added a custom rewrite\_rule to our site to allow for a pretty inbound link to be parsed and handled properly. Links are constructed as `domain.com/meetings/faculty/someIDnumber`
```
add_action( "init", "pleasing_permalinks" );
function pleasing_permalinks() {
add_rewrite_tag( '%hash%', '([^&]+)' );
ad... | If `faculty` is a child page of `meetings`, the rule should be:
```
add_rewrite_rule(
'meetings/faculty/([^/]+)/?$',
'index.php?pagename=meetings/faculty&hash=$matches[1]',
'top'
);
```
`pagename=meetings/faculty` instead of `p=1598`
EDIT- or alternately:
```
add_rewrite_rule(
'meetings/faculty/([^... |
93,923 | <p>I'm trying to perform a dynamic query that uses a dynamically passed taxonomy and post_type, and displays results accordingly — </p>
<p>A user makes a selection from 3 drop-downs on a form, each have a value. This is passed by the URL Query string. The query on page picks up parameters from the URL, utilising <code... | [
{
"answer_id": 93927,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 4,
"selected": true,
"text": "<p><a href=\"https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters\" rel=\"nofollow\"><code>ta... | 2013/03/30 | [
"https://wordpress.stackexchange.com/questions/93923",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29388/"
] | I'm trying to perform a dynamic query that uses a dynamically passed taxonomy and post\_type, and displays results accordingly —
A user makes a selection from 3 drop-downs on a form, each have a value. This is passed by the URL Query string. The query on page picks up parameters from the URL, utilising `$_GET`.
When... | [`tax_query` takes an array of arrays.](https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters) You have an array of arrays of arrays. `var_dump($tax_queries);` and will get this:
```
array(1) {
[0]=>
array(1) {
[0]=>
array(3) {
["taxonomy"]=>
string(15) "difficulty_mode"
... |
93,960 | <p>I am trying to load WordPress options within a standalone PHP file. The file is located in <code>/wp-content/plugins/plugin-name/file.php</code>. I have used the following to open wp-load.php:</p>
<pre><code>if (file_exists('../../../wp-load.php')) {
require_once ('../../../wp-load.php');
}
</code></pre>
<p>Do... | [
{
"answer_id": 93967,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 0,
"selected": false,
"text": "<p>This error has nothing to do with wp-load.php. You are declaring the 'some_plugin_function' function twice wi... | 2013/03/30 | [
"https://wordpress.stackexchange.com/questions/93960",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15507/"
] | I am trying to load WordPress options within a standalone PHP file. The file is located in `/wp-content/plugins/plugin-name/file.php`. I have used the following to open wp-load.php:
```
if (file_exists('../../../wp-load.php')) {
require_once ('../../../wp-load.php');
}
```
Doing so outputs the following error:
... | The problem happens when you have a function declared in the root file of the plugin or in the functions.php file of a theme. You need to require\_once a file for functions and move those functions into that file.
For example:
Your plugin is called some-plugin and the root file is some-plugin.php. Any function on the... |
94,036 | <p>I have this loop where I loop through every post of my CPT and fetch the title and the content of each post and put it into an array. That is no problem.</p>
<p>But as it happens I have created a repeatable field with <a href="http://www.advancedcustomfields.com/add-ons/repeater-field/" rel="nofollow">Advanced Cust... | [
{
"answer_id": 94037,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>I don't think this is a restrict Wordpress question, but you might try</p>\n\n<pre><code>$args = array(\n 'p... | 2013/03/31 | [
"https://wordpress.stackexchange.com/questions/94036",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2830/"
] | I have this loop where I loop through every post of my CPT and fetch the title and the content of each post and put it into an array. That is no problem.
But as it happens I have created a repeatable field with [Advanced Custom Fields](http://www.advancedcustomfields.com/add-ons/repeater-field/) that is present in eac... | I don't think this is a restrict Wordpress question, but you might try
```
$args = array(
'posts_per_page' => '-1',
'post_type' => 'work',
'orderby' => 'ID',
'order' => 'DESC',
);
$data = array('work' => array());
$loop = new WP_Query($args);
if( $loop->have_posts() ):
while( $loop->have_posts() ... |
94,088 | <p>The code below is meant to display an Advanced Custom Fields Repeater field.</p>
<p>I need to have unique values for the "for" attribute of the Label tag, and for the ID value of the trailing checkbox input field. </p>
<p>Also, in order for the field label to work correctly, I need the "for" value to match the ID ... | [
{
"answer_id": 94098,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 1,
"selected": false,
"text": "<p>This sounds more like a php question, but you might try</p>\n\n<pre><code><?php $uniqid = uniqid('item_');?... | 2013/04/01 | [
"https://wordpress.stackexchange.com/questions/94088",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29051/"
] | The code below is meant to display an Advanced Custom Fields Repeater field.
I need to have unique values for the "for" attribute of the Label tag, and for the ID value of the trailing checkbox input field.
Also, in order for the field label to work correctly, I need the "for" value to match the ID value of the inpu... | Try using a "counter" variable for the loop maybe?
```
<?php
if ( get_field('ingredients-list') )
{
echo '<ul class="ingredientsList">';
$count=0;
while ( has_sub_field('ingredients-list') )
{
echo '<li class="ingredient" itemprop="ingredients"> <label for="check-'. $count .'"> <input type="che... |
94,092 | <p>I am creating a custom tours and travel theme in which I have created custom post type Cities, Locations, Destinations and i am using custom permalink structure. <code>/%category%/%postname%/</code></p>
<p>So now I want to append a state name or district name before that city, destination or location name. Let me m... | [
{
"answer_id": 94095,
"author": "dipali",
"author_id": 20711,
"author_profile": "https://wordpress.stackexchange.com/users/20711",
"pm_score": 2,
"selected": true,
"text": "<p>try this</p>\n\n<pre><code>add_filter( 'rewrite_rules_array','my_insert_rewrite_rules' );\nadd_filter( 'query_va... | 2013/04/01 | [
"https://wordpress.stackexchange.com/questions/94092",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20072/"
] | I am creating a custom tours and travel theme in which I have created custom post type Cities, Locations, Destinations and i am using custom permalink structure. `/%category%/%postname%/`
So now I want to append a state name or district name before that city, destination or location name. Let me make it more clear by ... | try this
```
add_filter( 'rewrite_rules_array','my_insert_rewrite_rules' );
add_filter( 'query_vars','my_insert_query_vars' );
function my_insert_rewrite_rules( $rules )
{
$newrules = array();
$newrules['(.+?)/custom_post_type_slug/(.+?)/?$'] = 'index.php?post_type=custom_post_type_slug&dynamic_string=$matche... |
94,097 | <p>i have this code to limit the comments per user. </p>
<pre><code><!-- #only one comment -->
<?php global $current_user,$post;
$args = array('user_id' => $current_user->ID,'post_id' => $post->ID);
$usercomment = get_comments($args);
if(count($usercomment) >= 1){
echo 'Thank you for your c... | [
{
"answer_id": 94113,
"author": "nonsensecreativity",
"author_id": 10997,
"author_profile": "https://wordpress.stackexchange.com/users/10997",
"pm_score": 1,
"selected": true,
"text": "<p>Try this, the code below will generate every comment by the <code>$current_user->user_email</code... | 2013/04/01 | [
"https://wordpress.stackexchange.com/questions/94097",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30792/"
] | i have this code to limit the comments per user.
```
<!-- #only one comment -->
<?php global $current_user,$post;
$args = array('user_id' => $current_user->ID,'post_id' => $post->ID);
$usercomment = get_comments($args);
if(count($usercomment) >= 1){
echo 'Thank you for your comment';
} else {
comment_form();
... | Try this, the code below will generate every comment by the `$current_user->user_email` for the author\_email, if the `$usercomment` return something, then there is a comment by the current user so echo "thank you", but if it's not return anything output the form.
```
global $current_user,$post;
$usercomment = get_co... |
94,114 | <p>I have a question about usage of previous_posts_link/next_posts_link. Is it possible to use it for custom post types too?</p>
<p>I like to hear from you.</p>
<p>Thanks in advance.
Casper</p>
| [
{
"answer_id": 94118,
"author": "dtbaker",
"author_id": 29029,
"author_profile": "https://wordpress.stackexchange.com/users/29029",
"pm_score": 1,
"selected": false,
"text": "<p>This is the code that worked for me. I have a custom post type called \"feature\" defined like this:</p>\n\n<p... | 2013/04/01 | [
"https://wordpress.stackexchange.com/questions/94114",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25971/"
] | I have a question about usage of previous\_posts\_link/next\_posts\_link. Is it possible to use it for custom post types too?
I like to hear from you.
Thanks in advance.
Casper | This is the code that worked for me. I have a custom post type called "feature" defined like this:
```
$args = array(
'label' => 'feature',
'description' => 'Product feature pages',
'labels' => array(
'name' => 'Features',
'singular_name' ... |
94,126 | <p>How to remove the <strong>Gravatar</strong> image from <strong>Username column</strong> in the <strong>All User</strong> admin page?</p>
<p><img src="https://i.stack.imgur.com/WPCl1.jpg" alt="enter image description here"></p>
| [
{
"answer_id": 94118,
"author": "dtbaker",
"author_id": 29029,
"author_profile": "https://wordpress.stackexchange.com/users/29029",
"pm_score": 1,
"selected": false,
"text": "<p>This is the code that worked for me. I have a custom post type called \"feature\" defined like this:</p>\n\n<p... | 2013/04/01 | [
"https://wordpress.stackexchange.com/questions/94126",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1044/"
] | How to remove the **Gravatar** image from **Username column** in the **All User** admin page?
 | This is the code that worked for me. I have a custom post type called "feature" defined like this:
```
$args = array(
'label' => 'feature',
'description' => 'Product feature pages',
'labels' => array(
'name' => 'Features',
'singular_name' ... |
94,130 | <p>I have installed Wordpress on my local Ubuntu machine, with standard LAMP configuration and phpMyAdmin. The installation directory is <code>localhost:///var/www/blog</code>.</p>
<p>At the second step of the installation, after I've entered the MySQL configuration, the following message appeared:</p>
<pre><code>Sor... | [
{
"answer_id": 94147,
"author": "Pothi Kalimuthu",
"author_id": 9584,
"author_profile": "https://wordpress.stackexchange.com/users/9584",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>Which file and directory permissions should I set on a new Wordpress/LAMP installation?<... | 2013/04/01 | [
"https://wordpress.stackexchange.com/questions/94130",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6117/"
] | I have installed Wordpress on my local Ubuntu machine, with standard LAMP configuration and phpMyAdmin. The installation directory is `localhost:///var/www/blog`.
At the second step of the installation, after I've entered the MySQL configuration, the following message appeared:
```
Sorry, but I can’t write the wp-con... | >
> Which file and directory permissions should I set on a new Wordpress/LAMP installation?
>
>
>
There is no definite answer to this. It varies depending on the server setup. The rule of thumb is to use the minimal permission to make WordPress work on a server. This means to start with 400 (or 600) and go from th... |
94,150 | <p>I'm using "Map Categories to Pages" to add categories to pages.</p>
<p>When I call the link <a href="http://mypage.com/category/catA+catB" rel="nofollow">http://mypage.com/category/catA+catB</a> I get all my articles, that are associated to the categories catA and catB. What I'm looking for is:</p>
<p>A) a way to ... | [
{
"answer_id": 95480,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": true,
"text": "<p>To display pages in a category archive index:</p>\n\n<ol>\n<li><p>Add category taxonomy to the <code>Page</c... | 2013/04/01 | [
"https://wordpress.stackexchange.com/questions/94150",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/154/"
] | I'm using "Map Categories to Pages" to add categories to pages.
When I call the link <http://mypage.com/category/catA+catB> I get all my articles, that are associated to the categories catA and catB. What I'm looking for is:
A) a way to do something similar with pages: call <http://mypage.com/pages/catA+catB> and get... | To display pages in a category archive index:
1. Add category taxonomy to the `Page` post-type
Static pages, by default, do not have any taxonomies associated with them, including the `category` taxonomy. So you need to register the `category` taxonomy for the `page` post type, using [**`register_taxonomy_for_object_... |
94,162 | <p>I am working with the <a href="https://codex.wordpress.org/Theme_Customization_API" rel="nofollow">Theme Customizer API</a> and am going crazy trying to find the stored values. The values successfully save and update on the front-end, so they are obviously registered successfully, however, I'm storing the options a... | [
{
"answer_id": 94165,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": true,
"text": "<p>If your settings are stored as <strong>Theme Mods</strong>, rather than as a <strong>Settings API option</st... | 2013/04/01 | [
"https://wordpress.stackexchange.com/questions/94162",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2527/"
] | I am working with the [Theme Customizer API](https://codex.wordpress.org/Theme_Customization_API) and am going crazy trying to find the stored values. The values successfully save and update on the front-end, so they are obviously registered successfully, however, I'm storing the options as theme specific via this meth... | If your settings are stored as **Theme Mods**, rather than as a **Settings API option**, then you need to pass [the appropriate value to the `type` parameter to `$wp_customize->add_setting()`](https://codex.wordpress.org/Class_Reference/WP_Customize_Manager/add_setting):
* `'option'`: Settings API option (`get_option(... |
94,183 | <p>Is it possible to have several custom fields with the same name? </p>
<p>For example, I have a custom field called "promotion" for a CPT called "event". Sometimes there are more than one promotion applied to the same event, each for a certain type of participant. So I'd like to have one "promotion" custom field wit... | [
{
"answer_id": 94186,
"author": "BigBagel",
"author_id": 26434,
"author_profile": "https://wordpress.stackexchange.com/users/26434",
"pm_score": 4,
"selected": true,
"text": "<p>Yes, it's possible to have multiple fields with the same key. </p>\n\n<p>When using <code>get_post_meta($post_... | 2013/04/01 | [
"https://wordpress.stackexchange.com/questions/94183",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11634/"
] | Is it possible to have several custom fields with the same name?
For example, I have a custom field called "promotion" for a CPT called "event". Sometimes there are more than one promotion applied to the same event, each for a certain type of participant. So I'd like to have one "promotion" custom field with a value ... | Yes, it's possible to have multiple fields with the same key.
When using `get_post_meta($post_id, $key, $single)`, make sure you set the `$single` parameter to `false` (or just leave it off since it defaults to `false`).
```
get_post_meta( $post->ID, 'Event Promotion', false )
```
or
```
get_post_meta( $post->ID,... |
94,191 | <p>With custom meta boxes, how would I go about displaying the background image (or color if no image is linked) within the page.</p>
<p>Code for the page where I want data to displayed. I want to apply the background color/image to section id="masthead".</p>
<pre><code><?php if (get_post_meta($post->ID, '_sqcm... | [
{
"answer_id": 94214,
"author": "Marco Berrocal",
"author_id": 28639,
"author_profile": "https://wordpress.stackexchange.com/users/28639",
"pm_score": 2,
"selected": true,
"text": "<p>You need to extract the value of the custom metabox (be this background color or background image) and t... | 2013/04/01 | [
"https://wordpress.stackexchange.com/questions/94191",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30833/"
] | With custom meta boxes, how would I go about displaying the background image (or color if no image is linked) within the page.
Code for the page where I want data to displayed. I want to apply the background color/image to section id="masthead".
```
<?php if (get_post_meta($post->ID, '_sqcmb_masthead_select', true)) ... | You need to extract the value of the custom metabox (be this background color or background image) and then, once you validate to make sure it has a value, which one is empty or what happens if both have values, to determine an INLINE-STYLING on the following piece of code:
```
<section id="masthead" style="backgroun... |
94,193 | <p>I have a custom post type with a custom taxonomy. I don't link to the taxonomy on the page but from the admin anyone can visit the taxonomy/term url and the unstyled list page will be visible. How can I force wp to not use the default layout (index.php) for that listing? What's the best method? For example I creat a... | [
{
"answer_id": 94195,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 1,
"selected": false,
"text": "<p>Check out the <a href=\"http://codex.wordpress.org/Template_Hierarchy#Custom_Taxonomies_display\" rel=\"nofollow... | 2013/04/01 | [
"https://wordpress.stackexchange.com/questions/94193",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30713/"
] | I have a custom post type with a custom taxonomy. I don't link to the taxonomy on the page but from the admin anyone can visit the taxonomy/term url and the unstyled list page will be visible. How can I force wp to not use the default layout (index.php) for that listing? What's the best method? For example I creat a ta... | If you just want to "turn off" the public facing part of a taxonomy (eg. just use it for grouping), you can do that when you [register it](http://codex.wordpress.org/Function_Reference/register_taxonomy).
Just set the `query_var` argument to `false` and WordPress will not recognize taxonomy page requests and simply 40... |
94,201 | <p>How do I display the loop inside a static page? Like the loop when I use the search (which in this theme it's actually working) or on index.php</p>
<p>An example for what I'm saying can be seen here: <a href="http://www.gaganews.com.br/noticias/" rel="nofollow">http://www.gaganews.com.br/noticias/</a> I want a page... | [
{
"answer_id": 94219,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 2,
"selected": true,
"text": "<p>You could use <a href=\"http://codex.wordpress.org/query_posts\" rel=\"nofollow\"><code>query_posts()</code></a> ... | 2013/04/01 | [
"https://wordpress.stackexchange.com/questions/94201",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29409/"
] | How do I display the loop inside a static page? Like the loop when I use the search (which in this theme it's actually working) or on index.php
An example for what I'm saying can be seen here: <http://www.gaganews.com.br/noticias/> I want a page like this, showing all my posts with pagination, since my home page is ki... | You could use [`query_posts()`](http://codex.wordpress.org/query_posts) to set up a new loop in your page. Assuming that the posts you want are in the category 'Noticias', with a slug of 'noticias':
```
query_posts( 'category=noticias' );
if( have_posts() ) {
get_template_part( 'loop', 'index' );
}
wp_reset_query(... |
94,203 | <p>Looking to add an action to <code>wp_head</code> but only if the user is in "theme customizer" mode. Does anyone know if there's a conditional for this?</p>
| [
{
"answer_id": 94219,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 2,
"selected": true,
"text": "<p>You could use <a href=\"http://codex.wordpress.org/query_posts\" rel=\"nofollow\"><code>query_posts()</code></a> ... | 2013/04/01 | [
"https://wordpress.stackexchange.com/questions/94203",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2527/"
] | Looking to add an action to `wp_head` but only if the user is in "theme customizer" mode. Does anyone know if there's a conditional for this? | You could use [`query_posts()`](http://codex.wordpress.org/query_posts) to set up a new loop in your page. Assuming that the posts you want are in the category 'Noticias', with a slug of 'noticias':
```
query_posts( 'category=noticias' );
if( have_posts() ) {
get_template_part( 'loop', 'index' );
}
wp_reset_query(... |
94,208 | <p>I must be doing something wrong here.</p>
<p>I setup my site with a static front page using front-page.php. I created a page in the admin with a title and chose the front-page.php in the template dropdown.</p>
<p>My title shows up fine, however the_content(); does not.</p>
<p>I'm not doing anything special as sho... | [
{
"answer_id": 94209,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>Well first of all, if you set your page as the static front page, you don't need to associate the template with the... | 2013/04/02 | [
"https://wordpress.stackexchange.com/questions/94208",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27059/"
] | I must be doing something wrong here.
I setup my site with a static front page using front-page.php. I created a page in the admin with a title and chose the front-page.php in the template dropdown.
My title shows up fine, however the\_content(); does not.
I'm not doing anything special as shown below.
```
<?php
/*... | You don't really have a Loop.
```
<?php get_header(); ?>
<div class="content">
<div class="welcome_area">
<div class="welcome_area_title"><?php the_title('');?></div>
<div class="welcome_area_text"><?php
if (have_posts()) {
while (have_posts()) {
the_post();
the_content();
}
} ?>
```
What is happening... |
94,212 | <p>I am working on a Wordpress theme that hides the default WYSIWYG editor and replaces it with a custom module system which is fine and dandy, but I've come to the realisation if someone were to use the theme on a pre-existing site they wouldn't be able to access their previously entered content which is obviously bad... | [
{
"answer_id": 94651,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Just check for <code>$_GET['post']</code>. New posts don't have a post ID:</p>\n\n<pre><code>add_action( 'load-post-ne... | 2013/04/02 | [
"https://wordpress.stackexchange.com/questions/94212",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1687/"
] | I am working on a Wordpress theme that hides the default WYSIWYG editor and replaces it with a custom module system which is fine and dandy, but I've come to the realisation if someone were to use the theme on a pre-existing site they wouldn't be able to access their previously entered content which is obviously bad.
... | You should really only need to run this on an existing post, since new posts will be created in the manner you specify.
```
add_action( 'load-post.php', 'custom_content_conversion' );
function custom_content_conversion()
{
if (! empty($_GET['post']) )
{
// Get the post object
$post = get_post($... |
94,215 | <p>How would I go about hiding a post based on a meta_value selection done on the back end.</p>
<p>The usual method is to just change the post status from Publish to Draft however, I want this to work based on a dropdown selection.</p>
<p>meta_key being <code>current_status</code> and a dropdown box with meta_value o... | [
{
"answer_id": 94216,
"author": "Marco Berrocal",
"author_id": 28639,
"author_profile": "https://wordpress.stackexchange.com/users/28639",
"pm_score": 0,
"selected": false,
"text": "<p>Within the loop, extract the value.</p>\n\n<p>Once you have it, do a simple <code>if</code> test to see... | 2013/04/02 | [
"https://wordpress.stackexchange.com/questions/94215",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30837/"
] | How would I go about hiding a post based on a meta\_value selection done on the back end.
The usual method is to just change the post status from Publish to Draft however, I want this to work based on a dropdown selection.
meta\_key being `current_status` and a dropdown box with meta\_value of `active` and `leased`.
... | Use the [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) action to alter the main query with [`meta_query`](https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters) arguments to only select posts with `active` `current_status`.
This example would work for you... |
94,220 | <p>When a user signs up on my site they have to select a date as part of resignation.</p>
<p>On their profile page I need to show a countdown to that date. Something simple like attached. How can I create this function?</p>
<p><img src="https://i.stack.imgur.com/F2Hhp.png" alt="enter image description here"></p>
| [
{
"answer_id": 94216,
"author": "Marco Berrocal",
"author_id": 28639,
"author_profile": "https://wordpress.stackexchange.com/users/28639",
"pm_score": 0,
"selected": false,
"text": "<p>Within the loop, extract the value.</p>\n\n<p>Once you have it, do a simple <code>if</code> test to see... | 2013/04/02 | [
"https://wordpress.stackexchange.com/questions/94220",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18085/"
] | When a user signs up on my site they have to select a date as part of resignation.
On their profile page I need to show a countdown to that date. Something simple like attached. How can I create this function?
 | Use the [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) action to alter the main query with [`meta_query`](https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters) arguments to only select posts with `active` `current_status`.
This example would work for you... |
94,233 | <p>Here is my basic plugin code. I am just starting from scratch. I will explain the functionality. It is simple, While my plugin is active it will add a new meta box in add new post page just below the tags box. The user can add a value to my text box & i will save that value with post ID to my table. You can unde... | [
{
"answer_id": 94216,
"author": "Marco Berrocal",
"author_id": 28639,
"author_profile": "https://wordpress.stackexchange.com/users/28639",
"pm_score": 0,
"selected": false,
"text": "<p>Within the loop, extract the value.</p>\n\n<p>Once you have it, do a simple <code>if</code> test to see... | 2013/04/02 | [
"https://wordpress.stackexchange.com/questions/94233",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23497/"
] | Here is my basic plugin code. I am just starting from scratch. I will explain the functionality. It is simple, While my plugin is active it will add a new meta box in add new post page just below the tags box. The user can add a value to my text box & i will save that value with post ID to my table. You can understand ... | Use the [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) action to alter the main query with [`meta_query`](https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters) arguments to only select posts with `active` `current_status`.
This example would work for you... |
94,251 | <p>I have been trying and searching to accomplish this. I have the "custom menu" widgets "Members Area", "Admin Area" in side bar, assigned menus to them. Fine, they display.</p>
<p>I want to show "Admin Area" widget only when the current user is admin. I believe it has something to do with adding a filter to "sidebar... | [
{
"answer_id": 94216,
"author": "Marco Berrocal",
"author_id": 28639,
"author_profile": "https://wordpress.stackexchange.com/users/28639",
"pm_score": 0,
"selected": false,
"text": "<p>Within the loop, extract the value.</p>\n\n<p>Once you have it, do a simple <code>if</code> test to see... | 2013/04/02 | [
"https://wordpress.stackexchange.com/questions/94251",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30853/"
] | I have been trying and searching to accomplish this. I have the "custom menu" widgets "Members Area", "Admin Area" in side bar, assigned menus to them. Fine, they display.
I want to show "Admin Area" widget only when the current user is admin. I believe it has something to do with adding a filter to "sidebars\_widgets... | Use the [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) action to alter the main query with [`meta_query`](https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters) arguments to only select posts with `active` `current_status`.
This example would work for you... |
94,256 | <p>I was looking at the user table and noticed for a super admin ( have access to network admin panel ) and an admin to a network site have same <code>wp_capabilities</code> which is <code>a:1:{s:13:"administrator";b:1;}</code> and also the <code>wp_user_level</code> is <code>10</code> for both.</p>
<p>So, I was wonde... | [
{
"answer_id": 94257,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 3,
"selected": true,
"text": "<p>Site admins are stored in a site option as an array of usernames.</p>\n\n<p>For example, using SQL in MySQLWor... | 2013/04/02 | [
"https://wordpress.stackexchange.com/questions/94256",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3094/"
] | I was looking at the user table and noticed for a super admin ( have access to network admin panel ) and an admin to a network site have same `wp_capabilities` which is `a:1:{s:13:"administrator";b:1;}` and also the `wp_user_level` is `10` for both.
So, I was wondering **what is the database value that differentiate b... | Site admins are stored in a site option as an array of usernames.
For example, using SQL in MySQLWorkbench you can do a query such as this:
```
SELECT * FROM wp_sitemeta where meta_key='site_admins';
```
To get back a serialised PHP array. Modifying this value by adding your username and user ID will make you a sit... |
94,267 | <p>I've got a piece of text in a div that I want to change on each page of my website. At the moment I'm not sure what function I should be using to do this. Here's what I have so far...</p>
<pre><code><?php
$page = is_page();
switch ($page){
case 'home':
$content = 'How much money....';
break;
case 'about':
$conte... | [
{
"answer_id": 94270,
"author": "Dominic",
"author_id": 9905,
"author_profile": "https://wordpress.stackexchange.com/users/9905",
"pm_score": 0,
"selected": false,
"text": "<p><code>is_page()</code> is a boolean function, it only returns true or false. </p>\n\n<p>You might find using <co... | 2013/04/02 | [
"https://wordpress.stackexchange.com/questions/94267",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30858/"
] | I've got a piece of text in a div that I want to change on each page of my website. At the moment I'm not sure what function I should be using to do this. Here's what I have so far...
```
<?php
$page = is_page();
switch ($page){
case 'home':
$content = 'How much money....';
break;
case 'about':
$content = 'We design..... | If you wanted to use your switch statement, you could use:
```
switch ($post->post_name){
case 'home':
$content = 'How much money....';
break;
case 'about':
$content = 'We design....';
break;
case 'services':
$content = 'At the....';
break;
case 'blog':
... |
94,273 | <p>Let's say that I have a post that I only want to be shown in the page of the category that it belongs to. The problem is that this post is also visible in the latest posts page.</p>
<p>Is there a way to hide this post from the latest post page and show it only in the page of the category of the post?</p>
| [
{
"answer_id": 94274,
"author": "Sagive",
"author_id": 7990,
"author_profile": "https://wordpress.stackexchange.com/users/7990",
"pm_score": 0,
"selected": false,
"text": "<p>Your question is hard to understand.. Do you mean a specific post or somthing automatic? if you mean a specific p... | 2013/04/02 | [
"https://wordpress.stackexchange.com/questions/94273",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30863/"
] | Let's say that I have a post that I only want to be shown in the page of the category that it belongs to. The problem is that this post is also visible in the latest posts page.
Is there a way to hide this post from the latest post page and show it only in the page of the category of the post? | ```
function exclude_single_posts_home($query) {
if ($query->is_home() && $query->is_main_query() && !is_admin()) {
$query->set('post__not_in', array(post-id));
}
}
add_action('pre_get_posts', 'exclude_single_posts_home');
```
Source: [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/p... |
94,284 | <p>I would like to redirect authors when they visit the URL <code>mynetwork.com/OWNBLOG/wp-admin/upload.php</code> to another page. How can I do that?</p>
<p>I tried this code but i received this error : </p>
<blockquote>
<p>"Warning: Cannot modify header information - headers already sent by (output started at /ho... | [
{
"answer_id": 94274,
"author": "Sagive",
"author_id": 7990,
"author_profile": "https://wordpress.stackexchange.com/users/7990",
"pm_score": 0,
"selected": false,
"text": "<p>Your question is hard to understand.. Do you mean a specific post or somthing automatic? if you mean a specific p... | 2013/04/02 | [
"https://wordpress.stackexchange.com/questions/94284",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29072/"
] | I would like to redirect authors when they visit the URL `mynetwork.com/OWNBLOG/wp-admin/upload.php` to another page. How can I do that?
I tried this code but i received this error :
>
> "Warning: Cannot modify header information - headers already sent by (output started at /home/content/59/104129/html/wp-admin/inc... | ```
function exclude_single_posts_home($query) {
if ($query->is_home() && $query->is_main_query() && !is_admin()) {
$query->set('post__not_in', array(post-id));
}
}
add_action('pre_get_posts', 'exclude_single_posts_home');
```
Source: [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/p... |
94,296 | <p>I am trying to migrate my blog from my local web server to an online web server and I have a doubt about this procedure.</p>
<p>I have uploaded all my local file in the root of my web server.</p>
<p>I have also export the tables of my local database (using phpMyAdmin) and I have import them on my online database.<... | [
{
"answer_id": 94274,
"author": "Sagive",
"author_id": 7990,
"author_profile": "https://wordpress.stackexchange.com/users/7990",
"pm_score": 0,
"selected": false,
"text": "<p>Your question is hard to understand.. Do you mean a specific post or somthing automatic? if you mean a specific p... | 2013/04/02 | [
"https://wordpress.stackexchange.com/questions/94296",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29275/"
] | I am trying to migrate my blog from my local web server to an online web server and I have a doubt about this procedure.
I have uploaded all my local file in the root of my web server.
I have also export the tables of my local database (using phpMyAdmin) and I have import them on my online database.
Then I have chan... | ```
function exclude_single_posts_home($query) {
if ($query->is_home() && $query->is_main_query() && !is_admin()) {
$query->set('post__not_in', array(post-id));
}
}
add_action('pre_get_posts', 'exclude_single_posts_home');
```
Source: [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/p... |
94,313 | <p>I'm launching a new WordPress theme and was wondering if it's possible to select and activate that specific page's template in code rather than going into the CMS and manually selecting it from the drop-down. I ask because once I launch the theme, a whole bunch of pages won't have a template associated with them unt... | [
{
"answer_id": 94319,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 2,
"selected": false,
"text": "<p>Presumably you are using wp_insert_post to create your pages. Having done so, do</p>\n\n<pre><code>update_pos... | 2013/04/02 | [
"https://wordpress.stackexchange.com/questions/94313",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17193/"
] | I'm launching a new WordPress theme and was wondering if it's possible to select and activate that specific page's template in code rather than going into the CMS and manually selecting it from the drop-down. I ask because once I launch the theme, a whole bunch of pages won't have a template associated with them until ... | Presumably you are using wp\_insert\_post to create your pages. Having done so, do
```
update_post_meta($id, '_wp_page_template', 'my_template.php');
``` |
94,315 | <p>I am using the article tag with the following code:</p>
<pre><code><article id="post-<?php the_ID(); ?>" <?php post_class('clearfix span4 '); ?> role="article">
</article>
</code></pre>
<p>and I would like to add "odd" and "even" to the current <code>post_class</code>.</p>
<p>I found the f... | [
{
"answer_id": 94317,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 4,
"selected": true,
"text": "<p>Try this (untested):</p>\n\n<pre><code><?php $zebra = (++$j % 2 == 0) ? 'evenpost' : 'oddpost'; ?>\n\n&l... | 2013/04/02 | [
"https://wordpress.stackexchange.com/questions/94315",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21245/"
] | I am using the article tag with the following code:
```
<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix span4 '); ?> role="article">
</article>
```
and I would like to add "odd" and "even" to the current `post_class`.
I found the following code on other site:
```
<?php echo (++$j % 2 == 0) ? 'even... | Try this (untested):
```
<?php $zebra = (++$j % 2 == 0) ? 'evenpost' : 'oddpost'; ?>
<article id="post-<?php the_ID(); ?>" <?php post_class('clearfix span4 ' . $zebra); ?> role="article">
```
You just need to place theodd/even class into a variable before passing it to post\_class. |
94,334 | <p>I registered a non-hierarchical custom taxonomy ('property_features').
There is a checkbox for every terms of this tax in a custom meta box on the edit-screen.
All terms are displayed and all terms wich are attached to the post are checked correctly.</p>
<p>So far so good...</p>
<p>... but when I check one of the... | [
{
"answer_id": 94344,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": -1,
"selected": false,
"text": "<blockquote>\n <p>When I change to 'hierarchical' => true in the register_taxonomy args everything works fine.... | 2013/04/02 | [
"https://wordpress.stackexchange.com/questions/94334",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30887/"
] | I registered a non-hierarchical custom taxonomy ('property\_features').
There is a checkbox for every terms of this tax in a custom meta box on the edit-screen.
All terms are displayed and all terms wich are attached to the post are checked correctly.
So far so good...
... but when I check one of the unchecked boxes... | This seems to be a core bug, spotted at 4.5 as well. Although documentation implies otherwise, you can not select in practice terms of non hierarchical taxonomies with the "checkoxed" metabox, the only working option is the "tag" style metabox. |
94,337 | <p>I am working on a WordPress plugin that creates several new tables into the database. It also loads some default data into the tables from CSV files. Most of these are small and loading the data works fine. One, however, is a zip code database meant to be loaded with just over 43,000 rows of data.</p>
<p>The first ... | [
{
"answer_id": 94352,
"author": "Jesse",
"author_id": 9145,
"author_profile": "https://wordpress.stackexchange.com/users/9145",
"pm_score": 3,
"selected": true,
"text": "<p>I have some suggestions for you:</p>\n\n<ul>\n<li>1, create MySQL insert queries on your own.</li>\n<li>2, combine ... | 2013/04/02 | [
"https://wordpress.stackexchange.com/questions/94337",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27707/"
] | I am working on a WordPress plugin that creates several new tables into the database. It also loads some default data into the tables from CSV files. Most of these are small and loading the data works fine. One, however, is a zip code database meant to be loaded with just over 43,000 rows of data.
The first time I tri... | I have some suggestions for you:
* 1, create MySQL insert queries on your own.
* 2, combine **multiple** insert values queries into one like
values(1,2,3),(4,5,6)
* 3, use `$wpdb->query` then
you need to figure out what the appropriate number of "**multiple**" is.
I've tried with 100 and it worked for me but I thin... |
94,338 | <p>I am trying to add a custom WordPress editor field to the General Settings page in the admin. I have it working except that when you save anything with HTML it converts all the code to HTML entities so the HTML displays on the frontend as text. For example...</p>
<ol>
<li>I add a link in the <strong>Text</strong>... | [
{
"answer_id": 94340,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 0,
"selected": false,
"text": "<p>From the <a href=\"http://codex.wordpress.org/Function_Reference/wp_editor\" rel=\"nofollow\">codex</a>:</p>\... | 2013/04/02 | [
"https://wordpress.stackexchange.com/questions/94338",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28787/"
] | I am trying to add a custom WordPress editor field to the General Settings page in the admin. I have it working except that when you save anything with HTML it converts all the code to HTML entities so the HTML displays on the frontend as text. For example...
1. I add a link in the **Text** editor as `<a href="http://... | I found out I needed to add `html_entity_decode()` around the value so my final code is...
```
/**
* Add Copyright text to general settings menu
*/
$custom_general_settings = new FD_Custom_General_Settings();
class FD_Custom_General_Settings
{
function __construct()
{
add_filter('admin_init', array(&... |
94,343 | <p>This is default get_template_part function inside WordPress:</p>
<pre><code>function get_template_part( $slug, $name = null ) {
do_action( "get_template_part_{$slug}", $slug, $name );
$templates = array();
if ( isset($name) )
$templates[] = "{$slug}-{$name}.php";
$templates[] = "{$slug}.ph... | [
{
"answer_id": 109402,
"author": "user36382",
"author_id": 36382,
"author_profile": "https://wordpress.stackexchange.com/users/36382",
"pm_score": 2,
"selected": false,
"text": "<pre>\n<code>\n/**\n*Extend WP Core get_template_part() function to load files from the within Plugin director... | 2013/04/02 | [
"https://wordpress.stackexchange.com/questions/94343",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1372/"
] | This is default get\_template\_part function inside WordPress:
```
function get_template_part( $slug, $name = null ) {
do_action( "get_template_part_{$slug}", $slug, $name );
$templates = array();
if ( isset($name) )
$templates[] = "{$slug}-{$name}.php";
$templates[] = "{$slug}.php";
loc... | ```
/**
*Extend WP Core get_template_part() function to load files from the within Plugin directory defined by PLUGIN_DIR_PATH constant
* * Load the page to be displayed
* from within plugin files directory only
* * @uses mec_locate_admin_menu_template() function
* * @param $slug * @param null $name
*/
function ... |
94,364 | <p>In a custom post type I have post titles disabled, however in the list of posts and in the slug it just shows the title as "auto-draft". I want to automatically take two pieces of post-meta and make then the title and the slug.</p>
<p>I thought this would work, but I can't make it happen:</p>
<pre><code>function s... | [
{
"answer_id": 94366,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 3,
"selected": true,
"text": "<p>You are using wrong variable on the following line:</p>\n\n<pre><code>$data['post_title'] = $post_title;\n<... | 2013/04/03 | [
"https://wordpress.stackexchange.com/questions/94364",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23492/"
] | In a custom post type I have post titles disabled, however in the list of posts and in the slug it just shows the title as "auto-draft". I want to automatically take two pieces of post-meta and make then the title and the slug.
I thought this would work, but I can't make it happen:
```
function set_event_title( $data... | You are using wrong variable on the following line:
```
$data['post_title'] = $post_title;
```
you should use $event\_title in $post\_title as following:
```
$data['post_title'] = $event_title;
```
Also Get Post ID from $postarr parameter.
**Updated Code :**
```
function set_event_title( $data , $postarr ) {
... |
94,377 | <p>I am really confused at this point. I can not figure it out how to rename <code>Edit My Profile</code> link in the admin backend.</p>
<p>How can that be done?</p>
| [
{
"answer_id": 94366,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 3,
"selected": true,
"text": "<p>You are using wrong variable on the following line:</p>\n\n<pre><code>$data['post_title'] = $post_title;\n<... | 2013/04/03 | [
"https://wordpress.stackexchange.com/questions/94377",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29581/"
] | I am really confused at this point. I can not figure it out how to rename `Edit My Profile` link in the admin backend.
How can that be done? | You are using wrong variable on the following line:
```
$data['post_title'] = $post_title;
```
you should use $event\_title in $post\_title as following:
```
$data['post_title'] = $event_title;
```
Also Get Post ID from $postarr parameter.
**Updated Code :**
```
function set_event_title( $data , $postarr ) {
... |
94,396 | <p>How can I set a limit to the <strong>top level</strong> menu items in <code>wp_nav_menu</code>?</p>
<p>Example:</p>
<p>I have this menu in my admin dashboard:</p>
<p><img src="https://i.stack.imgur.com/dVNg9.png" alt="Example menu"></p>
<p>I would like to count <strong>ONLY</strong> the top level items and displ... | [
{
"answer_id": 94403,
"author": "Simon",
"author_id": 9458,
"author_profile": "https://wordpress.stackexchange.com/users/9458",
"pm_score": 2,
"selected": false,
"text": "<p>According to the codex, you just need to use <code>depth</code>parameter to display only top-level pages : </p>\n\... | 2013/04/03 | [
"https://wordpress.stackexchange.com/questions/94396",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30910/"
] | How can I set a limit to the **top level** menu items in `wp_nav_menu`?
Example:
I have this menu in my admin dashboard:

I would like to count **ONLY** the top level items and display a limited number of them, let's say 5.
So no matter if you're in the admin das... | According to the codex, you just need to use `depth`parameter to display only top-level pages :
```
<?php wp_nav_menu( array( 'location' => 'your_location', 'depth' => 1 ) ); ?>
```
For more reference see [this](http://codex.wordpress.org/Function_Reference/wp_nav_menu).
You could also fix both of your problem by ... |
94,401 | <p>I am using the WordPress function <a href="http://codex.wordpress.org/Function_Reference/add_meta_box" rel="nofollow"><code>add_meta_box()</code></a> to add my own custom metabox.</p>
<p>So how can I auto close/hide on page open ?</p>
<p>Currently, I just add a CSS class <code>closed</code> to metabox's <code><... | [
{
"answer_id": 94404,
"author": "Johannes Pille",
"author_id": 9745,
"author_profile": "https://wordpress.stackexchange.com/users/9745",
"pm_score": 2,
"selected": false,
"text": "<p>The toggling of a metaboxes' open/close state is done via JS by WP as well - obviously so, since it happe... | 2013/04/03 | [
"https://wordpress.stackexchange.com/questions/94401",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6332/"
] | I am using the WordPress function [`add_meta_box()`](http://codex.wordpress.org/Function_Reference/add_meta_box) to add my own custom metabox.
So how can I auto close/hide on page open ?
Currently, I just add a CSS class `closed` to metabox's `<div>` element via jQuery like so:
**HTML :** (example)
```
<div id="my_... | Hook into `postbox_classes`. `postbox_classes` is the function which will output the classes for the metabox.
```
apply_filters( "postbox_classes_{$page}_{$id}", $classes )
```
Your code could look like this:
```
add_action( 'add_meta_boxes', 'add_my_metabox' );
function add_my_metabox() {
$id = 'my-metabo... |
94,411 | <p>I don't understand when to use $post->ID or $post->post->ID with CPTs. I have :</p>
<pre><code>$event = get_post( $event_id );
$event_pre_register = get_post_meta($event->post->ID, "Event Pre-register deadline", true);
</code></pre>
<p>Or is it : get_post_meta($event->ID ... ?</p>
| [
{
"answer_id": 94414,
"author": "Johannes Pille",
"author_id": 9745,
"author_profile": "https://wordpress.stackexchange.com/users/9745",
"pm_score": 2,
"selected": true,
"text": "<p>If you have the CPT's ID in the <code>$event_id</code> variable you plug into the <code>get_post()</code> ... | 2013/04/03 | [
"https://wordpress.stackexchange.com/questions/94411",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11634/"
] | I don't understand when to use $post->ID or $post->post->ID with CPTs. I have :
```
$event = get_post( $event_id );
$event_pre_register = get_post_meta($event->post->ID, "Event Pre-register deadline", true);
```
Or is it : get\_post\_meta($event->ID ... ? | If you have the CPT's ID in the `$event_id` variable you plug into the `get_post()` call - why would you not simply just (re)use that for the first parameter of `get_post_meta()` ?
That aside, [`get_post()`](http://codex.wordpress.org/Function_Reference/get_post) returns a post object (instance of WP\_Post), which you... |
94,420 | <p>I've gone through the various issues with headers already sent, checking for white space and making sure that the get_header line appears after the wp_redirect but I'm stuck.</p>
<p>The code is:</p>
<pre><code><?php if ( !is_user_logged_in()) {
include (TEMPLATEPATH . '/member.php');
} else { ?>... | [
{
"answer_id": 94421,
"author": "anjali",
"author_id": 30686,
"author_profile": "https://wordpress.stackexchange.com/users/30686",
"pm_score": 1,
"selected": false,
"text": "<p>try this.</p>\n\n<pre><code> echo 'Please enter a title';\n</code></pre>\n\n<p>Remove this line & check you... | 2013/04/03 | [
"https://wordpress.stackexchange.com/questions/94420",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7408/"
] | I've gone through the various issues with headers already sent, checking for white space and making sure that the get\_header line appears after the wp\_redirect but I'm stuck.
The code is:
```
<?php if ( !is_user_logged_in()) {
include (TEMPLATEPATH . '/member.php');
} else { ?>
<?php
if( 'POST' == $_S... | try this.
```
echo 'Please enter a title';
```
Remove this line & check your output. |
94,446 | <p>I am currently using the following code to display a list with links to posts in a specific CPT and taxonomy:</p>
<pre><code> <?php
$custom_terms = get_terms('videoscategory');
foreach(array($custom_terms as $custom_term) {
wp_reset_query();
$args = array('post_type' => 'product',
'tax_query... | [
{
"answer_id": 94452,
"author": "montrealist",
"author_id": 8105,
"author_profile": "https://wordpress.stackexchange.com/users/8105",
"pm_score": 2,
"selected": false,
"text": "<p>According to <a href=\"https://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters\" rel=\"nofo... | 2013/04/03 | [
"https://wordpress.stackexchange.com/questions/94446",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24067/"
] | I am currently using the following code to display a list with links to posts in a specific CPT and taxonomy:
```
<?php
$custom_terms = get_terms('videoscategory');
foreach(array($custom_terms as $custom_term) {
wp_reset_query();
$args = array('post_type' => 'product',
'tax_query' => array(
'r... | Ok I figured it out!
```
<?php
$custom_terms = get_terms('your_other_category');
$other_custom_terms = get_terms('your_category');
foreach ($custom_terms as $custom_term) {
foreach ($other_custom_terms as $other_custom_term) {
wp_reset_query();
$args = array('post_type' => 'product',
'tax_query' => ar... |
94,477 | <pre><code>$.ajax({
type: "POST",
dataType: "text",
url: ajaxurl,
data: {
action: "more_news",
nonce: nonce,
offset: offset
},
success : function(data, textStatus, jqXHR){
console.log( nonce );
console.log( data );
console.log( textStat... | [
{
"answer_id": 94494,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>The second parameter for <code>wp_verify_nonce()</code> is the action. That part is not in your question, but I guess ... | 2013/04/03 | [
"https://wordpress.stackexchange.com/questions/94477",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7855/"
] | ```
$.ajax({
type: "POST",
dataType: "text",
url: ajaxurl,
data: {
action: "more_news",
nonce: nonce,
offset: offset
},
success : function(data, textStatus, jqXHR){
console.log( nonce );
console.log( data );
console.log( textStatus );
... | The second parameter for `wp_verify_nonce()` is the action. That part is not in your question, but I guess it should be called like:
```
if ( !wp_verify_nonce($_POST['nonce'], $_POST['action']) ){
``` |
94,482 | <p>What I'm simply trying to do is grab the featured image thumbnail image from a specified post/page and display that image on any other page somewhere.</p>
<p>So for instance, if it's a single post, use the thumbnail from post 9. If it's this page, use the thumbnail from 82, and so on.</p>
<p>It doesn't seem as si... | [
{
"answer_id": 94492,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>Each post object has a public member <code>$post_parent</code>. That is the post ID of the parent post. So this should... | 2013/04/03 | [
"https://wordpress.stackexchange.com/questions/94482",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27059/"
] | What I'm simply trying to do is grab the featured image thumbnail image from a specified post/page and display that image on any other page somewhere.
So for instance, if it's a single post, use the thumbnail from post 9. If it's this page, use the thumbnail from 82, and so on.
It doesn't seem as simple as this:
```... | Looks like this might be the reason why it wasn't working the way I needed.
before -> if ( has\_post\_thumbnail () )
Seems that only relates to the specific post/page you're on, and not the page/page that you're getting the image from - if you don't enter a post ID. But then I tried it with the post ID I was trying t... |
94,493 | <p>I have 2 loops, movie trailers and gaming trailers but gaming trailers is displaying under both Movie Trailers and Gaming Trailer. Each loop displays the post tagged with either <code>Movie Trailer</code> or <code>Gaming Trailer</code>. </p>
<p>How do I get posts tagged with "Movie Trailers" under the movies area ... | [
{
"answer_id": 94496,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 1,
"selected": false,
"text": "<p>I think you have misunderstood the use of <code>pre_get_posts()</code>. You'd normally use this in your funct... | 2013/04/03 | [
"https://wordpress.stackexchange.com/questions/94493",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15330/"
] | I have 2 loops, movie trailers and gaming trailers but gaming trailers is displaying under both Movie Trailers and Gaming Trailer. Each loop displays the post tagged with either `Movie Trailer` or `Gaming Trailer`.
How do I get posts tagged with "Movie Trailers" under the movies area and posts tagged with "Gaming Tra... | You can't add the pre\_get\_posts action right before the loop. You HAVE to do it in functions.php. It has to be set before the site actually queries the db to set up the loop which happens before your template file is loaded.
What you are doing is looping through the exact same query twice, because pre\_get\_posts ca... |
94,506 | <p>I am writing a plugin that upon activation creates a set of pages. The first page that I create I want to be the parent of the rest of the pages that are added. For some reason, this is not working. Can someone please take a look at my code and tell me what I have wrong?</p>
<p>The code I use to add the first pa... | [
{
"answer_id": 94496,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 1,
"selected": false,
"text": "<p>I think you have misunderstood the use of <code>pre_get_posts()</code>. You'd normally use this in your funct... | 2013/04/04 | [
"https://wordpress.stackexchange.com/questions/94506",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30695/"
] | I am writing a plugin that upon activation creates a set of pages. The first page that I create I want to be the parent of the rest of the pages that are added. For some reason, this is not working. Can someone please take a look at my code and tell me what I have wrong?
The code I use to add the first page and return... | You can't add the pre\_get\_posts action right before the loop. You HAVE to do it in functions.php. It has to be set before the site actually queries the db to set up the loop which happens before your template file is loaded.
What you are doing is looping through the exact same query twice, because pre\_get\_posts ca... |
94,526 | <p>I created custom post type. I created category called product-categories. I listed all categories in sidebar.php. How to show the sidebar in all the category pages listing all the categories. Sidebar.php code is,</p>
'name',
'order' => 'ASC',
'hide_empty' => 0,
'use_des... | [
{
"answer_id": 94496,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 1,
"selected": false,
"text": "<p>I think you have misunderstood the use of <code>pre_get_posts()</code>. You'd normally use this in your funct... | 2013/04/04 | [
"https://wordpress.stackexchange.com/questions/94526",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29257/"
] | I created custom post type. I created category called product-categories. I listed all categories in sidebar.php. How to show the sidebar in all the category pages listing all the categories. Sidebar.php code is,
'name',
'order' => 'ASC',
'hide\_empty' => 0,
'use\_desc\_for\_title' => 1,
'child\_of' => 21,
'hier... | You can't add the pre\_get\_posts action right before the loop. You HAVE to do it in functions.php. It has to be set before the site actually queries the db to set up the loop which happens before your template file is loaded.
What you are doing is looping through the exact same query twice, because pre\_get\_posts ca... |
94,530 | <p>I have installed <code>Advanced Custom Fields 4.0.1</code> and created a new <code>Field group</code> containing a single field called <code>preamble</code>. I would like to position this new field before the editor in the posts edit screen. It seems like all custom fields always are added after a posts ordinary fie... | [
{
"answer_id": 94604,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 2,
"selected": false,
"text": "<p>I've checked into this a bit. I looked at the ACF source. The plain fields that ACF uses are still actually ... | 2013/04/04 | [
"https://wordpress.stackexchange.com/questions/94530",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14870/"
] | I have installed `Advanced Custom Fields 4.0.1` and created a new `Field group` containing a single field called `preamble`. I would like to position this new field before the editor in the posts edit screen. It seems like all custom fields always are added after a posts ordinary fields.
A solution wouldn't be to drop... | This can be solved using [this nice snippet](https://wordpress.stackexchange.com/a/88103/12615) and `edit_form_after_title` hook. But I haven't tested what happens when more than one meta box exists. With a single ACF field (`position:normal, style:no-metabox`) it works:
```
add_action( 'edit_form_after_title', 'pre_t... |
94,554 | <p>I have the following custom meta-box, which works to list a post type, I simply want to allow multiple values to be selected but cannot get it to work, it appears if I tell the select to store multiple and set the name to be an array Wordpress does not store any value.</p>
<p><a href="http://pastebin.com/VLQGZjmu" ... | [
{
"answer_id": 94604,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 2,
"selected": false,
"text": "<p>I've checked into this a bit. I looked at the ACF source. The plain fields that ACF uses are still actually ... | 2013/04/04 | [
"https://wordpress.stackexchange.com/questions/94554",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30978/"
] | I have the following custom meta-box, which works to list a post type, I simply want to allow multiple values to be selected but cannot get it to work, it appears if I tell the select to store multiple and set the name to be an array Wordpress does not store any value.
<http://pastebin.com/VLQGZjmu>
After hours of tr... | This can be solved using [this nice snippet](https://wordpress.stackexchange.com/a/88103/12615) and `edit_form_after_title` hook. But I haven't tested what happens when more than one meta box exists. With a single ACF field (`position:normal, style:no-metabox`) it works:
```
add_action( 'edit_form_after_title', 'pre_t... |
94,565 | <p>I am trying to find a way to link the 'username' in comments from <strong>registered</strong> and <strong>logged in</strong> users to their profile pages instead of their website URL. And comments from unregistered users to their website URL as usual.</p>
<p>Is this possible? My wordpress version is 3.5.1 and I am ... | [
{
"answer_id": 94570,
"author": "gdaniel",
"author_id": 30984,
"author_profile": "https://wordpress.stackexchange.com/users/30984",
"pm_score": 1,
"selected": false,
"text": "<p>If the users are already logged in, then simply pointing to the admin page would have them see their profile. ... | 2013/04/04 | [
"https://wordpress.stackexchange.com/questions/94565",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30729/"
] | I am trying to find a way to link the 'username' in comments from **registered** and **logged in** users to their profile pages instead of their website URL. And comments from unregistered users to their website URL as usual.
Is this possible? My wordpress version is 3.5.1 and I am using the default theme Twenty Twelv... | I have written a solution for that some time ago:
```
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 Comment author URI to blog author page
* Description: Changes the comment author URI to the blog’s author archive
* Version: 2012.07.18
* Author: Fuxia Scholz
* Author URI: https://fuxia.me
* Licen... |
94,566 | <p>I want to show activity loop for certain groups only.</p>
<p>If I use</p>
<pre><code><?php if ( bp_has_activities( array(bp_ajax_querystring( 'activity' ),'object' => 'groups','per_page'=>6 ,'primary_id' => $group_id, 'page' => isset($_REQUEST['page']) ? $_REQUEST['page'] : 1 ) ) ) : ?>
</code></... | [
{
"answer_id": 94824,
"author": "shanebp",
"author_id": 16575,
"author_profile": "https://wordpress.stackexchange.com/users/16575",
"pm_score": 0,
"selected": false,
"text": "<p>You should state which version of BP you're using. </p>\n\n<p>Try using:</p>\n\n<pre><code>function groups_get... | 2013/04/04 | [
"https://wordpress.stackexchange.com/questions/94566",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4130/"
] | I want to show activity loop for certain groups only.
If I use
```
<?php if ( bp_has_activities( array(bp_ajax_querystring( 'activity' ),'object' => 'groups','per_page'=>6 ,'primary_id' => $group_id, 'page' => isset($_REQUEST['page']) ? $_REQUEST['page'] : 1 ) ) ) : ?>
```
I can pass one group ID to filter results.... | After getting all the groups\_ids i get all activities\_ids by doing:
```
<?php
global $bp,$wpdb;
$groups_ids = implode(', ', $groups_ids);
$sql = "SELECT id FROM {$bp->activity->table_name} WHERE component = 'groups' AND item_id IN ({$groups_ids})";
$activity_ids = $wpdb->get_results( $sql);
$a_id... |
94,585 | <p>From what I have gathered, once a nonce is generated it is valid for reuse for the next 48 hours.</p>
<p>Is it safe to code with this in mind? I'm writing a plugin that does a bit of toing and froing with the client via AJAX and want to know if I should just generate a nonce when the page loads and use that for all... | [
{
"answer_id": 94590,
"author": "Andy",
"author_id": 498,
"author_profile": "https://wordpress.stackexchange.com/users/498",
"pm_score": 0,
"selected": false,
"text": "<p>WordPress nonces are not use-once. You can reuse the nonce as often as you like until it expires.</p>\n"
},
{
... | 2013/04/04 | [
"https://wordpress.stackexchange.com/questions/94585",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29162/"
] | From what I have gathered, once a nonce is generated it is valid for reuse for the next 48 hours.
Is it safe to code with this in mind? I'm writing a plugin that does a bit of toing and froing with the client via AJAX and want to know if I should just generate a nonce when the page loads and use that for all communica... | 1, the nonce lifetime is about 24 hours by default actually. take a look at [wp\_verify\_nonce](http://codex.wordpress.org/Function_Reference/wp_verify_nonce#Return_Values) function.
To be more accurate, the lifetime is controlled by filter
```
apply_filters( 'nonce_life', DAY_IN_SECONDS );
```
2, if the lifetime v... |
94,617 | <p>I am creating a widget, it needs to store about 10 IDs. Right now I'm using following field method to store each of the ID in a separate field. It stores data of each field in a separately in the wordpress. Is it possible to store the data of all fields in just one row in wordpress for examlpe using an array?</p>
<... | [
{
"answer_id": 94625,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>You have to collect multiple fields under the same name like this …</p>\n\n<pre><code>name=\"collect[1]\"\nname=\"colle... | 2013/04/04 | [
"https://wordpress.stackexchange.com/questions/94617",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31005/"
] | I am creating a widget, it needs to store about 10 IDs. Right now I'm using following field method to store each of the ID in a separate field. It stores data of each field in a separately in the wordpress. Is it possible to store the data of all fields in just one row in wordpress for examlpe using an array?
```
<inp... | You have to collect multiple fields under the same name like this …
```
name="collect[1]"
name="collect[2]"
```
… and adjust your widget logic to this.
Here is a very simple demo widget:
```
<?php # -*- coding: utf-8 -*-
/* Plugin Name: Store Options as array */
add_action( 'widgets_init', array ( 'T5_Array_Opti... |
94,626 | <p>I set static page as front page.</p>
<p>I need to know if user currently on homepage in my custom plugin.</p>
<p>Functions <strong>is_home()</strong> and <strong>is_front_page()</strong> doesn't works, since homepage is static page.</p>
<p>I can get an id of this page :</p>
<pre><code>$frontpage_id = get_option(... | [
{
"answer_id": 94628,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>I guess you are talking about the editor screen? If so, you can use the global variable <code>$post_ID</code>:</p>\n\n... | 2013/04/04 | [
"https://wordpress.stackexchange.com/questions/94626",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27485/"
] | I set static page as front page.
I need to know if user currently on homepage in my custom plugin.
Functions **is\_home()** and **is\_front\_page()** doesn't works, since homepage is static page.
I can get an id of this page :
```
$frontpage_id = get_option('page_on_front');
```
But how to get id of current page ... | This is why I asked for more code context. I'll have to guess that you are checking for the front page outside of any hooked function, or inside a function that is called too early, before is\_front\_page() is ready.
The following will work.
```
function your_function() {
$d = is_front_page();
var_dump($d);
}
add_a... |
94,630 | <p>I have a custom post type that has custom meta that I want to be able to filter on the Admin page. Much like the "All | Published | Drafts | and Trash" links located above the post list. I can't seem to find a hook to hook into. Does one exist?</p>
<p><a href="https://wordpress.stackexchange.com/questions/578/addi... | [
{
"answer_id": 94723,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 4,
"selected": true,
"text": "<p>Just like in <a href=\"https://wordpress.stackexchange.com/q/578/12615\">Adding a Taxonomy Filter to Admin Li... | 2013/04/04 | [
"https://wordpress.stackexchange.com/questions/94630",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18501/"
] | I have a custom post type that has custom meta that I want to be able to filter on the Admin page. Much like the "All | Published | Drafts | and Trash" links located above the post list. I can't seem to find a hook to hook into. Does one exist?
[This question](https://wordpress.stackexchange.com/questions/578/adding-a... | Just like in [Adding a Taxonomy Filter to Admin List for a Custom Post Type?](https://wordpress.stackexchange.com/q/578/12615) the filter `parse_query` could be used, but here I'm using `posts_where`.
---
The row `All | Published | ...` is controlled by `views_edit-{$post_type}` and the `$views` array contains each i... |
94,639 | <p>I have an action hook which works perfectly for the_content.
I would like to apply the same hook anytime a handful of custom_fields are requested.</p>
<p>The custom fields are 1) myfieldone 2) myfieldart 3) myfieldestion
So lets just take one of those - "myfieldone"
Is there a way - where anytime "myfieldone" custo... | [
{
"answer_id": 94732,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n <p>How would I apply the same filter to meta key value?</p>\n</blockquote>\n\n<p>What you are tr... | 2013/04/04 | [
"https://wordpress.stackexchange.com/questions/94639",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31011/"
] | I have an action hook which works perfectly for the\_content.
I would like to apply the same hook anytime a handful of custom\_fields are requested.
The custom fields are 1) myfieldone 2) myfieldart 3) myfieldestion
So lets just take one of those - "myfieldone"
Is there a way - where anytime "myfieldone" custom field ... | I have no experience with the `get_{$meta_type}_metadata` filter either, hence all I can offer is a further approach to a possible workaround:
*Iff* you don't need to satisfy third parties using `get_post_meta`, but only want to use the filter in your own code, you could write a custom wrapper for `get_post_meta`, whi... |
94,644 | <p>I made a site some time ago and after some days some posts were indexed by search engines. Today I changed the permalink structure from <code>/%postname%/</code> to <code>/%category%/%postname%/</code>.</p>
<p>After that, when people come to my site from search engines a <code>404 page not found error</code> appea... | [
{
"answer_id": 94645,
"author": "Griffin",
"author_id": 10036,
"author_profile": "https://wordpress.stackexchange.com/users/10036",
"pm_score": 0,
"selected": false,
"text": "<p>You need to add 301 redirects from your old page urls to the new ones.</p>\n\n<p>This plugin should accomplish... | 2013/04/04 | [
"https://wordpress.stackexchange.com/questions/94644",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31016/"
] | I made a site some time ago and after some days some posts were indexed by search engines. Today I changed the permalink structure from `/%postname%/` to `/%category%/%postname%/`.
After that, when people come to my site from search engines a `404 page not found error` appears. I want to change all old URLs to the new... | That happens because WordPress reads your old post name as category name now - and it cannot find that category.
Solution: filter `404_template` and try to find the post and its permalink. Then redirect.
```
<?php # -*- coding: utf-8 -*-
/* Plugin Name: Redirect to category */
add_filter( '404_template', 't5_redire... |
94,659 | <p>I have WP website with over 40,000 posts. Now I'll like to delete all posts, categories and tags. So All content and related meta. All I want to keep is static files. Is there a easy way to do this through database? Some query to drop all relevant tables? Sorry, I am not good with db and code, so please give me deta... | [
{
"answer_id": 94660,
"author": "Mophilly",
"author_id": 21058,
"author_profile": "https://wordpress.stackexchange.com/users/21058",
"pm_score": 0,
"selected": false,
"text": "<p>You wrote that you are not good with database, so please be extremely careful with the advice I present here.... | 2013/04/05 | [
"https://wordpress.stackexchange.com/questions/94659",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30851/"
] | I have WP website with over 40,000 posts. Now I'll like to delete all posts, categories and tags. So All content and related meta. All I want to keep is static files. Is there a easy way to do this through database? Some query to drop all relevant tables? Sorry, I am not good with db and code, so please give me detaile... | Use [WP-CLI](https://wp-cli.org/commands/db/reset/) to remove all tables from the database in MySQL.
>
> Runs DROP\_DATABASE and CREATE\_DATABASE MySQL statements using DB\_HOST, DB\_NAME, DB\_USER and DB\_PASSWORD database credentials specified in wp-config.php.
>
>
>
```
wp db reset --yes
``` |
94,663 | <p>How do I add an id attribute dynamically to every heading tag on a wordpress website using php? I wanted to make it so that for every heading tag (h1, h2, h3, h4, h5, h6) I have a unique id attached so that it would be like: <code><h1 id="this_is_sparta">This Is Sparta</h1></code></p>
<p>So I can link t... | [
{
"answer_id": 94666,
"author": "Rajeev Vyas",
"author_id": 6961,
"author_profile": "https://wordpress.stackexchange.com/users/6961",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <code>the_content</code> filter, and then find all header tags in content and add ids. </p>\n\n<... | 2013/04/05 | [
"https://wordpress.stackexchange.com/questions/94663",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31020/"
] | How do I add an id attribute dynamically to every heading tag on a wordpress website using php? I wanted to make it so that for every heading tag (h1, h2, h3, h4, h5, h6) I have a unique id attached so that it would be like: `<h1 id="this_is_sparta">This Is Sparta</h1>`
So I can link to it using `<a href="#this_is_spa... | I had this very same dilemma, and I found this plugin: [Add IDs to Header Tags](https://wordpress.org/plugins/add-ids-to-header-tags/), and it works fine for posts. (I'm not affiliated to the plugin in any way).
To make it work for pages too, I had to make a change in the code, which is explained on this support page:... |
94,701 | <p>I have a question. I have a custom post type called Place. I have a situation that there can be place in place. I want to have a custom field <code>parent_place</code> where I could choose a parent of place.<br>
The Place can have none or one parent. </p>
<p>Is there any posibility to list all posts (<code>type = p... | [
{
"answer_id": 94666,
"author": "Rajeev Vyas",
"author_id": 6961,
"author_profile": "https://wordpress.stackexchange.com/users/6961",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <code>the_content</code> filter, and then find all header tags in content and add ids. </p>\n\n<... | 2013/04/05 | [
"https://wordpress.stackexchange.com/questions/94701",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25675/"
] | I have a question. I have a custom post type called Place. I have a situation that there can be place in place. I want to have a custom field `parent_place` where I could choose a parent of place.
The Place can have none or one parent.
Is there any posibility to list all posts (`type = place`) in custom field and ... | I had this very same dilemma, and I found this plugin: [Add IDs to Header Tags](https://wordpress.org/plugins/add-ids-to-header-tags/), and it works fine for posts. (I'm not affiliated to the plugin in any way).
To make it work for pages too, I had to make a change in the code, which is explained on this support page:... |
94,714 | <p>Can anyone tell me how to get all the users who have author privileges by querying the DB in WordPress and order them by number of posts written by them.</p>
<p>I use the following query to get all the users from DB:</p>
<pre><code>$authors = $wpdb->get_results(
"SELECT ID, user_nicename from $wpdb->user... | [
{
"answer_id": 94715,
"author": "Rajeev Vyas",
"author_id": 6961,
"author_profile": "https://wordpress.stackexchange.com/users/6961",
"pm_score": 1,
"selected": false,
"text": "<pre><code>$args = array();\n$args['fields'] = array( 'ID', 'display_name' );\n$args['role'] = 'author';\n$auth... | 2013/04/05 | [
"https://wordpress.stackexchange.com/questions/94714",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28044/"
] | Can anyone tell me how to get all the users who have author privileges by querying the DB in WordPress and order them by number of posts written by them.
I use the following query to get all the users from DB:
```
$authors = $wpdb->get_results(
"SELECT ID, user_nicename from $wpdb->users ORDER BY display_name"
);... | Unless you want to retrieve custom data from the database, you will hardly ever need to make use of the [`WPDB`](http://codex.wordpress.org/Class_Reference/wpdb) class (or its global object, respectively). Though it is obviously possible to do things that way as well.
Just for the sake of completeness, *if* you had a ... |
94,739 | <p>I want to insert post programatically so here is the code to add one:</p>
<pre><code>global $user_ID;
$new_post = array(
'post_title' => 'My New Post',
'post_content' => 'Lorem ipsum dolor sit amet...',
'post_status' => 'publish',
'post_date' => date('Y-m-d H:i:s'),
'post_author' =&g... | [
{
"answer_id": 94745,
"author": "dipali",
"author_id": 20711,
"author_profile": "https://wordpress.stackexchange.com/users/20711",
"pm_score": -1,
"selected": false,
"text": "<pre><code> $wp_filetype = wp_check_filetype(basename($filename), null );\n $wp_upload_dir = wp_upload_dir();\n ... | 2013/04/05 | [
"https://wordpress.stackexchange.com/questions/94739",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24411/"
] | I want to insert post programatically so here is the code to add one:
```
global $user_ID;
$new_post = array(
'post_title' => 'My New Post',
'post_content' => 'Lorem ipsum dolor sit amet...',
'post_status' => 'publish',
'post_date' => date('Y-m-d H:i:s'),
'post_author' => $user_ID,
'post_type' ... | The post thumbnail is just saved as post meta with the key: `_thumbnail_id`. So after you insert the post and get the post id, you can set the post meta for that post. The `$thumbnail_id` is just the ID of the image you'd like to set as the thumbnail, up to you since I can't tell from your question what this should be.... |
94,762 | <p>I am using the technique described here <a href="https://wordpress.stackexchange.com/questions/14881/seperating-custom-post-search-results">Seperating Custom Post Search Results</a> and here <a href="https://wordpress.stackexchange.com/questions/74798/posts-groupby-problem">posts_groupby problem</a> to seperate my s... | [
{
"answer_id": 94769,
"author": "montrealist",
"author_id": 8105,
"author_profile": "https://wordpress.stackexchange.com/users/8105",
"pm_score": 2,
"selected": true,
"text": "<p>What kind of control do you want exactly? There are, for example, plugins that provide a UI through which you... | 2013/04/05 | [
"https://wordpress.stackexchange.com/questions/94762",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13663/"
] | I am using the technique described here [Seperating Custom Post Search Results](https://wordpress.stackexchange.com/questions/14881/seperating-custom-post-search-results) and here [posts\_groupby problem](https://wordpress.stackexchange.com/questions/74798/posts-groupby-problem) to seperate my search results and group ... | What kind of control do you want exactly? There are, for example, plugins that provide a UI through which you can order posts by various parameters.
If you just want to order them all by one parameter that will not change, you can simply add it to your query (since [you can order by multiple conditions](https://stack... |
94,764 | <p>I am wanting to update the meta_key in the database to reorder postmeta from the frontend.
I'm using jQuery UI drag and drop to move items into an order, I can update the values but the meta_key is not so easy. My meta_key and values are like this:</p>
<ul>
<li>add_task_0_assigned => value</li>
<li>add_task_0_compl... | [
{
"answer_id": 94769,
"author": "montrealist",
"author_id": 8105,
"author_profile": "https://wordpress.stackexchange.com/users/8105",
"pm_score": 2,
"selected": true,
"text": "<p>What kind of control do you want exactly? There are, for example, plugins that provide a UI through which you... | 2013/04/05 | [
"https://wordpress.stackexchange.com/questions/94764",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31057/"
] | I am wanting to update the meta\_key in the database to reorder postmeta from the frontend.
I'm using jQuery UI drag and drop to move items into an order, I can update the values but the meta\_key is not so easy. My meta\_key and values are like this:
* add\_task\_0\_assigned => value
* add\_task\_0\_complete => value... | What kind of control do you want exactly? There are, for example, plugins that provide a UI through which you can order posts by various parameters.
If you just want to order them all by one parameter that will not change, you can simply add it to your query (since [you can order by multiple conditions](https://stack... |
94,774 | <p>I have a client who has requested a WP based portfolio where they will present their projects and clients, filtered by categories and tags. They also wish to filter all projects done for a particular client. I decided to use regular posts for the projects, but I'm unsure as to what would be a good setup for clients.... | [
{
"answer_id": 94769,
"author": "montrealist",
"author_id": 8105,
"author_profile": "https://wordpress.stackexchange.com/users/8105",
"pm_score": 2,
"selected": true,
"text": "<p>What kind of control do you want exactly? There are, for example, plugins that provide a UI through which you... | 2013/04/05 | [
"https://wordpress.stackexchange.com/questions/94774",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3390/"
] | I have a client who has requested a WP based portfolio where they will present their projects and clients, filtered by categories and tags. They also wish to filter all projects done for a particular client. I decided to use regular posts for the projects, but I'm unsure as to what would be a good setup for clients.
... | What kind of control do you want exactly? There are, for example, plugins that provide a UI through which you can order posts by various parameters.
If you just want to order them all by one parameter that will not change, you can simply add it to your query (since [you can order by multiple conditions](https://stack... |
94,776 | <p>I'm actually building custom type to WP and need to be able to restrict post access to some user role, ie. in admin area, collaborators can see posts but can't edit them, just only open them as read-only. I used some plugins (Adminimize and User Role Editor) but, as far as I know, they don't apply to my needs.</p>
... | [
{
"answer_id": 94778,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 2,
"selected": false,
"text": "<p>If you simply remove the meta box, there's no way of saving/updating the post. Tested here with the regular ... | 2013/04/06 | [
"https://wordpress.stackexchange.com/questions/94776",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31062/"
] | I'm actually building custom type to WP and need to be able to restrict post access to some user role, ie. in admin area, collaborators can see posts but can't edit them, just only open them as read-only. I used some plugins (Adminimize and User Role Editor) but, as far as I know, they don't apply to my needs.
Does an... | brasolfilo's suggestion that you remove the submit meta box is only part of what I'd consider a complete solution. I can hack a "submit" button into that page using FireBug or any of a few other tools, in a matter of minutes.
I would...
1. Remove the meta box. This is brasofilo's solution, and I won't elaborate as t... |
94,787 | <p>I am trying to get all the IDs in my navigation and convert it to a string so that I can use it with <code>wp_query</code> to get the pages that are only listed in the nav. The code to get the IDs:</p>
<pre><code>$menu_name = 'primary';
if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $... | [
{
"answer_id": 94793,
"author": "anu",
"author_id": 490,
"author_profile": "https://wordpress.stackexchange.com/users/490",
"pm_score": 5,
"selected": true,
"text": "<p>Menu items are stored in the <code>posts</code> table with a <code>post_type</code> of <code>nav_menu_item</code>. So, ... | 2013/04/06 | [
"https://wordpress.stackexchange.com/questions/94787",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14761/"
] | I am trying to get all the IDs in my navigation and convert it to a string so that I can use it with `wp_query` to get the pages that are only listed in the nav. The code to get the IDs:
```
$menu_name = 'primary';
if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] )) {
$menu = wp_g... | Menu items are stored in the `posts` table with a `post_type` of `nav_menu_item`. So, what you are returning is the ID of the menu item itself, not what it points to.
The page/post ID that the menu item refers to is stored in the `postmeta` table, with a `post_id` that matches the menu item `ID` and `meta_key` = `_men... |
94,808 | <p>I installed a plugin for my users in WPMU and I want to make it appear at the end of the admin menu ....</p>
<p>I tried this but the menu never appears at the end:</p>
<pre><code>function custom_menu_order($menu_ord) {
if (!$menu_ord) return true;
return array(
'index.php', // Dashboard
'edit.php'... | [
{
"answer_id": 94839,
"author": "Simon Blackbourn",
"author_id": 2877,
"author_profile": "https://wordpress.stackexchange.com/users/2877",
"pm_score": 0,
"selected": false,
"text": "<p>Are you using <a href=\"http://codex.wordpress.org/Function_Reference/add_menu_page\" rel=\"nofollow\">... | 2013/04/06 | [
"https://wordpress.stackexchange.com/questions/94808",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29072/"
] | I installed a plugin for my users in WPMU and I want to make it appear at the end of the admin menu ....
I tried this but the menu never appears at the end:
```
function custom_menu_order($menu_ord) {
if (!$menu_ord) return true;
return array(
'index.php', // Dashboard
'edit.php', // Posts
'uplo... | The global variable `$menu` can be manipulated. Here, we are moving the *Pages* menu item to the end:

Maybe there's a simpler method to do the recursive array search, I've grabbed an example from PHP Manual. The value to be searched has to be ... |
94,811 | <p>Is there a way to prevent Wordpress from automatically wrapping every metabox in the postbox class? Or at least add my own outer div so I can make custom changes via css? Thanks!</p>
| [
{
"answer_id": 94818,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>Add your necessary classes with the <code>postbox_classes_{$page}_{$id}</code> filter. For example...</p>\n\n... | 2013/04/06 | [
"https://wordpress.stackexchange.com/questions/94811",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31072/"
] | Is there a way to prevent Wordpress from automatically wrapping every metabox in the postbox class? Or at least add my own outer div so I can make custom changes via css? Thanks! | Add your necessary classes with the `postbox_classes_{$page}_{$id}` filter. For example...
```
function add_class($classes) {
$classes[] = 'awesome-new-class-that-I-could-not-live-without';
return $classes;
}
add_filter('postbox_classes_post_submitdiv','add_class');
```
That will add your class to the "Submit" m... |
94,817 | <p>I am building an LMS type system in WordPress, controlled by <code>Custom Post types</code>.
The post type is called <code>Lessons</code> (with a slug of <code>courses</code>) and it has one <code>custom taxonomy</code> (category) called <code>courses</code>.</p>
<p>The domain URL structure shows right now as:</p>
<... | [
{
"answer_id": 94820,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 7,
"selected": true,
"text": "<p>Change your rewrite to add the course query var:</p>\n\n<pre><code>'rewrite' => array('slug' => 'courses/%cour... | 2013/04/06 | [
"https://wordpress.stackexchange.com/questions/94817",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30778/"
] | I am building an LMS type system in WordPress, controlled by `Custom Post types`.
The post type is called `Lessons` (with a slug of `courses`) and it has one `custom taxonomy` (category) called `courses`.
The domain URL structure shows right now as:
`domain.example/courses/lesson-name`.
I want it to become:
`domain... | Change your rewrite to add the course query var:
```
'rewrite' => array('slug' => 'courses/%course%')
```
Then filter `post_type_link` to insert the selected course into the permalink:
```
function wpa_course_post_link( $post_link, $id = 0 ){
$post = get_post($id);
if ( is_object( $post ) ){
$term... |
94,828 | <p>I have a CPT registered that is called <code>lessons</code> with a custom taxonomy (category) that is called <code>courses</code>. I want the <code>/courses</code> page (archive-courses.php?) to display the individual courses (i.e. "online marketing", "paid advertising") and not the individual posts (lessons).</p>
... | [
{
"answer_id": 94829,
"author": "Johannes Pille",
"author_id": 9745,
"author_profile": "https://wordpress.stackexchange.com/users/9745",
"pm_score": 3,
"selected": true,
"text": "<p>If you'd like to list the individual courses, i.e. the taxonomy terms, you'd use neither <a href=\"https:/... | 2013/04/06 | [
"https://wordpress.stackexchange.com/questions/94828",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30778/"
] | I have a CPT registered that is called `lessons` with a custom taxonomy (category) that is called `courses`. I want the `/courses` page (archive-courses.php?) to display the individual courses (i.e. "online marketing", "paid advertising") and not the individual posts (lessons).
Would this mean I'd just customize the l... | If you'd like to list the individual courses, i.e. the taxonomy terms, you'd use neither [`WP_Query`](https://codex.wordpress.org/Class_Reference/WP_Query) nor the WP standard [Loop](http://codex.wordpress.org/The_Loop).
Instead, make use of the [`get_terms`](http://codex.wordpress.org/Function_Reference/get_terms) fu... |
94,838 | <p>I am curious as there are three function for loading files in plugins:</p>
<p><code>plugin_dir_path()</code> and <code>plugins_url()</code>, along with <code>plugin_dir_url()</code> So as a plugin developer, which would you use for loading php files? the main example shows: <code>plugin_dir_path()</code> - but if o... | [
{
"answer_id": 94841,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p><code>plugin_dir_path()</code> is the only one of the three that gives you the local <em>filesystem</em> path, ie: ... | 2013/04/06 | [
"https://wordpress.stackexchange.com/questions/94838",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27670/"
] | I am curious as there are three function for loading files in plugins:
`plugin_dir_path()` and `plugins_url()`, along with `plugin_dir_url()` So as a plugin developer, which would you use for loading php files? the main example shows: `plugin_dir_path()` - but if one were to write an auto loader function, which functi... | Return values of the three mentioned functions
----------------------------------------------
**1.** [`plugin_dir_path( __FILE__ )`](http://codex.wordpress.org/Function_Reference/plugin_dir_path) returns the servers *filesystem directory path* pointing to the current file, i.e. something along the lines of
`/home/w... |
94,848 | <p>i want to remove all html tags from content like <code><p>, <br>, <img>, <a></code> i <code>tried strip_tags()</code>
also tried</p>
<pre><code>$content = get_the_content();
$content = apply_filters('the_content', $content);
</code></pre>
<p>but not working for me. any reliable solution ?? ... | [
{
"answer_id": 94850,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 4,
"selected": true,
"text": "<p>The WordPress function, at least the one I tend to use, would be <a href=\"http://codex.wordpress.org/Function... | 2013/04/06 | [
"https://wordpress.stackexchange.com/questions/94848",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25586/"
] | i want to remove all html tags from content like `<p>, <br>, <img>, <a>` i `tried strip_tags()`
also tried
```
$content = get_the_content();
$content = apply_filters('the_content', $content);
```
but not working for me. any reliable solution ?? | The WordPress function, at least the one I tend to use, would be [`wp_filter_nohtml_kses`](http://codex.wordpress.org/Function_Reference/wp_filter_nohtml_kses). That should remove all of the HTML, but you need to be careful not to put some HTML back by running `the_content` filters on your HTML-less string.
I am not s... |
94,854 | <p>Within a loop, that otherwise works fine, <code>the_time()</code> is giving me a date and time about 25 days and a few hours ahead of the actual date.<br />For instance, if I post today, it lists it as "April 30th, 2013" (today is April 6th, 2013).</p>
<p>I can't for the life of me figure out why it's doing this.</... | [
{
"answer_id": 94887,
"author": "WPMU-DEV Ari",
"author_id": 31044,
"author_profile": "https://wordpress.stackexchange.com/users/31044",
"pm_score": -1,
"selected": false,
"text": "<p>If this is on a VPS or a dedicated server, I would advise you take a look at your server's settings and ... | 2013/04/06 | [
"https://wordpress.stackexchange.com/questions/94854",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23492/"
] | Within a loop, that otherwise works fine, `the_time()` is giving me a date and time about 25 days and a few hours ahead of the actual date.
For instance, if I post today, it lists it as "April 30th, 2013" (today is April 6th, 2013).
I can't for the life of me figure out why it's doing this.
A couple things: This is... | >
> if I post today, it lists it as April 30th, 2013 (today is April 6th,
> 2013).
>
>
>
Your using a lowercase t in your [date format string](http://php.net/manual/en/function.date.php).
==================================================================================================
```
t Number of days in t... |
94,856 | <p>I am helping my father with his WordPress website.<br />
It has over 1,700 posts with TITLES IN UPPERCASE.</p>
<p>We'd like to change these to "Title Case" in the database (possibly using <a href="http://camendesign.com/code/title-case">this PHP script</a>).</p>
<p>The WordPress "To Title Case" plug-in changes the... | [
{
"answer_id": 94857,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": false,
"text": "<p>You could change the post title when it is viewed:</p>\n\n<pre><code>add_action( 'the_post', 'wpse_94856_title_update'... | 2013/04/06 | [
"https://wordpress.stackexchange.com/questions/94856",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10305/"
] | I am helping my father with his WordPress website.
It has over 1,700 posts with TITLES IN UPPERCASE.
We'd like to change these to "Title Case" in the database (possibly using [this PHP script](http://camendesign.com/code/title-case)).
The WordPress "To Title Case" plug-in changes the case at the template level - w... | Updating the posts
------------------
```
$all_posts = get_posts(
'posts_per_page' => -1,
'post_type' => 'post'
);
foreach ( $all_posts as $single ) {
wp_update_post( array(
'ID' => $single->ID,
'post_title' => to_title_case( $single->post_title ) // see function below
));
}
```
Conv... |
94,863 | <p>I've noticed that my WooCommerce products are not searched by the default WordPress search function. Any idea how to modify the function to ensure that products and product tabs are searched?</p>
| [
{
"answer_id": 94870,
"author": "Zach Russell",
"author_id": 30778,
"author_profile": "https://wordpress.stackexchange.com/users/30778",
"pm_score": 1,
"selected": false,
"text": "<p>I'm running several WooCommerce sites, and the WordPress search does include products along with posts/pa... | 2013/04/07 | [
"https://wordpress.stackexchange.com/questions/94863",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25029/"
] | I've noticed that my WooCommerce products are not searched by the default WordPress search function. Any idea how to modify the function to ensure that products and product tabs are searched? | Just extend your search form with a hidden input: (notice the last input field)
```
<form role="search" method="get" class="search-form" action="<?php echo home_url( '/' ); ?>">
<label>
<span class="screen-reader-text"><?php echo _x( 'Search for:', 'label' ) ?></span>
<input type="search" class="se... |
94,882 | <p>My Permalink custom url is /%post_id%/%postname%/</p>
<p>and my website is in Persian language, for some posts the Permalink is change in URL from</p>
<p><a href="http://www.ahangbaz.com/1300/%D8%A7%D8%A8%DB%8C-%D8%B7%D9%BE%D8%B4-%DA%86%D8%B4%D9%85%D9%87/" rel="nofollow">http://www.ahangbaz.com/1300/%d8%a7%d8%a8%d... | [
{
"answer_id": 99228,
"author": "Indolering",
"author_id": 32766,
"author_profile": "https://wordpress.stackexchange.com/users/32766",
"pm_score": 1,
"selected": false,
"text": "<p>I don't have comment capabilities, but the problem is very likely to be on the MS server side, specifically... | 2013/04/07 | [
"https://wordpress.stackexchange.com/questions/94882",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31087/"
] | My Permalink custom url is /%post\_id%/%postname%/
and my website is in Persian language, for some posts the Permalink is change in URL from
[http://www.ahangbaz.com/1300/%d8%a7%d8%a8%db%8c-%d8%b7%d9%be%d8%b4-%da%86%d8%b4%d9%85%d9%87/](http://www.ahangbaz.com/1300/%D8%A7%D8%A8%DB%8C-%D8%B7%D9%BE%D8%B4-%DA%86%D8%B4%D9... | The problem as @Indolering mentioned is related to URL Rewrite module that the URLs containing UTF-8 characters is not correctly passed when processed by the URL Rewrite module.
Because I'm not the server owner and I'm unable to install the mentioned hotfix (even though I'm using IIS8.5 the problem is still existed) I... |
94,897 | <p>I'm trying to implement plant classification as a custom taxonomy for a custom post type.</p>
<p>For now, plant classification should be on three levels: <code>Family</code>, <code>Genus</code>, <code>Species</code>.</p>
<p>As I see it, there are two possible ways:</p>
<ol>
<li><p><strong>Using taxonomy level as ... | [
{
"answer_id": 94900,
"author": "helgatheviking",
"author_id": 6477,
"author_profile": "https://wordpress.stackexchange.com/users/6477",
"pm_score": 1,
"selected": false,
"text": "<p>Why not use a hierarchical taxonomy? I can't think of a better use for hierarchy than what you are descr... | 2013/04/07 | [
"https://wordpress.stackexchange.com/questions/94897",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9310/"
] | I'm trying to implement plant classification as a custom taxonomy for a custom post type.
For now, plant classification should be on three levels: `Family`, `Genus`, `Species`.
As I see it, there are two possible ways:
1. **Using taxonomy level as an indicator of taxonomy type, ex:**
```
plant_class ... | Why not use a hierarchical taxonomy? I can't think of a better use for hierarchy than what you are describing. As far as your perceived disadvantages:
>
> Admin needs to select all applicable classification parts when
> associating to a plant (eg; a family, a genus and a species)
>
>
>
```
Rhamnaceae
- Ziziphus
... |
94,916 | <p>I have 3 different custom post types, with each type forming my main navigation.
When I post something new under one of them, I want that category in the nav to be marked with a "new" label for a limited time (7 days for example).</p>
<p>I've found a few decent posts on how to apply it to single posts, but I can't ... | [
{
"answer_id": 98893,
"author": "Tom",
"author_id": 31100,
"author_profile": "https://wordpress.stackexchange.com/users/31100",
"pm_score": 1,
"selected": false,
"text": "<p>In case anyone else is looking for this in the future, turns out the best way to do it is by using <code>wp_get_re... | 2013/04/07 | [
"https://wordpress.stackexchange.com/questions/94916",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31100/"
] | I have 3 different custom post types, with each type forming my main navigation.
When I post something new under one of them, I want that category in the nav to be marked with a "new" label for a limited time (7 days for example).
I've found a few decent posts on how to apply it to single posts, but I can't figure out... | In case anyone else is looking for this in the future, turns out the best way to do it is by using `wp_get_recent_posts` function. Someone knocked up an example that worked great for me:
```
<?php $args = array( 'numberposts' => '1' );
$recent_post = wp_get_recent_posts( $args );
if (strtotime($recent_post[0]['post_d... |
94,945 | <p>I'd like to be able to check if the twentytwelve theme is active. I know if I was checking for an active plugin I'd do something like:</p>
<pre><code>$active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
if ( in_array( 'plugin-folder/plugin-folder.php', $active_plugins ) ) {
//do ... | [
{
"answer_id": 94952,
"author": "liying",
"author_id": 24490,
"author_profile": "https://wordpress.stackexchange.com/users/24490",
"pm_score": 3,
"selected": false,
"text": "<pre><code> if( 'twentytwelve' == get_option( 'template' ) ) {\n // do something\n }\n</code></pre>\n"
},
... | 2013/04/07 | [
"https://wordpress.stackexchange.com/questions/94945",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25029/"
] | I'd like to be able to check if the twentytwelve theme is active. I know if I was checking for an active plugin I'd do something like:
```
$active_plugins = apply_filters( 'active_plugins', get_option( 'active_plugins' ) );
if ( in_array( 'plugin-folder/plugin-folder.php', $active_plugins ) ) {
//do stuff
} else {... | You can use [`wp_get_theme`](http://codex.wordpress.org/Function_Reference/wp_get_theme):
```
<?php
$theme = wp_get_theme(); // gets the current theme
if ( 'Twenty Twelve' == $theme->name || 'Twenty Twelve' == $theme->parent_theme ) {
// if you're here Twenty Twelve is the active theme or is
// the current the... |
94,948 | <p>I have a section on my main page that displays a new “Portfolio” post each time I write one no matter what category I assign them to. What I want to do is make the main page only display <strong>one</strong> specific category (<code>events</code>) from these Portfolio posts. I’m just wondering what I need to change ... | [
{
"answer_id": 94960,
"author": "Griffin",
"author_id": 10036,
"author_profile": "https://wordpress.stackexchange.com/users/10036",
"pm_score": 1,
"selected": false,
"text": "<p>Wyck is correct. You can find the answer you seek in the wonderful Wordpress documentation.</p>\n\n<p>But, 'ca... | 2013/04/08 | [
"https://wordpress.stackexchange.com/questions/94948",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31114/"
] | I have a section on my main page that displays a new “Portfolio” post each time I write one no matter what category I assign them to. What I want to do is make the main page only display **one** specific category (`events`) from these Portfolio posts. I’m just wondering what I need to change in the below code to do tha... | Wyck is correct. You can find the answer you seek in the wonderful Wordpress documentation.
But, 'cause why not, here's the answer for you:
You're very close, you just need to change your "tax\_query" array to include the term you're requesting. Like this:
```
'tax_query' => array(
array(
... |
94,954 | <p>One of the things that my plugin does is creates a number of SQL tables as part of a versioning function (that is run under the admin_init hook as I couldn't find a better wordpress way of doing things). I call the initialisation script as part of the setUp routine and theorectically should be dropped as part of the... | [
{
"answer_id": 104852,
"author": "Fabien Quatravaux",
"author_id": 16975,
"author_profile": "https://wordpress.stackexchange.com/users/16975",
"pm_score": 1,
"selected": false,
"text": "<p>Have you tried to execute the SQL statements manually ? You would perhaps see an error message prev... | 2013/04/08 | [
"https://wordpress.stackexchange.com/questions/94954",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9519/"
] | One of the things that my plugin does is creates a number of SQL tables as part of a versioning function (that is run under the admin\_init hook as I couldn't find a better wordpress way of doing things). I call the initialisation script as part of the setUp routine and theorectically should be dropped as part of the t... | The unit tests transform all `CREATE TABLE` and `DROP TABLE` queries to `CREATE TEMPORARY TABLE` and `DROP TEMPORARY TALBE`, respectively. So in your `tearDown` the query will attempt to drop temporary tables with those names, but not the actual tables. To fix this, add this before your `DROP` queries:
```
remove_filt... |
94,958 | <p>The following code in functions.php outputs a post when I publish, not a Page:</p>
<pre><code>// custom post_type for agenda
add_action( 'init', 'create_my_post_types' );
function create_my_post_types() {
register_post_type( 'agenda', array(
'labels' => array(
'name_admin_bar' => _x... | [
{
"answer_id": 94970,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 0,
"selected": false,
"text": "<p>You Don't need to create a custom post type just add the metabox if the page is the one you require ex:</p>\n... | 2013/04/08 | [
"https://wordpress.stackexchange.com/questions/94958",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27278/"
] | The following code in functions.php outputs a post when I publish, not a Page:
```
// custom post_type for agenda
add_action( 'init', 'create_my_post_types' );
function create_my_post_types() {
register_post_type( 'agenda', array(
'labels' => array(
'name_admin_bar' => _x( 'Agenda', 'add ne... | Your screenshot seems to indicate that you're interested in the status message for your custom post type saying `'Page updated. View page'`. If that's true, the reason that you're getting `'Post updated. View post'` is that you haven't provided status messages for your custom post type.
Here's the code for the admin e... |
94,963 | <p>I want to remove the website field from the user contact info. I use the following to remove the AIM,Jabber and Yahoo IM . But I am not able to use this to remove the website. Someone please help.</p>
<pre><code>function remove_contactmethods( $contactmethods ) {
unset($contactmethods['aim']);
unset($contac... | [
{
"answer_id": 94966,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 5,
"selected": true,
"text": "<p><em>Revisited and updated answer:</em> </p>\n\n<p>We can't use the <code>user_contactmethods</code> filter to r... | 2013/04/08 | [
"https://wordpress.stackexchange.com/questions/94963",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28044/"
] | I want to remove the website field from the user contact info. I use the following to remove the AIM,Jabber and Yahoo IM . But I am not able to use this to remove the website. Someone please help.
```
function remove_contactmethods( $contactmethods ) {
unset($contactmethods['aim']);
unset($contactmethods['yim'... | *Revisited and updated answer:*
We can't use the `user_contactmethods` filter to remove the website wrapper, because this piece is hardcoded in the `user-edit.php` file and not part of the filterable *user contacts* loop, generated by:
```
wp_get_user_contact_methods( $profileuser )
```
Hiding it with CSS
--------... |
94,964 | <p>i would like to use the brand new wp's upload tool in a personnal theme options page. I found a lot of tutorials like :
<a href="http://mikejolley.com/2012/12/using-the-new-wordpress-3-5-media-uploader-in-plugins/" rel="nofollow">wp media uploader in plugins</a>
...and it works very fine. But i'd like to filter the ... | [
{
"answer_id": 94966,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 5,
"selected": true,
"text": "<p><em>Revisited and updated answer:</em> </p>\n\n<p>We can't use the <code>user_contactmethods</code> filter to r... | 2013/04/08 | [
"https://wordpress.stackexchange.com/questions/94964",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31123/"
] | i would like to use the brand new wp's upload tool in a personnal theme options page. I found a lot of tutorials like :
[wp media uploader in plugins](http://mikejolley.com/2012/12/using-the-new-wordpress-3-5-media-uploader-in-plugins/)
...and it works very fine. But i'd like to filter the file type the end user can se... | *Revisited and updated answer:*
We can't use the `user_contactmethods` filter to remove the website wrapper, because this piece is hardcoded in the `user-edit.php` file and not part of the filterable *user contacts* loop, generated by:
```
wp_get_user_contact_methods( $profileuser )
```
Hiding it with CSS
--------... |
94,965 | <p>I am getting the following error when I try to access my Wordpress website. It was working quite fine previously. Could anyone help me on this.</p>
<blockquote>
<p>No configuration file found and no installation code available. Exiting...</p>
</blockquote>
| [
{
"answer_id": 94982,
"author": "uzair",
"author_id": 11502,
"author_profile": "https://wordpress.stackexchange.com/users/11502",
"pm_score": 2,
"selected": true,
"text": "<p>In Wordpress there will be a default <strong>wp-config.php</strong> file and I think this has been missing from y... | 2013/04/08 | [
"https://wordpress.stackexchange.com/questions/94965",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23712/"
] | I am getting the following error when I try to access my Wordpress website. It was working quite fine previously. Could anyone help me on this.
>
> No configuration file found and no installation code available. Exiting...
>
>
> | In Wordpress there will be a default **wp-config.php** file and I think this has been missing from your package. Please Check if it is there, else create a new one with file name **wp-config.php** and Place the following code in it with appropriate Database Credentials.
```
<?php
// ** MySQL settings ** //
define('DB_... |
94,968 | <p>I want to disable changing password option for all my subscriber users.</p>
<p>Is it possible by doing any code tweak or something using any plugin?</p>
<p><img src="https://i.stack.imgur.com/Q3Des.jpg" alt="Disable password changing option for subscriber users"></p>
<p>If someone has any idea or plugin knowledge... | [
{
"answer_id": 94971,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": false,
"text": "<p>If you want to hide the passwords fields on the profile page, you can use the <code>show_password_fields</code... | 2013/04/08 | [
"https://wordpress.stackexchange.com/questions/94968",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25262/"
] | I want to disable changing password option for all my subscriber users.
Is it possible by doing any code tweak or something using any plugin?

If someone has any idea or plugin knowledge to do this then appreciated. | You can try
```
if( current_user_can( 'subscriber' ) ) {
add_filter( 'show_password_fields', '__return_false' );
}
```
see also
<http://wpengineer.com/2285/disable-password-fields-for-non-admins/>
<http://adambrown.info/p/wp_hooks/hook/show_password_fields> |
94,990 | <p>I want to get my all <code>posts-meta</code>, But on the base of <code>key</code>. For example the main query for getting the post-meta is</p>
<pre><code> <?php $meta_values = get_post_meta($post_id, $key, $single); ?>
</code></pre>
<p>Now i want to get this <code>post-meta</code> on the base of <code>key</... | [
{
"answer_id": 94993,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 2,
"selected": false,
"text": "<p>You can query your <code>postmeta</code> table directly using something like:</p>\n\n<pre><code>global $wpdb;\... | 2013/04/08 | [
"https://wordpress.stackexchange.com/questions/94990",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27912/"
] | I want to get my all `posts-meta`, But on the base of `key`. For example the main query for getting the post-meta is
```
<?php $meta_values = get_post_meta($post_id, $key, $single); ?>
```
Now i want to get this `post-meta` on the base of `key` only. My current query to get the post-meta is
```
<?php echo get_pos... | `$post->ID` is what makes the meta value distinguished across all posts with the same meta key.
So if you want to shorthand the `get_post_meta` call for the current post you can do this:
```
function get_cuurent_post_meta($key){
global $post;
return get_post_meta($post->ID,$key,true);
}
```
and you can call... |
95,012 | <p>Based on the current page, I'm listing the links of all pages which belongs to the parent ancestor. However when I'm accessing a grandchild, the top parent page will gone from the links hierarchy. This is what I have tried:</p>
<pre><code><?php
// display the sub pages from the current page item
if($post->pos... | [
{
"answer_id": 94993,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 2,
"selected": false,
"text": "<p>You can query your <code>postmeta</code> table directly using something like:</p>\n\n<pre><code>global $wpdb;\... | 2013/04/08 | [
"https://wordpress.stackexchange.com/questions/95012",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | Based on the current page, I'm listing the links of all pages which belongs to the parent ancestor. However when I'm accessing a grandchild, the top parent page will gone from the links hierarchy. This is what I have tried:
```
<?php
// display the sub pages from the current page item
if($post->post_parent) {
$chi... | `$post->ID` is what makes the meta value distinguished across all posts with the same meta key.
So if you want to shorthand the `get_post_meta` call for the current post you can do this:
```
function get_cuurent_post_meta($key){
global $post;
return get_post_meta($post->ID,$key,true);
}
```
and you can call... |
95,016 | <p>I recently implemented a comment area on my website and tried to get the email notification to work. It doesn't seem to want to send email notifications when new comments are made. </p>
<p>Just to see if PHP can send emails, I tried to reset the password (because you'll get a new password via mail), and I got the m... | [
{
"answer_id": 95027,
"author": "Ralf912",
"author_id": 16589,
"author_profile": "https://wordpress.stackexchange.com/users/16589",
"pm_score": 3,
"selected": false,
"text": "<p>Step by step: First find the file where the error message appear. I use Notepad++ and the <kbd>CTRL</kbd> + <k... | 2013/04/08 | [
"https://wordpress.stackexchange.com/questions/95016",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22530/"
] | I recently implemented a comment area on my website and tried to get the email notification to work. It doesn't seem to want to send email notifications when new comments are made.
Just to see if PHP can send emails, I tried to reset the password (because you'll get a new password via mail), and I got the message:
>... | Step by step: First find the file where the error message appear. I use Notepad++ and the `CTRL` + `F` command to search in files. It is a good idea to search only the first few words of the error message, because some error messages are combined of different messages.
Your error message appear in `wp-login.php` and h... |