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 |
|---|---|---|---|---|---|---|
96,554 | <p>Trying to figure out an issue a fellow programmer is having. I was wondering if the <code>functions.php</code> file get called at all when you do admin side AJAX? I know that when you do an AJAX call a part of WP gets loaded up to process the call and send back a response. Is the <code>functions.php</code> file i... | [
{
"answer_id": 96556,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 6,
"selected": true,
"text": "<p><code>admin-ajax.php</code> loads <code>wp-load.php</code>:</p>\n\n<pre><code>/** Load WordPress Bootstrap */\nrequire_... | 2013/04/20 | [
"https://wordpress.stackexchange.com/questions/96554",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2234/"
] | Trying to figure out an issue a fellow programmer is having. I was wondering if the `functions.php` file get called at all when you do admin side AJAX? I know that when you do an AJAX call a part of WP gets loaded up to process the call and send back a response. Is the `functions.php` file included in that?
The reason... | `admin-ajax.php` loads `wp-load.php`:
```
/** Load WordPress Bootstrap */
require_once( dirname( dirname( __FILE__ ) ) . '/wp-load.php' );
```
`wp-load.php` loads `wp-config.php`, and there `wp-settings.php` is loaded.
And here we find this:
```
// Load the functions for the active theme, for both parent and child... |
96,564 | <p>Hi I have a form that adds attachments to a post, however when the form posts it obviously doesn't show the post with the new attachment echoing "your file has been uploaded". When the user refreshes the page (to try and show their new attachment) the form posts again!</p>
<p>Is it possible to either (1) stop the f... | [
{
"answer_id": 96565,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": false,
"text": "<p>Instead of …</p>\n\n<pre><code>} else {\n echo \"<p>Your file has been uploaded.</p>\";\n}\n</code></pr... | 2013/04/20 | [
"https://wordpress.stackexchange.com/questions/96564",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25609/"
] | Hi I have a form that adds attachments to a post, however when the form posts it obviously doesn't show the post with the new attachment echoing "your file has been uploaded". When the user refreshes the page (to try and show their new attachment) the form posts again!
Is it possible to either (1) stop the form postin... | Instead of …
```
} else {
echo "<p>Your file has been uploaded.</p>";
}
```
… redirect to another address on success:
```
} else {
$new_url = add_query_arg( 'success', 1, get_permalink() );
wp_redirect( $new_url, 303 );
exit;
}
```
[Status code 303 triggers a GET request](http://www.w3.org/Protoc... |
96,576 | <p>I've been changing the way that the Single product page looks. I've moved a few things about by hooking into Woocommerce and also editing the css.</p>
<p>Out of the box the single product page shows the short description (described as woocommerce_template_single_excerpt in the content-single-product.php file) next ... | [
{
"answer_id": 96594,
"author": "Ewout",
"author_id": 26106,
"author_profile": "https://wordpress.stackexchange.com/users/26106",
"pm_score": 2,
"selected": false,
"text": "<p>I never understood this either from woocommerce... I'd expect a 'product description' as the main post info and ... | 2013/04/20 | [
"https://wordpress.stackexchange.com/questions/96576",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31802/"
] | I've been changing the way that the Single product page looks. I've moved a few things about by hooking into Woocommerce and also editing the css.
Out of the box the single product page shows the short description (described as woocommerce\_template\_single\_excerpt in the content-single-product.php file) next to the ... | Slightly different fix provided by Woocommerce so I thought I should include it here:
In templates/single-product/short-description.php where it says:
```
$post->post_excerpt
```
Replace this (2 occurrences) with;
```
$post->post_content
```
Thanks |
96,584 | <p>I found <a href="https://wordpress.stackexchange.com/q/35849">this post</a> that describes how to filter category posts with Ajax and it works great, but I also want to filter my custom taxonomies the same way and I can't get it to work. It shows me all posts instead of just the posts from my taxonomy. </p>
<p>I k... | [
{
"answer_id": 96683,
"author": "Emily",
"author_id": 31814,
"author_profile": "https://wordpress.stackexchange.com/users/31814",
"pm_score": 3,
"selected": false,
"text": "<p>I figured it out! Here is the code I used:</p>\n\n<p>Add to <code>functions.php</code>:</p>\n\n<pre><code>add_ac... | 2013/04/20 | [
"https://wordpress.stackexchange.com/questions/96584",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31814/"
] | I found [this post](https://wordpress.stackexchange.com/q/35849) that describes how to filter category posts with Ajax and it works great, but I also want to filter my custom taxonomies the same way and I can't get it to work. It shows me all posts instead of just the posts from my taxonomy.
I know the menu needs to ... | I figured it out! Here is the code I used:
Add to `functions.php`:
```
add_action( 'wp_ajax_nopriv_load-filter2', 'prefix_load_term_posts' );
add_action( 'wp_ajax_load-filter2', 'prefix_load_term_posts' );
function prefix_load_term_posts () {
$term_id = $_POST[ 'term' ];
$args = array (
... |
96,615 | <p>(or add comma to all items but the last one...)</p>
<p>Most of the information I have found relates to using a counter within a <code>foreach</code> loop. In this particular situation I am using Advanced Custom Fields and I am within a standard loop, not a <code>foreach</code> loop.</p>
<p>I need to add a comma to... | [
{
"answer_id": 96618,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": true,
"text": "<p>There is nothing 'standard' about a <code>while</code> loop and in this case it makes things harder, since you... | 2013/04/21 | [
"https://wordpress.stackexchange.com/questions/96615",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13663/"
] | (or add comma to all items but the last one...)
Most of the information I have found relates to using a counter within a `foreach` loop. In this particular situation I am using Advanced Custom Fields and I am within a standard loop, not a `foreach` loop.
I need to add a comma to the end of each item except the last.
... | There is nothing 'standard' about a `while` loop and in this case it makes things harder, since you need a total count of all the items in loop in order to know if you are on the last item or not. It is not obvious how to get that total count with a function like `has_sub_field` but there is a quick way to do this that... |
96,620 | <p>Is keeping <code>wp-admin/install.php</code> and <code>wp-admin/install-helper.php</code> a security leak on the newer versions of wordpress? By default file permission on those files are 644.</p>
<p>If there is any leak, what kind of please?</p>
| [
{
"answer_id": 96632,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 5,
"selected": true,
"text": "<p>No, there is no security risk. Both files do sanity checks before anything happens.</p>\n\n<p>If WordPress is already i... | 2013/04/21 | [
"https://wordpress.stackexchange.com/questions/96620",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28744/"
] | Is keeping `wp-admin/install.php` and `wp-admin/install-helper.php` a security leak on the newer versions of wordpress? By default file permission on those files are 644.
If there is any leak, what kind of please? | No, there is no security risk. Both files do sanity checks before anything happens.
If WordPress is already installed:
* `install-helper.php` returns just a blank page.
* `install.php` says WordPress is installed and you should log in:

You can forb... |
96,644 | <p>Can I list all files uploaded by users in Network sites? In Multisite each user can manage their files with their own blog but the Super admin can't monitor all the uploaded files...how can i do that? </p>
| [
{
"answer_id": 96651,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>You have to run through each blog and fetch the recent attachments with:</p>\n\n<pre><code>$args = array (\n 'pos... | 2013/04/21 | [
"https://wordpress.stackexchange.com/questions/96644",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29072/"
] | Can I list all files uploaded by users in Network sites? In Multisite each user can manage their files with their own blog but the Super admin can't monitor all the uploaded files...how can i do that? | You have to run through each blog and fetch the recent attachments with:
```
$args = array (
'post_type' => 'attachment',
'numberposts' => 30
);
$attachments = get_posts( $args );
```
Dashboard widgets are registered on `wp_network_dashboard_setup` in multi-site and `wp_dashboard_setup` in single-site.
... |
96,660 | <p>I'm writing a custom post type plugin. Part of it I'm outputting to the template via shortcodes. But other parts need a custom post template, and I figured out how to use the template hierarchy for CPT's. But the custom template is in the theme, and I'm thinking the plugin should be self-contained, at least to start... | [
{
"answer_id": 96661,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>You could hook into <code>template_include</code> and return your plugin file if the request is for your post type:</p... | 2013/04/21 | [
"https://wordpress.stackexchange.com/questions/96660",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5397/"
] | I'm writing a custom post type plugin. Part of it I'm outputting to the template via shortcodes. But other parts need a custom post template, and I figured out how to use the template hierarchy for CPT's. But the custom template is in the theme, and I'm thinking the plugin should be self-contained, at least to start wi... | >
> So what's the best practice here?
>
>
>
I would say a combination of letting the theme handle it and providing a default with your plugin.
You can use the `single_template` filter to switch out the template. In your callback, see if the theme provided a template for the post type, if it did, do nothing.
```
... |
96,673 | <p>Here is the code on how to delete all dashboard widgets - the default, and plugin widgets but I want to change the code to only delete custom dashboard widgets not the default ones.</p>
<hr>
<pre><code>// Create the function to use in the action hook
function remove_dashboard_widgets() {
global $wp_meta_boxes;... | [
{
"answer_id": 96678,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>The built-in dashboard widgets are not marked somehow, you have to use a fixed list:</p>\n\n<pre><code>'dashboard_right... | 2013/04/21 | [
"https://wordpress.stackexchange.com/questions/96673",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31825/"
] | Here is the code on how to delete all dashboard widgets - the default, and plugin widgets but I want to change the code to only delete custom dashboard widgets not the default ones.
---
```
// Create the function to use in the action hook
function remove_dashboard_widgets() {
global $wp_meta_boxes;
if ( !arra... | The built-in dashboard widgets are not marked somehow, you have to use a fixed list:
```
'dashboard_right_now',
'dashboard_plugins',
'dashboard_quick_press',
'dashboard_recent_drafts',
'dashboard_recent_comments',
'dashboard_incoming_links',
'dashboard_primary',
'dashboard_secondary'
```
So your code should test if ... |
96,681 | <p>When wordpress sidebar outputs any particular <code>registered sidebar</code> it loop through all widgets that assigned through it and outputs it (i guess). Is is possible to hook into the loop and add some content, say <strong>I want to add a ad code every three widgets</strong>.</p>
<p><strong>What I have tried?<... | [
{
"answer_id": 96685,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>Hook into <code>'dynamic_sidebar'</code> and count how often it is called.</p>\n\n<p>You get the current active sidebar... | 2013/04/21 | [
"https://wordpress.stackexchange.com/questions/96681",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3094/"
] | When wordpress sidebar outputs any particular `registered sidebar` it loop through all widgets that assigned through it and outputs it (i guess). Is is possible to hook into the loop and add some content, say **I want to add a ad code every three widgets**.
**What I have tried?** Unable to find any leads. Tried to sea... | Hook into `'dynamic_sidebar'` and count how often it is called.
You get the current active sidebar with `key( $GLOBALS['wp_registered_sidebars'] )`.
```
add_action( 'dynamic_sidebar', 'wpse_96681_hr' );
function wpse_96681_hr( $widget )
{
static $counter = 0;
// right sidebar in Twenty Ten. Adjust to your n... |
96,690 | <p>I'm converting a HTML site to WP for a client and they have a simple contact form in place.</p>
<p>If the submission is sucessful it currently, in it's HTML form, sends them to thankyou.html but I want to be able to send it to a custom permalink (Ie; to a page with the ID of 8) within the new installation, is it po... | [
{
"answer_id": 96693,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>If your form has been incorporated into WordPress as a <a href=\"http://codex.wordpress.org/Pages#Creating_Yo... | 2013/04/21 | [
"https://wordpress.stackexchange.com/questions/96690",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18547/"
] | I'm converting a HTML site to WP for a client and they have a simple contact form in place.
If the submission is sucessful it currently, in it's HTML form, sends them to thankyou.html but I want to be able to send it to a custom permalink (Ie; to a page with the ID of 8) within the new installation, is it possible wit... | If your form has been incorporated into WordPress as a [page template](http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates), which I encourage, then [`get_permalink(8); // or 12`](http://codex.wordpress.org/Function_Reference/get_permalink) should do it.
If not, then `http://example.com/?p=8` and `http:... |
96,692 | <p>I'm trying to add a rich text editor to my own plugin.
So I googled it first of course and I found several answers on <a href="http://www.dev4press.com/2010/tutorials/wordpress/tips/add-rich-text-editor-to-your-plugin/" rel="nofollow noreferrer">dev4press</a> and <a href="https://stackoverflow.com/questions/1037749... | [
{
"answer_id": 96713,
"author": "i-4Web",
"author_id": 31394,
"author_profile": "https://wordpress.stackexchange.com/users/31394",
"pm_score": 1,
"selected": false,
"text": "<p>I suggest you use the built in wp_editor() function. Google \"wp_editor wordpress codex\" and Check out this tu... | 2013/04/21 | [
"https://wordpress.stackexchange.com/questions/96692",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30688/"
] | I'm trying to add a rich text editor to my own plugin.
So I googled it first of course and I found several answers on [dev4press](http://www.dev4press.com/2010/tutorials/wordpress/tips/add-rich-text-editor-to-your-plugin/) and [Stack Overflow](https://stackoverflow.com/questions/10377496/add-rich-text-editor-in-wp-plug... | `wp_editor()` outputs the textarea(html codes),
so, maybe you dont need to use that in functions.php, but use inside the page's source.
(for example, in your plugin.php:
```
<div class="blabla>
<form action="" method="POST">
<?php wp_editor( 'Hi,its content' , 'desired_id_of_textarea', $settings = array('textarea_... |
96,702 | <p>I'm trying to set a <code>post__not_in</code> which use a global <code>$popular</code> variable, defined in the <code>index.php</code>.</p>
<p>-index.php-</p>
<pre><code>$popular[] = 1 //post id=1
$popular[] = 2 //post id=2
$popular[] = 3 //post id=3
</code></pre>
<p>-functions.php-</p>
<pre><code>function modif... | [
{
"answer_id": 96705,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>You have to declare <code>$popular</code> to be global before you use it. Based on the code you've posted you... | 2013/04/22 | [
"https://wordpress.stackexchange.com/questions/96702",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31852/"
] | I'm trying to set a `post__not_in` which use a global `$popular` variable, defined in the `index.php`.
-index.php-
```
$popular[] = 1 //post id=1
$popular[] = 2 //post id=2
$popular[] = 3 //post id=3
```
-functions.php-
```
function modify_query_exclude_popular($query) {
if ($query->is_main_query() && $query->... | You have to declare `$popular` to be global before you use it. Based on the code you've posted you haven't done that.
```
global $popular;
$popular[] = 1 //post id=1
$popular[] = 2 //post id=2
$popular[] = 3 //post id=3
```
However, if you mean the `index.php` in the theme, that file is not always used. You may be d... |
96,703 | <p>I just imported 1000 post into a custom post type on a site and the slugs are all blank. There is a problem with the importing plugin i'm using. My SQL is weak :-/ know what i need to do but not sure who to write the query.</p>
<p><strong>I need help writing a query to run in phpmyadmin to copy post_title to post_n... | [
{
"answer_id": 96706,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>You do not want a simple <code>SQL</code> solution. <code>post_name</code> is used to generate permalinks. If... | 2013/04/22 | [
"https://wordpress.stackexchange.com/questions/96703",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2873/"
] | I just imported 1000 post into a custom post type on a site and the slugs are all blank. There is a problem with the importing plugin i'm using. My SQL is weak :-/ know what i need to do but not sure who to write the query.
**I need help writing a query to run in phpmyadmin to copy post\_title to post\_name where post... | You do not want a simple `SQL` solution. `post_name` is used to generate permalinks. If you simply copy the title to the name (slug) you will have spaces and punctuation in the URL, and that is going to be a problem. It will result in broken links. Additionally, you could end up with two posts having the same permalink... |
96,762 | <p>I'm building a plugin that has a meta box. Some of the fields in the meta box are required. Is using jQuery the only method for achieving this? Can I require that a field is filled in using PHP?</p>
| [
{
"answer_id": 96764,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>There is no way to require input per PHP. Only the browser can do that, and the browser gets the output after PHP is d... | 2013/04/22 | [
"https://wordpress.stackexchange.com/questions/96762",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I'm building a plugin that has a meta box. Some of the fields in the meta box are required. Is using jQuery the only method for achieving this? Can I require that a field is filled in using PHP? | You can use Javascript to create a first-line convenience warning, but that is not a secure solution. You will need to interrupt the post save to truly create a required field.
```
function req_meta_wpse_96762($data){
$allow_pending = false;
if (isset($_POST['meta'])) {
foreach ($_POST['meta'] as $v) {
i... |
96,771 | <p>The Plugin List Category Post used as shortcode in a post/page allows to display a number of random posts from several categories.</p>
<p>But when I use the plugin's widget I can choose only one category.</p>
<p>Is there a way to use the widget and allow to choose several categories?</p>
| [
{
"answer_id": 96942,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 0,
"selected": false,
"text": "<p>Unfortunately, the widget for this rather slip-shod plugin seems to have been built as an afterthought, and d... | 2013/04/22 | [
"https://wordpress.stackexchange.com/questions/96771",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31886/"
] | The Plugin List Category Post used as shortcode in a post/page allows to display a number of random posts from several categories.
But when I use the plugin's widget I can choose only one category.
Is there a way to use the widget and allow to choose several categories? | You can use these shortcodes:
This will show posts that are in Categories 17 AND 25 AND 2
```
[catlist id=17+25+2]
```
OR
This will include post that are from any of categories 17 OR 24 OR 32
```
[catlist id=17,24,32]
```
You can also us catlist name in the same way:
```
[catlist name=sega+nintendo]
[catl... |
96,783 | <p>I have a simple widget that needs its width and height set by the user, so that it is displayed properly on the blog.</p>
<p>The thing is: on the <strong>Administrator/Appearance/Widgets</strong> page, if the admin user puts something like "400px" on the width, it works perfectly. But what if the user puts "xxxx"?<... | [
{
"answer_id": 96786,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 0,
"selected": false,
"text": "<p>This is not WP-specific.</p>\n\n<p>Your widget most likely already has a form. That form has a name/ID (if no... | 2013/04/22 | [
"https://wordpress.stackexchange.com/questions/96783",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31659/"
] | I have a simple widget that needs its width and height set by the user, so that it is displayed properly on the blog.
The thing is: on the **Administrator/Appearance/Widgets** page, if the admin user puts something like "400px" on the width, it works perfectly. But what if the user puts "xxxx"?
Is there any way that ... | @tf is almost there, I think. You *can* use JS on your widget's admin form, as I've done it before (though not for validation).
Within your widget's constructor, add an action:
```
add_action( "admin_print_scripts-widgets.php", array( __CLASS__, 'register_my_validation_script' ) );
```
Then create the corresponding... |
96,785 | <p>I made a custom post type with the machine name special_media_post and wordpress is simply not seeing the single-special_media_post.php. I am at a complete lose. It keeps defaulting to the index.php</p>
<p>Here is my code for my custom post type and its taxonomies:</p>
<pre><code>//Post and Taxonomy stuff
//Regist... | [
{
"answer_id": 96792,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 7,
"selected": true,
"text": "<p>Visit the permalinks page (which will flush it) and check again. WordPress probably just needs to be nudged to... | 2013/04/22 | [
"https://wordpress.stackexchange.com/questions/96785",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31884/"
] | I made a custom post type with the machine name special\_media\_post and wordpress is simply not seeing the single-special\_media\_post.php. I am at a complete lose. It keeps defaulting to the index.php
Here is my code for my custom post type and its taxonomies:
```
//Post and Taxonomy stuff
//Register Custom Post Ty... | Visit the permalinks page (which will flush it) and check again. WordPress probably just needs to be nudged to recognize your addition to the hierarchy. |
96,825 | <p>I have looked around and I cannot seem to find an answer to this question. There are similar questions/answers but none I have seen managed to answer this question, so I am sorry in advanced if I have missed this question if it has already been asked.</p>
<p>My Question is, is it possible to pull posts from a Categ... | [
{
"answer_id": 96827,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 2,
"selected": false,
"text": "<p><strong>Non-Multisite setup:</strong></p>\n\n<p>You need to create another instance of the <a href=\"http://co... | 2013/04/23 | [
"https://wordpress.stackexchange.com/questions/96825",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31899/"
] | I have looked around and I cannot seem to find an answer to this question. There are similar questions/answers but none I have seen managed to answer this question, so I am sorry in advanced if I have missed this question if it has already been asked.
My Question is, is it possible to pull posts from a Category from a... | **Non-Multisite setup:**
You need to create another instance of the [WPDB Class](http://codex.wordpress.org/Class_Reference/wpdb).
```
$newWPDB = new wpdb('Username','password','database','localhost');
$rows = $newWPDB->get_results("you-query-here");
```
---
**On WordPress Multisite:**
>
> Does having Wordpress ... |
96,845 | <ul>
<li>I have a custom post type 'courses', with a course description as post_content, and number of attachments</li>
<li><p>I also have a custom post type 'course units', linked to the courses with a custom field 'course-id'</p></li>
<li><p>I created a template file for the course dashboard, showing a list of the un... | [
{
"answer_id": 96827,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 2,
"selected": false,
"text": "<p><strong>Non-Multisite setup:</strong></p>\n\n<p>You need to create another instance of the <a href=\"http://co... | 2013/04/23 | [
"https://wordpress.stackexchange.com/questions/96845",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9134/"
] | * I have a custom post type 'courses', with a course description as post\_content, and number of attachments
* I also have a custom post type 'course units', linked to the courses with a custom field 'course-id'
* I created a template file for the course dashboard, showing a list of the units, and a couple of links - t... | **Non-Multisite setup:**
You need to create another instance of the [WPDB Class](http://codex.wordpress.org/Class_Reference/wpdb).
```
$newWPDB = new wpdb('Username','password','database','localhost');
$rows = $newWPDB->get_results("you-query-here");
```
---
**On WordPress Multisite:**
>
> Does having Wordpress ... |
96,856 | <p>I am creating a plugin for post.php page where user can select (one or more) blogs and copy the post content,title,author,categories everything in selected blogs. The copied post would be the child of original post and now the original post would be parent post.</p>
<p>I want to know that is there any WP function w... | [
{
"answer_id": 98607,
"author": "dannepanne",
"author_id": 32524,
"author_profile": "https://wordpress.stackexchange.com/users/32524",
"pm_score": 4,
"selected": true,
"text": "<p>To copy a post from one blog to another you can do something like this:</p>\n\n<pre><code>function copy_post... | 2013/04/23 | [
"https://wordpress.stackexchange.com/questions/96856",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31835/"
] | I am creating a plugin for post.php page where user can select (one or more) blogs and copy the post content,title,author,categories everything in selected blogs. The copied post would be the child of original post and now the original post would be parent post.
I want to know that is there any WP function which can d... | To copy a post from one blog to another you can do something like this:
```
function copy_post_to_blog($post_id, $target_blog_id) {
$post = get_post($post_id, ARRAY_A); // get the original post
$post['ID'] = ''; // empty id field, to tell wordpress that this will be a new post
switch_to_blog($target_blog_i... |
96,869 | <p>Is it <strong>easily possible</strong> to edit links in the <code>WP_Admin_Bar</code> global <code>$wp_admin_bar</code> instance?</p>
| [
{
"answer_id": 96870,
"author": "Julian F. Weinert",
"author_id": 31527,
"author_profile": "https://wordpress.stackexchange.com/users/31527",
"pm_score": 4,
"selected": true,
"text": "<p><strong>Yes</strong> I recently ran into the situation where I wanted to change the profile link in t... | 2013/04/23 | [
"https://wordpress.stackexchange.com/questions/96869",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31527/"
] | Is it **easily possible** to edit links in the `WP_Admin_Bar` global `$wp_admin_bar` instance? | **Yes** I recently ran into the situation where I wanted to change the profile link in the user-info section of the admin bar. The problem is that you can only get all nodes, add and remove them. Not edit. And you also cannot modify the `$wp_admin_bar->nodes` property due it is private.
When easily removing and adding... |
96,875 | <p>I use a news ticker jQuery plugin to show the last posts.</p>
<p>The codes are in the <code>header.php</code> file and work fine on the home page, but not on single pages. The links are loaded but they don't move.</p>
<p>Here is the <a href="http://dayfun.ir/" rel="nofollow">home page</a> and here the <a href="htt... | [
{
"answer_id": 96916,
"author": "Fränk",
"author_id": 17670,
"author_profile": "https://wordpress.stackexchange.com/users/17670",
"pm_score": 1,
"selected": false,
"text": "<p>All the jQuery code in WordPress needs to run in No Conflict mode: <a href=\"http://codex.wordpress.org/Function... | 2013/04/23 | [
"https://wordpress.stackexchange.com/questions/96875",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23951/"
] | I use a news ticker jQuery plugin to show the last posts.
The codes are in the `header.php` file and work fine on the home page, but not on single pages. The links are loaded but they don't move.
Here is the [home page](http://dayfun.ir/) and here the [single page](http://dayfun.ir/%D8%A7%D8%B3-%D8%A7%D9%85-%D8%A7%D8... | Your Theme is enqueueing jQuery 1.7.2:
```
<script type="text/javascript" src="http://dayfun.ir/wp-content/themes/Sparks/lib/js/jquery.min.1.7.2.js"></script>
```
And WordPress is enqueueing jQuery 1.8.3:
```
<script type='text/javascript' src='http://dayfun.ir/wp-includes/js/jquery/jquery.js?ver=1.8.3'></script>
... |
96,910 | <p>I've created a custom post type and created a couple of custom user roles and want to be able to restrict the view of the post type based on the specific roles.</p>
<p>Is there a straightforward way to restrict this?</p>
| [
{
"answer_id": 96914,
"author": "gdaniel",
"author_id": 30984,
"author_profile": "https://wordpress.stackexchange.com/users/30984",
"pm_score": 0,
"selected": false,
"text": "<p>Well.. I see no code... so I don't know if you created the custom post type yourself, or used a plugin. I'm as... | 2013/04/23 | [
"https://wordpress.stackexchange.com/questions/96910",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26814/"
] | I've created a custom post type and created a couple of custom user roles and want to be able to restrict the view of the post type based on the specific roles.
Is there a straightforward way to restrict this? | Every role has capabilities.
Here is a simple contributor to our endeavor: (he just writes and edits)
```
add_role('contributor', 'Contributor', array(
'read' => true,
'edit_posts' => true,
'delete_posts' => false,
));
```
Now he has a new capability (he can edit other peoples posts)
```
function add_c... |
96,943 | <p>I need to create a loop that can logically be described as the following for a carousel:
Requirements:</p>
<ul>
<li>3 Loops</li>
<li>2 Posts Per Loop</li>
<li>No Duplicates</li>
<li>Order by Post Date</li>
</ul>
<p>Visual: </p>
<pre><code>< Start Loop #1 >
< Post #1 >
< Post #2 >
< End Loop #... | [
{
"answer_id": 96946,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>To precisely match your three <code><ul></code> pattern you can do this:</p>\n\n<pre><code>$my_query = ... | 2013/04/23 | [
"https://wordpress.stackexchange.com/questions/96943",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31940/"
] | I need to create a loop that can logically be described as the following for a carousel:
Requirements:
* 3 Loops
* 2 Posts Per Loop
* No Duplicates
* Order by Post Date
Visual:
```
< Start Loop #1 >
< Post #1 >
< Post #2 >
< End Loop #1 >
< Start Loop #2 >
< Post #3 >
< Post #4 >
< End Loop #2 >
< Start Loop #3 >... | i use this code in my portfolio <http://pocketapps.co/>

```
<?php $args = array(
//your argument code
);
query_posts($args);?>
<ul>
<?php ... |
97,026 | <p>I made a custom post type called 'portfolio' but I want to change it to 'projects'. What would be the exact steps I need to take in order to safely change the name and prevent the custom post type posts from disappearing in the dashboard?</p>
<p>Note: There are already posts in <code>portfolio</code> so I can't jus... | [
{
"answer_id": 97029,
"author": "Wesley Cheung",
"author_id": 31537,
"author_profile": "https://wordpress.stackexchange.com/users/31537",
"pm_score": 3,
"selected": true,
"text": "<p>If you have no posts in your portfolio yet.</p>\n\n<p>It would be really simple. Rename everything with \... | 2013/04/24 | [
"https://wordpress.stackexchange.com/questions/97026",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18320/"
] | I made a custom post type called 'portfolio' but I want to change it to 'projects'. What would be the exact steps I need to take in order to safely change the name and prevent the custom post type posts from disappearing in the dashboard?
Note: There are already posts in `portfolio` so I can't just switch out `portfol... | If you have no posts in your portfolio yet.
It would be really simple. Rename everything with "Portfolio" into "Projects".
You will lose nothing and change the name.
**Edit :**
Try use this plugin <http://wordpress.org/extend/plugins/ptypeconverter/> to export the current posts safely and import it into your new c... |
97,031 | <p>I've tried the plugins that are available in the Wordpress plugins section but they seem to fail miserably. Initially, I used Auto Post Expire By User Role which worked for a time, but for some reason now it doesn't. </p>
<p>What I want is to add a code in functions.php that will automatically set as drafts posts w... | [
{
"answer_id": 97033,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 1,
"selected": false,
"text": "<p>You just declared the query, but you didn't execute it!</p>\n\n<pre><code>function expire_posts() {\n global ... | 2013/04/24 | [
"https://wordpress.stackexchange.com/questions/97031",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31610/"
] | I've tried the plugins that are available in the Wordpress plugins section but they seem to fail miserably. Initially, I used Auto Post Expire By User Role which worked for a time, but for some reason now it doesn't.
What I want is to add a code in functions.php that will automatically set as drafts posts which are 3... | There are some issues with your query
```
$daystogo = "30";
$sql =
"UPDATE {$wpdb->posts}
SET post_status = 'draft'
WHERE (post_type = 'post' AND post_status = 'publish')
AND DATEDIFF(NOW(), post_date) > %d";
$wpdb->query( $wpdb->prepare( $sql, $daystogo ) );
```
You do not want to untrash trashed posts by declari... |
97,032 | <p>I started to use contact 7 plugin and I'm having a slider and some effects on other images when i activate the plugin they stop working this is the web page </p>
<pre><code>http://www.digitalways.com.sa/
</code></pre>
<p>I don't understand what it do! if it stops the javascript or css files but I searched in ... | [
{
"answer_id": 97033,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 1,
"selected": false,
"text": "<p>You just declared the query, but you didn't execute it!</p>\n\n<pre><code>function expire_posts() {\n global ... | 2013/04/24 | [
"https://wordpress.stackexchange.com/questions/97032",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27084/"
] | I started to use contact 7 plugin and I'm having a slider and some effects on other images when i activate the plugin they stop working this is the web page
```
http://www.digitalways.com.sa/
```
I don't understand what it do! if it stops the javascript or css files but I searched in the files if it has the same n... | There are some issues with your query
```
$daystogo = "30";
$sql =
"UPDATE {$wpdb->posts}
SET post_status = 'draft'
WHERE (post_type = 'post' AND post_status = 'publish')
AND DATEDIFF(NOW(), post_date) > %d";
$wpdb->query( $wpdb->prepare( $sql, $daystogo ) );
```
You do not want to untrash trashed posts by declari... |
97,043 | <p>I want to check if user is logged in and if have created a page. If so, option 1 is shown. This all works fine.</p>
<p>But <strong>how to display page title+link of page created by that user</strong> between {page title with link to page}</p>
<p>See the code below I tested it with no results. As used in the code b... | [
{
"answer_id": 97045,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>To list all pages with title and permalink from one user you need <code>$wpdb->get_results()</code>. The following c... | 2013/04/24 | [
"https://wordpress.stackexchange.com/questions/97043",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31765/"
] | I want to check if user is logged in and if have created a page. If so, option 1 is shown. This all works fine.
But **how to display page title+link of page created by that user** between {page title with link to page}
See the code below I tested it with no results. As used in the code below, nothing special is showi... | To list all pages with title and permalink from one user you need `$wpdb->get_results()`. The following code is based on this answer: [How to count current user's pages?](https://wordpress.stackexchange.com/a/96461/73)
First, we move the counter into a separate helper function; we might need it later again:
```
/**
... |
97,060 | <p>I have a hard time figuring out what's wrong with this code. </p>
<p><strong>What I'm trying to do:</strong> setup up a custom field in admin using the ACF plugin to lists in a meta-box on all pages a list of testimonials (custom-post-type). From the drop-down menu the client can select a testimonial that will show... | [
{
"answer_id": 97065,
"author": "s1lv3r",
"author_id": 27536,
"author_profile": "https://wordpress.stackexchange.com/users/27536",
"pm_score": 2,
"selected": false,
"text": "<p>The code doesn't seem syntactical wrong in the first place. What kind of field type are you using? Relationship... | 2013/04/24 | [
"https://wordpress.stackexchange.com/questions/97060",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13214/"
] | I have a hard time figuring out what's wrong with this code.
**What I'm trying to do:** setup up a custom field in admin using the ACF plugin to lists in a meta-box on all pages a list of testimonials (custom-post-type). From the drop-down menu the client can select a testimonial that will show up on that specific pa... | The code doesn't seem syntactical wrong in the first place. What kind of field type are you using? Relationship?
Also why are you overriding `$post_object` and where does it come from in the first place? That part of the code is missing.
To get the field which is attached to the current post (inside the current loop... |
97,061 | <p>I'm using Wordpress 3.5.1 with a modified twentytwelve theme.
My main site structure is based on the <a href="http://wordpress.org/support/plugin/smooth-slider" rel="nofollow">Smooth Slider</a> plugin (<a href="http://jquery.malsup.com/cycle/" rel="nofollow">jQuery Cycle</a>).</p>
<p>I have <strong>Pages</strong> ... | [
{
"answer_id": 97065,
"author": "s1lv3r",
"author_id": 27536,
"author_profile": "https://wordpress.stackexchange.com/users/27536",
"pm_score": 2,
"selected": false,
"text": "<p>The code doesn't seem syntactical wrong in the first place. What kind of field type are you using? Relationship... | 2013/04/24 | [
"https://wordpress.stackexchange.com/questions/97061",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31979/"
] | I'm using Wordpress 3.5.1 with a modified twentytwelve theme.
My main site structure is based on the [Smooth Slider](http://wordpress.org/support/plugin/smooth-slider) plugin ([jQuery Cycle](http://jquery.malsup.com/cycle/)).
I have **Pages** that contain only a shortcode (for example, `[smoothslider id='4']`) to dis... | The code doesn't seem syntactical wrong in the first place. What kind of field type are you using? Relationship?
Also why are you overriding `$post_object` and where does it come from in the first place? That part of the code is missing.
To get the field which is attached to the current post (inside the current loop... |
97,074 | <p>Before asking for help I would like to clarify that I don't have advanced skills on PHP. What I want to achieve is to display different messages for every period of time that I set <strong><em>(I need this to LOOP every day)</em></strong>. After reading this -> <a href="http://codex.wordpress.org/Function_Reference/... | [
{
"answer_id": 97075,
"author": "s1lv3r",
"author_id": 27536,
"author_profile": "https://wordpress.stackexchange.com/users/27536",
"pm_score": 4,
"selected": true,
"text": "<p>You would just need to format the time that is returned by current_time() with the php date() function like this... | 2013/04/24 | [
"https://wordpress.stackexchange.com/questions/97074",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31047/"
] | Before asking for help I would like to clarify that I don't have advanced skills on PHP. What I want to achieve is to display different messages for every period of time that I set ***(I need this to LOOP every day)***. After reading this -> <http://codex.wordpress.org/Function_Reference/current_time> I tried to check:... | You would just need to format the time that is returned by current\_time() with the php date() function like this:
```
$my_time = date('G', current_time('timestamp'));
```
The param 'G' tells the function you just want to have the hour part (0 to 23) of the date. Have a look here: <http://www.php.net/manual/en/funct... |
97,085 | <p>I am lazy loading some images with URLs which are added via custom fields.</p>
<p>The lazy load plugin I'm using requires a place-holder image in the <code>src</code> attribute and the actual image in data-original.</p>
<p><a href="http://www.appelsiini.net/projects/lazyload" rel="nofollow">http://www.appelsiini.n... | [
{
"answer_id": 97086,
"author": "Alex Dumitru",
"author_id": 5810,
"author_profile": "https://wordpress.stackexchange.com/users/5810",
"pm_score": 0,
"selected": false,
"text": "<p>This should work</p>\n\n<pre><code>$so97086_template_directory = get_bloginfo('template_directory');\n</cod... | 2013/04/24 | [
"https://wordpress.stackexchange.com/questions/97085",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31546/"
] | I am lazy loading some images with URLs which are added via custom fields.
The lazy load plugin I'm using requires a place-holder image in the `src` attribute and the actual image in data-original.
<http://www.appelsiini.net/projects/lazyload>
I need the image height and width as well, so I've been using `wp_get_att... | You cannot use `bloginfo()` while your are outputting using `echo` because bloginfo it self also out puts string using `echo`. Below will work for you, you also have extra double quote which i have removed....
```
<?php
$attch_id_1 = pn_get_attachment_id_from_url(get_post_meta($post->ID, 'img1', true));
... |
97,092 | <p>I registered a few custom sidebars, and the corresponding code in my version of TwentyTwelve theme now looks like this: </p>
<pre><code> register_sidebar( array(
'name' => __( 'Sidebar #1', 'twentytwelve' ),
'id' => 'sidebar-1',
'description' => __( 'Appears on posts and pages except the opt... | [
{
"answer_id": 97095,
"author": "Jamie",
"author_id": 14761,
"author_profile": "https://wordpress.stackexchange.com/users/14761",
"pm_score": 0,
"selected": false,
"text": "<p>look in the sidebar pages that are in the template. All the code you need is already there. You will see somethi... | 2013/04/24 | [
"https://wordpress.stackexchange.com/questions/97092",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31921/"
] | I registered a few custom sidebars, and the corresponding code in my version of TwentyTwelve theme now looks like this:
```
register_sidebar( array(
'name' => __( 'Sidebar #1', 'twentytwelve' ),
'id' => 'sidebar-1',
'description' => __( 'Appears on posts and pages except the optional Front Page templa... | Instead of calling `get_sidebar()` call `get_sidebar( 'somethingelse' );`. It will attempt to load `sidebar-somethingelse.php` and if that doesn’t exist it will load `sidebar.php`. You can then modify the `sidebar-somethingelse.php` to load a different sidebar etc
I strongly recommend you look up how the [template hie... |
97,115 | <p>I'm trying to display a BuddyPress xprofile field on a WordPress multsite blog. I thought this might do the trick but displayed_user doesn't seem to work outside of BP? Is there an easy way to do this? I know there's an <a href="http://wordpress.org/extend/plugins/bp-profile-widget-for-blogs/" rel="nofollow">old plu... | [
{
"answer_id": 97095,
"author": "Jamie",
"author_id": 14761,
"author_profile": "https://wordpress.stackexchange.com/users/14761",
"pm_score": 0,
"selected": false,
"text": "<p>look in the sidebar pages that are in the template. All the code you need is already there. You will see somethi... | 2013/04/24 | [
"https://wordpress.stackexchange.com/questions/97115",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/676/"
] | I'm trying to display a BuddyPress xprofile field on a WordPress multsite blog. I thought this might do the trick but displayed\_user doesn't seem to work outside of BP? Is there an easy way to do this? I know there's an [old plugin](http://wordpress.org/extend/plugins/bp-profile-widget-for-blogs/) that does it in a wi... | Instead of calling `get_sidebar()` call `get_sidebar( 'somethingelse' );`. It will attempt to load `sidebar-somethingelse.php` and if that doesn’t exist it will load `sidebar.php`. You can then modify the `sidebar-somethingelse.php` to load a different sidebar etc
I strongly recommend you look up how the [template hie... |
97,121 | <p>I am writing a plugin where I need to pre-load some data in the custom tables that I create upon Activation. My inserts have run fine thus far until I attempt to insert a record with a DATE datatype. Can someone please tell me what I have wrong here?</p>
<p>Database Table Definition:</p>
<pre><code>$sql = "CREA... | [
{
"answer_id": 97125,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p><a href=\"http://php.net/manual/en/function.date.php\" rel=\"nofollow\"><code>date</code></a> does not take a ... | 2013/04/24 | [
"https://wordpress.stackexchange.com/questions/97121",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30695/"
] | I am writing a plugin where I need to pre-load some data in the custom tables that I create upon Activation. My inserts have run fine thus far until I attempt to insert a record with a DATE datatype. Can someone please tell me what I have wrong here?
Database Table Definition:
```
$sql = "CREATE TABLE IF NOT EXISTS ... | [`date`](http://php.net/manual/en/function.date.php) does not take a human readable string. It takes a [Unix timestamp](http://en.wikipedia.org/wiki/Unix_time). You need to convert that human date to a timestamp with [`strtotime`](http://www.php.net/manual/en/function.strtotime.php).
```
'begin_date' => date('Y-m-d'... |
97,127 | <p>I've got a few automated scripts that run to notify users of certain updates to the application, etc... and for one in particular, I need to be able to display the users <code>user_login</code> and their password.</p>
<p>How do I show the user their password if it's encrypted?</p>
| [
{
"answer_id": 97133,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": false,
"text": "<p>User passwords are stored in the database as what is called a <a href=\"https://en.wikipedia.org/wiki/Cryptog... | 2013/04/24 | [
"https://wordpress.stackexchange.com/questions/97127",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9295/"
] | I've got a few automated scripts that run to notify users of certain updates to the application, etc... and for one in particular, I need to be able to display the users `user_login` and their password.
How do I show the user their password if it's encrypted? | *Theoretically*, this *could* be achieved by saving a user's password elsewhere, when he or she updates it.
**Note that this sort of thing is *hardly ever* recommendable.**
In almost all cases, there is a better architectural approach that renders having to be able to show plain-text passwords unnecessary.
That be... |
97,130 | <p>On my homepage, I have 3 columns showing varying amounts of information from posts in specific categories (first 2 of them child categories, the third column displays posts from various child categories, but one parent category).</p>
<p>I want to determine which posts to display (by category as described) in each, ... | [
{
"answer_id": 97133,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": false,
"text": "<p>User passwords are stored in the database as what is called a <a href=\"https://en.wikipedia.org/wiki/Cryptog... | 2013/04/24 | [
"https://wordpress.stackexchange.com/questions/97130",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31583/"
] | On my homepage, I have 3 columns showing varying amounts of information from posts in specific categories (first 2 of them child categories, the third column displays posts from various child categories, but one parent category).
I want to determine which posts to display (by category as described) in each, by making ... | *Theoretically*, this *could* be achieved by saving a user's password elsewhere, when he or she updates it.
**Note that this sort of thing is *hardly ever* recommendable.**
In almost all cases, there is a better architectural approach that renders having to be able to show plain-text passwords unnecessary.
That be... |
97,136 | <h2>Short Version:</h2>
<p>Custom menu with a custom post type that supports a custom taxonomy. The custom post type works, the menu for it works and stays open. The custom taxonomy works, but the sidebar menu doesn't stay open. I need to make the category keep the submenu open, as it does natively (when not placed in... | [
{
"answer_id": 98122,
"author": "Radley Sustaire",
"author_id": 19105,
"author_profile": "https://wordpress.stackexchange.com/users/19105",
"pm_score": 2,
"selected": true,
"text": "<p><strong>I could not find a built-in way to accomplish this solution, but I have created a workaround</s... | 2013/04/24 | [
"https://wordpress.stackexchange.com/questions/97136",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19105/"
] | Short Version:
--------------
Custom menu with a custom post type that supports a custom taxonomy. The custom post type works, the menu for it works and stays open. The custom taxonomy works, but the sidebar menu doesn't stay open. I need to make the category keep the submenu open, as it does natively (when not placed... | **I could not find a built-in way to accomplish this solution, but I have created a workaround**
I realized, if the menu won't stay open, why not open it myself?
I created the following two functions, which are easy enough to understand. They need to be called in a javascript file which is loaded via admin script (se... |
97,142 | <p>I am using Dave's Wordpress Live Search on my site www.frome.fm but it only works when logged in as admin. When logged out or browsing as guest the spinning icon shows for a second or two but then no results are displayed. I've tried disabling plugins to no avail. The wp-admin folder is not protected with .htaccess ... | [
{
"answer_id": 97146,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>That plugin uses the <a href=\"http://codex.wordpress.org/AJAX_in_Plugins\" rel=\"nofollow\">AJAX API</a> as ... | 2013/04/24 | [
"https://wordpress.stackexchange.com/questions/97142",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27293/"
] | I am using Dave's Wordpress Live Search on my site www.frome.fm but it only works when logged in as admin. When logged out or browsing as guest the spinning icon shows for a second or two but then no results are displayed. I've tried disabling plugins to no avail. The wp-admin folder is not protected with .htaccess ser... | That plugin uses the [AJAX API](http://codex.wordpress.org/AJAX_in_Plugins) as it should...
```
http://frome.fm/wp-admin/admin-ajax.php?s=ho&action=dwls_search
```
... but when not logged in that request fails (from HttpFox)...
```
07:23:58.923 0.155 470 0 GET (Aborted) NS_BINDING_ABORTED http://frome.fm/... |
97,155 | <p>I've a page named "share" with a complex loop that's working perfectly. This page is located at <code>domain.com/share</code>. Now I need to use this page as the home page, so I went to "Settings -> Reading" and chose that page as static page. </p>
<p>The problem now is that the pagination no longer works. On the a... | [
{
"answer_id": 99035,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 2,
"selected": false,
"text": "<p>I didn't test this, but the <a href=\"http://codex.wordpress.org/Function_Reference/WP_Query#Paginati... | 2013/04/25 | [
"https://wordpress.stackexchange.com/questions/97155",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8536/"
] | I've a page named "share" with a complex loop that's working perfectly. This page is located at `domain.com/share`. Now I need to use this page as the home page, so I went to "Settings -> Reading" and chose that page as static page.
The problem now is that the pagination no longer works. On the actual page it shows l... | I had faced the same problem. And finally, I solved the problem.
Getting the current Pagination Number
```
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?>
```
For getting the current pagination number on a static front page (Page template) you have to use the 'page' query variable.
```... |
97,170 | <p>I have a template which outputs the blog posts (Blog Page), I open one of the posts which use single.php template, Now how can I get the ID of it's parent which is the (Blog Page)?</p>
<p>I should say that I want to use this ID to get the meta box value of the blog page in single.php.</p>
<p>The same goes for a cu... | [
{
"answer_id": 97174,
"author": "saifur",
"author_id": 31689,
"author_profile": "https://wordpress.stackexchange.com/users/31689",
"pm_score": 1,
"selected": false,
"text": "<p>Use <code>$post->post_parent</code> to get the parent ID of the post. Here <code>$post</code> is an object w... | 2013/04/25 | [
"https://wordpress.stackexchange.com/questions/97170",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32014/"
] | I have a template which outputs the blog posts (Blog Page), I open one of the posts which use single.php template, Now how can I get the ID of it's parent which is the (Blog Page)?
I should say that I want to use this ID to get the meta box value of the blog page in single.php.
The same goes for a custom post type, l... | WordPress 5.7 introduces a new helper function to more easily fetch the parent post's ID:
`get_post_parent()`
This can also be used in conjunction with `has_post_parent()`, so you could have something like looks like:
```
<?php if ( has_post_parent() ) : ?>
<a href="<?php the_permalink( get_post_parent() ); ?>">
... |
97,176 | <p>I am having trouble with Woocommerce product details and order details relationship. I'm not able to find the product ID of a related order ID on the <em>View Orders</em> page of the Woocommerce theme. I simply want to get the product content and permalink etc on <em>View Orders</em> page.</p>
<p>I tried searching ... | [
{
"answer_id": 97228,
"author": "Ewout",
"author_id": 26106,
"author_profile": "https://wordpress.stackexchange.com/users/26106",
"pm_score": 8,
"selected": true,
"text": "<p></p>\n\n<h2>WooCommerce 3.0+</h2>\n\n<p>you can get the order items of an order by</p>\n\n<pre class=\"lang-php p... | 2013/04/25 | [
"https://wordpress.stackexchange.com/questions/97176",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31943/"
] | I am having trouble with Woocommerce product details and order details relationship. I'm not able to find the product ID of a related order ID on the *View Orders* page of the Woocommerce theme. I simply want to get the product content and permalink etc on *View Orders* page.
I tried searching in `wp_postmeta` but had... | WooCommerce 3.0+
----------------
you can get the order items of an order by
```php
$order = wc_get_order( $order_id );
$items = $order->get_items();
```
then if you loop through the items, you can get all the relevant data:
```php
foreach ( $items as $item ) {
$product_name = $item->get_name();
$product_i... |
97,177 | <p>I installed a WordPress for a domain name. When I use this domain name will point to <code>index.php</code> in my template. I want show a under construction page for this domain name, but the other hand I still want work on <code>index.php</code> in my template.</p>
| [
{
"answer_id": 97184,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 5,
"selected": true,
"text": "<p>You can filter <code>template_include</code> and include a special file for users who are not logged in:</p>\n\n<pre><c... | 2013/04/25 | [
"https://wordpress.stackexchange.com/questions/97177",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31425/"
] | I installed a WordPress for a domain name. When I use this domain name will point to `index.php` in my template. I want show a under construction page for this domain name, but the other hand I still want work on `index.php` in my template. | You can filter `template_include` and include a special file for users who are not logged in:
```
/* Plugin Name: T5 Under Construction */
add_filter( 'template_include', 't5_uc_template' );
function t5_uc_template( $template )
{
$uc_template = dirname( __FILE__ ) . '/under-construction.php';
if ( ! is_user... |
97,181 | <p>i wanted to make an offline copy of my live website on my pc so i installed xamp and installed on it wordpress and exported the database and took a copy of files on fttp and after i have done eveything and i wanted to make open my live website to edit something
it gives me a blank page when i open</p>
<pre><code> ... | [
{
"answer_id": 97183,
"author": "dipali",
"author_id": 20711,
"author_profile": "https://wordpress.stackexchange.com/users/20711",
"pm_score": -1,
"selected": false,
"text": "<p>Add this code to theme's functions.php file</p>\n\n<pre><code>add_action('init', 'clear_buffer_output');\nfunc... | 2013/04/25 | [
"https://wordpress.stackexchange.com/questions/97181",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27084/"
] | i wanted to make an offline copy of my live website on my pc so i installed xamp and installed on it wordpress and exported the database and took a copy of files on fttp and after i have done eveything and i wanted to make open my live website to edit something
it gives me a blank page when i open
```
"www.sitename.... | i found the problem there was space in function.php |
97,204 | <p>I have created an options page in my WordPress theme that allows the user to input a url/upload an image to an input field. The field has the name headerimage_options[image] and when it is populated it can be saved and outputted in the theme with the following code: <code><?php echo esc_url( $headerimage_options[... | [
{
"answer_id": 97205,
"author": "s1lv3r",
"author_id": 27536,
"author_profile": "https://wordpress.stackexchange.com/users/27536",
"pm_score": 1,
"selected": false,
"text": "<p>You could do it this way (assumes that you know that all 3 images are there every time):</p>\n\n<pre><code><... | 2013/04/25 | [
"https://wordpress.stackexchange.com/questions/97204",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29158/"
] | I have created an options page in my WordPress theme that allows the user to input a url/upload an image to an input field. The field has the name headerimage\_options[image] and when it is populated it can be saved and outputted in the theme with the following code: `<?php echo esc_url( $headerimage_options['image'] )... | Instead of echoing out these images, just store them as strings inside an array and choose one of the array items at random.
```
<?php $headerimage_options = get_option('headerimage_options' );
$images = array();
$images[] = '<img title="'.get_bloginfo('name').'" src="'.esc_url( $headerimage_options['image'] ).'"/>';... |
97,221 | <p>I've spotted that some of my users have duplicate metadata key values (my only fault because i inserted data directly to the wp_usermeta table!). This query for example</p>
<pre><code>SELECT * FROM `wp_usermeta` WHERE `user_id` =2327x LIMIT 0 , 30
</code></pre>
<p>returns two rows</p>
<pre><code>meta_id - user_... | [
{
"answer_id": 97231,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 2,
"selected": false,
"text": "<p>This should do what you want:</p>\n\n<pre><code>global $wpdb;\n$wpdb->query(\"\n DELETE FROM $wpdb->... | 2013/04/25 | [
"https://wordpress.stackexchange.com/questions/97221",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16267/"
] | I've spotted that some of my users have duplicate metadata key values (my only fault because i inserted data directly to the wp\_usermeta table!). This query for example
```
SELECT * FROM `wp_usermeta` WHERE `user_id` =2327x LIMIT 0 , 30
```
returns two rows
```
meta_id - user_id - meta_key - meta_value
178208 - ... | This should do what you want:
```
global $wpdb;
$wpdb->query("
DELETE FROM $wpdb->usermeta
WHERE meta_id NOT IN (
SELECT MIN(meta_id)
FROM $wpdb->usermeta
GROUP BY user_id, meta_key, meta_value
)"
);
```
Maybe you should first **back up your table**, though. |
97,226 | <p>I would like a sub-menu in which the user visits a page, post, or category (in this example, "info") and is <em>then</em> displayed a list of children categories/pages. Not a dropdown menu, but a menu that appears only when the user is already in the parent category.</p>
<p>I need a code which continues to display... | [
{
"answer_id": 97836,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 1,
"selected": false,
"text": "<p>I'm using the following code on one of my websites:</p>\n\n<pre><code> if ( // Maybe you want different co... | 2013/04/25 | [
"https://wordpress.stackexchange.com/questions/97226",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5205/"
] | I would like a sub-menu in which the user visits a page, post, or category (in this example, "info") and is *then* displayed a list of children categories/pages. Not a dropdown menu, but a menu that appears only when the user is already in the parent category.
I need a code which continues to display the *parent's* ch... | Funny, I just ran into this same conundrum a few months back...
Background
----------
I found it quite bizarre that Wordpress applies all manner of CSS classes to menu-items in order to distinguish the current item and its ancestors, but then completely ignores the sub-menus and their relationship with the current it... |
97,227 | <p>What function can be used to update a post's post date and time to the current date & time?</p>
| [
{
"answer_id": 97229,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 6,
"selected": true,
"text": "<p>Call <code>wp_update_post()</code> with a special value for <code>'post_date'</code> and <code>'post_date_gmt'</code>:<... | 2013/04/25 | [
"https://wordpress.stackexchange.com/questions/97227",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22588/"
] | What function can be used to update a post's post date and time to the current date & time? | Call `wp_update_post()` with a special value for `'post_date'` and `'post_date_gmt'`:
```
$time = current_time('mysql');
wp_update_post(
array (
'ID' => 123, // ID of the post to update
'post_date' => $time,
'post_date_gmt' => get_gmt_from_date( $time )
)
);
``` |
97,241 | <p>I have some script that is loading in the admin. I only need it to load on the new post and edit posts screens.</p>
<p>What is the best way to do this?</p>
| [
{
"answer_id": 97242,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": false,
"text": "<p>The global variable <code>$hook_suffix</code> is:</p>\n\n<ul>\n<li><code>post-new.php</code> for the new post and</li>... | 2013/04/25 | [
"https://wordpress.stackexchange.com/questions/97241",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8278/"
] | I have some script that is loading in the admin. I only need it to load on the new post and edit posts screens.
What is the best way to do this? | Check the page and enqueue your script accordingly:
```
global $pagenow;
if (! empty($pagenow) && ('post-new.php' === $pagenow || 'post.php' === $pagenow ))
add_action('admin_enqueue_scripts', 'enqueue_my_scripts');
function enqueue_my_scripts() {
wp_enqueue_script(...);
} // function enqueue_my_scripts
``` |
97,248 | <p>Using a child of Twenty Twelve, I've been adding color to all the major containers (#main, #content, #secondary, etc.) using</p>
<pre><code>#arbitrary-id {
background-color: #dedede;
}
</code></pre>
<p>This works for everything but body. I should be more clear: it changed the body background color until I messed ... | [
{
"answer_id": 97250,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>It sounds like you just need to <a href=\"http://codex.wordpress.org/Function_Reference/remove_theme_support\"... | 2013/04/25 | [
"https://wordpress.stackexchange.com/questions/97248",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32044/"
] | Using a child of Twenty Twelve, I've been adding color to all the major containers (#main, #content, #secondary, etc.) using
```
#arbitrary-id {
background-color: #dedede;
}
```
This works for everything but body. I should be more clear: it changed the body background color until I messed with the background color ... | It sounds like you just need to [remove support for the custom background color](http://codex.wordpress.org/Function_Reference/remove_theme_support).
```
remove_theme_support( 'custom-background' );
```
You will probably need to hook it to get it to run after the parent `functions.php`
```
function disable_bg_wpse_... |
97,280 | <p>I'm writing a slideshow shortcode and need to grab the shortcode attributes in an external function so I can add the javascript to the footer.</p>
<p>For example:</p>
<pre><code>add_shortcode('test','test_function');
function test_function($atts) {
extract(shortcode_atts(array(
'arrows' => true,
... | [
{
"answer_id": 97285,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>You can pass an array to your script with <code>wp_localize_script($handle, $object_name, $l10n)</code>.</p>\n\n<pre><... | 2013/04/25 | [
"https://wordpress.stackexchange.com/questions/97280",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10946/"
] | I'm writing a slideshow shortcode and need to grab the shortcode attributes in an external function so I can add the javascript to the footer.
For example:
```
add_shortcode('test','test_function');
function test_function($atts) {
extract(shortcode_atts(array(
'arrows' => true,
), $atts));
retur... | You can pass an array to your script with `wp_localize_script($handle, $object_name, $l10n)`.
```
function test_function( $atts )
{
$data = shortcode_atts(
array (
'arrows' => TRUE
),
$atts
);
wp_enqueue_script( 'your_script_name' );
wp_localize_script(
'your... |
97,291 | <p>How can I temporarily remove content from all pages, but leave up the URL?</p>
<p>I need to turn off all site content, but leave the URL's up so google can still find them.</p>
<p>...at least I think I want to do this. Basically, I am in negotiation with another site about who "owns" the content, but both of us ha... | [
{
"answer_id": 97299,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>Depends on what you mean by \"content\". If you just want to remove the post body then...</p>\n\n<pre><code>f... | 2013/04/26 | [
"https://wordpress.stackexchange.com/questions/97291",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13196/"
] | How can I temporarily remove content from all pages, but leave up the URL?
I need to turn off all site content, but leave the URL's up so google can still find them.
...at least I think I want to do this. Basically, I am in negotiation with another site about who "owns" the content, but both of us have agreed to remo... | Depends on what you mean by "content". If you just want to remove the post body then...
```
function remove_body_wpse_97291($content) {
return "Content temporarily removed";
}
add_filter('the_content','remove_body_wpse_97291',100);
```
If you want more aggressive content removal...
```
function remove_all_content... |
97,303 | <p>Hi I'm using the smarty templating engine in wordpress to generate HTML like the one below:</p>
<pre><code><li>
<div class="checkbox_container" data-asin="B0009Y7APU"><input type="checkbox" class="ecom_compare_products" data-asin="B0009Y7APU" value="B0009Y7APU"/>
</div>
<div class="sma... | [
{
"answer_id": 97299,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>Depends on what you mean by \"content\". If you just want to remove the post body then...</p>\n\n<pre><code>f... | 2013/04/26 | [
"https://wordpress.stackexchange.com/questions/97303",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26801/"
] | Hi I'm using the smarty templating engine in wordpress to generate HTML like the one below:
```
<li>
<div class="checkbox_container" data-asin="B0009Y7APU"><input type="checkbox" class="ecom_compare_products" data-asin="B0009Y7APU" value="B0009Y7APU"/>
</div>
<div class="small_img_container"><img class="related_pro... | Depends on what you mean by "content". If you just want to remove the post body then...
```
function remove_body_wpse_97291($content) {
return "Content temporarily removed";
}
add_filter('the_content','remove_body_wpse_97291',100);
```
If you want more aggressive content removal...
```
function remove_all_content... |
97,306 | <p>I would like to be able to use the jQuery Fancybox's Ajax feature to request datas from the front-end.
Here is a part of the code i'm using on the plugin part :</p>
<pre><code>wp_localize_script( 'wpPluginjs', 'ajax_vars', array(
'url' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_crea... | [
{
"answer_id": 97353,
"author": "Mooncake",
"author_id": 25458,
"author_profile": "https://wordpress.stackexchange.com/users/25458",
"pm_score": 0,
"selected": false,
"text": "<p>I don't know if it's the best practice but if i use the following href it works:</p>\n\n<pre><code>href: '../... | 2013/04/26 | [
"https://wordpress.stackexchange.com/questions/97306",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25458/"
] | I would like to be able to use the jQuery Fancybox's Ajax feature to request datas from the front-end.
Here is a part of the code i'm using on the plugin part :
```
wp_localize_script( 'wpPluginjs', 'ajax_vars', array(
'url' => admin_url( 'admin-ajax.php' ),
'nonce' => wp_create_nonce( 'ajax-nonc... | `&nonce` should be `?nonce`. The `?` begins a query string, the `&` separates arguments within a query string. |
97,314 | <p>I'm working on a site where there are multiple content types in addition to the built-in ones (see list below). I'd like to establish the ability to mark related content in any direction, from any content type to any other.</p>
<p>The content types are:</p>
<ul>
<li><code>post</code></li>
<li><code>page</code></li... | [
{
"answer_id": 97341,
"author": "s1lv3r",
"author_id": 27536,
"author_profile": "https://wordpress.stackexchange.com/users/27536",
"pm_score": 1,
"selected": false,
"text": "<p>The actual question for me is: For what and how do you use the relationship information? Where is it displayed ... | 2013/04/26 | [
"https://wordpress.stackexchange.com/questions/97314",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/99/"
] | I'm working on a site where there are multiple content types in addition to the built-in ones (see list below). I'd like to establish the ability to mark related content in any direction, from any content type to any other.
The content types are:
* `post`
* `page`
* `topic` (from bbpress)
* `case` (custom types from ... | Why not do...
```
$my_post_types = array(
'post',
'page',
'topic',
'case',
'note',
'question',
'therapy_guideline'
);
p2p_register_connection_type( array(
'name' => 'my_post_relationships',
'from' => $my_post_types,
'to' => $my_post_types,
'sortable' => 'any',
're... |
97,315 | <p>I've been searching on the net for a solution to my problem all day, but I can't make sense of anything I see, since I know absolutely NOTHING about coding.</p>
<h3>What I'd like to do:</h3>
<ol>
<li>I'd like to set a cookie when a person visits one particular page on my website, let's call it Page 1.</li>
<li>The... | [
{
"answer_id": 97344,
"author": "s1lv3r",
"author_id": 27536,
"author_profile": "https://wordpress.stackexchange.com/users/27536",
"pm_score": 1,
"selected": false,
"text": "<p>So the only part that is missing from your code is checking what page you are currently on. The is_page() funct... | 2013/04/26 | [
"https://wordpress.stackexchange.com/questions/97315",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32064/"
] | I've been searching on the net for a solution to my problem all day, but I can't make sense of anything I see, since I know absolutely NOTHING about coding.
### What I'd like to do:
1. I'd like to set a cookie when a person visits one particular page on my website, let's call it Page 1.
2. Then, when that visitor goe... | So the only part that is missing from your code is checking what page you are currently on. The is\_page() function is a good way to get this context.
You could try it this way (I did not test it, only writeup out of my head to show the concept):
```
function set_newuser_cookie() {
if (!isset($_COOKIE['subscriber... |
97,349 | <p>I added this code to my functions.php file </p>
<pre><code>add_filter('locale', 'wpse27056_setLocale');
function wpse27056_setLocale($locale) {
if ( is_admin() ) {
return 'en_US';
}
return $locale;
}
</code></pre>
<p>so the frontend is available in <code>ro_RO</code> and <code>wp-admin</code> ... | [
{
"answer_id": 97344,
"author": "s1lv3r",
"author_id": 27536,
"author_profile": "https://wordpress.stackexchange.com/users/27536",
"pm_score": 1,
"selected": false,
"text": "<p>So the only part that is missing from your code is checking what page you are currently on. The is_page() funct... | 2013/04/26 | [
"https://wordpress.stackexchange.com/questions/97349",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2215/"
] | I added this code to my functions.php file
```
add_filter('locale', 'wpse27056_setLocale');
function wpse27056_setLocale($locale) {
if ( is_admin() ) {
return 'en_US';
}
return $locale;
}
```
so the frontend is available in `ro_RO` and `wp-admin` is available in `en_US`
Well... that almost wor... | So the only part that is missing from your code is checking what page you are currently on. The is\_page() function is a good way to get this context.
You could try it this way (I did not test it, only writeup out of my head to show the concept):
```
function set_newuser_cookie() {
if (!isset($_COOKIE['subscriber... |
97,356 | <p>In apply_filters()</p>
<pre><code>apply_filters( $tag, $value, $var ... );
</code></pre>
<p>I'm having trouble wrapping my head around the <code>$value</code> and <code>$var</code>. I read the codex and it sounds like the <code>$value</code> can be modified, <code>$var</code> not, but I haven't found any examples ... | [
{
"answer_id": 97359,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 6,
"selected": true,
"text": "<p>Try to see the function with better names:</p>\n\n<pre><code>apply_filters(\n $filter_name, // used for add_filt... | 2013/04/26 | [
"https://wordpress.stackexchange.com/questions/97356",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13405/"
] | In apply\_filters()
```
apply_filters( $tag, $value, $var ... );
```
I'm having trouble wrapping my head around the `$value` and `$var`. I read the codex and it sounds like the `$value` can be modified, `$var` not, but I haven't found any examples of this in the wild. It seems to be used as a way to pass a variable.... | Try to see the function with better names:
```
apply_filters(
$filter_name, // used for add_filter( $filter_name, 'callback' );
$value_to_change, // the only variable whose value you can change
$context_1, // context
$context_2 // more context
);
```
So when that function is called a... |
97,361 | <p>I want to modify the date display of the post entries from current format: </p>
<p>April 26, 2013</p>
<p>to this:</p>
<p>04/26/2013</p>
<p>Where in the code can I make this change? </p>
<p>Thank you in advance!</p>
| [
{
"answer_id": 97363,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<pre><code>the_time( 'm/d/Y' );\n</code></pre>\n\n<p>or</p>\n\n<pre><code>the_date( 'm/d/Y' );\n</code></pre>\n\n<p>Note, ... | 2013/04/26 | [
"https://wordpress.stackexchange.com/questions/97361",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31921/"
] | I want to modify the date display of the post entries from current format:
April 26, 2013
to this:
04/26/2013
Where in the code can I make this change?
Thank you in advance! | ```
the_time( 'm/d/Y' );
```
or
```
the_date( 'm/d/Y' );
```
Note, `the_date()` will not print the same value twice. If a second post would get the same output you get nothing.
If your theme doesn’t set a fixed value, like Twenty Twelve …
```
get_the_date()
```
… then the format is taken from your settings in ... |
97,374 | <p>I want to display a unique message on the post (single.php) page <strong>outside the loop</strong> on author box. I want the message to be different depending on the author's capabilities. So for instance, if the author can <code>manage_options</code> then echo <code>this is admin</code>, else if the author can <cod... | [
{
"answer_id": 97375,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": true,
"text": "<p>Use <code>global $authordata</code>:</p>\n\n<p>Testing for roles:</p>\n\n<pre><code>global $authordata; \n\nif ( in_... | 2013/04/26 | [
"https://wordpress.stackexchange.com/questions/97374",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32079/"
] | I want to display a unique message on the post (single.php) page **outside the loop** on author box. I want the message to be different depending on the author's capabilities. So for instance, if the author can `manage_options` then echo `this is admin`, else if the author can `edit_others_posts` then echo `this is edi... | Use `global $authordata`:
Testing for roles:
```
global $authordata;
if ( in_array( 'administrator', $authordata->roles ) )
{
echo 'Hello Admin!';
}
elseif ( in_array( 'editor', $authordata->roles ) )
{
// echo something else
}
```
Or testing for capabilities:
```
if ( ! empty ( $authordata->allcaps['m... |
97,384 | <p>I'm working on an advanced search (which uses custom sql queries), and the query string is formed using variables. For example, if the person checks some options, only those conditions get added to the WHERE clause.</p>
<p>I can't use <code>$wpdb->prepare</code>, since I want to be able to add variables to my qu... | [
{
"answer_id": 97375,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": true,
"text": "<p>Use <code>global $authordata</code>:</p>\n\n<p>Testing for roles:</p>\n\n<pre><code>global $authordata; \n\nif ( in_... | 2013/04/26 | [
"https://wordpress.stackexchange.com/questions/97384",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21258/"
] | I'm working on an advanced search (which uses custom sql queries), and the query string is formed using variables. For example, if the person checks some options, only those conditions get added to the WHERE clause.
I can't use `$wpdb->prepare`, since I want to be able to add variables to my query string that look som... | Use `global $authordata`:
Testing for roles:
```
global $authordata;
if ( in_array( 'administrator', $authordata->roles ) )
{
echo 'Hello Admin!';
}
elseif ( in_array( 'editor', $authordata->roles ) )
{
// echo something else
}
```
Or testing for capabilities:
```
if ( ! empty ( $authordata->allcaps['m... |
97,412 | <p>My wordpress settings email is contact@domain.com. When I search my entire database for the email of wordpress@domain.com, it does not exist.</p>
<p>Yet my registration emails are still sent from wordpress@domain.com for some reason.</p>
<p>The only thing I can think of is that when I look in my wp_users table, I ... | [
{
"answer_id": 97415,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>WordPress does not look at your admin email, it uses the made-up address, each time <code>wp_mail()</code> was called ... | 2013/04/26 | [
"https://wordpress.stackexchange.com/questions/97412",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5335/"
] | My wordpress settings email is contact@domain.com. When I search my entire database for the email of wordpress@domain.com, it does not exist.
Yet my registration emails are still sent from wordpress@domain.com for some reason.
The only thing I can think of is that when I look in my wp\_users table, I have no user wit... | Ok, then you can try this
You can set the header, just not with a parameter. WordPress uses "hooks" and the hooks you need are 'wp\_mail\_from' and 'wp\_mail\_from\_name' hooks.
Here are the hooks you might add to your theme's functions.php file to modify the "From:" header when using wp\_mail() to the email address G... |
97,433 | <p>On <code>wp-admin/post.php?post=447&action=edit</code> for example I have a link and an input. </p>
<p>The link appears as follows:</p>
<pre><code><a href="#" class="button insert-media add_media" data-editor="tj_image_url" >gallery</a>
</code></pre>
<p>When I click the link the media library open... | [
{
"answer_id": 97453,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>There is a <a href=\"http://codex.wordpress.org/Function_Reference/body_class\" rel=\"nofollow\"><code>body_c... | 2013/04/26 | [
"https://wordpress.stackexchange.com/questions/97433",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31499/"
] | On `wp-admin/post.php?post=447&action=edit` for example I have a link and an input.
The link appears as follows:
```
<a href="#" class="button insert-media add_media" data-editor="tj_image_url" >gallery</a>
```
When I click the link the media library opens, and i'd like the URL of the inserted image to populate an... | There is a [`body_class`](http://codex.wordpress.org/Function_Reference/body_class) set for the home page called `full-width-content`. That suggests to me that:
1. The homepage intentionally does not have a sidebar. You will need to edit the template appropriate template file to change that. That should be `index.php`... |
97,466 | <p>I'm tryin to use this accordion script in my WP: <a href="http://www.armagost.com/zaccordion/" rel="nofollow">http://www.armagost.com/zaccordion/</a></p>
<p>Problem is that on a standalone html/php file it works well but once pasted in my header.php file there's no way to make it work.
I tried also including it wit... | [
{
"answer_id": 97468,
"author": "Sisir",
"author_id": 3094,
"author_profile": "https://wordpress.stackexchange.com/users/3094",
"pm_score": 2,
"selected": false,
"text": "<p>Looking at your code again. Here is what i think</p>\n\n<p><strong>Change This:</strong></p>\n\n<pre><code><scr... | 2013/04/27 | [
"https://wordpress.stackexchange.com/questions/97466",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31212/"
] | I'm tryin to use this accordion script in my WP: <http://www.armagost.com/zaccordion/>
Problem is that on a standalone html/php file it works well but once pasted in my header.php file there's no way to make it work.
I tried also including it with `<?php require_once("example.php") ?>` but no success.
You can see my ... | You seem to still be having issues, what i'd do to avoid having all that code clutter the header is setup a bunch of enqueues, but handle the html5 js inside the print scripts action along with the appropriate conditional comments(there's no proper way to do this with the enqueue system).
First the HTML5 js, outright ... |
97,469 | <p>I am struggling to get the <a href="http://codex.wordpress.org/WPMU_Functions/get_last_updated" rel="nofollow">get_last_updated()</a> function to work on main blog.</p>
<p>I have a network site with about about 9 blogs on it.</p>
<p>I am simply trying to loop all my blogs and find do some querying from each blog. ... | [
{
"answer_id": 97468,
"author": "Sisir",
"author_id": 3094,
"author_profile": "https://wordpress.stackexchange.com/users/3094",
"pm_score": 2,
"selected": false,
"text": "<p>Looking at your code again. Here is what i think</p>\n\n<p><strong>Change This:</strong></p>\n\n<pre><code><scr... | 2013/04/27 | [
"https://wordpress.stackexchange.com/questions/97469",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11327/"
] | I am struggling to get the [get\_last\_updated()](http://codex.wordpress.org/WPMU_Functions/get_last_updated) function to work on main blog.
I have a network site with about about 9 blogs on it.
I am simply trying to loop all my blogs and find do some querying from each blog. But I can't seem to get this simple `get_... | You seem to still be having issues, what i'd do to avoid having all that code clutter the header is setup a bunch of enqueues, but handle the html5 js inside the print scripts action along with the appropriate conditional comments(there's no proper way to do this with the enqueue system).
First the HTML5 js, outright ... |
97,478 | <p>I have 4 footer widgets in the theme I'm working on. It works great. The only thing that I can't get to work is the responsiveness of the widgets. The 4 footer widgets keep on showing up next to each other on smaller screens, and I need them to be on top of each other for smaller screens. Can any one help me around ... | [
{
"answer_id": 97492,
"author": "saifur",
"author_id": 31689,
"author_profile": "https://wordpress.stackexchange.com/users/31689",
"pm_score": 0,
"selected": false,
"text": "<p>You need to set the width of each div (first, second, third, forth) to 25% and use <code>float:left</code>. </p... | 2013/04/27 | [
"https://wordpress.stackexchange.com/questions/97478",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31545/"
] | I have 4 footer widgets in the theme I'm working on. It works great. The only thing that I can't get to work is the responsiveness of the widgets. The 4 footer widgets keep on showing up next to each other on smaller screens, and I need them to be on top of each other for smaller screens. Can any one help me around thi... | Set the width of the div to 100% and remove the float for the media query used for smaller screens like this:
```
@media screen and (max-with 600px){
.widget-area{
float: none;
width: 100%;
}
}
```
And for the desktop view:
```
@media screen and (min-with 600px){
.widget-area{
float: left;
width: 25%;
}
}
`... |
97,495 | <p>Can't work out which conditional tag to use to add a page title to the portfolio archive page which uses custom posts types.</p>
<p>This doesn't work:</p>
<pre><code>if( is_archive('portfolio') )
echo '<div class="portfolio-title">Add Your Page Title Here</div>';
};
</code></pre>
<p>// Here's the code... | [
{
"answer_id": 97496,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>Use <code>is_post_type_archive()</code>:</p>\n\n<pre><code>if ( is_post_type_archive( 'portfolio' ) )\n{\n // echo ... | 2013/04/27 | [
"https://wordpress.stackexchange.com/questions/97495",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29218/"
] | Can't work out which conditional tag to use to add a page title to the portfolio archive page which uses custom posts types.
This doesn't work:
```
if( is_archive('portfolio') )
echo '<div class="portfolio-title">Add Your Page Title Here</div>';
};
```
// Here's the code which generates the portfolio post type and ... | Use `is_post_type_archive()`:
```
if ( is_post_type_archive( 'portfolio' ) )
{
// echo something
}
```
You can also pass multiple post types here:
```
if ( is_post_type_archive( array ( 'portfolio', 'project' ) ) )
{
// echo something
}
``` |
97,501 | <p>I have this code in my style.css</p>
<pre><code>iframe[src*="http://www.youtube.com/"]
{width:480px !important; height:305px !important;padding-top: 20px;display:none}
</code></pre>
<p>as you can see, it makes youtube videos not to display. But I want to display videos in some time period (for example: from 2.00 A... | [
{
"answer_id": 97503,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>You could filter <code>body_class</code> and add a time depending class:</p>\n\n<pre><code>add_filter( 'body_class', '... | 2013/04/27 | [
"https://wordpress.stackexchange.com/questions/97501",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24600/"
] | I have this code in my style.css
```
iframe[src*="http://www.youtube.com/"]
{width:480px !important; height:305px !important;padding-top: 20px;display:none}
```
as you can see, it makes youtube videos not to display. But I want to display videos in some time period (for example: from 2.00 AM to 2.00 PM). How to do i... | You could filter `body_class` and add a time depending class:
```
add_filter( 'body_class', 'time_body_classes' );
function time_body_classes( $classes )
{
$classes[] = 'time-' . date( 'a' ); // time-am or time-pm
$classes[] = 'time-' . date( 'H' ); // time-02 or time-17
return $classes;
}
```
Then you... |
97,502 | <p>I am relatively new to jQuery and AJAX in particular. I have a small issue with the return value always being 0, though I think this is actually the success message and it's not returning anything.</p>
<p>I have scoured the Google-verse and I have the die() function on the PHP callback and I believe the add_actions... | [
{
"answer_id": 97510,
"author": "Omar Abid",
"author_id": 2167,
"author_profile": "https://wordpress.stackexchange.com/users/2167",
"pm_score": 1,
"selected": false,
"text": "<p>Try running this code on the console</p>\n\n<pre><code>jQuery.post(ajaxurl, {action:'cleanlinks_ajax_get_post_... | 2013/04/27 | [
"https://wordpress.stackexchange.com/questions/97502",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28602/"
] | I am relatively new to jQuery and AJAX in particular. I have a small issue with the return value always being 0, though I think this is actually the success message and it's not returning anything.
I have scoured the Google-verse and I have the die() function on the PHP callback and I believe the add\_actions are corr... | So I worked it out. It was not the jQuery as such though I have improved that, it was the placement of the call back function. I moved it over to the main plugin file and it worked. |
97,515 | <p>I have 2 sidebars(primary and secondary). I want the secondary sidebar to display only on the blog page and primary sidebar to display everywhere else except for the blog page.
What have I tried:</p>
<p>In functions.php : </p>
<pre><code>if (is_page('blog-35')) {
get_sidebar('secondary');
} else {
get_side... | [
{
"answer_id": 97510,
"author": "Omar Abid",
"author_id": 2167,
"author_profile": "https://wordpress.stackexchange.com/users/2167",
"pm_score": 1,
"selected": false,
"text": "<p>Try running this code on the console</p>\n\n<pre><code>jQuery.post(ajaxurl, {action:'cleanlinks_ajax_get_post_... | 2013/04/27 | [
"https://wordpress.stackexchange.com/questions/97515",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32120/"
] | I have 2 sidebars(primary and secondary). I want the secondary sidebar to display only on the blog page and primary sidebar to display everywhere else except for the blog page.
What have I tried:
In functions.php :
```
if (is_page('blog-35')) {
get_sidebar('secondary');
} else {
get_sidebar('primary');
}
``... | So I worked it out. It was not the jQuery as such though I have improved that, it was the placement of the call back function. I moved it over to the main plugin file and it worked. |
97,533 | <p>It's a sad day in the world when I Google something and it returns nothing. I am trying to use the default datepicker (or ANY datepicker at this point) and am unable to because of my lack of knowledge with Wordpress/PHP. In my plugin, I am attempting to register jquery and the ui and apparently am breaking other p... | [
{
"answer_id": 97534,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 4,
"selected": true,
"text": "<p>Given that all of the libraries you need for the datepicker <a href=\"http://codex.wordpress.org/Function_Refe... | 2013/04/28 | [
"https://wordpress.stackexchange.com/questions/97533",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30695/"
] | It's a sad day in the world when I Google something and it returns nothing. I am trying to use the default datepicker (or ANY datepicker at this point) and am unable to because of my lack of knowledge with Wordpress/PHP. In my plugin, I am attempting to register jquery and the ui and apparently am breaking other parts ... | Given that all of the libraries you need for the datepicker [are bundled with WordPress](http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Default_Scripts_Included_and_Registered_by_WordPress) and are [registered](http://codex.wordpress.org/Function_Reference/wp_register_script) with all of the appropriat... |
97,536 | <p>I need help in styling the first post differently than the rest. What makes this differently is that I'm using this get_template_part in order for infinite scroll to work on my site.</p>
<p>This is what I use on index.php</p>
<pre><code><?php while (have_posts()) : the_post();
get_template_part( 'content', get_... | [
{
"answer_id": 97538,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>If you are using <code>post_class()</code> in your <code>content</code> template like this …</p>\n\n<pre><code><div... | 2013/04/28 | [
"https://wordpress.stackexchange.com/questions/97536",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8049/"
] | I need help in styling the first post differently than the rest. What makes this differently is that I'm using this get\_template\_part in order for infinite scroll to work on my site.
This is what I use on index.php
```
<?php while (have_posts()) : the_post();
get_template_part( 'content', get_post_format() );
endwh... | Got it to work!
```
<?php if ( 1 > get_query_var( 'paged' ) ) { ?>
<?php if ( is_first_post() ) { ?>
first! <br />
<?php the_title();?>
<?php the_excerpt();?>
<?php } else { ?>
<?php the_title();?>
<?php the_excerpt();?>
<?php } ?>
<?php } else { ?>
<?php the_title(); ?>
<?php the_excerpt();?>
<?php } ?>
... |
97,547 | <p>I'm just starting to populate my CPT. I want to keep it separate from regular posts. But when I go look at regular posts (in the <code>single.php</code> template), the Prev/Next nav includes CPT posts.</p>
<p>Interestingly, CPT posts do <em>not</em> appear on the home page list.</p>
<p>UPDATE: I'm using the <code>... | [
{
"answer_id": 97548,
"author": "NotoriousWebmaster",
"author_id": 5397,
"author_profile": "https://wordpress.stackexchange.com/users/5397",
"pm_score": 2,
"selected": false,
"text": "<p>The issue was that the get_previous/next nav filters were \"out in the open\" in the plugin; so they ... | 2013/04/28 | [
"https://wordpress.stackexchange.com/questions/97547",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5397/"
] | I'm just starting to populate my CPT. I want to keep it separate from regular posts. But when I go look at regular posts (in the `single.php` template), the Prev/Next nav includes CPT posts.
Interestingly, CPT posts do *not* appear on the home page list.
UPDATE: I'm using the `get_previous_post_join`, `get_previous_p... | The issue was that the get\_previous/next nav filters were "out in the open" in the plugin; so they were executed every time the plugin was loaded. I put them in a function called myplugin\_set\_nav\_filters(), which I invoked before the loop in the CPT single template, and everything worked as advertised.
Now the nav... |
97,564 | <p>I know many people asked for this question but I didn't find a proper way to do it. How to add a simple meta_query (product_cat) before the execution of the shop page's query.</p>
<p>Maybe by using a filter ?</p>
<p>Regards,</p>
<p>Adrien</p>
| [
{
"answer_id": 97616,
"author": "adelval",
"author_id": 40965,
"author_profile": "https://wordpress.stackexchange.com/users/40965",
"pm_score": 5,
"selected": true,
"text": "<p>The shop page is actually an archive page for posts of type 'product'. Its template is in woocommerce/archive-p... | 2013/04/28 | [
"https://wordpress.stackexchange.com/questions/97564",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23524/"
] | I know many people asked for this question but I didn't find a proper way to do it. How to add a simple meta\_query (product\_cat) before the execution of the shop page's query.
Maybe by using a filter ?
Regards,
Adrien | The shop page is actually an archive page for posts of type 'product'. Its template is in woocommerce/archive-product.php.
You need to use the [pre\_get\_posts](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) action to preprocess the query before the loop, [conditional\_tags](http://codex.wordpr... |
97,571 | <p>I use a slider to show my post thumbnails. But the problem is that the slider adds thumbnails without the <code>alt</code> attribute:<br>
<code><img src="http://example.com/wallpaper-791556-1180x500.jpg" /></code></p>
<p>But I want to have the <code>alt</code> attribute, as you may already guessed.
I've read ... | [
{
"answer_id": 97574,
"author": "ArgGeo",
"author_id": 31047,
"author_profile": "https://wordpress.stackexchange.com/users/31047",
"pm_score": -1,
"selected": false,
"text": "<p>You could try using javascript</p>\n\n<pre><code>jQuery('.post-thumbnail-wrapper a img').removeAttr('alt');\n<... | 2013/04/28 | [
"https://wordpress.stackexchange.com/questions/97571",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32138/"
] | I use a slider to show my post thumbnails. But the problem is that the slider adds thumbnails without the `alt` attribute:
`<img src="http://example.com/wallpaper-791556-1180x500.jpg" />`
But I want to have the `alt` attribute, as you may already guessed.
I've read a lot about it and about array, but had not succee... | When I test `get_the_post_thumbnail` (also `the_post_thumbnail`) on WordPress 3.5.1, the `alt` attribute is added as it should be. If [you look at the source](http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/post-thumbnail-template.php#L93), you will see that [`get_the_post_thumbnail`](http://codex.wordpre... |
97,591 | <p>I'm using xdebug and webgrind to profile my WordPress installation because it's a bit slow. As there are some 20 plugins activated, I figured xdebug will be able to find the bottleneck.</p>
<p>However, to my surprise, it appears that localizing routines are taking the majority part of the execution time. And yes I'... | [
{
"answer_id": 97593,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>For each translation file, WordPress has to unpack it, then each entry will be converted into an <code>Translation_Entr... | 2013/04/28 | [
"https://wordpress.stackexchange.com/questions/97591",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26808/"
] | I'm using xdebug and webgrind to profile my WordPress installation because it's a bit slow. As there are some 20 plugins activated, I figured xdebug will be able to find the bottleneck.
However, to my surprise, it appears that localizing routines are taking the majority part of the execution time. And yes I'm using a ... | For each translation file, WordPress has to unpack it, then each entry will be converted into an `Translation_Entry` object.
The short string *"caller\_get\_posts" is deprecated. Use "ignore\_sticky\_posts" instead.* will need three times more memory when it is translated:
```
'"caller_get_posts" is deprecated. Use... |
97,601 | <p><strong>FINAL UPDATE:</strong> Updated code from @birgire solved my issue. If you are facing a similar issue, please read the accepted answer.</p>
<hr>
<p><strong>ORIGINAL QUESTION IN DETAIL:</strong>
Currently under the appearance menu in admin, there is a link called 'editor', which when clicked leads to editab... | [
{
"answer_id": 97608,
"author": "montrealist",
"author_id": 8105,
"author_profile": "https://wordpress.stackexchange.com/users/8105",
"pm_score": 1,
"selected": false,
"text": "<p>From <a href=\"http://codex.wordpress.org/Function_Reference/add_submenu_page#Parameters\" rel=\"nofollow no... | 2013/04/28 | [
"https://wordpress.stackexchange.com/questions/97601",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25508/"
] | **FINAL UPDATE:** Updated code from @birgire solved my issue. If you are facing a similar issue, please read the accepted answer.
---
**ORIGINAL QUESTION IN DETAIL:**
Currently under the appearance menu in admin, there is a link called 'editor', which when clicked leads to editable main-stylesheet, my effort is to p... | You can check out [this](https://wordpress.stackexchange.com/questions/88275/can-not-redirect-from-plugin-registered-admin-page/88283#88283) excellent answer by @Eugene Manuilov. In your case the relevant admin page action is:
```
load-appearance_page_customstyle
```
and the url to the custom stylesheet you want to ... |
97,617 | <p>I need to check each page to see if it has a default template or another template assigned. If it's default, I want to do X if it's not, then I will do Y. Problem I found is that the query is not showing that particular field. I wanted to find</p>
<pre><code> [meta_key] => '_wp_page_template',
[meta_value] =>... | [
{
"answer_id": 97608,
"author": "montrealist",
"author_id": 8105,
"author_profile": "https://wordpress.stackexchange.com/users/8105",
"pm_score": 1,
"selected": false,
"text": "<p>From <a href=\"http://codex.wordpress.org/Function_Reference/add_submenu_page#Parameters\" rel=\"nofollow no... | 2013/04/29 | [
"https://wordpress.stackexchange.com/questions/97617",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14761/"
] | I need to check each page to see if it has a default template or another template assigned. If it's default, I want to do X if it's not, then I will do Y. Problem I found is that the query is not showing that particular field. I wanted to find
```
[meta_key] => '_wp_page_template',
[meta_value] => 'default'
```
th... | You can check out [this](https://wordpress.stackexchange.com/questions/88275/can-not-redirect-from-plugin-registered-admin-page/88283#88283) excellent answer by @Eugene Manuilov. In your case the relevant admin page action is:
```
load-appearance_page_customstyle
```
and the url to the custom stylesheet you want to ... |
97,653 | <p>How to move image attachment from post to another (not to "Remove Permanently" and Re-Upload) ?</p>
<p>I'm using WordPress 3.5.0 and I have a thousand images to process. Is there a built-in function for this ? or is there a WordPress plugin doing this ?</p>
| [
{
"answer_id": 97608,
"author": "montrealist",
"author_id": 8105,
"author_profile": "https://wordpress.stackexchange.com/users/8105",
"pm_score": 1,
"selected": false,
"text": "<p>From <a href=\"http://codex.wordpress.org/Function_Reference/add_submenu_page#Parameters\" rel=\"nofollow no... | 2013/04/29 | [
"https://wordpress.stackexchange.com/questions/97653",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3608/"
] | How to move image attachment from post to another (not to "Remove Permanently" and Re-Upload) ?
I'm using WordPress 3.5.0 and I have a thousand images to process. Is there a built-in function for this ? or is there a WordPress plugin doing this ? | You can check out [this](https://wordpress.stackexchange.com/questions/88275/can-not-redirect-from-plugin-registered-admin-page/88283#88283) excellent answer by @Eugene Manuilov. In your case the relevant admin page action is:
```
load-appearance_page_customstyle
```
and the url to the custom stylesheet you want to ... |
97,657 | <p>As the title says. Would be grateful for your help. Thank you. </p>
| [
{
"answer_id": 97660,
"author": "Balas",
"author_id": 17849,
"author_profile": "https://wordpress.stackexchange.com/users/17849",
"pm_score": -1,
"selected": false,
"text": "<pre><code><ul>\n\n<?php\n\n // we add this, to show all posts in our\n // Glossary sorted alphabet... | 2013/04/29 | [
"https://wordpress.stackexchange.com/questions/97657",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8541/"
] | As the title says. Would be grateful for your help. Thank you. | Try to do all theme modifications in functions.php whenever possible. It keeps the theme files clean and uncluttered. Here's an example using the [`pre_get_posts` action](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts):
```
function order_category_archives( $query ) {
if ( is_category() && $que... |
97,658 | <p>I've this function, which I'm pretty sure a lot of you already know:</p>
<pre><code>function catch_that_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = $matc... | [
{
"answer_id": 97683,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>You will need to grab the image, get its ID, and then use <a href=\"http://codex.wordpress.org/Function_Refer... | 2013/04/29 | [
"https://wordpress.stackexchange.com/questions/97658",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32170/"
] | I've this function, which I'm pretty sure a lot of you already know:
```
function catch_that_image() {
global $post, $posts;
$first_img = '';
ob_start();
ob_end_clean();
$output = preg_match_all('/<img.+src=[\'"]([^\'"]+)[\'"].*>/i', $post->post_content, $matches);
$first_img = $matches[1][0];
return $f... | **When the first image is a Wordpress image attachment.**
in 3.6, there is an easier way.
```
function get_first_image_medium_size_url($post_id) {
if(!$images = get_attached_images($post_id))
return false;
$first_image = current($images);
if(!$src = wp_get_attachment_image_src($first_image->ID,'medium'))
... |
97,672 | <p>I am using the german Wordpress 3.5.1–de_DE with Woocommerce 2.0.8 and the Woothemes Mystile Theme 1.2.8.</p>
<p>I have a big picture for a product (Jellyfish.jpg) and want to use a specific area of that big picture as a thumbnail, because Wordpress/Woocommerce automatically chooses a not useful part of the image. ... | [
{
"answer_id": 138570,
"author": "Meetai.com",
"author_id": 19438,
"author_profile": "https://wordpress.stackexchange.com/users/19438",
"pm_score": 0,
"selected": false,
"text": "<p>The <code>*e1367238219134-150x150.jpg</code> files are automatically generated by Wordpress as work copies... | 2013/04/29 | [
"https://wordpress.stackexchange.com/questions/97672",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32173/"
] | I am using the german Wordpress 3.5.1–de\_DE with Woocommerce 2.0.8 and the Woothemes Mystile Theme 1.2.8.
I have a big picture for a product (Jellyfish.jpg) and want to use a specific area of that big picture as a thumbnail, because Wordpress/Woocommerce automatically chooses a not useful part of the image. So I used... | You can fix this using the following code snippet from Brian Krogsard, that I modified. This code should preferably be placed into the functions.php file of your child theme. Instead of taking the original 150x150 thumb it now takes the correct, cropped 150x150 thumb.
```
/* This snippet removes the action that insert... |
97,680 | <p>I have two plugins in the dashboard, <a href="http://wordpress.org/extend/plugins/wordpress-seo/" rel="nofollow">SEO Wordpress</a> and <a href="http://wordpress.org/extend/plugins/custom-content-type-manager/" rel="nofollow">Custom Content Type Manager</a>, and for security reasons I want to hide these from dashboar... | [
{
"answer_id": 97686,
"author": "NielsPilon",
"author_id": 28103,
"author_profile": "https://wordpress.stackexchange.com/users/28103",
"pm_score": 0,
"selected": false,
"text": "<p>Do you want to hide it for a specific kind of user like an author? If so, you can use the Advanced Access M... | 2013/04/29 | [
"https://wordpress.stackexchange.com/questions/97680",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I have two plugins in the dashboard, [SEO Wordpress](http://wordpress.org/extend/plugins/wordpress-seo/) and [Custom Content Type Manager](http://wordpress.org/extend/plugins/custom-content-type-manager/), and for security reasons I want to hide these from dashboard. How to do that?
I tried to hide the SEO Wordpress w... | Wordpress SEO
-------------
If you want to remove the admin menu:

you can do that with:
```
function hide_wpseo() {
remove_action('admin_menu', 'zeo_options_menu');
}
add_action( 'init', 'hide_wpseo');
```
where it will be removed for all users.
WordPress SEO ... |
97,684 | <p>I want the list of users with their email IDs, filtered by some x-profile data.</p>
<p>For example, I want to send an email to users who have checked a checkbox on their profile.</p>
<p>How can I get the info of users filtered by the x-profile data?</p>
| [
{
"answer_id": 98246,
"author": "Eric Allen",
"author_id": 5831,
"author_profile": "https://wordpress.stackexchange.com/users/5831",
"pm_score": 3,
"selected": false,
"text": "<p>You will want to use the <a href=\"http://codex.wordpress.org/Class_Reference/wpdb\" rel=\"nofollow\"><code>$... | 2013/04/29 | [
"https://wordpress.stackexchange.com/questions/97684",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17234/"
] | I want the list of users with their email IDs, filtered by some x-profile data.
For example, I want to send an email to users who have checked a checkbox on their profile.
How can I get the info of users filtered by the x-profile data? | You will want to use the [`$wpdb`](http://codex.wordpress.org/Class_Reference/wpdb) class to execute a query for users with a certain x-profile field value.
I'm no MySQL expert, so someone else likely has a better way to write this query (if you do, please share it and I'll update my code), but here's one approach to ... |
97,706 | <p>I'm looking for a wordpress rewrite that will let me pass a query var. I have a custom post type that produces urls like this:</p>
<p>example.com/custom-post-slug/custom-post-title/</p>
<p>my goal is to have </p>
<p>example.com/custom-post-slug/custom-post-title/cid/10/ </p>
<p>Pass the value 10 into cid </p>
... | [
{
"answer_id": 97722,
"author": "guidod",
"author_id": 14499,
"author_profile": "https://wordpress.stackexchange.com/users/14499",
"pm_score": 0,
"selected": false,
"text": "<p>You would need to create a custom rewrite rule that maps not just the post slug but also the cid value, see thi... | 2013/04/29 | [
"https://wordpress.stackexchange.com/questions/97706",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28619/"
] | I'm looking for a wordpress rewrite that will let me pass a query var. I have a custom post type that produces urls like this:
example.com/custom-post-slug/custom-post-title/
my goal is to have
example.com/custom-post-slug/custom-post-title/cid/10/
Pass the value 10 into cid
Any suggestions? | You can use [`add_rewrite_endpoint`](http://codex.wordpress.org/Rewrite_API/add_rewrite_endpoint), which will add a query var and generate the necessary rewrite rules:
```
function wpd_cid_endpoint() {
add_rewrite_endpoint( 'cid', EP_PERMALINK );
}
add_action( 'init', 'wpd_cid_endpoint' );
```
Don't forget to [f... |
97,709 | <p>I have created a short code called <code>[contianer-narrow][/container-narrow]</code> which wraps your content in a twitter bootstrap class: <code>.container-narrow</code> the issue is that the page title is not included. is there a way to say:</p>
<p><code>if this short code is used, include the page title, else f... | [
{
"answer_id": 97722,
"author": "guidod",
"author_id": 14499,
"author_profile": "https://wordpress.stackexchange.com/users/14499",
"pm_score": 0,
"selected": false,
"text": "<p>You would need to create a custom rewrite rule that maps not just the post slug but also the cid value, see thi... | 2013/04/29 | [
"https://wordpress.stackexchange.com/questions/97709",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27670/"
] | I have created a short code called `[contianer-narrow][/container-narrow]` which wraps your content in a twitter bootstrap class: `.container-narrow` the issue is that the page title is not included. is there a way to say:
`if this short code is used, include the page title, else forget it?` | You can use [`add_rewrite_endpoint`](http://codex.wordpress.org/Rewrite_API/add_rewrite_endpoint), which will add a query var and generate the necessary rewrite rules:
```
function wpd_cid_endpoint() {
add_rewrite_endpoint( 'cid', EP_PERMALINK );
}
add_action( 'init', 'wpd_cid_endpoint' );
```
Don't forget to [f... |
97,712 | <p>Am trying to create a widget that searches for names. The searching and all that is fine, but when I hit submit, I get returned to the front page. I tried messing with the action="", but no matter what I change it to, the widget still redirects to the home page.</p>
<p>Am sure it's simple, I just can't figure out w... | [
{
"answer_id": 97722,
"author": "guidod",
"author_id": 14499,
"author_profile": "https://wordpress.stackexchange.com/users/14499",
"pm_score": 0,
"selected": false,
"text": "<p>You would need to create a custom rewrite rule that maps not just the post slug but also the cid value, see thi... | 2013/04/29 | [
"https://wordpress.stackexchange.com/questions/97712",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32186/"
] | Am trying to create a widget that searches for names. The searching and all that is fine, but when I hit submit, I get returned to the front page. I tried messing with the action="", but no matter what I change it to, the widget still redirects to the home page.
Am sure it's simple, I just can't figure out what am doi... | You can use [`add_rewrite_endpoint`](http://codex.wordpress.org/Rewrite_API/add_rewrite_endpoint), which will add a query var and generate the necessary rewrite rules:
```
function wpd_cid_endpoint() {
add_rewrite_endpoint( 'cid', EP_PERMALINK );
}
add_action( 'init', 'wpd_cid_endpoint' );
```
Don't forget to [f... |
97,728 | <p>I have a costume search in a site i am making.</p>
<p>When a user search a certain term, i want to display category list with a count of how many posts are found with in that category.</p>
<p>I thought of a way but i have problems doing it.</p>
<ol>
<li>in search.php in the loop in <code>have_posts()</code>, i w... | [
{
"answer_id": 97738,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>It is easy to get the number of posts in a category...</p>\n\n<pre><code>$qry = new WP_Query(array('cat'=>... | 2013/04/29 | [
"https://wordpress.stackexchange.com/questions/97728",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25617/"
] | I have a costume search in a site i am making.
When a user search a certain term, i want to display category list with a count of how many posts are found with in that category.
I thought of a way but i have problems doing it.
1. in search.php in the loop in `have_posts()`, i will add a line that check each post's c... | This is what i did:
I run another query without pagination like this:
```
$newQuaryVars = '&posts_per_page=99999999999999&post_type=post';
$posts = query_posts($query_string .$newQuaryVars);
$categoriesList = array();
$categoriesAmounts = array();
```
Then in the `while have posts` i did the following:
```
while (... |
97,765 | <p>I have added this code to my child theme's <code>functions.php</code> file and use the new class but it styles the entire site, not the page I added to the code. What am I doing wrong?</p>
<pre><code>add_filter('body_class','custom_body_class');
function custom_body_class($classes) {
if( is_page('38034') ) {
... | [
{
"answer_id": 97769,
"author": "ferne97",
"author_id": 24814,
"author_profile": "https://wordpress.stackexchange.com/users/24814",
"pm_score": 2,
"selected": false,
"text": "<p>Your function name does not match. Try this..</p>\n\n<pre><code>add_filter( 'body_class', 'custom_body_class' ... | 2013/04/30 | [
"https://wordpress.stackexchange.com/questions/97765",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29218/"
] | I have added this code to my child theme's `functions.php` file and use the new class but it styles the entire site, not the page I added to the code. What am I doing wrong?
```
add_filter('body_class','custom_body_class');
function custom_body_class($classes) {
if( is_page('38034') ) {
$classes[] = 'new-... | The ID can/should be given without quotes (otherwise if you a page with '38034' as slug/post\_name, this will be used instead of the page with the ID 38034). And you want to `return $classes` no matter if you added your own or not.
```
add_filter('body_class', 'custom_body_class');
function custom_body_class($classes)... |
97,799 | <p>I'm using the following code to get a list of all the pages that are children of my project page and display them in a Recent Projects section of my template's footer element.</p>
<p>I've noticed that the <code>get_page_children()</code> method returns everything about that page - <code>post_author</code>, <code>po... | [
{
"answer_id": 97802,
"author": "montrealist",
"author_id": 8105,
"author_profile": "https://wordpress.stackexchange.com/users/8105",
"pm_score": 2,
"selected": false,
"text": "<p>There isn't much overhead, you're hitting the database anyway. Just use <code>array_map</code>.</p>\n\n<pre>... | 2013/04/30 | [
"https://wordpress.stackexchange.com/questions/97799",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28664/"
] | I'm using the following code to get a list of all the pages that are children of my project page and display them in a Recent Projects section of my template's footer element.
I've noticed that the `get_page_children()` method returns everything about that page - `post_author`, `post_date`, `post_content`, `post_title... | You can just return the IDs, then get each title by the respective ID. And to restrict the query to four posts only, you can use `posts_per_page`.
I modified and optimized your above code a bit, so here it is:
```
<h3>Recent Projects</h3>
<ul class="footer-list"><?php
$projects_page = get_page_by_title('Project... |
97,811 | <p><strong>PROBLEM:</strong> I'am trying to prevent execution of default WordPress query for custom category template. I have found a possible solution, but looks like it preventing execution of all post queries:</p>
<pre><code>function _cancel_query( $query ) {
if ( !is_admin() && !is_feed() && is... | [
{
"answer_id": 97817,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 4,
"selected": true,
"text": "<p>Completely canceling main query is pretty much high level madness, that involves subclassing <code>wp</code> class.</... | 2013/04/30 | [
"https://wordpress.stackexchange.com/questions/97811",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24610/"
] | **PROBLEM:** I'am trying to prevent execution of default WordPress query for custom category template. I have found a possible solution, but looks like it preventing execution of all post queries:
```
function _cancel_query( $query ) {
if ( !is_admin() && !is_feed() && is_search() ) {
$query = false;
}... | Completely canceling main query is pretty much high level madness, that involves subclassing `wp` class.
I would:
1. Hook into `pre_get_posts` with `is_main_query()` check
2. Run featured query (still inside hook) and stash results somewhere
3. Use those results to set excluded posts on main query |
97,843 | <p>I'm trying to set a post's featured image based on custom fields. There are different types of posts and therefore the featured image should be set depending on which custom fields have been filled out.</p>
<p>Here is what I currently have (edited):</p>
<pre><code>//Set post thumbnail based on various conditions
... | [
{
"answer_id": 97846,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 2,
"selected": false,
"text": "<p>You have to set the <a href=\"http://codex.wordpress.org/Function_Reference/get_post_meta#Return_Value\" rel=... | 2013/04/30 | [
"https://wordpress.stackexchange.com/questions/97843",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23492/"
] | I'm trying to set a post's featured image based on custom fields. There are different types of posts and therefore the featured image should be set depending on which custom fields have been filled out.
Here is what I currently have (edited):
```
//Set post thumbnail based on various conditions
if (get_post_m... | You have to set the [`$single` paramter of `get_post_meta`](http://codex.wordpress.org/Function_Reference/get_post_meta#Return_Value) to false (or don't set it) to get an array.
Here is a sped-up version:
```
if ($attachment_id = get_post_meta($post_id, 'featured_image', true)) :
elseif ($attachment_id = get... |
97,855 | <p>I'm trying to have alternating classes on the list created by wp_list_pages.</p>
<p>Currently I have extended the Walker_page class updating the start_el function as follows:</p>
<pre><code>class Sidebar_walker extends Walker_page {
var $alternate = 'background_1';
function start_el( &$output, $page, $depth,... | [
{
"answer_id": 97856,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>Each time the method <code>start_el()</code> is called it starts from scratch and doesn’t know anything about earlier ... | 2013/04/30 | [
"https://wordpress.stackexchange.com/questions/97855",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27062/"
] | I'm trying to have alternating classes on the list created by wp\_list\_pages.
Currently I have extended the Walker\_page class updating the start\_el function as follows:
```
class Sidebar_walker extends Walker_page {
var $alternate = 'background_1';
function start_el( &$output, $page, $depth, $args, $current_page... | Consider this a complement to toscho's solution.
I believe that ...
```
$this->alternate = ($this->alternate != 'background_1') ? 'background_1' : 'background_2';
$css_class[] = $this->alternate;
```
... will do what you want.
The difference is that toscho's solution, using the `static` keyword, will make that va... |
97,869 | <p>I want to create a functions.php file in my child theme and put some code in it, but i can't do it because everytime i create a functions.php file and put a code in it an error occurs.</p>
<p>Does anybody know the way to do it?</p>
<pre><code><? php
add_action('iphorm_post_process_1', 'mytheme_create_wp_post',... | [
{
"answer_id": 97856,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>Each time the method <code>start_el()</code> is called it starts from scratch and doesn’t know anything about earlier ... | 2013/04/30 | [
"https://wordpress.stackexchange.com/questions/97869",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25490/"
] | I want to create a functions.php file in my child theme and put some code in it, but i can't do it because everytime i create a functions.php file and put a code in it an error occurs.
Does anybody know the way to do it?
```
<? php
add_action('iphorm_post_process_1', 'mytheme_create_wp_post', 10, 1);
function mythem... | Consider this a complement to toscho's solution.
I believe that ...
```
$this->alternate = ($this->alternate != 'background_1') ? 'background_1' : 'background_2';
$css_class[] = $this->alternate;
```
... will do what you want.
The difference is that toscho's solution, using the `static` keyword, will make that va... |
97,875 | <p>EDIT: Adding more background info. </p>
<p>I've coded a plugin that adds a meta box to the post page. When the post is published, the plugin will generate a random ID for the post, and insert the random ID and the post guid to a custom table in the database. After publishing, or upon editing, the plugin queries the... | [
{
"answer_id": 97880,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>If your query fails you will get the \"property of non-object\" error. You should be checking to see that the... | 2013/04/30 | [
"https://wordpress.stackexchange.com/questions/97875",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31990/"
] | EDIT: Adding more background info.
I've coded a plugin that adds a meta box to the post page. When the post is published, the plugin will generate a random ID for the post, and insert the random ID and the post guid to a custom table in the database. After publishing, or upon editing, the plugin queries the custom ta... | I've solved the problem myself though it is probably not be the right way to do it. **Note that I've had to type "website-address" instead of the actual URL** because system here won't let me use more than one URL in a post without more reputation. That makes it quite difficult to convey what's actually going on of cou... |
97,890 | <p>I am not sure if it is much different for any page but I am wondering how to remove a metabox from the appearance>menu page without having to go into the wordpress core files and remove it. Is there something I can do to override it so it doesn't appear both on the page and on the screen options menu?</p>
| [
{
"answer_id": 97900,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 4,
"selected": true,
"text": "<p>By inspecting the file <code>/wp-admin/nav-menus.php</code> we can see that these meta-boxes: </p>\n\n<p><img s... | 2013/05/01 | [
"https://wordpress.stackexchange.com/questions/97890",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31618/"
] | I am not sure if it is much different for any page but I am wondering how to remove a metabox from the appearance>menu page without having to go into the wordpress core files and remove it. Is there something I can do to override it so it doesn't appear both on the page and on the screen options menu? | By inspecting the file `/wp-admin/nav-menus.php` we can see that these meta-boxes:

are rendered with:
```
<?php do_meta_boxes( 'nav-menus', 'side', null ); ?>
```
The file `/wp-admin/includes/nav-menu.php` contains the corresponding `add_meta_box()` calls and from... |
97,899 | <p>Hi I'm having problems with the <code>the_title</code> filter here's the code that I have:</p>
<pre><code>function zen_title_filter($title){
if(is_singular()){
if(!empty($_GET['asin'])){
if($title == 'Product Details Page' || $title == 'Compare Products Page'){
$title = zen_... | [
{
"answer_id": 97901,
"author": "Andy Adams",
"author_id": 6816,
"author_profile": "https://wordpress.stackexchange.com/users/6816",
"pm_score": 2,
"selected": true,
"text": "<p>Since you're generating things on the fly, we can use a global flag to let us know when we want the title appl... | 2013/05/01 | [
"https://wordpress.stackexchange.com/questions/97899",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26801/"
] | Hi I'm having problems with the `the_title` filter here's the code that I have:
```
function zen_title_filter($title){
if(is_singular()){
if(!empty($_GET['asin'])){
if($title == 'Product Details Page' || $title == 'Compare Products Page'){
$title = zen_get_titles();
... | Since you're generating things on the fly, we can use a global flag to let us know when we want the title applied.
```
add_filter('the_content', function($content){
if(is_page('compare')){
global $asin_doing_template;
// mark that we're doing a template
$asin_doing_template = true;
$asin = esc_attr($_G... |
97,903 | <p>Edit: I have rewritten the question in hopes I will get a reply from someone who knows the theme customizer.</p>
<p>I am trying to figure out how to disable setting controls in the Wordpress theme customizer page. An example is:</p>
<ol>
<li><p>A section in the theme customizer contains a checkbox that is used to ... | [
{
"answer_id": 97901,
"author": "Andy Adams",
"author_id": 6816,
"author_profile": "https://wordpress.stackexchange.com/users/6816",
"pm_score": 2,
"selected": true,
"text": "<p>Since you're generating things on the fly, we can use a global flag to let us know when we want the title appl... | 2013/05/01 | [
"https://wordpress.stackexchange.com/questions/97903",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31618/"
] | Edit: I have rewritten the question in hopes I will get a reply from someone who knows the theme customizer.
I am trying to figure out how to disable setting controls in the Wordpress theme customizer page. An example is:
1. A section in the theme customizer contains a checkbox that is used to hide or show text in a ... | Since you're generating things on the fly, we can use a global flag to let us know when we want the title applied.
```
add_filter('the_content', function($content){
if(is_page('compare')){
global $asin_doing_template;
// mark that we're doing a template
$asin_doing_template = true;
$asin = esc_attr($_G... |
97,904 | <p>when you make a new site from the network admin panel, and then go to the site dashboard it comes up with a "page not found" message.</p>
<p>I am working in localhost/mulitsite/</p>
<p>is the redirect url is correct</p>
<pre><code>RewriteEngine On
RewriteBase /wpmu/
RewriteRule ^index\.php$ - [L]
# add a trailin... | [
{
"answer_id": 97981,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>Rewrite rules should not have absolute paths. This was likely caused by a bug, fixed in WP 3.5.1, see <a href=\"http... | 2013/05/01 | [
"https://wordpress.stackexchange.com/questions/97904",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29259/"
] | when you make a new site from the network admin panel, and then go to the site dashboard it comes up with a "page not found" message.
I am working in localhost/mulitsite/
is the redirect url is correct
```
RewriteEngine On
RewriteBase /wpmu/
RewriteRule ^index\.php$ - [L]
# add a trailing slash to /wp-admin
Rewrite... | Rewrite rules should not have absolute paths. This was likely caused by a bug, fixed in WP 3.5.1, see [Changing subdir multisite install to subdir core directory structure](https://wordpress.stackexchange.com/questions/78145/changing-subdir-multisite-install-to-subdir-core-directory-structure) question.
Update to 3.5.... |