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 |
|---|---|---|---|---|---|---|
117,648 | <p>I have a plugin for Thesis that fixes issues with Wish List Member. The plug is called thesis-wlm. It only has a box.php file. I uploaded thesis-wlm.zip as a plugin and Wordpress attempted to install it but failed. </p>
<p>I then added the thesis-wlm folder, which contains the box.php file, to the plugins folde... | [
{
"answer_id": 117656,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>How to install plugin only from PHP file?</p>\n</blockquote>\n\n<p>I am admittedly guessing ... | 2013/10/12 | [
"https://wordpress.stackexchange.com/questions/117648",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22989/"
] | I have a plugin for Thesis that fixes issues with Wish List Member. The plug is called thesis-wlm. It only has a box.php file. I uploaded thesis-wlm.zip as a plugin and Wordpress attempted to install it but failed.
I then added the thesis-wlm folder, which contains the box.php file, to the plugins folder but nothing ... | Your plugin isn't visible because you haven't provided a `Plugin Name` in your header. Change `Name` to `Plugin Name` and it'll show up. You're also missing a few lines in your header, if that's a concern to you. It's best to just follow [the example provided in the codex](http://codex.wordpress.org/Writing_a_Plugin#Fi... |
117,664 | <p>After much unsuccessful searching, I'm hoping someone here can help me out. I am using Advanced Customs Fields (I assume most people are familiar) to create a post from the front end. I want to validate a field, and make sure there is a value before I save anything to the database.</p>
<p>I have this function, but ... | [
{
"answer_id": 117667,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>In my experience, the only way to check the values of the fields is by directly accessing the <code>$_POST</code> ... | 2013/10/12 | [
"https://wordpress.stackexchange.com/questions/117664",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23492/"
] | After much unsuccessful searching, I'm hoping someone here can help me out. I am using Advanced Customs Fields (I assume most people are familiar) to create a post from the front end. I want to validate a field, and make sure there is a value before I save anything to the database.
I have this function, but the two me... | A couple years later and ACF has integrated this functionality into the plugin itself, so no need for this custom code in the first place. :) |
118,683 | <p>Good morning.
I am trying to query various Wordpress pages, using public query variables, for example</p>
<pre><code>http://dmkim1979.ru/?p=37 // single post
http://dmkim1979.ru/?page_id=40 // single page
</code></pre>
<p>But I don't understand how to use most of these variables.
An... | [
{
"answer_id": 119287,
"author": "Oleg Butuzov",
"author_id": 14536,
"author_profile": "https://wordpress.stackexchange.com/users/14536",
"pm_score": 1,
"selected": false,
"text": "<p>In simple words - it will tell wordpress what to query (to request a data from database).</p>\n\n<p>in a... | 2013/10/13 | [
"https://wordpress.stackexchange.com/questions/118683",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40371/"
] | Good morning.
I am trying to query various Wordpress pages, using public query variables, for example
```
http://dmkim1979.ru/?p=37 // single post
http://dmkim1979.ru/?page_id=40 // single page
```
But I don't understand how to use most of these variables.
And I cannot find complete i... | In simple words - it will tell wordpress what to query (to request a data from database).
in all of cases it will try to search a posts (no mater post this or page or other post type)
<http://dmkim.ru/?s=uuu> - eq search **uuu** on posts (default post type post & pages) and return a results (this is search)
<http://... |
118,690 | <p>I am experimenting with creating a simple plugin to create a custom post type named project but am having some trouble with the rewrite rules not been flushed on activation.</p>
<p>I have the main plugin file with this function:</p>
<pre><code>register_activation_hook( __FILE__, 'Project_Custom_Post_Type::activate... | [
{
"answer_id": 118693,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>Your string is not read as a callback. You should pass an array:</p>\n\n<pre><code>$pcpt = new Project_Custom_Post_Ty... | 2013/10/13 | [
"https://wordpress.stackexchange.com/questions/118690",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39159/"
] | I am experimenting with creating a simple plugin to create a custom post type named project but am having some trouble with the rewrite rules not been flushed on activation.
I have the main plugin file with this function:
```
register_activation_hook( __FILE__, 'Project_Custom_Post_Type::activate' );
```
Then withi... | Your string is not read as a callback. You should pass an array:
```
$pcpt = new Project_Custom_Post_Type;
register_activation_hook( __FILE__, array( $pcpt, 'activate' ) );
```
Note that `init` happens **before** plugin activation, so not callbacks from your class will be executed. |
118,696 | <p>Right now my code is displaying the category name and link. But if an article is in a subcategory, I want to display the subcategory's name and link instead of the parent category's name and link. For some reason though it's still just showing the parent category. Any ideas what I'm doing wrong with the code?</p>
<... | [
{
"answer_id": 118693,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>Your string is not read as a callback. You should pass an array:</p>\n\n<pre><code>$pcpt = new Project_Custom_Post_Ty... | 2013/10/13 | [
"https://wordpress.stackexchange.com/questions/118696",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34465/"
] | Right now my code is displaying the category name and link. But if an article is in a subcategory, I want to display the subcategory's name and link instead of the parent category's name and link. For some reason though it's still just showing the parent category. Any ideas what I'm doing wrong with the code?
```
... | Your string is not read as a callback. You should pass an array:
```
$pcpt = new Project_Custom_Post_Type;
register_activation_hook( __FILE__, array( $pcpt, 'activate' ) );
```
Note that `init` happens **before** plugin activation, so not callbacks from your class will be executed. |
118,697 | <p>I am trying to customize the output of the previous post link.
I want to display 2 titles (with link) for the previous post, one should be a custom text and other should be title of post, for example:</p>
<blockquote>
<pre><code>Read Previous
This is Post tile.
</code></pre>
</blockquote>
<p>Both of them should li... | [
{
"answer_id": 118714,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>Of course it is the same. Why would you think that that same placeholder-- <code>%link</code>-- would be re... | 2013/10/13 | [
"https://wordpress.stackexchange.com/questions/118697",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37595/"
] | I am trying to customize the output of the previous post link.
I want to display 2 titles (with link) for the previous post, one should be a custom text and other should be title of post, for example:
>
>
> ```
> Read Previous
> This is Post tile.
>
> ```
>
>
Both of them should link to the previous post
I am t... | I would just filter `previous_post_link` and `next_post_link`. This way, your template stays clean, and you move the extra logic to the `functions.php`.
Example, not tested:
```
add_filter( 'previous_post_link', 'filter_single_post_pagination', 10, 4 );
add_filter( 'next_post_link', 'filter_single_post_pagination... |
118,705 | <p>I have recently installed Disqus on my blog and have a problem with the link in the comment count. </p>
<p>On the main page <a href="https://scotthelme.co.uk" rel="nofollow">here</a> all the comments counts for each post link to the appropriate URL for the post with <code>#disqus_thread</code> appended to take the ... | [
{
"answer_id": 118706,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>Filter <code>get_comments_link</code> to change the URL. You get two arguments: the link and the post ID.</p>\n\n<pre... | 2013/10/13 | [
"https://wordpress.stackexchange.com/questions/118705",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37686/"
] | I have recently installed Disqus on my blog and have a problem with the link in the comment count.
On the main page [here](https://scotthelme.co.uk) all the comments counts for each post link to the appropriate URL for the post with `#disqus_thread` appended to take the user to the comment section at the bottom.
If... | I found the section of code I needed to modify in `wp-includes\comment-template.php`:
I changed this:
```
return apply_filters( 'get_comments_link', get_permalink( $post_id ) . '#comments', $post_id );
```
To this:
```
return apply_filters( 'get_comments_link', get_permalink( $post_id ) . '#disqus_thread', $post_i... |
118,721 | <p>I'm writing a tutorial on using the R language to do some applied statistics. An example post is:</p>
<p><a href="http://mcmcinirt.stat.cmu.edu/archives/223" rel="nofollow">http://mcmcinirt.stat.cmu.edu/archives/223</a></p>
<p>I would like to have all of the blocks of source code be loaded from local files on the ... | [
{
"answer_id": 118724,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Use the built-in tool: the media library. There are two steps to do that:</p>\n\n<ol>\n<li>Allow uploading <code>txt<... | 2013/10/13 | [
"https://wordpress.stackexchange.com/questions/118721",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40383/"
] | I'm writing a tutorial on using the R language to do some applied statistics. An example post is:
<http://mcmcinirt.stat.cmu.edu/archives/223>
I would like to have all of the blocks of source code be loaded from local files on the webserver. In that way, I could use git to sync them with the files that I'm actually u... | I would not use the media uploader for this because you want to "use git to sync them with the files that I'm actually using". There is no straightforward way to sync files uploaded via the uploader, or to update/replace those files. Core functionality in that respect is quite limited. You'd be FTPing into the server t... |
118,731 | <p>WordPress keeps writing rewrite rules into .htaccess again and again till it causes an error and causes server to return 500 Internal server error...</p>
<p>i.e. My .htaccess is a series of</p>
<pre><code># BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]... | [
{
"answer_id": 118732,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>I am not sure why this happens, but you can stop all write access to your .htaccess with a simple filter:</p>\n\n<pre... | 2013/10/13 | [
"https://wordpress.stackexchange.com/questions/118731",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32723/"
] | WordPress keeps writing rewrite rules into .htaccess again and again till it causes an error and causes server to return 500 Internal server error...
i.e. My .htaccess is a series of
```
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILE... | I am not sure why this happens, but you can stop all write access to your .htaccess with a simple filter:
```
add_filter( 'flush_rewrite_rules_hard', '__return_false' );
```
Neither WordPress nor any plugins calling `flush_rewrite_rules()` will write something into the file now. Other methods to access and change th... |
118,735 | <p>i have a group of metaboxes which i finally are now saving but am struggling to get the saved values back into the input boxes they came from. so for example i have a meta field called link text and if i put 'link 1 text' in there and save I save it but it doesn't show back in the form.</p>
<p>the code i use for th... | [
{
"answer_id": 118737,
"author": "Imperative Ideas",
"author_id": 28719,
"author_profile": "https://wordpress.stackexchange.com/users/28719",
"pm_score": 2,
"selected": true,
"text": "<p>You want to get the data out of the custom post type, assign it to a variable, then echo that value i... | 2013/10/13 | [
"https://wordpress.stackexchange.com/questions/118735",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36308/"
] | i have a group of metaboxes which i finally are now saving but am struggling to get the saved values back into the input boxes they came from. so for example i have a meta field called link text and if i put 'link 1 text' in there and save I save it but it doesn't show back in the form.
the code i use for this is:
``... | You want to get the data out of the custom post type, assign it to a variable, then echo that value into the field when the page loads. If nothing else, that will make your code a lot more readable (and easier to troubleshoot) While it's not explicitly about what you are doing, you an see the exact method at work here ... |
118,764 | <p>I've been working on updating a site which was running on an old version of WordPress, I've had to update the theme, most of the plugins and finally got the WordPress up to date. I've had to do a few customisations including using plugins to replace old theme functions that the site used which are not present/workin... | [
{
"answer_id": 118737,
"author": "Imperative Ideas",
"author_id": 28719,
"author_profile": "https://wordpress.stackexchange.com/users/28719",
"pm_score": 2,
"selected": true,
"text": "<p>You want to get the data out of the custom post type, assign it to a variable, then echo that value i... | 2013/10/14 | [
"https://wordpress.stackexchange.com/questions/118764",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31802/"
] | I've been working on updating a site which was running on an old version of WordPress, I've had to update the theme, most of the plugins and finally got the WordPress up to date. I've had to do a few customisations including using plugins to replace old theme functions that the site used which are not present/working i... | You want to get the data out of the custom post type, assign it to a variable, then echo that value into the field when the page loads. If nothing else, that will make your code a lot more readable (and easier to troubleshoot) While it's not explicitly about what you are doing, you an see the exact method at work here ... |
118,772 | <p>One JS file is making an ajax call. Within the success of this ajax call another AJAX call is made. The second call checks whether the email has already been registered. If it has been then the second AJAX call recieves no returned data as shown in firebug and Chrome console in the case. But the same code works jus... | [
{
"answer_id": 118796,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 4,
"selected": false,
"text": "<p>What you're experiencing (AJAX works locally, but not on the server) there is a delay problem. Locally everything ... | 2013/10/14 | [
"https://wordpress.stackexchange.com/questions/118772",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38052/"
] | One JS file is making an ajax call. Within the success of this ajax call another AJAX call is made. The second call checks whether the email has already been registered. If it has been then the second AJAX call recieves no returned data as shown in firebug and Chrome console in the case. But the same code works just fi... | What you're experiencing (AJAX works locally, but not on the server) there is a delay problem. Locally everything works that fast, that you can't *see* your problem. In short, this is your problem:
>
> AJAX callback (A) executes > AJAX Callback (B) doesn't know that it has to wait for (A) > You can't see the problem ... |
118,779 | <p>I was wondering if it is possible to make shortcode not case sensitive, should be pretty straight forward but I want:</p>
<pre><code>[test=1]
</code></pre>
<p>to work while written as </p>
<pre><code>[TeST=1], [TEST=1]
</code></pre>
<p>And if so, how do I do it?</p>
| [
{
"answer_id": 118783,
"author": "Matt",
"author_id": 24077,
"author_profile": "https://wordpress.stackexchange.com/users/24077",
"pm_score": 1,
"selected": false,
"text": "<p>If you're talking about a shortcode you've created yourself, you'd have to register all possibilities of case.</... | 2013/10/14 | [
"https://wordpress.stackexchange.com/questions/118779",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38335/"
] | I was wondering if it is possible to make shortcode not case sensitive, should be pretty straight forward but I want:
```
[test=1]
```
to work while written as
```
[TeST=1], [TEST=1]
```
And if so, how do I do it? | Here is another simple idea for a *case-insensitive* shortcode:
```
/**
* Make a shortcode case insensitive via the the_content filter
*
* @param string $content
* @return string $content
*/
function my_case_insensitive_shortcode( $content )
{
$sc = 'test'; // Edit this shortcode name to your needs
$fr... |
118,789 | <p>This is how i am loading the post thumbnail image ?</p>
<p>What if there is no image, i want to show a default image ?</p>
<p>How can i show that.</p>
<p>Here is the code i use to display thumbnail.</p>
<pre><code> $html .= '<div class="post event" id="post-'.$post->ID.'">
&l... | [
{
"answer_id": 118791,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": false,
"text": "<p>The featured image-related functions do not offer any way to define a default/fallback image. So, you'll h... | 2013/10/14 | [
"https://wordpress.stackexchange.com/questions/118789",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37664/"
] | This is how i am loading the post thumbnail image ?
What if there is no image, i want to show a default image ?
How can i show that.
Here is the code i use to display thumbnail.
```
$html .= '<div class="post event" id="post-'.$post->ID.'">
<a href="'.get_permalink($post->ID).'"> '.get_... | The featured image-related functions do not offer any way to define a default/fallback image. So, you'll have to define one yourself, e.g.
```
<?php $featured_image = ( '' != get_the_post_thumbnail() ? get_the_post_thumbnail() : get_template_directory_uri() . '/images/img_not_available.png' ); ?>
<a href="<?php the_p... |
118,793 | <p>I'm trying to add language option to my website. I've coded my theme and I need to show the web in three different languages. I've got the little flags and I've managed to pass a php variable with the language it's selected. With that variable I've made a if for the wp_nav_menu assignment in the header.php. It works... | [
{
"answer_id": 118791,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": false,
"text": "<p>The featured image-related functions do not offer any way to define a default/fallback image. So, you'll h... | 2013/10/14 | [
"https://wordpress.stackexchange.com/questions/118793",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40417/"
] | I'm trying to add language option to my website. I've coded my theme and I need to show the web in three different languages. I've got the little flags and I've managed to pass a php variable with the language it's selected. With that variable I've made a if for the wp\_nav\_menu assignment in the header.php. It works ... | The featured image-related functions do not offer any way to define a default/fallback image. So, you'll have to define one yourself, e.g.
```
<?php $featured_image = ( '' != get_the_post_thumbnail() ? get_the_post_thumbnail() : get_template_directory_uri() . '/images/img_not_available.png' ); ?>
<a href="<?php the_p... |
118,795 | <p>I have seen another question located <a href="https://wordpress.stackexchange.com/questions/10447/how-to-grab-first-image-attached-to-post-and-display-in-rss-feed">here</a>, but it's not useful for my case; it's not working. Also, "RSS Feed Image" plugin is not working as desired.</p>
<p>I want to <strong>display t... | [
{
"answer_id": 118791,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": false,
"text": "<p>The featured image-related functions do not offer any way to define a default/fallback image. So, you'll h... | 2013/10/14 | [
"https://wordpress.stackexchange.com/questions/118795",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15946/"
] | I have seen another question located [here](https://wordpress.stackexchange.com/questions/10447/how-to-grab-first-image-attached-to-post-and-display-in-rss-feed), but it's not useful for my case; it's not working. Also, "RSS Feed Image" plugin is not working as desired.
I want to **display the first image** of the pos... | The featured image-related functions do not offer any way to define a default/fallback image. So, you'll have to define one yourself, e.g.
```
<?php $featured_image = ( '' != get_the_post_thumbnail() ? get_the_post_thumbnail() : get_template_directory_uri() . '/images/img_not_available.png' ); ?>
<a href="<?php the_p... |
118,809 | <p>I have the theme Hatch and I can't figure out how to change the meta-description of the home-page. It is not an actual page, it is the default view for posts.</p>
<p>Have searched everywhere for an answer but really can't figure it out. I have downloaded the plug-in SEO by Yoast, but only seem to be able to change ... | [
{
"answer_id": 119017,
"author": "RenTheMighty",
"author_id": 36178,
"author_profile": "https://wordpress.stackexchange.com/users/36178",
"pm_score": -1,
"selected": false,
"text": "<p>For <strong>WordPress SEO</strong> (by Yoast) - it's under titles and meta - there will be a home tab. ... | 2013/10/14 | [
"https://wordpress.stackexchange.com/questions/118809",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40427/"
] | I have the theme Hatch and I can't figure out how to change the meta-description of the home-page. It is not an actual page, it is the default view for posts.
Have searched everywhere for an answer but really can't figure it out. I have downloaded the plug-in SEO by Yoast, but only seem to be able to change the meta-d... | You do not need to add Yoast if you only want to add meta tags to the homepage. Just some minor editing will save you on performance.
You can use the [is\_home()](http://codex.wordpress.org/Function_Reference/is_home) function.
Insert this to your `header.php`:
```
<?php if (is_home()) { ?>
<meta name="description"... |
118,818 | <p>I have a custom field which stores a date in a timestamp. I want to run a query that display posts based on the month, for example all entries from March, the specific day or year doesn't matter. I'm guessing i need to use the DATE or the DATETIME type for the meta query, but i don't know how to proceed:</p>
<pre><... | [
{
"answer_id": 123178,
"author": "eskimo",
"author_id": 36783,
"author_profile": "https://wordpress.stackexchange.com/users/36783",
"pm_score": 4,
"selected": true,
"text": "<p>You need the 2 digit month number that you want to query on and then use the code below. This should be easy wi... | 2013/10/14 | [
"https://wordpress.stackexchange.com/questions/118818",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8038/"
] | I have a custom field which stores a date in a timestamp. I want to run a query that display posts based on the month, for example all entries from March, the specific day or year doesn't matter. I'm guessing i need to use the DATE or the DATETIME type for the meta query, but i don't know how to proceed:
```
if ($_GET... | You need the 2 digit month number that you want to query on and then use the code below. This should be easy with php (for example, see [this post](https://stackoverflow.com/questions/3768072/php-date-function-to-get-month-of-the-date)). In the code below `$month` is the number of the month in a 2 digit format, eg Marc... |
118,820 | <p>I would like to get show multiple page's content on one page with shortcodes. If I use <code>return $html;</code> the shortcodes not working, if I use <code>return do_shortcode($html);</code> the shortcode working, but the content of the page dissapear. What is the working solution?</p>
<pre><code>function get_page... | [
{
"answer_id": 280085,
"author": "Yogesh",
"author_id": 127915,
"author_profile": "https://wordpress.stackexchange.com/users/127915",
"pm_score": 1,
"selected": false,
"text": "<pre><code>function get_page_func( $atts ){\n extract(shortcode_atts( array(\n 'title' => ''\n ... | 2013/10/14 | [
"https://wordpress.stackexchange.com/questions/118820",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38284/"
] | I would like to get show multiple page's content on one page with shortcodes. If I use `return $html;` the shortcodes not working, if I use `return do_shortcode($html);` the shortcode working, but the content of the page dissapear. What is the working solution?
```
function get_page_func( $atts ){
extract(shortcod... | ```
function get_page_func( $atts ){
extract(shortcode_atts( array(
'title' => ''
), $atts ) );
$page = get_page_by_title($title);
$args = array(
'include' => $page->ID,
);
$pages = get_pages($args);
$html = $pages[0]->post_content;
$html = do_shortcode($html);
... |
118,829 | <p>My post categories are empty. When editing or adding a post they are not displayed in the box. On the /wp-admin/edit-tags.php?taxonomy=category page none of the categories are displayed there either. If I attempt to add a category such as News which was previously there, I get the message, "A term with the name prov... | [
{
"answer_id": 280085,
"author": "Yogesh",
"author_id": 127915,
"author_profile": "https://wordpress.stackexchange.com/users/127915",
"pm_score": 1,
"selected": false,
"text": "<pre><code>function get_page_func( $atts ){\n extract(shortcode_atts( array(\n 'title' => ''\n ... | 2013/10/14 | [
"https://wordpress.stackexchange.com/questions/118829",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25235/"
] | My post categories are empty. When editing or adding a post they are not displayed in the box. On the /wp-admin/edit-tags.php?taxonomy=category page none of the categories are displayed there either. If I attempt to add a category such as News which was previously there, I get the message, "A term with the name provide... | ```
function get_page_func( $atts ){
extract(shortcode_atts( array(
'title' => ''
), $atts ) );
$page = get_page_by_title($title);
$args = array(
'include' => $page->ID,
);
$pages = get_pages($args);
$html = $pages[0]->post_content;
$html = do_shortcode($html);
... |
118,859 | <p>I'm still learning Wordpress and slowly getting better, but my skill set is not up to par for the changes I am asking for. </p>
<p>I need to customize the gallery output for two sections on my site: 1) Portfolio Pages and 2) Blog Posts</p>
<p>On the PORTFOLIO PAGES, I want WP to render the gallery as images tags w... | [
{
"answer_id": 118862,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 0,
"selected": false,
"text": "<p>Just use the regular gallery shortcode, and replace the rendering function (the callback) very late, in <code>wp_head... | 2013/10/14 | [
"https://wordpress.stackexchange.com/questions/118859",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40446/"
] | I'm still learning Wordpress and slowly getting better, but my skill set is not up to par for the changes I am asking for.
I need to customize the gallery output for two sections on my site: 1) Portfolio Pages and 2) Blog Posts
On the PORTFOLIO PAGES, I want WP to render the gallery as images tags with attributes as... | To get the images from [gallery\_shortcode](https://developer.wordpress.org/reference/functions/gallery_shortcode/) into a list I just followed the example. [strip\_tags](http://php.net/manual/en/function.strip-tags.php) seems to strip out all the elements you define, so I kept `a`,`img` and `li`. After that I just wra... |
118,861 | <p>I have a custom post type - <strong>case</strong> - for which I am building an archive page. There are three custom taxonomies for this type - <strong>micro_organisms</strong>, <strong>infection_types</strong>, and <strong>antibiotic_types</strong>. These taxonomies are hierarchical, and have a variety of terms, up ... | [
{
"answer_id": 118887,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 4,
"selected": true,
"text": "<p>If you see doc for <a href=\"http://codex.wordpress.org/Template_Tags/wp_list_categories\" rel=\"noreferrer\">... | 2013/10/14 | [
"https://wordpress.stackexchange.com/questions/118861",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/99/"
] | I have a custom post type - **case** - for which I am building an archive page. There are three custom taxonomies for this type - **micro\_organisms**, **infection\_types**, and **antibiotic\_types**. These taxonomies are hierarchical, and have a variety of terms, up to three levels deep. For the given post type, I'm w... | If you see doc for [`wp_list_categories`](http://codex.wordpress.org/Template_Tags/wp_list_categories) in codex, you'll se that it accepts a `include` param, that should contain a comma separed list of categorys ids.
So if you change your function `get_terms_by_post_type` creating the function `get_terms_id_by_post_ty... |
118,888 | <p>Is there a way to create a custom post type in WordPress that will only include the default meta boxes and not any other meta box that was added by other plugins?</p>
<p>The idea is to use the custom post to develop a plugin, this plugin will need to have all the functions custom post type but with all the meta boxe... | [
{
"answer_id": 118890,
"author": "Imperative Ideas",
"author_id": 28719,
"author_profile": "https://wordpress.stackexchange.com/users/28719",
"pm_score": 2,
"selected": false,
"text": "<p>Off the top of my head, without actually testing it, this should work. You want to test for is_admin... | 2013/10/15 | [
"https://wordpress.stackexchange.com/questions/118888",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28237/"
] | Is there a way to create a custom post type in WordPress that will only include the default meta boxes and not any other meta box that was added by other plugins?
The idea is to use the custom post to develop a plugin, this plugin will need to have all the functions custom post type but with all the meta boxes that th... | Off the top of my head, without actually testing it, this should work. You want to test for is\_admin so we don't go running the code on the front end, then also test for the post type being equal to its slug. Edited this because I made a silly mistake before.
Reference this page of the Codex: <http://codex.wordpress.... |
118,895 | <p>How can i disable all js files from plugins and load one single js file which i have combined and compressed ?</p>
<p>Is there any way ?</p>
| [
{
"answer_id": 118898,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 0,
"selected": false,
"text": "<p>You can try to do something like this:</p>\n\n<pre><code>add_action( 'wp_enqueue_scripts', 'wpse8170_di... | 2013/10/15 | [
"https://wordpress.stackexchange.com/questions/118895",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37664/"
] | How can i disable all js files from plugins and load one single js file which i have combined and compressed ?
Is there any way ? | You could install a plug-in like [asset Queue Manager](https://es.wordpress.org/plugins/asset-queue-manager/) to keep track of all the active stylesheets and javascript files (it's preaty neat, you can live-preview how the page would look without an asset to see if your site gets broken or not), and then in your theme'... |
118,897 | <p>I want to display all the images added as gallery in a post with prettyphoto class.</p>
<p>I am using this code.</p>
<pre><code> <?php
/* The loop */
while ( have_posts() ) : the_post();
if ( get_post_gallery() ) :
$gallery = get_post_gallery( get_the_ID(), false )... | [
{
"answer_id": 118902,
"author": "Imperative Ideas",
"author_id": 28719,
"author_profile": "https://wordpress.stackexchange.com/users/28719",
"pm_score": 0,
"selected": false,
"text": "<p>TutsPlus did <a href=\"http://wp.tutsplus.com/tutorials/how-to-integrate-prettyphoto-with-post-image... | 2013/10/15 | [
"https://wordpress.stackexchange.com/questions/118897",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37664/"
] | I want to display all the images added as gallery in a post with prettyphoto class.
I am using this code.
```
<?php
/* The loop */
while ( have_posts() ) : the_post();
if ( get_post_gallery() ) :
$gallery = get_post_gallery( get_the_ID(), false );
/* Loop ... | You can alter the foreach loop as follows,
```
foreach( $gallery['ids'] as $attachment_id )
{
$image_attributes = wp_get_attachment_image_src( $attachment_id );
if( $image_attributes ) {
$src = isset($image_attributes[0])? $image_attributes[0] : '';
if(!empty($src)) {
... |
118,913 | <p>When adding a new tag in the admin interface, WordPress doesn't reload the page. It appears to send the data with an ajax call, clear the fields and add the tag to the list on the right.</p>
<p>I am working with a custom taxonomy that operates like tags. I have added a custom field to that taxonomy. When the user a... | [
{
"answer_id": 118902,
"author": "Imperative Ideas",
"author_id": 28719,
"author_profile": "https://wordpress.stackexchange.com/users/28719",
"pm_score": 0,
"selected": false,
"text": "<p>TutsPlus did <a href=\"http://wp.tutsplus.com/tutorials/how-to-integrate-prettyphoto-with-post-image... | 2013/10/15 | [
"https://wordpress.stackexchange.com/questions/118913",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39309/"
] | When adding a new tag in the admin interface, WordPress doesn't reload the page. It appears to send the data with an ajax call, clear the fields and add the tag to the list on the right.
I am working with a custom taxonomy that operates like tags. I have added a custom field to that taxonomy. When the user adds a new ... | You can alter the foreach loop as follows,
```
foreach( $gallery['ids'] as $attachment_id )
{
$image_attributes = wp_get_attachment_image_src( $attachment_id );
if( $image_attributes ) {
$src = isset($image_attributes[0])? $image_attributes[0] : '';
if(!empty($src)) {
... |
118,970 | <p>Say I created a custom post type called 'Private Posts' (<code>$post_type</code> = <code>itsme_private_posts</code>) and want all posts under the custom post type to be set to 'Private' automatically when published i.e. by default. How do I do it?</p>
<p>Based on <a href="https://stackoverflow.com/a/13572134/107141... | [
{
"answer_id": 118976,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 5,
"selected": true,
"text": "<p>The problem with the code in your question is it <em>always</em> intercepts. You completely lose the... | 2013/10/15 | [
"https://wordpress.stackexchange.com/questions/118970",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10691/"
] | Say I created a custom post type called 'Private Posts' (`$post_type` = `itsme_private_posts`) and want all posts under the custom post type to be set to 'Private' automatically when published i.e. by default. How do I do it?
Based on [@brasofilo's answer to a related question on StackOverflow](https://stackoverflow.c... | The problem with the code in your question is it *always* intercepts. You completely lose the ability to not publish, no drafts possible. Why this leads to untrashable post is something I didn't inspect further. Anyway this isn't what one wants.
I'm glad the javascript solution is working for you, but personally I hav... |
118,983 | <p>My Question:</p>
<p>How do you make an anchor link to an offsite webpage that when clicked opens up the offsite webpage as an iframe that is inside a new Wordpress page where the Wordpress header and footer remain but the iframed webpage shows where the content would normally be?</p>
<p>For Example:</p>
<p>You ha... | [
{
"answer_id": 118996,
"author": "daniel0mullins",
"author_id": 38739,
"author_profile": "https://wordpress.stackexchange.com/users/38739",
"pm_score": 1,
"selected": false,
"text": "<p>I would approach this one of two ways:</p>\n\n<ol>\n<li>Use a <code>target</code> attribute in the lin... | 2013/10/15 | [
"https://wordpress.stackexchange.com/questions/118983",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16641/"
] | My Question:
How do you make an anchor link to an offsite webpage that when clicked opens up the offsite webpage as an iframe that is inside a new Wordpress page where the Wordpress header and footer remain but the iframed webpage shows where the content would normally be?
For Example:
You have a wordpress page with... | I would approach this one of two ways:
1. Use a `target` attribute in the link to open it in an iframe (not universal across browsers)
2. Use JavaScript to replace the `src` attribute on your iframe
Option 1:
```
<a href="somethirdpartysite.com/reg" target="thirdparty">Register</a>
<iframe name="thirdparty"></iframe... |
119,015 | <p><strong>Overview</strong></p>
<ol>
<li><p>I am creating a theme which has 2 custom post types (as custom plugins):</p>
<ol>
<li>Articles </li>
<li>Reviews</li>
</ol></li>
<li><p>I have also created <code>single-articles.php</code> and <code>archive-articles.php</code> templates inside the plugin. Same for Reviews ... | [
{
"answer_id": 119018,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>If we look <a href=\"http://core.trac.wordpress.org/browser/tags/3.6.1/wp-includes/query.php#L1573\" rel=\"nofollow... | 2013/10/16 | [
"https://wordpress.stackexchange.com/questions/119015",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12116/"
] | **Overview**
1. I am creating a theme which has 2 custom post types (as custom plugins):
1. Articles
2. Reviews
2. I have also created `single-articles.php` and `archive-articles.php` templates inside the plugin. Same for Reviews CPT.
3. BOTH the custom post types use the **default** WordPress Taxonomies (categorie... | If we look [in source](http://core.trac.wordpress.org/browser/tags/3.6.1/wp-includes/query.php#L1573), we'll see under what conditions `is_archive` is true:
```
if ( $this->is_post_type_archive
|| $this->is_date
|| $this->is_author
|| $this->is_category
|| $this->is_tag
|| $this->is_tax )
$this->is_archive = true;... |
119,033 | <p>I was learning how to make my own WordPress plugin, currently I'm confused on how if there is no thumbnail in the post then I use the default image as thumbnail. Code that I used:</p>
<pre><code>add_action( 'the_post', 'mythumb' );
function mythum(){
if (!has_post_thumbnail()) {
$defaultthum = "http://examp... | [
{
"answer_id": 119032,
"author": "Karine",
"author_id": 39090,
"author_profile": "https://wordpress.stackexchange.com/users/39090",
"pm_score": 0,
"selected": false,
"text": "<p>In your poedit project settings, add _x to the keywords</p>\n\n<p><a href=\"http://wp.tutsplus.com/tutorials/t... | 2013/10/16 | [
"https://wordpress.stackexchange.com/questions/119033",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40514/"
] | I was learning how to make my own WordPress plugin, currently I'm confused on how if there is no thumbnail in the post then I use the default image as thumbnail. Code that I used:
```
add_action( 'the_post', 'mythumb' );
function mythum(){
if (!has_post_thumbnail()) {
$defaultthum = "http://example.com/default... | When adding \_x to the keywords, try it this way:
\_x:1,2c
This tells the parser to watch out for \_x and to take the first argument as msgid and the second argument as a comment, which will then be recognized as context by poEdit and inserted as msgctxt.
Oddly enough, my poEdit then shows me the msgid twice in the ... |
119,055 | <p>I am trying to use a plugin function in a custom php file.
Pasting this code at the top of my file i can use all the wordpress functions:</p>
<pre><code><?php
$file = dirname(__FILE__);
$file = substr($file, 0, stripos($file, "wp-content") );
require( $file .'/wp-blog-header.php');
</code></pre>
<p>But i get t... | [
{
"answer_id": 119078,
"author": "George Jipa",
"author_id": 6998,
"author_profile": "https://wordpress.stackexchange.com/users/6998",
"pm_score": 0,
"selected": false,
"text": "<p>You should make ajax requests via admin-ajax.php.</p>\n\n<p><a href=\"http://wp.smashingmagazine.com/2011/1... | 2013/10/16 | [
"https://wordpress.stackexchange.com/questions/119055",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17815/"
] | I am trying to use a plugin function in a custom php file.
Pasting this code at the top of my file i can use all the wordpress functions:
```
<?php
$file = dirname(__FILE__);
$file = substr($file, 0, stripos($file, "wp-content") );
require( $file .'/wp-blog-header.php');
```
But i get this error when i call plugin ... | If you are intent on calling into Wordpress functionality from outside of the usual WP workflow, you can put the following two lines in your code:
```
define("WP_USE_THEMES", false);
require_once("../../../wp-blog-header.php");
```
Of course, the above assumes I'm calling this from within a root theme or plugin fold... |
119,063 | <p>For a project I needed to heavily modify the behavior of WP_Query. So what I did was extending WP_Query basically like this:</p>
<pre><code>class eacf_shared_query extends \WP_Query {
function query( $query ) {
// do things before ...
$posts = parent::query($query);
// do things afte... | [
{
"answer_id": 120648,
"author": "Dominic Yun",
"author_id": 30896,
"author_profile": "https://wordpress.stackexchange.com/users/30896",
"pm_score": 1,
"selected": false,
"text": "<p>I'd suggest you hook a filter to the <code>posts_results</code> hook to replace $posts with the result of... | 2013/10/16 | [
"https://wordpress.stackexchange.com/questions/119063",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27536/"
] | For a project I needed to heavily modify the behavior of WP\_Query. So what I did was extending WP\_Query basically like this:
```
class eacf_shared_query extends \WP_Query {
function query( $query ) {
// do things before ...
$posts = parent::query($query);
// do things after ...
... | Ok so it's doable but could potentially mess up a few things down the line so it's at your own risk, but then so is everything :)
I've been trying to do this in order to use a GeoQuery extension class to order events by distance from some location.
The simplest way to do it is this:
```
add_action( 'after_setup_them... |
119,064 | <p>The WordPress documentation for <a href="http://codex.wordpress.org/Determining_Plugin_and_Content_Directories" rel="noreferrer">Determining Plugin and Content Directories</a> states that:</p>
<blockquote>
<p>WordPress makes use of the following constants when determining the
path to the content and plugin dire... | [
{
"answer_id": 119084,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 6,
"selected": true,
"text": "<h2>Reference file in current path or deeper nested</h2>\n\n<p>To reference the current path</p>\n\n<pre><code>plugin_... | 2013/10/16 | [
"https://wordpress.stackexchange.com/questions/119064",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4997/"
] | The WordPress documentation for [Determining Plugin and Content Directories](http://codex.wordpress.org/Determining_Plugin_and_Content_Directories) states that:
>
> WordPress makes use of the following constants when determining the
> path to the content and plugin directories. **These should not be used
> directly... | Reference file in current path or deeper nested
-----------------------------------------------
To reference the current path
```
plugin_dir_path( __FILE__ )."further/nesting/here.css";
```
which works in **Plugins and Themes**.
Reference URl/URi in a plugin
-----------------------------
To point to a plugin or t... |
119,087 | <p>In woocommerce/classes/abstracts/abstract-wc-product.php on line 338.
The is_sold_individualy function is default "false".
Is there a way to set this default option to "true"? So in de Wordpress back-end the checkbox is checked by default? </p>
<pre><code> function is_sold_individually() {
$return = false;
... | [
{
"answer_id": 119092,
"author": "helgatheviking",
"author_id": 6477,
"author_profile": "https://wordpress.stackexchange.com/users/6477",
"pm_score": 0,
"selected": false,
"text": "<p>You want it to be true <em>all</em> the time? The <code>apply_filters()</code> is your tip off that you... | 2013/10/16 | [
"https://wordpress.stackexchange.com/questions/119087",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40531/"
] | In woocommerce/classes/abstracts/abstract-wc-product.php on line 338.
The is\_sold\_individualy function is default "false".
Is there a way to set this default option to "true"? So in de Wordpress back-end the checkbox is checked by default?
```
function is_sold_individually() {
$return = false;
if ( 'yes... | You can use a built-in function from WordPress:
```
add_filter( 'woocommerce_is_sold_individually', '__return_true' );
```
This line [in a separate plugin](https://wordpress.stackexchange.com/questions/73031/where-to-put-my-code-plugin-or-functions-php) will set the value always to `true`. |
119,104 | <p>I'm trying to in some way hook into when a new category is created. What I would like to do is to see the term and slug that was created and log them/email them. I have tried to hook in to create_category(). That only gives me an ID, not the term and slug. Would be great if someone could lead me on the right track.<... | [
{
"answer_id": 119092,
"author": "helgatheviking",
"author_id": 6477,
"author_profile": "https://wordpress.stackexchange.com/users/6477",
"pm_score": 0,
"selected": false,
"text": "<p>You want it to be true <em>all</em> the time? The <code>apply_filters()</code> is your tip off that you... | 2013/10/16 | [
"https://wordpress.stackexchange.com/questions/119104",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40543/"
] | I'm trying to in some way hook into when a new category is created. What I would like to do is to see the term and slug that was created and log them/email them. I have tried to hook in to create\_category(). That only gives me an ID, not the term and slug. Would be great if someone could lead me on the right track. | You can use a built-in function from WordPress:
```
add_filter( 'woocommerce_is_sold_individually', '__return_true' );
```
This line [in a separate plugin](https://wordpress.stackexchange.com/questions/73031/where-to-put-my-code-plugin-or-functions-php) will set the value always to `true`. |
119,107 | <p>I'm adding a number of items to the user profiles using this method in my <code>functions.php</code></p>
<pre><code>function modify_contact_methods($profile_fields) {
// Add new fields
$profile_fields['twitter'] = 'Twitter Username';
$profile_fields['facebook'] = 'Facebook URL';
$profile_fields['gp... | [
{
"answer_id": 119113,
"author": "nathanaelphilip",
"author_id": 40502,
"author_profile": "https://wordpress.stackexchange.com/users/40502",
"pm_score": 3,
"selected": true,
"text": "<p>This is a great plugin that allows you to easily add custom fields to Users (among other things). </p>... | 2013/10/16 | [
"https://wordpress.stackexchange.com/questions/119107",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5295/"
] | I'm adding a number of items to the user profiles using this method in my `functions.php`
```
function modify_contact_methods($profile_fields) {
// Add new fields
$profile_fields['twitter'] = 'Twitter Username';
$profile_fields['facebook'] = 'Facebook URL';
$profile_fields['gplus'] = 'Google+ URL';
... | This is a great plugin that allows you to easily add custom fields to Users (among other things).
<http://www.advancedcustomfields.com/>
This tutorial will help you retrieve the values from user:
<http://www.advancedcustomfields.com/resources/how-to/how-to-get-values-from-a-user/> |
119,123 | <p>I am in the process of customizing the back-end of WordPress for a new product that we will be releasing. I am trying to figure out what the best way is to update the avatar size that shows up in the adminbar, in the top right corner.</p>
<p>I'm trying to set the image size 30px x 30px instead of the default 16px. ... | [
{
"answer_id": 119127,
"author": "Dero",
"author_id": 36190,
"author_profile": "https://wordpress.stackexchange.com/users/36190",
"pm_score": 2,
"selected": false,
"text": "<p>You need to hook into <code>wp_admin_bar</code> action and alter the corresponding object. Something along these... | 2013/10/16 | [
"https://wordpress.stackexchange.com/questions/119123",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25237/"
] | I am in the process of customizing the back-end of WordPress for a new product that we will be releasing. I am trying to figure out what the best way is to update the avatar size that shows up in the adminbar, in the top right corner.
I'm trying to set the image size 30px x 30px instead of the default 16px. Does any o... | You need to hook into `wp_admin_bar` action and alter the corresponding object. Something along these lines will do the trick for you. Place the following code to your `functions.php`.
```php
function _update_avatar_size( $wp_admin_bar ) {
$user_id = get_current_user_id();
$current_user = wp_get_current_... |
119,146 | <p>I want to hide my plugin list. Suppose anyone can see which plugin I use from <a href="http://whatwpthemeisthat.com/" rel="nofollow">this site</a>. How can I hide my plugin list from here? I use WordPress new version, and I want to always update my plugin but don't want anyone can see my plugin name. How can I do th... | [
{
"answer_id": 119429,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>WordPress needs themes and plugins to be in web-accessible folder, so that any scripts and styles from them can be ... | 2013/10/17 | [
"https://wordpress.stackexchange.com/questions/119146",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22576/"
] | I want to hide my plugin list. Suppose anyone can see which plugin I use from [this site](http://whatwpthemeisthat.com/). How can I hide my plugin list from here? I use WordPress new version, and I want to always update my plugin but don't want anyone can see my plugin name. How can I do that?
```
function cws_hidden_... | WordPress needs themes and plugins to be in web-accessible folder, so that any scripts and styles from them can be downloaded by browsers and work.
From there it's technologically easy to detect such resources in page source and/or proactively scan site for presence of files belonging to popular plugins.
There is not... |
119,171 | <p>The following code uploads an image which I want to associate with a custom post type.</p>
<pre><code>$upload_overrides = array( 'test_form' => FALSE );
if($file_errors['error'] == 0) {
if($new_reseller_id = wp_insert_post( $new_reseller_profile_data )){
//$this->wps_process_image($file, $new_reseller... | [
{
"answer_id": 119174,
"author": "codecowboy",
"author_id": 500,
"author_profile": "https://wordpress.stackexchange.com/users/500",
"pm_score": 3,
"selected": true,
"text": "<p>I needed to do the following:</p>\n\n<pre><code>set_post_thumbnail( $new_reseller_id, $attach_id );\n</code></p... | 2013/10/17 | [
"https://wordpress.stackexchange.com/questions/119171",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/500/"
] | The following code uploads an image which I want to associate with a custom post type.
```
$upload_overrides = array( 'test_form' => FALSE );
if($file_errors['error'] == 0) {
if($new_reseller_id = wp_insert_post( $new_reseller_profile_data )){
//$this->wps_process_image($file, $new_reseller_id);exit;
$upl... | I needed to do the following:
```
set_post_thumbnail( $new_reseller_id, $attach_id );
``` |
119,180 | <p>I am trying to use a plugin function ( <code>wp-bannerize()</code> ) inside my custom plugin. but when i write:</p>
<pre><code>if( function_exists('wp_bannerize') ){
echo "exist";
}else{
echo "not exist";
}
</code></pre>
<p>The output is <code>not exists</code></p>
<p>How ... | [
{
"answer_id": 119174,
"author": "codecowboy",
"author_id": 500,
"author_profile": "https://wordpress.stackexchange.com/users/500",
"pm_score": 3,
"selected": true,
"text": "<p>I needed to do the following:</p>\n\n<pre><code>set_post_thumbnail( $new_reseller_id, $attach_id );\n</code></p... | 2013/10/17 | [
"https://wordpress.stackexchange.com/questions/119180",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17815/"
] | I am trying to use a plugin function ( `wp-bannerize()` ) inside my custom plugin. but when i write:
```
if( function_exists('wp_bannerize') ){
echo "exist";
}else{
echo "not exist";
}
```
The output is `not exists`
How can i get this function inside my custom plugin?
UPDAT... | I needed to do the following:
```
set_post_thumbnail( $new_reseller_id, $attach_id );
``` |
119,213 | <p>This is a follow up to <a href="https://wordpress.stackexchange.com/questions/13480/get-terms-return-errors/13482#13482">this post</a>, outlining why I can not use the get_terms function while in functions.php (actually calling via ajax/admin_ajax.php).</p>
<p>I can grab the terms (custom tax) on any post, on any p... | [
{
"answer_id": 119220,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 0,
"selected": false,
"text": "<p>Just add <code>global $post;</code> before use <code>$post</code> variable:</p>\n\n<pre><code>while ($query-&... | 2013/10/17 | [
"https://wordpress.stackexchange.com/questions/119213",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14862/"
] | This is a follow up to [this post](https://wordpress.stackexchange.com/questions/13480/get-terms-return-errors/13482#13482), outlining why I can not use the get\_terms function while in functions.php (actually calling via ajax/admin\_ajax.php).
I can grab the terms (custom tax) on any post, on any page, except when in... | So, thanks to G. M.'s help I was able to debug the problem more efficiently, now that I knew init was indeed not being called. I started stripping out all extraneous functions from my functions.php file and I realized I called do\_action twice, as I have many functions run through admin-ajax.php. The do\_action calls m... |
119,228 | <p>I need query help!</p>
<p>I am trying to set up a <code>meta_query</code> (for <code>get_comments</code>) for keys that aren't yet set.</p>
<p>I have some code that allows moderators to add a custom meta key to individual comments. Click the checkbox and the meta key is set to <code>shadow</code>, unclick it the m... | [
{
"answer_id": 119232,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>You have no need for three states. Logically, you have \"set\" and \"unset\". Don't complicate things. When ... | 2013/10/17 | [
"https://wordpress.stackexchange.com/questions/119228",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39093/"
] | I need query help!
I am trying to set up a `meta_query` (for `get_comments`) for keys that aren't yet set.
I have some code that allows moderators to add a custom meta key to individual comments. Click the checkbox and the meta key is set to `shadow`, unclick it the meta key is set to an empty string.
This means tha... | For the record this is the code that ultimately worked for me:
```
$comments = get_comments( array(
'order' => 'ASC',
'post_id' => get_the_ID(),
'meta_query' => array(
'relation' => 'OR',
array( // Select comments that... |
119,229 | <p>I am writing my plugin's uninstall.php file and would like it to delete any terms that were created in the plugin's custom taxonomy.</p>
<p>In the plugin's uninstall.php file I am using this:</p>
<pre><code>// Delete all custom terms for this taxonomy
$terms = get_terms('custom_taxonomy');
foreach ($terms as $term... | [
{
"answer_id": 119230,
"author": "Ivan Hanák",
"author_id": 40545,
"author_profile": "https://wordpress.stackexchange.com/users/40545",
"pm_score": 0,
"selected": false,
"text": "<p>Call your cleaning function when uninstalling your plugin through <a href=\"http://codex.wordpress.org/Fun... | 2013/10/17 | [
"https://wordpress.stackexchange.com/questions/119229",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29049/"
] | I am writing my plugin's uninstall.php file and would like it to delete any terms that were created in the plugin's custom taxonomy.
In the plugin's uninstall.php file I am using this:
```
// Delete all custom terms for this taxonomy
$terms = get_terms('custom_taxonomy');
foreach ($terms as $term) {
wp_delete_ter... | Using the uninstall hook would be legitimate ***if it worked***, but it dumps the same error as the uninstall file. It would have more chances of working as it loads the main plugin file to perform the uninstall function, but if the taxonomy is not registered anymore (and it is not, as we need to deactivate before unin... |
119,231 | <p>I'm trying to show my CPT Category along with any posts associated with it below the title. I have the first loop fine:</p>
<pre><code><?php $cats = get_categories(array('taxonomy' => 'custtax', 'orderby' => 'term_group'));
if(!empty($cats)) :
foreach($cats as $cat) : ?>
<a ... | [
{
"answer_id": 119233,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>You need a <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters\" rel=\"nofollo... | 2013/10/17 | [
"https://wordpress.stackexchange.com/questions/119231",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7355/"
] | I'm trying to show my CPT Category along with any posts associated with it below the title. I have the first loop fine:
```
<?php $cats = get_categories(array('taxonomy' => 'custtax', 'orderby' => 'term_group'));
if(!empty($cats)) :
foreach($cats as $cat) : ?>
<a href="<?php echo get_category... | To expand on the answer from @s\_ha\_dum - you need to modify a few things about your query.
First, use his suggested tax query:
```
$args = array(
'post_type' => 'custcpt',
'tax_query' => array(
array(
'taxonomy' => 'custtax',
'field' => 'id',
'terms' => $cat->te... |
119,234 | <p>I'm trying to write a shortcode that will allow the option to display all users or show a singular user, defined by a user id or "nicename".</p>
<p>The shortcode would look something like this: <code>[staff display="all"]</code> or <code>[staff display="single" user="3"]</code></p>
<p>I have a standard shortcode w... | [
{
"answer_id": 119233,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>You need a <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters\" rel=\"nofollo... | 2013/10/17 | [
"https://wordpress.stackexchange.com/questions/119234",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5295/"
] | I'm trying to write a shortcode that will allow the option to display all users or show a singular user, defined by a user id or "nicename".
The shortcode would look something like this: `[staff display="all"]` or `[staff display="single" user="3"]`
I have a standard shortcode working that displays all users, but I'd... | To expand on the answer from @s\_ha\_dum - you need to modify a few things about your query.
First, use his suggested tax query:
```
$args = array(
'post_type' => 'custcpt',
'tax_query' => array(
array(
'taxonomy' => 'custtax',
'field' => 'id',
'terms' => $cat->te... |
119,241 | <p>I have a CPT: </p>
<pre><code>function CPT_init(){
register_post_type('custcpt', array(
'labels' => array(
'name' => __('Products'),
'singular_name' => __('Product'),
'all_items' => __('View Products'),
'... | [
{
"answer_id": 119242,
"author": "random_user_name",
"author_id": 11704,
"author_profile": "https://wordpress.stackexchange.com/users/11704",
"pm_score": 5,
"selected": true,
"text": "<p>Remove the slashes on your rewrite slug. Should be like so:</p>\n\n<pre><code> ...\n 'rewrite' ... | 2013/10/17 | [
"https://wordpress.stackexchange.com/questions/119241",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7355/"
] | I have a CPT:
```
function CPT_init(){
register_post_type('custcpt', array(
'labels' => array(
'name' => __('Products'),
'singular_name' => __('Product'),
'all_items' => __('View Products'),
'add_new' => __(... | Remove the slashes on your rewrite slug. Should be like so:
```
...
'rewrite' => array('slug' => 'products', 'with_front' => false)
...
```
Also, you can't have the same slug for both a taxonomy and a custom post type. They need to be unique, otherwise WP won't know which one applies to which.
Additio... |
119,250 | <p>I'm considering using the hooks for the WordPress registration form to add some custom fields: <a href="https://codex.wordpress.org/Customizing_the_Registration_Form" rel="noreferrer">https://codex.wordpress.org/Customizing_the_Registration_Form</a></p>
<p>My question is, if it's even possible, how do I display som... | [
{
"answer_id": 119270,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 2,
"selected": false,
"text": "<p>To display the user meta data in the User's page, you need the filters <code>manage_users_custom_column</co... | 2013/10/17 | [
"https://wordpress.stackexchange.com/questions/119250",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21334/"
] | I'm considering using the hooks for the WordPress registration form to add some custom fields: <https://codex.wordpress.org/Customizing_the_Registration_Form>
My question is, if it's even possible, how do I display some of these custom fields in the backend Users > All Users? For example if I have fields for 'zip code... | Actually I found this to be more strait forward and simpler:
```
//add columns to User panel list page
function add_user_columns($column) {
$column['address'] = 'Street Address';
$column['zipcode'] = 'Zip Code';
return $column;
}
add_filter( 'manage_users_columns', 'add_user_columns' );
//add the data
f... |
119,273 | <p>I want to modify submited password in <a href="http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/user.php#L40" rel="nofollow">wp_logon</a> <code>wp_authenticate</code> action.
When authenticating, I want to grab submited password, modify it, and pass back to <a href="http://core.trac.wordpress.org/browser/... | [
{
"answer_id": 119275,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<p>The things you can change in there are:</p>\n\n<ul>\n<li><code>$secure_cookie = apply_filters('secure_signon_cooki... | 2013/10/18 | [
"https://wordpress.stackexchange.com/questions/119273",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29076/"
] | I want to modify submited password in [wp\_logon](http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/user.php#L40) `wp_authenticate` action.
When authenticating, I want to grab submited password, modify it, and pass back to [wp\_logon](http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/user.php#L40)
... | It didn't work in any reasonable hack.
The only way it could work was hacking wp\_logon core function itself with global variable, which was undisairable.
SO I went with another solution.
I removed authentication function and made my own
```
remove_action('authenticate', 'wp_authenticate_username_password', 20);
ad... |
119,289 | <p>I write a wordpress plugin. My plugin has options. All options are in one group, 'pluginname-settings'. All option names are uniform and look like "pluginname-settings['option-name']". Some code to illustrate my case:</p>
<pre><code>register_setting( 'pluginname_options', 'pluginname-settings', 'pluginname_validate... | [
{
"answer_id": 119502,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>There are two ways:</p>\n\n<ol>\n<li><p>Pass the tab ID as hidden field with your form and update only the fields whi... | 2013/10/18 | [
"https://wordpress.stackexchange.com/questions/119289",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40608/"
] | I write a wordpress plugin. My plugin has options. All options are in one group, 'pluginname-settings'. All option names are uniform and look like "pluginname-settings['option-name']". Some code to illustrate my case:
```
register_setting( 'pluginname_options', 'pluginname-settings', 'pluginname_validate' );
add_setti... | First kick in your validation callback by changing the `register_setting()` to
```
register_setting( 'pluginname_options', 'pluginname-settings', 'pluginname_validate' );
```
And then update your validation function to actually do something. Below it gets the current state of the options, and then only updates the ... |
119,294 | <p>In WordPress shortcodes, how can I pass boolean attributes?<br>
Both of <code>[shortcode boolean_attribute="true"]</code> or <code>[shortcode boolean_attribute=true]</code> are giving string values.</p>
<p>EDIT </p>
<p>There would be no problem for users who know what they're doing if I use the trick which was co... | [
{
"answer_id": 119298,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 5,
"selected": true,
"text": "<p>Is easy to use <code>0</code> and <code>1</code> values and then typecasting inside the function:</p>\n\n<p><c... | 2013/10/18 | [
"https://wordpress.stackexchange.com/questions/119294",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40607/"
] | In WordPress shortcodes, how can I pass boolean attributes?
Both of `[shortcode boolean_attribute="true"]` or `[shortcode boolean_attribute=true]` are giving string values.
EDIT
There would be no problem for users who know what they're doing if I use the trick which was commented by @brasofilo. But some users wil... | Is easy to use `0` and `1` values and then typecasting inside the function:
`[shortcode boolean_attribute='1']` or `[shortcode boolean_attribute='0']`
but if you want you can also strictly check for `'false'` and assign it to boolean, in this way you can also use:
`[shortcode boolean_attribute='false']` or `[shortco... |
119,295 | <p>I don't want this shown to members who register for my website as it's confusing and irrelevant for them. </p>
<p>I assume some code added to <code>functions.php</code> will do the trick but what code?</p>
| [
{
"answer_id": 119321,
"author": "Ian",
"author_id": 40489,
"author_profile": "https://wordpress.stackexchange.com/users/40489",
"pm_score": 0,
"selected": false,
"text": "<p>Not sure about Yoast SEO but this is what I use for non admin users:</p>\n\n<pre><code>function my_remove_menu_it... | 2013/10/18 | [
"https://wordpress.stackexchange.com/questions/119295",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40612/"
] | I don't want this shown to members who register for my website as it's confusing and irrelevant for them.
I assume some code added to `functions.php` will do the trick but what code? | This *should* hide it for everyone but the admin. If you run into any issues, you can use a plugin like [Advanced Access Manager](http://wordpress.org/plugins/advanced-access-manager/) to get the job done. With that you will have more control of what each user level has access to.
```
function hide_yoastseo() {
if ( !... |
119,302 | <p>I am using <a href="https://github.com/Gizburdt/Wordpress-Cuztom-Helper/" rel="nofollow">these</a> helper classes to create a custom post but wp_query does not return any instances. Checked the source and as far as I can see the public has been set to true.</p>
<p>The query is the following:</p>
<pre><code> $numF... | [
{
"answer_id": 119306,
"author": "HMR",
"author_id": 40616,
"author_profile": "https://wordpress.stackexchange.com/users/40616",
"pm_score": 1,
"selected": false,
"text": "<p>Just spent another hour trying to debug something because the shift key on my keyboard doesn't always work.</p>\n... | 2013/10/18 | [
"https://wordpress.stackexchange.com/questions/119302",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40616/"
] | I am using [these](https://github.com/Gizburdt/Wordpress-Cuztom-Helper/) helper classes to create a custom post but wp\_query does not return any instances. Checked the source and as far as I can see the public has been set to true.
The query is the following:
```
$numFetch=$multiple?100:1;
$args = array( 'posts_... | Just spent another hour trying to debug something because the shift key on my keyboard doesn't always work.
```
post-type != post_type
```
There should be an under score between post and type, not a hyphen. |
119,330 | <p>I imagine this is really simple but I can't work it out. I am trying to add a menu page to the WordPress dashboard through my theme. I have the following...</p>
<pre><code>add_menu_page(
'Test',
'Test',
'manage_options',
'myplugin/myplugin-admin.php',
'',
plugins_url( 'myplugin/image... | [
{
"answer_id": 119332,
"author": "Ivan Hanák",
"author_id": 40545,
"author_profile": "https://wordpress.stackexchange.com/users/40545",
"pm_score": 4,
"selected": true,
"text": "<p>There is not such a function as <code>theme_url</code>, if I am not mistaken.</p>\n\n<p>Take look at <a hre... | 2013/10/18 | [
"https://wordpress.stackexchange.com/questions/119330",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10247/"
] | I imagine this is really simple but I can't work it out. I am trying to add a menu page to the WordPress dashboard through my theme. I have the following...
```
add_menu_page(
'Test',
'Test',
'manage_options',
'myplugin/myplugin-admin.php',
'',
plugins_url( 'myplugin/image/icon.png' ),
... | There is not such a function as `theme_url`, if I am not mistaken.
Take look at [`get_template_directory_uri`](http://codex.wordpress.org/Function_Reference/get_template_directory_uri) or [`get_stylesheet_directory_uri`](http://codex.wordpress.org/Function_Reference/get_stylesheet_directory_uri) |
119,340 | <p>I am trying to add some code to the head (namely a block of tracking script) via a plugin I am making. </p>
<p>The plugin has an interface where the user enters some details which are then added to the options table. This is all working perfectly fine so far. But then I want to write a conditional statement if ther... | [
{
"answer_id": 119342,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 2,
"selected": false,
"text": "<p>Try turning your code around:</p>\n\n<pre><code>function testingone() {\n if( FALSE !== get_option( 'MyOptio... | 2013/10/18 | [
"https://wordpress.stackexchange.com/questions/119340",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19698/"
] | I am trying to add some code to the head (namely a block of tracking script) via a plugin I am making.
The plugin has an interface where the user enters some details which are then added to the options table. This is all working perfectly fine so far. But then I want to write a conditional statement if there is an op... | Pull the `add_action()` outside of the function, and put the conditional inside the callback. Also, if you're printing a script directly, use `wp_print_scripts` instead of `wp_head`. You also have a syntax error.
```
function testingone(){
if( get_option( 'MyOptionName' ) ) {
?>
<script>var Script... |
119,389 | <p>I am using URL rewrite like this page: <a href="https://wordpress.stackexchange.com/questions/69496/unexpected-problem-in-url-rewrite">unexpected problem in url rewrite</a></p>
<p>It works without any problem, but when I try to use the same rules for nested page, it doesn't work. Say, I have two pages named <code>p... | [
{
"answer_id": 119392,
"author": "Jordan Lovato",
"author_id": 38205,
"author_profile": "https://wordpress.stackexchange.com/users/38205",
"pm_score": 0,
"selected": false,
"text": "<p>Okies, so before we begin doing anything with regex besides numbers, lets take a look at all of your pa... | 2013/10/19 | [
"https://wordpress.stackexchange.com/questions/119389",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23214/"
] | I am using URL rewrite like this page: [unexpected problem in url rewrite](https://wordpress.stackexchange.com/questions/69496/unexpected-problem-in-url-rewrite)
It works without any problem, but when I try to use the same rules for nested page, it doesn't work. Say, I have two pages named `page-a` and `page-b`. `page... | I have found my answer while searching. Thanks to this answer of @Milo: <https://wordpress.stackexchange.com/a/50775/23214>
`pagename` must include the full parent/child path. So, I had to change `index.php?pagename=page-b...` to `index.php?pagename=page-a/page-b...`. Changed it and works ok.
Here is the Full code:
... |
119,390 | <p>I am a newbie at WordPress. In my "recent posts" shortcode, I used <code>global $post</code> variable, because <code>the_title()</code> function was giving me page's title, not post's title. I am not exactly sure, but I thought that's because of loop inside of a loop. </p>
<p>Some advanced users here tell me not to... | [
{
"answer_id": 119391,
"author": "random_user_name",
"author_id": 11704,
"author_profile": "https://wordpress.stackexchange.com/users/11704",
"pm_score": 2,
"selected": false,
"text": "<p>The disadvantage is that <code>global $post</code> can give you unexpected results, unless you are c... | 2013/10/19 | [
"https://wordpress.stackexchange.com/questions/119390",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40607/"
] | I am a newbie at WordPress. In my "recent posts" shortcode, I used `global $post` variable, because `the_title()` function was giving me page's title, not post's title. I am not exactly sure, but I thought that's because of loop inside of a loop.
Some advanced users here tell me not to use `global` variable, so using... | The `global` variable `$post` will be set to the first post in the main query. When any Loop runs (assuming it is constructed correctly), whether the main Loop or any number of secondary ones, `$post` will be set to each post in that/those loops in turn. At the end of the Loop, it will be set to the the last post in th... |
119,393 | <p>I'm using Disqus for my blog comments, and Google Analytics for tracking users. I have both implemented using plugins (Disqus Comment System and Google Analyticator). I'd like to track comments, but I can't figure out how to do that.</p>
<p>I have researched the problem, and there's some documentation for it, but i... | [
{
"answer_id": 119394,
"author": "Ram Ratan Maurya",
"author_id": 24756,
"author_profile": "https://wordpress.stackexchange.com/users/24756",
"pm_score": 2,
"selected": true,
"text": "<p>You can use that snippet just anywhere where it can be rendered on single pages. For example, you can... | 2013/10/19 | [
"https://wordpress.stackexchange.com/questions/119393",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40644/"
] | I'm using Disqus for my blog comments, and Google Analytics for tracking users. I have both implemented using plugins (Disqus Comment System and Google Analyticator). I'd like to track comments, but I can't figure out how to do that.
I have researched the problem, and there's some documentation for it, but it's not ve... | You can use that snippet just anywhere where it can be rendered on single pages. For example, you can paste this under functions.php of your theme:
```
function hook_disqus_config(){
if( ! is_singular() ) return;
?>
<script type="text/javascript">
function disqus_config() {
this.callbacks.onNewComment = ... |
119,412 | <p>I am developing a theme where I would like to have a front-end area, but when I
try to include the <code>wp_editor()</code> in the page template I am getting this result:</p>
<p><img src="https://i.stack.imgur.com/xW4PO.png" alt="wp_editor() problem"></p>
<p>P.S.
The wordpress editor works fine in the dashboard.<... | [
{
"answer_id": 119435,
"author": "josh",
"author_id": 24323,
"author_profile": "https://wordpress.stackexchange.com/users/24323",
"pm_score": 2,
"selected": false,
"text": "<p>You need to first define the <code>$settings</code> and the <code>$editor_id</code> and the <code>$content</code... | 2013/10/19 | [
"https://wordpress.stackexchange.com/questions/119412",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40650/"
] | I am developing a theme where I would like to have a front-end area, but when I
try to include the `wp_editor()` in the page template I am getting this result:

P.S.
The wordpress editor works fine in the dashboard.
`.
Something like this should work for you:
```
// default settings
$content = 'This content gets loaded first.';
$editor_id = 'my_frontend_editor';
$settings = array(
'wpautop' => true, // ... |
119,414 | <p>Am developing a WordPress site. My site footer having a link to navigate RSS Feed URL. This URL is generated using <code><?php bloginfo('rss2_url'); ?></code> and it correctly generating the URL like <code>mysite.com/?feed=rss2</code> but this link is not working from home page. Showing page not found when i t... | [
{
"answer_id": 119435,
"author": "josh",
"author_id": 24323,
"author_profile": "https://wordpress.stackexchange.com/users/24323",
"pm_score": 2,
"selected": false,
"text": "<p>You need to first define the <code>$settings</code> and the <code>$editor_id</code> and the <code>$content</code... | 2013/10/19 | [
"https://wordpress.stackexchange.com/questions/119414",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17931/"
] | Am developing a WordPress site. My site footer having a link to navigate RSS Feed URL. This URL is generated using `<?php bloginfo('rss2_url'); ?>` and it correctly generating the URL like `mysite.com/?feed=rss2` but this link is not working from home page. Showing page not found when i try to access it from home page.... | You need to first define the `$settings` and the `$editor_id` and the `$content` variables. Then you can call `wp_editor()`.
Something like this should work for you:
```
// default settings
$content = 'This content gets loaded first.';
$editor_id = 'my_frontend_editor';
$settings = array(
'wpautop' => true, // ... |
119,433 | <p>It's possible to make a site totally inaccessible via feeds (RSS, Atom, RDF) with a function like this:</p>
<pre><code>function itsme_disable_feed() {
wp_die( __( 'No feed available, please visit the <a href="'. esc_url( home_url( '/' ) ) .'">homepage</a>!' ) );
}
add_action('do_feed', 'itsme_disabl... | [
{
"answer_id": 119437,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>Very, very quick unscientific research suggests that there is only one <code>query_var</code> set for the mai... | 2013/10/19 | [
"https://wordpress.stackexchange.com/questions/119433",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10691/"
] | It's possible to make a site totally inaccessible via feeds (RSS, Atom, RDF) with a function like this:
```
function itsme_disable_feed() {
wp_die( __( 'No feed available, please visit the <a href="'. esc_url( home_url( '/' ) ) .'">homepage</a>!' ) );
}
add_action('do_feed', 'itsme_disable_feed', 1);
add_action('d... | Very, very quick unscientific research suggests that there is only one `query_var` set for the main feed. Other feeds such as category, tag, author feeds have more than one `query_var`. Thus the following should kill the main feed but leave others intact.
```
add_filter(
'pre_get_posts',
function($qry) {
if ... |
119,445 | <p>I'm trying to pass a wordpress plugin some form data via ajax and it works just fine, unless the form data is serialized, then the server responds with an error message.
I'm stuck with this for days now, but I can't get it to work.
What am I doing wrong, this can't be so hard, right?</p>
<p>Here's the error message... | [
{
"answer_id": 119447,
"author": "josh",
"author_id": 24323,
"author_profile": "https://wordpress.stackexchange.com/users/24323",
"pm_score": 0,
"selected": false,
"text": "<p>Why are you using <code>jQuery.ajax</code>? </p>\n\n<p>When you define <code>jQuery(document).ready(function($)... | 2013/10/19 | [
"https://wordpress.stackexchange.com/questions/119445",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40663/"
] | I'm trying to pass a wordpress plugin some form data via ajax and it works just fine, unless the form data is serialized, then the server responds with an error message.
I'm stuck with this for days now, but I can't get it to work.
What am I doing wrong, this can't be so hard, right?
Here's the error message:
>
> ca... | When working with AJAX and Forms in WordPress I like to code in the ajax action to the form so serialize works out of the box. Actually I wrote an article on this last year: <https://webdevstudios.com/2015/02/12/handling-ajax-in-wordpress/>
But, you're here for answers, not a blog article, so here's the brief part of ... |
119,452 | <p>Supposing that I have two domains in my theme named "basic" and "advance".</p>
<p>Is it possible to load two different domains in my theme?</p>
<pre><code>load_theme_textdomain( 'basic', TEMPLATEPATH.'/languages' );
load_theme_textdomain( 'advance', TEMPLATEPATH.'/languages' );
</code></pre>
| [
{
"answer_id": 119454,
"author": "josh",
"author_id": 24323,
"author_profile": "https://wordpress.stackexchange.com/users/24323",
"pm_score": 2,
"selected": false,
"text": "<p>You certainly can.. however, you cannot use two separate language translations on a single text string.</p>\n\n<... | 2013/10/20 | [
"https://wordpress.stackexchange.com/questions/119452",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28340/"
] | Supposing that I have two domains in my theme named "basic" and "advance".
Is it possible to load two different domains in my theme?
```
load_theme_textdomain( 'basic', TEMPLATEPATH.'/languages' );
load_theme_textdomain( 'advance', TEMPLATEPATH.'/languages' );
``` | Note that if you put your mo-files inside your theme’s directory, **the same mo-file will be loaded for every theme textdomain**. That is because a theme mo-file is based solely on the locale. For example:
```
load_theme_textdomain( 'basic', get_template_directory() . '/languages' );
load_theme_textdomain( 'advance', ... |
119,466 | <p>I want to program the <strong>Add to Cart</strong> button, on a product page, so when the customer press on it, it skips the <strong>Cart</strong> & <strong>Checkout</strong> pages and send him directly to the PayPal payment gateway. </p>
<p>Not spending time on the Cart page, nor filling details on the Checkou... | [
{
"answer_id": 119481,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 2,
"selected": false,
"text": "<p>A solution can be found in the function <a href=\"http://docs.woothemes.com/wc-apidocs/source-function-wooc... | 2013/10/20 | [
"https://wordpress.stackexchange.com/questions/119466",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40673/"
] | I want to program the **Add to Cart** button, on a product page, so when the customer press on it, it skips the **Cart** & **Checkout** pages and send him directly to the PayPal payment gateway.
Not spending time on the Cart page, nor filling details on the Checkout page.
How can I do this? | A solution can be found in the function [`woocommerce_add_to_cart_action`](http://docs.woothemes.com/wc-apidocs/source-function-woocommerce_add_to_cart_action.html#283-462). We have to chain two filters. In the first, we check for the product ID, if it's one of a list we add the redirect.
```
add_action( 'woocommerce_... |
119,467 | <p>I'm developing my new theme using <a href="https://github.com/justintadlock/hybrid-core" rel="nofollow">Hybrid core framework</a>
and trying to add my class <code>item</code> on <code>hybrid_post_attributes</code> generated class using filter with this code. </p>
<pre><code>add_filter( 'hybrid_post_attributes', '... | [
{
"answer_id": 119473,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>For your filter to work, the Hybrid Core code would have to run something like <code>$abcd = apply_filters('... | 2013/10/20 | [
"https://wordpress.stackexchange.com/questions/119467",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40671/"
] | I'm developing my new theme using [Hybrid core framework](https://github.com/justintadlock/hybrid-core)
and trying to add my class `item` on `hybrid_post_attributes` generated class using filter with this code.
```
add_filter( 'hybrid_post_attributes', 'my_post_atributes');
function my_post_atributes($attributes){
re... | For your filter to work, the Hybrid Core code would have to run something like `$abcd = apply_filters('hybrid_post_attributes',$something);` and I don't see that in the code you posted. In fact, I don't see `apply_filters` anywhere at all. Based entirely on that posted code, you can't filter those items.
I don't thin... |
119,482 | <p>I'm using this code in my plugin to add an extra field to the user profiles so that the user can upload an image. It uploads the file perfectly but the only problem is the part that has to delete the previous uploaded image doesn't work.</p>
<p>This is my code:</p>
<pre><code><?php
add_action( 'show_user_profi... | [
{
"answer_id": 119535,
"author": "aminb5",
"author_id": 39353,
"author_profile": "https://wordpress.stackexchange.com/users/39353",
"pm_score": 1,
"selected": true,
"text": "<p>I figured it out! the problem is the path is not right! Thanks to this post : Alow users to delete uploaded ima... | 2013/10/20 | [
"https://wordpress.stackexchange.com/questions/119482",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39353/"
] | I'm using this code in my plugin to add an extra field to the user profiles so that the user can upload an image. It uploads the file perfectly but the only problem is the part that has to delete the previous uploaded image doesn't work.
This is my code:
```
<?php
add_action( 'show_user_profile', 'my_show_extra_prof... | I figured it out! the problem is the path is not right! Thanks to this post : Alow users to delete uploaded images inside backend?
this function below helped :
```
function url_to_path_test($url){
$url=str_replace(rtrim(get_site_url(),'/').'/', ABSPATH, $url);
return $url;
}
```
So in my code if you chan... |
119,493 | <p>I have following situation. I have a WP Multisite installed in subdirectory:</p>
<pre><code>my-domain.com/subfolder/wp-multisite-root
</code></pre>
<p>Now normally next sites added would be created like that</p>
<pre><code>my-domain.com/subfolder/wp-multisite-root
my-domain.com/subfolder/wp-multisite-root/site1
m... | [
{
"answer_id": 119494,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 1,
"selected": false,
"text": "<p>The simplest solution is to make <code>my-domain/subfolder/</code> the WordPress install directory and bas... | 2013/10/20 | [
"https://wordpress.stackexchange.com/questions/119493",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25348/"
] | I have following situation. I have a WP Multisite installed in subdirectory:
```
my-domain.com/subfolder/wp-multisite-root
```
Now normally next sites added would be created like that
```
my-domain.com/subfolder/wp-multisite-root
my-domain.com/subfolder/wp-multisite-root/site1
my-domain.com/subfolder/wp-multisite-r... | After these years I hope this will still answer your question...
I think I've got the situation working you want.
Allthough I don't have the Wordpress installation in '/subfolder/', but I've a installation 'in subdirectory' per language, and on the same level:
```
my-domain.com/nl/ -> this is primary installation, s... |
119,495 | <p>I have noticed that in the <code><html></code> tag on my WP site that the language is defined as US English. </p>
<pre><code><html lang="en-US" prefix="og: http://ogp.me/ns#">
</code></pre>
<p>I would like to change it to British English <code>en-GB</code> but I'm not sure of the best way. </p>
<p>I d... | [
{
"answer_id": 119496,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 5,
"selected": true,
"text": "<p>The value for that string is normally taken from the option <code>WPLANG</code> in your database table <code>$prefix_o... | 2013/10/20 | [
"https://wordpress.stackexchange.com/questions/119495",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37686/"
] | I have noticed that in the `<html>` tag on my WP site that the language is defined as US English.
```
<html lang="en-US" prefix="og: http://ogp.me/ns#">
```
I would like to change it to British English `en-GB` but I'm not sure of the best way.
I dug around and found `language_attributes()` in `general-template.ph... | The value for that string is normally taken from the option `WPLANG` in your database table `$prefix_options`. You can set it in the backend under *Settings/General* (`wp-admin/options-general.php`) or per SQL.
There several ways to change that value per PHP:
1. Create a global variable `$locale` in your `wp-config.p... |
119,507 | <p>I've got a page with a blogroll in the left column and a sidbar in the right one. When I try to retrieve the page-id inside of the sidebar like:</p>
<pre><code>echo $post->ID;
echo get_the_ID();
</code></pre>
<p>The result is <strong>3726</strong> but the page URI is <strong>page_id=3722</strong> ! I'm really c... | [
{
"answer_id": 119586,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>There are two ways to get what you need. One is mentioned in <a href=\"https://wordpress.stackexchange.com/questions/... | 2013/10/20 | [
"https://wordpress.stackexchange.com/questions/119507",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40655/"
] | I've got a page with a blogroll in the left column and a sidbar in the right one. When I try to retrieve the page-id inside of the sidebar like:
```
echo $post->ID;
echo get_the_ID();
```
The result is **3726** but the page URI is **page\_id=3722** ! I'm really confused now. I badly have to catch the real page id to... | There are two ways to get what you need. One is mentioned in [Identify the page being shown while in The Loop](https://wordpress.stackexchange.com/questions/99534/identify-the-page-being-shown-while-in-the-loop):
```
$post_id = get_queried_object_id();
```
Unfortunately, this might break. `get_queried_object_id()` l... |
119,512 | <p>The question sounds weird i know, but what i'm trying to do is add a gravity form into a template that i made.</p>
<p>But all of their tutorials seem to be more along the lines of adding a form to a page and not so much to a template.</p>
<p>So the idea was to use a get_content() from a specific Page that i create... | [
{
"answer_id": 119515,
"author": "SeekingCharlie",
"author_id": 31168,
"author_profile": "https://wordpress.stackexchange.com/users/31168",
"pm_score": 2,
"selected": true,
"text": "<p>You can just put something like the following into your template file where you want the form to appear... | 2013/10/20 | [
"https://wordpress.stackexchange.com/questions/119512",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35567/"
] | The question sounds weird i know, but what i'm trying to do is add a gravity form into a template that i made.
But all of their tutorials seem to be more along the lines of adding a form to a page and not so much to a template.
So the idea was to use a get\_content() from a specific Page that i created (called "Form"... | You can just put something like the following into your template file where you want the form to appear (example of a form called Contact Us):
```
gravity_form('Contact Us', false, false, false, '', false);
```
For more info on the false etc, see here: <http://www.gravityhelp.com/documentation/page/Embedding_A_Form> |
119,526 | <p>I've got this code below working to create a default menu. I was wondering how I would create sub-items/subpages... </p>
<pre><code>// Check if the menu exists
$menu_exists = wp_get_nav_menu_object('Main Menu');
// If it doesn't exist, let's create it.
if( !$menu_exists){
$menu_id = wp_create_nav_menu('Main Me... | [
{
"answer_id": 119578,
"author": "cfgm",
"author_id": 39200,
"author_profile": "https://wordpress.stackexchange.com/users/39200",
"pm_score": -1,
"selected": false,
"text": "<p>Are you using one of the default themes or something similar? You normally organise sub-pages by setting the 'P... | 2013/10/21 | [
"https://wordpress.stackexchange.com/questions/119526",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38850/"
] | I've got this code below working to create a default menu. I was wondering how I would create sub-items/subpages...
```
// Check if the menu exists
$menu_exists = wp_get_nav_menu_object('Main Menu');
// If it doesn't exist, let's create it.
if( !$menu_exists){
$menu_id = wp_create_nav_menu('Main Menu');
// Se... | I was also doing the same thing check out this question Hope this will help you .
[Menu page Exists or not](https://wordpress.stackexchange.com/questions/119281/check-if-add-menu-page-exists-or-not) |
119,527 | <p>I'm trying to display a list of 5 authors <strong>randomly</strong>. Here are some solutions I had found:</p>
<p><a href="https://stackoverflow.com/questions/5502609/get-authors-randomly">https://stackoverflow.com/questions/5502609/get-authors-randomly</a>
<a href="https://wordpress.stackexchange.com/a/91326/1044">... | [
{
"answer_id": 119578,
"author": "cfgm",
"author_id": 39200,
"author_profile": "https://wordpress.stackexchange.com/users/39200",
"pm_score": -1,
"selected": false,
"text": "<p>Are you using one of the default themes or something similar? You normally organise sub-pages by setting the 'P... | 2013/10/21 | [
"https://wordpress.stackexchange.com/questions/119527",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1044/"
] | I'm trying to display a list of 5 authors **randomly**. Here are some solutions I had found:
<https://stackoverflow.com/questions/5502609/get-authors-randomly>
<https://wordpress.stackexchange.com/a/91326/1044>
I'm currently using the former solution except that I use `WP_User_Query` like so:
```
$args = array(
... | I was also doing the same thing check out this question Hope this will help you .
[Menu page Exists or not](https://wordpress.stackexchange.com/questions/119281/check-if-add-menu-page-exists-or-not) |
119,538 | <p>I have several inputboxes and no textareas in my custom content type. Can I use Akismet that comes with WP for that? If I can, how to do that?</p>
<p>E.g. If I have 5 inputboxes like: name, address, city, telephone, email in my form that is saved from the front page and is used for further processing.</p>
<p>How t... | [
{
"answer_id": 119817,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": false,
"text": "<h2>Akismet - libraries:</h2>\n\n<p>First I want to mention that there are many <em>Akismet</em> libraries out t... | 2013/10/21 | [
"https://wordpress.stackexchange.com/questions/119538",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17368/"
] | I have several inputboxes and no textareas in my custom content type. Can I use Akismet that comes with WP for that? If I can, how to do that?
E.g. If I have 5 inputboxes like: name, address, city, telephone, email in my form that is saved from the front page and is used for further processing.
How to use Akismet on ... | Akismet - libraries:
--------------------
First I want to mention that there are many *Akismet* libraries out there:
<http://akismet.com/development/>
and here are the API documents:
<http://akismet.com/development/api/>
Akismet - WordPress plugin:
---------------------------
But as I understand it, you want to u... |
119,558 | <p>I'd like to display some CSS only for <a href="http://www.piedmontpool.com/events" rel="nofollow">this page</a>.</p>
<p>In the theme's header.php, I have tried both:</p>
<pre><code><?php if(is_page('events')) { ?>
<style>
#main {
background-image: none;
}
</style>
<?php } ?>
</code>... | [
{
"answer_id": 119562,
"author": "Kaushik Kishore",
"author_id": 40580,
"author_profile": "https://wordpress.stackexchange.com/users/40580",
"pm_score": 1,
"selected": false,
"text": "<p>You can use. <code>get_the_ID()</code> function to getting the id of the page or the post. then write... | 2013/10/21 | [
"https://wordpress.stackexchange.com/questions/119558",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3206/"
] | I'd like to display some CSS only for [this page](http://www.piedmontpool.com/events).
In the theme's header.php, I have tried both:
```
<?php if(is_page('events')) { ?>
<style>
#main {
background-image: none;
}
</style>
<?php } ?>
```
and
```
<?php if(is_page(43)) { ?>
<style>
#main {
background-ima... | instead of echoing your styles anywhere, you can hook your code at wp\_head to add it in head or wp\_footer to add it in your footer, see if it works for you,
```
function my_custom_style(){
global $post;
if ( !empty ( $post->post_name ) && $post->post_name == 'events' ){ ?>
<style type="text/css">
... |
119,559 | <p>I have many pages in my wp installation. All I want is to be able to display the excerpt of any page, also on any page (before more tag). How do I go about it?</p>
<p>I was fetching the content of the current (front) page through this code:</p>
<pre><code>global $more;
$temp = $more;
$more = false;
echo get_the_co... | [
{
"answer_id": 119582,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>The content is manipulated by the <a href=\"http://core.trac.wordpress.org/browser/tags/3.6.1/wp-includes/pos... | 2013/10/21 | [
"https://wordpress.stackexchange.com/questions/119559",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38598/"
] | I have many pages in my wp installation. All I want is to be able to display the excerpt of any page, also on any page (before more tag). How do I go about it?
I was fetching the content of the current (front) page through this code:
```
global $more;
$temp = $more;
$more = false;
echo get_the_content( '' );
$more = ... | The content is manipulated by the [`get_the_content` function](http://core.trac.wordpress.org/browser/tags/3.6.1/wp-includes/post-template.php#L180), and that function always assumes the current post in the Loop. You can't pass it an ID, strangely.
The easiest way to get just the bit before the more for an arbitrary ... |
119,560 | <p>I want the start page to be editable from a template. At the moment I can only edit the content by directly editing the HTML.</p>
<p>Setup:</p>
<ul>
<li>Settings » Read » "Front page displays Your latest posts"</li>
<li>The template that shows in the startpage is <code>index.php</code></li>
</ul>
<p>I... | [
{
"answer_id": 119563,
"author": "onetrickpony",
"author_id": 1986,
"author_profile": "https://wordpress.stackexchange.com/users/1986",
"pm_score": -1,
"selected": false,
"text": "<p>Rename it to <code>front-page.php</code>. That one is loaded on the home page before attempting to load <... | 2013/10/21 | [
"https://wordpress.stackexchange.com/questions/119560",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38804/"
] | I want the start page to be editable from a template. At the moment I can only edit the content by directly editing the HTML.
Setup:
* Settings » Read » "Front page displays Your latest posts"
* The template that shows in the startpage is `index.php`
I want to be able to create a page edited from the Pages list that... | If you are editing a theme or you are having a child theme, You can make your own custom template, give it a name Include header and footer in it using
```
<?php
/**
* Template Name: Home Page
*
* Home page Layout
*/
get_header(); ?>
<!-- Do whateveer you want here -->
get_footer(); ?>
```
When you crea... |
119,565 | <p>I am trying to fetch from the WP database posts with two meta_key values, but the result is <code>0</code> posts.</p>
<p>Print out of the arguments:</p>
<pre><code>Array (
[taxonomy] => cardstax
[term] => christmas
[post_type] => cards
[paged] => 1
[caller_get_posts] => 1
... | [
{
"answer_id": 119620,
"author": "jam",
"author_id": 5878,
"author_profile": "https://wordpress.stackexchange.com/users/5878",
"pm_score": -1,
"selected": false,
"text": "<p>Changed DECIMAL and NUMERIC to CHAR and it worked out.</p>\n"
},
{
"answer_id": 119636,
"author": "Ott... | 2013/10/21 | [
"https://wordpress.stackexchange.com/questions/119565",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5878/"
] | I am trying to fetch from the WP database posts with two meta\_key values, but the result is `0` posts.
Print out of the arguments:
```
Array (
[taxonomy] => cardstax
[term] => christmas
[post_type] => cards
[paged] => 1
[caller_get_posts] => 1
[meta_query] => Array (
[relation]... | Remove the quotes around the values for your second meta query. You're comparing numbers to chars, which won't work. |
119,573 | <p>Can we somehow use wp_localize_script() to create global js variables without a specific script handle which can be accessed from all the js files, even if the js scripts are not enqueued properly by using wp_enqueue_script ?</p>
<p>This is the code I am using which creates varibale for 'ajaxscript' handle, so I ca... | [
{
"answer_id": 119575,
"author": "Kumar",
"author_id": 32466,
"author_profile": "https://wordpress.stackexchange.com/users/32466",
"pm_score": 6,
"selected": true,
"text": "<p>Instead of using wp_localize_script in that case, you can hook your js variables at wp_head, that way it would b... | 2013/10/21 | [
"https://wordpress.stackexchange.com/questions/119573",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13615/"
] | Can we somehow use wp\_localize\_script() to create global js variables without a specific script handle which can be accessed from all the js files, even if the js scripts are not enqueued properly by using wp\_enqueue\_script ?
This is the code I am using which creates varibale for 'ajaxscript' handle, so I cant acc... | Instead of using wp\_localize\_script in that case, you can hook your js variables at wp\_head, that way it would be available to all js files
like:
```
function my_js_variables(){ ?>
<script type="text/javascript">
var ajaxurl = '<?php echo admin_url( "admin-ajax.php" ); ?>';
var ajaxnonce = '<?... |
119,599 | <p>So, my cousin owns a fashion blog and she recently had a fall out with a brand of shoes and she wants to remove all the links on all posts that point to the brand website.</p>
<p>So, is there a way I can automatically via SQL commands or maybe a plugin check all posts on the blog and turn links like this:</p>
<pre... | [
{
"answer_id": 119602,
"author": "Kumar",
"author_id": 32466,
"author_profile": "https://wordpress.stackexchange.com/users/32466",
"pm_score": 2,
"selected": false,
"text": "<p>There is no plugin to remove anchor tags with that url ( atleast I don't know any ), but you can replace the ur... | 2013/10/21 | [
"https://wordpress.stackexchange.com/questions/119599",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20683/"
] | So, my cousin owns a fashion blog and she recently had a fall out with a brand of shoes and she wants to remove all the links on all posts that point to the brand website.
So, is there a way I can automatically via SQL commands or maybe a plugin check all posts on the blog and turn links like this:
```
<p style="text... | You can use the [Search Regex](http://wordpress.org/plugins/search-regex/) plugin. This will allow you to create a regular expression to intelligently search and replace across all of your posts.
After you activate the plugin, go to Tools, Search Regex. If you want to remove all links to `http://example.com`, here is ... |
119,611 | <p>I do not have access to <em>"wp-includes/admin-bar.php"</em> due to security restrictions placed by my host, they have advised me to use css stylesheets which I am not familiar with.</p>
<p>I am looking to add a left and right sided margin to the links (login/register/sign out etc) in the admin bar so they align wi... | [
{
"answer_id": 119602,
"author": "Kumar",
"author_id": 32466,
"author_profile": "https://wordpress.stackexchange.com/users/32466",
"pm_score": 2,
"selected": false,
"text": "<p>There is no plugin to remove anchor tags with that url ( atleast I don't know any ), but you can replace the ur... | 2013/10/21 | [
"https://wordpress.stackexchange.com/questions/119611",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40612/"
] | I do not have access to *"wp-includes/admin-bar.php"* due to security restrictions placed by my host, they have advised me to use css stylesheets which I am not familiar with.
I am looking to add a left and right sided margin to the links (login/register/sign out etc) in the admin bar so they align with the main conte... | You can use the [Search Regex](http://wordpress.org/plugins/search-regex/) plugin. This will allow you to create a regular expression to intelligently search and replace across all of your posts.
After you activate the plugin, go to Tools, Search Regex. If you want to remove all links to `http://example.com`, here is ... |
119,617 | <p>I have using the Wordpress <code>paginate_links()</code> to build a paginator on a custom archive template for a custom post type. My site uses permalinks:</p>
<pre><code><?php echo paginate_links(array(
'base' => get_pagenum_link(1) . '%_%',
'current' => max(1, get_query_var('paged')),
'format... | [
{
"answer_id": 119663,
"author": "benedict_w",
"author_id": 19475,
"author_profile": "https://wordpress.stackexchange.com/users/19475",
"pm_score": 4,
"selected": true,
"text": "<p>Seems that the query string is coming from the base argument call to <code>get_pagenum_link()</code> so I h... | 2013/10/21 | [
"https://wordpress.stackexchange.com/questions/119617",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19475/"
] | I have using the Wordpress `paginate_links()` to build a paginator on a custom archive template for a custom post type. My site uses permalinks:
```
<?php echo paginate_links(array(
'base' => get_pagenum_link(1) . '%_%',
'current' => max(1, get_query_var('paged')),
'format' => 'page/%#%',
'total' => $w... | Seems that the query string is coming from the base argument call to `get_pagenum_link()` so I have removed the query string component and re-add it with 'add\_args'. Like so:
```
<?php echo paginate_links(array(
'base' => preg_replace('/\?.*/', '/', get_pagenum_link(1)) . '%_%',
'current' => max(1, get_quer... |
119,630 | <pre><code> function rpm_pre_get_post($query){
if($query->is_main_query()){
$query->set('meta_key', 'parent-project');
$query->set('meta_value', 'Metro-E');
}
}
add_action( 'pre_get_posts', 'rpm_pre_get_post', 9999 );
</code></pre>
<p>That should effectively pull back al... | [
{
"answer_id": 119633,
"author": "tatemz",
"author_id": 32212,
"author_profile": "https://wordpress.stackexchange.com/users/32212",
"pm_score": 2,
"selected": false,
"text": "<p>Perhaps you should try this:</p>\n\n<pre><code>function rpm_pre_get_post($query){\n if($query->is_main_qu... | 2013/10/21 | [
"https://wordpress.stackexchange.com/questions/119630",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22983/"
] | ```
function rpm_pre_get_post($query){
if($query->is_main_query()){
$query->set('meta_key', 'parent-project');
$query->set('meta_value', 'Metro-E');
}
}
add_action( 'pre_get_posts', 'rpm_pre_get_post', 9999 );
```
That should effectively pull back all posts that have the key 'p... | There was an issue caused by so search filtering I was doing. I removed that code and everything was good. |
119,648 | <p>I have the following div in my <code>post</code>,</p>
<pre><code><div class="my_calss" id="my_id">
my content
</div>
</code></pre>
<p>Here, <strong>my_id</strong> is different for each post. </p>
<p>I need to display <code>my_id</code> in sidebar into php code. That means,</p>
<pre><code><?php... | [
{
"answer_id": 119633,
"author": "tatemz",
"author_id": 32212,
"author_profile": "https://wordpress.stackexchange.com/users/32212",
"pm_score": 2,
"selected": false,
"text": "<p>Perhaps you should try this:</p>\n\n<pre><code>function rpm_pre_get_post($query){\n if($query->is_main_qu... | 2013/10/22 | [
"https://wordpress.stackexchange.com/questions/119648",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28533/"
] | I have the following div in my `post`,
```
<div class="my_calss" id="my_id">
my content
</div>
```
Here, **my\_id** is different for each post.
I need to display `my_id` in sidebar into php code. That means,
```
<?php echo do_shortcode('[wp_value id=1]'); ?>
```
need to assign the above id.
I explained thi... | There was an issue caused by so search filtering I was doing. I removed that code and everything was good. |
119,673 | <p>I am going to try and sum up what I am trying to achieve...</p>
<p>Basically I have a custom post type called 'marketing_list' which will have custom fields holding information relating to marketing lists available for purchase.</p>
<p>Each marketing list will belong to a category (custom taxonomy).</p>
<p>So cur... | [
{
"answer_id": 119682,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 0,
"selected": false,
"text": "<p>The problematic part of permalink structure you asking for is for permalinks like</p>\n\n<pre><code>/marketin... | 2013/10/22 | [
"https://wordpress.stackexchange.com/questions/119673",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39159/"
] | I am going to try and sum up what I am trying to achieve...
Basically I have a custom post type called 'marketing\_list' which will have custom fields holding information relating to marketing lists available for purchase.
Each marketing list will belong to a category (custom taxonomy).
So currently my URL's look li... | The bulk of your question is fairly easy and has been covered here many times before. I also gave a talk at WordCamp Portland on the topic, which you can [watch, download slides, code, etc. here](http://boyn.es/2013/08/10/wcpdx/).
The last part of your question,
>
> On top of that I would like to create some additio... |
119,693 | <p>I has been completed a theme for a client. I Used to access the live wp-admin page using</p>
<p><strong><a href="http://name.myname.com/wp-login.php" rel="nofollow">http://name.myname.com/wp-login.php</a></strong></p>
<p>But that page shows just a blank(white) page. How to get fix that?</p>
<p>Note: Their hostin... | [
{
"answer_id": 119698,
"author": "Philip Benton",
"author_id": 39159,
"author_profile": "https://wordpress.stackexchange.com/users/39159",
"pm_score": 3,
"selected": true,
"text": "<p>What does the content of <code>theme name/include/widget.php</code> ?</p>\n\n<p>The error is pointing to... | 2013/10/22 | [
"https://wordpress.stackexchange.com/questions/119693",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38263/"
] | I has been completed a theme for a client. I Used to access the live wp-admin page using
**<http://name.myname.com/wp-login.php>**
But that page shows just a blank(white) page. How to get fix that?
Note: Their hosting provider is supporting wordpress.
The error now generating is:
```
Parse error: syntax error, une... | What does the content of `theme name/include/widget.php` ?
The error is pointing to line 1 and telling you it did not expect to see `?>` there.
My guess (without seeing the file) is you have closed a php tag instead of opened it. |
119,694 | <p>I would love to customized and dumb down my dashboard with custom icons, shortcuts, guides, etc. I can do this already using widgets, but I would like to dare and do something better.</p>
<p>wp_welcome_panel on this regard, is awesome: I can customized it, I can make it show whatever I want but... only administrato... | [
{
"answer_id": 119703,
"author": "Oleg Butuzov",
"author_id": 14536,
"author_profile": "https://wordpress.stackexchange.com/users/14536",
"pm_score": 2,
"selected": false,
"text": "<p>There are two ways to do that.</p>\n\n<p>You can (a) Edit capability from <code>edit_theme_options</code... | 2013/10/22 | [
"https://wordpress.stackexchange.com/questions/119694",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16281/"
] | I would love to customized and dumb down my dashboard with custom icons, shortcuts, guides, etc. I can do this already using widgets, but I would like to dare and do something better.
wp\_welcome\_panel on this regard, is awesome: I can customized it, I can make it show whatever I want but... only administrators can s... | Where is the "Welcome Panel"?
-----------------------------
The Wordpress dashboard (which houses the "Welcome Panel") basically is the
```
~/wp-admin/index.php
```
When does it show?
------------------
As you can see when looking at the [source](https://github.com/WordPress/WordPress/blob/master/wp-admin/index.ph... |
119,719 | <p>I have three custom <code>'location'</code> post types which make up a hierarchy of areas:</p>
<pre><code>location1, location2, location3.
</code></pre>
<p><code>location1</code> is the top level and then <code>location2</code> and <code>location3</code> are childeren of each other. For example, <code>location1</c... | [
{
"answer_id": 119722,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<h2>Doing it different</h2>\n\n<p>Your problem mainly is a <a href=\"https://meta.stackexchange.com/questions/66377/w... | 2013/10/22 | [
"https://wordpress.stackexchange.com/questions/119719",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37054/"
] | I have three custom `'location'` post types which make up a hierarchy of areas:
```
location1, location2, location3.
```
`location1` is the top level and then `location2` and `location3` are childeren of each other. For example, `location1` might be Buildings, `location2` `Floors`, and `location3` Rooms.
`location2... | It seems that you are looking to accomplish is a simple parent/child relationship with \*n levels. I ran into something similar when working on subordinate posts <https://github.com/codearachnid/wp-subordinate-post>. The way I resolved the hierarchy (and even allowed for deep permalinking was to utilize the **post\_par... |
119,738 | <p>When I insert a post I've found that there is a slow call to wp_unique_post_slug from within insert_post (In the database I'm using to test there is 155,000 posts - live would have considerably more). As I don't believe a slug is important for what I'm doing (a person who is browsing our site will probably never see... | [
{
"answer_id": 119742,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<h2>Source inspection -> Abort cases</h2>\n\n<p>When you look at the source of <a href=\"https://github.com/WordPress... | 2013/10/22 | [
"https://wordpress.stackexchange.com/questions/119738",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9519/"
] | When I insert a post I've found that there is a slow call to wp\_unique\_post\_slug from within insert\_post (In the database I'm using to test there is 155,000 posts - live would have considerably more). As I don't believe a slug is important for what I'm doing (a person who is browsing our site will probably never se... | I know this is really old question, but today I was dealing with something similar, and I have found a solution - if `wp_unique_post_slug()` calling is performance bottleneck, and `post_name` value is not important, then **set post\_name manualy to some random value**.
My `wp_insert_post` post action was taking too lo... |
119,774 | <p>I am using a multisite WordPress install to manage several blogs for our different shops, the current set up looks something like this:</p>
<pre><code>http://mydomain.com/blogs/shop1/
http://mydomain.com/blogs/shop2/
http://mydomain.com/blogs/shop3/
...
http://mydomain.com/blogs/
</code></pre>
<p>When setting up W... | [
{
"answer_id": 119742,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<h2>Source inspection -> Abort cases</h2>\n\n<p>When you look at the source of <a href=\"https://github.com/WordPress... | 2013/10/23 | [
"https://wordpress.stackexchange.com/questions/119774",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40790/"
] | I am using a multisite WordPress install to manage several blogs for our different shops, the current set up looks something like this:
```
http://mydomain.com/blogs/shop1/
http://mydomain.com/blogs/shop2/
http://mydomain.com/blogs/shop3/
...
http://mydomain.com/blogs/
```
When setting up WordPress I set the base ur... | I know this is really old question, but today I was dealing with something similar, and I have found a solution - if `wp_unique_post_slug()` calling is performance bottleneck, and `post_name` value is not important, then **set post\_name manualy to some random value**.
My `wp_insert_post` post action was taking too lo... |
119,776 | <p>I'm registering 7 custom taxonomies in my functions.php. Since each function uses the same labels and arguments and is attached to the same Custom Post Type, I'm wondering if it's possible to register all the taxonomies in 1 function? Here is the code that is repeated 7 times with the <code><XXX></code> as the... | [
{
"answer_id": 119798,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>Nope. Not the WordPress way at least.</p>\n\n<p>You could probably make helper function (plain PHP realm in other w... | 2013/10/23 | [
"https://wordpress.stackexchange.com/questions/119776",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40679/"
] | I'm registering 7 custom taxonomies in my functions.php. Since each function uses the same labels and arguments and is attached to the same Custom Post Type, I'm wondering if it's possible to register all the taxonomies in 1 function? Here is the code that is repeated 7 times with the `<XXX>` as the only changing parts... | Nope. Not the WordPress way at least.
You could probably make helper function (plain PHP realm in other words) to build instances of label arrays, however that would seriously hinder making strings translatable. |
119,784 | <p>I try create a quick comment form on my wordpress with a link like this:
<img src="https://i.stack.imgur.com/vKDGW.jpg" alt="enter image description here"></p>
<p>My plan is when you click this link,you get a comment form with jquery show() function, where you can add a comment in ajax.<br>
jquery:</p>
<pre><code>... | [
{
"answer_id": 119787,
"author": "Rares P.",
"author_id": 21370,
"author_profile": "https://wordpress.stackexchange.com/users/21370",
"pm_score": 0,
"selected": false,
"text": "<p><strong>1</strong>. Try to see if your js is loaded. Try this by adding: alert(\"test\"); and refresh the we... | 2013/10/23 | [
"https://wordpress.stackexchange.com/questions/119784",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38916/"
] | I try create a quick comment form on my wordpress with a link like this:

My plan is when you click this link,you get a comment form with jquery show() function, where you can add a comment in ajax.
jquery:
```
$.noConflict();
jQuery( ".comment-... | WordPress runs `$.noConflict();` by default.
You attempting to run it again manually likely throws a
>
> TypeError: Cannot call method 'noConflict' of undefined
>
>
>
Make use of your browser's JS console rather than jsbin... |
119,813 | <p>I'm trying to display all the posts that use a custom taxonomy. I believe the issue is that it is my code is not generating an array of terms.</p>
<pre><code> $clients_terms = get_terms('clients');
$clients_query = new WP_Query( array(
'post_type' => 'work',
'posts_per_page' => 4,
'tax_... | [
{
"answer_id": 119816,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": true,
"text": "<p>I think your problem is here:</p>\n\n<pre><code>'terms' => array($clients_terms->slug)\n</code></pre>... | 2013/10/23 | [
"https://wordpress.stackexchange.com/questions/119813",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24931/"
] | I'm trying to display all the posts that use a custom taxonomy. I believe the issue is that it is my code is not generating an array of terms.
```
$clients_terms = get_terms('clients');
$clients_query = new WP_Query( array(
'post_type' => 'work',
'posts_per_page' => 4,
'tax_query' => array(
... | I think your problem is here:
```
'terms' => array($clients_terms->slug)
```
You define `$clients_terms` like so:
```
$clients_terms = get_terms('clients');
```
...which will return an *array of objects*. But you try to access it as an *object* in your query args. That should be producing some kind of PHP notice?... |
119,814 | <p>I have a custom post type with a bunch of custom fields. I want to validate the meta box input with jQuery as soon as you press the Publish button. Here's what I have (I left out all my validation stuff):</p>
<pre><code>$("input#publish").click(function(e){
e.preventDefault();
$("#ajax-loading").show();
... | [
{
"answer_id": 119816,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": true,
"text": "<p>I think your problem is here:</p>\n\n<pre><code>'terms' => array($clients_terms->slug)\n</code></pre>... | 2013/10/23 | [
"https://wordpress.stackexchange.com/questions/119814",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11686/"
] | I have a custom post type with a bunch of custom fields. I want to validate the meta box input with jQuery as soon as you press the Publish button. Here's what I have (I left out all my validation stuff):
```
$("input#publish").click(function(e){
e.preventDefault();
$("#ajax-loading").show();
$('form#post'... | I think your problem is here:
```
'terms' => array($clients_terms->slug)
```
You define `$clients_terms` like so:
```
$clients_terms = get_terms('clients');
```
...which will return an *array of objects*. But you try to access it as an *object* in your query args. That should be producing some kind of PHP notice?... |
119,820 | <p>I have a sub-directory in my Wordpress theme (there are a lot of pages and I want a more logical structure). I have a custom post type called "entry" but if I place the archive-entry.php template in my sub-directory it is no longer picked up by the theme.</p>
<p>Is there a way I can put my custom post type archive ... | [
{
"answer_id": 119826,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 3,
"selected": true,
"text": "<p>Unlike page templates, WordPress doesn't look in subdirectories for post template pages. The base functio... | 2013/10/23 | [
"https://wordpress.stackexchange.com/questions/119820",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19475/"
] | I have a sub-directory in my Wordpress theme (there are a lot of pages and I want a more logical structure). I have a custom post type called "entry" but if I place the archive-entry.php template in my sub-directory it is no longer picked up by the theme.
Is there a way I can put my custom post type archive templates ... | Unlike page templates, WordPress doesn't look in subdirectories for post template pages. The base function used for locating such templates is `locate_template()` (see [source](http://queryposts.com/function/locate_template/)), which looks in the root directory of your theme (and parent theme).
*(On the other hand `g... |
119,829 | <p>I want to show recent posts like this.</p>
<pre><code><ul id="recent-posts">
<?php foreach( wp_get_recent_posts() as $recent ){ ?>
<li>
<a href="<?php echo get_permalink($recent['ID']); ?>">
<?php echo $recent["post_title"]; ?> by
<?php echo $recent["post_a... | [
{
"answer_id": 119836,
"author": "Oleg Butuzov",
"author_id": 14536,
"author_profile": "https://wordpress.stackexchange.com/users/14536",
"pm_score": 3,
"selected": false,
"text": "<pre><code>echo get_the_author_meta('display_name', $recent[\"post_author\"]);\n// code from deprecated.php... | 2013/10/23 | [
"https://wordpress.stackexchange.com/questions/119829",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38849/"
] | I want to show recent posts like this.
```
<ul id="recent-posts">
<?php foreach( wp_get_recent_posts() as $recent ){ ?>
<li>
<a href="<?php echo get_permalink($recent['ID']); ?>">
<?php echo $recent["post_title"]; ?> by
<?php echo $recent["post_author"]; ?>
</a>
</li>
<?php } ?>
</ul>
... | Try [`get_user_by()`](http://codex.wordpress.org/Function_Reference/get_user_by):
```
get_user_by( $field, $value );
```
In your case, you'd pass ID, and the user ID:
```
// Get user object
$recent_author = get_user_by( 'ID', $recent["post_author"] );
// Get user display name
$author_display_name = $recent_author->... |
119,835 | <p>The incomplete <a href="http://codex.wordpress.org/Function_Reference/rewind_posts" rel="nofollow noreferrer">Codex about this</a>, says very simply:</p>
<blockquote>
<p><strong>rewind_posts():</strong><br/>
Rewind the loop posts.</p>
</blockquote>
<p>As per <a href="https://wordpress.stackexchange.com/questions/110... | [
{
"answer_id": 119844,
"author": "Kishore Sahoo",
"author_id": 38156,
"author_profile": "https://wordpress.stackexchange.com/users/38156",
"pm_score": 4,
"selected": true,
"text": "<h2>It generally the clears the current loop</h2>\n\n<pre><code>// main loop\n<?php if (have_posts()) : ... | 2013/10/23 | [
"https://wordpress.stackexchange.com/questions/119835",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22728/"
] | The incomplete [Codex about this](http://codex.wordpress.org/Function_Reference/rewind_posts), says very simply:
>
> **rewind\_posts():**
>
> Rewind the loop posts.
>
>
>
As per [this WPSE thread](https://wordpress.stackexchange.com/questions/110813/get-the-post-type-of-current-taxonomy-or-category-page), with... | It generally the clears the current loop
----------------------------------------
```
// main loop
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
// rewind
<?php rewind_posts(); ?>
// new loop
<?php while (have_posts()) : the_post(); ?>
<?php the_con... |
119,839 | <p>I'm not familiar enough with wordpress to ask the question directly, so please bare with me as I explain what I'm looking for.</p>
<p>I have four primary sections of my business (A, B, C & D, for example).</p>
<ul>
<li>each section has it's own page</li>
<li>each section also has a category with the same name<... | [
{
"answer_id": 119844,
"author": "Kishore Sahoo",
"author_id": 38156,
"author_profile": "https://wordpress.stackexchange.com/users/38156",
"pm_score": 4,
"selected": true,
"text": "<h2>It generally the clears the current loop</h2>\n\n<pre><code>// main loop\n<?php if (have_posts()) : ... | 2013/10/23 | [
"https://wordpress.stackexchange.com/questions/119839",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40808/"
] | I'm not familiar enough with wordpress to ask the question directly, so please bare with me as I explain what I'm looking for.
I have four primary sections of my business (A, B, C & D, for example).
* each section has it's own page
* each section also has a category with the same name
* various pages and posts are ca... | It generally the clears the current loop
----------------------------------------
```
// main loop
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
<?php the_content(); ?>
<?php endwhile; endif; ?>
// rewind
<?php rewind_posts(); ?>
// new loop
<?php while (have_posts()) : the_post(); ?>
<?php the_con... |
119,840 | <p>I am trying to the redirect on a cart page using a bellow code but,I am not able to redirect on cart page .</p>
<pre><code>wp_redirect("'.home_url('cart').'");
</code></pre>
| [
{
"answer_id": 119841,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 1,
"selected": false,
"text": "<p>Try it like the following. The <code>exit()</code> is necessary to stop other code from running and ... | 2013/10/23 | [
"https://wordpress.stackexchange.com/questions/119840",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39122/"
] | I am trying to the redirect on a cart page using a bellow code but,I am not able to redirect on cart page .
```
wp_redirect("'.home_url('cart').'");
``` | Please use get\_page\_by\_path
```
wp_redirect( get_page_by_path( 'cart' ) );
exit();
```
[Reference link for get page by path](http://codex.wordpress.org/Function_Reference/get_page_by_path) |
119,843 | <p>Reactor Theme is built on Zurb Foundation and is <a href="http://awtheme.com/" rel="nofollow">here</a> - I think it's quite good.</p>
<p>The theme I am replacing used the featured image in the posts or blog page but not in the post itself. Reactor calls the image in both. I want to try and change that so that I c... | [
{
"answer_id": 119841,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 1,
"selected": false,
"text": "<p>Try it like the following. The <code>exit()</code> is necessary to stop other code from running and ... | 2013/10/23 | [
"https://wordpress.stackexchange.com/questions/119843",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30859/"
] | Reactor Theme is built on Zurb Foundation and is [here](http://awtheme.com/) - I think it's quite good.
The theme I am replacing used the featured image in the posts or blog page but not in the post itself. Reactor calls the image in both. I want to try and change that so that I can have the featured image on the blog... | Please use get\_page\_by\_path
```
wp_redirect( get_page_by_path( 'cart' ) );
exit();
```
[Reference link for get page by path](http://codex.wordpress.org/Function_Reference/get_page_by_path) |
119,847 | <p>I am using wp_insert_term() to insert a large number of taxonomy terms from a csv file. The contents of that csv file might change occasionally. According to the codex, wp_insert_term() needs to run on add_action('init') but I only want to run it once. How can I achieve that on plugin activation?</p>
<p>I am curren... | [
{
"answer_id": 119849,
"author": "josh",
"author_id": 24323,
"author_profile": "https://wordpress.stackexchange.com/users/24323",
"pm_score": 3,
"selected": false,
"text": "<p>The <code><a href=\"http://codex.wordpress.org/Function_Reference/register_activation_hook\" rel=\"noreferrer\">... | 2013/10/23 | [
"https://wordpress.stackexchange.com/questions/119847",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/500/"
] | I am using wp\_insert\_term() to insert a large number of taxonomy terms from a csv file. The contents of that csv file might change occasionally. According to the codex, wp\_insert\_term() needs to run on add\_action('init') but I only want to run it once. How can I achieve that on plugin activation?
I am currently j... | I don't think there is a need to add the items to the init hook from the activation function. I think you can call them directly:
```
private static function single_activate() {
self::add_partner_terms(); //$this->add_partner_terms();
self::add_geo_terms(); //$this->add_geo_terms();
}
```
I'm not really sur... |
119,862 | <p>I have a client that has multiple pages of content that will be changed on various intervals depending on the day and/or date. For example one of the pages is "Specials of the Day"</p>
<p>They already know what the specials are for all seven days of the week and they simply rotate through them, after seven days it... | [
{
"answer_id": 119867,
"author": "Kishore Sahoo",
"author_id": 38156,
"author_profile": "https://wordpress.stackexchange.com/users/38156",
"pm_score": -1,
"selected": false,
"text": "<p>$special-of-the-day is the current day\nWe can use like www.yoursite/com/'.$special-of-the-day.'/</p>\... | 2013/10/23 | [
"https://wordpress.stackexchange.com/questions/119862",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6971/"
] | I have a client that has multiple pages of content that will be changed on various intervals depending on the day and/or date. For example one of the pages is "Specials of the Day"
They already know what the specials are for all seven days of the week and they simply rotate through them, after seven days it starts bac... | Not sure if I'm understanding you correctly, but if you want to display a special of the day, depending on the day ... I have a rough representation of how you could go about doing so.
**Example:**
```
$current_day = date('N');// 1 (for Monday) through 7 (for Sunday) - daily/weekly
//$current_day = date('j');// 1 to ... |