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
74,345
<p>I'm trying to get all the children categories to display in this loop but I'm struggling with the code. This is what I have so far. </p> <pre><code>&lt;?php $args=array('orderby' =&gt; 'name', 'order' =&gt; 'ASC'); $categories=get_categories($args); foreach ($categories as $cat) { ?&gt; &lt;dt&gt;&lt;a...
[ { "answer_id": 74352, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 6, "selected": true, "text": "<p>You can't just pass the string \"parent\" to <a href=\"http://codex.wordpress.org/Function_Reference/get_categ...
2012/11/29
[ "https://wordpress.stackexchange.com/questions/74345", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24242/" ]
I'm trying to get all the children categories to display in this loop but I'm struggling with the code. This is what I have so far. ``` <?php $args=array('orderby' => 'name', 'order' => 'ASC'); $categories=get_categories($args); foreach ($categories as $cat) { ?> <dt><a href="#" class="customer-acquisiti...
You can't just pass the string "parent" to [`get_categories`](http://codex.wordpress.org/Function_Reference/get_categories). You have to pass the ID of the parent. ``` $categories=get_categories( array( 'parent' => $cat->cat_ID ) ); ``` Notice that there are two [similar but not equal "get child" parameters](htt...
74,350
<p>I have a plugin that is returning post IDs based on <code>$_GET</code> data (which searches a secondary DB table). I am attempting to hook into the standard <code>have_posts()</code> function called within a taxonomy page to show the results. Since the data is passed in on the actual page, I can't use the normal <co...
[ { "answer_id": 74654, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": true, "text": "<p>I can see several possibilities for this one.</p>\n\n<p>First, I am not convinced that that you can't use <cod...
2012/11/29
[ "https://wordpress.stackexchange.com/questions/74350", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9605/" ]
I have a plugin that is returning post IDs based on `$_GET` data (which searches a secondary DB table). I am attempting to hook into the standard `have_posts()` function called within a taxonomy page to show the results. Since the data is passed in on the actual page, I can't use the normal `pre_get_posts` stand-by, li...
I can see several possibilities for this one. First, I am not convinced that that you can't use `pre_get_posts` though maybe you'd have to reorganize your code. You don't have to wait for your theme template to use `$_GET`. Try: ``` function tst() { // global $_GET; // sometimes necessary var_dump($_GET); } a...
74,367
<p>There is a theme hack or a worm circulating online which adds this code to all functions.php files. It happened to me on my local server.</p> <p>Here's the code - <a href="http://pastebin.com/AUsHUng1" rel="nofollow">http://pastebin.com/AUsHUng1</a></p> <p>How do I find the theme hack that creates it? Or the worm?...
[ { "answer_id": 74654, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": true, "text": "<p>I can see several possibilities for this one.</p>\n\n<p>First, I am not convinced that that you can't use <cod...
2012/11/29
[ "https://wordpress.stackexchange.com/questions/74367", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7349/" ]
There is a theme hack or a worm circulating online which adds this code to all functions.php files. It happened to me on my local server. Here's the code - <http://pastebin.com/AUsHUng1> How do I find the theme hack that creates it? Or the worm? **UPDATE:** I have found that this line: ``` $elem == substr(__FILE__...
I can see several possibilities for this one. First, I am not convinced that that you can't use `pre_get_posts` though maybe you'd have to reorganize your code. You don't have to wait for your theme template to use `$_GET`. Try: ``` function tst() { // global $_GET; // sometimes necessary var_dump($_GET); } a...
74,386
<p>Is there an easy way to reverse the default item order of a category rss feed?</p> <pre><code>Default: Last posted item first Wanted: First posted item first </code></pre> <p>No plugins please, plain wp api function calls (such as add_action or add_filter) will do!</p>
[ { "answer_id": 74654, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": true, "text": "<p>I can see several possibilities for this one.</p>\n\n<p>First, I am not convinced that that you can't use <cod...
2012/11/29
[ "https://wordpress.stackexchange.com/questions/74386", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23380/" ]
Is there an easy way to reverse the default item order of a category rss feed? ``` Default: Last posted item first Wanted: First posted item first ``` No plugins please, plain wp api function calls (such as add\_action or add\_filter) will do!
I can see several possibilities for this one. First, I am not convinced that that you can't use `pre_get_posts` though maybe you'd have to reorganize your code. You don't have to wait for your theme template to use `$_GET`. Try: ``` function tst() { // global $_GET; // sometimes necessary var_dump($_GET); } a...
74,391
<p>I have the following function. This is part of a membership-based site. When a post of the type "message" is moved to Publish status, it should send an email to all users who belong (custom user meta) to the district(s) that are checked (taxonomy) when the post is drafted.</p> <p>If I send to a small group, it seem...
[ { "answer_id": 74393, "author": "Chris", "author_id": 16178, "author_profile": "https://wordpress.stackexchange.com/users/16178", "pm_score": 2, "selected": false, "text": "<p>Sounds to me perhaps its hanging after your PHP running exceeds PHP.ini's script timeout limit.</p>\n" }, { ...
2012/11/29
[ "https://wordpress.stackexchange.com/questions/74391", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13676/" ]
I have the following function. This is part of a membership-based site. When a post of the type "message" is moved to Publish status, it should send an email to all users who belong (custom user meta) to the district(s) that are checked (taxonomy) when the post is drafted. If I send to a small group, it seems to work....
Well, this isn't a full solution per se, but I would start by isolating whether the problem is the SQL queries or the `wp_mail()` call. If you comment out the `wp_mail()` line, you can get an idea of how long the function takes to run the queries and build the messages without trying to send them. If you find that sud...
74,395
<p>I'm using an external CSV reading library that takes a filehandle (resource) as an argument. I'm using wp_handle_upload() to actually process and store the file in the Uploads directory, but that returns the file path, not a resource.</p> <p>Is <code>$filehandle = fopen( $file['file'], 'r' )</code> acceptable here,...
[ { "answer_id": 74401, "author": "Ralf912", "author_id": 16589, "author_profile": "https://wordpress.stackexchange.com/users/16589", "pm_score": 1, "selected": false, "text": "<p>WordPress do not use <code>fopen()</code>. The WordPress filesystem uses four methods to access a file:</p>\n\...
2012/11/29
[ "https://wordpress.stackexchange.com/questions/74395", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3687/" ]
I'm using an external CSV reading library that takes a filehandle (resource) as an argument. I'm using wp\_handle\_upload() to actually process and store the file in the Uploads directory, but that returns the file path, not a resource. Is `$filehandle = fopen( $file['file'], 'r' )` acceptable here, or is there a bett...
What follows is kind of complicated. You can probably just use `fopen` or `file_get_contents` without any issues. There's the [filesystem api](http://codex.wordpress.org/Filesystem_API). Which deals with determining ownership of a file and returning the correct way of accessing it -- most of the time that just means n...
74,418
<p>The great starter theme _S for Wordpress has the following CSS reset included, which works pretty well I find: <a href="https://gist.github.com/4173728" rel="nofollow">https://gist.github.com/4173728</a></p> <p>But I prefer the Eric Meyer one, which I'm sure you're all familiar with.</p> <p>I find I run into probl...
[ { "answer_id": 74419, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 2, "selected": false, "text": "<p>Well, your linked gist is not a reset. Reset implies that it provides you with a blank slate -- that one...
2012/11/30
[ "https://wordpress.stackexchange.com/questions/74418", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22913/" ]
The great starter theme \_S for Wordpress has the following CSS reset included, which works pretty well I find: <https://gist.github.com/4173728> But I prefer the Eric Meyer one, which I'm sure you're all familiar with. I find I run into problems with the \_S one because I'll be wondering why something isn't reacting...
Well, your linked gist is not a reset. Reset implies that it provides you with a blank slate -- that one doesn't, it looks more like [normalize.css](http://necolas.github.com/normalize.css/). There is not official WordPress CSS reset. If you're building a theme you can use what you like. However, there are several [W...
74,435
<p>I want to display custom static content, essentially an image and a small description, at the top of each category page (different for each category and sub category), displayed above a list of titles of the category posts with excerpts. </p> <p>Is there an automated solution/plugin available for this? I need an au...
[ { "answer_id": 74437, "author": "Kristian Vitozev", "author_id": 17449, "author_profile": "https://wordpress.stackexchange.com/users/17449", "pm_score": 0, "selected": false, "text": "<p>You can use the following plugin: <a href=\"http://wordpress.org/extend/plugins/categorytinymce/scree...
2012/11/30
[ "https://wordpress.stackexchange.com/questions/74435", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23070/" ]
I want to display custom static content, essentially an image and a small description, at the top of each category page (different for each category and sub category), displayed above a list of titles of the category posts with excerpts. Is there an automated solution/plugin available for this? I need an automated wa...
Simply call the [`category_description()`](http://queryposts.com/function/category_description/) - this displays the description that you can enter for each category that you add in the admin UI under "category" (or post tag or each other custom taxonomy). You can as well use the underlying API function: ``` term_des...
74,446
<p>Is it possible to validate PHP code?</p> <p>I have a Custom Post Type (Film) with Custom Meta Boxes. </p> <p>Everything is working fine, I can add new Films and details to the Custom Meta Boxes.</p> <p>My problem is with the Update button. If I create a new film, add info and click Update a get a white screen.</p...
[ { "answer_id": 74448, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 4, "selected": true, "text": "<p>Your code works just fine on my end. So, I'd say your problem is elsewhere.</p>\n\n<p><a href=\"http://wordpr...
2012/11/30
[ "https://wordpress.stackexchange.com/questions/74446", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17373/" ]
Is it possible to validate PHP code? I have a Custom Post Type (Film) with Custom Meta Boxes. Everything is working fine, I can add new Films and details to the Custom Meta Boxes. My problem is with the Update button. If I create a new film, add info and click Update a get a white screen. I know the problem is wit...
Your code works just fine on my end. So, I'd say your problem is elsewhere. [Troubleshooting guide](http://wordpress.org/support/topic/troubleshooting-wordpress-34-master-list?replies=5). You can use standard [debugging](http://codex.wordpress.org/Debugging_in_WordPress) or [FirePHP](https://wordpress.stackexchange.c...
74,453
<p>I'm trying to add a little form after each post for a plugin I have to code, but I'm not very familiar with Wordpress. By using add_action with the_content as hook, I was able to add some text to the content. </p> <p>My trouble is that the whole text stored in the $content variable seemed to be processed somehow. S...
[ { "answer_id": 74469, "author": "Zach", "author_id": 9605, "author_profile": "https://wordpress.stackexchange.com/users/9605", "pm_score": 0, "selected": false, "text": "<p>You'll actually want to <code>filter</code> the content, not use an action. You could wrap your form in the output ...
2012/11/30
[ "https://wordpress.stackexchange.com/questions/74453", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24269/" ]
I'm trying to add a little form after each post for a plugin I have to code, but I'm not very familiar with Wordpress. By using add\_action with the\_content as hook, I was able to add some text to the content. My trouble is that the whole text stored in the $content variable seemed to be processed somehow. Specifica...
If I understand what you are doing, and the problem you are having, the first thing I'd try is to [add your `the_content` filter with a large priority number](http://codex.wordpress.org/Function_Reference/add_filter) so that it runs late, and hopefully after the other formatting filters. `add_filter('the_content','yo...
74,461
<p>I am working on my site which is a WordPress based site. It is a sweepstakes site well winprizesonline.com is the site which inspired me most. Now I want a dynamic search like that site on my site but I have no idea how and where to add code.</p> <p>Like here; <a href="http://www.winprizesonline.com/new/contests/" ...
[ { "answer_id": 74469, "author": "Zach", "author_id": 9605, "author_profile": "https://wordpress.stackexchange.com/users/9605", "pm_score": 0, "selected": false, "text": "<p>You'll actually want to <code>filter</code> the content, not use an action. You could wrap your form in the output ...
2012/11/30
[ "https://wordpress.stackexchange.com/questions/74461", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24272/" ]
I am working on my site which is a WordPress based site. It is a sweepstakes site well winprizesonline.com is the site which inspired me most. Now I want a dynamic search like that site on my site but I have no idea how and where to add code. Like here; <http://www.winprizesonline.com/new/contests/> you can see the 3 ...
If I understand what you are doing, and the problem you are having, the first thing I'd try is to [add your `the_content` filter with a large priority number](http://codex.wordpress.org/Function_Reference/add_filter) so that it runs late, and hopefully after the other formatting filters. `add_filter('the_content','yo...
74,464
<p>Is it possible to force user to set featured image on some types of posts. For example I've got custom post type <code>mm_photo</code> and I want to show some error message or somehow block user from publishing or updating post when there is no featured image set.</p>
[ { "answer_id": 74547, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 2, "selected": false, "text": "<p>Fairly simple using jQuery and global <code>$typenow</code> ex:</p>\n\n<pre><code>add_action('admin_print_scr...
2012/11/30
[ "https://wordpress.stackexchange.com/questions/74464", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24275/" ]
Is it possible to force user to set featured image on some types of posts. For example I've got custom post type `mm_photo` and I want to show some error message or somehow block user from publishing or updating post when there is no featured image set.
Fairly simple using jQuery and global `$typenow` ex: ``` add_action('admin_print_scripts-post.php', 'my_publish_admin_hook'); add_action('admin_print_scripts-post-new.php', 'my_publish_admin_hook'); function my_publish_admin_hook(){ global $typenow; if (in_array($typenow, array('post','page','mm_photo '))){ ...
74,468
<p>I use a custom post type in one of my sites for image slideshows. I have publicly queryable set to false/off but when Google crawls my site I see 404 errors for the URLs for my slideshows. I thought that by having publicly queryable off Wordpress would not create those front end URLs.</p> <p>How can I completely tur...
[ { "answer_id": 74472, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<p>Apparently your <strong>slideshow</strong>, not WordPress, it revealing those URLs. I assume it is wrapping t...
2012/11/30
[ "https://wordpress.stackexchange.com/questions/74468", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5391/" ]
I use a custom post type in one of my sites for image slideshows. I have publicly queryable set to false/off but when Google crawls my site I see 404 errors for the URLs for my slideshows. I thought that by having publicly queryable off Wordpress would not create those front end URLs. How can I completely turn off the...
Another option would be to set a 301 redirect for all the slideshow CPTs to redirect somewhere (like the home page). This would get picked up by Google, and also make sure no one accidentally gets on them ``` function rkv_slideshow_redirect() { global $wp_query; // redirect from 'slideshow' CPT to home page ...
74,477
<p>I've setup an "album" custom post type and want to add an icon on the index page where the RED circle is (see image below; from wptheming.com). </p> <p>Here's my function to replace the icon. The CSS is what I found when I inspected the icon element with firebug:</p> <pre><code>add_action('admin_head', 'album_foo'...
[ { "answer_id": 74472, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<p>Apparently your <strong>slideshow</strong>, not WordPress, it revealing those URLs. I assume it is wrapping t...
2012/11/30
[ "https://wordpress.stackexchange.com/questions/74477", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24181/" ]
I've setup an "album" custom post type and want to add an icon on the index page where the RED circle is (see image below; from wptheming.com). Here's my function to replace the icon. The CSS is what I found when I inspected the icon element with firebug: ``` add_action('admin_head', 'album_foo'); function album_foo...
Another option would be to set a 301 redirect for all the slideshow CPTs to redirect somewhere (like the home page). This would get picked up by Google, and also make sure no one accidentally gets on them ``` function rkv_slideshow_redirect() { global $wp_query; // redirect from 'slideshow' CPT to home page ...
74,493
<p>I'm using the following query for a custom post type:</p> <pre><code>&lt;?php $posts = get_posts(array( 'numberposts' =&gt; -1, 'offset' =&gt; 20, 'post_type' =&gt; 'faqs' )); if($posts) { foreach($...
[ { "answer_id": 77354, "author": "livearoha", "author_id": 25235, "author_profile": "https://wordpress.stackexchange.com/users/25235", "pm_score": 0, "selected": false, "text": "<p>Set 'numberposts' value to a large positive number. With numberposts set to -1 it will return all the faqs i...
2012/11/30
[ "https://wordpress.stackexchange.com/questions/74493", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24281/" ]
I'm using the following query for a custom post type: ``` <?php $posts = get_posts(array( 'numberposts' => -1, 'offset' => 20, 'post_type' => 'faqs' )); if($posts) { foreach($posts as $post) ...
Reason of this behavior is pretty simple. First of all you have to know that `get_posts` uses `WP_Query` to get posts. So let's look at WP\_Query implementation. On [line 1998 of query.php](http://core.trac.wordpress.org/browser/tags/3.6/wp-includes/query.php#L1998) you can find: ``` if ( $q['posts_per_page'] == -1 )...
74,500
<p>I'm trying to add a conditional that will display a default image if the "image" field isn't populated... here's what I'm trying to work with:</p> <pre><code>$args = array( 'posts_per_page' =&gt; 3, 'post_type' =&gt; 'post', 'meta_query' =&gt; array( array( 'key' =&gt; 'is_featured', ...
[ { "answer_id": 74630, "author": "user1757516", "author_id": 23013, "author_profile": "https://wordpress.stackexchange.com/users/23013", "pm_score": 3, "selected": true, "text": "<p>You can't pull it in wp-admin you actually have to go look at the plugin in wordpress repository and see if...
2012/11/30
[ "https://wordpress.stackexchange.com/questions/74500", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22688/" ]
I'm trying to add a conditional that will display a default image if the "image" field isn't populated... here's what I'm trying to work with: ``` $args = array( 'posts_per_page' => 3, 'post_type' => 'post', 'meta_query' => array( array( 'key' => 'is_featured', 'value' => '1', ...
You can't pull it in wp-admin you actually have to go look at the plugin in wordpress repository and see if they added there or to the plugin author's site for a changelog. That would be a nice feature for the future.
74,515
<p>I'd like to change only one output of native WP Gallery (in media.php)</p> <p>On Smashing Magazine (<a href="http://wp.smashingmagazine.com/2011/05/26/better-image-management-practices-with-wordpress" rel="noreferrer">link</a>) author advises to change whole gallery_shortcode function. But I wondered if is possible...
[ { "answer_id": 74537, "author": "Ahmad M", "author_id": 12961, "author_profile": "https://wordpress.stackexchange.com/users/12961", "pm_score": 2, "selected": true, "text": "<p>There are no filter hook called <code>captiontag</code>. You can change the value of the caption html tag by sp...
2012/11/30
[ "https://wordpress.stackexchange.com/questions/74515", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24212/" ]
I'd like to change only one output of native WP Gallery (in media.php) On Smashing Magazine ([link](http://wp.smashingmagazine.com/2011/05/26/better-image-management-practices-with-wordpress)) author advises to change whole gallery\_shortcode function. But I wondered if is possible to change only specific output ($cap...
There are no filter hook called `captiontag`. You can change the value of the caption html tag by specifying the `captiontag` option when inserting the `[gallery]` shortcode. From the [gallery shortcode codex page](http://codex.wordpress.org/Gallery_Shortcode): > > **captiontag** > > > the name of the XHTML tag us...
74,517
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://wordpress.stackexchange.com/questions/14834/determining-if-the-user-is-logged-in">determining if the user is logged in</a> </p> </blockquote> <p>Please check my site <a href="http://247ebookstore.com/sg3/monestatic-igues/" rel="nofollow n...
[ { "answer_id": 74537, "author": "Ahmad M", "author_id": 12961, "author_profile": "https://wordpress.stackexchange.com/users/12961", "pm_score": 2, "selected": true, "text": "<p>There are no filter hook called <code>captiontag</code>. You can change the value of the caption html tag by sp...
2012/11/30
[ "https://wordpress.stackexchange.com/questions/74517", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24272/" ]
> > **Possible Duplicate:** > > [determining if the user is logged in](https://wordpress.stackexchange.com/questions/14834/determining-if-the-user-is-logged-in) > > > Please check my site <http://247ebookstore.com/sg3/monestatic-igues/> still working on it. If you check the given page you'll see "Visit Website...
There are no filter hook called `captiontag`. You can change the value of the caption html tag by specifying the `captiontag` option when inserting the `[gallery]` shortcode. From the [gallery shortcode codex page](http://codex.wordpress.org/Gallery_Shortcode): > > **captiontag** > > > the name of the XHTML tag us...
74,527
<p>I have <em>one</em> page that I need to change the URL for.</p> <p>Currently, the page resides at example.com/departments/human-resources/</p> <p>(human-resources is a sub-page of /departments/ )</p> <p>My client wants to maintain the legacy url for the hr department which is:</p> <p><a href="http://example.com/...
[ { "answer_id": 74531, "author": "developdaly", "author_id": 3293, "author_profile": "https://wordpress.stackexchange.com/users/3293", "pm_score": 2, "selected": true, "text": "<p><a href=\"http://wordpress.org/extend/plugins/redirection/\" rel=\"nofollow\">Redirection</a> allows you to m...
2012/11/30
[ "https://wordpress.stackexchange.com/questions/74527", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24286/" ]
I have *one* page that I need to change the URL for. Currently, the page resides at example.com/departments/human-resources/ (human-resources is a sub-page of /departments/ ) My client wants to maintain the legacy url for the hr department which is: <http://example.com/hr/> How can I rewrite any request for `^/hr/...
[Redirection](http://wordpress.org/extend/plugins/redirection/) allows you to modify post slugs and keeps a history of them, pointing all requests for the history of a page to the same destination. It's useful for all sorts of other things too, but it will definitely solve this problem.
74,528
<p>I am doing a special migration from someone's custom CMS to a WP installation. I successfully got the posts and comments migrated into their respective tables. Now I need to get the comment count into the wp_posts table for each matching id. I have something like this. I'm close, I think:</p> <pre><code>SELECT ...
[ { "answer_id": 74531, "author": "developdaly", "author_id": 3293, "author_profile": "https://wordpress.stackexchange.com/users/3293", "pm_score": 2, "selected": true, "text": "<p><a href=\"http://wordpress.org/extend/plugins/redirection/\" rel=\"nofollow\">Redirection</a> allows you to m...
2012/11/30
[ "https://wordpress.stackexchange.com/questions/74528", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8279/" ]
I am doing a special migration from someone's custom CMS to a WP installation. I successfully got the posts and comments migrated into their respective tables. Now I need to get the comment count into the wp\_posts table for each matching id. I have something like this. I'm close, I think: ``` SELECT COUNT(comment_con...
[Redirection](http://wordpress.org/extend/plugins/redirection/) allows you to modify post slugs and keeps a history of them, pointing all requests for the history of a page to the same destination. It's useful for all sorts of other things too, but it will definitely solve this problem.
74,540
<p>I'm building a single template right now for a custom post type. I'm wondering if there is a way to check if either at least one or multiple of the custom values has been entered so I can display the div accordingly. Basically, I want to display the div it has anything filled out, if it is left blank then don't show...
[ { "answer_id": 74531, "author": "developdaly", "author_id": 3293, "author_profile": "https://wordpress.stackexchange.com/users/3293", "pm_score": 2, "selected": true, "text": "<p><a href=\"http://wordpress.org/extend/plugins/redirection/\" rel=\"nofollow\">Redirection</a> allows you to m...
2012/11/30
[ "https://wordpress.stackexchange.com/questions/74540", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18241/" ]
I'm building a single template right now for a custom post type. I'm wondering if there is a way to check if either at least one or multiple of the custom values has been entered so I can display the div accordingly. Basically, I want to display the div it has anything filled out, if it is left blank then don't show it...
[Redirection](http://wordpress.org/extend/plugins/redirection/) allows you to modify post slugs and keeps a history of them, pointing all requests for the history of a page to the same destination. It's useful for all sorts of other things too, but it will definitely solve this problem.
74,553
<p>As new user to wordpress I'm finding that the preset templates structure a little restricting coming from the flexibility of other template routed CMS I've worked with.</p> <p>Saying this, I know there are plenty of workarounds and I'm now currently in the process of trying to establish them.</p> <p>--</p> <p>One...
[ { "answer_id": 74559, "author": "Brent", "author_id": 10972, "author_profile": "https://wordpress.stackexchange.com/users/10972", "pm_score": 2, "selected": false, "text": "<p>One of my favorite pieces of WordPress reference materials: <a href=\"http://codex.wordpress.org/File:Template_H...
2012/12/01
[ "https://wordpress.stackexchange.com/questions/74553", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24294/" ]
As new user to wordpress I'm finding that the preset templates structure a little restricting coming from the flexibility of other template routed CMS I've worked with. Saying this, I know there are plenty of workarounds and I'm now currently in the process of trying to establish them. -- One of the main hurdles I'm...
Mobile might not be a great example -- [responsive design](http://en.wikipedia.org/wiki/Responsive_web_design) would take care of that. Were this my project I would take a slightly different approach. Instead of prefixing the URL, I would stick the mobile on the end with an rewrite endpoint. An endpoint combined with ...
74,558
<p>I have this idea for linking to a paragraph within a post. It would work by every paragraph within <code>the_content()</code> on post pages having an anchor tag automatically placed before it, like this: <code>&lt;a href="#p1"&gt;&lt;/a&gt;</code> where '1' is the first paragraph and it would increment for every sub...
[ { "answer_id": 74560, "author": "Brent", "author_id": 10972, "author_profile": "https://wordpress.stackexchange.com/users/10972", "pm_score": 0, "selected": false, "text": "<p>Sounds like a job for Jquery. </p>\n\n<p>Jquery would look like this:</p>\n\n<pre><code>var i = 0;\n$('.entry p'...
2012/12/01
[ "https://wordpress.stackexchange.com/questions/74558", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5089/" ]
I have this idea for linking to a paragraph within a post. It would work by every paragraph within `the_content()` on post pages having an anchor tag automatically placed before it, like this: `<a href="#p1"></a>` where '1' is the first paragraph and it would increment for every subsequent paragraph, eg p2, p3, p4... ...
I think that should really be `<a name="p1">` around the paragraphs with link to the paragraphs being `<a href="#p1">`. If that is what you are trying to accomplish ( what used to be called a named anchors ), that technique is not valid in HTML 5. You can instead link to any `id` in the page, so with that in mind. `...
74,573
<p>I want to if the check next post has a specific tag. I tried the following code, but it is not working because <code>has_tag()</code> only works in the loop. I want to use it outside the loop.</p> <pre><code>&lt;?php if ( has_tag( 'mario', $post-&gt;ID ) ) : ?&gt; my content &lt;?php endif; ?&gt; </code></pre> <p>...
[ { "answer_id": 74574, "author": "Zach", "author_id": 9605, "author_profile": "https://wordpress.stackexchange.com/users/9605", "pm_score": 0, "selected": false, "text": "<p>You should be able to use something like this:</p>\n\n<pre><code>$post_id = 123;\n$posttags = get_the_tags($post_id...
2012/12/01
[ "https://wordpress.stackexchange.com/questions/74573", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23841/" ]
I want to if the check next post has a specific tag. I tried the following code, but it is not working because `has_tag()` only works in the loop. I want to use it outside the loop. ``` <?php if ( has_tag( 'mario', $post->ID ) ) : ?> my content <?php endif; ?> ``` The following code lists the tags from post, but I d...
The [**`has_tag()`**](http://codex.wordpress.org/Function_Reference/has_tag) conditional does *not* have to be used inside the Loop; it can be passed a `$post` *object* as a second parameter: ``` has_tag( $tag, $post ); ``` Since `has_tag()` defaults to the *current* post, you simply need to pass it the object for t...
74,603
<p>WordPress has an option to pick "Latest Posts" and "Static Page" under "Settings" in Admin Panel. My questions:</p> <ol> <li>What page template is getting loaded in each of those modes?</li> <li>Why <code>paged</code> stops working and <code>page</code> starts working when I select "Static Page" - <code>paged</code...
[ { "answer_id": 74574, "author": "Zach", "author_id": 9605, "author_profile": "https://wordpress.stackexchange.com/users/9605", "pm_score": 0, "selected": false, "text": "<p>You should be able to use something like this:</p>\n\n<pre><code>$post_id = 123;\n$posttags = get_the_tags($post_id...
2012/12/01
[ "https://wordpress.stackexchange.com/questions/74603", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17167/" ]
WordPress has an option to pick "Latest Posts" and "Static Page" under "Settings" in Admin Panel. My questions: 1. What page template is getting loaded in each of those modes? 2. Why `paged` stops working and `page` starts working when I select "Static Page" - `paged` works, however, when I create new page template wi...
The [**`has_tag()`**](http://codex.wordpress.org/Function_Reference/has_tag) conditional does *not* have to be used inside the Loop; it can be passed a `$post` *object* as a second parameter: ``` has_tag( $tag, $post ); ``` Since `has_tag()` defaults to the *current* post, you simply need to pass it the object for t...
74,612
<p>I am using a wordpress theme which has a page template named <code>roomtypes</code>. I am not a php pro but as far as I understand this template gets the posts. When I add a Room type, it is created as a post with a <code>post_type=roomtype</code>.<br> So this template gets these posts, adds their title and a thumbn...
[ { "answer_id": 74614, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 1, "selected": false, "text": "<p><code>the_content()</code> (and many others) must be <a href=\"http://codex.wordpress.org/The_Loop\" rel=\"n...
2012/12/01
[ "https://wordpress.stackexchange.com/questions/74612", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24095/" ]
I am using a wordpress theme which has a page template named `roomtypes`. I am not a php pro but as far as I understand this template gets the posts. When I add a Room type, it is created as a post with a `post_type=roomtype`. So this template gets these posts, adds their title and a thumbnail image. My problem is,...
`the_content()` (and many others) must be [**inside The Loop**](http://codex.wordpress.org/The_Loop). For retrieving a post/page/custom-post-type data outside the Loop, take a look here: [Get post content from outside the loop](https://wordpress.stackexchange.com/q/51741/12615) The working code, **based on your ...
74,620
<p>I am having alot of trouble with this. I was using <code>&lt;?php query_posts( array( 'post__not_in' =&gt; get_option( 'sticky_posts' ), 'paged' =&gt; get_query_var( 'paged' ) ) ); ?&gt;</code> to exclude the posts from the main query on the my homepage because stickies are being used in the slider. I am making this...
[ { "answer_id": 74621, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 3, "selected": false, "text": "<p><code>query_posts</code> isn't recommended because its <a href=\"http://codex.wordpress.org/Function_Refe...
2012/12/02
[ "https://wordpress.stackexchange.com/questions/74620", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24319/" ]
I am having alot of trouble with this. I was using `<?php query_posts( array( 'post__not_in' => get_option( 'sticky_posts' ), 'paged' => get_query_var( 'paged' ) ) ); ?>` to exclude the posts from the main query on the my homepage because stickies are being used in the slider. I am making this theme for wordpress.org a...
`query_posts` isn't recommended because its [breaks things](http://codex.wordpress.org/Function_Reference/query_posts#Caveats). You're really close, but just declaring the function itself will not work. You need to [hook](http://codex.wordpress.org/Plugin_API) the function into something. In your case, this would be `...
74,633
<p>I'm working on a wp project with responsive theme.</p> <p>I have single level nav menu at the top of the site, that I want to change to a Select Option tag for mobile browsers (small screens) with options for the nav items which is much easier to select in mobile site. So the UL LI menu will be replaced with a Sele...
[ { "answer_id": 74635, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": 2, "selected": true, "text": "<p>Here's what I've put together from different articles/themes:</p>\n\n<p><strong>files to modify:</strong></p...
2012/12/02
[ "https://wordpress.stackexchange.com/questions/74633", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22618/" ]
I'm working on a wp project with responsive theme. I have single level nav menu at the top of the site, that I want to change to a Select Option tag for mobile browsers (small screens) with options for the nav items which is much easier to select in mobile site. So the UL LI menu will be replaced with a Selection- Opt...
Here's what I've put together from different articles/themes: **files to modify:** functions.php header.php style.css js (create folder "js" in theme root directory) **The Javascript:** ``` jQuery(function() { jQuery("<select />").appendTo("nav"); jQuery("<option />", { "selected": "selected...
74,636
<p>How do I remove a particular tag name from the tag cloud ?</p> <p>I changed <code>wp-includes/default-widgets.php</code> on line 1038 from</p> <pre><code>wp_tag_cloud( apply_filters('widget_tag_cloud_args', array('taxonomy' =&gt; $current_taxonomy) ) ); </code></pre> <p>to</p> <pre><code>wp_tag_cloud( apply_filt...
[ { "answer_id": 74638, "author": "Niraj Chauhan", "author_id": 1743, "author_profile": "https://wordpress.stackexchange.com/users/1743", "pm_score": 0, "selected": false, "text": "<p>You are passing name, you ll need to pass ID of that tag.</p>\n\n<p><code>wp_tag_cloud( apply_filters('wid...
2012/12/02
[ "https://wordpress.stackexchange.com/questions/74636", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24322/" ]
How do I remove a particular tag name from the tag cloud ? I changed `wp-includes/default-widgets.php` on line 1038 from ``` wp_tag_cloud( apply_filters('widget_tag_cloud_args', array('taxonomy' => $current_taxonomy) ) ); ``` to ``` wp_tag_cloud( apply_filters('widget_tag_cloud_args', array('taxonomy' => $current_...
First: Don’t touch the core files, they will be overwritten during the next update. There is already an argument for exclusions available: `exclude`. It expects a term id. Sample: ``` wp_tag_cloud( array ( 'exclude' => 54 ) ); ``` Sometimes you don’t know the ID, but you can get it if you know the ...
74,670
<p>Fighting to create an ajax request. I've been reading couple of articles but still I can't get my plugin to send and recive ajax datas. </p> <p>first init the js </p> <pre><code> function ajax_load_scripts() { // load our jquery file that sends the $.post request wp_enqueue_script( "ajax-calls",...
[ { "answer_id": 74672, "author": "Matthew Boynes", "author_id": 12324, "author_profile": "https://wordpress.stackexchange.com/users/12324", "pm_score": 0, "selected": false, "text": "<p>Most likely, your JS isn't including the 'action' parameter, or it isn't set to <code>add_tipps</code>....
2012/12/02
[ "https://wordpress.stackexchange.com/questions/74670", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23759/" ]
Fighting to create an ajax request. I've been reading couple of articles but still I can't get my plugin to send and recive ajax datas. first init the js ``` function ajax_load_scripts() { // load our jquery file that sends the $.post request wp_enqueue_script( "ajax-calls", plugin_dir_url( __FI...
If you need to use the WordPress enviorment and functions in your ajax processing funciton then you need to post/get your AJAX request to admin-ajax.php, So change ``` 'ajaxurl' => plugin_dir_url('my_plugin.php') ``` to ``` 'ajaxurl' => admin_url('admin-ajax.php') ```
74,676
<p>I'm looking for a definitive answer here. When object caching is enabled, where do options and transients end up living?</p> <p>By default, both are stored in the database. But I've heard some references that memcache will store them elsewhere and APC will do something else entirely. Where, <em>exactly</em>, wil...
[ { "answer_id": 74707, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 0, "selected": false, "text": "<p>Options are always stored in the database, while transients may be stored only in shared memory if APC and ...
2012/12/02
[ "https://wordpress.stackexchange.com/questions/74676", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/46/" ]
I'm looking for a definitive answer here. When object caching is enabled, where do options and transients end up living? By default, both are stored in the database. But I've heard some references that memcache will store them elsewhere and APC will do something else entirely. Where, *exactly*, will this data be persi...
WordPress, by default, does a form of "Object Caching" but its lifetime is only a single page load. Options are actually a really good example of this. Check out [this answer](https://wordpress.stackexchange.com/questions/27717/are-all-options-loaded-to-memory-on-each-request/27720#27720) for more info. The summary: ...
74,691
<p>I want to look up a page id and determine if it's a page or post. Then query that id and display stuff like title, featured image, etc.</p> <p>This works for Pages:</p> <pre><code> query_posts('page=' . $featured_tab); </code></pre> <p>This works or Posts:</p> <pre><code> query_posts('p=' . $featured_tab)...
[ { "answer_id": 74700, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 1, "selected": false, "text": "<p>You don't have to determine what type it is to query it, you just have to set the proper arguments to override defa...
2012/12/02
[ "https://wordpress.stackexchange.com/questions/74691", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16641/" ]
I want to look up a page id and determine if it's a page or post. Then query that id and display stuff like title, featured image, etc. This works for Pages: ``` query_posts('page=' . $featured_tab); ``` This works or Posts: ``` query_posts('p=' . $featured_tab); ``` This will tell me if $featured\_tag...
You don't have to determine what type it is to query it, you just have to set the proper arguments to override defaults. First off, we'll use [`WP_Query`](http://codex.wordpress.org/Class_Reference/WP_Query) to do additional queries instead of `query_posts`. If we only set the `p` argument, `post_type` defaults to `po...
74,720
<p>I want to list all the values of a custom metabox in a custom post type.</p> <p>Here is the code to get the one meta box in a single post </p> <pre><code>&lt;?php echo get_post_meta($post-&gt;ID, 'institution_location', true);?&gt; </code></pre> <p>but say I want to list all the meta boxes in the home page or a d...
[ { "answer_id": 74723, "author": "hannit cohen", "author_id": 395, "author_profile": "https://wordpress.stackexchange.com/users/395", "pm_score": 0, "selected": false, "text": "<p>Try using <a href=\"http://codex.wordpress.org/Function_Reference/get_post_custom\" rel=\"nofollow\">get_post...
2012/12/03
[ "https://wordpress.stackexchange.com/questions/74720", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11917/" ]
I want to list all the values of a custom metabox in a custom post type. Here is the code to get the one meta box in a single post ``` <?php echo get_post_meta($post->ID, 'institution_location', true);?> ``` but say I want to list all the meta boxes in the home page or a dropdown menu in a search form not just in ...
I tried to use WP\_Query and it works fine. ``` <?php $args = array('post_type' => 'institution'); $the_query = new WP_Query($args); while ( $the_query->have_posts() ) : $the_query->next_post(); $id= $the_query->post->ID; $location = get_post_meta($id, 'institution_location', true); echo $loca...
74,732
<p>I'm trying to add a div to a widget's content in my dynamic sidebar.</p> <p>Here is the register code;</p> <pre><code>register_sidebar(array( 'name' =&gt; "Sidebar1", 'id' =&gt; 'home-sidebar-1', 'before_widget' =&gt; '&lt;div class="sidebar-box"&gt;', 'after_widget' =&gt; '&lt;/div...
[ { "answer_id": 74733, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>Add the second <code>div</code> to the title parameter:</p>\n\n<pre><code>register_sidebar(array(\n 'name' =&gt...
2012/12/03
[ "https://wordpress.stackexchange.com/questions/74732", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24358/" ]
I'm trying to add a div to a widget's content in my dynamic sidebar. Here is the register code; ``` register_sidebar(array( 'name' => "Sidebar1", 'id' => 'home-sidebar-1', 'before_widget' => '<div class="sidebar-box">', 'after_widget' => '</div>', 'before_title' => '<div class=...
In addition to Toscho's answer here's what you need for a robust solution: ``` // if no title then add widget content wrapper to before widget add_filter( 'dynamic_sidebar_params', 'check_sidebar_params' ); function check_sidebar_params( $params ) { global $wp_registered_widgets; $settings_getter = $wp_regist...
74,735
<p>How do you add a new class to the HTML generated when an image with captions is added?</p> <p>For example, from this:</p> <pre><code>&lt;div id="attachment_xyz" class="wp-caption alignleft"... </code></pre> <p>to this:</p> <pre><code>&lt;div id="attachment_xyz" class="wp-caption alignleft my_new_class"... </code...
[ { "answer_id": 74738, "author": "shea", "author_id": 19726, "author_profile": "https://wordpress.stackexchange.com/users/19726", "pm_score": 3, "selected": true, "text": "<blockquote>\n <p>Adapted from <a href=\"https://wordpress.stackexchange.com/a/51064/19726\">this answer</a></p>\n</...
2012/12/03
[ "https://wordpress.stackexchange.com/questions/74735", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24359/" ]
How do you add a new class to the HTML generated when an image with captions is added? For example, from this: ``` <div id="attachment_xyz" class="wp-caption alignleft"... ``` to this: ``` <div id="attachment_xyz" class="wp-caption alignleft my_new_class"... ``` Adding, in this case, **my\_new\_class**. Thanks,...
> > Adapted from [this answer](https://wordpress.stackexchange.com/a/51064/19726) > > > Add this code to your functions.php file: ``` add_action( 'after_setup_theme', 'wpse_74735_replace_wp_caption_shortcode' ); /** * Replace the default caption shortcode handler. * * @return void */ function wpse_74735_repl...
74,739
<p>I have created a custom post type 'hotel' and custom 'taxonomy' so when administrator creates a new hotel and saves it it related custom taxonomy automatically get created but I don't want to show custom metabox in the admin side hotel edit page so for that I used WordPress function but nothing happen.</p> <h2>My c...
[ { "answer_id": 74738, "author": "shea", "author_id": 19726, "author_profile": "https://wordpress.stackexchange.com/users/19726", "pm_score": 3, "selected": true, "text": "<blockquote>\n <p>Adapted from <a href=\"https://wordpress.stackexchange.com/a/51064/19726\">this answer</a></p>\n</...
2012/12/03
[ "https://wordpress.stackexchange.com/questions/74739", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20072/" ]
I have created a custom post type 'hotel' and custom 'taxonomy' so when administrator creates a new hotel and saves it it related custom taxonomy automatically get created but I don't want to show custom metabox in the admin side hotel edit page so for that I used WordPress function but nothing happen. My custom post ...
> > Adapted from [this answer](https://wordpress.stackexchange.com/a/51064/19726) > > > Add this code to your functions.php file: ``` add_action( 'after_setup_theme', 'wpse_74735_replace_wp_caption_shortcode' ); /** * Replace the default caption shortcode handler. * * @return void */ function wpse_74735_repl...
74,742
<p>I would like to identify admin users and non-admin (but logged in) users through cookies. I need this feature because I use Hyper Cache (which uses cookies to identify those who send pages in cache): I would like to serve cached page to all users not logged in and to all users logged in but non-admin. The logged in ...
[ { "answer_id": 74745, "author": "fischi", "author_id": 15680, "author_profile": "https://wordpress.stackexchange.com/users/15680", "pm_score": -1, "selected": false, "text": "<p>You can achieve this by </p>\n\n<pre><code>if ( current_user_can( 'manage_options' ) ) {\n // Code for the ...
2012/12/03
[ "https://wordpress.stackexchange.com/questions/74742", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17092/" ]
I would like to identify admin users and non-admin (but logged in) users through cookies. I need this feature because I use Hyper Cache (which uses cookies to identify those who send pages in cache): I would like to serve cached page to all users not logged in and to all users logged in but non-admin. The logged in adm...
You can use [`current_user_can()`](http://codex.wordpress.org/Function_Reference/current_user_can) to detect what type of user is logged in, if any, then use [`setcookie()`](http://us.php.net/manual/en/function.setcookie.php) and [`$_COOKIE`](http://us.php.net/manual/en/reserved.variables.cookies.php) to test and set t...
74,748
<p>I'm running multisite with each subsite using the same custom theme. I'm using NHP Options for logo upload and contact page info changes in that theme.</p> <p>I'd like to add a site list page to the main site (which is using a different theme) and have each subsites logo be displayed beside its name in the list.</p...
[ { "answer_id": 74750, "author": "developdaly", "author_id": 3293, "author_profile": "https://wordpress.stackexchange.com/users/3293", "pm_score": 0, "selected": false, "text": "<p>Using <code>get_option()</code> will do the unserializing for you and is much easier.</p>\n\n<pre><code>&lt;...
2012/12/03
[ "https://wordpress.stackexchange.com/questions/74748", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24356/" ]
I'm running multisite with each subsite using the same custom theme. I'm using NHP Options for logo upload and contact page info changes in that theme. I'd like to add a site list page to the main site (which is using a different theme) and have each subsites logo be displayed beside its name in the list. Getting the...
may be its a late reply, but i hope this code will help you and anothers to solve this problem. ``` <?php global $wpdb; $blogs = $wpdb->get_results("SELECT blog_id FROM {$wpdb->blogs} WHERE site_id = '{$wpdb->siteid}' AND spam = '0' AND deleted = '0' AND archived = '0' AND blog_id != 1 "); $sites = array(); ...
74,762
<p>Is there a hook for the popup window which shows up when you click on the edit button on an image in a post?</p>
[ { "answer_id": 74809, "author": "ggutenberg", "author_id": 1979, "author_profile": "https://wordpress.stackexchange.com/users/1979", "pm_score": -1, "selected": false, "text": "<pre><code>add_filter( 'attachment_fields_to_edit', 'attachment_fields_to_edit', null, 2 );\nadd_filter( 'attac...
2012/12/03
[ "https://wordpress.stackexchange.com/questions/74762", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23974/" ]
Is there a hook for the popup window which shows up when you click on the edit button on an image in a post?
The answer is *there is no damn hook for the edit button*. It's just a bunch of JS contained within `wp-includes/js/tinymce/plugins/wpeditimage/plugin.js`. I've included the barebones of what you need below. Key points: a. Clicking an element with a `data-wp-imgselect` attribute will open the image edit dialogue. Yo...
74,772
<p>How to make admin theme option with image slide show so admin can change image dynamicly (user can upload and change the image and title slider) as a slideshow on the webpage? Thank you for any feedback.</p> <p>Note: without any plugin</p>
[ { "answer_id": 74809, "author": "ggutenberg", "author_id": 1979, "author_profile": "https://wordpress.stackexchange.com/users/1979", "pm_score": -1, "selected": false, "text": "<pre><code>add_filter( 'attachment_fields_to_edit', 'attachment_fields_to_edit', null, 2 );\nadd_filter( 'attac...
2012/12/03
[ "https://wordpress.stackexchange.com/questions/74772", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16683/" ]
How to make admin theme option with image slide show so admin can change image dynamicly (user can upload and change the image and title slider) as a slideshow on the webpage? Thank you for any feedback. Note: without any plugin
The answer is *there is no damn hook for the edit button*. It's just a bunch of JS contained within `wp-includes/js/tinymce/plugins/wpeditimage/plugin.js`. I've included the barebones of what you need below. Key points: a. Clicking an element with a `data-wp-imgselect` attribute will open the image edit dialogue. Yo...
74,773
<p>I've included the javascript by </p> <pre><code>wp_enqueue_script('slider', plugins_url( 'slider.js', __FILE__ ) ); </code></pre> <p>with just a simple</p> <pre><code>$(document).ready(function () { alert("alert"); }); </code></pre> <p>It shows up in the browser but doesn't prompt me with "alert".</p> <p>PS...
[ { "answer_id": 74775, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 2, "selected": true, "text": "<p>A few things:</p>\n\n<ol>\n<li>The version of jQuery that ships with WordPress is run in noConflict() mode. Meaning y...
2012/12/03
[ "https://wordpress.stackexchange.com/questions/74773", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15816/" ]
I've included the javascript by ``` wp_enqueue_script('slider', plugins_url( 'slider.js', __FILE__ ) ); ``` with just a simple ``` $(document).ready(function () { alert("alert"); }); ``` It shows up in the browser but doesn't prompt me with "alert". PS: Forgot to mention I've also included the jquery, but s...
A few things: 1. The version of jQuery that ships with WordPress is run in noConflict() mode. Meaning you have to use `jQuery` instead of `$` when you make your first reference. 2. Don't register your own version of jQuery when you're developing. You're locking yourself in to a single version that may or may not be co...
74,779
<p>With this line everything works fine - (as a <strong>Non-Wordpress</strong> index.php): </p> <pre><code>&lt;link href="style.css" rel="stylesheet" type="text/css"/&gt; </code></pre> <p>When I activate the file as a wp theme and replace above line with: </p> <pre><code>&lt;link href="&lt;?php bloginfo('styleshe...
[ { "answer_id": 74780, "author": "user1576978", "author_id": 23576, "author_profile": "https://wordpress.stackexchange.com/users/23576", "pm_score": 2, "selected": false, "text": "<p>you should declare the full url to your theme , eq:</p>\n\n<pre><code>&lt;img id=\"thinker01\" src=\"&lt;?...
2012/12/03
[ "https://wordpress.stackexchange.com/questions/74779", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24334/" ]
With this line everything works fine - (as a **Non-Wordpress** index.php): ``` <link href="style.css" rel="stylesheet" type="text/css"/> ``` When I activate the file as a wp theme and replace above line with: ``` <link href="<?php bloginfo('stylesheet_url');?>" rel="stylesheet" type="text/css"/> ``` everything...
> > images folder is inside theme's folder. > > > But relative URLs do not work that way. They are relative to the URL not to the filesystem path. Your problem is here: `<img id="thinker01" src="images/thinker01.png" width="120" height="163" />` If you look at the request (via HttpFox or other means) you will se...
74,785
<p>The site I'm working on will have a very large number of unique user roles via a members plugin. Because of that, I'd like to have the Role drop-down selection on the Add New User page to display roles alphabetically, rather than descending order of creation. </p> <p>Is there any way to do this?</p>
[ { "answer_id": 74790, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 2, "selected": false, "text": "<p>Apparently there's a filter that you can use in the <code>get_editable_roles</code> function (which is call...
2012/12/03
[ "https://wordpress.stackexchange.com/questions/74785", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24371/" ]
The site I'm working on will have a very large number of unique user roles via a members plugin. Because of that, I'd like to have the Role drop-down selection on the Add New User page to display roles alphabetically, rather than descending order of creation. Is there any way to do this?
Almost the same approach *One Trick Pony* has chosen, but I am using translated names and `uasort()` (to preserve the keys): ``` add_filter( 'editable_roles', 't5_sort_editable_roles' ); /** * Array of roles. * * @wp-hook editable_roles * @param array $roles * @return array */ function t5_sort_editable_roles...
74,786
<p>I would like to change the appearance of the categories and archives widgets in the sidebar such that each category/month alternates the row color. The only way I know how to accomplish this requires modifying the PHP code in the core that generates the category and archives widgets (outputting alternating css style...
[ { "answer_id": 74787, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 1, "selected": false, "text": "<p>Use the <a href=\"https://developer.mozilla.org/en-US/docs/CSS/%3anth-child\" rel=\"nofollow\"><code>:nth-c...
2012/12/03
[ "https://wordpress.stackexchange.com/questions/74786", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18774/" ]
I would like to change the appearance of the categories and archives widgets in the sidebar such that each category/month alternates the row color. The only way I know how to accomplish this requires modifying the PHP code in the core that generates the category and archives widgets (outputting alternating css styles d...
Use the [`:nth-child()`](https://developer.mozilla.org/en-US/docs/CSS/%3anth-child) pseudo-class: ``` li:nth-child(odd){ background-color: white; } li:nth-child(even){ background-color: green; } ```
74,791
<p>I am customizing the WP admin area and want the functions I am using to only affect a specific user. Any Ideas on how to write this?</p>
[ { "answer_id": 74787, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 1, "selected": false, "text": "<p>Use the <a href=\"https://developer.mozilla.org/en-US/docs/CSS/%3anth-child\" rel=\"nofollow\"><code>:nth-c...
2012/12/03
[ "https://wordpress.stackexchange.com/questions/74791", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3246/" ]
I am customizing the WP admin area and want the functions I am using to only affect a specific user. Any Ideas on how to write this?
Use the [`:nth-child()`](https://developer.mozilla.org/en-US/docs/CSS/%3anth-child) pseudo-class: ``` li:nth-child(odd){ background-color: white; } li:nth-child(even){ background-color: green; } ```
74,837
<p>Help! I want to change my "Previous" and "Next" post links to use the actual post titles. I have done all kinds of online research and code manipulation without any success.</p> <p>I am using the Yoko theme. Here is my current single.php code. What do I need to update it to be? My website is www.thelawstudentswife....
[ { "answer_id": 74799, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 4, "selected": true, "text": "<p>A transient is set to reflect the state of the cron, which gets deleted when all tasks complete. Any subsequ...
2012/12/03
[ "https://wordpress.stackexchange.com/questions/74837", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24374/" ]
Help! I want to change my "Previous" and "Next" post links to use the actual post titles. I have done all kinds of online research and code manipulation without any success. I am using the Yoko theme. Here is my current single.php code. What do I need to update it to be? My website is www.thelawstudentswife.com ``` <...
A transient is set to reflect the state of the cron, which gets deleted when all tasks complete. Any subsequent requests are ignored if that transient is found...
74,841
<p>I'm trying to display multiple feeds using the fetch_feed function. Its working well thus far except I can't figure out why the title for each individual rss feed will not show up. Here is my code:</p> <pre><code>&lt;?php // Get RSS Feed(s) include_once(ABSPATH . WPINC . '/feed.php'); $rsslist = array( 'http://ww...
[ { "answer_id": 74850, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": true, "text": "<p>I don't see anything to suggest that <a href=\"http://codex.wordpress.org/Function_Reference/fetch_feed\" rel=...
2012/12/03
[ "https://wordpress.stackexchange.com/questions/74841", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24392/" ]
I'm trying to display multiple feeds using the fetch\_feed function. Its working well thus far except I can't figure out why the title for each individual rss feed will not show up. Here is my code: ``` <?php // Get RSS Feed(s) include_once(ABSPATH . WPINC . '/feed.php'); $rsslist = array( 'http://www.lt11.com/rss',...
I don't see anything to suggest that [`fetch_feed`](http://codex.wordpress.org/Function_Reference/fetch_feed) is supposed to accept an array of values. That is not mentioned in the Codex, nor the source, [`@param string $url URL to retrieve feed`](http://core.trac.wordpress.org/browser/trunk/wp-includes/feed.php#L523)....
74,852
<p>I'm trying to add a java script file to my admin header and use admin-ajax.php to use ajax in my wp-admin (still learning a lot about the process). I've created a custom folder in my theme_directory/js called custom with the file I need to add to the admin header but it doesn't seem to be working. here's the code:...
[ { "answer_id": 74855, "author": "ItsPronounced", "author_id": 1414, "author_profile": "https://wordpress.stackexchange.com/users/1414", "pm_score": 3, "selected": true, "text": "<p>Ahh ok I figured it out while researching. I needed to add the $hook parameter and pass it to my function ...
2012/12/04
[ "https://wordpress.stackexchange.com/questions/74852", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1414/" ]
I'm trying to add a java script file to my admin header and use admin-ajax.php to use ajax in my wp-admin (still learning a lot about the process). I've created a custom folder in my theme\_directory/js called custom with the file I need to add to the admin header but it doesn't seem to be working. here's the code: ``...
Ahh ok I figured it out while researching. I needed to add the $hook parameter and pass it to my function like so: ``` function my_admin_enqueue_scripts($hook) { global $current_screen; if ( 'post.php' != $hook ) return; wp_register_script('my-scripts', get_template_directory_uri() . '/js/custom/m...
74,869
<p>I'm using the theme options from the <a href="http://underscores.me/" rel="nofollow">underscores (_s)</a> WP theme as a base for my own theme options. If I wanted to insert the validation from the bottom function into the top function's $output array, how would this be done? </p> <p>At the moment I seem to be repla...
[ { "answer_id": 74855, "author": "ItsPronounced", "author_id": 1414, "author_profile": "https://wordpress.stackexchange.com/users/1414", "pm_score": 3, "selected": true, "text": "<p>Ahh ok I figured it out while researching. I needed to add the $hook parameter and pass it to my function ...
2012/12/04
[ "https://wordpress.stackexchange.com/questions/74869", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4999/" ]
I'm using the theme options from the [underscores (\_s)](http://underscores.me/) WP theme as a base for my own theme options. If I wanted to insert the validation from the bottom function into the top function's $output array, how would this be done? At the moment I seem to be replacing the entire array with my valid...
Ahh ok I figured it out while researching. I needed to add the $hook parameter and pass it to my function like so: ``` function my_admin_enqueue_scripts($hook) { global $current_screen; if ( 'post.php' != $hook ) return; wp_register_script('my-scripts', get_template_directory_uri() . '/js/custom/m...
74,872
<p>I am working on a wp site where I need to manage 500s of child pages for a single page such as About menu can have more child pages need to manage those child pages as sub menu and I have more than 5 such menus. </p> <p>My client is saying that it will cause load to the server. Does this create a problem in server?...
[ { "answer_id": 74855, "author": "ItsPronounced", "author_id": 1414, "author_profile": "https://wordpress.stackexchange.com/users/1414", "pm_score": 3, "selected": true, "text": "<p>Ahh ok I figured it out while researching. I needed to add the $hook parameter and pass it to my function ...
2012/12/04
[ "https://wordpress.stackexchange.com/questions/74872", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/478/" ]
I am working on a wp site where I need to manage 500s of child pages for a single page such as About menu can have more child pages need to manage those child pages as sub menu and I have more than 5 such menus. My client is saying that it will cause load to the server. Does this create a problem in server? If yes, i...
Ahh ok I figured it out while researching. I needed to add the $hook parameter and pass it to my function like so: ``` function my_admin_enqueue_scripts($hook) { global $current_screen; if ( 'post.php' != $hook ) return; wp_register_script('my-scripts', get_template_directory_uri() . '/js/custom/m...
74,878
<p>I am having a strange issue with permalinks while using the <code>/%postname%/</code> structure.</p> <p>I can access my custom post types using the pretty permalink <code>localhost/cpu/&lt;post-type&gt;/&lt;post-title&gt;/</code> but I am getting a 404 error on Pages. The url of a page is <code>localhost/cpu/&lt;pa...
[ { "answer_id": 74855, "author": "ItsPronounced", "author_id": 1414, "author_profile": "https://wordpress.stackexchange.com/users/1414", "pm_score": 3, "selected": true, "text": "<p>Ahh ok I figured it out while researching. I needed to add the $hook parameter and pass it to my function ...
2012/12/04
[ "https://wordpress.stackexchange.com/questions/74878", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17305/" ]
I am having a strange issue with permalinks while using the `/%postname%/` structure. I can access my custom post types using the pretty permalink `localhost/cpu/<post-type>/<post-title>/` but I am getting a 404 error on Pages. The url of a page is `localhost/cpu/<page-title>/` My `.htaccess` file (generated automati...
Ahh ok I figured it out while researching. I needed to add the $hook parameter and pass it to my function like so: ``` function my_admin_enqueue_scripts($hook) { global $current_screen; if ( 'post.php' != $hook ) return; wp_register_script('my-scripts', get_template_directory_uri() . '/js/custom/m...
74,891
<p>I'm displaying list or archives using </p> <pre><code>&lt;?php get_archives('monthly', '', 'html', '', '', FALSE); ?&gt; </code></pre> <p>and my list displays </p> <p>December 2012 November 2012 etc </p> <p>However I would like to format this to display:</p> <p>12.12 11.12 10.12 etc </p> <p>Any ideas?</p>
[ { "answer_id": 74900, "author": "shea", "author_id": 19726, "author_profile": "https://wordpress.stackexchange.com/users/19726", "pm_score": 0, "selected": false, "text": "<p>Try changing the date display format under <em>Settings > General</em> in your WordPress admin. Choose the <stron...
2012/12/04
[ "https://wordpress.stackexchange.com/questions/74891", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4986/" ]
I'm displaying list or archives using ``` <?php get_archives('monthly', '', 'html', '', '', FALSE); ?> ``` and my list displays December 2012 November 2012 etc However I would like to format this to display: 12.12 11.12 10.12 etc Any ideas?
There is but the filter sucks, it only gives you the link HTML: ``` add_filter( 'get_archives_link', 'wpse74891_archives_link' ); function wpse74891_archives_link( $link ) { $link = preg_replace_callback( '/>([A-Za-z]+\s+\d{4})/', function( $matches ) { return '>' . date( 'm.y', strtotime( $matches[1] ) );...
74,893
<p>I'm using woocommerce as my e-commerce solution and the metabox plugin ( <a href="http://www.deluxeblogtips.com/meta-box/" rel="nofollow">http://www.deluxeblogtips.com/meta-box/</a> ) to make my life a lot easier when implementing meta boxes. I've never had any issues with it but I now need to add my own custom meta...
[ { "answer_id": 75488, "author": "mroncetwice", "author_id": 13424, "author_profile": "https://wordpress.stackexchange.com/users/13424", "pm_score": 2, "selected": false, "text": "<p>Here's the metabox code what I'm using which is working fine for me:</p>\n\n<pre><code>// Add meta boxes w...
2012/12/04
[ "https://wordpress.stackexchange.com/questions/74893", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20095/" ]
I'm using woocommerce as my e-commerce solution and the metabox plugin ( <http://www.deluxeblogtips.com/meta-box/> ) to make my life a lot easier when implementing meta boxes. I've never had any issues with it but I now need to add my own custom meta box to the woocommerce product post type....but it never gets added? ...
Here's the metabox code what I'm using which is working fine for me: ``` // Add meta boxes with TinyMCE via wp_editor() function // Define the custom box add_action( 'add_meta_boxes', 'product_details_add' ); // Do something with the data entered add_action( 'save...
74,896
<p>I'm using WooCommerce on my Wordpress site, and have a widget in the sidebar showing all product categories. It's setup to hide empty categories, and that works well. However, it still shows categories that contain only products that are out of stock - that I would like to change.</p> <p>Technical explanation: WooC...
[ { "answer_id": 74993, "author": "Steve", "author_id": 23132, "author_profile": "https://wordpress.stackexchange.com/users/23132", "pm_score": 0, "selected": false, "text": "<p>If you go to WooCommerce => Settings and select the 'Inventory' tab you'll see an option to 'Hide out of stock i...
2012/12/04
[ "https://wordpress.stackexchange.com/questions/74896", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23417/" ]
I'm using WooCommerce on my Wordpress site, and have a widget in the sidebar showing all product categories. It's setup to hide empty categories, and that works well. However, it still shows categories that contain only products that are out of stock - that I would like to change. Technical explanation: WooCommerce pr...
Use the `woocommerce_product_categories_widget_args` and `woocommerce_get_availability` filters in a custom function to filter the product categories widget for out of stock products. See what you can come up using these filters and post the code back here if you get stuck. Here's some code from my site which may hel...
74,899
<p>I have this code which displays images with their captions in a list. On clicking caption, opens image in an attachment page, but clicking on image, opens that image with a dark-gray background. Is there a way to display image on attachment page on clicking on it?? I played alot with it, but no success.</p> <pre><c...
[ { "answer_id": 74914, "author": "Oleg Butuzov", "author_id": 14536, "author_profile": "https://wordpress.stackexchange.com/users/14536", "pm_score": 0, "selected": false, "text": "<p>have you tried switch statment in wp-config?</p>\n\n<pre><code>/* URLS - not used anymore - doesn't work ...
2012/12/04
[ "https://wordpress.stackexchange.com/questions/74899", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24411/" ]
I have this code which displays images with their captions in a list. On clicking caption, opens image in an attachment page, but clicking on image, opens that image with a dark-gray background. Is there a way to display image on attachment page on clicking on it?? I played alot with it, but no success. ``` $i = 0; ...
I agree with @robin and tend to use that search & replace tool (interconnectit) for more complex DB's. For simple installs though, I like to use [Peach](http://petesaia.github.com/Peach/), since it's a slightly less involved process. I'll often start off trying Peach, and then move to interconnectit's tool if there are...
74,924
<p>I want to disable author pages for certain users, for example the admin user doesn't post anything but still has an author page. </p> <p>Is that possible? Maybe a plugin that adds an option to the users page in the admin panel to enable/disable the author page?</p>
[ { "answer_id": 74927, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>I would recommend filtering <a href=\"http://core.trac.wordpress.org/browser/tags/3.4.2/wp-includes/author-...
2012/12/04
[ "https://wordpress.stackexchange.com/questions/74924", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23974/" ]
I want to disable author pages for certain users, for example the admin user doesn't post anything but still has an author page. Is that possible? Maybe a plugin that adds an option to the users page in the admin panel to enable/disable the author page?
I think a combination of the answers so far along with an admin area field to disable the author archive(s) is the best bet. A class to wrap everything up (along with some constants and methods that will be clear later): ``` <?php class Author_Archive_Disabler { // meta key that will store the disabled status ...
74,934
<p>I'm working on a theme that has a number of image sizes defined correctly using:</p> <pre><code>add_image_size( 'name', 500, 200, true ); </code></pre> <p>I would like to override these defined sizes from the child theme:</p> <pre><code>add_image_size( 'new-name', 400, 300, true ); </code></pre> <p>I know I can ...
[ { "answer_id": 74936, "author": "robin", "author_id": 19635, "author_profile": "https://wordpress.stackexchange.com/users/19635", "pm_score": -1, "selected": false, "text": "<p>In your chile theme you would need to use \n<code>add_action( 'after_setup_theme','new-name');</code></p>\n" ...
2012/12/04
[ "https://wordpress.stackexchange.com/questions/74934", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7968/" ]
I'm working on a theme that has a number of image sizes defined correctly using: ``` add_image_size( 'name', 500, 200, true ); ``` I would like to override these defined sizes from the child theme: ``` add_image_size( 'new-name', 400, 300, true ); ``` I know I can add new sizes, but if I add the same name i.e: `...
The [**`add_image_size( $name, $width, $height, $crop )`**](http://codex.wordpress.org/Function_Reference/add_image_size) function is graceful enough to handle multiple calls using the same `$name`. It simply [overwrites the existing value](http://core.trac.wordpress.org/browser/tags/3.4.2/wp-includes/media.php#L185): ...
74,940
<p>What is the wordpress wp-includes folder for? That is, whats the fundamental architectural purpose of it, for example why isn't it all in themes or an admin folder?</p> <p>Can a plugin developer rely in it's contents (e.g. jQuery) and for how long?</p> <p>I would also like to know, who decides what goes in there a...
[ { "answer_id": 74941, "author": "Zach", "author_id": 9605, "author_profile": "https://wordpress.stackexchange.com/users/9605", "pm_score": 0, "selected": false, "text": "<p><code>wp-includes</code> is the directory that contains most of WordPress' main functionality. It's where all the m...
2012/12/04
[ "https://wordpress.stackexchange.com/questions/74940", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22458/" ]
What is the wordpress wp-includes folder for? That is, whats the fundamental architectural purpose of it, for example why isn't it all in themes or an admin folder? Can a plugin developer rely in it's contents (e.g. jQuery) and for how long? I would also like to know, who decides what goes in there and how does it ge...
`wp-includes` contains everything needed to run WordPress via the frontend ( and then some ). It is the territory of WordPress Core, and as the adage goes, never modify core under any circumstances. While `wp-content` may define plugins and themes, the API itself and the vast majority of the WordPress core sits in tha...
74,953
<p>I would like to know how I can determine if a post/page has an image gallery (not documents/videos etc)? I am not talking about gallery shortcode as shown here <a href="https://wordpress.stackexchange.com/questions/20218/check-if-post-page-has-gallery">Check if post/page has gallery?</a></p> <p>so that</p> <pre><c...
[ { "answer_id": 74955, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 2, "selected": false, "text": "<p>You could use <code>get_posts</code> and search for image attachments.</p>\n\n<pre><code>&lt;?php\n$image...
2012/12/04
[ "https://wordpress.stackexchange.com/questions/74953", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16419/" ]
I would like to know how I can determine if a post/page has an image gallery (not documents/videos etc)? I am not talking about gallery shortcode as shown here [Check if post/page has gallery?](https://wordpress.stackexchange.com/questions/20218/check-if-post-page-has-gallery) so that ``` if (has_gallery = true){ ...
You could use `get_posts` and search for image attachments. ``` <?php $images = get_posts(array( 'post_parent' => $the_parent_to_check, // whatever this is 'post_type' => 'attachment', // attachments 'post_mime_type' => 'image', // only image attachments 'post_status' => 'inherit', // attach...
74,975
<p>In current version of WordPress it is quite easy to expand the attachments fields using <code>attachment_fields_to_edit</code> filter, but in latest <strong>WordPress 3.5 RC2</strong> it's not working. We can expand it using custom meta fields, but using this requires editing each attachment in Media tb. I was wonde...
[ { "answer_id": 75766, "author": "eddiemoya", "author_id": 51, "author_profile": "https://wordpress.stackexchange.com/users/51", "pm_score": 1, "selected": false, "text": "<p>You should still be able to use attachment_fields_to_edit, however those fields are also added to the modal window...
2012/12/04
[ "https://wordpress.stackexchange.com/questions/74975", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11897/" ]
In current version of WordPress it is quite easy to expand the attachments fields using `attachment_fields_to_edit` filter, but in latest **WordPress 3.5 RC2** it's not working. We can expand it using custom meta fields, but using this requires editing each attachment in Media tb. I was wondering if it is possible to e...
You can add inputs and fields to attachments by hooking into `attachment_fields_to_edit`. This will add fields to both the modal as well as the attachment editor. The catch I found is that WordPress (if anyone has experienced differently PLMK) doesn't save the extra fields data so you have to hook into a couple other i...
75,031
<p>I'm trying to order the main query on the 'Jobs' post type archive page. I want to order them by a meta_key so the ones which have a value (i.e. are checked as Featured') are shown first. Here's what I have at the moment..</p> <pre><code>function featured_jobs_order( $orderby ) { if( !is_post_type_archive('job...
[ { "answer_id": 75039, "author": "Matthew Boynes", "author_id": 12324, "author_profile": "https://wordpress.stackexchange.com/users/12324", "pm_score": 1, "selected": false, "text": "<p>That happens because of the way WordPress structures the MySQL queries, and the way <code>posts</code> ...
2012/12/05
[ "https://wordpress.stackexchange.com/questions/75031", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24124/" ]
I'm trying to order the main query on the 'Jobs' post type archive page. I want to order them by a meta\_key so the ones which have a value (i.e. are checked as Featured') are shown first. Here's what I have at the moment.. ``` function featured_jobs_order( $orderby ) { if( !is_post_type_archive('jobs') ) { ...
That happens because of the way WordPress structures the MySQL queries, and the way `posts` joins `postmeta`. If a post doesn't have a value in `featured`, it won't join. Here are two options for you: 1. Update the way you're storing `featured` to store the value regardless (either '1' or '0'). Ensure that every post ...
75,041
<p>I can only really seem to find documentation on wether one get_field exists or not.</p> <p>Is it possible to put multiple get_field's into one variable and use that variable to check if any of the singular get_field variables exist?</p> <p>So for example I have these variables below, and then put them all into one...
[ { "answer_id": 75052, "author": "28inch", "author_id": 23589, "author_profile": "https://wordpress.stackexchange.com/users/23589", "pm_score": 0, "selected": false, "text": "<p>Are you sure that your 'get_field()' function returns NULL when a field is not set? I think isset is giving you...
2012/12/05
[ "https://wordpress.stackexchange.com/questions/75041", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11327/" ]
I can only really seem to find documentation on wether one get\_field exists or not. Is it possible to put multiple get\_field's into one variable and use that variable to check if any of the singular get\_field variables exist? So for example I have these variables below, and then put them all into one: `$promotions...
ACF does not return NULL variables, it will return an empty. Try checking with `!empty` instead of `isset`.
75,046
<pre><code>Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 81 bytes) in /home/public_html/hol/wp-includes/meta.php on line 571 </code></pre> <p>I'm receiving this error when I try to log into my wordpress blog as admin. If I login anything else lower than level 3 everything works fine!...
[ { "answer_id": 75050, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 3, "selected": true, "text": "<p>Turn off all plugins. Switch to TwentyTen. Then install the debug bar and helpers. Then switch back to custom theme ...
2012/12/05
[ "https://wordpress.stackexchange.com/questions/75046", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
``` Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 81 bytes) in /home/public_html/hol/wp-includes/meta.php on line 571 ``` I'm receiving this error when I try to log into my wordpress blog as admin. If I login anything else lower than level 3 everything works fine! I tried removing ...
Turn off all plugins. Switch to TwentyTen. Then install the debug bar and helpers. Then switch back to custom theme - reload. Turn one plugin on - reload, next plugin - reload, etc.
75,069
<p>I am costuming a template. There is a list grabbing the introduction from the first 1-2 paragraphs (all the articles from a category). If I set the excerpt to 295 words, sometimes the list grabs additional words from the next paragraph. I would like to add a Read More tag to stop it. Can someone help me with that pa...
[ { "answer_id": 75076, "author": "Freddy", "author_id": 5516, "author_profile": "https://wordpress.stackexchange.com/users/5516", "pm_score": 0, "selected": false, "text": "<p>To get what you want you need to do two things.</p>\n\n<p>1) Establish a custom excerpt length (in words, not cha...
2012/12/05
[ "https://wordpress.stackexchange.com/questions/75069", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24476/" ]
I am costuming a template. There is a list grabbing the introduction from the first 1-2 paragraphs (all the articles from a category). If I set the excerpt to 295 words, sometimes the list grabs additional words from the next paragraph. I would like to add a Read More tag to stop it. Can someone help me with that part?...
You can grab the first one or two paragraphs with a regular expression (regexp) ``` function custom_excerpt( $content = '' ){ if( empty( $content ) ) return $content; $result = ''; $matches = array(); // grab all paragraphs from $content preg_match_all( '#<\s*p[^>]*>(.*?)<\s*/\s*p>#ui', ...
75,071
<p>I have a <code>404.php</code> template for my theme. I also have <code>WP_DEBUG</code> in wp-config.php set to <code>TRUE</code>.</p> <p>Consider this 404 template:</p> <pre><code>get_header(); ?&gt; &lt;div id="content" style="full-width"&gt; &lt;div id="post-&lt;?php the_ID(); ?&gt;" &lt;?php post_class(); ...
[ { "answer_id": 75073, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/the_ID\" rel=\"nofollow\"><code>the_ID</code></a> is ...
2012/12/05
[ "https://wordpress.stackexchange.com/questions/75071", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21329/" ]
I have a `404.php` template for my theme. I also have `WP_DEBUG` in wp-config.php set to `TRUE`. Consider this 404 template: ``` get_header(); ?> <div id="content" style="full-width"> <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <div class="post-content"> Whatever. </div> ...
[`the_ID`](http://codex.wordpress.org/Function_Reference/the_ID) is meant for use in the Loop. Even if your Loop starts in `get_header` not everything is going to have proper loop. It kinda looks like that what is happening, but on the other hand `have_posts`, which should start your Loop, should mean the Loop doesn't ...
75,079
<p>I am curious whether Wordpress is able to run nested <code>meta_query</code>, with each having different relation keys? As of Wordpress 3.0, <code>tax_query</code> is able to perform this function; I'm wondering whether this has an equivalent with <code>meta_query</code>.</p> <pre><code>$results = query_posts( arra...
[ { "answer_id": 82145, "author": "vmassuchetto", "author_id": 7385, "author_profile": "https://wordpress.stackexchange.com/users/7385", "pm_score": 3, "selected": false, "text": "<p>That seems to be impossible. Please someone correct me if I'm wrong.</p>\n\n<p>The <code>meta_query</code> ...
2012/12/05
[ "https://wordpress.stackexchange.com/questions/75079", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11379/" ]
I am curious whether Wordpress is able to run nested `meta_query`, with each having different relation keys? As of Wordpress 3.0, `tax_query` is able to perform this function; I'm wondering whether this has an equivalent with `meta_query`. ``` $results = query_posts( array( 'post_type' => 'event_id', 'meta_que...
The question was for Wordpress 3.0, but just in case someone has the same question for a more recent version, from Wordpress Codex: > > "Starting with version 4.1, meta\_query clauses can be nested in order to construct complex queries." > > > <https://developer.wordpress.org/reference/classes/wp_query/#custom-fi...
75,103
<p>There are multiple ways to identify if a plugin is active (<a href="https://wordpress.stackexchange.com/questions/14410/how-to-check-if-a-plugin-is-enabled-through-api">here's one)</a> but how can we identify if a specific JetPack component is active, for example <a href="http://jetpack.me/support/photon/" rel="nofo...
[ { "answer_id": 75107, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 3, "selected": false, "text": "<p>Checking for the option value <code>jetpack_active_modules</code>.</p>\n\n<p><img src=\"https://i.stack.imgu...
2012/12/06
[ "https://wordpress.stackexchange.com/questions/75103", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1057/" ]
There are multiple ways to identify if a plugin is active ([here's one)](https://wordpress.stackexchange.com/questions/14410/how-to-check-if-a-plugin-is-enabled-through-api) but how can we identify if a specific JetPack component is active, for example [Photon](http://jetpack.me/support/photon/)?
We just committed a new function to Jetpack Trunk, and it should be enabled in the next release, `Jetpack::is_module_active()` -- <http://plugins.trac.wordpress.org/changeset/716884> Then you can just call: ``` if( class_exists( 'Jetpack' ) && Jetpack::is_module_active( 'contact-form' ) ) {} ``` Or at least, you ...
75,106
<p>I performed a MySQL dump of my WordPress production database to be imported into my local development environment. I plan on frequently performing this database dump and import. Is it possible for me to AVOID running a search &amp; replace script or a MySQL query that updates all of the permalinks, site URLs, etc?</...
[ { "answer_id": 75109, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 2, "selected": false, "text": "<p>What you posted will work fine for all links that are generated by WordPress: permalinks, script/style en...
2012/12/06
[ "https://wordpress.stackexchange.com/questions/75106", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17193/" ]
I performed a MySQL dump of my WordPress production database to be imported into my local development environment. I plan on frequently performing this database dump and import. Is it possible for me to AVOID running a search & replace script or a MySQL query that updates all of the permalinks, site URLs, etc? Could I...
What you posted will work fine for all links that are generated by WordPress: permalinks, script/style enqueues for local files, featured images, etc. I tend to define my Site URL and Home URL dynamically like this: ``` <?php define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']); define('WP_SITEURL', WP_HOME . '/wp');...
75,111
<p>Hi I wanted to change the default WordPress gallery short-code and make it a slider.</p> <pre><code> remove_shortcode( 'gallery' ); function gallery_filter( $atts, $content = null ) { extract(shortcode_atts(array('gallery_name' =&gt; ''), $args)); $args = array( 'post_type' =&gt; 'attachment', ...
[ { "answer_id": 75109, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 2, "selected": false, "text": "<p>What you posted will work fine for all links that are generated by WordPress: permalinks, script/style en...
2012/12/06
[ "https://wordpress.stackexchange.com/questions/75111", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23617/" ]
Hi I wanted to change the default WordPress gallery short-code and make it a slider. ``` remove_shortcode( 'gallery' ); function gallery_filter( $atts, $content = null ) { extract(shortcode_atts(array('gallery_name' => ''), $args)); $args = array( 'post_type' => 'attachment', 'numberposts' ...
What you posted will work fine for all links that are generated by WordPress: permalinks, script/style enqueues for local files, featured images, etc. I tend to define my Site URL and Home URL dynamically like this: ``` <?php define('WP_HOME', 'http://' . $_SERVER['HTTP_HOST']); define('WP_SITEURL', WP_HOME . '/wp');...
75,130
<p>I'm trying to do something similar to this question here: <a href="https://wordpress.stackexchange.com/questions/36013/remove-action-or-remove-filter-with-external-classes">remove_action or remove_filter with external classes?</a> </p> <p>I'm trying to remove the </p> <blockquote> <p><code>&lt;!-- This site is o...
[ { "answer_id": 75140, "author": "Steve Claridge", "author_id": 1941, "author_profile": "https://wordpress.stackexchange.com/users/1941", "pm_score": 2, "selected": false, "text": "<p>I don't think you are going to be able to do that using <code>remove_action</code>. The function argument...
2012/12/06
[ "https://wordpress.stackexchange.com/questions/75130", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2204/" ]
I'm trying to do something similar to this question here: [remove\_action or remove\_filter with external classes?](https://wordpress.stackexchange.com/questions/36013/remove-action-or-remove-filter-with-external-classes) I'm trying to remove the > > `<!-- This site is optimized with the Yoast WordPress SEO plugin...
A simple way to achieve this (but without the Class approach) is by filtering the output of `wp_head` action hook using the [output buffering](http://uk.php.net/manual/en/ref.outcontrol.php). In your theme's `header.php`, wrap the `wp_head()` call with `ob_start($cb)` and `ob_end_flush();` functions like: ``` ob_star...
75,135
<p>Normally, a MySQL database can be exported and imported using these simple SSH commands:</p> <p><strong>Export:</strong></p> <pre><code>mysqldump -u USERNAME -p DATABASE_NAME &gt; filename.sql </code></pre> <p><strong>Import:</strong></p> <pre><code>mysql -u USERNAME -p DATABASE_NAME &lt; filename.sql </code></p...
[ { "answer_id": 75137, "author": "Steve Claridge", "author_id": 1941, "author_profile": "https://wordpress.stackexchange.com/users/1941", "pm_score": 5, "selected": true, "text": "<p>It is that simple for Wordpress too. I use the following to back up my WP sites:</p>\n\n<pre><code>mysqldu...
2012/12/06
[ "https://wordpress.stackexchange.com/questions/75135", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10691/" ]
Normally, a MySQL database can be exported and imported using these simple SSH commands: **Export:** ``` mysqldump -u USERNAME -p DATABASE_NAME > filename.sql ``` **Import:** ``` mysql -u USERNAME -p DATABASE_NAME < filename.sql ``` But it's not that simple when it comes to WordPress. From what I see, additional...
It is that simple for Wordpress too. I use the following to back up my WP sites: ``` mysqldump -u <user> -p<pass> --quick --extended-insert <db-name> > backup.sql ``` [The mysqldump document](http://dev.mysql.com/doc/refman/5.1/en/mysqldump.html) gives the details on all the parameters. `--extended-insert` is quick...
75,149
<p>I've seen all the documentation in the codex, but I am doing something wrong since it doesn't work!</p> <p>I want to implement this jQuery plugin (<a href="https://github.com/davidcrawford/typist-jquery" rel="nofollow noreferrer">https://github.com/davidcrawford/typist-jquery</a>) in my welcome page (<a href="http:...
[ { "answer_id": 75143, "author": "RRikesh", "author_id": 17305, "author_profile": "https://wordpress.stackexchange.com/users/17305", "pm_score": 3, "selected": true, "text": "<p>Update your <code>wp_options</code> table.</p>\n\n<p>Look for <code>siteurl</code> and <code>home</code> and ch...
2012/12/06
[ "https://wordpress.stackexchange.com/questions/75149", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24500/" ]
I've seen all the documentation in the codex, but I am doing something wrong since it doesn't work! I want to implement this jQuery plugin (<https://github.com/davidcrawford/typist-jquery>) in my welcome page ([www.english.intermediavs.com](http://www.english.intermediavs.com)). I've added this code in my function.ph...
Update your `wp_options` table. Look for `siteurl` and `home` and change their values to point to your localhost, that is, `http://localhost/mylocalsite`. This should be enough to make your site work again. You don't need to find and replace all instances where the old url is present. For example you [should not chan...
75,157
<p>Following the solution from Jeff @ <a href="https://wordpress.stackexchange.com/questions/46994/custom-permalinks-post-type-hierarchical-taxonomys">Custom permalinks - post type - hierarchical taxonomy&#39;s</a></p> <p>I managed to rewrite my url's for custom taxonomy's. However i do have one thing that bothers me ...
[ { "answer_id": 75160, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 1, "selected": false, "text": "<p>There is a quick and somewhat dirty potential solution to this. I say 'potential' because I can't spot the pr...
2012/12/06
[ "https://wordpress.stackexchange.com/questions/75157", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24417/" ]
Following the solution from Jeff @ [Custom permalinks - post type - hierarchical taxonomy's](https://wordpress.stackexchange.com/questions/46994/custom-permalinks-post-type-hierarchical-taxonomys) I managed to rewrite my url's for custom taxonomy's. However i do have one thing that bothers me and that is a double slas...
After changing something i have the final code that makes it work. This is where you register the post types. (not changed) ``` register_post_type( "products", array( 'label' => CUSTOM_MENU_TITLE, 'labels' => array( 'name' => CUSTOM_MENU_NAM...
75,161
<p>We have a multisite setup, the primary domain needs to have www.primary.net, and secure.primary.net mapped in wordpress so the primary site's content loads on both. The problem we are facing is secure.primary.com doesn't work. secure.primary.net always ends up at: <a href="http://www.primary.net/wp-signup.php?new=se...
[ { "answer_id": 75162, "author": "Tyler Carter", "author_id": 16921, "author_profile": "https://wordpress.stackexchange.com/users/16921", "pm_score": 0, "selected": false, "text": "<p>There is a table where WordPress stores the Path->Blog ID references. IF you add another record that poin...
2012/12/06
[ "https://wordpress.stackexchange.com/questions/75161", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20603/" ]
We have a multisite setup, the primary domain needs to have www.primary.net, and secure.primary.net mapped in wordpress so the primary site's content loads on both. The problem we are facing is secure.primary.com doesn't work. secure.primary.net always ends up at: <http://www.primary.net/wp-signup.php?new=secure.primar...
Install [WordPress MU Domain Mapping*Plugin*](http://wordpress.org/extend/plugins/wordpress-mu-domain-mapping/), and edit the `wp_domain_mapping` database table. Insert a new row for `blog_id` #1 manually, for example: ``` +------+-----------+----------------------+----------+ | id | blog_id | domain ...
75,194
<p>Running a dedicated managed server with 2 GIGS of RAM. How much memory can I define in <code>wp-config.php</code></p> <p>Currently I have </p> <pre><code>define('WP_MEMORY_LIMIT', '256M'); </code></pre> <p>I suspect a plugin that resizes images when they are being uploaded, that might cause the server to crash, b...
[ { "answer_id": 75221, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 0, "selected": false, "text": "<p>I have had some great success using <a href=\"http://www.cloudflare.com/plans\" rel=\"nofollow\">cloud flare<...
2012/12/06
[ "https://wordpress.stackexchange.com/questions/75194", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23634/" ]
Running a dedicated managed server with 2 GIGS of RAM. How much memory can I define in `wp-config.php` Currently I have ``` define('WP_MEMORY_LIMIT', '256M'); ``` I suspect a plugin that resizes images when they are being uploaded, that might cause the server to crash, but I am not sure yet. How can I allocate mo...
The easiest way to go would be to use an "Origin Pull" CDN. These sorts of delivery networks pull media directly from your site, cache it (usually for the TTL defined by your Cache related HTTP headers). Any origin pull CDN will work fine with multi-site. You rewrite all static resource URLs in your content to the CDN...
75,197
<p>I run a multiple author platform with more than 1000 writers. Most users writer their content externally (Microsoft Word, OpenOffice etc) and paste it into the Visual Editor. Around 20% of the articles have a double space after every single period.</p> <p>Feedback from the users tells me that some versions of these...
[ { "answer_id": 75205, "author": "Alex Lane", "author_id": 16016, "author_profile": "https://wordpress.stackexchange.com/users/16016", "pm_score": 1, "selected": false, "text": "<p>Add this to your <code>functions.php</code> file</p>\n\n<pre><code>&lt;?php\n\nfunction my_the_content_filte...
2012/12/06
[ "https://wordpress.stackexchange.com/questions/75197", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22585/" ]
I run a multiple author platform with more than 1000 writers. Most users writer their content externally (Microsoft Word, OpenOffice etc) and paste it into the Visual Editor. Around 20% of the articles have a double space after every single period. Feedback from the users tells me that some versions of these programs ...
I cannot offer a JavaScript solution, because I am not sure where exactly this is happening. But … we can hook into `wp_insert_post_data` and solve this issue in PHP: ``` add_filter( 'wp_insert_post_data', 't5_strip_double_spaces', 20 ); function t5_strip_double_spaces( $data ) { $data['post_content'] = preg_rep...
75,258
<p>I got this code that rewrite the url's for custom posttypes. It works but only for a depth where the posttitle is on the 5th segment. How can i adjust it so it accepts multiple depths?</p> <p>e.g.:</p> <pre><code>http://www.mydomain.com/post_type/category1/postname/ http://www.mydomain.com/post_type/category1/chil...
[ { "answer_id": 75277, "author": "jochem", "author_id": 24417, "author_profile": "https://wordpress.stackexchange.com/users/24417", "pm_score": 2, "selected": true, "text": "<p>After testing countless different structures i came up with this. It's manual work specifying each category but ...
2012/12/07
[ "https://wordpress.stackexchange.com/questions/75258", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24417/" ]
I got this code that rewrite the url's for custom posttypes. It works but only for a depth where the posttitle is on the 5th segment. How can i adjust it so it accepts multiple depths? e.g.: ``` http://www.mydomain.com/post_type/category1/postname/ http://www.mydomain.com/post_type/category1/child1/postname/ http://w...
After testing countless different structures i came up with this. It's manual work specifying each category but gives me more control. If someone comes up with a better solution, please let me know. ``` function mmp_rewrite_rules($rules) { //Product structure $newRules['product/(.+)/(.+)/(.+)/(.+)/?$'] = 'index.php?...
75,263
<p>Recently I made a theme for my WordPress blog. Now I want to filter(remove) my 5 latest post from the main page (<code>index.php</code>) and show them in a slider. Now my 5 latest posts are showing in the first page and slider simultaneously :(</p> <h1>Update:</h1> <p>Thanks for your reply. I couldn't solve my pro...
[ { "answer_id": 75271, "author": "swtshweta", "author_id": 14123, "author_profile": "https://wordpress.stackexchange.com/users/14123", "pm_score": -1, "selected": false, "text": "<p>Please check whether you have added wp_reset_query() while ending the loop. Moreover, you can also check wh...
2012/12/07
[ "https://wordpress.stackexchange.com/questions/75263", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21035/" ]
Recently I made a theme for my WordPress blog. Now I want to filter(remove) my 5 latest post from the main page (`index.php`) and show them in a slider. Now my 5 latest posts are showing in the first page and slider simultaneously :( Update: ======= Thanks for your reply. I couldn't solve my problem. this is my index...
I don't know if WP has a built in feature for it's query but you could do something like this: ``` $count = 0; if(have_posts()) : while (have_posts()) : the_post(); if ($count < 4 ) { $count++; } else { ... your blogroll code ... } endwhile; endif; ```
75,266
<p>I try to insert a post with <code>html tag</code> with <code>class</code> attribute, like this: <code>&lt;dl class="dl-horizontal"&gt;</code>, but after saving the post, WP removes an attribute.<br> How can I fix it?<br> The only way I've found, is to make a <code>shortcode</code>: </p> <pre><code>add_shortcode('a...
[ { "answer_id": 75267, "author": "theMojoWill", "author_id": 20503, "author_profile": "https://wordpress.stackexchange.com/users/20503", "pm_score": 1, "selected": false, "text": "<p>Make sure you stay in the HTML mode in the text editor. Sometimes going back in and making changes in the ...
2012/12/07
[ "https://wordpress.stackexchange.com/questions/75266", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16331/" ]
I try to insert a post with `html tag` with `class` attribute, like this: `<dl class="dl-horizontal">`, but after saving the post, WP removes an attribute. How can I fix it? The only way I've found, is to make a `shortcode`: ``` add_shortcode('attr', 'html_attr'); function html_attr( $atts, $content = null ){ ...
Please look at the TinyMCE Advanced plugin. <http://wordpress.org/extend/plugins/tinymce-advanced/> You can configure it to leave certain tags alone. it's really useful.
75,305
<p>I have registered a custom post type [equipment] and have a taxonomy of [equipment_type] within the taxonomy I have parent and child categories. For example: </p> <p>Equipment (Custom post type)</p> <p>Equipment Types (Taxonomy)</p> <p>Cameras (Parent term)</p> <ul> <li><p>Camera A (Child term)</p></li> <li><p>C...
[ { "answer_id": 75367, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>The WordPress Template Hierarchy provides the exact template file that you need: <a href=\"http://codex.wor...
2012/12/07
[ "https://wordpress.stackexchange.com/questions/75305", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24556/" ]
I have registered a custom post type [equipment] and have a taxonomy of [equipment\_type] within the taxonomy I have parent and child categories. For example: Equipment (Custom post type) Equipment Types (Taxonomy) Cameras (Parent term) * Camera A (Child term) * Camera B What I would like to create is effectively...
I want to document this because I just found the answer recently. The problem with having taxonomy is that most developers have the **mindset of expecting** the taxonomy to be seen inside the `post_type` url of: ``` http://hostname/post_type/taxonomy_term ``` Instead, you are going to find the url in: ``` http:/...
75,307
<p>I have a custom post type 'properties' that I'd like to control the HTML output for. For simplicity, let's focus on the <strong>archive</strong> view.</p> <p>As a basic example, here is what a loop looks like in an <code>archive.php</code> file:</p> <pre><code>&lt;?php while ( have_posts() ) : the_post(); ?&gt; ...
[ { "answer_id": 75640, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 0, "selected": false, "text": "<p>You can change the loop via hook, like this for cpt 'my_post_type '</p>\n\n<pre><code>// $this? - example was used...
2012/12/07
[ "https://wordpress.stackexchange.com/questions/75307", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6816/" ]
I have a custom post type 'properties' that I'd like to control the HTML output for. For simplicity, let's focus on the **archive** view. As a basic example, here is what a loop looks like in an `archive.php` file: ``` <?php while ( have_posts() ) : the_post(); ?> <h2><?php the_title(); ?></h2> <div><?php the...
There're two very often forgotten action ref arrays: `loop_start/_end()`. Just turn on output buffering and you're ready to go. ``` add_action( 'loop_start', 'wpse75307_plugin_loop' ); add_action( 'loop_end', 'wpse75307_plugin_loop' ); /** * Callback function triggered during: * + 'loop_start'/`have_posts()` after ...
75,311
<p>I am using the standard wordpress loop that looks like:</p> <pre><code> &lt;?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?&gt; &lt;h2&gt;&lt;?php the_title(); ?&gt;&lt;/h2&gt; &lt;?php endwhile; else: ?&gt; &lt;h2&gt;We're sorry...there is no content.&lt;/h2&gt; &lt;?ph...
[ { "answer_id": 75313, "author": "Steve Claridge", "author_id": 1941, "author_profile": "https://wordpress.stackexchange.com/users/1941", "pm_score": 0, "selected": false, "text": "<p>This should help you:</p>\n\n<p><a href=\"https://wordpress.stackexchange.com/questions/74345/get-the-chi...
2012/12/07
[ "https://wordpress.stackexchange.com/questions/75311", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9820/" ]
I am using the standard wordpress loop that looks like: ``` <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <h2><?php the_title(); ?></h2> <?php endwhile; else: ?> <h2>We're sorry...there is no content.</h2> <?php endif; ?> ``` Then, what I wanted to do was exclude a c...
I recommend you use the `pre_get_posts` filter or ditch `query_posts` and use `WP Query`. That way you can easily use `category__not_in (array)` parameter and not mess any other loops up. ``` function exclude_category($query) { // this requires term id instead of term name so change "20" to the "sport" id // this as...
75,336
<p>I have a list of products on a page and am trying to order them by a custom field called "price". Unfortunately, $3,950,000 is coming before $349,000. I've used a couple of codes but neither one is working. Does anyone have any suggestions? Thanks.</p> <p>Here's the first code I've tried.</p> <pre><code>$query = n...
[ { "answer_id": 75341, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": true, "text": "<p>You are storing your \"price\" (apparently) as human readable formatted currency. That makes it a string. And ...
2012/12/07
[ "https://wordpress.stackexchange.com/questions/75336", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24569/" ]
I have a list of products on a page and am trying to order them by a custom field called "price". Unfortunately, $3,950,000 is coming before $349,000. I've used a couple of codes but neither one is working. Does anyone have any suggestions? Thanks. Here's the first code I've tried. ``` $query = new WP_Query( array ( ...
You are storing your "price" (apparently) as human readable formatted currency. That makes it a string. And that means it is going to be sorted alphabetically, more or less, and not numerically as you need it to be. If you can store those values without the punctuation, and use `meta_value_num`-- your second query abov...
75,380
<p>Is it possible for a WordPress site to display the users default Gravatar image (of chosen set, eg Retro, Identicon, etc), rather than the users uploaded avatar? As in, all user avatars next to comments would be a generated 'Retro' picture, regardless of whether they had a custom avatar at Gravatar or not.</p> <p><...
[ { "answer_id": 75382, "author": "Sudar", "author_id": 24579, "author_profile": "https://wordpress.stackexchange.com/users/24579", "pm_score": 1, "selected": false, "text": "<p>Yeah it is possible.</p>\n\n<p>Just add a function to the <code>get_avatar</code> hook</p>\n\n<pre><code>functio...
2012/12/08
[ "https://wordpress.stackexchange.com/questions/75380", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
Is it possible for a WordPress site to display the users default Gravatar image (of chosen set, eg Retro, Identicon, etc), rather than the users uploaded avatar? As in, all user avatars next to comments would be a generated 'Retro' picture, regardless of whether they had a custom avatar at Gravatar or not. **Screensho...
Found you can create the address manually to return the image from Gravatar, and pass in parameters to force default and theme. Combined this in part with @Sudar's answer, as well as the code from `pluggable.php` as the admin page will grab the ID not email from `$id_or_email`, so a check needed to be added so the admi...
75,381
<p>I have the following code which gives be posts that are published in the last 100 days</p> <pre><code>function smbd_cats_by_days ($where = '') { $where .= " AND post_date &lt; '" . date('y-m-d', strtotime("-100 days")) . "'"; return $where; } add_filter('posts_where', 'smbd_cats_by_days'); </code></pre> ...
[ { "answer_id": 75389, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 3, "selected": true, "text": "<p>I was afraid you wanted that one. <a href=\"https://wordpress.stackexchange.com/questions/45901/passing-a-para...
2012/12/08
[ "https://wordpress.stackexchange.com/questions/75381", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24579/" ]
I have the following code which gives be posts that are published in the last 100 days ``` function smbd_cats_by_days ($where = '') { $where .= " AND post_date < '" . date('y-m-d', strtotime("-100 days")) . "'"; return $where; } add_filter('posts_where', 'smbd_cats_by_days'); ``` It is working fine. But no...
I was afraid you wanted that one. [You can't really do that](https://wordpress.stackexchange.com/questions/45901/passing-a-parameter-to-filter-and-action-functions). Follow the link for some workarounds. You could also set a variable or a constant in `functions.php`, or create a theme option for this. Then use that in ...
75,395
<p>I have uninstalled and then reinstalled all my plugins hoping to restore my WordPress installation to its original state because I have problem with the funtion of RevieAzon plugin. </p> <p>For example, BEFORE I delete the WP Policies plugin I modified the categories in menu area but went I reinstall it the plugin ...
[ { "answer_id": 75389, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 3, "selected": true, "text": "<p>I was afraid you wanted that one. <a href=\"https://wordpress.stackexchange.com/questions/45901/passing-a-para...
2012/12/08
[ "https://wordpress.stackexchange.com/questions/75395", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24584/" ]
I have uninstalled and then reinstalled all my plugins hoping to restore my WordPress installation to its original state because I have problem with the funtion of RevieAzon plugin. For example, BEFORE I delete the WP Policies plugin I modified the categories in menu area but went I reinstall it the plugin is not in ...
I was afraid you wanted that one. [You can't really do that](https://wordpress.stackexchange.com/questions/45901/passing-a-parameter-to-filter-and-action-functions). Follow the link for some workarounds. You could also set a variable or a constant in `functions.php`, or create a theme option for this. Then use that in ...
75,424
<p>I was turned down with <a href="https://wordpress.stackexchange.com/questions/75401/simple-jquery-script-not-working-in-wordpress">this question</a> because I get a php error and my question revolves around jquery, but when I take out the JQUERY everything works fine. <strong>* Again I'm creating a wordpress plugin....
[ { "answer_id": 75432, "author": "Kuldeep Daftary", "author_id": 20241, "author_profile": "https://wordpress.stackexchange.com/users/20241", "pm_score": 2, "selected": false, "text": "<p>Use plugins like :</p>\n\n<p><a href=\"http://wordpress.org/extend/plugins/wp-dummy-content/\" rel=\"n...
2012/12/09
[ "https://wordpress.stackexchange.com/questions/75424", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23013/" ]
I was turned down with [this question](https://wordpress.stackexchange.com/questions/75401/simple-jquery-script-not-working-in-wordpress) because I get a php error and my question revolves around jquery, but when I take out the JQUERY everything works fine. **\* Again I'm creating a wordpress plugin. I am trying show a...
Use plugins like : [WP DUMMY CONTENT](http://wordpress.org/extend/plugins/wp-dummy-content/) > > Easy generation and deletion of blog posts, pages, and sub pages for developers. Full site structure in one click. > > > [DEMO DATA CREATOR](http://wordpress.org/extend/plugins/demo-data-creator/) > > Demo Data C...
75,443
<p>Hi i'd like to order by multiple meta_keys</p> <p>want to make it order using these keys</p> <p>adminscore + user_like + _count-views_all + comment_count</p> <p>combine these keys how should i array order it??</p> <p>i try this but not work..</p> <pre><code> $args = array( 'meta_key' =&gt; 'adminsc...
[ { "answer_id": 75478, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 1, "selected": false, "text": "<p>The only thing you can do here is to use the <a href=\"http://codex.wordpress.org/Plugin_API/Filter_Re...
2012/12/09
[ "https://wordpress.stackexchange.com/questions/75443", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24596/" ]
Hi i'd like to order by multiple meta\_keys want to make it order using these keys adminscore + user\_like + \_count-views\_all + comment\_count combine these keys how should i array order it?? i try this but not work.. ``` $args = array( 'meta_key' => 'adminscore' + 'user_like' + '_count-views_all' ...
This line is wrong: ``` 'meta_key' => 'adminscore' + 'user_like' + '_count-views_all' + 'comment_count', ``` `'meta_key'` only accepts string value. What you need is an additional meta key, e.g. "totalscore" that holds the total value of the scores you have for all the meta values. You can manually run a php functi...
75,445
<p>When I write my site's title, description, posts, pages, or a taxonomy description, small dashes <code>&amp;#45;</code> are turned into longer, uglier ones <code>&amp;#8211;</code>.</p> <p>Is there some way to stop this from happening? Can I put some sort of function in my functions.php? Any ideas?</p>
[ { "answer_id": 75478, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 1, "selected": false, "text": "<p>The only thing you can do here is to use the <a href=\"http://codex.wordpress.org/Plugin_API/Filter_Re...
2012/12/09
[ "https://wordpress.stackexchange.com/questions/75445", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2979/" ]
When I write my site's title, description, posts, pages, or a taxonomy description, small dashes `&#45;` are turned into longer, uglier ones `&#8211;`. Is there some way to stop this from happening? Can I put some sort of function in my functions.php? Any ideas?
This line is wrong: ``` 'meta_key' => 'adminscore' + 'user_like' + '_count-views_all' + 'comment_count', ``` `'meta_key'` only accepts string value. What you need is an additional meta key, e.g. "totalscore" that holds the total value of the scores you have for all the meta values. You can manually run a php functi...
75,455
<p>I´d like to set specific featured image for all posts in one category.</p> <p>So, if I have category Good Jokes, all posts in category Good Jokes will have the same featured image displayed in front page.</p> <p>My current code in content.php is:</p> <pre><code>&lt;?php if(trim(get_the_post_thumbnail($post-&gt;ID...
[ { "answer_id": 75478, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 1, "selected": false, "text": "<p>The only thing you can do here is to use the <a href=\"http://codex.wordpress.org/Plugin_API/Filter_Re...
2012/12/09
[ "https://wordpress.stackexchange.com/questions/75455", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24600/" ]
I´d like to set specific featured image for all posts in one category. So, if I have category Good Jokes, all posts in category Good Jokes will have the same featured image displayed in front page. My current code in content.php is: ``` <?php if(trim(get_the_post_thumbnail($post->ID)) != '' and $themolio_options['sh...
This line is wrong: ``` 'meta_key' => 'adminscore' + 'user_like' + '_count-views_all' + 'comment_count', ``` `'meta_key'` only accepts string value. What you need is an additional meta key, e.g. "totalscore" that holds the total value of the scores you have for all the meta values. You can manually run a php functi...
75,465
<p>I would like to add the CSS class of the current menu item (and the classes of its parents &amp; ancestors) to the current page body classes.</p> <p>For example, if the current menu item has a CSS class "products" (as defined in Appearance | Menus), then the body for the corresponding page should also have the clas...
[ { "answer_id": 75471, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 0, "selected": false, "text": "<p>In the answer <a href=\"https://wordpress.stackexchange.com/questions/33249/how-to-add-current-parent-...
2012/12/09
[ "https://wordpress.stackexchange.com/questions/75465", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24604/" ]
I would like to add the CSS class of the current menu item (and the classes of its parents & ancestors) to the current page body classes. For example, if the current menu item has a CSS class "products" (as defined in Appearance | Menus), then the body for the corresponding page should also have the class "products". ...
This is what I managed to cobble together thanks to Mridul Aggarwal's hints: ``` function pa_assign_menu_class_to_body(){ // 'main' is the theme_location, set earlier using register_nav_menus() $menu_name = 'main'; $class_list = array(); if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $me...
75,470
<p>I cannot find documentation or discussions on what is and how to use Drop-in plugins.<br /> The question was raised in this Q&amp;A, <a href="https://wordpress.stackexchange.com/q/75420/12615">Populate content on install</a>.</p> <p><em>Is a <code>wp-content/install.php</code> file that redefines the pluggable funct...
[ { "answer_id": 75476, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 4, "selected": true, "text": "<p>To answer your question, Yes</p>\n\n<p>In fact, there are many other functions you can override in that...
2012/12/09
[ "https://wordpress.stackexchange.com/questions/75470", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12615/" ]
I cannot find documentation or discussions on what is and how to use Drop-in plugins. The question was raised in this Q&A, [Populate content on install](https://wordpress.stackexchange.com/q/75420/12615). *Is a `wp-content/install.php` file that redefines the pluggable function [`wp_install_defaults`](http://core.t...
To answer your question, Yes In fact, there are many other functions you can override in that file, it's included as the first line of "wp-admin/includes/upgrade.php" & there are many functions inside to be overridden Unfortunately, there is not too much information available regarding drop-in plugins but i'll try to...
75,475
<p>I want to add a list (like a cd track list) of names and links to all images next my nextgen gallery, how can I retrieve this list? (similar to the list in the select object in the Gallery Settings, in the gallery admin page)</p>
[ { "answer_id": 75481, "author": "Upeksha", "author_id": 19683, "author_profile": "https://wordpress.stackexchange.com/users/19683", "pm_score": 1, "selected": false, "text": "<p>You may use a function similar to below one to retrieve a list of image properties in a Next-Gen image gallery...
2012/12/09
[ "https://wordpress.stackexchange.com/questions/75475", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24608/" ]
I want to add a list (like a cd track list) of names and links to all images next my nextgen gallery, how can I retrieve this list? (similar to the list in the select object in the Gallery Settings, in the gallery admin page)
Ok, this has worked for me. ``` <?php // get the track list global $nggdb; $gallery = $nggdb->get_gallery ($galleryID, 'sortorder', 'ASC', true, 0, 0); ?> <div id="tracklist"> <?php foreach($gallery as $image) { ?> <div class="single_image" id="image-<?php echo $image->pid; ?>"> <a href="<?php the_permalink(...
75,491
<p>I've identified two methods of separating pages in nav menu on my blog (<a href="http://reasonandfolly.com" rel="nofollow">http://reasonandfolly.com</a>) but cannot figure out what php or css file needs to be modified to achieve the result and will admit to not knowing the difference between "span class" and "span d...
[ { "answer_id": 75494, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 1, "selected": false, "text": "<p>This is one of the code i have used in the past. The below code goes in your functions.php</p>\n\n<pre...
2012/12/09
[ "https://wordpress.stackexchange.com/questions/75491", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24591/" ]
I've identified two methods of separating pages in nav menu on my blog (<http://reasonandfolly.com>) but cannot figure out what php or css file needs to be modified to achieve the result and will admit to not knowing the difference between "span class" and "span divider." Until I get a better handle on basic WP coding,...
This is one of the code i have used in the past. The below code goes in your functions.php ``` class MP_Footer_Menu extends Walker_Nav_Menu { function start_el(&$output, $item, $depth = 0, $args = array(), $id = 0) { STATIC $counter = 0; if ($counter++) $output .= '<li class="divider">...
75,492
<p>I am developing a blog where the main posts are of a custom post type.</p> <p>Let's assume it is a Book custom post type.</p> <p>I want the /author/admin page to list the books of the author admin, but instead, it goes and searches for Posts of admin, which is the built-in basic post type.</p> <p>How do I make my...
[ { "answer_id": 75493, "author": "Shaon", "author_id": 7805, "author_profile": "https://wordpress.stackexchange.com/users/7805", "pm_score": -1, "selected": false, "text": "<p>use the parameter post_type=your-custom-post-type-slug-here</p>\n\n<p>for example if your post type slug is \"pro...
2012/12/09
[ "https://wordpress.stackexchange.com/questions/75492", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15943/" ]
I am developing a blog where the main posts are of a custom post type. Let's assume it is a Book custom post type. I want the /author/admin page to list the books of the author admin, but instead, it goes and searches for Posts of admin, which is the built-in basic post type. How do I make my custom post type Book t...
You can modify all main queries *before* they happen via the [`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) action and a check if [`is_main_query`](http://codex.wordpress.org/Function_Reference/is_main_query): ``` function wpa75492_post_type_query( $query ) { if ( $query->i...
75,496
<p>I have a link on my post edit page (admin side) that calls up AJAX and jQuery to run a function inside my <code>functions.php</code> page. The link is wired up and calling the jQuery but I can't seem to debug whats going on inside my function thats being called from jQuery. I want the clicked link to delete custom...
[ { "answer_id": 75498, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 3, "selected": true, "text": "<p>You aren't echoing anything so you aren't going to get much of an AJAX response. All you are doing with AJAX, ...
2012/12/09
[ "https://wordpress.stackexchange.com/questions/75496", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1414/" ]
I have a link on my post edit page (admin side) that calls up AJAX and jQuery to run a function inside my `functions.php` page. The link is wired up and calling the jQuery but I can't seem to debug whats going on inside my function thats being called from jQuery. I want the clicked link to delete custom metadata for th...
You aren't echoing anything so you aren't going to get much of an AJAX response. All you are doing with AJAX, really, is loading a webpage with Javascript. If the page doesn't print anything, you don't see anything. You don't need to return anything from AJAX but if you don't you will have a hard time working out wheth...
75,507
<p>I'm looking to create a /menu/widget area like the following site:</p> <p><a href="http://www.microsoft.com/en-gb/default.aspx" rel="nofollow">http://www.microsoft.com/en-gb/default.aspx</a></p> <p>please see sections under downloads, security, support, about</p> <p>is this considered a footer menu as well? my th...
[ { "answer_id": 75520, "author": "jb510", "author_id": 2932, "author_profile": "https://wordpress.stackexchange.com/users/2932", "pm_score": 0, "selected": false, "text": "<p>FYI, what you should be looking/googling for is usually referred to as a \"Mega Menu\".</p>\n\n<p>There are severa...
2012/12/09
[ "https://wordpress.stackexchange.com/questions/75507", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24622/" ]
I'm looking to create a /menu/widget area like the following site: <http://www.microsoft.com/en-gb/default.aspx> please see sections under downloads, security, support, about is this considered a footer menu as well? my theme's footer menu is just a standard menu on the bottom right corner of the theme like the exam...
I'm going to assume you're using Twenty Eleven theme, or another theme that supports child themes. If you're using a custom theme, then you can just edit the existing Functions.php and add your additional functionality there, and then edit the existing Style.css. However, if your situation is different, please post bac...
75,508
<p>I am using Woocommerce and I have products in a category called B2B whose single_product.php is only to be shown to people with the capability read_b2b. </p> <pre><code>&lt;?php if ( have_posts() ) : ?&gt; &lt;?php do_action('woocommerce_before_shop_loop'); ?&gt; &lt;?php if (is_product_category('b2b')) &amp;&amp; ...
[ { "answer_id": 75514, "author": "Steve", "author_id": 23132, "author_profile": "https://wordpress.stackexchange.com/users/23132", "pm_score": 0, "selected": false, "text": "<p>You might want to take a look at the <a href=\"http://wcdocs.woothemes.com/\" rel=\"nofollow\">WooCommerce docum...
2012/12/09
[ "https://wordpress.stackexchange.com/questions/75508", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24623/" ]
I am using Woocommerce and I have products in a category called B2B whose single\_product.php is only to be shown to people with the capability read\_b2b. ``` <?php if ( have_posts() ) : ?> <?php do_action('woocommerce_before_shop_loop'); ?> <?php if (is_product_category('b2b')) && if current_user_can('read_b2b') { ?...
My guess is that your problem is here: ``` if (is_product_category('b2b')) ``` Taking a look at the [Woocommerce Documention for Conditional Tags](http://wcdocs.woothemes.com/codex/theming/conditional-tags/) `is_product_category()` will return `true` on product category archives. Therefore, it will **never** be true...
75,517
<p>I'm looking to get a number of records back from the database given a list of numbers and was wondering how I would use $wpdb->prepare to do this (to take advantage of the sanitising vs SQL injection attacks that it gives me). </p> <p>A wrong way of going about what I'd like to achieve is <code>$wpdb-&gt;query($wpd...
[ { "answer_id": 75522, "author": "Ralf912", "author_id": 16589, "author_profile": "https://wordpress.stackexchange.com/users/16589", "pm_score": 4, "selected": true, "text": "<p><code>$wpdb-&gt;prepare()</code> use the same syntax for formatting like php's <code>printf()</code>. SSo you w...
2012/12/09
[ "https://wordpress.stackexchange.com/questions/75517", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9519/" ]
I'm looking to get a number of records back from the database given a list of numbers and was wondering how I would use $wpdb->prepare to do this (to take advantage of the sanitising vs SQL injection attacks that it gives me). A wrong way of going about what I'd like to achieve is `$wpdb->query($wpdb->prepare('SELECT...
`$wpdb->prepare()` use the same syntax for formatting like php's `printf()`. SSo you will need something like `... WHERE post_id IN (%d,%d,%d) ...` This will fit for three ids. But what if we got more or less than three ids? We will use the php tools to create the needed formatting string (assuming `$ids` is an array ...
75,548
<p>I have posts which have a custom field date in the format yyyy-mm-dd. What Im trying to do is list all the posts for a specific year on the side of a single page based on the year in the custom field of this post and separated into months.</p> <p>So for example if the post has a custom field date of 1990 then I wan...
[ { "answer_id": 75583, "author": "M-R", "author_id": 17061, "author_profile": "https://wordpress.stackexchange.com/users/17061", "pm_score": 3, "selected": true, "text": "<p>Mysql's <a href=\"http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_month\" rel=\"nofoll...
2012/12/10
[ "https://wordpress.stackexchange.com/questions/75548", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22502/" ]
I have posts which have a custom field date in the format yyyy-mm-dd. What Im trying to do is list all the posts for a specific year on the side of a single page based on the year in the custom field of this post and separated into months. So for example if the post has a custom field date of 1990 then I want to list ...
Mysql's [Month function](http://dev.mysql.com/doc/refman/5.5/en/date-and-time-functions.html#function_month) can help you on this. Assuming that your meta value is in SQL date format. ``` ORDER BY MONTH($wpdb->postmeta.meta_value) ASC ```