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 |
|---|---|---|---|---|---|---|
37,332 | <p>I know this type of question has been asked over and over, but I couldn't find a solution for my problem, so I hope you can help me. I am using WP 3.3. and I have created a custom table. Now I want to insert some data into it, but I can't get it working. This is my code:</p>
<pre><code>global $wpdb;
$table_name = $... | [
{
"answer_id": 37357,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 5,
"selected": true,
"text": "<p>When <code>$wpdb</code> method doesn't perform as it should it is likely issue with resulting SQL query (because of w... | 2011/12/26 | [
"https://wordpress.stackexchange.com/questions/37332",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11437/"
] | I know this type of question has been asked over and over, but I couldn't find a solution for my problem, so I hope you can help me. I am using WP 3.3. and I have created a custom table. Now I want to insert some data into it, but I can't get it working. This is my code:
```
global $wpdb;
$table_name = $wpdb->prefix .... | When `$wpdb` method doesn't perform as it should it is likely issue with resulting SQL query (because of wrong input or something else).
Follow [`wpdb reference in Codex`](http://codex.wordpress.org/Class_Reference/wpdb#Show_and_Hide_SQL_Errors) for troubleshooting:
* enable database error display via `$wpdb->show_er... |
37,334 | <p>Here is what I am thinking of trying to hide wp-content from the urls of files included in page source.</p>
<p>defining the following in wp-settings.php</p>
<pre><code>define ('WP_CONTENT_URL','http://example.com/myownfoldername');
</code></pre>
<p>and adding this to <code>.htaccess</code></p>
<pre><code>Rewrite... | [
{
"answer_id": 37335,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>You don’t need a separate rule in your .htaccess. Add …</p>\n\n<pre><code>define( 'WP_CONTENT_DIR', 'YOUR_LOCAL_PATH' )... | 2011/12/26 | [
"https://wordpress.stackexchange.com/questions/37334",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11438/"
] | Here is what I am thinking of trying to hide wp-content from the urls of files included in page source.
defining the following in wp-settings.php
```
define ('WP_CONTENT_URL','http://example.com/myownfoldername');
```
and adding this to `.htaccess`
```
RewriteRule ^myownfoldername/(.*) /wp-content/$1 [QSA,L]
```
... | You don’t need a separate rule in your .htaccess. Add …
```
define( 'WP_CONTENT_DIR', 'YOUR_LOCAL_PATH' );
define( 'WP_CONTENT_URL', 'YOUR_PUBLIC_PATH' );
```
… to your `wp-config.php`. Do **not** write into `wp-settings.php`. This file will be overwritten during the next update – never touch a core file. |
37,358 | <p>I have added new fields on the user profile page. </p>
<p>I want to display a message that says: "It's good ... or not"</p>
<p>I couldn't find a hook in the WordPress codex. </p>
<p>I don't want to use a plugin only my own code I want change this code :</p>
<pre><code><div id="message" class="updated">
... | [
{
"answer_id": 37364,
"author": "Brian Fegter",
"author_id": 4793,
"author_profile": "https://wordpress.stackexchange.com/users/4793",
"pm_score": 3,
"selected": true,
"text": "<p>You will have to use a gettext filter as there are no hooks or filters associated with your request.</p>\n\n... | 2011/12/27 | [
"https://wordpress.stackexchange.com/questions/37358",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9716/"
] | I have added new fields on the user profile page.
I want to display a message that says: "It's good ... or not"
I couldn't find a hook in the WordPress codex.
I don't want to use a plugin only my own code I want change this code :
```
<div id="message" class="updated">
<p><strong>Updated profile </strong></p>... | You will have to use a gettext filter as there are no hooks or filters associated with your request.
```
function custom_user_message($translation, $text){
if('Profile updated.' == $text){
$current_user = wp_get_current_user();
$foo_condition = ''; //Do some checking here for user custom field
... |
37,359 | <p>As per other posts, I am trying to produce a customised WordPress installation as a CMS for my fishkeeping website.</p>
<p>On one of my custom post types (<code>species</code>, which displays information about a given species of fish) doesn't use the standard "Post" editor at all, instead it has numerous fields in ... | [
{
"answer_id": 37360,
"author": "Joseph Leedy",
"author_id": 8554,
"author_profile": "https://wordpress.stackexchange.com/users/8554",
"pm_score": 2,
"selected": false,
"text": "<p>Two questions: (1) Are you using WordPress 3.3 and (2) Is this on the backend? If the answer to both is yes... | 2011/12/27 | [
"https://wordpress.stackexchange.com/questions/37359",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6344/"
] | As per other posts, I am trying to produce a customised WordPress installation as a CMS for my fishkeeping website.
On one of my custom post types (`species`, which displays information about a given species of fish) doesn't use the standard "Post" editor at all, instead it has numerous fields in meta boxes such as "G... | Two questions: (1) Are you using WordPress 3.3 and (2) Is this on the backend? If the answer to both is yes, then you might be able to use the new [`wp_editor`](http://codex.wordpress.org/Function_Reference/wp_editor) command. |
37,365 | <p>Or does this break the purpose of the nonce, which I admint I don't quite understand it? :)</p>
<p>For example on two ajax requests that run on page load, or when something is clicked:</p>
<pre><code> $.ajax({
type: 'post',
url: 'admin-ajax.php',
data: { action: 'foo',
_ajax_nonce: '<?php ec... | [
{
"answer_id": 37368,
"author": "Naoise Golden",
"author_id": 5048,
"author_profile": "https://wordpress.stackexchange.com/users/5048",
"pm_score": 3,
"selected": true,
"text": "<p>The <a href=\"http://codex.wordpress.org/Function_Reference/wp_create_nonce\" rel=\"nofollow\">WordPress no... | 2011/12/27 | [
"https://wordpress.stackexchange.com/questions/37365",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11451/"
] | Or does this break the purpose of the nonce, which I admint I don't quite understand it? :)
For example on two ajax requests that run on page load, or when something is clicked:
```
$.ajax({
type: 'post',
url: 'admin-ajax.php',
data: { action: 'foo',
_ajax_nonce: '<?php echo $nonce; ?>' }
});
... | The [WordPress nonce creation function](http://codex.wordpress.org/Function_Reference/wp_create_nonce) is to be called only on the [`init`](http://codex.wordpress.org/Plugin_API/Action_Reference/init) hook:
>
> Use the init or any subsequent action to call this function. Calling
> it outside of an action can lead to... |
37,372 | <p>I am trying to integrate a check box, so that the user can opt-in to my MailChimp newsletter, into the Contact Form 7.</p>
<p>I used this tutorial : <a href="http://www.silenceit.ca/2011/02/28/how-to-integrate-mailchimp-with-contact-form-7" rel="nofollow">http://www.silenceit.ca/2011/02/28/how-to-integrate-mailchim... | [
{
"answer_id": 37808,
"author": "avexdesigns",
"author_id": 11452,
"author_profile": "https://wordpress.stackexchange.com/users/11452",
"pm_score": 0,
"selected": false,
"text": "<p>Ok, so I was able to change this code to work with the new version of Contact Form 7. After following inst... | 2011/12/27 | [
"https://wordpress.stackexchange.com/questions/37372",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11452/"
] | I am trying to integrate a check box, so that the user can opt-in to my MailChimp newsletter, into the Contact Form 7.
I used this tutorial : <http://www.silenceit.ca/2011/02/28/how-to-integrate-mailchimp-with-contact-form-7>
Everything works (sends the data to the email address, and also sends data to mailchimp) But... | Thanks to the answer from John at avexdesign above as well as the link to the tutorial from SilenceIT, I have a couple more details in case anyone comes across this.
As of version 3.1, the line to edit is now line 60 in the controller.php file. As stated by avexdesigns, you must change ONLY the variables '$items' that... |
37,379 | <p>I use the following code in my template.</p>
<pre><code><?php echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ago'; ?>
</code></pre>
<p>It shows like 2 days ago, 20 days ago, 90 days ago.</p>
<p>Is there a way to show 1 week ago instead of 7 days ago, 1 month ago instead of 30 days ag... | [
{
"answer_id": 37381,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 2,
"selected": true,
"text": "<p>As far as I know that's as deep as wordpress can go, you will have to use php to get it into weeks/months/etc.</p>\n... | 2011/12/28 | [
"https://wordpress.stackexchange.com/questions/37379",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5074/"
] | I use the following code in my template.
```
<?php echo human_time_diff(get_the_time('U'), current_time('timestamp')) . ' ago'; ?>
```
It shows like 2 days ago, 20 days ago, 90 days ago.
Is there a way to show 1 week ago instead of 7 days ago, 1 month ago instead of 30 days ago, 1 year ago instead of 365 days ago? ... | As far as I know that's as deep as wordpress can go, you will have to use php to get it into weeks/months/etc.
You have 2 options:
Use `human_time_diff` and create a function that just calculates the differences(pretty easy to figure out 7 days = 1 week, etc). I would honestly not use `human_time_diff` though and use... |
37,385 | <p>I need a foreach loop inside "the loop"</p>
<p><strong>This is my current code (index.php) :</strong></p>
<pre><code><?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div><a href="<?php the_permalink(); ?>" title="<?php get_the_title(); ?>"> <?php the_title(); ?>... | [
{
"answer_id": 37381,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 2,
"selected": true,
"text": "<p>As far as I know that's as deep as wordpress can go, you will have to use php to get it into weeks/months/etc.</p>\n... | 2011/12/28 | [
"https://wordpress.stackexchange.com/questions/37385",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5074/"
] | I need a foreach loop inside "the loop"
**This is my current code (index.php) :**
```
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<div><a href="<?php the_permalink(); ?>" title="<?php get_the_title(); ?>"> <?php the_title(); ?></a></div>
<div><a data-backdrop="true" data-controls-modal="modal-fr... | As far as I know that's as deep as wordpress can go, you will have to use php to get it into weeks/months/etc.
You have 2 options:
Use `human_time_diff` and create a function that just calculates the differences(pretty easy to figure out 7 days = 1 week, etc). I would honestly not use `human_time_diff` though and use... |
37,389 | <p>Inside the WordPress admin dashboard there is a button for making the left side menu collapse (to show just icons and not the icons + text on left side). How can I add jQuery so that it gets automatically collapsed once my plugin opens up. I tried this but it didn't work for me. I want to give a sort of 'full screen... | [
{
"answer_id": 37390,
"author": "tamilsweet",
"author_id": 10701,
"author_profile": "https://wordpress.stackexchange.com/users/10701",
"pm_score": 2,
"selected": false,
"text": "<p>You have to trigger the click event. Try,</p>\n\n<pre><code>jQuery(document).ready(function() { jQuery(\"#c... | 2011/12/28 | [
"https://wordpress.stackexchange.com/questions/37389",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11461/"
] | Inside the WordPress admin dashboard there is a button for making the left side menu collapse (to show just icons and not the icons + text on left side). How can I add jQuery so that it gets automatically collapsed once my plugin opens up. I tried this but it didn't work for me. I want to give a sort of 'full screen' o... | You have to trigger the click event. Try,
```
jQuery(document).ready(function() { jQuery("#collapse-menu").trigger('click'); });
```
**Update:**
Use the following code to check if menu is already folded, if not trigger click event to fold it.
```
jQuery(document).ready(function() {
if ( !$(document.body).hasCla... |
37,402 | <p>I have a <em>working</em> query that calls all my posts that have a certain meta value for one of two meta keys:</p>
<pre><code>$term = filter_var( $_GET['term'] );
$query = get_posts( [
'post_type' => 'some_cpt_name',
'meta_query' => [
'relation' => 'OR',
[
'key' ... | [
{
"answer_id": 37405,
"author": "scribu",
"author_id": 205,
"author_profile": "https://wordpress.stackexchange.com/users/205",
"pm_score": 2,
"selected": true,
"text": "<p>As with most questions involving <code>OR</code> clauses, the answer is the same: use a custom query or alter <code>... | 2011/12/28 | [
"https://wordpress.stackexchange.com/questions/37402",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/385/"
] | I have a *working* query that calls all my posts that have a certain meta value for one of two meta keys:
```
$term = filter_var( $_GET['term'] );
$query = get_posts( [
'post_type' => 'some_cpt_name',
'meta_query' => [
'relation' => 'OR',
[
'key' => 'foo',
'valu... | As with most questions involving `OR` clauses, the answer is the same: use a custom query or alter `WP_Query` using the `'posts_clauses'` filter. |
37,409 | <p>I don't want people to have to log in, I just want to prompt them with a question and if they can answer it, they can access the site. All the solutions and plugins that I've found seem to be overkill for my needs. Does this kind of thing exist?</p>
| [
{
"answer_id": 37412,
"author": "George Pearce",
"author_id": 7434,
"author_profile": "https://wordpress.stackexchange.com/users/7434",
"pm_score": 2,
"selected": false,
"text": "<p>You could add a statement to the end that require them to answer a question if they dont have a cookie set... | 2011/12/28 | [
"https://wordpress.stackexchange.com/questions/37409",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11470/"
] | I don't want people to have to log in, I just want to prompt them with a question and if they can answer it, they can access the site. All the solutions and plugins that I've found seem to be overkill for my needs. Does this kind of thing exist? | You could add a statement to the end that require them to answer a question if they dont have a cookie set and sets a cookie when they do, allowing them access to the site. I'm on my phone but something like this.
```
<?php
if($_POST['q'] == 'answer') {
// set cookie
} elseif($_COOKIE['q'] != 'cookie') {
// include... |
37,414 | <p>I'm new to wordpress and tried to Google and looked up codex but it didn't help.
I downloaded a free theme from Github and I'm trying to learn how to make a theme by looking at its code. In the header.php I found this piece</p>
<pre><code><nav class="mainnav" role="navigation">
<?php wp_nav_menu( array... | [
{
"answer_id": 37503,
"author": "Ciprian",
"author_id": 7349,
"author_profile": "https://wordpress.stackexchange.com/users/7349",
"pm_score": 0,
"selected": false,
"text": "<p>The <strong>'container' => 'false'</strong> code indicates that the menu will not be surrounded by a <strong></s... | 2011/12/28 | [
"https://wordpress.stackexchange.com/questions/37414",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I'm new to wordpress and tried to Google and looked up codex but it didn't help.
I downloaded a free theme from Github and I'm trying to learn how to make a theme by looking at its code. In the header.php I found this piece
```
<nav class="mainnav" role="navigation">
<?php wp_nav_menu( array('menu' => 'Main Menu',... | `wp_nav_menu()` is a [template tag](http://codex.wordpress.org/Template_Tags) - that is function designed to be called in theme template file to output something.
This specific function generates and displays output of [navigation menu](http://codex.wordpress.org/Navigation_Menus).
Arguments, you are asking about, de... |
37,442 | <p>In a small plugin I’ve written to <a href="https://gist.github.com/1281778" rel="nofollow">add an IP address column to the comments list</a> I want to remove the avatars.<br>
In line 156 I tried to use <code>remove_filter</code>:</p>
<pre><code>remove_filter( 'comment_author', 'floated_admin_avatar', 50 );
</code><... | [
{
"answer_id": 37465,
"author": "tamilsweet",
"author_id": 10701,
"author_profile": "https://wordpress.stackexchange.com/users/10701",
"pm_score": 0,
"selected": false,
"text": "<p>May be its the priority 50. Instead let it be default.</p>\n\n<p>From <a href=\"http://codex.wordpress.org/... | 2011/12/28 | [
"https://wordpress.stackexchange.com/questions/37442",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/73/"
] | In a small plugin I’ve written to [add an IP address column to the comments list](https://gist.github.com/1281778) I want to remove the avatars.
In line 156 I tried to use `remove_filter`:
```
remove_filter( 'comment_author', 'floated_admin_avatar', 50 );
```
Well … I know this function [fails sometimes](http://h... | As usual with hooks this is issue of timing.
* your init function is hooked to admin load process, which works fine for most things;
* however in this specific case function is added to filter in constructor of `WP_Comments_List_Table` class, and object is created in `edit-comments.php` after admin loader had been pro... |
37,449 | <p>I am setting up a multiblog. In sub-blogs that mapped on a different domain, permalinks work with only "default" values. They broke if set to other valid values.</p>
<p>My main domain name is abc.com<br>
I have three subdomains: aaa.abc.com, bbb.abc.com, ccc.abc.com<br>
Everything works fine.
Now, I need to map bb... | [
{
"answer_id": 37459,
"author": "George Pearce",
"author_id": 7434,
"author_profile": "https://wordpress.stackexchange.com/users/7434",
"pm_score": 0,
"selected": false,
"text": "<p>When you mapped the domain onto your multisite installation on the server, was it to the same root directo... | 2011/12/28 | [
"https://wordpress.stackexchange.com/questions/37449",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11164/"
] | I am setting up a multiblog. In sub-blogs that mapped on a different domain, permalinks work with only "default" values. They broke if set to other valid values.
My main domain name is abc.com
I have three subdomains: aaa.abc.com, bbb.abc.com, ccc.abc.com
Everything works fine.
Now, I need to map bbb.com to bbb... | I think it;s the AllowOverride All - may need to fiddle with it. I've seen times where "all" didn't quite work as well as you'd think. Weird, but there ya go. |
37,482 | <p>OK, seriously. I have a really modified index.php.
The result: after the second paginated page, the page returns <code>Not found</code> and 404, while the posts are shown already.</p>
<p>Can anybody tell me, what it happening?</p>
<p>Working example with the problem:</p>
<ul>
<li>everything ok: <a href="http://pe... | [
{
"answer_id": 37483,
"author": "petermolnar",
"author_id": 4209,
"author_profile": "https://wordpress.stackexchange.com/users/4209",
"pm_score": 1,
"selected": false,
"text": "<p>OK, this is the most stupid bug I've ever seen.</p>\n\n<p>According to this <a href=\"http://www.iriswebsolu... | 2011/12/29 | [
"https://wordpress.stackexchange.com/questions/37482",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4209/"
] | OK, seriously. I have a really modified index.php.
The result: after the second paginated page, the page returns `Not found` and 404, while the posts are shown already.
Can anybody tell me, what it happening?
Working example with the problem:
* everything ok: <http://petermolnar.eu/photoblog>
* everything still ok: ... | It's not correct solving of issue and it's not a bug. Here is explanation why it happens: "Pagination is calculated before you get to the template file that runs query\_posts. The proper way to alter posts\_per\_page conditionally is to use the pre\_get\_posts hook to modify the main query."
<https://wordpress.stackexc... |
37,484 | <p>i would like to integrate Paypal payments to my Wordpress website, in order to send a digital product. I only want a simple redirection to the paypal payments form, to either pay through paypal or with a credit card (i have a payments standard account there).</p>
<p>The problem is the notifications system. I would ... | [
{
"answer_id": 37483,
"author": "petermolnar",
"author_id": 4209,
"author_profile": "https://wordpress.stackexchange.com/users/4209",
"pm_score": 1,
"selected": false,
"text": "<p>OK, this is the most stupid bug I've ever seen.</p>\n\n<p>According to this <a href=\"http://www.iriswebsolu... | 2011/12/29 | [
"https://wordpress.stackexchange.com/questions/37484",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6329/"
] | i would like to integrate Paypal payments to my Wordpress website, in order to send a digital product. I only want a simple redirection to the paypal payments form, to either pay through paypal or with a credit card (i have a payments standard account there).
The problem is the notifications system. I would like my cl... | It's not correct solving of issue and it's not a bug. Here is explanation why it happens: "Pagination is calculated before you get to the template file that runs query\_posts. The proper way to alter posts\_per\_page conditionally is to use the pre\_get\_posts hook to modify the main query."
<https://wordpress.stackexc... |
37,520 | <p>I have a multi-site network, on one of the sites the access is restricted to registered users, and only an administrator can create users.</p>
<p>I was asked to get rid of the confirmation email sent to new users, and I know you can select an option to add the user without sendind the email.</p>
<p>The problem is... | [
{
"answer_id": 38692,
"author": "Tomas Buteler",
"author_id": 5552,
"author_profile": "https://wordpress.stackexchange.com/users/5552",
"pm_score": 3,
"selected": true,
"text": "<p>Haven't really tested this, but WP actually uses this filter if you check the \"noconfirmation\" box, excep... | 2011/12/29 | [
"https://wordpress.stackexchange.com/questions/37520",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7361/"
] | I have a multi-site network, on one of the sites the access is restricted to registered users, and only an administrator can create users.
I was asked to get rid of the confirmation email sent to new users, and I know you can select an option to add the user without sendind the email.
The problem is, that option is o... | Haven't really tested this, but WP actually uses this filter if you check the "noconfirmation" box, except that it does so only for super\_admins, like you said:
```
add_filter( 'wpmu_signup_user_notification', '__return_false' );
``` |
37,537 | <p>I have a need to set the <code>wp_postmeta</code> value (in table: <code>wp_postmeta</code>) on every post that has a specific <code>term_taxonomy_id</code> (in table: <code>wp_term_relationships</code>):</p>
<p>Specifically:</p>
<ul>
<li>run a query against every <code>post_ID</code> that has <code>term_taxonomy... | [
{
"answer_id": 37868,
"author": "deadlyhifi",
"author_id": 737,
"author_profile": "https://wordpress.stackexchange.com/users/737",
"pm_score": 3,
"selected": true,
"text": "<p>I think I know what you mean, and if that is the case it's actually a straightforward operation.</p>\n\n<p>First... | 2011/12/30 | [
"https://wordpress.stackexchange.com/questions/37537",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2511/"
] | I have a need to set the `wp_postmeta` value (in table: `wp_postmeta`) on every post that has a specific `term_taxonomy_id` (in table: `wp_term_relationships`):
Specifically:
* run a query against every `post_ID` that has `term_taxonomy_id` value of 18
* if the `wp_postmeta` for that `post_ID` doesn't contain the key... | I think I know what you mean, and if that is the case it's actually a straightforward operation.
Firstly [get all the](http://codex.wordpress.org/Class_Reference/wpdb#SELECT_Generic_Results) `object_id`s from the `term_relationship` table.
```
$results = $wpdb->get_results("SELECT `object_id` FROM $wpdb->term_relatio... |
37,538 | <p>I found this example of a shortcode on the Internet:</p>
<pre><code>function project_shortcode( $atts, $content = null ) {
extract( shortcode_atts( array(
'class' => '',
'id' => '',
), $atts ) );
return '<div id="' . $id . '" class="' . $class . '">' . $content . '&l... | [
{
"answer_id": 37540,
"author": "janoChen",
"author_id": 781,
"author_profile": "https://wordpress.stackexchange.com/users/781",
"pm_score": 2,
"selected": false,
"text": "<p>Got it:</p>\n\n<pre><code>// Project shortcode\nfunction project_shortcode( $atts, $content = null ) {\n extra... | 2011/12/30 | [
"https://wordpress.stackexchange.com/questions/37538",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/781/"
] | I found this example of a shortcode on the Internet:
```
function project_shortcode( $atts, $content = null ) {
extract( shortcode_atts( array(
'class' => '',
'id' => '',
), $atts ) );
return '<div id="' . $id . '" class="' . $class . '">' . $content . '</div>';
}
add_shortcode('b... | Don’t use output buffering. It is too slow and sometimes hard to debug. Use [heredoc](http://www.php.net/manual/en/language.types.string.php#language.types.string.syntax.heredoc).
Example:
```php
$output = <<<MYUNIQUENAME
<div>$foo
<p>Some $bar</p>
</div>
MYUNIQUENAME;
``` |
37,548 | <p>Adding this in the widget form method:</p>
<pre><code>wp_editor($text, $this->get_field_id('text'));
</code></pre>
<p>seems to work. But after you press the "Save" button the widget goes funky...</p>
<p>Adding <code>_WP_Editors::editor_js();</code> makes it show after you press the save button, but then oth... | [
{
"answer_id": 38348,
"author": "Annika Backstrom",
"author_id": 66,
"author_profile": "https://wordpress.stackexchange.com/users/66",
"pm_score": 0,
"selected": false,
"text": "<p>I haven't dug into its code, but at first glance <a href=\"http://wordpress.org/extend/plugins/spots/\" rel... | 2011/12/30 | [
"https://wordpress.stackexchange.com/questions/37548",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11532/"
] | Adding this in the widget form method:
```
wp_editor($text, $this->get_field_id('text'));
```
seems to work. But after you press the "Save" button the widget goes funky...
Adding `_WP_Editors::editor_js();` makes it show after you press the save button, but then other things start to act weird. I think it has so... | As said I think it's quite hard to find a reliable solution because you have to take care of so many things.
I go either for the way proposed by Danny van Kooten:
<http://dannyvankooten.com/450/tinymce-wysiwyg-editor-in-wordpress-plugin/>
add and open the editor in a thickbox or another way I've used once, using the ... |
37,551 | <p>I'm making a custom post type which is intended to be viewed by logged in users only, I've created a single-{postType}.php to override the default rendering and has included a logincheck in the top which redirects to the login page and back, after login.</p>
<p>I've not enabled archive for my post type, so I imagin... | [
{
"answer_id": 37566,
"author": "Tareq",
"author_id": 7156,
"author_profile": "https://wordpress.stackexchange.com/users/7156",
"pm_score": 4,
"selected": true,
"text": "<p>A simple filter on your post content can do this job easily. Lets try this code </p>\n\n<pre><code>function tp_stop... | 2011/12/30 | [
"https://wordpress.stackexchange.com/questions/37551",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11531/"
] | I'm making a custom post type which is intended to be viewed by logged in users only, I've created a single-{postType}.php to override the default rendering and has included a logincheck in the top which redirects to the login page and back, after login.
I've not enabled archive for my post type, so I imagine I don't ... | A simple filter on your post content can do this job easily. Lets try this code
```
function tp_stop_guestes( $content ) {
global $post;
if ( $post->post_type == 'YOUR_CUSTOM_POSTTYPE' ) {
if ( !is_user_logged_in() ) {
$content = 'Please login to view this post';
}
}
retu... |
37,603 | <p>I've got a string with post ID's: <code>43,23,65</code>.<br>
I was hoping I could use <code>get_posts()</code> and use the string with ID's as an argument.</p>
<p>But I can't find any functions for retrieving multiple posts by ID.</p>
<p>Do I really have to do a <code>WP_query</code>?</p>
<p>I've also seen someon... | [
{
"answer_id": 37604,
"author": "CookiesForDevo",
"author_id": 10908,
"author_profile": "https://wordpress.stackexchange.com/users/10908",
"pm_score": 7,
"selected": true,
"text": "<p>You can use <a href=\"https://codex.wordpress.org/Template_Tags/get_posts\"><code>get_posts()</code></a>... | 2011/12/31 | [
"https://wordpress.stackexchange.com/questions/37603",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1447/"
] | I've got a string with post ID's: `43,23,65`.
I was hoping I could use `get_posts()` and use the string with ID's as an argument.
But I can't find any functions for retrieving multiple posts by ID.
Do I really have to do a `WP_query`?
I've also seen someone mention using `tag_in` - but I can't find any documentat... | You can use [`get_posts()`](https://codex.wordpress.org/Template_Tags/get_posts) as it takes the same arguments as `WP_Query`.
To pass it the IDs, use `'post__in' => array(43,23,65)` (only takes arrays).
Something like:
```
$args = array(
'post__in' => array(43,23,65)
);
$posts = get_posts($args);
foreach ($p... |
37,618 | <p>I feel like I must be missing something pretty obvious, here, but I can't seem to get WordPress to cooperate.</p>
<p>I'm generating Facebook OG tags with a function. Everything works fine, except for the excerpt.</p>
<p>Since the deprecation of <code>get_the_excerpt($post->ID)</code>, is there another way to cr... | [
{
"answer_id": 37624,
"author": "hakre",
"author_id": 178,
"author_profile": "https://wordpress.stackexchange.com/users/178",
"pm_score": 1,
"selected": false,
"text": "<p>Try:</p>\n\n<pre><code> get_post($post->ID)->post_excerpt\n ^^^^^^^^^^^^\n</code></pr... | 2011/12/31 | [
"https://wordpress.stackexchange.com/questions/37618",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11567/"
] | I feel like I must be missing something pretty obvious, here, but I can't seem to get WordPress to cooperate.
I'm generating Facebook OG tags with a function. Everything works fine, except for the excerpt.
Since the deprecation of `get_the_excerpt($post->ID)`, is there another way to create an excerpt without having ... | Turns out the answer was in `wp_trim_excerpt()`.
It's defined in `wp-includes/functions.php:1879`:
```
/**
* Generates an excerpt from the content, if needed.
*
* The excerpt word amount will be 55 words and if the amount is greater than
* that, then the string ' [...]' will be appended to the excerpt. If the str... |
37,633 | <p>I removed the categories column from "All posts" page by applying this code.</p>
<pre><code>add_filter("manage_edit-post_columns", "my_post_edit_columns");
function my_post_edit_columns($columns){
unset($columns['categories']);
return $columns;
}
</code></pre>
<p>This code removed categories column. But still ... | [
{
"answer_id": 37634,
"author": "Kailey Lampert",
"author_id": 11571,
"author_profile": "https://wordpress.stackexchange.com/users/11571",
"pm_score": 4,
"selected": true,
"text": "<p>I tested this and it works for removing the categories dropdown on the All Posts page:</p>\n\n<pre><code... | 2011/12/31 | [
"https://wordpress.stackexchange.com/questions/37633",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5074/"
] | I removed the categories column from "All posts" page by applying this code.
```
add_filter("manage_edit-post_columns", "my_post_edit_columns");
function my_post_edit_columns($columns){
unset($columns['categories']);
return $columns;
}
```
This code removed categories column. But still i see the categories filte... | I tested this and it works for removing the categories dropdown on the All Posts page:
```
add_action( 'load-edit.php', 'no_category_dropdown' );
function no_category_dropdown() {
add_filter( 'wp_dropdown_cats', '__return_false' );
}
```
-- below: old answer when I misunderstood the question --
The code you pos... |
37,644 | <p>I am trying to include a special Archive page with my theme, right now I have a PHP file with </p>
<p><code>Template Name: Archives Template</code> at the top and I the user must create a blank archive POST PAGE and then select this as the template.</p>
<p>The content for creating the page is blank so nothing is a... | [
{
"answer_id": 37649,
"author": "Brian Fegter",
"author_id": 4793,
"author_profile": "https://wordpress.stackexchange.com/users/4793",
"pm_score": 5,
"selected": true,
"text": "<p>To wit, this technically isn't a 'page', however it's a way to surface content using mod_rewrite. The goal h... | 2012/01/01 | [
"https://wordpress.stackexchange.com/questions/37644",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8668/"
] | I am trying to include a special Archive page with my theme, right now I have a PHP file with
`Template Name: Archives Template` at the top and I the user must create a blank archive POST PAGE and then select this as the template.
The content for creating the page is blank so nothing is added into the database for t... | To wit, this technically isn't a 'page', however it's a way to surface content using mod\_rewrite. The goal here is to add a URI segment of foobar that will trigger a custom query, then include the specified template file.
Add a rewrite rule:
```
add_action('init', 'foo_add_rewrite_rule');
function foo_add_rewrite_ru... |
37,650 | <p>There is earlier post with similar title, but it does not look in to the WordPress 3.3, and that is important as 3.3 advertises interestingly: "Use the postname permalink structure without a performance penalty"</p>
<p>Problem with Wordpress 3.2 and earlier was that first it looked page names, and then 404. It didn... | [
{
"answer_id": 38061,
"author": "weston deboer",
"author_id": 8926,
"author_profile": "https://wordpress.stackexchange.com/users/8926",
"pm_score": 0,
"selected": false,
"text": "<p>This link should answer your question:</p>\n\n<p><a href=\"http://ottopress.com/2011/how-the-postname-perm... | 2012/01/01 | [
"https://wordpress.stackexchange.com/questions/37650",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11584/"
] | There is earlier post with similar title, but it does not look in to the WordPress 3.3, and that is important as 3.3 advertises interestingly: "Use the postname permalink structure without a performance penalty"
Problem with Wordpress 3.2 and earlier was that first it looked page names, and then 404. It didn't check t... | This isn't easily done in WP 3.3 unless you trick the rewrite rules to be in the correct spot and make wp\_rewrite think verbose rules are being used in the front end. The class below works.
```
class Test_Post_Type {
const POST_TYPE = 'test';
public static function init() {
global $wp_rewrite;
... |
37,665 | <p>What function can I use to fetch content of a single page within a post?
Let's say I want to split my post into 5 pages - how can I get content of, say, page 3?</p>
<p>Can't seem to find this in Codex...</p>
| [
{
"answer_id": 37670,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 2,
"selected": false,
"text": "<p>This should do the trick:</p>\n\n<pre><code>/**\n * For posts paginated using <!--nextpage-->, return ... | 2012/01/01 | [
"https://wordpress.stackexchange.com/questions/37665",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11598/"
] | What function can I use to fetch content of a single page within a post?
Let's say I want to split my post into 5 pages - how can I get content of, say, page 3?
Can't seem to find this in Codex... | This should do the trick:
```
/**
* For posts paginated using <!--nextpage-->, return a particular "page" of content.
* This function uses code from WP's setup_postdata() function.
* @param string $content the content to search for paginated page content.
* @param int $page_number the index of the page to return t... |
37,666 | <p>I am trying to find out a way to "email" users when a post is made?</p>
<p>It would be nice to have a drop down menu or check box to check to "email that user" when Publishing a new post?? So I can just check one of the USERS to notify??</p>
<p>Anything like this available? I have found this as a plugin - Email Po... | [
{
"answer_id": 37670,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 2,
"selected": false,
"text": "<p>This should do the trick:</p>\n\n<pre><code>/**\n * For posts paginated using <!--nextpage-->, return ... | 2012/01/01 | [
"https://wordpress.stackexchange.com/questions/37666",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11572/"
] | I am trying to find out a way to "email" users when a post is made?
It would be nice to have a drop down menu or check box to check to "email that user" when Publishing a new post?? So I can just check one of the USERS to notify??
Anything like this available? I have found this as a plugin - Email Post Changes -- but... | This should do the trick:
```
/**
* For posts paginated using <!--nextpage-->, return a particular "page" of content.
* This function uses code from WP's setup_postdata() function.
* @param string $content the content to search for paginated page content.
* @param int $page_number the index of the page to return t... |
37,668 | <p>I'm trying to get posts from 3 different categories and list them on the front page: </p>
<pre><code> // Carousel articles
$args = array( 'numberposts' => 3, 'orderby' => 'date', 'category' => 'karusell' );
$carousel = get_posts($args);
// News articles
$args = array( 'numberposts' => 3, 'orde... | [
{
"answer_id": 37670,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 2,
"selected": false,
"text": "<p>This should do the trick:</p>\n\n<pre><code>/**\n * For posts paginated using <!--nextpage-->, return ... | 2012/01/01 | [
"https://wordpress.stackexchange.com/questions/37668",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1447/"
] | I'm trying to get posts from 3 different categories and list them on the front page:
```
// Carousel articles
$args = array( 'numberposts' => 3, 'orderby' => 'date', 'category' => 'karusell' );
$carousel = get_posts($args);
// News articles
$args = array( 'numberposts' => 3, 'orderby' => 'date', 'category'... | This should do the trick:
```
/**
* For posts paginated using <!--nextpage-->, return a particular "page" of content.
* This function uses code from WP's setup_postdata() function.
* @param string $content the content to search for paginated page content.
* @param int $page_number the index of the page to return t... |
37,691 | <p>PART 01: INTRO
Hey Stackexchange
Greetings from the Snowy alps of Norway</p>
<p>I have now tried for two full consecutive days to
reverse engineer Magic Fields. Why?
Because I am a simple man, and want to import data to my wordpress from an exotic database using CSV (and not programming a php routine, which I don'... | [
{
"answer_id": 37670,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 2,
"selected": false,
"text": "<p>This should do the trick:</p>\n\n<pre><code>/**\n * For posts paginated using <!--nextpage-->, return ... | 2012/01/02 | [
"https://wordpress.stackexchange.com/questions/37691",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11604/"
] | PART 01: INTRO
Hey Stackexchange
Greetings from the Snowy alps of Norway
I have now tried for two full consecutive days to
reverse engineer Magic Fields. Why?
Because I am a simple man, and want to import data to my wordpress from an exotic database using CSV (and not programming a php routine, which I don't know nor... | This should do the trick:
```
/**
* For posts paginated using <!--nextpage-->, return a particular "page" of content.
* This function uses code from WP's setup_postdata() function.
* @param string $content the content to search for paginated page content.
* @param int $page_number the index of the page to return t... |
37,706 | <p>I've set up a custom hierarchical taxonomy called 'region'.</p>
<p>So now I have e.g. <code>url.com/region/leeds/</code> etc.</p>
<p>However, I'm now expanding to other countries, so I'm making the region sub-categories of the parent.</p>
<p>I want to rewrite the parent category URL to lose the <code>/region</cod... | [
{
"answer_id": 44043,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 2,
"selected": true,
"text": "<p>This is possible, but, the effort required is not trivial, and it is not performant, I would advise against do... | 2012/01/02 | [
"https://wordpress.stackexchange.com/questions/37706",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/737/"
] | I've set up a custom hierarchical taxonomy called 'region'.
So now I have e.g. `url.com/region/leeds/` etc.
However, I'm now expanding to other countries, so I'm making the region sub-categories of the parent.
I want to rewrite the parent category URL to lose the `/region` and instead become
`url.com/region/uk` ->... | This is possible, but, the effort required is not trivial, and it is not performant, I would advise against doing it.
Your regions taxonomy will have a rewrite rule similar to this:
```
regions/(.+?)/?$ -> region: (.+?)
```
What you're wanting is something similar to this:
```
(.+?)/?$ -> region(.+?)
```
The pro... |
37,708 | <p>I'm doing a site in wordpress and I need some help.<br>
I have a custom registration form where users can sign up and get special roles, but I want to save the users to the database as not activated so that the admin activates them through a plugin. Problem is that the code I'm using, just saves the user in the db i... | [
{
"answer_id": 37709,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>On user creation you should write into a database field the fact that the created account is not activated.</p>\n\... | 2011/11/14 | [
"https://wordpress.stackexchange.com/questions/37708",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10891/"
] | I'm doing a site in wordpress and I need some help.
I have a custom registration form where users can sign up and get special roles, but I want to save the users to the database as not activated so that the admin activates them through a plugin. Problem is that the code I'm using, just saves the user in the db immed... | Wordpress does not have a active/deactivate function out of the [box](http://wordpress.org/extend/ideas/topic/disable-user-accounts)
This worked for me to create users with aditional data.
```
wp_insert_user(array(
'user_login' => $username,
'user_pass' => $password,
'user_email' => $email,
... |
37,713 | <p>i have wordpress blog under my main site like following</p>
<pre><code>-root (mainsite)
-blog
</code></pre>
<p>i have placed <code>.htaccess</code> file to redirect my index.html page to index.php, .htaccess file have following code</p>
<pre><code>Redirect 303 /index.html http://mysite.com/index.php
</code></p... | [
{
"answer_id": 37709,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>On user creation you should write into a database field the fact that the created account is not activated.</p>\n\... | 2012/01/02 | [
"https://wordpress.stackexchange.com/questions/37713",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10517/"
] | i have wordpress blog under my main site like following
```
-root (mainsite)
-blog
```
i have placed `.htaccess` file to redirect my index.html page to index.php, .htaccess file have following code
```
Redirect 303 /index.html http://mysite.com/index.php
```
but after placing this file, my blog site stopped wo... | Wordpress does not have a active/deactivate function out of the [box](http://wordpress.org/extend/ideas/topic/disable-user-accounts)
This worked for me to create users with aditional data.
```
wp_insert_user(array(
'user_login' => $username,
'user_pass' => $password,
'user_email' => $email,
... |
37,733 | <p>I recently started an article directory using wordpress, and theme by dimox and plugin and plugin by artilcesss dot com.</p>
<p>On homepage it shows number registered authors and and published posts. </p>
<p>It is using %2$s for registered authors and %1$s for number of published articles in main index template.</... | [
{
"answer_id": 37735,
"author": "Rob Vermeer",
"author_id": 11135,
"author_profile": "https://wordpress.stackexchange.com/users/11135",
"pm_score": 2,
"selected": false,
"text": "<p>I think you are searching for this: <a href=\"http://codex.wordpress.org/Function_Reference/wp_count_posts... | 2012/01/02 | [
"https://wordpress.stackexchange.com/questions/37733",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11616/"
] | I recently started an article directory using wordpress, and theme by dimox and plugin and plugin by artilcesss dot com.
On homepage it shows number registered authors and and published posts.
It is using %2$s for registered authors and %1$s for number of published articles in main index template.
I have so many un... | I think you are searching for this: <http://codex.wordpress.org/Function_Reference/wp_count_posts>
```
<?php
$count_posts = wp_count_posts();
$draft_posts = $count_posts->draft;
?>
``` |
37,744 | <p>I am doing some maintenance on a blog that I was hired to create a couple of months ago. They wanted to add a slider in, so I started to implement FlexSlider. I ran into a problem though with the slider.</p>
<p>I have added the needed dependencies into the header:</p>
<pre><code><script src="https://ajax.google... | [
{
"answer_id": 37735,
"author": "Rob Vermeer",
"author_id": 11135,
"author_profile": "https://wordpress.stackexchange.com/users/11135",
"pm_score": 2,
"selected": false,
"text": "<p>I think you are searching for this: <a href=\"http://codex.wordpress.org/Function_Reference/wp_count_posts... | 2012/01/02 | [
"https://wordpress.stackexchange.com/questions/37744",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/807/"
] | I am doing some maintenance on a blog that I was hired to create a couple of months ago. They wanted to add a slider in, so I started to implement FlexSlider. I ran into a problem though with the slider.
I have added the needed dependencies into the header:
```
<script src="https://ajax.googleapis.com/ajax/libs/jquer... | I think you are searching for this: <http://codex.wordpress.org/Function_Reference/wp_count_posts>
```
<?php
$count_posts = wp_count_posts();
$draft_posts = $count_posts->draft;
?>
``` |
37,777 | <p>I've made a quick PHP script/page that uses the wp_insert_post() function to insert a post directly. And this works great. The post I am manually adding has an image in it, so I firstly manually/programatically upload the image to the respective "/uploads/" folder where all my post images are saved (btw im not usi... | [
{
"answer_id": 37783,
"author": "Rob Vermeer",
"author_id": 11135,
"author_profile": "https://wordpress.stackexchange.com/users/11135",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/wp_insert_attachment\" rel=\"nofollow\">Function R... | 2012/01/03 | [
"https://wordpress.stackexchange.com/questions/37777",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11636/"
] | I've made a quick PHP script/page that uses the wp\_insert\_post() function to insert a post directly. And this works great. The post I am manually adding has an image in it, so I firstly manually/programatically upload the image to the respective "/uploads/" folder where all my post images are saved (btw im not using ... | [Function Reference/wp insert attachment](http://codex.wordpress.org/Function_Reference/wp_insert_attachment)
```
$image_id = wp_insert_attachment( $attachment, $filename, $parent_post_id );
```
This function will return an image id which you can use for the featured image.
```
update_post_meta($post_id, "_thumbnai... |
37,790 | <p>I am wondering why my pages (post doesn't have this problem) have a double bar "<code>|</code>" in them</p>
<p>eg. <code>About || Jiew Meng's Blog</code></p>
<p><a href="http://jiewmeng.phpfogapp.com/about/" rel="nofollow noreferrer"><img src="https://i.imgur.com/OUepu.png" alt=""></a></p>
<p><strong>UPDATE</stro... | [
{
"answer_id": 37797,
"author": "Kevin Langley Jr.",
"author_id": 9968,
"author_profile": "https://wordpress.stackexchange.com/users/9968",
"pm_score": 2,
"selected": false,
"text": "<p>I came across this same situation where I needed dynamic menus for my Custom Post Type Archive pages t... | 2012/01/03 | [
"https://wordpress.stackexchange.com/questions/37790",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/794/"
] | I am wondering why my pages (post doesn't have this problem) have a double bar "`|`" in them
eg. `About || Jiew Meng's Blog`
[](http://jiewmeng.phpfogapp.com/about/)
**UPDATE**
Actually it appears in other pages too, like [this](http://jiewmeng.phpfogapp.com/portfolio/klif-media-v2... | To get your custom post types to show up in Appearance -> Menus, you need to do two things:
1. Check your arguments and make sure that **show\_in\_nav\_menus** is set to **true**.
2. Go to the Appearance -> Menus page and at the very top, click on **Screen Options**. In the panel that opens, make sure that your custom... |
37,798 | <p>To Wordpress' visual editor (TinyMCE), I would like to add a button that adds four non-breaking spaces when clicked, like this:</p>
<pre><code>&nbsp;&nbsp;&nbsp;&nbsp;
</code></pre>
<p>I found some plugins that add buttons to the HTML editor, but not to the visual editor (<a href="http://wordpress.... | [
{
"answer_id": 80342,
"author": "akTed",
"author_id": 25472,
"author_profile": "https://wordpress.stackexchange.com/users/25472",
"pm_score": 3,
"selected": false,
"text": "<p>TL;DR, code is at the bottom.</p>\n\n<p>OK, this should work for you, but it is a beta. It works for me, but I h... | 2012/01/03 | [
"https://wordpress.stackexchange.com/questions/37798",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10691/"
] | To Wordpress' visual editor (TinyMCE), I would like to add a button that adds four non-breaking spaces when clicked, like this:
```
```
I found some plugins that add buttons to the HTML editor, but not to the visual editor ([this one](http://wordpress.org/extend/plugins/post-editor-buttons-f... | I already demonstrated how you can achieve such thing in this [question](https://wordpress.stackexchange.com/questions/76976/shortcode-to-insert-nextpage/76989#76989) but I can explain it here again with your request. I have tested this in Wordpress 3.5 and it works elegantly. To avoid this answer being the length of a... |
37,822 | <p>I have one external page (<code>google_map.php</code>) which contain code to display google map information based on the selection criteria. </p>
<p>And in the wordpress page I want to display the google map which is coded in <code>google_map.php</code>. </p>
<p>I want to ask that how can I add <code>google_map... | [
{
"answer_id": 37823,
"author": "bingjie2680",
"author_id": 6496,
"author_profile": "https://wordpress.stackexchange.com/users/6496",
"pm_score": 4,
"selected": true,
"text": "<p>It is actually very simple. just </p>\n\n<ul>\n<li>add the following text in at begining of google_map.php pa... | 2012/01/03 | [
"https://wordpress.stackexchange.com/questions/37822",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11693/"
] | I have one external page (`google_map.php`) which contain code to display google map information based on the selection criteria.
And in the wordpress page I want to display the google map which is coded in `google_map.php`.
I want to ask that how can I add `google_map.php` page in my wordpress page?
Or other opti... | It is actually very simple. just
* add the following text in at begining of google\_map.php page
* upload this page to your theme folder.
* go to dashboard to create a page, when create a page chose page telmplate: google map.
that is it, you can read more [here](http://codex.wordpress.org/Pages#Creating_Your_Own_Pa... |
37,837 | <p>I'm trying to simplify my deploy process and am making use of the Capistrano tool. Is there a way to have capistrano flush W3TC's cache in a deploy task?</p>
| [
{
"answer_id": 52766,
"author": "andreascreten",
"author_id": 7983,
"author_profile": "https://wordpress.stackexchange.com/users/7983",
"pm_score": 0,
"selected": false,
"text": "<p>You could use wp-cli to flush W3TC: <a href=\"https://github.com/wp-cli/wp-cli\" rel=\"nofollow\">https://... | 2012/01/03 | [
"https://wordpress.stackexchange.com/questions/37837",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11657/"
] | I'm trying to simplify my deploy process and am making use of the Capistrano tool. Is there a way to have capistrano flush W3TC's cache in a deploy task? | As @andreascreten, [wp-cli](https://github.com/wp-cli/wp-cli) will do the job for you.
wp-cli includes commands for W3TC (located in the `src/php/wp-cli/commands/community/total-cache.php` file), so you can flush the cache by running:
```
$ wp total-cache flush <type>
```
Where `<type>` is one of 'db', 'minify', 'o... |
37,845 | <p>I have nasty issue occuring every so often where sometime a guest blogger would inadvertently put a non-UTF character or an unbalanced HTML tag into a post, which will then break the RSS feed and will result in FeedBurner not being able to send it to subscribers via email.</p>
<p>Is there a technological way to avo... | [
{
"answer_id": 41242,
"author": "Brian Fegter",
"author_id": 4793,
"author_profile": "https://wordpress.stackexchange.com/users/4793",
"pm_score": 2,
"selected": false,
"text": "<p>If this is just happening in the RSS content area, try filtering out the chars by using the_content_rss fil... | 2012/01/03 | [
"https://wordpress.stackexchange.com/questions/37845",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/977/"
] | I have nasty issue occuring every so often where sometime a guest blogger would inadvertently put a non-UTF character or an unbalanced HTML tag into a post, which will then break the RSS feed and will result in FeedBurner not being able to send it to subscribers via email.
Is there a technological way to avoid this ki... | copy this code in a php file, copy this file in your plugins-folder and after this activate it on the backend of WordPress. I hope this helps, but i dont test it, write it on scratch.
```
<?php
/**
* Plugin Name: Non-UTF characters in RSS feed
* Plugin URI: http://wordpress.stackexchange.com/questions/37845/non-utf... |
37,847 | <p>On my blog on all my main loops I have it set to show the <code>excerpt</code> instead of the <code>content</code></p>
<p>If I make a longer post and leave the <code>excerpt</code> text box empty, then wordpress will make it's own excerpt from my post and show the <code>[...]</code> or a custom link at the end. Th... | [
{
"answer_id": 37853,
"author": "GavinR",
"author_id": 2001,
"author_profile": "https://wordpress.stackexchange.com/users/2001",
"pm_score": 1,
"selected": false,
"text": "<p>Add this in your theme's functions.php:</p>\n\n<pre><code>function new_excerpt_more($more) {\n global $post... | 2012/01/04 | [
"https://wordpress.stackexchange.com/questions/37847",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8668/"
] | On my blog on all my main loops I have it set to show the `excerpt` instead of the `content`
If I make a longer post and leave the `excerpt` text box empty, then wordpress will make it's own excerpt from my post and show the `[...]` or a custom link at the end. Thats great however if I DO enter my own excerpt into the... | Perhaps a conditional statement like the following will work. The logic is: "If the post has an explicit excerpt, add a read more link. Otherwise, use default excerpt behavior."
```
if($post->post_excerpt) {
the_excerpt();
echo '<a href="'.get_permalink().'">Read More</a>';
} else {
the_excerpt();
}
```
... |
37,864 | <p>I searching a lot to found a way solves that and no luck at least.</p>
<p>Sorry for my unpulish english, I do my best explaining my issue.</p>
<p>I have a Custom Post Type called <code>'Events'</code> this have two categories <code>'Congresses in Argentina'</code> and <code>'International Congresses'</code>, I nee... | [
{
"answer_id": 38070,
"author": "bevi",
"author_id": 11667,
"author_profile": "https://wordpress.stackexchange.com/users/11667",
"pm_score": 0,
"selected": false,
"text": "<p>This is the code I use to make it work, at least it's a start :)</p>\n\n<p>This was for the first column and firs... | 2012/01/04 | [
"https://wordpress.stackexchange.com/questions/37864",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11667/"
] | I searching a lot to found a way solves that and no luck at least.
Sorry for my unpulish english, I do my best explaining my issue.
I have a Custom Post Type called `'Events'` this have two categories `'Congresses in Argentina'` and `'International Congresses'`, I need to show the list of posts sorted by columns (2) ... | Here is the actual code I use to resolve the initial need, this was taken for another question/answer an really works, the only thing I like to make is to put each position of the post of the column at the same row of the other term.
```
<?php
// for a given post type, return all
$post_... |
37,876 | <p>I'm trying to add a feature to my 'Services' custom post type single template that displays one thing if the post type has one or more child post types and another thing if it doesn't. So far I've come up with this, however it doesn't seem to work as expected:</p>
<pre><code><?php
if($post->post_parent)
$chil... | [
{
"answer_id": 37898,
"author": "Stephen Radford",
"author_id": 10959,
"author_profile": "https://wordpress.stackexchange.com/users/10959",
"pm_score": 1,
"selected": false,
"text": "<p>If you're using custom post types then you're going to need to create a custom loop.</p>\n\n<pre><code... | 2012/01/04 | [
"https://wordpress.stackexchange.com/questions/37876",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10076/"
] | I'm trying to add a feature to my 'Services' custom post type single template that displays one thing if the post type has one or more child post types and another thing if it doesn't. So far I've come up with this, however it doesn't seem to work as expected:
```
<?php
if($post->post_parent)
$children = wp_list_pages... | If you're using custom post types then you're going to need to create a custom loop.
```
<?php $loop = new WP_Query( array( 'post_type' => 'services', 'posts_per_page' => 5) ); ?>
<?php while ( $loop->have_posts() ) : $loop->the_post(); ?>
POST HERE
<?php endwhile; ?>
``` |
37,880 | <p>I am trying to use wp_dropdown_categories at front end. I got the dropdown box with default "uncategorized", the rest of the category is not there. </p>
<pre><code>function cats_dropdown(){
require_once(ABSPATH . '/wp-admin/includes/template.php');
$args = array('taxonomy' => 'category');
?>
<div... | [
{
"answer_id": 37881,
"author": "Stephen Radford",
"author_id": 10959,
"author_profile": "https://wordpress.stackexchange.com/users/10959",
"pm_score": 0,
"selected": false,
"text": "<p>You shouldn't need to define the taxonomy of category as that's the default. Have you tried just using... | 2012/01/04 | [
"https://wordpress.stackexchange.com/questions/37880",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5210/"
] | I am trying to use wp\_dropdown\_categories at front end. I got the dropdown box with default "uncategorized", the rest of the category is not there.
```
function cats_dropdown(){
require_once(ABSPATH . '/wp-admin/includes/template.php');
$args = array('taxonomy' => 'category');
?>
<div>
<?php wp_dropd... | It could be that it won't show empty categories, categories that has no posts attached to them.
Try to change `$args = array('taxonomy' => 'category');` to `$args = array('taxonomy' => 'category', 'hide_empty' => 0);` |
37,887 | <p>I have <code>wp_dropdown_categories</code> working without setting <code>child_of</code>. Once I set <code>child_of</code>, all categories disappear. Here's my code, what should I do to enable <code>child_of</code>?</p>
<pre><code>function dropdown(){
$book_term=term_exists('book','category');
$book_term_id... | [
{
"answer_id": 37890,
"author": "Velvet Blues",
"author_id": 11498,
"author_profile": "https://wordpress.stackexchange.com/users/11498",
"pm_score": 1,
"selected": false,
"text": "<p>The variable <code>$book_term_id</code> has not been set. You either need to pass it to your function or ... | 2012/01/04 | [
"https://wordpress.stackexchange.com/questions/37887",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5210/"
] | I have `wp_dropdown_categories` working without setting `child_of`. Once I set `child_of`, all categories disappear. Here's my code, what should I do to enable `child_of`?
```
function dropdown(){
$book_term=term_exists('book','category');
$book_term_id = $book_term['term_id'];
$dropdown = array(
'chi... | The variable `$book_term_id` has not been set. You either need to pass it to your function or set it in your function.
Pass it to your function:
```
<?php dropdown($book_term_id); ?>
```
Set it in your function:
```
function dropdown(){
$book_term_id = 5; // if a global variable, you can just use: global $book_... |
37,893 | <p>I am building a new website on Wordpress, and all my pages have the add comment box at the bottom. I wish fo rthis to be removed from pages such as Home, Contact Us, About etc etc, but want it to remain on the blogs and galleries.</p>
<p>I have read <a href="https://wordpress.stackexchange.com/questions/4092/how-to... | [
{
"answer_id": 37890,
"author": "Velvet Blues",
"author_id": 11498,
"author_profile": "https://wordpress.stackexchange.com/users/11498",
"pm_score": 1,
"selected": false,
"text": "<p>The variable <code>$book_term_id</code> has not been set. You either need to pass it to your function or ... | 2012/01/04 | [
"https://wordpress.stackexchange.com/questions/37893",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11682/"
] | I am building a new website on Wordpress, and all my pages have the add comment box at the bottom. I wish fo rthis to be removed from pages such as Home, Contact Us, About etc etc, but want it to remain on the blogs and galleries.
I have read [this question](https://wordpress.stackexchange.com/questions/4092/how-to-re... | The variable `$book_term_id` has not been set. You either need to pass it to your function or set it in your function.
Pass it to your function:
```
<?php dropdown($book_term_id); ?>
```
Set it in your function:
```
function dropdown(){
$book_term_id = 5; // if a global variable, you can just use: global $book_... |
37,911 | <p>Does anybody know how to modify the url struct only for the single post page? </p>
<p>When I go to a post page, the url should look like: example.com/xxx/my-post. All other urls (with the exception of the single post pages) should not contain "xxx" in the url.</p>
<p>Customizing the permalink settings would add xx... | [
{
"answer_id": 38366,
"author": "c10b10",
"author_id": 8036,
"author_profile": "https://wordpress.stackexchange.com/users/8036",
"pm_score": 3,
"selected": true,
"text": "<p>The solution is to reregister the default post type just after Wordpress, and to add a rewrite slug. Also, the _bu... | 2012/01/04 | [
"https://wordpress.stackexchange.com/questions/37911",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8036/"
] | Does anybody know how to modify the url struct only for the single post page?
When I go to a post page, the url should look like: example.com/xxx/my-post. All other urls (with the exception of the single post pages) should not contain "xxx" in the url.
Customizing the permalink settings would add xxx in front of tax... | The solution is to reregister the default post type just after Wordpress, and to add a rewrite slug. Also, the \_builtin param needs to be set to false.
```
add_action( 'init', 'my_new_default_post_type', 1 );
function my_new_default_post_type() {
register_post_type( 'post', array(
'labels' => array(
... |
37,918 | <p>I would like to add thickbox for the template which I develop to WordPress. At this time I'm trying with a clean template that have only <code>header.php</code>, <code>footer.php</code>,<code>index.php</code>, and <code>functions.php</code>.</p>
<p>I've included the <code><?php wp_head(); ?></code> into <code... | [
{
"answer_id": 37920,
"author": "Norcross",
"author_id": 403,
"author_profile": "https://wordpress.stackexchange.com/users/403",
"pm_score": 2,
"selected": true,
"text": "<p>You need to use the <a href=\"http://codex.wordpress.org/Function_Reference/wp_enqueue_script\" rel=\"nofollow\">w... | 2012/01/04 | [
"https://wordpress.stackexchange.com/questions/37918",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11699/"
] | I would like to add thickbox for the template which I develop to WordPress. At this time I'm trying with a clean template that have only `header.php`, `footer.php`,`index.php`, and `functions.php`.
I've included the `<?php wp_head(); ?>` into `header.php` and the `<?php wp_footer(); ?>` into `footer.php`.
I've includ... | You need to use the [wp\_enqueue\_script](http://codex.wordpress.org/Function_Reference/wp_enqueue_script) function (in your functions.php file) to call the relevant scripts you need. It allows for both built-in libraries and to add any custom that you're including in your theme. |
37,935 | <p>Is there a way to limit the number of words per post through the the_content() function or something similar? </p>
| [
{
"answer_id": 37939,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 2,
"selected": true,
"text": "<p>You can limit is through a filter on <code>the_content</code></p>\n\n<p>For example (in functions.php):</p>\n\n<pre>... | 2012/01/04 | [
"https://wordpress.stackexchange.com/questions/37935",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7355/"
] | Is there a way to limit the number of words per post through the the\_content() function or something similar? | You can limit is through a filter on `the_content`
For example (in functions.php):
```
add_filter("the_content", "Content_Filter_Custom");
function Content_Filter_Custom($content)
{
// return a subset of it
return substr($content, 0, 300);
}
``` |
37,941 | <p>I need help with this code.
How can I change the code so that the posts from one category to be arranged like the this scheme. <a href="http://www.picvalley.net/v.php?p=u/2455/193250090019420937401325705906biUpRgmJ0uJopq9iAnr5.PNG" rel="nofollow">scheme picture</a>
</p>
<pre><code> <?php query_posts('... | [
{
"answer_id": 37939,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 2,
"selected": true,
"text": "<p>You can limit is through a filter on <code>the_content</code></p>\n\n<p>For example (in functions.php):</p>\n\n<pre>... | 2012/01/04 | [
"https://wordpress.stackexchange.com/questions/37941",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11705/"
] | I need help with this code.
How can I change the code so that the posts from one category to be arranged like the this scheme. [scheme picture](http://www.picvalley.net/v.php?p=u/2455/193250090019420937401325705906biUpRgmJ0uJopq9iAnr5.PNG)
```
<?php query_posts('cat=3&showposts=1'); ?>
<?php while(have_pos... | You can limit is through a filter on `the_content`
For example (in functions.php):
```
add_filter("the_content", "Content_Filter_Custom");
function Content_Filter_Custom($content)
{
// return a subset of it
return substr($content, 0, 300);
}
``` |
37,960 | <p>The WordPress codex <a href="https://developer.wordpress.org/reference/functions/wp_enqueue_script/" rel="nofollow noreferrer">says</a>:</p>
<p>(<a href="https://web.archive.org/web/20160120120740/https://codex.wordpress.org/Function_Reference/wp_enqueue_script" rel="nofollow noreferrer">old codex page</a>)</p>
<b... | [
{
"answer_id": 37965,
"author": "krembo99",
"author_id": 13256,
"author_profile": "https://wordpress.stackexchange.com/users/13256",
"pm_score": 5,
"selected": true,
"text": "<p>Where did you put your code ? </p>\n\n<ol>\n<li>the \"true\" arguments goes in the <code>wp_register_script();... | 2012/01/05 | [
"https://wordpress.stackexchange.com/questions/37960",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/781/"
] | The WordPress codex [says](https://developer.wordpress.org/reference/functions/wp_enqueue_script/):
([old codex page](https://web.archive.org/web/20160120120740/https://codex.wordpress.org/Function_Reference/wp_enqueue_script))
>
> $in\_footer
>
>
> (boolean) (optional) Normally scripts are placed in the
> secti... | Where did you put your code ?
1. the "true" arguments goes in the `wp_register_script();`, not the `wp_enqueue_script() ;`
the functions is:
`<?php wp_enqueue_script('handle', 'src', 'deps', 'ver', 'in_footer'); ?>`
meaning
```
<?php wp_enqueue_script('NameMySccript', 'path/to/MyScript',
'dependencies_MyScr... |
37,961 | <p>I have a query var <code>show=othertemplate</code> that I can add to any URL to show any post, page or archive in Wordpress in a different template, like this: <strong>mysite.com/[any URL]/?show=othertemplate</strong>. I'd like for it to be accessible via clean URL, like <strong>[any URL]/othertemplate</strong> or ... | [
{
"answer_id": 37968,
"author": "Brian Fegter",
"author_id": 4793,
"author_profile": "https://wordpress.stackexchange.com/users/4793",
"pm_score": 0,
"selected": false,
"text": "<p>Check out my post <a href=\"https://wordpress.stackexchange.com/questions/37644/create-a-page-without-addin... | 2012/01/05 | [
"https://wordpress.stackexchange.com/questions/37961",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3564/"
] | I have a query var `show=othertemplate` that I can add to any URL to show any post, page or archive in Wordpress in a different template, like this: **mysite.com/[any URL]/?show=othertemplate**. I'd like for it to be accessible via clean URL, like **[any URL]/othertemplate** or **[any URL]/show/othertemplate**.
I have... | You should look at "Rewrite Endpoints", which are much simpler to work with than custom rewrites. And they fit your use case perfectly: <http://codex.wordpress.org/Rewrite_API/add_rewrite_endpoint>
You might add your "show" endpoint like so:
```
function wpsx_37961_add_endpoints() {
// Add the "show" rewrite end... |
37,967 | <p>Why wont the custom fields from this post type save?</p>
<p>I have a custom post-type called Photos and a couple of meta boxes. Here is basically what I have in my functions.php</p>
<pre><code>add_action('init', 'photo_register');
function photo_register() {
$labels = array(
'name' => _x('My Phot... | [
{
"answer_id": 37969,
"author": "Brian Fegter",
"author_id": 4793,
"author_profile": "https://wordpress.stackexchange.com/users/4793",
"pm_score": 0,
"selected": false,
"text": "<p>You need to isolate your save_post action. You also aren't passing in the post_id as an argument to the fun... | 2012/01/05 | [
"https://wordpress.stackexchange.com/questions/37967",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2661/"
] | Why wont the custom fields from this post type save?
I have a custom post-type called Photos and a couple of meta boxes. Here is basically what I have in my functions.php
```
add_action('init', 'photo_register');
function photo_register() {
$labels = array(
'name' => _x('My Photos', 'post type general n... | I use the following code to prevent updates of my custom fields during auto-saves, ajax requests (quick edit) and bulk edits.
```
add_action('save_post', 'save_my_post');
function save_my_post($post_id)
{
// Stop WP from clearing custom fields on autosave,
// and also during ajax requests (e.g. quick edit) and... |
37,976 | <p>I am looking for a host to start my new WordPress site.</p>
<p>The criteria for this is that they must totally/truly specialise in WordPress hosting.</p>
<p>Many companies claim to have a certain expertise in hosting WordPress, but the fact is they just have it installed.</p>
<p>I would like recommendations for h... | [
{
"answer_id": 37969,
"author": "Brian Fegter",
"author_id": 4793,
"author_profile": "https://wordpress.stackexchange.com/users/4793",
"pm_score": 0,
"selected": false,
"text": "<p>You need to isolate your save_post action. You also aren't passing in the post_id as an argument to the fun... | 2012/01/05 | [
"https://wordpress.stackexchange.com/questions/37976",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11682/"
] | I am looking for a host to start my new WordPress site.
The criteria for this is that they must totally/truly specialise in WordPress hosting.
Many companies claim to have a certain expertise in hosting WordPress, but the fact is they just have it installed.
I would like recommendations for hosts in the UK but am op... | I use the following code to prevent updates of my custom fields during auto-saves, ajax requests (quick edit) and bulk edits.
```
add_action('save_post', 'save_my_post');
function save_my_post($post_id)
{
// Stop WP from clearing custom fields on autosave,
// and also during ajax requests (e.g. quick edit) and... |
37,994 | <p>I need to use the_permalink() in order to construct a simple link from each post . the link should be like </p>
<pre><code>http://www.mysite.com/category/year/post-name?output=something..
</code></pre>
<p>I use ?output=something" ></p>
<p>the problem is that the trailing slash of the permalink is giving me an ext... | [
{
"answer_id": 37995,
"author": "krembo99",
"author_id": 13256,
"author_profile": "https://wordpress.stackexchange.com/users/13256",
"pm_score": 0,
"selected": false,
"text": "<pre><code>echo substr(the_permalink(), 0, -1);\n</code></pre>\n"
},
{
"answer_id": 37997,
"author":... | 2012/01/05 | [
"https://wordpress.stackexchange.com/questions/37994",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I need to use the\_permalink() in order to construct a simple link from each post . the link should be like
```
http://www.mysite.com/category/year/post-name?output=something..
```
I use ?output=something" >
the problem is that the trailing slash of the permalink is giving me an extar trailing slash that is breaki... | You can use the `trim` command to do this, specifically, the `rtrim` to remove the character from the right side:
```
$url = rtrim(get_permalink(),'/');
```
Using a blanket `substr -1` technique would cause problems if there isn't a trailing slash in the permalink. Also, the function `the_permalink` echoes the link,... |
38,006 | <p>Is there a way or a plugin so that I can see statistics for may comments and commenters? Like top commenters, most commented post, etc. </p>
<p>Thanks,
Alex</p>
| [
{
"answer_id": 38008,
"author": "Dora Daniluc",
"author_id": 11729,
"author_profile": "https://wordpress.stackexchange.com/users/11729",
"pm_score": 0,
"selected": false,
"text": "<p>I use Admin comments statistics plugin ( <a href=\"http://www.greatwpplugins.com/admin-comments-statistic... | 2012/01/05 | [
"https://wordpress.stackexchange.com/questions/38006",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11727/"
] | Is there a way or a plugin so that I can see statistics for may comments and commenters? Like top commenters, most commented post, etc.
Thanks,
Alex | For most commented posts you can use a custom loop in the sidebar for example:
```
<h3>Most Commented Posts</h3>
<?php $most_commented = new WP_Query('orderby=comment_count&posts_per_page=5');
if($most_commented->have_posts()) : ?>
<ul class="most-commented-posts">
<?php while($most_commented->have_posts()) : $mos... |
38,009 | <p>I have a menu that is currently shown with <code>wp_list_pages( 'title_li=' );</code>
This shows all the sub pages from all the pages in the menu.</p>
<p>I want to exclude a page with id 56 from displaying its sub items.</p>
<p>When I use <code>wp_list_pages( 'exclude=56&title_li=' );</code> the menu becomes h... | [
{
"answer_id": 38019,
"author": "Simon Scarfe",
"author_id": 3489,
"author_profile": "https://wordpress.stackexchange.com/users/3489",
"pm_score": 2,
"selected": false,
"text": "<p>There's a filter called wp_list_pages_exclude that you could possibly hook into (put this in your functions... | 2012/01/05 | [
"https://wordpress.stackexchange.com/questions/38009",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5807/"
] | I have a menu that is currently shown with `wp_list_pages( 'title_li=' );`
This shows all the sub pages from all the pages in the menu.
I want to exclude a page with id 56 from displaying its sub items.
When I use `wp_list_pages( 'exclude=56&title_li=' );` the menu becomes huge and all over the page.
When I use wp\_l... | There's a filter called wp\_list\_pages\_exclude that you could possibly hook into (put this in your functions.php):
```
function filter_wp_list_pages($exclude){
$exclude[] = 56;
return $exclude;
}
add_filter("wp_list_pages_excludes", "filter_wp_list_pages");
``` |
38,013 | <p>I have 264,307 "http" (post_type = http) rows in my wp_posts table. 99% of those have them have this post_title:</p>
<pre><code>GET http://twitter.com/statuses/user_timeline/@xcentric.json?count=100
</code></pre>
<p>and "error" as the post_status.</p>
<p>Can I simply delete these without it affecting my site? My ... | [
{
"answer_id": 38012,
"author": "Sebastien Hervieu",
"author_id": 11731,
"author_profile": "https://wordpress.stackexchange.com/users/11731",
"pm_score": 1,
"selected": false,
"text": "<p>Have you tried to log in using the following url once logged in?</p>\n\n<p><a href=\"http://localhos... | 2012/01/05 | [
"https://wordpress.stackexchange.com/questions/38013",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7858/"
] | I have 264,307 "http" (post\_type = http) rows in my wp\_posts table. 99% of those have them have this post\_title:
```
GET http://twitter.com/statuses/user_timeline/@xcentric.json?count=100
```
and "error" as the post\_status.
Can I simply delete these without it affecting my site? My wp\_posts table is 5gb!
Than... | The way you describe it, it sounds as if WordPress was installed to your root directory. That however doesn't explain why <http://localhost:8888/wp-admin/> doesn't work, unless you renamed the directory..? Try accessing <http://localhost:8888/wp-login.php> |
38,030 | <p>I need to determine if the current post has a "more" tag. I'm currently using</p>
<pre><code>$pos=strpos($post->post_content, '<!--more-->');
</code></pre>
<p>Am I missing a built in method similar to has_excerpt()?</p>
| [
{
"answer_id": 38037,
"author": "Scott",
"author_id": 4610,
"author_profile": "https://wordpress.stackexchange.com/users/4610",
"pm_score": 3,
"selected": true,
"text": "<p>Quite simply put: there is no built in function that does the same thing as your code above.</p>\n\n<p>Bonus conten... | 2012/01/05 | [
"https://wordpress.stackexchange.com/questions/38030",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6620/"
] | I need to determine if the current post has a "more" tag. I'm currently using
```
$pos=strpos($post->post_content, '<!--more-->');
```
Am I missing a built in method similar to has\_excerpt()? | Quite simply put: there is no built in function that does the same thing as your code above.
Bonus content: [More tag tricks](http://digwp.com/2010/01/wordpress-more-tag-tricks/) |
38,057 | <p>I am trying to create a post (well, in the end, multiple posts) from a metabox using the 'save_post' hook. I executed the script once, creating 3900 or so new posts before I crawled into posts.php and discovered that wp_insert_post() calls the 'save_post' hook. Does anyone have a creative solution around this to cre... | [
{
"answer_id": 38181,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<h2>Update</h2>\n\n<p>The answer is so simple, I couldn’t see it at first. :)</p>\n\n<p>Just remove the action during the... | 2012/01/06 | [
"https://wordpress.stackexchange.com/questions/38057",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11740/"
] | I am trying to create a post (well, in the end, multiple posts) from a metabox using the 'save\_post' hook. I executed the script once, creating 3900 or so new posts before I crawled into posts.php and discovered that wp\_insert\_post() calls the 'save\_post' hook. Does anyone have a creative solution around this to cr... | I figured it out, what I ended up doing was as follows:
```php
function my_metabox_save() {
//do this just once
if( MY_DOING_SAVE != 'my_doing_save' ) {
define( MY_DOING_SAVE , 'my_doing_save' );
//data authenticity check
//process & sanitize data
//create posts
for( $i=0; $i<$count; $i++ ) {... |
38,075 | <p>I hope i can write a clear question since i got confused trying to solve this...</p>
<p>I got a custom post type... that custom post type has taxomony (category like)<br>
and i want to <strong>return a structure like this</strong> in a page that show all posts of<br>
that post type..</p>
<p>-----------------------... | [
{
"answer_id": 38355,
"author": "sanchothefat",
"author_id": 1733,
"author_profile": "https://wordpress.stackexchange.com/users/1733",
"pm_score": 3,
"selected": true,
"text": "<p>If I follow your question correctly you could use a nested query loop, that is looping through your taxonomy... | 2012/01/06 | [
"https://wordpress.stackexchange.com/questions/38075",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7990/"
] | I hope i can write a clear question since i got confused trying to solve this...
I got a custom post type... that custom post type has taxomony (category like)
and i want to **return a structure like this** in a page that show all posts of
that post type..
--------------------------------------------- DESIRED S... | If I follow your question correctly you could use a nested query loop, that is looping through your taxonomy terms and then doing a WP\_Query loop for each one.
There is a more complicated approach using custom SQL and a filter but the following example is what I would go for:
```
$terms = get_terms("locations");
$co... |
38,085 | <p>I am running WP multi-site and BP. The plugin in question is Anti-Splog by WPMUDEV. They have advised they do not support customisations.</p>
<p>Anti-Splog tries to limit spam blogs from appearing on your multi-site network.</p>
<p>I am running a subdomain install. Therefore, on the form where the signup for a sub... | [
{
"answer_id": 38355,
"author": "sanchothefat",
"author_id": 1733,
"author_profile": "https://wordpress.stackexchange.com/users/1733",
"pm_score": 3,
"selected": true,
"text": "<p>If I follow your question correctly you could use a nested query loop, that is looping through your taxonomy... | 2012/01/06 | [
"https://wordpress.stackexchange.com/questions/38085",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11755/"
] | I am running WP multi-site and BP. The plugin in question is Anti-Splog by WPMUDEV. They have advised they do not support customisations.
Anti-Splog tries to limit spam blogs from appearing on your multi-site network.
I am running a subdomain install. Therefore, on the form where the signup for a subdomain occurs, I ... | If I follow your question correctly you could use a nested query loop, that is looping through your taxonomy terms and then doing a WP\_Query loop for each one.
There is a more complicated approach using custom SQL and a filter but the following example is what I would go for:
```
$terms = get_terms("locations");
$co... |
38,098 | <p>I have a website and i need to be able to edit the dashboard widgets so it shows relevant information to the website.</p>
<p>At the moment all that is showing is the right now widget. Inside this widget, i don't need the discussion section nor do i need posts and tags. What i do need is custom post types, for examp... | [
{
"answer_id": 38100,
"author": "v0idless",
"author_id": 6228,
"author_profile": "https://wordpress.stackexchange.com/users/6228",
"pm_score": 2,
"selected": true,
"text": "<p>You can get a little more fancy, but this should get you started.</p>\n\n<pre><code>add_action( 'right_now_conte... | 2012/01/06 | [
"https://wordpress.stackexchange.com/questions/38098",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9218/"
] | I have a website and i need to be able to edit the dashboard widgets so it shows relevant information to the website.
At the moment all that is showing is the right now widget. Inside this widget, i don't need the discussion section nor do i need posts and tags. What i do need is custom post types, for example product... | You can get a little more fancy, but this should get you started.
```
add_action( 'right_now_content_table_end', 'wpse_3809');
function wpse_3809() {
$types = get_post_types( array( '_builtin' => false ) );
foreach( $types as $type ) :
$num_posts = wp_count_posts( $type );
$num = number_format_... |
38,101 | <p>I'm working on a plugin for a system to use Wordpress as the authentication backend, so that I can use my existing Wordpress users in another application. The plugin works great when running in single website mode:</p>
<pre><code>include /path/to/wordpress/wp-config.php
global $wpdb;
// SQL and code to select user ... | [
{
"answer_id": 38125,
"author": "prettyboymp",
"author_id": 203,
"author_profile": "https://wordpress.stackexchange.com/users/203",
"pm_score": 3,
"selected": true,
"text": "<p>You'll want to include the <code>wp-load.php</code>, not the <code>wp-config.php</code>. </p>\n\n<p>Depending ... | 2012/01/06 | [
"https://wordpress.stackexchange.com/questions/38101",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3522/"
] | I'm working on a plugin for a system to use Wordpress as the authentication backend, so that I can use my existing Wordpress users in another application. The plugin works great when running in single website mode:
```
include /path/to/wordpress/wp-config.php
global $wpdb;
// SQL and code to select user and compare en... | You'll want to include the `wp-load.php`, not the `wp-config.php`.
Depending on how you're doing it, you may also have to set `$_SERVER` variables if they aren't already set to prevent WordPress from trying to redirect you. For example:
```
$_SERVER = array(
"HTTP_HOST" => "http://example.com",
"SERVER_NAME" => ... |
38,102 | <p>I am trying to use a self written script for the jQuery library in my self-made theme, but it's not working. When I simply use script-tags, everything is alright. So it has to be something with wp_enqueue_script and wp_register_script.
In the beginning of my code in the index.php I have</p>
<pre><code><?php
... | [
{
"answer_id": 38104,
"author": "Azizur Rahman",
"author_id": 3797,
"author_profile": "https://wordpress.stackexchange.com/users/3797",
"pm_score": 0,
"selected": false,
"text": "<p>I would recommend you put your code in <code>functions.php</code> as that would be loaded before your <cod... | 2012/01/06 | [
"https://wordpress.stackexchange.com/questions/38102",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11437/"
] | I am trying to use a self written script for the jQuery library in my self-made theme, but it's not working. When I simply use script-tags, everything is alright. So it has to be something with wp\_enqueue\_script and wp\_register\_script.
In the beginning of my code in the index.php I have
```
<?php
wp_enqueue_sc... | You want to use `wp_enqueue_scripts`.
```
add_action( 'wp_enqueue_scripts', 'wpse_3810' );
function wpse_3810() {
wp_enqueue_script( 'jquery' );
wp_register_script( 'my_name', 'path/to/my/script/script.js'));
wp_enqueue_script( 'my_name' );
}
``` |
38,155 | <p>Is it possible to set certain settings from the theme functions file for example the setting <code>Enable threaded (nested) comments</code> ca I set it to allow <code>2</code> as the answer without having the user go into the admin panel and setting it for there wordpress comment settings?</p>
| [
{
"answer_id": 38167,
"author": "Nikolay Yordanov",
"author_id": 8344,
"author_profile": "https://wordpress.stackexchange.com/users/8344",
"pm_score": 2,
"selected": false,
"text": "<p>Well, you can do something like this which will always reset the option to 2:</p>\n\n<pre><code>add_act... | 2012/01/07 | [
"https://wordpress.stackexchange.com/questions/38155",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8668/"
] | Is it possible to set certain settings from the theme functions file for example the setting `Enable threaded (nested) comments` ca I set it to allow `2` as the answer without having the user go into the admin panel and setting it for there wordpress comment settings? | I am satisfied with Nikolay Yordanov's answer. Just generalizing the solution.
Yes, we can update WordPress options programmatically. WordPress saves options in **wp\_options** table. **wp\_options** holds two rows **option\_name** and **option\_value** to store key and value respectively. We need right **option\_name... |
38,156 | <p>I just noticed, in a theme file, I can access custom functions I add to my functions file, however I can NOT access variables I set in my functions file.</p>
<p>I have a few variables I set inside my functions.php file for example...</p>
<pre><code>$feedburnerUsername = 'username';
</code></pre>
<p>Now in my side... | [
{
"answer_id": 38167,
"author": "Nikolay Yordanov",
"author_id": 8344,
"author_profile": "https://wordpress.stackexchange.com/users/8344",
"pm_score": 2,
"selected": false,
"text": "<p>Well, you can do something like this which will always reset the option to 2:</p>\n\n<pre><code>add_act... | 2012/01/07 | [
"https://wordpress.stackexchange.com/questions/38156",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8668/"
] | I just noticed, in a theme file, I can access custom functions I add to my functions file, however I can NOT access variables I set in my functions file.
I have a few variables I set inside my functions.php file for example...
```
$feedburnerUsername = 'username';
```
Now in my sidebar.php file If I try to access t... | I am satisfied with Nikolay Yordanov's answer. Just generalizing the solution.
Yes, we can update WordPress options programmatically. WordPress saves options in **wp\_options** table. **wp\_options** holds two rows **option\_name** and **option\_value** to store key and value respectively. We need right **option\_name... |
38,180 | <p>I'm writing a plugin with a settings/option page and I want some php code to be executed whenever someone saves the settings on that page and that page alone. Which actions do I need to hook into to accomplish this?</p>
| [
{
"answer_id": 38608,
"author": "Anh Tran",
"author_id": 2051,
"author_profile": "https://wordpress.stackexchange.com/users/2051",
"pm_score": 3,
"selected": true,
"text": "<p>If you're using <a href=\"http://codex.wordpress.org/Settings_API\" rel=\"nofollow\">Settings API</a>, then you ... | 2012/01/07 | [
"https://wordpress.stackexchange.com/questions/38180",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2234/"
] | I'm writing a plugin with a settings/option page and I want some php code to be executed whenever someone saves the settings on that page and that page alone. Which actions do I need to hook into to accomplish this? | If you're using [Settings API](http://codex.wordpress.org/Settings_API), then you should use a sanitize callback:
```
register_setting( $option_group, $option_name, $sanitize_callback );
```
The myth is that the `$sanitize_callback` actually is a filter for your options when it's saved in the database. This is the p... |
38,191 | <p>I got a metabox that hold a monthly budget per client...<br>
that meta box is inside a custom post type called clients.
Inside that metabox the only thing entered is numbers.</p>
<p>I want to get the sum of all the clients.<br>
Any ideas?</p>
<p>Altough i think its pure php.. somehow using foreach - to the request... | [
{
"answer_id": 38206,
"author": "mor7ifer",
"author_id": 11740,
"author_profile": "https://wordpress.stackexchange.com/users/11740",
"pm_score": 0,
"selected": false,
"text": "<pre><code>$args = array(\n 'numberposts' => -1, // all the posts\n 'post_type' => 'clients'\n);\... | 2012/01/07 | [
"https://wordpress.stackexchange.com/questions/38191",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7990/"
] | I got a metabox that hold a monthly budget per client...
that meta box is inside a custom post type called clients.
Inside that metabox the only thing entered is numbers.
I want to get the sum of all the clients.
Any ideas?
Altough i think its pure php.. somehow using foreach - to the request of @Fahd Murtaza i... | Asuming that you have a variable called `$posts` that contains all the posts (or easier: Post IDs) from some query.
You can then work with `$result` and process everything you need. Calling post data is easy, as the key would be the post ID.
```
// For other arguments look into @link http://codex.wordpress.org/Class_... |
38,207 | <p>I have a problem regarding special characters that are appearing messed up on the front-end .
mainly the get converted to question marks, or something like �?)</p>
<p>Example - Frédèric becomes Fr�d�ric.</p>
<p>some facts that made me puzzled:</p>
<ul>
<li><p>This WP install is on LOCAL machine, and shares the se... | [
{
"answer_id": 42953,
"author": "Jared",
"author_id": 2415,
"author_profile": "https://wordpress.stackexchange.com/users/2415",
"pm_score": 2,
"selected": false,
"text": "<p><strong>Edit:</strong></p>\n\n<p>Do you have <code><meta charset=\"utf-8\" /></code> in your <code><head&... | 2012/01/08 | [
"https://wordpress.stackexchange.com/questions/38207",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I have a problem regarding special characters that are appearing messed up on the front-end .
mainly the get converted to question marks, or something like �?)
Example - Frédèric becomes Fr�d�ric.
some facts that made me puzzled:
* This WP install is on LOCAL machine, and shares the server with at
least 40 other ... | **Edit:**
Do you have `<meta charset="utf-8" />` in your `<head>` tag? A user [here](http://wordpress.org/support/topic/utf-8-encoding-problem) fixed a similar problem with character encoding by adding this.
There are actually [many Google results](https://www.google.com/webhp?sourceid=chrome-instant&ie=UTF-8&ion=1#h... |
38,226 | <p>I have this code</p>
<pre><code>add_action( 'delete_post', 'my_delete_function' );
function my_delete_function() {
global $wpdb;
$wpdb->query("
DELETE FROM wp_votes WHERE post=".$thePostID."
;);
}
</code></pre>
<p>How can I get the id of the post being deleted?</p>
<p>Additionally, will this still... | [
{
"answer_id": 38230,
"author": "Asko",
"author_id": 11809,
"author_profile": "https://wordpress.stackexchange.com/users/11809",
"pm_score": 3,
"selected": true,
"text": "<p>I haven't tested so I'm providing you with two possibilities, Inside a loop, use the following:</p>\n\n<pre><code>... | 2012/01/08 | [
"https://wordpress.stackexchange.com/questions/38226",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11810/"
] | I have this code
```
add_action( 'delete_post', 'my_delete_function' );
function my_delete_function() {
global $wpdb;
$wpdb->query("
DELETE FROM wp_votes WHERE post=".$thePostID."
;);
}
```
How can I get the id of the post being deleted?
Additionally, will this still work if multiple posts are deleted ... | I haven't tested so I'm providing you with two possibilities, Inside a loop, use the following:
```
$post_id = get_the_ID();
```
Outside a loop, use the following:
```
global $wp_query;
$post_id = $wp_query->post->ID;
```
Or:
```
global $post;
$post_id = $post->ID
```
Or you can pass the post ID in a function,... |
38,237 | <p>I am trying to design a button in the sidebar which is related to the post displayed. The button is basically a "other news in CAT1". i have this piece of code:</p>
<pre><code><div id="pagine">
<?php
$category = get_the_category();
if($category[0]){
echo '<a href="'.get_category_link($category[0]->... | [
{
"answer_id": 38246,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 1,
"selected": false,
"text": "<p>get_the_category returns an array of the stdClass object of all categories associated with the current post_id.</p... | 2012/01/08 | [
"https://wordpress.stackexchange.com/questions/38237",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11819/"
] | I am trying to design a button in the sidebar which is related to the post displayed. The button is basically a "other news in CAT1". i have this piece of code:
```
<div id="pagine">
<?php
$category = get_the_category();
if($category[0]){
echo '<a href="'.get_category_link($category[0]->term_id ).'"><div id="pagine"... | One these three should do the job for you...
1. Function: [`the_category();`](http://codex.wordpress.org/Function_Reference/the_category)
--------------------------------------------------------------------------------------------
```
News su <?php the_category(', '); ?>
```
**Displays as:**
>
> News su [WordPres... |
38,241 | <p>Does anybody have an idea on how to allow a user to drop in separators or dividers between certain nav menu items?</p>
<p>Google only seems to bring up rookie CSS tips for first/last child selectors but I am after something very much like Firefox bookmarks.</p>
<p><strong>UPDATE:</strong></p>
<p>I <em>do</em> app... | [
{
"answer_id": 38242,
"author": "Asko",
"author_id": 11809,
"author_profile": "https://wordpress.stackexchange.com/users/11809",
"pm_score": -1,
"selected": false,
"text": "<p>I'd use jQuery's <a href=\"http://api.jquery.com/before/\" rel=\"nofollow\">.before()</a> and <a href=\"http://a... | 2012/01/08 | [
"https://wordpress.stackexchange.com/questions/38241",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1685/"
] | Does anybody have an idea on how to allow a user to drop in separators or dividers between certain nav menu items?
Google only seems to bring up rookie CSS tips for first/last child selectors but I am after something very much like Firefox bookmarks.
**UPDATE:**
I *do* appreciate all input so far, but I'll elaborate... | Use a [custom walker](https://wordpress.stackexchange.com/a/14039/73). Extend `start_el()` to print `<li class="menu_separator"><hr></li>` if the menu title is just a `'-'`.
functions.php
-------------
```
function wpse38241_setup_menu()
{
register_nav_menu( 'main-menu', 'Main Menu' );
}
add_action( 'after_setup_... |
38,244 | <p>I have this action/hook:</p>
<pre><code>add_action( 'before_delete_post', 'my_delete_function' );
function my_delete_function($post_id) {
global $wpdb;
$achievement = get_the_category($post_id);
$h = $achievement[0]->cat_ID;
$s = ''.str_replace('"', '', $h);
if ( $s == 6 || $s == 5){
... | [
{
"answer_id": 38253,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 2,
"selected": false,
"text": "<p><strike><code>wp_delete_post()</code> <strong>always</strong> triggers <code>before_delete_post</code> - th... | 2012/01/08 | [
"https://wordpress.stackexchange.com/questions/38244",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11810/"
] | I have this action/hook:
```
add_action( 'before_delete_post', 'my_delete_function' );
function my_delete_function($post_id) {
global $wpdb;
$achievement = get_the_category($post_id);
$h = $achievement[0]->cat_ID;
$s = ''.str_replace('"', '', $h);
if ( $s == 6 || $s == 5){
$wpdb->query("... | `wp_delete_post()` **always** triggers `before_delete_post` - the problem must be that you're hooking your function conditionally (i.e. not all the time).
`before_delete_post` **only** gets triggered if you're actually *deleting* the post permanently, not just trashing it.
If you need to listen for trashing too, use ... |
38,245 | <p>I'm looking for a shortcode similar to this:</p>
<pre><code>[hidetext]some text to hide[/hidetext]
</code></pre>
<p>Then what will happen is that the the tag will hide the text from any page that isn't the Single Post page. Only on the Single Post Page will the <code>[hidetext]</code> show. How can I do something ... | [
{
"answer_id": 38253,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 2,
"selected": false,
"text": "<p><strike><code>wp_delete_post()</code> <strong>always</strong> triggers <code>before_delete_post</code> - th... | 2012/01/08 | [
"https://wordpress.stackexchange.com/questions/38245",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/127/"
] | I'm looking for a shortcode similar to this:
```
[hidetext]some text to hide[/hidetext]
```
Then what will happen is that the the tag will hide the text from any page that isn't the Single Post page. Only on the Single Post Page will the `[hidetext]` show. How can I do something like this? | `wp_delete_post()` **always** triggers `before_delete_post` - the problem must be that you're hooking your function conditionally (i.e. not all the time).
`before_delete_post` **only** gets triggered if you're actually *deleting* the post permanently, not just trashing it.
If you need to listen for trashing too, use ... |
38,266 | <p>I'm learning about plugins and shortcodes. I noticed that when I activate my plugin its code gets loaded on all of my pages-- even pages that don't have my shortcode. (I don't mean content vs. admin pages). On some content pages, I use a particular shortcode and on other content pages, I don't-- but in any case, the... | [
{
"answer_id": 38272,
"author": "Noel Tock",
"author_id": 2393,
"author_profile": "https://wordpress.stackexchange.com/users/2393",
"pm_score": 0,
"selected": false,
"text": "<p>Could do something along the lines of (in the header.php):</p>\n\n<pre><code><?php\n if ( have_posts... | 2012/01/08 | [
"https://wordpress.stackexchange.com/questions/38266",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4509/"
] | I'm learning about plugins and shortcodes. I noticed that when I activate my plugin its code gets loaded on all of my pages-- even pages that don't have my shortcode. (I don't mean content vs. admin pages). On some content pages, I use a particular shortcode and on other content pages, I don't-- but in any case, the pl... | WP v3.3 gave us the ability to run wp\_enqueue\_script in the middle of a page. [Ticket 9346](http://core.trac.wordpress.org/ticket/9346)
This has made it much easier to include your JS with better granularity (when using shortcodes, at least). Here, jquery will be only included when our shortcode is fired.
```
funct... |
38,268 | <p>As soon as I enable the option </p>
<p>Performance --> Browser cache --> 'Set expires header' to true</p>
<p>I get a 500 Internal Server Error.</p>
<p>Then I have to SSH into the server and delete the new entries to make the site work again.</p>
<p>I have googled a lot and it seems nobody has this problem. ANd... | [
{
"answer_id": 38275,
"author": "Noel Tock",
"author_id": 2393,
"author_profile": "https://wordpress.stackexchange.com/users/2393",
"pm_score": 1,
"selected": false,
"text": "<p>I think it's important that you remove custom options by default (or maybe even give the user the chance to ex... | 2012/01/08 | [
"https://wordpress.stackexchange.com/questions/38268",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9024/"
] | As soon as I enable the option
Performance --> Browser cache --> 'Set expires header' to true
I get a 500 Internal Server Error.
Then I have to SSH into the server and delete the new entries to make the site work again.
I have googled a lot and it seems nobody has this problem. ANd yes I have already
sudo a2enmod... | In [another answer](https://wordpress.stackexchange.com/questions/25910/uninstall-activate-deactivate-a-plugin-typical-features-how-to/25979#25979) I wrote about uninstall/activate/deactivate/upgrade routines. I guess most of the comments already tell it, but to sum it up:
* Uninstall: Remove *everything*, your plugi... |
38,285 | <p>After using the <code>wp_login</code> hook, is it possible to add a snippet of javascript code to the page seen immediately after the login in wordpress?</p>
<p>I want to use this top implement a notification system that notifies the user when they login.</p>
| [
{
"answer_id": 67534,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>The typical method to store pending action in WordPress is to set short-lived transient (<a href=\"http://queryposts... | 2012/01/08 | [
"https://wordpress.stackexchange.com/questions/38285",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11810/"
] | After using the `wp_login` hook, is it possible to add a snippet of javascript code to the page seen immediately after the login in wordpress?
I want to use this top implement a notification system that notifies the user when they login. | I would do something like this:
```
function wpse38285_wp_login( $user_login ) {
set_transient( $user_login, '1', 0 );
}
add_action( 'wp_login', 'wpse38285_wp_login' );
function wpse38285_wp_footer() {
global $current_user;
get_currentuserinfo();
if ( ! is_user_logged_in() )
return;
if ... |
38,286 | <p>I'm confused, because there are a lots of functions about attachments . I've tried a lots of functions. I'm setting a <em>featured image</em> for my every blog post. </p>
<p>I have to get different sizes of this image. FOr example a need this variations of <em>featured image</em></p>
<p>600px*400px</p>
<p>300px*1... | [
{
"answer_id": 38288,
"author": "Andres Yanez",
"author_id": 10229,
"author_profile": "https://wordpress.stackexchange.com/users/10229",
"pm_score": 3,
"selected": true,
"text": "<p>Since you have defined the featured image for each post with using</p>\n\n<pre><code><?php the_post_thu... | 2012/01/08 | [
"https://wordpress.stackexchange.com/questions/38286",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3552/"
] | I'm confused, because there are a lots of functions about attachments . I've tried a lots of functions. I'm setting a *featured image* for my every blog post.
I have to get different sizes of this image. FOr example a need this variations of *featured image*
600px\*400px
300px\*150px
64px\*64px
(Images can be cro... | Since you have defined the featured image for each post with using
```
<?php the_post_thumbnail( 'custombig' ); // or another custom size name ?>
```
should be enough, for info you can read:
<http://justintadlock.com/archives/2009/11/16/everything-you-need-to-know-about-wordpress-2-9s-post-image-feature>
<http://m... |
38,302 | <p>I am currently using the wp_login hook to run a php function when a user logins. However, I want to show users who login notifications (a pop up with recent posts, etc) and I was planning to do this by running a javascript function. </p>
<p>Is it possible to edit the page shown to the user after login?</p>
<p>This... | [
{
"answer_id": 38307,
"author": "Jakub Slaby",
"author_id": 10585,
"author_profile": "https://wordpress.stackexchange.com/users/10585",
"pm_score": 0,
"selected": false,
"text": "<p>you may try using the wp_redirect() function, I was doing that in the past but I don't know how it will be... | 2012/01/09 | [
"https://wordpress.stackexchange.com/questions/38302",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11810/"
] | I am currently using the wp\_login hook to run a php function when a user logins. However, I want to show users who login notifications (a pop up with recent posts, etc) and I was planning to do this by running a javascript function.
Is it possible to edit the page shown to the user after login?
This is the code I h... | ```
add_filter( "login_redirect", "my_login_redirect", 10, 3 );
function my_login_redirect( $redirect_to, $request, $user )
{
return home_url( "/your_page/" );
}
```
Should about do it for you. Modified from a script that I had running in wp3.3.1.
Docs: [`home_url()`](http://codex.wordpress.org/Function_Referenc... |
38,337 | <p>This question is not technical but rather "ideological" - where in WP should favicon be stored (in "correct" way)? Should it be in the root (where wp-config.php) is stored OR should it be in current theme's folder? Or should 2 copies be kept (which I don't want to do)?
I know, either way will work and will result in... | [
{
"answer_id": 38339,
"author": "stealthyninja",
"author_id": 1748,
"author_profile": "https://wordpress.stackexchange.com/users/1748",
"pm_score": 3,
"selected": false,
"text": "<p>It should always be in the root folder then it'll work whether you explicitly link to it or not.</p>\n\n<p... | 2012/01/09 | [
"https://wordpress.stackexchange.com/questions/38337",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11842/"
] | This question is not technical but rather "ideological" - where in WP should favicon be stored (in "correct" way)? Should it be in the root (where wp-config.php) is stored OR should it be in current theme's folder? Or should 2 copies be kept (which I don't want to do)?
I know, either way will work and will result in no... | It should always be in the root folder then it'll work whether you explicitly link to it or not.
You can also use this as a function in your theme's `functions.php` to explicitly link to it:
```
function my_favicon() {
echo '<link rel="shortcut icon" href="' . get_bloginfo('wpurl') . '/favicon.ico" />';
}
add... |
38,361 | <p>I'd like to build an advanced search form for a specific custom post type, having filters for the custom post types custom fields, custom taxonomies, and for a separate custom post types properties (fields and taxonomies) which will be links to the first post type using a custom relationship field.</p>
<p>I've rece... | [
{
"answer_id": 38425,
"author": "Jens Wedin",
"author_id": 8520,
"author_profile": "https://wordpress.stackexchange.com/users/8520",
"pm_score": 0,
"selected": false,
"text": "<p>Take a look at Relevanssi plugin, it might do what you are looking for: <a href=\"http://wordpress.org/extend... | 2012/01/09 | [
"https://wordpress.stackexchange.com/questions/38361",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/967/"
] | I'd like to build an advanced search form for a specific custom post type, having filters for the custom post types custom fields, custom taxonomies, and for a separate custom post types properties (fields and taxonomies) which will be links to the first post type using a custom relationship field.
I've recently start... | I think something like this you would be best writing yourself.
Take a look at: <http://www.catalysthomes.co.uk/homes-for-sale/>
Properties are loaded into a CPT and I have my own custom search in the sidebar. Of that search its searching a number of things such as taxonomies, custom fields and ordering by date price... |
38,378 | <p>I'm using a more or less fresh local install of WP 3.3.1. A few days ago I set up a couple menus (Appearance > Menus) without a hitch. Today I tried creating a new menu and add a page to it, but the page was never successfully added to the menu; the spinner just went on forever.</p>
<p>I thought maybe the menu name... | [
{
"answer_id": 38425,
"author": "Jens Wedin",
"author_id": 8520,
"author_profile": "https://wordpress.stackexchange.com/users/8520",
"pm_score": 0,
"selected": false,
"text": "<p>Take a look at Relevanssi plugin, it might do what you are looking for: <a href=\"http://wordpress.org/extend... | 2012/01/09 | [
"https://wordpress.stackexchange.com/questions/38378",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11296/"
] | I'm using a more or less fresh local install of WP 3.3.1. A few days ago I set up a couple menus (Appearance > Menus) without a hitch. Today I tried creating a new menu and add a page to it, but the page was never successfully added to the menu; the spinner just went on forever.
I thought maybe the menu name was confl... | I think something like this you would be best writing yourself.
Take a look at: <http://www.catalysthomes.co.uk/homes-for-sale/>
Properties are loaded into a CPT and I have my own custom search in the sidebar. Of that search its searching a number of things such as taxonomies, custom fields and ordering by date price... |
38,387 | <p>I am trying to load jquery-ui using wp_enqueue_script. I can check that jquery is loaded. jquery-ui is registered i.e. output of var_dump( wp_script_is( 'jquery-ui-tabs', 'registered' ) ); is bool(true) which indicates it is registered but it does not get included to the page.</p>
<p>I am using wordpress version 3.... | [
{
"answer_id": 38390,
"author": "Asko",
"author_id": 11809,
"author_profile": "https://wordpress.stackexchange.com/users/11809",
"pm_score": 0,
"selected": false,
"text": "<p>You should register new scripts with the following method:</p>\n\n<pre><code>wp_register_script('jquery-ui', get_... | 2012/01/09 | [
"https://wordpress.stackexchange.com/questions/38387",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8146/"
] | I am trying to load jquery-ui using wp\_enqueue\_script. I can check that jquery is loaded. jquery-ui is registered i.e. output of var\_dump( wp\_script\_is( 'jquery-ui-tabs', 'registered' ) ); is bool(true) which indicates it is registered but it does not get included to the page.
I am using wordpress version 3.3.1
... | Here's an alternative way to load a popular script like jquery-ui (using google api's)
```
<?php
// first, check to see if jquery-ui is already loaded
if( !wp_script_is('jquery-ui') ) {
// you don't have to use googleapi's, but I think it helps. It saves the user's browser from loading the same script agai... |
38,394 | <p>I have a custom post type, jobs, being displayed on an external page using WP_Query() - the query itself is working fine.</p>
<p>However when I try to paginate the results, the older/newer links show up, but when I click on them, the content doesn't change - ie the page 'number' changes in the URL & the page re... | [
{
"answer_id": 38396,
"author": "Rob Vermeer",
"author_id": 11135,
"author_profile": "https://wordpress.stackexchange.com/users/11135",
"pm_score": 0,
"selected": false,
"text": "<p>A problem with a custom query is that the posts_per_page resets before the page loads. So if you got 10 po... | 2012/01/09 | [
"https://wordpress.stackexchange.com/questions/38394",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I have a custom post type, jobs, being displayed on an external page using WP\_Query() - the query itself is working fine.
However when I try to paginate the results, the older/newer links show up, but when I click on them, the content doesn't change - ie the page 'number' changes in the URL & the page reloads, but th... | A problem with a custom query is that the posts\_per\_page resets before the page loads. So if you got 10 posts, than you only have one page, because the default posts\_per\_page is 10. If you have 11 posts than you will see the second page, but not beyond that.
Solution for this is changing your posts\_per\_page sett... |
38,398 | <p>If I try to add a skype username as the URL for a wp_nav_menu item, the item is saved but the URL is not.</p>
<p>The username URL is in the following format:</p>
<p>skype:example?call</p>
<p>Any thoughts on add skype: as an acceptable protocol?</p>
<p>Thanks.</p>
| [
{
"answer_id": 38396,
"author": "Rob Vermeer",
"author_id": 11135,
"author_profile": "https://wordpress.stackexchange.com/users/11135",
"pm_score": 0,
"selected": false,
"text": "<p>A problem with a custom query is that the posts_per_page resets before the page loads. So if you got 10 po... | 2012/01/09 | [
"https://wordpress.stackexchange.com/questions/38398",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6204/"
] | If I try to add a skype username as the URL for a wp\_nav\_menu item, the item is saved but the URL is not.
The username URL is in the following format:
skype:example?call
Any thoughts on add skype: as an acceptable protocol?
Thanks. | A problem with a custom query is that the posts\_per\_page resets before the page loads. So if you got 10 posts, than you only have one page, because the default posts\_per\_page is 10. If you have 11 posts than you will see the second page, but not beyond that.
Solution for this is changing your posts\_per\_page sett... |
38,405 | <p>I am using a custom post type + taxonomies in a podcast solution for a client. The setting (settings >> discussion) for comments is set to "allow comments". When I add / edit posts under the "posts" tab, comments are enabled by default.</p>
<p>However, when I add / edit posts under the custom post type (podcast) ... | [
{
"answer_id": 38406,
"author": "Jason Rhodes",
"author_id": 871,
"author_profile": "https://wordpress.stackexchange.com/users/871",
"pm_score": 1,
"selected": false,
"text": "<p>Just taking a random stab but do you have to add \"comments\" to the supports array parameter, in the <code>r... | 2012/01/10 | [
"https://wordpress.stackexchange.com/questions/38405",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5861/"
] | I am using a custom post type + taxonomies in a podcast solution for a client. The setting (settings >> discussion) for comments is set to "allow comments". When I add / edit posts under the "posts" tab, comments are enabled by default.
However, when I add / edit posts under the custom post type (podcast) - comments a... | Ok - so I solved this. Here is what appears to be the problem.
Comments are disabled by default for custom-post-types. This happens *even if
you have them enabled in the overall settings*
To fix it, all I had to do was the following:
1. In SETTINGS > DISCUSSION uncheck the "Allow people to post comments on new arti... |
38,427 | <p>Not sure where my error is (I did piece most of this together from snippets on different websites,) but when I test my theme, only "Left Menu" displays. There are definitely two menus, however where "Menu Right" should be is a duplicate of "Menu Left."</p>
<p>Here's my header</p>
<pre><code><nav id="navigation"... | [
{
"answer_id": 38437,
"author": "Noel Tock",
"author_id": 2393,
"author_profile": "https://wordpress.stackexchange.com/users/2393",
"pm_score": 2,
"selected": false,
"text": "<p>You need to define the <strong>theme location</strong> when displaying with wp_nav_menu, i.e.:</p>\n\n<pre><co... | 2012/01/10 | [
"https://wordpress.stackexchange.com/questions/38427",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11884/"
] | Not sure where my error is (I did piece most of this together from snippets on different websites,) but when I test my theme, only "Left Menu" displays. There are definitely two menus, however where "Menu Right" should be is a duplicate of "Menu Left."
Here's my header
```
<nav id="navigation" role="navigation">
<... | You need to define the **theme location** when displaying with wp\_nav\_menu, i.e.:
```
<?php
wp_nav_menu( array(
'theme_location' => 'left-menu',
'menu' => 'Left Menu'
)
); ?>
``` |
38,428 | <p>I am considering moving away from Drupal and drupal-cod due to the lack of good themes.</p>
<p>The two major features I am looking for are:</p>
<ol>
<li>Ticket sales (PayPal), with receipts sent to attendee</li>
<li>Sponsorship sales (PayPal with different options: Gold, Silver, Bronze by price-range)</li>
</ol>
... | [
{
"answer_id": 38437,
"author": "Noel Tock",
"author_id": 2393,
"author_profile": "https://wordpress.stackexchange.com/users/2393",
"pm_score": 2,
"selected": false,
"text": "<p>You need to define the <strong>theme location</strong> when displaying with wp_nav_menu, i.e.:</p>\n\n<pre><co... | 2012/01/10 | [
"https://wordpress.stackexchange.com/questions/38428",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11882/"
] | I am considering moving away from Drupal and drupal-cod due to the lack of good themes.
The two major features I am looking for are:
1. Ticket sales (PayPal), with receipts sent to attendee
2. Sponsorship sales (PayPal with different options: Gold, Silver, Bronze by price-range)
Secondary features:
* StackOverflow ... | You need to define the **theme location** when displaying with wp\_nav\_menu, i.e.:
```
<?php
wp_nav_menu( array(
'theme_location' => 'left-menu',
'menu' => 'Left Menu'
)
); ?>
``` |
38,429 | <p>I have searched alot for finding the list of Full documentation for buddypress Hooks (action, filtrs) and functions but not satisfied with that limited documentation provided by <a href="http://codex.buddypress.org/home/" rel="nofollow">Buddypress</a>.</p>
<p>Like if i want to find the detail about <strong>bp_direc... | [
{
"answer_id": 38434,
"author": "Noel Tock",
"author_id": 2393,
"author_profile": "https://wordpress.stackexchange.com/users/2393",
"pm_score": 2,
"selected": false,
"text": "<p>Here you go:</p>\n\n<p><a href=\"http://byotos.wordpress.com/2010/02/07/how-to-get-a-list-of-buddypress-action... | 2012/01/10 | [
"https://wordpress.stackexchange.com/questions/38429",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11632/"
] | I have searched alot for finding the list of Full documentation for buddypress Hooks (action, filtrs) and functions but not satisfied with that limited documentation provided by [Buddypress](http://codex.buddypress.org/home/).
Like if i want to find the detail about **bp\_directory\_groups\_search\_form()** there is n... | and here is the almighty output for buddypress 1.5.2!
```
bp_activity_setup_globals
bp_activity_setup_nav
bp_activity_directory_activity_setup
bp_activity_screen_my_activity
bp_activity_screen_friends
bp_activity_screen_groups
bp_activity_screen_favorites
bp_activity_screen_mentions
bp_activity_screen_notification_set... |
38,436 | <p>I would like to know is it possible to add script right after head tag?
I don't want to use add_action('wp_head','function');</p>
<p>So here is the case:</p>
<ul>
<li>I have custom fields values for example 'this is the custom field value'</li>
<li>I want to echo it after head tag</li>
<li>I want to echo it using... | [
{
"answer_id": 40616,
"author": "Dwayne Charrington",
"author_id": 1687,
"author_profile": "https://wordpress.stackexchange.com/users/1687",
"pm_score": 1,
"selected": false,
"text": "<p>Fairly certain this is not possible without editing the actual theme header.php file. The function wp... | 2012/01/10 | [
"https://wordpress.stackexchange.com/questions/38436",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11886/"
] | I would like to know is it possible to add script right after head tag?
I don't want to use add\_action('wp\_head','function');
So here is the case:
* I have custom fields values for example 'this is the custom field value'
* I want to echo it after head tag
* I want to echo it using functions.php
* I don't want to ... | Fairly certain this is not possible without editing the actual theme header.php file. The function wp\_head() does in-fact include other scripts, not sure you get a choice to add a script right above everything else and to be honest I don't see why you would need too.
Your constraints seem rather strict, I'm curious w... |
38,439 | <p>I am not able to understand a very logic behind add_action / add_filter</p>
<p>Consider following example:</p>
<pre><code>function SearchFilter($query) {
if ($query->is_search) {
$query->set('post_type', 'page');
}
return $query;
}
add_filter('pre_get_posts','SearchFilter');
</code></pre>
<p>My q... | [
{
"answer_id": 38444,
"author": "mor7ifer",
"author_id": 11740,
"author_profile": "https://wordpress.stackexchange.com/users/11740",
"pm_score": 0,
"selected": false,
"text": "<p>The best way I know of to get args is to look up the do_action call for the hook you're using in the code. <a... | 2012/01/10 | [
"https://wordpress.stackexchange.com/questions/38439",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4314/"
] | I am not able to understand a very logic behind add\_action / add\_filter
Consider following example:
```
function SearchFilter($query) {
if ($query->is_search) {
$query->set('post_type', 'page');
}
return $query;
}
add_filter('pre_get_posts','SearchFilter');
```
My questions are
* How can I know wheter... | When calling an action hook using
```
add_action('some_action_tag','callback_function',$priority,$number_of_arguments);
```
The callback function is called when a `do_action()` call is fired with the corresponding tag for example:
```
do_action('some_action_tag',$argument1,$argument2,$argument3....);
```
And whe... |
38,454 | <p>I am new to wordpress, Here i use the wordpress TwentyEleven theme, i need to customize the widget markup. It means the suppose i want to change the element 'ul' to div and add some class or id to this element. Now currently it was not possible for me because the wordpress default widgets are already available insi... | [
{
"answer_id": 38455,
"author": "Ole Henrik Skogstrøm",
"author_id": 11552,
"author_profile": "https://wordpress.stackexchange.com/users/11552",
"pm_score": -1,
"selected": false,
"text": "<p>You can disable all the standard widgets easily by adding an empty text-box widget to the first ... | 2012/01/10 | [
"https://wordpress.stackexchange.com/questions/38454",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11893/"
] | I am new to wordpress, Here i use the wordpress TwentyEleven theme, i need to customize the widget markup. It means the suppose i want to change the element 'ul' to div and add some class or id to this element. Now currently it was not possible for me because the wordpress default widgets are already available inside w... | <http://codex.wordpress.org/Function_Reference/unregister_widget>
add something like this to functions.php:
```
if (!function_exists('my_unregister_default_wp_widgets')) {
function my_unregister_default_wp_widgets() {
unregister_widget('WP_Widget_Calendar');
unregister_widget('WP_Widget_Recent_Po... |
38,530 | <p>I need to get a bunch of posts with their metadata. Of course you can't get metadata with a standard posts query, so you generally have to do a <code>get_post_custom()</code> for each post.</p>
<p>I'm trying with one custom query, like this:</p>
<pre><code>$results = $wpdb->get_results("
SELECT p.ID,
... | [
{
"answer_id": 39928,
"author": "Ethan Seifert",
"author_id": 984,
"author_profile": "https://wordpress.stackexchange.com/users/984",
"pm_score": 5,
"selected": false,
"text": "<p>I would recommend a pivot query. Using your example:</p>\n<pre><code>SELECT p.ID, \n p.post_title,... | 2012/01/10 | [
"https://wordpress.stackexchange.com/questions/38530",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2336/"
] | I need to get a bunch of posts with their metadata. Of course you can't get metadata with a standard posts query, so you generally have to do a `get_post_custom()` for each post.
I'm trying with one custom query, like this:
```
$results = $wpdb->get_results("
SELECT p.ID,
p.post_title,
pm1.meta_v... | Post meta information is automatically cached in memory for a standard `WP_Query` (and the main query), unless you specifically tell it not to do so by using the `update_post_meta_cache` parameter.
Therefore, you should not be writing your own queries for this.
How the meta caching works for normal queries:
If the ... |
38,536 | <p>I design my site in win7 system, and today before a server rent, I moving my blog from win7 to my another computer witch is installed CentOS 5.5 for a last test, I have reference the article <a href="http://codex.wordpress.org/Moving_WordPress" rel="nofollow">http://codex.wordpress.org/Moving_WordPress</a></p>
<p>... | [
{
"answer_id": 38541,
"author": "viclou",
"author_id": 11924,
"author_profile": "https://wordpress.stackexchange.com/users/11924",
"pm_score": 0,
"selected": false,
"text": "<p>I think that you may need to modify some data in your database.</p>\n\n<p>Assuming your table prefix is <code>w... | 2012/01/10 | [
"https://wordpress.stackexchange.com/questions/38536",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4549/"
] | I design my site in win7 system, and today before a server rent, I moving my blog from win7 to my another computer witch is installed CentOS 5.5 for a last test, I have reference the article <http://codex.wordpress.org/Moving_WordPress>
moving my site from `d:/www/` to `/var/www/html`, and my site runs well, all the p... | I have solved this strange problem by myself. Share my experience to all.
Find these 2 lines in `/etc/php.ini`
```
upload_max_filesize 16M
post_max_size 16M
```
Add common before, so that change as:
```
;upload_max_filesize 16M
;post_max_size 16M
```
And final, do not forget restart apache: `service httpd re... |
38,551 | <p>I am trying to display a list of posts (custom post types) coming from a different WordPress installation (to make things more clear, my client wants has two separate sites, and they want to list their listings on both sites, but only add them once).</p>
<p>I have tried to implement this with PHP/MySQL and I am abl... | [
{
"answer_id": 38557,
"author": "Nickiler",
"author_id": 10950,
"author_profile": "https://wordpress.stackexchange.com/users/10950",
"pm_score": 1,
"selected": false,
"text": "<p>The simplest way to get post from WordPress to WordPress is to use RSS. You can use SimplePie to work with th... | 2012/01/11 | [
"https://wordpress.stackexchange.com/questions/38551",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11928/"
] | I am trying to display a list of posts (custom post types) coming from a different WordPress installation (to make things more clear, my client wants has two separate sites, and they want to list their listings on both sites, but only add them once).
I have tried to implement this with PHP/MySQL and I am able to grab ... | The simplest way to get post from WordPress to WordPress is to use RSS. You can use SimplePie to work with the feeds on your destination site. <http://simplepie.org/wiki/reference/start>
I used this technique to get posts from WordPress to Joomla CMS and I never looked back.
**Edit Added**
I have used feeds for this... |
38,560 | <p>I am developer of the plugin mapsmarker.com which also offers several APIs which can be accessed directly (eg www.mapsmarker.com/wp-content/plugins/leaflet-maps-marker/leaflet-geojson.php?marker=1)
For these APIs I initially wrote the absolut directory path to a file with the following function on plugin install:</p... | [
{
"answer_id": 38563,
"author": "Noel Tock",
"author_id": 2393,
"author_profile": "https://wordpress.stackexchange.com/users/2393",
"pm_score": 2,
"selected": false,
"text": "<p>I guess it sounds silly, but could you work your way up from the plug-in directory?</p>\n\n<pre><code>if ( fil... | 2012/01/11 | [
"https://wordpress.stackexchange.com/questions/38560",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11291/"
] | I am developer of the plugin mapsmarker.com which also offers several APIs which can be accessed directly (eg www.mapsmarker.com/wp-content/plugins/leaflet-maps-marker/leaflet-geojson.php?marker=1)
For these APIs I initially wrote the absolut directory path to a file with the following function on plugin install:
```
... | I came up with this solution.
This function checks in each directory level starting from the directory of the current file for the file wp-config.php.
```
<?php
function find_wp_config_path() {
$dir = dirname(__FILE__);
do {
if( file_exists($dir."/wp-config.php") ) {
r... |
38,562 | <p>Good to hear that Sonny (wordpress3.3) has the new editor API <a href="http://codex.wordpress.org/Function_Reference/wp_editor" rel="nofollow"><strong>wp_editor()</strong></a> that gives us the ability to use multiple instances of the editor in our custom fields with ease.</p>
<p>But I needed to customize the defau... | [
{
"answer_id": 48754,
"author": "Dipesh KC",
"author_id": 7247,
"author_profile": "https://wordpress.stackexchange.com/users/7247",
"pm_score": 3,
"selected": true,
"text": "<p>I was looking for a solution to place custom metabox above the default editor and i've found the solution to my... | 2012/01/11 | [
"https://wordpress.stackexchange.com/questions/38562",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7247/"
] | Good to hear that Sonny (wordpress3.3) has the new editor API [**wp\_editor()**](http://codex.wordpress.org/Function_Reference/wp_editor) that gives us the ability to use multiple instances of the editor in our custom fields with ease.
But I needed to customize the default editor (for the main content) and couldn't fi... | I was looking for a solution to place custom metabox above the default editor and i've found the solution to my old question (how to customize the default editor with the wp\_editor)!
The solution was to unset the default editor first. Then create another metabox to to place the content then use wp\_editor to create n... |
38,576 | <p>I would like to turn /{custom-post-type}/{post-name} to /{post-name}, is this possible?</p>
<p>If this is not possible, can I change the labels/terminology in Pages or Posts so that they could be called "Clients" or "Projects" etc?</p>
| [
{
"answer_id": 38579,
"author": "RagnaRock",
"author_id": 9877,
"author_profile": "https://wordpress.stackexchange.com/users/9877",
"pm_score": 3,
"selected": false,
"text": "<p>You need to use option <code>'rewrite'</code> in your custom post type registration.</p>\n\n<p>E.g.\n<code>'re... | 2012/01/11 | [
"https://wordpress.stackexchange.com/questions/38576",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9771/"
] | I would like to turn /{custom-post-type}/{post-name} to /{post-name}, is this possible?
If this is not possible, can I change the labels/terminology in Pages or Posts so that they could be called "Clients" or "Projects" etc? | You need to use option `'rewrite'` in your custom post type registration.
E.g.
`'rewrite' => array('slug' => 'products'),`
From the [codex](http://codex.wordpress.org/Post_Types#URLs_of_Namespaced_Custom_Post_Types_Identifiers)
>
> When you namespace a URL and still want to use a "clean" URL
> structure, you need ... |