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
38,581
<p>Not sure how hard this is but i'll try and explain it as simply as possible.</p> <p>I have a custom post type called: "Movies" with an taxonomy term called "Actor"</p> <p>For example purposes suppose were on the taxonomy page "Tom Cruise" which will output a load of posts(movies) that Tom has been in.</p> <p>What...
[ { "answer_id": 38595, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 0, "selected": false, "text": "<p>You need to create a loop that's based off the tax.</p>\n\n<pre><code>$args = array(\n 'actor' =&gt; get...
2012/01/11
[ "https://wordpress.stackexchange.com/questions/38581", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1778/" ]
Not sure how hard this is but i'll try and explain it as simply as possible. I have a custom post type called: "Movies" with an taxonomy term called "Actor" For example purposes suppose were on the taxonomy page "Tom Cruise" which will output a load of posts(movies) that Tom has been in. What i'm trying to work out ...
Just banged this out real quick, it should be a start at least. The basic concept here was to get ALL the posts tagged with the main person (in this case, Tom Cruise, you'll have to setup that variable on your own. Once you have those, iterate through them, and `foreach` movie (Top Gun, Tropic Thunder, Mission Impossib...
38,582
<p>I want to get the full local filename of an uploaded image so that I can copy it to a new directory and process it with my own image processing scripts. Which hooks/actions should I look into to achieve this?</p> <p>Thanks</p>
[ { "answer_id": 38585, "author": "Simon Scarfe", "author_id": 3489, "author_profile": "https://wordpress.stackexchange.com/users/3489", "pm_score": 4, "selected": true, "text": "<p>The <code>handle_upload</code> hook is called after wp_handle_upload is run, and it sends in a named array c...
2012/01/11
[ "https://wordpress.stackexchange.com/questions/38582", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9771/" ]
I want to get the full local filename of an uploaded image so that I can copy it to a new directory and process it with my own image processing scripts. Which hooks/actions should I look into to achieve this? Thanks
The `handle_upload` hook is called after wp\_handle\_upload is run, and it sends in a named array consisting of 'file', 'url' & 'type'. You could possibly use code like this to utilise it, depending on what you need to achieve: ``` function process_images($results) { if( $results['type'] === 'image/jpeg' ) { // or...
38,603
<p>Is there any way to force WordPress 3.3 to use the old Flash uploader instead of the new HTML5 version? (you can read below if you care about why I want to do this...)</p> <p>I'm working with someone on WordPress 3.3 whose image uploader occasionally freezes when bulk uploading large numbers of images. I've tried...
[ { "answer_id": 60008, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 2, "selected": false, "text": "<h2>Context</h2>\n<p>Searching for <code>.swf</code> in the Core, found this in <code>/wp-admin/includes/media....
2012/01/11
[ "https://wordpress.stackexchange.com/questions/38603", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11273/" ]
Is there any way to force WordPress 3.3 to use the old Flash uploader instead of the new HTML5 version? (you can read below if you care about why I want to do this...) I'm working with someone on WordPress 3.3 whose image uploader occasionally freezes when bulk uploading large numbers of images. I've tried troubleshoo...
Context ------- Searching for `.swf` in the Core, found this in `/wp-admin/includes/media.php`: ``` $plupload_init = array( 'runtimes' => 'html5,silverlight,flash,html4', 'browse_button' => 'plupload-browse-button', 'container' => 'plupload-upload-ui', 'drop_element' => 'drag-drop-area', 'file_dat...
38,606
<p>I can get a list of the most recent image attachments like so:</p> <pre><code>$attachments = get_posts( array( 'post_type' =&gt; 'attachment', 'posts_per_page' =&gt; $number, 'post_mime_type' =&gt; 'image' ) ); </code></pre> <p>This returns all images that have been recently uploaded, whether they are ...
[ { "answer_id": 38610, "author": "Shane", "author_id": 10555, "author_profile": "https://wordpress.stackexchange.com/users/10555", "pm_score": 1, "selected": false, "text": "<p>Did you try adding a filter to get_posts. This isn't tested, just a thought after a bit of searching :</p>\n\n<p...
2012/01/11
[ "https://wordpress.stackexchange.com/questions/38606", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43/" ]
I can get a list of the most recent image attachments like so: ``` $attachments = get_posts( array( 'post_type' => 'attachment', 'posts_per_page' => $number, 'post_mime_type' => 'image' ) ); ``` This returns all images that have been recently uploaded, whether they are attached to a post or page, or unat...
Did you try adding a filter to get\_posts. This isn't tested, just a thought after a bit of searching : ``` function my_filter( $query ) { if( is_home() ) //Example, if u want to display recent images on home { $query->set( 'post_type', array( 'attachment', 'my_cpt' ) ); } } add_filter...
38,639
<p>I have a set of image sizes for WordPress that look like this:</p> <pre><code>add_image_size('1039', 1039, 697); add_image_size('960', 960, 644); add_image_size('800', 800, 537); add_image_size('768', 768, 515); add_image_size('640', 640, 429); add_image_size('480', 480, 322); add_image_size('320', 320, 215); add_i...
[ { "answer_id": 38624, "author": "xentek", "author_id": 3207, "author_profile": "https://wordpress.stackexchange.com/users/3207", "pm_score": 0, "selected": false, "text": "<p>Yeah, don't install malicious plugins, or use encryption (see: <a href=\"http://php.net/manual/en/book.mcrypt.php...
2012/01/11
[ "https://wordpress.stackexchange.com/questions/38639", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11960/" ]
I have a set of image sizes for WordPress that look like this: ``` add_image_size('1039', 1039, 697); add_image_size('960', 960, 644); add_image_size('800', 800, 537); add_image_size('768', 768, 515); add_image_size('640', 640, 429); add_image_size('480', 480, 322); add_image_size('320', 320, 215); add_image_size('240...
Actually, there's not too much you can do. If an intruder has direct access to your site - where they can run `get_option()` or perform direct SQL queries - then you've already run into a problem. The safest bet here is to exercise your best judgement when installing new plugins. In other words, the best plan of acti...
38,646
<p>I am writing a theme and in it I have a function which creates two metaboxes. The forth parameter of the "add_meta_box()" function I used can be set to ( high, core, default or low). I want the boxes to appear in a particular order ( ie order within one of these 4 groups - eg with both metaboxes being set to 'priori...
[ { "answer_id": 38648, "author": "Rob Vermeer", "author_id": 11135, "author_profile": "https://wordpress.stackexchange.com/users/11135", "pm_score": 6, "selected": true, "text": "<p>In you PhpMyAdmin query for: (if you have a different database prefix, change that in the query, also chang...
2012/01/12
[ "https://wordpress.stackexchange.com/questions/38646", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6169/" ]
I am writing a theme and in it I have a function which creates two metaboxes. The forth parameter of the "add\_meta\_box()" function I used can be set to ( high, core, default or low). I want the boxes to appear in a particular order ( ie order within one of these 4 groups - eg with both metaboxes being set to 'priorit...
In you PhpMyAdmin query for: (if you have a different database prefix, change that in the query, also change the user\_id to yours) ``` SELECT * FROM `wp_usermeta` WHERE `user_id` =1 AND `meta_key` LIKE 'meta-box%' ``` Than delete those values and you will get the original order back. If you only want to chang...
38,662
<p>I am trying to find some way when using <code>WP_Query</code> of ordering by multiple meta_values. I know I can order by multiple values and I know how to order by meta_values but I cant seem to figure out how to do multiple meta_values. Is it possible ?</p>
[ { "answer_id": 38664, "author": "byronyasgur", "author_id": 6169, "author_profile": "https://wordpress.stackexchange.com/users/6169", "pm_score": 0, "selected": false, "text": "<p>As far as I can tell this is currently impossible, but in my case anyway I was doing dates so I just stored ...
2012/01/12
[ "https://wordpress.stackexchange.com/questions/38662", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6169/" ]
I am trying to find some way when using `WP_Query` of ordering by multiple meta\_values. I know I can order by multiple values and I know how to order by meta\_values but I cant seem to figure out how to do multiple meta\_values. Is it possible ?
you can also store it like yyyy-mm-dd and and use ``` $date_array = explode( '-', $date_string ); ``` to make it into an easy to manage array. or even better change it into a unix timestamp with ``` $unix_time = strtotime( $date_string ); ``` php loves to work with unix time stamps, it's the native format. and...
38,666
<p>I've tried a number of plugins including Add Meta Tags and Meta SEO Pack which add a meta tag description to the home page.</p> <p>But my home page is static so the description is added to my blog page.</p> <p>I know I could add them manually but are there any plugins do this?</p> <p>Thanks</p>
[ { "answer_id": 38664, "author": "byronyasgur", "author_id": 6169, "author_profile": "https://wordpress.stackexchange.com/users/6169", "pm_score": 0, "selected": false, "text": "<p>As far as I can tell this is currently impossible, but in my case anyway I was doing dates so I just stored ...
2012/01/12
[ "https://wordpress.stackexchange.com/questions/38666", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1063/" ]
I've tried a number of plugins including Add Meta Tags and Meta SEO Pack which add a meta tag description to the home page. But my home page is static so the description is added to my blog page. I know I could add them manually but are there any plugins do this? Thanks
you can also store it like yyyy-mm-dd and and use ``` $date_array = explode( '-', $date_string ); ``` to make it into an easy to manage array. or even better change it into a unix timestamp with ``` $unix_time = strtotime( $date_string ); ``` php loves to work with unix time stamps, it's the native format. and...
38,669
<p>After performing a WordPress upgrade to 3.3.1, I can no longer access the administration interface. The website works fine, but when I click on Dashboard, I receive the following error:</p> <p><strong>Fatal error</strong>: Call to undefined function _wp_admin_html_begin() in <strong>/home/a7938356/public_html/wp-ad...
[ { "answer_id": 38664, "author": "byronyasgur", "author_id": 6169, "author_profile": "https://wordpress.stackexchange.com/users/6169", "pm_score": 0, "selected": false, "text": "<p>As far as I can tell this is currently impossible, but in my case anyway I was doing dates so I just stored ...
2012/01/12
[ "https://wordpress.stackexchange.com/questions/38669", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11969/" ]
After performing a WordPress upgrade to 3.3.1, I can no longer access the administration interface. The website works fine, but when I click on Dashboard, I receive the following error: **Fatal error**: Call to undefined function \_wp\_admin\_html\_begin() in **/home/a7938356/public\_html/wp-admin/admin-header.php** o...
you can also store it like yyyy-mm-dd and and use ``` $date_array = explode( '-', $date_string ); ``` to make it into an easy to manage array. or even better change it into a unix timestamp with ``` $unix_time = strtotime( $date_string ); ``` php loves to work with unix time stamps, it's the native format. and...
38,695
<p>I wish to insert large posts in my site, close to 300,000 words.</p> <p>I removed all bold, italics, footnotes etc. and I pasted text in the HTML tab of post admin editor.</p> <p>My posts are truncated to 75656 words.</p> <p>Is there such an upper limit on the number of words per page?</p> <p>If yes, can you pro...
[ { "answer_id": 38764, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 1, "selected": false, "text": "<p>You can hide the submit button, if to much words on the editor. The Editor has an id and also the button; use an s...
2012/01/12
[ "https://wordpress.stackexchange.com/questions/38695", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16266/" ]
I wish to insert large posts in my site, close to 300,000 words. I removed all bold, italics, footnotes etc. and I pasted text in the HTML tab of post admin editor. My posts are truncated to 75656 words. Is there such an upper limit on the number of words per page? If yes, can you propose any alternative as per how...
You can hide the submit button, if to much words on the editor. The Editor has an id and also the button; use an small JS to realized your requirement. An example solution for the comment form can you find at the follow code and more infos on [this post](http://wpengineer.com/2321/comment-length-limiter/). ``` jQuery(...
38,696
<p>I am developing a multiple search filters function and I need to filter the search results page.</p> <p>I have 3 custom post types, each one with its custom taxonomy. So I have the custom post types: <br></p> <ol> <li><b>CPT</b> books; <br></li> <li><b>CPT</b> fruits;<br></li> <li><b>CPT</b> cars<br></li> </ol> <...
[ { "answer_id": 38721, "author": "dwenaus", "author_id": 4229, "author_profile": "https://wordpress.stackexchange.com/users/4229", "pm_score": 2, "selected": false, "text": "<p>in the options value you could use something like this</p>\n\n<pre><code>&lt;option value=\"tax_slug_a[ 103 ]\"&...
2012/01/12
[ "https://wordpress.stackexchange.com/questions/38696", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10275/" ]
I am developing a multiple search filters function and I need to filter the search results page. I have 3 custom post types, each one with its custom taxonomy. So I have the custom post types: 1. **CPT** books; 2. **CPT** fruits; 3. **CPT** cars Each one of these custom post types has a custom taxonomy attached. ...
in the options value you could use something like this ``` <option value="tax_slug_a[ 103 ]">Ford</option> <option value="tax_slug_a[ 24 ]"> Mercedes</option> <option value="tax_slug_b[ 67 ]"> Orange</option> ``` the resulting form submission would give you an array with both chosen the tax slug info and the term id...
38,707
<p>Did some research, but I was unable to implement it after all.</p> <p>I have a custom post type accessible only by a new role. I want to filter the post type listing so that each user should see only his records (as Author users can see their posts only). I've tried to filter parse_query but it works for the main l...
[ { "answer_id": 38721, "author": "dwenaus", "author_id": 4229, "author_profile": "https://wordpress.stackexchange.com/users/4229", "pm_score": 2, "selected": false, "text": "<p>in the options value you could use something like this</p>\n\n<pre><code>&lt;option value=\"tax_slug_a[ 103 ]\"&...
2012/01/12
[ "https://wordpress.stackexchange.com/questions/38707", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11506/" ]
Did some research, but I was unable to implement it after all. I have a custom post type accessible only by a new role. I want to filter the post type listing so that each user should see only his records (as Author users can see their posts only). I've tried to filter parse\_query but it works for the main listing on...
in the options value you could use something like this ``` <option value="tax_slug_a[ 103 ]">Ford</option> <option value="tax_slug_a[ 24 ]"> Mercedes</option> <option value="tax_slug_b[ 67 ]"> Orange</option> ``` the resulting form submission would give you an array with both chosen the tax slug info and the term id...
38,709
<p>Have had an autocomplete field working for months but has stopped working when not logged in? Not sure when but within the last few days or week (not updated wordpress recently).</p> <p>already have; add_action('wp_ajax_filter_schools', 'filter_schools'); add_action('wp_ajax_nopriv_filter_schools', 'filter_schools'...
[ { "answer_id": 38710, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 4, "selected": true, "text": "<p><strong>Edit:</strong> I've kept my original answer below, however, I'm not sure what I was thinking... Yo...
2012/01/12
[ "https://wordpress.stackexchange.com/questions/38709", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3978/" ]
Have had an autocomplete field working for months but has stopped working when not logged in? Not sure when but within the last few days or week (not updated wordpress recently). already have; add\_action('wp\_ajax\_filter\_schools', 'filter\_schools'); add\_action('wp\_ajax\_nopriv\_filter\_schools', 'filter\_schools...
**Edit:** I've kept my original answer below, however, I'm not sure what I was thinking... You should *never* need to trigger `do_action( 'wp_ajax...' )`. While I can't be sure what the issue is, is the code in the question is roughly ok (I think `$_POST` should be `$_GET` with `.getJSON`). --- Try putting this at t...
38,712
<p>My theme's <code>search.php</code> currently has a few "IF" statements to deal with the different types of search that my website uses.</p> <p>I have a site-wide search, a species (custom post type) specific search and an advanced species search.</p> <p>For the "species" search, I've simply added an input akin to ...
[ { "answer_id": 38710, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 4, "selected": true, "text": "<p><strong>Edit:</strong> I've kept my original answer below, however, I'm not sure what I was thinking... Yo...
2012/01/12
[ "https://wordpress.stackexchange.com/questions/38712", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6344/" ]
My theme's `search.php` currently has a few "IF" statements to deal with the different types of search that my website uses. I have a site-wide search, a species (custom post type) specific search and an advanced species search. For the "species" search, I've simply added an input akin to `<input type="hidden" name="...
**Edit:** I've kept my original answer below, however, I'm not sure what I was thinking... You should *never* need to trigger `do_action( 'wp_ajax...' )`. While I can't be sure what the issue is, is the code in the question is roughly ok (I think `$_POST` should be `$_GET` with `.getJSON`). --- Try putting this at t...
38,741
<p>So I'm working with a non-wordpress theme called "Misty" and it uses this code to pull categories:</p> <pre><code>&lt;li class="sidebox"&gt; &lt;h3&gt;&lt;?php _e('Categories','ml'); ?&gt;&lt;/h3&gt; &lt;ul id="catList"&gt; &lt;?php if (function_exists('wp_list_categories')) { ...
[ { "answer_id": 38744, "author": "Jeremy Ferguson", "author_id": 11846, "author_profile": "https://wordpress.stackexchange.com/users/11846", "pm_score": 3, "selected": true, "text": "<p>The child ul comes with the class \"children\", so you can use this to target your css.<br>\n<code>ul.c...
2012/01/12
[ "https://wordpress.stackexchange.com/questions/38741", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7355/" ]
So I'm working with a non-wordpress theme called "Misty" and it uses this code to pull categories: ``` <li class="sidebox"> <h3><?php _e('Categories','ml'); ?></h3> <ul id="catList"> <?php if (function_exists('wp_list_categories')) { wp_list_categories("show_count=1&include=...
The child ul comes with the class "children", so you can use this to target your css. `ul.children li { }` Even without that, though, you could just use the hierarchy of lists to target.. `ul#catList ul li { }` would target any li within a ul, within the #catList ID.
38,765
<p>I have a problem. I've got a PHP script that tracks individual file downloads, and I'm looking for a way to display that number in individual posts. I've got a half-baked solution- a plain ol' MySQL manual connection script, but I'm trying to convert it to use as a Wordpress plugin (I want it to use WPDB). <strong>I...
[ { "answer_id": 38767, "author": "MathSmath", "author_id": 1537, "author_profile": "https://wordpress.stackexchange.com/users/1537", "pm_score": 1, "selected": false, "text": "<p>Since you only want a single value from a single column, you can use the get_var method instead of the query m...
2012/01/12
[ "https://wordpress.stackexchange.com/questions/38765", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11575/" ]
I have a problem. I've got a PHP script that tracks individual file downloads, and I'm looking for a way to display that number in individual posts. I've got a half-baked solution- a plain ol' MySQL manual connection script, but I'm trying to convert it to use as a Wordpress plugin (I want it to use WPDB). **I've tried...
Instead of using `$wpdb->query()`, use `$wpdb->get_results()`. This method allows you to specify a return type so the query is returned as an associative array. For example ... ``` $results = $wpdb->get_results( "SELECT * FROM mb_download_manager WHERE filename='" . $namemeta . ".zip'", ARRAY_A ); ``` T...
38,806
<p>I am making a site which will only have password protected pages. I would like it so that the password box is open by default, and is a required fields to publish the post. Ideally I would also remove the 'public' and 'private' options.</p> <p>Is this possible?</p>
[ { "answer_id": 38813, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 0, "selected": false, "text": "<p>You might be much better off using a plugin to make the <em>blog</em> private, as opposed to each individua...
2012/01/13
[ "https://wordpress.stackexchange.com/questions/38806", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9771/" ]
I am making a site which will only have password protected pages. I would like it so that the password box is open by default, and is a required fields to publish the post. Ideally I would also remove the 'public' and 'private' options. Is this possible?
You would be better suited by allowing members to sign up on your site, then giving each uses level permissions to read different posts. A plugin like [Members](http://wordpress.org/extend/plugins/members/) might work for this. But, if you really want to do what you asked, you're going to have to do some javascript ha...
38,808
<p>The plugin <a href="http://urbangiraffe.com/plugins/advanced-permalinks/" rel="nofollow">Advanced Permalinks</a> breaks the RSS feed since Wordpress version 3.1. The developer has stopped working on the plugin, and I haven't seen any solution for it. Since my site is dependent on the plugin I can't just disable it e...
[ { "answer_id": 38813, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 0, "selected": false, "text": "<p>You might be much better off using a plugin to make the <em>blog</em> private, as opposed to each individua...
2012/01/13
[ "https://wordpress.stackexchange.com/questions/38808", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10084/" ]
The plugin [Advanced Permalinks](http://urbangiraffe.com/plugins/advanced-permalinks/) breaks the RSS feed since Wordpress version 3.1. The developer has stopped working on the plugin, and I haven't seen any solution for it. Since my site is dependent on the plugin I can't just disable it either. Does anyone know of a ...
You would be better suited by allowing members to sign up on your site, then giving each uses level permissions to read different posts. A plugin like [Members](http://wordpress.org/extend/plugins/members/) might work for this. But, if you really want to do what you asked, you're going to have to do some javascript ha...
38,809
<p>I'm using the Roots theme which with custom css. </p> <p>I'm using the page "Home" as the front page the page "Blog" as the blog page (in WP reading settings)</p> <p>I'm trying to set the front page "Home" to use the template "full-width", but instead Wordpress ignores this and uses the "front page" template. </p>...
[ { "answer_id": 38813, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 0, "selected": false, "text": "<p>You might be much better off using a plugin to make the <em>blog</em> private, as opposed to each individua...
2012/01/13
[ "https://wordpress.stackexchange.com/questions/38809", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5864/" ]
I'm using the Roots theme which with custom css. I'm using the page "Home" as the front page the page "Blog" as the blog page (in WP reading settings) I'm trying to set the front page "Home" to use the template "full-width", but instead Wordpress ignores this and uses the "front page" template. This only happens o...
You would be better suited by allowing members to sign up on your site, then giving each uses level permissions to read different posts. A plugin like [Members](http://wordpress.org/extend/plugins/members/) might work for this. But, if you really want to do what you asked, you're going to have to do some javascript ha...
38,819
<p>I would like to remove or hide the Biography input field from the profile page. How do you do this? I already removed some contact methods from this page, but I'm not sure how to get rid of the biography.</p>
[ { "answer_id": 38900, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 6, "selected": true, "text": "<p>There is no dedicated hook – user management is a low priority in WordPress. You have to use output buffering (yes, not...
2012/01/13
[ "https://wordpress.stackexchange.com/questions/38819", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11686/" ]
I would like to remove or hide the Biography input field from the profile page. How do you do this? I already removed some contact methods from this page, but I'm not sure how to get rid of the biography.
There is no dedicated hook – user management is a low priority in WordPress. You have to use output buffering (yes, not nice). Here is a simple demonstration how this could be done: ``` add_action( 'personal_options', array ( 'T5_Hide_Profile_Bio_Box', 'start' ) ); /** * Captures the part with the biobox in an outp...
38,823
<p>My friend has a code that will allow users to receive a special key to gain access into into the closed/open beta event for any game they select. When a person is logged in, they can click on a link which will show them a key. If a person is logged logged in, the event page will tell them to login. What my friend...
[ { "answer_id": 48981, "author": "SickHippie", "author_id": 5434, "author_profile": "https://wordpress.stackexchange.com/users/5434", "pm_score": 1, "selected": false, "text": "<pre><code>get_currentuserinfo();\n$username = $current_user-&gt;user_login\n</code></pre>\n\n<p>That should wor...
2012/01/13
[ "https://wordpress.stackexchange.com/questions/38823", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12032/" ]
My friend has a code that will allow users to receive a special key to gain access into into the closed/open beta event for any game they select. When a person is logged in, they can click on a link which will show them a key. If a person is logged logged in, the event page will tell them to login. What my friend needs...
Since the question is asking how to get the user name from the cookies here is a solution: ```php function is_user_administrator(): string { if ( function_exists( 'get_site_option' ) ) { $siteurl = get_site_option( 'siteurl' ); if ( $siteurl ) { $cookie_hash = 'wordpress_logged_in_' . ...
38,825
<p>I've built a directory of members on a non-WP site (using php and mysql). Each member can log in and update their details using a username and password.</p> <p>I want to be able to get this to automatically create a user on the Wordpress site using the details from the directory of members. Ideally, if they update ...
[ { "answer_id": 48981, "author": "SickHippie", "author_id": 5434, "author_profile": "https://wordpress.stackexchange.com/users/5434", "pm_score": 1, "selected": false, "text": "<pre><code>get_currentuserinfo();\n$username = $current_user-&gt;user_login\n</code></pre>\n\n<p>That should wor...
2012/01/13
[ "https://wordpress.stackexchange.com/questions/38825", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5864/" ]
I've built a directory of members on a non-WP site (using php and mysql). Each member can log in and update their details using a username and password. I want to be able to get this to automatically create a user on the Wordpress site using the details from the directory of members. Ideally, if they update their deta...
Since the question is asking how to get the user name from the cookies here is a solution: ```php function is_user_administrator(): string { if ( function_exists( 'get_site_option' ) ) { $siteurl = get_site_option( 'siteurl' ); if ( $siteurl ) { $cookie_hash = 'wordpress_logged_in_' . ...
38,845
<p>I have installed a theme on WordPress added pages, created a custom menu called Primary Nav. I have then assigned this as my Primary Menu. I have child pages and the menu looks like this.</p> <p>I have looked at the WordPress resources to find a solution but it seems as though I have followed the instructions on cr...
[ { "answer_id": 38921, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": 2, "selected": true, "text": "<p>Without seeing your code it's hard to say what you should do to fix it. The code you've supplied is the html...
2012/01/13
[ "https://wordpress.stackexchange.com/questions/38845", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11682/" ]
I have installed a theme on WordPress added pages, created a custom menu called Primary Nav. I have then assigned this as my Primary Menu. I have child pages and the menu looks like this. I have looked at the WordPress resources to find a solution but it seems as though I have followed the instructions on creating dro...
Without seeing your code it's hard to say what you should do to fix it. The code you've supplied is the html output not the PHP code right? [Take a look at one of my previous answers](https://wordpress.stackexchange.com/questions/28501/how-to-create-a-drop-down-menu-like-in-twenty-eleven-theme/28503#28503). Make sure ...
38,846
<p>this is pretty straight forward: How do I redirect mobile users to /mobile, but still allow them to click a "Full site" button and see the full site without being redirected again back to the mobile site?</p> <p>I have played with a bunch of the plugins that say they do this, but none seem to handle the second ste...
[ { "answer_id": 38848, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 0, "selected": false, "text": "<p>Check the <code>$is_iphone;</code> variable. Then do your own redirects.</p>\n" }, { "answer_id": 38892, ...
2012/01/13
[ "https://wordpress.stackexchange.com/questions/38846", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5181/" ]
this is pretty straight forward: How do I redirect mobile users to /mobile, but still allow them to click a "Full site" button and see the full site without being redirected again back to the mobile site? I have played with a bunch of the plugins that say they do this, but none seem to handle the second step. They red...
``` function mobile_redirect() { if (isset($_COOKIE["redirected"]) && $_COOKIE["redirected"]) return; global $is_iphone; if( isset($is_iphone) && $is_iphone ) { wp_redirect( '/mobile/' ); setcookie("redirected", true); exit; } } add_action('init', 'mobile_redirect'); ```...
38,849
<p>My home.php shows a list of (N) posts and &lt;&lt; Previous &amp; Next >> links. When clicked, I want to fetch previous/next list of (N) posts using Ajax. This is: I do NOT want to load the entire page. I just want to get the posts' list and append it to current. </p> <p>For this I make an ajax request and send hre...
[ { "answer_id": 38870, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 1, "selected": false, "text": "<p>Check out <code>WP::parse_request()</code> - unfortunately, it was never really designed for public use. Yo...
2012/01/13
[ "https://wordpress.stackexchange.com/questions/38849", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6076/" ]
My home.php shows a list of (N) posts and << Previous & Next >> links. When clicked, I want to fetch previous/next list of (N) posts using Ajax. This is: I do NOT want to load the entire page. I just want to get the posts' list and append it to current. For this I make an ajax request and send href (URL) as parameter...
Check out `WP::parse_request()` - unfortunately, it was never really designed for public use. You could try this, not sure of the repercussions: ``` global $wp, $wp_the_query; // Grab the request_uri component of the referer URL. if ( ! $url = parse_url( $_GET['my_referer_parameter'] ) ) return 'Oh dear, p...
38,859
<p>Does anyone know how I can have a unique robots.txt file for every domain served by my wp-multisite-installation? I did a search on plugins but couldn't find anything suitable.</p>
[ { "answer_id": 38867, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 3, "selected": true, "text": "<p>Straight from the source, (line 1845 <code>wp-includes/functions.php</code>, 3.3.1):</p>\n\n<pre><code>funct...
2012/01/13
[ "https://wordpress.stackexchange.com/questions/38859", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12041/" ]
Does anyone know how I can have a unique robots.txt file for every domain served by my wp-multisite-installation? I did a search on plugins but couldn't find anything suitable.
Straight from the source, (line 1845 `wp-includes/functions.php`, 3.3.1): ``` function do_robots() { header( 'Content-Type: text/plain; charset=utf-8' ); do_action( 'do_robotstxt' ); $output = "User-agent: *\n"; $public = get_option( 'blog_public' ); if ( '0' == $public ) { $output .= "Di...
38,861
<p>I am trying to add a page to WordPress programatically. I am using this code:</p> <pre><code> function add_media_page(){ if(!(is_page('My New Post'))){ // Create post object $my_post = array( 'post_title' =&gt; 'My new Post', 'post_content' =&gt; 'This is my post.', 'post_status' =&gt; 'publish', ...
[ { "answer_id": 38864, "author": "Rob Vermeer", "author_id": 11135, "author_profile": "https://wordpress.stackexchange.com/users/11135", "pm_score": 2, "selected": false, "text": "<p><code>'post_type' =&gt; ['page']</code> must be <code>'post_type' =&gt; 'page'</code>. Just look at the ex...
2012/01/13
[ "https://wordpress.stackexchange.com/questions/38861", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6169/" ]
I am trying to add a page to WordPress programatically. I am using this code: ``` function add_media_page(){ if(!(is_page('My New Post'))){ // Create post object $my_post = array( 'post_title' => 'My new Post', 'post_content' => 'This is my post.', 'post_status' => 'publish', 'post_author' => 1...
'post\_type' => ['page'] is wrong; it should be 'post\_type' => 'page'
38,882
<p>I have mainly protected categories, but I have one open category, how can I set it up so I load only the open catgeory posts to show on my home page</p>
[ { "answer_id": 38884, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 1, "selected": true, "text": "<p>This should about do it for you, add args as needed</p>\n\n<pre><code>$args = array(\n //basic post data\n ...
2012/01/13
[ "https://wordpress.stackexchange.com/questions/38882", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10745/" ]
I have mainly protected categories, but I have one open category, how can I set it up so I load only the open catgeory posts to show on my home page
This should about do it for you, add args as needed ``` $args = array( //basic post data 'posts_per_page' => 10, 'post_type' => 'post', 'post_status' => 'publish', //category 'category_name' => 'your-cat-slug' ); $posts = new WP_Query( $args ); ``` Docs: [`WP_Query`](http://codex.wor...
38,902
<p>long time lurker - first time poster. </p> <p>A client of mine has a website developed in CakePHP, and a wordpress blog installed in the /blog/ directory. </p> <p>Let's say the url of the main domain is <code>http://www.realdomain.com</code>, with the blog being <code>http://www.realdomain.com/blog/</code>.</p> <...
[ { "answer_id": 38916, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 0, "selected": false, "text": "<p>WordPress will force HTTPS for all assets if the current protocol is SSL. I'm assuming <code>realdomain.mai...
2012/01/14
[ "https://wordpress.stackexchange.com/questions/38902", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12050/" ]
long time lurker - first time poster. A client of mine has a website developed in CakePHP, and a wordpress blog installed in the /blog/ directory. Let's say the url of the main domain is `http://www.realdomain.com`, with the blog being `http://www.realdomain.com/blog/`. They don't have their own SSL certificate so...
Just to keep things nice & clear, I've posted this as a new answer. Let's reset the playing field & follow the below instructions as if it were a shiny new install (ignore all code & suggestions in previous answers). In your `wp-config.php` ``` define( 'WP_SITEURL', 'http://www.realdomain.com/blog' ); define( 'SSL_DO...
38,903
<p>what about if you are on a multi site install, where would you put the favicon to have it automaticallly recognized by the browser (and no blot the code with link tag)cause there is no real root per se?</p> <p>Thank you in advance for your help on this</p>
[ { "answer_id": 39036, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 2, "selected": false, "text": "<p>I would use a rewrite to map requests for <code>/favicon.ico</code> to <code>/icons/example.com.ico</code>:...
2012/01/14
[ "https://wordpress.stackexchange.com/questions/38903", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11269/" ]
what about if you are on a multi site install, where would you put the favicon to have it automaticallly recognized by the browser (and no blot the code with link tag)cause there is no real root per se? Thank you in advance for your help on this
I would use a rewrite to map requests for `/favicon.ico` to `/icons/example.com.ico`: ``` RewriteCond %{REQUEST_URI} ^/favicon\.ico RewriteCond %{SERVER_NAME} ^(www\.)?([a-z0-9]+) RewriteCond %{DOCUMENT_ROOT}/icons/%2.ico -f RewriteRule . /icons/%2.ico [L] ``` Note the regex for line #2 depends on your set-up - is e...
38,906
<p>Like the title says, what code would I use on a wordpress page so that it will only show posts that have a specific tag?</p>
[ { "answer_id": 38908, "author": "Tribbey", "author_id": 11970, "author_profile": "https://wordpress.stackexchange.com/users/11970", "pm_score": 1, "selected": false, "text": "<p>Before the loop, use query_posts function</p>\n\n<pre><code>query_posts( 'tag=foo' );\n</code></pre>\n\n<p>Thi...
2012/01/14
[ "https://wordpress.stackexchange.com/questions/38906", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12032/" ]
Like the title says, what code would I use on a wordpress page so that it will only show posts that have a specific tag?
I'm pretty sure I always read on here that `new WP_Query()` is recommended over `query_posts`. Additionally you can use the [Transient API](http://codex.wordpress.org/Transients_API) to improve performance on additional queries. Place this in whatever template where you'd like the list to display: ``` // Get any exist...
38,915
<p>I am new to wordpress. I searched</p> <blockquote> <p>page vs post</p> </blockquote> <p>and found that pages are mostly static contents (in the sense that they dont need to be changed and stays in its place for ever). My question is my site consists of lets say 20 pages. They are sorted into 4 categories so each...
[ { "answer_id": 38908, "author": "Tribbey", "author_id": 11970, "author_profile": "https://wordpress.stackexchange.com/users/11970", "pm_score": 1, "selected": false, "text": "<p>Before the loop, use query_posts function</p>\n\n<pre><code>query_posts( 'tag=foo' );\n</code></pre>\n\n<p>Thi...
2012/01/14
[ "https://wordpress.stackexchange.com/questions/38915", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6944/" ]
I am new to wordpress. I searched > > page vs post > > > and found that pages are mostly static contents (in the sense that they dont need to be changed and stays in its place for ever). My question is my site consists of lets say 20 pages. They are sorted into 4 categories so each category has 5 pages. I want to...
I'm pretty sure I always read on here that `new WP_Query()` is recommended over `query_posts`. Additionally you can use the [Transient API](http://codex.wordpress.org/Transients_API) to improve performance on additional queries. Place this in whatever template where you'd like the list to display: ``` // Get any exist...
38,935
<p>I wrote the following function to convert the current WordPress date format into a format that can be recognized by the jQuery UI Datepicker:</p> <p>From: <a href="http://codex.wordpress.org/Formatting_Date_and_Time" rel="nofollow">http://codex.wordpress.org/Formatting_Date_and_Time</a></p> <p>To: <a href="http://...
[ { "answer_id": 38965, "author": "krembo99", "author_id": 13256, "author_profile": "https://wordpress.stackexchange.com/users/13256", "pm_score": 2, "selected": false, "text": "<p>as for the document of the datapicker UI , I believe you do not need this function .\nthe document specifies ...
2012/01/14
[ "https://wordpress.stackexchange.com/questions/38935", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12062/" ]
I wrote the following function to convert the current WordPress date format into a format that can be recognized by the jQuery UI Datepicker: From: <http://codex.wordpress.org/Formatting_Date_and_Time> To: <http://docs.jquery.com/UI/Datepicker/formatDate> ``` /** * Convert a date format to a jQuery UI DatePicker f...
as for the document of the datapicker UI , I believe you do not need this function . the document specifies that you can use the following formats : ``` COOKIE - 'D, dd M yy' ISO_8601 - 'yy-mm-dd' ``` which are ,IMHO, compatible . At any rate , there are many PHP functions that will help you do time - converstion, ...
38,937
<p>I've got a Wordpress MU install in a sub-directory of my webserver. When I point my virtual host at that directory I get my index page but no styling or access to any pages. It's like it can't access anything in the sub-directories of my WP root, I get the 500 error. When I check the Apache log it says,</p> <p>"...
[ { "answer_id": 38938, "author": "TimWolla", "author_id": 12063, "author_profile": "https://wordpress.stackexchange.com/users/12063", "pm_score": 2, "selected": true, "text": "<p>You should have a look at this: <a href=\"https://stackoverflow.com/a/1612329/782822\">Request exceeded the li...
2012/01/14
[ "https://wordpress.stackexchange.com/questions/38937", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12068/" ]
I've got a Wordpress MU install in a sub-directory of my webserver. When I point my virtual host at that directory I get my index page but no styling or access to any pages. It's like it can't access anything in the sub-directories of my WP root, I get the 500 error. When I check the Apache log it says, "Request excee...
You should have a look at this: [Request exceeded the limit of 10 internal redirects due to probable configuration error.?](https://stackoverflow.com/a/1612329/782822) and [RewriteRule Flags](https://httpd.apache.org/docs/2.3/rewrite/flags.html#flag_l) It seems that you have a recursion in there. It is probably the la...
38,943
<p>I have a portfolio custom post type with a text field for a site link, I need to echo that link in the template page. What i have so far is this:</p> <pre><code> &lt;?php $site= get_post_custom_values('projLink'); if($site[0] != ""){ ?&gt; &lt;span&gt;&lt;p&gt...
[ { "answer_id": 38938, "author": "TimWolla", "author_id": 12063, "author_profile": "https://wordpress.stackexchange.com/users/12063", "pm_score": 2, "selected": true, "text": "<p>You should have a look at this: <a href=\"https://stackoverflow.com/a/1612329/782822\">Request exceeded the li...
2012/01/14
[ "https://wordpress.stackexchange.com/questions/38943", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11799/" ]
I have a portfolio custom post type with a text field for a site link, I need to echo that link in the template page. What i have so far is this: ``` <?php $site= get_post_custom_values('projLink'); if($site[0] != ""){ ?> <span><p><a href="<?php var_dump($site);...
You should have a look at this: [Request exceeded the limit of 10 internal redirects due to probable configuration error.?](https://stackoverflow.com/a/1612329/782822) and [RewriteRule Flags](https://httpd.apache.org/docs/2.3/rewrite/flags.html#flag_l) It seems that you have a recursion in there. It is probably the la...
38,948
<p>On a site I'm designing (business site versus blog - static homepage, etc.) for a client I have 7 different top -level product/service pages which have the same layout except for a graphic that stretches across the top, below the horizontal navbar and above the page content. Everything up to and including the navbar...
[ { "answer_id": 38938, "author": "TimWolla", "author_id": 12063, "author_profile": "https://wordpress.stackexchange.com/users/12063", "pm_score": 2, "selected": true, "text": "<p>You should have a look at this: <a href=\"https://stackoverflow.com/a/1612329/782822\">Request exceeded the li...
2012/01/14
[ "https://wordpress.stackexchange.com/questions/38948", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5686/" ]
On a site I'm designing (business site versus blog - static homepage, etc.) for a client I have 7 different top -level product/service pages which have the same layout except for a graphic that stretches across the top, below the horizontal navbar and above the page content. Everything up to and including the navbar wi...
You should have a look at this: [Request exceeded the limit of 10 internal redirects due to probable configuration error.?](https://stackoverflow.com/a/1612329/782822) and [RewriteRule Flags](https://httpd.apache.org/docs/2.3/rewrite/flags.html#flag_l) It seems that you have a recursion in there. It is probably the la...
38,956
<p>I just need to say in single.php if post type = x then display y. Else, don't display it.</p>
[ { "answer_id": 38958, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>It depends a bit on what exactly <code>y</code> is, but this should probably help you out: <a href=\"http://codex....
2012/01/15
[ "https://wordpress.stackexchange.com/questions/38956", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12069/" ]
I just need to say in single.php if post type = x then display y. Else, don't display it.
``` if( get_post_type() == 'post_type_slug' ) { //do some stuff } else { //do other stuff } ``` Should do it, alternately you can use templates to handle that, which wordpress has setup pretty well by default. See the [codex page on template hierarchy](http://codex.wordpress.org/Template_Hierarchy), specifica...
38,961
<p>I have a taxonomy in which term order matters, but varies from post to post. So I want to be able to set the order that terms are displayed in on a per-post basis:</p> <ul> <li><p><strong>My first post</strong> | Tagged: Apples, Oranges, Bananas</p></li> <li><p><strong>Some other post</strong> | Tagged: Oranges, Ba...
[ { "answer_id": 38966, "author": "Chris_O", "author_id": 251, "author_profile": "https://wordpress.stackexchange.com/users/251", "pm_score": 2, "selected": false, "text": "<p>I'm not sure if I understand exactly what your trying to accomplish but I've outlined a way for you to sort the or...
2012/01/15
[ "https://wordpress.stackexchange.com/questions/38961", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3564/" ]
I have a taxonomy in which term order matters, but varies from post to post. So I want to be able to set the order that terms are displayed in on a per-post basis: * **My first post** | Tagged: Apples, Oranges, Bananas * **Some other post** | Tagged: Oranges, Bananas, Apples Since this would vary from post to post, I...
I'm not sure if I understand exactly what your trying to accomplish but I've outlined a way for you to sort the order of terms associated with the current post. ### Html for the term order metabox: ``` echo '<ul id="the-terms">' $terms = get_the_terms( $post->ID, $taxonomy ); foreach ( $terms as...
38,963
<p>I'm creating a single page site and obviously want to include the blog posts. I'm currently looping through the pages and using the_content() and the_title() to display them. However, the_content doesn't include the blog posts on the blog page. I tried another loop in this one, but it didn't work. Any ideas to point...
[ { "answer_id": 38964, "author": "Eve Freeman", "author_id": 12073, "author_profile": "https://wordpress.stackexchange.com/users/12073", "pm_score": 0, "selected": false, "text": "<p>From <a href=\"http://codex.wordpress.org/The_Loop_in_Action\" rel=\"nofollow\">http://codex.wordpress.org...
2012/01/15
[ "https://wordpress.stackexchange.com/questions/38963", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12079/" ]
I'm creating a single page site and obviously want to include the blog posts. I'm currently looping through the pages and using the\_content() and the\_title() to display them. However, the\_content doesn't include the blog posts on the blog page. I tried another loop in this one, but it didn't work. Any ideas to point...
To include posts and pages in the loop, use the 'post\_type' argument: ``` <?php $wp_query = new WP_Query(); $args = array( 'post_type' => array('post','page') ); $wp_query->query($args); while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <?php the_content(); ?> <?php endwhile; ?> ``` <http://codex.w...
38,978
<p>I wrote a <a href="http://wordpress.org/extend/plugins/simple-sopa-blackout/" rel="nofollow">simple plugin</a> that will redirect the users to a page on a certain date. (in this case it's for the Blackout against SOPA here in the US) </p> <p>Right now I'm using the line <code>wp_redirect(plugins_url( 'simple-sopa-b...
[ { "answer_id": 38964, "author": "Eve Freeman", "author_id": 12073, "author_profile": "https://wordpress.stackexchange.com/users/12073", "pm_score": 0, "selected": false, "text": "<p>From <a href=\"http://codex.wordpress.org/The_Loop_in_Action\" rel=\"nofollow\">http://codex.wordpress.org...
2012/01/15
[ "https://wordpress.stackexchange.com/questions/38978", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2204/" ]
I wrote a [simple plugin](http://wordpress.org/extend/plugins/simple-sopa-blackout/) that will redirect the users to a page on a certain date. (in this case it's for the Blackout against SOPA here in the US) Right now I'm using the line `wp_redirect(plugins_url( 'simple-sopa-blackout/blackout.php'),302 );` to redirec...
To include posts and pages in the loop, use the 'post\_type' argument: ``` <?php $wp_query = new WP_Query(); $args = array( 'post_type' => array('post','page') ); $wp_query->query($args); while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <?php the_content(); ?> <?php endwhile; ?> ``` <http://codex.w...
38,979
<p>I am trying to add custom intervals for the WP cron in a plugin. It run with "hourly", "daily" default recurrence time. It dont' run when I add my own custom recurrence time for the function wp_schedule_event.</p> <p>I want to execute a function every X hours (defined by users).</p> <p>Thanks. </p> <p>Here is th...
[ { "answer_id": 38991, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 3, "selected": false, "text": "<p>WP-Cron doesn't run in the admin scope - remove your <code>if ( is_admin() )</code> condition.</p>\n" }, ...
2012/01/15
[ "https://wordpress.stackexchange.com/questions/38979", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12076/" ]
I am trying to add custom intervals for the WP cron in a plugin. It run with "hourly", "daily" default recurrence time. It dont' run when I add my own custom recurrence time for the function wp\_schedule\_event. I want to execute a function every X hours (defined by users). Thanks. Here is the code: ``` <?php /* ...
WP-Cron doesn't run in the admin scope - remove your `if ( is_admin() )` condition.
38,999
<p>I'm trying to get a video to display inside a widget which is called from a custom field inside a post. The code I am using is here: </p> <pre><code>&lt;?php query_posts('cat=8&amp;showposts=1'.get_option('posts_per_page')); ?&gt; &lt;?php if(have_posts()) : while(have_posts()) : the_post(); ?&gt;&lt;?php if( get_...
[ { "answer_id": 39000, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": true, "text": "<p><code>query_posts</code> is for modifying the main loop only, if you're doing additional queries outside of or withi...
2012/01/15
[ "https://wordpress.stackexchange.com/questions/38999", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11945/" ]
I'm trying to get a video to display inside a widget which is called from a custom field inside a post. The code I am using is here: ``` <?php query_posts('cat=8&showposts=1'.get_option('posts_per_page')); ?> <?php if(have_posts()) : while(have_posts()) : the_post(); ?><?php if( get_post_meta($post->ID, "youtube", tr...
`query_posts` is for modifying the main loop only, if you're doing additional queries outside of or within the main loop, create a new [WP\_Query](http://codex.wordpress.org/Class_Reference/WP_Query) instance. also- I'm not sure why you have `showposts=1` and then `get_option('posts_per_page')` immediately after. If f...
39,028
<p>I'm writing a plugin that needs to display a custom link immediately near the comments. I have the option in the plugin admin to display before or after. I'm familiar with the comments_array, but that doesn't allow me to just add a string of html just before the comments or just after the comments but before the c...
[ { "answer_id": 39030, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 3, "selected": true, "text": "<p><code>do_action( 'comment_form_before' );</code> is called on line 1553 of /wp-includes/comment-template.php, ...
2012/01/15
[ "https://wordpress.stackexchange.com/questions/39028", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12090/" ]
I'm writing a plugin that needs to display a custom link immediately near the comments. I have the option in the plugin admin to display before or after. I'm familiar with the comments\_array, but that doesn't allow me to just add a string of html just before the comments or just after the comments but before the comme...
`do_action( 'comment_form_before' );` is called on line 1553 of /wp-includes/comment-template.php, right before the output of the comment form, that should handle that one for you. I'll update this if I can find the hook before the comments. edit ==== It seems like you might be able to modify Walker\_Comment (found i...
39,029
<p>I have a custom post type called Testimonial that includes custom fields "name", "title" and "bank". I would like to display each of these items on a page. Here's what I have so far:</p> <pre><code> &lt;?php while ( $loop-&gt;have_posts() ) : $loop-&gt;the_post(); the_title(); echo '&lt;div class...
[ { "answer_id": 39032, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": false, "text": "<p>See the <a href=\"http://codex.wordpress.org/Custom_Fields\" rel=\"nofollow\">Custom Fields</a> page in Codex for t...
2012/01/15
[ "https://wordpress.stackexchange.com/questions/39029", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2748/" ]
I have a custom post type called Testimonial that includes custom fields "name", "title" and "bank". I would like to display each of these items on a page. Here's what I have so far: ``` <?php while ( $loop->have_posts() ) : $loop->the_post(); the_title(); echo '<div class="entry-content">'; ...
``` <?php while ( $loop->have_posts() ) : $loop->the_post(); the_title(); echo '<div class="entry-content">'; the_content(); echo '</div>'; echo '<div class="custom-field">'; echo get_post_meta( get_the_ID(), 'name', true ); echo get_post_meta( get_the_ID(), 'title', true ); echo get_post_meta( get_the_...
39,037
<p>I'm trying to create a menu directly hard-coded, basically I need to display the parent category and below its child categories, however I have to do this several times meaning something like this:</p> <ul>Category 1</ul> <p><li>category child of 1.1</li> <li>category child of 1.2</li> <li>category child of 1....
[ { "answer_id": 39039, "author": "Michael", "author_id": 4884, "author_profile": "https://wordpress.stackexchange.com/users/4884", "pm_score": 1, "selected": false, "text": "<p>use <a href=\"http://codex.wordpress.org/Function_Reference/get_categories\" rel=\"nofollow\"><code>get_categori...
2012/01/15
[ "https://wordpress.stackexchange.com/questions/39037", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4907/" ]
I'm trying to create a menu directly hard-coded, basically I need to display the parent category and below its child categories, however I have to do this several times meaning something like this: Category 1 - category child of 1.1 - category child of 1.2 - category child of 1.3 Category 2 - category child of 2....
Have you tried ``` wp_list_categories( array('depth'=>2,'title_li'=>null)); ``` This outputs the categories as a list, with their children as a nested list. The categories are linked to their respective page.
39,042
<p>I just learned (with help from Rob Vermeer!) how to use one template and be able to call different top graphics depending on the page and now I want to know if the following is possible:</p> <p>I'm using the page.php (default template) for several pages. Layout for those pages are the same but sidebar content on ea...
[ { "answer_id": 39043, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 1, "selected": false, "text": "<p>I've used the following before:</p>\n\n<pre><code>if( !dynamic_sidebar( 'archive-sidebar' ) ) {\n if( !dyn...
2012/01/16
[ "https://wordpress.stackexchange.com/questions/39042", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5686/" ]
I just learned (with help from Rob Vermeer!) how to use one template and be able to call different top graphics depending on the page and now I want to know if the following is possible: I'm using the page.php (default template) for several pages. Layout for those pages are the same but sidebar content on each page wi...
If you're using static pages, try using [`is_page()`](http://codex.wordpress.org/Function_Reference/is_page) for your conditionals. Let's assume your static pages have slugs, "customers", "vendors", and "services": ``` <?php if ( is_page( 'customers' ) : get_sidebar('customer'); elseif ( is_page( 'vendors' ) ) : ...
39,058
<p>I have a list of events on a clients website that show in a sidebar. When viewing the homepage you see one event and if you're anywhere else on the site you see two events in the sidebar. I am currently ordering them by using a meta_query compare that checks if the event is today or in the future.</p> <p>What I wou...
[ { "answer_id": 39064, "author": "Nickiler", "author_id": 10950, "author_profile": "https://wordpress.stackexchange.com/users/10950", "pm_score": 3, "selected": true, "text": "<p>This is just a shot in the dark but I would try ordering the events in descending order instead of ascending. ...
2012/01/16
[ "https://wordpress.stackexchange.com/questions/39058", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1687/" ]
I have a list of events on a clients website that show in a sidebar. When viewing the homepage you see one event and if you're anywhere else on the site you see two events in the sidebar. I am currently ordering them by using a meta\_query compare that checks if the event is today or in the future. What I would like t...
This is just a shot in the dark but I would try ordering the events in descending order instead of ascending. `'order' => 'DESC'`
39,070
<p>I'm currently building an event calendar on WordPress with a custom post type. I'm using custom fields for date, description, etc.</p> <p>Now I want to sort the events by date.. So --></p> <pre><code>January 3, 2012 January 10, 2012 Feburary 1, 2012 .... </code></pre>
[ { "answer_id": 39073, "author": "Jared", "author_id": 2415, "author_profile": "https://wordpress.stackexchange.com/users/2415", "pm_score": 0, "selected": false, "text": "<p>I used this to sort posts by its meta key and value descending in a custom post type:</p>\n\n<pre><code>global $wp...
2012/01/16
[ "https://wordpress.stackexchange.com/questions/39070", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12102/" ]
I'm currently building an event calendar on WordPress with a custom post type. I'm using custom fields for date, description, etc. Now I want to sort the events by date.. So --> ``` January 3, 2012 January 10, 2012 Feburary 1, 2012 .... ```
I've used Jared's approach several times successfully, although I agree that Stephen Harris' answer should also now work (but it's a more recent addition to WP\_Query which wasn't available at the time I was building an events listing). Depending on the date format you are suing to store the date, you might also need t...
39,079
<p>In the Appearance -> Widgets menu there is a list of widgets that you can drag and drop to show in the sidebar.</p> <p>Where is the HTML/PHP code for these custom widgets?</p> <p>I've been on WordPress's Function Reference but couldn't find anything. Surely these widgets must be pulled from a HTML/PHP template.</p...
[ { "answer_id": 39082, "author": "wassem", "author_id": 12109, "author_profile": "https://wordpress.stackexchange.com/users/12109", "pm_score": 0, "selected": false, "text": "<p>it is in the functions.php</p>\n\n<p>function twentyeleven_widgets_init() {</p>\n\n<pre><code>register_widget( ...
2012/01/16
[ "https://wordpress.stackexchange.com/questions/39079", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12105/" ]
In the Appearance -> Widgets menu there is a list of widgets that you can drag and drop to show in the sidebar. Where is the HTML/PHP code for these custom widgets? I've been on WordPress's Function Reference but couldn't find anything. Surely these widgets must be pulled from a HTML/PHP template. The reason I want ...
The [WordPress Widgets API](http://codex.wordpress.org/Widgets_API) is how various widgets are created and sidebars registered. When creating a new widget there are variables that can be added to any widget. Those get their value from the [`register_sidebars`](http://codex.wordpress.org/Function_Reference/register_sid...
39,085
<p>I would like to remove "Comments" and "Author" columns from the list of pages, and add a couple of my own "Permalink" etc.</p> <p>Is this possible? Is there an appropriate hook I could use?</p>
[ { "answer_id": 39082, "author": "wassem", "author_id": 12109, "author_profile": "https://wordpress.stackexchange.com/users/12109", "pm_score": 0, "selected": false, "text": "<p>it is in the functions.php</p>\n\n<p>function twentyeleven_widgets_init() {</p>\n\n<pre><code>register_widget( ...
2012/01/16
[ "https://wordpress.stackexchange.com/questions/39085", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9771/" ]
I would like to remove "Comments" and "Author" columns from the list of pages, and add a couple of my own "Permalink" etc. Is this possible? Is there an appropriate hook I could use?
The [WordPress Widgets API](http://codex.wordpress.org/Widgets_API) is how various widgets are created and sidebars registered. When creating a new widget there are variables that can be added to any widget. Those get their value from the [`register_sidebars`](http://codex.wordpress.org/Function_Reference/register_sid...
39,087
<p>Is there a way to have "Pages" set as the default tab when the user logs in to the admin area? I am using a heavily customised set up, where none of the dashboard widgets are useful so they are hidden anyway.</p>
[ { "answer_id": 39089, "author": "keatch", "author_id": 2727, "author_profile": "https://wordpress.stackexchange.com/users/2727", "pm_score": -1, "selected": false, "text": "<p>Yes, use <a href=\"http://wordpress.org/extend/plugins/adminimize/\" rel=\"nofollow noreferrer\" title=\"adminim...
2012/01/16
[ "https://wordpress.stackexchange.com/questions/39087", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9771/" ]
Is there a way to have "Pages" set as the default tab when the user logs in to the admin area? I am using a heavily customised set up, where none of the dashboard widgets are useful so they are hidden anyway.
The best way is to re-direct user logins to your page and also remove the dashboard from the menu, this can be done with 2 filters. Redirect logins to your page edit screen example based on user roles, this example uses "author": ``` function dashboard_redirect($url) { global $current_user; // is there a user...
39,094
<p>I'm looking for Cutom Post Type Category List &amp; Post Count. Here is my code..</p> <pre><code> &lt;?php $taxonomy = 'project-tags'; $tax_terms = get_terms($taxonomy); ?&gt; &lt;?php foreach ($tax_terms as $tax_term) { echo '&lt;l...
[ { "answer_id": 39095, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 2, "selected": true, "text": "<p><code>$tax_term-&gt;count</code> should contain the number of posts in the category. You may need to add the <...
2012/01/16
[ "https://wordpress.stackexchange.com/questions/39094", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3190/" ]
I'm looking for Cutom Post Type Category List & Post Count. Here is my code.. ``` <?php $taxonomy = 'project-tags'; $tax_terms = get_terms($taxonomy); ?> <?php foreach ($tax_terms as $tax_term) { echo '<li>' . '<a class="tag" href="' ...
`$tax_term->count` should contain the number of posts in the category. You may need to add the `$args` parameter if you want to include subcategory counts. Docs: [`get_terms()`](http://codex.wordpress.org/Function_Reference/get_terms)
39,099
<p>OK, here's my prob. I have static homepage and a separate posts page on my wordpress site. I have defined the two in the admin panel. Now, I have also set the max number of posts to be displayed to 5(in settings> reading), but all the posts(10+) are still being displayed on the blog page.</p> <p>I'm also displaying...
[ { "answer_id": 39113, "author": "OleVik", "author_id": 2983, "author_profile": "https://wordpress.stackexchange.com/users/2983", "pm_score": 2, "selected": true, "text": "<p>This could be caused by a theme or plugin overriding the WordPress settings. You could try enabling the TwentyElev...
2012/01/16
[ "https://wordpress.stackexchange.com/questions/39099", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12110/" ]
OK, here's my prob. I have static homepage and a separate posts page on my wordpress site. I have defined the two in the admin panel. Now, I have also set the max number of posts to be displayed to 5(in settings> reading), but all the posts(10+) are still being displayed on the blog page. I'm also displaying the lates...
This could be caused by a theme or plugin overriding the WordPress settings. You could try enabling the TwentyEleven or TwentyTen theme, as well as disabling any plugins, to see if it works then. If so, you could post which theme you are using (if it's prebuilt) or which plugins you had to disable to get it working - ...
39,124
<p>I'm creating a cron job that runs outside of WordPress. From a development perspective, this makes it really easy to debug and create cleanup scripts or cron jobs, by just running a command like the following on the command line:</p> <pre class="lang-php prettyprint-override"><code>php myfile.php </code></pre> <p>...
[ { "answer_id": 44750, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 2, "selected": false, "text": "<p>Disable any plugins you may have that do whole-page caching. WP-Super-Cache, W3 Total Cache, etc.</p>\n\n<p>WordPre...
2012/01/16
[ "https://wordpress.stackexchange.com/questions/39124", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2333/" ]
I'm creating a cron job that runs outside of WordPress. From a development perspective, this makes it really easy to debug and create cleanup scripts or cron jobs, by just running a command like the following on the command line: ```php php myfile.php ``` My issue is that WordPress somehow delays all output... typic...
After some testing indeed, both WP Super Cache and W3 Total Cache do not release the buffer (or prevent the buffer from being released). Turning off "output delay" is simple and depends on the caching plugin involved. **WP Super Cache**: ``` wp_cache_disable(); ob_end_flush(); // or ob_end_clean(); ``` This should...
39,125
<p>I have been trying google for this, but not so easy to search for. I have a custom hierarchical taxonomy, something along the lines of:</p> <pre><code>Chainsaws - Electric - Petrol - Other Grasscutters - Electric - Petrol - Other </code></pre> <p>What I need to do is create an index page, retaining the hierarchica...
[ { "answer_id": 39126, "author": "Rob Vermeer", "author_id": 11135, "author_profile": "https://wordpress.stackexchange.com/users/11135", "pm_score": 4, "selected": true, "text": "<pre><code>&lt;?php\n$args = array(\n 'taxonomy' =&gt; 'product-type',\n 'hierarchical' =&gt; true,\n '...
2012/01/16
[ "https://wordpress.stackexchange.com/questions/39125", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12119/" ]
I have been trying google for this, but not so easy to search for. I have a custom hierarchical taxonomy, something along the lines of: ``` Chainsaws - Electric - Petrol - Other Grasscutters - Electric - Petrol - Other ``` What I need to do is create an index page, retaining the hierarchical structure. The closest ...
``` <?php $args = array( 'taxonomy' => 'product-type', 'hierarchical' => true, 'title_li' => '', 'hide_empty' => false ); ?> <ul> <?php wp_list_categories( $args ); ?> </ul> ``` You can use the wp\_list\_categories function also for taxonomies. <http://codex.wordpress.org/Template_Tags/wp_list_cate...
39,130
<p>Before I get started, I want to acknowledge that there are some really good articles that are targeted at how to conditionally enqueue scripts based on page/post content.</p> <ul> <li><a href="http://beerpla.net/2010/01/13/wordpress-plugin-development-how-to-include-css-and-javascript-conditionally-and-only-when-ne...
[ { "answer_id": 39131, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 3, "selected": true, "text": "<p>I copy pasted your code into my dev environment, changed nothing but the page name, and it works just fine. Ar...
2012/01/16
[ "https://wordpress.stackexchange.com/questions/39130", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12055/" ]
Before I get started, I want to acknowledge that there are some really good articles that are targeted at how to conditionally enqueue scripts based on page/post content. * [WordPress Plugin Development - How To Include CSS and JavaScript Conditionally And Only When Needed By The Posts](http://beerpla.net/2010/01/13/w...
I copy pasted your code into my dev environment, changed nothing but the page name, and it works just fine. Are you sure that it's not being enqueued and you just have it pointed wrong or that the page is not named incorrectly or something?
39,133
<p><img src="https://i.stack.imgur.com/0anYp.png" alt="Image showing current comment form"></p> <p>As you can see in the picture: "Comment" label displays always in the same place. How can I remove it or customized it? I really don't know what function controls this label. Part of my comments.php looks like this:</p> ...
[ { "answer_id": 39135, "author": "OleVik", "author_id": 2983, "author_profile": "https://wordpress.stackexchange.com/users/2983", "pm_score": 1, "selected": false, "text": "<p>If you want to remove it, then find the part of your template file (probably index.php or loop.php) which refers ...
2012/01/16
[ "https://wordpress.stackexchange.com/questions/39133", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11949/" ]
![Image showing current comment form](https://i.stack.imgur.com/0anYp.png) As you can see in the picture: "Comment" label displays always in the same place. How can I remove it or customized it? I really don't know what function controls this label. Part of my comments.php looks like this: ``` <?php if ( have_comment...
If you want to remove it, then find the part of your template file (probably index.php or loop.php) which refers to a comment-template and remove it, and also disable commenting in WordPress-settings (to disable use of comments.php from other pages). If you want to style it, look for `comment_form()` or a similar func...
39,139
<p>So I limited the amount of characters per post via <code>the_excerpt('50')</code> but it removes the image that I added to my post. How can I bring that image back so it shows up above the post then limits the characters?</p>
[ { "answer_id": 39154, "author": "Gavin Anderegg", "author_id": 2984, "author_profile": "https://wordpress.stackexchange.com/users/2984", "pm_score": 3, "selected": true, "text": "<p>The problem is that <a href=\"http://codex.wordpress.org/Function_Reference/the_excerpt\" rel=\"nofollow\"...
2012/01/16
[ "https://wordpress.stackexchange.com/questions/39139", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7355/" ]
So I limited the amount of characters per post via `the_excerpt('50')` but it removes the image that I added to my post. How can I bring that image back so it shows up above the post then limits the characters?
The problem is that [the\_excerpt() strips all HTML](http://codex.wordpress.org/Function_Reference/the_excerpt). There's a good reason for this: what if the 49th word of a 50 word excerpt was the first word of a bulleted list? Or the second word in an `<h1>`? The way I would work around this is by using [post thumbnai...
39,141
<p>I found an amazing plugin that loads the next posts with Ajax.</p> <p><a href="http://www.problogdesign.com/wordpress/load-next-wordpress-posts-with-ajax" rel="nofollow">http://www.problogdesign.com/wordpress/load-next-wordpress-posts-with-ajax</a></p> <p>However it doesn't work with custom post types.</p> <p>The...
[ { "answer_id": 39144, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 2, "selected": true, "text": "<p>In principal, you could use this with <em>any</em> archive page. All it's doing is fetching the next page of results ...
2012/01/16
[ "https://wordpress.stackexchange.com/questions/39141", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1063/" ]
I found an amazing plugin that loads the next posts with Ajax. <http://www.problogdesign.com/wordpress/load-next-wordpress-posts-with-ajax> However it doesn't work with custom post types. The code looks fairly simple. Any idea how to edit the code to use custom post types? Thanks
In principal, you could use this with *any* archive page. All it's doing is fetching the next page of results and displaying the data. The reason it won't work with CPTs is because of the way the PHP script is queued - with an `!is_singular()` filter. The core of the plugin is in the JavaScript. Namely, this section:...
39,142
<p>I'm developing a client website with Wordpress (3.3) but have found that the image caption feature strips out any HTML tags.</p> <p>The resulting caption is plain text which makes proper image crediting difficult. Also being a client website, WYSIWYG editing is required.</p> <p>For example if my shortcode is:</p> ...
[ { "answer_id": 39173, "author": "Sterex", "author_id": 6592, "author_profile": "https://wordpress.stackexchange.com/users/6592", "pm_score": 0, "selected": false, "text": "<p>Okay, your problem seems interesting.</p>\n\n<p>One thing I could think of is:</p>\n\n<pre><code>[caption caption...
2012/01/16
[ "https://wordpress.stackexchange.com/questions/39142", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12126/" ]
I'm developing a client website with Wordpress (3.3) but have found that the image caption feature strips out any HTML tags. The resulting caption is plain text which makes proper image crediting difficult. Also being a client website, WYSIWYG editing is required. For example if my shortcode is: ``` [caption caption...
I'm glad that better support should be added in version 3.4 but for now I've fixed the issue by changing the behaviour of image insertion so that it doesn't use the [caption] shortcode. Here's what I added to functions.php: ``` add_filter( 'disable_captions', create_function('$a', 'return true;') ); function image_s...
39,145
<p>On my test case, the page' title is "Privacy". The straightforward approach</p> <pre><code>strtolower(the_title()) </code></pre> <p>also returns "Privacy" -- still with a capital P. I also tried</p> <pre><code>mb_strtolower(the_title()) </code></pre> <p>and </p> <pre><code>mb_strtolower(the_title(), 'utf8') <...
[ { "answer_id": 39149, "author": "Rob Vermeer", "author_id": 11135, "author_profile": "https://wordpress.stackexchange.com/users/11135", "pm_score": 3, "selected": false, "text": "<p>I think the best method for this is by using CSS (text-transform: lowercase).</p>\n\n<p>But if you want to...
2012/01/16
[ "https://wordpress.stackexchange.com/questions/39145", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12127/" ]
On my test case, the page' title is "Privacy". The straightforward approach ``` strtolower(the_title()) ``` also returns "Privacy" -- still with a capital P. I also tried ``` mb_strtolower(the_title()) ``` and ``` mb_strtolower(the_title(), 'utf8') ``` with similar results. Not sure if it matters, but my wp-...
lowercasing the title ===================== If I'm understanding you correctly, you should be doing: ``` strtolower(get_the_title()); ``` or ``` print strtolower(get_the_title()); ``` if you want to display it. Below is an explanation as to why. the\_title() vs. get\_the\_title() ==============================...
39,147
<p>I would like to make my home page in such a way it shows the most viewed, random and recent posts by thre differents part by limitin the number of posts......give me at least some hints or idea to try it. Thank you in advance</p>
[ { "answer_id": 39149, "author": "Rob Vermeer", "author_id": 11135, "author_profile": "https://wordpress.stackexchange.com/users/11135", "pm_score": 3, "selected": false, "text": "<p>I think the best method for this is by using CSS (text-transform: lowercase).</p>\n\n<p>But if you want to...
2012/01/16
[ "https://wordpress.stackexchange.com/questions/39147", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12124/" ]
I would like to make my home page in such a way it shows the most viewed, random and recent posts by thre differents part by limitin the number of posts......give me at least some hints or idea to try it. Thank you in advance
lowercasing the title ===================== If I'm understanding you correctly, you should be doing: ``` strtolower(get_the_title()); ``` or ``` print strtolower(get_the_title()); ``` if you want to display it. Below is an explanation as to why. the\_title() vs. get\_the\_title() ==============================...
39,153
<p>I'm not sure what I'm doing wrong here. I have a field called "grid_thumbnail" and a "related_projects" post_object. I am able to display the title of the related post. I just don't know how to get the Image URL of that related post. Suggestions?</p> <pre><code>&lt;?php foreach(get_field('related_projects') as $pos...
[ { "answer_id": 39526, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 3, "selected": true, "text": "<p>There is a second parameter on <code>get_field()</code> which you are not using, try this line instead:</p>\n\...
2012/01/17
[ "https://wordpress.stackexchange.com/questions/39153", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7739/" ]
I'm not sure what I'm doing wrong here. I have a field called "grid\_thumbnail" and a "related\_projects" post\_object. I am able to display the title of the related post. I just don't know how to get the Image URL of that related post. Suggestions? ``` <?php foreach(get_field('related_projects') as $post_object): ?> ...
There is a second parameter on `get_field()` which you are not using, try this line instead: `<img src="<?php echo get_field( 'grid_thumbnail', $post_object->ID ); ?>"><br />` Docs: [`get_field()`](http://plugins.elliotcondon.com/advanced-custom-fields/documentation/get_field/)
39,158
<p>I'm trying to get into grips in using AJAX in wordpress, the following code creates a form with an input box using the wordpress feature shortcode [ajaxf].</p> <pre><code>&lt;?php add_action( "wp_ajax_ajaxcf", "my_action_callback" ); add_action( "wp_ajax_nopriv_ajaxcf", "my_action_callback" ); function my_action_c...
[ { "answer_id": 39159, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": true, "text": "<p>This is just a simple javascript issue. When your javascript that attaches the click behavior to the form is parsed,...
2012/01/17
[ "https://wordpress.stackexchange.com/questions/39158", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8776/" ]
I'm trying to get into grips in using AJAX in wordpress, the following code creates a form with an input box using the wordpress feature shortcode [ajaxf]. ``` <?php add_action( "wp_ajax_ajaxcf", "my_action_callback" ); add_action( "wp_ajax_nopriv_ajaxcf", "my_action_callback" ); function my_action_callback() { $...
This is just a simple javascript issue. When your javascript that attaches the click behavior to the form is parsed, the form element doesn't yet exist because it's further down the page, so it doesn't get attached. Either move the javascript below the form, wrap it in a `jQuery(document).ready()`, or use [`live`](http...
39,166
<p>I know I can set up post, pages, and custom post types to use featured images in wordpress by enabling theme support:</p> <pre><code>add_theme_support( 'post-thumbnails'); </code></pre> <p>Or enabling theme support for a specific set of post types:</p> <pre><code> add_theme_support( 'post-thumbnails', array('p...
[ { "answer_id": 39168, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": 2, "selected": false, "text": "<p>If you added a custom with the 3 sizes:</p>\n\n<pre><code>add_image_size( 'small', 111, 222, true );\nadd_i...
2012/01/17
[ "https://wordpress.stackexchange.com/questions/39166", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4400/" ]
I know I can set up post, pages, and custom post types to use featured images in wordpress by enabling theme support: ``` add_theme_support( 'post-thumbnails'); ``` Or enabling theme support for a specific set of post types: ``` add_theme_support( 'post-thumbnails', array('post','page')); ``` I also know that...
I believe that is what the `set_post_thumbnail_size` function is for. > > Set the default Post Thumbnail dimensions. To register additional image sizes for Post Thumbnails use: add\_image\_size(). > > > See <http://codex.wordpress.org/Function_Reference/set_post_thumbnail_size>
39,179
<p>Without using timthumb, does anyone know of a way to set jpeg_quality for certain post-types or posts?</p>
[ { "answer_id": 39186, "author": "Chris_O", "author_id": 251, "author_profile": "https://wordpress.stackexchange.com/users/251", "pm_score": 1, "selected": false, "text": "<p>You can hook into the <a href=\"http://adambrown.info/p/wp_hooks/hook/jpeg_quality\" rel=\"nofollow\">jpeg_quality...
2012/01/17
[ "https://wordpress.stackexchange.com/questions/39179", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6848/" ]
Without using timthumb, does anyone know of a way to set jpeg\_quality for certain post-types or posts?
You can hook into the [jpeg\_quality filter](http://adambrown.info/p/wp_hooks/hook/jpeg_quality) and do a check for the post type you want to apply the filter to. ``` add_filter( 'jpeg_quality', 'my_jpeq_quality' ); function my_jpeg_quality( $quality ) { if ((isset($_GET['post_type']) && $_GET['post_type'] == 'your_p...
39,189
<p>I want to display taxonomies instead of categories on the homepage of my blog. What can I do to achieve this?</p>
[ { "answer_id": 39185, "author": "Jared", "author_id": 2415, "author_profile": "https://wordpress.stackexchange.com/users/2415", "pm_score": 2, "selected": false, "text": "<p>I think what you are looking for is this: <a href=\"http://codex.wordpress.org/Function_Reference/get_terms\" rel=...
2012/01/17
[ "https://wordpress.stackexchange.com/questions/39189", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12140/" ]
I want to display taxonomies instead of categories on the homepage of my blog. What can I do to achieve this?
I think what you are looking for is this: <http://codex.wordpress.org/Function_Reference/get_terms> Example of how to get all `my_taxonomy` terms and echo them in an unordered list. ``` $terms = get_terms( "my_taxonomy" ); $count = count( $terms ); if ( $count > 0 ){ echo "<ul>"; foreach ( $terms as $ter...
39,195
<p>How can I add the widget manually in the code ?</p>
[ { "answer_id": 39197, "author": "mor7ifer", "author_id": 11740, "author_profile": "https://wordpress.stackexchange.com/users/11740", "pm_score": 0, "selected": false, "text": "<p>Depending on how your call to <code>dynamic_sidebar()</code> is setup, you should be able to drop them in bef...
2012/01/17
[ "https://wordpress.stackexchange.com/questions/39195", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12144/" ]
How can I add the widget manually in the code ?
Have a look at the **[`the_widget()`](http://codex.wordpress.org/Function_Reference/the_widget)** function. The first argument is required. It is the PHP class name of the widget. For example: ``` <div class="sidebar"> <?php the_widget('WP_Widget_Search') ?> </div> ``` You can also pass on extra arguments: ``` <d...
39,203
<p>I never really dug into the compression options I have for my plugins and themes, so here I am. I was reading a few articles about PHP compression <a href="http://perishablepress.com/press/2007/03/26/fast-effective-php-compression/" rel="nofollow">like this one</a> and I had a question.</p> <p>Is it really as easy ...
[ { "answer_id": 39242, "author": "scribu", "author_id": 205, "author_profile": "https://wordpress.stackexchange.com/users/205", "pm_score": 3, "selected": true, "text": "<p>To answer your question, yes, it is that easy to enable compression. However, that's only a small step when configur...
2012/01/17
[ "https://wordpress.stackexchange.com/questions/39203", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2415/" ]
I never really dug into the compression options I have for my plugins and themes, so here I am. I was reading a few articles about PHP compression [like this one](http://perishablepress.com/press/2007/03/26/fast-effective-php-compression/) and I had a question. Is it really as easy as adding the following code in the ...
To answer your question, yes, it is that easy to enable compression. However, that's only a small step when configuring a site for performance. You should not attempt to handle compression from your plugin, unless the entire purpose of the plugin is load time optimization. Leave that to dedicated plugins, such as the ...
39,212
<p>I has custom field 'People' and I have parent pages(post types) and child pages (post types). This is my code:</p> <pre><code>&lt;?php $args = array( 'post_type'=&gt; 'people', 'posts_per_page' =&gt; -1, ); $loop = new WP_Query( $args ); while ( $loop-&gt;have_posts() ) { ?&gt; &lt;?php $loop-&gt;the_po...
[ { "answer_id": 39242, "author": "scribu", "author_id": 205, "author_profile": "https://wordpress.stackexchange.com/users/205", "pm_score": 3, "selected": true, "text": "<p>To answer your question, yes, it is that easy to enable compression. However, that's only a small step when configur...
2012/01/17
[ "https://wordpress.stackexchange.com/questions/39212", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12148/" ]
I has custom field 'People' and I have parent pages(post types) and child pages (post types). This is my code: ``` <?php $args = array( 'post_type'=> 'people', 'posts_per_page' => -1, ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) { ?> <?php $loop->the_post();?> <div class="title"> ...
To answer your question, yes, it is that easy to enable compression. However, that's only a small step when configuring a site for performance. You should not attempt to handle compression from your plugin, unless the entire purpose of the plugin is load time optimization. Leave that to dedicated plugins, such as the ...
39,232
<p><img src="https://i.stack.imgur.com/YmJTI.png" alt="WP URL call"></p> <p>I got this image from one E-book for WP plugin development. Could you please clarify me why the Plugins are loaded before Pluggables. </p>
[ { "answer_id": 39234, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 3, "selected": true, "text": "<p>Directly from source for <a href=\"http://core.trac.wordpress.org/browser/trunk/wp-includes/pluggable.php\" ...
2012/01/17
[ "https://wordpress.stackexchange.com/questions/39232", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12152/" ]
![WP URL call](https://i.stack.imgur.com/YmJTI.png) I got this image from one E-book for WP plugin development. Could you please clarify me why the Plugins are loaded before Pluggables.
Directly from source for [`pluggable.php`](http://core.trac.wordpress.org/browser/trunk/wp-includes/pluggable.php): ``` <?php /** * These functions can be replaced via plugins. If plugins do not redefine these * functions, then these will be used instead. * * @package WordPress */ ?> ``` So, there's your answer...
39,241
<p>I'm having some trouble with this sample widget code. I want to get all images (Minus the post thumbnail) from a page called "Gallery" but for some reason this is pulling all uploaded images from the entire site.</p> <p>Also, how would I go about excluding the post thumbnail from this query?</p> <pre><code> query...
[ { "answer_id": 39492, "author": "Ole Henrik Skogstrøm", "author_id": 11552, "author_profile": "https://wordpress.stackexchange.com/users/11552", "pm_score": 4, "selected": true, "text": "<h2>Use get_children</h2>\n\n<p>I used this code to extract all the images from a page gallery in the...
2012/01/17
[ "https://wordpress.stackexchange.com/questions/39241", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7999/" ]
I'm having some trouble with this sample widget code. I want to get all images (Minus the post thumbnail) from a page called "Gallery" but for some reason this is pulling all uploaded images from the entire site. Also, how would I go about excluding the post thumbnail from this query? ``` query_posts('pagename=gall...
Use get\_children ----------------- I used this code to extract all the images from a page gallery in the chosen order. you can include this code in the loop or use it stand alone. just choose the appropriate post\_parent code (see bellow the code example). This example show all images associated to the page id 1, ha...
39,251
<p>I have a widget that I need to add a category select list to. The end user should be able to select a category and I need to save the category ID with the widget.</p> <p>I've hit a stumbling block in that I cannot get my exclude array to work. The excluded cats still show up in the dropdown. What am I doing wrong?<...
[ { "answer_id": 39255, "author": "OleVik", "author_id": 2983, "author_profile": "https://wordpress.stackexchange.com/users/2983", "pm_score": 2, "selected": true, "text": "<p>Per <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query\" rel=\"nofollow\">http://codex.wordpress.org/Cl...
2012/01/17
[ "https://wordpress.stackexchange.com/questions/39251", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/366/" ]
I have a widget that I need to add a category select list to. The end user should be able to select a category and I need to save the category ID with the widget. I've hit a stumbling block in that I cannot get my exclude array to work. The excluded cats still show up in the dropdown. What am I doing wrong? ``` funct...
Per <http://codex.wordpress.org/Class_Reference/WP_Query> you would need to prefix the numerical identifier of the array with a minus-sign, such as `$query = new WP_Query( 'cat=-12,-34,-56' );`, which would exclude the categories with the identifier 12, 34 and 56. You could achieve this by changing the `get_cats` func...
39,266
<p>I have a form in a page template that allows users to submit posts into a custom post type from the front-end:</p> <pre><code>$post = array( 'post_status' =&gt; 'draft', 'post_type' =&gt; 'stories', 'post_content' =&gt; wp_kses_post( $story_content ), 'post_title' =&gt; esc_attr( wp_kses( $story_tit...
[ { "answer_id": 39268, "author": "Shane", "author_id": 10555, "author_profile": "https://wordpress.stackexchange.com/users/10555", "pm_score": -1, "selected": false, "text": "<p>Still can't comment it seems, but you have an extra comma in your array.</p>\n\n<pre><code> $post = array(\n ...
2012/01/17
[ "https://wordpress.stackexchange.com/questions/39266", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/300/" ]
I have a form in a page template that allows users to submit posts into a custom post type from the front-end: ``` $post = array( 'post_status' => 'draft', 'post_type' => 'stories', 'post_content' => wp_kses_post( $story_content ), 'post_title' => esc_attr( wp_kses( $story_title, array() ) ), 'post...
The issue is in using the `$post` variable for arguments. After changing this to something like `$new_post` I no longer get the notices. There must be some conflict with the `global $post` that WordPress uses. I took this from the Codex, but looking back at the page, I realize that `$post` was just referring the argu...
39,274
<p>This site has been very helpful for me in learning how to rewrite permalinks using add_filters to solve issues we were having when we merged two blogs into one. But, I do have one item I have been unable to find any tips for:</p> <p>On the date based archives links, i.e. www.domain.com/2011/12/</p> <p>I simply w...
[ { "answer_id": 63003, "author": "Jaypee", "author_id": 15574, "author_profile": "https://wordpress.stackexchange.com/users/15574", "pm_score": 0, "selected": false, "text": "<p>sounds like you need to rewrite the custom post type permalink or in this case the permastruct.</p>\n\n<p>I did...
2012/01/18
[ "https://wordpress.stackexchange.com/questions/39274", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12176/" ]
This site has been very helpful for me in learning how to rewrite permalinks using add\_filters to solve issues we were having when we merged two blogs into one. But, I do have one item I have been unable to find any tips for: On the date based archives links, i.e. www.domain.com/2011/12/ I simply want to translate t...
**The really easy way:** Change your permalink structure to include a "front" part. Eg. `/news/%postname%` **The slightly more complicated and inflexible way:** WordPress holds it's data permastruct in a property of the global `WP_Rewrite` object stored in `$wp_rewrite`. You can hook in sometime early-ish (around `ini...
39,275
<p>There is any way of using the main site footer (blog id =1) on all the network sites. I want to have the same footer in all the network. On the main site i got a theme and the child sites created by users got another theme.</p> <p><strong>Basically i want to use the same footer on both themes but manage all the wid...
[ { "answer_id": 39280, "author": "Nick Budden", "author_id": 7772, "author_profile": "https://wordpress.stackexchange.com/users/7772", "pm_score": 0, "selected": false, "text": "<p>Yes. Just use switch_to_blog and restore_current_blog on either end of the footer, then code your footer as ...
2012/01/18
[ "https://wordpress.stackexchange.com/questions/39275", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4130/" ]
There is any way of using the main site footer (blog id =1) on all the network sites. I want to have the same footer in all the network. On the main site i got a theme and the child sites created by users got another theme. **Basically i want to use the same footer on both themes but manage all the widgets from just t...
First of all, using the same `footer.php` file for multiple themes would be problematic, as different themes use different elements which need to be closed in this file. A better way would be to create a custom function that you call in every `footer.php` file. Such a function would be best placed in a file in `wp-con...
39,285
<p>Hello: I am trying to add 7 custom fields to the standard Wordpress wp-admin/profile.php page. There are a few site which suggest a simple bit of code to do this, for example:</p> <p><a href="http://wpengineer.com/2173/custom-fields-wordpress-user-profile/" rel="nofollow">http://wpengineer.com/2173/custom-fields-wo...
[ { "answer_id": 39295, "author": "Hameedullah Khan", "author_id": 5337, "author_profile": "https://wordpress.stackexchange.com/users/5337", "pm_score": 3, "selected": false, "text": "<p>There is no WordPress way to add fields between user's bio and password, but as you said your self you ...
2012/01/18
[ "https://wordpress.stackexchange.com/questions/39285", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12179/" ]
Hello: I am trying to add 7 custom fields to the standard Wordpress wp-admin/profile.php page. There are a few site which suggest a simple bit of code to do this, for example: <http://wpengineer.com/2173/custom-fields-wordpress-user-profile/> But, I want to be able to add my custom fields so that they appear exactly ...
There is no WordPress way to add fields between user's bio and password, but as you said your self you can do it the javascript way. Below is the code that adds single field to give you an example on how you can achieve the same. **NOTE:** The code below only display the fields but does not process any information or ...
39,294
<p>i tried to figure this out but i can't until know </p> <p>i have new custom post type of <code>questions</code> and i have other post types also like <code>job listing</code>, <code>resumes</code> etc </p> <p>what i want here to make search for the post type questions only here what i done </p> <pre><code> ...
[ { "answer_id": 39300, "author": "Dipesh KC", "author_id": 7247, "author_profile": "https://wordpress.stackexchange.com/users/7247", "pm_score": 1, "selected": false, "text": "<pre><code>global $query_string; \n$query_args = explode(\"&amp;\", $query_string);\n$search_args = array();\n...
2012/01/18
[ "https://wordpress.stackexchange.com/questions/39294", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12185/" ]
i tried to figure this out but i can't until know i have new custom post type of `questions` and i have other post types also like `job listing`, `resumes` etc what i want here to make search for the post type questions only here what i done ``` <?php global $app_abbr, $header_search; $header_search ...
A better approach is to address the main search query. @Dipesh's answer is technically correct, but I would suggest using the [`pre_get_posts`](https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) action instead to affect the intial query, rather than generating a new one. Much less work! ``` add_act...
39,306
<p>As you can see in my next/previous link I have an extra space before the word "Previous" and I can't seem to find it. Any help is greatly appreciated:</p> <p><a href="http://themeforward.com/demo2/?p=1813&amp;page=2" rel="nofollow">http://themeforward.com/demo2/?p=1813&amp;page=2</a></p> <p>Custom function:</p> ...
[ { "answer_id": 39300, "author": "Dipesh KC", "author_id": 7247, "author_profile": "https://wordpress.stackexchange.com/users/7247", "pm_score": 1, "selected": false, "text": "<pre><code>global $query_string; \n$query_args = explode(\"&amp;\", $query_string);\n$search_args = array();\n...
2012/01/18
[ "https://wordpress.stackexchange.com/questions/39306", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5205/" ]
As you can see in my next/previous link I have an extra space before the word "Previous" and I can't seem to find it. Any help is greatly appreciated: <http://themeforward.com/demo2/?p=1813&page=2> Custom function: ``` // Custom Next/Previous Page add_filter('wp_link_pages_args', 'wp_link_pages_args_prevnext_add'); ...
A better approach is to address the main search query. @Dipesh's answer is technically correct, but I would suggest using the [`pre_get_posts`](https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) action instead to affect the intial query, rather than generating a new one. Much less work! ``` add_act...
39,308
<p>I'm using the <a href="http://shailan.com/wordpress/plugins/superfish-dropdown-menu/" rel="nofollow">superfish dropdown menu</a> to create a drop down menu.</p> <p>It's created the menu fine showing all the parent pages with the child pages in drop down's below.</p> <p>The only problem I have is that the parent pa...
[ { "answer_id": 39853, "author": "Matthew Boynes", "author_id": 12324, "author_profile": "https://wordpress.stackexchange.com/users/12324", "pm_score": 4, "selected": true, "text": "<p>I downloaded this plugin and took a look and it does work as advertised for me. The function it uses for...
2012/01/18
[ "https://wordpress.stackexchange.com/questions/39308", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4588/" ]
I'm using the [superfish dropdown menu](http://shailan.com/wordpress/plugins/superfish-dropdown-menu/) to create a drop down menu. It's created the menu fine showing all the parent pages with the child pages in drop down's below. The only problem I have is that the parent pages are by `menu_order` which is what I wan...
I downloaded this plugin and took a look and it does work as advertised for me. The function it uses for displaying the page list is: ``` wp_list_pages(array( 'sort_column'=>'menu_order', 'depth'=>'4', 'title_li'=>'', 'exclude'=>$exclude )); ?> ``` Which is very straightforwar...
39,312
<p>I keep getting this on my WordPress site after I moved it from my development server to the live site. It's happening in one file that is using a few functions which I think is causing it, but I don't know how to fix it.</p> <blockquote> <p>Allowed memory size of 268435456 bytes exhausted (tried to allocate 45231...
[ { "answer_id": 39853, "author": "Matthew Boynes", "author_id": 12324, "author_profile": "https://wordpress.stackexchange.com/users/12324", "pm_score": 4, "selected": true, "text": "<p>I downloaded this plugin and took a look and it does work as advertised for me. The function it uses for...
2012/01/18
[ "https://wordpress.stackexchange.com/questions/39312", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2415/" ]
I keep getting this on my WordPress site after I moved it from my development server to the live site. It's happening in one file that is using a few functions which I think is causing it, but I don't know how to fix it. > > Allowed memory size of 268435456 bytes exhausted (tried to allocate 452314848 bytes) in **Unk...
I downloaded this plugin and took a look and it does work as advertised for me. The function it uses for displaying the page list is: ``` wp_list_pages(array( 'sort_column'=>'menu_order', 'depth'=>'4', 'title_li'=>'', 'exclude'=>$exclude )); ?> ``` Which is very straightforwar...
39,314
<p>I have a WordPress plugin I created that creates custom top level menu and submenu fine. The submenu calls this, (see code beneath) the BranchMaintenance PHP form, which shows branches in a table, ex the dbase, (using <code>$wpdb</code>).</p> <p>It's getting the jQuery UI dialog modal form to popup which is the pro...
[ { "answer_id": 39338, "author": "Shane", "author_id": 10555, "author_profile": "https://wordpress.stackexchange.com/users/10555", "pm_score": 2, "selected": false, "text": "<p>Although I'm not clear on what <em>exactly</em> you need, maybe I could offer a few pointers.</p>\n\n<p>First of...
2012/01/18
[ "https://wordpress.stackexchange.com/questions/39314", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12192/" ]
I have a WordPress plugin I created that creates custom top level menu and submenu fine. The submenu calls this, (see code beneath) the BranchMaintenance PHP form, which shows branches in a table, ex the dbase, (using `$wpdb`). It's getting the jQuery UI dialog modal form to popup which is the problem. Doubtless my co...
Although I'm not clear on what *exactly* you need, maybe I could offer a few pointers. First off, the documentation on the various sites have everything you need, so you should visit the [WordPress Codex](http://codex.wordpress.org), and [jQuery UI examples](http://jqueryui.com/demos/). **Hooks** admin\_init : You c...
39,315
<p>I've got some code like this:</p> <pre> $query_args = array(); $query_args['fields'] = array( 'ID', 'display_name' ); $query_args['role'] = 'subscriber'; $users = get_users( $query_args ); foreach ($users as $user) $users_array[$user->ID] = $user->display_name; </pre> <p>I want to get more roles and also include <...
[ { "answer_id": 39371, "author": "Tomas Buteler", "author_id": 5552, "author_profile": "https://wordpress.stackexchange.com/users/5552", "pm_score": 0, "selected": false, "text": "<p>All the parameters from the function <a href=\"http://codex.wordpress.org/Function_Reference/get_users\" r...
2012/01/18
[ "https://wordpress.stackexchange.com/questions/39315", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7938/" ]
I've got some code like this: ``` $query_args = array(); $query_args['fields'] = array( 'ID', 'display_name' ); $query_args['role'] = 'subscriber'; $users = get_users( $query_args ); foreach ($users as $user) $users_array[$user->ID] = $user->display_name; ``` I want to get more roles and also include `contributor`,...
Fastforward to WordPress 4.4 - it will support the `role__in` attribute! ------------------------------------------------------------------------ It looks like WordPress 4.4 is our **lucky version number**, because it will support both the `role__in` and `role__not_in` attributes of the `WP_User_Query` class. So to i...
39,348
<p>Currently I'm having some difficulties with below snippet.</p> <p>As it currently works it shows <code>the_excerpt_rss</code> on a single post and single page. AND it shows the option on <code>is_home()</code>.</p> <p>But what if a page (instead of the 'blog') is the frontpage? If possible I'd like to include the ...
[ { "answer_id": 39350, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": true, "text": "<p>Try <code>if ( 'page' == get_option( 'show_on_front' ) ) {}</code>.</p>\n\n<h3>Edit</h3>\n\n<blockquote>\n ...
2012/01/18
[ "https://wordpress.stackexchange.com/questions/39348", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
Currently I'm having some difficulties with below snippet. As it currently works it shows `the_excerpt_rss` on a single post and single page. AND it shows the option on `is_home()`. But what if a page (instead of the 'blog') is the frontpage? If possible I'd like to include the option as well. I've tried several ver...
Try `if ( 'page' == get_option( 'show_on_front' ) ) {}`. ### Edit > > but I've tried adding and replacing `<?php endwhile; endif; elseif (is_home()): ?>` with both of your code. Could you perhaps include your snippet with mine? > > > I'm not sure why you would do that. I was specifically answering this question:...
39,357
<p>I'm building my friends blog and he asked me a rather odd request. He wants the latest five blog posts to be visible to non-registered members but not to others. I'm using s2Member for membership handling.</p> <p>My Initial attempt was just limiting the number of blog posts to 5 and hiding the pagination button bas...
[ { "answer_id": 39350, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": true, "text": "<p>Try <code>if ( 'page' == get_option( 'show_on_front' ) ) {}</code>.</p>\n\n<h3>Edit</h3>\n\n<blockquote>\n ...
2012/01/18
[ "https://wordpress.stackexchange.com/questions/39357", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12203/" ]
I'm building my friends blog and he asked me a rather odd request. He wants the latest five blog posts to be visible to non-registered members but not to others. I'm using s2Member for membership handling. My Initial attempt was just limiting the number of blog posts to 5 and hiding the pagination button based on if s...
Try `if ( 'page' == get_option( 'show_on_front' ) ) {}`. ### Edit > > but I've tried adding and replacing `<?php endwhile; endif; elseif (is_home()): ?>` with both of your code. Could you perhaps include your snippet with mine? > > > I'm not sure why you would do that. I was specifically answering this question:...
39,361
<p>I'm having trouble with inserting a string which is containing quotation marks in wordpress via wpdb.</p> <p>I've written a hook for save_post and trying to write the post_title in a table via wpdp->update.</p> <p>String is taken straight from the $_POST array. Unfortunatly, in the db the string is saved with esca...
[ { "answer_id": 39363, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 2, "selected": false, "text": "<p>Try <code>stripslashes</code>. See the <a href=\"http://php.net/manual/en/function.stripslashes.php\" rel...
2012/01/18
[ "https://wordpress.stackexchange.com/questions/39361", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10985/" ]
I'm having trouble with inserting a string which is containing quotation marks in wordpress via wpdb. I've written a hook for save\_post and trying to write the post\_title in a table via wpdp->update. String is taken straight from the $\_POST array. Unfortunatly, in the db the string is saved with escaped quotation ...
Try `stripslashes`. See the [php documentation](http://php.net/manual/en/function.stripslashes.php). To clarify, the slashes are inserted to escape the content prior to insertion into the database. You should use the above function when you want to display the content.
39,364
<p>I am trying to achieve a similar look to the image below, a working example can be found here: <a href="http://www.menshealth.com/celebrity-fitness/mark-wahlberg-fighter-workout" rel="nofollow noreferrer">http://www.menshealth.com/celebrity-fitness/mark-wahlberg-fighter-workout</a></p> <p><img src="https://i.stack.i...
[ { "answer_id": 39370, "author": "Vlad Ionescu", "author_id": 12205, "author_profile": "https://wordpress.stackexchange.com/users/12205", "pm_score": -1, "selected": false, "text": "<p>Change this line:</p>\n\n<p><code>'before' =&gt; '&lt;p&gt;' . __(''),</code></p>\n\n<p>To:</p>\n\n<p><c...
2012/01/18
[ "https://wordpress.stackexchange.com/questions/39364", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5205/" ]
I am trying to achieve a similar look to the image below, a working example can be found here: <http://www.menshealth.com/celebrity-fitness/mark-wahlberg-fighter-workout> ![example](https://i.stack.imgur.com/9l9cv.jpg) **The needed code must do the following (some of my questions have been answered, but these remain)...
Your pagination links are wrapped in with this tag `<p class="pagelinks">` so giving them all the same spacing is easy using CSS like so: ``` .pagelinks a { margin: 0 5px !important; } /* override other defined margins */ ``` maybe you want them all centered on the page too: ``` .pagelinks { display:block; text-ali...
39,387
<p>For various reasons, I can't use Wordpress' built-in Thumbnail functionality.</p> <p>What I want to do instead is to use the first image in the post as the thumbnail.</p> <p>Here's what I found in the codex: <a href="http://codex.wordpress.org/Function_Reference/get_children#Show_the_first_image_associated_with_th...
[ { "answer_id": 39390, "author": "Andres Yanez", "author_id": 10229, "author_profile": "https://wordpress.stackexchange.com/users/10229", "pm_score": 1, "selected": false, "text": "<pre><code>function get_attachment_id_from_src ($src) {\n global $wpdb;\n\n $reg = \"/-[0-9]+x[0-9]+?....
2012/01/19
[ "https://wordpress.stackexchange.com/questions/39387", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10277/" ]
For various reasons, I can't use Wordpress' built-in Thumbnail functionality. What I want to do instead is to use the first image in the post as the thumbnail. Here's what I found in the codex: [Show the first image associated with the post](http://codex.wordpress.org/Function_Reference/get_children#Show_the_first_im...
I decided to use this, which is based on @AndresYanez's answer: ``` function get_image_id_by_link($link) { global $wpdb; $link = preg_replace('/-\d+x\d+(?=\.(jpg|jpeg|png|gif)$)/i', '', $link); return $wpdb->get_var("SELECT ID FROM {$wpdb->posts} WHERE BINARY guid='$link'"); } ``` This is much more suc...
39,408
<p>One of my Wordpress themes requires a few third party plugins to run correctly. </p> <p>Most of the times I used to call functions from third party plugins using conditional statements like</p> <pre><code> if(function_exist('plugin_function')) { plugin_function() // do something } </code></pre>...
[ { "answer_id": 39410, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 0, "selected": false, "text": "<p>If you need it only a plugin page, then there's <a href=\"http://codex.wordpress.org/Function_Reference/is_plugin_a...
2012/01/19
[ "https://wordpress.stackexchange.com/questions/39408", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8421/" ]
One of my Wordpress themes requires a few third party plugins to run correctly. Most of the times I used to call functions from third party plugins using conditional statements like ``` if(function_exist('plugin_function')) { plugin_function() // do something } ``` suppose though I need to use...
`is_plugin_active()` is rather fragile: it will break when either the plugin author renames the main file or when the user renames the plugin's directory or main file. It's better to check if a certain public function exists. To avoid having to make that check each time you need some of the plugin's functionality, you...
39,411
<p>I cannot get a cookie to set properly through WordPress theme. I am putting the following code on the bottom of my <code>functions.php</code> page for my theme.</p> <pre><code>function set_cookie() { if (isset($_GET['id'])) { $referrerID = $_GET['id']; setcookie('referrerid', $referrerID,time()+ 3600 * ...
[ { "answer_id": 39415, "author": "Geert", "author_id": 4936, "author_profile": "https://wordpress.stackexchange.com/users/4936", "pm_score": 3, "selected": true, "text": "<p>Make sure the HTTP headers are not sent already at the point you want to set the cookie. Here's how you can test th...
2012/01/19
[ "https://wordpress.stackexchange.com/questions/39411", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12224/" ]
I cannot get a cookie to set properly through WordPress theme. I am putting the following code on the bottom of my `functions.php` page for my theme. ``` function set_cookie() { if (isset($_GET['id'])) { $referrerID = $_GET['id']; setcookie('referrerid', $referrerID,time()+ 3600 * 24, COOKIEPATH, COOKIE_DO...
Make sure the HTTP headers are not sent already at the point you want to set the cookie. Here's how you can test that: ``` function set_cookie() { var_dump(headers_sent()); // should be bool(false) ... ``` Turning `WP_DEBUG` on in your config.php file may help also while debugging. --- By the way, you really s...
39,412
<p>Is there a hook for user activation (after they click the email confirm)? I am creating a plugin to automatically add them to my email software, but I want them to have to confirm their email first.</p>
[ { "answer_id": 39415, "author": "Geert", "author_id": 4936, "author_profile": "https://wordpress.stackexchange.com/users/4936", "pm_score": 3, "selected": true, "text": "<p>Make sure the HTTP headers are not sent already at the point you want to set the cookie. Here's how you can test th...
2012/01/19
[ "https://wordpress.stackexchange.com/questions/39412", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11141/" ]
Is there a hook for user activation (after they click the email confirm)? I am creating a plugin to automatically add them to my email software, but I want them to have to confirm their email first.
Make sure the HTTP headers are not sent already at the point you want to set the cookie. Here's how you can test that: ``` function set_cookie() { var_dump(headers_sent()); // should be bool(false) ... ``` Turning `WP_DEBUG` on in your config.php file may help also while debugging. --- By the way, you really s...
39,431
<p>If I go to wp-admin/edit-tags.php?taxonomy=location then I correctly see a list of terms.</p> <p>If I loop through:</p> <pre><code>get_terms("category"); </code></pre> <p>Then I correctly see several terms for the taxonomy of category. Have I created my custom taxonomy incorrectly for the same function not to out...
[ { "answer_id": 39432, "author": "Jared", "author_id": 2415, "author_profile": "https://wordpress.stackexchange.com/users/2415", "pm_score": 5, "selected": true, "text": "<p>If you are trying to use <em>all</em> of the terms in that taxonomy for something, try this:</p>\n\n<p><code>get_te...
2012/01/19
[ "https://wordpress.stackexchange.com/questions/39431", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7635/" ]
If I go to wp-admin/edit-tags.php?taxonomy=location then I correctly see a list of terms. If I loop through: ``` get_terms("category"); ``` Then I correctly see several terms for the taxonomy of category. Have I created my custom taxonomy incorrectly for the same function not to output any results for my taxonomy? ...
If you are trying to use *all* of the terms in that taxonomy for something, try this: `get_terms( "location", array( "hide_empty" => 0 ) );` You may be trying to return taxonomy terms that have no relationship to any object.
39,446
<p>I'm trying to create a function that would allow me to change the title of an established meta box (i.e, change Meta Box title 'Authors' to 'Team', etc.)</p> <p>I didn't want to use JS or have to unset the original meta box and re-add it.</p> <p>I started off with the following as per another thread that listed th...
[ { "answer_id": 39447, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 5, "selected": true, "text": "<h2>Improved Answer</h2>\n<p>I've decided to revisit this question after realising how unnecesarily hacky it ...
2012/01/19
[ "https://wordpress.stackexchange.com/questions/39446", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12238/" ]
I'm trying to create a function that would allow me to change the title of an established meta box (i.e, change Meta Box title 'Authors' to 'Team', etc.) I didn't want to use JS or have to unset the original meta box and re-add it. I started off with the following as per another thread that listed the code like so: ...
Improved Answer --------------- I've decided to revisit this question after realising how unnecesarily hacky it is. The the best solution is to to remove the metabox, and then re-add it, specifying an alternative title. Here's an example for the post post-type. ``` add_action( 'add_meta_boxes_post', 'wpse39446_add_...
39,455
<p>I'm wondering how I can show recent posts from the same taxonomy as the post that's currently being viewed (working with custom post types and custom taxonomies).</p> <p>If it was simply a category of a regular post, it would look like this:</p> <pre><code>&lt;?php global $post; $categories = get_the_category(); f...
[ { "answer_id": 39447, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 5, "selected": true, "text": "<h2>Improved Answer</h2>\n<p>I've decided to revisit this question after realising how unnecesarily hacky it ...
2012/01/19
[ "https://wordpress.stackexchange.com/questions/39455", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12239/" ]
I'm wondering how I can show recent posts from the same taxonomy as the post that's currently being viewed (working with custom post types and custom taxonomies). If it was simply a category of a regular post, it would look like this: ``` <?php global $post; $categories = get_the_category(); foreach ($categories as $...
Improved Answer --------------- I've decided to revisit this question after realising how unnecesarily hacky it is. The the best solution is to to remove the metabox, and then re-add it, specifying an alternative title. Here's an example for the post post-type. ``` add_action( 'add_meta_boxes_post', 'wpse39446_add_...
39,464
<p>How can I remove the admin bar in both the front and backend for all users in WordPress 3.3?</p>
[ { "answer_id": 39465, "author": "Rob Vermeer", "author_id": 11135, "author_profile": "https://wordpress.stackexchange.com/users/11135", "pm_score": 2, "selected": true, "text": "<pre><code>/* Front end */\nshow_admin_bar( false );\n\n/* back end */\nfunction disableAdminBar(){\n remov...
2012/01/19
[ "https://wordpress.stackexchange.com/questions/39464", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2107/" ]
How can I remove the admin bar in both the front and backend for all users in WordPress 3.3?
``` /* Front end */ show_admin_bar( false ); /* back end */ function disableAdminBar(){ remove_action( 'admin_footer', 'wp_admin_bar_render', 1000 ); function remove_admin_bar_style_backend() { echo '<style>body.admin-bar #wpcontent, body.admin-bar #adminmenu { padding-top: 0px !important; }</style...
39,469
<p>I've used almost all of the Wordpress example code but it still doesn't work. I've put the php file under wp-content/plugins/menuitem/ .The code is simple</p> <pre><code>&lt;?php add_action('admin_menu', 'donations_overview_menu'); function donations_overview_menu() { add_options_page('Donations overview', 'Don...
[ { "answer_id": 39471, "author": "Jared", "author_id": 2415, "author_profile": "https://wordpress.stackexchange.com/users/2415", "pm_score": 0, "selected": false, "text": "<p><code>add_options_page</code> adds a page to the Settings tab of the dashboard, not its own tab. I just copied you...
2012/01/19
[ "https://wordpress.stackexchange.com/questions/39469", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7164/" ]
I've used almost all of the Wordpress example code but it still doesn't work. I've put the php file under wp-content/plugins/menuitem/ .The code is simple ``` <?php add_action('admin_menu', 'donations_overview_menu'); function donations_overview_menu() { add_options_page('Donations overview', 'Donations overview',...
The code itself is fine. But you would need to activate the plug-in: you can't simply place the file in the plug-ins directory. You will need to give the plug-in a 'header' too. [See the Codex](http://codex.wordpress.org/Writing_a_Plugin). Alternatively, place the code in your theme's functions.php, but really it shou...
39,470
<p>Is there a filter or hook that I can use for uploaded media?</p> <p>I need to use it for custom CSS properties based on the media's description. It will be like:</p> <pre><code>&lt;img src="image_url" style="width: 60%;" /&gt; </code></pre> <p>or</p> <pre><code>&lt;img src="image_url" style="width: 80%;" /&gt;...
[ { "answer_id": 39478, "author": "matchdav", "author_id": 11852, "author_profile": "https://wordpress.stackexchange.com/users/11852", "pm_score": 0, "selected": false, "text": "<p>Why wouldn't you just use jQuery? </p>\n\n<pre><code>$(selector).css('width','60%')\n</code></pre>\n" }, ...
2012/01/19
[ "https://wordpress.stackexchange.com/questions/39470", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5645/" ]
Is there a filter or hook that I can use for uploaded media? I need to use it for custom CSS properties based on the media's description. It will be like: ``` <img src="image_url" style="width: 60%;" /> ``` or ``` <img src="image_url" style="width: 80%;" /> ``` Media description screenshot: ![Edit Media scree...
After inserting the image, click it again and click the small edit window. You can then add inline CSS using the Advanced Settings already built into WordPress. ![enter image description here](https://i.stack.imgur.com/JPLed.png)
39,473
<p>I'm working with a custom XML-RPC method to capture some information for a plugin I am building. When activated the user has to authenticate themselves by entering there user/password given to them when purchasing the plugin on my WP site.</p> <p>The plugin uses this code:</p> <pre><code>if ( isset( $_POST['userna...
[ { "answer_id": 39476, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 0, "selected": false, "text": "<p>Nothing looks wrong with your code. You're definitely adding the XMLRPC endpoint correctly. The only issue I see is...
2012/01/19
[ "https://wordpress.stackexchange.com/questions/39473", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9065/" ]
I'm working with a custom XML-RPC method to capture some information for a plugin I am building. When activated the user has to authenticate themselves by entering there user/password given to them when purchasing the plugin on my WP site. The plugin uses this code: ``` if ( isset( $_POST['username'] ) && isset( $_PO...
I sent it to you on Twitter, but here it is again. I made this little class to help me do XML-RPC faster. ``` abstract class MZAXMLRPC { protected $calls = Array(); protected $namespace = "myxmlrpc"; function __construct($namespace){ $this->namespace = $namespace; $reflector = new Reflect...
39,483
<p>Well I'm here again with almost the same problem as I had in <a href="https://wordpress.stackexchange.com/questions/37431/broken-pagination-need-help-figuring-out-why/37435#37435">this post three weeks ago</a>, but let me explain what has happened since then:</p> <p>I was originally using one loop to display the mo...
[ { "answer_id": 39486, "author": "Shane", "author_id": 10555, "author_profile": "https://wordpress.stackexchange.com/users/10555", "pm_score": 0, "selected": false, "text": "<p>Shouldn't you be using paging parameters in your WP_Query</p>\n\n<pre><code> $posts = new WP_Query( array( /*you...
2012/01/19
[ "https://wordpress.stackexchange.com/questions/39483", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
Well I'm here again with almost the same problem as I had in [this post three weeks ago](https://wordpress.stackexchange.com/questions/37431/broken-pagination-need-help-figuring-out-why/37435#37435), but let me explain what has happened since then: I was originally using one loop to display the most recent sticky post...
I see a few issues that are probably contributing to your issue: 1. Only ever use `query_posts()` to modify the primary Loop. 2. The [`caller_get_posts` parameter has been deprecated](http://codex.wordpress.org/Class_Reference/WP_Query#Sticky_Post_Parameters), in favor of `ignore_sticky_posts` 3. The `$wp_query` varia...
39,488
<p>I want to modify $path in the following filter. It has 1 input and 2 args. </p> <pre><code>function documents_template( $template = '' ) { $path = DOCUMENTS_INCLUDES_DIR . '/document/' . $template; return apply_filters( 'document_template', $path, $template ); } </code></pre> <p>This is my function to a...
[ { "answer_id": 39489, "author": "Rob Vermeer", "author_id": 11135, "author_profile": "https://wordpress.stackexchange.com/users/11135", "pm_score": 5, "selected": true, "text": "<pre><code>function my_locate_template( $path, $template ){\n\n $path = MY_INCLUDES_DIR . '/document/'. $...
2012/01/19
[ "https://wordpress.stackexchange.com/questions/39488", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5210/" ]
I want to modify $path in the following filter. It has 1 input and 2 args. ``` function documents_template( $template = '' ) { $path = DOCUMENTS_INCLUDES_DIR . '/document/' . $template; return apply_filters( 'document_template', $path, $template ); } ``` This is my function to add filter, it gets error m...
``` function my_locate_template( $path, $template ){ $path = MY_INCLUDES_DIR . '/document/'. $template; return $path; } add_filter( 'documents_template','my_locate_template', 10, 2 ); ``` add\_filter takes 4 variables. The first and second are required. 1. name of the filter, 2. name of the function. The...