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 |
|---|---|---|---|---|---|---|
15,869 | <p>What is the definite hook which identifies links.php page (add, edit, delete, etc. Blogroll Links), and only this page?</p>
<p>Any help would be appreciated.</p>
<p>Thanks,
cadeyrn</p>
<p>EDIT</p>
<p>Sorry, I forgot to mention, I need this hook in the admin area. I have a plugin, that brakes an other one, becau... | [
{
"answer_id": 15875,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>Inside the (public) wp template hierarchy there's no <code>links.php</code> file expected. Links are a built in tax... | 2011/04/28 | [
"https://wordpress.stackexchange.com/questions/15869",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4209/"
] | What is the definite hook which identifies links.php page (add, edit, delete, etc. Blogroll Links), and only this page?
Any help would be appreciated.
Thanks,
cadeyrn
EDIT
Sorry, I forgot to mention, I need this hook in the admin area. I have a plugin, that brakes an other one, because both are triggered by the adm... | OK, I made an awful, but working solution: the hook is `admin_menu`, than, in the called function, I added
```
if( strstr($_SERVER['PHP_SELF'],'link.php')
```
in the begining.
If there's a better solution, please someone send it. |
15,882 | <p>I'm using <code>wp_insert_post</code> to programmatically add content to a site. This works fine with posts, categories and tags, but not with pages.</p>
<p>When I attempt to add a page (i.e. post with post_type=page), the rewrite rules do not get properly regenerated (or something happens to them after <code>wp_i... | [
{
"answer_id": 39733,
"author": "Matthew Boynes",
"author_id": 12324,
"author_profile": "https://wordpress.stackexchange.com/users/12324",
"pm_score": 1,
"selected": false,
"text": "<p>Hard to say what your issue is without seeing more code, but I would bet that your issue will be resolv... | 2011/04/28 | [
"https://wordpress.stackexchange.com/questions/15882",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4330/"
] | I'm using `wp_insert_post` to programmatically add content to a site. This works fine with posts, categories and tags, but not with pages.
When I attempt to add a page (i.e. post with post\_type=page), the rewrite rules do not get properly regenerated (or something happens to them after `wp_insert_post`). Specifically... | Hard to say what your issue is without seeing more code, but I would bet that your issue will be resolved if you add this after inserting your post:
```
do_action('save_post', $post_ID, $post);
```
WordPress uses this action to flush cache, rewrite rules, etc. Make sure to use the appropriate variables for $post\_ID... |
15,914 | <p>I would like to introduce page-hierarchy navigation in my WordPress blog using subpages. So each page may have sub-pages, but I'd like that when a visitor clicks on a page header he will be redirected to a specific subpage. For example, say my hierarchy is:</p>
<pre><code>1. Movies
1.1 General
1.2 Westerns
1.3 Anim... | [
{
"answer_id": 15917,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 4,
"selected": true,
"text": "<p>Using WordPress custom nav menus create a menu and add the \"General\" page 2 times. The first as the parent and t... | 2011/04/29 | [
"https://wordpress.stackexchange.com/questions/15914",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4927/"
] | I would like to introduce page-hierarchy navigation in my WordPress blog using subpages. So each page may have sub-pages, but I'd like that when a visitor clicks on a page header he will be redirected to a specific subpage. For example, say my hierarchy is:
```
1. Movies
1.1 General
1.2 Westerns
1.3 Animated
2. Music
... | Using WordPress custom nav menus create a menu and add the "General" page 2 times. The first as the parent and the second as the first child then add the rest of the pages as childs under the first General.
Change the title in the first general to movies then on the front end when a user clicks movies they will got to... |
15,922 | <p>Hopefully it will be an easy question.</p>
<p>I created Wordpress template and now i would like to use that template for for several pages, however i would like to have different background color on some of the elements such as footer, header etc. that will be depending on parent. So lets say i have PARENT A (green... | [
{
"answer_id": 15923,
"author": "kovshenin",
"author_id": 1316,
"author_profile": "https://wordpress.stackexchange.com/users/1316",
"pm_score": 0,
"selected": false,
"text": "<p>You might want to look at <code>$post->post_parent</code> having the global <code>$post</code> inside your ... | 2011/04/29 | [
"https://wordpress.stackexchange.com/questions/15922",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4986/"
] | Hopefully it will be an easy question.
I created Wordpress template and now i would like to use that template for for several pages, however i would like to have different background color on some of the elements such as footer, header etc. that will be depending on parent. So lets say i have PARENT A (green backgroun... | Using `body_class()`, by default, WordPress adds classes like `parent-pageid-43` to it. This only goes one level deep, though.
The code below works for any ancestors of your parent pages, not just children. It relies on the [is\_page\_or\_ancestor plugin](http://wordpress.org/extend/plugins/is-page-or-ancestor/) for t... |
15,925 | <p>I'm trying to add a stylesheet to the options page for my plugin - code looks like this:</p>
<pre><code>add_action( 'admin_print_styles-rps-paypal', 'rps_paypal_add_css' );
function rps_paypal_add_css() {
wp_enqueue_style( 'rps_paypal', plugins_url( '/rps_paypal/css/rps-paypal.css' ) );
}
add_action( 'admin_menu... | [
{
"answer_id": 15923,
"author": "kovshenin",
"author_id": 1316,
"author_profile": "https://wordpress.stackexchange.com/users/1316",
"pm_score": 0,
"selected": false,
"text": "<p>You might want to look at <code>$post->post_parent</code> having the global <code>$post</code> inside your ... | 2011/04/29 | [
"https://wordpress.stackexchange.com/questions/15925",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3430/"
] | I'm trying to add a stylesheet to the options page for my plugin - code looks like this:
```
add_action( 'admin_print_styles-rps-paypal', 'rps_paypal_add_css' );
function rps_paypal_add_css() {
wp_enqueue_style( 'rps_paypal', plugins_url( '/rps_paypal/css/rps-paypal.css' ) );
}
add_action( 'admin_menu', 'rps_myplugi... | Using `body_class()`, by default, WordPress adds classes like `parent-pageid-43` to it. This only goes one level deep, though.
The code below works for any ancestors of your parent pages, not just children. It relies on the [is\_page\_or\_ancestor plugin](http://wordpress.org/extend/plugins/is-page-or-ancestor/) for t... |
15,971 | <p>hey guys,
it's weird and I've never experienced that before. I've created a new blog and a custom theme. I'm using <code><?php echo date("H:i"); ?></code>in my theme. </p>
<p>The time that's put is 2h earlier. e.g. if it's actually 16:00 o'clock the date generated with date() is 14:00.</p>
<p>I don't know wh... | [
{
"answer_id": 15972,
"author": "Grimosos",
"author_id": 4854,
"author_profile": "https://wordpress.stackexchange.com/users/4854",
"pm_score": 0,
"selected": false,
"text": "<p>I think that the problem is that the server date is different between your.\nYour server has a different <code>... | 2011/04/29 | [
"https://wordpress.stackexchange.com/questions/15971",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3529/"
] | hey guys,
it's weird and I've never experienced that before. I've created a new blog and a custom theme. I'm using `<?php echo date("H:i"); ?>`in my theme.
The time that's put is 2h earlier. e.g. if it's actually 16:00 o'clock the date generated with date() is 14:00.
I don't know why that happens? I'm using the germ... | This could probably make exquisite debugging session, but taking in account it's Friday evening - just use [`date_i18n()`](http://codex.wordpress.org/Function_Reference/date_i18n) instead and let WordPress deal with a huge mess that time/date issues usually are. |
15,977 | <p>I have a website with 5 main pages (consider them as sections), then 3-5 sub pages for each of them. I would like to display a flash banner for each section, i.e. it should display the flash banner on that page and all its sub pages.</p>
<p>Right now i am able to get that o the main page by using the following code... | [
{
"answer_id": 15980,
"author": "xLRDxREVENGEx",
"author_id": 4998,
"author_profile": "https://wordpress.stackexchange.com/users/4998",
"pm_score": 0,
"selected": false,
"text": "<p>You should create a template for each page that way you can add the banner directly to it without having t... | 2011/04/29 | [
"https://wordpress.stackexchange.com/questions/15977",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1555/"
] | I have a website with 5 main pages (consider them as sections), then 3-5 sub pages for each of them. I would like to display a flash banner for each section, i.e. it should display the flash banner on that page and all its sub pages.
Right now i am able to get that o the main page by using the following code.
```
<?p... | You can do that by using this nice little function:
```
function is_page_or_child_of($slug){
global $post;
if (empty($slug))
return false;
//is it the page?
if ($post->post_name = $slug)
return true;
//check the children
$page = get_page_by_path($slug);
$children = get_page... |
15,993 | <p>I want to created automatically rounded corner thumbnails for a particular project I'm working on, using something like this: <a href="http://webdeveloperplus.com/php/create-thumbnail-images-with-rounded-corners/">http://webdeveloperplus.com/php/create-thumbnail-images-with-rounded-corners/</a></p>
<p>What I'd idea... | [
{
"answer_id": 15995,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 1,
"selected": false,
"text": "<p>What thumbnails are you wanting to style, the \"thumbnail\" image size in general, or Post Thumbnails?</p>\... | 2011/04/29 | [
"https://wordpress.stackexchange.com/questions/15993",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10/"
] | I want to created automatically rounded corner thumbnails for a particular project I'm working on, using something like this: <http://webdeveloperplus.com/php/create-thumbnail-images-with-rounded-corners/>
What I'd ideally like to do is find a way to hook something like this into the thumbnail creation process itself ... | Looks like you can hook into the [`wp_create_thumbnail` filter](http://adambrown.info/p/wp_hooks/hook/wp_create_thumbnail?version=3.1&file=wp-admin/includes/image.php):
```
function wp_create_thumbnail( $file, $max_side, $deprecated = '' ) {
if ( !empty( $deprecated ) )
_deprecated_argument( __FUNCTION__, '1.2' )... |
16,004 | <p>I have a function that redirects users to the login page (home) if they're trying to access any other page without being logged in, here's how it works:</p>
<pre><code>function restrict_access_if_logged_out(){
if (!is_user_logged_in() && !is_home()){
wp_redirect( get_option('home') );
}
}
ad... | [
{
"answer_id": 16005,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": false,
"text": "<p>Try passing <code>the_permalink()</code> as the <code>$redirect</code> argument:</p>\n\n<pre><code>function... | 2011/04/30 | [
"https://wordpress.stackexchange.com/questions/16004",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3893/"
] | I have a function that redirects users to the login page (home) if they're trying to access any other page without being logged in, here's how it works:
```
function restrict_access_if_logged_out(){
if (!is_user_logged_in() && !is_home()){
wp_redirect( get_option('home') );
}
}
add_action( 'wp', 'restr... | Thanks all, I kind of used a bit of what everyone recommended so in the end my code looks like this:
```
function restrict_access_if_logged_out(){
if (!is_user_logged_in() && !is_home()){
wp_redirect( get_option('home') . '?redirect_to=' . esc_url($_SERVER["HTTP_HOST"] . $_SERVER["REQUEST_URI"]) );
}
}... |
16,006 | <p>I am new to wordpress and apache. Following the introduction i found from google, i installed the apache(2.2.17)+mysql(5.5.11)+php(5.2.17)+wordpress(3.1.1) successfully on my PC. But when I login with the right user name and password, it just go into the wp-admin directory but not the homepage.</p>
<p>I guess I mis... | [
{
"answer_id": 16008,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>Your home page is available on the link in the upper left corner right besides the WordPress logo.</p>\n\n<h3>Update</... | 2011/04/30 | [
"https://wordpress.stackexchange.com/questions/16006",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5000/"
] | I am new to wordpress and apache. Following the introduction i found from google, i installed the apache(2.2.17)+mysql(5.5.11)+php(5.2.17)+wordpress(3.1.1) successfully on my PC. But when I login with the right user name and password, it just go into the wp-admin directory but not the homepage.
I guess I missed some c... | Your home page is available on the link in the upper left corner right besides the WordPress logo.
### Update
In your [.htaccess](https://wordpress.stackexchange.com/questions/tagged/htaccess) or **httpd-vhosts.conf** you have to declare the index.php as index file, and FollowSymLinks has to be On:
```
# sample .hta... |
16,010 | <p>I created a WordPress template and now I would like to use that template for several pages, however I would like to have different background color on some of the elements such as footer, header etc... which will depend on the parent.</p>
<p>So lets say I have PARENT A (green background) and PARENT B (white backgro... | [
{
"answer_id": 16011,
"author": "TomHarrigan",
"author_id": 4968,
"author_profile": "https://wordpress.stackexchange.com/users/4968",
"pm_score": 0,
"selected": false,
"text": "<p>You can do something along the lines of the code below, having a different div depending on the page id. Put... | 2011/04/29 | [
"https://wordpress.stackexchange.com/questions/16010",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I created a WordPress template and now I would like to use that template for several pages, however I would like to have different background color on some of the elements such as footer, header etc... which will depend on the parent.
So lets say I have PARENT A (green background) and PARENT B (white background) now w... | If your theme is using the `body_class();` function then you can target pages via CSS.
If you have parent page with the ID of 2 and the background you wanted to change was the .content div, you would simply use :
`.parent-pageid-2 .content {
background: green;
}`
Or something similar to that effect. This would work... |
16,019 | <p>I'd like to customize the feed URL of a certain Wordpress-based blog that I don't own in order to show all posts ever published. This is because I like that blog and I want to read everything the author has written, without missing a single post. Is this possible? Or should I surf this blog manually? Thank you.</p>
| [
{
"answer_id": 16020,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 1,
"selected": false,
"text": "<p>No not possible. WordPress gives the owner of the site control over how many posts to show in the feed. The defau... | 2011/04/30 | [
"https://wordpress.stackexchange.com/questions/16019",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5004/"
] | I'd like to customize the feed URL of a certain Wordpress-based blog that I don't own in order to show all posts ever published. This is because I like that blog and I want to read everything the author has written, without missing a single post. Is this possible? Or should I surf this blog manually? Thank you. | By default it gives 10 posts per feed, you can add `paged` parameter to get old posts
```
website.com/feed -> get last 10 posts
website.com/feed/?paged=2 -> get next 10 posts
```
and so on... |
16,024 | <p>In this website:</p>
<p><a href="http://alexchen.info/brianfunshine/" rel="nofollow">http://alexchen.info/brianfunshine/</a></p>
<p>I have a navigation menu taken from the twentyten theme. I want to make some links clickeable and some not (some don't have to behave like a link). I have accomplished this with some ... | [
{
"answer_id": 16026,
"author": "anu",
"author_id": 490,
"author_profile": "https://wordpress.stackexchange.com/users/490",
"pm_score": 0,
"selected": false,
"text": "<p>If you don't want a link to behave like a link, then don't make it a link - ie remove the <code><a> </a></... | 2011/04/30 | [
"https://wordpress.stackexchange.com/questions/16024",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/781/"
] | In this website:
<http://alexchen.info/brianfunshine/>
I have a navigation menu taken from the twentyten theme. I want to make some links clickeable and some not (some don't have to behave like a link). I have accomplished this with some CSS but it doesn't work in all browsers.
The links are dinamically generated wi... | Create a custom menu item in the admin panel with a dummy URL, foo.com or whatever. Add it to the menu, then delete the target URL and save. The menu item will be rendered without an href attribute and will be unclickable. |
16,033 | <p>When adding an image to a page or post, Wordpress is automatically adding a paragraph tag <code><p></code> as parent holding the image. Like so:</p>
<pre><code><p><img src="my-image.jpg" alt=""></p>
</code></pre>
<p>Since there is no parent selector in CSS I'd love to find a solution to app... | [
{
"answer_id": 16036,
"author": "Geert",
"author_id": 4936,
"author_profile": "https://wordpress.stackexchange.com/users/4936",
"pm_score": 4,
"selected": true,
"text": "<p>You could use jQuery if you don't mind to rely on JavaScript for adding the class.</p>\n\n<pre><code>$(document).re... | 2011/04/30 | [
"https://wordpress.stackexchange.com/questions/16033",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3529/"
] | When adding an image to a page or post, Wordpress is automatically adding a paragraph tag `<p>` as parent holding the image. Like so:
```
<p><img src="my-image.jpg" alt=""></p>
```
Since there is no parent selector in CSS I'd love to find a solution to apply a specific classname to those paragraphs holding an actual... | You could use jQuery if you don't mind to rely on JavaScript for adding the class.
```
$(document).ready(function() {
$('p:has(img)').addClass('image');
});
```
Update: the `.has()` method is probably faster, see this [jsperf.com test](http://jsperf.com/jquery-pseudo-selector-has-versus-method-has).
```
$(docum... |
16,038 | <p>Does anyone know how to publish your own bookmarklet in a blog like wordpress.com or blogger.com? All of them seem to format the bookmarklet removing the javascript or messing it up.</p>
<p>E.g., pasting this in wordpress blog:</p>
<pre>
<a href="javascript:(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g>f.fn.jq... | [
{
"answer_id": 16117,
"author": "Norcross",
"author_id": 403,
"author_profile": "https://wordpress.stackexchange.com/users/403",
"pm_score": 0,
"selected": false,
"text": "<p>Most visual editors will attempt to format your code. If wrapping it in the <code><code> </code></cod... | 2011/04/30 | [
"https://wordpress.stackexchange.com/questions/16038",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5007/"
] | Does anyone know how to publish your own bookmarklet in a blog like wordpress.com or blogger.com? All of them seem to format the bookmarklet removing the javascript or messing it up.
E.g., pasting this in wordpress blog:
```
<a href="javascript:(function(e,a,g,h,f,c,b,d){if(!(f=e.jQuery)||g>f.fn.jquery||h(f)){c=a.cr... | Create a clickable link on <http://jsfiddle.net/> and link to it. |
16,070 | <p>How can I get the search terms highlighted without plugin? </p>
| [
{
"answer_id": 16071,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 4,
"selected": false,
"text": "<p>Add these 2 functions to your functions.php</p>\n\n<pre><code>function search_excerpt_highlight() {\n $excerpt ... | 2011/05/01 | [
"https://wordpress.stackexchange.com/questions/16070",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5020/"
] | How can I get the search terms highlighted without plugin? | Add these 2 functions to your functions.php
```
function search_excerpt_highlight() {
$excerpt = get_the_excerpt();
$keys = implode('|', explode(' ', get_search_query()));
$excerpt = preg_replace('/(' . $keys .')/iu', '<strong class="search-highlight">\0</strong>', $excerpt);
echo '<p>' . $excerpt . '... |
16,077 | <p>I've read several examples of how to do this but I still can't get it to work - each time I use get_posts() it seems to only keep and display the first set of results. </p>
<p>loop.php</p>
<pre><code>function home_index() {
global $post;
echo '<ul>';
$args = array(
'numberposts' => 3,
'offs... | [
{
"answer_id": 16115,
"author": "Norcross",
"author_id": 403,
"author_profile": "https://wordpress.stackexchange.com/users/403",
"pm_score": 0,
"selected": false,
"text": "<p>You shouldn't have to do all that. The below function will allow you to control what shows up in the default loop... | 2011/05/01 | [
"https://wordpress.stackexchange.com/questions/16077",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3545/"
] | I've read several examples of how to do this but I still can't get it to work - each time I use get\_posts() it seems to only keep and display the first set of results.
loop.php
```
function home_index() {
global $post;
echo '<ul>';
$args = array(
'numberposts' => 3,
'offset' => 0,
'order... | So I finally figured out 2 ways of doing it. The first way is...
```
global $wp_query;
$args = array(
array(
'numberposts' => 3,
'offset' => 0,
'orderby' => 'post_date',
'order' => 'DESC',
'post_type' => 'gp_news',
'post_status' ... |
16,079 | <p>this is my code. It gets the variables from the url. It is very slow and sometimes don't even complete. How can I improve it?</p>
<p>Note: Most of the times some of the variables will not have any value. I thought that if I check this and remove it's array from the query it will improve it somehow.</p>
<pre><code>... | [
{
"answer_id": 16100,
"author": "tollmanz",
"author_id": 4850,
"author_profile": "https://wordpress.stackexchange.com/users/4850",
"pm_score": 0,
"selected": false,
"text": "<p>Not sure if this is just a typo, but your key variables are missing the <code>$</code>. This should trigger a f... | 2011/05/01 | [
"https://wordpress.stackexchange.com/questions/16079",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5015/"
] | this is my code. It gets the variables from the url. It is very slow and sometimes don't even complete. How can I improve it?
Note: Most of the times some of the variables will not have any value. I thought that if I check this and remove it's array from the query it will improve it somehow.
```
$value1 = $_GET['extr... | I have a hunch that meta query of this complexity is going to be crazy. I am not sure what you are trying to do without context described, but most likely there are easier way to organize that. |
16,086 | <p>This is probably a stupid question, but I am setting up a finnish Wordpress installation. The "custom fields" section in the "write post" section is gone; I gather it is hidden by default. </p>
<p>That is a great step, but my finnish is a bit rusty, it's my first WP install, and I can't for the life of me find the ... | [
{
"answer_id": 16087,
"author": "MartinJJ",
"author_id": 3710,
"author_profile": "https://wordpress.stackexchange.com/users/3710",
"pm_score": 3,
"selected": false,
"text": "<p>Go to edit/create a page or post in wp-admin at the top is a \"Screen Options\" panel link, here you can enable... | 2011/05/01 | [
"https://wordpress.stackexchange.com/questions/16086",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2161/"
] | This is probably a stupid question, but I am setting up a finnish Wordpress installation. The "custom fields" section in the "write post" section is gone; I gather it is hidden by default.
That is a great step, but my finnish is a bit rusty, it's my first WP install, and I can't for the life of me find the switch to ... | Per default some meta boxes are hidden. These boxes are stored in an array which you can find in `wp-admin/includes/template.php#get_hidden_meta_boxes()`. There is a filter, and therefore a chance for a plugin:
```
<?php # -*- coding: utf-8 -*-
/*
Plugin Name: Enable Custom Fields per Default
Version: 1.0
Required... |
16,097 | <p>I am creating a WP plugin based around Custom Post Types (CPT), where you can dynamically specify a CPT, complete with any number of associated dynamic Meta Boxes and form elements such as radio buttons, textfields etc.., using the excellent <a href="http://www.deluxeblogtips.com/2011/03/meta-box-script-update-v30.h... | [
{
"answer_id": 16098,
"author": "Manny Fleurmond",
"author_id": 2234,
"author_profile": "https://wordpress.stackexchange.com/users/2234",
"pm_score": 0,
"selected": false,
"text": "<p>Not sure if it will be available during that hook, but I normally make the $post object global and get t... | 2011/05/01 | [
"https://wordpress.stackexchange.com/questions/16097",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5024/"
] | I am creating a WP plugin based around Custom Post Types (CPT), where you can dynamically specify a CPT, complete with any number of associated dynamic Meta Boxes and form elements such as radio buttons, textfields etc.., using the excellent [Meta Box Script V3.1 from RilWis](http://www.deluxeblogtips.com/2011/03/meta-... | If you're talking about on post pages in admin, couldn't you just grab id from url?
```
$post_id = $_REQUEST['post'];
``` |
16,107 | <p>I would like to expand only the active part of the sidebar menu and hide the parts which have nothing to do with the actual selection. Just like how its done on every Explorer like file manager, or how it is with accordion menus.</p>
<p>In the default TwentyTen theme, this is the class definition for the active sub... | [
{
"answer_id": 16109,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": true,
"text": "<p>I use just such a menu in my Oenology Theme. Feel free to use the sidebar menu CSS to suit your needs! Rathe... | 2011/05/01 | [
"https://wordpress.stackexchange.com/questions/16107",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5025/"
] | I would like to expand only the active part of the sidebar menu and hide the parts which have nothing to do with the actual selection. Just like how its done on every Explorer like file manager, or how it is with accordion menus.
In the default TwentyTen theme, this is the class definition for the active submenu:
```... | I use just such a menu in my Oenology Theme. Feel free to use the sidebar menu CSS to suit your needs! Rather than try to post it all here, I'll just link to the [Oenology GitHub repository](http://www.github.com/chipbennett/oenology).
EDIT:
[Here's where the sidebar navigation menu style definitions start](https://g... |
16,108 | <p>I am working on a creating a directory style page template that uses custom meta fields in Wordpress that are used to generate up to 10 directory listings on a page. </p>
<p>The below code works very well for this purpose with one exception. If one of my directory pages only has 5 listings, the code is still displa... | [
{
"answer_id": 16111,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": false,
"text": "<p>The easiest way would be to add a simple conditional:</p>\n\n<pre><code>$values = get_post_custom_values(\"... | 2011/05/01 | [
"https://wordpress.stackexchange.com/questions/16108",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5026/"
] | I am working on a creating a directory style page template that uses custom meta fields in Wordpress that are used to generate up to 10 directory listings on a page.
The below code works very well for this purpose with one exception. If one of my directory pages only has 5 listings, the code is still displayed for li... | The easiest way would be to add a simple conditional:
```
$values = get_post_custom_values("listing_heading_10");
if ( $values ) { ?>
<h3 class="listing-title"><?php echo $values[0]; ?></h3>
<?php }
```
That said, is there any reason that you can't put your output code in a `foreach` loop?
e.g.
```
$values ... |
16,136 | <p>I want to add post formats for each post type. For example, I have a post type 'Gallery'. I want to add 'images', 'galleries' and 'videos' in this post. In normal posts I want to use another list of post formats.</p>
<p>I try:</p>
<pre><code>function postf()
{
global $post_ID;
$postType = get_post_type( $... | [
{
"answer_id": 16146,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 0,
"selected": false,
"text": "<p>Post Formats are a custom taxonomy, registered for the \"Post\" post-type. If you want to use the \"Post Fo... | 2011/05/01 | [
"https://wordpress.stackexchange.com/questions/16136",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5041/"
] | I want to add post formats for each post type. For example, I have a post type 'Gallery'. I want to add 'images', 'galleries' and 'videos' in this post. In normal posts I want to use another list of post formats.
I try:
```
function postf()
{
global $post_ID;
$postType = get_post_type( $post_ID );
if( $... | Try adding the post format support on the arguments when you register your post type instead of using `add_post_type_support`, like this for example:
```
$args = array(
...
'supports' => array('title', 'editor', 'author', 'post-formats')
);
register_post_type('gallery-custompost', $args);
```
See if have an... |
16,138 | <p>My blog is WP3.1.2, theme: Twenty Ten</p>
<p>I would like to add a strip of visual editor on top of the comments box (something like you see at the top of question box on this site). How can I do it WITHOUT PLUGINS? </p>
<p>I have searched this site and the WP forums, but could not find something I could use.</p>
... | [
{
"answer_id": 16146,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 0,
"selected": false,
"text": "<p>Post Formats are a custom taxonomy, registered for the \"Post\" post-type. If you want to use the \"Post Fo... | 2011/05/01 | [
"https://wordpress.stackexchange.com/questions/16138",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5021/"
] | My blog is WP3.1.2, theme: Twenty Ten
I would like to add a strip of visual editor on top of the comments box (something like you see at the top of question box on this site). How can I do it WITHOUT PLUGINS?
I have searched this site and the WP forums, but could not find something I could use.
Although WP displays... | Try adding the post format support on the arguments when you register your post type instead of using `add_post_type_support`, like this for example:
```
$args = array(
...
'supports' => array('title', 'editor', 'author', 'post-formats')
);
register_post_type('gallery-custompost', $args);
```
See if have an... |
16,141 | <p>I'm still very novice at PHP so any help is greatly appreciated. Typically I have found the codex to be very helpful but it appears custom walkers may be outside its scope.</p>
<p>I'd like to have thumbnails show in a custom nav menu which I have in a theme. From what I understand I need to create a custom walker t... | [
{
"answer_id": 16146,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 0,
"selected": false,
"text": "<p>Post Formats are a custom taxonomy, registered for the \"Post\" post-type. If you want to use the \"Post Fo... | 2011/05/01 | [
"https://wordpress.stackexchange.com/questions/16141",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5042/"
] | I'm still very novice at PHP so any help is greatly appreciated. Typically I have found the codex to be very helpful but it appears custom walkers may be outside its scope.
I'd like to have thumbnails show in a custom nav menu which I have in a theme. From what I understand I need to create a custom walker to accompli... | Try adding the post format support on the arguments when you register your post type instead of using `add_post_type_support`, like this for example:
```
$args = array(
...
'supports' => array('title', 'editor', 'author', 'post-formats')
);
register_post_type('gallery-custompost', $args);
```
See if have an... |
16,143 | <p>I'm setting up a widget that allows to add an image to a sidebar / widget area.</p>
<p>Basically I have a dropdown that allows the user to select one of the available sizes inside the theme's <code>functions.php</code> file using <code>add_image_size()</code>.</p>
<p>Apart from the obvious ( renaming all the <code... | [
{
"answer_id": 16149,
"author": "Marcin",
"author_id": 3768,
"author_profile": "https://wordpress.stackexchange.com/users/3768",
"pm_score": 3,
"selected": true,
"text": "<pre><code><?php\nglobal $_wp_additional_image_sizes;\nprint '<pre>';\nprint_r( $_wp_additional_image_sizes ... | 2011/05/02 | [
"https://wordpress.stackexchange.com/questions/16143",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3732/"
] | I'm setting up a widget that allows to add an image to a sidebar / widget area.
Basically I have a dropdown that allows the user to select one of the available sizes inside the theme's `functions.php` file using `add_image_size()`.
Apart from the obvious ( renaming all the `add_image_size()` ) is there a way to get t... | ```
<?php
global $_wp_additional_image_sizes;
print '<pre>';
print_r( $_wp_additional_image_sizes );
print '</pre>';
``` |
16,148 | <p>I am using wordpress 3.1. and I have to reorganize categorize my posts. For this purpose, I am willing to remove some categories. Therefore, after login to admin section of my blog, I go to post > posts > I select the articles I want to edit > I select edit option from "Bulk Action" select box > I select new categor... | [
{
"answer_id": 16149,
"author": "Marcin",
"author_id": 3768,
"author_profile": "https://wordpress.stackexchange.com/users/3768",
"pm_score": 3,
"selected": true,
"text": "<pre><code><?php\nglobal $_wp_additional_image_sizes;\nprint '<pre>';\nprint_r( $_wp_additional_image_sizes ... | 2011/05/02 | [
"https://wordpress.stackexchange.com/questions/16148",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/958/"
] | I am using wordpress 3.1. and I have to reorganize categorize my posts. For this purpose, I am willing to remove some categories. Therefore, after login to admin section of my blog, I go to post > posts > I select the articles I want to edit > I select edit option from "Bulk Action" select box > I select new categories... | ```
<?php
global $_wp_additional_image_sizes;
print '<pre>';
print_r( $_wp_additional_image_sizes );
print '</pre>';
``` |
16,161 | <p>I am developing a plugin.</p>
<p>I want to know difference between</p>
<pre><code>get_bloginfo('url');
</code></pre>
<p>and</p>
<pre><code>get_site_url();
</code></pre>
<p>I got same output, then what's the difference?</p>
| [
{
"answer_id": 16163,
"author": "MartinJJ",
"author_id": 3710,
"author_profile": "https://wordpress.stackexchange.com/users/3710",
"pm_score": 2,
"selected": false,
"text": "<p>Check out the parameters over at Codex:</p>\n\n<p><strong><a href=\"http://codex.wordpress.org/Function_Referen... | 2011/05/02 | [
"https://wordpress.stackexchange.com/questions/16161",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4314/"
] | I am developing a plugin.
I want to know difference between
```
get_bloginfo('url');
```
and
```
get_site_url();
```
I got same output, then what's the difference? | * **`get_bloginfo('url')`** calls `home_url()` calls `get_home_url()` reads option `home`
* `get_bloginfo('wpurl')` calls `site_url()` calls **`get_site_url()`** reads option `siteurl`
* `get_bloginfo('siteurl')` and `get_bloginfo('home')` are deprecated arguments and return `get_bloginfo('url')` (`siteurl` argument is... |
16,166 | <p>I just installed WordPress 3.1.2, I got </p>
<blockquote>
<p>`Notice: automatic_feed_links is deprecated since version 3.0! Use add_theme_support( 'automatic-feed-links' ) instead. in /works/web/elements/wp-includes/functions.php on line 3303 </p>
</blockquote>
<p>I also got an error about Cannot open stream or ... | [
{
"answer_id": 16167,
"author": "MartinJJ",
"author_id": 3710,
"author_profile": "https://wordpress.stackexchange.com/users/3710",
"pm_score": 3,
"selected": true,
"text": "<p>it sounds like even though its a fresh install of WP 3.1.2 that you are also using an existing theme that is usi... | 2011/05/02 | [
"https://wordpress.stackexchange.com/questions/16166",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/794/"
] | I just installed WordPress 3.1.2, I got
>
> `Notice: automatic\_feed\_links is deprecated since version 3.0! Use add\_theme\_support( 'automatic-feed-links' ) instead. in /works/web/elements/wp-includes/functions.php on line 3303
>
>
>
I also got an error about Cannot open stream or something about `wp-cron.php... | it sounds like even though its a fresh install of WP 3.1.2 that you are also using an existing theme that is using a deprecated function (you havent said so but im presuming),
if so paste this into your themes functions.php file (if your theme doesnt have one just create one and save it in your themes root folder)..
... |
16,174 | <p>I have a custom post type (CPT) called <code>property</code>. I have registered a featured property <code>metabox</code>for it as explained in this question "<a href="https://wordpress.stackexchange.com/questions/9968/how-do-i-create-a-featured-post-within-a-custom-post-type">How do I create a featured post within a... | [
{
"answer_id": 16177,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": -1,
"selected": false,
"text": "<p>I think what you are trying to do her is a little too complex. Essentially you want two (meta and date) sort orders... | 2011/05/02 | [
"https://wordpress.stackexchange.com/questions/16174",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1343/"
] | I have a custom post type (CPT) called `property`. I have registered a featured property `metabox`for it as explained in this question "[How do I create a featured post within a custom post type?](https://wordpress.stackexchange.com/questions/9968/how-do-i-create-a-featured-post-within-a-custom-post-type)". So a featur... | ```
<?php
// query posts
$query_property = query_posts( array(
'orderby' => 'date meta_value' // orderby date AND meta value
) );
// First loop
$query_feat = $query_string.'&meta_value=on&meta_key=property_featured';
// Offset for second loop
$query_all = $query_string.'&offset=3&meta_key=property_featured';
... |
16,194 | <p>I’d like to have a plugin for a flexible sidebar/widget management. In fact, I want to give a user the possibility to choose which sidebar should be displayed per page/post. </p>
<p>I know there are many sidebar plugins out there. Unfortunately, I haven’t found one which cover all my wishes. So I’d like to code thi... | [
{
"answer_id": 16177,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": -1,
"selected": false,
"text": "<p>I think what you are trying to do her is a little too complex. Essentially you want two (meta and date) sort orders... | 2011/05/02 | [
"https://wordpress.stackexchange.com/questions/16194",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3817/"
] | I’d like to have a plugin for a flexible sidebar/widget management. In fact, I want to give a user the possibility to choose which sidebar should be displayed per page/post.
I know there are many sidebar plugins out there. Unfortunately, I haven’t found one which cover all my wishes. So I’d like to code this on my ow... | ```
<?php
// query posts
$query_property = query_posts( array(
'orderby' => 'date meta_value' // orderby date AND meta value
) );
// First loop
$query_feat = $query_string.'&meta_value=on&meta_key=property_featured';
// Offset for second loop
$query_all = $query_string.'&offset=3&meta_key=property_featured';
... |
16,200 | <p>I'd like my frontpage to display a list of my lastest blog posts merged with my latest "Products" custom post type posts.</p>
<p>From the documentation i gather this should work:</p>
<pre><code>query_posts( array('post_type' => array('post', 'product') ) );
while (have_posts()) : the_post();
the_title();
... | [
{
"answer_id": 16177,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": -1,
"selected": false,
"text": "<p>I think what you are trying to do her is a little too complex. Essentially you want two (meta and date) sort orders... | 2011/05/02 | [
"https://wordpress.stackexchange.com/questions/16200",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/82/"
] | I'd like my frontpage to display a list of my lastest blog posts merged with my latest "Products" custom post type posts.
From the documentation i gather this should work:
```
query_posts( array('post_type' => array('post', 'product') ) );
while (have_posts()) : the_post();
the_title();
the_excerpt();
endwhile;... | ```
<?php
// query posts
$query_property = query_posts( array(
'orderby' => 'date meta_value' // orderby date AND meta value
) );
// First loop
$query_feat = $query_string.'&meta_value=on&meta_key=property_featured';
// Offset for second loop
$query_all = $query_string.'&offset=3&meta_key=property_featured';
... |
16,206 | <p>I've found very little on this site or in Google searches for examples of validating metabox custom fields.</p>
<p>If anyone wants to give examples, here are some cases that would be useful</p>
<p>1) Date entered as 05/02/2011 is valid date format<br>
2) Number entered in text box is numeric and between 100 and 5... | [
{
"answer_id": 16207,
"author": "tollmanz",
"author_id": 4850,
"author_profile": "https://wordpress.stackexchange.com/users/4850",
"pm_score": 2,
"selected": false,
"text": "<p>Straight from the WP Codex @ <a href=\"http://codex.wordpress.org/Function_Reference/add_meta_box\" rel=\"nofol... | 2011/05/03 | [
"https://wordpress.stackexchange.com/questions/16206",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3175/"
] | I've found very little on this site or in Google searches for examples of validating metabox custom fields.
If anyone wants to give examples, here are some cases that would be useful
1) Date entered as 05/02/2011 is valid date format
2) Number entered in text box is numeric and between 100 and 500
3) Text in te... | Straight from the WP Codex @ <http://codex.wordpress.org/Function_Reference/add_meta_box>, you call the `save_post` hook and specify the function that will be run to validate/save your data:
```
/* Do something with the data entered */
add_action('save_post', 'myplugin_save_postdata');
```
Then you define that funct... |
16,208 | <p>I have a wordpress widget that has the standard outline like:</p>
<pre><code>class my_widget extends WP_Widget{
function my_widget(){
//do setup stuff
}
function form(){
//do form stuff
}
function update(){
//do update stuff
}
function widget($args, $instance){
//how can we dynamically add style and... | [
{
"answer_id": 16215,
"author": "Norcross",
"author_id": 403,
"author_profile": "https://wordpress.stackexchange.com/users/403",
"pm_score": 0,
"selected": false,
"text": "<p>Are you looking to have a script only trigger when the widget is being used?</p>\n"
},
{
"answer_id": 162... | 2011/05/03 | [
"https://wordpress.stackexchange.com/questions/16208",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5066/"
] | I have a wordpress widget that has the standard outline like:
```
class my_widget extends WP_Widget{
function my_widget(){
//do setup stuff
}
function form(){
//do form stuff
}
function update(){
//do update stuff
}
function widget($args, $instance){
//how can we dynamically add style and script here
... | I'm plucking this code out of my **[Total Widget Control](http://codecongo.com/items/1)** plugin, so it might throw an error or two. I dunno, just let me know if it does. This is basically the widget code that I use for everything that I build.
```
if (!function_exists("register_multiwidget")):
/**
* Register a ... |
16,209 | <p>I am building a template where wordpress is being used primarily as an image CMS, I am pulling the first image from the content section of each post. </p>
<pre><code><img src="<?php echo grab_image() ?>" />
function grab_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$out... | [
{
"answer_id": 16211,
"author": "Lea Cohen",
"author_id": 373,
"author_profile": "https://wordpress.stackexchange.com/users/373",
"pm_score": 0,
"selected": false,
"text": "<p>Maybe you'd like to make a photoblog with <a href=\"http://johannes.jarolim.com/blog/wordpress/yet-another-photo... | 2011/05/03 | [
"https://wordpress.stackexchange.com/questions/16209",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2661/"
] | I am building a template where wordpress is being used primarily as an image CMS, I am pulling the first image from the content section of each post.
```
<img src="<?php echo grab_image() ?>" />
function grab_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img... | Use `get_children()` ([Codex ref](http://codex.wordpress.org/Function_Reference/get_children)):
```
$images = get_children( array(
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'orderby' => 'menu_order',
'order' => 'ASC'
) );
```
The first image ... |
16,216 | <p>Just before I start please note that I am new at any type of WordPress/PHP security. Few days ago friend of mine asked me to create Theme Options for his Theme, all set and working fine, however he had few minor issues with his Theme in the past and I would like to make sure that Nonce and check_admin_referer is set... | [
{
"answer_id": 16231,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>It's not exactly answer to your question but I suggest you check out <a href=\"http://codex.wordpress.org/Settings_A... | 2011/05/03 | [
"https://wordpress.stackexchange.com/questions/16216",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5069/"
] | Just before I start please note that I am new at any type of WordPress/PHP security. Few days ago friend of mine asked me to create Theme Options for his Theme, all set and working fine, however he had few minor issues with his Theme in the past and I would like to make sure that Nonce and check\_admin\_referer is set ... | It's not exactly answer to your question but I suggest you check out [Settings API](http://codex.wordpress.org/Settings_API) instead. It's not ideal (a little too verbose), but it's very structured approach so it's easier to get nice consistent looking form and harder to get security wrong.
Chip Bennett had published ... |
16,223 | <p>In BuddyPress, when a user clicks on their username, they are presented with a page that contains a menu:</p>
<pre><code>Activity
Profile
Messages
Friends
Groups
Settings
</code></pre>
<p>How do I add an item to this menu?</p>
<p>How do display this menu inside my template? (The default page template only display... | [
{
"answer_id": 30715,
"author": "laras126",
"author_id": 3040,
"author_profile": "https://wordpress.stackexchange.com/users/3040",
"pm_score": 4,
"selected": true,
"text": "<p>Here's an example of adding a menu items pointing to custom templates. If you want to link to existing BP elemen... | 2011/05/03 | [
"https://wordpress.stackexchange.com/questions/16223",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3525/"
] | In BuddyPress, when a user clicks on their username, they are presented with a page that contains a menu:
```
Activity
Profile
Messages
Friends
Groups
Settings
```
How do I add an item to this menu?
How do display this menu inside my template? (The default page template only displays the main navigation.) | Here's an example of adding a menu items pointing to custom templates. If you want to link to existing BP elements, you'll need to look up the appropriate action. Add this to `functions.php`:
```
// Set up Cutsom BP navigation
function my_setup_nav() {
global $bp;
bp_core_new_nav_item( array(
... |
16,234 | <p>Is there any plugin which creates a new post from each image I upload/select with it?</p>
<p>I want to create many posts with one image per post.
Currently I select, upload all images. Then create new post, name it same as image file name, insert image from media library and then save to draft/publish it</p>
| [
{
"answer_id": 34783,
"author": "nico",
"author_id": 10592,
"author_profile": "https://wordpress.stackexchange.com/users/10592",
"pm_score": 1,
"selected": false,
"text": "<p>I've found a plugin named YAPB (Yet Another Photoblog) that does exactly what you need, in combination with YAPB ... | 2011/05/03 | [
"https://wordpress.stackexchange.com/questions/16234",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5073/"
] | Is there any plugin which creates a new post from each image I upload/select with it?
I want to create many posts with one image per post.
Currently I select, upload all images. Then create new post, name it same as image file name, insert image from media library and then save to draft/publish it | ```
add_action('add_attachment', 'create_post');
function create_post( $attach_ID ) {
$attachment = get_post( $attach_ID );
$my_post_data = array(
'post_title' => $attachment->post_title,
'post_type' => 'post',
'post_category' => array('0'),
'pos... |
16,243 | <p>Is possible to get current-menu-item as a php variable?</p>
<p>I'm listing the category museums via the menu item 'museums we support' so i'd like the get 'museums we support' bit and display it somewhere?</p>
<p>Any help appreciated!</p>
| [
{
"answer_id": 16250,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure I exactly follow.</p>\n\n<p>The \"Museums We Support\" is generated by a Post Title, Page Titl... | 2011/05/03 | [
"https://wordpress.stackexchange.com/questions/16243",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3978/"
] | Is possible to get current-menu-item as a php variable?
I'm listing the category museums via the menu item 'museums we support' so i'd like the get 'museums we support' bit and display it somewhere?
Any help appreciated! | This is possible by filtering `wp_nav_menu_objects`, which is the easiest place to check which item is the current menu item, because [WordPress already added the classes for you](http://core.trac.wordpress.org/browser/tags/3.1.2/wp-includes/nav-menu-template.php#L192).
```
add_filter( 'wp_nav_menu_objects', 'wpse1624... |
16,247 | <p>I want to list all the users of my site and the amount of posts each user has.</p>
<p>So far I have the function below, but I don't know how to pull in each user's ID to use in the count_user_posts...</p>
<pre><code><ul>
<?php foreach ( get_users('order=DESC&orderby=post_count') as $user ) : ?>
... | [
{
"answer_id": 16248,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>WordPress has a <a href=\"http://codex.wordpress.org/Function_Reference/wp_list_authors\" rel=\"nofollow\">wp_list_a... | 2011/05/03 | [
"https://wordpress.stackexchange.com/questions/16247",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1893/"
] | I want to list all the users of my site and the amount of posts each user has.
So far I have the function below, but I don't know how to pull in each user's ID to use in the count\_user\_posts...
```
<ul>
<?php foreach ( get_users('order=DESC&orderby=post_count') as $user ) : ?>
<li style="color:#fff;"><span styl... | WordPress has a [wp\_list\_authors](http://codex.wordpress.org/Function_Reference/wp_list_authors) function with the option to list post count.
```
<?php
$args = array( 'orderby' => 'post_count', 'optioncount' => true);
wp_list_authors( $args );
?>
```
EDIT: While it's possible to do it the way you're doing it and ... |
16,263 | <p>I'm developing a a site using the wp e-commerce plugin, and it handles tags in pretty much the same way it would if I were using it for a blog instead of a store.</p>
<p>The issue is that I want to use the tags as a secondary kind of navigation menu so that customers can view all items made from a certain material ... | [
{
"answer_id": 16265,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": true,
"text": "<p>you can use <code>wp_list_categories()</code> to output an unordered list:</p>\n\n<pre><code><?php\nwp_list_categ... | 2011/05/03 | [
"https://wordpress.stackexchange.com/questions/16263",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4871/"
] | I'm developing a a site using the wp e-commerce plugin, and it handles tags in pretty much the same way it would if I were using it for a blog instead of a store.
The issue is that I want to use the tags as a secondary kind of navigation menu so that customers can view all items made from a certain material no matter ... | you can use `wp_list_categories()` to output an unordered list:
```
<?php
wp_list_categories( array('taxonomy' => 'product_tag') );
?>
``` |
16,278 | <p>I got this error message when I was installing a plugin: "Unable to locate WordPress Content directory (wp-content)".</p>
<p>I found a solution here: http://<a href="http://wordpress.org/support/topic/cannot-find-content-directory-wp-content" rel="nofollow">wordpress.org/support/topic/cannot-find-content-directory-... | [
{
"answer_id": 16281,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": true,
"text": "<p>The first part (<code>add_filter()</code>) tells WordPress to use the direct-write method. The second part (... | 2011/05/03 | [
"https://wordpress.stackexchange.com/questions/16278",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4509/"
] | I got this error message when I was installing a plugin: "Unable to locate WordPress Content directory (wp-content)".
I found a solution here: http://[wordpress.org/support/topic/cannot-find-content-directory-wp-content](http://wordpress.org/support/topic/cannot-find-content-directory-wp-content)
They suggested addin... | The first part (`add_filter()`) tells WordPress to use the direct-write method. The second part (`define()`) tells WordPress to apply `0751` permissions to any directory it creates. [More information here](http://www.viper007bond.com/2009/05/07/wordpress-how-to-force-direct-filewrites-for-upgrades/).
I would **not con... |
16,280 | <p>I'm trying to add footers to the end of my posts. I need to be able to assign different footers to different posts (not globally).</p>
<p>I tried using <a href="http://wordpress.org/extend/plugins/wp-post-footer/" rel="nofollow">WP Post Footer</a>, but it's not working on WP 3.1.2.</p>
| [
{
"answer_id": 16282,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 0,
"selected": false,
"text": "<p>Anything you add, <em>inside the Loop</em>, but <em>after</em> the call to either <code>the_content()</code... | 2011/05/03 | [
"https://wordpress.stackexchange.com/questions/16280",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5085/"
] | I'm trying to add footers to the end of my posts. I need to be able to assign different footers to different posts (not globally).
I tried using [WP Post Footer](http://wordpress.org/extend/plugins/wp-post-footer/), but it's not working on WP 3.1.2. | Here is a quick solution for you:
on the page or post you want to add a post footer create a new custom field named `post_footer` and in the value add the footer content.
then paste this code in your theme's functions.php file
```
add_filter('the_content',`my_post_footer`,99);
function my_post_footer($content){
g... |
16,286 | <p>I'm using More Fields plugin, and when I use my functions.php to embed the custom field, I get an odd issue. The field value is followed by a "1"</p>
<p>I use this code:</p>
<pre><code>//Address
add_action( 'woo_post_inside_before', 'my_address' );
function my_address() {
global $post;
if ( is_single() &&a... | [
{
"answer_id": 16289,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 0,
"selected": false,
"text": "<p>This is a hunch because I do not know that plugin, your adding styling tags into the parameters of that function, I... | 2011/05/03 | [
"https://wordpress.stackexchange.com/questions/16286",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4902/"
] | I'm using More Fields plugin, and when I use my functions.php to embed the custom field, I get an odd issue. The field value is followed by a "1"
I use this code:
```
//Address
add_action( 'woo_post_inside_before', 'my_address' );
function my_address() {
global $post;
if ( is_single() && in_category('listings') )... | There is no WordPress function called `meta()`. Try using `get_post_custom()` ([Codex ref](http://codex.wordpress.org/Function_Reference/get_post_custom)) instead. For example:
```
//Address
add_action( 'woo_post_inside_before', 'my_address' );
function my_address() {
if ( is_single() && in_category('listings') ) ... |
16,291 | <p>While inside "the loop" in WordPress, is there an easy way to detect if a post is the most recent? A Usage Example: I want to make the first post output an H1 for the title instead of an H2. Or I want the first post to display a thumbnail image (and not the rest).</p>
<p>Here is some pseudocode what I'm trying to g... | [
{
"answer_id": 16293,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": false,
"text": "<p>Try using <code>get_posts()</code>? <a href=\"http://codex.wordpress.org/Template_Tags/get_posts\" rel=\"no... | 2011/05/03 | [
"https://wordpress.stackexchange.com/questions/16291",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5088/"
] | While inside "the loop" in WordPress, is there an easy way to detect if a post is the most recent? A Usage Example: I want to make the first post output an H1 for the title instead of an H2. Or I want the first post to display a thumbnail image (and not the rest).
Here is some pseudocode what I'm trying to get across:... | In addition to @Milo Answer (this avoids a senseless query, because we already got every needed information from the current wp\_query):
```
if ( have_posts() ) :
while ( have_posts() ) : the_post();
$headline_html_tag = $GLOBALS['wp_query']->current_post === (int) 0 && $GLOBALS['paged'] === (int) 1 ? '1'... |
16,298 | <p>After upgrading from 2.8.x (maybe it was 2.9.x) to 3.1.2, all the references inside posts to filenames (usually images) which contain accented chars stopped working.</p>
<p>Before, filenames that are displayed in the filesystem like "EXPRESSÃO.jpg" would be correctly called out in the post content HTML as "EXPRESS... | [
{
"answer_id": 19395,
"author": "Steven",
"author_id": 1447,
"author_profile": "https://wordpress.stackexchange.com/users/1447",
"pm_score": 1,
"selected": false,
"text": "<p>Maybe you should consider option C).<br>\nConvert all accented characters to normal UTF-8 characters.<br>\nSo <co... | 2011/05/03 | [
"https://wordpress.stackexchange.com/questions/16298",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5090/"
] | After upgrading from 2.8.x (maybe it was 2.9.x) to 3.1.2, all the references inside posts to filenames (usually images) which contain accented chars stopped working.
Before, filenames that are displayed in the filesystem like "EXPRESSÃO.jpg" would be correctly called out in the post content HTML as "EXPRESSÃO.jpg". ... | Maybe you should consider option C).
Convert all accented characters to normal UTF-8 characters.
So `EXPRESSÃO.jpg` -> `EXPRESSAO.jpg`
I think this would help you a lot, not only when it come sto coding and file systems, but also storing names / references in databases.
**Update**
This is a function I use for ... |
16,304 | <p>I was able to use <code><?php wp_nav_menu( array( 'theme_location' => 'primary-menu', 'container' => false ) ); ?></code> to create the menu within my theme. Messed around with 'items_wrap' but couldn't get it to display correctly.</p>
<p>I need to add an image and container div into the sub menu ul be... | [
{
"answer_id": 16308,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>What you want is invalid markup. The only children an <code>ul</code> can have are <code>li</code>. Use CSS instead:</p... | 2011/05/04 | [
"https://wordpress.stackexchange.com/questions/16304",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5093/"
] | I was able to use `<?php wp_nav_menu( array( 'theme_location' => 'primary-menu', 'container' => false ) ); ?>` to create the menu within my theme. Messed around with 'items\_wrap' but couldn't get it to display correctly.
I need to add an image and container div into the sub menu ul before the li's. This is the struct... | What you want is invalid markup. The only children an `ul` can have are `li`. Use CSS instead:
```css
#nav ul
{
padding-top: 40px; /* Your image size. */
background: url(/path/to/your/image/img.png) top center no-repeat transparent;
}
``` |
16,305 | <p>I read somewhere*) that there's some <code>q</code> part inside the wp_query object, that identifies search engine visitors and shows the keywords they searched for.</p>
<p>I'm currently developing local, so i can't access/see <code>$GLOBALS['wp_query']->q;</code>. </p>
<p>Could someone varify if this exists an... | [
{
"answer_id": 16308,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>What you want is invalid markup. The only children an <code>ul</code> can have are <code>li</code>. Use CSS instead:</p... | 2011/05/04 | [
"https://wordpress.stackexchange.com/questions/16305",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/385/"
] | I read somewhere\*) that there's some `q` part inside the wp\_query object, that identifies search engine visitors and shows the keywords they searched for.
I'm currently developing local, so i can't access/see `$GLOBALS['wp_query']->q;`.
Could someone varify if this exists and/or has some alternate solution for ret... | What you want is invalid markup. The only children an `ul` can have are `li`. Use CSS instead:
```css
#nav ul
{
padding-top: 40px; /* Your image size. */
background: url(/path/to/your/image/img.png) top center no-repeat transparent;
}
``` |
16,324 | <p>I added a link to a PDF in my custom navigation menu. Is there a way to force it to download instead of open?</p>
| [
{
"answer_id": 16332,
"author": "Jan Fabry",
"author_id": 8,
"author_profile": "https://wordpress.stackexchange.com/users/8",
"pm_score": 2,
"selected": false,
"text": "<p>What happens when the browser encounters a PDF does not depend on how you link to it. You can <em>suggest</em> to th... | 2011/05/04 | [
"https://wordpress.stackexchange.com/questions/16324",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2774/"
] | I added a link to a PDF in my custom navigation menu. Is there a way to force it to download instead of open? | If you don't mind all PDF attachments been forced to be downloaded then you can use something like this:
```
<?php
if (have_posts()) : while (have_posts()) : the_post();
$pdf_title = $post->post_title;
$uploads_dir = wp_upload_dir();
$attachment_src = get_post_meta( $post->ID, '_wp_attached_file', true );... |
16,342 | <p>I am building a front end post layout editor using <a href="http://jqueryui.com/demos/sortable/" rel="noreferrer">jQuery UI Sortable</a>.</p>
<p>The posts are laid out in 300px by 250px boxes over a background image. The posts are created and edited using the WordPress admin but I want to allow the sites administra... | [
{
"answer_id": 16347,
"author": "Geert",
"author_id": 4936,
"author_profile": "https://wordpress.stackexchange.com/users/4936",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://jsfiddle.net/TbR69/1/\" rel=\"nofollow\">http://jsfiddle.net/TbR69/1/</a></p>\n\n<p>Far from fini... | 2011/05/04 | [
"https://wordpress.stackexchange.com/questions/16342",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/251/"
] | I am building a front end post layout editor using [jQuery UI Sortable](http://jqueryui.com/demos/sortable/).
The posts are laid out in 300px by 250px boxes over a background image. The posts are created and edited using the WordPress admin but I want to allow the sites administrator to adjust the order of the boxes u... | Brady is correct that the best way to handle saving and displaying of custom post type orders is by using the `menu_order` property
Here's the jquery to make the list sortable and to pass the data via ajax to wordpress:
```
jQuery(document).ready(function($) {
var itemList = $('#sortable');
itemList.... |
16,365 | <p>I have been trying to get the answer to this for ages now and wondered if anyone here could help. I would like to 'grab' the first link in a post and attach it to a button/image. I have tried the numerous options available here: <a href="http://wpquestions.com/question/show/id/873" rel="nofollow">http://wpquestions.... | [
{
"answer_id": 16370,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": false,
"text": "<p>A more updated and clean method: </p>\n\n<pre><code>function get_link_url() {\n $content = get_the_conte... | 2011/05/04 | [
"https://wordpress.stackexchange.com/questions/16365",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5113/"
] | I have been trying to get the answer to this for ages now and wondered if anyone here could help. I would like to 'grab' the first link in a post and attach it to a button/image. I have tried the numerous options available here: <http://wpquestions.com/question/show/id/873>
I have had greater success with the last sug... | A more updated and clean method:
```
function get_link_url() {
$content = get_the_content();
$has_url = get_url_in_content( $content );
return ( $has_url ) ? $has_url : apply_filters( 'the_permalink', get_permalink() );
}
```
<http://www.wprecipes.com/how-to-get-the-first-image-from-the-post-and-displa... |
16,372 | <p>As the title says , I want a plugin/function to prevent/inform the user when he tries to publish the post without setting the featured image.</p>
<p>ANY HELP ???</p>
| [
{
"answer_id": 16376,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<pre><code><?php\n// Something like that should help, but you'll have to play with it to get it working:\n// inside... | 2011/05/04 | [
"https://wordpress.stackexchange.com/questions/16372",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5117/"
] | As the title says , I want a plugin/function to prevent/inform the user when he tries to publish the post without setting the featured image.
ANY HELP ??? | The `has_post_thumbnail()` works for me, in WP versions 3.4.1 and other most recently.
But in this logic, because the WP will publish the post even with `exit` or `wp_die()` or anything to terminate the PHP script. For prevent that the post stay with published status, you will need to update the post before terminate. ... |
16,373 | <p>I need your <strong>recommendation for the best practice</strong> here:</p>
<ul>
<li>A custom post type I have created
needs a list of attachments at the
end of the post content.</li>
<li>I have created a series of functions that handle
displaying the list of appropriate
attachments for a post.</li>
<li>I don't wan... | [
{
"answer_id": 16374,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": true,
"text": "<pre><code><?php\n// A)\n// inside your template\nif ( function_exists( 'the_attachment_stuff()' ) )\n{\n // do s... | 2011/05/04 | [
"https://wordpress.stackexchange.com/questions/16373",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3687/"
] | I need your **recommendation for the best practice** here:
* A custom post type I have created
needs a list of attachments at the
end of the post content.
* I have created a series of functions that handle
displaying the list of appropriate
attachments for a post.
* I don't want to use shortcode to insert this attachm... | ```
<?php
// A)
// inside your template
if ( function_exists( 'the_attachment_stuff()' ) )
{
// do stuff
}
// better/faster
if ( class_exists( 'attachment_plugin_class' ) )
{
// do stuff
}
// B)
// inside your template
do_action( 'the_attachment_suff');
// means setting this inside your plugin
// this avoids ... |
16,382 | <p>I am using <code>$wpdb->update</code> to update a custom table I have in my database. When I <code>var_dump</code> the result it returns:</p>
<pre><code>int(0)
</code></pre>
<p>So I tried <code>$wpdb->print_error()</code> to see what's wrong. However, it shows nothing. I also tried <code>$wpdb->show_error... | [
{
"answer_id": 16390,
"author": "goldenapples",
"author_id": 290,
"author_profile": "https://wordpress.stackexchange.com/users/290",
"pm_score": 2,
"selected": false,
"text": "<p>A zero response means zero rows affected, which is different from an error.</p>\n\n<p>Its hard to say without... | 2011/05/05 | [
"https://wordpress.stackexchange.com/questions/16382",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4224/"
] | I am using `$wpdb->update` to update a custom table I have in my database. When I `var_dump` the result it returns:
```
int(0)
```
So I tried `$wpdb->print_error()` to see what's wrong. However, it shows nothing. I also tried `$wpdb->show_errors()`, but again it showed nothing.
The [wpdb docs](http://codex.wordpre... | I would recommend running the following code right after your query to see what's happening:
```
exit( var_dump( $wpdb->last_query ) );
```
This should print the last query that hit your database. In cases like these, I usually will manually run such a query through phpMyAdmin to see if it runs without errors and to... |
16,386 | <p>My question is basically identical to this other question <a href="https://wordpress.stackexchange.com/questions/6811/creating-a-metabox-to-upload-multiple-images">here</a>, however my question is still slightly different. I basically have a custom post type called "Packages" each package can have a slideshow with i... | [
{
"answer_id": 16395,
"author": "Geert",
"author_id": 4936,
"author_profile": "https://wordpress.stackexchange.com/users/4936",
"pm_score": 2,
"selected": false,
"text": "<p>You could basically use the code from <a href=\"https://wordpress.stackexchange.com/questions/6811/creating-a-meta... | 2011/05/05 | [
"https://wordpress.stackexchange.com/questions/16386",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1687/"
] | My question is basically identical to this other question [here](https://wordpress.stackexchange.com/questions/6811/creating-a-metabox-to-upload-multiple-images), however my question is still slightly different. I basically have a custom post type called "Packages" each package can have a slideshow with its own images.... | Generally speaking, I would take the approach of querying for post attachments, but withhold the attachment that is the post thumbnail. WP provides a simple way of finding the post thumbnail ID with `get_post_thumbnail_id` ([Codex Ref](http://codex.wordpress.org/Function_Reference/get_post_thumbnail_id)). To modify the... |
16,387 | <p>There are two different category "Life Sciences" and "General Lab" and there are sub-categorical product on "Life Sciences".
Now "General Lab" category want to fetch all the sub-category and products which "Life sciences" have. The code is in category.php.
Here is the whole code:
<code>
</p>
<pre> <div id="co... | [
{
"answer_id": 16408,
"author": "Jan Fabry",
"author_id": 8,
"author_profile": "https://wordpress.stackexchange.com/users/8",
"pm_score": 1,
"selected": false,
"text": "<p>When you go to the second page of the \"General Lab\", WordPress does a query for posts in that category and finds n... | 2011/05/05 | [
"https://wordpress.stackexchange.com/questions/16387",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5125/"
] | There are two different category "Life Sciences" and "General Lab" and there are sub-categorical product on "Life Sciences".
Now "General Lab" category want to fetch all the sub-category and products which "Life sciences" have. The code is in category.php.
Here is the whole code:
```
<div id="container">
<... | When you go to the second page of the "General Lab", WordPress does a query for posts in that category and finds none. If WordPress finds no posts, it will display the 404 template. The only case is [when you are on the *first* page of a taxonomy](https://wordpress.stackexchange.com/questions/11354/do-we-still-need-to-... |
16,393 | <p>I have a custom post type "mycustom_products" (hierarchical) that has custom taxonomies called 'categories' and 'tags' (as many other custom post types do). My custom category is called "myprod_category" (also hierarchical) and my tag taxonomy is called "product_tag" (<em>not</em> hierarchical). </p>
<p>I want to... | [
{
"answer_id": 16769,
"author": "MZAweb",
"author_id": 5223,
"author_profile": "https://wordpress.stackexchange.com/users/5223",
"pm_score": 1,
"selected": false,
"text": "<p>If I understand you correctly, I think there is no direct option.</p>\n\n<p>You should query all products within ... | 2011/05/05 | [
"https://wordpress.stackexchange.com/questions/16393",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1663/"
] | I have a custom post type "mycustom\_products" (hierarchical) that has custom taxonomies called 'categories' and 'tags' (as many other custom post types do). My custom category is called "myprod\_category" (also hierarchical) and my tag taxonomy is called "product\_tag" (*not* hierarchical).
I want to show a list of ... | >
> If you have a lot of products, probably a custom sql query is a better option.
>
>
>
I'd probably recommend following that route either way. Custom queries may be 'icky', but it'll lighten resources and be a darn slight quicker in most cases\*
I've written a function that does most of the labour, and may well... |
16,394 | <p>If I know a taxonomy term slug, how can I get that term's name?</p>
| [
{
"answer_id": 16398,
"author": "tollmanz",
"author_id": 4850,
"author_profile": "https://wordpress.stackexchange.com/users/4850",
"pm_score": 7,
"selected": true,
"text": "<p>The function you are looking for is <code>get_term_by</code>. You would use it as such:</p>\n<pre><code><?php... | 2011/05/05 | [
"https://wordpress.stackexchange.com/questions/16394",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2107/"
] | If I know a taxonomy term slug, how can I get that term's name? | The function you are looking for is `get_term_by`. You would use it as such:
```
<?php $term = get_term_by('slug', 'my-term-slug', 'category'); $name = $term->name; ?>
```
This results in `$term` being an object containing the following:
```
term_id
name
slug
term_group
term_taxonomy_id
taxonomy
description
parent
... |
16,401 | <p>When I use <code>add_menu_page</code> & <code>add_submenu_page</code> to add menu items,</p>
<pre><code>add_menu_page( 'Forms', 'Forms', 'administrator', 'forms', 'forms_job_menupage_cb' );
add_submenu_page( 'forms', 'Job Applications', 'Job Applications', 'administrator', 'job-applications', 'forms_job_menupag... | [
{
"answer_id": 16409,
"author": "MikeSchinkel",
"author_id": 89,
"author_profile": "https://wordpress.stackexchange.com/users/89",
"pm_score": 5,
"selected": true,
"text": "<p>Hi <strong>@JM at Work:</strong></p>\n\n<p>Yes, it is unfortunately that the submenu page is added for every men... | 2011/05/05 | [
"https://wordpress.stackexchange.com/questions/16401",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3788/"
] | When I use `add_menu_page` & `add_submenu_page` to add menu items,
```
add_menu_page( 'Forms', 'Forms', 'administrator', 'forms', 'forms_job_menupage_cb' );
add_submenu_page( 'forms', 'Job Applications', 'Job Applications', 'administrator', 'job-applications', 'forms_job_menupage_cb' );
add_submenu_page( 'forms', 'Quo... | Hi **@JM at Work:**
Yes, it is unfortunately that the submenu page is added for every menu page. It would be nice [if there were an option but alas, there currently is not](http://core.trac.wordpress.org/ticket/17324#comment:21).
To remove the submenu page option in WordPress 3.1 or great use `remove_submenu_page()`... |
16,413 | <p>I have a big problem and no clue how to solve it :) I want to add a "module" to my homepage (static homepage, not blog posts) that will display the 2 latest blog posts in a very particular way and link back to them. The posts would only display on the homepage and not every other page but the php template used for t... | [
{
"answer_id": 16433,
"author": "Fred Rocha",
"author_id": 1450,
"author_profile": "https://wordpress.stackexchange.com/users/1450",
"pm_score": 0,
"selected": false,
"text": "<p>Nice handwriting :)</p>\n\n<p>This can be simply done by checking whether the current page is home, and by fe... | 2011/05/05 | [
"https://wordpress.stackexchange.com/questions/16413",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4402/"
] | I have a big problem and no clue how to solve it :) I want to add a "module" to my homepage (static homepage, not blog posts) that will display the 2 latest blog posts in a very particular way and link back to them. The posts would only display on the homepage and not every other page but the php template used for the ... | Personally, I like using `get_posts()` ([Codex ref](http://codex.wordpress.org/Template_Tags/get_posts)) for quick-and-dirty Loops.
In your `front-page.php` template file, try the following:
```
<?php
// Create a variable to hold our custom Loop results
$frontpageposts = get_posts( array(
'numberposts' => 2 //... |
16,414 | <p>I want to edit a file <code>style.css</code> but the theme editor shows this:</p>
<pre><code>/* ---------- Reset Tags ----------- */
@import url("css/reset.css");
/* ---------- Reset Tags ----------- */
@import url("css/prettyPhoto.css");
/* ---------- Shortcodes ----------- */
@import url("css/shortcodes.css");
... | [
{
"answer_id": 16417,
"author": "Geert",
"author_id": 4936,
"author_profile": "https://wordpress.stackexchange.com/users/4936",
"pm_score": 1,
"selected": false,
"text": "<p>If you move your CSS files to the root of your theme, instead of a separate \"css\" directory, the CSS files will ... | 2011/05/05 | [
"https://wordpress.stackexchange.com/questions/16414",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5073/"
] | I want to edit a file `style.css` but the theme editor shows this:
```
/* ---------- Reset Tags ----------- */
@import url("css/reset.css");
/* ---------- Reset Tags ----------- */
@import url("css/prettyPhoto.css");
/* ---------- Shortcodes ----------- */
@import url("css/shortcodes.css");
/* ---------- Site Style... | The theme editor [has support for files in a subdirectory](http://core.trac.wordpress.org/ticket/4131) - but only if this is the main theme and only for PHP files. This seems to be an omission, I [opened a ticket for it](http://core.trac.wordpress.org/ticket/17333). |
16,415 | <p><strong>Situation:</strong> I'm working on a plugin and I'm developing it as a class, everything worked fine until I run into this situation. I wanted to make things a bit cleaner and tried this..</p>
<pre><code>class MyPlugin {
function __construct() {
add_action('admin_menu', array(&$this, 'myplug... | [
{
"answer_id": 16422,
"author": "Scott",
"author_id": 4610,
"author_profile": "https://wordpress.stackexchange.com/users/4610",
"pm_score": 0,
"selected": false,
"text": "<p>the function load_view should be like this?:</p>\n\n<pre><code>function load_view($filename) {\n include(dirnam... | 2011/05/05 | [
"https://wordpress.stackexchange.com/questions/16415",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5132/"
] | **Situation:** I'm working on a plugin and I'm developing it as a class, everything worked fine until I run into this situation. I wanted to make things a bit cleaner and tried this..
```
class MyPlugin {
function __construct() {
add_action('admin_menu', array(&$this, 'myplugin_create_menus');
} ... | You can't pass an argument to the callback function. [`add_menu_page()` adds it as an action handler](http://core.trac.wordpress.org/browser/tags/3.1.2/wp-admin/includes/plugin.php#L878), and [`admin.php` fires the action](http://core.trac.wordpress.org/browser/tags/3.1.2/wp-admin/admin.php#L151), without any arguments... |
16,421 | <p>I'm using the <a href="http://wordpress.org/extend/plugins/wp-tweetbutton/" rel="nofollow noreferrer">WP-TweetButton</a> but when I set the settings to add the button manually. Nothing is displayed.</p>
<p>Settings:<img src="https://i.stack.imgur.com/D7XXd.png" alt="enter image description here"></p>
<p>The Code:<... | [
{
"answer_id": 16422,
"author": "Scott",
"author_id": 4610,
"author_profile": "https://wordpress.stackexchange.com/users/4610",
"pm_score": 0,
"selected": false,
"text": "<p>the function load_view should be like this?:</p>\n\n<pre><code>function load_view($filename) {\n include(dirnam... | 2011/05/05 | [
"https://wordpress.stackexchange.com/questions/16421",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/781/"
] | I'm using the [WP-TweetButton](http://wordpress.org/extend/plugins/wp-tweetbutton/) but when I set the settings to add the button manually. Nothing is displayed.
Settings:
The Code:
```
<div id="social-buttons">
<div id="... | You can't pass an argument to the callback function. [`add_menu_page()` adds it as an action handler](http://core.trac.wordpress.org/browser/tags/3.1.2/wp-admin/includes/plugin.php#L878), and [`admin.php` fires the action](http://core.trac.wordpress.org/browser/tags/3.1.2/wp-admin/admin.php#L151), without any arguments... |
16,427 | <p>I'm trying to do some WordPress URL rewriting ...</p>
<p>Specifically I have custom post type that currently works like this:</p>
<p><code>http://mydomain.com/videos/post-title/</code></p>
<p>But I would like to have it located at:</p>
<p><code>http://mydomain.com/videos/author-name/post-title/</code></p>
<p>Is... | [
{
"answer_id": 16429,
"author": "Mild Fuzz",
"author_id": 784,
"author_profile": "https://wordpress.stackexchange.com/users/784",
"pm_score": 0,
"selected": false,
"text": "<p>goto the permalinks section on the settings in the admin panel, set a <code>custom structure</code> like so:</p... | 2011/05/05 | [
"https://wordpress.stackexchange.com/questions/16427",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3986/"
] | I'm trying to do some WordPress URL rewriting ...
Specifically I have custom post type that currently works like this:
`http://mydomain.com/videos/post-title/`
But I would like to have it located at:
`http://mydomain.com/videos/author-name/post-title/`
Is there any way to achieve this? | using Jhon's [Custom Post Permalinks](http://wordpress.org/extend/plugins/custom-post-permalinks/) plugin it should be easy
using:
```
/%post_type%/%author%/%postname%/
``` |
16,439 | <p>I'd like to make all the links in posts on one of <a href="http://www.dancebloggers.com" rel="nofollow">my sites</a> to be with rel="nofollow" on links inside posts. I wasn't able to find a plugin that did the job except for WP-NoExternalLinks. It also didn't work, unless I used it's dooms day option:</p>
<blockq... | [
{
"answer_id": 16445,
"author": "웃mauri",
"author_id": 3022,
"author_profile": "https://wordpress.stackexchange.com/users/3022",
"pm_score": 3,
"selected": true,
"text": "<p>you can add a filter in your functions.php\nadd</p>\n\n<pre><code>// Nofollow in content\nadd_filter('the_content'... | 2011/05/05 | [
"https://wordpress.stackexchange.com/questions/16439",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/161/"
] | I'd like to make all the links in posts on one of [my sites](http://www.dancebloggers.com) to be with rel="nofollow" on links inside posts. I wasn't able to find a plugin that did the job except for WP-NoExternalLinks. It also didn't work, unless I used it's dooms day option:
>
> "Mask ALL links in document (can slow... | you can add a filter in your functions.php
add
```
// Nofollow in content
add_filter('the_content', 'my_nofollow');
function my_nofollow($content) {
//return stripslashes(wp_rel_nofollow($content));
return preg_replace_callback('/<a[^>]+/', 'my_nofollow_callback', $content);
}
function my_nofollow_callback(... |
16,440 | <p>I need a plugin for custom post type. I need something like this:</p>
<p><img src="https://i.stack.imgur.com/crrY1.jpg" alt="Mockup with image uploader under edit screen"></p>
<p>Can anyone suggest a plugin which has this feature, especially image upload and "Add another" button option.</p>
| [
{
"answer_id": 16445,
"author": "웃mauri",
"author_id": 3022,
"author_profile": "https://wordpress.stackexchange.com/users/3022",
"pm_score": 3,
"selected": true,
"text": "<p>you can add a filter in your functions.php\nadd</p>\n\n<pre><code>// Nofollow in content\nadd_filter('the_content'... | 2011/05/05 | [
"https://wordpress.stackexchange.com/questions/16440",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5074/"
] | I need a plugin for custom post type. I need something like this:

Can anyone suggest a plugin which has this feature, especially image upload and "Add another" button option. | you can add a filter in your functions.php
add
```
// Nofollow in content
add_filter('the_content', 'my_nofollow');
function my_nofollow($content) {
//return stripslashes(wp_rel_nofollow($content));
return preg_replace_callback('/<a[^>]+/', 'my_nofollow_callback', $content);
}
function my_nofollow_callback(... |
16,452 | <p>say i've got a url <a href="http://bfami.modernactivity.co.uk/category/museum/orderby/date/order/desc/" rel="nofollow">http://bfami.modernactivity.co.uk/category/museum/orderby/date/order/desc/</a></p>
<p>that works with;</p>
<pre><code>add_rewrite_rule( 'category/(.+?)/orderby/([^/]+)/order/([^/]+)(/page/?([0-9]{... | [
{
"answer_id": 16454,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 1,
"selected": false,
"text": "<p>You are looking for <a href=\"http://codex.wordpress.org/Function_Reference/get_query_var\" rel=\"nofollow\">... | 2011/05/05 | [
"https://wordpress.stackexchange.com/questions/16452",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3978/"
] | say i've got a url <http://bfami.modernactivity.co.uk/category/museum/orderby/date/order/desc/>
that works with;
```
add_rewrite_rule( 'category/(.+?)/orderby/([^/]+)/order/([^/]+)(/page/?([0-9]{1,}))?/?$', 'index.php?category_name=$matches[1]&paged=$matches[5]&orderby=$matches[2]&order=$matches[3]', 'top' );
```
h... | ended up with;
```
class="<?=( strpos( $oby ,'date' ) ? 'active' : null )?>"
```
though can imagine i'll need to get this working on one job or the other...
thanks all! |
16,466 | <p>On this page: <a href="http://codex.wordpress.org/Function_Reference/wp_add_dashboard_widget" rel="nofollow">http://codex.wordpress.org/Function_Reference/wp_add_dashboard_widget</a></p>
<p>The function <strong>wp_add_dashboard_widget</strong> is described.</p>
<p>It states:</p>
<pre><code>wp_add_dashboard_widget... | [
{
"answer_id": 16468,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 1,
"selected": false,
"text": "<p>Do you need to handle form/input data? If not, then you can omit the <code>$control_Callback</code>, and si... | 2011/05/05 | [
"https://wordpress.stackexchange.com/questions/16466",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4816/"
] | On this page: <http://codex.wordpress.org/Function_Reference/wp_add_dashboard_widget>
The function **wp\_add\_dashboard\_widget** is described.
It states:
```
wp_add_dashboard_widget($widget_id, $widget_name, $callback, $control_callback = null)
```
How do you use the $control\_callback, properly? I am completeley... | Solution : hover on the title bar of your widget, then click **configure**
Don't ask me why this works like this but it does. |
16,474 | <p>I'm working on a plugin, and part of it involves setting an option value that applies to all sites in a WordPress network. I know about the <a href="http://codex.wordpress.org/WPMU_Functions/add_site_option">add_site_option</a> and <a href="http://codex.wordpress.org/WPMU_Functions/get_site_option">get_site_option<... | [
{
"answer_id": 27818,
"author": "BjornW",
"author_id": 637,
"author_profile": "https://wordpress.stackexchange.com/users/637",
"pm_score": 0,
"selected": false,
"text": "<p>I'm afraid that the only method I know of is the method you mentioned of manually inject the html and deal with the... | 2011/05/05 | [
"https://wordpress.stackexchange.com/questions/16474",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1782/"
] | I'm working on a plugin, and part of it involves setting an option value that applies to all sites in a WordPress network. I know about the [add\_site\_option](http://codex.wordpress.org/WPMU_Functions/add_site_option) and [get\_site\_option](http://codex.wordpress.org/WPMU_Functions/get_site_option) functions that let... | There's a `wpmu_options` action that lets you append more HTML on the Network Settings page.
If you want to add your own sub-menu/page to the Settings parent menu:
```
add_action('network_admin_menu', 'add_my_netw_settings_page');
function add_my_netw_settings_page() {
add_submenu_page(
'settings.php',
... |
16,482 | <p>I am having a bit of a problem with my custom post types. I can create them fine in my theme, but I cannot get them to show up in the 'Menu' screen ... at least not by default.</p>
<p>I have tried adding menu and UI flags to my code (see below), but no dice.</p>
<p>Interestingly enough, when I enable the Custom Po... | [
{
"answer_id": 28068,
"author": "Brian Fegter",
"author_id": 4793,
"author_profile": "https://wordpress.stackexchange.com/users/4793",
"pm_score": 1,
"selected": false,
"text": "<p>You can force the custom post type to stay on by editing the current user option 'metaboxhidden_nav-menus':... | 2011/05/05 | [
"https://wordpress.stackexchange.com/questions/16482",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5150/"
] | I am having a bit of a problem with my custom post types. I can create them fine in my theme, but I cannot get them to show up in the 'Menu' screen ... at least not by default.
I have tried adding menu and UI flags to my code (see below), but no dice.
Interestingly enough, when I enable the Custom Post Types UI plugi... | Please make sure in Appearance -> Menu and go to Scree Option on the top and make sure to tick the CPT UI, and it will appear. |
16,504 | <p>I'd like to display 9 posts and be able to insert a sticky post with its custom html template in between 4th & 5th post. Currently the sticky post gets displayed in both the "sticky container" and regular posts.</p>
<p>
have_posts()) : $my_query->the_post();
?></p>
<pre><code><?php if ($count <= ... | [
{
"answer_id": 16488,
"author": "Dillie-O",
"author_id": 1165,
"author_profile": "https://wordpress.stackexchange.com/users/1165",
"pm_score": 0,
"selected": false,
"text": "<p>According to the N<a href=\"http://codex.wordpress.org/Network_Admin_Users_Screen\" rel=\"nofollow\">etwork Adm... | 2011/05/06 | [
"https://wordpress.stackexchange.com/questions/16504",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2313/"
] | I'd like to display 9 posts and be able to insert a sticky post with its custom html template in between 4th & 5th post. Currently the sticky post gets displayed in both the "sticky container" and regular posts.
have\_posts()) : $my\_query->the\_post();
?>
```
<?php if ($count <= 9 ){ ;?>
<article>
<?php... | To follow up to xLRDxREVENGEx's answer, here's a screenshot of the checkbox you need to check in the network admin section:
 |
16,514 | <p>In my new custom theme I want my user to be able to add a 'customer testimony'. All I need for each entry is a plain text area for the content of the testimony and a text input for the author of the testimony (i.e. who said it). My question is what would you use to create this custom post type or something else?</p>... | [
{
"answer_id": 16515,
"author": "anu",
"author_id": 490,
"author_profile": "https://wordpress.stackexchange.com/users/490",
"pm_score": 0,
"selected": false,
"text": "<p>Just enable the title - you don't need to display it.</p>\n"
},
{
"answer_id": 16590,
"author": "mfields",... | 2011/05/06 | [
"https://wordpress.stackexchange.com/questions/16514",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5158/"
] | In my new custom theme I want my user to be able to add a 'customer testimony'. All I need for each entry is a plain text area for the content of the testimony and a text input for the author of the testimony (i.e. who said it). My question is what would you use to create this custom post type or something else?
My in... | If I were setting up this custom taxonomy, I would use only two fields: title and content. If it's there and it fits your needs then it is best to use it IMHO. Title can be used for the name of the person who wrote the testimonial and content would be used for the testimonial itself. You will have to write little to no... |
16,518 | <p>I have recently added theme support for post_thumbnails with three new sizes, I wanted to resize all the old images uploaded previously. I have written my own script as follows:</p>
<pre><code>function resizeImages()
{
require ( ABSPATH . 'wp-admin/includes/image.php' );
global $wpdb;
$images = $wpdb-... | [
{
"answer_id": 16523,
"author": "Sisir",
"author_id": 3094,
"author_profile": "https://wordpress.stackexchange.com/users/3094",
"pm_score": 1,
"selected": false,
"text": "<p>use this plugin instead. Always work for me :) <a href=\"http://wordpress.org/extend/plugins/regenerate-thumbnails... | 2011/05/06 | [
"https://wordpress.stackexchange.com/questions/16518",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2911/"
] | I have recently added theme support for post\_thumbnails with three new sizes, I wanted to resize all the old images uploaded previously. I have written my own script as follows:
```
function resizeImages()
{
require ( ABSPATH . 'wp-admin/includes/image.php' );
global $wpdb;
$images = $wpdb->get_results(... | use this plugin instead. Always work for me :) <http://wordpress.org/extend/plugins/regenerate-thumbnails> |
16,527 | <p>I'm developing a theme for a client, and I want to allow her to change the site title, description, and her password as needed. However, I don't want to give access to all of the other options (e.g. the site URL).</p>
<p>I have some experience creating a theme options panel (via <a href="http://net.tutsplus.com/tut... | [
{
"answer_id": 16533,
"author": "Patriek",
"author_id": 2434,
"author_profile": "https://wordpress.stackexchange.com/users/2434",
"pm_score": 1,
"selected": false,
"text": "<p>Just create input fields on your options page and on postback do a\"\nupdate_option('blogname') or update_option... | 2011/05/06 | [
"https://wordpress.stackexchange.com/questions/16527",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4285/"
] | I'm developing a theme for a client, and I want to allow her to change the site title, description, and her password as needed. However, I don't want to give access to all of the other options (e.g. the site URL).
I have some experience creating a theme options panel (via [this article on nettuts+](http://net.tutsplus... | An easier approach would be to leave the `options-general.php` sub menu unblocked and define:
```
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
```
in your wp-config.php. When the siteurl and homeurl are defined in wp-config.php the options are grayed out on the options page. Thi... |
16,530 | <p>I know it is possible to change the "Enter Title Here". But is there’s a function to add text (“how to...”, “simple rules to post...”) inside the post text/input area! Any help?</p>
| [
{
"answer_id": 16533,
"author": "Patriek",
"author_id": 2434,
"author_profile": "https://wordpress.stackexchange.com/users/2434",
"pm_score": 1,
"selected": false,
"text": "<p>Just create input fields on your options page and on postback do a\"\nupdate_option('blogname') or update_option... | 2011/05/06 | [
"https://wordpress.stackexchange.com/questions/16530",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4612/"
] | I know it is possible to change the "Enter Title Here". But is there’s a function to add text (“how to...”, “simple rules to post...”) inside the post text/input area! Any help? | An easier approach would be to leave the `options-general.php` sub menu unblocked and define:
```
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
```
in your wp-config.php. When the siteurl and homeurl are defined in wp-config.php the options are grayed out on the options page. Thi... |
16,538 | <p>I have a plugin I want to use, but it depends on the $ identifier, as apposed to using jQuery.</p>
<p>Is it possible to enable the $, to save me recoding the plugin?</p>
<p><strong>EDIT</strong></p>
<p>The plugin automatically adds the javascript, therefore I can't wrap it.</p>
| [
{
"answer_id": 16539,
"author": "Sisir",
"author_id": 3094,
"author_profile": "https://wordpress.stackexchange.com/users/3094",
"pm_score": 4,
"selected": true,
"text": "<p>Try this: </p>\n\n<pre><code>jQuery(function ($) {\n /* You can safely use $ in this code block to reference jQu... | 2011/05/06 | [
"https://wordpress.stackexchange.com/questions/16538",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/784/"
] | I have a plugin I want to use, but it depends on the $ identifier, as apposed to using jQuery.
Is it possible to enable the $, to save me recoding the plugin?
**EDIT**
The plugin automatically adds the javascript, therefore I can't wrap it. | Try this:
```
jQuery(function ($) {
/* You can safely use $ in this code block to reference jQuery
Call your plugin here
*/
})
```
I think you already know this. But still for reference <http://api.jquery.com/jQuery.noConflict/> |
16,540 | <p>I am writing a media plugin that uses custom tables to store its contents. (eg not the post tables where wordpress stores it attachment data). Now i'm looking for a way to use the default wordpress comment system to add comments to it. (These comments will not be in the regular comment table but also a custom table.... | [
{
"answer_id": 16541,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": false,
"text": "<p>Try using the <code>preprocess_comment</code> filter hook, e.g.</p>\n\n<pre><code>function my_handling_func... | 2011/05/06 | [
"https://wordpress.stackexchange.com/questions/16540",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2434/"
] | I am writing a media plugin that uses custom tables to store its contents. (eg not the post tables where wordpress stores it attachment data). Now i'm looking for a way to use the default wordpress comment system to add comments to it. (These comments will not be in the regular comment table but also a custom table.
I... | `wp_list_comments()` has no filters or hooks so its going to be a bit hard, what you can do is use `comments_array` filter hook
```
add_filter('comments_array','my_custom_comments_list');
function my_custom_comments_list($comments, $post_id){
//if criteria are met
//pull your comments from your own table
... |
16,547 | <p>I'm developing WordPress plugins. When I activate my plugin, I'm getting the following message: </p>
<blockquote>
<p>The plugin generated 293 characters of
unexpected output during activation.
If you notice “headers already sent”
messages, problems with syndication
feeds or other issues, try
deactivatin... | [
{
"answer_id": 16549,
"author": "Matthew Muro",
"author_id": 1511,
"author_profile": "https://wordpress.stackexchange.com/users/1511",
"pm_score": 4,
"selected": false,
"text": "<p>This is typically caused by spaces or new lines before the opening <code><?php</code> tag or after the c... | 2011/05/06 | [
"https://wordpress.stackexchange.com/questions/16547",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3552/"
] | I'm developing WordPress plugins. When I activate my plugin, I'm getting the following message:
>
> The plugin generated 293 characters of
> unexpected output during activation.
> If you notice “headers already sent”
> messages, problems with syndication
> feeds or other issues, try
> deactivating or removing t... | My guess is you get a PHP error, which generates output before the headers are sent. If you have `E_NOTICE` enabled, calling `$_POST['foo']` may generate a "Notice: undefined variable" error if that variable is not set.
Best practice: never assume anything about GET, POST, COOKIE and REQUEST variables. Always check fi... |
16,573 | <p>I'm learning how to build html forms using PHP by taking an example from "simplr form registration" plugin.</p>
<p>I'm looking at this code:</p>
<pre><code>$form .= apply_filters('simplr-reg-instructions', __('Please fill out this form to sign up for this site', 'simplr-reg'));
</code></pre>
<p>Can you please exp... | [
{
"answer_id": 16579,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 3,
"selected": false,
"text": "<p>You have two different functions here <code>apply_filters</code> and <code>__()</code></p>\n\n<p>apply_filter... | 2011/05/06 | [
"https://wordpress.stackexchange.com/questions/16573",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5171/"
] | I'm learning how to build html forms using PHP by taking an example from "simplr form registration" plugin.
I'm looking at this code:
```
$form .= apply_filters('simplr-reg-instructions', __('Please fill out this form to sign up for this site', 'simplr-reg'));
```
Can you please explain what is happning here - what... | That line is using two different functions that need two separate explanations.
\_\_()
------
This is a translation function. If the settings are done right, it will translate the first parameter from a list of pre-translated strings. If an installation has a file with a compiled translation for this function to use,... |
16,584 | <p>I'm hoping that you are my saviours. There seem be lots of people with this problem on the forums, but no clear answer. Here's my predicament:-</p>
<p>I've just put together a new Wordpress site on new hosting and it works a treat. I'm over the moon at how cool it is. However, on our previous (non Wordpress) hostin... | [
{
"answer_id": 16587,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 1,
"selected": false,
"text": "<p>The problem your having is because of the way the WordPress rewrite system works. The WordPress .htaccess sends a... | 2011/05/06 | [
"https://wordpress.stackexchange.com/questions/16584",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5176/"
] | I'm hoping that you are my saviours. There seem be lots of people with this problem on the forums, but no clear answer. Here's my predicament:-
I've just put together a new Wordpress site on new hosting and it works a treat. I'm over the moon at how cool it is. However, on our previous (non Wordpress) hosting we had a... | The problem your having is because of the way the WordPress rewrite system works. The WordPress .htaccess sends all requests (that dont actually exist except index.php) through the index.php file in the WordPress root directory. If any request is made for a file named index.php it will also get sent through the root Wo... |
16,596 | <pre><code>Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate ... bytes) in wp-includes/pomo/streams.php on line ...
</code></pre>
<ol>
<li>
Plugins like Super-cashe & Total-cashe don't help.</li>
<li>Reducing the number of wordpress plugins and widgets used gives minimal effect.</li>
... | [
{
"answer_id": 16597,
"author": "Vergil Penkov",
"author_id": 1948,
"author_profile": "https://wordpress.stackexchange.com/users/1948",
"pm_score": 0,
"selected": false,
"text": "<p>Try putting this into your wp config:</p>\n\n<pre><code>define('WP_MEMORY_LIMIT', '96M');\n</code></pre>\n... | 2010/11/12 | [
"https://wordpress.stackexchange.com/questions/16596",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | ```
Fatal error: Allowed memory size of 33554432 bytes exhausted (tried to allocate ... bytes) in wp-includes/pomo/streams.php on line ...
```
1. Plugins like Super-cashe & Total-cashe don't help.
2. Reducing the number of wordpress plugins and widgets used gives minimal effect.
Can anyone offer solution (except ask... | Try increasing the memory for PHP and Wordpress by editing the memory\_limit line in your php.ini (if you have access to it) to 64M:
`memory_limit = 64M;`
If no php.ini, or add this line at the top of .htaccess file:
`php_value memory_limit 64M`
If that doesn't work, add this line near the top of your wp-config.php... |
16,600 | <p>I am getting this error when I try to return the post_title value from my WP_Query: </p>
<pre><code>**Fatal error:** Cannot use object of type WP_Query as array
</code></pre>
<p>Here is the code:</p>
<pre><code>$query = new WP_Query( array( 'meta_key' => 'Old ID', 'meta_value' => $atts['oldid'] ) );
return ... | [
{
"answer_id": 16602,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 4,
"selected": true,
"text": "<p>I'm not sure you understand the logic of <code>WP_Query</code>. Rather than explain in words, here's a code ... | 2011/05/06 | [
"https://wordpress.stackexchange.com/questions/16600",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3564/"
] | I am getting this error when I try to return the post\_title value from my WP\_Query:
```
**Fatal error:** Cannot use object of type WP_Query as array
```
Here is the code:
```
$query = new WP_Query( array( 'meta_key' => 'Old ID', 'meta_value' => $atts['oldid'] ) );
return $query['post_title'];
```
How can I sho... | I'm not sure you understand the logic of `WP_Query`. Rather than explain in words, here's a code example;
```
$query = new WP_Query( array( 'meta_key' => 'Old ID', 'meta_value' => $atts['oldid'] ) );
if ( $query->have_posts() )
return $query->posts[0]->post_title;
return '';
```
Check out [the codex on interact... |
16,613 | <p>I'm building a site for a magazine using WP and am needing to display a month of posts at a time.</p>
<p><strong>How would I make the next_posts_link(); and previous_posts_link(); functions return results, shorted as one month per page?</strong></p>
<p>If I can't do it via those functions, how would I make the fro... | [
{
"answer_id": 16615,
"author": "Nina",
"author_id": 5175,
"author_profile": "https://wordpress.stackexchange.com/users/5175",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure if this is what you're looking for; however, this may help out.</p>\n\n<pre><code><?php\n foreach (... | 2011/05/06 | [
"https://wordpress.stackexchange.com/questions/16613",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1682/"
] | I'm building a site for a magazine using WP and am needing to display a month of posts at a time.
**How would I make the next\_posts\_link(); and previous\_posts\_link(); functions return results, shorted as one month per page?**
If I can't do it via those functions, how would I make the front page display in an arch... | You have to modify the query that selects the posts to select by month. This bit of code placed in the template will get the page number and subtract that from the current month.
```
<?php
$page = get_query_var('paged') ? get_query_var('paged') : 1;
$subtractor = $page-1;
$date = date("Y-m-d H:i:s");
$current_month =... |
16,614 | <p>I have the latest, version 3.1.2 and have multisite installed. I have debug on true for testing purposes. I get the follow error when I install plugins.</p>
<p>Where and how do I fix this?</p>
<blockquote>
<p>Error:
Notice: has_cap was called with an argument that is deprecated since version 2.0! Usage of user... | [
{
"answer_id": 16619,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>You are fine , its the plugins who are bad!\nsome plugins have not been updated and are still using User leve... | 2011/05/06 | [
"https://wordpress.stackexchange.com/questions/16614",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5182/"
] | I have the latest, version 3.1.2 and have multisite installed. I have debug on true for testing purposes. I get the follow error when I install plugins.
Where and how do I fix this?
>
> Error:
> Notice: has\_cap was called with an argument that is deprecated since version 2.0! Usage of user levels by plugins and th... | You are fine , its the plugins who are bad!
some plugins have not been updated and are still using User level as capability when adding menu pages instead of capability, for example
```
10 = manage_options = admin
```
take a look at [this thread](http://wordpress.org/support/topic/has_cap-was-called-with-an-argumen... |
16,616 | <p>I need a loop/plugin/widget to display latest posts from the category the user is browsing and at the same time if he visits the home page, it should show posts from all categories (not a specific one)</p>
<p>Any Ideas ???</p>
| [
{
"answer_id": 16618,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>here is a quick one: (edit: I updated some forgotten punctuation).</p>\n\n<pre><code><?php\n/*\nPlugin Nam... | 2011/05/07 | [
"https://wordpress.stackexchange.com/questions/16616",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5184/"
] | I need a loop/plugin/widget to display latest posts from the category the user is browsing and at the same time if he visits the home page, it should show posts from all categories (not a specific one)
Any Ideas ??? | here is a quick one: (edit: I updated some forgotten punctuation).
```
<?php
/*
Plugin Name: Recent posts per category loop
Plugin URI: http://en.bainternet.info
Description: answer to http://wordpress.stackexchange.com/questions/16616/recent-posts-per-category-loop
Author: Bainternet
Version: 1.0
Author URI: http://... |
16,624 | <p>I'm making a custom activity calendar for a client here: <a href="http://arbeidshesten.com/aktivitetskalender/" rel="nofollow">http://arbeidshesten.com/aktivitetskalender/</a></p>
<p>The backend is a custom post type "aktiviteter", with custom fields for the date ("dato") and some more details.</p>
<p>The code loo... | [
{
"answer_id": 16639,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": true,
"text": "<p>Adding function to hooks is runtime operation, it is not persistent. Whatever hook operation you run in Ajax actions ... | 2011/05/07 | [
"https://wordpress.stackexchange.com/questions/16624",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2721/"
] | I'm making a custom activity calendar for a client here: <http://arbeidshesten.com/aktivitetskalender/>
The backend is a custom post type "aktiviteter", with custom fields for the date ("dato") and some more details.
The code looks like this:
```
<table>
<tr>
<th>Aktivitet</th>
<th>Sted</th>
<th>Dato</th>
<th>konta... | Adding function to hooks is runtime operation, it is not persistent. Whatever hook operation you run in Ajax actions - they are performed in separate WP instance and expire as soon as Ajax response is returned. They have no influence on currently loaded page.
You probably need to hook your functionality to `save_post`... |
16,665 | <p>Im looking a way to change the following HTML:</p>
<pre><code><div class="votes">Rating: <strong>+5</strong> (from 5 votes)</div>
</code></pre>
<p>and produce:</p>
<pre><code><div class="votes"><div class="calculated-rating">+5</div></div>
</code></pre>
<p>Thanks i... | [
{
"answer_id": 16666,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<pre><code><script type=\"text/javascript\">\njQuery(document).ready(function(){\n jQuery('.votes').each(funct... | 2011/05/08 | [
"https://wordpress.stackexchange.com/questions/16665",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2011/"
] | Im looking a way to change the following HTML:
```
<div class="votes">Rating: <strong>+5</strong> (from 5 votes)</div>
```
and produce:
```
<div class="votes"><div class="calculated-rating">+5</div></div>
```
Thanks in advance. | ```
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('.votes').each(function(){
votes = jQuery('strong',this).html();
jQuery(this).html('<div class="calculated-rating">'+votes+'</div>');
});
});
</script>
``` |
16,673 | <p>Hey guys,
My WordPress permalink structure is set to `/%postname%/.</p>
<p>When I create a page with a name "FAQs" the permalink generated is "mydomain.com/faqs".</p>
<p>When I link to this page in my code (hardcoded) like this...</p>
<p><code><a href="<?php bloginfo('home'); ?>/faqs#b" title="FAQ's">... | [
{
"answer_id": 16666,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<pre><code><script type=\"text/javascript\">\njQuery(document).ready(function(){\n jQuery('.votes').each(funct... | 2011/05/08 | [
"https://wordpress.stackexchange.com/questions/16673",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3529/"
] | Hey guys,
My WordPress permalink structure is set to `/%postname%/.
When I create a page with a name "FAQs" the permalink generated is "mydomain.com/faqs".
When I link to this page in my code (hardcoded) like this...
`<a href="<?php bloginfo('home'); ?>/faqs#b" title="FAQ's">FAQs</a>` (pay attention to the #b hash a... | ```
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('.votes').each(function(){
votes = jQuery('strong',this).html();
jQuery(this).html('<div class="calculated-rating">'+votes+'</div>');
});
});
</script>
``` |
16,675 | <p>My site is reaching CPU limits all the time, I just ran Debug Queries and got more than 4000 queries, no wonder site is slow. </p>
| [
{
"answer_id": 16666,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<pre><code><script type=\"text/javascript\">\njQuery(document).ready(function(){\n jQuery('.votes').each(funct... | 2011/05/08 | [
"https://wordpress.stackexchange.com/questions/16675",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5213/"
] | My site is reaching CPU limits all the time, I just ran Debug Queries and got more than 4000 queries, no wonder site is slow. | ```
<script type="text/javascript">
jQuery(document).ready(function(){
jQuery('.votes').each(function(){
votes = jQuery('strong',this).html();
jQuery(this).html('<div class="calculated-rating">'+votes+'</div>');
});
});
</script>
``` |
16,676 | <p>I'm using the plugin <a href="http://wealthynetizen.com/comment-rating-pro/" rel="nofollow">comments rating</a> (thumbs up - thumbs down) on my comments template.
It stores "karma" in the db column "comment_karma" in comments table.
I am looking for a way to sort wp_list_comments by higher karma to lowest. </p>
<... | [
{
"answer_id": 16680,
"author": "MartinJJ",
"author_id": 3710,
"author_profile": "https://wordpress.stackexchange.com/users/3710",
"pm_score": 4,
"selected": true,
"text": "<p>Just incase if you have not checked out the <a href=\"http://wealthynetizen.com/comment-rating-pro/\" rel=\"nofo... | 2011/05/08 | [
"https://wordpress.stackexchange.com/questions/16676",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2119/"
] | I'm using the plugin [comments rating](http://wealthynetizen.com/comment-rating-pro/) (thumbs up - thumbs down) on my comments template.
It stores "karma" in the db column "comment\_karma" in comments table.
I am looking for a way to sort wp\_list\_comments by higher karma to lowest.
Have tried something like
```
... | Just incase if you have not checked out the [**plugin developers page**](http://wealthynetizen.com/comment-rating-pro/) but heres something that you could try
```
if (function_exists(ckrating_get_comments)) {
$post_id = $post->ID;
$mycomments = ckrating_get_comments(
"post_id=$post_id&status=approve&
orderby=comment_k... |
16,708 | <p>I created an option panel following a tutorial.</p>
<p>But each time I try to save the settings I get the following:</p>
<blockquote>
<p>You do not have sufficient permissions to access this page.</p>
</blockquote>
<p>Any suggestions to fix this?</p>
<p><em>(Not sure if this helps but I'm using Wordpress 3.1.2... | [
{
"answer_id": 16710,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": true,
"text": "<p>You're adding the menu page using the \"administrator\" role. Is the account you're using an administrator?<... | 2011/05/09 | [
"https://wordpress.stackexchange.com/questions/16708",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/781/"
] | I created an option panel following a tutorial.
But each time I try to save the settings I get the following:
>
> You do not have sufficient permissions to access this page.
>
>
>
Any suggestions to fix this?
*(Not sure if this helps but I'm using Wordpress 3.1.2)*
**EDIT:**
I don't have the permission issue ... | You're adding the menu page using the "administrator" role. Is the account you're using an administrator?
Note:
1) You should be using an appropriate *capability*, rather than a *user role*. Generally, the appropriate capability for editing Theme options is `edit_theme_options`.
2) There is a known bug with WordPres... |
16,709 | <p>I'm working on a project in which I'm creating a custom post type and custom data entered via meta boxes associated with my custom post type. For whatever reason I decided to code the meta boxes in such a way that the inputs in each metabox are part of an array. For instance, I'm storing longitude and latitude:</p>
... | [
{
"answer_id": 17081,
"author": "user4356",
"author_id": 4356,
"author_profile": "https://wordpress.stackexchange.com/users/4356",
"pm_score": -1,
"selected": false,
"text": "<p>I have the same question. Maybe you need the 'type' parameter? Check out this related question: \n<a href=\"ht... | 2011/05/09 | [
"https://wordpress.stackexchange.com/questions/16709",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4850/"
] | I'm working on a project in which I'm creating a custom post type and custom data entered via meta boxes associated with my custom post type. For whatever reason I decided to code the meta boxes in such a way that the inputs in each metabox are part of an array. For instance, I'm storing longitude and latitude:
```
<p... | **No, it is not possible, and could even be dangerous.**
There is no reliable way to do this without encountering gotchas and pitfalls such as a search for `10` matching `100` or `210`, or matching the wrong sub-value etc. Such solutions are unreliable and have performance and security issues.
Serialised data is an a... |
16,714 | <p>I thought about adding it as inline CSS with code from the <code>functions.php</code>
(not really sure how to do it).</p>
<p>Something like this:</p>
<pre><code>function addcss() {
background: $this_is_the_css_value;
}
</code></pre>
<p>I would like to know that. But if there's is a better option (without addin... | [
{
"answer_id": 17081,
"author": "user4356",
"author_id": 4356,
"author_profile": "https://wordpress.stackexchange.com/users/4356",
"pm_score": -1,
"selected": false,
"text": "<p>I have the same question. Maybe you need the 'type' parameter? Check out this related question: \n<a href=\"ht... | 2011/05/09 | [
"https://wordpress.stackexchange.com/questions/16714",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/781/"
] | I thought about adding it as inline CSS with code from the `functions.php`
(not really sure how to do it).
Something like this:
```
function addcss() {
background: $this_is_the_css_value;
}
```
I would like to know that. But if there's is a better option (without adding inline CSS). I would like to know it too. | **No, it is not possible, and could even be dangerous.**
There is no reliable way to do this without encountering gotchas and pitfalls such as a search for `10` matching `100` or `210`, or matching the wrong sub-value etc. Such solutions are unreliable and have performance and security issues.
Serialised data is an a... |
16,716 | <p>I am using WP 3.0.3 and I would like to exclude sticky posts from my query:</p>
<p>This doesn't seem to work:</p>
<pre><code><?php query_posts( 'posts_per_page=9&cat=-1,-2&ignore_sticky_posts=1' );?>
</code></pre>
<p>To get JUST the sticky post I use the following:</p>
<pre><code>$sticky = get_opti... | [
{
"answer_id": 16717,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 2,
"selected": false,
"text": "<p>Have you tried using</p>\n\n<pre><code>query_posts( array( 'post__not_in' => get_option( 'sticky_posts' ) ) );\n... | 2011/05/09 | [
"https://wordpress.stackexchange.com/questions/16716",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2313/"
] | I am using WP 3.0.3 and I would like to exclude sticky posts from my query:
This doesn't seem to work:
```
<?php query_posts( 'posts_per_page=9&cat=-1,-2&ignore_sticky_posts=1' );?>
```
To get JUST the sticky post I use the following:
```
$sticky = get_option('sticky_posts');
$args = array(
'posts_per_page' =>... | `ignore_sticky_posts` was introduced in WordPress 3.1. Before this version, you can use `caller_get_posts`, which will have the same effect (this option was used when you queried the posts via `get_posts()`, which uses the same `WP_Query` class in the background, but should ignore sticky posts). The name was a bit conf... |
16,723 | <p>The posts on our music blog usually include multiple tracks of music. </p>
<p>I want to have each individual track be its own entity--a custom post type called <em>"track"</em>--which I want to be able to insert freely into a post where I wish using a shortcode.</p>
<p>The image below explains pretty well what I a... | [
{
"answer_id": 16732,
"author": "mattl",
"author_id": 5158,
"author_profile": "https://wordpress.stackexchange.com/users/5158",
"pm_score": 0,
"selected": false,
"text": "<p>You have two issues here I think. </p>\n\n<p>1 - Making a short code. <a href=\"http://net.tutsplus.com/tutorials/... | 2011/05/09 | [
"https://wordpress.stackexchange.com/questions/16723",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5231/"
] | The posts on our music blog usually include multiple tracks of music.
I want to have each individual track be its own entity--a custom post type called *"track"*--which I want to be able to insert freely into a post where I wish using a shortcode.
The image below explains pretty well what I am looking to do.
(Link ... | I would suggest creating a new custom taxonomy for relations between a post and its "tracks" or grouping of track posts if you'd like
that way you can easily create a shortcode that will query all the needed tracks at once using a shortcode instead of calling your shortcode over and over and to order them you can creat... |
16,733 | <p>I used the <em>comment meta</em> to add a simple <strong>rating</strong> system. The user can post a rate from the comment form from where I added 3 dropdown comment meta. </p>
<p>The rating is working well, reflecting the ratings together with the comment written by the user. My only problem now is this: how can I... | [
{
"answer_id": 16754,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>This is a solution which will display the average <em>after</em> the last comment. As a workaround you could simply... | 2011/05/09 | [
"https://wordpress.stackexchange.com/questions/16733",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5233/"
] | I used the *comment meta* to add a simple **rating** system. The user can post a rate from the comment form from where I added 3 dropdown comment meta.
The rating is working well, reflecting the ratings together with the comment written by the user. My only problem now is this: how can I get the average of all the ra... | If you need to show the averages in the content, you need to pre-calculate them (before showing the comments).
My approach would be having a custom meta in the post with the calculated averages and modify those metas every time a new comment (rating) is saved.
Something like
```
add_action("comment_post", "wpse167... |
16,760 | <p>My Wordpress site uses a custom front page (<code>home.php</code>). The blog page uses a template (<code>blog.php</code>).</p>
<p>However when I visit the blog page the navigation bar does not highligt the current page. This is because the class <code>.current-menu-item</code> (and the class <code>.current_page_ite... | [
{
"answer_id": 16764,
"author": "anu",
"author_id": 490,
"author_profile": "https://wordpress.stackexchange.com/users/490",
"pm_score": 3,
"selected": true,
"text": "<ul>\n<li>Go to Appearance > Menu</li>\n<li>click screen options (near top of page)</li>\n<li>tick \"Link target\"</li>\n<... | 2011/05/09 | [
"https://wordpress.stackexchange.com/questions/16760",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5238/"
] | My Wordpress site uses a custom front page (`home.php`). The blog page uses a template (`blog.php`).
However when I visit the blog page the navigation bar does not highligt the current page. This is because the class `.current-menu-item` (and the class `.current_page_item`) are missing from the navigation `li`. This c... | * Go to Appearance > Menu
* click screen options (near top of page)
* tick "Link target"
Now, when you click a menu item drop down, you can choose what the link target is (you want to choose New window or tab) |
16,770 | <p>I have a unique plugin whose purpose is to set up a new WordPress site with a theme, default widgets, default plugins, custom menus, pages, posts, etc.</p>
<p>The plugin does everything it needs to do when activated and never runs again.</p>
<p>I'm looking for suggestions on how I might, as the last step in the ac... | [
{
"answer_id": 16775,
"author": "MZAweb",
"author_id": 5223,
"author_profile": "https://wordpress.stackexchange.com/users/5223",
"pm_score": 3,
"selected": true,
"text": "<p>You can deactivate it with:</p>\n\n<pre><code>deactivate_plugins( basename( __FILE__ ) );\n</code></pre>\n\n<p>I d... | 2011/05/09 | [
"https://wordpress.stackexchange.com/questions/16770",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/366/"
] | I have a unique plugin whose purpose is to set up a new WordPress site with a theme, default widgets, default plugins, custom menus, pages, posts, etc.
The plugin does everything it needs to do when activated and never runs again.
I'm looking for suggestions on how I might, as the last step in the activation routine,... | You can deactivate it with:
```
deactivate_plugins( basename( __FILE__ ) );
```
I don't think you can delete it. It would be a big security risk, IMO. But if the folder has the correct (but insecure) permissions, you could use the PHP function [rmdir](http://php.net/manual/en/function.rmdir.php) |
16,777 | <p>Is it really neccessary to put <code>WP_HOME</code>, <code>WP_SITEURL</code> in <code>wp-config.php</code> or set these settings via admin panel every time when moving a WordPress instance to another url (for example: moving from dev environment to production)? Is there any better strategy?</p>
| [
{
"answer_id": 16778,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>You could put those settings in an external file and exclude it from your publishing process.</p>\n"
},
{
... | 2011/05/09 | [
"https://wordpress.stackexchange.com/questions/16777",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5968/"
] | Is it really neccessary to put `WP_HOME`, `WP_SITEURL` in `wp-config.php` or set these settings via admin panel every time when moving a WordPress instance to another url (for example: moving from dev environment to production)? Is there any better strategy? | Those parameters and admin settings change the URLs in the database. The only other way to do that is run SQL queries on the DB in phpmyadmin to change them:
```
UPDATE wp_options SET option_value = replace(option_value, 'http://olddomain.com', 'http://newdomain.com') WHERE option_name = 'home' OR option_name = 'siteu... |
16,791 | <p>I have been trying to find a way to return page information in order to create a landing page. I have done this with posts before, to create a blog reel, and would like to achieve the same overall result with pages.</p>
<p><strong>The Scenario:</strong>
I use a drop menu with pages created in the WordPress. Nesting... | [
{
"answer_id": 16859,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": true,
"text": "<p>Two suggestions:</p>\n\n<ol>\n<li>To output your \"Loop\" only for Child Pages, and not for Grandchild etc. ... | 2011/05/09 | [
"https://wordpress.stackexchange.com/questions/16791",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5264/"
] | I have been trying to find a way to return page information in order to create a landing page. I have done this with posts before, to create a blog reel, and would like to achieve the same overall result with pages.
**The Scenario:**
I use a drop menu with pages created in the WordPress. Nesting the pages builds the m... | Two suggestions:
1. To output your "Loop" only for Child Pages, and not for Grandchild etc. Pages, add a conditional.
e.g.
```
foreach ( $mypages as $page ) {
if ( $page->post_parent == $post->ID ) {
// Loop goes here
}
}
```
1. To output only an excerpt of each Child Page, enable excerpt suppo... |