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 |
|---|---|---|---|---|---|---|
25,052 | <p>I followed <a href="http://www.deluxeblogtips.com/2010/04/how-to-create-meta-box-wordpress-post.html">this</a> tutorial to create custom metaboxes.</p>
<p>It seems like <a href="http://www.qianqin.de/qtranslate/">qtranslate</a> enables you to use shortcodes almost everywhere.
For example:</p>
<p>Post titles:</p>
... | [
{
"answer_id": 46442,
"author": "Q Studio",
"author_id": 7968,
"author_profile": "https://wordpress.stackexchange.com/users/7968",
"pm_score": 2,
"selected": false,
"text": "<pre><code><?php\n\n$meta = get_post_meta( $post->ID, 'Meta', true );\n$lan = qtrans_getLanguage();\n$meta_l... | 2011/08/05 | [
"https://wordpress.stackexchange.com/questions/25052",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/781/"
] | I followed [this](http://www.deluxeblogtips.com/2010/04/how-to-create-meta-box-wordpress-post.html) tutorial to create custom metaboxes.
It seems like [qtranslate](http://www.qianqin.de/qtranslate/) enables you to use shortcodes almost everywhere.
For example:
Post titles:
```
<!--:en-->Cheng Feng Enterprises<!--:--... | ```
<?php
$meta = get_post_meta( $post->ID, 'Meta', true );
$lan = qtrans_getLanguage();
$meta_lan = qtrans_use( $lan, $meta, true );
echo $meta_lan;
?>
```
then enter your custom field data using the qtranslate comments:
```
<!--:ca-->CA<!--:--><!--:es-->ES<!--:--><!--:en-->EN<!--:-->
``` |
25,057 | <p>Below is my tax query, at the moment this returns all posts which have at least one of the specified terms.</p>
<p>Is there a way I can have it return only posts which have <strong>ALL</strong> of the specified terms?</p>
<pre><code>[tax_query] => Array
(
[relation] => AND
[0] => Array... | [
{
"answer_id": 25058,
"author": "Chris Carson",
"author_id": 7568,
"author_profile": "https://wordpress.stackexchange.com/users/7568",
"pm_score": 3,
"selected": false,
"text": "<p>Try <code>[operator] => AND</code> in both the sub-arrays. I think that will work from my reading of <c... | 2011/08/05 | [
"https://wordpress.stackexchange.com/questions/25057",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7663/"
] | Below is my tax query, at the moment this returns all posts which have at least one of the specified terms.
Is there a way I can have it return only posts which have **ALL** of the specified terms?
```
[tax_query] => Array
(
[relation] => AND
[0] => Array
(
[taxonomy] =... | Try `[operator] => AND` in both the sub-arrays. I think that will work from my reading of `WP_Tax_Query::get_sql()`. |
25,062 | <p>I'm currently developing a plugin and the chances are that I will more than likely release it on the public plugin repository so others can use it.</p>
<p>The plugin will be using an API and to use this API you need to pass a username and password. So my plugin needs to store these login credentials in the database... | [
{
"answer_id": 25067,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 2,
"selected": false,
"text": "<p>This is exactly the circumstance OAuth was designed for.</p>\n\n<p>From the <a href=\"http://oauth.net/\" rel=\"nofol... | 2011/08/05 | [
"https://wordpress.stackexchange.com/questions/25062",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4610/"
] | I'm currently developing a plugin and the chances are that I will more than likely release it on the public plugin repository so others can use it.
The plugin will be using an API and to use this API you need to pass a username and password. So my plugin needs to store these login credentials in the database. I don't ... | While I agree with the previous answers, to answer the question you actually asked, what comes to mind is to use one of these constants for wp-config.php:
```
define('AUTH_KEY', 'redacted');
define('SECURE_AUTH_KEY', 'redacted');
define('LOGGED_IN_KEY', 'redacted');
define('NONCE_KEY', 'redacted');
`... |
25,076 | <p>I want to filter WordPress search (and also WordPress listing of posts) on 2 values of a custom taxonomy.</p>
<p>I tried this code, filtering my custom taxonomy named "marque", excluding 70 or 67 IDs (nb : in my back-office, posts can only be classified into one term of my taxonomy a time) :</p>
<pre><code>// Filt... | [
{
"answer_id": 25086,
"author": "Chris Carson",
"author_id": 7568,
"author_profile": "https://wordpress.stackexchange.com/users/7568",
"pm_score": 1,
"selected": false,
"text": "<p>Try</p>\n\n<pre><code>$tax_query = array(\n 'relation' => 'AND',\n array(\n 'taxonomy' =&g... | 2011/08/05 | [
"https://wordpress.stackexchange.com/questions/25076",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7671/"
] | I want to filter WordPress search (and also WordPress listing of posts) on 2 values of a custom taxonomy.
I tried this code, filtering my custom taxonomy named "marque", excluding 70 or 67 IDs (nb : in my back-office, posts can only be classified into one term of my taxonomy a time) :
```
// Filtering on listing
func... | Try
```
$tax_query = array(
'relation' => 'AND',
array(
'taxonomy' => 'marque',
'terms' => array( 70, 67 ),
'field' => 'term_id',
'operator' => 'NOT IN'
)
);
//turn it into a WP_Tax_Query object...
$tax_query = new WP_TaxQuery($tax_query);
$query->set("tax_query", $tax... |
25,078 | <p>I have a form that creates a new user by using:</p>
<pre><code>wp_create_user()
</code></pre>
<p>This works, but after this I want to auto log in the user.</p>
<p>I tried using:</p>
<pre><code>$creds = array();
$creds['user_login'] = 'username';
$creds['user_password'] = 'password';
$creds['remember'] = true;
$u... | [
{
"answer_id": 25081,
"author": "Chris Carson",
"author_id": 7568,
"author_profile": "https://wordpress.stackexchange.com/users/7568",
"pm_score": 2,
"selected": false,
"text": "<p>You should probably use the action hook <code>init</code> to catch and process the registration form. This... | 2011/08/05 | [
"https://wordpress.stackexchange.com/questions/25078",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2417/"
] | I have a form that creates a new user by using:
```
wp_create_user()
```
This works, but after this I want to auto log in the user.
I tried using:
```
$creds = array();
$creds['user_login'] = 'username';
$creds['user_password'] = 'password';
$creds['remember'] = true;
$user = wp_signon( $creds, false );
if ( i... | Here is a function I wrote that hooks into the gravity forms create user form but it can be added to whatever action hook your wp\_create\_user function is attached to.
```
function my_auto_login( $user_id ) {
wp_set_auth_cookie( $user_id, false, is_ssl() );
wp_redirect( admin_url( 'profile.php' ) );
exit;... |
25,110 | <p>Sometimes it's nice to have admin on a different host (admin.mysite.com) then the actual site (www.mysite.com). </p>
<p>If admin.mysite.com is not publicly accessible, then images attached to posts on admin.mysite.com will not be accessible on www.mysite.com since the url to the attached image is absolute and conta... | [
{
"answer_id": 25111,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>you can configure the tinymce to use relative paths for images using the <code>tiny_mce_before_init</code> li... | 2011/08/05 | [
"https://wordpress.stackexchange.com/questions/25110",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4486/"
] | Sometimes it's nice to have admin on a different host (admin.mysite.com) then the actual site (www.mysite.com).
If admin.mysite.com is not publicly accessible, then images attached to posts on admin.mysite.com will not be accessible on www.mysite.com since the url to the attached image is absolute and contains the do... | I found another way of doing this. I added the following to functions.php:
```
function yoursite_get_relative_attachment_path($path)
{
$paths = (object)parse_url($path);
return $paths->path;
}
function yoursite_wp_handle_upload($info)
{
$info['url'] = yoursite_get_relative_attachment_path($info['url']);
... |
25,112 | <p>I've been searching for a better way to utilize the built in Thickbox function for images. I've been using my method for a few months, but I don't think it's the best way to do it. Here is the code I've been using (I don't remember where I found the code or I'd link to the article):</p>
<pre><code><?php
if (!is_... | [
{
"answer_id": 25121,
"author": "zac",
"author_id": 2661,
"author_profile": "https://wordpress.stackexchange.com/users/2661",
"pm_score": 2,
"selected": true,
"text": "<p>What if you try adding this to your functions.php</p>\n\n<pre><code>function tb(){\n wp_enqueue_script('thickbox',... | 2011/08/06 | [
"https://wordpress.stackexchange.com/questions/25112",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5339/"
] | I've been searching for a better way to utilize the built in Thickbox function for images. I've been using my method for a few months, but I don't think it's the best way to do it. Here is the code I've been using (I don't remember where I found the code or I'd link to the article):
```
<?php
if (!is_admin()){
/*
add ... | What if you try adding this to your functions.php
```
function tb(){
wp_enqueue_script('thickbox',null,array('jquery'));
wp_enqueue_style('thickbox.css', '/'.WPINC.'/js/thickbox/thickbox.css', null, '1.0');
}
add_action('wp_enqueue_scripts','tb');
```
and keeping your bit of jQuery (not sure what your are ne... |
25,125 | <p>Is there a way to select and display the last X approved comments regardless of which posts or categories they belong to ?</p>
<p>I just want to show on my home page the last comments added on my site, but I can't find anywhere how to do that.</p>
| [
{
"answer_id": 25128,
"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/get_comments\" rel=\"nofollow\">get_comments()</a> and ... | 2011/08/06 | [
"https://wordpress.stackexchange.com/questions/25125",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5915/"
] | Is there a way to select and display the last X approved comments regardless of which posts or categories they belong to ?
I just want to show on my home page the last comments added on my site, but I can't find anywhere how to do that. | A slightly more complete and less abrupt answer.
```
<?php
$args = array(
'status' => 'approve',
'number' => '5'
);
$comments = get_comments($args);
foreach($comments as $comment) :
// display any of the following indexes as you'd like
var_dump($comment);
endforeach;
?>
``` |
25,140 | <p>Let's cut right to the chase:
I have two custom post types: <strong>interviews</strong> and <strong>people</strong>. They both have custom taxonomy <strong>names</strong>. In interviews there is a video interview with one particular person along with the transcript of the video. In people, there is a short biography... | [
{
"answer_id": 25143,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>You could use the <a href=\"http://wordpress.org/extend/plugins/posts-to-posts/\" rel=\"nofollow\">Plugin Post2Post</a... | 2011/08/06 | [
"https://wordpress.stackexchange.com/questions/25140",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7666/"
] | Let's cut right to the chase:
I have two custom post types: **interviews** and **people**. They both have custom taxonomy **names**. In interviews there is a video interview with one particular person along with the transcript of the video. In people, there is a short biography and a photo of that person.
On my home p... | You could use the [Plugin Post2Post](http://wordpress.org/extend/plugins/posts-to-posts/) to associate the interviews with the people and to get these associations to your query. |
25,144 | <p>When doing a bit of Google searching for content on our blog, I noticed to my shock and horror that individual images from the Media Library are somehow generating their own URLs that Google is somehow finding and indexing!</p>
<p>For example this page:<br>
<a href="http://blog.stackoverflow.com/2008/08/special-de... | [
{
"answer_id": 25146,
"author": "Scott",
"author_id": 4610,
"author_profile": "https://wordpress.stackexchange.com/users/4610",
"pm_score": 4,
"selected": true,
"text": "<p>This thing you are saying is unwanted is just normal functionality under WordPress and it cannot be removed. Howeve... | 2011/08/06 | [
"https://wordpress.stackexchange.com/questions/25144",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/152/"
] | When doing a bit of Google searching for content on our blog, I noticed to my shock and horror that individual images from the Media Library are somehow generating their own URLs that Google is somehow finding and indexing!
For example this page:
<http://blog.stackoverflow.com/2008/08/special-development-team-podca... | This thing you are saying is unwanted is just normal functionality under WordPress and it cannot be removed. However there are things you can do to point the unwanted URL to something more usefull.
Here is a forum post on this issue with some interesting fixes and a description on what is happening:
<http://wordpress... |
25,155 | <p>I have been searching for some time on how to modify the Widgets Administration Screen, i'm attempting to add the sidebar id to the wrapper elements.</p>
<ul>
<li><p><strong>Current output:</strong> (produced by wordpress)</p>
<pre><code><div class="widgets-holder-wrap">
</code></pre></li>
<li><p><strong>Des... | [
{
"answer_id": 25167,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>As I understand the whole point of that ticket is that this is not possible without modifying core files (which is a... | 2011/08/06 | [
"https://wordpress.stackexchange.com/questions/25155",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5910/"
] | I have been searching for some time on how to modify the Widgets Administration Screen, i'm attempting to add the sidebar id to the wrapper elements.
* **Current output:** (produced by wordpress)
```
<div class="widgets-holder-wrap">
```
* **Desired output:**
```
<div id="sidebar-id-here" class="widgets-holder-wra... | I'd personally suggest an enqueue, it's preferable where possible to make use of caching and script compression.
Firstly, the enqueue.
```
add_action( 'admin_enqueue_scripts', 'add_sidebar_ids_to_widget_admin' );
function add_sidebar_ids_to_widget_admin( $current_page_hook ) {
if( 'widgets.php' != $current_page_... |
25,157 | <p>I am using a blog to keep track of citations I may want to use for a thesis. Each citation is a Post, authors are categories, which are parents to subcategories that are named for the titles of books or articles by that author. In the description of the book/article subcategories, I put the publishing information, e... | [
{
"answer_id": 25162,
"author": "Chris Carson",
"author_id": 7568,
"author_profile": "https://wordpress.stackexchange.com/users/7568",
"pm_score": 0,
"selected": false,
"text": "<p>Copy <code>page.php</code> in your theme root and name it <code>page-list-of-categories.php</code>. Put th... | 2011/08/06 | [
"https://wordpress.stackexchange.com/questions/25157",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7690/"
] | I am using a blog to keep track of citations I may want to use for a thesis. Each citation is a Post, authors are categories, which are parents to subcategories that are named for the titles of books or articles by that author. In the description of the book/article subcategories, I put the publishing information, e.g.... | First you need to get all the categories that don't have parents (top-level categories). We're going to use [`get_terms`](http://codex.wordpress.org/Function_Reference/get_terms) for this. Get terms will either return an empty array, a `WP_Error` object, or an array of objects representing terms. So we need to make sur... |
25,158 | <p>I want to create two new sites. One will be a simple site with a few pages -- not really a blog, but I might add a blog to it at some point. The other site will be more like a blog -- with guest posts by a number of people, and it will probably have affiliate links -- possibly Amazon links. It might also have Google... | [
{
"answer_id": 25162,
"author": "Chris Carson",
"author_id": 7568,
"author_profile": "https://wordpress.stackexchange.com/users/7568",
"pm_score": 0,
"selected": false,
"text": "<p>Copy <code>page.php</code> in your theme root and name it <code>page-list-of-categories.php</code>. Put th... | 2011/08/06 | [
"https://wordpress.stackexchange.com/questions/25158",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7692/"
] | I want to create two new sites. One will be a simple site with a few pages -- not really a blog, but I might add a blog to it at some point. The other site will be more like a blog -- with guest posts by a number of people, and it will probably have affiliate links -- possibly Amazon links. It might also have Google Ad... | First you need to get all the categories that don't have parents (top-level categories). We're going to use [`get_terms`](http://codex.wordpress.org/Function_Reference/get_terms) for this. Get terms will either return an empty array, a `WP_Error` object, or an array of objects representing terms. So we need to make sur... |
25,176 | <p>I want to specify for the images of my post - if is number x, output this, else if is number y output this instead, etc. I'm trying make specific treatments to my 1st, 4th, 9th images for that post. This code below is the code i'm using to just simply output all of my images for the post. Any ideas?</p>
<pre><co... | [
{
"answer_id": 25174,
"author": "DennisT",
"author_id": 5778,
"author_profile": "https://wordpress.stackexchange.com/users/5778",
"pm_score": 1,
"selected": false,
"text": "<p>Unzip the file on your computer and upload all the files to your public_html folder.</p>\n\n<p>When that's done,... | 2011/08/06 | [
"https://wordpress.stackexchange.com/questions/25176",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5698/"
] | I want to specify for the images of my post - if is number x, output this, else if is number y output this instead, etc. I'm trying make specific treatments to my 1st, 4th, 9th images for that post. This code below is the code i'm using to just simply output all of my images for the post. Any ideas?
```
<?php $images ... | WordPress Codex has quite extensive [installation instructions](http://codex.wordpress.org/Installing_WordPress).
>
> I see there's a .zip file and a .tar.gz file -- which should I use?
>
>
>
No difference. Archive format is merely for convenience, contents are the same.
>
> I want the site to be at http not at... |
25,227 | <p>I have a non-Wordpress site , <strong>www.example.com</strong></p>
<p>For canonicalization purposes I have this in .htaccess :</p>
<pre><code>Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
</code></pre>
<p>This way all... | [
{
"answer_id": 25228,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 0,
"selected": false,
"text": "<p>You don't need that code. WordPress itself handles redirects to canonical URLs. Just set it up to have the www addr... | 2011/08/07 | [
"https://wordpress.stackexchange.com/questions/25227",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7710/"
] | I have a non-Wordpress site , **www.example.com**
For canonicalization purposes I have this in .htaccess :
```
Options +FollowSymLinks
RewriteEngine On
RewriteCond %{HTTP_HOST} !^www\.example\.com$
RewriteRule (.*) http://www.example.com/$1 [R=301,L]
```
This way all non-www links will be redirected to www versi... | As per @Milo, I'm adding my comment above as an answer...
Try going to `example.com/blog/wp-admin/options-permalink.php`. That should work, because the php file actually exists. If so, try updating your permalink options to a friendly version, like "Day and name". This will put a new `.htaccess` in the blog directory ... |
25,241 | <p>Yet another URL rewrite issue :)</p>
<h2>The Problem</h2>
<p>I have a URL rewrite rule that should work, but against all logic it redirects without passing the query var.</p>
<h2>The Juicy Details</h2>
<p>The site has a page structure set up like so:</p>
<blockquote>
<p><strong>/our-firm/shareholders</strong>... | [
{
"answer_id": 25562,
"author": "Josh",
"author_id": 7802,
"author_profile": "https://wordpress.stackexchange.com/users/7802",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried flushing your rewrite rules after add_rewrite_rule():</p>\n\n<pre><code>function my_custom_rewrites(... | 2011/08/07 | [
"https://wordpress.stackexchange.com/questions/25241",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7672/"
] | Yet another URL rewrite issue :)
The Problem
-----------
I have a URL rewrite rule that should work, but against all logic it redirects without passing the query var.
The Juicy Details
-----------------
The site has a page structure set up like so:
>
> **/our-firm/shareholders**
>
>
>
and I have a Custom Post... | You should try setting 'slug' ( in the 'rewrite' parameter/option) to 'our-firm/shareholders', just like the structure you have set in the add\_rewrite\_rule() function.
The first parameter of add\_rewrite\_rule() and the 'rewrite' setting of the custom post type must be equal in order to get the rewritting actually w... |
25,256 | <p>I want to show only top level pages, without the dropdown. I am trying to set the depth to 0...</p>
<pre><code>wp_nav_menu( array( 'theme_location' => 'primary', 'depth' => 0 ) );
</code></pre>
<p>But it generates:</p>
<pre><code><ul>
<li class="current_page_item">
<a href="http:/... | [
{
"answer_id": 25257,
"author": "Chris Carson",
"author_id": 7568,
"author_profile": "https://wordpress.stackexchange.com/users/7568",
"pm_score": 2,
"selected": false,
"text": "<p>Try <code>\"depth\"=>1</code>. 0 means \"unlimited\".</p>\n"
},
{
"answer_id": 25260,
"auth... | 2011/08/07 | [
"https://wordpress.stackexchange.com/questions/25256",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7716/"
] | I want to show only top level pages, without the dropdown. I am trying to set the depth to 0...
```
wp_nav_menu( array( 'theme_location' => 'primary', 'depth' => 0 ) );
```
But it generates:
```
<ul>
<li class="current_page_item">
<a href="http://www.test.com/" title="Home">Home</a>
</li>
<li cl... | Try `"depth"=>1`. 0 means "unlimited". |
25,269 | <p>I'm using WordPress as a directory site, where a user can submit a post, which becomes their ad/listing. The users are assigned a custom wordpress role.</p>
<p>Posts need to need to be approved and published by the admin once, and then they can freely update their post as they see fit. It work's fine like this at t... | [
{
"answer_id": 25272,
"author": "Chris Carson",
"author_id": 7568,
"author_profile": "https://wordpress.stackexchange.com/users/7568",
"pm_score": 2,
"selected": false,
"text": "<p>I recently was dealing with the exact same problem. I didn't solve it, and we decided that since people ha... | 2011/08/08 | [
"https://wordpress.stackexchange.com/questions/25269",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4999/"
] | I'm using WordPress as a directory site, where a user can submit a post, which becomes their ad/listing. The users are assigned a custom wordpress role.
Posts need to need to be approved and published by the admin once, and then they can freely update their post as they see fit. It work's fine like this at the moment ... | Thanks to Chris's suggestion of assigning a capability on the fly I was able to get something working that might help someone else. There may be a better method, but this one works well for my situation.
Because I'm working with a custom post type of `listing` I needed to assign the mapped capability `publish_listings... |
25,273 | <p>How to check if jQuery library exist in head tags?</p>
<pre><code><head>
<script type="javascript/text" src="http://code.jquery.com/jquery-1.6.2.js"></script>
</head>
</code></pre>
<p>and if not exist how do I load in head tags the jquery library, I'm doing a plugins and I want to load my p... | [
{
"answer_id": 25274,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": true,
"text": "<p>scripts and styles should never be embedded directly in themes or templates because of potential conflicts between p... | 2011/08/08 | [
"https://wordpress.stackexchange.com/questions/25273",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/420/"
] | How to check if jQuery library exist in head tags?
```
<head>
<script type="javascript/text" src="http://code.jquery.com/jquery-1.6.2.js"></script>
</head>
```
and if not exist how do I load in head tags the jquery library, I'm doing a plugins and I want to load my plugins script in jQuery and also do able to check ... | scripts and styles should never be embedded directly in themes or templates because of potential conflicts between plugins and themes.
To use jQuery in a plugin or theme it should be enqueued with [wp enqueue script](http://codex.wordpress.org/Function_Reference/wp_enqueue_script). This will make sure it's added only ... |
25,297 | <p>currently I m showing post image and it's exceprt on my index page of website. Beacuse of this site is slow downs as each image is passed to timthumb.php file. I want to change in code so that image is displayed direct without passing to timthumb.php file for resizing. Is there any way to achieve this?? </p>
<p>Tha... | [
{
"answer_id": 25300,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 1,
"selected": false,
"text": "<p>add the size to your images sizes using <a href=\"http://codex.wordpress.org/Function_Reference/add_image_siz... | 2011/08/08 | [
"https://wordpress.stackexchange.com/questions/25297",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7050/"
] | currently I m showing post image and it's exceprt on my index page of website. Beacuse of this site is slow downs as each image is passed to timthumb.php file. I want to change in code so that image is displayed direct without passing to timthumb.php file for resizing. Is there any way to achieve this??
Thanks in adv... | add the size to your images sizes using [`add_image_size()`](http://codex.wordpress.org/Function_Reference/add_image_size) to your theme's functions.php file. eg:
```
if ( function_exists( 'add_theme_support' ) ) {
add_image_size( 'index-thumb', 220, 180 ); // 220 pixels wide by 180 pixels tall
}
```
then set th... |
25,298 | <p>example page;
<a href="http://www.c-art.org.uk/2011/07/01/jenny-abbot/" rel="nofollow">http://www.c-art.org.uk/2011/07/01/jenny-abbot/</a></p>
<p>some reason the gravatar image is overwriting the posts featured image thumb (100x100). Nnot sure how its doing it! How can i get rid of it?</p>
<pre><code><meta prop... | [
{
"answer_id": 25299,
"author": "Chris Carson",
"author_id": 7568,
"author_profile": "https://wordpress.stackexchange.com/users/7568",
"pm_score": 2,
"selected": true,
"text": "<p>I can't see a Facebook share button on <a href=\"http://www.c-art.org.uk/2011/07/01/jenny-abbot/\" rel=\"nof... | 2011/08/08 | [
"https://wordpress.stackexchange.com/questions/25298",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3978/"
] | example page;
<http://www.c-art.org.uk/2011/07/01/jenny-abbot/>
some reason the gravatar image is overwriting the posts featured image thumb (100x100). Nnot sure how its doing it! How can i get rid of it?
```
<meta property="og:title" content="Jenny Abbot" />
<meta property="og:description" content="C-Art — Cumbria A... | I can't see a Facebook share button on [the page you are talking about](http://www.c-art.org.uk/2011/07/01/jenny-abbot/), but I ran this through [Facebook Lint](http://developers.facebook.com/tools/lint/?url=http://www.c-art.org.uk/2011/07/01/jenny-abbot/) and it appears that your Open Graph meta tags are working corre... |
25,324 | <p>My theme registers custom menus with this function:</p>
<pre><code>function nav_menus() {
if ( function_exists( 'register_nav_menus' ) ) {
register_nav_menus(
array('main-menu' => __( 'Main Menu' ), 'sub-menu' => __( 'Sub Menu' ))
);
}
}
</code></pre>
<p>I need to place code into ... | [
{
"answer_id": 25325,
"author": "cheesypeanut",
"author_id": 7649,
"author_profile": "https://wordpress.stackexchange.com/users/7649",
"pm_score": 4,
"selected": true,
"text": "<p>You can use the function <code>has_nav_menu('main-menu')</code>. See the WordPress Codex <a href=\"http://co... | 2011/08/08 | [
"https://wordpress.stackexchange.com/questions/25324",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6620/"
] | My theme registers custom menus with this function:
```
function nav_menus() {
if ( function_exists( 'register_nav_menus' ) ) {
register_nav_menus(
array('main-menu' => __( 'Main Menu' ), 'sub-menu' => __( 'Sub Menu' ))
);
}
}
```
I need to place code into my sidebar, that checks to see i... | You can use the function `has_nav_menu('main-menu')`. See the WordPress Codex [here](http://codex.wordpress.org/Function_Reference/has_nav_menu). |
25,350 | <p>How can I limit the amount of results returned?</p>
<pre><code>$images = $wpdb->get_col("
SELECT ID FROM $wpdb->posts
WHERE post_type = 'attachment'
AND ID in ($meta)
ORDER BY menu_order ASC
");
</code></pre>
| [
{
"answer_id": 25351,
"author": "Ashfame",
"author_id": 1521,
"author_profile": "https://wordpress.stackexchange.com/users/1521",
"pm_score": 3,
"selected": true,
"text": "<pre><code>$images = $wpdb->get_col(\"\n SELECT ID FROM $wpdb->posts\n WHERE post_type = 'attachment'\n ... | 2011/08/08 | [
"https://wordpress.stackexchange.com/questions/25350",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5698/"
] | How can I limit the amount of results returned?
```
$images = $wpdb->get_col("
SELECT ID FROM $wpdb->posts
WHERE post_type = 'attachment'
AND ID in ($meta)
ORDER BY menu_order ASC
");
``` | ```
$images = $wpdb->get_col("
SELECT ID FROM $wpdb->posts
WHERE post_type = 'attachment'
AND ID in ($meta)
ORDER BY menu_order ASC
LIMIT 5
");
```
Like @Kaiser suggested you can specify a range (5th to 20th results, a total of 15 results are returned at max) like this:
```
$images = $wpdb->get_c... |
25,355 | <p>I have a Wordpress site in which the background color is black and the text is white. The site is fine, but it's a pain trying to edit content in the visual editor as the background is white (same color as the text). I end up having to tell users to use the HTML view or write up the content in black color text an... | [
{
"answer_id": 25351,
"author": "Ashfame",
"author_id": 1521,
"author_profile": "https://wordpress.stackexchange.com/users/1521",
"pm_score": 3,
"selected": true,
"text": "<pre><code>$images = $wpdb->get_col(\"\n SELECT ID FROM $wpdb->posts\n WHERE post_type = 'attachment'\n ... | 2011/08/08 | [
"https://wordpress.stackexchange.com/questions/25355",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2365/"
] | I have a Wordpress site in which the background color is black and the text is white. The site is fine, but it's a pain trying to edit content in the visual editor as the background is white (same color as the text). I end up having to tell users to use the HTML view or write up the content in black color text and then... | ```
$images = $wpdb->get_col("
SELECT ID FROM $wpdb->posts
WHERE post_type = 'attachment'
AND ID in ($meta)
ORDER BY menu_order ASC
LIMIT 5
");
```
Like @Kaiser suggested you can specify a range (5th to 20th results, a total of 15 results are returned at max) like this:
```
$images = $wpdb->get_c... |
25,362 | <p>My site is using WooThemes <a href="http://www.woothemes.com/2011/06/statua/" rel="nofollow">Statua theme</a>. I'm trying to get my resized slider images to link to their respective full size images (or attachment pages). </p>
<p>I asked a similar question on the WooThemes <a href="http://forum.woothemes.com/topic.... | [
{
"answer_id": 25369,
"author": "Pippin",
"author_id": 2418,
"author_profile": "https://wordpress.stackexchange.com/users/2418",
"pm_score": 3,
"selected": true,
"text": "<pre><code>$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), \"full\" );\n\necho '<a h... | 2011/08/09 | [
"https://wordpress.stackexchange.com/questions/25362",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3711/"
] | My site is using WooThemes [Statua theme](http://www.woothemes.com/2011/06/statua/). I'm trying to get my resized slider images to link to their respective full size images (or attachment pages).
I asked a similar question on the WooThemes [support](http://forum.woothemes.com/topic.php?id=49784) [forums](http://forum... | ```
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "full" );
echo '<a href="' . $image[0] . '">Link to Full Size</a>';
``` |
25,372 | <p>I use the Twenty Ten theme, customized.</p>
<p>The theme text is: Your email address will not be published.</p>
<p>With the email box below, this gives readers the impression that they must enter an email address, yet I set my settings so one is not required.</p>
<p>I'd like to edit the text to read:</p>
<p>You ... | [
{
"answer_id": 25369,
"author": "Pippin",
"author_id": 2418,
"author_profile": "https://wordpress.stackexchange.com/users/2418",
"pm_score": 3,
"selected": true,
"text": "<pre><code>$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), \"full\" );\n\necho '<a h... | 2011/08/09 | [
"https://wordpress.stackexchange.com/questions/25372",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7745/"
] | I use the Twenty Ten theme, customized.
The theme text is: Your email address will not be published.
With the email box below, this gives readers the impression that they must enter an email address, yet I set my settings so one is not required.
I'd like to edit the text to read:
You do not have to leave an email a... | ```
$image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "full" );
echo '<a href="' . $image[0] . '">Link to Full Size</a>';
``` |
25,383 | <p>I been looking around for this, but couldn't find a way.
The scenario is:
I have a custom post type 'Company', and I'm creating Company type posts through my plugin's code. When I create a new Company post, I set the author as Admin. Now further down the code, I'm creating a custom role 'Representative' and assigni... | [
{
"answer_id": 25434,
"author": "Rutwick Gangurde",
"author_id": 4740,
"author_profile": "https://wordpress.stackexchange.com/users/4740",
"pm_score": 3,
"selected": true,
"text": "<p><strong>I'm reposting this with an example, I really don't get the code formatting of this editor, last ... | 2011/08/09 | [
"https://wordpress.stackexchange.com/questions/25383",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4740/"
] | I been looking around for this, but couldn't find a way.
The scenario is:
I have a custom post type 'Company', and I'm creating Company type posts through my plugin's code. When I create a new Company post, I set the author as Admin. Now further down the code, I'm creating a custom role 'Representative' and assigning ... | **I'm reposting this with an example, I really don't get the code formatting of this editor, last time I was so irritated with it that I skipped the code!**
That dropdown is populated using a filter 'wp\_dropdown\_users' (user.php, line 976). This filter returns the dropdown (html select) as a string. You can interc... |
25,386 | <p>This is what I want to do:</p>
<ol>
<li>In the media uploader, add a link "Use this attachment ID as custom field".</li>
<li>Add the attachment ID in a custom fields meta box.</li>
</ol>
<p>I've searched for hours for a plugin that does this but found nothing. Code examples, plugins, hints. Anything might be helpf... | [
{
"answer_id": 25434,
"author": "Rutwick Gangurde",
"author_id": 4740,
"author_profile": "https://wordpress.stackexchange.com/users/4740",
"pm_score": 3,
"selected": true,
"text": "<p><strong>I'm reposting this with an example, I really don't get the code formatting of this editor, last ... | 2011/08/09 | [
"https://wordpress.stackexchange.com/questions/25386",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5244/"
] | This is what I want to do:
1. In the media uploader, add a link "Use this attachment ID as custom field".
2. Add the attachment ID in a custom fields meta box.
I've searched for hours for a plugin that does this but found nothing. Code examples, plugins, hints. Anything might be helpful. | **I'm reposting this with an example, I really don't get the code formatting of this editor, last time I was so irritated with it that I skipped the code!**
That dropdown is populated using a filter 'wp\_dropdown\_users' (user.php, line 976). This filter returns the dropdown (html select) as a string. You can interc... |
25,405 | <p>I know there have been many question like this and I've read them, but I still cant get it working... I have this query:</p>
<pre><code>query_posts(array('cat'=>3,'posts_per_page'=>5));
</code></pre>
<p>And I simply display the content below in <code>while (have_posts()) : the_post();</code> loop
How can I ... | [
{
"answer_id": 25416,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>try adding :</p>\n\n<pre><code>$page = (get_query_var('paged')) ? get_query_var('paged') : 1;\n</code></pre>\... | 2011/08/09 | [
"https://wordpress.stackexchange.com/questions/25405",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15476/"
] | I know there have been many question like this and I've read them, but I still cant get it working... I have this query:
```
query_posts(array('cat'=>3,'posts_per_page'=>5));
```
And I simply display the content below in `while (have_posts()) : the_post();` loop
How can I add pagination to this?
I'm trying with addi... | try adding :
```
$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
```
and then in your args array add `'paged'=> $page` |
25,418 | <p>For security reasons I don't want it to be obvious that I use Word Press.
I use the W3 Total Cache plugin and minify HTML, CSS and JS. I may also use a CDN.</p>
<p>Is it possible to modify the W3 Total Cache plugin so that it can rewrite the Wordpress directories "wp-content", "wp-admin" and "wp-includes" without a... | [
{
"answer_id": 25416,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>try adding :</p>\n\n<pre><code>$page = (get_query_var('paged')) ? get_query_var('paged') : 1;\n</code></pre>\... | 2011/08/09 | [
"https://wordpress.stackexchange.com/questions/25418",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5864/"
] | For security reasons I don't want it to be obvious that I use Word Press.
I use the W3 Total Cache plugin and minify HTML, CSS and JS. I may also use a CDN.
Is it possible to modify the W3 Total Cache plugin so that it can rewrite the Wordpress directories "wp-content", "wp-admin" and "wp-includes" without actually re... | try adding :
```
$page = (get_query_var('paged')) ? get_query_var('paged') : 1;
```
and then in your args array add `'paged'=> $page` |
25,433 | <p>I have a custom post type (photos) with a custom taxonomy (categories) and I'd like to display the taxonomy list in my sidebar in two columns. I have a modified snippet that I found elsewhere to do this, but it doesn't generate the current class for the particular category it is on. Maybe it is not the best way to l... | [
{
"answer_id": 25437,
"author": "Rutwick Gangurde",
"author_id": 4740,
"author_profile": "https://wordpress.stackexchange.com/users/4740",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <a href=\"http://codex.wordpress.org/Function_Reference/wp_get_object_terms\" rel=\"nofollo... | 2011/08/09 | [
"https://wordpress.stackexchange.com/questions/25433",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7762/"
] | I have a custom post type (photos) with a custom taxonomy (categories) and I'd like to display the taxonomy list in my sidebar in two columns. I have a modified snippet that I found elsewhere to do this, but it doesn't generate the current class for the particular category it is on. Maybe it is not the best way to list... | As a follow up to @Rutwick Gangurde Answer, here's an example.
Notes:
* Put it in your functions.php file, call it in the template file.
* Alter the output by inspecting the `$term` inside the foreach loop
* Read the comments inside the function
-
```
function wpse25433_terms_list( $cat = array('categories'), ... |
25,442 | <p>I'm using a slightly modified copy of the <a href="http://wordpress.org/extend/plugins/multisite-user-management/" rel="nofollow">Multi Site User Management</a> plugin to keeps users synced across a multisite network, but have one problem with it. When a user's role is updated on the main site, the role is NOT updat... | [
{
"answer_id": 25965,
"author": "PrivateUser",
"author_id": 5074,
"author_profile": "https://wordpress.stackexchange.com/users/5074",
"pm_score": 0,
"selected": false,
"text": "<p>Hi i'm not sure whether this plugin will help you or not. But give it a try. Try scribu's <a href=\"http://... | 2011/08/09 | [
"https://wordpress.stackexchange.com/questions/25442",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2418/"
] | I'm using a slightly modified copy of the [Multi Site User Management](http://wordpress.org/extend/plugins/multisite-user-management/) plugin to keeps users synced across a multisite network, but have one problem with it. When a user's role is updated on the main site, the role is NOT updated on the sub site. In order ... | I've found a way around the problem. It's not a "fix", but rather a way to get around the problem of needing synchronized user roles. Instead of trying to make all user roles match up, I decided to only check the user roles for the main site. see my function below for how I did it:
```
/*
* Function to check a specifi... |
25,446 | <p>is there an easy way for me to save a variable and link it to a user?</p>
<p>specifically I want to use meta box to output a variable on the front page, then have it be a link so if a user clicks it, it will store it in a div. I can do all the meta box stuff, just need the variable to be stored when link is clicked... | [
{
"answer_id": 25451,
"author": "Chris",
"author_id": 7435,
"author_profile": "https://wordpress.stackexchange.com/users/7435",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <a href=\"http://codex.wordpress.org/Function_Reference/update_user_meta\" rel=\"nofollow\">update_use... | 2011/08/09 | [
"https://wordpress.stackexchange.com/questions/25446",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7766/"
] | is there an easy way for me to save a variable and link it to a user?
specifically I want to use meta box to output a variable on the front page, then have it be a link so if a user clicks it, it will store it in a div. I can do all the meta box stuff, just need the variable to be stored when link is clicked. kind of ... | To expound on Chris' answer, the AJAX call would look something like this in your functions.php file:
```
add_action('wp_ajax_add_favorite', 'add_favorite');
function add_favorite(){
$post_id = $_POST['postID'];
$nonce = $_POST['nonce'];
if(!wp_verify_nonce($nonce, 'wpnonce'))
exit;
if($post_... |
25,461 | <p>I have several custom widgets that are installed as part of my theme. I'd like to execute conditional code inside each widget's admin panel (not the public side, I'm just interested in the admin panel inside function form($intance)), depending on which sidebar the widget is inserted into.</p>
<p>How can I obtain a ... | [
{
"answer_id": 25479,
"author": "Sean Lee",
"author_id": 6851,
"author_profile": "https://wordpress.stackexchange.com/users/6851",
"pm_score": 2,
"selected": false,
"text": "<p>If your sidebar has a name, you can retrieve the sidebar name using <code>get_sidebar( $name )</code></p>\n\n<p... | 2011/08/09 | [
"https://wordpress.stackexchange.com/questions/25461",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6620/"
] | I have several custom widgets that are installed as part of my theme. I'd like to execute conditional code inside each widget's admin panel (not the public side, I'm just interested in the admin panel inside function form($intance)), depending on which sidebar the widget is inserted into.
How can I obtain a reference ... | If your sidebar has a name, you can retrieve the sidebar name using `get_sidebar( $name )`
inside the widget itself, try this:
```
global $wp_registered_widgets, $wp_registered_sidebars;
$sidebars_widgets = get_option('sidebars_widgets');
if($sidebars_widgets["sidebar-1"]) echo 'hooray';
``` |
25,505 | <p>Is there a way to take a plugin slug (e.g. 'akismet') of a plugin that is NOT currently installed and somehow retrieve the download URL of the current version (e.g. 'http://downloads.wordpress.org/plugin/akismet.2.5.3.zip')?</p>
<p>This is for a command line script I am trying to develop that will enable plugin ins... | [
{
"answer_id": 25509,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 2,
"selected": false,
"text": "<p>I forget exactly if the plugin slug is a reliable method to get the url, it might be in most cases but not all due ... | 2011/08/10 | [
"https://wordpress.stackexchange.com/questions/25505",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/300/"
] | Is there a way to take a plugin slug (e.g. 'akismet') of a plugin that is NOT currently installed and somehow retrieve the download URL of the current version (e.g. 'http://downloads.wordpress.org/plugin/akismet.2.5.3.zip')?
This is for a command line script I am trying to develop that will enable plugin installation ... | I forget exactly if the plugin slug is a reliable method to get the url, it might be in most cases but not all due to how plugins are named.
You can query the api @wordpress.org for the plugins xml file which also contains the download link.
For example:
```
$plugin_slug = 'akismet';
$return_plugin_info = "http://a... |
25,523 | <p>I'm creating a new page in WordPress admin for a theme. In this new page will be a list of people registered (in a form), but with few details / information. So when a person clicks on something, I would like to open a "pop-up" (with all information) but not display this popup/page in the menus of the WordPress admi... | [
{
"answer_id": 25531,
"author": "gruvii",
"author_id": 2506,
"author_profile": "https://wordpress.stackexchange.com/users/2506",
"pm_score": 0,
"selected": false,
"text": "<p>I would think you could add a css class to the body of that new admin page using a wordpress filter, then use css... | 2011/08/10 | [
"https://wordpress.stackexchange.com/questions/25523",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3575/"
] | I'm creating a new page in WordPress admin for a theme. In this new page will be a list of people registered (in a form), but with few details / information. So when a person clicks on something, I would like to open a "pop-up" (with all information) but not display this popup/page in the menus of the WordPress adminis... | You can use the built in ThickBox to display the popup by Ajax:
```
//first add thickbox to your page
function add_thickbox(){
if(is_admin() && (isset($_GET['page']) && $_GET['page'] == "my-plugin-file.php") {
wp_enqueue_script('jquery');
wp_enqueue_script('thickbox',null,array('jquery'));
wp_enqueue_... |
25,533 | <p>I'm using the <a href="http://jigoshop.com/" rel="nofollow">Jigoshop plugin</a> (everything's going great so far!) and need to display the product SKU on a page, does anyone know how to do this?</p>
<p>p.s I would ask on the Jigoshop forum but you have to pay for it.</p>
| [
{
"answer_id": 25531,
"author": "gruvii",
"author_id": 2506,
"author_profile": "https://wordpress.stackexchange.com/users/2506",
"pm_score": 0,
"selected": false,
"text": "<p>I would think you could add a css class to the body of that new admin page using a wordpress filter, then use css... | 2011/08/10 | [
"https://wordpress.stackexchange.com/questions/25533",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4588/"
] | I'm using the [Jigoshop plugin](http://jigoshop.com/) (everything's going great so far!) and need to display the product SKU on a page, does anyone know how to do this?
p.s I would ask on the Jigoshop forum but you have to pay for it. | You can use the built in ThickBox to display the popup by Ajax:
```
//first add thickbox to your page
function add_thickbox(){
if(is_admin() && (isset($_GET['page']) && $_GET['page'] == "my-plugin-file.php") {
wp_enqueue_script('jquery');
wp_enqueue_script('thickbox',null,array('jquery'));
wp_enqueue_... |
25,560 | <p>I have created some content using php, js and html which shows the bandwidth the site has used (using the cPanel API and the Google Graphs API)
I want this to be shown on the dashboard in Wordpress (viewable to Admins and Editors only)</p>
<p>How do I do this?</p>
| [
{
"answer_id": 25592,
"author": "westondeboer",
"author_id": 2691,
"author_profile": "https://wordpress.stackexchange.com/users/2691",
"pm_score": 3,
"selected": true,
"text": "<pre><code><?php\n/*\nPlugin Name: Dashboard Google Page Rank\nPlugin URI: http://wordpress.org/extend/plugi... | 2011/08/10 | [
"https://wordpress.stackexchange.com/questions/25560",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5864/"
] | I have created some content using php, js and html which shows the bandwidth the site has used (using the cPanel API and the Google Graphs API)
I want this to be shown on the dashboard in Wordpress (viewable to Admins and Editors only)
How do I do this? | ```
<?php
/*
Plugin Name: Dashboard Google Page Rank
Plugin URI: http://wordpress.org/extend/plugins/dashboard-google-pagerank/
Description: Shows your google pagerank in the wordpress dashboard
Author: Weston Deboer
Version: 1.1
Author URI: http://westondeboer.com
*/
function gpr_wp_dashboard_test() {
include('yourfil... |
25,561 | <p>Is it possible to change the Wordpress logo and header in the Dashboard so I can customise it a little more to my business? Ideally it could be done in a way so that it wouldn't break every time I upgrade Wordpress to the latest version.</p>
| [
{
"answer_id": 25592,
"author": "westondeboer",
"author_id": 2691,
"author_profile": "https://wordpress.stackexchange.com/users/2691",
"pm_score": 3,
"selected": true,
"text": "<pre><code><?php\n/*\nPlugin Name: Dashboard Google Page Rank\nPlugin URI: http://wordpress.org/extend/plugi... | 2011/08/10 | [
"https://wordpress.stackexchange.com/questions/25561",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5864/"
] | Is it possible to change the Wordpress logo and header in the Dashboard so I can customise it a little more to my business? Ideally it could be done in a way so that it wouldn't break every time I upgrade Wordpress to the latest version. | ```
<?php
/*
Plugin Name: Dashboard Google Page Rank
Plugin URI: http://wordpress.org/extend/plugins/dashboard-google-pagerank/
Description: Shows your google pagerank in the wordpress dashboard
Author: Weston Deboer
Version: 1.1
Author URI: http://westondeboer.com
*/
function gpr_wp_dashboard_test() {
include('yourfil... |
25,591 | <p>For example, inside the loop could i do something like this</p>
<pre><code>if lastpost {
}
else {
}
</code></pre>
| [
{
"answer_id": 25594,
"author": "Dwayne Charrington",
"author_id": 1687,
"author_profile": "https://wordpress.stackexchange.com/users/1687",
"pm_score": 2,
"selected": false,
"text": "<p>I've coded up a quick little example for you. Should explain how to get the first and last post in a ... | 2011/08/11 | [
"https://wordpress.stackexchange.com/questions/25591",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2107/"
] | For example, inside the loop could i do something like this
```
if lastpost {
}
else {
}
``` | ```
if ($wp_query->current_post +1 == $wp_query->post_count) {
// this is the last post
}
```
Change $wp\_query to your own query variable if you made a new WP\_Query object. |
25,597 | <p>I love stackexchange's tag subscription feature. Now i'm receiving email notifications only for the topics i'm interested in. I would like to have this feature in my wordpress site. Is there any good tag subscription plugin available?. </p>
<p>If there is no plugin available why not WA experts create one and submit... | [
{
"answer_id": 25598,
"author": "GavinR",
"author_id": 2001,
"author_profile": "https://wordpress.stackexchange.com/users/2001",
"pm_score": 3,
"selected": true,
"text": "<p>If you're willing to use an outside provider, you can add the <a href=\"http://codex.wordpress.org/WordPress_Feeds... | 2011/08/11 | [
"https://wordpress.stackexchange.com/questions/25597",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5074/"
] | I love stackexchange's tag subscription feature. Now i'm receiving email notifications only for the topics i'm interested in. I would like to have this feature in my wordpress site. Is there any good tag subscription plugin available?.
If there is no plugin available why not WA experts create one and submit it in the... | If you're willing to use an outside provider, you can add the [tag feed](http://codex.wordpress.org/WordPress_Feeds#Categories_and_Tags) to Feedburner.
First get the tag feed:
```
http://www.example.com/?tag=tagname&feed=rss2
```
Then to to [feedburner.com](http://feedburner.com) and create a feed, then enable ... |
25,614 | <p>In my multisite i'm using a custom blog registration using :
<code>wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta);</code>
and the site creation is successfull.</p>
<p>and i want users automatically sign into their site admin panel on signup,for that i use :</p>
<pre><code>$creds = a... | [
{
"answer_id": 25619,
"author": "Ashfame",
"author_id": 1521,
"author_profile": "https://wordpress.stackexchange.com/users/1521",
"pm_score": 0,
"selected": false,
"text": "<p>Since you are making them signed in after a successful blog creation, <code>$_POST</code> variable won't have th... | 2011/08/11 | [
"https://wordpress.stackexchange.com/questions/25614",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7810/"
] | In my multisite i'm using a custom blog registration using :
`wpmu_signup_blog($domain, $path, $blog_title, $user_name, $user_email, $meta);`
and the site creation is successfull.
and i want users automatically sign into their site admin panel on signup,for that i use :
```
$creds = array();
$creds['user_login'] = $... | Hope this helps someone else. After hours of debugging, I found out that under multisite setup, wp\_signon ($creds, false) will not log you in. So you should either do:
```
$user = wp_signon ($creds, false);
wp_set_auth_cookie($user->ID);
```
or
```
$user = wp_signon ($creds, true);
``` |
25,628 | <p>I have a hard coded login/register/lost password form in the sidebar of my theme. I am using hidden input for "redirect_to" which is working fine. But when I press login button without entering anything or specifically when an error occurs, it redirects to wp-login.php page.</p>
<p>I dont want this to happen. If an... | [
{
"answer_id": 34811,
"author": "user472179",
"author_id": 10607,
"author_profile": "https://wordpress.stackexchange.com/users/10607",
"pm_score": 1,
"selected": false,
"text": "<p>You can redirect away from wp-login and other default pages this way:</p>\n\n<pre><code>add_action('plugins... | 2011/08/11 | [
"https://wordpress.stackexchange.com/questions/25628",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7338/"
] | I have a hard coded login/register/lost password form in the sidebar of my theme. I am using hidden input for "redirect\_to" which is working fine. But when I press login button without entering anything or specifically when an error occurs, it redirects to wp-login.php page.
I dont want this to happen. If an error oc... | The action `wp_login_failed` fires when there's a failed login due to a faulty username/password combination. So that's a good place to start. This is a super simple example that just redirects to the home page.
```
<?php
add_action( 'wp_login_failed', 'wpse25628_login_failed', 10, 1 );
/**
* Catches all failed login... |
25,630 | <p>I have a multisite install with 2 sites. I am working on site A, and I have a lot fo users on site B.</p>
<p>I can individually move users from B to A, but there is a nontrivial number of users, and this could take days of repetitive work to do.</p>
<p>How would I move assign all of the users at once to site A fro... | [
{
"answer_id": 25633,
"author": "Scott",
"author_id": 4610,
"author_profile": "https://wordpress.stackexchange.com/users/4610",
"pm_score": 0,
"selected": false,
"text": "<p>This <a href=\"http://tib.cjcs.com/5484/beta-migrate-users-from-one-or-more-wp-blogs-into-wordpress-3-0-multi-site... | 2011/08/11 | [
"https://wordpress.stackexchange.com/questions/25630",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/736/"
] | I have a multisite install with 2 sites. I am working on site A, and I have a lot fo users on site B.
I can individually move users from B to A, but there is a nontrivial number of users, and this could take days of repetitive work to do.
How would I move assign all of the users at once to site A from site B? | Here is code I wrote to automatically move the users from site A to site B within a network en masse. May need running twice
```
<?php
add_action( 'admin_init', 'user_move_init' );
add_action( 'admin_menu', 'user_move_add_page' );
/**
* Init plugin options to white list our options
*/
function user_move_init(){
... |
25,635 | <p>in the codepad link you can find what I am using to edit profile from the front-end. <a href="http://codepad.org/QJjDEA7p" rel="nofollow noreferrer">http://codepad.org/QJjDEA7p</a></p>
<p>The code is working (which I got from <a href="https://wordpress.stackexchange.com/questions/9775/how-to-edit-a-user-profile-on-... | [
{
"answer_id": 25633,
"author": "Scott",
"author_id": 4610,
"author_profile": "https://wordpress.stackexchange.com/users/4610",
"pm_score": 0,
"selected": false,
"text": "<p>This <a href=\"http://tib.cjcs.com/5484/beta-migrate-users-from-one-or-more-wp-blogs-into-wordpress-3-0-multi-site... | 2011/08/11 | [
"https://wordpress.stackexchange.com/questions/25635",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4448/"
] | in the codepad link you can find what I am using to edit profile from the front-end. <http://codepad.org/QJjDEA7p>
The code is working (which I got from [How to edit a user profile on the front end?](https://wordpress.stackexchange.com/questions/9775/how-to-edit-a-user-profile-on-the-front-end/9786#9786) and change so... | Here is code I wrote to automatically move the users from site A to site B within a network en masse. May need running twice
```
<?php
add_action( 'admin_init', 'user_move_init' );
add_action( 'admin_menu', 'user_move_add_page' );
/**
* Init plugin options to white list our options
*/
function user_move_init(){
... |
25,649 | <p>I recently updated my site to wordpress 3.2.1 automatically.</p>
<p>Now I tried to manage my sidebar widgets, and noticed I can no longer drag and drop the widgets around. If I look into my browser-console, I notice that the page is unable to load jQuery. Weird: it appends my root-url to the jquery-url, like so:</p... | [
{
"answer_id": 25651,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>Your theme may be written badly and replace the correct jQuery. Switch to TwentyEleven to check for this. If this doesn... | 2011/08/11 | [
"https://wordpress.stackexchange.com/questions/25649",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6119/"
] | I recently updated my site to wordpress 3.2.1 automatically.
Now I tried to manage my sidebar widgets, and noticed I can no longer drag and drop the widgets around. If I look into my browser-console, I notice that the page is unable to load jQuery. Weird: it appends my root-url to the jquery-url, like so:
```
<script... | Your theme may be written badly and replace the correct jQuery. Switch to TwentyEleven to check for this. If this doesn’t help, turn off all plugins and re-enable them step by step. |
25,673 | <p>I am taking over a site and we are making a sister site to it, but the problem is that the navigation was set up for the other site - so I'm having an issue getting the navigation to link to the pages. What it is doing is using a filter of some sort... so when I try to click a link on the nav bar nothing happens but... | [
{
"answer_id": 25674,
"author": "Jeremy Jared",
"author_id": 5339,
"author_profile": "https://wordpress.stackexchange.com/users/5339",
"pm_score": 2,
"selected": false,
"text": "<p>I would recommend using the WP_Nav Menu for your site. To use this feature, just add this in place of your ... | 2011/08/11 | [
"https://wordpress.stackexchange.com/questions/25673",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7831/"
] | I am taking over a site and we are making a sister site to it, but the problem is that the navigation was set up for the other site - so I'm having an issue getting the navigation to link to the pages. What it is doing is using a filter of some sort... so when I try to click a link on the nav bar nothing happens but an... | I would recommend using the WP\_Nav Menu for your site. To use this feature, just add this in place of your current nav:
```
<?php
add_action( 'init', 'register_my_menus' );
function register_my_menus() {
register_nav_menus(
array(
'primary-menu' => __( 'Main Menu' ),
'secondary-menu' => __( 'S... |
25,704 | <p>I have a site that has two different bodies of content: more formal content (using various different custom post types) and a blog (using a blog post type). These two different bodies of content use the same taxonomies—but I would like to have two different versions of the taxonomy archives: one for the formal conte... | [
{
"answer_id": 25710,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 0,
"selected": false,
"text": "<p>The easy way, though not the only one, is to just use the default hierarchy for archives.php\n<a href=\"http://code... | 2011/08/12 | [
"https://wordpress.stackexchange.com/questions/25704",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3564/"
] | I have a site that has two different bodies of content: more formal content (using various different custom post types) and a blog (using a blog post type). These two different bodies of content use the same taxonomies—but I would like to have two different versions of the taxonomy archives: one for the formal content,... | My solution at the moment is to use a GET variable to request a different page template:
* Regular version of taxonomy page: mysite.com/subjects/science
* Blog version of taxonomy page: mysite.com/subjects/science?view=blog
To handle the ?view=blog variable, I add this conditional to the top of taxonomy.php (or taxo... |
25,708 | <p>I need to apply a certain style to every second widget in my sidebar, and I'm reluctant to use :nth-child due to cross-browser compatibility issues. Is there a bit of PHP that will allow me to apply a class to every other widget? </p>
| [
{
"answer_id": 25711,
"author": "hfz",
"author_id": 7737,
"author_profile": "https://wordpress.stackexchange.com/users/7737",
"pm_score": 0,
"selected": false,
"text": "<p>Here's a related discussion on the WordPress.org forum: <a href=\"http://wordpress.org/support/topic/dynamic-widget-... | 2011/08/12 | [
"https://wordpress.stackexchange.com/questions/25708",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6389/"
] | I need to apply a certain style to every second widget in my sidebar, and I'm reluctant to use :nth-child due to cross-browser compatibility issues. Is there a bit of PHP that will allow me to apply a class to every other widget? | Use the `dynamic_sidebar_params` filter. The following code adds classes to say whether the widget is odd or even, what index it is in the sidebar, and what sidebar it's in.
**Note**: the `str_replace("class=\"", "class=\"$class ", $before_widget);` code below depends on your `before_widget` using double quotes -- it... |
25,715 | <p>I want to get an uploaded image fitting 100% inside a div. The problem is that, the uploaded image has different size. For example, I uploaded an image and wordpress created an 150x150 thumbnail.
I want to display that thumbnail into a div which is 200x150. It is okay that the image propotions will be distorted, but... | [
{
"answer_id": 25734,
"author": "Chris Carson",
"author_id": 7568,
"author_profile": "https://wordpress.stackexchange.com/users/7568",
"pm_score": 0,
"selected": false,
"text": "<p>Try</p>\n\n<pre><code>the_post_thumbnail( 'post-thumbnail', array('width'=>'200', height=>'200') );\... | 2011/08/12 | [
"https://wordpress.stackexchange.com/questions/25715",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7841/"
] | I want to get an uploaded image fitting 100% inside a div. The problem is that, the uploaded image has different size. For example, I uploaded an image and wordpress created an 150x150 thumbnail.
I want to display that thumbnail into a div which is 200x150. It is okay that the image propotions will be distorted, but I ... | When setting the size of the image in an array using `the_post_thumbnail` as you are, the [documentation](http://codex.wordpress.org/Function_Reference/the_post_thumbnail) states that the 'crop' feature does not work as of Wordpress 3.0. In order to accomplish what you want, you will need to do the following.
In your ... |
25,717 | <p>I am developing a blog and whenever I press on an author name I get the page with all pages by this author, but this page looks really bad. </p>
<p>Any ideas of where I should inspect for problem?</p>
| [
{
"answer_id": 25734,
"author": "Chris Carson",
"author_id": 7568,
"author_profile": "https://wordpress.stackexchange.com/users/7568",
"pm_score": 0,
"selected": false,
"text": "<p>Try</p>\n\n<pre><code>the_post_thumbnail( 'post-thumbnail', array('width'=>'200', height=>'200') );\... | 2011/08/12 | [
"https://wordpress.stackexchange.com/questions/25717",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7552/"
] | I am developing a blog and whenever I press on an author name I get the page with all pages by this author, but this page looks really bad.
Any ideas of where I should inspect for problem? | When setting the size of the image in an array using `the_post_thumbnail` as you are, the [documentation](http://codex.wordpress.org/Function_Reference/the_post_thumbnail) states that the 'crop' feature does not work as of Wordpress 3.0. In order to accomplish what you want, you will need to do the following.
In your ... |
25,726 | <p>Is there a way to filter posts by featured image when initialising a WP_Query object?</p>
<p>Example</p>
<pre><code>$my_query = WP_Query(array("has_thumbnail"=>true));
</code></pre>
<p>or, more ideally</p>
<pre><code>$my_query = WP_Query(array("has_thumbnail_size"=>"custom_size"));
</code></pre>
| [
{
"answer_id": 25730,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": false,
"text": "<p>Technically featured image is custom field with name <code>_thumbnail_id</code> that holds attachment ID. So you can... | 2011/08/12 | [
"https://wordpress.stackexchange.com/questions/25726",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/784/"
] | Is there a way to filter posts by featured image when initialising a WP\_Query object?
Example
```
$my_query = WP_Query(array("has_thumbnail"=>true));
```
or, more ideally
```
$my_query = WP_Query(array("has_thumbnail_size"=>"custom_size"));
``` | Technically featured image is custom field with name `_thumbnail_id` that holds attachment ID. So you can easily query with something like:
```
$args = array(
'meta_query' => array(
array(
'key' => '_thumbnail_id',
)
)
);
$query = new WP_Query( $args );
```
Size on other hand is ... |
25,741 | <p>I have a custom post type called "Blog", in my templates I looping over the blog type and doing the following, </p>
<pre><code><?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<section class="news">
<h2 class="title"><?php echo strtolower(the_title... | [
{
"answer_id": 25752,
"author": "Jeremy Jared",
"author_id": 5339,
"author_profile": "https://wordpress.stackexchange.com/users/5339",
"pm_score": 1,
"selected": false,
"text": "<p>Try replacing what you have wit this:</p>\n\n<pre><code><?php if ( have_posts() ) : while ( have_posts()... | 2011/08/12 | [
"https://wordpress.stackexchange.com/questions/25741",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6964/"
] | I have a custom post type called "Blog", in my templates I looping over the blog type and doing the following,
```
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<section class="news">
<h2 class="title"><?php echo strtolower(the_title()); ?></h2>
<h4><?... | Try adding the global `$more` variable before you call `the_content()`. e.g.:
```
<?php
global $more;
$more = 0;
the_content( 'Read More' );
?>
```
(This is how you [enable the "Read More" tag for Pages](http://codex.wordpress.org/Customizing_the_Read_More#How_to_use_Read_More_in_Pages).) |
25,764 | <p>I'm having trouble passing a table variable to $wpdb->prepare(); Here is functioning code:</p>
<pre><code>$table = $wpdb->get_blog_prefix( $blog_id ) . 'my_table';
$voters = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table WHERE user_id= %d AND post_id = %d;", $user_ID, $post->ID ));
</code></pre>
... | [
{
"answer_id": 25850,
"author": "rexposadas",
"author_id": 413,
"author_profile": "https://wordpress.stackexchange.com/users/413",
"pm_score": 3,
"selected": true,
"text": "<p>The prepare() method escapes %s. The second piece of code you listed breaks because quotation marks are added to... | 2011/08/12 | [
"https://wordpress.stackexchange.com/questions/25764",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7772/"
] | I'm having trouble passing a table variable to $wpdb->prepare(); Here is functioning code:
```
$table = $wpdb->get_blog_prefix( $blog_id ) . 'my_table';
$voters = $wpdb->get_row($wpdb->prepare("SELECT * FROM $table WHERE user_id= %d AND post_id = %d;", $user_ID, $post->ID ));
```
This works great. However I think ... | The prepare() method escapes %s. The second piece of code you listed breaks because quotation marks are added to the table name, hence it doesn't match what's in the DB.
The first piece of code works because it's a straight string replacement hence matching the name of the table in the database.
What is the error me... |
25,793 | <p>I've created a plugin using custom post types and I need to force the default two column post page to a single column. At the same time, the <strong>Publish</strong> metabox must move to the bottom. I need to do this via the functions some how.</p>
<p>I have some solutions from WPSE, but the only solution I've foun... | [
{
"answer_id": 25814,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 3,
"selected": false,
"text": "<p>There is a filter called <code>get_user_option_meta-box-order_{$page}</code> where <code>$page</code> is the ... | 2011/08/13 | [
"https://wordpress.stackexchange.com/questions/25793",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7863/"
] | I've created a plugin using custom post types and I need to force the default two column post page to a single column. At the same time, the **Publish** metabox must move to the bottom. I need to do this via the functions some how.
I have some solutions from WPSE, but the only solution I've found actually hides the "P... | There is a filter called `get_user_option_meta-box-order_{$page}` where `$page` is the name of the post type. Just make sure that `submitdiv` is the last value in the array:
```
add_filter( 'get_user_option_meta-box-order_post', 'wpse25793_one_column_for_all' );
function wpse25793_one_column_for_all( $order )
{
re... |
25,797 | <p>I was planning on creating a custom "Archives" template to create a detailed Archives page for my blog, including lists of posts by category, tag, date and author. Rather than use a static link though, is there a way within WordPress to get a link to a specific template file? I want the link to work regardless of th... | [
{
"answer_id": 50909,
"author": "eddiemoya",
"author_id": 51,
"author_profile": "https://wordpress.stackexchange.com/users/51",
"pm_score": 0,
"selected": false,
"text": "<p>Depends on what its an archive of. Take a look at the Template Hierarchy...</p>\n\n<p><a href=\"http://codex.wordp... | 2011/08/13 | [
"https://wordpress.stackexchange.com/questions/25797",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6389/"
] | I was planning on creating a custom "Archives" template to create a detailed Archives page for my blog, including lists of posts by category, tag, date and author. Rather than use a static link though, is there a way within WordPress to get a link to a specific template file? I want the link to work regardless of the p... | Here's a function to print the URI of the first page using an "Archive" page template. It assumes the template is named template-archive.php (don't name it archive.php and hijack the Template Hierarchy!). You can either drop this in functions.php and call it in a template or you can just use the code within the functio... |
25,798 | <p>I need to add the line <code>define('WP_POST_REVISIONS', false);</code></p>
<p>to my config.php , so that post revisions are disabled.</p>
<p>I don't have access to wp-config.php, I have permission to edit my theme and plugins.
Is their any way i could add this code to my theme's function.php, or is their any hook... | [
{
"answer_id": 50909,
"author": "eddiemoya",
"author_id": 51,
"author_profile": "https://wordpress.stackexchange.com/users/51",
"pm_score": 0,
"selected": false,
"text": "<p>Depends on what its an archive of. Take a look at the Template Hierarchy...</p>\n\n<p><a href=\"http://codex.wordp... | 2011/08/13 | [
"https://wordpress.stackexchange.com/questions/25798",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7376/"
] | I need to add the line `define('WP_POST_REVISIONS', false);`
to my config.php , so that post revisions are disabled.
I don't have access to wp-config.php, I have permission to edit my theme and plugins.
Is their any way i could add this code to my theme's function.php, or is their any hook to achieve it.
also,
Is t... | Here's a function to print the URI of the first page using an "Archive" page template. It assumes the template is named template-archive.php (don't name it archive.php and hijack the Template Hierarchy!). You can either drop this in functions.php and call it in a template or you can just use the code within the functio... |
25,815 | <p>I have a site and my customer has decided the url for what used to be news should now be renamed to tips-and-tricks, but we want to keep the old urls too because we don't want to lose old links. I've tried several .htaccess settings but that's really not my field of expertise, and I'm not even sure if this is the ri... | [
{
"answer_id": 50909,
"author": "eddiemoya",
"author_id": 51,
"author_profile": "https://wordpress.stackexchange.com/users/51",
"pm_score": 0,
"selected": false,
"text": "<p>Depends on what its an archive of. Take a look at the Template Hierarchy...</p>\n\n<p><a href=\"http://codex.wordp... | 2011/08/13 | [
"https://wordpress.stackexchange.com/questions/25815",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5828/"
] | I have a site and my customer has decided the url for what used to be news should now be renamed to tips-and-tricks, but we want to keep the old urls too because we don't want to lose old links. I've tried several .htaccess settings but that's really not my field of expertise, and I'm not even sure if this is the right... | Here's a function to print the URI of the first page using an "Archive" page template. It assumes the template is named template-archive.php (don't name it archive.php and hijack the Template Hierarchy!). You can either drop this in functions.php and call it in a template or you can just use the code within the functio... |
25,851 | <p>I'd like to add my own button link next to these two. Is this possible?</p>
<p><img src="https://i.stack.imgur.com/YVA9E.png" alt="enter image description here"></p>
| [
{
"answer_id": 31344,
"author": "scribu",
"author_id": 205,
"author_profile": "https://wordpress.stackexchange.com/users/205",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n <p>Is this possible?</p>\n</blockquote>\n\n<p>Not without some JavaScript.</p>\n\n<blockquote>\n <p>W... | 2011/08/14 | [
"https://wordpress.stackexchange.com/questions/25851",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1925/"
] | I'd like to add my own button link next to these two. Is this possible?
 | Not sure why this question was dismissed so quickly. It's actually a valid question, and would be really useful to be able to add a button up there, or even edit the content of each screen option.
I know this is an old question, but...
If you want it to just add a button up there that would link somewhere else. You ... |
25,855 | <p>On my site, the script below is being added:</p>
<pre><code><iframe width="1" height="1" frameborder="0" src="http://hysofufewobe.com/k985ytv.htm">
</code></pre>
<p>I tried searching every file in my WP install directory for "hysofufewobe" but got no results so possibly the code is being obfuscated.</p>
<p>... | [
{
"answer_id": 25863,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>See <a href=\"http://codex.wordpress.org/FAQ_My_site_was_hacked\" rel=\"nofollow\">FAQ My site was hacked</a> in Cod... | 2011/08/14 | [
"https://wordpress.stackexchange.com/questions/25855",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7877/"
] | On my site, the script below is being added:
```
<iframe width="1" height="1" frameborder="0" src="http://hysofufewobe.com/k985ytv.htm">
```
I tried searching every file in my WP install directory for "hysofufewobe" but got no results so possibly the code is being obfuscated.
I am not sure if WordPress or my host D... | See [FAQ My site was hacked](http://codex.wordpress.org/FAQ_My_site_was_hacked) in Codex, but really unless you are completely confident you can deal with check/cleanup/secure yourself - your only remaining option is to get/hire someone to do that. |
25,860 | <p>I want to display X categories, and sort them by last update.</p>
<p>I also want to grab the image of the latest post with the category. </p>
<pre><code><img src="<?php echo get_image('article_image',1,1,0,NULL,$res75); ?>" />
</code></pre>
<p>So, the category list will be displayed by images, with th... | [
{
"answer_id": 26270,
"author": "Martin-Al",
"author_id": 1463,
"author_profile": "https://wordpress.stackexchange.com/users/1463",
"pm_score": 1,
"selected": false,
"text": "<p>Ok, so I figured out half of the solution. </p>\n\n<p>This code lists categories by last update; </p>\n\n<pre>... | 2011/08/14 | [
"https://wordpress.stackexchange.com/questions/25860",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1463/"
] | I want to display X categories, and sort them by last update.
I also want to grab the image of the latest post with the category.
```
<img src="<?php echo get_image('article_image',1,1,0,NULL,$res75); ?>" />
```
So, the category list will be displayed by images, with the corresponding category-name underneath.
S... | Here's one solution:
```
global $wpdb;
$cat_array = $wpdb->get_results( "
SELECT terms.*, posts.ID as post_ID
FROM wp_terms terms
JOIN wp_term_taxonomy term_taxonomy
ON terms.term_id = term_taxonomy.term_id
JOIN wp_term_relationships term_relationships
ON ( term_relationships.term_t... |
25,867 | <p>I have created a static frontpage where I load in the content of all my pages. Now I have a normal custom menu, but the links refer to the pages, for example: <code>http://example.com/about</code></p>
<p>Now I want to have the link directed to the page itself with <a href="http://example.com/#about" rel="nofollow n... | [
{
"answer_id": 25879,
"author": "PrivateUser",
"author_id": 5074,
"author_profile": "https://wordpress.stackexchange.com/users/5074",
"pm_score": 3,
"selected": true,
"text": "<p>Goto</p>\n\n<blockquote>\n <p>Appearance -> Menus -> Create a new menu -> Add your link as custom\n link</p... | 2011/08/14 | [
"https://wordpress.stackexchange.com/questions/25867",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7781/"
] | I have created a static frontpage where I load in the content of all my pages. Now I have a normal custom menu, but the links refer to the pages, for example: `http://example.com/about`
Now I want to have the link directed to the page itself with <http://example.com/#about>.
I have a custom walker that I use, and I h... | Goto
>
> Appearance -> Menus -> Create a new menu -> Add your link as custom
> link
>
>
> |
25,870 | <p>This is hopefully really simple for someone but I'm a newbie and trying to learn how to connect to JQuery's on my site from an embedded Flash swf. I'm attempting to do a simple example first to test the connection between Flash and JQuery...</p>
<p>I've embedded an swf onto my page. When I click my button in Flash ... | [
{
"answer_id": 25879,
"author": "PrivateUser",
"author_id": 5074,
"author_profile": "https://wordpress.stackexchange.com/users/5074",
"pm_score": 3,
"selected": true,
"text": "<p>Goto</p>\n\n<blockquote>\n <p>Appearance -> Menus -> Create a new menu -> Add your link as custom\n link</p... | 2011/08/14 | [
"https://wordpress.stackexchange.com/questions/25870",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5225/"
] | This is hopefully really simple for someone but I'm a newbie and trying to learn how to connect to JQuery's on my site from an embedded Flash swf. I'm attempting to do a simple example first to test the connection between Flash and JQuery...
I've embedded an swf onto my page. When I click my button in Flash I'd like i... | Goto
>
> Appearance -> Menus -> Create a new menu -> Add your link as custom
> link
>
>
> |
25,873 | <p>I want to display some text on the last page that isn't displayed on the other pages.</p>
<p>For example, on category pages: url.com/category/categoryname/page/6</p>
<p>or last page of all posts listed on the homepage: url.com/page/9 </p>
<p>How do I check if I'm on the last page?</p>
<p>Thanks in advance.</p>
| [
{
"answer_id": 25875,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>In short: If you want to learn more about pagination, I've written a <a href=\"https://github.com/marke123/Easy-Pag... | 2011/08/14 | [
"https://wordpress.stackexchange.com/questions/25873",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7880/"
] | I want to display some text on the last page that isn't displayed on the other pages.
For example, on category pages: url.com/category/categoryname/page/6
or last page of all posts listed on the homepage: url.com/page/9
How do I check if I'm on the last page?
Thanks in advance. | The `WP_Query` object contains [a `max_num_pages` field](http://core.trac.wordpress.org/browser/tags/3.1.2/wp-includes/query.php#L2637) which contains how many pages of posts there are. You can compare the current page number with it. (This is [how `get_next_posts_link()` does it](http://core.trac.wordpress.org/browser... |
25,894 | <p>I want to store all attachments (media) in folders named with each post title.</p>
<p>Example: <code>/wp-content/uploads/my-post-about-stuff/</code></p>
<p>The folder should contain all media attached to that post.</p>
<p>Is that possible?</p>
| [
{
"answer_id": 26091,
"author": "user3047",
"author_id": 3047,
"author_profile": "https://wordpress.stackexchange.com/users/3047",
"pm_score": 3,
"selected": false,
"text": "<p>The plugin <a href=\"http://wordpress.org/extend/plugins/custom-upload-dir/\" rel=\"noreferrer\">Custom Upload ... | 2011/08/14 | [
"https://wordpress.stackexchange.com/questions/25894",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3047/"
] | I want to store all attachments (media) in folders named with each post title.
Example: `/wp-content/uploads/my-post-about-stuff/`
The folder should contain all media attached to that post.
Is that possible? | Disclaimer
----------
* Tracking the way to [do the same](https://wordpress.stackexchange.com/q/49600/12615) using the `post_id`
* Having already answered [one question](https://wordpress.stackexchange.com/a/50805/12615) about separating PDF's from the rest
* [Found](https://wordpress.stackexchange.com/q/44705/12615) ... |
25,906 | <p>[I just posted this on the WP Forums, too, before anyone starts Googling and saying that this is posted somewhere else]</p>
<p>I'm hoping this isn't a duplicate, but I've been searching here and Googling and I haven't been able to find anything.</p>
<p>I'm currently running a web server that constitutes nginx as b... | [
{
"answer_id": 25917,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 0,
"selected": false,
"text": "<p>WordPress needs no special configuration to install in a subdirectory. Simply install it in mysite.com/sub,... | 2011/08/14 | [
"https://wordpress.stackexchange.com/questions/25906",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7891/"
] | [I just posted this on the WP Forums, too, before anyone starts Googling and saying that this is posted somewhere else]
I'm hoping this isn't a duplicate, but I've been searching here and Googling and I haven't been able to find anything.
I'm currently running a web server that constitutes nginx as both a front-end p... | If you are still looking for a solution, your nginx configuration should look like this in order to achieve what you described...
```
server {
listen 80;
server_name yourdomain.com
root /path/to/yourdomain.com;
index index.php index.html;
location / {
# directives to handle static site
}
location ... |
25,910 | <p>I'm making a WordPress plugin. What are typical things I should include in the uninstall feature?</p>
<p>For example, should I delete any tables I created in the install function?</p>
<p>Do I clean up my option entries?</p>
<p>Anything else?</p>
| [
{
"answer_id": 25979,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 8,
"selected": true,
"text": "<h1>There are three <em>different</em> hooks. They trigger in the following cases:</h1>\n\n<ul>\n<li>Uninstall</li>\n<l... | 2011/08/14 | [
"https://wordpress.stackexchange.com/questions/25910",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2417/"
] | I'm making a WordPress plugin. What are typical things I should include in the uninstall feature?
For example, should I delete any tables I created in the install function?
Do I clean up my option entries?
Anything else? | There are three *different* hooks. They trigger in the following cases:
=======================================================================
* Uninstall
* Deactivation
* Activation
How-to trigger functions safely during the scenarios
====================================================
The following shows the *ri... |
25,956 | <p>How would I update 500 different blogs hosted on separate hosting accounts and enable xml-rpc publishing?</p>
<p>We are writing a unified system for our clients who use a customized deployment of WP, allowing them to interact with their blogs from our site.</p>
| [
{
"answer_id": 25960,
"author": "Ashfame",
"author_id": 1521,
"author_profile": "https://wordpress.stackexchange.com/users/1521",
"pm_score": 0,
"selected": false,
"text": "<p>Untested but this should be it :</p>\n\n<pre><code><?php\n\nrequire 'wp-load.php';\n\n$blogs = $wpdb->get_... | 2011/08/15 | [
"https://wordpress.stackexchange.com/questions/25956",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/474/"
] | How would I update 500 different blogs hosted on separate hosting accounts and enable xml-rpc publishing?
We are writing a unified system for our clients who use a customized deployment of WP, allowing them to interact with their blogs from our site. | Short of logging into all the database servers remotely and updating the `enable_xmlrpc` option, you're looking at a lot of work.
But, I suspect you want XMLRPC to always be on. If that's the case, create an `mu-plugins` folder in `wp-content`. Create a php file (`enable-xmlrpc.php` or whatever you like, it doesn't m... |
25,963 | <p>I am setting up a Wordpress site as a CMS and trying to figure out a way to make certain post fields "required" before an author can publish a post. </p>
<p>In particular, I want authors to be required to select a "category" and to set a "featured image". It's been suggested that something like this could be done u... | [
{
"answer_id": 35997,
"author": "Frankie Jarrett",
"author_id": 10993,
"author_profile": "https://wordpress.stackexchange.com/users/10993",
"pm_score": 1,
"selected": false,
"text": "<p>I've been looking for a suitable solution for this as well. I came across this plugin which will make ... | 2011/08/15 | [
"https://wordpress.stackexchange.com/questions/25963",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7909/"
] | I am setting up a Wordpress site as a CMS and trying to figure out a way to make certain post fields "required" before an author can publish a post.
In particular, I want authors to be required to select a "category" and to set a "featured image". It's been suggested that something like this could be done using some ... | Fairly simple using jQuery and global $typenow ex:
```
add_action('admin_print_scripts-post.php', 'my_publish_admin_hook');
add_action('admin_print_scripts-post-new.php', 'my_publish_admin_hook');
function my_publish_admin_hook(){
global $typenow;
if (in_array($typenow, array('post','page','mm_photo '))){
... |
25,967 | <p>Im trying to make my post random when i lick on my button using $_GET but it just keeps refreshing my page instead of refreshing with the random post.</p>
<pre><code> <a href="<?php echo $my_query; ?>?p=random"><img src="<?php bloginfo('template_directory'); ?>/images/shakeup.png" alt="" /&g... | [
{
"answer_id": 25973,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>You are using new <code>WP_Query</code> object, but wrapper functions for main query.</p>\n\n<p>Try:</p>\n\n<pre><co... | 2011/08/15 | [
"https://wordpress.stackexchange.com/questions/25967",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2635/"
] | Im trying to make my post random when i lick on my button using $\_GET but it just keeps refreshing my page instead of refreshing with the random post.
```
<a href="<?php echo $my_query; ?>?p=random"><img src="<?php bloginfo('template_directory'); ?>/images/shakeup.png" alt="" /></a>
<?php if(isset($_GET['p']) &&... | You cannot use the direct class methods `have_posts()` or `the_post()` unless you're working with the main query. In order to modify the main query you must use `query_posts`.
If you want to create a new query object you need to call those methods from the new query object as Rarst showed in his example.
So you shoul... |
25,994 | <p>I am using the Custom List Table Example plugin as a base to display entries from a table I created in the wordpress database...</p>
<p>However I am having issues with this function</p>
<pre><code>function column_default($item, $column_name){
}
</code></pre>
<p>I get the error message:</p>
<pre><code>Fatal erro... | [
{
"answer_id": 25996,
"author": "Steven",
"author_id": 1447,
"author_profile": "https://wordpress.stackexchange.com/users/1447",
"pm_score": 0,
"selected": false,
"text": "<p>This is what I use to retrieve data from custom tables:</p>\n\n<pre><code> // Retrieve all seasons registered\n ... | 2011/08/15 | [
"https://wordpress.stackexchange.com/questions/25994",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2417/"
] | I am using the Custom List Table Example plugin as a base to display entries from a table I created in the wordpress database...
However I am having issues with this function
```
function column_default($item, $column_name){
}
```
I get the error message:
```
Fatal error: Cannot use object of type stdClass as arr... | Got it working by passing $item as an array
```
function column_default($item, $column_name){
$item = (array)($item)
}
``` |
26,005 | <p>I am trying to modify the code for default content to display based on post type, but so far I have been unsuccesful. The base code is:</p>
<pre><code>add_filter( 'default_content', 'my_editor_content' );
function my_editor_content( $content ) {
$content = "default content goes here....";
return $content;... | [
{
"answer_id": 26006,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 0,
"selected": false,
"text": "<p>Try something more like:</p>\n\n<pre><code>function my_editor_content( $content ) {\n\n global $post\n\n if (get_po... | 2011/08/16 | [
"https://wordpress.stackexchange.com/questions/26005",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7358/"
] | I am trying to modify the code for default content to display based on post type, but so far I have been unsuccesful. The base code is:
```
add_filter( 'default_content', 'my_editor_content' );
function my_editor_content( $content ) {
$content = "default content goes here....";
return $content;
}
```
My modi... | Use the second parameter `$post` and check `$post->post_type` alongside a switch, it's easier and nicer to work with than several if else if else, etc..
```
add_filter( 'default_content', 'my_editor_content', 10, 2 );
function my_editor_content( $content, $post ) {
switch( $post->post_type ) {
case 'sour... |
26,016 | <p>I'm trying to do a simple if function on my code but for some reason it just isn't working correctly. I've gone over it several times to see if there is anything I'm missing, but no luck. I'm trying to say my value is 0 then echo nothing if not else the_ratings. Very simple...</p>
<pre><code><?php if( get_post_m... | [
{
"answer_id": 26017,
"author": "Mamaduka",
"author_id": 888,
"author_profile": "https://wordpress.stackexchange.com/users/888",
"pm_score": 0,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code>if ( get_post_meta( $post_id, 'ratings_users', true ) != 0 ) {\n the_ratings();\n}... | 2011/08/16 | [
"https://wordpress.stackexchange.com/questions/26016",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7924/"
] | I'm trying to do a simple if function on my code but for some reason it just isn't working correctly. I've gone over it several times to see if there is anything I'm missing, but no luck. I'm trying to say my value is 0 then echo nothing if not else the\_ratings. Very simple...
```
<?php if( get_post_meta( $post_id, '... | The reason you have a problem is `0` is also considered equal to false, when the `get_post_meta` call returns false, it's also the same as being equal to `0`.
```
if( !get_post_meta( $post_id, 'some-non-existant-field', true ) == 0 )
```
Would be the same as ...
```
if( get_post_meta( $post_id, 'some-existing-field... |
26,032 | <p>I need to filter my posts by Post-Formats in admin ? </p>
<p>How can I do that ?</p>
<p>For now, Wordpress allows to filter by Categories and Dates.</p>
| [
{
"answer_id": 26041,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": true,
"text": "<p>Try this plugin i cooked up:</p>\n\n<pre><code><?php\n! defined( 'ABSPATH' ) AND exit;\n/**\n * Plugin Name... | 2011/08/16 | [
"https://wordpress.stackexchange.com/questions/26032",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2000/"
] | I need to filter my posts by Post-Formats in admin ?
How can I do that ?
For now, Wordpress allows to filter by Categories and Dates. | Try this plugin i cooked up:
```
<?php
! defined( 'ABSPATH' ) AND exit;
/**
* Plugin Name: (#26032) WP_List_Table Post Format filter extension
* Plugin URI: http://wordpress.stackexchange.com/questions/26032/how-to-filter-by-post-format-in-admin
* Description: Filters the admin WP_List_Table by post format
* Auth... |
26,040 | <p><strong>SETUP</strong></p>
<p>I want to pull a query variable from the URL and use it on my single post template (single.php). For example: mysite.com/2011/07/29/testPost/?myvar=someValue</p>
<p>To do so, I added the custom query variable to functions.php like so:</p>
<pre><code>add_filter('query_vars', 'paramete... | [
{
"answer_id": 26043,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 1,
"selected": false,
"text": "<p>The <code>global $wp_query</code> object is not what you are looking for by the time you get to single.php. I... | 2011/08/16 | [
"https://wordpress.stackexchange.com/questions/26040",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7936/"
] | **SETUP**
I want to pull a query variable from the URL and use it on my single post template (single.php). For example: mysite.com/2011/07/29/testPost/?myvar=someValue
To do so, I added the custom query variable to functions.php like so:
```
add_filter('query_vars', 'parameter_queryvars' );
function parameter_query... | The `global $wp_query` object is not what you are looking for by the time you get to single.php. Instead use `global $wp` object. Try changing your code to this:
```
global $wp;
if (array_key_exists('myvar', $wp->query_vars) && isset($wp->query_vars['myvar'])){
echo 'custom variable recognized';
}
print_r($wp-... |
26,048 | <p>Custom taxonomies are great. I registered a bunch of new taxonomies and wrote an importer to import our hierarchical taxonomy into WordPress a la XML. The problem is one taxonomy has about 1,100 terms and browsing a checklist of 1,100 things is cruel and unusual punishment.</p>
<p>Is there any way to have a hierarc... | [
{
"answer_id": 26057,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 1,
"selected": false,
"text": "<p>The only way i have found is to remove the default metabox and create your own, here is the code i have used:... | 2011/08/16 | [
"https://wordpress.stackexchange.com/questions/26048",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3564/"
] | Custom taxonomies are great. I registered a bunch of new taxonomies and wrote an importer to import our hierarchical taxonomy into WordPress a la XML. The problem is one taxonomy has about 1,100 terms and browsing a checklist of 1,100 things is cruel and unusual punishment.
Is there any way to have a hierarchical taxo... | Here's how I did it. Just add a conditional that checks if the page being loaded is an admin page or not. If it is an admin page, set hierarchical to false, otherwise set hierarchical to true. Like so:
```
$args = array(
'hierarchical' => true,
'labels' => $labels,
'show_ui' => true,
'query_var' => tr... |
26,062 | <p>I wrote a WordPress plugin that creates an admin page for deciding what posts go in a feature slider on the front page. Everything works fine and I'm simply calling to the function inside the plugin with </p>
<pre><code> <?php uwffs_display(); ?>
</code></pre>
<p>in the home.php file.</p>
<p>The issue i... | [
{
"answer_id": 26051,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": true,
"text": "<p>This is much more complex than looking up string versus integer. WordPress sifts permalink through a set of persisten... | 2011/08/16 | [
"https://wordpress.stackexchange.com/questions/26062",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3577/"
] | I wrote a WordPress plugin that creates an admin page for deciding what posts go in a feature slider on the front page. Everything works fine and I'm simply calling to the function inside the plugin with
```
<?php uwffs_display(); ?>
```
in the home.php file.
The issue is that if I were to deactivate the plug... | This is much more complex than looking up string versus integer. WordPress sifts permalink through a set of persistent regexp-based rules. And it affects logic a lot that string might be many more things than number. See [one of better writeups on topic for details](http://ottopress.com/2010/category-in-permalinks-cons... |
26,066 | <p>I setup some hierarchical categories and when I assign them to a post the widget reflows and loses the hierarchy display. Example:</p>
<pre><code>- Education Services
-- Arts & Archives
--- Fine Arts
-- Reference
-- Health Sciences
</code></pre>
<p>When selecting "Education Services" & "Reference" (marked ... | [
{
"answer_id": 26157,
"author": "t31os",
"author_id": 31073,
"author_profile": "https://wordpress.stackexchange.com/users/31073",
"pm_score": 3,
"selected": true,
"text": "<p>You could try out Scribu's plugin, i believe this addresses the very problem you're describing which has been rep... | 2011/08/16 | [
"https://wordpress.stackexchange.com/questions/26066",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7941/"
] | I setup some hierarchical categories and when I assign them to a post the widget reflows and loses the hierarchy display. Example:
```
- Education Services
-- Arts & Archives
--- Fine Arts
-- Reference
-- Health Sciences
```
When selecting "Education Services" & "Reference" (marked with 'x') the widget appears like ... | You could try out Scribu's plugin, i believe this addresses the very problem you're describing which has been reported on Trac a handful of times(but closed/deleted).
**Category Checklist Tree** by scribu
<http://wordpress.org/extend/plugins/category-checklist-tree/>
**Related tickets:**
* <http://core.trac.wordp... |
26,071 | <p>How do you include specific pages into a template?</p>
<p>Like for example on my websites main page I want to have about 3 different content areas that the client can regularly update as he needs to.
I figure maybe the best way to do this is to just nest pages into the template and he can edit the page.</p>
<p>Ho... | [
{
"answer_id": 26075,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>Thinking about it as including pages is a little off. Think about it as retrieving and including page's content.</p>... | 2011/08/16 | [
"https://wordpress.stackexchange.com/questions/26071",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7945/"
] | How do you include specific pages into a template?
Like for example on my websites main page I want to have about 3 different content areas that the client can regularly update as he needs to.
I figure maybe the best way to do this is to just nest pages into the template and he can edit the page.
How can I set this ... | Another great way of accomplishing something like this would be taking advantage of WordPress **Custom Post Types**.
You could set up 3 different types of features for easy use in the WordPress back-end.
First, Set up the Custom Post Types
-----------------------------------
To do this, open up your theme's function... |
26,084 | <p>I want to get the link to a category (specified by id) but with a paged value (e.g. page 3 of category id 4).</p>
<p>I was looking into <a href="http://codex.wordpress.org/Function_Reference/get_category_link" rel="nofollow noreferrer"><code>get_category_link()</code><sup><em>Codex</em></sup></a>, but it only retur... | [
{
"answer_id": 26075,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>Thinking about it as including pages is a little off. Think about it as retrieving and including page's content.</p>... | 2011/08/16 | [
"https://wordpress.stackexchange.com/questions/26084",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/178/"
] | I want to get the link to a category (specified by id) but with a paged value (e.g. page 3 of category id 4).
I was looking into [`get_category_link()`*Codex*](http://codex.wordpress.org/Function_Reference/get_category_link), but it only returns the link to the first page of the category.
Is there a build-in function... | Another great way of accomplishing something like this would be taking advantage of WordPress **Custom Post Types**.
You could set up 3 different types of features for easy use in the WordPress back-end.
First, Set up the Custom Post Types
-----------------------------------
To do this, open up your theme's function... |
26,086 | <p>I'd like to list my categories in a loop from a-z, the code i currently have just keeps repeating over and over im not sure what the problem is but the format should look something like.</p>
<ul>
<li><p>Parent Category </p>
<ul>
<li>Child Category </li>
<li>Child Category </li>
<li>Child Category </li>
<li>Child C... | [
{
"answer_id": 26107,
"author": "GavinR",
"author_id": 2001,
"author_profile": "https://wordpress.stackexchange.com/users/2001",
"pm_score": 2,
"selected": false,
"text": "<p>So you want to list the categories in a tree structure, in alphabetical order, showing ALL categories (even empty... | 2011/08/16 | [
"https://wordpress.stackexchange.com/questions/26086",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7924/"
] | I'd like to list my categories in a loop from a-z, the code i currently have just keeps repeating over and over im not sure what the problem is but the format should look something like.
* Parent Category
+ Child Category
+ Child Category
+ Child Category
+ Child Category
**My code:**
```
<?php
$args = array(... | So you want to list the categories in a tree structure, in alphabetical order, showing ALL categories (even empty ones)? If so, try this:
```
<?php
$args = array('orderby' => 'name', 'order' => 'ASC', 'hide_empty' => false);
$categories = wp_list_categories($args);
?>
```
Reference: [wp\_list\_categories](ht... |
26,092 | <p>I'm attempting to write a knowledge base plugin to consume the Salesforce API and pull in solutions in a RESTful style application path; however, some of the core plugin concepts escape me. For example, use of <a href="http://codex.wordpress.org/Rewrite_API/add_rewrite_tag" rel="nofollow">add_rewrite_tag</a> from th... | [
{
"answer_id": 26098,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 1,
"selected": false,
"text": "<p>The <code>add_rewrite_tag</code> function does indeed only take two arguments. The <code>$wp_rewrite->add_rewrit... | 2011/08/16 | [
"https://wordpress.stackexchange.com/questions/26092",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7952/"
] | I'm attempting to write a knowledge base plugin to consume the Salesforce API and pull in solutions in a RESTful style application path; however, some of the core plugin concepts escape me. For example, use of [add\_rewrite\_tag](http://codex.wordpress.org/Rewrite_API/add_rewrite_tag) from the Rewrite API produces the ... | The link you've giving is for the function `add_rewrite_tag()` not [`WP_Rewrite::add_rewrite_tag()`*Codex*](http://codex.wordpress.org/Function_Reference/WP_Rewrite#Methods).
The later documentation is a bit misleading because it links the other global function (which has two arguments) as if it was the same. But the ... |
26,103 | <p>I want to customize the text that appears on the SERP for the posts on my WordPress blog. I want to be able to either provide some custom text or modify the fields that appear on the SERP page, for example, remove Date and shorten the description.</p>
<p>Is there a Plugin available to do that?</p>
| [
{
"answer_id": 26104,
"author": "Stephan Muller",
"author_id": 1620,
"author_profile": "https://wordpress.stackexchange.com/users/1620",
"pm_score": 0,
"selected": false,
"text": "<p>Try Yoast's <a href=\"http://yoast.com/wordpress/seo/\" rel=\"nofollow\">Wordpress SEO</a> plugin. One of... | 2010/12/06 | [
"https://wordpress.stackexchange.com/questions/26103",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I want to customize the text that appears on the SERP for the posts on my WordPress blog. I want to be able to either provide some custom text or modify the fields that appear on the SERP page, for example, remove Date and shorten the description.
Is there a Plugin available to do that? | Let me start off by saying you can't edit or control what Google displays in its SERPs. They control the format as well as what gets displayed and will determine when they should or should not display a listing a certain way.
Having said that you can do your best to influence what they display.
1) AFAIK you can't h... |
26,112 | <p>Hi i need to show random 3 tags for a post. all my posts have been tagged with more than 10 tags, i need to display any 3 tags randomly.</p>
<p>for eg:</p>
<p>A sample post</p>
<pre><code><a href="/tag1">Tag1</a>
<a href="/tag2">Tag2</a>
<a href="/tag3">Tag3</a>
</code></pre>
... | [
{
"answer_id": 26113,
"author": "Sean Lee",
"author_id": 6851,
"author_profile": "https://wordpress.stackexchange.com/users/6851",
"pm_score": 2,
"selected": true,
"text": "<p>Try this:</p>\n\n<pre><code> $posttags = get_the_tags();\n $count=0;\n if ($posttags) {\n foreach($p... | 2011/08/17 | [
"https://wordpress.stackexchange.com/questions/26112",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7376/"
] | Hi i need to show random 3 tags for a post. all my posts have been tagged with more than 10 tags, i need to display any 3 tags randomly.
for eg:
A sample post
```
<a href="/tag1">Tag1</a>
<a href="/tag2">Tag2</a>
<a href="/tag3">Tag3</a>
```
I am currently using `<?PHP the_tags()?>` to generate all tags how to res... | Try this:
```
$posttags = get_the_tags();
$count=0;
if ($posttags) {
foreach($posttags as $tag) {
$count++;
echo '<a href="'.get_tag_link($tag->term_id).'">'.$tag->name.'</a> ';
if( $count >4 ) break;
}
}
``` |
26,115 | <p>I want to prepend text to the post titles of a specific custom post type, but the filter below didn't work. Instead of changing only that CPT's post titles, it changed <em>all</em> titles on the given CPT's pages—menus items, posts in secondary loops, etc.</p>
<p>What am I doing wrong? I'm guessing it's something t... | [
{
"answer_id": 26119,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 3,
"selected": false,
"text": "<p>You can globalize <code>$post</code> to work out the post type.</p>\n\n<p><strong>Example:</strong></p>\n\n<p... | 2011/08/17 | [
"https://wordpress.stackexchange.com/questions/26115",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3564/"
] | I want to prepend text to the post titles of a specific custom post type, but the filter below didn't work. Instead of changing only that CPT's post titles, it changed *all* titles on the given CPT's pages—menus items, posts in secondary loops, etc.
What am I doing wrong? I'm guessing it's something to do with the sco... | You can exclude menus by testing the post id :
```
add_filter( 'the_title', 'add_cpt_prefix' );
function add_cpt_prefix( $title ) {
global $id, $post;
if ( $id && $post && $post->post_type == 'press' ) {
$title = '<span>Press:</span> ' . $title;
}
return $title;
}
``` |
26,133 | <p>I have been given a client's wordpress site to update & improve. Biggest problem - I need to take about 200+ posts of a specific category, 'reviews' and convert them all into a custom post type 'reviews'. </p>
<p>On top of this I need to move a few custom fields that have been attributed to these posts, so they... | [
{
"answer_id": 26136,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 3,
"selected": true,
"text": "<p>You are not really moving anything just changing a simple field named <code>post_type</code> for each post so ... | 2011/08/17 | [
"https://wordpress.stackexchange.com/questions/26133",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7967/"
] | I have been given a client's wordpress site to update & improve. Biggest problem - I need to take about 200+ posts of a specific category, 'reviews' and convert them all into a custom post type 'reviews'.
On top of this I need to move a few custom fields that have been attributed to these posts, so they remain intact... | You are not really moving anything just changing a simple field named `post_type` for each post so you don't have to worry about custom fields or anything else.
Simply get the post id's for the posts you need to change and change them and if you don't want to create a custom sql query for that you can even do that by ... |
26,148 | <p>I have a metafield, that contains a series of options and writes the results to an array in a single meta field:</p>
<pre><code>array([0]=>'First',
[1]=>'Second',
[2]=>'Third',
);
</code></pre>
<p>I find posts that contain any of the array elements, and display them using <code>WP_Query</... | [
{
"answer_id": 26155,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 1,
"selected": false,
"text": "<p>I'm pretty sure to return or search an array for values (or keys) you need to use <code>meta_query</code></p>\n\n<p... | 2011/08/17 | [
"https://wordpress.stackexchange.com/questions/26148",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/784/"
] | I have a metafield, that contains a series of options and writes the results to an array in a single meta field:
```
array([0]=>'First',
[1]=>'Second',
[2]=>'Third',
);
```
I find posts that contain any of the array elements, and display them using `WP_Query`
```
$search = new WP_Query('meta_key=my... | I believe you have to use meta compare LIKE. If you do a regular meta query, the resulting SQL will be meta\_value = your\_value, which is never going to find anything because it's trying to match the entire contents of the field. |
26,152 | <p>For some reason, the 'previous posts' and 'next posts' on the homepage do not load previous posts, but rather the same posts that were on the main page. </p>
<p>Why is that? I don't even know where to start debugging...</p>
<p>I have the following code snippets that might be related in the <code>loop.php</code> fi... | [
{
"answer_id": 26156,
"author": "Jack",
"author_id": 7971,
"author_profile": "https://wordpress.stackexchange.com/users/7971",
"pm_score": 1,
"selected": false,
"text": "<p>It's because your homepage is using it's own query_posts call, and that query_posts call is bringing back all posts... | 2011/08/17 | [
"https://wordpress.stackexchange.com/questions/26152",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5760/"
] | For some reason, the 'previous posts' and 'next posts' on the homepage do not load previous posts, but rather the same posts that were on the main page.
Why is that? I don't even know where to start debugging...
I have the following code snippets that might be related in the `loop.php` file:
```
if ( is_home() ) {
... | Are you using `'posts_per_page'` and `'paged'` in the query string? if not try to add
```
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$query .= 'posts_per_page=5&paged='.$paged
```
Number 5 will be replaced with the number of posts after which you want the next page (pagination) link to show up.
... |
26,158 | <p>Using the <a href="http://jigoshop.com/" rel="nofollow">http://jigoshop.com/</a> plugin, is it possible to change the order in which the products are displayed in the different grids.</p>
<p>I'm not quite sure how it decides the order but is it possible to change it to sort it via menu order?</p>
<p>This is the pa... | [
{
"answer_id": 26662,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 0,
"selected": false,
"text": "<p>Jigoshop has a lot of filter hooks that if you use them right you can do anything you want (almost), In your ... | 2011/08/17 | [
"https://wordpress.stackexchange.com/questions/26158",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4588/"
] | Using the <http://jigoshop.com/> plugin, is it possible to change the order in which the products are displayed in the different grids.
I'm not quite sure how it decides the order but is it possible to change it to sort it via menu order?
This is the page I'm working on - <http://www.roadsafetyforchildren.co.uk/produ... | As Bainternet said you need to adjust the query vars, however I needed to change the order well before 'jigoshop\_before\_shop\_loop' hook to get this to work. This function fires at pre\_get\_posts and orders by title.
```
add_action('pre_get_posts', 'my_custom_query');
function my_custom_query($wp_query){
... |
26,159 | <p>I have a custom post type called "number" and I would like to achieve URL's for it's "posts" to be the following <a href="http://website.com/post-name" rel="nofollow">http://website.com/post-name</a> instead of <a href="http://website.com/number/post-name" rel="nofollow">http://website.com/number/post-name</a>.</p>
... | [
{
"answer_id": 26856,
"author": "Alex Older",
"author_id": 3365,
"author_profile": "https://wordpress.stackexchange.com/users/3365",
"pm_score": 2,
"selected": true,
"text": "<p>You could use a rewrite rule in your .htaccess file to remove number from the link.</p>\n\n<p>You'll need some... | 2011/08/17 | [
"https://wordpress.stackexchange.com/questions/26159",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4212/"
] | I have a custom post type called "number" and I would like to achieve URL's for it's "posts" to be the following <http://website.com/post-name> instead of <http://website.com/number/post-name>.
I tried to set the 'rewrite' parameter in register\_post\_type to: `'rewrite' => array( 'slug' => '', 'with_front' => false )... | You could use a rewrite rule in your .htaccess file to remove number from the link.
You'll need something along the lines of:
```
RewriteRule ^number/(.+)$ $1 [R=301,L]
``` |
26,164 | <p>I have a WordPress site with more than 8000 posts and everytime I add a new one the site becomes unresponsive. I checked the MySQL slow queries log and found out that it is performing a select that returns most of the rows in the posts table and is taking a lot of time to execute.</p>
<p>This is an example:</p>
<p... | [
{
"answer_id": 26166,
"author": "RolandoMySQLDBA",
"author_id": 4699,
"author_profile": "https://wordpress.stackexchange.com/users/4699",
"pm_score": 2,
"selected": false,
"text": "<p>What you may want to do is perform an EXPLAIN on the query like this:</p>\n\n<pre><code>EXPLAIN SELECT I... | 2011/08/17 | [
"https://wordpress.stackexchange.com/questions/26164",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/231/"
] | I have a WordPress site with more than 8000 posts and everytime I add a new one the site becomes unresponsive. I checked the MySQL slow queries log and found out that it is performing a select that returns most of the rows in the posts table and is taking a lot of time to execute.
This is an example:
```
Query_time: ... | What you may want to do is perform an EXPLAIN on the query like this:
```
EXPLAIN SELECT ID, post_author, post_date,
post_date_gmt, post_status, post_name,
post_modified, post_modified_gmt, post_parent,
post_type FROM wp_posts
WHERE ( (post_status = 'publish' AND (post_type = 'post' OR post_type = ''))
OR (post_status... |
26,170 | <p>I'd like to sync my theme's README.markdown into a page on my site and would <em>love</em> to be able to only have to update that text a single time -- namely, when I commit my code up to BitBucket. I have my theme doing <code>hg pull -u</code> on a regular basis, so the code stays fresh and the README will get upda... | [
{
"answer_id": 26194,
"author": "Tareq",
"author_id": 7156,
"author_profile": "https://wordpress.stackexchange.com/users/7156",
"pm_score": 0,
"selected": false,
"text": "<p>You may parse the markdown file and show the contents in the page with some method, say with shortcode. When you u... | 2011/08/17 | [
"https://wordpress.stackexchange.com/questions/26170",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/61/"
] | I'd like to sync my theme's README.markdown into a page on my site and would *love* to be able to only have to update that text a single time -- namely, when I commit my code up to BitBucket. I have my theme doing `hg pull -u` on a regular basis, so the code stays fresh and the README will get updated every time I make... | I achieved that using WP-Cron capabilities.
```
add_action('wp', 'wpse_26170_activation');
function wpse_26170_activation() {
if ( !wp_next_scheduled( 'wpse_26170_update_readme_page' ) ) {
wp_schedule_event( current_time( 'timestamp' ), 'daily', 'wpse_26170_update_readme_page');
}
}
function wpse_261... |
26,173 | <p>I had 5 plugins with updates. After updating all of them through the Available Updates tool they disappeared from the Network Plugins page. I received errors like this for all plugins:</p>
<pre><code>The plugin custom-post-type-ui/custom-post-type-ui.php has been deactivated due to an error: Plugin file does not ex... | [
{
"answer_id": 28389,
"author": "jsims281",
"author_id": 7308,
"author_profile": "https://wordpress.stackexchange.com/users/7308",
"pm_score": 3,
"selected": true,
"text": "<p>We resolved this issue by removing re-uploading the admin and includes folders, although I'm not sure what origi... | 2011/08/17 | [
"https://wordpress.stackexchange.com/questions/26173",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4224/"
] | I had 5 plugins with updates. After updating all of them through the Available Updates tool they disappeared from the Network Plugins page. I received errors like this for all plugins:
```
The plugin custom-post-type-ui/custom-post-type-ui.php has been deactivated due to an error: Plugin file does not exist.
```
The... | We resolved this issue by removing re-uploading the admin and includes folders, although I'm not sure what originally caused the issue. |
26,186 | <p>When developing a plugin should the functions be grouped together into a Class to avoid namespace conflicts?</p>
<p>Does using classes create performance overheads for PHP?</p>
<p>If there is a performance hit, should function names just be pre-fixed instead?</p>
| [
{
"answer_id": 26188,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 1,
"selected": false,
"text": "<p>Classes don't usually offer any benefits in terms of performance, but they very rarely have any negative effe... | 2011/08/17 | [
"https://wordpress.stackexchange.com/questions/26186",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3317/"
] | When developing a plugin should the functions be grouped together into a Class to avoid namespace conflicts?
Does using classes create performance overheads for PHP?
If there is a performance hit, should function names just be pre-fixed instead? | >
> When developing a plugin should the functions be grouped together into a Class to avoid namespace conflicts?
>
>
>
Yes, but that's only one of the minor arguments. In-fact that's not the "true" nature of a class in [OOAD](http://en.wikipedia.org/wiki/Object-oriented_analysis_and_design).
>
> Does using class... |
26,187 | <p>In the script below, which resides in a custom widget, I'm trying to determine which sidebar area the widget has been added to because I want to alter the default text depending on which sidebar the user has added the widget to. This code should only execute on the admin side while editing the widget.</p>
<p>Howeve... | [
{
"answer_id": 48389,
"author": "Gustav Graf",
"author_id": 15011,
"author_profile": "https://wordpress.stackexchange.com/users/15011",
"pm_score": 4,
"selected": true,
"text": "<pre><code> $sideBars = wp_get_sidebars_widgets ();\n $mySideBar = false;\n foreach ($sideBars as $si... | 2011/08/17 | [
"https://wordpress.stackexchange.com/questions/26187",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6620/"
] | In the script below, which resides in a custom widget, I'm trying to determine which sidebar area the widget has been added to because I want to alter the default text depending on which sidebar the user has added the widget to. This code should only execute on the admin side while editing the widget.
However, regardl... | ```
$sideBars = wp_get_sidebars_widgets ();
$mySideBar = false;
foreach ($sideBars as $sideBarName => $sideBar) {
if (array_search ($this->id, $sideBar) !== false) {
$mySideBar = $sideBarName;
break;
}
}
``` |
26,192 | <p>I'm trying to pass the variables to a new page, I made a function in my theme to get the results. Now when I use <code>yelplist();</code> on the front page of my theme it gets the results and when i click on the link it passes the image and city back to me as requested. </p>
<p><strong>Questions:</strong></p>
<ul... | [
{
"answer_id": 26614,
"author": "Drew Gourley",
"author_id": 4282,
"author_profile": "https://wordpress.stackexchange.com/users/4282",
"pm_score": 0,
"selected": false,
"text": "<p>Could this be as easy as resetting the variable once we've hit the page with the query string?</p>\n\n<p>Sa... | 2011/08/17 | [
"https://wordpress.stackexchange.com/questions/26192",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2635/"
] | I'm trying to pass the variables to a new page, I made a function in my theme to get the results. Now when I use `yelplist();` on the front page of my theme it gets the results and when i click on the link it passes the image and city back to me as requested.
**Questions:**
* However I am wondering what i can do to ... | **Edit:** OK, I get what you're trying to do a little better. This should help get you there.
1. Cache the data that you are going to want. You'll go over your API limit quickly if you query Yelp on every page load - not to mention slowing your site down terribly.
```
function yelplist() {
$pizza_joints = wp_ca... |
26,202 | <p>I'm using gpp slideshow, which overwrites wordpress's default gallery display. I only want to use it on my custom post type, "listings" - how would I reference it to only replace wordpress's default gallery on the "listings' page?</p>
<p>I have this code in my functions.php, and I can't seem to get the reference ri... | [
{
"answer_id": 26203,
"author": "Isendra",
"author_id": 7358,
"author_profile": "https://wordpress.stackexchange.com/users/7358",
"pm_score": 0,
"selected": false,
"text": "<p>You appear to be missing a parenthesis. Try:</p>\n\n<pre><code>if (is_single() && is_post_type('post_typ... | 2011/08/18 | [
"https://wordpress.stackexchange.com/questions/26202",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4902/"
] | I'm using gpp slideshow, which overwrites wordpress's default gallery display. I only want to use it on my custom post type, "listings" - how would I reference it to only replace wordpress's default gallery on the "listings' page?
I have this code in my functions.php, and I can't seem to get the reference right for th... | Try using [`get_post_type()`](http://codex.wordpress.org/Function_Reference/get_post_type) instead:
```
if ( is_single() && 'post_type' == get_post_type() ) {
// Do something
}
```
The `is_post_type()` conditional is deprecated. But even when it existed, it returned true if *the current post is any registered cu... |
26,209 | <p>I created some shortcodes which I have include into functions.php</p>
<p>This is the shortcode.php code I have used:</p>
<pre><code>// alert box
function alertBox($atts, $content = null) {
extract(shortcode_atts(array(
"bgcolor" => '#ffffff'
), $atts));
return '<div class="alertBox" styl... | [
{
"answer_id": 26214,
"author": "anmari",
"author_id": 3569,
"author_profile": "https://wordpress.stackexchange.com/users/3569",
"pm_score": 0,
"selected": false,
"text": "<p>Hi sometimes it is a \"silly\" error . Look at the start of the file - is the bracket \"< ? php \" correctly ... | 2011/08/18 | [
"https://wordpress.stackexchange.com/questions/26209",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7990/"
] | I created some shortcodes which I have include into functions.php
This is the shortcode.php code I have used:
```
// alert box
function alertBox($atts, $content = null) {
extract(shortcode_atts(array(
"bgcolor" => '#ffffff'
), $atts));
return '<div class="alertBox" style="background:'.$bgcolor.'"... | First, change this:
```
include TEMPLATEPATH . '/extras/shortcodes.php';
```
...to this:
```
include ( TEMPLATEPATH . '/extras/shortcodes.php' );
```
Second, change `TEMPLATEPATH` to `get_template_directory()`:
```
include ( get_template_directory() . '/extras/shortcodes.php' );
```
([The `TEMPLATEPATH` and `S... |
26,213 | <p>I currently developing wordpress widget for my website. This widget will pull user latest post in my website and show in their blog.</p>
<p>In the widget there is option for user to use their css or my css for the widget</p>
<p>I use this code in my widget and its work perfectly but this code will always load the ... | [
{
"answer_id": 26234,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 0,
"selected": false,
"text": "<p>You need to pull the option <em>out of the Widget</em> and make it a <em>Plugin option</em>.</p>\n\n<p>For ... | 2011/08/18 | [
"https://wordpress.stackexchange.com/questions/26213",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7992/"
] | I currently developing wordpress widget for my website. This widget will pull user latest post in my website and show in their blog.
In the widget there is option for user to use their css or my css for the widget
I use this code in my widget and its work perfectly but this code will always load the css.
```
add_act... | This is sort of sloppy as the style will still be enqueued regardless.
In the code to display your widget, change the CSS selectors based on whether or not the user selected own style:
```
<?php
$prefix = $instance['own_style'] ? 'ownstyle_' : 'pluginstyle_';
//then....
?>
<div id="<?php echo $prefix; ?>selector"> .... |
26,219 | <p>my objective is to define a custom excerpt length. I know that I can do it defining a new function in my functions.php located in the child theme of the Twenty Eleven.</p>
<p>It should override these lines :</p>
<pre><code>/**
* Sets the post excerpt length to 40 words.
*
* To override this length in a child th... | [
{
"answer_id": 26221,
"author": "Aurélien Denis",
"author_id": 7995,
"author_profile": "https://wordpress.stackexchange.com/users/7995",
"pm_score": 2,
"selected": false,
"text": "<p>Well I finally solved the problem. The excerpt_length function is NOT use with the excerpt box of the Wor... | 2011/08/18 | [
"https://wordpress.stackexchange.com/questions/26219",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7994/"
] | my objective is to define a custom excerpt length. I know that I can do it defining a new function in my functions.php located in the child theme of the Twenty Eleven.
It should override these lines :
```
/**
* Sets the post excerpt length to 40 words.
*
* To override this length in a child theme, remove the filte... | Well I finally solved the problem. The excerpt\_length function is NOT use with the excerpt box of the WordPress editor. You have to put all your content in the main area. |