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 |
|---|---|---|---|---|---|---|
22,808 | <p>I have a tag page that is generated with the first image attachments from all of the posts. I call it in the loop with :</p>
<pre><code><img src="<?php echo get_first_attachment() ?>" />
</code></pre>
<p>and this is the function :</p>
<pre><code>function get_first_attachment(){
$querystr =
"
... | [
{
"answer_id": 22869,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": true,
"text": "<p>I'd try to get rid of custom query altogether. Try something like:</p>\n\n<pre><code>$attachments = get_posts(array(\... | 2011/07/13 | [
"https://wordpress.stackexchange.com/questions/22808",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2661/"
] | I have a tag page that is generated with the first image attachments from all of the posts. I call it in the loop with :
```
<img src="<?php echo get_first_attachment() ?>" />
```
and this is the function :
```
function get_first_attachment(){
$querystr =
"
SELECT
wp_posts.post_excer... | I'd try to get rid of custom query altogether. Try something like:
```
$attachments = get_posts(array(
'post_type' => 'attachment',
'post_parent' => get_the_ID(),
'numberposts' => 1,
));
``` |
22,809 | <p>is there a way to add a class to every nth item in a menu using wp_nav_menu?</p>
<p>Trying to create columns but need to add a 'last' class to the 3rd item.</p>
<p>cheers! Dc</p>
| [
{
"answer_id": 22911,
"author": "mike23",
"author_id": 1381,
"author_profile": "https://wordpress.stackexchange.com/users/1381",
"pm_score": 2,
"selected": false,
"text": "<p>You can use <em>jQuery</em> to do that. Try this in your header :</p>\n\n<pre><code>$(document).ready(function() ... | 2011/07/13 | [
"https://wordpress.stackexchange.com/questions/22809",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3978/"
] | is there a way to add a class to every nth item in a menu using wp\_nav\_menu?
Trying to create columns but need to add a 'last' class to the 3rd item.
cheers! Dc | got this working like this in the end...
```
function add_nthclass($items, $args){
$scb = get_object_vars($args);
switch($scb['menu']) {
case 'mainpages':
$nth = 2;
$items = explode('</li>',$items);
$newitems = array();
// loop through the menu items, an... |
22,810 | <p>I'd like to style differently the content before the link, but in single.php.</p>
<p>To be more specific, all my posts on the homepage only have a summary, and the rest of the text is cut thanks to the use of the more tag. So when I click on "read more" I see the complete post, starting with the summary we previou... | [
{
"answer_id": 22911,
"author": "mike23",
"author_id": 1381,
"author_profile": "https://wordpress.stackexchange.com/users/1381",
"pm_score": 2,
"selected": false,
"text": "<p>You can use <em>jQuery</em> to do that. Try this in your header :</p>\n\n<pre><code>$(document).ready(function() ... | 2011/07/13 | [
"https://wordpress.stackexchange.com/questions/22810",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6938/"
] | I'd like to style differently the content before the link, but in single.php.
To be more specific, all my posts on the homepage only have a summary, and the rest of the text is cut thanks to the use of the more tag. So when I click on "read more" I see the complete post, starting with the summary we previously seen on... | got this working like this in the end...
```
function add_nthclass($items, $args){
$scb = get_object_vars($args);
switch($scb['menu']) {
case 'mainpages':
$nth = 2;
$items = explode('</li>',$items);
$newitems = array();
// loop through the menu items, an... |
22,835 | <p>I have a site with several custom taxonomies, and have found that one of the slowest parts of the site is attempting to query with an OR across several of these at once. I'm using a <code>WP_Query</code> like so:</p>
<pre><code>array(
'tax_query' => array(
'relation' => 'OR',
array('taxonomy' => ... | [
{
"answer_id": 22919,
"author": "Marcus Downing",
"author_id": 3828,
"author_profile": "https://wordpress.stackexchange.com/users/3828",
"pm_score": 2,
"selected": false,
"text": "<p>I have a solution, but it's a really ugly one. I'd love to hear a better one, but I'm not sure it's possi... | 2011/07/13 | [
"https://wordpress.stackexchange.com/questions/22835",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3828/"
] | I have a site with several custom taxonomies, and have found that one of the slowest parts of the site is attempting to query with an OR across several of these at once. I'm using a `WP_Query` like so:
```
array(
'tax_query' => array(
'relation' => 'OR',
array('taxonomy' => 'tax1', 'field' => 'slug', 'terms'... | I have a solution, but it's a really ugly one. I'd love to hear a better one, but I'm not sure it's possible.
`WP_Query::get_posts()` calls `parse_tax_query()` twice: first near the start, then again just before getting the SQL from it. There's no single hook that lets me intercept and adjust the value of `$tax_query`... |
22,836 | <p>I'd like to make my categories that have child-categories non-selectable on the post article page.</p>
<p>What I want to do is to remove the checkbox before their label.</p>
<p>I've looked at the filter documentation but I wasn't able to find any filter that suited my need.</p>
| [
{
"answer_id": 58525,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 3,
"selected": true,
"text": "<p>I really doubt this is filterable, so jQuery comes to rescue :)</p>\n<h3>The Code</h3>\n<pre><code>add_action... | 2011/07/13 | [
"https://wordpress.stackexchange.com/questions/22836",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6938/"
] | I'd like to make my categories that have child-categories non-selectable on the post article page.
What I want to do is to remove the checkbox before their label.
I've looked at the filter documentation but I wasn't able to find any filter that suited my need. | I really doubt this is filterable, so jQuery comes to rescue :)
### The Code
```
add_action( 'admin_footer-post.php', 'wpse_22836_remove_top_categories_checkbox' );
add_action( 'admin_footer-post-new.php', 'wpse_22836_remove_top_categories_checkbox' );
function wpse_22836_remove_top_categories_checkbox()
{
globa... |
22,849 | <p>At the risk of sounding completely ridiculous, I'm posting this question here as the nature of my query doesn't seem to help me much from google.</p>
<p>My WordPress default RSS feeds makes use of post excerpt this feed is accessed via <code>www.mydomain.com/feed</code></p>
<p>I have a requirement to make another RS... | [
{
"answer_id": 22863,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": true,
"text": "<p>Here is how to create a custom feed:</p>\n\n<p>first create a new file in your theme's directory , name it <co... | 2011/07/13 | [
"https://wordpress.stackexchange.com/questions/22849",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5411/"
] | At the risk of sounding completely ridiculous, I'm posting this question here as the nature of my query doesn't seem to help me much from google.
My WordPress default RSS feeds makes use of post excerpt this feed is accessed via `www.mydomain.com/feed`
I have a requirement to make another RSS feed that is the full te... | Here is how to create a custom feed:
first create a new file in your theme's directory , name it `your-custom-feed.php` and put this code inside
```
<?php
/**
* custom RSS feed.
*
* @package WordPress
*/
header('Content-Type: ' . feed_content_type('rss-http') . '; charset=' . get_o... |
22,857 | <p>I want to add a jQuery dialog modal to a form page. When the dialog box is triggered I see the the text content but with no CSS. I'm pulling in the jquery in the functions.php for the page:</p>
<pre><code>wp_enqueue_script('jquery-ui-dialog');
</code></pre>
<p>The jquery css (jquery-ui-dialog.css) is under my wp-i... | [
{
"answer_id": 22860,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": true,
"text": "<p>There is no <code>jquery-ui-dialog</code> style defined in WordPress Out of the box, you need to ue the styles... | 2011/07/13 | [
"https://wordpress.stackexchange.com/questions/22857",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3880/"
] | I want to add a jQuery dialog modal to a form page. When the dialog box is triggered I see the the text content but with no CSS. I'm pulling in the jquery in the functions.php for the page:
```
wp_enqueue_script('jquery-ui-dialog');
```
The jquery css (jquery-ui-dialog.css) is under my wp-includes/css directory.
I t... | There is no `jquery-ui-dialog` style defined in WordPress Out of the box, you need to ue the stylesheets manually, when i needed to enqueue the jQuery-UI style i pulled it from google api CDN
```
wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
... |
22,865 | <p>I've been able to setup and use a couple different LDAP plugins (CoSign SSO, Simple LDAP Logon) to create new WordPress users based on the Active Directory users but it still requires them to manually log in to make posts. Is there a way to have it pull the user's credentials from the browser and automatically log ... | [
{
"answer_id": 22860,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": true,
"text": "<p>There is no <code>jquery-ui-dialog</code> style defined in WordPress Out of the box, you need to ue the styles... | 2011/07/13 | [
"https://wordpress.stackexchange.com/questions/22865",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7005/"
] | I've been able to setup and use a couple different LDAP plugins (CoSign SSO, Simple LDAP Logon) to create new WordPress users based on the Active Directory users but it still requires them to manually log in to make posts. Is there a way to have it pull the user's credentials from the browser and automatically log them... | There is no `jquery-ui-dialog` style defined in WordPress Out of the box, you need to ue the stylesheets manually, when i needed to enqueue the jQuery-UI style i pulled it from google api CDN
```
wp_enqueue_style('jquery-style', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.2/themes/smoothness/jquery-ui.css');
... |
22,873 | <p>As suggested on this site, I am using this code to style an excerpt if no post format is selected/if it is a standard post.</p>
<pre><code><?php
$format = get_post_format();
if ( false === $format )
{
echo 'This is a default post';
the_excerpt();
}
?>
</code></pre>
<p>However, it seems there must be a better... | [
{
"answer_id": 22876,
"author": "Michelle",
"author_id": 16,
"author_profile": "https://wordpress.stackexchange.com/users/16",
"pm_score": 1,
"selected": true,
"text": "<p>I'm not sure I understand. Do you just want to join all the if-statements together? If that's the case you could use... | 2011/07/13 | [
"https://wordpress.stackexchange.com/questions/22873",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6565/"
] | As suggested on this site, I am using this code to style an excerpt if no post format is selected/if it is a standard post.
```
<?php
$format = get_post_format();
if ( false === $format )
{
echo 'This is a default post';
the_excerpt();
}
?>
```
However, it seems there must be a better way to include it with one PHP ... | I'm not sure I understand. Do you just want to join all the if-statements together? If that's the case you could use elseif, like so:
```
<?php
$format = get_post_format();
if ( false === $format ) {
echo 'This is a default post';
the_excerpt();
} elseif ( has_post_format( 'video' )) { ?>
A VIDEO POST
<?php the... |
22,879 | <p>I noticed that I have a directory <code>meta/</code> as a sub-directory of the wp-admin folder, but there is nothing in it. What goes in here? Should I keep it?</p>
| [
{
"answer_id": 22876,
"author": "Michelle",
"author_id": 16,
"author_profile": "https://wordpress.stackexchange.com/users/16",
"pm_score": 1,
"selected": true,
"text": "<p>I'm not sure I understand. Do you just want to join all the if-statements together? If that's the case you could use... | 2011/07/13 | [
"https://wordpress.stackexchange.com/questions/22879",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5909/"
] | I noticed that I have a directory `meta/` as a sub-directory of the wp-admin folder, but there is nothing in it. What goes in here? Should I keep it? | I'm not sure I understand. Do you just want to join all the if-statements together? If that's the case you could use elseif, like so:
```
<?php
$format = get_post_format();
if ( false === $format ) {
echo 'This is a default post';
the_excerpt();
} elseif ( has_post_format( 'video' )) { ?>
A VIDEO POST
<?php the... |
22,901 | <p>There are certain posts on the website I'm developing, that don't need the author(s) by-line. (such as press releases)</p>
<p>Is there any method, that allows me to remove the author (and co-authors) for certain posts?</p>
| [
{
"answer_id": 22910,
"author": "mike23",
"author_id": 1381,
"author_profile": "https://wordpress.stackexchange.com/users/1381",
"pm_score": 2,
"selected": false,
"text": "<p>A quick fix would be to use WP's <a href=\"http://codex.wordpress.org/Function_Reference/body_class\" rel=\"nofol... | 2011/07/14 | [
"https://wordpress.stackexchange.com/questions/22901",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3420/"
] | There are certain posts on the website I'm developing, that don't need the author(s) by-line. (such as press releases)
Is there any method, that allows me to remove the author (and co-authors) for certain posts? | Thanks to mike23's suggestion, I solved my problem with conditional tags.
---
Just insert the following in the author area of `single.php`, `archive.php` and any other page template that displays an author.
```
<?php if ( has_tag('press-releases') ) {
echo '';
} else {
echo 'by '; the_author_posts_link(... |
22,904 | <p>My <a href="http://www.superlogical.net/art/movie/2011/07/first-look-at-dwarves-from-the-hobbit/" rel="nofollow">site</a> has Facebook social graph meta tags in its page:</p>
<pre><code><meta property="og:title" content="First Look at Dwarves from The Hobbit"/>
<meta property="og:description" content="Movi... | [
{
"answer_id": 22907,
"author": "chrishajer",
"author_id": 6230,
"author_profile": "https://wordpress.stackexchange.com/users/6230",
"pm_score": 1,
"selected": true,
"text": "<p>The Facebook Page Publish plugin is adding the og:description. Looking through the code in fpp_index.php at l... | 2011/07/14 | [
"https://wordpress.stackexchange.com/questions/22904",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3206/"
] | My [site](http://www.superlogical.net/art/movie/2011/07/first-look-at-dwarves-from-the-hobbit/) has Facebook social graph meta tags in its page:
```
<meta property="og:title" content="First Look at Dwarves from The Hobbit"/>
<meta property="og:description" content="Movie"/>
```
The only Facebook-related plugin I hav... | The Facebook Page Publish plugin is adding the og:description. Looking through the code in fpp\_index.php at lines 843 - 851:
```
$description = array();
if ($options['show_post_author']) {
$description[] = esc_attr(fpp_get_post_author($post));/*, ENT_COMPAT, 'UTF-8')*/
}
if ($options['show... |
22,922 | <p>my first question is ...</p>
<p>I want to retrieve path of an upload image. Important: The image isn't atached of any post. I have image url like:</p>
<p><code>http://localhost/wp-content/uploads/2011/06/sample.jpg</code></p>
<p>And I want to get the path, like:</p>
<p><code>/Applications/XAMPP/htdocs/wp-content... | [
{
"answer_id": 22929,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>This is not very reliable in general (especially not in multisite environment), but for specific case it can be good... | 2011/07/14 | [
"https://wordpress.stackexchange.com/questions/22922",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7023/"
] | my first question is ...
I want to retrieve path of an upload image. Important: The image isn't atached of any post. I have image url like:
`http://localhost/wp-content/uploads/2011/06/sample.jpg`
And I want to get the path, like:
`/Applications/XAMPP/htdocs/wp-content/uploads/2011/06/sample.jpg`
Thanks,
Marcos.
... | This is not very reliable in general (especially not in multisite environment), but for specific case it can be good enough:
```
$url = 'http://localhost/wp-content/uploads/2011/06/sample.jpg';
$uploads = wp_upload_dir();
$path = str_replace( $uploads['baseurl'], $uploads['basedir'], $url);
``` |
22,923 | <p>How can i redirect all posts permalinks to .html ,in Wordpress ? now all my posts url are ending in .html ,but before it was without .html </p>
<p>to be more clear ,for example a post url like this www.example.com/posturl to be redirected to www.example.com/posturl.html .it's simple to redirect them one by one,but ... | [
{
"answer_id": 22929,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>This is not very reliable in general (especially not in multisite environment), but for specific case it can be good... | 2011/07/14 | [
"https://wordpress.stackexchange.com/questions/22923",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6927/"
] | How can i redirect all posts permalinks to .html ,in Wordpress ? now all my posts url are ending in .html ,but before it was without .html
to be more clear ,for example a post url like this www.example.com/posturl to be redirected to www.example.com/posturl.html .it's simple to redirect them one by one,but i need a r... | This is not very reliable in general (especially not in multisite environment), but for specific case it can be good enough:
```
$url = 'http://localhost/wp-content/uploads/2011/06/sample.jpg';
$uploads = wp_upload_dir();
$path = str_replace( $uploads['baseurl'], $uploads['basedir'], $url);
``` |
22,930 | <p>How to get displayed child pages on parent page and also on child page of that parent in sidebar?Trying to paste code from wp codex page and from several other sites, but with no success.I always get instead of list of child pages, list of parent pages!?
what is the problem?Just to mention, maybe is important, all p... | [
{
"answer_id": 22931,
"author": "Nathan Fitzgerald - Fitzgenius",
"author_id": 7025,
"author_profile": "https://wordpress.stackexchange.com/users/7025",
"pm_score": 0,
"selected": false,
"text": "<p>Try this</p>\n\n<pre><code> <ul class=\"sidenav\">\n <?php\n if($post-&... | 2011/07/14 | [
"https://wordpress.stackexchange.com/questions/22930",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4490/"
] | How to get displayed child pages on parent page and also on child page of that parent in sidebar?Trying to paste code from wp codex page and from several other sites, but with no success.I always get instead of list of child pages, list of parent pages!?
what is the problem?Just to mention, maybe is important, all pare... | If you don't want a *list of Pages*, then why are you calling `wp_list_pages()` in your code? that function returns a *list of Pages*.
You probably [need to use `get_posts()` instead](http://codex.wordpress.org/Template_Tags/get_posts), and then loop through the results to output whatever `$post` content you want to d... |
22,943 | <p>I want to get a sidebar and save it in a Variable, <br />
This is impossible with the get_sidebar function since it simply prints out <br />
the sidebar, is there another function that I can use?</p>
| [
{
"answer_id": 22945,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 1,
"selected": false,
"text": "<p>The <code>get_sidebar()</code> function is an <em>include</em> function, used to include <code>sidebar.php<... | 2011/07/14 | [
"https://wordpress.stackexchange.com/questions/22943",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3642/"
] | I want to get a sidebar and save it in a Variable,
This is impossible with the get\_sidebar function since it simply prints out
the sidebar, is there another function that I can use? | You probably need to use [output buffering](http://www.php.net/manual/en/ref.outcontrol.php), if I understand your question correctly.
Try something like this:
```
ob_start();
dynamic_sidebar('sidebar-id');
$sidebar = ob_get_contents();
ob_end_clean();
```
That will put the output of the sidebar into the variable $... |
22,949 | <p>is it possible to create a loop of posts using WP_Query or query_posts using the title?</p>
<p>ie</p>
<pre><code>$args = array('post_title'='LIKE '.$str.'% ');
$res = WP_Query($arg);
// the loop...
// trying this now...
$mypostids = $wpdb->get_col("select ID from $wpdb->posts where post_title like 'Abb%'... | [
{
"answer_id": 22952,
"author": "Rajeev Vyas",
"author_id": 6961,
"author_profile": "https://wordpress.stackexchange.com/users/6961",
"pm_score": 2,
"selected": false,
"text": "<p>Yes it is possible....</p>\n<pre><code>global $wpdb;\n\n$mypostids = $wpdb->get_col("select ID from ... | 2011/07/14 | [
"https://wordpress.stackexchange.com/questions/22949",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3978/"
] | is it possible to create a loop of posts using WP\_Query or query\_posts using the title?
ie
```
$args = array('post_title'='LIKE '.$str.'% ');
$res = WP_Query($arg);
// the loop...
// trying this now...
$mypostids = $wpdb->get_col("select ID from $wpdb->posts where post_title like 'Abb%' ");
echo count($mypostid... | got this working with the help from this post in the end. Cheers guys;
```
$finalArgs = array (
'posts_per_page'=>5,
'order' => 'ASC',
'post_type' => 'school'
);
// Create a new instance
$searchSchools = new WP_Query( $finalArgs );
$mypostids =... |
22,951 | <p>I'm trying to enqueue a JS script only when someone is adding or editing a custom post type I created called "recipes". Currently the script works ok when I do this:</p>
<pre><code>if (is_admin()){
wp_enqueue_script( 'my-script' );
}
</code></pre>
<p>But this loads it in every admin page, I'm assuming I need t... | [
{
"answer_id": 22954,
"author": "mike23",
"author_id": 1381,
"author_profile": "https://wordpress.stackexchange.com/users/1381",
"pm_score": 7,
"selected": true,
"text": "<p>You can do it like this (put in your <code>functions.php</code>) :</p>\n\n<pre><code>function add_admin_scripts( $... | 2011/07/14 | [
"https://wordpress.stackexchange.com/questions/22951",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3893/"
] | I'm trying to enqueue a JS script only when someone is adding or editing a custom post type I created called "recipes". Currently the script works ok when I do this:
```
if (is_admin()){
wp_enqueue_script( 'my-script' );
}
```
But this loads it in every admin page, I'm assuming I need to hook it to a function bu... | You can do it like this (put in your `functions.php`) :
```
function add_admin_scripts( $hook ) {
global $post;
if ( $hook == 'post-new.php' || $hook == 'post.php' ) {
if ( 'recipes' === $post->post_type ) {
wp_enqueue_script( 'myscript', get_stylesheet_directory_uri().'/js/myscript... |
22,962 | <p>I want to programmatically add the current user to a role and also remove the current user from a role in a php page i created . am really stuck. thanks in advance</p>
| [
{
"answer_id": 22964,
"author": "mike23",
"author_id": 1381,
"author_profile": "https://wordpress.stackexchange.com/users/1381",
"pm_score": 3,
"selected": false,
"text": "<p>You can do that like this :</p>\n\n<pre><code>$my_user = new WP_User( $user_id );\n$my_user->set_role( \"edito... | 2011/07/14 | [
"https://wordpress.stackexchange.com/questions/22962",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6987/"
] | I want to programmatically add the current user to a role and also remove the current user from a role in a php page i created . am really stuck. thanks in advance | You can do that like this :
```
$my_user = new WP_User( $user_id );
$my_user->set_role( "editor" );
``` |
22,965 | <p>is possible to get images added to a post programmatically? I am working on custom template (my first) and I need to display Images added to a post in specific way.(first image as title image and the rest of imgs only render into hidden img tags (will be visible through lightbox slideshow).</p>
<p>So is there any f... | [
{
"answer_id": 22967,
"author": "mike23",
"author_id": 1381,
"author_profile": "https://wordpress.stackexchange.com/users/1381",
"pm_score": 2,
"selected": false,
"text": "<p>This gets all the images attached to a post :</p>\n\n<pre><code>$args = array( 'post_type' => 'attachment', 'n... | 2011/07/14 | [
"https://wordpress.stackexchange.com/questions/22965",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7031/"
] | is possible to get images added to a post programmatically? I am working on custom template (my first) and I need to display Images added to a post in specific way.(first image as title image and the rest of imgs only render into hidden img tags (will be visible through lightbox slideshow).
So is there any function li... | You can use `get_posts()` ([Codex ref for getting Post attachments](http://codex.wordpress.org/Template_Tags/get_posts#Show_all_attachments)).
```
<?php
$args = array(
'post_type' => 'attachment',
'post_mime_type' => 'image',
'numberposts' => -1,
'post_status' => null,
'post_parent' => $post->I... |
22,969 | <p>I want to get the page content (so i can parse the tags/short-codes in it), but i don't want to output the result itself to the browser (i.e. echo=0).</p>
<p>I tried get_the_content(); but its the same deal.</p>
| [
{
"answer_id": 22970,
"author": "mike23",
"author_id": 1381,
"author_profile": "https://wordpress.stackexchange.com/users/1381",
"pm_score": 0,
"selected": false,
"text": "<p>You can try this :</p>\n\n<pre><code>$page_data = get_page( $page_id ); \n$page_content = $page_data->post_con... | 2011/07/14 | [
"https://wordpress.stackexchange.com/questions/22969",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5797/"
] | I want to get the page content (so i can parse the tags/short-codes in it), but i don't want to output the result itself to the browser (i.e. echo=0).
I tried get\_the\_content(); but its the same deal. | Where are you doing your code parsing? If you're doing it directly in the template file, inside the Loop, then you should be using `get_the_content()`.
However, it might be more efficient to filter `the_content()`, via the `the_content` filter. e.g. in `functions.php`:
```
function mytheme_filter_the_content( $conten... |
22,994 | <p>When creating a new network site, by default the site option <code>Uploads Use Yearmonth Folders</code> is on (set to <code>1</code>). I have to set it to <code>0</code> each time I create a new site. This isn't horrid, but is it possible to make this the default for newly created sites? Perhaps a hook or something ... | [
{
"answer_id": 22995,
"author": "Lucas",
"author_id": 6565,
"author_profile": "https://wordpress.stackexchange.com/users/6565",
"pm_score": 1,
"selected": false,
"text": "<p>I'm a little confused by your question. Are you referring to URLs? If so go to Settings > Permalinks and adjust ... | 2011/07/14 | [
"https://wordpress.stackexchange.com/questions/22994",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2226/"
] | When creating a new network site, by default the site option `Uploads Use Yearmonth Folders` is on (set to `1`). I have to set it to `0` each time I create a new site. This isn't horrid, but is it possible to make this the default for newly created sites? Perhaps a hook or something I am overlooking? | You could just change the option after the blog is created:
```
add_action('wpmu_new_blog', function($blog_id){
switch_to_blog($blog_id);
update_option('uploads_use_yearmonth_folders', false);
restore_current_blog();
});
```
Drop this code into a .php file inside wp-content/mu-plugins |
23,007 | <p>I'd like to prevent certain user roles from accessing the dashboard <a href="http://www.openeye.net/wp-admin/" rel="noreferrer">http://www.openeye.net/wp-admin/</a> at all. I've moved and restyled user profiles to a new page that's viewable on the site. How would I go about doing this?</p>
| [
{
"answer_id": 23008,
"author": "John P Bloch",
"author_id": 11,
"author_profile": "https://wordpress.stackexchange.com/users/11",
"pm_score": 6,
"selected": true,
"text": "<p>To lock subscribers and contributors out of the admin:</p>\n\n<pre><code>function wpse23007_redirect(){\n if( i... | 2011/07/14 | [
"https://wordpress.stackexchange.com/questions/23007",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3296/"
] | I'd like to prevent certain user roles from accessing the dashboard <http://www.openeye.net/wp-admin/> at all. I've moved and restyled user profiles to a new page that's viewable on the site. How would I go about doing this? | To lock subscribers and contributors out of the admin:
```
function wpse23007_redirect(){
if( is_admin() && !defined('DOING_AJAX') && ( current_user_can('subscriber') || current_user_can('contributor') ) ){
wp_redirect(home_url());
exit;
}
}
add_action('init','wpse23007_redirect');
```
Hope that helps. A... |
23,012 | <p>I've managed create a metabox that lets me upload and then fetch the images and then also been able to add jquery ui sortable to be able to sort the images, however I've no idea how to add actual functionality so that the sort order get saved.</p>
<p>If someone has an idea how to achieve this or some tutorial that ... | [
{
"answer_id": 23024,
"author": "Alex Older",
"author_id": 3365,
"author_profile": "https://wordpress.stackexchange.com/users/3365",
"pm_score": 0,
"selected": false,
"text": "<p>Within the WordPress admin you should be able to order the attached media associated with a post/page/custom ... | 2011/07/15 | [
"https://wordpress.stackexchange.com/questions/23012",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2830/"
] | I've managed create a metabox that lets me upload and then fetch the images and then also been able to add jquery ui sortable to be able to sort the images, however I've no idea how to add actual functionality so that the sort order get saved.
If someone has an idea how to achieve this or some tutorial that would be h... | To save the menu order use `wp_update_post()` with each attachment ID and its new menu position:
```
$thisattachment = array();
$thisattachment['ID'] = $thisid;
$thisattachment['menu_order'] = $new_menu_position;
wp_update_post($thisattachment);
```
EDIT - assuming these are already attachments and you're updating t... |
23,026 | <p>Is there anyway to rename a user role name via hook, instead of using plugin?</p>
<h3>Edit</h3>
<p>For example, <code>administrator</code> » <code>owner</code></p>
| [
{
"answer_id": 23100,
"author": "czepol",
"author_id": 7060,
"author_profile": "https://wordpress.stackexchange.com/users/7060",
"pm_score": 1,
"selected": false,
"text": "<p>You can create a custom localization file. Get this file: <a href=\"http://svn.automattic.com/wordpress-i18n/pot/... | 2011/07/15 | [
"https://wordpress.stackexchange.com/questions/23026",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6851/"
] | Is there anyway to rename a user role name via hook, instead of using plugin?
### Edit
For example, `administrator` » `owner` | ```
function change_role_name() {
global $wp_roles;
if ( ! isset( $wp_roles ) )
$wp_roles = new WP_Roles();
//You can list all currently available roles like this...
//$roles = $wp_roles->get_names();
//print_r($roles);
//You can replace "administrator" with any other role "editor", "... |
23,031 | <p>I have my custom post type set up with hierarchicy set to true and the url works like: <em>Lions News › S1 › Test Post 1</em> which is nice except that it should go one futher and be like <em>Lions Minis › Lions News › S1 › Test Post 1</em> Lions Minis being the parent page to everything. Is there a way to to set th... | [
{
"answer_id": 23046,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<p>Take a look at this line: <code>'rewrite' => array( 'slug' => 'lions_news', 'with_front' => false ),</code... | 2011/07/15 | [
"https://wordpress.stackexchange.com/questions/23031",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6787/"
] | I have my custom post type set up with hierarchicy set to true and the url works like: *Lions News › S1 › Test Post 1* which is nice except that it should go one futher and be like *Lions Minis › Lions News › S1 › Test Post 1* Lions Minis being the parent page to everything. Is there a way to to set that up?
The follo... | you should just be able to change this line
```
'rewrite' => array( 'slug' => 'lions_minis/lions_news', 'with_front' => false ),
```
Remember to always visit the Settings->Permalinks menu in wordpress after making a rewrite change for it to update the links! |
23,035 | <p>How can I remove "edit your profile" submenu under "my-account-with-avatar" admin menu bar, while still keeping the avatar and logout?</p>
| [
{
"answer_id": 23082,
"author": "BjornW",
"author_id": 637,
"author_profile": "https://wordpress.stackexchange.com/users/637",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure if you can remove it (haven't checked), but you may achieve the same using css to hide the edit your p... | 2011/07/15 | [
"https://wordpress.stackexchange.com/questions/23035",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6851/"
] | How can I remove "edit your profile" submenu under "my-account-with-avatar" admin menu bar, while still keeping the avatar and logout? | There is a `remove_menu` hook for the admin menu bar.
The class you want to hook into `$wp_admin_bar` , you can see the remove function here and test it out since there is no documentation on it ( line 86), it should work with the submenu ID.
<http://core.trac.wordpress.org/browser/tags/3.2.1/wp-includes/class-wp-ad... |
23,054 | <p>I was trying to clear up some empty tables left behind by other previously used plugins. As such i was trying to delete the GD Star rating plugin and now I cannot access my WP admin. i get the <code>'You do not have sufficient permissions to access this page'</code></p>
<p>I turned on the debug to true and saw the ... | [
{
"answer_id": 23083,
"author": "BjornW",
"author_id": 637,
"author_profile": "https://wordpress.stackexchange.com/users/637",
"pm_score": 1,
"selected": false,
"text": "<p>You probably don't want to hear this, but I would suggest to reinstall WordPress and put your backups back. In the ... | 2011/07/15 | [
"https://wordpress.stackexchange.com/questions/23054",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5411/"
] | I was trying to clear up some empty tables left behind by other previously used plugins. As such i was trying to delete the GD Star rating plugin and now I cannot access my WP admin. i get the `'You do not have sufficient permissions to access this page'`
I turned on the debug to true and saw the errors caused by lots... | since i posted as a comment and most people miss the good tips that are in the comments, I'm posting again as an answer
The reason is because `GD Star rating` plugin creates custom capabilities and your query deleted all references of `%rating%` it deleted the `wp_user_roles` option which holds all capabilities roles.... |
23,070 | <p>I have a short code that is adding a form to a page. How do I ensure that the CSS for the form is loaded in time with the shortcode?</p>
| [
{
"answer_id": 23074,
"author": "BjornW",
"author_id": 637,
"author_profile": "https://wordpress.stackexchange.com/users/637",
"pm_score": 0,
"selected": false,
"text": "<p>You add the css for this form to your theme's style.css. The css is already there no matter if you have a form or n... | 2011/07/15 | [
"https://wordpress.stackexchange.com/questions/23070",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5767/"
] | I have a short code that is adding a form to a page. How do I ensure that the CSS for the form is loaded in time with the shortcode? | you can check with `the_posts` hook if your shortcode exists and only enqueue the style if so :
```
function check_for_shortcode($posts) {
if ( empty($posts) )
return $posts;
$found = false;
foreach ($posts as $post) {
if ( stripos($post->post_content, '[CHANGE_TO_YOUR_SHORT_CODE') )
... |
23,088 | <p>I'm trying to modify how results are displayed in a post list that's currently controlled by the code below. However, it's not built in the WP_Query <code>while ( $the_query->have_posts() ) : $the_query->the_post();</code> style I'm accustomed to and have built a lot of shortcodes and loop styles around. </p>
... | [
{
"answer_id": 23087,
"author": "GavinR",
"author_id": 2001,
"author_profile": "https://wordpress.stackexchange.com/users/2001",
"pm_score": 0,
"selected": false,
"text": "<p>This will visually remove it from the page (but the links will still be in the HTML):</p>\n\n<p>Use the class on ... | 2011/07/15 | [
"https://wordpress.stackexchange.com/questions/23088",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3564/"
] | I'm trying to modify how results are displayed in a post list that's currently controlled by the code below. However, it's not built in the WP\_Query `while ( $the_query->have_posts() ) : $the_query->the_post();` style I'm accustomed to and have built a lot of shortcodes and loop styles around.
How can I change the c... | Got it figured out...
While I did manually remove the next page links, CloudFlare's cache was not playing nice. |
23,089 | <p>I was just wondering if calling get_bloginfo too many times was going to harm performance in a theme and if the data should just be put into its own var?</p>
| [
{
"answer_id": 23109,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 1,
"selected": true,
"text": "<p><a href=\"http://core.trac.wordpress.org/browser/tags/3.2.1/wp-includes/general-template.php#L400\" rel=\"nofo... | 2011/07/15 | [
"https://wordpress.stackexchange.com/questions/23089",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6886/"
] | I was just wondering if calling get\_bloginfo too many times was going to harm performance in a theme and if the data should just be put into its own var? | [`get_bloginfo()`](http://core.trac.wordpress.org/browser/tags/3.2.1/wp-includes/general-template.php#L400) is not cached and calling it over and over would harm your performance just like creating many calls to the database yourself.
a simple solution which doesn't evolve any caching in to minimize the database and f... |
23,105 | <p>Relevant link: <a href="http://themeforward.com/demo2/2011/01/17/testing-comments/" rel="nofollow">http://themeforward.com/demo2/2011/01/17/testing-comments/</a></p>
<p>I've been toying with this for about 10 minutes, trying to get the sidebar to align properly and I can't figure it out.</p>
<p>I placed my comment... | [
{
"answer_id": 23106,
"author": "Sean Lee",
"author_id": 6851,
"author_profile": "https://wordpress.stackexchange.com/users/6851",
"pm_score": 0,
"selected": false,
"text": "<p>try styling the post content to float left, sidebar to float right, and clear left the comment.</p>\n"
},
{... | 2011/07/15 | [
"https://wordpress.stackexchange.com/questions/23105",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5205/"
] | Relevant link: <http://themeforward.com/demo2/2011/01/17/testing-comments/>
I've been toying with this for about 10 minutes, trying to get the sidebar to align properly and I can't figure it out.
I placed my comments in a new DIV to separate them from the posts. Usually I wouldn't do this but I want designers to have... | Put content and comments into a container div with float: left; and then add the same to your sidebar. |
23,111 | <p>This is probably easy once you know but I'm having trouble getting the static page content to appear AFTER a list of posts.</p>
<p>I'm using a named page template which displays posts as a slider and I want to display the static content of the page underneath this slider.</p>
<p>To display the static content I've ... | [
{
"answer_id": 23116,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/wp_reset_query\" rel=\"nofollow\"><code>wp_reset_query();</... | 2011/07/15 | [
"https://wordpress.stackexchange.com/questions/23111",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7061/"
] | This is probably easy once you know but I'm having trouble getting the static page content to appear AFTER a list of posts.
I'm using a named page template which displays posts as a slider and I want to display the static content of the page underneath this slider.
To display the static content I've got this in my te... | [`wp_reset_query();`](http://codex.wordpress.org/Function_Reference/wp_reset_query) or consider saving your `$wp_query` result into `$my_query = new WP_Query(); if( $my_query->have_posts();` etc. Just take a look at the codex page. |
23,130 | <p>I'm using the code below from another answer to query posts from 1 custom role, eg "friends". I thought I could just comma separate the roles to list posts from more than one role, but this didn't work. Is there another way I can write it? I've tried <code>'role' => 'friends', 'enemies'</code> and <code>'role' =&... | [
{
"answer_id": 23140,
"author": "Rajeev Vyas",
"author_id": 6961,
"author_profile": "https://wordpress.stackexchange.com/users/6961",
"pm_score": 1,
"selected": false,
"text": "<p>Below is function to get user ids for roles, from <a href=\"http://sltaylor.co.uk/blog/get-wordpress-users-b... | 2011/07/16 | [
"https://wordpress.stackexchange.com/questions/23130",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4999/"
] | I'm using the code below from another answer to query posts from 1 custom role, eg "friends". I thought I could just comma separate the roles to list posts from more than one role, but this didn't work. Is there another way I can write it? I've tried `'role' => 'friends', 'enemies'` and `'role' => 'friends, enemies'` b... | Just do the get\_users() twice and merge the results:
```
<?php
$friends = get_users( array( 'role' => 'friends' ) );
$enemies = get_users( array( 'role' => 'enemies' ) );
$friends_n_foe = array_merge($friends, $enemies);
$IDs = array();
foreach( $friends_n_foe as $person ) {
$IDs[] = $person->ID;
}
$news = ne... |
23,131 | <p>I use this code for display custom posts :</p>
<pre><code>$args = array(
'category__in' => $bookcat,
'meta_query' => array(
'relation' => 'OR',
array('key' => 'bookname','compare' => 'LIKE','value' => $bookname),
array('key' => 'authr','compare' => 'LIKE','val... | [
{
"answer_id": 23139,
"author": "Scott",
"author_id": 4610,
"author_profile": "https://wordpress.stackexchange.com/users/4610",
"pm_score": 2,
"selected": true,
"text": "<p>Looking at your code it looks perfectly fine. Although the more complex you make your query the more resources it i... | 2011/07/16 | [
"https://wordpress.stackexchange.com/questions/23131",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6097/"
] | I use this code for display custom posts :
```
$args = array(
'category__in' => $bookcat,
'meta_query' => array(
'relation' => 'OR',
array('key' => 'bookname','compare' => 'LIKE','value' => $bookname),
array('key' => 'authr','compare' => 'LIKE','value' => $authr),
array('key' =>... | Looking at your code it looks perfectly fine. Although the more complex you make your query the more resources it is going to take and the longer it is going to take. You mention that your CPU usage rises to 80% which would be normal but how long is the usage holding at 80%? If its for a very short while then I wouldn'... |
23,136 | <p>I've created a custom post type with categories and sub categories, what I need to do is list out the post titles and images for a given sub-category or category in a page template.</p>
<p>I've got as far as getting the all the listed items in the custom post type, but I'm unsure how to go further... any help appre... | [
{
"answer_id": 23137,
"author": "Rajeev Vyas",
"author_id": 6961,
"author_profile": "https://wordpress.stackexchange.com/users/6961",
"pm_score": 2,
"selected": false,
"text": "<p>You can get it if you have/know category/subcategory slug...</p>\n\n<p>Just pass it in args array for query_... | 2011/07/16 | [
"https://wordpress.stackexchange.com/questions/23136",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3782/"
] | I've created a custom post type with categories and sub categories, what I need to do is list out the post titles and images for a given sub-category or category in a page template.
I've got as far as getting the all the listed items in the custom post type, but I'm unsure how to go further... any help appreciated.
`... | This is a version of a function I'm using in the framework I'm working on, with example html replacing another function that contains something like it.
```
// Custom Loop
function arrr_custom_loop( $r_type = 'post', $r_post_num, $r_tax = 'category', $r_terms = 'featured' ) {
$args = array(
'showposts' => $r_po... |
23,142 | <p>I want 5 posts on my front page but 10 posts on subsequent pages (page 2, 3, ..).</p>
<p>In my Settings > Reading > Blog pages show at most > I have 10. But I want to show only 5 posts on the front page, so in index.php I use this :</p>
<pre><code>if ( $paged <= 1 ) $posts = query_posts($query_string.'&post... | [
{
"answer_id": 23257,
"author": "Sean Lee",
"author_id": 6851,
"author_profile": "https://wordpress.stackexchange.com/users/6851",
"pm_score": -1,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code>$page_num = $paged;\nif ($pagenum='') $pagenum = 1;\nif ($pagenum > 1) { $post_... | 2011/07/16 | [
"https://wordpress.stackexchange.com/questions/23142",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5915/"
] | I want 5 posts on my front page but 10 posts on subsequent pages (page 2, 3, ..).
In my Settings > Reading > Blog pages show at most > I have 10. But I want to show only 5 posts on the front page, so in index.php I use this :
```
if ( $paged <= 1 ) $posts = query_posts($query_string.'&posts_per_page=5&paged='.$paged)... | There is a `post_limits` hook that you can use for this purpose exactly:
```
// in homepage show 6 posts
add_filter('post_limits', 'homepage_limits' );
function homepage_limits( $limits )
{
if(is_home() ) {
return 'LIMIT 0, 6';;
}
return $limits;
}
``` |
23,151 | <p>I have the following code that prints a comma separated list which I need in the form of an array, how do I get the list of id's into an array called $excluded_categories with contents as per below?</p>
<pre><code>$categories = get_categories(array('taxonomy'=>'projects_category', 'exclude'=>7, 'orderby'=>... | [
{
"answer_id": 23152,
"author": "t31os",
"author_id": 31073,
"author_profile": "https://wordpress.stackexchange.com/users/31073",
"pm_score": 2,
"selected": false,
"text": "<p>I'm pretty sure if you switched to <code>get_terms</code> or similar you could return the data as an array and h... | 2011/07/16 | [
"https://wordpress.stackexchange.com/questions/23151",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4316/"
] | I have the following code that prints a comma separated list which I need in the form of an array, how do I get the list of id's into an array called $excluded\_categories with contents as per below?
```
$categories = get_categories(array('taxonomy'=>'projects_category', 'exclude'=>7, 'orderby'=>'id'));
if ( !empty( $... | WP has a lot of nifty functions in the corners for such stuff. Try this:
```
if ( !empty( $categories ) ) {
$excluded_categories = wp_list_pluck( $categories, 'term_id');
$excluded_categories = implode(',', $excluded_categories);
}
``` |
23,154 | <p>I have a custom post type of <code>players</code>, and archive-players.php lists them all at an address such as <code>www.site.com/players</code>.</p>
<p>I'm then using a url like <code>www.site.com/players?type=pro</code> to list another page of just the pro players (modified wp_query based on custom user role, he... | [
{
"answer_id": 23155,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 5,
"selected": true,
"text": "<p>You have to add another rule which maps the /page/# to the &paged=# variable.</p>\n\n<p>Really though, you're ki... | 2011/07/16 | [
"https://wordpress.stackexchange.com/questions/23154",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4999/"
] | I have a custom post type of `players`, and archive-players.php lists them all at an address such as `www.site.com/players`.
I'm then using a url like `www.site.com/players?type=pro` to list another page of just the pro players (modified wp\_query based on custom user role, hence why I don't just do this with a taxono... | You have to add another rule which maps the /page/# to the &paged=# variable.
Really though, you're kinda doing it all backwards here by filtering the rules array. Just calling add\_rewrite\_rule to add your rules makes a bit more sense.
```
function plugin_name_add_rewrite_rules() {
add_rewrite_rule('players/type/... |
23,158 | <p>Is there a quick way to disable all comments on all posts and pages. I know that you can go into the dashboard under posts, click edit, and Do Not Allow, under comments. Is that the only way?</p>
| [
{
"answer_id": 23160,
"author": "Hiranthi",
"author_id": 7067,
"author_profile": "https://wordpress.stackexchange.com/users/7067",
"pm_score": 0,
"selected": false,
"text": "<p>Not including the comment-form in your theme also works (that's what I usually do).</p>\n"
},
{
"answer... | 2011/07/16 | [
"https://wordpress.stackexchange.com/questions/23158",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6133/"
] | Is there a quick way to disable all comments on all posts and pages. I know that you can go into the dashboard under posts, click edit, and Do Not Allow, under comments. Is that the only way? | The check if comments are enabled is performed by [`comments_open()`](http://codex.wordpress.org/Function_Reference/comments_open) function.
You can make it always return false via a filter with something like this:
```
add_filter('comments_open', '__return_false');
```
Other way would be to make comments avai... |
23,174 | <p>When I try to automatically install updates to Wordpress or plugins, I receive an error:</p>
<blockquote>
<p>An error occurred while updating... Could not create directory
.../wp-content/upgrade/...</p>
</blockquote>
<p>My web host runs an Apache environment, and other Wordpress websites I own don't have this ... | [
{
"answer_id": 23569,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 4,
"selected": false,
"text": "<blockquote>\n <p><strong>First do not use 777, change it back to 755.</strong></p>\n</blockquote>\n\n<p>Second you n... | 2011/07/16 | [
"https://wordpress.stackexchange.com/questions/23174",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3206/"
] | When I try to automatically install updates to Wordpress or plugins, I receive an error:
>
> An error occurred while updating... Could not create directory
> .../wp-content/upgrade/...
>
>
>
My web host runs an Apache environment, and other Wordpress websites I own don't have this problem. I have CHMOD the /wp-c... | >
> **First do not use 777, change it back to 755.**
>
>
>
Second you need to add the proper group permissions most likely to the same that Apache is running under.
To find that out try:
```
ps aux | grep apache
```
You will see the Apache user group on the left.
Now change your WordPress folder to the same u... |
23,176 | <p>If I upload a large size image inn my wordpress, the image breaks my template width. I have seen some templates which scale the large image's width to the maximum width of the post div.
What CSS or code I need to change for that purpose? Thanks.</p>
| [
{
"answer_id": 23178,
"author": "Pippin",
"author_id": 2418,
"author_profile": "https://wordpress.stackexchange.com/users/2418",
"pm_score": 0,
"selected": false,
"text": "<p>You don't need any CSS, just go to Settings > Media and adjust the Large image size width to that of your post co... | 2011/07/16 | [
"https://wordpress.stackexchange.com/questions/23176",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6908/"
] | If I upload a large size image inn my wordpress, the image breaks my template width. I have seen some templates which scale the large image's width to the maximum width of the post div.
What CSS or code I need to change for that purpose? Thanks. | In your `functions.php` file, you need to define `$content_width`, which will cause WordPress to scale **large**-size images, and also embedded videos, accordingly.
e.g. if the width of your content area is 600px:
```
if ( ! isset( $content_width ) ) {
$content_width = 600;
}
```
You will probably also want to ... |
23,193 | <p>I've created a custom taxonomy and I'm trying to get Wordpress to display the taxonomy template when no term is defined. Currently Wordpress is only showing the template when a term is defined on the URL.</p>
<p>My taxonomy is called <code>projects</code> and defined like this:</p>
<pre><code>$args = array(
'l... | [
{
"answer_id": 23194,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried flushing your rewrite rules?</p>\n\n<p>If not, go to <code>Dashboard -> Settings -> Pe... | 2011/07/17 | [
"https://wordpress.stackexchange.com/questions/23193",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6616/"
] | I've created a custom taxonomy and I'm trying to get Wordpress to display the taxonomy template when no term is defined. Currently Wordpress is only showing the template when a term is defined on the URL.
My taxonomy is called `projects` and defined like this:
```
$args = array(
'labels' => array(
'name' ... | I had a similar issue. I ended up using the archives.php and had a little more luck with that. It would see and use the archives.php (and the archives-video.php I created from it), but would not see taxonomy.php or taxonomy-videos.php or category.php like it should. |
23,195 | <p>I have an IF statement shown below that runs one of 2 custom queries, based on the url. The problem I'm facing is if the url contains pagination such as <code>/page/2/</code>, my query breaks because the url isn't correctly matched. I'm very new to php and in my searching I've come across a few different php functio... | [
{
"answer_id": 23194,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried flushing your rewrite rules?</p>\n\n<p>If not, go to <code>Dashboard -> Settings -> Pe... | 2011/07/17 | [
"https://wordpress.stackexchange.com/questions/23195",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4999/"
] | I have an IF statement shown below that runs one of 2 custom queries, based on the url. The problem I'm facing is if the url contains pagination such as `/page/2/`, my query breaks because the url isn't correctly matched. I'm very new to php and in my searching I've come across a few different php functions that may he... | I had a similar issue. I ended up using the archives.php and had a little more luck with that. It would see and use the archives.php (and the archives-video.php I created from it), but would not see taxonomy.php or taxonomy-videos.php or category.php like it should. |
23,196 | <p>I use excerpts of posts in my front page. In my excerpt, the summary of the post seems to be clumped together with no spaces that are indicated in the post (e.g., paragraph spaces are automatically removed). I understand this is the default behavior.</p>
<p>Question: Is there a way to retain the paragraph in excerp... | [
{
"answer_id": 23197,
"author": "Samuel Hulick",
"author_id": 7084,
"author_profile": "https://wordpress.stackexchange.com/users/7084",
"pm_score": 0,
"selected": false,
"text": "<p>The line that's important isn't likely to be the \"if\", it's this one:</p>\n\n<pre><code><?php the_exc... | 2011/07/17 | [
"https://wordpress.stackexchange.com/questions/23196",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5021/"
] | I use excerpts of posts in my front page. In my excerpt, the summary of the post seems to be clumped together with no spaces that are indicated in the post (e.g., paragraph spaces are automatically removed). I understand this is the default behavior.
Question: Is there a way to retain the paragraph in excerpts?
To sh... | Looks like my other answer wasn't working, so I looked into it and found this:
<http://aaronrussell.co.uk/legacy/improving-wordpress-the_excerpt/>
That article should give you all you need to keep the `<p>` tags in there. |
23,205 | <p>Does anyone know where I can get a <em>list of all the <strong>body classes</em></strong> generated by <code>body_class()</code> for <strong>every sections</strong> and <strong>every conditions</strong>, including <em>custom post-types</em>, etc.?</p>
<p>For example, for a <em>search result</em> page with certain c... | [
{
"answer_id": 23208,
"author": "Hiranthi",
"author_id": 7067,
"author_profile": "https://wordpress.stackexchange.com/users/7067",
"pm_score": 1,
"selected": false,
"text": "<p>There's a list of that on <a href=\"http://wpengineer.com/816/wordpress-28-body_class-automatic_feed_links/\" r... | 2011/07/17 | [
"https://wordpress.stackexchange.com/questions/23205",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1044/"
] | Does anyone know where I can get a *list of all the **body classes*** generated by `body_class()` for **every sections** and **every conditions**, including *custom post-types*, etc.?
For example, for a *search result* page with certain conditions (eg. *logged-in*), the function produces this:
```
<body class="search... | Several classes have been added since WordPress 2.8 (when the WPEngineer post was written). I would refer directly to the [`body_class()` Codex entry](http://codex.wordpress.org/Function_Reference/body_class), which currently lists the following:
* rtl
* home
* blog
* archive
* date
* search
* paged
* attachment
* err... |
23,235 | <p>Hitting a brick wall with the following:</p>
<p>I have:</p>
<ul>
<li>1 custom post type called <code>cpt_community</code></li>
<li>1 custom taxonomy called <code>tax_community</code></li>
</ul>
<p>If I set <code>'rewrite' => true</code> in my CPT registration, then permalinks to an entry for this CPT are of th... | [
{
"answer_id": 23358,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 3,
"selected": false,
"text": "<p>Use the function flush_rewrite_rules() for set the rewrite rules new, but not with your code on init-hook, only on... | 2011/07/17 | [
"https://wordpress.stackexchange.com/questions/23235",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/490/"
] | Hitting a brick wall with the following:
I have:
* 1 custom post type called `cpt_community`
* 1 custom taxonomy called `tax_community`
If I set `'rewrite' => true` in my CPT registration, then permalinks to an entry for this CPT are of the form of `http://<domain>/cpt_community/test_item/`, and I get a 404 when bro... | Use the function flush\_rewrite\_rules() for set the rewrite rules new, but not with your code on init-hook, only on activation plugin or theme! See more in my post: <http://wpengineer.com/2044/custom-post-type-and-permalink/>
```
global $wp_rewrite;
$wp_rewrite->flush_rules();
```
Flush rules *only* on activation (... |
23,239 | <p>I have a custom post type called "stock" and each post is going to have a stock_id, stock_name, stock_description and stock_available fields,...I would like to have defaults for these fields so the user doesn't have to load them on each new item. Is there a way?</p>
| [
{
"answer_id": 23358,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 3,
"selected": false,
"text": "<p>Use the function flush_rewrite_rules() for set the rewrite rules new, but not with your code on init-hook, only on... | 2011/07/17 | [
"https://wordpress.stackexchange.com/questions/23239",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5057/"
] | I have a custom post type called "stock" and each post is going to have a stock\_id, stock\_name, stock\_description and stock\_available fields,...I would like to have defaults for these fields so the user doesn't have to load them on each new item. Is there a way? | Use the function flush\_rewrite\_rules() for set the rewrite rules new, but not with your code on init-hook, only on activation plugin or theme! See more in my post: <http://wpengineer.com/2044/custom-post-type-and-permalink/>
```
global $wp_rewrite;
$wp_rewrite->flush_rules();
```
Flush rules *only* on activation (... |
23,259 | <p>I am trying to add the parent category class in post_class() of some posts from one of my subcatgories. I have an advanved theme so I need to style all the posts from the parent cateogry using it's class, not the subcategory class (too much hassle in CSS).</p>
| [
{
"answer_id": 23260,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": true,
"text": "<p>Perhaps something like:</p>\n\n<pre><code>function mytheme_get_post_class_parent_cats() {\n $parent_cat_c... | 2011/07/17 | [
"https://wordpress.stackexchange.com/questions/23259",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7097/"
] | I am trying to add the parent category class in post\_class() of some posts from one of my subcatgories. I have an advanved theme so I need to style all the posts from the parent cateogry using it's class, not the subcategory class (too much hassle in CSS). | Perhaps something like:
```
function mytheme_get_post_class_parent_cats() {
$parent_cat_classes = array();
// Get parent categories
$post_cats = wp_get_post_categories();
// Loop through post categories
foreach ( $post_cats as $post_cat ) {
$cat_parents = get_category_parents( $post_cat , f... |
23,261 | <p>I'm trying to insert a php code for a post-rating on wordpress.
It used to work out of the echo normally and in-place.
Now, using this code, instead of the rating showing up after "User Rating:" it renders completely out of the 'anime-info' div and show up above it.</p>
<p>The code is " . the_ratings() . "
The full... | [
{
"answer_id": 23266,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>It's because you're echoing a function that itself echoes a value. The function has a display parameter that you ha... | 2011/07/17 | [
"https://wordpress.stackexchange.com/questions/23261",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7100/"
] | I'm trying to insert a php code for a post-rating on wordpress.
It used to work out of the echo normally and in-place.
Now, using this code, instead of the rating showing up after "User Rating:" it renders completely out of the 'anime-info' div and show up above it.
The code is " . the\_ratings() . "
The full code sho... | It's because you're echoing a function that itself echoes a value. The function has a display parameter that you have to set to `false` if you want it to `return` it's value to use it that way:
```
function the_ratings($start_tag = 'div', $custom_id = 0, $display = true)
```
Also -
```
if($category->cat_ID = 4)
``... |
23,276 | <p>I'm trying to use a jquery toggle shortcode in a theme template.</p>
<p>The shortcode goes like this:</p>
<pre><code>[sws_toggle3 title="Title"]You can now see the displayed text.[/sws_toggle3]
</code></pre>
<p>I want to pull posts from a specific category and use the toggle to display them in the page.</p>
<p>T... | [
{
"answer_id": 23281,
"author": "markratledge",
"author_id": 268,
"author_profile": "https://wordpress.stackexchange.com/users/268",
"pm_score": 0,
"selected": false,
"text": "<p>I don't see the link with twentyten active, so if it only appears in another theme, clean that theme or repla... | 2011/07/18 | [
"https://wordpress.stackexchange.com/questions/23276",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7101/"
] | I'm trying to use a jquery toggle shortcode in a theme template.
The shortcode goes like this:
```
[sws_toggle3 title="Title"]You can now see the displayed text.[/sws_toggle3]
```
I want to pull posts from a specific category and use the toggle to display them in the page.
This is what my theme template currently ... | Found it! It was happening in FireFox but not Chrome. I looked at all my FireFox Extensions, and found "Browser Enhancements 1.0" and "Browser Coupons 1.0"
<http://www.webenhancements.me/>.
The other URL was searchdock.me, and was reported as a "threat" here:
<http://www.threatexpert.com/report.aspx?md5=af6cc99d717c... |
23,282 | <p>I have added several new fields to the user profile (areacode, company, affiliate, etc) and I would like to present a way to search on these fields. Please point me in the right direction.</p>
| [
{
"answer_id": 23287,
"author": "Sean Lee",
"author_id": 6851,
"author_profile": "https://wordpress.stackexchange.com/users/6851",
"pm_score": 1,
"selected": false,
"text": "<p>There are some plugins that you can take give a try, it may not be exact, but it should cover your needs:</p>\n... | 2011/07/18 | [
"https://wordpress.stackexchange.com/questions/23282",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6874/"
] | I have added several new fields to the user profile (areacode, company, affiliate, etc) and I would like to present a way to search on these fields. Please point me in the right direction. | I just had a project where i needed to create a search by user meta form and i ended up creating a shortcode for it, i just altered it a bit to show you how to make it work with your fields, so just paste this code inside your theme's functions.php file or a plugin file:
```
add_shortcode('user_search','My_User_search... |
23,291 | <p>In my theme, i want to create a generic way of inserting a meta box to a post, page, portfolio or other custom item.</p>
<p>For now, this action is like :</p>
<pre><code>add_action('admin_init', 'add_portfolio_settings');
</code></pre>
<p>Which works fine, but has a problem. It currently works only for creating a... | [
{
"answer_id": 23296,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 0,
"selected": false,
"text": "<p>Basically that's how action and filter hooks work, with predefined parameters and arguments.</p>\n\n<p>You ca... | 2011/07/18 | [
"https://wordpress.stackexchange.com/questions/23291",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6329/"
] | In my theme, i want to create a generic way of inserting a meta box to a post, page, portfolio or other custom item.
For now, this action is like :
```
add_action('admin_init', 'add_portfolio_settings');
```
Which works fine, but has a problem. It currently works only for creating an add\_meta\_box for a portfolio ... | What you want is quite possible, but not exactly mainstream technique. Take a look at my [Implementing advanced add\_\* function wrappers](https://wordpress.stackexchange.com/questions/11231/implementing-advanced-add-function-wrappers) question.
However your real issue here is not being unable to pass arguments. It is... |
23,292 | <p>I have spent the last few days working on and researching this question and have found no solution. </p>
<p>Basically I want to replace the query string which wordpress parses in order to query the database.</p>
<p>So for example, I want to say if the url is:</p>
<pre><code>www.mysite.com/support/question
</code>... | [
{
"answer_id": 23298,
"author": "thatthing",
"author_id": 7109,
"author_profile": "https://wordpress.stackexchange.com/users/7109",
"pm_score": 0,
"selected": false,
"text": "<p>I am not sure if this is what you are looking for maybe you can try this plugin: </p>\n\n<p><a href=\"http://w... | 2011/07/18 | [
"https://wordpress.stackexchange.com/questions/23292",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4816/"
] | I have spent the last few days working on and researching this question and have found no solution.
Basically I want to replace the query string which wordpress parses in order to query the database.
So for example, I want to say if the url is:
```
www.mysite.com/support/question
```
go to
```
www.mysite.com/an... | To at least answer the title of your question, the [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) filter may be useful. From the Codex:
>
> This hook is called after the query variable object is created, but
> before the actual query is run.
>
>
> The pre\_get\_posts action... |
23,306 | <p>I would like to show a plugin in a specific page's sidebar only.</p>
<p><strong>For Example:</strong>
I have the pages like ..</p>
<ul>
<li>home</li>
<li>about us</li>
<li><ul>
<li>sub page 1</li>
</ul></li>
<li><ul>
<li>sub page 2</li>
</ul></li>
<li><ul>
<li>sub page 3</li>
</ul></li>
<li><ul>
<li>sub page 4</l... | [
{
"answer_id": 23307,
"author": "keatch",
"author_id": 2727,
"author_profile": "https://wordpress.stackexchange.com/users/2727",
"pm_score": 2,
"selected": false,
"text": "<p>You may try <a href=\"http://wordpress.org/extend/plugins/widget-logic/\" rel=\"nofollow\" title=\"Widget Logic\"... | 2011/07/18 | [
"https://wordpress.stackexchange.com/questions/23306",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5669/"
] | I would like to show a plugin in a specific page's sidebar only.
**For Example:**
I have the pages like ..
* home
* about us
* + sub page 1
* + sub page 2
* + sub page 3
* + sub page 4
**UPdate:**
i want to show, **plugin 1** in **sub page 1** and **sub page 4 only** and not to all other pages.i tried `is_page('su... | The way to [use is\_page](http://codex.wordpress.org/Function_Reference/is_page) with multiple pages is as follows:
```
is_page(array(42,'about-me','Contact'));
```
You have to use the `array` keyword |
23,318 | <p>I recently developed a small plugin for my site, that uses AJAX, and now I am trying to implement the same AJAX techniques for the same site's templates, but I keep getting <code>-1</code> as the result, here is my code,</p>
<p>functions.php:</p>
<pre><code> //Front end AJAX functions
function eu_custom_qu... | [
{
"answer_id": 23320,
"author": "Cristian",
"author_id": 2264,
"author_profile": "https://wordpress.stackexchange.com/users/2264",
"pm_score": 3,
"selected": true,
"text": "<p>You are passing 'eu_custom_query' as the action in your AJAX. It should be 'custom_query'.</p>\n\n<p>You decide ... | 2011/07/18 | [
"https://wordpress.stackexchange.com/questions/23318",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2632/"
] | I recently developed a small plugin for my site, that uses AJAX, and now I am trying to implement the same AJAX techniques for the same site's templates, but I keep getting `-1` as the result, here is my code,
functions.php:
```
//Front end AJAX functions
function eu_custom_query(){
global $post;
... | You are passing 'eu\_custom\_query' as the action in your AJAX. It should be 'custom\_query'.
You decide the action name, when you add the action i.e. 'wp\_ajax\_my\_action' would be called 'my\_action'
You are confusing it with the callback method. Hope that makes sense.
p.s. to fix your code change:
```
add_actio... |
23,322 | <p>I want to use built-in WP media gallery. I'm trying to simply add images in one - horizontal line. I want images with original size and without any link. I'm trying to add/edit some code into wp-admin/includes/media.php but I can't get it ;/ I know I have to use size="full" and columns="0" but how to add this with s... | [
{
"answer_id": 23329,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 1,
"selected": false,
"text": "<p>No</p>\n\n<ol>\n<li>Do not hack core files. </li>\n<li>The full size image is an option by default, you can change... | 2011/07/18 | [
"https://wordpress.stackexchange.com/questions/23322",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15476/"
] | I want to use built-in WP media gallery. I'm trying to simply add images in one - horizontal line. I want images with original size and without any link. I'm trying to add/edit some code into wp-admin/includes/media.php but I can't get it ;/ I know I have to use size="full" and columns="0" but how to add this with shor... | **UPDATE**
I've just submitted [a core patch to add `link="none"` support](http://core.trac.wordpress.org/ticket/18178) to the `[gallery]` shortcode.
**ORIGINAL ANSWER**
You don't need to hack core to do what you want to do; just use [the appropriate `[gallery]` shortcode parameters](http://codex.wordpress.org/Galle... |
23,327 | <p>Here's my setup. I have a Multisite instance running at <a href="http://example.com">http://example.com</a>, and I want to do development and staging. Moving an existing Multisite instance of WP onto localhost is a nightmare, so I'm going to do dev on a staging location instead.</p>
<p>I set up <a href="http://stag... | [
{
"answer_id": 23480,
"author": "timshutes",
"author_id": 5861,
"author_profile": "https://wordpress.stackexchange.com/users/5861",
"pm_score": 3,
"selected": true,
"text": "<p>One thought - when I go to www.example.com/staging/wp-admin it automatically redirects me to www.example.com/wp... | 2011/07/18 | [
"https://wordpress.stackexchange.com/questions/23327",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/871/"
] | Here's my setup. I have a Multisite instance running at <http://example.com>, and I want to do development and staging. Moving an existing Multisite instance of WP onto localhost is a nightmare, so I'm going to do dev on a staging location instead.
I set up <http://staging.example.com> to point to the /public\_html/st... | One thought - when I go to www.example.com/staging/wp-admin it automatically redirects me to www.example.com/wp-admin
Could the redirect from staging.example.com to example.com/staging be conflicting with the existing install?
UPDATE: looks like it could be related to .htaccess issues and complicated domain reference... |
23,340 | <p>So hard to find this info...</p>
<p>I'd like to know a way to find out if there are pages. Something like:</p>
<pre><code>if (has_pages()) { /* do something */ }
</code></pre>
<p>I can't find a reference to any similar function... how might one go about finding out if there are pages. In case yr wondering I'd lik... | [
{
"answer_id": 23341,
"author": "helenhousandi",
"author_id": 2226,
"author_profile": "https://wordpress.stackexchange.com/users/2226",
"pm_score": 0,
"selected": false,
"text": "<p>You might try using <code>wp_count_posts</code>, which will return an object with post statuses as propert... | 2011/07/18 | [
"https://wordpress.stackexchange.com/questions/23340",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6068/"
] | So hard to find this info...
I'd like to know a way to find out if there are pages. Something like:
```
if (has_pages()) { /* do something */ }
```
I can't find a reference to any similar function... how might one go about finding out if there are pages. In case yr wondering I'd like to only show a pages menu if th... | You could also use `wp_list_pages()` ([Codex ref](http://codex.wordpress.org/Function_Reference/wp_list_pages)):
```
<?php
$has_pages = wp_list_pages( array( 'echo' => false ) );
if ( $has_pages ) {
// There are pages; do something
}
?>
``` |
23,344 | <p>I have a custom post with a lot of meta boxes. I recently tried to add some dynamic metaboxes, using this question: <a href="https://wordpress.stackexchange.com/questions/19838/create-more-meta-boxes-as-needed">Create more Meta Boxes as needed</a></p>
<p>I managed to get the metaboxes to add nicely, the jquery work... | [
{
"answer_id": 23384,
"author": "tollmanz",
"author_id": 4850,
"author_profile": "https://wordpress.stackexchange.com/users/4850",
"pm_score": 2,
"selected": false,
"text": "<p>I believe the problem lies in the following code:</p>\n\n<pre><code>if (isset($_POST['reviews-nonce'])){\n i... | 2011/07/18 | [
"https://wordpress.stackexchange.com/questions/23344",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1118/"
] | I have a custom post with a lot of meta boxes. I recently tried to add some dynamic metaboxes, using this question: [Create more Meta Boxes as needed](https://wordpress.stackexchange.com/questions/19838/create-more-meta-boxes-as-needed)
I managed to get the metaboxes to add nicely, the jquery works, everything works e... | Following are the issues that were preventing from the meta values to be saved in both of your save functions.
**1. Incorrect post\_type checking.**
You are checking post type to be of 'page' in your save function where as your meta boxes are being displayed on your custom post type of 'film'.
Your code:
```
if ( 'p... |
23,364 | <p>This is the <a href="http://codex.wordpress.org/Function_Reference/is_active_widget" rel="noreferrer">manual page</a> and this is <a href="http://core.trac.wordpress.org/browser/tags/3.2.1/wp-includes/widgets.php" rel="noreferrer">the code</a>.</p>
<p>But I'm still struggling to understand how to use this function.... | [
{
"answer_id": 23368,
"author": "onetrickpony",
"author_id": 1986,
"author_profile": "https://wordpress.stackexchange.com/users/1986",
"pm_score": 4,
"selected": true,
"text": "<p>You should make the check inside the widget class, unless you don't have a choice. The example in the <a hre... | 2011/07/18 | [
"https://wordpress.stackexchange.com/questions/23364",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | This is the [manual page](http://codex.wordpress.org/Function_Reference/is_active_widget) and this is [the code](http://core.trac.wordpress.org/browser/tags/3.2.1/wp-includes/widgets.php).
But I'm still struggling to understand how to use this function. Perhaps I am using it right, but something I can't think of is wr... | You should make the check inside the widget class, unless you don't have a choice. The example in the [codex](http://codex.wordpress.org/Function_Reference/is_active_widget) is pretty much what you're looking for:
```
class cbs_map_widget extends WP_Widget{
function cbs_map_widget(){
$this->WP_Widget('cbsmaps',... |
23,381 | <p>I have a custom search which is a form that submits to the same page and uses wp_query to filter the results for a jobs site that I would also like the keyword search to also search in custom fields and a custom taxonomy but I am unsure how to use posts_join to do this. </p>
<p>I want to allow the user to type in t... | [
{
"answer_id": 23683,
"author": "kevin",
"author_id": 1997,
"author_profile": "https://wordpress.stackexchange.com/users/1997",
"pm_score": 0,
"selected": false,
"text": "<p>Give a look at this plugin: <a href=\"http://wordpress.org/extend/plugins/search-everything/\" rel=\"nofollow\">Se... | 2011/07/19 | [
"https://wordpress.stackexchange.com/questions/23381",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6224/"
] | I have a custom search which is a form that submits to the same page and uses wp\_query to filter the results for a jobs site that I would also like the keyword search to also search in custom fields and a custom taxonomy but I am unsure how to use posts\_join to do this.
I want to allow the user to type in the refer... | Managed to figure it out by adapting that code from the link i posted:
```
function atom_search_where($where){
global $wpdb;
if($_SESSION['js'] != '')
$where .= "OR (t.name LIKE '%".trim($_SESSION['js'])."%' AND {$wpdb- >posts}.post_status = 'publish')";
$where .= "OR ($wpdb->postmeta.meta_key = '_job_ref' AND $wpd... |
23,386 | <p>I'd like to be able to edit a Page or Post that I'm on in Wordpress rather than go to the admin panel on left and find the page or post.</p>
<p>I somehow think it used to be there, but when I navigate to a page, it's not in the Top Admin Menu options.</p>
| [
{
"answer_id": 23389,
"author": "Joshua",
"author_id": 7105,
"author_profile": "https://wordpress.stackexchange.com/users/7105",
"pm_score": 2,
"selected": false,
"text": "<p>Typically most themes will include an edit link on the post/page itself that takes you directly to the backend to... | 2011/07/19 | [
"https://wordpress.stackexchange.com/questions/23386",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4088/"
] | I'd like to be able to edit a Page or Post that I'm on in Wordpress rather than go to the admin panel on left and find the page or post.
I somehow think it used to be there, but when I navigate to a page, it's not in the Top Admin Menu options. | Typically most themes will include an edit link on the post/page itself that takes you directly to the backend to edit the post. If not, you can always add it yourself with code similar to the following in single.php, page.php, etc.:
```
<?php edit_post_link('(Edit this post)', '<p>', '</p>'); ?>
```
(See <http://co... |
23,421 | <p>I want to retrieve a specific post_meta of all posts contained in a specific category. I want to build a search form at the top of each category with a select field which would be filled up by the required post_meta of all the post contained in the category the user is currently in. Is this doable?
Maybe it's possib... | [
{
"answer_id": 23514,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 0,
"selected": false,
"text": "<p>I sounds like your doing this wrong. You do not typically query the post meta first in a hierarchical query since ... | 2011/07/19 | [
"https://wordpress.stackexchange.com/questions/23421",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7131/"
] | I want to retrieve a specific post\_meta of all posts contained in a specific category. I want to build a search form at the top of each category with a select field which would be filled up by the required post\_meta of all the post contained in the category the user is currently in. Is this doable?
Maybe it's possibl... | Thank you very much for your answers!
I finally found what I wanted here : <http://sixrevisions.com/wordpress/custom-fields-search/>
Here is the code :
```
<form name="search" action="" method="get">
<select name="City">
<?php
$metakey = 'city';
$cities = $wpdb->get_col($wpdb->prepare("SELECT DISTINCT meta_valu... |
23,453 | <p>I am trying to remove the admin bar from a theme front end of a theme. </p>
<p>I found the following code block:</p>
<pre><code>add_filter( 'show_admin_bar', '__return_false' );
remove_action( 'personal_options', '_admin_bar_preferences' );
</code></pre>
<p>Which works fine. <em>However</em> I wanted to add a cho... | [
{
"answer_id": 23454,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 0,
"selected": false,
"text": "<p>Have you saved your settings, so that they <em>do</em> exist in the database?</p>\n\n<p>Also: what if you c... | 2011/07/19 | [
"https://wordpress.stackexchange.com/questions/23453",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/784/"
] | I am trying to remove the admin bar from a theme front end of a theme.
I found the following code block:
```
add_filter( 'show_admin_bar', '__return_false' );
remove_action( 'personal_options', '_admin_bar_preferences' );
```
Which works fine. *However* I wanted to add a choice for the user, so that I can add a pe... | Just launching the function at an earlier point solved the issue
```
function block_admin(){
$show = get_option('admin_bar_');
$show = $show['admin_bar_toggle'];
fb::log($show,'shoe');
if (!$show || $show != 'on'){
add_filter( 'show_admin_bar', '__return_false' );
remove_action( 'perso... |
23,469 | <p>For some reason, my menu items are showing tooltips on hover-over- In other words, the menu links have "title" attributes being added to them. Looking at my other, older WordPress sites, this is not the case. I can't remember having this issue before- Why would this be happening?</p>
<p>Thanks-</p>
| [
{
"answer_id": 23470,
"author": "Yarin",
"author_id": 4197,
"author_profile": "https://wordpress.stackexchange.com/users/4197",
"pm_score": 0,
"selected": false,
"text": "<p>I fixed this by adding a explicitly creating a menu vs relying on the default. Don't know why this would help (Fi... | 2011/07/19 | [
"https://wordpress.stackexchange.com/questions/23469",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4197/"
] | For some reason, my menu items are showing tooltips on hover-over- In other words, the menu links have "title" attributes being added to them. Looking at my other, older WordPress sites, this is not the case. I can't remember having this issue before- Why would this be happening?
Thanks- | Here’s the code to remove it from wp\_page\_menu(), wp\_nav\_menu() and wp\_list\_categories() function:
```
function my_menu_notitle( $menu ){
return $menu = preg_replace('/ title=\"(.*?)\"/', '', $menu );
}
add_filter( 'wp_nav_menu', 'my_menu_notitle' );
add_filter( 'wp_page_menu', 'my_menu_notitle' );
add_filte... |
23,474 | <p>I have a members section on my site and they see specific custom menu items. I'm seeking a way to simply apply a star to the <code><li></code> based on it's permission level and what the user's role is. </p>
<p>Something to the effect of.</p>
<pre><code>if( current_user_can('integrator') || current_user_can(... | [
{
"answer_id": 23478,
"author": "robertwbradford",
"author_id": 7152,
"author_profile": "https://wordpress.stackexchange.com/users/7152",
"pm_score": 0,
"selected": false,
"text": "<p>Instead of adding the classes directly to the li elements, you could add it to a wrapper. Or why not the... | 2011/07/19 | [
"https://wordpress.stackexchange.com/questions/23474",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3296/"
] | I have a members section on my site and they see specific custom menu items. I'm seeking a way to simply apply a star to the `<li>` based on it's permission level and what the user's role is.
Something to the effect of.
```
if( current_user_can('integrator') || current_user_can('distributor')) :
```
This is what I... | WRT to your question "need to apply the class if another class is present and the user's role is (whatever)"
The easiest was to do this, isn't in the code, but yet in the CSS. You can target an element that has more then once class. So, using your class `PARTNER_STAR` and if your other class is say `another` you can h... |
23,484 | <p>I have the following:</p>
<pre><code>$query = 'SELECT * FROM wp_pod_tbl_add_questions WHERE id LIKE '. $id;
$row = $wpdb -> get_results($query);
</code></pre>
<p>How do I get the columns named 'id' and 'name' from $row?</p>
| [
{
"answer_id": 23488,
"author": "Jeff Rose",
"author_id": 2390,
"author_profile": "https://wordpress.stackexchange.com/users/2390",
"pm_score": 2,
"selected": false,
"text": "<p>Always Try the WordPress Codex:\n<a href=\"http://codex.wordpress.org/Class_Reference/wpdb#SELECT_Generic_Resu... | 2011/07/19 | [
"https://wordpress.stackexchange.com/questions/23484",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2417/"
] | I have the following:
```
$query = 'SELECT * FROM wp_pod_tbl_add_questions WHERE id LIKE '. $id;
$row = $wpdb -> get_results($query);
```
How do I get the columns named 'id' and 'name' from $row? | ```
foreach( $wpdb->get_results("SELECT * FROM your_table_name WHERE id LIKE' . $id . ';") as $key => $row) {
// each column in your row will be accessible like this
$my_column = $row->column_name;}
```
More info [here](https://www.wphub.com/blog/posts/working-with-database-tables-plugins-part-2/) |
23,486 | <p>Just trying the multisite feature for the first time. The primary hostname is blog.domain1.com. When trying to create multiple sites, it only allows me to create XXXXX.blog.domain1.com. But what I really want is blog.domain2.com, blog.domain3.com, etc. All on the same Apache instance, same database, same IP.</p>
<p... | [
{
"answer_id": 23488,
"author": "Jeff Rose",
"author_id": 2390,
"author_profile": "https://wordpress.stackexchange.com/users/2390",
"pm_score": 2,
"selected": false,
"text": "<p>Always Try the WordPress Codex:\n<a href=\"http://codex.wordpress.org/Class_Reference/wpdb#SELECT_Generic_Resu... | 2011/07/19 | [
"https://wordpress.stackexchange.com/questions/23486",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6573/"
] | Just trying the multisite feature for the first time. The primary hostname is blog.domain1.com. When trying to create multiple sites, it only allows me to create XXXXX.blog.domain1.com. But what I really want is blog.domain2.com, blog.domain3.com, etc. All on the same Apache instance, same database, same IP.
Is that d... | ```
foreach( $wpdb->get_results("SELECT * FROM your_table_name WHERE id LIKE' . $id . ';") as $key => $row) {
// each column in your row will be accessible like this
$my_column = $row->column_name;}
```
More info [here](https://www.wphub.com/blog/posts/working-with-database-tables-plugins-part-2/) |
23,503 | <p>I'm wanting to find a way to have all pages listed without paging and to do so in a method that isn't going to be over-written when I update WordPress, i.e. in the form of a hook.</p>
<p>The page is in the administration:<br />
<img src="https://i.stack.imgur.com/KkPaM.png" alt="all pages" /></p>
<p>With all the pag... | [
{
"answer_id": 23504,
"author": "GavinR",
"author_id": 2001,
"author_profile": "https://wordpress.stackexchange.com/users/2001",
"pm_score": 2,
"selected": false,
"text": "<p>You can <a href=\"http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates\" rel=\"nofollow\">create a n... | 2011/07/20 | [
"https://wordpress.stackexchange.com/questions/23503",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1599/"
] | I'm wanting to find a way to have all pages listed without paging and to do so in a method that isn't going to be over-written when I update WordPress, i.e. in the form of a hook.
The page is in the administration:

With all the pages being listed I can then use jav... | If that listing has too many pages, maybe you'll run into troubles.
You probably already know that this can be set in the `Screen Options` of the page `http://example.com/wp-admin/edit.php?post_type=page`.
If you try to put a really high value there, this warning pops up and the system doesn't accept it:
![1500 page... |
23,509 | <p>I'm having a devil of a time getting my plugin settings to save. I've gone through the code so many times I have to think I've simply missed something. I'm following the Setting API, but any changes I make on the plugin settings page don't save. What did I miss?</p>
<pre><code>function __construct() {
self::$ins... | [
{
"answer_id": 23544,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 3,
"selected": true,
"text": "<p>the problem is you keep resting the values here:</p>\n\n<pre><code> $options = array(\n 'cemb_seminar_s... | 2011/07/20 | [
"https://wordpress.stackexchange.com/questions/23509",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6064/"
] | I'm having a devil of a time getting my plugin settings to save. I've gone through the code so many times I have to think I've simply missed something. I'm following the Setting API, but any changes I make on the plugin settings page don't save. What did I miss?
```
function __construct() {
self::$instance = $this;
/... | the problem is you keep resting the values here:
```
$options = array(
'cemb_seminar_seminars_college' => '0',
'cemb_seminar_showcases_college' => '0',
'cemb_seminar_writers_college' > '0',
'cemb_seminar_aet_college' => '0',
'cemb_seminar_mbu_college' => '0',
'cemb_semi... |
23,522 | <p>Hi I have a VPS and one particular site is apparently causing the server to crash and I am getting alerts about lots of IO going on. How can I troubleshoot to see what is causing the extra load?</p>
| [
{
"answer_id": 23544,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 3,
"selected": true,
"text": "<p>the problem is you keep resting the values here:</p>\n\n<pre><code> $options = array(\n 'cemb_seminar_s... | 2011/07/20 | [
"https://wordpress.stackexchange.com/questions/23522",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5844/"
] | Hi I have a VPS and one particular site is apparently causing the server to crash and I am getting alerts about lots of IO going on. How can I troubleshoot to see what is causing the extra load? | the problem is you keep resting the values here:
```
$options = array(
'cemb_seminar_seminars_college' => '0',
'cemb_seminar_showcases_college' => '0',
'cemb_seminar_writers_college' > '0',
'cemb_seminar_aet_college' => '0',
'cemb_seminar_mbu_college' => '0',
'cemb_semi... |
23,532 | <p>I have done all the steps requiered to import the dump.sql file to new database, and copiey the entire content from the old domain over to the new one.</p>
<p>When i login to mydomain/wp-admin, i'm redirected back to the frontpage of the old domain, and can't access my control panel. I've followed all the steps for... | [
{
"answer_id": 23535,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>First add </p>\n\n<pre><code>define('WP_SITEURL', 'http://example.com');\ndefine('WP_HOME', 'http://example.c... | 2011/07/20 | [
"https://wordpress.stackexchange.com/questions/23532",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7169/"
] | I have done all the steps requiered to import the dump.sql file to new database, and copiey the entire content from the old domain over to the new one.
When i login to mydomain/wp-admin, i'm redirected back to the frontpage of the old domain, and can't access my control panel. I've followed all the steps for setting i... | First add
```
define('WP_SITEURL', 'http://example.com');
define('WP_HOME', 'http://example.com');
```
To your wp-config.php file (obviously change example.com to your domain)
then login and once you see the admin panel navigate to `http://yoursite/wp-admin/options.php`
there you can change `home` and `siteurl` t... |
23,557 | <p>How can i get the row counts in query post like mysql count(*).</p>
<pre><code>$obj_name = new WP_Query($args);
while ($obj_name->have_posts()) : $obj_name->the_post();
// here i want to predict looping counts
endwhile;
</code></pre>
<p>How can i do this.</p>
| [
{
"answer_id": 23558,
"author": "GavinR",
"author_id": 2001,
"author_profile": "https://wordpress.stackexchange.com/users/2001",
"pm_score": 6,
"selected": true,
"text": "<pre><code>$num = $obj_name->post_count; \n</code></pre>\n\n<p>Reference: <a href=\"http://codex.wordpress.org/Cla... | 2011/07/20 | [
"https://wordpress.stackexchange.com/questions/23557",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4022/"
] | How can i get the row counts in query post like mysql count(\*).
```
$obj_name = new WP_Query($args);
while ($obj_name->have_posts()) : $obj_name->the_post();
// here i want to predict looping counts
endwhile;
```
How can i do this. | ```
$num = $obj_name->post_count;
```
Reference: [wp\_query](http://codex.wordpress.org/Class_Reference/WP_Query) |
23,568 | <p>Is there a way to put a placeholder text in the category form label? Right now the label is empty and has a dropdown menu filled with categories. I want to make a dummy placeholder text which will be something to : CHOOSE THE CATEGORY!</p>
<pre><code><option value="<option value="<?php wp_dropdown_categori... | [
{
"answer_id": 23574,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>I’m not sure if I understand your question right. Do you need the parameter <code>'show_option_none'</code> or somethi... | 2011/07/20 | [
"https://wordpress.stackexchange.com/questions/23568",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5499/"
] | Is there a way to put a placeholder text in the category form label? Right now the label is empty and has a dropdown menu filled with categories. I want to make a dummy placeholder text which will be something to : CHOOSE THE CATEGORY!
```
<option value="<option value="<?php wp_dropdown_categories('exclude=34, selecte... | You can add it as an argument:
```
<?php wp_dropdown_categories( 'show_option_none=CHOOSE THE CATEGORY!' ); ?>
```
Reference: [wp\_dropdown\_categories](http://codex.wordpress.org/Function_Reference/wp_dropdown_categories) |
23,571 | <p>Can I get the term by its id without knowing to which taxonomy it belongs?</p>
<p>I have a meta field that stores term ids, but doesn't store the taxonomy. However, all the <code>get_term</code> function have taxonomy parameter marked as required.</p>
<p>Maybe I can get the taxonomy of the term by its (term's) id ... | [
{
"answer_id": 23573,
"author": "onetrickpony",
"author_id": 1986,
"author_profile": "https://wordpress.stackexchange.com/users/1986",
"pm_score": 3,
"selected": true,
"text": "<p>Yes, but you need you make your own SQL query.</p>\n\n<p>A modified version of WP's get_term():</p>\n\n<pre>... | 2011/07/20 | [
"https://wordpress.stackexchange.com/questions/23571",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5902/"
] | Can I get the term by its id without knowing to which taxonomy it belongs?
I have a meta field that stores term ids, but doesn't store the taxonomy. However, all the `get_term` function have taxonomy parameter marked as required.
Maybe I can get the taxonomy of the term by its (term's) id somehow? | Yes, but you need you make your own SQL query.
A modified version of WP's get\_term():
```
function &get_term_by_id_only($term, $output = OBJECT, $filter = 'raw') {
global $wpdb;
$null = null;
if ( empty($term) ) {
$error = new WP_Error('invalid_term', __('Empty Term'));
return $error;
... |
23,599 | <p>I have created a custom taxonomy for my site called <code>projects</code> with a matching template called <code>taxonomy-projects.php</code>. The problem is that when I browse to <code>http://mysite.com/projects</code> the template is not triggered, <code>index.php</code> is, but when I browse to <code>http://mysite... | [
{
"answer_id": 23766,
"author": "danielwiener",
"author_id": 6817,
"author_profile": "https://wordpress.stackexchange.com/users/6817",
"pm_score": 1,
"selected": false,
"text": "<p>Have you tried it with the permalink base in the url? It defaults to \"category\".\n<a href=\"http://mysite... | 2011/07/20 | [
"https://wordpress.stackexchange.com/questions/23599",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6616/"
] | I have created a custom taxonomy for my site called `projects` with a matching template called `taxonomy-projects.php`. The problem is that when I browse to `http://mysite.com/projects` the template is not triggered, `index.php` is, but when I browse to `http://mysite.com/projects/someterm` the template shows up just f... | you have to use archive-projects.php to work mysite.com/projects, that's all |
23,602 | <p>I am trying to redirect this page if the user is logged in or not be i keep getting this error</p>
<pre><code>Warning: Cannot modify header information - headers already sent by (output started at /home/*******/*********.com/wp-content/plugins/graph2.php:54) in /home/*******/*********.com/wp-includes/pluggable.php ... | [
{
"answer_id": 23605,
"author": "Pippin",
"author_id": 2418,
"author_profile": "https://wordpress.stackexchange.com/users/2418",
"pm_score": 2,
"selected": false,
"text": "<p>Replace <code>wp_redirect( 'http://www.example.com' );</code> with <code>wp_redirect( 'http://www.example.com' );... | 2011/07/20 | [
"https://wordpress.stackexchange.com/questions/23602",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I am trying to redirect this page if the user is logged in or not be i keep getting this error
```
Warning: Cannot modify header information - headers already sent by (output started at /home/*******/*********.com/wp-content/plugins/graph2.php:54) in /home/*******/*********.com/wp-includes/pluggable.php on line 934
`... | Replace `wp_redirect( 'http://www.example.com' );` with `wp_redirect( 'http://www.example.com' ); exit;` |
23,606 | <p>I've searched far and wide to try and find an answer to my question. I'm hoping I can get help here. Here goes...</p>
<p>I'm currently retrieving the terms of my custom taxonomy using:</p>
<pre><code><?php echo get_the_term_list( $post->ID, 'skills', '<ul><li>', '</li><li>', '</l... | [
{
"answer_id": 23614,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 4,
"selected": true,
"text": "<p>Can try this: </p>\n\n<pre><code>$terms = get_the_terms ($post->id, 'skills');\nif ( !is_wp_error($terms)) : ?&g... | 2011/07/21 | [
"https://wordpress.stackexchange.com/questions/23606",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7189/"
] | I've searched far and wide to try and find an answer to my question. I'm hoping I can get help here. Here goes...
I'm currently retrieving the terms of my custom taxonomy using:
```
<?php echo get_the_term_list( $post->ID, 'skills', '<ul><li>', '</li><li>', '</li></ul>' ); ?>
```
What I'm trying to do is retrieve t... | Can try this:
```
$terms = get_the_terms ($post->id, 'skills');
if ( !is_wp_error($terms)) : ?>
<?php
$skills_links = wp_list_pluck($terms, 'name');
$skills_yo = implode(", ", $skills_links);
?>
<span><?php echo $skills_yo; ?></span>
``` |
23,669 | <p>I have a taxonomy called <strong><code>tcp_product_category</code></strong>. In the admin panel I have created a few terms within this taxonomy. On the homepage I want to display the description of one of those terms with the slug <strong><code>all-products</code></strong>. </p>
<p>For all normal categories I use t... | [
{
"answer_id": 24092,
"author": "ChrisPlaneta",
"author_id": 7212,
"author_profile": "https://wordpress.stackexchange.com/users/7212",
"pm_score": 2,
"selected": false,
"text": "<p>Ok. I've found a solution. Thanks to <a href=\"http://coding.smashingmagazine.com/2011/06/08/how-to-build-a... | 2011/07/21 | [
"https://wordpress.stackexchange.com/questions/23669",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7212/"
] | I have a taxonomy called **`tcp_product_category`**. In the admin panel I have created a few terms within this taxonomy. On the homepage I want to display the description of one of those terms with the slug **`all-products`**.
For all normal categories I use this code:
```
<?php echo category_description( get_term_b... | Ok. I've found a solution. Thanks to [this great article on Smashing Magazine](http://coding.smashingmagazine.com/2011/06/08/how-to-build-a-media-site-on-wordpress-part-2/)
The code to retrieve category description from any taxonomy term would be :
```
<?php echo (get_term_by('slug', 'your-term-name', 'your-taxonomy-... |
23,672 | <p>I have a WP network and have found that users with roles other than "super user" (admins, editors, authors, etc.) are getting a 404 when trying to preview draft posts/pages/custom post types.</p>
<p>Any idea why this would be? I have the following:</p>
<ul>
<li>Version 3.1.4</li>
<li>Subdomain network install</li>... | [
{
"answer_id": 24092,
"author": "ChrisPlaneta",
"author_id": 7212,
"author_profile": "https://wordpress.stackexchange.com/users/7212",
"pm_score": 2,
"selected": false,
"text": "<p>Ok. I've found a solution. Thanks to <a href=\"http://coding.smashingmagazine.com/2011/06/08/how-to-build-a... | 2011/07/21 | [
"https://wordpress.stackexchange.com/questions/23672",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7152/"
] | I have a WP network and have found that users with roles other than "super user" (admins, editors, authors, etc.) are getting a 404 when trying to preview draft posts/pages/custom post types.
Any idea why this would be? I have the following:
* Version 3.1.4
* Subdomain network install
* Domain mapping plugin (if this... | Ok. I've found a solution. Thanks to [this great article on Smashing Magazine](http://coding.smashingmagazine.com/2011/06/08/how-to-build-a-media-site-on-wordpress-part-2/)
The code to retrieve category description from any taxonomy term would be :
```
<?php echo (get_term_by('slug', 'your-term-name', 'your-taxonomy-... |
23,674 | <p>Can I assign a template file to a custom post type?</p>
<p>I have created a custom post type called <code>items</code>, and I would like to assign templates to the items like you can do with pages.</p>
| [
{
"answer_id": 23677,
"author": "mike23",
"author_id": 1381,
"author_profile": "https://wordpress.stackexchange.com/users/1381",
"pm_score": 5,
"selected": false,
"text": "<p>You can create template for custom post types by creating files, like for example :</p>\n\n<pre><code>single-mycu... | 2011/07/21 | [
"https://wordpress.stackexchange.com/questions/23674",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2632/"
] | Can I assign a template file to a custom post type?
I have created a custom post type called `items`, and I would like to assign templates to the items like you can do with pages. | From [WordPress version 4.7](https://wordpress.org/news/2016/12/vaughan/) you can now assign custom page templates to other post types along with page.
To achieve this in addition to the Template Name file header, the post types supported by a template can be specified using Template Post Type: as following.
```
<?ph... |
23,681 | <p><strong>I'm trying to add a new option to a theme options panel</strong> to hide/show the comments links in the theme template files.</p>
<p>I've got the option to show up in the panel, but there's something wrong in that it doesn't work and there are no php errors. I've noted below in <strong>Main options code</st... | [
{
"answer_id": 23870,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": true,
"text": "<p>To answer the first part of your question: your settings form already has the <code>checkbox</code> case cov... | 2011/07/21 | [
"https://wordpress.stackexchange.com/questions/23681",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/268/"
] | **I'm trying to add a new option to a theme options panel** to hide/show the comments links in the theme template files.
I've got the option to show up in the panel, but there's something wrong in that it doesn't work and there are no php errors. I've noted below in **Main options code** where I've added the option as... | To answer the first part of your question: your settings form already has the `checkbox` case covered; so if you add a new checkbox input, **you don't need to add anything to the switch**. This code will apply to *all* checkbox inputs you add:
```
case 'checkbox':
?>
<input type="checkbox" name="vertigo_theme_opti... |
23,690 | <p>I've been looking for a video plugin in the plugin depository but couldn't find one that I'm looking for.</p>
<p>Basically, I want visitors to be able to play the video in the home page but the issue here is that the home page is displaying post excerpts. So if I would just post the video as normal, it would be cut... | [
{
"answer_id": 23870,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": true,
"text": "<p>To answer the first part of your question: your settings form already has the <code>checkbox</code> case cov... | 2011/07/21 | [
"https://wordpress.stackexchange.com/questions/23690",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3305/"
] | I've been looking for a video plugin in the plugin depository but couldn't find one that I'm looking for.
Basically, I want visitors to be able to play the video in the home page but the issue here is that the home page is displaying post excerpts. So if I would just post the video as normal, it would be cut in the ho... | To answer the first part of your question: your settings form already has the `checkbox` case covered; so if you add a new checkbox input, **you don't need to add anything to the switch**. This code will apply to *all* checkbox inputs you add:
```
case 'checkbox':
?>
<input type="checkbox" name="vertigo_theme_opti... |
23,701 | <p>The <a href="http://justintadlock.com/plugindevbook">Professional WordPress Plugin Development</a> book explains in detail how to properly use the Settings API, and it also demonstrates how to add Menus and Submenus, but unfortunately it doesn't provide any joined-up examples of this. Whilst I've managed to get most... | [
{
"answer_id": 23704,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 4,
"selected": true,
"text": "<p>There are several components to error/notice creation and display process:</p>\n\n<ol>\n<li><a href=\"http://codex.wo... | 2011/07/21 | [
"https://wordpress.stackexchange.com/questions/23701",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1341/"
] | The [Professional WordPress Plugin Development](http://justintadlock.com/plugindevbook) book explains in detail how to properly use the Settings API, and it also demonstrates how to add Menus and Submenus, but unfortunately it doesn't provide any joined-up examples of this. Whilst I've managed to get most of it working... | There are several components to error/notice creation and display process:
1. [`add_settings_error()`](http://codex.wordpress.org/Function_Reference/add_settings_error) call to add item to stack (global `$wp_settings_errors` variable).
2. `settings_errors` transient that keeps the errors so they survive move from page... |
23,723 | <p>This lists the posts in my custom taxonomy template page:</p>
<pre><code><?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
</code></pre>
<p>How can I order those posts by comment count?</p>
| [
{
"answer_id": 23725,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 2,
"selected": false,
"text": "<p>WP Query has a comment_count parameter since 2.9.</p>\n\n<p>So:</p>\n\n<pre><code>query_posts(array('orderby' =>... | 2011/07/22 | [
"https://wordpress.stackexchange.com/questions/23723",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2107/"
] | This lists the posts in my custom taxonomy template page:
```
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
```
How can I order those posts by comment count? | A friend helped me with a solution that I could place in my functions.php file:
```
add_filter( 'pre_get_posts', 'my_pre_get_posts' );
function my_pre_get_posts( $query ) {
if ( is_tax( 'locations' ) && empty( $query->query_vars['suppress_filters'] ) )
$query->set( 'orderby', 'comment_count' );
ret... |
23,732 | <p>I am making a portfolio site where each portfolio entry is a subpage of "Work". In my template, I am trying to say something like: worked on 15 projects and counting, where 15 is the total number of subpages.</p>
<p>Whats the easiest way to do this?</p>
| [
{
"answer_id": 23734,
"author": "GavinR",
"author_id": 2001,
"author_profile": "https://wordpress.stackexchange.com/users/2001",
"pm_score": 3,
"selected": true,
"text": "<p>Use the following code, replacing the number after \"child_of=\" to the id of the parent page.</p>\n\n<pre><code>&... | 2011/07/22 | [
"https://wordpress.stackexchange.com/questions/23732",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10118/"
] | I am making a portfolio site where each portfolio entry is a subpage of "Work". In my template, I am trying to say something like: worked on 15 projects and counting, where 15 is the total number of subpages.
Whats the easiest way to do this? | Use the following code, replacing the number after "child\_of=" to the id of the parent page.
```
<?php
$count = 0;
$pages = get_pages('child_of=681&depth=1');
foreach($pages as $page) {
$count++;
}
echo $count;
?>
```
Reference: [get\_pages](http://codex.wordpress.org/Function_Reference/get_pages) |
23,736 | <p>I am a big fan of the JSON API plugin. The developer did a great job and I thank him very much. I am learning how to work with json and jquery and am trying to limit the information I get back from an ajax request. I have been able to use the include and custom field options successfully but amd falling a little sh... | [
{
"answer_id": 36981,
"author": "moimikey",
"author_id": 11018,
"author_profile": "https://wordpress.stackexchange.com/users/11018",
"pm_score": 2,
"selected": false,
"text": "<p>I think it really all depends on what the issue with limiting this information is. Do you not want this parti... | 2011/07/22 | [
"https://wordpress.stackexchange.com/questions/23736",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7235/"
] | I am a big fan of the JSON API plugin. The developer did a great job and I thank him very much. I am learning how to work with json and jquery and am trying to limit the information I get back from an ajax request. I have been able to use the include and custom field options successfully but amd falling a little short ... | I think it really all depends on what the issue with limiting this information is. Do you not want this particular data to be exposed? Do you not want to iterate through so much data? Are you intending on passing this data through a $.getJSON() request? Are you passing this data to a PHP function to handle it?
You can... |
23,741 | <p>How can I change the category slug that appears in the URL of a post that's in multiple categories? I'd like to change the default WordPress behaviour of using the category with the lowest id.</p>
<p>I thought this would do it:</p>
<pre><code>add_filter('post_link', 'mspc_post_link', 1, 2);
function mspc_post_link... | [
{
"answer_id": 40573,
"author": "Matthew Boynes",
"author_id": 12324,
"author_profile": "https://wordpress.stackexchange.com/users/12324",
"pm_score": 2,
"selected": false,
"text": "<p>Even though this question is pretty old, and you've probably long moved on, I figured I'd offer a solut... | 2011/07/22 | [
"https://wordpress.stackexchange.com/questions/23741",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7239/"
] | How can I change the category slug that appears in the URL of a post that's in multiple categories? I'd like to change the default WordPress behaviour of using the category with the lowest id.
I thought this would do it:
```
add_filter('post_link', 'mspc_post_link', 1, 2);
function mspc_post_link($link, $post) {
... | Similar plugin but compatible to latest wp version 3.5.2
<http://wordpress.org/plugins/wp-category-permalink/>
>
> This plugin allows you to select a 'main' category for your posts, for better permalinks and SEO. It uses the same meta data as the "Hikari Category Permalink" and the "sCategory Permalink", but it has ... |
23,763 | <p>I have gallery (I'm using <a href="http://wordpress.org/extend/plugins/cleaner-gallery/" rel="nofollow">Cleaner Gallery</a> plugin) with many images. I want to add asynchronous image loading with jQuery (I'm using <a href="http://www.sebastianoarmelibattana.com/projects/jail" rel="nofollow">JAIL</a> to do that). But... | [
{
"answer_id": 23775,
"author": "maryisdead",
"author_id": 2637,
"author_profile": "https://wordpress.stackexchange.com/users/2637",
"pm_score": 0,
"selected": false,
"text": "<p>Are you caching your site?</p>\n\n<p>If not, the function <code>cleaner_gallery_plugin_gallery_image</code> i... | 2011/07/22 | [
"https://wordpress.stackexchange.com/questions/23763",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15476/"
] | I have gallery (I'm using [Cleaner Gallery](http://wordpress.org/extend/plugins/cleaner-gallery/) plugin) with many images. I want to add asynchronous image loading with jQuery (I'm using [JAIL](http://www.sebastianoarmelibattana.com/projects/jail) to do that). But to use this JAIL plugin I need to change gallery outpu... | In cleaner-gallery.php make changes to the cleaner\_gallery\_plugin\_gallery\_image function that starts on line 122 and ends on line 151.
What we are doing is replacing href with data-href in the two instances that output the html with the image attributes.
```
function cleaner_gallery_plugin_gallery_image( $image,... |
23,774 | <p>In wp-signup.php there are these lines:</p>
<pre><code>add_action( 'wp_head', 'wpmu_signup_stylesheet' );
get_header();
</code></pre>
<p>I need to remove <code>wpmu_signup_stylesheet</code> from the <code>wp_head</code> action, but I seem to be struggling, I assume it is because the action is being called straight... | [
{
"answer_id": 23776,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": -1,
"selected": false,
"text": "<p>Try adding a priority:</p>\n\n<pre><code>remove_action( 'wp_head', 'wpmu_signup_stylesheet', 11 );\n</code... | 2011/07/22 | [
"https://wordpress.stackexchange.com/questions/23774",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3669/"
] | In wp-signup.php there are these lines:
```
add_action( 'wp_head', 'wpmu_signup_stylesheet' );
get_header();
```
I need to remove `wpmu_signup_stylesheet` from the `wp_head` action, but I seem to be struggling, I assume it is because the action is being called straight after.
Here is what I've tried from a plugin:
... | The action is not right after actually. There is `get_header()` call, then `get_header` action and then locating and loading template file that has `wp_head()` in it.
I try not to mess with removing things from inside of same hook you are at, so in this case I'd (ab)use that `get_header` action to hook function that w... |
23,813 | <p>I'd like to add the field "Company Name" to the add new user page in the admin panel. I've done quite a bit of searching and have been unable to find details on how to do this. I can easily add info to the profile page and registration with..</p>
<pre><code> function my_custom_userfields( $contactmethods ) {
... | [
{
"answer_id": 23840,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 1,
"selected": false,
"text": "<p><code>user_contactmethods</code> filter hook does not get called at the <code>user-new.php</code> page so tha... | 2011/07/22 | [
"https://wordpress.stackexchange.com/questions/23813",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3296/"
] | I'd like to add the field "Company Name" to the add new user page in the admin panel. I've done quite a bit of searching and have been unable to find details on how to do this. I can easily add info to the profile page and registration with..
```
function my_custom_userfields( $contactmethods ) {
//Adds custome... | In order to do this you'll have to manually change the user-new.php page. It's not the correct way to handle it but if you're in desperate need this is how it's done.
I added
```
<tr class="form-field">
<th scope="row"><label for="company_name"><?php _e('Company Name') ?> </label></th>
<td><input name="compa... |
23,823 | <p>I have a custom post type for portfolio. To create one, you need to create a page with a particular template that i'm making, named page-portfolio.</p>
<p>Now, a portfolio post has custom fields as well. But, how can i make a custom field that is displayed in the post only if i select the 'portfolio' template ? Tha... | [
{
"answer_id": 23824,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 2,
"selected": true,
"text": "<p>This is confusing you're mixing up the terminology of WordPress. A custom post type acts like a <em>post</em> and no... | 2011/07/23 | [
"https://wordpress.stackexchange.com/questions/23823",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6329/"
] | I have a custom post type for portfolio. To create one, you need to create a page with a particular template that i'm making, named page-portfolio.
Now, a portfolio post has custom fields as well. But, how can i make a custom field that is displayed in the post only if i select the 'portfolio' template ? That is, a cu... | This is confusing you're mixing up the terminology of WordPress. A custom post type acts like a *post* and not a *page*. If you have a custom post type called "portfolio" and use the proper template hierarchy, you don't have to do anything special. But you will need to name it `single-portfolio.php` and not `page-portf... |
23,829 | <p>I am a trying to create a dashboard like custom page template that list post of of the current logged in user. I've tried to find a solution on the net. but none were appropriate</p>
| [
{
"answer_id": 23830,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": true,
"text": "<p>this should work for you:</p>\n\n<pre><code>if ( is_user_logged_in() ):\n\n global $current_user;\n wp_get_cur... | 2011/07/23 | [
"https://wordpress.stackexchange.com/questions/23829",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6150/"
] | I am a trying to create a dashboard like custom page template that list post of of the current logged in user. I've tried to find a solution on the net. but none were appropriate | this should work for you:
```
if ( is_user_logged_in() ):
global $current_user;
wp_get_current_user();
$author_query = array('posts_per_page' => '-1','author' => $current_user->ID);
$author_posts = new WP_Query($author_query);
while($author_posts->have_posts()) : $author_posts->the_post();
?>
... |
23,839 | <p>I've created a custom post type as a plugin and released it into the repository. One of the core features involves using a featured image. I've added <code>thumbnail</code> to <code>$supports</code> in <code>register_post_type()</code>, so the meta box shows up in the Administration Panel. I'm also hooking into <cod... | [
{
"answer_id": 23841,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 4,
"selected": true,
"text": "<p>There are comments in core code that this should be improved, but they are there for a while already. Basically there... | 2011/07/23 | [
"https://wordpress.stackexchange.com/questions/23839",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3898/"
] | I've created a custom post type as a plugin and released it into the repository. One of the core features involves using a featured image. I've added `thumbnail` to `$supports` in `register_post_type()`, so the meta box shows up in the Administration Panel. I'm also hooking into `after_setup_theme` and calling `add_the... | There are comments in core code that this should be improved, but they are there for a while already. Basically there is no native function to add or remove *part* of some feature, only feature altogether.
Doing it manually would be running something like this after theme is done (late on `after_setup_theme` hook):
`... |
23,859 | <p>I'm trying to set up some permalinks for my site. Right now all the posts are under sitename.com/blog/, which is fine. But the category pages and tag pages show as 'sitename.com/blog/category/catname' and 'sitename.com/blog/tag/tagname'.</p>
<p>Is there a way to just skip the 'category' and 'tag' parts of the URL? ... | [
{
"answer_id": 23866,
"author": "Srikanth AD",
"author_id": 7281,
"author_profile": "https://wordpress.stackexchange.com/users/7281",
"pm_score": 0,
"selected": false,
"text": "<p>Advanced permalinks plugin might solve your issue</p>\n\n<hr>\n\n<p><a href=\"http://urbangiraffe.com/plugin... | 2011/07/23 | [
"https://wordpress.stackexchange.com/questions/23859",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7277/"
] | I'm trying to set up some permalinks for my site. Right now all the posts are under sitename.com/blog/, which is fine. But the category pages and tag pages show as 'sitename.com/blog/category/catname' and 'sitename.com/blog/tag/tagname'.
Is there a way to just skip the 'category' and 'tag' parts of the URL? As in:
'si... | I was messing with my permalinks today for the same reason. And i ended up with a solution that worked great.
You have to change your custom permalink structure to:
```
/%category%/%postname%/
```
In the category base field just put a period mark:
```
.
```
and your permalinks will display in this form:
```
CA... |
23,864 | <p>I'm using the Wordpress SEO by Yoast plugin. I'm having problems getting the Sitemaps XML section to work properly. Google gives me the dreaded red X for the status of the sitemap. </p>
<p>The error message Google gives is: 208 "Invalid URL
This is not a valid URL. Please correct it and resubmit."</p>
<p>The incor... | [
{
"answer_id": 23866,
"author": "Srikanth AD",
"author_id": 7281,
"author_profile": "https://wordpress.stackexchange.com/users/7281",
"pm_score": 0,
"selected": false,
"text": "<p>Advanced permalinks plugin might solve your issue</p>\n\n<hr>\n\n<p><a href=\"http://urbangiraffe.com/plugin... | 2011/07/23 | [
"https://wordpress.stackexchange.com/questions/23864",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4509/"
] | I'm using the Wordpress SEO by Yoast plugin. I'm having problems getting the Sitemaps XML section to work properly. Google gives me the dreaded red X for the status of the sitemap.
The error message Google gives is: 208 "Invalid URL
This is not a valid URL. Please correct it and resubmit."
The incorrect Google XML l... | I was messing with my permalinks today for the same reason. And i ended up with a solution that worked great.
You have to change your custom permalink structure to:
```
/%category%/%postname%/
```
In the category base field just put a period mark:
```
.
```
and your permalinks will display in this form:
```
CA... |
23,867 | <p>Is it possible to hook in and override the default notification message for WP MS? I know the message being sent out is in /wp-admin/user-new.php</p>
<pre><code>if ( is_multisite() ) {
function admin_created_user_email( $text ) {
/* translators: 1: Site name, 2: site URL, 3: role */
return sprin... | [
{
"answer_id": 23875,
"author": "rocketman27",
"author_id": 2647,
"author_profile": "https://wordpress.stackexchange.com/users/2647",
"pm_score": 1,
"selected": false,
"text": "<p>Would this kind of thing work?</p>\n\n<pre><code>if ( !function_exists('wp_new_user_notification') ) {\nfunc... | 2011/07/23 | [
"https://wordpress.stackexchange.com/questions/23867",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7282/"
] | Is it possible to hook in and override the default notification message for WP MS? I know the message being sent out is in /wp-admin/user-new.php
```
if ( is_multisite() ) {
function admin_created_user_email( $text ) {
/* translators: 1: Site name, 2: site URL, 3: role */
return sprintf( __( 'Hi,
Y... | @user2647 seems to be on the right path, but I think that this is more correct:
```
remove_action( 'wpmu_new_user', 'newuser_notify_siteadmin' );
add_action( 'wpmu_new_user', 'my_notification' );
function my_notification ($user_id) {
// Make your custom notification here.
}
``` |
23,869 | <p>I'm trying to pass a post's content (which may contain HTML) to JavaScript via wp_localize_script(). wp_localize_script() can't handle multi-dimensional arrays, so I'm <a href="http://www.ronakg.com/2011/05/passing-php-array-to-javascript-using-wp_localize_script/" rel="nofollow">encoding it in JSON and then decodin... | [
{
"answer_id": 23873,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 0,
"selected": false,
"text": "<p><code>placemarks[] = array(</code> this means that <code>placemarks</code> is array of arrays, is that right?... | 2011/07/23 | [
"https://wordpress.stackexchange.com/questions/23869",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3898/"
] | I'm trying to pass a post's content (which may contain HTML) to JavaScript via wp\_localize\_script(). wp\_localize\_script() can't handle multi-dimensional arrays, so I'm [encoding it in JSON and then decoding it with jQuery](http://www.ronakg.com/2011/05/passing-php-array-to-javascript-using-wp_localize_script/).
Th... | While it's not exact answer to your precise question, I agree with method suggest in comment. Just skip trying to stuff data into single dimension and make use of `l10n_print_after` argument instead.
See [pass object/JSON to wp\_localize\_script](https://wordpress.stackexchange.com/questions/8655/pass-object-json-to-w... |
23,916 | <p>I'm creating an age select menu in the admin, populated from a taxonomy of <code>age</code>. The taxonomy is hierarchical as follows:</p>
<ul>
<li>18-25 (parent, ID 183)
<ul>
<li>18 (child)</li>
<li>19</li>
<li>20</li>
<li>21</li>
<li>22</li>
<li>23</li>
<li>24</li>
<li>25</li>
</ul></li>
<li>26-30 (parent, ID 184)... | [
{
"answer_id": 23957,
"author": "Manny Fleurmond",
"author_id": 2234,
"author_profile": "https://wordpress.stackexchange.com/users/2234",
"pm_score": 5,
"selected": true,
"text": "<p>This should work for you:</p>\n\n<pre><code>$taxonomyName = \"age\";\n//This gets top layer terms only. ... | 2011/07/24 | [
"https://wordpress.stackexchange.com/questions/23916",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4999/"
] | I'm creating an age select menu in the admin, populated from a taxonomy of `age`. The taxonomy is hierarchical as follows:
* 18-25 (parent, ID 183)
+ 18 (child)
+ 19
+ 20
+ 21
+ 22
+ 23
+ 24
+ 25
* 26-30 (parent, ID 184)
+ 26
+ 27
+ 28
+ 29
+ 30
I would like to only list the children (18, 19 etc) and not... | This should work for you:
```
$taxonomyName = "age";
//This gets top layer terms only. This is done by setting parent to 0.
$parent_terms = get_terms( $taxonomyName, array( 'parent' => 0, 'orderby' => 'slug', 'hide_empty' => false ) );
echo '<ul>';
foreach ( $parent_terms as $pterm ) {
//Get the Child terms
... |