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 |
|---|---|---|---|---|---|---|
53,944 | <p>I'd like to add a link to BuddyPress' My Favourite Topics in a Custom Menu. Is there a way to use the current logged in user's username in the link? </p>
<p>I mean like the <code>%category%</code> in the permalinks.</p>
| [
{
"answer_id": 54136,
"author": "Pontus Abrahamsson",
"author_id": 16722,
"author_profile": "https://wordpress.stackexchange.com/users/16722",
"pm_score": -1,
"selected": false,
"text": "<p>Is there something like current_user_can()... or is_super_admin near the edit link? cus it sounds ... | 2012/06/01 | [
"https://wordpress.stackexchange.com/questions/53944",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4209/"
] | I'd like to add a link to BuddyPress' My Favourite Topics in a Custom Menu. Is there a way to use the current logged in user's username in the link?
I mean like the `%category%` in the permalinks. | Only super users can edit profiles in Wordpress Multisite. This is because user profiles are site-independent in multisite. A user has one profile, but may be a member of multiple sites with multiple owners. You can't let one of them screw around with the user's profile...
If you really want to take control of this, y... |
53,950 | <p>I know how to add a Walker to a custom menu created by the theme (menu named <code>primary</code> in this example), but how can I target a menu thats created in a widget with the default wordpress custom menu widget?</p>
<pre><code>if ( has_nav_menu( 'primary' ) ) {
$args = array(
'menu' => 'main-menu',
... | [
{
"answer_id": 53952,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 5,
"selected": true,
"text": "<p>If you look at implementation of <code>WP_Nav_Menu_Widget</code> class you will see the following code: <... | 2012/06/01 | [
"https://wordpress.stackexchange.com/questions/53950",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15642/"
] | I know how to add a Walker to a custom menu created by the theme (menu named `primary` in this example), but how can I target a menu thats created in a widget with the default wordpress custom menu widget?
```
if ( has_nav_menu( 'primary' ) ) {
$args = array(
'menu' => 'main-menu',
'menu_id' => 'main-menu',
... | If you look at implementation of `WP_Nav_Menu_Widget` class you will see the following code:
```
function widget($args, $instance) {
// Get menu
$nav_menu = ! empty( $instance['nav_menu'] ) ? wp_get_nav_menu_object( $instance['nav_menu'] ) : false;
if ( !$nav_menu )
return;
$instance['title'... |
53,957 | <p>I'm setting up my wordpress <a href="http://heavensgatewinery.ca/test" rel="nofollow">website on my server now</a> and have the rotating images on the home page and it's beautiful, but now I want to have a conditional tag telling wordpress if it's not the home page use the featured images per each page.</p>
<p>This... | [
{
"answer_id": 53959,
"author": "Michelle",
"author_id": 16,
"author_profile": "https://wordpress.stackexchange.com/users/16",
"pm_score": 2,
"selected": false,
"text": "<p>You might want to try <code>is_front_page()</code> instead of <code>is_home()</code>. <code>is_home()</code> return... | 2012/06/01 | [
"https://wordpress.stackexchange.com/questions/53957",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25108/"
] | I'm setting up my wordpress [website on my server now](http://heavensgatewinery.ca/test) and have the rotating images on the home page and it's beautiful, but now I want to have a conditional tag telling wordpress if it's not the home page use the featured images per each page.
This is the code I've placed onto my hom... | There are multiple issues that I think you want to adjust:
1. You open an extra PHP tag before the second `if` statement. That shouldn't be there.
2. Make sure that `is_home()` is what you want. If you have a static front page (set in Settings > Reading), then you actually want `is_front_page()`. Think of `is_home()` ... |
53,967 | <p>I'm trying to delete all child posts when the parent is deleted. </p>
<p>The parent post deletes just fine, but the child posts are not properly deleting. </p>
<p>Here's the code I have in place now:</p>
<pre><code>$args = array(
'post_parent' => $parentid,
'post_type' => 'custom-type'
... | [
{
"answer_id": 53989,
"author": "Barry Kooij",
"author_id": 16655,
"author_profile": "https://wordpress.stackexchange.com/users/16655",
"pm_score": 3,
"selected": true,
"text": "<p>Try it like this:</p>\n\n<pre><code>$args = array( \n 'post_parent' => $parentid,\n 'post_type' =&... | 2012/06/01 | [
"https://wordpress.stackexchange.com/questions/53967",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12484/"
] | I'm trying to delete all child posts when the parent is deleted.
The parent post deletes just fine, but the child posts are not properly deleting.
Here's the code I have in place now:
```
$args = array(
'post_parent' => $parentid,
'post_type' => 'custom-type'
);
$posts = get_posts( $args ... | Try it like this:
```
$args = array(
'post_parent' => $parentid,
'post_type' => 'custom-type'
);
$posts = get_posts( $args );
if (is_array($posts) && count($posts) > 0) {
// Delete all the Children of the Parent Page
foreach($posts as $post){
wp_delete_post($post->ID, true);
}
}
// ... |
53,970 | <p>Does anyone have any idea how to sanitize CSS entered via user input? I am concerned about cross-site scripting via CSS. I am using wp_filter_kses to clean up user entered HTML, but I need a like solution for user entered styles. So far I am using the following ugly and incomplete function but I'd like something ... | [
{
"answer_id": 53976,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": -1,
"selected": false,
"text": "<p>Well, if you want the 50mm-barrel gun approach, you could use <a href=\"http://codex.wordpress.org/Functio... | 2012/06/01 | [
"https://wordpress.stackexchange.com/questions/53970",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16662/"
] | Does anyone have any idea how to sanitize CSS entered via user input? I am concerned about cross-site scripting via CSS. I am using wp\_filter\_kses to clean up user entered HTML, but I need a like solution for user entered styles. So far I am using the following ugly and incomplete function but I'd like something more... | The best approach I found was to incorporate CSSTidy into my plugin. I took a page from JetPack which has a Custom CSS feature.
JetPack's CSSTidy implementation is contained in the Jetpack\_Safe\_CSS class as function, filter\_attr. I couldn't entirely figure out why JetPack was nesting the user entered CSS inside a '... |
53,982 | <p>I have 2 custom taxonomies, each with a number of terms:</p>
<pre><code>tax1
term1_1
term1_2
tax2
term2_1
term2_2
term2_3
</code></pre>
<p>I am trying to have each taxonomy usea different template file for each its single-term archive pages. I.E. <code>term1_1 and term1_2</code> use one template, while... | [
{
"answer_id": 53987,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 2,
"selected": false,
"text": "<p>Check WordPress <a href=\"http://codex.wordpress.org/images/1/18/Template_Hierarchy.png\" rel=\"nofollow... | 2012/06/01 | [
"https://wordpress.stackexchange.com/questions/53982",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5846/"
] | I have 2 custom taxonomies, each with a number of terms:
```
tax1
term1_1
term1_2
tax2
term2_1
term2_2
term2_3
```
I am trying to have each taxonomy usea different template file for each its single-term archive pages. I.E. `term1_1 and term1_2` use one template, while `term2_1 - 3` use a second one. I can ... | I would intercept the template loader at `template_redirect`:
```
function wpse53892_taxonomy_template_redirect() {
// code goes here
}
add_action( 'template_redirect', 'wpse53892_taxonomy_template_redirect' );
```
Then, you would check to see if the query is a custom taxonomy:
```
if ( is_tax() ) {
// This... |
53,988 | <p>i have a page who display the latest posts of an author. But when the author has no post i get a display message</p>
<blockquote>
<p>Warning: rsort() expects parameter 1 to be array, null given in ...</p>
</blockquote>
<p>Here the script</p>
<pre><code>function wpmu_latest_post_auther($authorId,$how_many = 10, ... | [
{
"answer_id": 53987,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 2,
"selected": false,
"text": "<p>Check WordPress <a href=\"http://codex.wordpress.org/images/1/18/Template_Hierarchy.png\" rel=\"nofollow... | 2012/06/01 | [
"https://wordpress.stackexchange.com/questions/53988",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12003/"
] | i have a page who display the latest posts of an author. But when the author has no post i get a display message
>
> Warning: rsort() expects parameter 1 to be array, null given in ...
>
>
>
Here the script
```
function wpmu_latest_post_auther($authorId,$how_many = 10, $how_many_words = 50, $more_text = "[...]",... | I would intercept the template loader at `template_redirect`:
```
function wpse53892_taxonomy_template_redirect() {
// code goes here
}
add_action( 'template_redirect', 'wpse53892_taxonomy_template_redirect' );
```
Then, you would check to see if the query is a custom taxonomy:
```
if ( is_tax() ) {
// This... |
53,997 | <p>As an example, let's say I set my "About Us" page (slug: about-us) as my home page static page. Upon doing this, when someone requests mysite.com/about-us, WordPress does a nice redirect to the home page so that I don't end up with duplicate content of having two pages pointing to the same content.</p>
<p>I'm tryin... | [
{
"answer_id": 53998,
"author": "GhostToast",
"author_id": 13676,
"author_profile": "https://wordpress.stackexchange.com/users/13676",
"pm_score": 0,
"selected": false,
"text": "<p>I believe this page will have the best information for you:\n<a href=\"http://codex.wordpress.org/Class_Ref... | 2012/06/01 | [
"https://wordpress.stackexchange.com/questions/53997",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6620/"
] | As an example, let's say I set my "About Us" page (slug: about-us) as my home page static page. Upon doing this, when someone requests mysite.com/about-us, WordPress does a nice redirect to the home page so that I don't end up with duplicate content of having two pages pointing to the same content.
I'm trying to find ... | First off, the behavior you describe is not a *redirect* but a *URL rewrite*.
That being said, there's a WordPress [option](http://codex.wordpress.org/Option_Reference) called `page_on_front` that is set to the page ID of the static page to be used as a front page. This option's value is only relevant if the option `s... |
54,006 | <p>So I am attempting to filter out certain posts in the get_posts call. Essentially, I want to be able to specify a certain block of posts, and only get the posts that correspond with the block. Right now I have a table that contains both block IDs and post IDs, so I have been looking into using the posts_join and the... | [
{
"answer_id": 54017,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 0,
"selected": false,
"text": "<p>Depending on the flow of interaction I would store the information in either user_meta or post_meta. If the user ... | 2012/06/01 | [
"https://wordpress.stackexchange.com/questions/54006",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7402/"
] | So I am attempting to filter out certain posts in the get\_posts call. Essentially, I want to be able to specify a certain block of posts, and only get the posts that correspond with the block. Right now I have a table that contains both block IDs and post IDs, so I have been looking into using the posts\_join and the ... | Why not use the `include` (or conversely, `exclude`) argument for `get_posts()`? It takes an array of post IDs. |
54,016 | <p>I would like to copy all the posts, users, and pages from my main site into a sub site. I've tried exporting and importing, but the main site has thousands of entries and hundreds of users, and the import seems to fail at around 250 posts without an error. Any ideas for the migration would be greatly appreciated.</p... | [
{
"answer_id": 54053,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 1,
"selected": false,
"text": "<p>Unfortunately, this fine plugin (<a href=\"http://wordpress.org/extend/plugins/add-cloned-sites-for-wpmu-bat... | 2012/06/01 | [
"https://wordpress.stackexchange.com/questions/54016",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5927/"
] | I would like to copy all the posts, users, and pages from my main site into a sub site. I've tried exporting and importing, but the main site has thousands of entries and hundreds of users, and the import seems to fail at around 250 posts without an error. Any ideas for the migration would be greatly appreciated. | I was able to use the standard WordPress import and export by raising the maximum memory limit in `wp-config.php`:
```
define( 'WP_MAX_MEMORY_LIMIT', '1024M' );
``` |
54,032 | <p><img src="https://i.stack.imgur.com/Fy2xm.jpg" alt="enter image description here"></p>
<p>To The right are the taxonomies, under them are the different terms, based on the radio selection of the terms..... i have to filter and display the car models.......</p>
<p>The Live working can be found here, <a href="http:/... | [
{
"answer_id": 55677,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 1,
"selected": false,
"text": "<p>Here's how you do it, </p>\n\n<pre><code><form name=\"filterby\" action=\"\" method=\"GET\">\n\n <inp... | 2012/06/02 | [
"https://wordpress.stackexchange.com/questions/54032",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14583/"
] | 
To The right are the taxonomies, under them are the different terms, based on the radio selection of the terms..... i have to filter and display the car models.......
The Live working can be found here, [follow the link](http://carandhalf.com/new-ca... | Here's how you do it,
```
<form name="filterby" action="" method="GET">
<input type="radio" name="cartype" value="bentley" OnChange="document.filterby.submit()" /> Bentley<br />
<input type="radio" name="cartype" value="bmw" OnChange="document.filterby.submit()"/> BMW
<input type="radio" name="cartype" v... |
54,036 | <p>in a blow I'm working on there is a navigation menu made of pages and subpages. I didn't code it, so I'm not completely sure how it works, but after reading some code it seems that the menu is generated by this line in the navivation.php file.</p>
<pre><code><?php wp_list_pages('title_li=&depth='.$bpt_naviga... | [
{
"answer_id": 54040,
"author": "Michael",
"author_id": 4884,
"author_profile": "https://wordpress.stackexchange.com/users/4884",
"pm_score": 2,
"selected": false,
"text": "<p>try to edit your code to:</p>\n\n<pre><code><?php wp_list_pages('title_li=&depth='.$bpt_navigation_depth.... | 2012/06/02 | [
"https://wordpress.stackexchange.com/questions/54036",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13206/"
] | in a blow I'm working on there is a navigation menu made of pages and subpages. I didn't code it, so I'm not completely sure how it works, but after reading some code it seems that the menu is generated by this line in the navivation.php file.
```
<?php wp_list_pages('title_li=&depth='.$bpt_navigation_depth.'&sort_col... | try to edit your code to:
```
<?php wp_list_pages('title_li=&depth='.$bpt_navigation_depth.'&sort_column=menu_order&exclude=17'); ?>
``` |
54,037 | <p>I need a way to set the default avatar for buddypress's <code>bp_core_fetch_avatar</code>. Using the regular <code>get_avatar</code> you can just set the <code>$default</code> path but I can't find anyway to do it with buddypress's function. For instance, I use this function to get the full size avatar for a post au... | [
{
"answer_id": 54285,
"author": "shanebp",
"author_id": 16575,
"author_profile": "https://wordpress.stackexchange.com/users/16575",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n <p>I need a way to set the default avatar for buddypress's bp_core_fetch_avatar.</p>\n</blockquot... | 2012/06/02 | [
"https://wordpress.stackexchange.com/questions/54037",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12700/"
] | I need a way to set the default avatar for buddypress's `bp_core_fetch_avatar`. Using the regular `get_avatar` you can just set the `$default` path but I can't find anyway to do it with buddypress's function. For instance, I use this function to get the full size avatar for a post author but adding `default => "mysite.... | As @shanebp said:
>
> You can define the default avatar site-wide by using BP\_AVATAR\_DEFAULT
>
>
>
For this you can define the constant(s) `BP_AVATAR_DEFAULT` and/or `BP_AVATAR_DEFAULT_THUMB` inside the [`bp-custom.php`](http://codex.buddypress.org/plugindev/bp-custom-php/) as described at the buddypress codex ... |
54,044 | <p>I have various different extra profile fields which I have set in functions.php however with the upload one if a user uploads an image and saves the form the image is set, however if they go back and edit another field it sets the image field to null.</p>
<p>Here is the code I have in my functions.php file. Any hel... | [
{
"answer_id": 54047,
"author": "Johannes Pille",
"author_id": 9745,
"author_profile": "https://wordpress.stackexchange.com/users/9745",
"pm_score": 3,
"selected": true,
"text": "<p>The last parameter of <a href=\"http://codex.wordpress.org/Function_Reference/update_user_meta\" rel=\"nof... | 2012/06/02 | [
"https://wordpress.stackexchange.com/questions/54044",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16517/"
] | I have various different extra profile fields which I have set in functions.php however with the upload one if a user uploads an image and saves the form the image is set, however if they go back and edit another field it sets the image field to null.
Here is the code I have in my functions.php file. Any help would be... | The last parameter of [`update_user_meta()`](http://codex.wordpress.org/Function_Reference/update_user_meta), the previous value, is an optional parameter. If it's set it checks whether the value in the database is indeed the one you fed `update_user_meta()`. If you set that paramteter by grabbing the value from the da... |
54,056 | <p>I was trying this code to get current user info, but showing nothing. My WordPress version is 3.3.1</p>
<pre><code><?php
wp_get_current_user();
/**
* @example Safe usage: $current_user = wp_get_current_user();
* if ( !($current_user instanceof WP_User) )
* return;
*/
echo 'Us... | [
{
"answer_id": 54060,
"author": "Johannes Pille",
"author_id": 9745,
"author_profile": "https://wordpress.stackexchange.com/users/9745",
"pm_score": 4,
"selected": true,
"text": "<p>Have you tried to go with the \"Safe usage\" alternative given in the commented section?</p>\n\n<p>I hones... | 2012/06/02 | [
"https://wordpress.stackexchange.com/questions/54056",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16623/"
] | I was trying this code to get current user info, but showing nothing. My WordPress version is 3.3.1
```
<?php
wp_get_current_user();
/**
* @example Safe usage: $current_user = wp_get_current_user();
* if ( !($current_user instanceof WP_User) )
* return;
*/
echo 'Username: ' . $curre... | Have you tried to go with the "Safe usage" alternative given in the commented section?
I honestly don't have any experience with `wp_get_current_user()`, since I never use it, but anyhow, this ought to work:
```
global $current_user;
echo 'Username: ' . $current_user->user_login . '<br />';
echo 'User email: ' . $cu... |
54,064 | <p>Is there some way to get the $handle for each script that has been enqueued?</p>
<p>Is there some array that holds all the handles so that I can loop through it and do something using each $handle?</p>
| [
{
"answer_id": 54066,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 6,
"selected": true,
"text": "<p>the <code>$wp_scripts</code> global holds all the script data:</p>\n\n<pre><code>function wpa54064_inspect_scripts()... | 2012/06/03 | [
"https://wordpress.stackexchange.com/questions/54064",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1226/"
] | Is there some way to get the $handle for each script that has been enqueued?
Is there some array that holds all the handles so that I can loop through it and do something using each $handle? | the `$wp_scripts` global holds all the script data:
```
function wpa54064_inspect_scripts() {
global $wp_scripts;
foreach( $wp_scripts->queue as $handle ) :
echo $handle;
endforeach;
}
add_action( 'wp_print_scripts', 'wpa54064_inspect_scripts' );
``` |
54,094 | <p>I'm trying to set the post thumbnail (featured image) with javascript from an existing image in the media gallery. I would consider a php-based option too I suppose (one that would require clicking update before the images show up).</p>
<p><strong>Some Background</strong></p>
<p>I'm building a site for a music ve... | [
{
"answer_id": 54492,
"author": "fdsa",
"author_id": 8288,
"author_profile": "https://wordpress.stackexchange.com/users/8288",
"pm_score": 2,
"selected": false,
"text": "<p>You could display the images in a <a href=\"http://www.marghoobsuleman.com/jquery-image-dropdown\" rel=\"nofollow n... | 2012/06/03 | [
"https://wordpress.stackexchange.com/questions/54094",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5846/"
] | I'm trying to set the post thumbnail (featured image) with javascript from an existing image in the media gallery. I would consider a php-based option too I suppose (one that would require clicking update before the images show up).
**Some Background**
I'm building a site for a music venue with a custom "event" post-... | You need to do an ajax call with action: 'set-post-thumbnail'
Check in admin-ajax.php (line 1477 in 3.3.2) for the expected values and nonce, but in general you need to send post\_id, attachment\_id and nonce.
The nonce should come from: wp\_create\_nonce( "set\_post\_thumbnail-$post\_id" );
The admin does something... |
54,095 | <p>I have a case where that are a lot of widgets in several custom sidebars. I am wondering if there is a simple way to alter the titles of each widget dynamically. Typically a widget has a title field you can set manually or on the plugin itself.</p>
<p>I wish to add something like a meta field value per post to each... | [
{
"answer_id": 54096,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 4,
"selected": true,
"text": "<p>You can use the <a href=\"https://github.com/WordPress/WordPress/blob/3.3.2/wp-includes/widgets.php#L169\"... | 2012/06/03 | [
"https://wordpress.stackexchange.com/questions/54095",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1509/"
] | I have a case where that are a lot of widgets in several custom sidebars. I am wondering if there is a simple way to alter the titles of each widget dynamically. Typically a widget has a title field you can set manually or on the plugin itself.
I wish to add something like a meta field value per post to each widget ti... | You can use the [`widget_display_callback`](https://github.com/WordPress/WordPress/blob/3.3.2/wp-includes/widgets.php#L169) (fired, predictably, just prior to displaying a widget :) ).
```
add_filter('widget_display_callback','wptuts54095_widget_custom_title',10,3);
function wptuts54095_widget_custom_title($instance... |
54,116 | <p>Anyone know how to add quick comment moderation links for users who have permission to add/edit posts and comments? (Upprove / Unappove / Edit / Spam / Trash ). <strong>Note:</strong> in my comments.php I call the loop with <code><?php wp_list_comments(); ?></code> </p>
| [
{
"answer_id": 54122,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>Per default <code>wp_list_comments()</code> calls the class <code>Walker_Comment</code>. Its method <code>start_el()</c... | 2012/06/04 | [
"https://wordpress.stackexchange.com/questions/54116",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15801/"
] | Anyone know how to add quick comment moderation links for users who have permission to add/edit posts and comments? (Upprove / Unappove / Edit / Spam / Trash ). **Note:** in my comments.php I call the loop with `<?php wp_list_comments(); ?>` | Per default `wp_list_comments()` calls the class `Walker_Comment`. Its method `start_el()` calls `edit_comment_link()` and here we find a filter for your question: It is called `'edit_comment_link'` and it passes two variables, the link text and the comment ID, which we can use.
The URLs to mark a comment as spam or t... |
54,139 | <p>Hi I installed w3 total cache on my nginx powered site, I'm having errors however.
For example when I enable page caching disk:enhanced I get:</p>
<p>It appears Page Cache URL rewriting is not working. If using apache, verify that the server configuration allows .htaccess or if using nginx verify all configuration... | [
{
"answer_id": 54144,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 2,
"selected": false,
"text": "<p>You need to set the path to your .conf file in the plugin general options then let W3 Total write to the file.</p>... | 2012/06/04 | [
"https://wordpress.stackexchange.com/questions/54139",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5844/"
] | Hi I installed w3 total cache on my nginx powered site, I'm having errors however.
For example when I enable page caching disk:enhanced I get:
It appears Page Cache URL rewriting is not working. If using apache, verify that the server configuration allows .htaccess or if using nginx verify all configuration files are... | Your main configuration file at `/etc/nginx/nginx.conf` has [some pitfalls](http://wiki.nginx.org/Pitfalls) and it shouldn't be that complex. Let me share a simpler version for you to start with...
```
server {
server_name www.yourdomain.com;
# please replace the root path
# ex: /srv/www/mysite.com/public_html
... |
54,142 | <p>I want to change the order of a feed using pre_get_posts filter. But I want to exclude dates older than today. I see how one could do that if the date were in a meta key, but the date is in post_date. How can I check post_date to only show posts later than today? The site shows future post dates.</p>
<pre><code>... | [
{
"answer_id": 54151,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": false,
"text": "<p>You can't really check <code>post_date</code> in <code>pre_get_posts</code>, because, well, the action fire... | 2012/06/04 | [
"https://wordpress.stackexchange.com/questions/54142",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16725/"
] | I want to change the order of a feed using pre\_get\_posts filter. But I want to exclude dates older than today. I see how one could do that if the date were in a meta key, but the date is in post\_date. How can I check post\_date to only show posts later than today? The site shows future post dates.
```
<?php
functi... | You can't really check `post_date` in `pre_get_posts`, because, well, the action fires *before* (`pre_`...) the posts have actually been fetched (...`get_posts`). :)
But, you *can* use `$query->set()` to *add date parameters* to the query. This is taken from [an example in the **`WP_Query()`** Codex entry](http://code... |
54,162 | <p>How can I get the number of widgets that are active on a specific sidebar? Is there a core function for this?</p>
<p>I want to add a class to each widget on a sidebar based on how many of them are displayed.</p>
<p>Thanks.</p>
| [
{
"answer_id": 54172,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 0,
"selected": false,
"text": "<pre><code>function wpse_54162_get_widgets_count( $sidebar_index ) {\n global $wp_registered_sidebars;\n... | 2012/06/04 | [
"https://wordpress.stackexchange.com/questions/54162",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15859/"
] | How can I get the number of widgets that are active on a specific sidebar? Is there a core function for this?
I want to add a class to each widget on a sidebar based on how many of them are displayed.
Thanks. | After some research and based on the answer from Eugene Manuilov I made a function that adds custom classes to widgets in a specific sidebar ('sidebar-bottom' in my case) based on the number of widgets set in that sidebar. This will suit perfectly in horizontal sidebars and themes based on twitter bootstrap that need s... |
54,183 | <p>Some of my posts' titles have leading words, followed by a colon. I am removing the leading words and the column of every post title in the loop with the following:</p>
<pre><code><?php
$title = get_the_title();
$title_array = explode(':', $title);
$first_word = $title_array[1];
echo $first_word;
?>
... | [
{
"answer_id": 54172,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 0,
"selected": false,
"text": "<pre><code>function wpse_54162_get_widgets_count( $sidebar_index ) {\n global $wp_registered_sidebars;\n... | 2012/06/04 | [
"https://wordpress.stackexchange.com/questions/54183",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9636/"
] | Some of my posts' titles have leading words, followed by a colon. I am removing the leading words and the column of every post title in the loop with the following:
```
<?php
$title = get_the_title();
$title_array = explode(':', $title);
$first_word = $title_array[1];
echo $first_word;
?>
```
How can I also ... | After some research and based on the answer from Eugene Manuilov I made a function that adds custom classes to widgets in a specific sidebar ('sidebar-bottom' in my case) based on the number of widgets set in that sidebar. This will suit perfectly in horizontal sidebars and themes based on twitter bootstrap that need s... |
54,189 | <p>When user writes a comment and hits the submit button, WordPress reloads the page, before the comment is shown to the user.</p>
<p>Is there an Ajax-based solution that allows users to submit questions dynamically, without refreshing the whole page?</p>
| [
{
"answer_id": 54190,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 2,
"selected": false,
"text": "<p>Yes, there is a lot of solutions, check it here: <a href=\"http://wordpress.org/extend/plugins/search.ph... | 2012/06/04 | [
"https://wordpress.stackexchange.com/questions/54189",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10691/"
] | When user writes a comment and hits the submit button, WordPress reloads the page, before the comment is shown to the user.
Is there an Ajax-based solution that allows users to submit questions dynamically, without refreshing the whole page? | Save the following javascrip file `wpse54189-ajax-comments.js` inside your plug-in folder - say `plugins/plug-in-name/js` (or if this must go your theme, in your theme folder).
```
/*
* jQuery autoResize (textarea auto-resizer)
* @copyright James Padolsey http://james.padolsey.com
* @version 1.04
*/
(function(a)... |
54,196 | <p>When I use the following code in a (<a href="http://www.farinspace.com/wpalchemy-metabox/" rel="nofollow">wpalchemy</a>) custom meta box, everything works fine. That is until I pressed 'add new'. At this point, the title, slug, featured image, etc.. are being pre-populated with the content from my 'products' post ... | [
{
"answer_id": 54485,
"author": "Zach Lysobey",
"author_id": 5846,
"author_profile": "https://wordpress.stackexchange.com/users/5846",
"pm_score": 1,
"selected": false,
"text": "<p>Ok, I sorted this out myself. Instead of <code>get_posts</code> or <code>WP_Query</code> I used a custom s... | 2012/06/04 | [
"https://wordpress.stackexchange.com/questions/54196",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5846/"
] | When I use the following code in a ([wpalchemy](http://www.farinspace.com/wpalchemy-metabox/)) custom meta box, everything works fine. That is until I pressed 'add new'. At this point, the title, slug, featured image, etc.. are being pre-populated with the content from my 'products' post type.
The code builds a drop d... | After you create a custom loop, you need to restore the global post variables with [`wp_reset_query()`](http://codex.wordpress.org/Function_Reference/wp_reset_query). |
54,208 | <h3>The Problem</h3>
<p>I first noticed this with the plugin Quick-Cache, which activates without problem, but doesn't shows up anywhere. Its menu it's simply not there. Found why, and became aware of the conflict, <a href="http://wordpress.org/support/topic/plugin-quick-cache-a-wp-super-cache-alternative-definedisallo... | [
{
"answer_id": 54210,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 3,
"selected": true,
"text": "<p>I guess this would be of better use as a <code>mu-plugin</code>. </p>\n\n<p><strong>EDIT:</strong> Now avail... | 2012/06/04 | [
"https://wordpress.stackexchange.com/questions/54208",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12615/"
] | ### The Problem
I first noticed this with the plugin Quick-Cache, which activates without problem, but doesn't shows up anywhere. Its menu it's simply not there. Found why, and became aware of the conflict, [in the forums](http://wordpress.org/support/topic/plugin-quick-cache-a-wp-super-cache-alternative-definedisallo... | I guess this would be of better use as a `mu-plugin`.
**EDIT:** Now available as drop & play MU-Plugin. Also disables the »Theme« editor.
```
<?php
! defined( 'ABSPATH' ) AND exit;
/** Plugin Name: Disable »Theme/Plugin Editor« */
if ( ! class_exists( 'disable_admin_editor' ) )
{
add_action( 'plugins_loaded', a... |
54,216 | <p>I need to find out the post_id of a post_meta record where the custom key is 'XYZ' and the is 'ABC'? Is there an API for that? </p>
<p>Or do I need to run a regular select SQL with wpdb class?</p>
| [
{
"answer_id": 54217,
"author": "javy",
"author_id": 12870,
"author_profile": "https://wordpress.stackexchange.com/users/12870",
"pm_score": 0,
"selected": false,
"text": "<p>Does something like this work?</p>\n\n<pre><code>query_posts('meta_key=XYZ&meta_value=ABC');\nif (have_posts(... | 2012/06/04 | [
"https://wordpress.stackexchange.com/questions/54216",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14967/"
] | I need to find out the post\_id of a post\_meta record where the custom key is 'XYZ' and the is 'ABC'? Is there an API for that?
Or do I need to run a regular select SQL with wpdb class? | You should use [WP\_Query](http://codex.wordpress.org/Class_Reference/WP_Query) in this case ...
```
$my_query = new WP_Query( array( 'meta_key' => 'XYZ', 'meta_value' => 'ABC' ) );
$post_ids = array();
while ( $my_query->have_posts() ) {
$my_query->next_post();
$post_ids[] = $my_query->post->ID;
}
wp_reset_... |
54,237 | <p>I am using woocommerce plugin for ecommerce site. Problem is that it allows maximum 50 variations for a product, but my client requires around 350 variations with attributes size, color etc. etc. Is there a way to tweak the code or anything else?</p>
<p>Thanks,</p>
<p>Frank</p>
| [
{
"answer_id": 54274,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 2,
"selected": false,
"text": "<p>From the <a href=\"http://www.woothemes.com/support-forum/?viewtopic=80168\" rel=\"nofollow\">Woo forums</a>... | 2012/06/05 | [
"https://wordpress.stackexchange.com/questions/54237",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16753/"
] | I am using woocommerce plugin for ecommerce site. Problem is that it allows maximum 50 variations for a product, but my client requires around 350 variations with attributes size, color etc. etc. Is there a way to tweak the code or anything else?
Thanks,
Frank | From the [Woo forums](http://www.woothemes.com/support-forum/?viewtopic=80168):
>
> We have a limit of 50 linked variations per product right now (to
> prevent memory issues), anything above that is considered to be very
> complex and in need of some custom work. It is not easy to manage a
> single product with ov... |
54,241 | <p>I have seen WordPress developers use two different methods for loading custom widgets from the functions.php file. </p>
<p>The first:</p>
<pre><code>include("functions/my-custom-widget.php");
</code></pre>
<p>The second:</p>
<pre><code>require_once(dirname(__FILE__) . "/functions/my-custom-widget.php");
</code><... | [
{
"answer_id": 54245,
"author": "FelipeAls",
"author_id": 14677,
"author_profile": "https://wordpress.stackexchange.com/users/14677",
"pm_score": 2,
"selected": false,
"text": "<p><code>require_once</code> (<a href=\"http://php.net/manual/en/function.require-once.php\" rel=\"nofollow\">P... | 2012/06/05 | [
"https://wordpress.stackexchange.com/questions/54241",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16192/"
] | I have seen WordPress developers use two different methods for loading custom widgets from the functions.php file.
The first:
```
include("functions/my-custom-widget.php");
```
The second:
```
require_once(dirname(__FILE__) . "/functions/my-custom-widget.php");
```
Which one of these methods is more efficient. ... | Both are acceptable but not recommended. Use [`locate_template()`](http://codex.wordpress.org/Function_Reference/locate_template) instead because a child theme can overwrite the loaded file then.
Example:
```
$found = locate_template( 'functions/my-custom-widget.php', TRUE, TRUE );
```
The first `TRUE` tells WordPr... |
54,258 | <p>I am looking for some code where member can't use the same title as another post already having or used.</p>
<p>e.g if there is a post with title "Amazing Australia Tour" than it should not allow to use the same title to same or other user.</p>
| [
{
"answer_id": 54279,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 3,
"selected": true,
"text": "<h3>Main Code</h3>\n<p><sup><em>Please check the auxiliary code after this block</em></sup></p>\n<pre><code>/*\n... | 2012/06/05 | [
"https://wordpress.stackexchange.com/questions/54258",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9821/"
] | I am looking for some code where member can't use the same title as another post already having or used.
e.g if there is a post with title "Amazing Australia Tour" than it should not allow to use the same title to same or other user. | ### Main Code
*Please check the auxiliary code after this block*
```
/*
* Prevent Duplicated Titles
*
*/
if( is_admin() ) // check if we are in the administrative area
{
add_action( 'save_post', 'wpse_54258_check_for_duplicate_title', 11, 2 );
add_action( 'admin_head-post.php', 'wpse_54258_check_for_notic... |
54,262 | <p>I have created a small segment within WordPress that records match information for League of Legends. Using up to 30 different custom fields I can store information of 30 champions picked from 3 games (10 different champions are picked each game)</p>
<p>I want to query all games the champion 'Shen' has played in bu... | [
{
"answer_id": 54265,
"author": "Pontus Abrahamsson",
"author_id": 16722,
"author_profile": "https://wordpress.stackexchange.com/users/16722",
"pm_score": 1,
"selected": false,
"text": "<p>As @helenhousandi said, why not use the WP_Query, try this:</p>\n\n<pre><code><?php \n// the arg... | 2012/06/05 | [
"https://wordpress.stackexchange.com/questions/54262",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12818/"
] | I have created a small segment within WordPress that records match information for League of Legends. Using up to 30 different custom fields I can store information of 30 champions picked from 3 games (10 different champions are picked each game)
I want to query all games the champion 'Shen' has played in but the issu... | just add to your query `SELECT DISTINCT $wpdb->posts.` instead of `SELECT $wpdb->posts.` |
54,276 | <p>wordpress 3.3.2
hi. so i have this custom post type and i use a page to show just one post.
url.td/page/</p>
<p>the page renders the post but now i want to include comments.
if i allow comments for the page, the comments get assigned to the page, but i want it to get assigned to the post, for example
url.td/page/my... | [
{
"answer_id": 54265,
"author": "Pontus Abrahamsson",
"author_id": 16722,
"author_profile": "https://wordpress.stackexchange.com/users/16722",
"pm_score": 1,
"selected": false,
"text": "<p>As @helenhousandi said, why not use the WP_Query, try this:</p>\n\n<pre><code><?php \n// the arg... | 2012/06/05 | [
"https://wordpress.stackexchange.com/questions/54276",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10994/"
] | wordpress 3.3.2
hi. so i have this custom post type and i use a page to show just one post.
url.td/page/
the page renders the post but now i want to include comments.
if i allow comments for the page, the comments get assigned to the page, but i want it to get assigned to the post, for example
url.td/page/my-post
if ... | just add to your query `SELECT DISTINCT $wpdb->posts.` instead of `SELECT $wpdb->posts.` |
54,296 | <p>I have enabled comment replies in my blog. Lets say there is a comment Nick has written... when I'm gonna reply, I want to display a message "Replying to Nick" in the reply's form header. Anyone knows how? Thanks!</p>
| [
{
"answer_id": 54323,
"author": "tamilsweet",
"author_id": 10701,
"author_profile": "https://wordpress.stackexchange.com/users/10701",
"pm_score": 2,
"selected": false,
"text": "<p>The WordPress function <a href=\"http://codex.wordpress.org/Function_Reference/comment_form_title\" rel=\"n... | 2012/06/05 | [
"https://wordpress.stackexchange.com/questions/54296",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15801/"
] | I have enabled comment replies in my blog. Lets say there is a comment Nick has written... when I'm gonna reply, I want to display a message "Replying to Nick" in the reply's form header. Anyone knows how? Thanks! | The WordPress function [comment\_form\_title](http://codex.wordpress.org/Function_Reference/comment_form_title) works only for users with Javascript disabled or pages without the comment-reply.js JavaScript loaded.
WordPress may not fix this limitation at all
Two tickets have been opened before and closed without fix.... |
54,313 | <p>I have three custom fields set for each of the posts in the events category — year, month, and day. I am already querying for the events category, and now I'd like to sort the posts by the custom fields. I assume that I just need to insert something into the query_posts section of the code, but I'm not sure what. An... | [
{
"answer_id": 54314,
"author": "inTOWN",
"author_id": 17038,
"author_profile": "https://wordpress.stackexchange.com/users/17038",
"pm_score": 0,
"selected": false,
"text": "<p>I think that could be done with adding</p>\n\n<pre><code>meta_key=yourcustomfield&orderby=meta_value\n</cod... | 2012/05/31 | [
"https://wordpress.stackexchange.com/questions/54313",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/86641/"
] | I have three custom fields set for each of the posts in the events category — year, month, and day. I am already querying for the events category, and now I'd like to sort the posts by the custom fields. I assume that I just need to insert something into the query\_posts section of the code, but I'm not sure what. Any ... | I don't think there's an easy to sort by three different meta values, and really, I don't see why you need to in this case. Why not just save the event date in one meta value and sort by that? It makes your query much more efficient (removes two unnecessary joins) and lets you use the WP\_Query `orderby` field to sort ... |
54,347 | <p>It seems like stupid bug, but how can i order by title? It anyways orders by date! I'm using: </p>
<pre><code>query_posts( array(
'post_type' => 'page',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC'
) );
</code></pre>
<p>I want to use this in funct... | [
{
"answer_id": 54384,
"author": "Tommixoft",
"author_id": 15815,
"author_profile": "https://wordpress.stackexchange.com/users/15815",
"pm_score": 4,
"selected": true,
"text": "<p>Thanks to Chip Bennett who told me that i'm doing wrong by using <code>query_posts</code> inside content. So ... | 2012/06/06 | [
"https://wordpress.stackexchange.com/questions/54347",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15815/"
] | It seems like stupid bug, but how can i order by title? It anyways orders by date! I'm using:
```
query_posts( array(
'post_type' => 'page',
'posts_per_page' => -1,
'orderby' => 'title',
'order' => 'ASC'
) );
```
I want to use this in function as SHORTCODE. What i'm trying to a... | Thanks to Chip Bennett who told me that i'm doing wrong by using `query_posts` inside content. So i used `get_posts` and i got what i wanted, thanks!
Here is sample of how can you do it, if you got the same problem as me:
```
function some_name(){
global $post;
$tmp_post = $post;
$args = array( 'post_type'=>'page', ... |
54,358 | <p>I have a custom post type "Properties".</p>
<p>These properties posts are being listed out on page "Properties For Let".</p>
<p>Each property post has various custom meta including price, and number of bedrooms.</p>
<p>The properties will initially be listed in the order defined by the original wp query I set.</p... | [
{
"answer_id": 54359,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 2,
"selected": false,
"text": "<p>The function <a href=\"http://codex.wordpress.org/Function_Reference/add_query_arg\" rel=\"nofollow\"><co... | 2012/06/06 | [
"https://wordpress.stackexchange.com/questions/54358",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14542/"
] | I have a custom post type "Properties".
These properties posts are being listed out on page "Properties For Let".
Each property post has various custom meta including price, and number of bedrooms.
The properties will initially be listed in the order defined by the original wp query I set.
However at the top of the... | The function [`add_query_arg`](http://codex.wordpress.org/Function_Reference/add_query_arg) adds or replaces 'GET' parameters in a given (or the current) url.
For instance, suppose someone is viewing the page:
**www.example.com?order=ASC&orderby=meta\_value\_num&meta\_key=price**
(viewing properties in price order)... |
54,367 | <p>I'm using the plugin <a href="http://www.jigoshop.com" rel="nofollow noreferrer">Jigoshop</a> and I'd like to change the wording of the admin menu to something other than "Products":</p>
<p><img src="https://i.stack.imgur.com/RFxEp.png" alt="enter image description here"></p>
<p>How can I do this? What files need ... | [
{
"answer_id": 54369,
"author": "tamilsweet",
"author_id": 10701,
"author_profile": "https://wordpress.stackexchange.com/users/10701",
"pm_score": -1,
"selected": true,
"text": "<p>Inside the plugin folder check for File: jigoshop_taxonomy.php\nLine no: 120</p>\n\n<p>You will see</p>\n\n... | 2012/06/06 | [
"https://wordpress.stackexchange.com/questions/54367",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4588/"
] | I'm using the plugin [Jigoshop](http://www.jigoshop.com) and I'd like to change the wording of the admin menu to something other than "Products":

How can I do this? What files need editing? | Inside the plugin folder check for File: jigoshop\_taxonomy.php
Line no: 120
You will see
```
register_post_type( "product",
array(
'labels' => array(
'name' => __( 'Products', 'jigoshop' ),
'singular_name' => __( 'Product', 'jigoshop' ),
'all_items' ... |
54,375 | <p>I have a custom-post-type named <code>wr_events</code>. I have quite a lot of meta-boxes in this post-type. The post-type and the meta-boxes itself work just fine. </p>
<p>Only thing: No matter at what post-type I create a "New post" I get quite a lot of php errors and notices …</p>
<pre><code>Notice: Undefined in... | [
{
"answer_id": 54379,
"author": "MathSmath",
"author_id": 1537,
"author_profile": "https://wordpress.stackexchange.com/users/1537",
"pm_score": 3,
"selected": true,
"text": "<p>Start by reading the notices--they tell you very explicitly what the problem is.</p>\n\n<p>Let's start with the... | 2012/06/06 | [
"https://wordpress.stackexchange.com/questions/54375",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3529/"
] | I have a custom-post-type named `wr_events`. I have quite a lot of meta-boxes in this post-type. The post-type and the meta-boxes itself work just fine.
Only thing: No matter at what post-type I create a "New post" I get quite a lot of php errors and notices …
```
Notice: Undefined index: _wr_event_speaker in /Users... | Start by reading the notices--they tell you very explicitly what the problem is.
Let's start with the first one:
```
Notice: Undefined index: _wr_event_speaker in /Users/my/htdocs/wr/wp-content/themes/wr/functions.php on line 246
```
First, this is just a "notice". Meaning that no error has actually occurred. PHP i... |
54,386 | <p>For a moment, I wondered if my test site got hacked -- my WordPress site's dashboard was all broken (cosmetically). But when i looked at the source code of the page, I noticed that the "scripts and styles" that I enqueued for the front-end were also enqueued in the backend as well.</p>
<p>This is how I did it:</p>
... | [
{
"answer_id": 54387,
"author": "tamilsweet",
"author_id": 10701,
"author_profile": "https://wordpress.stackexchange.com/users/10701",
"pm_score": 0,
"selected": false,
"text": "<p>Just add the condition</p>\n\n<pre><code>if( is_admin() ) return;\n</code></pre>\n\n<p>So you will have</p>... | 2012/06/06 | [
"https://wordpress.stackexchange.com/questions/54386",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10691/"
] | For a moment, I wondered if my test site got hacked -- my WordPress site's dashboard was all broken (cosmetically). But when i looked at the source code of the page, I noticed that the "scripts and styles" that I enqueued for the front-end were also enqueued in the backend as well.
This is how I did it:
```
add_actio... | The "init" action runs both on frontend page loads, and on backend page loads.
Try hooking these to the "wp\_enqueue\_scripts" action instead. I believe it does not run on admin page loads.
**Example Code: (By OP)**
```
function wpse54388_scripts_styles() {
wp_enqueue_style( ... );
wp_enqueue_script( ... )... |
54,409 | <p>I'm using Wordpress' upload system (<a href="http://www.webmaster-source.com/2010/01/08/using-the-wordpress-uploader-in-your-plugin-or-theme/" rel="nofollow">as explained here</a>) on my plugin's admin page.</p>
<p>I can upload an image and get this image's URL. But i need attachment ID, image caption etc. How can ... | [
{
"answer_id": 54413,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 1,
"selected": false,
"text": "<p>The attachment metadata stored for the image is:</p>\n\n<pre><code>Array\n(\n [width] => 558\n [height] =... | 2012/06/06 | [
"https://wordpress.stackexchange.com/questions/54409",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3552/"
] | I'm using Wordpress' upload system ([as explained here](http://www.webmaster-source.com/2010/01/08/using-the-wordpress-uploader-in-your-plugin-or-theme/)) on my plugin's admin page.
I can upload an image and get this image's URL. But i need attachment ID, image caption etc. How can i reach them?
I have an `<form>` . ... | The attachment metadata stored for the image is:
```
Array
(
[width] => 558
[height] => 771
[hwstring_small] => height='62' width='128'
[file] => 2012/02/logo2.png
[sizes] => Array
(
[thumbnail] => Array
(
[file] => file_name.png
[width] => 150
... |
54,417 | <p>I'm at a loss, I've found several unanswered questions related to this one. I have a static post page which has a search form in the sidebar. What I want to happen is to type in a keyword and then 'filter'(return with ajax) only the posts that fit the search. I also want it to be paginated.</p>
<p>I've found severa... | [
{
"answer_id": 54418,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": true,
"text": "<p>The original request that loaded the page you are making the AJAX request <em>from</em> ended as soon as the page wa... | 2012/06/06 | [
"https://wordpress.stackexchange.com/questions/54417",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16459/"
] | I'm at a loss, I've found several unanswered questions related to this one. I have a static post page which has a search form in the sidebar. What I want to happen is to type in a keyword and then 'filter'(return with ajax) only the posts that fit the search. I also want it to be paginated.
I've found several ways to ... | The original request that loaded the page you are making the AJAX request *from* ended as soon as the page was sent to your browser. That connection is closed and it is gone from memory.
When you make an AJAX request, it's a new request, so `$wp_query` is empty because you haven't queried anything. You need to create ... |
54,422 | <p>How can I get a Previous / Next navigation that only navigates the child pages of the current page?</p>
<p>By that i mean url.com/page/<strong>child1</strong>, url.com/page/<strong>child2</strong> and so on..</p>
<p>I've been searching around alot but I'm still lost.</p>
<p>It seems like you can't do that accordi... | [
{
"answer_id": 54424,
"author": "fdsa",
"author_id": 8288,
"author_profile": "https://wordpress.stackexchange.com/users/8288",
"pm_score": 0,
"selected": false,
"text": "<p>You could use find the parent page of the current post using post->parent_page, then plug that into <a href=\"http... | 2012/06/07 | [
"https://wordpress.stackexchange.com/questions/54422",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15419/"
] | How can I get a Previous / Next navigation that only navigates the child pages of the current page?
By that i mean url.com/page/**child1**, url.com/page/**child2** and so on..
I've been searching around alot but I'm still lost.
It seems like you can't do that according to [wordpress](http://codex.wordpress.org/Next_... | All right, here it is, fully working:
```
<?php
$pagelist = get_pages("child_of=".$post->post_parent."&parent=".$post->post_parent."&sort_column=menu_order&sort_order=asc");
$pages = array();
foreach ($pagelist as $page) {
$pages[] += $page->ID;
}
$current = array_search($post->ID, $pages);
$prevID = $pages[$curre... |
54,423 | <p>I created a plugin and I need to use <a href="https://developer.wordpress.org/reference/functions/add_image_size/" rel="nofollow noreferrer"><code>add_image_size</code></a> in it. </p>
<p>I know how it works in the <code>functions.php</code> file and for a theme, but how can I implement this in a plugin?</p>
<p>I ... | [
{
"answer_id": 54434,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 3,
"selected": false,
"text": "<p>Just call this function in the <code>init</code> action. This action is fired for both frontend and back... | 2012/06/07 | [
"https://wordpress.stackexchange.com/questions/54423",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10612/"
] | I created a plugin and I need to use [`add_image_size`](https://developer.wordpress.org/reference/functions/add_image_size/) in it.
I know how it works in the `functions.php` file and for a theme, but how can I implement this in a plugin?
I want new images uploaded by WordPress users to be smaller for mobile screens... | Just call this function in the `init` action. This action is fired for both frontend and backend. So it should look like this:
```
add_action( 'init', 'wpse4378_add_new_image_size' );
function wpse4378_add_new_image_size() {
add_image_size( 'wp_small', 60, 75, true ); //mobile
}
``` |
54,427 | <p>The purpose of this plugin is to create a list that users can modify with up or down votes. The shortcode is supposed to display the list on a page and use JQuery to fadeIn and fadeOut while updating the database.</p>
<p>A demo of the concept is available at <a href="http://bucketlingerwedding.com/80s-music-recepti... | [
{
"answer_id": 54432,
"author": "Rutwick Gangurde",
"author_id": 4740,
"author_profile": "https://wordpress.stackexchange.com/users/4740",
"pm_score": 2,
"selected": true,
"text": "<p>You should probably write a plugin, which has the shortcode function. You can separate the AJAX/jQuery c... | 2012/06/07 | [
"https://wordpress.stackexchange.com/questions/54427",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13608/"
] | The purpose of this plugin is to create a list that users can modify with up or down votes. The shortcode is supposed to display the list on a page and use JQuery to fadeIn and fadeOut while updating the database.
A demo of the concept is available at <http://bucketlingerwedding.com/80s-music-reception/> (note: the wo... | You should probably write a plugin, which has the shortcode function. You can separate the AJAX/jQuery code in a plugin, but not in a shortcode. |
54,437 | <p>I'm trying to write a oneboxing routine that gives WordPress blog entries special treatment. So given a simple, unadorned URL in content, such as</p>
<blockquote>
<p><a href="http://blog.stackoverflow.com/2011/03/a-new-name-for-stack-overflow-with-surprise-ending/">http://blog.stackoverflow.com/2011/03/a-new-name... | [
{
"answer_id": 54439,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": false,
"text": "<p>Send a <code>HEAD</code> request to <code>/wp-feed.php</code> in the same directory as <code>/xmlrpc.php</code> (even ... | 2012/06/07 | [
"https://wordpress.stackexchange.com/questions/54437",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/152/"
] | I'm trying to write a oneboxing routine that gives WordPress blog entries special treatment. So given a simple, unadorned URL in content, such as
>
> <http://blog.stackoverflow.com/2011/03/a-new-name-for-stack-overflow-with-surprise-ending/>
>
>
>
How would I detect that this is a WordPress installation, **ideall... | Send a `HEAD` request to `/wp-feed.php` in the same directory as `/xmlrpc.php` (even in subdirectory installations). In WordPress you will get a `Location` header as response containing the string `feed`.
In your example for `blog.stackoverflow.com` you’ll get:
```
HTTP/1.1 301 Moved Permanently\r\n
Date: Thu, 07 Jun... |
54,453 | <p>I would like to run an add_action in functions.php only if the theme is being loaded from my localhost development site. How would I get this to run only on localhost?</p>
<pre><code>function livereload(){
?>
// mycode
<?php
}
add_action('headway_body_close', 'livereload');
</code></pre>
| [
{
"answer_id": 54454,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 1,
"selected": false,
"text": "<p>The easiest way to do it to check IP address of an user. If it equals to 127.0.0.1, then this user runni... | 2012/06/07 | [
"https://wordpress.stackexchange.com/questions/54453",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16839/"
] | I would like to run an add\_action in functions.php only if the theme is being loaded from my localhost development site. How would I get this to run only on localhost?
```
function livereload(){
?>
// mycode
<?php
}
add_action('headway_body_close', 'livereload');
``` | This is the corect answer
```
if ( $_SERVER["SERVER_ADDR"] == '127.0.0.1' ) {
function livereload(){
?>
// mycode
<?php
}
add_action('headway_body_close', 'livereload');
}
``` |
54,462 | <p>I have a number of top-level categories including "News" and "Sport". They each have multiple levels of child categories as shown below.</p>
<ul>
<li><p><strong>News</strong></p>
<ul>
<li>Australia
<ul>
<li>NSW
<ul>
<li>Sydney</li>
</ul></li>
</ul></li>
</ul></li>
<li><p><strong>Sports</strong></p>
<ul>
<li>Cyc... | [
{
"answer_id": 54532,
"author": "fdsa",
"author_id": 8288,
"author_profile": "https://wordpress.stackexchange.com/users/8288",
"pm_score": 0,
"selected": false,
"text": "<p>OK - I originally misunderstood your question.</p>\n\n<pre><code>function getLowestCategory()\n{\n $postCategori... | 2012/06/07 | [
"https://wordpress.stackexchange.com/questions/54462",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3842/"
] | I have a number of top-level categories including "News" and "Sport". They each have multiple levels of child categories as shown below.
* **News**
+ Australia
- NSW
* Sydney
* **Sports**
+ Cycling
- Road Cycling
- BMX
+ Triathlon
In my loop I want to display a single category - **what ever is the deepe... | The code you referenced in your question is flawed. In most cases it will work but it relies on an assumption that newer child terms are created after their parents, and as a result, have higher IDs.
To fool the code you posted, do this:
* Create a new category
* Edit an older child term
* Change its parent to the ne... |
54,470 | <p>Anyone here see why my pagination won't work? I can get "previous page" to show up, but when navigating to "page-2", the content will stay identical to the content on "page-1".</p>
<pre><code><?php
/*
Template Name: Generic Trips Template
*/
?>
<?php get_header(); ?>
<?php get_template_part(... | [
{
"answer_id": 54532,
"author": "fdsa",
"author_id": 8288,
"author_profile": "https://wordpress.stackexchange.com/users/8288",
"pm_score": 0,
"selected": false,
"text": "<p>OK - I originally misunderstood your question.</p>\n\n<pre><code>function getLowestCategory()\n{\n $postCategori... | 2012/06/07 | [
"https://wordpress.stackexchange.com/questions/54470",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6828/"
] | Anyone here see why my pagination won't work? I can get "previous page" to show up, but when navigating to "page-2", the content will stay identical to the content on "page-1".
```
<?php
/*
Template Name: Generic Trips Template
*/
?>
<?php get_header(); ?>
<?php get_template_part( "beforeloop", "page" ) ?>
... | The code you referenced in your question is flawed. In most cases it will work but it relies on an assumption that newer child terms are created after their parents, and as a result, have higher IDs.
To fool the code you posted, do this:
* Create a new category
* Edit an older child term
* Change its parent to the ne... |
54,509 | <p>After pretty much getting everything working with <code>query_posts</code>, I noticed my pagination wasn't running. I was told <code>pre_get_posts</code> should be the solution.</p>
<p>My problems:</p>
<ol>
<li>I don't know how to pass all my criteria
<code>(query_posts(array('post_type' => 'trips', 'types' =&g... | [
{
"answer_id": 54725,
"author": "MathSmath",
"author_id": 1537,
"author_profile": "https://wordpress.stackexchange.com/users/1537",
"pm_score": 2,
"selected": false,
"text": "<p>WordPress figures pagination details based on the <em>main query</em>, and before the template is parsed. Whic... | 2012/06/07 | [
"https://wordpress.stackexchange.com/questions/54509",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6828/"
] | After pretty much getting everything working with `query_posts`, I noticed my pagination wasn't running. I was told `pre_get_posts` should be the solution.
My problems:
1. I don't know how to pass all my criteria
`(query_posts(array('post_type' => 'trips', 'types' => $types,
'paged' => $paged,)`in to `pre_get_posts`
... | It appears that you want to *create a **custom page template** to display a **custom post type***? If so, you don't really need to mess with `pre_get_posts` at all.
**First**, create your custom page template. I assume you've already done this.
**Second**, you need to *create a custom query*, using [**`WP_Query()`**]... |
54,526 | <p>I have a simple Wordpress page that takes input from users and store into a database. I am able to get the values and update the database properly. However, whenever I try to enter some non-English text, it gets converted to something like '?????????'. But the issue is only with my page. If I use the Wordpress comme... | [
{
"answer_id": 54625,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>In your <code>wp-config.php</code> set the encoding constants correctly:</p>\n\n<pre><code>define( 'DB_CHARSET', 'utf8... | 2012/06/08 | [
"https://wordpress.stackexchange.com/questions/54526",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8129/"
] | I have a simple Wordpress page that takes input from users and store into a database. I am able to get the values and update the database properly. However, whenever I try to enter some non-English text, it gets converted to something like '?????????'. But the issue is only with my page. If I use the Wordpress comments... | In your `wp-config.php` set the encoding constants correctly:
```
define( 'DB_CHARSET', 'utf8' );
define( 'DB_COLLATE', 'utf8_general_ci' );
```
And add an `accept-charset` attribute to your form:
```
<form
name="frm"
method="post"
action="<?php bloginfo('url'); ?>/message/"
accept-charset='utf8... |
54,543 | <p>I want to start a new theme for my Multsite install instead of simply modifying the current theme. The problem is I have a lot of sites running on Multsite so it would be a little painful to change all my sites to the new theme one by one. </p>
<p>Is there a way to change the theme of sites by more then one at a ti... | [
{
"answer_id": 54552,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 0,
"selected": false,
"text": "<p>Create a <a href=\"http://codex.wordpress.org/Must_Use_Plugins\" rel=\"nofollow\">MU plugin</a> and filter <code>'temp... | 2012/06/08 | [
"https://wordpress.stackexchange.com/questions/54543",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16473/"
] | I want to start a new theme for my Multsite install instead of simply modifying the current theme. The problem is I have a lot of sites running on Multsite so it would be a little painful to change all my sites to the new theme one by one.
Is there a way to change the theme of sites by more then one at a time? In sit... | I wouldn't recommend to use `update_option` for this task. Why? Because themes/plugins may use `switch_theme` action and it won't get run in such case. And this action is pretty important - it will allow you to save your widgets for example...
Another problem with Fuxias answer is that she uses `template_directory` ho... |
54,546 | <p>Hi I'm trying to write a query which will pull the events out from the All in One Calendar Plugin. This is what I have so far:</p>
<pre><code><?php query_posts('post_type=ai1ec_event');?>
<?php while ( have_posts() ) : the_post(); ?>
<?php echo '<h5><a href="'.get_permalink().'">'.get_th... | [
{
"answer_id": 54813,
"author": "uknowit2",
"author_id": 15069,
"author_profile": "https://wordpress.stackexchange.com/users/15069",
"pm_score": 2,
"selected": false,
"text": "<p>Ok so hope this helps someone. Unless you want to query the database directly, the trick is to include the fo... | 2012/06/08 | [
"https://wordpress.stackexchange.com/questions/54546",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15069/"
] | Hi I'm trying to write a query which will pull the events out from the All in One Calendar Plugin. This is what I have so far:
```
<?php query_posts('post_type=ai1ec_event');?>
<?php while ( have_posts() ) : the_post(); ?>
<?php echo '<h5><a href="'.get_permalink().'">'.get_the_title().'</a></h5>'; ?>
<?php endwhile;... | Ok so hope this helps someone. Unless you want to query the database directly, the trick is to include the following:
```
$event = Ai1ec_Events_Helper::get_event($post->ID);
```
thereafter you can retrieve the variables, for example:
```
<?php query_posts('post_type=ai1ec_event');?>
<?php ... |
54,567 | <p><strong>IMPORTANT UPDATE: I've realised that my problems could also lie with the WordPress 3.3 update</strong>.</p>
<hr>
<p>A while ago I <a href="https://wordpress.stackexchange.com/a/47462/6344">posted a solution to my own question</a> about searching Custom Post Types.</p>
<p>At that time, I was using the URL ... | [
{
"answer_id": 54750,
"author": "Gavin Anderegg",
"author_id": 2984,
"author_profile": "https://wordpress.stackexchange.com/users/2984",
"pm_score": 1,
"selected": false,
"text": "<p>It's possible that, after moving the site, you hadn't updated WordPress' understanding of where the site ... | 2012/06/08 | [
"https://wordpress.stackexchange.com/questions/54567",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6344/"
] | **IMPORTANT UPDATE: I've realised that my problems could also lie with the WordPress 3.3 update**.
---
A while ago I [posted a solution to my own question](https://wordpress.stackexchange.com/a/47462/6344) about searching Custom Post Types.
At that time, I was using the URL `http://www.seriouslyfish.com/dev/` whilst... | It's possible that, after moving the site, you hadn't updated WordPress' understanding of where the site is located. You might want to try adding the following to your `wp-config.php` file:
```
define('WP_SITEURL', 'http://www.seriouslyfish.com');
define('WP_HOME', 'http://www.seriouslyfish.com');
```
This will over... |
54,583 | <p>I have my <code>style.php</code> file looking like this.</p>
<pre><code><?php header('Content-Type: text/css');?>
#div{
background:<?php echo get_option('bgcolor');?>;
}
</code></pre>
<p>This does not work, but when I do this it works.</p>
<pre><code><?php header('Content-Type: text/css');?&... | [
{
"answer_id": 54612,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 6,
"selected": true,
"text": "<p>WordPress functions are available only if WordPress is loaded. If you call your <code>style.php</code> directly you can... | 2012/06/08 | [
"https://wordpress.stackexchange.com/questions/54583",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12918/"
] | I have my `style.php` file looking like this.
```
<?php header('Content-Type: text/css');?>
#div{
background:<?php echo get_option('bgcolor');?>;
}
```
This does not work, but when I do this it works.
```
<?php header('Content-Type: text/css');?>
#div{
background: <?php echo 'blue';?>;
}
```
What woul... | WordPress functions are available only if WordPress is loaded. If you call your `style.php` directly you cannot use a WordPress function.
One simple way to load WordPress for your PHP driven stylesheet is to add an endpoint to WordPress: a custom, reserved URL where you load your template file.
To get there you have ... |
54,590 | <p>I would like to create a custom search form to search posts based on the values of about 4 custom fields. I tried using wp_query to achieve this but so far my biggest problem is that the I don't get any results when searching for data in custom fields - even for data that I am sure exists. Also, I can't figure out h... | [
{
"answer_id": 54619,
"author": "moraleida",
"author_id": 7890,
"author_profile": "https://wordpress.stackexchange.com/users/7890",
"pm_score": 2,
"selected": false,
"text": "<p>You need to combine your search query with a new WP Query...</p>\n\n<p>That would be something like this, on y... | 2012/06/08 | [
"https://wordpress.stackexchange.com/questions/54590",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16190/"
] | I would like to create a custom search form to search posts based on the values of about 4 custom fields. I tried using wp\_query to achieve this but so far my biggest problem is that the I don't get any results when searching for data in custom fields - even for data that I am sure exists. Also, I can't figure out how... | You need to combine your search query with a new WP Query...
That would be something like this, on your search.php
```
<?php
global $wp_query; // get the global object
$thesearch = get_search_query(); // get the string searched
// merge them with one or several meta_queries to meet your demand
$args = array_merge(... |
54,599 | <p>I'm facing a weird issue trying to do what I'm going to explain now.</p>
<p><strong>Context</strong><br></p>
<p><strong>Plugins I'm using:</strong> Custom Post Type UI / Advanced Custom Fields
Functionality:
I have a custom post type called "vendors". Within this post type I have several custom fields made on ACF... | [
{
"answer_id": 54601,
"author": "Pontus Abrahamsson",
"author_id": 16722,
"author_profile": "https://wordpress.stackexchange.com/users/16722",
"pm_score": 0,
"selected": false,
"text": "<p>I cant see where you check if the statement is true or not.\nYou should have something like:</p>\n\... | 2012/06/08 | [
"https://wordpress.stackexchange.com/questions/54599",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15574/"
] | I'm facing a weird issue trying to do what I'm going to explain now.
**Context**
**Plugins I'm using:** Custom Post Type UI / Advanced Custom Fields
Functionality:
I have a custom post type called "vendors". Within this post type I have several custom fields made on ACF. One of these fields is Called "Promote to H... | there is no third parameter for [get\_field](http://www.advancedcustomfields.com/docs/functions/get_field/), may be causing your error.
**EDIT-**
In your current code, if the 10 most recent posts don't contain a post with your meta key, you'll see nothing since you're only getting 10 posts and then filtering them. An... |
54,600 | <p>Is there a way to customize the WordPress>error page template so that the user isn't shown just a blank screen with text?</p>
<p>I'm not talking about 404, but when WordPress displays an error.</p>
<p>I'd like to style this page to match my theme.</p>
| [
{
"answer_id": 54611,
"author": "MathSmath",
"author_id": 1537,
"author_profile": "https://wordpress.stackexchange.com/users/1537",
"pm_score": 4,
"selected": true,
"text": "<p>You're probably talking about theming <code>wp_die()</code>, which is the function that produces those grey er... | 2012/06/08 | [
"https://wordpress.stackexchange.com/questions/54600",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8882/"
] | Is there a way to customize the WordPress>error page template so that the user isn't shown just a blank screen with text?
I'm not talking about 404, but when WordPress displays an error.
I'd like to style this page to match my theme. | You're probably talking about theming `wp_die()`, which is the function that produces those grey error pages with a white box of text in them.
**For a plugin solution**, you could try [this plugin](http://wordpress.org/extend/plugins/mudslide-error-pages/), which says it does what you want. Not sure about version supp... |
54,622 | <p>How can I apply my own css (to match <code>editor-style.css</code>) to <code>wp_editor</code> being used on the front end for comments?</p>
<p>Currently I'm using <a href="http://www.revood.com/blog/adding-visual-editor-to-wordpress-comments-box-part-2/" rel="nofollow">code from here</a> to enable the visual editor... | [
{
"answer_id": 54634,
"author": "Micah",
"author_id": 16896,
"author_profile": "https://wordpress.stackexchange.com/users/16896",
"pm_score": 0,
"selected": false,
"text": "<p>I'm using the wp_editor() in a form that I'm building for guest posts. In order to get the background to style t... | 2012/06/08 | [
"https://wordpress.stackexchange.com/questions/54622",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2932/"
] | How can I apply my own css (to match `editor-style.css`) to `wp_editor` being used on the front end for comments?
Currently I'm using [code from here](http://www.revood.com/blog/adding-visual-editor-to-wordpress-comments-box-part-2/) to enable the visual editor for comments.
My actual code in `functions.php`:
```
ad... | Actually you can include the editor-style.css (or any other stylesheet), just pass a "content\_css" value to tinymce that points to a css file:
```
wp_editor(
$content,
'editablecontent',
array(
'tinymce' => array(
'content_css' => get_stylesheet_directory_uri() . '/editor-styles.cs... |
54,636 | <p>Just a simple question here but though my googling and searching efforts haven't found the answer to it. I'm wanting to re-size the width of my WordPress WYSIWYG editor to be <code>650px</code>. What do I have to type into <code>functions.php</code> to get this effect?</p>
<p>I found this but it didn't do anything<... | [
{
"answer_id": 54640,
"author": "Kirill Fuchs",
"author_id": 16500,
"author_profile": "https://wordpress.stackexchange.com/users/16500",
"pm_score": 2,
"selected": false,
"text": "<p>The WYSIWYG uses the <code>.wp-editor-container</code> class. So the easiest way would be to change this ... | 2012/06/08 | [
"https://wordpress.stackexchange.com/questions/54636",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25108/"
] | Just a simple question here but though my googling and searching efforts haven't found the answer to it. I'm wanting to re-size the width of my WordPress WYSIWYG editor to be `650px`. What do I have to type into `functions.php` to get this effect?
I found this but it didn't do anything
```
add_action('admin_print_sty... | The WYSIWYG uses the `.wp-editor-container` class. So the easiest way would be to change this in your CSS. If your style is being overwritten then just add `!important`.
```
.wp-editor-container {
width:50%; // What ever size you want
}
```
the `wp_editor()` function also allows us to add a class to the `textare... |
54,643 | <p>By submitting a post for publication will be made a count of the number of words in the post and will add a div with font-size pre-set according to the number of words. </p>
<p>If the post contains up to 50 words, returns with font-size:18px;</p>
<pre><code><div style="font-size:18px;"><p>Text with up ... | [
{
"answer_id": 54648,
"author": "Kirill Fuchs",
"author_id": 16500,
"author_profile": "https://wordpress.stackexchange.com/users/16500",
"pm_score": 0,
"selected": false,
"text": "<p>the php function for this is</p>\n\n<p>str_word_count(string,return,char)</p>\n\n<p>Where string = (requi... | 2012/06/09 | [
"https://wordpress.stackexchange.com/questions/54643",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12990/"
] | By submitting a post for publication will be made a count of the number of words in the post and will add a div with font-size pre-set according to the number of words.
If the post contains up to 50 words, returns with font-size:18px;
```
<div style="font-size:18px;"><p>Text with up to 50 words.</p></div>
```
If ... | Filter `'the_content'`, [count the words](https://wordpress.stackexchange.com/a/52460/73), and add the markup you need. You should not use `str_word_count()` because it has issues with numbers and utf-8.
So let’s start with a word count function:
```
/**
* Alternative for str_word_count().
*
* @link http://toscho.... |
54,658 | <p>I created a picture gallery at: <a href="http://ellenandjosh.com/?page_id=5" rel="nofollow">http://ellenandjosh.com/?page_id=5</a>. </p>
<p>Currently, I have a loop that displays pagination after a certain number of images : <a href="http://pastebin.com/N6nRRUei" rel="nofollow">http://pastebin.com/N6nRRUei</a>.</p>... | [
{
"answer_id": 54660,
"author": "avk",
"author_id": 8430,
"author_profile": "https://wordpress.stackexchange.com/users/8430",
"pm_score": 0,
"selected": false,
"text": "<p>what you are saying is kind of not possible because your images have different width (as you said) and we cannot det... | 2012/06/09 | [
"https://wordpress.stackexchange.com/questions/54658",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9820/"
] | I created a picture gallery at: <http://ellenandjosh.com/?page_id=5>.
Currently, I have a loop that displays pagination after a certain number of images : <http://pastebin.com/N6nRRUei>.
Normally this works fine...but normally I don't have images that are different widths. WordPress crops the image by height, the wi... | It is definitely possible!!
Ok, here is what I did...
My new loop looks like:
```
<?php $ids = array();?>
<?php foreach(query_posts("category_name=photos&showposts=-1") as $post_blog): ?>
<?php $url = wp_get_attachment_image_src( get_post_thumbnail_id($post_blog->ID), 'gallery-full' ); ?> ... |
54,677 | <p>I have created a table, I now need to filter the data from that table when someone selects options from a form.</p>
<p>Whats a good way to do that? </p>
| [
{
"answer_id": 54660,
"author": "avk",
"author_id": 8430,
"author_profile": "https://wordpress.stackexchange.com/users/8430",
"pm_score": 0,
"selected": false,
"text": "<p>what you are saying is kind of not possible because your images have different width (as you said) and we cannot det... | 2012/06/09 | [
"https://wordpress.stackexchange.com/questions/54677",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I have created a table, I now need to filter the data from that table when someone selects options from a form.
Whats a good way to do that? | It is definitely possible!!
Ok, here is what I did...
My new loop looks like:
```
<?php $ids = array();?>
<?php foreach(query_posts("category_name=photos&showposts=-1") as $post_blog): ?>
<?php $url = wp_get_attachment_image_src( get_post_thumbnail_id($post_blog->ID), 'gallery-full' ); ?> ... |
54,687 | <p>I've seen posts which probably answer this, but unfortunately the answers are all a bit technical without telling you where the code should go?
At the moment I have my posts directed to a blog page. I separate my posts into three categories. What I would like is to have 3 columns for each category, with the ability ... | [
{
"answer_id": 54660,
"author": "avk",
"author_id": 8430,
"author_profile": "https://wordpress.stackexchange.com/users/8430",
"pm_score": 0,
"selected": false,
"text": "<p>what you are saying is kind of not possible because your images have different width (as you said) and we cannot det... | 2012/06/09 | [
"https://wordpress.stackexchange.com/questions/54687",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16910/"
] | I've seen posts which probably answer this, but unfortunately the answers are all a bit technical without telling you where the code should go?
At the moment I have my posts directed to a blog page. I separate my posts into three categories. What I would like is to have 3 columns for each category, with the ability to ... | It is definitely possible!!
Ok, here is what I did...
My new loop looks like:
```
<?php $ids = array();?>
<?php foreach(query_posts("category_name=photos&showposts=-1") as $post_blog): ?>
<?php $url = wp_get_attachment_image_src( get_post_thumbnail_id($post_blog->ID), 'gallery-full' ); ?> ... |
54,700 | <p>These are the functions I use in my theme to display the "entry-meta" which includes <strong>published</strong> and <strong>last modified</strong> dates (among others) of an article:</p>
<pre><code>// Shows Author and Published Date
if ( ! function_exists( 'reddle_posted_on' ) ) :
function reddle_posted_on() {
... | [
{
"answer_id": 54728,
"author": "its_me",
"author_id": 10691,
"author_profile": "https://wordpress.stackexchange.com/users/10691",
"pm_score": 2,
"selected": false,
"text": "<p><em>(Nevermind, follow the better answers above. <strong>Please do NOT edit this answer.</strong> It exists as ... | 2012/06/09 | [
"https://wordpress.stackexchange.com/questions/54700",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10691/"
] | These are the functions I use in my theme to display the "entry-meta" which includes **published** and **last modified** dates (among others) of an article:
```
// Shows Author and Published Date
if ( ! function_exists( 'reddle_posted_on' ) ) :
function reddle_posted_on() {
printf( __( '<span class="byline">Posted... | The issue is that for correct output WP needs to process date through [`date_i18n()`](http://queryposts.com/function/date_i18n/) function. When you use date format, **hardcoded in PHP code** (not simply saved in PHP `DATE_*` constant) like `'c'` - it's not available to your code and so for WP to process.
System-wide f... |
54,721 | <p>I am trying to make my custom post type display on the front end as if it were a page. Depending on the theme, it won't have the date, author, etc...</p>
<p>I've looked into creating a template such as 'single-<CPT>.php'. But that's too static to work for any theme design.</p>
<p>Is it possible to somehow te... | [
{
"answer_id": 54722,
"author": "Tyler Carter",
"author_id": 16921,
"author_profile": "https://wordpress.stackexchange.com/users/16921",
"pm_score": 1,
"selected": false,
"text": "<p>This is something I have to deal with every day when creating themes that use lots of custom post types. ... | 2012/06/09 | [
"https://wordpress.stackexchange.com/questions/54721",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14956/"
] | I am trying to make my custom post type display on the front end as if it were a page. Depending on the theme, it won't have the date, author, etc...
I've looked into creating a template such as 'single-<CPT>.php'. But that's too static to work for any theme design.
Is it possible to somehow tell the current theme to... | There are a number of template filters you can use to alter the template hierarchy. Have a look at the [template hierarchy page](http://codex.wordpress.org/Template_Hierarchy#Filter_Hierarchy) at the filters and example provided.
Here's a modified version of the example that uses `single_template`. It checks for a spe... |
54,726 | <p>Below is code that successfully displays a drop-down menu of page templates in my Wordpress theme. I'm using this menu in a custom post type, and don't quite understand how to label it in order to make it save the chosen value after the user "updates". </p>
<p>The value is, in fact, being saved to the database and ... | [
{
"answer_id": 54722,
"author": "Tyler Carter",
"author_id": 16921,
"author_profile": "https://wordpress.stackexchange.com/users/16921",
"pm_score": 1,
"selected": false,
"text": "<p>This is something I have to deal with every day when creating themes that use lots of custom post types. ... | 2012/06/10 | [
"https://wordpress.stackexchange.com/questions/54726",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15578/"
] | Below is code that successfully displays a drop-down menu of page templates in my Wordpress theme. I'm using this menu in a custom post type, and don't quite understand how to label it in order to make it save the chosen value after the user "updates".
The value is, in fact, being saved to the database and displaying... | There are a number of template filters you can use to alter the template hierarchy. Have a look at the [template hierarchy page](http://codex.wordpress.org/Template_Hierarchy#Filter_Hierarchy) at the filters and example provided.
Here's a modified version of the example that uses `single_template`. It checks for a spe... |
54,752 | <p>I've done my fair share of migrating Wordpress sites, but today I am completely and utterly stumped. I've worked for many hours on this, and I cannot find a solution. I hope someone here can help.</p>
<p>I have a site that I'm trying to migrate from my local testing server to www.mysite.com (not the actual URL). On... | [
{
"answer_id": 54755,
"author": "Pierre",
"author_id": 14490,
"author_profile": "https://wordpress.stackexchange.com/users/14490",
"pm_score": 0,
"selected": false,
"text": "<p>Instead of exporting the database why don't you try to export an xml file from wordpress itself.</p>\n\n<p>1) G... | 2012/06/10 | [
"https://wordpress.stackexchange.com/questions/54752",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16935/"
] | I've done my fair share of migrating Wordpress sites, but today I am completely and utterly stumped. I've worked for many hours on this, and I cannot find a solution. I hope someone here can help.
I have a site that I'm trying to migrate from my local testing server to www.mysite.com (not the actual URL). On the testi... | Folks, I think I solved the problem! I switched the import file from UFT-8 to ANSI encoding, and the site appears to be working fine. I guess moving between Windows and Linux machines, encoding is really important. I've never had this problem before, but I will watch out for it in the future. |
54,774 | <p>After making a lot of little changes to the current custom theme <a href="http://themezee.com/zeebizzcard/" rel="nofollow"> [zeeBizzCard]</a> I'm using, I want to reset it back to it's original style. Being new to WP, I didn't make a backup of the default theme and can not find a quick and easy method of reseting th... | [
{
"answer_id": 54775,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>If you look into the file <a href=\"http://themes.svn.wordpress.org/zeebizzcard/1.1/includes/admin/theme-admin.php\" re... | 2012/06/10 | [
"https://wordpress.stackexchange.com/questions/54774",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15619/"
] | After making a lot of little changes to the current custom theme [[zeeBizzCard]](http://themezee.com/zeebizzcard/) I'm using, I want to reset it back to it's original style. Being new to WP, I didn't make a backup of the default theme and can not find a quick and easy method of reseting the theme.
Have I missed somet... | If you look into the file [`includes/admin/theme-admin.php`](http://themes.svn.wordpress.org/zeebizzcard/1.1/includes/admin/theme-admin.php) you’ll see that the theme’s options are stored in `'themezee_options'`. You can either delete these options per database manager or per a plugin.
If you aren’t familiar with data... |
54,778 | <p>I have a custom post type called <code>q-questions</code>, and it has a custom taxonomy that called <code>q-categories</code>.<br>
I insert post via <code>wp_insert_post</code> and I want to define some terms for the taxonomy<br>
My code is:<br></p>
<pre><code>$my_post = array(
'post_title' => 'Custom-tax',
'pos... | [
{
"answer_id": 54779,
"author": "Tyler Carter",
"author_id": 16921,
"author_profile": "https://wordpress.stackexchange.com/users/16921",
"pm_score": 1,
"selected": false,
"text": "<p>A category is just a taxonomy. And taxonomies are made up of terms. You'll need to set the post's terms v... | 2012/06/10 | [
"https://wordpress.stackexchange.com/questions/54778",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16331/"
] | I have a custom post type called `q-questions`, and it has a custom taxonomy that called `q-categories`.
I insert post via `wp_insert_post` and I want to define some terms for the taxonomy
My code is:
```
$my_post = array(
'post_title' => 'Custom-tax',
'post_content' => 'This is my post.',
'post_type' => 'q-qu... | A category is just a taxonomy. And taxonomies are made up of terms. You'll need to set the post's terms via [wp\_set\_post\_terms](http://codex.wordpress.org/Function_Reference/wp_set_post_terms).
This should be fairly simple:
```
wp_set_post_terms( '42', array( 'term', 'terms', 'terms' ), 'q-categories' );
``` |
54,794 | <p><strong>Overview</strong>: I am not trying to return a post. I simply want the single highest value for a particular meta_value across all posts... just the value itself.</p>
<p><strong>Details</strong>: I have added a custom meta_key "price" to all my posts. The value is always an integer (no decimals or non-num... | [
{
"answer_id": 54795,
"author": "Dakshinamurthy Karra",
"author_id": 13215,
"author_profile": "https://wordpress.stackexchange.com/users/13215",
"pm_score": 5,
"selected": true,
"text": "<p>The meta_value is not of an integer type for max to return proper values. You can use mysql <code>... | 2012/06/11 | [
"https://wordpress.stackexchange.com/questions/54794",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15612/"
] | **Overview**: I am not trying to return a post. I simply want the single highest value for a particular meta\_value across all posts... just the value itself.
**Details**: I have added a custom meta\_key "price" to all my posts. The value is always an integer (no decimals or non-numeric characters). I am trying to do ... | The meta\_value is not of an integer type for max to return proper values. You can use mysql `cast` method to convert into integers as follows:
`SELECT max(cast(meta_value as unsigned)) FROM wp_postmeta WHERE meta_key='price'` |
54,810 | <p>I thought this would have displayed the post counts right next to the clickable links</p>
<pre><code>wp_tag_cloud(
array( 'taxonomy' => $taxonomy,
'format' => 'list',
'smallest' => 12,
'largest' => 12,
'number' => 10000 ,
'separator' => '<li>' ,
'topic_count_text_callback'=> 'def... | [
{
"answer_id": 54862,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>You'll have to use the <a href=\"http://codex.wordpress.org/Function_Reference/get_terms\" rel=\"nofollow\"><code>g... | 2012/06/11 | [
"https://wordpress.stackexchange.com/questions/54810",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14967/"
] | I thought this would have displayed the post counts right next to the clickable links
```
wp_tag_cloud(
array( 'taxonomy' => $taxonomy,
'format' => 'list',
'smallest' => 12,
'largest' => 12,
'number' => 10000 ,
'separator' => '<li>' ,
'topic_count_text_callback'=> 'default_topic_count_text' )
);
```
but, ... | You'll have to use the [`get_terms`](http://codex.wordpress.org/Function_Reference/get_terms) function to build your own list if you want the count in there.
If we read the details of `topic_count_text_callback` we can see why it may *appear* to not be working:
>
> topic\_count\_text\_callback
>
>
> (string) (opti... |
54,826 | <ol>
<li>I have setup a custom post type called 'expertizeom'
<ol>
<li>I have setup a page called "expertize" and added to my custom menu
(site main nav).</li>
<li>The page is rendered with an archive called archive-expertizeom.php</li>
</ol></li>
</ol>
<p>The problem is that when i browse to that page everything is w... | [
{
"answer_id": 54944,
"author": "Pontus Abrahamsson",
"author_id": 16722,
"author_profile": "https://wordpress.stackexchange.com/users/16722",
"pm_score": 2,
"selected": false,
"text": "<p>If you using <a href=\"http://codex.wordpress.org/Function_Reference/wp_nav_menu\" rel=\"nofollow\"... | 2012/06/11 | [
"https://wordpress.stackexchange.com/questions/54826",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16960/"
] | 1. I have setup a custom post type called 'expertizeom'
1. I have setup a page called "expertize" and added to my custom menu
(site main nav).
2. The page is rendered with an archive called archive-expertizeom.php
The problem is that when i browse to that page everything is working fine but **wordpress isn't
adding... | If you using [wp nav menu](http://codex.wordpress.org/Function_Reference/wp_nav_menu) you can use this to add the current-menu-item class put this in your theme functions.php file and **remember to change "mypageslug" to your wanted current page**:
```
function additional_active_item_classes($classes = array(), $menu_... |
54,829 | <p>Why WP Editor also strips the "placeholder" attribute of the input text element ?
Ofcourse, i am using the HTML mode.
Here is the input:</p>
<pre><code><input type="text" value="" name="s" style="width: 550px;" placeholder="Search this website..">
</code></pre>
<p>After updating the post (after strip):</p>
... | [
{
"answer_id": 58828,
"author": "Evan Mattson",
"author_id": 12055,
"author_profile": "https://wordpress.stackexchange.com/users/12055",
"pm_score": 0,
"selected": false,
"text": "<p>You could use a shortcode! ;)</p>\n\n<pre><code><?php\n\n// desired output: <input type=\"text\" va... | 2012/06/11 | [
"https://wordpress.stackexchange.com/questions/54829",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16963/"
] | Why WP Editor also strips the "placeholder" attribute of the input text element ?
Ofcourse, i am using the HTML mode.
Here is the input:
```
<input type="text" value="" name="s" style="width: 550px;" placeholder="Search this website..">
```
After updating the post (after strip):
```
<input type="text" value="" name... | The list of allowed elements and attributes is stored in the global variable `$allowedposttags` which is set in `wp-includes/kses.php`.
To override it create a simple [mu plugin](http://codex.wordpress.org/Must_Use_Plugins "Codex: Must Use Plugins") with the following content:
```
<?php # -*- coding: utf-8 -*-
/**
*... |
54,834 | <p>I have many post, all categorized. So 100 post, 40 in cat=4. All those 40 post have a custom field name point with a rating in there (how many point win). Si the question How to loop through all the post, and get ONLY the post with cat=4, and sort those post base on the point score in the custom field, and display, ... | [
{
"answer_id": 54839,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": true,
"text": "<p>See <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query\" rel=\"nofollow\">WP_Query in Codex</a> for info ... | 2012/06/11 | [
"https://wordpress.stackexchange.com/questions/54834",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3969/"
] | I have many post, all categorized. So 100 post, 40 in cat=4. All those 40 post have a custom field name point with a rating in there (how many point win). Si the question How to loop through all the post, and get ONLY the post with cat=4, and sort those post base on the point score in the custom field, and display, pos... | See [WP\_Query in Codex](http://codex.wordpress.org/Class_Reference/WP_Query) for info on how to [query on custom fields](http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters).
```
$args = array(
'posts_per_page' => -1,
'cat' => 4,
'meta_key' => 'point_score',
'orderby' => 'meta_... |
54,838 | <p>I´m using WPAlchemy which is a helper class for metabox creation. I´m trying to include it through my functions.php but I´m getting strange errors when I have WP_Debug set to true.</p>
<p>For some reason Wordpress is including a lot of stuff in the url that it shouldn't, this is the warning I get.</p>
<pre><code>W... | [
{
"answer_id": 54842,
"author": "Zach Lysobey",
"author_id": 5846,
"author_profile": "https://wordpress.stackexchange.com/users/5846",
"pm_score": 1,
"selected": false,
"text": "<p>When I've used WPAlchemy, the instructions have me put the WPAlchemy directory directly into the <code>wp-c... | 2012/06/11 | [
"https://wordpress.stackexchange.com/questions/54838",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5079/"
] | I´m using WPAlchemy which is a helper class for metabox creation. I´m trying to include it through my functions.php but I´m getting strange errors when I have WP\_Debug set to true.
For some reason Wordpress is including a lot of stuff in the url that it shouldn't, this is the warning I get.
```
Warning: include_once... | When I've used WPAlchemy, the instructions have me put the WPAlchemy directory directly into the `wp-content` folder - not the theme folder. It looks like your include code points to your theme directory. All the other stuff in the path is specific to your host, and probably not part of the problem. |
54,865 | <p>I've multiple header files (header-name.php), they are mainly being used by different custom post types.
Is there any way to enqueue script to only a specific header?</p>
<p>At this moment I'm targeting it with conditional tag like if <code>( 'MYPOSTTYPE' == get_post_type() )</code> but I'm looking for a better al... | [
{
"answer_id": 54874,
"author": "mrwweb",
"author_id": 9844,
"author_profile": "https://wordpress.stackexchange.com/users/9844",
"pm_score": 0,
"selected": false,
"text": "<p>The <code>wp_enqueue_scripts</code> action is part of the <code>wp_head</code> hook, so the enqueue process isn't... | 2012/06/11 | [
"https://wordpress.stackexchange.com/questions/54865",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16977/"
] | I've multiple header files (header-name.php), they are mainly being used by different custom post types.
Is there any way to enqueue script to only a specific header?
At this moment I'm targeting it with conditional tag like if `( 'MYPOSTTYPE' == get_post_type() )` but I'm looking for a better alternative.
do we hav... | You load the header file probably with `get_header()`. There is a hook you can use: `'get_header'`. You get the called header name as parameter.
```
add_action( 'get_header', 'wpse_54865_conditional_enqueue' );
function wpse_54865_conditional_enqueue( $name )
{
if ( 'my_custom_header_name' === $name )
{
... |
54,873 | <p>I created a subdomain (dev.mysite.com) and I duplicated my live site into this subdomain. However, when I go to dev.mysite.com, it loads mysite.com/dev instead.</p>
<p>I changed siteurl and home in wp_options to dev.mysite.com, removed the entire .htaccess, deleted W3 Total Cache, and it still does it.</p>
<p>When... | [
{
"answer_id": 54877,
"author": "Pontus Abrahamsson",
"author_id": 16722,
"author_profile": "https://wordpress.stackexchange.com/users/16722",
"pm_score": 1,
"selected": false,
"text": "<p>Sounds like it is something left in your database. Try to make a new backup and import it again the... | 2012/06/11 | [
"https://wordpress.stackexchange.com/questions/54873",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12476/"
] | I created a subdomain (dev.mysite.com) and I duplicated my live site into this subdomain. However, when I go to dev.mysite.com, it loads mysite.com/dev instead.
I changed siteurl and home in wp\_options to dev.mysite.com, removed the entire .htaccess, deleted W3 Total Cache, and it still does it.
When I just put a te... | Sounds like it is something left in your database. Try to make a new backup and import it again then run this SQL in your MySQL.
**Input your old domain as <http://www.old-domain.com> and the new in <http://www.new-domain.com>, also if you have changed the prefix (wp\_) to something other, change it before run.**
```... |
54,881 | <p>I've been looking around on how to re-size the WYSIWYS editor for wordpress and have used firebug to re-size the #post-body-content but it doesn't resize ever. It will resize in the firebug application but not when I go to put it into my style.css for my toolbox theme. </p>
<pre><code>#post-body-content {
width... | [
{
"answer_id": 54883,
"author": "Pontus Abrahamsson",
"author_id": 16722,
"author_profile": "https://wordpress.stackexchange.com/users/16722",
"pm_score": 0,
"selected": false,
"text": "<p>You have to add the css to WordPress admin section within your theme <strong>functions.php</strong>... | 2012/06/11 | [
"https://wordpress.stackexchange.com/questions/54881",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25108/"
] | I've been looking around on how to re-size the WYSIWYS editor for wordpress and have used firebug to re-size the #post-body-content but it doesn't resize ever. It will resize in the firebug application but not when I go to put it into my style.css for my toolbox theme.
```
#post-body-content {
width:650px !import... | Instead of resizing the editor, resize the internal representation inside the TinyMCE instance so the content itself never passes the line. This way the editor can eb any width and the content will never be wider than it's intended to
Start by adding the editor style in functions.php
```
function my_theme_add_editor_... |
54,909 | <p>I am looking for inserting a function's output before sidebar's first widget, and one in the end after the last widget</p>
<p>Is it possible? </p>
| [
{
"answer_id": 54937,
"author": "Todd Lahman",
"author_id": 13253,
"author_profile": "https://wordpress.stackexchange.com/users/13253",
"pm_score": 0,
"selected": false,
"text": "<p>Yes. Put your function, and anything else you want, before and after the dynamic_sidebar function. For exa... | 2012/06/12 | [
"https://wordpress.stackexchange.com/questions/54909",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2419/"
] | I am looking for inserting a function's output before sidebar's first widget, and one in the end after the last widget
Is it possible? | You can create your own actions using [do\_action](http://codex.wordpress.org/Function_Reference/do_action), like this:
```
<?php do_action('before_sidebar'); // you can name it whatever you want ?>
<?php if ( is_active_sidebar('main-sidebar') ) : ?>
<ul>
<?php dynamic_sidebar('main-sidebar'); ?>
</ul>... |
54,920 | <p>I am wondering how to achieve something specific. I am not sure if this functionality is already built into Wordpress, or if there is some PHP happening.</p>
<p>This is the site I am basing some of my design from: <a href="http://www.premiumpixels.com/" rel="nofollow">http://www.premiumpixels.com/</a></p>
<p>As y... | [
{
"answer_id": 54942,
"author": "WouterB",
"author_id": 6828,
"author_profile": "https://wordpress.stackexchange.com/users/6828",
"pm_score": -1,
"selected": false,
"text": "<p>Take a look at <a href=\"http://code.google.com/p/timthumb/\" rel=\"nofollow\">Timthumb</a>, a small php script... | 2012/06/12 | [
"https://wordpress.stackexchange.com/questions/54920",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16993/"
] | I am wondering how to achieve something specific. I am not sure if this functionality is already built into Wordpress, or if there is some PHP happening.
This is the site I am basing some of my design from: <http://www.premiumpixels.com/>
As you can see, the images that are on the front page are cropped, yet, when yo... | This is quite simple to implement, using core `post-thumbnails` functionality.
First, you need to *add Theme support for the feature*, via `functions.php`:
```
<?php
function wpse54920_setup_theme() {
// Support post thumbnails
add_theme_support( 'post-thumbnails' );
}
add_action( 'after_setup_theme', 'wpse54... |
54,923 | <p>Hello wordpress gurus!</p>
<p>I want to be able to set the frontpage via a custom field.</p>
<p>So for example, in the new page area in the wordpress admin there is a custom field that displays "Set as frontage", instead of the user going to the Settings > Reading settings and setting the front page there they can... | [
{
"answer_id": 54927,
"author": "Dakshinamurthy Karra",
"author_id": 13215,
"author_profile": "https://wordpress.stackexchange.com/users/13215",
"pm_score": 0,
"selected": false,
"text": "<p>First things first - the front page is a system wide setting (by definition). Using a post meta i... | 2012/06/12 | [
"https://wordpress.stackexchange.com/questions/54923",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8776/"
] | Hello wordpress gurus!
I want to be able to set the frontpage via a custom field.
So for example, in the new page area in the wordpress admin there is a custom field that displays "Set as frontage", instead of the user going to the Settings > Reading settings and setting the front page there they can do it via the ne... | You can do it by updating 2 options.
```
<?php
//This could be page or posts.
update_option('show_on_front', '<posts/page>');
//This one sets the page you want on front, won't work if the above option is set to 'posts'.
update_option('page_on_front', '<id of the page you want to set as front page>');
... |
54,925 | <p>I'm working on a project where each category should have a custom header page.
Any suggestions? I'm just looking for some direction on how to accomplish this.</p>
| [
{
"answer_id": 54935,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 0,
"selected": false,
"text": "<p>Install the <a href=\"http://wordpress.mfields.org/plugins/taxonomy-images/\" rel=\"nofollow\">plugin Taxonomy Images<... | 2012/06/12 | [
"https://wordpress.stackexchange.com/questions/54925",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16951/"
] | I'm working on a project where each category should have a custom header page.
Any suggestions? I'm just looking for some direction on how to accomplish this. | Use the `is_category()` condtional statement
```
if(is_category('category-a-slug')){
get_header('a');
}elseif(is_category('category-b-slug')){
get_header('b');
}
``` |
54,931 | <p>I added the following to my functions.php:</p>
<pre><code>add_action('pre_get_posts', 'keyl_get_emp_posts');
function keyl_get_emp_posts($query) {
if ($query->is_main_query())
$query->set('post_type', 'employee');
}
</code></pre>
<p>and so far it's effectively filtering out the search results. Th... | [
{
"answer_id": 54935,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 0,
"selected": false,
"text": "<p>Install the <a href=\"http://wordpress.mfields.org/plugins/taxonomy-images/\" rel=\"nofollow\">plugin Taxonomy Images<... | 2012/06/12 | [
"https://wordpress.stackexchange.com/questions/54931",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14804/"
] | I added the following to my functions.php:
```
add_action('pre_get_posts', 'keyl_get_emp_posts');
function keyl_get_emp_posts($query) {
if ($query->is_main_query())
$query->set('post_type', 'employee');
}
```
and so far it's effectively filtering out the search results. The default widgets Recent Posts a... | Use the `is_category()` condtional statement
```
if(is_category('category-a-slug')){
get_header('a');
}elseif(is_category('category-b-slug')){
get_header('b');
}
``` |
54,949 | <p>I am rebuilding a static website for a client using Wordpress on the main domain- eg domain.com. There is also a directory of members website at directory.domain.com which I was hoping to migrate over to the main website- <code>domain.com/directory/</code> <em>(We want to do this, firstly to keep it on the same doma... | [
{
"answer_id": 54955,
"author": "Vincent Guesné",
"author_id": 9716,
"author_profile": "https://wordpress.stackexchange.com/users/9716",
"pm_score": 2,
"selected": true,
"text": "<p>Its not good way to edit .htaccess for wordpress url rewriting (only for main urls settings from admin pan... | 2012/06/12 | [
"https://wordpress.stackexchange.com/questions/54949",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5864/"
] | I am rebuilding a static website for a client using Wordpress on the main domain- eg domain.com. There is also a directory of members website at directory.domain.com which I was hoping to migrate over to the main website- `domain.com/directory/` *(We want to do this, firstly to keep it on the same domain, but also so t... | Its not good way to edit .htaccess for wordpress url rewriting (only for main urls settings from admin panel)
You found your response here : [API basic url rewriting](http://wp.tutsplus.com/tutorials/creative-coding/the-rewrite-api-the-basics/) or [The Rewrite API: Post Types & Taxonomies](http://wp.tutsplus.com/tutor... |
54,973 | <p>I'm working with a client who wants visitors to be able to post comments on categories instead of on individual posts, but I am unsure on how to go about it. Is it possible to display the comment form in a category? Just pasting in <code><?php comments_template(); ?></code> didn't do it, unfortunately.</p>
| [
{
"answer_id": 54955,
"author": "Vincent Guesné",
"author_id": 9716,
"author_profile": "https://wordpress.stackexchange.com/users/9716",
"pm_score": 2,
"selected": true,
"text": "<p>Its not good way to edit .htaccess for wordpress url rewriting (only for main urls settings from admin pan... | 2012/06/12 | [
"https://wordpress.stackexchange.com/questions/54973",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17110/"
] | I'm working with a client who wants visitors to be able to post comments on categories instead of on individual posts, but I am unsure on how to go about it. Is it possible to display the comment form in a category? Just pasting in `<?php comments_template(); ?>` didn't do it, unfortunately. | Its not good way to edit .htaccess for wordpress url rewriting (only for main urls settings from admin panel)
You found your response here : [API basic url rewriting](http://wp.tutsplus.com/tutorials/creative-coding/the-rewrite-api-the-basics/) or [The Rewrite API: Post Types & Taxonomies](http://wp.tutsplus.com/tutor... |
54,978 | <p>I am writing a plugin where I want to read user agent and send custom headers back on certain agents. Unfortunately however several people have the W3 Total Cache plugin and what it's doing is that, when I have a condition that sends back the custom header, it then sends back that custom header for ALL user agents, ... | [
{
"answer_id": 54955,
"author": "Vincent Guesné",
"author_id": 9716,
"author_profile": "https://wordpress.stackexchange.com/users/9716",
"pm_score": 2,
"selected": true,
"text": "<p>Its not good way to edit .htaccess for wordpress url rewriting (only for main urls settings from admin pan... | 2012/06/12 | [
"https://wordpress.stackexchange.com/questions/54978",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13/"
] | I am writing a plugin where I want to read user agent and send custom headers back on certain agents. Unfortunately however several people have the W3 Total Cache plugin and what it's doing is that, when I have a condition that sends back the custom header, it then sends back that custom header for ALL user agents, not... | Its not good way to edit .htaccess for wordpress url rewriting (only for main urls settings from admin panel)
You found your response here : [API basic url rewriting](http://wp.tutsplus.com/tutorials/creative-coding/the-rewrite-api-the-basics/) or [The Rewrite API: Post Types & Taxonomies](http://wp.tutsplus.com/tutor... |
54,986 | <p>I need to modify the_post_thumbnail function to run "Lazyload" on it,
i think there is two solutions :</p>
<p>1- modify the args to be something like this </p>
<pre><code>the_post_thumbnail('product', array('data-original'=>$src, 'src'=>'grey.gif'));
</code></pre>
<p>(((NOT WORKING!)))</p>
<p>2- get only t... | [
{
"answer_id": 54988,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 4,
"selected": true,
"text": "<p>If you want to apply lazyload to each attachment image, you can just add your hoot to <code>wp_get_attach... | 2012/06/12 | [
"https://wordpress.stackexchange.com/questions/54986",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16505/"
] | I need to modify the\_post\_thumbnail function to run "Lazyload" on it,
i think there is two solutions :
1- modify the args to be something like this
```
the_post_thumbnail('product', array('data-original'=>$src, 'src'=>'grey.gif'));
```
(((NOT WORKING!)))
2- get only the image url from the function ... i've trie... | If you want to apply lazyload to each attachment image, you can just add your hoot to `wp_get_attachment_image_attributes` filter:
```
add_filter( 'wp_get_attachment_image_attributes', 'wpse8170_add_lazyload_to_attachment_image', 10, 2 );
function wpse8170_add_lazyload_to_attachment_image( $attr, $attachment ) {
$... |
54,987 | <p>When you add a text widget to a sidebar in Wordpress the widget includes this code </p>
<pre><code><div class="textwidget">
</code></pre>
<p>How do I remove this without editing the core?</p>
<p>FYI - I think this line is located here:
wp-includes/default-widgets.php (line 383)</p>
| [
{
"answer_id": 54990,
"author": "MZAweb",
"author_id": 5223,
"author_profile": "https://wordpress.stackexchange.com/users/5223",
"pm_score": -1,
"selected": false,
"text": "<p>You can use output buffering (http://php.net/manual/es/book.outcontrol.php) to get the whole generated page in a... | 2012/06/12 | [
"https://wordpress.stackexchange.com/questions/54987",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12727/"
] | When you add a text widget to a sidebar in Wordpress the widget includes this code
```
<div class="textwidget">
```
How do I remove this without editing the core?
FYI - I think this line is located here:
wp-includes/default-widgets.php (line 383) | OK, attempting to remove the with jQuery is counter intuitive.
Modifying it via output buffering is inefficient.
And we shouldn't edit the actual widget code itself, since this will revert back next time we update WordPress.
I would suggest either creating your own text widget, or simply extend and modify the existi... |
54,989 | <p>Is there any possibility on Wordpress to get an image from a post gallery?
Images are not inserted in the post, are on it's gallery.
I'm trying to do a "galleries index" page and instead having the user set a "cover image" I'd like to take any of the attached to the post as part of a gallery. </p>
<p>I tried the w... | [
{
"answer_id": 54991,
"author": "MZAweb",
"author_id": 5223,
"author_profile": "https://wordpress.stackexchange.com/users/5223",
"pm_score": 3,
"selected": true,
"text": "<p>You can get the attached media to a post using get_children. IE: get the first attached image for post ID == 14</p... | 2012/06/12 | [
"https://wordpress.stackexchange.com/questions/54989",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15574/"
] | Is there any possibility on Wordpress to get an image from a post gallery?
Images are not inserted in the post, are on it's gallery.
I'm trying to do a "galleries index" page and instead having the user set a "cover image" I'd like to take any of the attached to the post as part of a gallery.
I tried the wp\_get\_at... | You can get the attached media to a post using get\_children. IE: get the first attached image for post ID == 14
```
$args = array( 'post_mime_type' => 'image',
'numberposts' => 1,
'post_parent' => 14,
'post_type' => 'attachment' );
$first_attached_image = get_c... |
55,002 | <p>I am making a custom theme and I want the main page to be a gallery, not a blog,<br>
is it right to change <code>index.php</code> to a gallery page (content wise) or should I use another page?</p>
| [
{
"answer_id": 54991,
"author": "MZAweb",
"author_id": 5223,
"author_profile": "https://wordpress.stackexchange.com/users/5223",
"pm_score": 3,
"selected": true,
"text": "<p>You can get the attached media to a post using get_children. IE: get the first attached image for post ID == 14</p... | 2012/06/12 | [
"https://wordpress.stackexchange.com/questions/55002",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14982/"
] | I am making a custom theme and I want the main page to be a gallery, not a blog,
is it right to change `index.php` to a gallery page (content wise) or should I use another page? | You can get the attached media to a post using get\_children. IE: get the first attached image for post ID == 14
```
$args = array( 'post_mime_type' => 'image',
'numberposts' => 1,
'post_parent' => 14,
'post_type' => 'attachment' );
$first_attached_image = get_c... |
55,010 | <p>I have written the following function which copies all post terms from the "tribe_events_cat" taxonomy to the "categoria" taxonomy when the post is saved. There is a bug where in order for the terms to be copied, I need to click "update" twice (i.e. save the post twice).</p>
<p>I believe this happens because when I... | [
{
"answer_id": 55020,
"author": "Andy Adams",
"author_id": 6816,
"author_profile": "https://wordpress.stackexchange.com/users/6816",
"pm_score": 2,
"selected": false,
"text": "<p>This is a stab in the dark, but have you tried using the <code>set_object_terms</code> hook for your <code>ba... | 2012/06/12 | [
"https://wordpress.stackexchange.com/questions/55010",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/325/"
] | I have written the following function which copies all post terms from the "tribe\_events\_cat" taxonomy to the "categoria" taxonomy when the post is saved. There is a bug where in order for the terms to be copied, I need to click "update" twice (i.e. save the post twice).
I believe this happens because when I call `g... | This is a stab in the dark, but have you tried using the `set_object_terms` hook for your `bam_save_event_cat` function?
```
function bam_save_event_cat( $post_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids ) {
$taxonomy = 'categoria';
$tribe_cats = get_the_terms( $post_id, 'tribe_events_cat');
for... |
55,025 | <p>I am trying to retrieve in the "content composer" the categories of projects based on the active language. But i only get the categories off the main language, never on the other.</p>
<p>My code is:</p>
<p>
Category
All
<pre><code> $categories = get_categories('taxonomy=jw_por... | [
{
"answer_id": 55020,
"author": "Andy Adams",
"author_id": 6816,
"author_profile": "https://wordpress.stackexchange.com/users/6816",
"pm_score": 2,
"selected": false,
"text": "<p>This is a stab in the dark, but have you tried using the <code>set_object_terms</code> hook for your <code>ba... | 2012/06/12 | [
"https://wordpress.stackexchange.com/questions/55025",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17023/"
] | I am trying to retrieve in the "content composer" the categories of projects based on the active language. But i only get the categories off the main language, never on the other.
My code is:
Category
All
```
$categories = get_categories('taxonomy=jw_portfolio_categories');
if(!emp... | This is a stab in the dark, but have you tried using the `set_object_terms` hook for your `bam_save_event_cat` function?
```
function bam_save_event_cat( $post_id, $terms, $tt_ids, $taxonomy, $append, $old_tt_ids ) {
$taxonomy = 'categoria';
$tribe_cats = get_the_terms( $post_id, 'tribe_events_cat');
for... |
55,026 | <p>I am using wordpress for my new website and i have list of clients(name and their logos). I am confused how to make those editable using wordpress? Html as follows...</p>
<pre><code><ul>
<li><img src="1.jpg" alt="client1"/>Client1</li>
<li><img src="2.jpg" alt="client2"/>Client2&... | [
{
"answer_id": 55029,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": false,
"text": "<p>You could use custom post types, <s>search for <code>portfolio</code> to get a ton of examples</s>. See EAMann’s answe... | 2012/06/12 | [
"https://wordpress.stackexchange.com/questions/55026",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17024/"
] | I am using wordpress for my new website and i have list of clients(name and their logos). I am confused how to make those editable using wordpress? Html as follows...
```
<ul>
<li><img src="1.jpg" alt="client1"/>Client1</li>
<li><img src="2.jpg" alt="client2"/>Client2</li>
</ul>
```
Should i use custom post type or ... | You'll want to use a custom post type for this. But don't let the terms "custom post type" scare you off.
For example, [one of my clients](http://adaptelectronics.com) needed to present a "line card" displaying their various partners. All they wanted, originally, was the name and logo of their various partners. After ... |
55,081 | <p>I'm running a multisite network with 200+ themes installed and activated. Is there a way to manipulate the list of available themes in wp-admin so that <strong>certain theme does not appear in the list</strong>? I want to do it without editing core files.</p>
<p>I know WordPress gets the list of available themes fr... | [
{
"answer_id": 55109,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 3,
"selected": true,
"text": "<p>The following filter works in <strong>Multisite</strong> in the following screens:</p>\n<ul>\n<li><code>/wp-a... | 2012/06/13 | [
"https://wordpress.stackexchange.com/questions/55081",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16289/"
] | I'm running a multisite network with 200+ themes installed and activated. Is there a way to manipulate the list of available themes in wp-admin so that **certain theme does not appear in the list**? I want to do it without editing core files.
I know WordPress gets the list of available themes from the function `get_th... | The following filter works in **Multisite** in the following screens:
* `/wp-admin/network/themes.php`
* `/wp-admin/network/site-themes.php?id=1` (individual sites allowed themes)
```
add_filter( 'all_themes', 'wpse_55081_remove_themes_ms' );
function wpse_55081_remove_themes_ms($themes)
{
unset($themes['Twenty T... |
55,084 | <p>I have a few scripts which are being enqueued,</p>
<p>the problem is that I want to force the order of prominece to which these scripts are loaded. There is one in particular which is loaded from a plugin before the theme ones which requires jquery however the plugin does not require jquery (bad dev on the plugin b... | [
{
"answer_id": 55085,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 5,
"selected": true,
"text": "<p>You just need to enqueue your scripts before plugin does it. You can do it by setting priority to 0 for y... | 2012/06/13 | [
"https://wordpress.stackexchange.com/questions/55084",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14485/"
] | I have a few scripts which are being enqueued,
the problem is that I want to force the order of prominece to which these scripts are loaded. There is one in particular which is loaded from a plugin before the theme ones which requires jquery however the plugin does not require jquery (bad dev on the plugin but I'd rat... | You just need to enqueue your scripts before plugin does it. You can do it by setting priority to 0 for your hook. For example, do the following:
```
add_filter( 'wp_enqueue_scripts', 'wpse8170_enqueue_my_scripts', 0 );
// or if you enqueue your scripts on init action
// add_action( 'init', 'wpse8170_enqueue_my_script... |
55,088 | <p>I have a Wordpress site using custom post types, and I have also got the All In One SEO pack installed.</p>
<p>I wondered if anyone knows a hack or a modification I can make to the code which will allow me to stop the pictured area from showing up on certain custom post types?</p>
<p><img src="https://i.stack.imgu... | [
{
"answer_id": 55105,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 1,
"selected": false,
"text": "<p>Looks like it's just a matter of configuring the plugin...<br>\n<code>/wp-admin/options-general.php?page=all... | 2012/06/13 | [
"https://wordpress.stackexchange.com/questions/55088",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5590/"
] | I have a Wordpress site using custom post types, and I have also got the All In One SEO pack installed.
I wondered if anyone knows a hack or a modification I can make to the code which will allow me to stop the pictured area from showing up on certain custom post types?
 {
remove_meta_box( 'aiosp', 'movie', 'advanced' );
}
add_action( 'add_meta_boxes', 'wpse_55088_remo... |
55,110 | <p>I have a WordPress plugin, and I must load scripts from my plugin to the front of the site.</p>
<pre><code>class My_Plugin {
function __construct()
{
add_action('admin_menu', array(&$this, 'add_submenu'));
add_action('admin_init', array(&$this, 'admin_init'))
}
function load_my_scripts(){
w... | [
{
"answer_id": 55112,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 3,
"selected": true,
"text": "<p>Use <code>wp_enqueue_scripts</code> and <code>admin_enqueue_scripts</code> actions to enqueue your script... | 2012/06/13 | [
"https://wordpress.stackexchange.com/questions/55110",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15879/"
] | I have a WordPress plugin, and I must load scripts from my plugin to the front of the site.
```
class My_Plugin {
function __construct()
{
add_action('admin_menu', array(&$this, 'add_submenu'));
add_action('admin_init', array(&$this, 'admin_init'))
}
function load_my_scripts(){
wp_enqueue_script('scri... | Use `wp_enqueue_scripts` and `admin_enqueue_scripts` actions to enqueue your scripts:
```
// for front end
add_action('wp_enqueue_scripts', array(&$this, 'load_my_scripts'));
// for back end
add_action('admin_enqueue_scripts', array(&$this, 'load_my_scripts'));
```
Also pay attention that it is bad practice to load ... |
55,140 | <p>I am working on a theme at the moment and I have set up a post template.</p>
<p>This post template is linked to some custom post types.</p>
<p>When I query_posts for my post type on the actual post template itself it makes the content disappear for some reason? Is there something I am missing here?</p>
<p>Thanks,... | [
{
"answer_id": 55142,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": true,
"text": "<p>use <a href=\"http://codex.wordpress.org/Function_Reference/wp_reset_query\" rel=\"nofollow\"><code>wp_reset_query</... | 2012/06/13 | [
"https://wordpress.stackexchange.com/questions/55140",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17010/"
] | I am working on a theme at the moment and I have set up a post template.
This post template is linked to some custom post types.
When I query\_posts for my post type on the actual post template itself it makes the content disappear for some reason? Is there something I am missing here?
Thanks,
Mark
My loop is as fo... | use [`wp_reset_query`](http://codex.wordpress.org/Function_Reference/wp_reset_query) after your loop to restore the global post data for the main loop. |
55,159 | <p>I'm building a themes option panel and want users to be able to choose between Next/Previous links or pagination in my archives and homepage.</p>
<p>I need help combining the two functions below (pagination and next previous) to create a function which chooses based on the user's selection.</p>
<p>I figure the fun... | [
{
"answer_id": 55583,
"author": "shabushabu",
"author_id": 14944,
"author_profile": "https://wordpress.stackexchange.com/users/14944",
"pm_score": 3,
"selected": true,
"text": "<p>A simple if statement should do, so something like this:</p>\n\n<pre><code>function my_theme_navigation() {\... | 2012/06/13 | [
"https://wordpress.stackexchange.com/questions/55159",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5205/"
] | I'm building a themes option panel and want users to be able to choose between Next/Previous links or pagination in my archives and homepage.
I need help combining the two functions below (pagination and next previous) to create a function which chooses based on the user's selection.
I figure the function I add to th... | A simple if statement should do, so something like this:
```
function my_theme_navigation() {
if( get_option( $shortname .'_next_prev_or_paginate' ) == 'Next/Previous Links' ) :
// the block for next-prev navigation
else :
// the code for pagination
endif;
}
```
I have no way of knowing w... |
55,164 | <p>I would like to get all the comments for a group of post (not only one post. </p>
<p>I tried</p>
<pre><code>$comment_args = array('number' => '14', 'post_id' => '10,20,30,40' );
$comments = get_comments($comment_args);
foreach($comments as $comment) ...
</code></pre>
<p>But does not work. Any ideas... | [
{
"answer_id": 55167,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 3,
"selected": false,
"text": "<p>Unfortunately, <code>get_comments()</code> doesn't quite work that way. If you specify a post ID, the function will ... | 2012/06/13 | [
"https://wordpress.stackexchange.com/questions/55164",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17092/"
] | I would like to get all the comments for a group of post (not only one post.
I tried
```
$comment_args = array('number' => '14', 'post_id' => '10,20,30,40' );
$comments = get_comments($comment_args);
foreach($comments as $comment) ...
```
But does not work. Any ideas? | The `'post_id'` is converted to a positive integer in `WP_Comment_Query`, so you cannot successful pass anything else to `get_comments()`.
You have to filter `'comments_clauses'`. Here you can change the `WHERE` clause to use `comment_post_ID IN ( $ids )` instead of `comment_post_ID = $id`.
I would use a static clas... |