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 |
|---|---|---|---|---|---|---|
76,617 | <p>I have rules that only work on paginated pages (is_paged). However, they don't work on page number one (/page/1). This one is behaving exactly like the homepage (!is_paged), but unlike pages 2,3,4 etc. I want to prevent page 1 from behaving like the homepage and have it behave just like any other page.</p>
<pre><co... | [
{
"answer_id": 76623,
"author": "Michael",
"author_id": 4884,
"author_profile": "https://wordpress.stackexchange.com/users/4884",
"pm_score": 1,
"selected": false,
"text": "<p>do you mean you want a conditional for page 1 of all home queries which have more than one page as result?</p>\n... | 2012/12/19 | [
"https://wordpress.stackexchange.com/questions/76617",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I have rules that only work on paginated pages (is\_paged). However, they don't work on page number one (/page/1). This one is behaving exactly like the homepage (!is\_paged), but unlike pages 2,3,4 etc. I want to prevent page 1 from behaving like the homepage and have it behave just like any other page.
```
if (strpo... | EDIT - SOLVED: OK, so for whoever else looks for this, I found a workaround that is actually quite straightforward: on the paged.php template, set a variable such as $paged = true, than instead of !(is\_paged()) use !($paged). |
76,618 | <p>How can you edit the labels of the <code>wp-login.php</code> form?</p>
<p>I am using emails for logins, so I need to change <code>username</code> to <code>email</code>.</p>
<p>The answer here seems to be out of date, or just doesn't work with SSL or something: <a href="https://wordpress.stackexchange.com/questions... | [
{
"answer_id": 76619,
"author": "Kyle",
"author_id": 18066,
"author_profile": "https://wordpress.stackexchange.com/users/18066",
"pm_score": 2,
"selected": false,
"text": "<p>Found an answer on stackoverflow shortly after posting this:</p>\n\n<p><a href=\"https://stackoverflow.com/questi... | 2012/12/19 | [
"https://wordpress.stackexchange.com/questions/76618",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18066/"
] | How can you edit the labels of the `wp-login.php` form?
I am using emails for logins, so I need to change `username` to `email`.
The answer here seems to be out of date, or just doesn't work with SSL or something: [Function to change a label (Username) in a core WordPress File (wp-includes/general-template.php)](http... | Found an answer on stackoverflow shortly after posting this:
<https://stackoverflow.com/questions/12825865/change-wordpresss-login-label-username>
Uses the gettext filter instead of any wp functions |
76,620 | <p>I'm using <code>pre_get_posts</code> to adjust the number of posts displayed on my homepage. </p>
<pre><code>function lifelounge_query_adjust( $query ) {
if ( is_home() ) {
set_query_var( 'posts_per_page', 12 );
return;
}
}
add_filter( 'pre_get_posts', 'lifelounge_query_adjust' );
</code></... | [
{
"answer_id": 76639,
"author": "Ahmad M",
"author_id": 12961,
"author_profile": "https://wordpress.stackexchange.com/users/12961",
"pm_score": 5,
"selected": true,
"text": "<p>Here is an approach to account for sticky posts by getting the number of sticky posts (if any) and include that... | 2012/12/19 | [
"https://wordpress.stackexchange.com/questions/76620",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6477/"
] | I'm using `pre_get_posts` to adjust the number of posts displayed on my homepage.
```
function lifelounge_query_adjust( $query ) {
if ( is_home() ) {
set_query_var( 'posts_per_page', 12 );
return;
}
}
add_filter( 'pre_get_posts', 'lifelounge_query_adjust' );
```
But I am running into a probl... | Here is an approach to account for sticky posts by getting the number of sticky posts (if any) and include that in the calculation `posts_per_page` parameter:
```
add_action('pre_get_posts', 'ad_custom_query');
function ad_custom_query($query) {
if ($query->is_main_query() && is_home()) {
// set the numb... |
76,622 | <p>I see that it is possible to sort a user query by the number of posts each user has, but is it possible to exclude users with zero posts from the result? In the Wp_User_Query class there is a <code>pre_user_query</code> action, but query strings are a huge weak point, so I'm not sure what sort of filter action I'd ... | [
{
"answer_id": 76631,
"author": "GhostToast",
"author_id": 13676,
"author_profile": "https://wordpress.stackexchange.com/users/13676",
"pm_score": 0,
"selected": false,
"text": "<p>Submitting as answer for closure:</p>\n\n<pre><code> $all_members = get_users();\n foreach($all_memb... | 2012/12/19 | [
"https://wordpress.stackexchange.com/questions/76622",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6477/"
] | I see that it is possible to sort a user query by the number of posts each user has, but is it possible to exclude users with zero posts from the result? In the Wp\_User\_Query class there is a `pre_user_query` action, but query strings are a huge weak point, so I'm not sure what sort of filter action I'd want to use h... | Well I have come up with 2 solutions.
**Solution 1 - foreach loop and verify each user**
This one is based off of @GhostToast's solution, but with updated WordPress functions
```
//new query with default args
$author_query = new WP_User_Query();
// Get the results
$authors = $author_query->get_results();
if( $aut... |
76,649 | <p>I have a page where I'm pulling in content from another post, outside of the loop.</p>
<p>I've been successfull at getting the content of the specified post, but I cannot get the image from a custom field (advanced custom image field).</p>
<p>This is working to get the content from the post who's ID is 299:</p>
<... | [
{
"answer_id": 76651,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": true,
"text": "<p>see documentation for <a href=\"http://www.advancedcustomfields.com/docs/functions/get_field/\" rel=\"nofollow\"><co... | 2012/12/19 | [
"https://wordpress.stackexchange.com/questions/76649",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22688/"
] | I have a page where I'm pulling in content from another post, outside of the loop.
I've been successfull at getting the content of the specified post, but I cannot get the image from a custom field (advanced custom image field).
This is working to get the content from the post who's ID is 299:
```
$my_id = 299;
$pos... | see documentation for [`get_field`](http://www.advancedcustomfields.com/docs/functions/get_field/). change:
```
$attachment_id = get_field('image');
```
to pass the post ID as second argument:
```
$attachment_id = get_field('image', 299);
```
or:
```
$attachment_id = get_field('image', $my_id);
``` |
76,666 | <p>I want to make a specific page unsearchable. I don't want it's text to show up when i'm searching some text in the search box (on the sidebar on most themes).</p>
| [
{
"answer_id": 76670,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<pre><code>function hide_from_search($qry) {\n if (is_search()) $qry->query_vars['post__not_in'][] = xXx;\n ... | 2012/12/19 | [
"https://wordpress.stackexchange.com/questions/76666",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25035/"
] | I want to make a specific page unsearchable. I don't want it's text to show up when i'm searching some text in the search box (on the sidebar on most themes). | ```
function hide_from_search($qry) {
if (is_search()) $qry->query_vars['post__not_in'][] = xXx;
return $qry;
}
add_filter('pre_get_posts','hide_from_search');
```
The xXx is the ID number of the page to exclude. Just read it out of the URL on the backend. When you are editing the page you want to exclude look at... |
76,685 | <p>I have a custom taxonomy, <em>artist</em>, that is related to three custom post types: <em>videos</em>, <em>posts</em> and <em>letters</em>. I have an <code>taxonomy-artist.php</code> template that should display the archive for a given artist.</p>
<p>When I visit <code>/artist/ARTIST_NAME</code> it will display th... | [
{
"answer_id": 76689,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 1,
"selected": false,
"text": "<p>Taxonomy archive index pages for custom taxonomies are not rendered using <code>archive-{taxonomy}.php</cod... | 2012/12/20 | [
"https://wordpress.stackexchange.com/questions/76685",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7651/"
] | I have a custom taxonomy, *artist*, that is related to three custom post types: *videos*, *posts* and *letters*. I have an `taxonomy-artist.php` template that should display the archive for a given artist.
When I visit `/artist/ARTIST_NAME` it will display the taxonomy archive template *only if there are no other post... | Taxonomy archive index pages for custom taxonomies are not rendered using `archive-{taxonomy}.php`, but rather, using `taxonomy-{taxonomy}-{term}.php`, which falls back to `taxonomy-{taxonomy}.php`, which falls back to `taxonomy.php`. [Refer to the Template Hierarchy](http://codex.wordpress.org/Template_Hierarchy#Custo... |
76,695 | <p>I have a working front end posting system on my site that initially I designed with a simple text area for the content. I am now attempting to swap the textarea out with the TinyMCE function, wp_editor. I can easily get the editor to display and function properly, but on the submission of the form, the content is sa... | [
{
"answer_id": 76707,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 2,
"selected": false,
"text": "<p>Check with a array for the settings - <code>$settings</code> (array) (optional) An array of arguments. - on the fu... | 2012/12/20 | [
"https://wordpress.stackexchange.com/questions/76695",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23492/"
] | I have a working front end posting system on my site that initially I designed with a simple text area for the content. I am now attempting to swap the textarea out with the TinyMCE function, wp\_editor. I can easily get the editor to display and function properly, but on the submission of the form, the content is save... | Check with a array for the settings - `$settings` (array) (optional) An array of arguments. - on the function `wp_editor`.
```
wp_editor(
$post_obj->post_content,
'userpostcontent',
array( 'textarea_name' => 'user_post_content' )
)
``` |
76,700 | <p>I am building a theme and I need to call theme options
But I do get errors like white screen and 500 internal server error when I call theme options here </p>
<p>In WP query (newbie in PHP) </p>
<pre><code> <?query_posts ('meta_key=post_views_count&orderby=meta_value_num&order=DESC&meta_value=get_o... | [
{
"answer_id": 76705,
"author": "Mike Madern",
"author_id": 24806,
"author_profile": "https://wordpress.stackexchange.com/users/24806",
"pm_score": 4,
"selected": true,
"text": "<p>First, change your code into the following:</p>\n\n<pre><code>$value = get_option( 'mytheme_value' );\nquer... | 2012/12/20 | [
"https://wordpress.stackexchange.com/questions/76700",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22975/"
] | I am building a theme and I need to call theme options
But I do get errors like white screen and 500 internal server error when I call theme options here
In WP query (newbie in PHP)
```
<?query_posts ('meta_key=post_views_count&orderby=meta_value_num&order=DESC&meta_value=get_option(mytheme_value);');?>
```
Als... | First, change your code into the following:
```
$value = get_option( 'mytheme_value' );
query_posts ( "meta_key=post_views_count&orderby=meta_value_num&order=DESC&meta_value={$value}");
```
When you use single quotation marks, php isn't parsed in the string, and functions (like `get_option`) will never be called fro... |
76,712 | <p>I have a custom page on my blog that doesn't display <a href="http://www.slashgeek.net/geekshop/" rel="nofollow">RSS feed</a>. You can see the <a href="http://pastebin.com/VtjD1SAH" rel="nofollow">code here</a> for the custom page. I am not sure what I need to do to make rss feed for each individual post on that pag... | [
{
"answer_id": 76716,
"author": "dbeja",
"author_id": 9585,
"author_profile": "https://wordpress.stackexchange.com/users/9585",
"pm_score": 3,
"selected": true,
"text": "<p>You can create your own feeds in wordpress.</p>\n\n<p>Add this to functions.php:</p>\n\n<pre><code>function my_cust... | 2012/12/20 | [
"https://wordpress.stackexchange.com/questions/76712",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1264/"
] | I have a custom page on my blog that doesn't display [RSS feed](http://www.slashgeek.net/geekshop/). You can see the [code here](http://pastebin.com/VtjD1SAH) for the custom page. I am not sure what I need to do to make rss feed for each individual post on that page. I am not much in php myself so any help is appreciat... | You can create your own feeds in wordpress.
Add this to functions.php:
```
function my_customfeed() {
load_template( TEMPLATEPATH . 'your-customfeed.php');
}
add_action('do_feed_customfeed', 'my_customfeed', 10, 1);
```
This will enable a new feed called customfeed.
Now you can create your-customfeed.php in your t... |
76,720 | <p>WordPress 3.5 changed the media management and now the Media Library edit screen uses the default post type UI. Taxonomies are very useful for WP installs with different users and attachments, giving more possibilities to find the attachment and/or add classification.</p>
<p>I have seen <a href="https://wordpress.s... | [
{
"answer_id": 76721,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 5,
"selected": true,
"text": "<p>To add the taxonmies from post type post, the default, then it is easy to add taxonmies 'category' and 'tags' with ... | 2012/12/20 | [
"https://wordpress.stackexchange.com/questions/76720",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/170/"
] | WordPress 3.5 changed the media management and now the Media Library edit screen uses the default post type UI. Taxonomies are very useful for WP installs with different users and attachments, giving more possibilities to find the attachment and/or add classification.
I have seen [Can I add a Category Metabox to attac... | To add the taxonmies from post type post, the default, then it is easy to add taxonmies 'category' and 'tags' with a small plugin liek the source below.
```
<?php
/**
* Plugin Name: Attachment Taxonomies
* Plugin URI:
* Text Domain: attachment_taxonomies
* Domain Path: /languages
* Description:
* Version: ... |
76,738 | <p>What I need is some function to echo file name of image used in post like "image-file-name.jpg", or just "image-file-name".</p>
<p>Also it would be great to be able to have even more information about image like:</p>
<ul>
<li>image width, </li>
<li>image height, </li>
<li>image mime type / format, </li>
<li>image ... | [
{
"answer_id": 76743,
"author": "Karan",
"author_id": 17482,
"author_profile": "https://wordpress.stackexchange.com/users/17482",
"pm_score": 0,
"selected": false,
"text": "<p>If you have declare every field of image in custom field. Use following code for getting all post custom feild d... | 2012/12/20 | [
"https://wordpress.stackexchange.com/questions/76738",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25053/"
] | What I need is some function to echo file name of image used in post like "image-file-name.jpg", or just "image-file-name".
Also it would be great to be able to have even more information about image like:
* image width,
* image height,
* image mime type / format,
* image file size,
* image extension.
Also this may ... | You can get the file from your Url like this:
```
//get the URL from your Metafield, $post is your current Post
$image = get_post_meta( $post->ID, '_your_image_url_meta', true );
//set up a query to search your posts table for the Url
global $wpdb;
$query = "SELECT ID FROM $wpdb->posts WHERE guid = %s LIMIT ... |
76,742 | <p>how to get results of a row with NULL element?
I have to update the row which contains only the post_id and the repeat value, 'start' and 'end' should be NULL</p>
<p>mysql table screenshot: <a href="https://i.imgur.com/l27is.png" rel="nofollow noreferrer">http://i.imgur.com/l27is.png</a></p>
<pre><code>$wpdb->u... | [
{
"answer_id": 76844,
"author": "Paul Geisler",
"author_id": 10590,
"author_profile": "https://wordpress.stackexchange.com/users/10590",
"pm_score": 3,
"selected": true,
"text": "<p>My simple and quick solution is the use of a normal $wpdb->query() function:</p>\n\n<pre><code>$wpdb->q... | 2012/12/20 | [
"https://wordpress.stackexchange.com/questions/76742",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10590/"
] | how to get results of a row with NULL element?
I have to update the row which contains only the post\_id and the repeat value, 'start' and 'end' should be NULL
mysql table screenshot: [http://i.imgur.com/l27is.png](https://i.imgur.com/l27is.png)
```
$wpdb->update( $schedule_table, array( 'rpt' => $event_tag ), array(... | My simple and quick solution is the use of a normal $wpdb->query() function:
```
$wpdb->query( $wpdb->prepare("UPDATE $schedule_table SET rpt = %s WHERE post_id = %d AND start IS NULL AND end IS NULL", $event_tag, $post_ID ) );
``` |
76,755 | <p>I am trying to make it so that WP will create another size image for me, but only when the image is uploaded via the Thickbox, and only when it will be attached to a certain ID.</p>
<p>Does anybody know how to do this?</p>
<p>The following works, but will create an image of that size for every upload, which is jus... | [
{
"answer_id": 76844,
"author": "Paul Geisler",
"author_id": 10590,
"author_profile": "https://wordpress.stackexchange.com/users/10590",
"pm_score": 3,
"selected": true,
"text": "<p>My simple and quick solution is the use of a normal $wpdb->query() function:</p>\n\n<pre><code>$wpdb->q... | 2012/12/20 | [
"https://wordpress.stackexchange.com/questions/76755",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10097/"
] | I am trying to make it so that WP will create another size image for me, but only when the image is uploaded via the Thickbox, and only when it will be attached to a certain ID.
Does anybody know how to do this?
The following works, but will create an image of that size for every upload, which is just inefficient.
`... | My simple and quick solution is the use of a normal $wpdb->query() function:
```
$wpdb->query( $wpdb->prepare("UPDATE $schedule_table SET rpt = %s WHERE post_id = %d AND start IS NULL AND end IS NULL", $event_tag, $post_ID ) );
``` |
76,760 | <p>I'm trying to figure out how to find the actual function that's assigned to hooks and filters.</p>
<p>I've been looking at other questions asked here and found a couple plugins that are helpful for findings the add_actions and add_filters that show me the callback function name... but I'm having a hard time finding... | [
{
"answer_id": 77062,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>There are several things you can do.</p>\n\n<p>Google or <a href=\"http://codex.wordpress.org/Main_Page\" rel... | 2012/12/20 | [
"https://wordpress.stackexchange.com/questions/76760",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23126/"
] | I'm trying to figure out how to find the actual function that's assigned to hooks and filters.
I've been looking at other questions asked here and found a couple plugins that are helpful for findings the add\_actions and add\_filters that show me the callback function name... but I'm having a hard time finding that ac... | This is more of *PHP programming* question, rather than *WordPress* one. :)
If you are interested in exploring function of WordPress core alone, there is number of ways dedicated to that:
* Codex has [function reference](http://codex.wordpress.org/Function_Reference) that is human maintained - so it's not comprehensi... |
76,762 | <p>I'm currently working on a test website on my local server using WordPress version 3.4.2. I've tried various different solutions. Some have included installing various plugins, such as WP RSS Images and Featured Image in RSS. Even tried some of the solutions from the following posts:</p>
<ul>
<li><a href="https://w... | [
{
"answer_id": 76879,
"author": "swtshweta",
"author_id": 14123,
"author_profile": "https://wordpress.stackexchange.com/users/14123",
"pm_score": 0,
"selected": false,
"text": "<p>Strange none of the links above doesn't work for you. </p>\n\n<p>You can try this using Custom RSS Feed meth... | 2012/12/20 | [
"https://wordpress.stackexchange.com/questions/76762",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20870/"
] | I'm currently working on a test website on my local server using WordPress version 3.4.2. I've tried various different solutions. Some have included installing various plugins, such as WP RSS Images and Featured Image in RSS. Even tried some of the solutions from the following posts:
* [display featured image in RSS f... | By default, RSS won't display. You have to use RSS2. However this will help you. Paste it in your functions.php:
```
function insert_thumbnail_into_feed() {
global $post;
if ( has_post_thumbnail( $post->ID ) ){
// replace thumbnail with yours
$content = '<p>' .get_the_post_thumbnail( $post->ID, 'thumbnail' ) .... |
76,771 | <p>As an admin I really like the features and functionality of the WordPress 3.5 media manager. </p>
<p>With a multi-user site however all users can see all images in the media library - whether uploaded by them or not. Previously a <code>functions.php</code> script could mask / restrict access.<br>
For example: </p... | [
{
"answer_id": 105465,
"author": "timocouckuyt",
"author_id": 34954,
"author_profile": "https://wordpress.stackexchange.com/users/34954",
"pm_score": 3,
"selected": false,
"text": "<p>To let the current users only view his/her uploaded attachments, add the following code to your themes a... | 2012/12/20 | [
"https://wordpress.stackexchange.com/questions/76771",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25068/"
] | As an admin I really like the features and functionality of the WordPress 3.5 media manager.
With a multi-user site however all users can see all images in the media library - whether uploaded by them or not. Previously a `functions.php` script could mask / restrict access.
For example:
```
// Hide Media Library... | To let the current users only view his/her uploaded attachments, add the following code to your themes actions:
```
add_filter( 'posts_where', 'devplus_wpquery_where' );
function devplus_wpquery_where( $where ){
global $current_user;
if( is_user_logged_in() ){
// logged in user, but are we viewing th... |
76,781 | <p>I'm trying to take existing images and shrink the file size down by resizing to photos to a smaller resolution. I've tried a few methods so far:</p>
<ol>
<li>Simply editing the photo in photoshop and reuploaded, replacing the existing (and larger) file.</li>
<li>I tried the <a href="http://wordpress.org/extend/plug... | [
{
"answer_id": 76787,
"author": "vaibhav",
"author_id": 22975,
"author_profile": "https://wordpress.stackexchange.com/users/22975",
"pm_score": 0,
"selected": false,
"text": "<p>You can use wp-smush it plugin \n<a href=\"http://wordpress.org/extend/plugins/wp-smushit/\" rel=\"nofollow\">... | 2012/12/20 | [
"https://wordpress.stackexchange.com/questions/76781",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23413/"
] | I'm trying to take existing images and shrink the file size down by resizing to photos to a smaller resolution. I've tried a few methods so far:
1. Simply editing the photo in photoshop and reuploaded, replacing the existing (and larger) file.
2. I tried the [Imsanity](http://wordpress.org/extend/plugins/imsanity/) pl... | You can perform a combination of things to accomplish a smaller file size. Let me guide you through it.
Firstly, you could [add custom image sizes](http://codex.wordpress.org/Function_Reference/add_image_size) and adjust the dimensions to the very smallest for their purpose. Put the following in your functions file:
... |
76,802 | <p>I need to redirect a whole WordPress site to a single WordPress page.
A sort of maintenance mode, but the redirect has to go to a published WordPress page. Unfortunately, the maintenance page I need to show has to use other WordPress plugins.</p>
<p>I am not aware of any Maintenance Mode plugin which lets you do t... | [
{
"answer_id": 76807,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 5,
"selected": true,
"text": "<p>You can actually do this from inside WordPress itself, instead of needing to come up with a confusing and overengi... | 2012/12/20 | [
"https://wordpress.stackexchange.com/questions/76802",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I need to redirect a whole WordPress site to a single WordPress page.
A sort of maintenance mode, but the redirect has to go to a published WordPress page. Unfortunately, the maintenance page I need to show has to use other WordPress plugins.
I am not aware of any Maintenance Mode plugin which lets you do this. At mo... | You can actually do this from inside WordPress itself, instead of needing to come up with a confusing and overengineered .htaccess fix.
We can hook into the `template_redirect` filter, which only fires on the front-end (not in wp-admin). We then use the `is_page()` function to check if we're viewing a page with the ID... |
76,832 | <p>Is there any way, out of the box, to sort results from the JSON-API plugin based on values in custom fields? The request is paged, so the results will need to be sorted server-side.</p>
<p>I have an http request along the lines of:</p>
<pre><code>http://www.example.com/wordpress/?json=get_author_posts&author_s... | [
{
"answer_id": 76843,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 2,
"selected": false,
"text": "<p>You can sort via javascript <code>.sort()</code> a json array.</p>\n\n<p>Your example string was also splitable vi... | 2012/12/21 | [
"https://wordpress.stackexchange.com/questions/76832",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25087/"
] | Is there any way, out of the box, to sort results from the JSON-API plugin based on values in custom fields? The request is paged, so the results will need to be sorted server-side.
I have an http request along the lines of:
```
http://www.example.com/wordpress/?json=get_author_posts&author_slug=user&post_type=custom... | Looking through the source code, this plugin maps the query variable `orderby` to the WP\_Query argument of the same name, `orderby`.
What this means is that you should be able to do the following:
`http://www.example.com/wordpress/?json=get_author_posts&author_slug=user&post_type=custom&include=title,custom_fields&cu... |
76,861 | <p>I'm setting up the categories for my website and I have them like so:</p>
<p><img src="https://i.stack.imgur.com/st50L.jpg" alt="Original categories order"></p>
<p>That's it, I have children of the same name but they are not interchangeable. If that bugs you just think that they have different names.</p>
<p>Then ... | [
{
"answer_id": 77278,
"author": "navjotjsingh",
"author_id": 5730,
"author_profile": "https://wordpress.stackexchange.com/users/5730",
"pm_score": 2,
"selected": false,
"text": "<p>I see that you have selected all the parent categories for your post. When you add a new post, the order is... | 2012/12/21 | [
"https://wordpress.stackexchange.com/questions/76861",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20598/"
] | I'm setting up the categories for my website and I have them like so:

That's it, I have children of the same name but they are not interchangeable. If that bugs you just think that they have different names.
Then I go to a post and I want to add categ... | Category-list uses the function [wp\_terms\_checklist()](http://codex.wordpress.org/Function_Reference/wp_terms_checklist) in [wp-admin/includes/template.ph](http://core.trac.wordpress.org/browser/tags/3.5/wp-admin/includes/template.php#L0)p on row 90. The parameter "checked\_ontop" is set to true. So the checked check... |
76,874 | <p>I'm developing a plugin to replace a character for some user agents in titles, posts and comments but the filter doesn't work. Here is the plugin:</p>
<pre><code><?php
/*
Plugin Name: WP-HalfSpace
Description: نمایش فاصله بهجای نیمفاصله برای گوگل برای خرابنشدن نوشته در نتایج جستوجوی گوگل
Version: 1.0.0
Autho... | [
{
"answer_id": 76875,
"author": "Matthew Boynes",
"author_id": 12324,
"author_profile": "https://wordpress.stackexchange.com/users/12324",
"pm_score": 3,
"selected": true,
"text": "<p><code>register_activation_hook</code> and <code>register_deactivation_hook</code> refer to when the plug... | 2012/12/21 | [
"https://wordpress.stackexchange.com/questions/76874",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10968/"
] | I'm developing a plugin to replace a character for some user agents in titles, posts and comments but the filter doesn't work. Here is the plugin:
```
<?php
/*
Plugin Name: WP-HalfSpace
Description: نمایش فاصله بهجای نیمفاصله برای گوگل برای خرابنشدن نوشته در نتایج جستوجوی گوگل
Version: 1.0.0
Author: ahmadalli
Auth... | `register_activation_hook` and `register_deactivation_hook` refer to when the plugin is activated and deactivated, respectively, and only fire in those two instances. They're to be used, for example, when you need to add a database table (and take it back down). You don't need to remove your filters, either. Your plugi... |
76,877 | <p>Bare with me. Firstly, here is my whole script for my featured slider articles:</p>
<pre><code><div id="featured" class="<?php if ( $responsive ) echo 'flexslider' . $featured_auto_class; else echo 'et_cycle'; ?>">
<a id="left-arrow" href="#"><?php esc_html_e('Previous','Aggregate'); ?></... | [
{
"answer_id": 76882,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p>Okay so I tried to read your code, and failed, and reformatted it as it's currently unreadable, and any error... | 2012/12/21 | [
"https://wordpress.stackexchange.com/questions/76877",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24875/"
] | Bare with me. Firstly, here is my whole script for my featured slider articles:
```
<div id="featured" class="<?php if ( $responsive ) echo 'flexslider' . $featured_auto_class; else echo 'et_cycle'; ?>">
<a id="left-arrow" href="#"><?php esc_html_e('Previous','Aggregate'); ?></a>
<a id="right-arrow" href="#"><?php esc... | Okay so I tried to read your code, and failed, and reformatted it as it's currently unreadable, and any errors are obscured by this unreadability. I cannot stress the importance of indenting correctly and following a standardised formatting for making your life infinitely easier:
```
<?php
$featured_class = 'et_cycle'... |
76,890 | <p>I'm using Advanced Custom Fields plugin and microkid Related Posts.
I would like to display my custom fields inside Related post
This is what I got so far?</p>
<pre><code><?php //related artworks
$related = MRP_get_related_posts( $post->ID, true, false, 'quote_list' );
//for testing related array
//print_r ... | [
{
"answer_id": 76892,
"author": "Pontus Abrahamsson",
"author_id": 16722,
"author_profile": "https://wordpress.stackexchange.com/users/16722",
"pm_score": 2,
"selected": true,
"text": "<p>According to advenced custom fields you get the value with <code>get_field</code> <a href=\"http://w... | 2012/12/21 | [
"https://wordpress.stackexchange.com/questions/76890",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4986/"
] | I'm using Advanced Custom Fields plugin and microkid Related Posts.
I would like to display my custom fields inside Related post
This is what I got so far?
```
<?php //related artworks
$related = MRP_get_related_posts( $post->ID, true, false, 'quote_list' );
//for testing related array
//print_r ($related);
if(!emp... | According to advenced custom fields you get the value with `get_field` <http://www.advancedcustomfields.com/docs/functions/get_field/>
Just change "text\_field" to your field-key.
```
<?php
$related = MRP_get_related_posts( $post->ID, true, false, 'quote_list' );
if( !empty( $related ) ) {
foreach( $related as $... |
76,911 | <p>I'm quite lost with taxonomies and custom post type.</p>
<ul>
<li>I have a taxonomy -> auteur </li>
<li>I have custom_post-type -> citation (quote in french).</li>
</ul>
<p>I just want list all citations (quote) from an auteur (auteur = taxonomy) with a permalink structure like this :</p>
<pre><code>www.myblognam... | [
{
"answer_id": 85339,
"author": "Diana",
"author_id": 17048,
"author_profile": "https://wordpress.stackexchange.com/users/17048",
"pm_score": 1,
"selected": false,
"text": "<p>Don't know how did you set the post type and the taxonomy, but by default I think you're supposed to see all quo... | 2012/12/21 | [
"https://wordpress.stackexchange.com/questions/76911",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25111/"
] | I'm quite lost with taxonomies and custom post type.
* I have a taxonomy -> auteur
* I have custom\_post-type -> citation (quote in french).
I just want list all citations (quote) from an auteur (auteur = taxonomy) with a permalink structure like this :
```
www.myblogname.com/citation/auteur_name/
```
or
```
www... | Don't know how did you set the post type and the taxonomy, but by default I think you're supposed to see all quotes from an author through `myblogname.com/the-author-name`.
If you want to place static words such *auteur* or *citation* in the link, then this is related to how you set the options for creating the post ... |
76,913 | <p>Firstly, I've <a href="https://wordpress.stackexchange.com/questions/65635/wordpress-multisite-is-it-possible-to-put-the-main-site-in-a-subdirectory" title="Wordpress Multisite - is it possible to put the main site in a subdirectory?">read</a> <a href="http://codex.wordpress.org/Moving_WordPress#Moving_WordPress_Mul... | [
{
"answer_id": 77488,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 2,
"selected": false,
"text": "<p>It looks to me as if you've solved your own problem - just follow your steps 1-4, and for step 5 update the <code... | 2012/12/21 | [
"https://wordpress.stackexchange.com/questions/76913",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18155/"
] | Firstly, I've [read](https://wordpress.stackexchange.com/questions/65635/wordpress-multisite-is-it-possible-to-put-the-main-site-in-a-subdirectory "Wordpress Multisite - is it possible to put the main site in a subdirectory?") [a number](http://codex.wordpress.org/Moving_WordPress#Moving_WordPress_Multisite "Moving Wor... | I know it's old but I fixed it! i installed WP MU in a subfolder.
`htaccess`:
```
RewriteEngine On
RewriteBase /YOUR_SUBFOLDER
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
RewriteRule ^([_0-9a-zA-Z-]+/)?wp-admin$ $1wp-admin/ [R=301,L]
RewriteCond %{REQUEST_FILENAME} -f [OR]
RewriteCond %{REQUES... |
76,926 | <p>I created a table using the dbDelta function and then removed a few columns and added a few. The new columns did get created but the old columns did not get deleted from the table.</p>
<p>Is there a different way I am supposed to delete columns from the table ?</p>
| [
{
"answer_id": 76930,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 5,
"selected": true,
"text": "<p>As far as I know, <code>dbDelta()</code> is primarily used to add tables to the database. It can also add or alte... | 2012/12/21 | [
"https://wordpress.stackexchange.com/questions/76926",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24656/"
] | I created a table using the dbDelta function and then removed a few columns and added a few. The new columns did get created but the old columns did not get deleted from the table.
Is there a different way I am supposed to delete columns from the table ? | As far as I know, `dbDelta()` is primarily used to add tables to the database. It can also add or alter columns. To delete columns, you should use `$wpdb->query()`:
```
global $wpdb;
$table = $wpdb->prefix . 'table_name';
$wpdb->query( "ALTER TABLE $table DROP COLUMN column_name" );
``` |
76,936 | <p>I have added a button that links to a facebook page at the left of my <a href="http://mamou-mani.com" rel="nofollow"><strong>website</strong></a>, I would like to be able to let people like the page directly from my website. How can I do that?</p>
<p>Right now I added the following CSS line:</p>
<pre><code>#fbtab{... | [
{
"answer_id": 76930,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 5,
"selected": true,
"text": "<p>As far as I know, <code>dbDelta()</code> is primarily used to add tables to the database. It can also add or alte... | 2012/12/21 | [
"https://wordpress.stackexchange.com/questions/76936",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16340/"
] | I have added a button that links to a facebook page at the left of my [**website**](http://mamou-mani.com), I would like to be able to let people like the page directly from my website. How can I do that?
Right now I added the following CSS line:
```
#fbtab{
background: url(http://mamou-mani.com/wp-content/themes/art... | As far as I know, `dbDelta()` is primarily used to add tables to the database. It can also add or alter columns. To delete columns, you should use `$wpdb->query()`:
```
global $wpdb;
$table = $wpdb->prefix . 'table_name';
$wpdb->query( "ALTER TABLE $table DROP COLUMN column_name" );
``` |
76,943 | <p>I'm trying to add a new footer widget area to my theme. I was able to add the new footer widget area and it works correctly. But I would like to limit what can be done with the widget area by the end user, right now the user can add any widget that they wish to the new footer widget area.</p>
<p>I would like to lim... | [
{
"answer_id": 76946,
"author": "Aram Sahradyan",
"author_id": 21418,
"author_profile": "https://wordpress.stackexchange.com/users/21418",
"pm_score": -1,
"selected": false,
"text": "<p>I think as usually you do</p>\n\n<ul>\n<li>Javascript on frontend using some easy character counter li... | 2012/12/22 | [
"https://wordpress.stackexchange.com/questions/76943",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25121/"
] | I'm trying to add a new footer widget area to my theme. I was able to add the new footer widget area and it works correctly. But I would like to limit what can be done with the widget area by the end user, right now the user can add any widget that they wish to the new footer widget area.
I would like to limit the wid... | Widget areas are the wrong tools for what you need. They are built to offer a choice. Breaking that would be very difficult … and hard to understand for the user.
Alternative: Use a custom setting, for example in `wp-admin/options-general.php` where the tagline and the site title is. There is even a hook for such addi... |
76,952 | <p>I have a problem with my wordpress <a href="http://muraliprashanth.me" rel="nofollow noreferrer">blog here</a>. everything seems to be working fine but the problem is after each post i am appending author information like the image below</p>
<p><img src="https://i.stack.imgur.com/fxVmg.jpg" alt="Murali Prashanth"><... | [
{
"answer_id": 76963,
"author": "dbeja",
"author_id": 9585,
"author_profile": "https://wordpress.stackexchange.com/users/9585",
"pm_score": 2,
"selected": false,
"text": "<p>How are you creating the author's link?</p>\n\n<p>If you put in your template:</p>\n\n<pre><code><?php the_auth... | 2012/12/22 | [
"https://wordpress.stackexchange.com/questions/76952",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25126/"
] | I have a problem with my wordpress [blog here](http://muraliprashanth.me). everything seems to be working fine but the problem is after each post i am appending author information like the image below

but when i click on the
>
> View all posts by Murali Pras... | How are you creating the author's link?
If you put in your template:
```
<?php the_author_posts_link(); ?>
```
It will write the author's name and link for the current post.
To modify the template for the author page, wordpress search for the following files in your theme's folder (in this order):
1. author-{nice... |
76,954 | <p>I am using WordPress 3.4.1. I need to display the featured image of a page. How can I get the featured image URL by particular page ID. Any help?</p>
| [
{
"answer_id": 76955,
"author": "Sisir",
"author_id": 3094,
"author_profile": "https://wordpress.stackexchange.com/users/3094",
"pm_score": 6,
"selected": true,
"text": "<p>Did you try anything? Its always helpful to share what you have tried.</p>\n\n<pre><code>$url = wp_get_attachment_u... | 2012/12/22 | [
"https://wordpress.stackexchange.com/questions/76954",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24957/"
] | I am using WordPress 3.4.1. I need to display the featured image of a page. How can I get the featured image URL by particular page ID. Any help? | Did you try anything? Its always helpful to share what you have tried.
```
$url = wp_get_attachment_url( get_post_thumbnail_id($post_id) );
```
Or if you want to get the image by image size.
```
$src = wp_get_attachment_image_src( get_post_thumbnail_id($post_id), 'thumbnail_size' );
$url = $src[0];
```
<http://co... |
76,959 | <p>I would like to show a widget in only one page of my site, as i can see it is not possible right?</p>
<p>Should i add that for all my site pages or not?</p>
| [
{
"answer_id": 76975,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>It depends on where you want to show the widget.</p>\n\n<p>Let’s start with the widget area (sidebar) registration:</p>... | 2012/12/22 | [
"https://wordpress.stackexchange.com/questions/76959",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25115/"
] | I would like to show a widget in only one page of my site, as i can see it is not possible right?
Should i add that for all my site pages or not? | It depends on where you want to show the widget.
Let’s start with the widget area (sidebar) registration:
```
add_action( 'wp_loaded', 'wpse_76959_register_widget_area' );
function wpse_76959_register_widget_area()
{
register_sidebar(
array (
'name' => __(
'Widgets on ... |
76,965 | <p>I need to <code>get category id</code> in <code>single.php</code>. I tried this:<br>
<code>$cat_ID = get_query_var('cat');</code> </p>
<p>It didn't work. What should I use instead?</p>
| [
{
"answer_id": 76966,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 1,
"selected": false,
"text": "<p>You can simply use</p>\n\n<pre><code>$categories = get_the_category();\n</code></pre>\n\n<p>to get the assigned... | 2012/12/22 | [
"https://wordpress.stackexchange.com/questions/76965",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24957/"
] | I need to `get category id` in `single.php`. I tried this:
`$cat_ID = get_query_var('cat');`
It didn't work. What should I use instead? | Use wp\_get\_post\_categories()
Retrieve the list of categories for a post.
```
<?php wp_get_post_categories( $post_id, $args ) ?>
```
Be aware that the function returns an array (of category ids) even if you only have one category in your post.
The example below shows how categories are retrieved, and then additi... |
76,977 | <p>I have created an option array that stores a series of options, along with their values. The problem is that I want to ACCUMULATE these options and store them in the options database. Meaning I would be able to add multiple records to the database, instead of only updating a single option.</p>
<p>For example, I ne... | [
{
"answer_id": 76985,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>The simplest solution is to change the settings key name.</p>\n\n<pre><code>update_option('testimonials_setti... | 2012/12/22 | [
"https://wordpress.stackexchange.com/questions/76977",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15578/"
] | I have created an option array that stores a series of options, along with their values. The problem is that I want to ACCUMULATE these options and store them in the options database. Meaning I would be able to add multiple records to the database, instead of only updating a single option.
For example, I need to store... | >
> The problem is that I want to ACCUMULATE these options and store them
> in the options database. Meaning I would be able to add multiple
> records to the database, instead of only updating a single option.
>
>
> For example, I need to store testimonials that will allow the user to
> keep the name/testimonial ... |
76,991 | <p>I'm using this redirect after inserting a post. It's not working, it only refreshes the page the form is on. I know the $pid is getting the post ID so what is the problem? This is the very end of my php code for handling the form submission.</p>
<pre><code>$pid = wp_insert_post($new_post);
update_post_meta($pid,'d... | [
{
"answer_id": 76993,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 5,
"selected": true,
"text": "<p>You can only use <code>wp_redirect</code> <em>before</em> content is sent to the browser. If you were to enable php ... | 2012/12/22 | [
"https://wordpress.stackexchange.com/questions/76991",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10413/"
] | I'm using this redirect after inserting a post. It's not working, it only refreshes the page the form is on. I know the $pid is getting the post ID so what is the problem? This is the very end of my php code for handling the form submission.
```
$pid = wp_insert_post($new_post);
update_post_meta($pid,'domain',$domain... | You can only use `wp_redirect` *before* content is sent to the browser. If you were to enable php debugging you'd see a "headers already sent" error due to `get_header()` on the first line.
Rather than process the form in the template, you can [hook an earlier action](http://codex.wordpress.org/Plugin_API/Action_Refer... |
76,999 | <p>I was hoping for some assistance with a custom meta box that I added to my genesis child theme.</p>
<p>The data is being saved properly, and stored properly, but when I try to echo it out using get_post_meta, nothing shows up. But a custom function someone showed me does echo it out. Can someone figure out what i... | [
{
"answer_id": 76993,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 5,
"selected": true,
"text": "<p>You can only use <code>wp_redirect</code> <em>before</em> content is sent to the browser. If you were to enable php ... | 2012/12/22 | [
"https://wordpress.stackexchange.com/questions/76999",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12963/"
] | I was hoping for some assistance with a custom meta box that I added to my genesis child theme.
The data is being saved properly, and stored properly, but when I try to echo it out using get\_post\_meta, nothing shows up. But a custom function someone showed me does echo it out. Can someone figure out what it isn't wo... | You can only use `wp_redirect` *before* content is sent to the browser. If you were to enable php debugging you'd see a "headers already sent" error due to `get_header()` on the first line.
Rather than process the form in the template, you can [hook an earlier action](http://codex.wordpress.org/Plugin_API/Action_Refer... |
77,005 | <p>I had a bit of a scare with a malformed database last night which got me to getting onto making sure I have so many redundant backups of my site that I am covered in the event of the server dying, my home backup server dying, etc. :) That said, I am trying to use <code>httrack</code> to download the entire site, bu... | [
{
"answer_id": 76993,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 5,
"selected": true,
"text": "<p>You can only use <code>wp_redirect</code> <em>before</em> content is sent to the browser. If you were to enable php ... | 2012/12/22 | [
"https://wordpress.stackexchange.com/questions/77005",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25151/"
] | I had a bit of a scare with a malformed database last night which got me to getting onto making sure I have so many redundant backups of my site that I am covered in the event of the server dying, my home backup server dying, etc. :) That said, I am trying to use `httrack` to download the entire site, but I run into a ... | You can only use `wp_redirect` *before* content is sent to the browser. If you were to enable php debugging you'd see a "headers already sent" error due to `get_header()` on the first line.
Rather than process the form in the template, you can [hook an earlier action](http://codex.wordpress.org/Plugin_API/Action_Refer... |
77,036 | <pre><code>$width = 560;
$height = 315;
$code = "I8M_uCnxhwY";
$homepage = "/";
$currentpage = $_SERVER['REQUEST_URI'];
if($homepage!=$currentpage) {
echo '<iframe width=".$width." height=".$height." src="http://www.youtube.com/embed/'.$code.'" frameborder="0" allowfullscreen></iframe>';
}
</code></pre>
... | [
{
"answer_id": 77037,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 3,
"selected": true,
"text": "<p>I would say that's a quirk with the plugin. In this case, it's better to make a <a href=\"http://www.smashingmagaz... | 2012/12/23 | [
"https://wordpress.stackexchange.com/questions/77036",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25159/"
] | ```
$width = 560;
$height = 315;
$code = "I8M_uCnxhwY";
$homepage = "/";
$currentpage = $_SERVER['REQUEST_URI'];
if($homepage!=$currentpage) {
echo '<iframe width=".$width." height=".$height." src="http://www.youtube.com/embed/'.$code.'" frameborder="0" allowfullscreen></iframe>';
}
```
So, that's my current code.... | I would say that's a quirk with the plugin. In this case, it's better to make a [shortcode](http://www.smashingmagazine.com/2009/02/02/mastering-wordpress-shortcodes/).
Add this code to your functions.php file:
```
function wpse_77036_embed_video( $atts ) {
extract( shortcode_atts( array(
'homepage' => '... |
77,050 | <p>I have some actions like this</p>
<pre><code> function simple_notification() {
echo '<div>This is a notification</div>';
}
add_action( 'site_notices', 'simple_notification' );
function simple_notification2() {
echo '<div>This is a notification</div>';
}
add_ac... | [
{
"answer_id": 77053,
"author": "Pontus Abrahamsson",
"author_id": 16722,
"author_profile": "https://wordpress.stackexchange.com/users/16722",
"pm_score": 0,
"selected": false,
"text": "<p>The question is pretty wide. But here is an example how to show how meny notifications there are wh... | 2012/12/23 | [
"https://wordpress.stackexchange.com/questions/77050",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5074/"
] | I have some actions like this
```
function simple_notification() {
echo '<div>This is a notification</div>';
}
add_action( 'site_notices', 'simple_notification' );
function simple_notification2() {
echo '<div>This is a notification</div>';
}
add_action( 'site_notices', 'simple_notifica... | Don't ask me way but i actually have a function to count hooked functions to a tag
```
/**
* count_hooked_functions
* @author Ohad Raz
* @param string $tag hook name as string
* @return int the number of hooked functions to a specific hook
*/
function count_hooked_functions($tag = false){
global $wp_filter;... |
77,052 | <p>I Am trying to create a default custom field drop down with pre populated values from the DB to be shown while creating a new Post or editing a existing post.</p>
<p>I am aware about how to add a single custom field and have added few as follows</p>
<pre><code>add_action('wp_insert_post', 'set_default_custom_field... | [
{
"answer_id": 77070,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>Add your dropdown to the post edit screen in a meta box via <a href=\"https://developer.wordpress.org/reference/fun... | 2012/12/23 | [
"https://wordpress.stackexchange.com/questions/77052",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9415/"
] | I Am trying to create a default custom field drop down with pre populated values from the DB to be shown while creating a new Post or editing a existing post.
I am aware about how to add a single custom field and have added few as follows
```
add_action('wp_insert_post', 'set_default_custom_fields');
function set_de... | Instead of defining the default values for custom fields, you should do like Milo says.
You should have something like this in your functions.php.
I tried to follow what you need, but didn't test it.
```
<?php
// action to add meta boxes
add_action( 'add_meta_boxes', 'voodoo_dropdown_metabox' );
// action on saving p... |
77,060 | <p>Environment: WP 3.5, Twenty Twelve child theme. I created a custom template.
Now, I'd like to display the built-in sidebar-2 in this custom template page (instead of the default sidebar-1).
sidebar-2 is already registered by twenty twelve functions.php.
I read a bit about get_sidebar and how to activate other sideba... | [
{
"answer_id": 77070,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>Add your dropdown to the post edit screen in a meta box via <a href=\"https://developer.wordpress.org/reference/fun... | 2012/12/23 | [
"https://wordpress.stackexchange.com/questions/77060",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23296/"
] | Environment: WP 3.5, Twenty Twelve child theme. I created a custom template.
Now, I'd like to display the built-in sidebar-2 in this custom template page (instead of the default sidebar-1).
sidebar-2 is already registered by twenty twelve functions.php.
I read a bit about get\_sidebar and how to activate other sidebars... | Instead of defining the default values for custom fields, you should do like Milo says.
You should have something like this in your functions.php.
I tried to follow what you need, but didn't test it.
```
<?php
// action to add meta boxes
add_action( 'add_meta_boxes', 'voodoo_dropdown_metabox' );
// action on saving p... |
77,072 | <p>I want display and limit disk usage for each author and be able to manage disk usage as an administrator.</p>
<p>Example: author1: disk space is 20Mb; if they uploaded more 20Mb the upload button (in media library and post) is disabled.</p>
<p>author2: disk space is 30Mb, if they upload more 30Mb the upload butto... | [
{
"answer_id": 77075,
"author": "Pontus Abrahamsson",
"author_id": 16722,
"author_profile": "https://wordpress.stackexchange.com/users/16722",
"pm_score": 2,
"selected": false,
"text": "<p>Okey so this is just an example how you can archive this..</p>\n\n<p>First change the upload direct... | 2012/12/23 | [
"https://wordpress.stackexchange.com/questions/77072",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25167/"
] | I want display and limit disk usage for each author and be able to manage disk usage as an administrator.
Example: author1: disk space is 20Mb; if they uploaded more 20Mb the upload button (in media library and post) is disabled.
author2: disk space is 30Mb, if they upload more 30Mb the upload button (in media librar... | Okey so this is just an example how you can archive this..
First change the upload directory to the current users username. eg uploads/admin
```
function wpse_16722_type_upload_dir( $args ) {
// Get current user data
$current_user = wp_get_current_user();
// Make upload dir to current username
$newdi... |
77,091 | <p>Can this work? I want to send a email when a post is published to the recipient, that is called in custom field.</p>
<p><em>EDIT</em> I changed the code to another example I found.</p>
<pre><code>function wpr_Notification($post_id) {
$post = get_post($post_id);
$to = get_post_meta($post_id, 'recipient', tr... | [
{
"answer_id": 77095,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 1,
"selected": false,
"text": "<p>Yes, it can work. But you should filter the email in the custom field. Users might have a error in his context or ... | 2012/12/23 | [
"https://wordpress.stackexchange.com/questions/77091",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25174/"
] | Can this work? I want to send a email when a post is published to the recipient, that is called in custom field.
*EDIT* I changed the code to another example I found.
```
function wpr_Notification($post_id) {
$post = get_post($post_id);
$to = get_post_meta($post_id, 'recipient', true);
$headers = 'From: D... | Yes, it can work. But you should filter the email in the custom field. Users might have a error in his context or the mail address is wrong.
You can filter the email address with [filter\_var()](http://php.net/manual/function.filter-var.php) |
77,099 | <p>I have 5 author levels in my WordPress site. Levels are calculated using points</p>
<pre><code> - level 1
- level 2
- level 3
- level 4
- level 5
</code></pre>
<p>Authors getting impressions based on author levels like this.</p>
<pre><code> - Level l => 50%
- Level 2 => 55%
- Level 3 => 60%
- Leve... | [
{
"answer_id": 77105,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>You question is really \"how do I make my way work?\" but \"what is a good way to do this?\" so, maybe I am m... | 2012/12/23 | [
"https://wordpress.stackexchange.com/questions/77099",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5074/"
] | I have 5 author levels in my WordPress site. Levels are calculated using points
```
- level 1
- level 2
- level 3
- level 4
- level 5
```
Authors getting impressions based on author levels like this.
```
- Level l => 50%
- Level 2 => 55%
- Level 3 => 60%
- Level 4 => 65%
- Level 5 => 70%
```
As of now I... | ```
function get_current_number($author_id) {
$current_number = (int) get_user_meta( $author_id, 'revshare_current_number', true );
if( in_array( $current_number, range( 1, 99 ) ) ) {
$current_number++;
}
else {
$current_number = 1;
}
update_user_meta($author_id, 'revshare_curren... |
77,111 | <p>How can i remove the header,search and my home,activity,forum etc from registration page.os there any plugin to modify registration page.I am using buddypress plugin.I do not want to call color.css for my registration page.</p>
| [
{
"answer_id": 77118,
"author": "Ahmad M",
"author_id": 12961,
"author_profile": "https://wordpress.stackexchange.com/users/12961",
"pm_score": 0,
"selected": false,
"text": "<p>The theme you are using is a child theme of Buddypress default theme. You can override any file in the default... | 2012/12/24 | [
"https://wordpress.stackexchange.com/questions/77111",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25179/"
] | How can i remove the header,search and my home,activity,forum etc from registration page.os there any plugin to modify registration page.I am using buddypress plugin.I do not want to call color.css for my registration page. | If you don't mind editing your themes files, you can remove color.css from the registration page by editing the `functions.php` file and change [line 127](http://themes.trac.wordpress.org/browser/frisco-for-buddypress/1.6.13/functions.php#L127) from:
```
wp_enqueue_style( 'frisco-color-css');
```
to:
```
if ( ! is_... |
77,132 | <p>I currently use a Wordpress network in order to run a number of sites, which all use the same template, plugins and images. As posts appear on a multiple sites, it makes sense to only upload images to one location (and have one copy of an image), rather than multiple ones.</p>
<p>Could I perhaps achieve this by cre... | [
{
"answer_id": 77149,
"author": "Pontus Abrahamsson",
"author_id": 16722,
"author_profile": "https://wordpress.stackexchange.com/users/16722",
"pm_score": 3,
"selected": true,
"text": "<p>You can pretty simple add some actions to archive this.</p>\n\n<pre><code>function wpse_16722_main_u... | 2012/12/24 | [
"https://wordpress.stackexchange.com/questions/77132",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13882/"
] | I currently use a Wordpress network in order to run a number of sites, which all use the same template, plugins and images. As posts appear on a multiple sites, it makes sense to only upload images to one location (and have one copy of an image), rather than multiple ones.
Could I perhaps achieve this by creating a cu... | You can pretty simple add some actions to archive this.
```
function wpse_16722_main_uploads() {
switch_to_blog(1);
}
add_action('load-media-new.php', 'wpse_16722_main_uploads');
add_action('load-media-upload.php', 'wpse_16722_main_uploads');
add_action('load-media.php', 'wpse_16722_main_uploads');
add_action('loa... |
77,136 | <p>I have plugin I would like to use only on the contact page, however the script and css is being loaded on every page. Aside from the increased http requests, it is also causing another script to not work properly on another page.</p>
<p>Is there a way to stop this plugin from loading anywhere else on the site?</p>
... | [
{
"answer_id": 77137,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 2,
"selected": false,
"text": "<p>Try using </p>\n\n<pre><code>if(is_page('contact-page-slug')){ \n</code></pre>\n\n<p>to add your functions to ... | 2012/12/24 | [
"https://wordpress.stackexchange.com/questions/77136",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24587/"
] | I have plugin I would like to use only on the contact page, however the script and css is being loaded on every page. Aside from the increased http requests, it is also causing another script to not work properly on another page.
Is there a way to stop this plugin from loading anywhere else on the site?
I know how to... | Try using
```
if(is_page('contact-page-slug')){
```
to add your functions to that page only. |
77,138 | <p>On my website, registered users (subscriber role) can send drafts and, if admins validate them, they are published.</p>
<p>I'm trying to add a tag box to frontend editor used to send new posts. To implement the autocomplete feature I'm making an AJAX call to this URL:</p>
<pre><code>http://example.com/wp-admin/adm... | [
{
"answer_id": 77140,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 3,
"selected": false,
"text": "<p>Why not make your users contributors instead of subscribers? By default, contributors can submit draft posts but ... | 2012/12/24 | [
"https://wordpress.stackexchange.com/questions/77138",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25163/"
] | On my website, registered users (subscriber role) can send drafts and, if admins validate them, they are published.
I'm trying to add a tag box to frontend editor used to send new posts. To implement the autocomplete feature I'm making an AJAX call to this URL:
```
http://example.com/wp-admin/admin-ajax.php?action=aj... | All the WordPress AJAX calls should be handled by the `admin-ajax.php`, wether they happen on the frontend or in the backend. To grant the access you have to register the callbackfuntion for the AJAX call add those lines to your file:
```
add_action( 'wp_ajax_prefix_update_post', 'prefix_update_post' );
add_action( 'w... |
77,166 | <p>I want to switch from the Next Post/Previous Post type navigation, to showing the title of the previous or the next post.Here is the code I think needs to be changed, it's form loop-single.php</p>
<pre><code><nav id="nav-single">
<h3 class="assistive-text"><?php _e( 'Post navigation', 'admired' )... | [
{
"answer_id": 77140,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 3,
"selected": false,
"text": "<p>Why not make your users contributors instead of subscribers? By default, contributors can submit draft posts but ... | 2012/12/24 | [
"https://wordpress.stackexchange.com/questions/77166",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25199/"
] | I want to switch from the Next Post/Previous Post type navigation, to showing the title of the previous or the next post.Here is the code I think needs to be changed, it's form loop-single.php
```
<nav id="nav-single">
<h3 class="assistive-text"><?php _e( 'Post navigation', 'admired' ); ?></h3>
<span class="na... | All the WordPress AJAX calls should be handled by the `admin-ajax.php`, wether they happen on the frontend or in the backend. To grant the access you have to register the callbackfuntion for the AJAX call add those lines to your file:
```
add_action( 'wp_ajax_prefix_update_post', 'prefix_update_post' );
add_action( 'w... |
77,173 | <p>I am using this tutorial <a href="http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory#Using_a_pre-existing_subdirectory_install" rel="nofollow noreferrer">Giving WordPress Its Own Directory</a> to launch a WordPress (installed in a sub folder called <code>wordpress</code>) by using example.com instead of e... | [
{
"answer_id": 77140,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 3,
"selected": false,
"text": "<p>Why not make your users contributors instead of subscribers? By default, contributors can submit draft posts but ... | 2012/12/24 | [
"https://wordpress.stackexchange.com/questions/77173",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13339/"
] | I am using this tutorial [Giving WordPress Its Own Directory](http://codex.wordpress.org/Giving_WordPress_Its_Own_Directory#Using_a_pre-existing_subdirectory_install) to launch a WordPress (installed in a sub folder called `wordpress`) by using example.com instead of example.com/wordpress.
It says to copy `index.php` ... | All the WordPress AJAX calls should be handled by the `admin-ajax.php`, wether they happen on the frontend or in the backend. To grant the access you have to register the callbackfuntion for the AJAX call add those lines to your file:
```
add_action( 'wp_ajax_prefix_update_post', 'prefix_update_post' );
add_action( 'w... |
77,175 | <p>For some reason, when viewing a category, the posts are repeated - basically the whole loop repeats as many times as there are posts for that category. </p>
<p><strong>E.G.:</strong><br/>
If <code>category_a</code> has 3 posts, the page will display:</p>
<p>post1 - Featured<br/>
post2<br/>
post3<br/></p>
<p>post1... | [
{
"answer_id": 77140,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 3,
"selected": false,
"text": "<p>Why not make your users contributors instead of subscribers? By default, contributors can submit draft posts but ... | 2012/12/24 | [
"https://wordpress.stackexchange.com/questions/77175",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22688/"
] | For some reason, when viewing a category, the posts are repeated - basically the whole loop repeats as many times as there are posts for that category.
**E.G.:**
If `category_a` has 3 posts, the page will display:
post1 - Featured
post2
post3
post1 - Featured
post2
post3
post1 - Featured
post... | All the WordPress AJAX calls should be handled by the `admin-ajax.php`, wether they happen on the frontend or in the backend. To grant the access you have to register the callbackfuntion for the AJAX call add those lines to your file:
```
add_action( 'wp_ajax_prefix_update_post', 'prefix_update_post' );
add_action( 'w... |
77,181 | <p>I have implemented a <code>post_type_link</code> filter for my custom post and this is working great. However, the only downside is that the final URL only seems to be created when the post is published.</p>
<p>What I'd like is to create the custom URL after a user has typed in a title for the post. I'm having trou... | [
{
"answer_id": 77140,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 3,
"selected": false,
"text": "<p>Why not make your users contributors instead of subscribers? By default, contributors can submit draft posts but ... | 2012/12/24 | [
"https://wordpress.stackexchange.com/questions/77181",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6616/"
] | I have implemented a `post_type_link` filter for my custom post and this is working great. However, the only downside is that the final URL only seems to be created when the post is published.
What I'd like is to create the custom URL after a user has typed in a title for the post. I'm having trouble finding the corre... | All the WordPress AJAX calls should be handled by the `admin-ajax.php`, wether they happen on the frontend or in the backend. To grant the access you have to register the callbackfuntion for the AJAX call add those lines to your file:
```
add_action( 'wp_ajax_prefix_update_post', 'prefix_update_post' );
add_action( 'w... |
77,201 | <p>I have a custom post type 'Participant' with many custom fields. I also have a form with corresponding input fields for the user to fill out. When he submits the form, I want a new post to be generated with each custom fields containing the value chosen by the user.</p>
<p>Is it possible to do and if so, how?</p>
| [
{
"answer_id": 77205,
"author": "webaware",
"author_id": 24260,
"author_profile": "https://wordpress.stackexchange.com/users/24260",
"pm_score": 6,
"selected": true,
"text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/wp_insert_post\">wp_insert_post()</a> and <a href=... | 2012/12/25 | [
"https://wordpress.stackexchange.com/questions/77201",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11634/"
] | I have a custom post type 'Participant' with many custom fields. I also have a form with corresponding input fields for the user to fill out. When he submits the form, I want a new post to be generated with each custom fields containing the value chosen by the user.
Is it possible to do and if so, how? | Use [wp\_insert\_post()](http://codex.wordpress.org/Function_Reference/wp_insert_post) and [add\_post\_meta()](http://codex.wordpress.org/Function_Reference/add_post_meta), like this:
```
// insert the post and set the category
$post_id = wp_insert_post(array (
'post_type' => 'your_post_type',
'post_title' => ... |
77,227 | <p>Enqueuing Google Web Fonts the usual way, i.e., using the <code>wp_enqueue_style</code> function like so...</p>
<pre><code>function wpse_google_webfonts() {
wp_enqueue_style( 'google-webfonts', 'http://fonts.googleapis.com/css?family=Ubuntu+Condensed|Open+Sans:400italic,700italic,400,700' );
}
add_action( 'wp_e... | [
{
"answer_id": 77232,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Based on <a href=\"https://wordpress.stackexchange.com/questions/38319/how-to-add-defer-defer-tag-in-plugin-javascript... | 2012/12/25 | [
"https://wordpress.stackexchange.com/questions/77227",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10691/"
] | Enqueuing Google Web Fonts the usual way, i.e., using the `wp_enqueue_style` function like so...
```
function wpse_google_webfonts() {
wp_enqueue_style( 'google-webfonts', 'http://fonts.googleapis.com/css?family=Ubuntu+Condensed|Open+Sans:400italic,700italic,400,700' );
}
add_action( 'wp_enqueue_scripts', 'wpse_go... | WordPress knows what it is doing here. Honest.
When rendering an ampersand in HTML, you should always use `&` or `&`. The browser then converts it to `&` before actually firing the HTTP request. See for yourself by inspecting the network calls in a web inspector tool. You're not actually losing your non-latin... |
77,228 | <p>I tried to avoid ask this question, because I think that must be simple, but after long hours trying to get an answer I cant achieve it.</p>
<p>I am trying to get a permalink structure like this:</p>
<pre><code>http://domain.com/u/USERNAME
http://domain.com/p/POSTID
</code></pre>
<p>To get that structure I set a ... | [
{
"answer_id": 77232,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Based on <a href=\"https://wordpress.stackexchange.com/questions/38319/how-to-add-defer-defer-tag-in-plugin-javascript... | 2012/12/25 | [
"https://wordpress.stackexchange.com/questions/77228",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25163/"
] | I tried to avoid ask this question, because I think that must be simple, but after long hours trying to get an answer I cant achieve it.
I am trying to get a permalink structure like this:
```
http://domain.com/u/USERNAME
http://domain.com/p/POSTID
```
To get that structure I set a "Custom structure" in the permali... | WordPress knows what it is doing here. Honest.
When rendering an ampersand in HTML, you should always use `&` or `&`. The browser then converts it to `&` before actually firing the HTTP request. See for yourself by inspecting the network calls in a web inspector tool. You're not actually losing your non-latin... |
77,234 | <p>I'm looking for a way to link to author pages within one WordPress install simply by putting the @ symbol in front of a person's username in a post.... just like on twitter.</p>
<p>Example:</p>
<p>If the username is "Bill256" and I write "@Bill256" it will be linked to his author page.</p>
| [
{
"answer_id": 77244,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 5,
"selected": true,
"text": "<p>This is a little tricky because <a href=\"http://codex.wordpress.org/Function_Reference/sanitize_user\" rel=\"... | 2012/12/25 | [
"https://wordpress.stackexchange.com/questions/77234",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5205/"
] | I'm looking for a way to link to author pages within one WordPress install simply by putting the @ symbol in front of a person's username in a post.... just like on twitter.
Example:
If the username is "Bill256" and I write "@Bill256" it will be linked to his author page. | This is a little tricky because [`sanitize_user`](http://codex.wordpress.org/Function_Reference/sanitize_user) allows spaces in usernames, meaning it difficult to avoid grabbing the whole phrase '@johndoe said that ... ' as opposed to just the actual username '@johndoe' and you have no separator at the end that would h... |
77,268 | <p>Happy holidays everyone. </p>
<p>Hope someone can help me in thinking about a problem I've run into.</p>
<p>I have a plugin Im building that allows the user to pull address data from the maps API - ie it validates an address and if it is a business, pulls the marker icon, address details, web link etc. and builds ... | [
{
"answer_id": 77269,
"author": "webaware",
"author_id": 24260,
"author_profile": "https://wordpress.stackexchange.com/users/24260",
"pm_score": 1,
"selected": false,
"text": "<p>Probably safest to put HTML content in as the \"content\" of an <a href=\"http://codex.wordpress.org/Shortcod... | 2012/12/26 | [
"https://wordpress.stackexchange.com/questions/77268",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13551/"
] | Happy holidays everyone.
Hope someone can help me in thinking about a problem I've run into.
I have a plugin Im building that allows the user to pull address data from the maps API - ie it validates an address and if it is a business, pulls the marker icon, address details, web link etc. and builds a shortcode to re... | You have quite a bit of markup for that shortcode. Trying to pass all of that as a shortcode is going to be trouble.
I pulled it apart to look at it.
1. id="map"
2. z="11"
3. w="100%"
4. h="300"
5. scrollwheel="false"
6. maptype="ROADMAP"
7. address="Southampton, United Kingdom"
8. marker="true"
9. markerimage="`http:... |
77,276 | <p>I went through a lot of threads, codex page and tried messing with a lot of things but my code doesn't seem to be creating the tables. And I am not able to figure out where I am going wrong.
I checked booking_db_version in the database, it gets updated when I update it in the file.</p>
<p>Here's the code</p>
<pre>... | [
{
"answer_id": 77287,
"author": "Pontus Abrahamsson",
"author_id": 16722,
"author_profile": "https://wordpress.stackexchange.com/users/16722",
"pm_score": 5,
"selected": true,
"text": "<p>From WordPress-codex about <a href=\"http://codex.wordpress.org/Creating_Tables_with_Plugins#Creatin... | 2012/12/26 | [
"https://wordpress.stackexchange.com/questions/77276",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16933/"
] | I went through a lot of threads, codex page and tried messing with a lot of things but my code doesn't seem to be creating the tables. And I am not able to figure out where I am going wrong.
I checked booking\_db\_version in the database, it gets updated when I update it in the file.
Here's the code
```
global $booki... | From WordPress-codex about [dbDelta](http://codex.wordpress.org/Creating_Tables_with_Plugins#Creating_or_Updating_the_Table):
The dbDelta function examines the current table structure, compares it to the desired table structure, and either adds or modifies the table as necessary, so it can be very handy for updates (s... |
77,284 | <p>I'm trying out the <a href="http://wptheming.com/options-framework-theme/" rel="nofollow">Options Framework</a>, and I've started hacking options.php.</p>
<p>I have reduced the amount of options, and one of the options left is an image upload.</p>
<p>I have gone into Theme Options, and uploaded an image (for the l... | [
{
"answer_id": 77674,
"author": "Steve",
"author_id": 3206,
"author_profile": "https://wordpress.stackexchange.com/users/3206",
"pm_score": 1,
"selected": true,
"text": "<p>Selecting the theme master as the current theme outputs instructions to the front page of the website. Amongst the... | 2012/12/26 | [
"https://wordpress.stackexchange.com/questions/77284",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3206/"
] | I'm trying out the [Options Framework](http://wptheming.com/options-framework-theme/), and I've started hacking options.php.
I have reduced the amount of options, and one of the options left is an image upload.
I have gone into Theme Options, and uploaded an image (for the logo), but I cannot find mention of this any... | Selecting the theme master as the current theme outputs instructions to the front page of the website. Amongst the instructions is the necessity to use the code:
```
of_get_option($id,$default)
```
So, I needed to use:
```
of_get_option('logo_uploader')
``` |
77,316 | <p>is there any shortcode or a plugin that will add new quicktag, like this example:</p>
<p>[hidemytext]some hidden text[/hidemytext]</p>
<p>and any text inside those tag is hidden from the post or from the page.</p>
<p>Thanks and regards</p>
| [
{
"answer_id": 77321,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>You really should be able to work this out from <a href=\"http://codex.wordpress.org/Shortcode_API\" rel=\"no... | 2012/12/26 | [
"https://wordpress.stackexchange.com/questions/77316",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25236/"
] | is there any shortcode or a plugin that will add new quicktag, like this example:
[hidemytext]some hidden text[/hidemytext]
and any text inside those tag is hidden from the post or from the page.
Thanks and regards | Simple answer:
```
add_shortcode( 'hidemytext', '__return_false' );
```
But shortcodes should never be used like that. Imagine what happens when the plugin or theme with that shortcode is turned off: everyone can see the content now. This is not very user friendly.
So switch the logic: show nothing or the bare shor... |
77,334 | <p>I've got <a href="http://wordpress.org/extend/plugins/post-status-menu-items/" rel="noreferrer">a plugin</a> that puts post statuses into post type admin menus. I'm in the middle of internationalizing it, and I'm wondering how to handle this situation.</p>
<p>The plugin uses some unique strings that will get a textd... | [
{
"answer_id": 77335,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 5,
"selected": true,
"text": "<p>Never rely on core strings for translation, they may change or get a <code>context</code> parameter any time. Once that... | 2012/12/26 | [
"https://wordpress.stackexchange.com/questions/77334",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9844/"
] | I've got [a plugin](http://wordpress.org/extend/plugins/post-status-menu-items/) that puts post statuses into post type admin menus. I'm in the middle of internationalizing it, and I'm wondering how to handle this situation.
The plugin uses some unique strings that will get a textdomain like this:
```
__( 'Select the... | Never rely on core strings for translation, they may change or get a `context` parameter any time. Once that happens your users get a partially translated interface, and your translators have no way to fix that.
Also keep in mind the same string is not necessary translated everywhere with the same word. Even without a... |
77,337 | <p>I have a problem with my page. I'm trying to make a "Contact Us" page. It's working perfectly fine design-wise. But when I try to send the form to the same page as origin. It returns 404 error.</p>
<p>It only happens when I'm sending the form. I've tried both with GET and POST requests. Nothing seems to work.</p>
... | [
{
"answer_id": 77339,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 7,
"selected": true,
"text": "<p><a href=\"http://nacin.com/2010/05/11/in-wordpress-prefix-everything/\">Prefix everything</a>, especially your variable... | 2012/12/26 | [
"https://wordpress.stackexchange.com/questions/77337",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25242/"
] | I have a problem with my page. I'm trying to make a "Contact Us" page. It's working perfectly fine design-wise. But when I try to send the form to the same page as origin. It returns 404 error.
It only happens when I'm sending the form. I've tried both with GET and POST requests. Nothing seems to work.
I've even comm... | [Prefix everything](http://nacin.com/2010/05/11/in-wordpress-prefix-everything/), especially your variables. The names you are using are used by WordPress internally (see the comment form), so WordPress might try to do something with your form values. If that fails you get an error.
While `$_GET` problems are usually ... |
77,344 | <p>Why does WP pagination break when used on the homepage?</p>
<p>If you take the code below and use it in a page template it works perfectly (make sure you have 3 or more posts). However, as soon as you use the same code on home.php, front-page.php, index.php or even as a page template but set as a static homepage, i... | [
{
"answer_id": 77618,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": true,
"text": "<p>The solution is to not alter the main query in the template. The default query happens before the template is loaded... | 2012/12/27 | [
"https://wordpress.stackexchange.com/questions/77344",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4999/"
] | Why does WP pagination break when used on the homepage?
If you take the code below and use it in a page template it works perfectly (make sure you have 3 or more posts). However, as soon as you use the same code on home.php, front-page.php, index.php or even as a page template but set as a static homepage, it breaks.
... | The solution is to not alter the main query in the template. The default query happens before the template is loaded, so querying in the template overwrites that original query, which is a waste of resources. See the example in codex under [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get... |
77,347 | <p>I am trying to creating some custom options for a template I am developing but I am getting an error when the checkbox (Line 130) is unchecked:</p>
<blockquote>
<p>Warning: Illegal string offset 'show_admin_dev' in E:\composite-cms\WordPress-Settings-Sandbox-master\lib\admin\pages\dev-page.php on line 11</p>
</bl... | [
{
"answer_id": 77355,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 0,
"selected": false,
"text": "<p>It appears that <code>$options['show_admin_dev']</code> is actually a <em>string</em>, not an integer. You're try... | 2012/12/27 | [
"https://wordpress.stackexchange.com/questions/77347",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25246/"
] | I am trying to creating some custom options for a template I am developing but I am getting an error when the checkbox (Line 130) is unchecked:
>
> Warning: Illegal string offset 'show\_admin\_dev' in E:\composite-cms\WordPress-Settings-Sandbox-master\lib\admin\pages\dev-page.php on line 11
>
>
>
This is the line... | Your problem is that you haven't included a sanitization function as the third parameter to register\_settings on line 111. When no sanitization provided WordPress deletes the value of the option and creates a new one based **only** on what is passed in `$_POST`. Since unchecked checkboxes are not sent by the browser a... |
77,348 | <p>I'm creating a WordPress blog with some members-only page. In those members-only posts I have my own tutorial download links which i have uploaded for FREE. Problem is I want them to stop sharing the download link for the tutorials, instead of that I want to give them links which will only works once OR It will only... | [
{
"answer_id": 77355,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 0,
"selected": false,
"text": "<p>It appears that <code>$options['show_admin_dev']</code> is actually a <em>string</em>, not an integer. You're try... | 2012/12/27 | [
"https://wordpress.stackexchange.com/questions/77348",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25247/"
] | I'm creating a WordPress blog with some members-only page. In those members-only posts I have my own tutorial download links which i have uploaded for FREE. Problem is I want them to stop sharing the download link for the tutorials, instead of that I want to give them links which will only works once OR It will only wo... | Your problem is that you haven't included a sanitization function as the third parameter to register\_settings on line 111. When no sanitization provided WordPress deletes the value of the option and creates a new one based **only** on what is passed in `$_POST`. Since unchecked checkboxes are not sent by the browser a... |
77,349 | <p>I've been studying roles and capabilities and have worked with and worked up a bunch of awesome code for creating unique capabilities and roles. I have created a "Master Editor" role to maintain users with almost every capability...
However, edit_users & delete_users obviously allows for an editor to CUD users, ... | [
{
"answer_id": 77357,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": true,
"text": "<p>Your question seems to boil down to this</p>\n\n<blockquote>\n <p>I can't figure out how to check that the $u... | 2012/12/27 | [
"https://wordpress.stackexchange.com/questions/77349",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18726/"
] | I've been studying roles and capabilities and have worked with and worked up a bunch of awesome code for creating unique capabilities and roles. I have created a "Master Editor" role to maintain users with almost every capability...
However, edit\_users & delete\_users obviously allows for an editor to CUD users, inclu... | Your question seems to boil down to this
>
> I can't figure out how to check that the $userids in question are an
> administrators user ID.
>
>
>
Try
```
user_can($id,'administrator')
```
<http://codex.wordpress.org/Function_Reference/user_can>
The [Codex has a warning](http://codex.wordpress.org/Function_Re... |
77,366 | <p>I want to run a query base on the following $args. My question that how to pass variable number of arrays to tax_query as currently i have two arrays within tax_query it can be 1 , 3 or 5 and so on. Is there any possibility ? </p>
<pre>
$args = array (
'posts_per_page' => 10,
't... | [
{
"answer_id": 77357,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": true,
"text": "<p>Your question seems to boil down to this</p>\n\n<blockquote>\n <p>I can't figure out how to check that the $u... | 2012/12/27 | [
"https://wordpress.stackexchange.com/questions/77366",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25201/"
] | I want to run a query base on the following $args. My question that how to pass variable number of arrays to tax\_query as currently i have two arrays within tax\_query it can be 1 , 3 or 5 and so on. Is there any possibility ?
```
$args = array (
'posts_per_page' => 10,
'tax_query' => array(... | Your question seems to boil down to this
>
> I can't figure out how to check that the $userids in question are an
> administrators user ID.
>
>
>
Try
```
user_can($id,'administrator')
```
<http://codex.wordpress.org/Function_Reference/user_can>
The [Codex has a warning](http://codex.wordpress.org/Function_Re... |
77,381 | <p>How can one picture belongs different galleries?</p>
<p>For example, there are two galleries. I want to avoid loading the image twice (in two galleries) but it shown (included) in the first and second gallery.</p>
| [
{
"answer_id": 77357,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": true,
"text": "<p>Your question seems to boil down to this</p>\n\n<blockquote>\n <p>I can't figure out how to check that the $u... | 2012/12/27 | [
"https://wordpress.stackexchange.com/questions/77381",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25256/"
] | How can one picture belongs different galleries?
For example, there are two galleries. I want to avoid loading the image twice (in two galleries) but it shown (included) in the first and second gallery. | Your question seems to boil down to this
>
> I can't figure out how to check that the $userids in question are an
> administrators user ID.
>
>
>
Try
```
user_can($id,'administrator')
```
<http://codex.wordpress.org/Function_Reference/user_can>
The [Codex has a warning](http://codex.wordpress.org/Function_Re... |
77,388 | <p>I am making multi-language site powered by WordPress.</p>
<p><a href="http://wpml.org/" rel="nofollow noreferrer">WPML</a> is not free and it makes too many extra sql queries to database so it is not good solution for my site.</p>
<p><a href="http://wordpress.org/extend/plugins/qtranslate/" rel="nofollow noreferre... | [
{
"answer_id": 77391,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 1,
"selected": false,
"text": "<p>I use WPML in combination with a Caching Plugin for my multilanguage-sites.</p>\n\n<p>It is not free, i know, b... | 2012/12/27 | [
"https://wordpress.stackexchange.com/questions/77388",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15054/"
] | I am making multi-language site powered by WordPress.
[WPML](http://wpml.org/) is not free and it makes too many extra sql queries to database so it is not good solution for my site.
[qTranslate](http://wordpress.org/extend/plugins/qtranslate/) saves all languages in one database row and it is very complicated to mov... | i set up my wordpress site as a wordpress multisite and then used "[multisite language switcher](http://wordpress.org/plugins/multisite-language-switcher/)" plugin...
it is free and works great... |
77,390 | <p>I am using this function to display categories specified to a post having gallery on the image attachment page.</p>
<pre><code><p>CATEGORY: <?php the_category(', '); ?></p>
</code></pre>
<p>The problem is that this function doesn't return anything. I have also used this way to display categories... | [
{
"answer_id": 77516,
"author": "Pontus Abrahamsson",
"author_id": 16722,
"author_profile": "https://wordpress.stackexchange.com/users/16722",
"pm_score": 3,
"selected": true,
"text": "<p>If you have <strong>WordPress 3.5</strong> this will work.</p>\n\n<p><a href=\"http://make.wordpress... | 2012/12/27 | [
"https://wordpress.stackexchange.com/questions/77390",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24411/"
] | I am using this function to display categories specified to a post having gallery on the image attachment page.
```
<p>CATEGORY: <?php the_category(', '); ?></p>
```
The problem is that this function doesn't return anything. I have also used this way to display categories but no success:
```
<?php $categories =... | If you have **WordPress 3.5** this will work.
<http://make.wordpress.org/core/2012/12/12/attachment-editing-now-with-full-post-edit-ui/>
First you need to enable this in your theme, Put this in your functions.php file in your theme root.
```
add_action('init', 'wpse_77390_enable_media_categories' , 1);
function wpse... |
77,403 | <p>So I have this website that I am building and I am using get_the_author_meta to display various information about the user / author including user image.</p>
<p>I added a function in my functions.php which allows to add more options to the author profile such as: facebook profile, twitter, image etc etc..</p>
<p>t... | [
{
"answer_id": 77454,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>In the <a href=\"https://dl.dropbox.com/u/4405634/index.php\" rel=\"nofollow\">\"homepage\" code you posted,<... | 2012/12/27 | [
"https://wordpress.stackexchange.com/questions/77403",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7730/"
] | So I have this website that I am building and I am using get\_the\_author\_meta to display various information about the user / author including user image.
I added a function in my functions.php which allows to add more options to the author profile such as: facebook profile, twitter, image etc etc..
this is the bas... | it was my mistake to comment this code, in my real code it is not. anyway I found a solution myself finally.
changing the variable **$user->ID** to **$author** fixed the problem
that's the working code:
```
<img src="<?php echo esc_attr( get_the_author_meta( 'author_pic_sidebar', $author ) ); ?>" alt="" class="author-... |
77,406 | <p>I am trying to get feedback and ideas for solving an information architecture / content management problem using wordpress.</p>
<p>I have a large site ( 1,000+ pages, hundreds of posts ) made up of sections. Each section needs its own secondary navigation menu that contains both pages and custom links. This is ea... | [
{
"answer_id": 77454,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>In the <a href=\"https://dl.dropbox.com/u/4405634/index.php\" rel=\"nofollow\">\"homepage\" code you posted,<... | 2012/12/27 | [
"https://wordpress.stackexchange.com/questions/77406",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25265/"
] | I am trying to get feedback and ideas for solving an information architecture / content management problem using wordpress.
I have a large site ( 1,000+ pages, hundreds of posts ) made up of sections. Each section needs its own secondary navigation menu that contains both pages and custom links. This is easily done, b... | it was my mistake to comment this code, in my real code it is not. anyway I found a solution myself finally.
changing the variable **$user->ID** to **$author** fixed the problem
that's the working code:
```
<img src="<?php echo esc_attr( get_the_author_meta( 'author_pic_sidebar', $author ) ); ?>" alt="" class="author-... |
77,415 | <p>Is there a way to get comments with more than one <code>status</code> using <a href="http://codex.wordpress.org/Function_Reference/get_comments" rel="nofollow"><code>get_comments</code></a> function?</p>
<p>Let's say I would like to get both <code>trash</code> and <code>hold</code> comments.</p>
<p>It is possible ... | [
{
"answer_id": 77412,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 4,
"selected": false,
"text": "<p><code>admin-ajax.php</code> is part of the <a href=\"http://codex.wordpress.org/AJAX_in_Plugins\" rel=\"noref... | 2012/12/27 | [
"https://wordpress.stackexchange.com/questions/77415",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6259/"
] | Is there a way to get comments with more than one `status` using [`get_comments`](http://codex.wordpress.org/Function_Reference/get_comments) function?
Let's say I would like to get both `trash` and `hold` comments.
It is possible to do the same with posts:
```
get_posts(array('post_status' => 'draft,private,trash')... | `admin-ajax.php` is part of the [WordPress AJAX API](http://codex.wordpress.org/AJAX_in_Plugins), and yes, it does handle requests from both backend and front. Try not to worry about the fact that it is in `wp-admin`. I think that is a strange place for it too, but it is not a security problem in itself. How this relat... |
77,432 | <p>I have a custom post type which supports editor. (WordPress version 3.5)</p>
<p>I want to customize the editor for it.</p>
<ol>
<li>Make it readonly</li>
<li>Hide "Add Media" button</li>
<li>Hide HTML editor</li>
<li>Remove status bar showing word count</li>
</ol>
<p>I am using the following code:</p>
<pre><code... | [
{
"answer_id": 77447,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>It should be <code>'media_buttons' => FALSE</code>.</p>\n\n<pre><code>array (\n 'textarea_rows' => 5,\n 'me... | 2012/12/27 | [
"https://wordpress.stackexchange.com/questions/77432",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6076/"
] | I have a custom post type which supports editor. (WordPress version 3.5)
I want to customize the editor for it.
1. Make it readonly
2. Hide "Add Media" button
3. Hide HTML editor
4. Remove status bar showing word count
I am using the following code:
```
add_filter( 'tiny_mce_before_init', function( $args ) {
$... | It should be `'media_buttons' => FALSE`.
```
array (
'textarea_rows' => 5,
'media_buttons' => FALSE,
'teeny' => TRUE,
'tinymce' => TRUE
)
```
… creates this editor:
 |
77,433 | <p>I want to get the ID of the currently logged in user. I've found the function:
<code>get_current_user_id</code> which seems to be working, however I'm not sure what 'current' means in this context.</p>
<p>Meaning if the user views the profile of another user, then will the current user change to become the other us... | [
{
"answer_id": 77447,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>It should be <code>'media_buttons' => FALSE</code>.</p>\n\n<pre><code>array (\n 'textarea_rows' => 5,\n 'me... | 2012/12/27 | [
"https://wordpress.stackexchange.com/questions/77433",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18225/"
] | I want to get the ID of the currently logged in user. I've found the function:
`get_current_user_id` which seems to be working, however I'm not sure what 'current' means in this context.
Meaning if the user views the profile of another user, then will the current user change to become the other user?
In short I'm loo... | It should be `'media_buttons' => FALSE`.
```
array (
'textarea_rows' => 5,
'media_buttons' => FALSE,
'teeny' => TRUE,
'tinymce' => TRUE
)
```
… creates this editor:
 |
77,441 | <p>I'm trying to find how to edit format of <code>bbp_forum_freshness_link()</code> function in bbpress plugin. E.g. currently it displays how many days ago there was last activity and I would like to display date. So if someone would like to share some thoughts or code snippets, that would be great.</p>
| [
{
"answer_id": 77449,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>I cannot test it right now, but it should work like this:</p>\n\n<pre><code>add_filter( 'bbp_get_forum_freshness_link',... | 2012/12/27 | [
"https://wordpress.stackexchange.com/questions/77441",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25149/"
] | I'm trying to find how to edit format of `bbp_forum_freshness_link()` function in bbpress plugin. E.g. currently it displays how many days ago there was last activity and I would like to display date. So if someone would like to share some thoughts or code snippets, that would be great. | I cannot test it right now, but it should work like this:
```
add_filter( 'bbp_get_forum_freshness_link', 'wpse_77441_change_time_format', 10, 2 );
function wpse_77441_change_time_format( $anchor, $forum_id )
{
$last_active = get_post_meta( $forum_id, '_bbp_last_active_time', true );
if ( empty( $last_active... |
77,448 | <p>Here's what I have so far as my notification, but I can't find any information around how to input the user's name, role and site name within those sections. You can see where they are supposed to go. Any help would be much appreciated as I've been stumped for a few days now...</p>
<pre><code>function my_network_no... | [
{
"answer_id": 77451,
"author": "Pontus Abrahamsson",
"author_id": 16722,
"author_profile": "https://wordpress.stackexchange.com/users/16722",
"pm_score": 0,
"selected": false,
"text": "<p>First you need to get the current user data (Logged in). <a href=\"http://codex.wordpress.org/Funct... | 2012/12/27 | [
"https://wordpress.stackexchange.com/questions/77448",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25283/"
] | Here's what I have so far as my notification, but I can't find any information around how to input the user's name, role and site name within those sections. You can see where they are supposed to go. Any help would be much appreciated as I've been stumped for a few days now...
```
function my_network_notice(){
gl... | You can use the `bloginfo( 'name' )` function to display the site name. Information about the current logged in user can be retrieved using the [`get_currentuserinfo()`](http://codex.wordpress.org/Function_Reference/get_currentuserinfo) function.
Here is the fixed code:
```
function my_network_notice(){
global $p... |
77,472 | <p>This query works, but it takes upwards of 20 seconds to run on a Quad Core dedicated server... How can I optimize this?</p>
<pre><code>$slides=get_posts(
array('post_type' => 'any', 'numberposts' => 5, 'orderby' => 'date', 'order' => 'desc', "tax_query" =>
array(
"relation... | [
{
"answer_id": 77451,
"author": "Pontus Abrahamsson",
"author_id": 16722,
"author_profile": "https://wordpress.stackexchange.com/users/16722",
"pm_score": 0,
"selected": false,
"text": "<p>First you need to get the current user data (Logged in). <a href=\"http://codex.wordpress.org/Funct... | 2012/12/28 | [
"https://wordpress.stackexchange.com/questions/77472",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25290/"
] | This query works, but it takes upwards of 20 seconds to run on a Quad Core dedicated server... How can I optimize this?
```
$slides=get_posts(
array('post_type' => 'any', 'numberposts' => 5, 'orderby' => 'date', 'order' => 'desc', "tax_query" =>
array(
"relation" => "OR",
a... | You can use the `bloginfo( 'name' )` function to display the site name. Information about the current logged in user can be retrieved using the [`get_currentuserinfo()`](http://codex.wordpress.org/Function_Reference/get_currentuserinfo) function.
Here is the fixed code:
```
function my_network_notice(){
global $p... |
77,474 | <p>I have 3 custom post types and want the search widget to only search the custom post type it's currently on. ie. If viewing cpt_1 (single or archive) and someone uses the search widget in the sidebar it should only return results of cpt_1. Similarly viewing cpt_2 and searching should only return cpt_2 results.</p>
... | [
{
"answer_id": 96388,
"author": "Shawn",
"author_id": 31712,
"author_profile": "https://wordpress.stackexchange.com/users/31712",
"pm_score": 0,
"selected": false,
"text": "<p>I was able to do this by creating a custom search form by adding this:</p>\n\n<pre><code><input type=\"hidden... | 2012/12/28 | [
"https://wordpress.stackexchange.com/questions/77474",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2932/"
] | I have 3 custom post types and want the search widget to only search the custom post type it's currently on. ie. If viewing cpt\_1 (single or archive) and someone uses the search widget in the sidebar it should only return results of cpt\_1. Similarly viewing cpt\_2 and searching should only return cpt\_2 results.
I t... | You will need to modify searchform.php file in your theme directory.
To search for current post type posts add following code inside the form !
```
$post_type = get_post_type();
if($post_type){
echo '<input type="hidden" name="post_type" value="'.$post_type.'" />';
}
``` |
77,475 | <p>Each of my posts have a single custom field that is a string of a date (not the date of the post). Instead of my theme's current query, which orders by published date, I want to order by this custom field date. How can I change this query (the theme's query) to instead use my custom field (a string representation of... | [
{
"answer_id": 77484,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 2,
"selected": false,
"text": "<p>The <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query\" rel=\"nofollow\">WP_Query</a> page on the ... | 2012/12/28 | [
"https://wordpress.stackexchange.com/questions/77475",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25216/"
] | Each of my posts have a single custom field that is a string of a date (not the date of the post). Instead of my theme's current query, which orders by published date, I want to order by this custom field date. How can I change this query (the theme's query) to instead use my custom field (a string representation of a ... | The [WP\_Query](http://codex.wordpress.org/Class_Reference/WP_Query) page on the Codex has a section on [Order & Orderby Parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Order_.26_Orderby_Parameters).
If you want to order the query by a custom field you should add `'orderby' => 'meta_value'` **AND** you... |
77,480 | <p>I have been trying to get the admin bar to show up under a magento install. I have tried eveything to get it. I can get the user, get the footer but nothing happens to get the admin bar up.</p>
<p>from with in a 1column.phtml I called a </p>
<pre><code> <?php
echo $this->getLayout()->createB... | [
{
"answer_id": 77491,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 0,
"selected": false,
"text": "<p>Add also script and styles:</p>\n\n<pre><code>wp_enqueue_script( 'admin-bar' );\nwp_enqueue_style( 'admin-bar' );\... | 2012/12/28 | [
"https://wordpress.stackexchange.com/questions/77480",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25293/"
] | I have been trying to get the admin bar to show up under a magento install. I have tried eveything to get it. I can get the user, get the footer but nothing happens to get the admin bar up.
from with in a 1column.phtml I called a
```
<?php
echo $this->getLayout()->createBlock('core/template')->setTempla... | Have you tried possible displaying Magento in WordPress? I found an extension that allows Magento blocks within WordPress:
[website](https://wordpress.org/plugins/magento-wordpress-integration/)
Here is the actual plugin site - [MWI](http://www.mwi-plugin.com/documentation/) |
77,501 | <p>Is there a way to add a source link at the end of an article like <a href="http://www.technobuffalo.com/2012/12/27/windows-rt-hacked-to-run-on-htc-hd2/" rel="nofollow">TechnoBuffalo</a> (scroll down to end of post) with a plugin?</p>
<p>If someone could find a plugin or quickly make one for me that would be great.<... | [
{
"answer_id": 77508,
"author": "Pontus Abrahamsson",
"author_id": 16722,
"author_profile": "https://wordpress.stackexchange.com/users/16722",
"pm_score": 3,
"selected": true,
"text": "<p>Thats what meta_boxes are for. First you need to register the metabox within the page or post with t... | 2012/12/28 | [
"https://wordpress.stackexchange.com/questions/77501",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25302/"
] | Is there a way to add a source link at the end of an article like [TechnoBuffalo](http://www.technobuffalo.com/2012/12/27/windows-rt-hacked-to-run-on-htc-hd2/) (scroll down to end of post) with a plugin?
If someone could find a plugin or quickly make one for me that would be great. | Thats what meta\_boxes are for. First you need to register the metabox within the page or post with the function [add\_meta\_box](http://codex.wordpress.org/Function_Reference/add_meta_box). Then you want to get that value with [get\_post\_meta](http://codex.wordpress.org/Function_Reference/get_post_meta) on the page w... |
77,504 | <p>I want to have a link to create a new post that sets the category also.</p>
<p>I have tried <code>wp-admin/post-new.php?post_category=12</code> and <code>wp-admin/post-new.php?cat=12</code>, but neither worked. I also tried using the name rather than the id of the category; which also had no affect.</p>
<p><strong... | [
{
"answer_id": 77506,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 1,
"selected": false,
"text": "<p>I think you can go about the default option <code>default_category</code> and filter <code>option_default_category... | 2012/12/28 | [
"https://wordpress.stackexchange.com/questions/77504",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11882/"
] | I want to have a link to create a new post that sets the category also.
I have tried `wp-admin/post-new.php?post_category=12` and `wp-admin/post-new.php?cat=12`, but neither worked. I also tried using the name rather than the id of the category; which also had no affect.
**How do I create a link to a new post with a ... | Dave James Miller over at GitHub nailed this one for me. None of the work is from me, I'm just posting his code wrapped into a plguin since it works perfectly as advertised:
```
<?php
/**
* Plugin Name: Set default category from url parameter
* Plugin URI: https://gist.github.com/davejamesmiller/1966543
* Descript... |
77,513 | <p>I've dug through every question here on custom post type permalinks, but most seem to be either problems with custom taxonomy rewrites, or the obvious missing of flush_rewrite_rules(). But in my case, I'm only using a custom post type (no taxonomy), set to be hierarchical (so I can assign parent-child relationships)... | [
{
"answer_id": 78535,
"author": "Brady Vercher",
"author_id": 15304,
"author_profile": "https://wordpress.stackexchange.com/users/15304",
"pm_score": 4,
"selected": false,
"text": "<p>This is my first time participating here on Stack Exchange, but I'll give this a go and see if I can hel... | 2012/12/28 | [
"https://wordpress.stackexchange.com/questions/77513",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/838/"
] | I've dug through every question here on custom post type permalinks, but most seem to be either problems with custom taxonomy rewrites, or the obvious missing of flush\_rewrite\_rules(). But in my case, I'm only using a custom post type (no taxonomy), set to be hierarchical (so I can assign parent-child relationships),... | So after confirming that I could get the expected hierarchical page behavior with a completely clean install and just a single CPT declaration, I knew the fault lay somewhere within my own plugin that I use to handle CPT creation (very complex, handles custom metaboxes, taxonomies, etc). Problem was, despite all the ad... |
77,523 | <p>Okay,here's my challenge. My client doesn't like how when you roll over an image in the gallery a tooltip shows up with the image's descritpion, which is taken from it's title tag. But he still wants the image description to show up as the caption when you click on the image and enlarge it.</p>
<p>Here is a link to... | [
{
"answer_id": 77529,
"author": "Jared Cobb",
"author_id": 6737,
"author_profile": "https://wordpress.stackexchange.com/users/6737",
"pm_score": 3,
"selected": true,
"text": "<p>You're in the right file, <code>shutter-reloaded</code> is where you'll want to make the change.</p>\n\n<p>It ... | 2012/12/28 | [
"https://wordpress.stackexchange.com/questions/77523",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25311/"
] | Okay,here's my challenge. My client doesn't like how when you roll over an image in the gallery a tooltip shows up with the image's descritpion, which is taken from it's title tag. But he still wants the image description to show up as the caption when you click on the image and enlarge it.
Here is a link to a page in... | You're in the right file, `shutter-reloaded` is where you'll want to make the change.
It looks like the gallery plugin is parsing the entire document for its links to start. That function is called `init` on line 34. Inside that function, the plugin is going to loop through all the links on the page and determine if i... |
77,532 | <p>I want to add the categories ID to admin page.
I call it for my <code>functions.php</code>: <code>require_once('includes/categories_custom_id.php');</code>
The part of code:</p>
<pre><code>function categoriesColumnsHeader($columns) {
$columns['catID'] = __('ID');
return $columns;
}
add_filter( 'man... | [
{
"answer_id": 77533,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 0,
"selected": false,
"text": "<p>You had it almost all right, but the hook names, where did you get those from?</p>\n\n<p>The following are t... | 2012/12/28 | [
"https://wordpress.stackexchange.com/questions/77532",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I want to add the categories ID to admin page.
I call it for my `functions.php`: `require_once('includes/categories_custom_id.php');`
The part of code:
```
function categoriesColumnsHeader($columns) {
$columns['catID'] = __('ID');
return $columns;
}
add_filter( 'manage_categories_columns', 'categories... | The hooks for taxonomies are:
* `"manage_edit-${taxonomy}_columns"` for the header
* `"manage_edit-${taxonomy}_sortable_columns"` to make columns sortable
* `"manage_${taxonomy}_custom_column"` for the cell content
To catch all taxonomies write:
```
foreach ( get_taxonomies() as $taxonomy ) {
add_action( "manage... |
77,549 | <p>I've never used Wordpress but am considering it for a responsive church website.</p>
<p>BEFORE I purchase space froom a webhost here's my question preceded by a scenario I want:
Scenario: I want my landing page to be very simple. A header, horizontal links below the header, a horizontal slide show beneath the links... | [
{
"answer_id": 77533,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 0,
"selected": false,
"text": "<p>You had it almost all right, but the hook names, where did you get those from?</p>\n\n<p>The following are t... | 2012/12/28 | [
"https://wordpress.stackexchange.com/questions/77549",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25322/"
] | I've never used Wordpress but am considering it for a responsive church website.
BEFORE I purchase space froom a webhost here's my question preceded by a scenario I want:
Scenario: I want my landing page to be very simple. A header, horizontal links below the header, a horizontal slide show beneath the links and then ... | The hooks for taxonomies are:
* `"manage_edit-${taxonomy}_columns"` for the header
* `"manage_edit-${taxonomy}_sortable_columns"` to make columns sortable
* `"manage_${taxonomy}_custom_column"` for the cell content
To catch all taxonomies write:
```
foreach ( get_taxonomies() as $taxonomy ) {
add_action( "manage... |
77,565 | <p>I have the following shortcode in my content</p>
<pre><code>[src]<a href="#">Some Link</a>, <a href="#">Some Other Link</a>[/src]
</code></pre>
<p>My post structure looks like this:</p>
<pre><code><?php echo $content; ?>
<?php wp_link_pages();?>
</code></pre>
<p>If that shortc... | [
{
"answer_id": 77556,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 2,
"selected": true,
"text": "<p>See the question / answer on this <a href=\"https://wordpress.stackexchange.com/questions/76720/how-it-is-possible-... | 2012/12/28 | [
"https://wordpress.stackexchange.com/questions/77565",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25328/"
] | I have the following shortcode in my content
```
[src]<a href="#">Some Link</a>, <a href="#">Some Other Link</a>[/src]
```
My post structure looks like this:
```
<?php echo $content; ?>
<?php wp_link_pages();?>
```
If that shortcode is being used in the content, I'd like for wp\_link\_pages to appear before it, i... | See the question / answer on this [link](https://wordpress.stackexchange.com/questions/76720/how-it-is-possible-to-use-taxonomies-on-attachments).
The answer have 2 different solutions, easy with default categories and taxonomies and also a solution with custom taxonomies only for media. |
77,594 | <p>I have about 4,000 posts. Currently when I click on All Posts (edit.php) it's taking about 10 seconds to load and I'm showing approximately 1000 queries! </p>
<p>Most of them look like...</p>
<pre><code>SELECT t.*, tt.* FROM wp_terms AS t
INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id
INNER JOIN wp_... | [
{
"answer_id": 77556,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 2,
"selected": true,
"text": "<p>See the question / answer on this <a href=\"https://wordpress.stackexchange.com/questions/76720/how-it-is-possible-... | 2012/12/29 | [
"https://wordpress.stackexchange.com/questions/77594",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8558/"
] | I have about 4,000 posts. Currently when I click on All Posts (edit.php) it's taking about 10 seconds to load and I'm showing approximately 1000 queries!
Most of them look like...
```
SELECT t.*, tt.* FROM wp_terms AS t
INNER JOIN wp_term_taxonomy AS tt ON tt.term_id = t.term_id
INNER JOIN wp_term_relationships AS... | See the question / answer on this [link](https://wordpress.stackexchange.com/questions/76720/how-it-is-possible-to-use-taxonomies-on-attachments).
The answer have 2 different solutions, easy with default categories and taxonomies and also a solution with custom taxonomies only for media. |
77,597 | <p>I downloaded the latest version of WordPress (3.5) and created a custom theme. I plan to upload and install it for multiple clients. Is it possible to customize the default settings such as not have the sample post, page, and comment added when it's installed? And set the default theme that is activated?</p>
<p>I l... | [
{
"answer_id": 77606,
"author": "marikamitsos",
"author_id": 17797,
"author_profile": "https://wordpress.stackexchange.com/users/17797",
"pm_score": -1,
"selected": false,
"text": "<p>What you need to do is open the wp-includes/default-constants.php and change the following line (you wil... | 2012/12/29 | [
"https://wordpress.stackexchange.com/questions/77597",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25121/"
] | I downloaded the latest version of WordPress (3.5) and created a custom theme. I plan to upload and install it for multiple clients. Is it possible to customize the default settings such as not have the sample post, page, and comment added when it's installed? And set the default theme that is activated?
I looked at u... | I've answered a [similar Question](https://wordpress.stackexchange.com/a/75436/12615). Basically:
* create a [Dropin](http://hakre.wordpress.com/2010/05/01/must-use-and-drop-ins-plugins/) plugin at the root of `wp-content` named `install.php`
* inside `install.php`, create a new version of the pluggable function [`wp_... |
77,628 | <p>I have added some text input fields to metabox in my custom post. Now whenever I put some data in those text fields in admin panel and click 'save', all data vanishes. Here is the code:</p>
<pre><code><?php
function swpd_render_info_fields()
{
?>
<label for="swpd_comany_addr">Company Address<... | [
{
"answer_id": 77622,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 2,
"selected": false,
"text": "<p>Is it a best practice? Yes.</p>\n\n<p>What will be the behavior of plugins? They should work fine.</p>\n\n<p>What a... | 2012/12/29 | [
"https://wordpress.stackexchange.com/questions/77628",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25348/"
] | I have added some text input fields to metabox in my custom post. Now whenever I put some data in those text fields in admin panel and click 'save', all data vanishes. Here is the code:
```
<?php
function swpd_render_info_fields()
{
?>
<label for="swpd_comany_addr">Company Address</label>
<input type="text... | Is it a best practice? Yes.
What will be the behavior of plugins? They should work fine.
What are the pros and cons of my decision? Pros: More secure. Cons: none.
<http://codex.wordpress.org/Administration_Over_SSL> |
77,639 | <p>I have the WP3.4 and I would like to disable the admin bar. I have tried to do that with many ways, but the admin bar do not display. Is possible to do on this version of WP (3.4) or i make a mistake in the code?
Below are the ways that I've tried.
Thanks in advance.
The 1st : </p>
<pre><code>function my_function_a... | [
{
"answer_id": 77645,
"author": "Jeremy Jared",
"author_id": 5339,
"author_profile": "https://wordpress.stackexchange.com/users/5339",
"pm_score": 4,
"selected": true,
"text": "<p>You need to specify the order or number which signifies when the Hook gets fired. In this case I beleive it'... | 2012/12/29 | [
"https://wordpress.stackexchange.com/questions/77639",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I have the WP3.4 and I would like to disable the admin bar. I have tried to do that with many ways, but the admin bar do not display. Is possible to do on this version of WP (3.4) or i make a mistake in the code?
Below are the ways that I've tried.
Thanks in advance.
The 1st :
```
function my_function_admin_bar(){
... | You need to specify the order or number which signifies when the Hook gets fired. In this case I beleive it's `0` and the filter is: `wp_admin_bar_render`. The action to remove the function I believe is:
```
remove_action( 'in_admin_header', 'wp_admin_bar_render', 0);
```
The Function Reference:
[Function Reference... |
77,661 | <p>I've got custom template that I want to display paged blog posts. This is the beginning of my file:</p>
<pre><code>$wp_query = new WP_Query($args);
if($wp_query->have_posts()){
while($wp_query->have_posts()){ $wp_query->the_post();
//something...
<?php next_posts_link('Older ... | [
{
"answer_id": 77665,
"author": "Ed Burns",
"author_id": 25356,
"author_profile": "https://wordpress.stackexchange.com/users/25356",
"pm_score": 2,
"selected": false,
"text": "<p>Looking at the wordpress source, it looks like next_posts_link uses the global var $paged. My guess is that ... | 2012/12/29 | [
"https://wordpress.stackexchange.com/questions/77661",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17167/"
] | I've got custom template that I want to display paged blog posts. This is the beginning of my file:
```
$wp_query = new WP_Query($args);
if($wp_query->have_posts()){
while($wp_query->have_posts()){ $wp_query->the_post();
//something...
<?php next_posts_link('Older Entries'); ?>
<?php pr... | `next_posts_link` and `previous_posts_link` use the global `$wp_query`.
>
>
> ```
> function get_next_posts_link( $label = null, $max_page = 0 ) {
> global $paged, $wp_query;
>
> ```
>
> <http://core.trac.wordpress.org/browser/tags/3.5/wp-includes/link-template.php#L1523>
>
>
>
That means you need to do s... |
77,664 | <p>I'm using a vanilla up-to-date WordPress install. I've noticed that the visual editor, even in text mode, does not show <code><p></code> or <code><br></code> tags, and if you insert them it strips them out and replaces them with actual linebreaks, but the rendering still seems to work out okay. What I as... | [
{
"answer_id": 77668,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>br and p tags get stripped out and converted to newlines, they're not added until the post content is output. See t... | 2012/12/30 | [
"https://wordpress.stackexchange.com/questions/77664",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1390/"
] | I'm using a vanilla up-to-date WordPress install. I've noticed that the visual editor, even in text mode, does not show `<p>` or `<br>` tags, and if you insert them it strips them out and replaces them with actual linebreaks, but the rendering still seems to work out okay. What I assume is going on is that the tags are... | br and p tags get stripped out and converted to newlines, they're not added until the post content is output. See the codex entry for the [`wpautop`](http://codex.wordpress.org/Function_Reference/wpautop) function, this is what is converting those newlines to br and p tags on the\_content. It's difficult to say what ex... |
77,679 | <p>Suppose I have 3 categories (cat 1 , cat 2 , cat 3) , and my blog home page shows 6 recent posts . I want to show 2 recent posts from every category. </p>
<p>How can I do it?</p>
| [
{
"answer_id": 77688,
"author": "K Themes",
"author_id": 24783,
"author_profile": "https://wordpress.stackexchange.com/users/24783",
"pm_score": 0,
"selected": false,
"text": "<p>As far as I know you can only do this by using multiple loops - one for each category.\nHope this link helps:... | 2012/12/30 | [
"https://wordpress.stackexchange.com/questions/77679",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23926/"
] | Suppose I have 3 categories (cat 1 , cat 2 , cat 3) , and my blog home page shows 6 recent posts . I want to show 2 recent posts from every category.
How can I do it? | You can do it using the following loop:
```
<?php
$cat_477 = new WP_Query();
$cat_477->query('cat=477&showposts=4');
while($cat_477->have_posts()) : $cat_477->the_post(); ?>
<h3><a href=" <?php the_permalink(); ?>"><?php the_title(); ?></a></h3>
<p><?php echo get_the_excerpt(); ?></p>
<?php endwhil... |
77,690 | <p>I wish to use the excerpt of a post in the meta description for better SEO, so I am using the get_the_excerpt() function to get the post's excerpt. However, I noticed that at the end it is adding [...] when the post's content is not separated by the More separator, and when it is longer than the configured maximum l... | [
{
"answer_id": 77691,
"author": "K Themes",
"author_id": 24783,
"author_profile": "https://wordpress.stackexchange.com/users/24783",
"pm_score": 0,
"selected": false,
"text": "<pre><code>function change_excerpt_more( $more ) {\n return '[.....]';\n}\nadd_filter('excerpt_more', 'change... | 2012/12/30 | [
"https://wordpress.stackexchange.com/questions/77690",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21333/"
] | I wish to use the excerpt of a post in the meta description for better SEO, so I am using the get\_the\_excerpt() function to get the post's excerpt. However, I noticed that at the end it is adding [...] when the post's content is not separated by the More separator, and when it is longer than the configured maximum le... | Don't use `get_the_excerpt`. Just do something like:
```
if (is_singular() && isset($post->post_excerpt)) {
echo '<meta name="description" content="'.esc_attr($post->post_excerpt).'" />';
}
```
`$post` is populated long before the Loop. For "single" pages it will be populated with the post to be displayed. You c... |
77,693 | <p>I have customised the welcome panel on the dashboard for users with information in. I then hid the "Dismiss" button and added CSS to make the welcome panel always visible. Using the 'welcome_panel' hook.</p>
<p>This works fine for Admins but the Welcome Panel is not displayed for other users such as editors and aut... | [
{
"answer_id": 77703,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>As you already discovered, the display conditions for that panel are <a href=\"http://core.trac.wordpress.org... | 2012/12/30 | [
"https://wordpress.stackexchange.com/questions/77693",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25372/"
] | I have customised the welcome panel on the dashboard for users with information in. I then hid the "Dismiss" button and added CSS to make the welcome panel always visible. Using the 'welcome\_panel' hook.
This works fine for Admins but the Welcome Panel is not displayed for other users such as editors and authors. Its... | This is how I solved it:
In functions.php
```
// Custom Dashboard
function my_custom_dashboard() {
$screen = get_current_screen();
if( $screen->base == 'dashboard' ) {
include 'admin/dashboard-panel.php';
}
}
add_action('admin_notices', 'my_custom_dashboard');
```
dashboard-panel.php
```
<!-- H... |
77,709 | <p>So is it possible to do something like this with <code>add_action</code>?</p>
<pre><code>class class{}
$my_class = new class;
add_action('init', 'my_class');
</code></pre>
| [
{
"answer_id": 77713,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 4,
"selected": true,
"text": "<p>You can do this:</p>\n\n<pre><code>class testclass {\n function test() {\n echo 'howdy';\n }\n}\nadd_acti... | 2012/12/30 | [
"https://wordpress.stackexchange.com/questions/77709",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22622/"
] | So is it possible to do something like this with `add_action`?
```
class class{}
$my_class = new class;
add_action('init', 'my_class');
``` | You can do this:
```
class testclass {
function test() {
echo 'howdy';
}
}
add_action('wp_head',array('testclass','test'));
```
Or this:
```
$t = new testclass();
add_action('wp_head',array($t,'test'));
```
It doesn't work like...
```
$t = new testclass();
add_action('wp_head','t');
// or this either, fo... |
77,745 | <p>I've been using the excellent <a href="http://co.deme.me/projects/flickr-gallery/" rel="nofollow" title="Flickr Gallery">Flickr Gallery</a> plugin for a while but while upgrading a site to WP3.5 and the Twenty Twelve theme, I stumbled across oEmbeds and notice that Flickr is supported natively.</p>
<p>I did a quick... | [
{
"answer_id": 77767,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 2,
"selected": false,
"text": "<p>It doesn't have to do with the theme.</p>\n\n<p>Flickr oEmbed is returning an image file which name ends wit... | 2012/12/30 | [
"https://wordpress.stackexchange.com/questions/77745",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25390/"
] | I've been using the excellent [Flickr Gallery](http://co.deme.me/projects/flickr-gallery/ "Flickr Gallery") plugin for a while but while upgrading a site to WP3.5 and the Twenty Twelve theme, I stumbled across oEmbeds and notice that Flickr is supported natively.
I did a quick test and sure enough, simply placing the ... | It doesn't have to do with the theme.
Flickr oEmbed is returning an image file which name ends with [`_n.jpg`](https://i.stack.imgur.com/f31ow.jpg), and effectively it has a width of 320px. The bigger version ends with [`_b.jpg`](http://farm9.staticflickr.com/8221/8299345724_6e3498ee47_b.jpg)
The filter hook that we ... |
77,781 | <p>I am using WooCommerce on one of the site. I need to add one more field at the time of checkout to ask buyer wheteher to issue Invoice on his name or the name of his business?</p>
<p>Any advise how to do that? Or something like this is already there in Woo Commerce? Or what could be the simplest way to do that?</p>... | [
{
"answer_id": 77787,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 1,
"selected": false,
"text": "<p>The plugin is packed with hooks and provides an <a href=\"http://wcdocs.woothemes.com/\" rel=\"nofollow nore... | 2012/12/31 | [
"https://wordpress.stackexchange.com/questions/77781",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22618/"
] | I am using WooCommerce on one of the site. I need to add one more field at the time of checkout to ask buyer wheteher to issue Invoice on his name or the name of his business?
Any advise how to do that? Or something like this is already there in Woo Commerce? Or what could be the simplest way to do that? | As it happens, I just blogged about this yesterday, for how to [add a subscribe to mailing list checkbox](http://snippets.webaware.com.au/snippets/subscribe-to-mailing-list-in-woocommerce-checkout/). The key points are:
* look at the [WooCommerce tutorial](https://docs.woocommerce.com/document/tutorial-customising-che... |