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
66,546
<p>I have this weird thing to do and I have no idea how to do it. Ok, so:</p> <p>I have two custom taxonomies: <code>collections</code> and <code>categories</code> (both are prefixed, but for the sake of simplicity, I'll use these short names). A post will have a category and will be added into a collection.</p> <p>W...
[ { "answer_id": 66552, "author": "Sebastian Popa", "author_id": 20943, "author_profile": "https://wordpress.stackexchange.com/users/20943", "pm_score": 0, "selected": false, "text": "<p>I did something that sounds familiar with your case and the easiest way to do it was using the <a href=...
2012/09/28
[ "https://wordpress.stackexchange.com/questions/66546", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/223/" ]
I have this weird thing to do and I have no idea how to do it. Ok, so: I have two custom taxonomies: `collections` and `categories` (both are prefixed, but for the sake of simplicity, I'll use these short names). A post will have a category and will be added into a collection. What I have to do is to display all post...
You can try getting all the posts IDs from the first taxonomy ``` $objects = get_posts( array( 'category' => 'history', 'numberposts' => -1, ) ); foreach ($objects as $object) { $objects_ids[] = $object->ID; } ``` Then get the terms from the second taxonomy associated with them: ``` $collections = wp_get_object...
66,565
<p>I know the former allows additional parameters, so you can more user info, but other then that, why do both exist?</p> <p>The specific reason I want to know is that wp_insert_user() is happening REALLY slowly. Somewhere between 5 - 10 seconds. I don't remember having this problem in the past, when I was using creat...
[ { "answer_id": 66566, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 5, "selected": true, "text": "<p>None. The whole source of <code>wp_create_user()</code> is:</p>\n\n<pre><code>function wp_create_user($username, $pas...
2012/09/28
[ "https://wordpress.stackexchange.com/questions/66565", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11363/" ]
I know the former allows additional parameters, so you can more user info, but other then that, why do both exist? The specific reason I want to know is that wp\_insert\_user() is happening REALLY slowly. Somewhere between 5 - 10 seconds. I don't remember having this problem in the past, when I was using create\_user,...
None. The whole source of `wp_create_user()` is: ``` function wp_create_user($username, $password, $email = '') { $user_login = esc_sql( $username ); $user_email = esc_sql( $email ); $user_pass = $password; $userdata = compact('user_login', 'user_email', 'user_pass'); return wp_insert_user($use...
66,574
<p>Is there any way to overwrite a <code>&lt;head&gt;&lt;title&gt;Category title&lt;/title&gt;&lt;/head&gt;</code> tag?</p> <p>Let's say i have a "Videos" category, when user point's his browser to <code>www.website.com/category/videos/</code>, the page title (this one in <code>head</code> section) is <strong>Videos</...
[ { "answer_id": 66582, "author": "SeventhSteel", "author_id": 17276, "author_profile": "https://wordpress.stackexchange.com/users/17276", "pm_score": 1, "selected": false, "text": "<p>Depending on your theme, in the <code>header.php</code> template, just find the line with the <code>&lt;t...
2012/09/28
[ "https://wordpress.stackexchange.com/questions/66574", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9864/" ]
Is there any way to overwrite a `<head><title>Category title</title></head>` tag? Let's say i have a "Videos" category, when user point's his browser to `www.website.com/category/videos/`, the page title (this one in `head` section) is **Videos**. What i need to do is to somehow overwrite it to display **Archive** str...
You can use the [`wp_title`](http://codex.wordpress.org/Plugin_API/Filter_Reference/wp_title) filter to modify the output of the [`wp_title`](http://codex.wordpress.org/Function_Reference/wp_title) function. quick example based on the example from Codex: ``` add_filter( 'wp_title', 'wpa66574_title_filter', 10, 3 ); ...
66,575
<p>It looks like <a href="http://wordpress.org/extend/ideas/topic/add-current-cat-ancestor-class-to-categoly-list" rel="nofollow">adding current-cat-ancestor class to category list</a> was proposed, but never implemented. The only way I've been able to find so far is to re-create the <code>wp_list_categories()</code> f...
[ { "answer_id": 66782, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p>I don't see a simple way of hooking in, there may be if you dig deeper, and it's probably better to use a nav...
2012/09/28
[ "https://wordpress.stackexchange.com/questions/66575", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9605/" ]
It looks like [adding current-cat-ancestor class to category list](http://wordpress.org/extend/ideas/topic/add-current-cat-ancestor-class-to-categoly-list) was proposed, but never implemented. The only way I've been able to find so far is to re-create the `wp_list_categories()` function entirely: ``` function wp_list_...
After fumbling around with this for a bit, I realized I needed this to work with custom taxonomies, not just regular categories. I unfortunately couldn't use "all" of what either the solution I found or Tom did, so I ended up writing my own. As long as you specify a `taxonomy` arg, you should be all set: ``` function ...
66,576
<p>I found out something weird today.</p> <p>The current permalink is set to <code>/%category%/%postname%/</code> but this happens (example):</p> <p>I have a parent category <code>Food</code> and 4 subcategories <code>Burger</code>, <code>Pancake</code>, <code>Waffles</code>, and <code>Pizza</code>. As expected, the ...
[ { "answer_id": 66782, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p>I don't see a simple way of hooking in, there may be if you dig deeper, and it's probably better to use a nav...
2012/09/28
[ "https://wordpress.stackexchange.com/questions/66576", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6969/" ]
I found out something weird today. The current permalink is set to `/%category%/%postname%/` but this happens (example): I have a parent category `Food` and 4 subcategories `Burger`, `Pancake`, `Waffles`, and `Pizza`. As expected, the link should appear like this: `foo.com/food/burger/post-name` but it only works on ...
After fumbling around with this for a bit, I realized I needed this to work with custom taxonomies, not just regular categories. I unfortunately couldn't use "all" of what either the solution I found or Tom did, so I ended up writing my own. As long as you specify a `taxonomy` arg, you should be all set: ``` function ...
66,579
<p>We can use multiple plugins like wp-pagenavi or wp-paginate for implementing pagination for wordpress sites and making it ajax based using the following code: </p> <pre><code>jQuery(document).ready(function(){ // ajax pagination jQuery('#wp_page_numbers a').live('click', function(){ var link = jQu...
[ { "answer_id": 66587, "author": "Jared Cobb", "author_id": 6737, "author_profile": "https://wordpress.stackexchange.com/users/6737", "pm_score": 1, "selected": false, "text": "<p>Soumitra Chakraborty wrote a very good tutorial on <a href=\"http://wp.tutsplus.com/articles/getting-started-...
2012/09/28
[ "https://wordpress.stackexchange.com/questions/66579", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14123/" ]
We can use multiple plugins like wp-pagenavi or wp-paginate for implementing pagination for wordpress sites and making it ajax based using the following code: ``` jQuery(document).ready(function(){ // ajax pagination jQuery('#wp_page_numbers a').live('click', function(){ var link = jQuery(this).attr...
Soumitra Chakraborty wrote a very good tutorial on [Getting Started with AJAX & WordPress Pagination](http://wp.tutsplus.com/articles/getting-started-with-ajax-wordpress-pagination/). I would recommend following that pattern (in terms of how to use [`admin_ajax.php`](http://codex.wordpress.org/AJAX_in_Plugins) in conju...
66,583
<p>I've added a column to the edit screen and add an input for that column in the quickedit. Everything saves and displays like I'd expect with one small hiccup.</p> <p>If I click on Quick Edit for a particular post, make a change to the custom input, and save.... well the column updates properly. However, if I clic...
[ { "answer_id": 66646, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 3, "selected": true, "text": "<p>The solution was on the jquery side of things. The .on function needed to <em>bubble upwards</em> to be s...
2012/09/28
[ "https://wordpress.stackexchange.com/questions/66583", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6477/" ]
I've added a column to the edit screen and add an input for that column in the quickedit. Everything saves and displays like I'd expect with one small hiccup. If I click on Quick Edit for a particular post, make a change to the custom input, and save.... well the column updates properly. However, if I click Quick Edit...
The solution was on the jquery side of things. The .on function needed to *bubble upwards* to be sure that it was always getting the most recent, ajax-added content. I only had to adjust the first line to be more aligned with jquery documentation for [`.on()`](http://api.jquery.com/on/). ``` $( '#the-list' ).on( 'clic...
66,616
<p>I'm building a website with Wordpress and I'm using the plugin Event Organiser.</p> <p>I changed the config file of Wordpress to use the nl_NL (Dutch) language. This all works fine, even for the plugin, except the pages that use a template I overloaded in my child theme.</p> <p>So I made this child theme for twent...
[ { "answer_id": 66646, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 3, "selected": true, "text": "<p>The solution was on the jquery side of things. The .on function needed to <em>bubble upwards</em> to be s...
2012/09/29
[ "https://wordpress.stackexchange.com/questions/66616", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20957/" ]
I'm building a website with Wordpress and I'm using the plugin Event Organiser. I changed the config file of Wordpress to use the nl\_NL (Dutch) language. This all works fine, even for the plugin, except the pages that use a template I overloaded in my child theme. So I made this child theme for twenty eleven, and I ...
The solution was on the jquery side of things. The .on function needed to *bubble upwards* to be sure that it was always getting the most recent, ajax-added content. I only had to adjust the first line to be more aligned with jquery documentation for [`.on()`](http://api.jquery.com/on/). ``` $( '#the-list' ).on( 'clic...
66,645
<p>I'm using a plugin called CMS Page Order <a href="http://wordpress.org/extend/plugins/cms-page-order/" rel="nofollow noreferrer">http://wordpress.org/extend/plugins/cms-page-order/</a> (Now referred to as CPO)</p> <p>It's pretty simple, the said plugin adds a new item to the submenu of every custom post type. The m...
[ { "answer_id": 67705, "author": "loQ", "author_id": 21300, "author_profile": "https://wordpress.stackexchange.com/users/21300", "pm_score": 1, "selected": false, "text": "<p>have you tried considering jquery? Maybe this will help you. Ive tried it and it worked. Just put this in your fun...
2012/09/29
[ "https://wordpress.stackexchange.com/questions/66645", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2830/" ]
I'm using a plugin called CMS Page Order <http://wordpress.org/extend/plugins/cms-page-order/> (Now referred to as CPO) It's pretty simple, the said plugin adds a new item to the submenu of every custom post type. The menu item leads to a page where you can reorder the posts of the certain post type. I've added so th...
You can also change the menu with the global variables of WordPress for display the menu and submenu. All first items are in the var `$menu` and all suparts are in `$submenu`. Also a small example for change the order of the submenu-items with `edit.php`. Add thius plugin and see the result via debugging. The function...
66,677
<p>Here's my thing:</p> <p>I'm using a plugin that has multilang capabilities. The point is that the language translation in my country lang is very bad and it makes more complex than simpler my work. :D. So is there a way to force a plugin to not to use multilanguage and be showed, at least, in English?</p>
[ { "answer_id": 66678, "author": "lorenzov", "author_id": 20980, "author_profile": "https://wordpress.stackexchange.com/users/20980", "pm_score": 2, "selected": true, "text": "<p>What's the plugin? Is it using custom translations in mo/po files? Is there an admin interface which allows yo...
2012/09/30
[ "https://wordpress.stackexchange.com/questions/66677", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20979/" ]
Here's my thing: I'm using a plugin that has multilang capabilities. The point is that the language translation in my country lang is very bad and it makes more complex than simpler my work. :D. So is there a way to force a plugin to not to use multilanguage and be showed, at least, in English?
What's the plugin? Is it using custom translations in mo/po files? Is there an admin interface which allows you to set the plugin locale? There is a generic filter which you might be able to add to the plugin code to set the language which might look something like the following (obviously set the language to what you...
66,700
<p>i want to add a link to the first post of every WP blog that i have. For example this simple function adds the link to every post.</p> <pre><code> function add_link($link){ $link .= '&lt;a href="http://site.com"&gt;Link&lt;/a&gt;'; return $link; } add_filter('the_content','add_link'); </code></pre> ...
[ { "answer_id": 66703, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 0, "selected": false, "text": "<p>Trivial with some basic logic</p>\n\n<p>Add before your function:</p>\n\n<pre><code>$added = false;\n</code><...
2012/09/30
[ "https://wordpress.stackexchange.com/questions/66700", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12918/" ]
i want to add a link to the first post of every WP blog that i have. For example this simple function adds the link to every post. ``` function add_link($link){ $link .= '<a href="http://site.com">Link</a>'; return $link; } add_filter('the_content','add_link'); ``` so basically instead of the link s...
Just remove the filter when it is called the first time: ``` function add_link($link) { // this will guarantee the filter will not be called again. remove_filter( current_filter(), __FUNCTION__ ); return $link . '<a href="http://site.com">Link</a>'; } ```
66,714
<p>I'm using the below code to highlight the page name/gallery shown when the corresponding link is clicked on. My challenge is that regardless of what link I click, only the very first link(<code>page_id=24</code>/Haagen-Dazs) is highlighted. Any ideas what's causing the issue?</p> <p>Thanks.</p> <p><a href="http://...
[ { "answer_id": 66703, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 0, "selected": false, "text": "<p>Trivial with some basic logic</p>\n\n<p>Add before your function:</p>\n\n<pre><code>$added = false;\n</code><...
2012/09/30
[ "https://wordpress.stackexchange.com/questions/66714", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14606/" ]
I'm using the below code to highlight the page name/gallery shown when the corresponding link is clicked on. My challenge is that regardless of what link I click, only the very first link(`page_id=24`/Haagen-Dazs) is highlighted. Any ideas what's causing the issue? Thanks. [live site](http://urbanpalate.com/instyle-m...
Just remove the filter when it is called the first time: ``` function add_link($link) { // this will guarantee the filter will not be called again. remove_filter( current_filter(), __FUNCTION__ ); return $link . '<a href="http://site.com">Link</a>'; } ```
66,716
<p>I know this this is covered as individual topics but What I am looking for is a single function that stops <code>&lt;p&gt;</code> tags from being wrapped around via the Wordpress editor to shortcodes and images and also removes empty <code>&lt;p&gt;</code> tages, for example:</p> <ul> <li>remove <code>&lt;p&gt;</co...
[ { "answer_id": 66717, "author": "Jamie", "author_id": 14761, "author_profile": "https://wordpress.stackexchange.com/users/14761", "pm_score": 0, "selected": false, "text": "<p>I think removing the p tags altogether is a bad practice. For the empty p tags, there is a css rule that you can...
2012/09/30
[ "https://wordpress.stackexchange.com/questions/66716", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16641/" ]
I know this this is covered as individual topics but What I am looking for is a single function that stops `<p>` tags from being wrapped around via the Wordpress editor to shortcodes and images and also removes empty `<p>` tages, for example: * remove `<p>` tags that get wrapped around shortcodes, i.e., `<p>[shortcode...
### 1. Filtering the content Here's a one-function content filter to meet the above four requirements: ``` add_filter( 'the_content', 'strip_some_paragraphs', 20 ); function strip_some_paragraphs( $content ) { $content = preg_replace( '/<p>(([\s]*)|[\s]*(<img[^>]*>|\[[^\]]*\])[\s]*)<\/p>/', '$3',...
66,728
<p>Essentially I'm trying to add multiple sub nav menus and I'm pretty close but I just can't seem to find the right tack to solve my problem ... </p> <p>I'm using a variation of a Stu Nichols CSS Menu ... </p> <p>Code explains better ;-)</p> <p>The relationship required to build this menu would have the top leve...
[ { "answer_id": 66721, "author": "grm", "author_id": 88, "author_profile": "https://wordpress.stackexchange.com/users/88", "pm_score": 3, "selected": false, "text": "<p>There is a plugin called WP-DB-Backup <a href=\"http://wordpress.org/extend/plugins/wp-db-backup/\">http://wordpress.org...
2012/09/30
[ "https://wordpress.stackexchange.com/questions/66728", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20996/" ]
Essentially I'm trying to add multiple sub nav menus and I'm pretty close but I just can't seem to find the right tack to solve my problem ... I'm using a variation of a Stu Nichols CSS Menu ... Code explains better ;-) The relationship required to build this menu would have the top level elements as list-items, c...
There is a plugin called WP-DB-Backup <http://wordpress.org/extend/plugins/wp-db-backup/> You can configure it to email you a backup of your blog at a specific interval.
66,734
<p>I have been trying for two weeks to add a edit custom meta field to the admin edit comment form. I managed to show the field in the form, but it can't get it to update. </p> <p>I would also like to add this field to the registration form and profile.</p> <p>this is what I have so far </p> <pre><code>add_action( '...
[ { "answer_id": 66736, "author": "Michael Lewis", "author_id": 20149, "author_profile": "https://wordpress.stackexchange.com/users/20149", "pm_score": 0, "selected": false, "text": "<p>Try this:</p>\n\n<pre><code>function location_save($comment_content){\n $id = $_POST['comment_ID'];\n...
2012/09/30
[ "https://wordpress.stackexchange.com/questions/66734", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19108/" ]
I have been trying for two weeks to add a edit custom meta field to the admin edit comment form. I managed to show the field in the form, but it can't get it to update. I would also like to add this field to the registration form and profile. this is what I have so far ``` add_action( 'comment_post', 'save_comment...
The get\_comment\_ID function was not working. So use following code in location\_meta\_call function ``` function location_meta_call(){ $location = get_comment_meta($_GET["c"],'location', true); } add_filter('comment_save_pre','location_save'); function location_save($comment_content){ global $wpdb; ...
66,757
<p>I want to create a drop down list that will list all the posts in the category. I want the drop down list to appear on every post. So for example if I view a post that belongs to category Apples it should list all posts in category Apples</p>
[ { "answer_id": 66767, "author": "Sagive", "author_id": 7990, "author_profile": "https://wordpress.stackexchange.com/users/7990", "pm_score": 3, "selected": true, "text": "<p><strong>Hey @Ruriko ... its a 3 step action.</strong> </p>\n\n<ol>\n<li>get the current category ID</li>\n<li>get...
2012/10/01
[ "https://wordpress.stackexchange.com/questions/66757", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17971/" ]
I want to create a drop down list that will list all the posts in the category. I want the drop down list to appear on every post. So for example if I view a post that belongs to category Apples it should list all posts in category Apples
**Hey @Ruriko ... its a 3 step action.** 1. get the current category ID 2. get the posts for this specific category 3. get the posts into a select menu Please note that this code would use the first category id altough you might assign several categories to the same post. . ``` <?php // FIRST CATEGORY N...
66,770
<p>I need to create an "Empty Trash" button inside my plugin. How would I do it using PHP code?</p>
[ { "answer_id": 66773, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 4, "selected": true, "text": "<p>You can use <a href=\"http://codex.wordpress.org/Function_Reference/wp_delete_post\"><code>wp_delete_post</c...
2012/10/01
[ "https://wordpress.stackexchange.com/questions/66770", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7349/" ]
I need to create an "Empty Trash" button inside my plugin. How would I do it using PHP code?
You can use [`wp_delete_post`](http://codex.wordpress.org/Function_Reference/wp_delete_post). To get all posts with the "trash" status: `$trash = get_posts('post_status=trash&numberposts=-1');` Then: ``` foreach($trash as $post) wp_delete_post($post->ID, $bypass_trash = true); ```
66,784
<p>I'm trying to migrate my wordpress from a subfolde to the root. I've already done it from localhost to the subfolder with the same method</p> <pre><code>update_option('siteurl','http://example.com/blog'); update_option('home','http://example.com/blog'); </code></pre> <p>But this time it does not look to work... It...
[ { "answer_id": 66773, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 4, "selected": true, "text": "<p>You can use <a href=\"http://codex.wordpress.org/Function_Reference/wp_delete_post\"><code>wp_delete_post</c...
2012/10/01
[ "https://wordpress.stackexchange.com/questions/66784", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18809/" ]
I'm trying to migrate my wordpress from a subfolde to the root. I've already done it from localhost to the subfolder with the same method ``` update_option('siteurl','http://example.com/blog'); update_option('home','http://example.com/blog'); ``` But this time it does not look to work... It says "Call to undefined f...
You can use [`wp_delete_post`](http://codex.wordpress.org/Function_Reference/wp_delete_post). To get all posts with the "trash" status: `$trash = get_posts('post_status=trash&numberposts=-1');` Then: ``` foreach($trash as $post) wp_delete_post($post->ID, $bypass_trash = true); ```
66,788
<p>Is it possible to put a function somewhere other than the functions.php file? I.e directly into a template?</p> <p>I have the following that needs to be called before some code and to make sure this happens I want to place it above everything else in the template:</p> <pre><code>function set_region_cookie() { ...
[ { "answer_id": 66790, "author": "dipali", "author_id": 20711, "author_profile": "https://wordpress.stackexchange.com/users/20711", "pm_score": -1, "selected": false, "text": "<p>Yes, you can put function in anywhere in template. But, that function used for that template only.</p>\n" },...
2012/10/01
[ "https://wordpress.stackexchange.com/questions/66788", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4588/" ]
Is it possible to put a function somewhere other than the functions.php file? I.e directly into a template? I have the following that needs to be called before some code and to make sure this happens I want to place it above everything else in the template: ``` function set_region_cookie() { if(isset($_POST['regi...
Since you are using init "add\_action", then it is best not to use it in a template - since "add\_action" is used by Wordpress core's "do\_action" - which comes before the templates. If you want this function to take higher priority, place it in functions.php but use the 'priority' variable of "add\_action": ``` add_...
66,804
<p>I'm trying to write an image gallery plugin with jQuery. I'm using jQuerys $.post AJAX method to send and receive info from the relevant post page. Basically I'll be looping through the attachments and adding a new image each time the next button is hit, until I've used all images (when I'll need to return something...
[ { "answer_id": 66807, "author": "Matthew Boynes", "author_id": 12324, "author_profile": "https://wordpress.stackexchange.com/users/12324", "pm_score": 0, "selected": false, "text": "<p>Using ajax here would probably not be in your best interest (with one exception, see below). First, you...
2012/10/01
[ "https://wordpress.stackexchange.com/questions/66804", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5827/" ]
I'm trying to write an image gallery plugin with jQuery. I'm using jQuerys $.post AJAX method to send and receive info from the relevant post page. Basically I'll be looping through the attachments and adding a new image each time the next button is hit, until I've used all images (when I'll need to return something to...
As @MatthewBoynes already stated, making a `$.post()` request for every image might bring some overhead. A maybe better solution would be to grab and cache them, then throw them into your js files using [`wp_localize_script()`](http://queryposts.com/function/wp_localize_script/). ``` $attachments = get_posts( array(...
66,817
<p>I am using a sql query to access information to display on a wordpress page by adding the below code to a page template. I know the query works as I've tested it in phpmyadmin.</p> <pre><code> $rows = $newdb-&gt;get_results("SELECT TrainerName FROM trainers"); echo "&lt;ul&gt;"; foreach ($rows as $obj) : echo...
[ { "answer_id": 66820, "author": "Ben HartLenn", "author_id": 6645, "author_profile": "https://wordpress.stackexchange.com/users/6645", "pm_score": 2, "selected": false, "text": "<p>Where you have this:</p>\n\n<pre><code>$newdb = new wpdb();\n</code></pre>\n\n<p>You need to give the new d...
2012/10/01
[ "https://wordpress.stackexchange.com/questions/66817", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17732/" ]
I am using a sql query to access information to display on a wordpress page by adding the below code to a page template. I know the query works as I've tested it in phpmyadmin. ``` $rows = $newdb->get_results("SELECT TrainerName FROM trainers"); echo "<ul>"; foreach ($rows as $obj) : echo "<li>".$obj->Name."</l...
As Ben suggested, you need to pass the connection details when creating the wpdb class: ``` $newdb = new wpdb( 'user', 'password', 'database', 'hostname' ); ``` You should also test that the query actually returned something before using the result in a foreach loop: ``` if ($rows) { foreach ($rows as $obj) { ...
66,845
<p>I have this code in my <strong>header.php</strong> and it is working:</p> <pre><code>&lt;div id="news"&gt; &lt;?php query_posts('category_name=news'); ?&gt; &lt;?php while (have_posts()) : the_post(); ?&gt; &lt;div class="new"&gt; &lt;a href="&lt;?php the_permalink(); ?&g...
[ { "answer_id": 66861, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": false, "text": "<p>No that's impossible. When <em>WordPress</em> calls a method it has to be public. You could write a public method that...
2012/10/02
[ "https://wordpress.stackexchange.com/questions/66845", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17368/" ]
I have this code in my **header.php** and it is working: ``` <div id="news"> <?php query_posts('category_name=news'); ?> <?php while (have_posts()) : the_post(); ?> <div class="new"> <a href="<?php the_permalink(); ?>"> <?php the_post_thumbnail('thumbnail'); ...
No that's impossible. When *WordPress* calls a method it has to be public. You could write a public method that is called on the hook which calls a private method inside. Not sure if that makes sense though …
66,873
<p>Here's the overview of the setup:</p> <ul> <li>I have a multisite installation of WordPress 3.4.2.</li> <li>I've installed the <a href="http://wordpress.org/extend/plugins/active-directory-authentication-integration/">Active Directory Authentication Integration</a> plugin to allow users to use their AD credentials...
[ { "answer_id": 283717, "author": "luukvhoudt", "author_id": 44637, "author_profile": "https://wordpress.stackexchange.com/users/44637", "pm_score": 1, "selected": false, "text": "<p>Try a different approach. Instead of using plugins, I suggest modifying wordpress a little as described in...
2012/10/02
[ "https://wordpress.stackexchange.com/questions/66873", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13684/" ]
Here's the overview of the setup: * I have a multisite installation of WordPress 3.4.2. * I've installed the [Active Directory Authentication Integration](http://wordpress.org/extend/plugins/active-directory-authentication-integration/) plugin to allow users to use their AD credentials. This also allows assigning AD g...
Try a different approach. Instead of using plugins, I suggest modifying wordpress a little as described in the following answer. <https://stackoverflow.com/a/39195424/3157038> So in your case you should setup the wordpress installations like this: * mysite.com + root: \*/domains/mysite.com/public\_html + db: user\...
66,921
<p>I'm trying to register &amp; enqueue <a href="http://www.outsharked.com/imagemapster/" rel="nofollow">ImageMapster</a> in my Skeleton Child Theme on the main.php page to make an image map with hovering image effects. I added this code to the "Header Functions" section of my child theme's functions.php file:</p> <pr...
[ { "answer_id": 66935, "author": "Jared Cobb", "author_id": 6737, "author_profile": "https://wordpress.stackexchange.com/users/6737", "pm_score": 0, "selected": false, "text": "<p>Have you tried using <a href=\"http://codex.wordpress.org/Function_Reference/get_template_directory\" rel=\"n...
2012/10/02
[ "https://wordpress.stackexchange.com/questions/66921", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21055/" ]
I'm trying to register & enqueue [ImageMapster](http://www.outsharked.com/imagemapster/) in my Skeleton Child Theme on the main.php page to make an image map with hovering image effects. I added this code to the "Header Functions" section of my child theme's functions.php file: ``` add_action( 'wp_enqueue_scripts', 'l...
One problem: if you define the script in a `wp_register_script()` like so: ``` wp_register_script( 'jquery.imagemapster.js', get_template_directory_uri() . '/javascripts/jquery.imagemapster.js', array('jquery'), '1.2.6', false ); ``` ...then you only need to reference the *defined script's ...
66,930
<p>I am trying to develop a dashboard widget that counts posts or post types by month. I am really not sure how to go about doing this.</p> <p>I know how to create a dashboard widget and all that with post counts, post type counts.</p> <p>I even have a custom one that lists the most recent post types i have. But I have...
[ { "answer_id": 66940, "author": "Jonathan", "author_id": 17872, "author_profile": "https://wordpress.stackexchange.com/users/17872", "pm_score": 1, "selected": false, "text": "<p>I implemented something similar for a custom post type archive, because I didn't like the handling of wp_get_...
2012/10/02
[ "https://wordpress.stackexchange.com/questions/66930", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8337/" ]
I am trying to develop a dashboard widget that counts posts or post types by month. I am really not sure how to go about doing this. I know how to create a dashboard widget and all that with post counts, post type counts. I even have a custom one that lists the most recent post types i have. But I have yet to create ...
Just Went over your code and it looks fine but you are missing the code blocks for your foreach loops so: ``` add_action('wp_dashboard_setup', 'dashboard_test'); function dashboard_test() { global $wp_meta_boxes; wp_add_dashboard_widget('month_dashboard', 'Reports Submitted for the Year', 'custom_test'); } ...
66,932
<p>I have a specific need to import many post with featured images into a custom post type. The issue is, I need this to be a script because it runs off of another system that collects all the data. I currently have the custom post types setup and I have the data to be displayed in the custom post type using custom tem...
[ { "answer_id": 66940, "author": "Jonathan", "author_id": 17872, "author_profile": "https://wordpress.stackexchange.com/users/17872", "pm_score": 1, "selected": false, "text": "<p>I implemented something similar for a custom post type archive, because I didn't like the handling of wp_get_...
2012/10/02
[ "https://wordpress.stackexchange.com/questions/66932", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19217/" ]
I have a specific need to import many post with featured images into a custom post type. The issue is, I need this to be a script because it runs off of another system that collects all the data. I currently have the custom post types setup and I have the data to be displayed in the custom post type using custom templa...
Just Went over your code and it looks fine but you are missing the code blocks for your foreach loops so: ``` add_action('wp_dashboard_setup', 'dashboard_test'); function dashboard_test() { global $wp_meta_boxes; wp_add_dashboard_widget('month_dashboard', 'Reports Submitted for the Year', 'custom_test'); } ...
66,937
<p>i want to make custom filed that contains facebook like count for the post url to get the likes i used this code </p> <pre><code>function fb_count(){ $link = get_permalink($post-&gt;ID); $content = file_get_contents("http://api.facebook.com/restserver.php?method=links.getStats&amp;urls=".$link); $element = new Simp...
[ { "answer_id": 66955, "author": "Shady M Rasmy", "author_id": 17025, "author_profile": "https://wordpress.stackexchange.com/users/17025", "pm_score": 3, "selected": true, "text": "<p>I've done it, here is the complete code:</p>\n\n<pre><code>function insert_facebook_likes_custom_field($p...
2012/10/02
[ "https://wordpress.stackexchange.com/questions/66937", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17025/" ]
i want to make custom filed that contains facebook like count for the post url to get the likes i used this code ``` function fb_count(){ $link = get_permalink($post->ID); $content = file_get_contents("http://api.facebook.com/restserver.php?method=links.getStats&urls=".$link); $element = new SimpleXmlElement($content...
I've done it, here is the complete code: ``` function insert_facebook_likes_custom_field($post_ID) { global $wpdb; if (!wp_is_post_revision($post_ID)) { add_post_meta($post_ID, 'likes_count', '0', true); } } add_action('publish_page', 'insert_facebook_likes_custom_field'); add_action('publish_post'...
66,963
<p>Is it possible to display the total post count for all blogs in a Network? <code>get_blog_count</code> and <code>get_user_count</code> do so for blogs and users, but I can't find any methods to do so for post count.</p>
[ { "answer_id": 72899, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 2, "selected": false, "text": "<p>In form of a Network Dashboard Widget:</p>\n\n<p><img src=\"https://i.stack.imgur.com/IN7Yc.png\" alt=\"netw...
2012/10/03
[ "https://wordpress.stackexchange.com/questions/66963", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3842/" ]
Is it possible to display the total post count for all blogs in a Network? `get_blog_count` and `get_user_count` do so for blogs and users, but I can't find any methods to do so for post count.
Made a couple of tweaks to brasofilo's example as we were getting hit with memory execution issues; one of which may be related to a possible [switch\_to\_blog memory leak](http://wordpress.org/support/topic/switch_to_blog-causing-memory-leak) that has been impacting sites doing a lot of `switch_to_blog` calls (we woul...
66,967
<p>What is the best practice to apply an individual script to a particular page? When I try to apply the script of the whole page it has problems with other plug-ins. Is there a rule of thumb?</p> <pre><code> &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"&gt;&lt;/script&gt; &lt;...
[ { "answer_id": 72899, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 2, "selected": false, "text": "<p>In form of a Network Dashboard Widget:</p>\n\n<p><img src=\"https://i.stack.imgur.com/IN7Yc.png\" alt=\"netw...
2012/10/03
[ "https://wordpress.stackexchange.com/questions/66967", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20131/" ]
What is the best practice to apply an individual script to a particular page? When I try to apply the script of the whole page it has problems with other plug-ins. Is there a rule of thumb? ``` <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script> (function() { $('html')...
Made a couple of tweaks to brasofilo's example as we were getting hit with memory execution issues; one of which may be related to a possible [switch\_to\_blog memory leak](http://wordpress.org/support/topic/switch_to_blog-causing-memory-leak) that has been impacting sites doing a lot of `switch_to_blog` calls (we woul...
66,982
<p>I have a custom-post-type for events and use the normal <code>archive.php</code> template to list all previous events.</p> <p>The thing is that I use a custom query for my event-post-type inside <code>archive.php</code> like this …</p> <pre><code>&lt;?php if ( is_post_type_archive('wr_event') ) : ...
[ { "answer_id": 72899, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 2, "selected": false, "text": "<p>In form of a Network Dashboard Widget:</p>\n\n<p><img src=\"https://i.stack.imgur.com/IN7Yc.png\" alt=\"netw...
2012/10/03
[ "https://wordpress.stackexchange.com/questions/66982", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3529/" ]
I have a custom-post-type for events and use the normal `archive.php` template to list all previous events. The thing is that I use a custom query for my event-post-type inside `archive.php` like this … ``` <?php if ( is_post_type_archive('wr_event') ) : get_event_list( false, 'DSC' ); ...
Made a couple of tweaks to brasofilo's example as we were getting hit with memory execution issues; one of which may be related to a possible [switch\_to\_blog memory leak](http://wordpress.org/support/topic/switch_to_blog-causing-memory-leak) that has been impacting sites doing a lot of `switch_to_blog` calls (we woul...
67,001
<p>I would like to make XML files downloadable, instead of allowing the browser to displaying them inline.</p> <p>I know I can use the <code>Content-Disposition: attachment</code> HTTP header (of course, better solutions are welcome!). I want to add this header in all HTTP responses when a user tries to download an XM...
[ { "answer_id": 67004, "author": "Michael Ecklund", "author_id": 9579, "author_profile": "https://wordpress.stackexchange.com/users/9579", "pm_score": 2, "selected": false, "text": "<p>You will need to take a look at <a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference/send_he...
2012/10/03
[ "https://wordpress.stackexchange.com/questions/67001", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20974/" ]
I would like to make XML files downloadable, instead of allowing the browser to displaying them inline. I know I can use the `Content-Disposition: attachment` HTTP header (of course, better solutions are welcome!). I want to add this header in all HTTP responses when a user tries to download an XML file. **I can use ...
Actually, my recommendation would be to do things a bit differently. You can add a custom rewrite endpoint to WordPress to handle these files specifically. For example, the URL `http://site.com/download-xml/the_filename` would automatically download the specified file as an attachment. First, you need to add a custom...
67,002
<p><strong>How can I add a custom field to an array?</strong> To complicate matters, custom field is on the Author's page, not on a regular post. It's added via Advanced Custom Fields. Typically, that field value would be called with <code>&lt;?php the_field(author_status); ?&gt;</code>.</p> <p>Here's the full code I'...
[ { "answer_id": 67007, "author": "dipali", "author_id": 20711, "author_profile": "https://wordpress.stackexchange.com/users/20711", "pm_score": 0, "selected": false, "text": "<pre><code>$args = array(\n 'meta_query' =&gt; array(\n array(\n 'key' =&gt; 'author_status',...
2012/10/03
[ "https://wordpress.stackexchange.com/questions/67002", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18862/" ]
**How can I add a custom field to an array?** To complicate matters, custom field is on the Author's page, not on a regular post. It's added via Advanced Custom Fields. Typically, that field value would be called with `<?php the_field(author_status); ?>`. Here's the full code I'm working with right now. ``` <?php /...
This was added to the area with repeatable content: `<?php the_author_meta( 'author_status', $user->ID ); ?>` Replace author\_status with the name of your AUTHOR CUSTOM FIELD. Solution is from here: <http://codex.wordpress.org/Function_Reference/the_author_meta>
67,025
<p>I would like to create a custom query loop to display data depending on the current post title.</p> <p>Pseudo-code:</p> <pre><code>if post title = custom filed Show related content </code></pre> <p>I have a page called <code>artists</code> made up of custom fields and I would like to show the discography for...
[ { "answer_id": 67007, "author": "dipali", "author_id": 20711, "author_profile": "https://wordpress.stackexchange.com/users/20711", "pm_score": 0, "selected": false, "text": "<pre><code>$args = array(\n 'meta_query' =&gt; array(\n array(\n 'key' =&gt; 'author_status',...
2012/10/03
[ "https://wordpress.stackexchange.com/questions/67025", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21085/" ]
I would like to create a custom query loop to display data depending on the current post title. Pseudo-code: ``` if post title = custom filed Show related content ``` I have a page called `artists` made up of custom fields and I would like to show the discography for that artist. By pulling only the posts with...
This was added to the area with repeatable content: `<?php the_author_meta( 'author_status', $user->ID ); ?>` Replace author\_status with the name of your AUTHOR CUSTOM FIELD. Solution is from here: <http://codex.wordpress.org/Function_Reference/the_author_meta>
67,029
<p>I like to output and style in a shortcode, but the content that is get is the content of a page, so it's style like that</p> <pre><code>&lt;p&gt;2012-12-12&lt;/p&gt; &lt;p&gt;2012-6-23&lt;/p&gt; &lt;p&gt;2012-7-3&lt;/p&gt; </code></pre> <p>i like to be able to have ONLY the value date in a array to be able to outp...
[ { "answer_id": 67031, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 2, "selected": true, "text": "<p>Firstly, you need to remove the paragraph tags that were added by the <code>wp_autop</code> filter. There's another a...
2012/10/03
[ "https://wordpress.stackexchange.com/questions/67029", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3969/" ]
I like to output and style in a shortcode, but the content that is get is the content of a page, so it's style like that ``` <p>2012-12-12</p> <p>2012-6-23</p> <p>2012-7-3</p> ``` i like to be able to have ONLY the value date in a array to be able to output it in a unorder list after how do i do that (strip the p a...
Firstly, you need to remove the paragraph tags that were added by the `wp_autop` filter. There's another answer that covers this pretty well: [Is there an uw-wp\_autop function?](https://wordpress.stackexchange.com/questions/5650/is-there-un-wp-autop-function) I'm going to change the function a little for our purposes...
67,036
<p>I want to grab data from my theme options and have to use them in meta option fields in custom post types. I know how to grab theme option data and show them on front pages but don't know how to grab it for backend usage. I want to use data from one of my theme options text field and put it into my metabox text fiel...
[ { "answer_id": 67061, "author": "ifdion", "author_id": 6383, "author_profile": "https://wordpress.stackexchange.com/users/6383", "pm_score": 0, "selected": false, "text": "<p>Hope this help.</p>\n\n<p>Use WPAlchemy to set up your metaboxes. <a href=\"http://www.farinspace.com/wpalchemy-m...
2012/10/03
[ "https://wordpress.stackexchange.com/questions/67036", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20406/" ]
I want to grab data from my theme options and have to use them in meta option fields in custom post types. I know how to grab theme option data and show them on front pages but don't know how to grab it for backend usage. I want to use data from one of my theme options text field and put it into my metabox text field. ...
You can use the `get_option` function on the back-end too. There are several possibilities on how to pass your option value to your script: 1. Use `wp_localize_script` function to pass PHP values to your script ([see WordPress Codex page for this function](http://codex.wordpress.org/Function_Reference/wp_localize_scri...
67,057
<p>In the user profile in Dashboard I have a section 'Contact info' containing email, URL, aim, yahoo, jabber. I would like to build a widget and output that user info within the widget. What function should I use to get just the contact info of a user?</p>
[ { "answer_id": 67058, "author": "Ben HartLenn", "author_id": 6645, "author_profile": "https://wordpress.stackexchange.com/users/6645", "pm_score": 3, "selected": true, "text": "<p>It sounds like you're after the <a href=\"http://codex.wordpress.org/Function_Reference/get_userdata\" rel=\...
2012/10/03
[ "https://wordpress.stackexchange.com/questions/67057", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5844/" ]
In the user profile in Dashboard I have a section 'Contact info' containing email, URL, aim, yahoo, jabber. I would like to build a widget and output that user info within the widget. What function should I use to get just the contact info of a user?
It sounds like you're after the [get\_userdata()](http://codex.wordpress.org/Function_Reference/get_userdata) function. As a basic example, you could retrieve a users email like this: ``` <?php if ( $user_id ) { $user = get_userdata($user_id); echo 'Users Email is: ' . $user->user_email; } ?> ```
67,065
<p>I have a custom post which has a meta tag that needs to be using a file upload (for video files). I am wondering, what is the correct way of adding an "Upload" button that points to the WordPress media uploader and sets the url of the selected uploaded file to the text field that caused that associates the upload bu...
[ { "answer_id": 67081, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 5, "selected": true, "text": "<p>See this <a href=\"https://github.com/nkdeck07/Wordpress-Plugin--Media-Upload-Skeleton\" rel=\"nofollow noreferrer\...
2012/10/04
[ "https://wordpress.stackexchange.com/questions/67065", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6329/" ]
I have a custom post which has a meta tag that needs to be using a file upload (for video files). I am wondering, what is the correct way of adding an "Upload" button that points to the WordPress media uploader and sets the url of the selected uploaded file to the text field that caused that associates the upload butto...
See this [media uploader skeleton](https://github.com/nkdeck07/Wordpress-Plugin--Media-Upload-Skeleton). You can also use it in your custom markup, like Meta Box. A hint, check, that you only use the scripts on the page, where you active your Meta Box. Otherwise is it often a problem on the default pages and the uploa...
67,105
<p>When I reply to a comment in the WP backend in the "Comments" section (edit-comments.php) I can only post the reply as the logged in user. Is it possible to select a certain user like in the "Add new post" section (post-new.php) where I have a dropdown with all users that are allowed to write posts? </p>
[ { "answer_id": 67121, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 3, "selected": true, "text": "<p>Yes, add an user-select field in the comment form:</p>\n\n<pre><code>add_action('comment_form_after_fields',...
2012/10/04
[ "https://wordpress.stackexchange.com/questions/67105", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21110/" ]
When I reply to a comment in the WP backend in the "Comments" section (edit-comments.php) I can only post the reply as the logged in user. Is it possible to select a certain user like in the "Add new post" section (post-new.php) where I have a dropdown with all users that are allowed to write posts?
Yes, add an user-select field in the comment form: ``` add_action('comment_form_after_fields', function(){ // allow only users who can moderate comments to do this if(!current_user_can('moderate_comments')) return; $user = wp_get_current_user(); wp_dropdown_users(array( 'name' => 'alt_comment_us...
67,107
<p>Clients have been uploading huuuge images, then complaining that the server is running out of memory.</p> <p>Ofcourse one could bump the amount of memory, but this just introduces an arms race.</p> <p>What hooks can I add to impose a maximum image size ( dimensions, not filesize ) on files uploaded, e.g. No you ca...
[ { "answer_id": 67110, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 4, "selected": true, "text": "<p>Basically you just retrieve the info via <a href=\"http://php.net/manual/en/function.getimagesize.php\" rel=\"nofoll...
2012/10/04
[ "https://wordpress.stackexchange.com/questions/67107", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/736/" ]
Clients have been uploading huuuge images, then complaining that the server is running out of memory. Ofcourse one could bump the amount of memory, but this just introduces an arms race. What hooks can I add to impose a maximum image size ( dimensions, not filesize ) on files uploaded, e.g. No you can't upload that 8...
Basically you just retrieve the info via [`getimagesize()`](http://php.net/manual/en/function.getimagesize.php), a basic PHP function, a then handle your errors with notes. The plugin ---------- A basic plugin as a starting point: ``` <?php /** Plugin Name: (#67107) »kaiser« Restrict file upload via image dimensions...
67,113
<p>I'm getting a well known error from the question title. The problem is, website is running on a shared server and I don't have access to php.ini file. </p> <p>I've set `php_value memory_limit' inside .htaccess to higher value.</p> <p>I've set <code>WP_MEMORY_LIMIT</code> inside wp_config.php to higher value.</p> ...
[ { "answer_id": 67116, "author": "Damien", "author_id": 17132, "author_profile": "https://wordpress.stackexchange.com/users/17132", "pm_score": 1, "selected": false, "text": "<p>If you create a 'php.ini' and it makes no difference, then it is very likely that changing wp_config or changin...
2012/10/04
[ "https://wordpress.stackexchange.com/questions/67113", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15476/" ]
I'm getting a well known error from the question title. The problem is, website is running on a shared server and I don't have access to php.ini file. I've set `php\_value memory\_limit' inside .htaccess to higher value. I've set `WP_MEMORY_LIMIT` inside wp\_config.php to higher value. `phpinfo()` says that `max_ex...
You can simply create a text file and call it php.ini . Make sure the file has the text encoding "Unicode no BOM", as that will work best for both linux and windows. Use an FTP client to make a new file on the server and that will generate a file with the correct permissions and text encoding. Put just this line in it...
67,123
<p>I create product custom posts from an external data suscription, populating some custom fields and displaying product specifications automatically.</p> <p>As there are a lot of these products, the manual review of each one is made after the custom post have been already published. And it is at that moment when I wa...
[ { "answer_id": 67170, "author": "dzogchen", "author_id": 3717, "author_profile": "https://wordpress.stackexchange.com/users/3717", "pm_score": 0, "selected": false, "text": "<p>So there are two feeds - an external one that you use to create new custom posts, and then one you create with ...
2012/10/04
[ "https://wordpress.stackexchange.com/questions/67123", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3712/" ]
I create product custom posts from an external data suscription, populating some custom fields and displaying product specifications automatically. As there are a lot of these products, the manual review of each one is made after the custom post have been already published. And it is at that moment when I want my read...
There's a filter for that. I use: ``` function ts_feed_spruce_get_the_guid($content) { // double ? is ok as guid is not a url // '&' gets esc_url'ed and doesn't work anyway $content .= '?d=' . get_the_modified_time('YmdHisT'); return $content; } add_filter('get_the_guid', 'ts_feed_spruce_get_the_guid', 7); `...
67,127
<p>How do I turn off the WP Super Cache &amp; W3 Total Cache functionality programmatically? For instance, I neither want to make it use the cache on some requests nor cache the output of the request, do they support that using filters? I couldn't find anything useful in their documentation.</p>
[ { "answer_id": 67131, "author": "Damien", "author_id": 17132, "author_profile": "https://wordpress.stackexchange.com/users/17132", "pm_score": 1, "selected": false, "text": "<p>Both plugins you mention have settings pages that allow you to add directories or specific files to not cache. ...
2012/10/04
[ "https://wordpress.stackexchange.com/questions/67127", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1521/" ]
How do I turn off the WP Super Cache & W3 Total Cache functionality programmatically? For instance, I neither want to make it use the cache on some requests nor cache the output of the request, do they support that using filters? I couldn't find anything useful in their documentation.
Easiest way to do this was to define a constant programmatically: ``` // Tell WP Super Cache & W3 Total Cache to not cache WPReadable requests define( 'DONOTCACHEPAGE', true ); ```
67,141
<p>Ok, my question is a bit complex so I will try and give a general explanation and then go into details afterward.</p> <p>I am running WordPress 3.4.2 and I am using WCK Post Type Creator and WCK Custom Fields Creator to create my custom post type and custom fields.</p> <p>I am trying to query posts from the custom...
[ { "answer_id": 67144, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 5, "selected": true, "text": "<p>Normally you would just specify a meta_value, e.g.:</p>\n\n<pre><code> $args = array(\n 'post_type' =&gt; ...
2012/10/04
[ "https://wordpress.stackexchange.com/questions/67141", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21123/" ]
Ok, my question is a bit complex so I will try and give a general explanation and then go into details afterward. I am running WordPress 3.4.2 and I am using WCK Post Type Creator and WCK Custom Fields Creator to create my custom post type and custom fields. I am trying to query posts from the custom post type 'busin...
Normally you would just specify a meta\_value, e.g.: ``` $args = array( 'post_type' => 'business', 'meta_query' => array( array( 'key' => 'specials', 'value' => 'these are not the specials you are looking for - Obi Wan Kenobi' ) ) ); ``` Ho...
67,154
<h1>Question</h1> <ul> <li>what hook can be used to add a custom button to the 'Publish' metabox on the 'Edit Post' admin page?</li> </ul> <h1>Use case</h1> <p>I have a hand-rolled custom post type called <code>ash_newsletter</code>. I want to add a button to the <code>post.php?post={$post-&gt;ID}&amp;action=edit</code...
[ { "answer_id": 67163, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 4, "selected": false, "text": "<p>This will get you started;</p>\n\n<pre><code>add_action( 'post_submitbox_misc_actions', 'custom_button' );\n\nfun...
2012/10/04
[ "https://wordpress.stackexchange.com/questions/67154", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3644/" ]
Question ======== * what hook can be used to add a custom button to the 'Publish' metabox on the 'Edit Post' admin page? Use case ======== I have a hand-rolled custom post type called `ash_newsletter`. I want to add a button to the `post.php?post={$post->ID}&action=edit` admin page for this post type. The button wil...
This will get you started; ``` add_action( 'post_submitbox_misc_actions', 'custom_button' ); function custom_button(){ $html = '<div id="major-publishing-actions" style="overflow:hidden">'; $html .= '<div id="publishing-action">'; $html .= '<input type="submit" accesskey="p" tabindex="5" valu...
67,157
<p>I reviewed all related questions but none tackle this exactly so I'm posting the question in hopes the pro's know how to handle this. I would like to change the author slug to remove the term /author/ completely like this;</p> <p>currently <code>example.com/author/username</code></p> <p>want <code>example.com/user...
[ { "answer_id": 67182, "author": "OS.", "author_id": 18690, "author_profile": "https://wordpress.stackexchange.com/users/18690", "pm_score": -1, "selected": false, "text": "<p>One way to achieve this (and you have to be willing and able to hack WP) is the following:</p>\n\n<p>Part 1 - aft...
2012/10/04
[ "https://wordpress.stackexchange.com/questions/67157", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21127/" ]
I reviewed all related questions but none tackle this exactly so I'm posting the question in hopes the pro's know how to handle this. I would like to change the author slug to remove the term /author/ completely like this; currently `example.com/author/username` want `example.com/username` Moreover I'd like all post...
Just an *idea*: Use a MU installation and give the blog names the names of the authors (use Sub-directories). This way you should get much closer to what you want to achieve with on board stuff. This means that you'll get your author names appended to the original domain and when you go there, you'll see their blog pa...
67,159
<p>USER01 is not showing in Author drop down list while editing a Page if he's in the my custom ROLE "mycustomrole".</p> <p>If I change his role as an AUTHOR, and add the very same custom and non custom capacities, he's shown in the list.</p> <p>I created this role programatically, as shown below.</p> <p>Is there so...
[ { "answer_id": 67173, "author": "dzogchen", "author_id": 3717, "author_profile": "https://wordpress.stackexchange.com/users/3717", "pm_score": 0, "selected": false, "text": "<p>Not sure, but could the issues have to do with spelling \"plural\" as \"plurial\"?? I know that you are using ...
2012/10/04
[ "https://wordpress.stackexchange.com/questions/67159", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5437/" ]
USER01 is not showing in Author drop down list while editing a Page if he's in the my custom ROLE "mycustomrole". If I change his role as an AUTHOR, and add the very same custom and non custom capacities, he's shown in the list. I created this role programatically, as shown below. Is there something particular to ad...
the answer is provided here: [Users with custom roles not showing in post author select box](https://wordpress.stackexchange.com/questions/91862/users-with-custom-roles-not-showing-in-post-author-select-box) I tested and it works: ``` to add a level_1 cap to your role. It's PITA, considering how user levels have bee...
67,225
<p>I'm using Wordpress 3.4.2 for a private blog, i.e. one on which only I can post. Now, Wordpress prevents me from uploading certain file types (like C# source files). As far as I understand it, there's a white-list that defines what can be uploaded. </p> <p>Is there a plugin that can extend - or better, even disable...
[ { "answer_id": 67227, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>Filter <code>'user_has_cap'</code> and set <code>'unfiltered_upload'</code> to 1.</p>\n\n<p>Sample code <em>not tested...
2012/10/05
[ "https://wordpress.stackexchange.com/questions/67225", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21145/" ]
I'm using Wordpress 3.4.2 for a private blog, i.e. one on which only I can post. Now, Wordpress prevents me from uploading certain file types (like C# source files). As far as I understand it, there's a white-list that defines what can be uploaded. Is there a plugin that can extend - or better, even disable - this wh...
Unfortunately, toscho's answer doesn't work - at least not in Wordpress 3.4 and above. The correct solution is the following: ``` # # For this, see: wp-includes/capabilities.php > map_meta_cap() # function wpse_6533_map_unrestricted_upload_filter($caps, $cap) { if ($cap == 'unfiltered_upload') { $caps = array()...
67,237
<p>I'm currently using <code>get_field</code> with Advanced Custom Fields plugin (<a href="http://www.advancedcustomfields.com/docs/functions/get_field/" rel="nofollow">see here</a>) to get a single image for search results. The end result is that these pages are loading slow, as I believe this is due to MySQL returni...
[ { "answer_id": 67246, "author": "dipali", "author_id": 20711, "author_profile": "https://wordpress.stackexchange.com/users/20711", "pm_score": 0, "selected": false, "text": "<p>In advanced custom value if you adding field choose field type \"image\" &amp; choose return value \"Image URL...
2012/10/05
[ "https://wordpress.stackexchange.com/questions/67237", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13882/" ]
I'm currently using `get_field` with Advanced Custom Fields plugin ([see here](http://www.advancedcustomfields.com/docs/functions/get_field/)) to get a single image for search results. The end result is that these pages are loading slow, as I believe this is due to MySQL returning the whole array of all images in the g...
I have managed to work it out - the function was leading to a lot of queries, so I rewrote it as follows: ``` $housePhotos = get_post_custom_values('house_photos'); $housePhotos = explode(';',$housePhotos[0]); preg_match_all('`"([^"]*)"`', $housePhotos[1], $results); $imageURL = wp_get_attachment_im...
67,247
<p>I'm using plugin Woocommerce to do shop online.</p> <p>I have many categories for example <code>shoes</code>, <code>clothes</code> and so on. How can I display the products of specific category?</p> <p>I see such product loops of on the <a href="http://wcdocs.woothemes.com/snippets/sample-products-loop/" rel="nore...
[ { "answer_id": 67266, "author": "dwaser", "author_id": 8199, "author_profile": "https://wordpress.stackexchange.com/users/8199", "pm_score": 6, "selected": true, "text": "<p>You need to create a new loop for that. Here's the code I use for displaying products from a specific category on ...
2012/10/05
[ "https://wordpress.stackexchange.com/questions/67247", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21149/" ]
I'm using plugin Woocommerce to do shop online. I have many categories for example `shoes`, `clothes` and so on. How can I display the products of specific category? I see such product loops of on the [sample page](http://wcdocs.woothemes.com/snippets/sample-products-loop/), but I only want show the products of a spe...
You need to create a new loop for that. Here's the code I use for displaying products from a specific category on the home page: ``` <ul class="products"> <?php $args = array( 'post_type' => 'product', 'posts_per_page' => 1, 'product_cat' => 'shoes', 'orderby' => 'rand' ); $loop = new WP_Query( $ar...
67,261
<p>I'm using this piece of code to list users and their information. The problem I'm having is that the description isn't showing. Obviously it's because the description lays under "user_meta" and not "users". But how would I solve that?</p> <pre><code>&lt;?php $blogusers = get_users('include=2,3,4,5,6,7,8'); ...
[ { "answer_id": 67265, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 4, "selected": true, "text": "<p>The Native <a href=\"http://codex.wordpress.org/Function_Reference/get_users\" rel=\"noreferrer\">get_user...
2012/10/05
[ "https://wordpress.stackexchange.com/questions/67261", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21153/" ]
I'm using this piece of code to list users and their information. The problem I'm having is that the description isn't showing. Obviously it's because the description lays under "user\_meta" and not "users". But how would I solve that? ``` <?php $blogusers = get_users('include=2,3,4,5,6,7,8'); foreach ($blogus...
The Native [get\_users()](http://codex.wordpress.org/Function_Reference/get_users) function returns an array of user objects and each on holds ``` [ID] => 1 [user_login] => admin [user_pass] => $P$Bxudi6gJMk2GRt2ed3xvZ06c1BPZXi/ [user_nicename] => admin [user_email] => admin@host.com [user_url] => ht...
67,264
<p>I have Googled for a while and I am not sure how is the best way to do this.</p> <p>In <code>wp-includes/general-template.php</code> I am looking at the function <code>wp_get_archives()</code> which has this line of code in:</p> <p><code>$where = apply_filters( 'getarchives_where', "WHERE post_type = 'post' AND po...
[ { "answer_id": 67268, "author": "Jared Cobb", "author_id": 6737, "author_profile": "https://wordpress.stackexchange.com/users/6737", "pm_score": 1, "selected": false, "text": "<p>What you'll actually want to do is use the built-in WordPress class called <code>WP_Query</code>. This way y...
2012/10/05
[ "https://wordpress.stackexchange.com/questions/67264", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18531/" ]
I have Googled for a while and I am not sure how is the best way to do this. In `wp-includes/general-template.php` I am looking at the function `wp_get_archives()` which has this line of code in: `$where = apply_filters( 'getarchives_where', "WHERE post_type = 'post' AND post_status = 'publish'", $r );` What I want ...
A WordPress filter is a function that takes in a string, array, or object, does something to it, and returns that *filtered* string, array, or object. So what you want to do is turn `"WHERE post_type = 'post' AND post_status = 'publish'"` into `"WHERE post_type = 'post' OR post_type = 'events' AND post_status = 'publi...
67,304
<p>I've searched google quite a bit and every site has the same filter but it doesn't seem to be working for me. Not sure if it's my setup or just old code.</p> <p>I'm trying this:</p> <pre><code>add_filter( 'avatar_defaults', 'newgravatar' ); function newgravatar ($avatar_defaults) { $myavatar = get_bloginfo(...
[ { "answer_id": 67310, "author": "westondeboer", "author_id": 2691, "author_profile": "https://wordpress.stackexchange.com/users/2691", "pm_score": 0, "selected": false, "text": "<p>It is giving you that error because the image doesn't exist. I would try changing it to:</p>\n\n<pre><code>...
2012/10/05
[ "https://wordpress.stackexchange.com/questions/67304", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19413/" ]
I've searched google quite a bit and every site has the same filter but it doesn't seem to be working for me. Not sure if it's my setup or just old code. I'm trying this: ``` add_filter( 'avatar_defaults', 'newgravatar' ); function newgravatar ($avatar_defaults) { $myavatar = get_bloginfo('template_directory')...
I figured this out. The server I am working on doesn't have access to the outside. So, even though the image is in my template folder, the gravatar.com call in front of the image path was causing the error.
67,316
<p>I want to add a custom font into my theme. Please let me know if this is just as simple as uploading the font to a new folder named "fonts" and then changing the css and renaming the font-family property there or it's somewhat different procedure. I am not sure about it. Please help me.</p>
[ { "answer_id": 67324, "author": "Raam Dev", "author_id": 16453, "author_profile": "https://wordpress.stackexchange.com/users/16453", "pm_score": 3, "selected": true, "text": "<p>To use a custom font, simply upload the font to your theme folder and then add a CSS <code>@font-face</code> d...
2012/10/06
[ "https://wordpress.stackexchange.com/questions/67316", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20406/" ]
I want to add a custom font into my theme. Please let me know if this is just as simple as uploading the font to a new folder named "fonts" and then changing the css and renaming the font-family property there or it's somewhat different procedure. I am not sure about it. Please help me.
To use a custom font, simply upload the font to your theme folder and then add a CSS `@font-face` declaration to the top of your theme's `style.css` file pointing to the new font: ``` @font-face { font-family: CustomFont; src: url('CustomFont.ttf'); } ``` You can then reference that custom font in other CSS styles, ...
67,317
<p>I am using twenty eleven for my theme and I create a PHP page under it named results.php in the results.php here's my code:</p> <pre><code>&lt;?php get_header(); ?&gt; &lt;?php get_footer(); ?&gt; </code></pre> <p>From my index.php:</p> <pre><code>get_header(); ?&gt; &lt;a href="wp-content/themes/twentyeleven/res...
[ { "answer_id": 67319, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": -1, "selected": false, "text": "<p>There is no opening <code>&lt;?php</code> tag in your second (index.php) block of code.</p>\n<p>It should look l...
2012/10/06
[ "https://wordpress.stackexchange.com/questions/67317", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21173/" ]
I am using twenty eleven for my theme and I create a PHP page under it named results.php in the results.php here's my code: ``` <?php get_header(); ?> <?php get_footer(); ?> ``` From my index.php: ``` get_header(); ?> <a href="wp-content/themes/twentyeleven/result.php">Main</a> <?php get_footer(); ?> ```
You get `undefined function` because you are pointing to the result.php directly. That way WordPress just doesn't load. If you need to include result.php in a specific place use [get\_template\_part](http://codex.wordpress.org/Function_Reference/get_template_part) or even better [locate\_template](http://codex.wordpr...
67,325
<p>I want to add php code within jquery. I know that the file then cannot be saved as a js file but must be saved as a php file to execute the php code. If we save it as a php file then it can also not be enqueued within function.php. </p> <pre><code>jQuery(document).ready(function() { jQuery('#a, #b').change(function...
[ { "answer_id": 67326, "author": "2hamed", "author_id": 7410, "author_profile": "https://wordpress.stackexchange.com/users/7410", "pm_score": -1, "selected": false, "text": "<p>You can easily save your file as PHP file and enqueue it with <code>wp_enqueue_script</code> function without an...
2012/10/06
[ "https://wordpress.stackexchange.com/questions/67325", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20406/" ]
I want to add php code within jquery. I know that the file then cannot be saved as a js file but must be saved as a php file to execute the php code. If we save it as a php file then it can also not be enqueued within function.php. ``` jQuery(document).ready(function() { jQuery('#a, #b').change(function () { var ...
I see no reason for you to use PHP in your JavaScript file. Enqueue your script properly using the [`wp_enqueue_scripts`](http://codex.wordpress.org/Plugin_API/Action_Reference/wp_enqueue_scripts) hook and then use the [`wp_localize_script()`](http://codex.wordpress.org/Function_Reference/wp_localize_script)function to...
67,328
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://wordpress.stackexchange.com/questions/29338/how-to-show-login-error-and-lost-password-on-my-template-page">How to show &#39;login error&#39; and &#39;lost password&#39; on my template page?</a> </p> </blockquote> <p>I've created a custom ...
[ { "answer_id": 67343, "author": "ndm", "author_id": 20949, "author_profile": "https://wordpress.stackexchange.com/users/20949", "pm_score": 0, "selected": false, "text": "<p>Assuming you are using <code>wp_signon</code>, simply check if the returned object is a <code>WP_Error</code> inst...
2012/10/06
[ "https://wordpress.stackexchange.com/questions/67328", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21175/" ]
> > **Possible Duplicate:** > > [How to show 'login error' and 'lost password' on my template page?](https://wordpress.stackexchange.com/questions/29338/how-to-show-login-error-and-lost-password-on-my-template-page) > > > I've created a custom login form in a template page using the basic wp\_login\_form. I'm ...
I'm using this kind of code which seems to work (with wp\_signon). ``` <?php /* Template Name: Connexion */ global $user_ID; if (!$user_ID) { if($_POST){ $username = $wpdb->escape($_REQUEST['username']); $password = $wpdb->escape($_REQUEST['password']); $remember = $wpdb->escape($_REQUES...
67,329
<p>I think the question is straight forward. I want to have archive page, but want the single pages gone. Is there a way with custom post type options?</p>
[ { "answer_id": 67330, "author": "Miha Rekar", "author_id": 20791, "author_profile": "https://wordpress.stackexchange.com/users/20791", "pm_score": 0, "selected": false, "text": "<p>The way I solve issues like that is that I just don't link to the single pages. So if there is no link, to ...
2012/10/06
[ "https://wordpress.stackexchange.com/questions/67329", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19101/" ]
I think the question is straight forward. I want to have archive page, but want the single pages gone. Is there a way with custom post type options?
You can force single queries to 404 like they don't exist. ``` function wpse67329_force_mycpt_single_404() { if ( is_single() && get_post_type() == 'mycpt' ) { global $wp_query; $wp_query->set_404(); status_header('404'); } } add_action( 'template_redirect', 'wpse67329_force_mycpt_single_404' ); ```
67,332
<p>I installed WP in subfolder <code>/cms</code> and it runs live without subfolder. When I use <code>/%postname%/</code> as permalink I get 404 error on my site. My Server supported <code>mod_rewrite</code>.</p> <h1>My Code</h1> <p><em>wp-config.php</em></p> <pre><code>define('WP_SITEURL', 'http://www.sitename.de/c...
[ { "answer_id": 67352, "author": "Rob Bennet", "author_id": 2026, "author_profile": "https://wordpress.stackexchange.com/users/2026", "pm_score": 0, "selected": false, "text": "<p>Get rid of the .htaccess file under /cms and then visit Settings -> Permalinks to flush your rewrite rules. ...
2012/10/06
[ "https://wordpress.stackexchange.com/questions/67332", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12521/" ]
I installed WP in subfolder `/cms` and it runs live without subfolder. When I use `/%postname%/` as permalink I get 404 error on my site. My Server supported `mod_rewrite`. My Code ======= *wp-config.php* ``` define('WP_SITEURL', 'http://www.sitename.de/cms'); define('WP_HOME', 'http://www.sitename.de'); ``` ### r...
What I generally do * Install WP in sub directory. * Open permalink set required permalink. * Open settings->general link * Remove the sub directory name from 'Site Address (URL)' * Cut the index.php and .htaccess files from sub directory and paste them to root * change code in index.php as you did. * Again access set...
67,336
<p>Right now when I log out via:</p> <pre><code>&lt;a href="&lt;?php bloginfo('url'); ?&gt;/wp-login.php?action=logout"&gt;Log out&lt;/a&gt; </code></pre> <p>it redirects me to the page where I need to confirm the log out.</p> <p>How to eliminate the confirmation and redirect to the homepage after logout?</p>
[ { "answer_id": 67342, "author": "ndm", "author_id": 20949, "author_profile": "https://wordpress.stackexchange.com/users/20949", "pm_score": 7, "selected": true, "text": "<p>This happens because you are missing the neccessary nonce in the URL, which is being checked in <code>wp-login.php<...
2012/10/06
[ "https://wordpress.stackexchange.com/questions/67336", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17368/" ]
Right now when I log out via: ``` <a href="<?php bloginfo('url'); ?>/wp-login.php?action=logout">Log out</a> ``` it redirects me to the page where I need to confirm the log out. How to eliminate the confirmation and redirect to the homepage after logout?
This happens because you are missing the neccessary nonce in the URL, which is being checked in `wp-login.php` ``` case 'logout' : check_admin_referer('log-out'); ... ``` Use `wp_logout_url` in order to retreive the URL including the nonce. If you want to redirect to a custom URL, simply pass it as an argume...
67,345
<p>I develop a WordPress plugin, which has several database tables of its own. The plugin creates these tables when activated, and removes them when deleted/uninstalled.</p> <p>I have to implement an update process of the plugin which updates plugin's code as well as tables structure. The simplest case would be to ad...
[ { "answer_id": 67350, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 3, "selected": false, "text": "<p>In short, yes the - <a href=\"https://github.com/WordPress/WordPress/blob/3.4.2/wp-includes/wp-db.php#L1\...
2012/10/06
[ "https://wordpress.stackexchange.com/questions/67345", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19075/" ]
I develop a WordPress plugin, which has several database tables of its own. The plugin creates these tables when activated, and removes them when deleted/uninstalled. I have to implement an update process of the plugin which updates plugin's code as well as tables structure. The simplest case would be to add a new col...
In short, yes the - [`$wpdb`](https://github.com/WordPress/WordPress/blob/3.4.2/wp-includes/wp-db.php#L1) class. [See Codex](http://codex.wordpress.org/Class_Reference/wpdb) for more information. Whenever you interact with a custom table (or any table, really) you should go through `$wpdb` - in particularly make sure...
67,349
<p>I have one loop for big images, and I need the same loop with small images (thumbnails). This is where I am stuck.</p> <p><strong>Use case:</strong> I am trying to implement the elastic image slideshow jQuery plugin with WordPress following <a href="http://tympanus.net/codrops/2011/11/21/elastic-image-slideshow-wit...
[ { "answer_id": 67350, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 3, "selected": false, "text": "<p>In short, yes the - <a href=\"https://github.com/WordPress/WordPress/blob/3.4.2/wp-includes/wp-db.php#L1\...
2012/10/06
[ "https://wordpress.stackexchange.com/questions/67349", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16109/" ]
I have one loop for big images, and I need the same loop with small images (thumbnails). This is where I am stuck. **Use case:** I am trying to implement the elastic image slideshow jQuery plugin with WordPress following [this tutorial](http://tympanus.net/codrops/2011/11/21/elastic-image-slideshow-with-thumbnail-prev...
In short, yes the - [`$wpdb`](https://github.com/WordPress/WordPress/blob/3.4.2/wp-includes/wp-db.php#L1) class. [See Codex](http://codex.wordpress.org/Class_Reference/wpdb) for more information. Whenever you interact with a custom table (or any table, really) you should go through `$wpdb` - in particularly make sure...
67,357
<pre><code>&lt;?php $blogusers = get_users('include=5,6,2,7,12,8'); foreach ($blogusers as $user) { ... } ?&gt; </code></pre> <p>Right now, these users will sorted by first name. </p> <p>How do I sort this in the order the numbers are in <code>include=...</code>? </p> <p>Example:</p> <p>User 5 first, user ...
[ { "answer_id": 67374, "author": "Sy Holloway", "author_id": 21187, "author_profile": "https://wordpress.stackexchange.com/users/21187", "pm_score": 0, "selected": false, "text": "<p>Wordpress returns an array of objects.<br>\nHave you tried using 'orderby' as an extra paramiter? eg<br></...
2012/10/06
[ "https://wordpress.stackexchange.com/questions/67357", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21153/" ]
``` <?php $blogusers = get_users('include=5,6,2,7,12,8'); foreach ($blogusers as $user) { ... } ?> ``` Right now, these users will sorted by first name. How do I sort this in the order the numbers are in `include=...`? Example: User 5 first, user 6 second, user 2 third etc.
There is a simpler, faster method than the one by @Warface. This is an extention to @SyHolloway The concept here is to wrap [`get_users()`](http://codex.wordpress.org/Function_Reference/get_users) in a new function in which you can sort the result from `get_users()` by the `include` parameter using `usort` and then re...
67,372
<p>I'm trying to get page content when I only know the slug string.</p> <p>Is there a function for this, or an easy way to do this or is this a case of doing it via SQL?</p> <p>Thanks very much</p>
[ { "answer_id": 67373, "author": "Johannes Pille", "author_id": 9745, "author_profile": "https://wordpress.stackexchange.com/users/9745", "pm_score": 3, "selected": false, "text": "<h2>If on the page with the slug in question</h2>\n\n<p>Read up on <a href=\"http://codex.wordpress.org/Cond...
2012/10/06
[ "https://wordpress.stackexchange.com/questions/67372", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14485/" ]
I'm trying to get page content when I only know the slug string. Is there a function for this, or an easy way to do this or is this a case of doing it via SQL? Thanks very much
Use [`get_posts()`](http://codex.wordpress.org/Template_Tags/get_posts) and the parameter `name` which is the slug: ``` $page = get_posts([ 'name' => 'your-slug' ]); if ( $page ) { echo $page[0]->post_content; } ``` Be aware that the post type in `get_posts()` defaults to `'post'`. If you want a **page** use … ...
67,378
<p>I'm using the plugin <a href="http://wordpress.org/extend/plugins/post-from-site/" rel="nofollow">Post from site</a>, which sets up a WP front end writer. I changed some line of code because I need to select categories with checkboxes and not with a multiple select (as it was originally in the plugin). Unfortunately...
[ { "answer_id": 67437, "author": "Dale Sattler", "author_id": 12344, "author_profile": "https://wordpress.stackexchange.com/users/12344", "pm_score": 0, "selected": false, "text": "<p>I usually use <a href=\"http://codex.wordpress.org/Function_Reference/wp_set_post_terms\" rel=\"nofollow\...
2012/10/06
[ "https://wordpress.stackexchange.com/questions/67378", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21193/" ]
I'm using the plugin [Post from site](http://wordpress.org/extend/plugins/post-from-site/), which sets up a WP front end writer. I changed some line of code because I need to select categories with checkboxes and not with a multiple select (as it was originally in the plugin). Unfortunately it doesn't work: there is a ...
You changed the checkbox's name attribute value. You should use the same name value: terms[$taxonomy][] This should fix the code: ``` if (is_taxonomy_hierarchical($taxonomy)) //$out .= "<input class='{$term->term_taxonomy_id}' type='checkbox' value='{$term->term_taxonomy_id}' name='{$term->term_taxonomy_id}'...
67,387
<p>How to display posts with 'Event' custom type ordered by 'Start_Hour' and then by 'Start_Minute'?</p> <p>'Start_Hour' and 'Start_Minute' are numeric custom fields.</p> <p>I tried this, but it doesn't work:</p> <pre><code>$args = array( 'post_type'=&gt;'Events', 'orderby' =&gt; 'meta_value', 'meta_key' =&gt;...
[ { "answer_id": 67391, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": false, "text": "<p>when you use <code>'meta_key' =&gt; 'Start_Hour Start_Minute'</code> then the query looks for posts with a c...
2012/10/06
[ "https://wordpress.stackexchange.com/questions/67387", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21195/" ]
How to display posts with 'Event' custom type ordered by 'Start\_Hour' and then by 'Start\_Minute'? 'Start\_Hour' and 'Start\_Minute' are numeric custom fields. I tried this, but it doesn't work: ``` $args = array( 'post_type'=>'Events', 'orderby' => 'meta_value', 'meta_key' => 'Start_Hour Start_Minute', 'or...
Thanks to [Bainternet](https://wordpress.stackexchange.com/users/2487/bainternet) I found the solution: ``` function orderbyreplace($orderby) { return str_replace('menu_order', 'mt1.meta_value, mt2.meta_value', $orderby); } ``` and... ``` $args = array( 'post_type'=>'Events', 'orderby' => 'menu_order', 'o...
67,403
<p>I have a Wordpress 3.4.1 installed on a local WAMP server.</p> <p>I am in the process of upgrading it to a network, but I now realise my admin account has no admin privileges:</p> <ol> <li>No access to the Updates page (update-core.php) - I receive "You do not have sufficient permissions to access this page."</li>...
[ { "answer_id": 67391, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": false, "text": "<p>when you use <code>'meta_key' =&gt; 'Start_Hour Start_Minute'</code> then the query looks for posts with a c...
2012/10/07
[ "https://wordpress.stackexchange.com/questions/67403", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3206/" ]
I have a Wordpress 3.4.1 installed on a local WAMP server. I am in the process of upgrading it to a network, but I now realise my admin account has no admin privileges: 1. No access to the Updates page (update-core.php) - I receive "You do not have sufficient permissions to access this page." 2. No ability to install...
Thanks to [Bainternet](https://wordpress.stackexchange.com/users/2487/bainternet) I found the solution: ``` function orderbyreplace($orderby) { return str_replace('menu_order', 'mt1.meta_value, mt2.meta_value', $orderby); } ``` and... ``` $args = array( 'post_type'=>'Events', 'orderby' => 'menu_order', 'o...
67,408
<p>How do I discover the custom post type slug when I'm on an archive page?</p> <p>For instance if <code>/products/</code> fires the <code>archive-products.php</code> template, how (pragmatically) do I get the post type slug?</p> <p>Thanks</p>
[ { "answer_id": 67412, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 5, "selected": false, "text": "<p>To get the current post type use <code>get_post_type()</code>. Then ask <code>get_post_type_object()</code> for all th...
2012/10/07
[ "https://wordpress.stackexchange.com/questions/67408", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29/" ]
How do I discover the custom post type slug when I'm on an archive page? For instance if `/products/` fires the `archive-products.php` template, how (pragmatically) do I get the post type slug? Thanks
To get the current post type use `get_post_type()`. Then ask `get_post_type_object()` for all the data you need, for example the slug: ``` $post_type = get_post_type(); if ( $post_type ) { $post_type_data = get_post_type_object( $post_type ); $post_type_slug = $post_type_data->rewrite['slug']; echo $post_t...
67,413
<p>I'm testing for a certain fixed post on an about page, I guessed that the best way is to test for post title (?). </p> <p>Here's my code, what's going wrong?</p> <pre><code>&lt;?php if (is_page()) { $cat=get_cat_ID($post-&gt;post_title); $posts = get_posts ("cat=$cat&amp;showposts=35"); if ($posts) { fo...
[ { "answer_id": 67435, "author": "Miha Rekar", "author_id": 20791, "author_profile": "https://wordpress.stackexchange.com/users/20791", "pm_score": 0, "selected": false, "text": "<p>The best way would be to search for ID, not title! So then your if would be:</p>\n\n<pre><code>if ($post-&g...
2012/10/07
[ "https://wordpress.stackexchange.com/questions/67413", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12455/" ]
I'm testing for a certain fixed post on an about page, I guessed that the best way is to test for post title (?). Here's my code, what's going wrong? ``` <?php if (is_page()) { $cat=get_cat_ID($post->post_title); $posts = get_posts ("cat=$cat&showposts=35"); if ($posts) { foreach ($posts as $post): ...
First off all, `$post` is one of the WordPress core [global variables](http://codex.wordpress.org/Global_Variables) and as such should either not be touched or [reset](http://codex.wordpress.org/Function_Reference/wp_reset_postdata) after your `foreach` loop. Using [`setup_postdata()`](http://codex.wordpress.org/Funct...
67,424
<p>How do I add a favicon that only shows during viewing of my plugin's admin panel? I mean, what event do I intercept?</p>
[ { "answer_id": 67425, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 3, "selected": true, "text": "<p>When you add your admin (sub)page, then you're (hopfully) using <code>add_*menu_page()</code>. You can simply save i...
2012/10/07
[ "https://wordpress.stackexchange.com/questions/67424", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13/" ]
How do I add a favicon that only shows during viewing of my plugin's admin panel? I mean, what event do I intercept?
When you add your admin (sub)page, then you're (hopfully) using `add_*menu_page()`. You can simply save its result in a var. This var is the `$hook_suffix`. Then you can simply add your callback (that adds the favicon) to [the `admin_head-{$suffix}` hook Source Link](https://github.com/WordPress/WordPress/blob/master...
67,428
<p>I noticed while looking at the HTML of an edit page that WordPress uses a lot of hidden input elements for storing nonces. Is there a significant advantage to using either this style of storing nonces for AJAX use or using those stored via the <code>wp_localize_script</code> style?</p>
[ { "answer_id": 67425, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 3, "selected": true, "text": "<p>When you add your admin (sub)page, then you're (hopfully) using <code>add_*menu_page()</code>. You can simply save i...
2012/10/07
[ "https://wordpress.stackexchange.com/questions/67428", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2234/" ]
I noticed while looking at the HTML of an edit page that WordPress uses a lot of hidden input elements for storing nonces. Is there a significant advantage to using either this style of storing nonces for AJAX use or using those stored via the `wp_localize_script` style?
When you add your admin (sub)page, then you're (hopfully) using `add_*menu_page()`. You can simply save its result in a var. This var is the `$hook_suffix`. Then you can simply add your callback (that adds the favicon) to [the `admin_head-{$suffix}` hook Source Link](https://github.com/WordPress/WordPress/blob/master...
67,438
<p>I've been reading documents, viewing videos, etc. on how to create a Wordpress plugin. I've learned how to filter a post, add txt to a post, use conditionals to see if the page is a single post as not to display text throughout the entire site, etc.</p> <p>The part that I'm not understanding is how to create a plug...
[ { "answer_id": 67452, "author": "Abdussamad", "author_id": 12839, "author_profile": "https://wordpress.stackexchange.com/users/12839", "pm_score": 2, "selected": false, "text": "<p>If you want a frontend page you'll have to create one with your plugin's shortcode as the content. Then you...
2012/10/07
[ "https://wordpress.stackexchange.com/questions/67438", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21190/" ]
I've been reading documents, viewing videos, etc. on how to create a Wordpress plugin. I've learned how to filter a post, add txt to a post, use conditionals to see if the page is a single post as not to display text throughout the entire site, etc. The part that I'm not understanding is how to create a plugin, with i...
If you want a frontend page you'll have to create one with your plugin's shortcode as the content. Then you display your plugin's output in-place of that shortcode: ``` /* Plugin Name: WPSE67438 Page plugin */ class wpse67438_plugin { const PAGE_TITLE = 'WPSE67438'; //set the page title here. const SHORTCODE =...
67,451
<p>I'm using this bit to insert/update a custom post type from the front-end. The date is set from a custom jquery datepicker.</p> <pre><code> if (strtotime($date) &lt; strtotime('tomorrow')) { $newpostdata['post_status'] = 'publish'; } elseif (strtotime($date) &gt; strtotime('today')) { ...
[ { "answer_id": 75182, "author": "Sethmatics", "author_id": 24508, "author_profile": "https://wordpress.stackexchange.com/users/24508", "pm_score": 1, "selected": false, "text": "<p>We update the post status all the time, here is an example of how we allow users (on the front end editor t...
2012/10/08
[ "https://wordpress.stackexchange.com/questions/67451", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7890/" ]
I'm using this bit to insert/update a custom post type from the front-end. The date is set from a custom jquery datepicker. ``` if (strtotime($date) < strtotime('tomorrow')) { $newpostdata['post_status'] = 'publish'; } elseif (strtotime($date) > strtotime('today')) { $newpostdata['post_...
Answer couldn't be simpler. As pointed out by [Otto](https://wordpress.stackexchange.com/users/2232/otto) at the wp-hackers list, problem was me not setting `post_date_gmt` when using `wp_update_post()`. Final code looks like this: ``` if ( $post_date < strtotime( "tomorrow" ) ) { $status = 'publish'; ...
67,463
<p>I'm in a situation where i also need to get the id of the inserted meta( <code>meta_id</code> for post meta and <code>umeta_id</code> for user meta)</p> <p>For eg i add a user meta</p> <pre><code>add_user_meta($user_id,'some_key',$some_value,false); </code></pre> <p>is there a built in method of getting the umeta...
[ { "answer_id": 67464, "author": "dipali", "author_id": 20711, "author_profile": "https://wordpress.stackexchange.com/users/20711", "pm_score": 1, "selected": false, "text": "<p>No need to get Insert id for meta field.You get key value by using this function.</p>\n\n<pre><code>$user_some_...
2012/10/08
[ "https://wordpress.stackexchange.com/questions/67463", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7247/" ]
I'm in a situation where i also need to get the id of the inserted meta( `meta_id` for post meta and `umeta_id` for user meta) For eg i add a user meta ``` add_user_meta($user_id,'some_key',$some_value,false); ``` is there a built in method of getting the umeta\_id for this meta field without using custom query? S...
No need to get Insert id for meta field.You get key value by using this function. ``` $user_some_value = get_user_meta( $user_id, some_key ); ```
67,467
<p>I am using a small shortcode to output a list of movie titles arranged by decades. <code>decades</code> is my custom taxonomy with terms like <code>1930s</code> <code>1940s</code> etc.</p> <p>Here is my shortcode:</p> <pre><code>[fashionfilms type=fashionfilms tax=decades] </code></pre> <p>and here is how that s...
[ { "answer_id": 67470, "author": "Amit Erandole", "author_id": 3361, "author_profile": "https://wordpress.stackexchange.com/users/3361", "pm_score": 0, "selected": false, "text": "<p>As suggested by @hampsun above, adding <code>wp_reset_postdata()</code> fixed the double output issue. The...
2012/10/08
[ "https://wordpress.stackexchange.com/questions/67467", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3361/" ]
I am using a small shortcode to output a list of movie titles arranged by decades. `decades` is my custom taxonomy with terms like `1930s` `1940s` etc. Here is my shortcode: ``` [fashionfilms type=fashionfilms tax=decades] ``` and here is how that shortcode is parsed: ``` add_shortcode('fashionfilms', 'cw_output_...
You've used `wp_reset_query`, however, you should use `wp_reset_postdata`. `wp_reset_query` takes the current query object, and replaces it with the main query. The problem here however, is that you're using WP\_Query, which is a separate individual query object, the main query has not been touched and does not need p...
67,476
<p>In functions.php of my theme I have code to add page in admin area and append scripts to it. But scripts are not loaded. Bellow is code. Commented out add_action lines are the one I did check.</p> <pre><code> // functions.php // Append user style and scripts to Add New Wallpaper menu function pb_admin_sc...
[ { "answer_id": 67479, "author": "Miha Rekar", "author_id": 20791, "author_profile": "https://wordpress.stackexchange.com/users/20791", "pm_score": 2, "selected": true, "text": "<p>Use <code>add_action('admin_enqueue_scripts', 'pb_admin_style');</code> and as the <a href=\"http://codex.wo...
2012/10/08
[ "https://wordpress.stackexchange.com/questions/67476", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21181/" ]
In functions.php of my theme I have code to add page in admin area and append scripts to it. But scripts are not loaded. Bellow is code. Commented out add\_action lines are the one I did check. ``` // functions.php // Append user style and scripts to Add New Wallpaper menu function pb_admin_scripts() { ...
Use `add_action('admin_enqueue_scripts', 'pb_admin_style');` and as the [manual](http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts) states, the `admin_enqueue_scripts` can also be used to target a specific admin page. Use this to only select the admin page you want. ``` function pb_admin_sty...
67,480
<p>I am stuck at <code>add_custom_background</code>.</p> <p>I can change background color/image but I only want to change my index page. Currently, the changes apply on the whole page.</p> <p>I want to make the changes from WP-admin.</p> <p>How can I specify it to a specific page ?</p> <p>Edit:</p> <p>I just check...
[ { "answer_id": 67495, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": true, "text": "<p>You can check in your callback function if you are an the front page. </p>\n\n<p>Sample code for the theme’s <code>func...
2012/10/08
[ "https://wordpress.stackexchange.com/questions/67480", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21256/" ]
I am stuck at `add_custom_background`. I can change background color/image but I only want to change my index page. Currently, the changes apply on the whole page. I want to make the changes from WP-admin. How can I specify it to a specific page ? Edit: I just checked im running 3.3.1. So my version is not support...
You can check in your callback function if you are an the front page. Sample code for the theme’s `functions.php`: ``` add_action( 'after_setup_theme', 'wpse_67480_theme_setup' ); function wpse_67480_theme_setup() { $bg_options = array ( 'wp-head-callback' => 'wpse_67480_background_frontend', 'd...
67,482
<p>I've added two custom fields to attachments on my site, so the user can add a special image credit.</p> <p>I'm trying to write a function that looks to see if either of the custom fields are populated, and if so echoes the contents.</p> <p>The part I'm struggling with is getting the ID of the image into the functi...
[ { "answer_id": 67492, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 1, "selected": false, "text": "<p>Hopefully this helps,</p>\n\n<pre><code>function mat_image_credit() {\n global $post;\n $args = array(\n ...
2012/10/08
[ "https://wordpress.stackexchange.com/questions/67482", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13667/" ]
I've added two custom fields to attachments on my site, so the user can add a special image credit. I'm trying to write a function that looks to see if either of the custom fields are populated, and if so echoes the contents. The part I'm struggling with is getting the ID of the image into the function - it's simple ...
Hopefully this helps, ``` function mat_image_credit() { global $post; $args = array( 'post_type' => 'attachment', 'post_parent' => $post->ID, 'post_mime_type' => 'image', 'numberposts' => -1, ); $imgs = get_posts($args); foreach ($imgs as $img) { $fie...
67,489
<p>I have a weird problem I'm having hard time understanding.</p> <p>Pagination gives me error 404 when I click page #3 when there is only 1 post on that page. If I add 1 more so that on page #3 there are minimum 2 posts error goes away!</p> <p>Any way to diagnose this issue?</p> <p>My code is this:</p> <pre><code>...
[ { "answer_id": 67688, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>While comment is absolutely correct about what you should be doing, I want to elaborate a bit why exactly <code>quer...
2012/10/08
[ "https://wordpress.stackexchange.com/questions/67489", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I have a weird problem I'm having hard time understanding. Pagination gives me error 404 when I click page #3 when there is only 1 post on that page. If I add 1 more so that on page #3 there are minimum 2 posts error goes away! Any way to diagnose this issue? My code is this: ``` //default values ...
While comment is absolutely correct about what you should be doing, I want to elaborate a bit why exactly `query_posts()` is recipe for horribly broken pagination. Main WordPress query runs before execution reaches template file, which is actually chosen depending on results of it. When query runs for archives it take...
67,498
<p>how can I include a line-break inside the_excerpt. I’ve modified the length and the more-button via my functions.php. I’m using teaser for every blog-entry and sometimes it looks a bit ugly, that there no line-breaks included.</p>
[ { "answer_id": 67504, "author": "Johannes Pille", "author_id": 9745, "author_profile": "https://wordpress.stackexchange.com/users/9745", "pm_score": 3, "selected": false, "text": "<p>There is no filter that would allow you to set allowable tags not to be removed by <a href=\"http://codex...
2012/10/08
[ "https://wordpress.stackexchange.com/questions/67498", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19005/" ]
how can I include a line-break inside the\_excerpt. I’ve modified the length and the more-button via my functions.php. I’m using teaser for every blog-entry and sometimes it looks a bit ugly, that there no line-breaks included.
There is no filter that would allow you to set allowable tags not to be removed by [`the_excerpt()`](http://codex.wordpress.org/Function_Reference/the_excerpt). Arguably a shortcoming of the core. Anyhow, the actual excerpt generation does not happen in that template tag but entirely elsewhere: Excerpts are generated...
67,509
<p>I've created a custom registration form for a WordPress MultiSite installation. It allows registrations of new blogs and users. I want to check with ajax if a given username is available. This is what I have so far:</p> <pre><code>add_action( 'wp_footer', 'pb_ajax_add_js' ); function pb_ajax_add_js() { // add scr...
[ { "answer_id": 67510, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 1, "selected": false, "text": "<p>The problem is with your jQuery selector:</p>\n\n<pre><code>var usr = $(\"#site-addres-input\").attr('value');\n</cod...
2012/10/08
[ "https://wordpress.stackexchange.com/questions/67509", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20612/" ]
I've created a custom registration form for a WordPress MultiSite installation. It allows registrations of new blogs and users. I want to check with ajax if a given username is available. This is what I have so far: ``` add_action( 'wp_footer', 'pb_ajax_add_js' ); function pb_ajax_add_js() { // add script to the foo...
The problem is with your jQuery selector: ``` var usr = $("#site-addres-input").attr('value'); ``` Will get the default value of the input element. Typically this will be blank, because you're not setting it ahead of time. You need to use: ``` var usr = $("#site-addres-input").val(); ``` I'm also noticing that yo...
67,512
<p>I found this very useful code at the wp codex, it basically lists out the parent, child and grandchild pages, I'm using it in my sidebar and it works well for the parent and children pages, but when you go to a grandchild page, the menu changes and it now only shows the child/grandchild, instead of the same menu on ...
[ { "answer_id": 67523, "author": "Jen", "author_id": 13810, "author_profile": "https://wordpress.stackexchange.com/users/13810", "pm_score": 1, "selected": false, "text": "<p><a href=\"https://gist.github.com/3853924\" rel=\"nofollow\">https://gist.github.com/3853924</a></p>\n\n<p>This is...
2012/10/08
[ "https://wordpress.stackexchange.com/questions/67512", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19794/" ]
I found this very useful code at the wp codex, it basically lists out the parent, child and grandchild pages, I'm using it in my sidebar and it works well for the parent and children pages, but when you go to a grandchild page, the menu changes and it now only shows the child/grandchild, instead of the same menu on the...
I finally figured this out. I didn't want it to show up at all on pages without children, so the first if statement checks and only displays the menu if the parent has children. This menu stays the same whether you are on the parent, child, or grandchild page. :) ``` <?php if ( has_children() ) { //makes menu title o...
67,536
<p>I have a custom post type:</p> <pre><code>add_action( 'init', 'register_cpt_foto' ); function register_cpt_foto() { $labels = array( 'name' =&gt; _x( 'Fotoalbums', 'foto' ), 'singular_name' =&gt; _x( 'Fotoalbum', 'foto' ), 'add_new' =&gt; _x( 'Nieuw fotoalbum', 'foto' ), 'add_...
[ { "answer_id": 67537, "author": "Bram Vanroy", "author_id": 16574, "author_profile": "https://wordpress.stackexchange.com/users/16574", "pm_score": 1, "selected": false, "text": "<p>Found it:\nIn <code>facebook-photo-fetcher/_output_gallery.php</code> delete lines 15 to 17. These ones:</...
2012/10/08
[ "https://wordpress.stackexchange.com/questions/67536", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16574/" ]
I have a custom post type: ``` add_action( 'init', 'register_cpt_foto' ); function register_cpt_foto() { $labels = array( 'name' => _x( 'Fotoalbums', 'foto' ), 'singular_name' => _x( 'Fotoalbum', 'foto' ), 'add_new' => _x( 'Nieuw fotoalbum', 'foto' ), 'add_new_item' => _x( 'Voeg ...
[Comment reposted as answer at request of OP author:] Rather than deleting them, why don't you add your post\_type to the if() statement: ``` //Don't process anything but POSTS and PAGES (i.e. no revisions) if( $data['post_type'] != 'post' && $data['post_type'] != 'page' && $data['post_type'] != 'foto' ) return $...
67,540
<p>I am trying to create a function to add data from two custom fields after the entry title. I get it to show correctly when these fields are filled in. The fields are a image source url and an url the image has to link to.</p> <p>The problem is that it's taking up space even when the custom fields are empty. My php ...
[ { "answer_id": 67546, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 2, "selected": false, "text": "<p>Change,</p>\n\n<pre><code>if( !empty( $check[\"\"] ) )\n</code></pre>\n\n<p>To,</p>\n\n<pre><code>if( $check != '...
2012/10/08
[ "https://wordpress.stackexchange.com/questions/67540", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3497/" ]
I am trying to create a function to add data from two custom fields after the entry title. I get it to show correctly when these fields are filled in. The fields are a image source url and an url the image has to link to. The problem is that it's taking up space even when the custom fields are empty. My php skills are...
There are a few issues that break your code: * `$post` doesn't exist, you'd need to import it using `global`, or simply use `get_the_ID` as you're already doing * `$check['']` won't return anything since it will access an undefined index, outside of the `empty` construct it would trigger a warning I can't test it rig...
67,576
<p>I added the following function to the file <code>functions.php</code></p> <pre><code>function contentGenerator($param) { if($param) { echo "Content true"; } else { echo "Content false"; } } </code></pre> <p>How can I call this function within a <strong>specific</strong> blog post or page?</p>
[ { "answer_id": 67577, "author": "dipali", "author_id": 20711, "author_profile": "https://wordpress.stackexchange.com/users/20711", "pm_score": 1, "selected": false, "text": "<p><code>contentGenerator($param);</code><br />\nsimply put this code in page.php file.<br />\nIf you define funct...
2012/10/09
[ "https://wordpress.stackexchange.com/questions/67576", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19594/" ]
I added the following function to the file `functions.php` ``` function contentGenerator($param) { if($param) { echo "Content true"; } else { echo "Content false"; } } ``` How can I call this function within a **specific** blog post or page?
If you are talking about a post's/page's content, it's not possible. Here are three different ways of solving your problem.The first way will give you the possibility to add the generated content inside your post's (or page's) content. The other two will be printed in one of your template files. E.g. in your `single.ph...
67,586
<p>I am using this code to retrieve post meta: </p> <pre><code>if ( get_post_meta($post-&gt;ID,'a',true) == '') { echo '&lt;img src="' . get_bloginfo( 'template_url' ) . '/img/img22.jpg" &gt;&lt;/img&gt;'; } else { echo get_post_meta($post-&gt;ID,'a',true); } </code></pre> <p>My first block of if statement i...
[ { "answer_id": 67590, "author": "dipali", "author_id": 20711, "author_profile": "https://wordpress.stackexchange.com/users/20711", "pm_score": 0, "selected": false, "text": "<p>try this.Hope this will work fine</p>\n\n<pre><code>$key_1_value = get_post_meta($post-&gt;ID, 'a', true);\n ...
2012/10/09
[ "https://wordpress.stackexchange.com/questions/67586", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20406/" ]
I am using this code to retrieve post meta: ``` if ( get_post_meta($post->ID,'a',true) == '') { echo '<img src="' . get_bloginfo( 'template_url' ) . '/img/img22.jpg" ></img>'; } else { echo get_post_meta($post->ID,'a',true); } ``` My first block of if statement is always executing no matter whether the met...
I was having some issues like yours. It was because it was on a page template with a query above it. All I had to do was reset the [query](http://codex.wordpress.org/Function_Reference/wp_reset_query).
67,600
<p>I need to sort (custom) posts by 2 custom field values...</p> <p>custom field name 1: <code>is_sponsored</code> [ value can either be <code>1</code> or <code>0</code> ]</p> <p>custom field name 2: <code>sfp_date</code> [ <code>timestamp</code> aka current post date in seconds ]</p> <p>Posts whose "<code>is_sponso...
[ { "answer_id": 67604, "author": "Md Toufiqul Islam", "author_id": 21268, "author_profile": "https://wordpress.stackexchange.com/users/21268", "pm_score": -1, "selected": false, "text": "<p>I am writing your query modifying slightly. I hope it may help.</p>\n\n<pre><code>$sfp_query_args =...
2012/10/09
[ "https://wordpress.stackexchange.com/questions/67600", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13076/" ]
I need to sort (custom) posts by 2 custom field values... custom field name 1: `is_sponsored` [ value can either be `1` or `0` ] custom field name 2: `sfp_date` [ `timestamp` aka current post date in seconds ] Posts whose "`is_sponsored`" value is 1 need to be on top, sorted by "`sfp_date`" in `DESC`ending order. Al...
OK, the final workaround would be to split query: ``` $sfp_query_args = array( 'tax_query' => array( array( 'taxonomy' => 'sfp_post_category', 'terms' => $cat_id_arr ) ), 'meta_key' => 'is_sponsored', 'post_type' => 'sfpposts', 'post_status' => 'publish', 'showposts' => (int)$per_page, 'paged' ...
67,611
<p>On my site I have a number of parent pages with associated child pages. How can I show all the child pages of one particular parent when a visitor is either on the parent page or one of it's children?</p> <p>For example;</p> <p>If someone clicks onto the "Story" parent page, they'll see a list of "story" child pag...
[ { "answer_id": 67612, "author": "anu", "author_id": 490, "author_profile": "https://wordpress.stackexchange.com/users/490", "pm_score": 0, "selected": false, "text": "<p>Depends on how you want to do it, but you can use the Sub Pages widget plugin</p>\n\n<p><a href=\"http://wordpress.org...
2012/10/09
[ "https://wordpress.stackexchange.com/questions/67611", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18547/" ]
On my site I have a number of parent pages with associated child pages. How can I show all the child pages of one particular parent when a visitor is either on the parent page or one of it's children? For example; If someone clicks onto the "Story" parent page, they'll see a list of "story" child pages in the sidebar...
``` Add this code in sidebar.php.this code will help you. global $post; $parent_id = $post->post_parent; if(!empty($parent_id)){ $parent_post=get_post($parent_id); echo '<h1...
67,626
<p>On my site, I want some pages to not be queriable by the search form (so they don't appear when I've got something like www.ex.com/?s=banana)</p> <p>Is there a way to "Remove" pages from the search results page (without just blindly do a condition of if is_page(id), display:none)</p>
[ { "answer_id": 67628, "author": "Eric Holmes", "author_id": 23454, "author_profile": "https://wordpress.stackexchange.com/users/23454", "pm_score": 5, "selected": true, "text": "<p>In <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query\">WP_Query()</a> there is a 'post__not_in'...
2012/10/09
[ "https://wordpress.stackexchange.com/questions/67626", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8895/" ]
On my site, I want some pages to not be queriable by the search form (so they don't appear when I've got something like www.ex.com/?s=banana) Is there a way to "Remove" pages from the search results page (without just blindly do a condition of if is\_page(id), display:none)
In [WP\_Query()](http://codex.wordpress.org/Class_Reference/WP_Query) there is a 'post\_\_not\_in' argument where you can exclude specific post ID's. You would create a new WP\_Query inside of your search.php and use the current $query\_args, then add on your 'post\_\_not\_in'. If you wanted to make it more dynamic, ...
67,634
<p>I want to know if it is a good practice according to WordPress theme or plugin development.</p> <pre><code>add_action('init','all_my_hooks'); function all_my_hooks(){ // some initialization stuff here and then add_action('admin_init',-----); add_action('admin_menu',----); // more like so } </code></pre> <p>th...
[ { "answer_id": 67635, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 5, "selected": true, "text": "<p>In general: Yes, wait for a dedicated hook to start your own code. <a href=\"https://wordpress.stackexchange.com/questi...
2012/10/09
[ "https://wordpress.stackexchange.com/questions/67634", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21279/" ]
I want to know if it is a good practice according to WordPress theme or plugin development. ``` add_action('init','all_my_hooks'); function all_my_hooks(){ // some initialization stuff here and then add_action('admin_init',-----); add_action('admin_menu',----); // more like so } ``` thanks
In general: Yes, wait for a dedicated hook to start your own code. [Never](https://wordpress.stackexchange.com/questions/57079/how-to-remove-a-filter-that-is-an-anonymous-object/57088#57088 "How to remove a filter that is an anonymous object?") just throw an object instance into the global namespace. But `init` is rare...
67,649
<p>I want to clean up my theme options because I can't keep track of everything. How can I get my page_callback to link to a file sintead of a callback?</p> <p>I know that I could include the file in the callback but why if I can simply call the file here? </p> <pre><code> add_submenu_page( null ...
[ { "answer_id": 67653, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 2, "selected": false, "text": "<p>Instead of running to trac and complaining about a missing feature, I suggest to make use of an OOP construct:</p>\...
2012/10/09
[ "https://wordpress.stackexchange.com/questions/67649", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18726/" ]
I want to clean up my theme options because I can't keep track of everything. How can I get my page\_callback to link to a file sintead of a callback? I know that I could include the file in the callback but why if I can simply call the file here? ``` add_submenu_page( null // -> Set to n...
Instead of running to trac and complaining about a missing feature, I suggest to make use of an OOP construct: ``` // File: base.class.php abstract class wpse67649_admin_page_base { public function add_page() { add_submenu_page( null // -> Set to null - will hide menu link ...
67,655
<p>I have a custom post status which should be public visible but not displayed in the "all" list of the edit screen.</p> <p>This is how I register the post status:</p> <pre><code>register_post_status('my_custom_post_status', array( 'label' =&gt; __('The Label', 'domain'), 'public' =&gt; true, 'exclude_fr...
[ { "answer_id": 67656, "author": "Xaver", "author_id": 18981, "author_profile": "https://wordpress.stackexchange.com/users/18981", "pm_score": 5, "selected": true, "text": "<p>This solves my problem:</p>\n\n<pre><code>register_post_status('my_custom_post_status', array(\n 'label' =&gt;...
2012/10/09
[ "https://wordpress.stackexchange.com/questions/67655", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18981/" ]
I have a custom post status which should be public visible but not displayed in the "all" list of the edit screen. This is how I register the post status: ``` register_post_status('my_custom_post_status', array( 'label' => __('The Label', 'domain'), 'public' => true, 'exclude_from_search' => true, 'sh...
This solves my problem: ``` register_post_status('my_custom_post_status', array( 'label' => __('The Label', 'domain'), 'public' => !is_admin(), 'exclude_from_search' => true, 'show_in_admin_all_list' => false, 'label_count' => //blablabla )); ``` `!is_admin()` makes the status only public on the ...
67,662
<p>I am well aware that there are several posts covering the topic of customizing the <strong>permalink URL structure</strong> of <strong>custom post types</strong>, <strong>custom taxonomies</strong>, and <strong>taxonomy terms</strong>. However, none of them are real clear, don't work correctly, or cause problems els...
[ { "answer_id": 67670, "author": "Eric Holmes", "author_id": 23454, "author_profile": "https://wordpress.stackexchange.com/users/23454", "pm_score": 2, "selected": false, "text": "<p>I'm not sure it's possible, or perhaps it just may not be the best approach. Here is my reasoning:</p>\n\n...
2012/10/09
[ "https://wordpress.stackexchange.com/questions/67662", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9579/" ]
I am well aware that there are several posts covering the topic of customizing the **permalink URL structure** of **custom post types**, **custom taxonomies**, and **taxonomy terms**. However, none of them are real clear, don't work correctly, or cause problems elsewhere. --- Here are a few links, which already "kind...
I'm not sure it's possible, or perhaps it just may not be the best approach. Here is my reasoning: `domain.com/post-type-name/taxonomy-name/term-name/post-title/` Posts can be attached to multiple terms, so in essence there could be multiple links to the same post: ``` domain.com/post-type-name/taxonomy-name/term-n...
67,673
<p>I have some custom code built into the header of my theme that gets the featured image from a post, displays the image and links to the posts permalink when clicked on by a user.</p> <p>The problem I am having is that I have this happening on 2 different divs pulling in info from 2 different categories, but when yo...
[ { "answer_id": 67670, "author": "Eric Holmes", "author_id": 23454, "author_profile": "https://wordpress.stackexchange.com/users/23454", "pm_score": 2, "selected": false, "text": "<p>I'm not sure it's possible, or perhaps it just may not be the best approach. Here is my reasoning:</p>\n\n...
2012/10/09
[ "https://wordpress.stackexchange.com/questions/67673", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21292/" ]
I have some custom code built into the header of my theme that gets the featured image from a post, displays the image and links to the posts permalink when clicked on by a user. The problem I am having is that I have this happening on 2 different divs pulling in info from 2 different categories, but when you hover ov...
I'm not sure it's possible, or perhaps it just may not be the best approach. Here is my reasoning: `domain.com/post-type-name/taxonomy-name/term-name/post-title/` Posts can be attached to multiple terms, so in essence there could be multiple links to the same post: ``` domain.com/post-type-name/taxonomy-name/term-n...
67,675
<p>I'm working on a new plugin but it's my first to save which will save an option to the database. </p> <p>Currently I'm using <code>add_option</code> and I assumed that<br> - activation would fail or - the wrong value would be saved to the wp_blogID_options table </p> <p>because I wasn't using <code>add_blog_optio...
[ { "answer_id": 67670, "author": "Eric Holmes", "author_id": 23454, "author_profile": "https://wordpress.stackexchange.com/users/23454", "pm_score": 2, "selected": false, "text": "<p>I'm not sure it's possible, or perhaps it just may not be the best approach. Here is my reasoning:</p>\n\n...
2012/10/09
[ "https://wordpress.stackexchange.com/questions/67675", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17132/" ]
I'm working on a new plugin but it's my first to save which will save an option to the database. Currently I'm using `add_option` and I assumed that - activation would fail or - the wrong value would be saved to the wp\_blogID\_options table because I wasn't using `add_blog_option`. All the [posts](http://codex...
I'm not sure it's possible, or perhaps it just may not be the best approach. Here is my reasoning: `domain.com/post-type-name/taxonomy-name/term-name/post-title/` Posts can be attached to multiple terms, so in essence there could be multiple links to the same post: ``` domain.com/post-type-name/taxonomy-name/term-n...
67,693
<p>Looking for a way to disable the "Edit Image" option. I would still like to be able to edit the description, alt, etc. But remove the Edit image button or disable that image editor. Thanks, </p>
[ { "answer_id": 67759, "author": "loQ", "author_id": 21300, "author_profile": "https://wordpress.stackexchange.com/users/21300", "pm_score": 2, "selected": false, "text": "<p>I figured it out. Just put this in your functions.php file</p>\n\n<pre><code>add_action('admin_head-media-upload-p...
2012/10/10
[ "https://wordpress.stackexchange.com/questions/67693", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21297/" ]
Looking for a way to disable the "Edit Image" option. I would still like to be able to edit the description, alt, etc. But remove the Edit image button or disable that image editor. Thanks,
I figured it out. Just put this in your functions.php file ``` add_action('admin_head-media-upload-popup', 'remove_edit_image_button'); // for the pop up media box add_action('admin_head', 'remove_edit_image_button'); // for the media page function remove_edit_image_button() { ?> <style> .A1B1 p .button { ...
67,707
<p>I've been reading a lot about this but couldn't find a solution.</p> <p>Basically I'm trying to show a current menu item on a dynamic page that is created by a custom page type archive. The default menu control doesn't add the current-menu-item CSS class names. I've found a solution here - <a href="http://bloggings...
[ { "answer_id": 67722, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 1, "selected": false, "text": "<p>This is what you want to do,</p>\n\n<pre><code> add_filter( 'wp_get_nav_menu_items', 'cpt_archive_menu_filter', ...
2012/10/10
[ "https://wordpress.stackexchange.com/questions/67707", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21303/" ]
I've been reading a lot about this but couldn't find a solution. Basically I'm trying to show a current menu item on a dynamic page that is created by a custom page type archive. The default menu control doesn't add the current-menu-item CSS class names. I've found a solution here - <http://bloggingsquared.com/bloggin...
This is what you want to do, ``` add_filter( 'wp_get_nav_menu_items', 'cpt_archive_menu_filter', 10, 3 ); function cpt_archive_menu_filter( $items, $menu, $args ) { foreach ( $items as &$item ) { if ( $item->type != 'custom' ) continue; if ( get_query_var( 'post_type' ) == 'your-post-type' && $item-...
67,716
<p>So I have a plugin that appends or prepends an enhanced author biography to the content of a page/post/custom post type.</p> <p>It does this by hooking to either <code>the_content</code> or <code>the_excerpt</code> and appending/prepending content according to the plugin's configuration.</p> <p>I've started gettin...
[ { "answer_id": 67745, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>Do not ask for sidebars, ask for the <a href=\"http://queryposts.com/function/is_main_query/\" rel=\"nofollow\">main q...
2012/10/10
[ "https://wordpress.stackexchange.com/questions/67716", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21309/" ]
So I have a plugin that appends or prepends an enhanced author biography to the content of a page/post/custom post type. It does this by hooking to either `the_content` or `the_excerpt` and appending/prepending content according to the plugin's configuration. I've started getting support queries where the author biog...
On a parallel thread over on the [WordPress hacks forum](http://wordpress.org/support/topic/how-to-determine-if-a-filter-is-called-in-a-sidebarwidget-context), someone suggested using `in_the_loop()` and that works some of the time, with some plugins that use either `the_content` and/or `the_excerpt`, but not all of th...
67,732
<h2>Warning: fairly pedantic request ahead.</h2> <p>I have a design that makes use of posts (I.e., the blog) and a custom post type called "howto". The site front page ("/") has a template that displays the latest blog posts and latest howtos. When the user navigates to the blog section ("/blog"), they see a different...
[ { "answer_id": 67739, "author": "gregn3", "author_id": 6413, "author_profile": "https://wordpress.stackexchange.com/users/6413", "pm_score": -1, "selected": false, "text": "<p>Maybe you are looking for this:</p>\n\n<pre><code>&lt;?php\n\ndefine ('HOWTO_SLUG', 'my_howtos');\ndefine ('HOWT...
2012/10/10
[ "https://wordpress.stackexchange.com/questions/67732", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1682/" ]
Warning: fairly pedantic request ahead. --------------------------------------- I have a design that makes use of posts (I.e., the blog) and a custom post type called "howto". The site front page ("/") has a template that displays the latest blog posts and latest howtos. When the user navigates to the blog section ("/...
~~I don't have time to explain this in detail (I shall upon return) but in the meantime this **should** work for you,~~ `Answer updated with explanation as promised.` `WP Rewrite rules are like voodoo, I'm sure there's more than one way to go about this, but here's mine.` Problem: -------- Just to clarify your q...
67,740
<p>I am trying to embed a Ted talk video using the shortcode:</p> <pre><code>[ted id=myid] </code></pre> <p>But it's not working. It shows the text instead of the video. Is there any configuration I need to check to make it work?</p>
[ { "answer_id": 67768, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 4, "selected": true, "text": "<p>Unfortunately, this is going to be a problem for you.</p>\n<p>The <code>[ted]</code> shortcode is specific to WordPres...
2012/10/10
[ "https://wordpress.stackexchange.com/questions/67740", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13970/" ]
I am trying to embed a Ted talk video using the shortcode: ``` [ted id=myid] ``` But it's not working. It shows the text instead of the video. Is there any configuration I need to check to make it work?
Unfortunately, this is going to be a problem for you. The `[ted]` shortcode is specific to WordPress.com - not to a self-hosted site where you installed the software yourself from WordPress.org. The only embeds that WordPress.org's software supports by default are [listed in the Codex](http://codex.wordpress.org/Embe...
67,743
<p><a href="http://wordpress.org/extend/themes/twentytwelve" rel="nofollow">Twenty Twelve</a> comes with some page templates: Front Page &amp; Full Width. These are in the folder /page-templates. </p> <p>I've created my own template and saved it into this folder, but it is not present to be selected when editing a p...
[ { "answer_id": 67747, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 3, "selected": true, "text": "<p>Put the template file in your theme and add the following comment to the top of your file after the \n\n<pre><...
2012/10/10
[ "https://wordpress.stackexchange.com/questions/67743", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3206/" ]
[Twenty Twelve](http://wordpress.org/extend/themes/twentytwelve) comes with some page templates: Front Page & Full Width. These are in the folder /page-templates. I've created my own template and saved it into this folder, but it is not present to be selected when editing a page. There is no mention of the two page ...
Put the template file in your theme and add the following comment to the top of your file after the ``` /** * Template Name: This is the name of your template */ ``` WordPress will pick this up and in the page templates dropdown you will see "This is the name of your template" listed as an option