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 |
|---|---|---|---|---|---|---|
19,933 | <p>I have a running normal WP blog (blog 1). I want to create a Q&A section for my users, so I setup another blog with WP-Answer theme (blog 2).</p>
<p>The problem is I don't want my users at blog 1 have to register at blog 2 to post questions. I want they automatically grant the same privileges at blog 2.</p>
<p... | [
{
"answer_id": 19960,
"author": "mike23",
"author_id": 1381,
"author_profile": "https://wordpress.stackexchange.com/users/1381",
"pm_score": 2,
"selected": false,
"text": "<p>I think the easiest would be to keep one site, and only apply your Q&A styles to the pages you need. That way... | 2011/06/14 | [
"https://wordpress.stackexchange.com/questions/19933",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2051/"
] | I have a running normal WP blog (blog 1). I want to create a Q&A section for my users, so I setup another blog with WP-Answer theme (blog 2).
The problem is I don't want my users at blog 1 have to register at blog 2 to post questions. I want they automatically grant the same privileges at blog 2.
How can this be achi... | I think you want to install your second site on the same database but with a different table prefix, e.g. `$table_prefix = "qa_";` in `wp-config.php`
You are then able to define a custom user and/or user\_meta table by adding the following lines to `wp-config.php`
```
define('CUSTOM_USER_TABLE', [orig_table_prefix].'... |
19,961 | <p>when I made my wordpress site validate I got some strange errors like</p>
<pre><code>Error Line 6, Column 52: Bad value profile for attribute rel on element link: Keyword profile is not registered.
Error Line 12, Column 128: Bad value EditURI for attribute rel on element link: Keyword edituri is not registered.
... | [
{
"answer_id": 19949,
"author": "grm",
"author_id": 88,
"author_profile": "https://wordpress.stackexchange.com/users/88",
"pm_score": 4,
"selected": true,
"text": "<p>The easiest way to do this is by using copy&replace in the SQL file. Export the database. Use your favorite text edit... | 2011/06/14 | [
"https://wordpress.stackexchange.com/questions/19961",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6175/"
] | when I made my wordpress site validate I got some strange errors like
```
Error Line 6, Column 52: Bad value profile for attribute rel on element link: Keyword profile is not registered.
Error Line 12, Column 128: Bad value EditURI for attribute rel on element link: Keyword edituri is not registered.
Line 14, Column... | The easiest way to do this is by using copy&replace in the SQL file. Export the database. Use your favorite text editor and do a copy&replace and import it into a new database.
Then you go to wp-config.php and you change the WP\_HOME and WP\_SITEURL to the new host. Then you change the databasename. You also need to e... |
19,962 | <p>I have custom post-type 'sermon' with custom taxonomy 'speaker' attached to it. I wanted to assign custom meta values to the speaker taxonomy, so I am using the taxonomy meta class from Rilwis:</p>
<p><a href="http://www.deluxeblogtips.com/p/taxonomy-meta-script-for-wordpress.html" rel="nofollow">http://www.deluxeb... | [
{
"answer_id": 19971,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": true,
"text": "<p>you can use the <code>get_the_terms()</code> function to get the terms of that post in a specific taxonomy:</p... | 2011/06/14 | [
"https://wordpress.stackexchange.com/questions/19962",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/370/"
] | I have custom post-type 'sermon' with custom taxonomy 'speaker' attached to it. I wanted to assign custom meta values to the speaker taxonomy, so I am using the taxonomy meta class from Rilwis:
<http://www.deluxeblogtips.com/p/taxonomy-meta-script-for-wordpress.html>
I have used the class to add a metabox with the id... | you can use the `get_the_terms()` function to get the terms of that post in a specific taxonomy:
```
$terms = get_the_terms( $post->ID , 'speaker' ); //change speaker to whatever you call your taxonomy
//then you can use just the first term
$term_id = $terms[0]->term_id;
```
and now you have the term id inside `$ter... |
19,966 | <p>I am using <a href="http://wordpress.org/extend/plugins/contact-form-7/" rel="nofollow">contact form 7 plugin</a> in my blog.I am having donate option in the form with price option in radio button. user can select and submit.After submitting the form it should redirect to the paypal. with selected price .</p>
<p>i... | [
{
"answer_id": 19970,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 3,
"selected": true,
"text": "<p>First change the `on_sent_ok' to:</p>\n\n<pre><code>on_sent_ok: 'my_redirect();'\n</code></pre>\n\n<p>then cre... | 2011/06/14 | [
"https://wordpress.stackexchange.com/questions/19966",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4022/"
] | I am using [contact form 7 plugin](http://wordpress.org/extend/plugins/contact-form-7/) in my blog.I am having donate option in the form with price option in radio button. user can select and submit.After submitting the form it should redirect to the paypal. with selected price .
i tried
>
> on\_sent\_ok: "location... | First change the `on\_sent\_ok' to:
```
on_sent_ok: 'my_redirect();'
```
then create that `my_redirect()` function in the page that displays the form:
```
<script>
function my_redirect() {
var price = document.getElementById('PRICE_FIELD').value;
var url = 'https://www.sandbox.paypal.com/us/cgi-... |
19,986 | <p>Is there a way to hide the comments column in the backend? When you look at the pages, there's a comments column even though I've disabled them.</p>
<p>I made WordPress into a <a href="https://en.wikipedia.org/wiki/Content_management_system" rel="nofollow">CMS</a> and it may cause some confusion.</p>
| [
{
"answer_id": 19993,
"author": "helenhousandi",
"author_id": 2226,
"author_profile": "https://wordpress.stackexchange.com/users/2226",
"pm_score": 3,
"selected": true,
"text": "<p>Try this:</p>\n\n<pre><code>add_filter(\"manage_edit-page_columns\", \"my_page_edit_columns\");\n\nfunction... | 2011/06/14 | [
"https://wordpress.stackexchange.com/questions/19986",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4588/"
] | Is there a way to hide the comments column in the backend? When you look at the pages, there's a comments column even though I've disabled them.
I made WordPress into a [CMS](https://en.wikipedia.org/wiki/Content_management_system) and it may cause some confusion. | Try this:
```
add_filter("manage_edit-page_columns", "my_page_edit_columns");
function my_page_edit_columns($columns){
unset($columns['comments']);
return $columns;
}
```
If you need it for posts instead of pages, use `manage_edit-post_columns` instead. The same goes for any post type, really, as `manage_edit-... |
20,004 | <p>I have registered my custom taxonomy and want to use dropdown in back end...
code given here <a href="https://wordpress.stackexchange.com/questions/18578/taxonomy-dropdown-metabox-in-the-back-end">Taxonomy dropdown metabox in the back-end</a> works like a charm.... but now in admin there are two metaboxes one is my... | [
{
"answer_id": 20005,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 0,
"selected": false,
"text": "<p>use <a href=\"http://codex.wordpress.org/Function_Reference/remove_meta_box\" rel=\"nofollow\">remove_meta_box</a>.... | 2011/06/14 | [
"https://wordpress.stackexchange.com/questions/20004",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6185/"
] | I have registered my custom taxonomy and want to use dropdown in back end...
code given here [Taxonomy dropdown metabox in the back-end](https://wordpress.stackexchange.com/questions/18578/taxonomy-dropdown-metabox-in-the-back-end) works like a charm.... but now in admin there are two metaboxes one is my custom which ... | I had [the same question](https://wordpress.stackexchange.com/questions/6183/how-do-you-remove-a-category-style-hierarchical-taxonomy-metabox).
You use the `remove_meta_box` functions mentioned in a previous answer, but you have two options: `tagsdiv-{$tax_name}` for non-hierarchical taxonomies and `{$tax_name}div` fo... |
20,020 | <p>On my static frontpage, I would like to fetch the two latest posts as shown in this <a href="http://www.dobschin.com/wp-layout.png" rel="nofollow">link</a>.</p>
<p>Now the posts should always be displayed like this (i.e. constant height, limited number of characters), no matter what! If the post uses the more-tag o... | [
{
"answer_id": 20023,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 1,
"selected": false,
"text": "<p>The simple way to do this is to define the height/width in CSS of a container, and then apply a trim on the excerpt... | 2011/06/14 | [
"https://wordpress.stackexchange.com/questions/20020",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6194/"
] | On my static frontpage, I would like to fetch the two latest posts as shown in this [link](http://www.dobschin.com/wp-layout.png).
Now the posts should always be displayed like this (i.e. constant height, limited number of characters), no matter what! If the post uses the more-tag or not - it should always look like i... | The simple way to do this is to define the height/width in CSS of a container, and then apply a trim on the excerpt.
To change default excerpt length add this to you functions.php
```
function new_excerpt_length($length) {
return 100; // change this to how many any characters you want
}
add_filter('excerpt_leng... |
20,043 | <p>I've been trying various ways of doing this. Basically, I've been trying to make it so that a plugin of mine populates the terms of a taxonomy only once during the plugin's activation. The term populating is done in a function via the wp_insert_terms function. Calling the function straight inside the register_act... | [
{
"answer_id": 20085,
"author": "Hameedullah Khan",
"author_id": 5337,
"author_profile": "https://wordpress.stackexchange.com/users/5337",
"pm_score": 4,
"selected": true,
"text": "<p>Here is the fixed version of your code.</p>\n\n<pre><code>class vsetup {\n function __construct() {\... | 2011/06/15 | [
"https://wordpress.stackexchange.com/questions/20043",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2234/"
] | I've been trying various ways of doing this. Basically, I've been trying to make it so that a plugin of mine populates the terms of a taxonomy only once during the plugin's activation. The term populating is done in a function via the wp\_insert\_terms function. Calling the function straight inside the register\_activa... | Here is the fixed version of your code.
```
class vsetup {
function __construct() {
register_activation_hook(__FILE__,array($this,'activate'));
add_action( 'init', array( $this, 'create_taxonomies' ) );
}
function activate() {
$this->create_taxonomies();
wp_inser... |
20,044 | <p>In a theme I built from scratch I'm using the WP Photo Album Plus plugin. Per some books I've been using as guides, I need to include this code in the header in order to make comments work in a blog:</p>
<pre><code><?php if ( is_singular() ) wp_enqueue_script ( 'comment-reply'); wp_head() ; ?>
</code></pre>
... | [
{
"answer_id": 20052,
"author": "Ramkumar M",
"author_id": 5669,
"author_profile": "https://wordpress.stackexchange.com/users/5669",
"pm_score": 1,
"selected": false,
"text": "<p>In Wordpress plugin,they are using lot of functions inherit from predefined functions.so if you are delete a ... | 2011/06/15 | [
"https://wordpress.stackexchange.com/questions/20044",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5686/"
] | In a theme I built from scratch I'm using the WP Photo Album Plus plugin. Per some books I've been using as guides, I need to include this code in the header in order to make comments work in a blog:
```
<?php if ( is_singular() ) wp_enqueue_script ( 'comment-reply'); wp_head() ; ?>
```
I've been including this line... | This line has wrong syntax:
```
<?php if ( is_singular() ) wp_enqueue_script ( 'comment-reply'); wp_head() ; ?>
```
The call to `wp_head()` should not be on the same line as the conditional for the comment-reply script.
Change it to this:
```
<?php
// Conditional to determine if comment-reply form script should b... |
20,074 | <p>How would I go about not letting empty data into wordpress?</p>
<pre><code><?php
foreach($_POST['eirepanel_inline_ads_options_name'] as $post_eirepanel_inline_ads_options_name):
if(empty($post_eirepanel_inline_ads_options_name)):
echo 'empty';
else:
update_option('eirepanel_inline_ads_options', $_POS... | [
{
"answer_id": 20080,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": true,
"text": "<p>More importantly, you should not let *untrusted, unsanitized $_POST data* into WordPress.</p>\n\n<p>But I th... | 2011/06/15 | [
"https://wordpress.stackexchange.com/questions/20074",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18051/"
] | How would I go about not letting empty data into wordpress?
```
<?php
foreach($_POST['eirepanel_inline_ads_options_name'] as $post_eirepanel_inline_ads_options_name):
if(empty($post_eirepanel_inline_ads_options_name)):
echo 'empty';
else:
update_option('eirepanel_inline_ads_options', $_POST);
$eirepane... | More importantly, you should not let \*untrusted, unsanitized $\_POST data\* into WordPress.
But I think the issue is that you're updating the option with the entire $\_POST data, instead of the appropriate array key:
```
update_option('eirepanel_inline_ads_options', $_POST);
```
Should probably be something like:
... |
20,075 | <p>I would like to have a list of my most liked posts from facebook, and place it in the sidebar. Is there a way for doing it? (and if so, how?)</p>
| [
{
"answer_id": 20095,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 2,
"selected": false,
"text": "<p>A quick google <a href=\"http://www.google.co.uk/search?q=facebook%20api%20most%20liked%20pages\" rel=\"nof... | 2011/06/15 | [
"https://wordpress.stackexchange.com/questions/20075",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/161/"
] | I would like to have a list of my most liked posts from facebook, and place it in the sidebar. Is there a way for doing it? (and if so, how?) | A quick google [brought up these](http://www.google.co.uk/search?q=facebook%20api%20most%20liked%20pages), which led me to [this post](http://forums.digitalpoint.com/showthread.php?t=1865119#post14651844).
>
> 1. You can access the site's object in the Graph and get the current "Fan
> count". i.e.
> <http://graph.f... |
20,077 | <p>I have Press Release Section on my page where i would like to be able to add documents pdf, ms doc's etc.
Every time when i add new document to a post I would like download button to appear so user will be able to download that document. Could anyone point me at right direction or maybe there is a plugin existing w... | [
{
"answer_id": 20099,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<p><img src=\"https://i.stack.imgur.com/7NWPn.png\" alt=\"enter image description here\"> </p>\n\n<p><img src=\"https:... | 2011/06/15 | [
"https://wordpress.stackexchange.com/questions/20077",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4986/"
] | I have Press Release Section on my page where i would like to be able to add documents pdf, ms doc's etc.
Every time when i add new document to a post I would like download button to appear so user will be able to download that document. Could anyone point me at right direction or maybe there is a plugin existing whic... | No need to insert the download into the post as @kaiser says, you can automate:
```
$download = get_children( 'post_type=attachment&post_mime_type=application/pdf&post_parent='.$post->ID );
if ($download) {
foreach ( $download as $attachment_id => $attachment ) {
echo '<a href="'.wp_get_attachment_url($at... |
20,091 | <p>I'm trying to only display posts from a certain category in a widget. I've tried it in a few different ways but it is still showing posts from all categories. Here's my code at the moment:</p>
<pre><code>$posts = get_posts(array ('category'=>6, 'numberposts'=>$number, 'order'=>'DESC', 'orderby'=>'date')... | [
{
"answer_id": 20092,
"author": "kevin",
"author_id": 1997,
"author_profile": "https://wordpress.stackexchange.com/users/1997",
"pm_score": 1,
"selected": false,
"text": "<p>Did you try the example given in the codex?</p>\n\n<pre><code><?php\nglobal $post;\n$args = array( 'numberposts... | 2011/06/15 | [
"https://wordpress.stackexchange.com/questions/20091",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3570/"
] | I'm trying to only display posts from a certain category in a widget. I've tried it in a few different ways but it is still showing posts from all categories. Here's my code at the moment:
```
$posts = get_posts(array ('category'=>6, 'numberposts'=>$number, 'order'=>'DESC', 'orderby'=>'date'));
foreach ($posts... | Did you try the example given in the codex?
```
<?php
global $post;
$args = array( 'numberposts' => $number, 'category' => 6, 'order' => 'ASC', 'orderby' => 'post_date' );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
<li><a href="<?php the_permalink(); ?>"><?php the_tit... |
20,125 | <p>I want to make a TV Show database in Wordpress that has this URL format:</p>
<pre><code>/tvshows/friends/01/12/
</code></pre>
<ul>
<li><code>/tvshows/</code> would list all series</li>
<li><code>/tvshows/friends/</code> would list all the seasons available for Friends TV Show</li>
<li><code>/tvshows/friends/01/</c... | [
{
"answer_id": 20127,
"author": "Carson",
"author_id": 2107,
"author_profile": "https://wordpress.stackexchange.com/users/2107",
"pm_score": 2,
"selected": false,
"text": "<p>Justin Tadlock created a movie database using custom taxonomies that achieves something similar and he describes ... | 2011/06/15 | [
"https://wordpress.stackexchange.com/questions/20125",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4217/"
] | I want to make a TV Show database in Wordpress that has this URL format:
```
/tvshows/friends/01/12/
```
* `/tvshows/` would list all series
* `/tvshows/friends/` would list all the seasons available for Friends TV Show
* `/tvshows/friends/01/` would list all episodes of Friends from season 1
* `/tvshows/friends/01/... | First, you shouldn't do this with the built in post types of `post` or `page`. Use a custom post type.
>
> Example: `movies` and `series`, where
> `movies` is non-hierarchical, but
> `series` is.
>
>
>
Use [`register_post_type()`](https://wordpress.stackexchange.com/questions/18459/wpse-plugin-repository-show-... |
20,130 | <p>I have a error handling mechanism setup in <a href="http://wordpress.org/extend/plugins/basic-google-maps-placemarks/" rel="nofollow noreferrer">one of my plugins</a> to add notices and errors to the admin area, just like the core does. It works fine in most cases, but there are some situations (like saving a custom... | [
{
"answer_id": 20135,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>I currently don't have a clue what's going on with your plugin, so I point you at two things:</p>\n\n<p><a href=\"h... | 2011/06/16 | [
"https://wordpress.stackexchange.com/questions/20130",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3898/"
] | I have a error handling mechanism setup in [one of my plugins](http://wordpress.org/extend/plugins/basic-google-maps-placemarks/) to add notices and errors to the admin area, just like the core does. It works fine in most cases, but there are some situations (like saving a custom post type) where it doesn't. I'm guessi... | There are few things that I have pointed out in the code below too:
1. You were overwriting the options read from `get_option` using `array_merge`
2. You had hard-coded the Message Counts.
3. saving options in `__destruct` just does not work. (I don't have any clue yet, may be experts will shed some light on it.
I ha... |
20,143 | <p>I'm trying to figure out how to create a translation for a post using the internal WPML API (<code>inc/wpml-api.php</code>)</p>
<p>I simply want to create a translation for post ID xx, set some content and publish it.</p>
<p>I've tried to play around with <code>wpml_add_translatable_content</code> but couldn't get... | [
{
"answer_id": 20169,
"author": "mike23",
"author_id": 1381,
"author_profile": "https://wordpress.stackexchange.com/users/1381",
"pm_score": 4,
"selected": true,
"text": "<p>I came up with a function that does the job for now :</p>\n\n<pre><code>/**\n * Creates a translation of a post (t... | 2011/06/16 | [
"https://wordpress.stackexchange.com/questions/20143",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1381/"
] | I'm trying to figure out how to create a translation for a post using the internal WPML API (`inc/wpml-api.php`)
I simply want to create a translation for post ID xx, set some content and publish it.
I've tried to play around with `wpml_add_translatable_content` but couldn't get it right. Unfortunately there is not m... | I came up with a function that does the job for now :
```
/**
* Creates a translation of a post (to be used with WPML)
*
* @param int $post_id The ID of the post to be translated.
* @param string $post_type The post type of the post to be transaled (ie. 'post', 'page', 'custom type', etc.).
* @param string $lan... |
20,152 | <p>I refer to this question previously asked and not suitably answered:
<a href="https://wordpress.stackexchange.com/questions/7181/wordpress-overriding-actual-subdirectories">Wordpress overriding actual subdirectories</a>
and also
<a href="https://wordpress.stackexchange.com/questions/16584/non-wordpress-pages-code-ge... | [
{
"answer_id": 20160,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 0,
"selected": false,
"text": "<p>You should be able to just add a <code>RewriteCond</code> directive that will make sure the WordPress rules... | 2011/06/16 | [
"https://wordpress.stackexchange.com/questions/20152",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6242/"
] | I refer to this question previously asked and not suitably answered:
[Wordpress overriding actual subdirectories](https://wordpress.stackexchange.com/questions/7181/wordpress-overriding-actual-subdirectories)
and also
[Non "Wordpress" pages/code getting 404 error](https://wordpress.stackexchange.com/questions/16584/non... | This has worked for me in the past for a similar situation :
Put this on top of `.htaccess`
```
ErrorDocument 401 default
``` |
20,157 | <p>Can someone please tell me where the 404 redirection occurs? </p>
<p>I am wanting to redirect to a custom template.php instead of the 404 page.</p>
<p>Is this possible to do? If it is can some one provide me with a solution.</p>
<p>Thanks
Ravi</p>
| [
{
"answer_id": 20170,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 0,
"selected": false,
"text": "<p>at the top of your 404.php add:</p>\n\n<pre><code>if ($_SERVER['HTTP_REFERER'] == \"Whatever\"){\n include... | 2011/06/16 | [
"https://wordpress.stackexchange.com/questions/20157",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6245/"
] | Can someone please tell me where the 404 redirection occurs?
I am wanting to redirect to a custom template.php instead of the 404 page.
Is this possible to do? If it is can some one provide me with a solution.
Thanks
Ravi | Based on your comments, I think I get what you're saying. However, you don't want to *redirect* on a 404, since it defeats the object of the 'Not Found' header.
However, you can filter the 404 template path and pass back your own;
```
function __custom_404( $standard_404 )
{
if ( something_is_true() )
ret... |
20,180 | <p>I wanted to insert a form with a line of PHP code via shortcode. I am wondering if it's allowed? Has anyone tried it? Take the following for example:</p>
<pre><code>function get_form($atts) {
return '<form method="post" action="">
<input type="input" name="myinput" value=""></input>... | [
{
"answer_id": 20189,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 0,
"selected": false,
"text": "<p>no that wont work!</p>\n\n<p>you need to return all of the value as string/html:</p>\n\n<pre><code>function g... | 2011/06/16 | [
"https://wordpress.stackexchange.com/questions/20180",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6232/"
] | I wanted to insert a form with a line of PHP code via shortcode. I am wondering if it's allowed? Has anyone tried it? Take the following for example:
```
function get_form($atts) {
return '<form method="post" action="">
<input type="input" name="myinput" value=""></input>
<input type="hidde... | `$current_user` isn't declared in the scope of that function. You'd want to modify the code to be more like this:
```
function get_form($atts) {
$current_user = wp_get_current_user();
return '<form method="post" action="">
<input type="input" name="myinput" value=""></input>
<input type... |
20,192 | <p>Is there a dedicated WP function, action or filter to use when adding/modifying the HTTP headers?</p>
<p>For now I just hook a PHP header() call into the WP 'init' hook like this:</p>
<pre><code>add_action('init', 'add_header_xua');
function add_header_xua(){
if(!is_admin()){
header('X-UA-Compatible: I... | [
{
"answer_id": 20193,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 4,
"selected": true,
"text": "<p>The init action is the wrong place to do it. A better place would be at template_redirect, so that you only affect t... | 2011/06/16 | [
"https://wordpress.stackexchange.com/questions/20192",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2071/"
] | Is there a dedicated WP function, action or filter to use when adding/modifying the HTTP headers?
For now I just hook a PHP header() call into the WP 'init' hook like this:
```
add_action('init', 'add_header_xua');
function add_header_xua(){
if(!is_admin()){
header('X-UA-Compatible: IE=edge,chrome=1'); ... | The init action is the wrong place to do it. A better place would be at template\_redirect, so that you only affect the front end view of the site and not the admin areas. |
20,206 | <p>I have found this place to be a good source of information in the past through a lot of Googling for the problems I have run into. My question pertains to the verbose rewrite rules WordPress uses.</p>
<p>I have set up a custom post type called <em>project</em>, and I have registered a custom taxonomy called <em>pro... | [
{
"answer_id": 36797,
"author": "nonsensecreativity",
"author_id": 10997,
"author_profile": "https://wordpress.stackexchange.com/users/10997",
"pm_score": 1,
"selected": false,
"text": "<p>Hope this can solve your problem</p>\n\n<pre><code>function my_custom_post_type() {\n$labels = arra... | 2011/06/16 | [
"https://wordpress.stackexchange.com/questions/20206",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6260/"
] | I have found this place to be a good source of information in the past through a lot of Googling for the problems I have run into. My question pertains to the verbose rewrite rules WordPress uses.
I have set up a custom post type called *project*, and I have registered a custom taxonomy called *projects*. Everything w... | Hope this can solve your problem
```
function my_custom_post_type() {
$labels = array(
'name' => _x('Projects', 'post type general name'),
'singular_name' => _x('Project', 'post type singular name'),
'add_new' => _x('Add New', 'project item'),
'add_new_item' => __('Add New Project'),
'edit_item' =>... |
20,210 | <p>I am slowly going mad trying to figure this out..</p>
<p>I want to list custom post type 'mobile_review' by custom taxonomy 'mobile_phone', as multipe custom post types share this taxonomy I need some way to segment.</p>
<p>So far I have this:</p>
<pre><code>function get_terms_by_post_type($taxonomies,$args){
$... | [
{
"answer_id": 20216,
"author": "developdaly",
"author_id": 3293,
"author_profile": "https://wordpress.stackexchange.com/users/3293",
"pm_score": 0,
"selected": false,
"text": "<pre><code> $args = array(\n 'post_type' => 'mobile_review',\n 'taxonomy' => 'mobile_phone'\n);\n</... | 2011/06/16 | [
"https://wordpress.stackexchange.com/questions/20210",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6139/"
] | I am slowly going mad trying to figure this out..
I want to list custom post type 'mobile\_review' by custom taxonomy 'mobile\_phone', as multipe custom post types share this taxonomy I need some way to segment.
So far I have this:
```
function get_terms_by_post_type($taxonomies,$args){
$args = array(
'post_ty... | Here's an example that will list all the `mobile_review` posts that have the term `htc_desire_hd` in the taxonomy `mobile_phone` :
```
$tax_query = array( 'relation' => 'AND' );
$tax_query[] = array(
'taxonomy' => 'mobile_phone',
'terms' => array('htc_desire_hd'),
'field' => 'slug'
);
$args = array(
... |
20,218 | <p>I'd like to run some code only if a gallery (inserted with the <code>[gallery]</code> shortcode) has been inserted into a post/page. I did the following:</p>
<pre><code>gallery_shortcode($post->ID) ?
$gallery = 1 : $gallery = 0;
</code></pre>
<p>However, this always sets <code>$gallery = 0</code> whether there'... | [
{
"answer_id": 20219,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 5,
"selected": true,
"text": "<p>try :</p>\n\n<pre><code>if (strpos($post->post_content,'[gallery') === false){\n $gallery = 0;\n}else{\n ... | 2011/06/16 | [
"https://wordpress.stackexchange.com/questions/20218",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6195/"
] | I'd like to run some code only if a gallery (inserted with the `[gallery]` shortcode) has been inserted into a post/page. I did the following:
```
gallery_shortcode($post->ID) ?
$gallery = 1 : $gallery = 0;
```
However, this always sets `$gallery = 0` whether there's a gallery or not. Am I using this incorrectly? | try :
```
if (strpos($post->post_content,'[gallery') === false){
$gallery = 0;
}else{
$gallery = 1;
}
``` |
20,220 | <p>I'm a little stuck here. I have a menu in Wordpress with some posts in it.
What I would like is to retrieve all the posts as objects.</p>
<p>I think I'm pretty close, but the SQL query doesn't seem to work as I want.</p>
<p>This is wat I have so far:</p>
<pre><code>$querystr = "
SELECT wposts.* FROM wp_posts wpos... | [
{
"answer_id": 20225,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<p>There's a function to get a nav menu as object: <a href=\"http://phpdoc.wordpress.org/trunk/WordPress/Nav_Menus/_wp... | 2011/06/16 | [
"https://wordpress.stackexchange.com/questions/20220",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5986/"
] | I'm a little stuck here. I have a menu in Wordpress with some posts in it.
What I would like is to retrieve all the posts as objects.
I think I'm pretty close, but the SQL query doesn't seem to work as I want.
This is wat I have so far:
```
$querystr = "
SELECT wposts.* FROM wp_posts wposts
LEFT JOIN wp_postmeta wme... | I recently needed the same thing, I had menu of categories and I needed to get the categories that in the menu. After a several hours digging in the WP core, I found the
**wp\_get\_nav\_menu\_items()** function that helped me.
I finnally came with this, 220 was my menu\_id
```
$navcat = wp_get_nav_menu_items('220');... |
20,223 | <p>I have a field on the admin side where a user enters a number for a price. If a user enters 1000000 I'd like to be able to display on the front-end $1,000,000.</p>
<p>Any ideas on how to accomplish this?</p>
<p><strong>Edit</strong>
More details, the post is a custom post type 'property'.</p>
<p>To add the meta f... | [
{
"answer_id": 20224,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>Just a <strong>guess</strong> (you really need to be more specific in your Q - what screen, how did you add it, met... | 2011/06/17 | [
"https://wordpress.stackexchange.com/questions/20223",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4090/"
] | I have a field on the admin side where a user enters a number for a price. If a user enters 1000000 I'd like to be able to display on the front-end $1,000,000.
Any ideas on how to accomplish this?
**Edit**
More details, the post is a custom post type 'property'.
To add the meta fields on the back-end I'm using Meta ... | To format number, you can use the function `number_format_i18n` (it's not documented now, but you can see its source [here](http://phpxref.com/xref/wordpress/_functions/number_format_i18n.html)). Its work is format the number based on the language. You might want to look at `number_format` ([PHP built\_in function](htt... |
20,232 | <p>I am getting errors like </p>
<pre><code>Warning: explode() expects parameter 2 to be string, array given in /data/www/ae/wp-includes/query.php on line 2390
Warning: in_array() expects parameter 2 to be array, null given in /data/www/ae/wp-includes/query.php on line 2399
Warning: in_array() expects parameter 2 to b... | [
{
"answer_id": 20283,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 2,
"selected": false,
"text": "<p>You're not alone. It's a problem with a variable type assumption in <code>WP_Query</code>. I fixed it by ed... | 2011/06/17 | [
"https://wordpress.stackexchange.com/questions/20232",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3788/"
] | I am getting errors like
```
Warning: explode() expects parameter 2 to be string, array given in /data/www/ae/wp-includes/query.php on line 2390
Warning: in_array() expects parameter 2 to be array, null given in /data/www/ae/wp-includes/query.php on line 2399
Warning: in_array() expects parameter 2 to be array, null ... | Installing the hotfix plugin may help to solve the problem. <http://wordpress.org/extend/plugins/hotfix/>
Currently I am using wordpress3.1.3 and got same type errors while browsing the media(media list page) in admin panel and hotfix plugin solves that. |
20,240 | <p>for example: foobar.com/wp/edit instead of foobar.com/wp/wp-admin</p>
<p>How would I do that?</p>
<p>I've tried using this in htaccess but it won't work:</p>
<pre><code>##### ABOVE THIS POINT IS ALREADY INSERTED BY WORD PRESS
##### Admin Base Rewrite #####
RewriteCond %{REQUEST_URI} wp-admin/
RewriteCond %{QUERY_... | [
{
"answer_id": 20241,
"author": "mike23",
"author_id": 1381,
"author_profile": "https://wordpress.stackexchange.com/users/1381",
"pm_score": 1,
"selected": false,
"text": "<p>You can try the <a href=\"http://wordpress.org/extend/plugins/redirection/\" rel=\"nofollow\">Redirection</a> plu... | 2011/06/17 | [
"https://wordpress.stackexchange.com/questions/20240",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1226/"
] | for example: foobar.com/wp/edit instead of foobar.com/wp/wp-admin
How would I do that?
I've tried using this in htaccess but it won't work:
```
##### ABOVE THIS POINT IS ALREADY INSERTED BY WORD PRESS
##### Admin Base Rewrite #####
RewriteCond %{REQUEST_URI} wp-admin/
RewriteCond %{QUERY_STRING} !sercretword
Rewrite... | You can try the [Redirection](http://wordpress.org/extend/plugins/redirection/) plugin, it's great for exactly that.
**EDIT**
You could also for example setup a subdomain that makes a transparent redirect, as in : <http://admin.mywebsite.com/> which you would redirect to your wp-admin/ folder. But then I think people... |
20,244 | <p>I apologize if this is a newbie question, but I am very new to working with WP template files.</p>
<p>I am working on a campaign site (that I unfortunately can't show you before the launch in a couple weeks). I'm using a static home page, and I've managed to create a template that displays posts (title, date, excerp... | [
{
"answer_id": 20246,
"author": "MartinJJ",
"author_id": 3710,
"author_profile": "https://wordpress.stackexchange.com/users/3710",
"pm_score": 2,
"selected": false,
"text": "<p>Maybe take a look inside the 2010 theme that comes packaged with WP, index.php shows a call to a loop file: <co... | 2011/06/17 | [
"https://wordpress.stackexchange.com/questions/20244",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6271/"
] | I apologize if this is a newbie question, but I am very new to working with WP template files.
I am working on a campaign site (that I unfortunately can't show you before the launch in a couple weeks). I'm using a static home page, and I've managed to create a template that displays posts (title, date, excerpt) below ... | Maybe take a look inside the 2010 theme that comes packaged with WP, index.php shows a call to a loop file: `<?php get_template_part( 'loop', 'index' ); ?>` so you could (well this is how i would do it, cos i think it looks neater, [**but you could use multiple loops**](http://codex.wordpress.org/The_Loop#Multiple_Loop... |
20,250 | <p>I have this code:</p>
<pre><code> $args=array(
'public' => true,
'_builtin' => false
);
?>
<select id="<?php echo $this->get_field_id('posttype'); ?>" name="<?php echo $this->get_field_name('posttype'); ?>">
<?php foreach(get_pos... | [
{
"answer_id": 20469,
"author": "MartinJJ",
"author_id": 3710,
"author_profile": "https://wordpress.stackexchange.com/users/3710",
"pm_score": 0,
"selected": false,
"text": "<p>Theres a fix for that:</p>\n\n<pre><code><?php \n $args=array(\n 'public' =&g... | 2011/06/17 | [
"https://wordpress.stackexchange.com/questions/20250",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6249/"
] | I have this code:
```
$args=array(
'public' => true,
'_builtin' => false
);
?>
<select id="<?php echo $this->get_field_id('posttype'); ?>" name="<?php echo $this->get_field_name('posttype'); ?>">
<?php foreach(get_post_types($args,'names') as $post_type) { ?>
... | You just need to pull the Labels via `get_post_type_object();`
```
<?php
$args=array(
'public' => true,
'_builtin' => false
);
$output = 'names';
$operator = 'and';
$post_types=get_post_types($args,$output,$operator);
?>
<select id="" name="">
<?php foreach ($post_types as $post_type ) {
$l... |
20,273 | <p>I am trying to get three loops to display. they all belong to the same post type and the same taxonomy family. but i'm trying to separate the taxonomy by three different values. </p>
<pre><code>$argsOwners = array( 'tax_query' => array(array('taxonomy' => 'position', 'field' => 'slug', 'terms' => 'seni... | [
{
"answer_id": 20260,
"author": "Louis Stephens",
"author_id": 807,
"author_profile": "https://wordpress.stackexchange.com/users/807",
"pm_score": 2,
"selected": true,
"text": "<p>I personally do not know of any free tool that would achieve what you are looking for. The closest thing wou... | 2011/06/17 | [
"https://wordpress.stackexchange.com/questions/20273",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2774/"
] | I am trying to get three loops to display. they all belong to the same post type and the same taxonomy family. but i'm trying to separate the taxonomy by three different values.
```
$argsOwners = array( 'tax_query' => array(array('taxonomy' => 'position', 'field' => 'slug', 'terms' => 'senior-management' )));
$th... | I personally do not know of any free tool that would achieve what you are looking for. The closest thing would be to use a "slice and chop" company that would take your designs and slice them up for you at a price though.
There is a great "blank" wordpress theme out [there](http://digwp.com/2010/02/blank-wordpress-the... |
20,279 | <p>I need to build a php foreach that goes through all my terms in my custom taxonomy 'Section'.</p>
<p>I know how to get a foreach of all the terms in 'Section', but what i cant do is build it with levels.</p>
<p>I want the top parent term to be the heading, and its children will be displayed in a list.</p>
<p>Here... | [
{
"answer_id": 20282,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 2,
"selected": false,
"text": "<p>Why not use <code>wp_list_categories( 'taxonomy=section' )</code> ? It'll do all the nesting & hard wor... | 2011/06/17 | [
"https://wordpress.stackexchange.com/questions/20279",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5140/"
] | I need to build a php foreach that goes through all my terms in my custom taxonomy 'Section'.
I know how to get a foreach of all the terms in 'Section', but what i cant do is build it with levels.
I want the top parent term to be the heading, and its children will be displayed in a list.
Heres an html example of the... | I managed to work on it a little more and built the answer myself. Heres the code i needed.
```
<?php
$parent_terms = get_terms('section', 'orderby=name&hide_empty=0&parent=0');
foreach ( $parent_terms as $parent_term ) { ?>
<div class="accordian open">
<div class="accordian-title module-gradient"... |
20,294 | <p>My understanding is that <code>site_url()</code> returns the location where the WordPress core files are.</p>
<p>If my blog is hosted at <code>http://example.com/blog</code> then <code>site_url()</code> returns <code>http://example.com/blog</code></p>
<p>But then how does <code>home_url()</code> differ? For me, <c... | [
{
"answer_id": 20295,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": false,
"text": "<p>If you want WP installed in a directory but the site home on your domain root, you need to move the main index.php ... | 2011/06/17 | [
"https://wordpress.stackexchange.com/questions/20294",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6058/"
] | My understanding is that `site_url()` returns the location where the WordPress core files are.
If my blog is hosted at `http://example.com/blog` then `site_url()` returns `http://example.com/blog`
But then how does `home_url()` differ? For me, `home_url()` returns the same thing: `http://example.com/blog`
If that's ... | You are asking two questions at once:
1. What's the difference between `home_url()` and `site_url()`?
2. How do I get WordPress to return the URL root without the subdirectory where it's installed?
Here are the answers, and I confirmed with Andrew Nacin, a core developer of WordPress, as well as ran some server tests... |
20,310 | <p><code>get_categories()</code> and related functions, by default, don't return empty categories - categories with no posts. </p>
<p>I thought that, since there may be some underlying code checking the post counts, is it possible to additionally filter that list to only include categories <em>that themselves</em> con... | [
{
"answer_id": 20336,
"author": "scribu",
"author_id": 205,
"author_profile": "https://wordpress.stackexchange.com/users/205",
"pm_score": 0,
"selected": false,
"text": "<p>See the <a href=\"http://wordpress.org/extend/plugins/query-multiple-taxonomies/\" rel=\"nofollow\">Query Multiple ... | 2011/06/17 | [
"https://wordpress.stackexchange.com/questions/20310",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6289/"
] | `get_categories()` and related functions, by default, don't return empty categories - categories with no posts.
I thought that, since there may be some underlying code checking the post counts, is it possible to additionally filter that list to only include categories *that themselves* contain posts that have a certa... | Check out my answer on [how to get terms that are associated with others through the posts that they're attached to](https://wordpress.stackexchange.com/questions/16393/show-certain-terms-from-custom-taxonomy-but-exclude-parent-terms/16795#16795).
In your case, you could put it into practice like so;
```
$category_ID... |
20,313 | <p>There will be many people commenting on a post. So, when a commentator visits the post, he should be able to see 'only' his own comment(s).Post author can see all comments only on his own post.</p>
<p>How can I do this in WordPress?</p>
| [
{
"answer_id": 20337,
"author": "scribu",
"author_id": 205,
"author_profile": "https://wordpress.stackexchange.com/users/205",
"pm_score": 2,
"selected": false,
"text": "<p>By using the 'pre_get_comments' action, found in <code>wp-includes/comment.php</code>:</p>\n\n<pre><code>function r... | 2011/06/17 | [
"https://wordpress.stackexchange.com/questions/20313",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6291/"
] | There will be many people commenting on a post. So, when a commentator visits the post, he should be able to see 'only' his own comment(s).Post author can see all comments only on his own post.
How can I do this in WordPress? | By using the 'pre\_get\_comments' action, found in `wp-includes/comment.php`:
```
function restrict_visible_comments( $comments_query ) {
if ( !is_singular() )
return;
if ( current_user_can( 'moderate_comments' ) )
return; // moderators can see all comments
if ( get_current_user_id() == ... |
20,317 | <p>Not sure when it happened but the custom permalinks for pages on my client's Wordpress site have broken. I can fix it by reverting back to the default permalinks and then using the custom permalinks, but they break again whenever my clients edits a page. Blog posts, archives, tags, categories, and custom post types ... | [
{
"answer_id": 24429,
"author": "Pippin",
"author_id": 2418,
"author_profile": "https://wordpress.stackexchange.com/users/2418",
"pm_score": 2,
"selected": false,
"text": "<p>Do you have a custom post type? This is exactly the kind of behavior you will see from have a custom post type wi... | 2011/06/17 | [
"https://wordpress.stackexchange.com/questions/20317",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6294/"
] | Not sure when it happened but the custom permalinks for pages on my client's Wordpress site have broken. I can fix it by reverting back to the default permalinks and then using the custom permalinks, but they break again whenever my clients edits a page. Blog posts, archives, tags, categories, and custom post types per... | I was using the [Custom Post Type UI Plugin](https://wordpress.org/plugins/custom-post-type-ui/) and had generated the following code (which I added to the functions file) for a custom taxonomy through the plugin:
```
register_taxonomy( 'video_type',
array ( 0 => 'video' ),
array(
'hierarchical' =>... |
20,321 | <p>I'm trying to create an array of images for a slideshow gallery script, so need to separate the images from the post loop - any ideas of the best way to achieve this and make it easy to add images?
I can use a script to grab attachments (see below) but it seems a bit messy as: </p>
<ol>
<li>image uploaded appear i... | [
{
"answer_id": 20334,
"author": "Ramkumar M",
"author_id": 5669,
"author_profile": "https://wordpress.stackexchange.com/users/5669",
"pm_score": 0,
"selected": false,
"text": "<p>all your upload images are saved under Media Library.You can write Image Description text at the time of a ne... | 2011/06/18 | [
"https://wordpress.stackexchange.com/questions/20321",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6078/"
] | I'm trying to create an array of images for a slideshow gallery script, so need to separate the images from the post loop - any ideas of the best way to achieve this and make it easy to add images?
I can use a script to grab attachments (see below) but it seems a bit messy as:
1. image uploaded appear in the post te... | The best way to assign images to a given post is to just upload them in the WordPress post editing/new post area. You can also delete images from there.
With that said, here would be how you do that. You're going to hook into `wp_enqueue_script`, and call `wp_enqueue_script` to add your gallery script to the page. Th... |
20,326 | <p><strong>REQUIRED:</strong> Comments are displayed as "Off" while they aren't in wp-admin. Comment form is not displayed in these cases, while it is when a unit test post already has comments.</p>
<p>i have installed the <strong>Test data</strong> . and on some <strong>post</strong> and <strong>comment test post</s... | [
{
"answer_id": 20329,
"author": "Jeremy Jared",
"author_id": 5339,
"author_profile": "https://wordpress.stackexchange.com/users/5339",
"pm_score": 0,
"selected": false,
"text": "<p>I'll try to point you in the right direction, but I'm not 100% sure. I've only been*\"Stepping Into Templat... | 2011/06/18 | [
"https://wordpress.stackexchange.com/questions/20326",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4031/"
] | **REQUIRED:** Comments are displayed as "Off" while they aren't in wp-admin. Comment form is not displayed in these cases, while it is when a unit test post already has comments.
i have installed the **Test data** . and on some **post** and **comment test post** pages. these pages had some comments. and there is also ... | OK, I figured it out. It took a bit of digging and many bad suggestions. The solution is actually quite simple. Just replace this in your theme files:
**Where you have this**:
```
<div class="comments">
<?php comments_template(); ?>
</div>
```
**Replace it with this:**
```
<div clas... |
20,327 | <p><a href="http://adambrown.info/p/wp_hooks/hook/plugin_action_links_%7B%24plugin_file%7D" rel="nofollow">http://adambrown.info/p/wp_hooks/hook/plugin_action_links_%7B$plugin_file%7D</a></p>
<p>Says the hook is deprecated. However, the <a href="http://mobile.adambrown.info/p/wp_hooks/hook/%7B%24prefix%7Dplugin_actio... | [
{
"answer_id": 20335,
"author": "scribu",
"author_id": 205,
"author_profile": "https://wordpress.stackexchange.com/users/205",
"pm_score": 4,
"selected": true,
"text": "<p>Yes, both should work as expected:</p>\n\n<p><code>\"plugin_action_links_{$plugin_file}\"</code></p>\n\n<p><code>\"n... | 2011/06/18 | [
"https://wordpress.stackexchange.com/questions/20327",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6035/"
] | [http://adambrown.info/p/wp\_hooks/hook/plugin\_action\_links\_%7B$plugin\_file%7D](http://adambrown.info/p/wp_hooks/hook/plugin_action_links_%7B%24plugin_file%7D)
Says the hook is deprecated. However, the [{$prefix}plugin\_action\_hook\_{$plugin\_file}](http://mobile.adambrown.info/p/wp_hooks/hook/%7B%24prefix%7Dplug... | Yes, both should work as expected:
`"plugin_action_links_{$plugin_file}"`
`"network_admin_plugin_action_links_{$plugin_file}"`
Note that I'm using `"` instead of `'`.
PS: The term is *deprecated*, not depreciated. |
20,343 | <p>I'm using Posts 2 Posts plugin. I've got 2 custom types : movies and actors. I created a movie => actor connection so that for each movie I can see which actors play in.</p>
<p>But as far as I understand, in order to find out all the movies a particular actor has played in, you must create an actor => movie connect... | [
{
"answer_id": 20353,
"author": "John P Bloch",
"author_id": 11,
"author_profile": "https://wordpress.stackexchange.com/users/11",
"pm_score": 3,
"selected": false,
"text": "<p>No, you shouldn't need one each way.</p>\n\n<p>You can query on either direction of the one connection, so some... | 2011/06/18 | [
"https://wordpress.stackexchange.com/questions/20343",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5915/"
] | I'm using Posts 2 Posts plugin. I've got 2 custom types : movies and actors. I created a movie => actor connection so that for each movie I can see which actors play in.
But as far as I understand, in order to find out all the movies a particular actor has played in, you must create an actor => movie connection AS WEL... | To see connections on both edit screens, set `reciprocal` to `true`, but note this is for the UI only, it doesn't affect connections otherwise.
```
function my_connection_types() {
if ( !function_exists( 'p2p_register_connection_type' ) )
return;
p2p_register_connection_type( array(
'from' =>... |
20,347 | <p>How to make a post visible to only:</p>
<ol>
<li><p>The post author, irrespective of its user role.</p></li>
<li><p>All users from a specific user role.</p></li>
</ol>
<p>Other then these, no one should be able to see the post.</p>
<p>How should I approach this.</p>
<p>Note that I have only three user roles in W... | [
{
"answer_id": 20349,
"author": "chrisguitarguy",
"author_id": 6035,
"author_profile": "https://wordpress.stackexchange.com/users/6035",
"pm_score": 2,
"selected": false,
"text": "<p>Give your custom roles the capability to \"read_member_posts\" or whatever. Then you could apply a filte... | 2011/06/18 | [
"https://wordpress.stackexchange.com/questions/20347",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6291/"
] | How to make a post visible to only:
1. The post author, irrespective of its user role.
2. All users from a specific user role.
Other then these, no one should be able to see the post.
How should I approach this.
Note that I have only three user roles in WP. Admin, and 2 other custom roles. | Give your custom roles the capability to "read\_member\_posts" or whatever. Then you could apply a filter to the\_content()
```
add_filter( 'the_content', 'my_wpse20347_filter' );
function my_wpse20347_filter( $content )
{
global $post;
if( author_can( $post->ID, 'edit_posts' ) || current_user_can( 'read_memb... |
20,348 | <p>I'm using this code here to grab all my custom fields from a post for use in an gallery array. </p>
<p><a href="http://www.kevinleary.net/get-all-custom-fields-attached-post-page-post-type/" rel="nofollow">http://www.kevinleary.net/get-all-custom-fields-attached-post-page-post-type/</a></p>
<p><strong>function:</s... | [
{
"answer_id": 20350,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<pre><code>if( !empty($custom_fields) ) {\n $output = '';\n foreach( $custom_fields as $key => $value ){\n ... | 2011/06/18 | [
"https://wordpress.stackexchange.com/questions/20348",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6078/"
] | I'm using this code here to grab all my custom fields from a post for use in an gallery array.
<http://www.kevinleary.net/get-all-custom-fields-attached-post-page-post-type/>
**function:**
```
// Get all custom fields attached to a page
if ( !function_exists('base_get_all_custom_fields') ) {
function base_get_all_... | ```
if( !empty($custom_fields) ) {
$output = '';
foreach( $custom_fields as $key => $value ){
foreach( $value as $val ){
$output .= "{".$key." : '".$val."'},";
}
}
echo $output;
}
``` |
20,389 | <p>I'm working with a shortcode <code>[translate lang=eng]Apple[/translate]</code> which will be shown only if the "current language" is <code>eng</code>. If the post contains, in addition to the above, the declaration <code>[translate lang=rus]Яаблоко[/translate]</code> and the current language is neither <code>rus</c... | [
{
"answer_id": 20426,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>That's the best I can come up with:</p>\n\n<pre><code>function wpse20389_show_shortcode_tags()\n{\n echo '<pr... | 2011/06/19 | [
"https://wordpress.stackexchange.com/questions/20389",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6248/"
] | I'm working with a shortcode `[translate lang=eng]Apple[/translate]` which will be shown only if the "current language" is `eng`. If the post contains, in addition to the above, the declaration `[translate lang=rus]Яаблоко[/translate]` and the current language is neither `rus` nor `eng`, neither of `Яаблоко` or `Apple`... | That's the best I can come up with:
```
function wpse20389_show_shortcode_tags()
{
echo '<pre>Shortcode Tags: ';
print_r( $GLOBALS['wp_filter']['the_content'] );
echo '</pre>';
}
add_action( 'shutdown', 'wpse20389_show_shortcode_tags' );
``` |
20,395 | <p>For some reason, one of my top posts as reported by <a href="http://wordpress.org/extend/plugins/stats/" rel="nofollow" title="WordPress Stats">WordPress Stats</a> is actually non-existent...</p>
<p>What I see is:</p>
<blockquote>
<p>#2147483647 (loading title) </p>
</blockquote>
<p>and it links to "...?p=21474... | [
{
"answer_id": 20426,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>That's the best I can come up with:</p>\n\n<pre><code>function wpse20389_show_shortcode_tags()\n{\n echo '<pr... | 2011/06/19 | [
"https://wordpress.stackexchange.com/questions/20395",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6315/"
] | For some reason, one of my top posts as reported by [WordPress Stats](http://wordpress.org/extend/plugins/stats/ "WordPress Stats") is actually non-existent...
What I see is:
>
> #2147483647 (loading title)
>
>
>
and it links to "...?p=2147483647" which returns a 404.
Now a bit of background info:
* I'm actua... | That's the best I can come up with:
```
function wpse20389_show_shortcode_tags()
{
echo '<pre>Shortcode Tags: ';
print_r( $GLOBALS['wp_filter']['the_content'] );
echo '</pre>';
}
add_action( 'shutdown', 'wpse20389_show_shortcode_tags' );
``` |
20,424 | <p>I cannot figure out how to make next_posts_link() work within my custom WP_Query. Here is the function:</p>
<pre><code>function artists() {
echo '<div id="artists">';
$args = array( 'post_type' => 'artist', 'posts_per_page' => 3, 'paged' => get_query_var( 'page' ));
$loop = new WP_Query( $args ... | [
{
"answer_id": 20427,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 5,
"selected": true,
"text": "<p>try passing max_num_pages to the function:</p>\n\n<pre><code>next_posts_link('Older Entries »', $loop->max_num_pa... | 2011/06/19 | [
"https://wordpress.stackexchange.com/questions/20424",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6318/"
] | I cannot figure out how to make next\_posts\_link() work within my custom WP\_Query. Here is the function:
```
function artists() {
echo '<div id="artists">';
$args = array( 'post_type' => 'artist', 'posts_per_page' => 3, 'paged' => get_query_var( 'page' ));
$loop = new WP_Query( $args );
while ( $loop->have_p... | try passing max\_num\_pages to the function:
```
next_posts_link('Older Entries »', $loop->max_num_pages);
``` |
20,431 | <p>I've been stumbling around trying to figure out how to get a specific taxonomy term of the current page so that I can subsequently populate queries on the page for other post types that share the same term.</p>
<p>Basically: </p>
<ul>
<li>Page 1 has taxonomy term - education policy</li>
<li>page.php has four part... | [
{
"answer_id": 21270,
"author": "dashaluna",
"author_id": 1343,
"author_profile": "https://wordpress.stackexchange.com/users/1343",
"pm_score": 6,
"selected": true,
"text": "<p>Hm, if you registered a taxonomy for the \"page\" object type correctly and then assigned a term of that taxono... | 2011/06/19 | [
"https://wordpress.stackexchange.com/questions/20431",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1340/"
] | I've been stumbling around trying to figure out how to get a specific taxonomy term of the current page so that I can subsequently populate queries on the page for other post types that share the same term.
Basically:
* Page 1 has taxonomy term - education policy
* page.php has four parts:
1. standard loop that out... | Hm, if you registered a taxonomy for the "page" object type correctly and then assigned a term of that taxonomy to a page... I believe you can then access the taxonomy and term slugs in the following way:
```
get_query_var( 'taxonomy' )
get_query_var( 'term' )
```
If you `print_r($wp_query)` you will see all the par... |
20,475 | <p>this is my function :</p>
<pre><code>$prefix = 'dbt_';
$meta_box = array(
'id' => 'my-meta-box',
'title' => 'Custom meta box',
'page' => 'post',
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'name' => 'Checkbox',
... | [
{
"answer_id": 20478,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 3,
"selected": true,
"text": "<p>Your missing the prefix:</p>\n\n<p>Make sure you call <code>global $prefix</code> after your query and use <code>$p... | 2011/06/20 | [
"https://wordpress.stackexchange.com/questions/20475",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6332/"
] | this is my function :
```
$prefix = 'dbt_';
$meta_box = array(
'id' => 'my-meta-box',
'title' => 'Custom meta box',
'page' => 'post',
'context' => 'normal',
'priority' => 'high',
'fields' => array(
array(
'name' => 'Checkbox',
'id' => $prefix . 'checkbox',
... | Your missing the prefix:
Make sure you call `global $prefix` after your query and use `$prefix.'checkbox'` to your `get_post_meta`
```
<?php if ($meta_box = get_post_meta($post->ID, $prefix.'checkbox', true) ) : ?>
Show this when checkbox checked
<?php endif; ?>
``` |
20,476 | <p>I am wondering from the syntax </p>
<pre><code>$sql = $wpdb->prepare( 'query' [, value_parameter, value_parameter ... ] )
</code></pre>
<p>It appears (from the syntax - values within prepare) that it simple escapes values not craete a prepared statement giving me performance benefits when I execute it multiple ... | [
{
"answer_id": 20484,
"author": "Hameedullah Khan",
"author_id": 5337,
"author_profile": "https://wordpress.stackexchange.com/users/5337",
"pm_score": 3,
"selected": true,
"text": "<p><code>$wpdb-prepare</code> works like <code>sprintf</code> and <code>vsprintf</code>. The first argument... | 2011/06/20 | [
"https://wordpress.stackexchange.com/questions/20476",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3788/"
] | I am wondering from the syntax
```
$sql = $wpdb->prepare( 'query' [, value_parameter, value_parameter ... ] )
```
It appears (from the syntax - values within prepare) that it simple escapes values not craete a prepared statement giving me performance benefits when I execute it multiple times will different params?
... | `$wpdb-prepare` works like `sprintf` and `vsprintf`. The first argument will always be a format string.
The only acceptable format specifiers are `%s` and `%d`. Others I have never tested but may result in parse error as per the Codex. You must escape literal **%** in your query with **%**, e.g: `%%`
If you use it l... |
20,479 | <p>I am trying to enqueue/print scripts in the admin area. But they dont seem to appear.</p>
<pre><code>add_action('admin_init', function() {
add_meta_box('portfolio-meta', 'Details', 'portfolio_metabox_details', 'portfolio');
wp_register_script('jqeury-validate', 'http://ajax.aspnetcdn.com/ajax/jquery.valida... | [
{
"answer_id": 20481,
"author": "Dennis Hoppe",
"author_id": 6333,
"author_profile": "https://wordpress.stackexchange.com/users/6333",
"pm_score": 1,
"selected": false,
"text": "<p>Make sure your header.php (or another function in the header) runs the wp_head action hook. The code should... | 2011/06/20 | [
"https://wordpress.stackexchange.com/questions/20479",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3788/"
] | I am trying to enqueue/print scripts in the admin area. But they dont seem to appear.
```
add_action('admin_init', function() {
add_meta_box('portfolio-meta', 'Details', 'portfolio_metabox_details', 'portfolio');
wp_register_script('jqeury-validate', 'http://ajax.aspnetcdn.com/ajax/jquery.validate/1.8.1/jquer... | Use the `admin_enqueue_scripts` hook instead of `admin_init`
Note: you should use hooks that target admin pages as specifically as possible. e.g.:
* **Plugins**: Use the `admin_print_scripts-{plugin-page}` hook
* **Themes**: Use the `admin_print_scripts-{theme-page}` hook (where `{theme-page}` is whatever string you ... |
20,489 | <p>I Want to Add My Latest 5 Post Title with Corresponding Link in My Header Position.What was the Actual Php code?Am Newbie .... </p>
| [
{
"answer_id": 20495,
"author": "Daniel Sachs",
"author_id": 4451,
"author_profile": "https://wordpress.stackexchange.com/users/4451",
"pm_score": 4,
"selected": true,
"text": "<p>This sounds like an additional Loop on that page, right?\nYou might want to use:</p>\n\n<pre><code><ul>... | 2011/06/20 | [
"https://wordpress.stackexchange.com/questions/20489",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5669/"
] | I Want to Add My Latest 5 Post Title with Corresponding Link in My Header Position.What was the Actual Php code?Am Newbie .... | This sounds like an additional Loop on that page, right?
You might want to use:
```
<ul>
<?php $posts_query = new WP_Query('posts_per_page=5');
while ($posts_query->have_posts()) : $posts_query->the_post();
?>
<li><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></li>
<?php endwhile... |
20,506 | <p>I have the default setting (IIRC) of 10 comments per page, and max nesting of 5 deep.</p>
<p>The problem (or at least, minor annoyance) is that replies to comments are not counted towards that maximum of ten per page. I can understand that you do not want to break a thread, and that should be avoided, but in my tes... | [
{
"answer_id": 21023,
"author": "maryisdead",
"author_id": 2637,
"author_profile": "https://wordpress.stackexchange.com/users/2637",
"pm_score": 1,
"selected": false,
"text": "<p>You might want to play around with <code>Walker_Comment</code> in wp-includes/comment-template.php.</p>\n"
... | 2011/06/20 | [
"https://wordpress.stackexchange.com/questions/20506",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6342/"
] | I have the default setting (IIRC) of 10 comments per page, and max nesting of 5 deep.
The problem (or at least, minor annoyance) is that replies to comments are not counted towards that maximum of ten per page. I can understand that you do not want to break a thread, and that should be avoided, but in my test case I h... | Since I decided this would actually be pretty damn useful for myself too, I pushed on and wrote a custom walker, [`Walker_Paged_Threaded`](http://pastebin.com/nS9vJCVm).
I've tried to comment to the best of my ability, and admittedly it's a little thrown together, but I'm happy with the result.
How To Use It
--------... |
20,527 | <p>Any ideas how to accomplish this?</p>
<p>Something like this would work, but if there are threaded comments you get the wrong number, because pages with threaded comments have actually more comments than the <code>comments_per_page</code> setting:</p>
<pre><code>$c_page = get_query_var('cpage');
$c_per_page = get_... | [
{
"answer_id": 20555,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<p>I needed something similar a while ago. The following code is from my comment callback function. Inside your commen... | 2011/06/20 | [
"https://wordpress.stackexchange.com/questions/20527",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1986/"
] | Any ideas how to accomplish this?
Something like this would work, but if there are threaded comments you get the wrong number, because pages with threaded comments have actually more comments than the `comments_per_page` setting:
```
$c_page = get_query_var('cpage');
$c_per_page = get_query_var('comments_per_page');
... | Try the following custom Comment Walker class. The walker keep tracks for print index in a global variable named `$current_comment_print_index`; which is intialized in the `paged_walk` function.
You can print global variable `$current_comment_print_index` to show the current printed comment number.
```
<?php
/*
Plug... |
20,530 | <p>I'm trying to use the Thickbox file upload dialogue with a custom field to allow the user to upload an mp3. What I want to do is to grab the URL of the uploaded mp3 and save it as postmeta (saving the data when I've got it isn't a problem, but getting what I need is!).</p>
<p>I've got the code to make this work wit... | [
{
"answer_id": 28614,
"author": "Brian Fegter",
"author_id": 4793,
"author_profile": "https://wordpress.stackexchange.com/users/4793",
"pm_score": 1,
"selected": false,
"text": "<p>The fileurl should look like this:</p>\n\n<pre><code>fileurl = $('a', html).attr('href');\n</code></pre>\n\... | 2011/06/20 | [
"https://wordpress.stackexchange.com/questions/20530",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3430/"
] | I'm trying to use the Thickbox file upload dialogue with a custom field to allow the user to upload an mp3. What I want to do is to grab the URL of the uploaded mp3 and save it as postmeta (saving the data when I've got it isn't a problem, but getting what I need is!).
I've got the code to make this work with an image... | The fileurl should look like this:
```
fileurl = $('a', html).attr('href');
```
It's a pretty simple fix. I would do some validation on this:
```
if(/\.mp3\b/.test(fileurl)){
//Do something awesome
}else{
alert('The file you selected is not an MP3.');
}
```
Cheers! |
20,545 | <p>What is the most efficient way to determine which loop I'm in?</p>
<p>I have a few plugins that alter the query by hooking into various parts of <a href="http://core.trac.wordpress.org/browser/tags/3.5/wp-includes/query.php#L1919" rel="nofollow"><code>WP_Query::get_posts()</code></a>, through the usual suspects, ie... | [
{
"answer_id": 20547,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 0,
"selected": false,
"text": "<p>If secondary loops are called properly (i.e. by not mucking with <code>query_posts()</code>, and by setting... | 2011/06/20 | [
"https://wordpress.stackexchange.com/questions/20545",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6350/"
] | What is the most efficient way to determine which loop I'm in?
I have a few plugins that alter the query by hooking into various parts of [`WP_Query::get_posts()`](http://core.trac.wordpress.org/browser/tags/3.5/wp-includes/query.php#L1919), through the usual suspects, ie [`posts_where`, `posts_join`, etc](http://core... | Just a quick update that a new method `is_main_query()` has been introduced in WP 3.3.
### Example:
```
add_action( 'pre_get_posts', 'foo_modify_query_exclude_category' );
function foo_modify_query_exclude_category( $query ) {
if ( $query->is_main_query() && ! $query->get( 'cat' ) )
$query->set( 'cat', '-5' )... |
20,554 | <p>My custom 'Home' page is set to sort my custom posts via the custom date field with this (updated to be custom named) code in functions.php:</p>
<pre><code>// sort order for home page
add_action('wp', 'wwgo_check_page');
function wwgo_check_page () {
if (is_page()) {
add_filter('get_previous_post_sort', 'sort_i... | [
{
"answer_id": 28066,
"author": "Brian Fegter",
"author_id": 4793,
"author_profile": "https://wordpress.stackexchange.com/users/4793",
"pm_score": 0,
"selected": false,
"text": "<p>Why don't you use query_posts()?</p>\n\n<pre><code><?php\nquery_posts('meta_key=key_name&orderby=key... | 2011/06/21 | [
"https://wordpress.stackexchange.com/questions/20554",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6353/"
] | My custom 'Home' page is set to sort my custom posts via the custom date field with this (updated to be custom named) code in functions.php:
```
// sort order for home page
add_action('wp', 'wwgo_check_page');
function wwgo_check_page () {
if (is_page()) {
add_filter('get_previous_post_sort', 'sort_it');
add_f... | Use the `query_vars` or [request](http://codex.wordpress.org/Plugin_API/Filter_Reference/request) filter to add `orderby` if `orderby` is not presented in the query string |
20,565 | <p>I'm passing a GET variable at the end of my URL's as my search parameter. When I do a regular search, everything works fine:</p>
<p><em>www.mysite.com/?find=my+search</em></p>
<p>However, when I click over to the second page of results, Wordpress strips the search query of spaces and converts the URL to:</p>
<p><... | [
{
"answer_id": 20707,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 2,
"selected": false,
"text": "<p>Not sure exactly how you're adding \"find\" to the list of query variables, but this is the method you're supposed to... | 2011/06/21 | [
"https://wordpress.stackexchange.com/questions/20565",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3379/"
] | I'm passing a GET variable at the end of my URL's as my search parameter. When I do a regular search, everything works fine:
*www.mysite.com/?find=my+search*
However, when I click over to the second page of results, Wordpress strips the search query of spaces and converts the URL to:
*www.mysite.com/page/2/?find=mys... | Not sure exactly how you're adding "find" to the list of query variables, but this is the method you're supposed to use:
```
function wpa_20565_query_vars( $public_vars ) {
$public_vars[] = 'find';
return $public_vars;
}
add_filter( 'query_vars', 'wpa_20565_query_vars' );
```
I use that to add custom paginat... |
20,580 | <p>Is there a way to disable update notifications for specific plugins?</p>
<p>As a plugin developer, I have some plugins installed on my personal site using the svn trunk version for testing, but the same plugins are available from the plugin site. In these cases WP considers the latest version to be the <em>most rec... | [
{
"answer_id": 20600,
"author": "Hameedullah Khan",
"author_id": 5337,
"author_profile": "https://wordpress.stackexchange.com/users/5337",
"pm_score": 7,
"selected": true,
"text": "<p>For example if you don't want Wordpress to show update notifications for akismet, you will do it like:</... | 2011/06/21 | [
"https://wordpress.stackexchange.com/questions/20580",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4587/"
] | Is there a way to disable update notifications for specific plugins?
As a plugin developer, I have some plugins installed on my personal site using the svn trunk version for testing, but the same plugins are available from the plugin site. In these cases WP considers the latest version to be the *most recently publish... | For example if you don't want Wordpress to show update notifications for akismet, you will do it like:
```
function filter_plugin_updates( $value ) {
unset( $value->response['akismet/akismet.php'] );
return $value;
}
add_filter( 'site_transient_update_plugins', 'filter_plugin_updates' );
``` |
20,590 | <p>I have to insert posts programatically in Wordpress. I want that I should be able to publish posts via a url. Something like www.mypage.com/insertnewpost.php?title=blah&content=blahblahblah&category=1,2,3</p>
<p>The following code works only if I use it inside the functions.php file of the themes. </p>
<pr... | [
{
"answer_id": 20591,
"author": "Rakesh Sankar",
"author_id": 7237,
"author_profile": "https://wordpress.stackexchange.com/users/7237",
"pm_score": 0,
"selected": false,
"text": "<p>Hope the answer on this link is useful.</p>\n\n<p><a href=\"https://stackoverflow.com/questions/3947979/fa... | 2011/06/20 | [
"https://wordpress.stackexchange.com/questions/20590",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6398/"
] | I have to insert posts programatically in Wordpress. I want that I should be able to publish posts via a url. Something like www.mypage.com/insertnewpost.php?title=blah&content=blahblahblah&category=1,2,3
The following code works only if I use it inside the functions.php file of the themes.
```
include '../../../wp-... | I finally got the answer to the problem.
To make *this* code work:
```
global $user_ID;
$new_post = array(
'post_title' => 'My New Post',
'post_content' => 'Lorem ipsum dolor sit amet...',
'post_status' => 'publish',
'post_date' => date('Y-m-d H:i:s'),
'post_author' => $user_ID,
'post_type' => 'post',
'post_category'... |
20,612 | <p>I have this piece of code that works great: it retrieves a particular page from my WordPress database so I can wrap custom code around it in a template. In the instance below it grabs the page called Showreel:</p>
<pre><code> <?php
$page = get_page_by_title('Showreel');
?>
... | [
{
"answer_id": 20613,
"author": "baraboom",
"author_id": 6370,
"author_profile": "https://wordpress.stackexchange.com/users/6370",
"pm_score": 1,
"selected": false,
"text": "<p>As you already discovered, the get_page_by_title function does not accept arguments in that fashion. However, i... | 2011/06/21 | [
"https://wordpress.stackexchange.com/questions/20612",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6374/"
] | I have this piece of code that works great: it retrieves a particular page from my WordPress database so I can wrap custom code around it in a template. In the instance below it grabs the page called Showreel:
```
<?php
$page = get_page_by_title('Showreel');
?>
<?php
... | have a look at:
```
get_page_by_path()
```
codex.wordpress.org/Function\_Reference/get\_page\_by\_path |
20,617 | <p>My code validates and returns the custom field value. However, I can't get the value to return inside of the anchors.</p>
<p>Here is the code:</p>
<pre><code><div id="meta_mblink">
<?
if(function_exists('get_custom_field_data')) {
echo '<a href="'.get_custom_field_data('mblink', true).'"></a>'... | [
{
"answer_id": 20619,
"author": "Rev. Voodoo",
"author_id": 3429,
"author_profile": "https://wordpress.stackexchange.com/users/3429",
"pm_score": 0,
"selected": false,
"text": "<pre><code><div id=\"meta_mblink\">\n <?php\n if(function_exists('get_custom_field_data')) {\n ?>\n... | 2011/06/21 | [
"https://wordpress.stackexchange.com/questions/20617",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4499/"
] | My code validates and returns the custom field value. However, I can't get the value to return inside of the anchors.
Here is the code:
```
<div id="meta_mblink">
<?
if(function_exists('get_custom_field_data')) {
echo '<a href="'.get_custom_field_data('mblink', true).'"></a>';
}
?>
</div>
```
This is what is retur... | This is how I would code this:
```
$url = get_post_meta( get_the_ID(), 'mblink', true );
if ( ! empty( $url ) ) {
print '<a href="' . esc_url( $url ) . '">MBLINK</a>';
}
``` |
20,618 | <p>I've been searching for how to do this for a while but to no avail. Part of my template is using a lot of the same code, i.e. retrieving a specific page.</p>
<p>If this was Javascript I'd set up a function and keep calling the function. How can I call the code below repeatedly?</p>
<pre><code><?php
$page = ... | [
{
"answer_id": 20619,
"author": "Rev. Voodoo",
"author_id": 3429,
"author_profile": "https://wordpress.stackexchange.com/users/3429",
"pm_score": 0,
"selected": false,
"text": "<pre><code><div id=\"meta_mblink\">\n <?php\n if(function_exists('get_custom_field_data')) {\n ?>\n... | 2011/06/21 | [
"https://wordpress.stackexchange.com/questions/20618",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6374/"
] | I've been searching for how to do this for a while but to no avail. Part of my template is using a lot of the same code, i.e. retrieving a specific page.
If this was Javascript I'd set up a function and keep calling the function. How can I call the code below repeatedly?
```
<?php
$page = get_page_by_title('Excer... | This is how I would code this:
```
$url = get_post_meta( get_the_ID(), 'mblink', true );
if ( ! empty( $url ) ) {
print '<a href="' . esc_url( $url ) . '">MBLINK</a>';
}
``` |
20,622 | <p>I've got a multi-author site running on Wordpress 3.1.3 . </p>
<p>I'm trying to place an extra header above the title for a specific author. So if "John" posts on the blog, it would have an above the post on the home page that says "John's Perpective", or something of that nature. The idea is that we want one of t... | [
{
"answer_id": 20624,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 1,
"selected": true,
"text": "<p>When you're in the loop, you can use <a href=\"http://codex.wordpress.org/Function_Reference/get_the_author\" rel=\"no... | 2011/06/21 | [
"https://wordpress.stackexchange.com/questions/20622",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6376/"
] | I've got a multi-author site running on Wordpress 3.1.3 .
I'm trying to place an extra header above the title for a specific author. So if "John" posts on the blog, it would have an above the post on the home page that says "John's Perpective", or something of that nature. The idea is that we want one of the many aut... | When you're in the loop, you can use [`get_the_author()`](http://codex.wordpress.org/Function_Reference/get_the_author) to get the author's 'Public' name. Alternatively, you can use `get_the_author_meta( 'ID' )` in the loop to get the author ID.
So, modifying your psuedo-code:
```
if ( 2 == get_the_author_meta( 'ID' ... |
20,650 | <p>I have created a custom post type, but it just to list some data on a page and it doesn't have any single.php.</p>
<p>How do i disable so on the post page when i click publish it doesn't show the "View Page" link and also how do i disable the "View" link in the columns for that post type.</p>
<p>Thanks</p>
| [
{
"answer_id": 119088,
"author": "Matt",
"author_id": 25075,
"author_profile": "https://wordpress.stackexchange.com/users/25075",
"pm_score": 2,
"selected": false,
"text": "<p>The previous answer is incorrect. The message at the top of a post edit page cannot be modified using labels. Yo... | 2011/06/22 | [
"https://wordpress.stackexchange.com/questions/20650",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6386/"
] | I have created a custom post type, but it just to list some data on a page and it doesn't have any single.php.
How do i disable so on the post page when i click publish it doesn't show the "View Page" link and also how do i disable the "View" link in the columns for that post type.
Thanks | Changing the `public` argument of `register_post_type()` will remove the link to view your custom post type publicly.
```
'public' => false,
```
See: [WordPress Codex](http://codex.wordpress.org/Function_Reference/register_post_type#Arguments)
Note that this will also hide your custom post type from the admin navi... |
20,654 | <p>I've tried a number of solutions available on the internet, but none seem to work in WP 3.1.1.</p>
<p>Thanks!</p>
| [
{
"answer_id": 20671,
"author": "onetrickpony",
"author_id": 1986,
"author_profile": "https://wordpress.stackexchange.com/users/1986",
"pm_score": 3,
"selected": true,
"text": "<pre><code>remove_action('wp_head', 'feed_links', 2); \nadd_action('wp_head', 'my_feed_links');\n\nfunction my_... | 2011/06/22 | [
"https://wordpress.stackexchange.com/questions/20654",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1826/"
] | I've tried a number of solutions available on the internet, but none seem to work in WP 3.1.1.
Thanks! | ```
remove_action('wp_head', 'feed_links', 2);
add_action('wp_head', 'my_feed_links');
function my_feed_links() {
if ( !current_theme_supports('automatic-feed-links') ) return;
// post feed
?>
<link rel="alternate" type="<?php echo feed_content_type(); ?>"
title="<?php printf(__('%1$s %2$s Feed'), ... |
20,665 | <p>I am using <a href="http://wordpress.org/extend/plugins/si-contact-form/" rel="nofollow noreferrer"> Fast Secure Contact Form plugin</a> to create contact form widget.It working fine . Now i like to change captcha appearance.</p>
<p>Original captcha generated by plugin</p>
<p><img src="https://i.stack.imgur.com/g9... | [
{
"answer_id": 20668,
"author": "onetrickpony",
"author_id": 1986,
"author_profile": "https://wordpress.stackexchange.com/users/1986",
"pm_score": 2,
"selected": false,
"text": "<p>First, you should know that a image like that is very easy to read by almost any OCR. The first one is much... | 2011/06/22 | [
"https://wordpress.stackexchange.com/questions/20665",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4022/"
] | I am using [Fast Secure Contact Form plugin](http://wordpress.org/extend/plugins/si-contact-form/) to create contact form widget.It working fine . Now i like to change captcha appearance.
Original captcha generated by plugin

But, I need to c... | First, you should know that a image like that is very easy to read by almost any OCR. The first one is much more hard to crack.
Anyway, if you don't want to hack the existing plugin, you can use [Really Simple Captcha](http://wordpress.org/extend/plugins/really-simple-captcha/), it looks exactly like that.
In your fo... |
20,677 | <p>I'm fairly new to wordpress. I'm trying to develop a website with search option to find available room information.</p>
<p>I would like to add a search box where people would be able to enter their information and hit the Search button. Then it'll display the available rooms. Something like the below website</p>
<... | [
{
"answer_id": 20684,
"author": "Ramkumar M",
"author_id": 5669,
"author_profile": "https://wordpress.stackexchange.com/users/5669",
"pm_score": 0,
"selected": false,
"text": "<p>Please add this to your header.php file beside the RSS icon.</p>\n\n<pre><code><form method=\"get\" id=\"s... | 2011/06/22 | [
"https://wordpress.stackexchange.com/questions/20677",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6400/"
] | I'm fairly new to wordpress. I'm trying to develop a website with search option to find available room information.
I would like to add a search box where people would be able to enter their information and hit the Search button. Then it'll display the available rooms. Something like the below website
<http://www.eas... | I just wanted to add two small things for other peoples....
if your template supports it you can just add :
```
<?php include (TEMPLATEPATH . '/searchform.php'); ?>
```
2.adding the following code will put a text inside the search box. (like "Write your search and hit Enter" )
```
<form method="get" id="searchform... |
20,692 | <p>Is it possible to add some html after a set amount of posts?</p>
<p>For the purposes of a slider after 6 posts i need it to enclose in a div/li or whatever then start a new div/li for the next 6 and so on.</p>
<p>Here is my custom query which just prints the post name in a list.</p>
<pre><code><ul>
<?ph... | [
{
"answer_id": 20700,
"author": "mfields",
"author_id": 11019,
"author_profile": "https://wordpress.stackexchange.com/users/11019",
"pm_score": 2,
"selected": true,
"text": "<p>Here's one way of doing it:</p>\n\n<pre><code><?php\n$courses = get_posts( array(\n 'post_type' => 'co... | 2011/06/22 | [
"https://wordpress.stackexchange.com/questions/20692",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4630/"
] | Is it possible to add some html after a set amount of posts?
For the purposes of a slider after 6 posts i need it to enclose in a div/li or whatever then start a new div/li for the next 6 and so on.
Here is my custom query which just prints the post name in a list.
```
<ul>
<?php $args=array('post_type' => 'courses... | Here's one way of doing it:
```
<?php
$courses = get_posts( array(
'post_type' => 'courses',
'posts_per_page' => -1
) );
if ( $courses ) {
print "\n" . '<div style="background:pink">';
foreach ( $courses as $course_count => $post ) {
setup_postdata( $post );
the_title( "\n", '<br>'... |
20,702 | <p>I'm using a lot of thumbnails but never the original file. To save space, I'd like to prevent the original from being saved on disk but only keep a thumbnail of 100px. How can I do this?</p>
<p>Thanks,
Dennis</p>
| [
{
"answer_id": 24921,
"author": "Cristian",
"author_id": 2264,
"author_profile": "https://wordpress.stackexchange.com/users/2264",
"pm_score": 5,
"selected": true,
"text": "<pre><code>add_filter( 'wp_generate_attachment_metadata', 'delete_fullsize_image' );\nfunction delete_fullsize_imag... | 2011/06/22 | [
"https://wordpress.stackexchange.com/questions/20702",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4284/"
] | I'm using a lot of thumbnails but never the original file. To save space, I'd like to prevent the original from being saved on disk but only keep a thumbnail of 100px. How can I do this?
Thanks,
Dennis | ```
add_filter( 'wp_generate_attachment_metadata', 'delete_fullsize_image' );
function delete_fullsize_image( $metadata )
{
$upload_dir = wp_upload_dir();
$full_image_path = trailingslashit( $upload_dir['basedir'] ) . $metadata['file'];
$deleted = unlink( $full_image_path );
return $metadata;
}
``` |
20,706 | <p>I am relatively new to Wordpress, have been handed a site developed by someone else on one server, and have to deploy it to another. This site has bbpress installed, plus a load of other stuff. However it also seems to contain (somewhere) references to the other developers server, so even though I have copied the si... | [
{
"answer_id": 20708,
"author": "Scott",
"author_id": 4610,
"author_profile": "https://wordpress.stackexchange.com/users/4610",
"pm_score": 1,
"selected": false,
"text": "<p>There is most probably a load of references still in the database.</p>\n\n<p>How I would change the references wou... | 2011/06/22 | [
"https://wordpress.stackexchange.com/questions/20706",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3425/"
] | I am relatively new to Wordpress, have been handed a site developed by someone else on one server, and have to deploy it to another. This site has bbpress installed, plus a load of other stuff. However it also seems to contain (somewhere) references to the other developers server, so even though I have copied the site ... | There might be hardcoded links in the theme; download it and do a multifile search with a text editor.
Editing the text dump destroys serialized data; see another Q/A here: [Why is my database import losing text widget data?](https://wordpress.stackexchange.com/questions/9076/why-is-my-database-import-losing-text-widg... |
20,722 | <p>I added <code>'supports' => 'page-attributes'</code> to my custom post type, and now i have the meta box for page ordering.</p>
<p>When i use the argument <code>'sort_column' => 'menu_order'</code> with <code>get_pages()</code> on my custom post type, everything orders properly.</p>
<p>So why do the custom p... | [
{
"answer_id": 24012,
"author": "Scott",
"author_id": 4610,
"author_profile": "https://wordpress.stackexchange.com/users/4610",
"pm_score": 5,
"selected": true,
"text": "<p>I've just had to do the same thing as you, here is what I did to get this working:</p>\n\n<p><code>'supports' =>... | 2011/06/22 | [
"https://wordpress.stackexchange.com/questions/20722",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5140/"
] | I added `'supports' => 'page-attributes'` to my custom post type, and now i have the meta box for page ordering.
When i use the argument `'sort_column' => 'menu_order'` with `get_pages()` on my custom post type, everything orders properly.
So why do the custom pages not order properly when i query the posts using `qu... | I've just had to do the same thing as you, here is what I did to get this working:
`'supports' => array('title', 'editor', 'thumbnail', 'page-attributes')`
Register the post type with supports of page attributes. This adds the menu order meta box to the edit screen. From there you can place the order.
Then run my cu... |
20,723 | <p>This is the oddest thing I've ever seen on wordpress. Here's my problem: </p>
<p>I have a whole ton of text. But the last few lines I have this: </p>
<blockquote>
<p>< blockquote>[Laughs] I'm doing the
exact same thing I'm doin' live. Plug
in, turn it up, turn on the machine
and play. I don't overdub an... | [
{
"answer_id": 24012,
"author": "Scott",
"author_id": 4610,
"author_profile": "https://wordpress.stackexchange.com/users/4610",
"pm_score": 5,
"selected": true,
"text": "<p>I've just had to do the same thing as you, here is what I did to get this working:</p>\n\n<p><code>'supports' =>... | 2011/06/22 | [
"https://wordpress.stackexchange.com/questions/20723",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6378/"
] | This is the oddest thing I've ever seen on wordpress. Here's my problem:
I have a whole ton of text. But the last few lines I have this:
>
> < blockquote>[Laughs] I'm doing the
> exact same thing I'm doin' live. Plug
> in, turn it up, turn on the machine
> and play. I don't overdub anything. I
> ain't going ba... | I've just had to do the same thing as you, here is what I did to get this working:
`'supports' => array('title', 'editor', 'thumbnail', 'page-attributes')`
Register the post type with supports of page attributes. This adds the menu order meta box to the edit screen. From there you can place the order.
Then run my cu... |
20,724 | <p>I'm about to upgrade my Wordpress MU installation to wordpress 3</p>
<p>Before I update, I want to find out which blogs use which plugins.</p>
<p>I don't see a way to do that in the UI, is there?</p>
<p>What about a query of the mysql database?</p>
<p>Thanks</p>
| [
{
"answer_id": 24012,
"author": "Scott",
"author_id": 4610,
"author_profile": "https://wordpress.stackexchange.com/users/4610",
"pm_score": 5,
"selected": true,
"text": "<p>I've just had to do the same thing as you, here is what I did to get this working:</p>\n\n<p><code>'supports' =>... | 2011/06/22 | [
"https://wordpress.stackexchange.com/questions/20724",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3058/"
] | I'm about to upgrade my Wordpress MU installation to wordpress 3
Before I update, I want to find out which blogs use which plugins.
I don't see a way to do that in the UI, is there?
What about a query of the mysql database?
Thanks | I've just had to do the same thing as you, here is what I did to get this working:
`'supports' => array('title', 'editor', 'thumbnail', 'page-attributes')`
Register the post type with supports of page attributes. This adds the menu order meta box to the edit screen. From there you can place the order.
Then run my cu... |
20,729 | <p>I don't know how to make a plugin so I can't do what's suggested here <a href="https://wordpress.stackexchange.com/questions/15046/how-can-i-make-it-so-the-add-new-post-page-has-visibility-set-to-private-by-defau">How can I make it so the Add New Post page has Visibility set to Private by default?</a></p>
<p>so wha... | [
{
"answer_id": 20733,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 1,
"selected": false,
"text": "<p>The alternative would be to find someone else to make a plugin.</p>\n\n<p>If you're using WordPress.com (meaning you ... | 2011/06/22 | [
"https://wordpress.stackexchange.com/questions/20729",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4078/"
] | I don't know how to make a plugin so I can't do what's suggested here [How can I make it so the Add New Post page has Visibility set to Private by default?](https://wordpress.stackexchange.com/questions/15046/how-can-i-make-it-so-the-add-new-post-page-has-visibility-set-to-private-by-defau)
so what's alternative ? | Accepted solution is not the correct answer to change the visibility of any post type to any status. Below code is the right way to change the post status.
```
function set_post_type_status_private( $status, $post_id ) {
$status = 'private';
return $status;
}
add_filter( 'status_edit_pre', 'set_post_type_statu... |
20,731 | <p>How do I count the number of media attachments a specific post has?</p>
<p>Output example: This post has 22 photos.</p>
<p>Thanks!</p>
| [
{
"answer_id": 20732,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 3,
"selected": true,
"text": "<p>Use this code if you're in the loop:</p>\n\n<pre><code>$attachments = get_children( array( 'post_parent' => $post-&... | 2011/06/22 | [
"https://wordpress.stackexchange.com/questions/20731",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1057/"
] | How do I count the number of media attachments a specific post has?
Output example: This post has 22 photos.
Thanks! | Use this code if you're in the loop:
```
$attachments = get_children( array( 'post_parent' => $post->ID ) );
$count = count( $attachments );
```
If you're not in the loop, substitute `$post->ID` with the ID of the specific post. But that should count all attachments. |
20,738 | <p>I'm looking to draw a menu listing of the latest "n" number posts, where the number "n" will be a user defined setting stored as an option.</p>
<p>n = 5; //Pull the latest 5 posts from the database.</p>
<p>The script I'm currently using (below) pulls all of the posts from the database and then only displays the la... | [
{
"answer_id": 20739,
"author": "Mild Fuzz",
"author_id": 784,
"author_profile": "https://wordpress.stackexchange.com/users/784",
"pm_score": 3,
"selected": true,
"text": "<p><code>$yourquery = new WP_Query('posts_per_page=5&orderby=title');</code> would do that.</p>\n\n<hr>\n\n<p><s... | 2011/06/22 | [
"https://wordpress.stackexchange.com/questions/20738",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/366/"
] | I'm looking to draw a menu listing of the latest "n" number posts, where the number "n" will be a user defined setting stored as an option.
n = 5; //Pull the latest 5 posts from the database.
The script I'm currently using (below) pulls all of the posts from the database and then only displays the latest 5 out of tha... | `$yourquery = new WP_Query('posts_per_page=5&orderby=title');` would do that.
---
**Edit** *Added Answer*
```
<?php
$posts = new WP_Query('posts_per_page=5');
foreach($posts->posts as $post){
$sorted[$post->ID] = $post->post_title;
}
asort($sorted, SORT_STRING);
foreach($sorted as $k=>$v){
//your loop... |
20,754 | <p>Quick and dirty, I have meta boxes pertaining to concert information. (i.e. venue and location) and am trying to figure out how to <strong>properly display</strong> them in my post. </p>
<p>At the moment to display the meta-box data I have </p>
<pre><code><?php
$venue_info = get_post_custom_values("venue_info"... | [
{
"answer_id": 20755,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 0,
"selected": false,
"text": "<p>I see you're storing venue and location both under the \"venue_info\" key, how do you differentiate between the two... | 2011/06/22 | [
"https://wordpress.stackexchange.com/questions/20754",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6423/"
] | Quick and dirty, I have meta boxes pertaining to concert information. (i.e. venue and location) and am trying to figure out how to **properly display** them in my post.
At the moment to display the meta-box data I have
```
<?php
$venue_info = get_post_custom_values("venue_info");
if (isset($venue_info[0])) {
... | ### To check for meta key value then display:
```
if ( get_post_meta( $post->ID, 'venue_info', true ) ) : echo get_post_meta( $post->ID, 'venue_info', true )
endif;
```
via: [The Codex](http://codex.wordpress.org/Function_Reference/get_post_meta) |
20,758 | <p>Good day!
I don't know much code so I've been researching on how to modify my wp-config.php file so that the content and widgets of my site will show in the four languages (aside from English) I have on there. I don't care about translating the WP interface, just the content. The WP .mo files in the languages in que... | [
{
"answer_id": 20773,
"author": "anmari",
"author_id": 3569,
"author_profile": "https://wordpress.stackexchange.com/users/3569",
"pm_score": 1,
"selected": false,
"text": "<p>if you are somehow using .mo files to translate the content strings (and your theme is calling the necessary __()... | 2011/06/23 | [
"https://wordpress.stackexchange.com/questions/20758",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6425/"
] | Good day!
I don't know much code so I've been researching on how to modify my wp-config.php file so that the content and widgets of my site will show in the four languages (aside from English) I have on there. I don't care about translating the WP interface, just the content. The WP .mo files in the languages in questi... | I just found this which I applied and works perfectly:
If you have your blogs installed in subdirectories you could use this solution:
```
if (strpos($_SERVER['REQUEST_URI'], '/enblog') === 0) {
define ('WPLANG', 'en_US');
} else {
define ('WPLANG', 'pl_PL');
}
```
... and so on. Good luck! |
20,762 | <p>I am creating a contact form page. Perhaps I am doing it wrong? I have something like</p>
<pre><code><?php
// even when I remove this validation block it fails
if (isset($_POST['name'])) {
// do validation ...
}
get_header();
?>
...
<form id="frmContact" action="<?php the_permalink() ?>" metho... | [
{
"answer_id": 20773,
"author": "anmari",
"author_id": 3569,
"author_profile": "https://wordpress.stackexchange.com/users/3569",
"pm_score": 1,
"selected": false,
"text": "<p>if you are somehow using .mo files to translate the content strings (and your theme is calling the necessary __()... | 2011/06/23 | [
"https://wordpress.stackexchange.com/questions/20762",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3788/"
] | I am creating a contact form page. Perhaps I am doing it wrong? I have something like
```
<?php
// even when I remove this validation block it fails
if (isset($_POST['name'])) {
// do validation ...
}
get_header();
?>
...
<form id="frmContact" action="<?php the_permalink() ?>" method="post">
...
</form>
..... | I just found this which I applied and works perfectly:
If you have your blogs installed in subdirectories you could use this solution:
```
if (strpos($_SERVER['REQUEST_URI'], '/enblog') === 0) {
define ('WPLANG', 'en_US');
} else {
define ('WPLANG', 'pl_PL');
}
```
... and so on. Good luck! |
20,766 | <p>The user starts at a page showing posts of custom post type, "agent".</p>
<p>Each post displayed shows a region/custom taxonomy it belongs to and links to a page that shows all posts in the region the user clicked.</p>
<p>This is how these posts are currently displayed,</p>
<pre><code><?php while ( have_posts(... | [
{
"answer_id": 20767,
"author": "mfields",
"author_id": 11019,
"author_profile": "https://wordpress.stackexchange.com/users/11019",
"pm_score": 1,
"selected": false,
"text": "<p>Maybe try something like this before the loop:</p>\n\n<pre><code><?php\nquery_posts( wp_parse_args( $query_... | 2011/06/23 | [
"https://wordpress.stackexchange.com/questions/20766",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4090/"
] | The user starts at a page showing posts of custom post type, "agent".
Each post displayed shows a region/custom taxonomy it belongs to and links to a page that shows all posts in the region the user clicked.
This is how these posts are currently displayed,
```
<?php while ( have_posts() ) : the_post(); ?>
```
Idea... | This is what ended up working.
```
global $wp_query;
query_posts(array_merge(array('orderby' => 'meta_value', 'meta_key' => 'rw_lname' ),$wp_query->query));
<?php while ( have_posts() ) : the_post(); ?>
``` |
20,784 | <p>I'm very new to WordPress, especially when it comes to creating a custom loop as per below. This works fine, however I'm perplexed why "Blog pages show at most" (under Settings > Reading) is interfering with the query.</p>
<p>In the example below, I have post_per_page set at 10. If I leave the default "Blog pages s... | [
{
"answer_id": 20814,
"author": "Scott",
"author_id": 4610,
"author_profile": "https://wordpress.stackexchange.com/users/4610",
"pm_score": 1,
"selected": false,
"text": "<pre><code><?php\nglobal $query_string;\n$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;\n$custom_... | 2011/06/23 | [
"https://wordpress.stackexchange.com/questions/20784",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4999/"
] | I'm very new to WordPress, especially when it comes to creating a custom loop as per below. This works fine, however I'm perplexed why "Blog pages show at most" (under Settings > Reading) is interfering with the query.
In the example below, I have post\_per\_page set at 10. If I leave the default "Blog pages show at m... | see: <http://scribu.net/wordpress/wp-pagenavi/wpn-2-74.html> |
20,785 | <p>I want to get the original image with the same width and height as uploaded. </p>
<p>My original image is 630*370. </p>
<p>Using the following function call I get a thumbnail sized at 630*198.</p>
<pre class="lang-php prettyprint-override"><code>wp_get_attachment_image_src($PriImgId,array('630','370'));
</code><... | [
{
"answer_id": 20787,
"author": "mike23",
"author_id": 1381,
"author_profile": "https://wordpress.stackexchange.com/users/1381",
"pm_score": 7,
"selected": true,
"text": "<p>Try this : </p>\n\n<pre><code>wp_get_attachment_image_src( $PriImgId, 'full' );\n</code></pre>\n\n<p>Also, for mor... | 2011/06/23 | [
"https://wordpress.stackexchange.com/questions/20785",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4022/"
] | I want to get the original image with the same width and height as uploaded.
My original image is 630\*370.
Using the following function call I get a thumbnail sized at 630\*198.
```php
wp_get_attachment_image_src($PriImgId,array('630','370'));
```
How can I get it at 630\*370 | Try this :
```
wp_get_attachment_image_src( $PriImgId, 'full' );
```
Also, for more options see the [Codex](http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src). |
20,789 | <p>I'm working on WordPress where I have following code to get posts within loop.</p>
<pre><code> <?php
$posts = $woo_options['woo_latest_entries'];
query_posts('post_type=post&category_name=company');
if ( have_posts() ) : while ( have_posts() ) : the_post... | [
{
"answer_id": 20796,
"author": "mike23",
"author_id": 1381,
"author_profile": "https://wordpress.stackexchange.com/users/1381",
"pm_score": 2,
"selected": false,
"text": "<p>If it's just an esthetic thing and you don't need to use the count variable for further coding, you can just wrap... | 2011/06/23 | [
"https://wordpress.stackexchange.com/questions/20789",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3190/"
] | I'm working on WordPress where I have following code to get posts within loop.
```
<?php
$posts = $woo_options['woo_latest_entries'];
query_posts('post_type=post&category_name=company');
if ( have_posts() ) : while ( have_posts() ) : the_post(); $count++;
... | >
> Actually I want to assign ID's as per post index !
>
>
>
Here's your code that I modified.
```
<?php
global $wp_query;
$posts = $woo_options['woo_latest_entries'];
query_posts('post_type=post&category_name=company');
if ( have_posts() ) : while ( have_posts() ) : the_post(); $count++;
$index = $wp_qu... |
20,797 | <p>I have multiple values I need to be able to punch into a meta-box on the post edit screen. </p>
<p>EX: I am working with set-list information for concerts. </p>
<ol>
<li>Song 1</li>
<li>Song 2</li>
<li>Song 3</li>
</ol>
<p>etc...</p>
<p>I am always looking for efficiency in my code, here's the point:</p>
<p>Do ... | [
{
"answer_id": 20801,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": true,
"text": "<p>I believe that your best option would be to create a single field and save all values in an array, something l... | 2011/06/23 | [
"https://wordpress.stackexchange.com/questions/20797",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6423/"
] | I have multiple values I need to be able to punch into a meta-box on the post edit screen.
EX: I am working with set-list information for concerts.
1. Song 1
2. Song 2
3. Song 3
etc...
I am always looking for efficiency in my code, here's the point:
Do I just create a brand new id (i.e. song\_1, song\_2) for eve... | I believe that your best option would be to create a single field and save all values in an array, something like this: [**Create more Meta Boxes as needed**](https://wordpress.stackexchange.com/questions/19838/create-more-meta-boxes-as-needed/19852#19852). |
20,798 | <p>I am using.</p>
<pre><code><?php wp_nav_menu($args); ?>
</code></pre>
<p>to get menu from WordPress.</p>
<p>It returns the menus with <code><ul> and <li></code> structure.<br>
How can i set class name for every <code><li></code> tag uniquely.</p>
| [
{
"answer_id": 20799,
"author": "keatch",
"author_id": 2727,
"author_profile": "https://wordpress.stackexchange.com/users/2727",
"pm_score": 1,
"selected": false,
"text": "<p>You can use the CSS class for the menu.<br>\nUnder \"Screen Options\", flag \"<strong>CSS Classes</strong>\", und... | 2011/06/23 | [
"https://wordpress.stackexchange.com/questions/20798",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6245/"
] | I am using.
```
<?php wp_nav_menu($args); ?>
```
to get menu from WordPress.
It returns the menus with `<ul> and <li>` structure.
How can i set class name for every `<li>` tag uniquely. | You can use the CSS class for the menu.
Under "Screen Options", flag "**CSS Classes**", under "Show Advanced Properties".
Then, for every menu item, you have an additional input that is named "CSS Classes" |
20,815 | <p>Right, I'm banging my head against a wall here. I'm sure it's something incredibly simple but I keep getting undefined index errors on all of these variables.</p>
<pre><code>function meta_genus_species() {
global $post;
if (isset($post)) {
$custom = get_post_custom($post->ID);
}
if (iss... | [
{
"answer_id": 20817,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 4,
"selected": true,
"text": "<p>It's a common PHP error, usually when you try to access an array member with a non-existent key;</p>\n\n<pre... | 2011/06/23 | [
"https://wordpress.stackexchange.com/questions/20815",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6344/"
] | Right, I'm banging my head against a wall here. I'm sure it's something incredibly simple but I keep getting undefined index errors on all of these variables.
```
function meta_genus_species() {
global $post;
if (isset($post)) {
$custom = get_post_custom($post->ID);
}
if (isset($custom)) {
... | It's a common PHP error, usually when you try to access an array member with a non-existent key;
```
$array = array( 'hello' => 'world' );
echo $array['foobar']; // undefined index
```
You should check for the key first with `isset( $array['foobar'] );`
**UPDATE:** In this case, I would chuck in a loop that sets-up... |
20,819 | <p>I am using.</p>
<pre><code><?php wp_nav_menu($args); ?>
</code></pre>
<p>for get menu from wordpress.it returns the menus with <code><ul></code> and <code><li></code> structure. In that i need to set class name for every <code><li></code> tag uniquely.</p>
<p>thanks ravi</p>
| [
{
"answer_id": 20820,
"author": "Alex Thomas",
"author_id": 6243,
"author_profile": "https://wordpress.stackexchange.com/users/6243",
"pm_score": 1,
"selected": false,
"text": "<p>This should help you out buddy - <a href=\"http://wpveda.com/add-custom-classes-wpnavmenu-condition/\" rel=\... | 2011/06/23 | [
"https://wordpress.stackexchange.com/questions/20819",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6245/"
] | I am using.
```
<?php wp_nav_menu($args); ?>
```
for get menu from wordpress.it returns the menus with `<ul>` and `<li>` structure. In that i need to set class name for every `<li>` tag uniquely.
thanks ravi | More easily, you can just enter a unique class name on the admin menu page `/wp-admin/nav-menus.php`. You may need to look in the top right corner of the page for "Screen Options" and then enable CSS Classes. Then edit any menu item and add the class. |
20,833 | <p>i am new to wordpress so you can except a lot insane coding below. What i want is to give one option in the adminpanel of wordpress to my client under the Pages->MergeImage. when the client will click on MergeImage option appearing under the Pages Widget i want to display him my custom form . To achieve all the abov... | [
{
"answer_id": 20851,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p><code>add_options_page()</code> places the menu item under the Settings menu. I believe you'll find your plugin men... | 2011/06/23 | [
"https://wordpress.stackexchange.com/questions/20833",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5334/"
] | i am new to wordpress so you can except a lot insane coding below. What i want is to give one option in the adminpanel of wordpress to my client under the Pages->MergeImage. when the client will click on MergeImage option appearing under the Pages Widget i want to display him my custom form . To achieve all the above i... | You are using `add_options_page()` so this means that you are adding a page menu item under settings section of your WP admin menu. By the sounds of it you dont want to add your page there but you really want it to appear as a sub page of the `pages` menu. Am I correct in this assumption?
If that's the case you need t... |
20,835 | <p>It seems that none of the javascript is working when I log into the admin section of my site. I cannot do anything that requires javascript or AJAX : Nextgen thumbnails, Widget organisation, even the admin menu doesn't work.</p>
<p>The javascript in the front end of the site works as it should.</p>
<p>I looked in ... | [
{
"answer_id": 20838,
"author": "Dougal Campbell",
"author_id": 65,
"author_profile": "https://wordpress.stackexchange.com/users/65",
"pm_score": 2,
"selected": false,
"text": "<p>Most likely, you have a misbehaving plugin. Try disabling all plugins, then see if the problem goes away. If... | 2011/06/23 | [
"https://wordpress.stackexchange.com/questions/20835",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5232/"
] | It seems that none of the javascript is working when I log into the admin section of my site. I cannot do anything that requires javascript or AJAX : Nextgen thumbnails, Widget organisation, even the admin menu doesn't work.
The javascript in the front end of the site works as it should.
I looked in firebug for the s... | Script concatenation in admin area is normal behavior, but I am not sure that trying to load that many scripts is.
You can disable concatenation by defining `CONCATENATE_SCRIPTS` constant to `false`. In `wp-config.php` would be fitting:
```
define('CONCATENATE_SCRIPTS', false);
```
See [Disable\_Javascript\_Concat... |
20,854 | <p>I released a plugin that creates a shortcode and requires a JavaScript file and a CSS file to load on any page that contains that shortcode. I could just make the script/style load on all pages, but that's not the best practice. I only want to load the files on pages that call the shortcode. I've found two methods o... | [
{
"answer_id": 20856,
"author": "onetrickpony",
"author_id": 1986,
"author_profile": "https://wordpress.stackexchange.com/users/1986",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n <p>because CSS should be declared inside <code><head></code></p>\n</blockquote>\n\n<p>Fo... | 2011/06/23 | [
"https://wordpress.stackexchange.com/questions/20854",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3898/"
] | I released a plugin that creates a shortcode and requires a JavaScript file and a CSS file to load on any page that contains that shortcode. I could just make the script/style load on all pages, but that's not the best practice. I only want to load the files on pages that call the shortcode. I've found two methods of d... | Based on my own experience, I've used a combination of method 1 & 2 - the architecture and footer scripts of 1, and the 'look-ahead' technique of 2.
For the look-ahead though, I use regex in place of `stripos`; personal preference, faster, and can check for 'malformed' shortcode;
```
preg_match( '#\[ *shortcode([^\]]... |
20,857 | <p>I need to hide the branding section of my blog, but only when someone is viewing it from the iPad. I am not sure how to attack this. </p>
<p>EDIT: the function <code>remove_access</code> currently works in my template, but I need to add the iPad function.</p>
<p>So would this look correct for trying to hide the ar... | [
{
"answer_id": 20861,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>there's no foolproof method for doing this, but a quick and simple solution is to look at http user agent:</p>\n\n<p... | 2011/06/23 | [
"https://wordpress.stackexchange.com/questions/20857",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4273/"
] | I need to hide the branding section of my blog, but only when someone is viewing it from the iPad. I am not sure how to attack this.
EDIT: the function `remove_access` currently works in my template, but I need to add the iPad function.
So would this look correct for trying to hide the area:
```
<?php
function rem... | there's no foolproof method for doing this, but a quick and simple solution is to look at http user agent:
```
<?php
if( preg_match('/ipad/i',$_SERVER['HTTP_USER_AGENT']) ):
echo "is iPad";
endif;
``` |
20,865 | <p>We're creating a site where we want guest users to add pages to a favourites list (post IDs), so they can print or email their selection if they want.</p>
<p>What would the best way be to do this in WordPress? I think ajax but I'm not too sure how to save it in the WordPress framework.</p>
| [
{
"answer_id": 20871,
"author": "GavinR",
"author_id": 2001,
"author_profile": "https://wordpress.stackexchange.com/users/2001",
"pm_score": 0,
"selected": false,
"text": "<p>You can save the information directly to a database table, so you'd have a table of userIDs associated with postI... | 2011/06/23 | [
"https://wordpress.stackexchange.com/questions/20865",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3978/"
] | We're creating a site where we want guest users to add pages to a favourites list (post IDs), so they can print or email their selection if they want.
What would the best way be to do this in WordPress? I think ajax but I'm not too sure how to save it in the WordPress framework. | Cookies, or even HTML5 [local storage](http://diveintohtml5.info/storage.html), seem like a good way to implement this. Here's some basic code that could serve as a starting point. Post IDs are stored as CSV in the cookie.
```
// Load current favourite posts from cookie
$favposts = (isset($_COOKIE['favposts'])) ? expl... |
20,873 | <p>This is the code im using in my functions file:</p>
<pre><code>add_action('init', 'sort_out_jquery_pngfix_frontend');
function sort_out_jquery_pngfix_frontend() {
global $wp_scripts;
if(!is_admin()) {
wp_deregister_script('jquery');
wp_register_script('jquery', 'https://ajax.googleapis.com/a... | [
{
"answer_id": 20875,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 4,
"selected": true,
"text": "<p>From quick look at code this conditional only seems to be processed for styles and not scripts.</p>\n"
},
{
"... | 2011/06/23 | [
"https://wordpress.stackexchange.com/questions/20873",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4610/"
] | This is the code im using in my functions file:
```
add_action('init', 'sort_out_jquery_pngfix_frontend');
function sort_out_jquery_pngfix_frontend() {
global $wp_scripts;
if(!is_admin()) {
wp_deregister_script('jquery');
wp_register_script('jquery', 'https://ajax.googleapis.com/ajax/libs/jquer... | From quick look at code this conditional only seems to be processed for styles and not scripts. |
20,876 | <p>What I'm trying to do is use <a href="http://lesscss.org/">less css</a> with Wordpress.</p>
<p>You're supposed to link to your .less files with the rel attribute set to 'stylesheet/less'. But I can't figure out how to alter the code that enqueue_style outputs.</p>
<p>Is there a way to apply a filter and affect th... | [
{
"answer_id": 20879,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 4,
"selected": true,
"text": "<p>Yep, final style link output is passed through <code>style_loader_tag</code> filter.</p>\n"
},
{
"answer_id":... | 2011/06/23 | [
"https://wordpress.stackexchange.com/questions/20876",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6449/"
] | What I'm trying to do is use [less css](http://lesscss.org/) with Wordpress.
You're supposed to link to your .less files with the rel attribute set to 'stylesheet/less'. But I can't figure out how to alter the code that enqueue\_style outputs.
Is there a way to apply a filter and affect the output?
EDIT: If anyone i... | Yep, final style link output is passed through `style_loader_tag` filter. |
20,882 | <p>Can anyone tell me what the "<code>$handle</code>" ( first parameter ) of <code>wp_localize_script</code> is normally used for. Thanks.</p>
<p>P.s.: I have no idea why but stackexchange is telling me this question dosen't meet quality standards.</p>
<p>Edit: When i put in my ps it accepted it so i suppose it's the... | [
{
"answer_id": 20884,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>The handle is arbitrary (as in not technically meaningful) name of script that is used for human convenience when de... | 2011/06/23 | [
"https://wordpress.stackexchange.com/questions/20882",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6169/"
] | Can anyone tell me what the "`$handle`" ( first parameter ) of `wp_localize_script` is normally used for. Thanks.
P.s.: I have no idea why but stackexchange is telling me this question dosen't meet quality standards.
Edit: When i put in my ps it accepted it so i suppose it's the length of the quesion.... if you feel ... | It's basically a unique id of the script you registered or enqueued before.
Let's say we enqueued a two scripts with [wp\_enqueue\_script()](http://codex.wordpress.org/Function_Reference/wp_enqueue_script):
```
wp_enqueue_script( 'my_script_1','/js/some_script.js' );
wp_enqueue_script( 'my_script_2','/js/some_other_... |
20,912 | <p>I have a page that displays posts (4 on each row), with a thumbnail image & title for each. Is it possible to click a text/icon link and dynamically switch the page template? I'm looking to provide an alternate view of the posts, perhaps with larger images, more text/custom fields added etc.</p>
<p>I thought it... | [
{
"answer_id": 20914,
"author": "user6428",
"author_id": 6428,
"author_profile": "https://wordpress.stackexchange.com/users/6428",
"pm_score": 0,
"selected": false,
"text": "<p>It can be achieved with jquery slider or tabs, instead of page template where URL will change. Just need to wor... | 2011/06/24 | [
"https://wordpress.stackexchange.com/questions/20912",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4999/"
] | I have a page that displays posts (4 on each row), with a thumbnail image & title for each. Is it possible to click a text/icon link and dynamically switch the page template? I'm looking to provide an alternate view of the posts, perhaps with larger images, more text/custom fields added etc.
I thought it would be easy... | I think I have a workable solution on what I was trying to do. This works but is there a better way? Also are there any implications I should be aware of when using $\_GET? Didn't realize it would be this easy :) perhaps I'm missing something.
```
<?php $view = $_GET["view"]; ?>
```
Then if the URL is domain.com/pag... |
20,915 | <p>Asked this question on StackOverflow and they directed me over yonder... nice place ya got here =)</p>
<p>I've been developing a pretty simple WordPress plugin, and wanted to do some live validation of certain fields on the page, which is where I am stuck. I've been looking everywhere for something that worked, and... | [
{
"answer_id": 20916,
"author": "Hameedullah Khan",
"author_id": 5337,
"author_profile": "https://wordpress.stackexchange.com/users/5337",
"pm_score": 3,
"selected": true,
"text": "<p><strong>PLEASE!! PLEASE!!</strong> Don't send the php function names from your javascript. Below is the ... | 2011/06/24 | [
"https://wordpress.stackexchange.com/questions/20915",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6463/"
] | Asked this question on StackOverflow and they directed me over yonder... nice place ya got here =)
I've been developing a pretty simple WordPress plugin, and wanted to do some live validation of certain fields on the page, which is where I am stuck. I've been looking everywhere for something that worked, and I simply ... | **PLEASE!! PLEASE!!** Don't send the php function names from your javascript. Below is the correct way of doing it. It might not be best way but at least secure way.
To register your javascript (see the use of **plugins\_url** instead of path\_join), Also the validation is now part of your plugin, it does not have to ... |
20,921 | <p>I was wondering how I could setup a taxonomy metabox on a post edit page that would be similar to the "tags" kind (with search field and automatic suggestions), but without the right to add a new term.</p>
<p>So for example if I'm typign a word, I get suggestions of terms that I can use from the existing terms list... | [
{
"answer_id": 22570,
"author": "Hameedullah Khan",
"author_id": 5337,
"author_profile": "https://wordpress.stackexchange.com/users/5337",
"pm_score": 3,
"selected": true,
"text": "<p>I came up with a solution for your first question. i.e the tax metabox that only suggests terms from exi... | 2011/06/24 | [
"https://wordpress.stackexchange.com/questions/20921",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1381/"
] | I was wondering how I could setup a taxonomy metabox on a post edit page that would be similar to the "tags" kind (with search field and automatic suggestions), but without the right to add a new term.
So for example if I'm typign a word, I get suggestions of terms that I can use from the existing terms list, but if I... | I came up with a solution for your first question. i.e the tax metabox that only suggests terms from existing terms list but does not allow you to add new terms. The solution is jQuery based and modifies the default behavior of the tags (i.e non heirarchical taxonomies) meta box.
**Limitation:** Currently it only all... |
20,923 | <p>I have a series of posts, all with featured images, but I need to be able to customise the crop top right corner. In this instance, I need them to be cropped from top right, but it would be useful to also know how to position that point myself.</p>
<p>At present, the add_image_size() function is taking its crop fro... | [
{
"answer_id": 20925,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 5,
"selected": true,
"text": "<p>Intermediate image generation is extremely rigid. <code>image_resize()</code> keeps it close to code and completely ... | 2011/06/24 | [
"https://wordpress.stackexchange.com/questions/20923",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/784/"
] | I have a series of posts, all with featured images, but I need to be able to customise the crop top right corner. In this instance, I need them to be cropped from top right, but it would be useful to also know how to position that point myself.
At present, the add\_image\_size() function is taking its crop from the ce... | Intermediate image generation is extremely rigid. `image_resize()` keeps it close to code and completely lacks hooks.
Pretty much only option for this is to hook into `wp_generate_attachment_metadata` and overwrite WP-generated image with your own (which will need bit of a `image_resize()` fork).
I need this for work... |
20,926 | <p>I am running Qtranslate for <a href="http://www.businessinstitute.nl/?lang=en" rel="nofollow">my website</a>.</p>
<p>I am very impressed by this plugin.
Now my only problem is that I cannot set a custom title and description for my homepage per language.
I can only setup one line for the title in the general settin... | [
{
"answer_id": 20925,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 5,
"selected": true,
"text": "<p>Intermediate image generation is extremely rigid. <code>image_resize()</code> keeps it close to code and completely ... | 2011/06/24 | [
"https://wordpress.stackexchange.com/questions/20926",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2293/"
] | I am running Qtranslate for [my website](http://www.businessinstitute.nl/?lang=en).
I am very impressed by this plugin.
Now my only problem is that I cannot set a custom title and description for my homepage per language.
I can only setup one line for the title in the general settings for my website.
I have installed... | Intermediate image generation is extremely rigid. `image_resize()` keeps it close to code and completely lacks hooks.
Pretty much only option for this is to hook into `wp_generate_attachment_metadata` and overwrite WP-generated image with your own (which will need bit of a `image_resize()` fork).
I need this for work... |
20,946 | <p>There are a million posts on the topic in this stack exchange, and yet for some reason I cannot get this to work for me. I wonder what I'm doing wrong?</p>
<p>In my functions.php I define this:</p>
<pre><code>add_filter('query_vars', 'add_quote_query_vars');
function add_quote_query_vars($qv){
$qv[] = 'xx-quot... | [
{
"answer_id": 20978,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>From quick test with your filter active last test snippet works just fine for me. Also I don't get redirected from h... | 2011/06/24 | [
"https://wordpress.stackexchange.com/questions/20946",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3687/"
] | There are a million posts on the topic in this stack exchange, and yet for some reason I cannot get this to work for me. I wonder what I'm doing wrong?
In my functions.php I define this:
```
add_filter('query_vars', 'add_quote_query_vars');
function add_quote_query_vars($qv){
$qv[] = 'xx-quote';
return $qv;
}... | I was experiencing a similar problem and traced it back to Yoast's WordPress SEO plugin. This is a very popular plugin, so I wanted to post my fix. If you are running this plugin, do the following:
1. Navigate to SEO > Permalinks
2. Is "Redirect ugly URL's to clean permalinks" checked?
3. If so, scroll down to the inp... |
20,948 | <p>Is calling function_exists() faster or slower that apply_filters() ... or is the difference so small that it should not be considered?</p>
<p>I did a bit of testing based on Kaiser's and it showed that function_exists() is ~3 times faster where both the function and filter exist. and ~11 times faster if the filter ... | [
{
"answer_id": 20950,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": false,
"text": "<p>I don't know if one is faster or slower than the other, but I would suggest that using <code>apply_filters(... | 2011/06/24 | [
"https://wordpress.stackexchange.com/questions/20948",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11019/"
] | Is calling function\_exists() faster or slower that apply\_filters() ... or is the difference so small that it should not be considered?
I did a bit of testing based on Kaiser's and it showed that function\_exists() is ~3 times faster where both the function and filter exist. and ~11 times faster if the filter does no... | I don't know if one is faster or slower than the other, but I would suggest that using `apply_filters()` is the *better* approach, because it is *cleaner*, and more intuitive (in the sense of doing things the "WordPress way").
**EDIT**
If you're doing comparison tests, shouldn't you compare the time required to execu... |