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
20,965
<p>I'm using the code below to create pagination for my post results, it works fine but is it possible to add a "view all posts on one page" button to the pagination? </p> <p>This would presumably override the pagination code and just display everything all posts on one page.</p> <pre><code>function numeric_paginati...
[ { "answer_id": 20959, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": false, "text": "<p>Install the <a href=\"http://wordpress.org/extend/plugins/custom-post-type-ui/\" rel=\"nofollow\">Custom Post Type ...
2011/06/24
[ "https://wordpress.stackexchange.com/questions/20965", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2837/" ]
I'm using the code below to create pagination for my post results, it works fine but is it possible to add a "view all posts on one page" button to the pagination? This would presumably override the pagination code and just display everything all posts on one page. ``` function numeric_pagination ($pageCount = 9, $q...
Install the [Custom Post Type UI plugin](http://wordpress.org/extend/plugins/custom-post-type-ui/) and create a `Product` [custom post type](http://codex.wordpress.org/Post_Types#Custom_Types). You can then create separate templates in your theme to display your products archive and posts.
20,973
<p>This is what I'm trying to do:</p> <p>if number of posts is greater than 20 -> display link to another page (which shows all posts) if number of posts is less than 20 -> don't display the link</p> <p>So far I've been able to return the number of posts using </p> <pre><code>$count_posts = wp_count_posts('inventory...
[ { "answer_id": 20977, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 5, "selected": true, "text": "<p>If I remember right count of posts in category is stored persistently in category object. So use <a href=\"http://cod...
2011/06/24
[ "https://wordpress.stackexchange.com/questions/20973", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2837/" ]
This is what I'm trying to do: if number of posts is greater than 20 -> display link to another page (which shows all posts) if number of posts is less than 20 -> don't display the link So far I've been able to return the number of posts using ``` $count_posts = wp_count_posts('inventory'); $published_posts = $coun...
If I remember right count of posts in category is stored persistently in category object. So use [`get_category()`](http://codex.wordpress.org/Function_Reference/get_category) or variation of it and fetch the number out of object. Example code (not tested): ``` $category = get_category($id); $count = $category->categ...
20,984
<p>I'm working on trying to get my homepage template to display post-format 'gallery' a little different than the other formats but having no luck so far.</p> <p>Here is a snippet 'inside the loop' that shows what I am trying to accomplish. Basically saying if post-format = 'aside' do x, elseif post-format is gallery,...
[ { "answer_id": 20977, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 5, "selected": true, "text": "<p>If I remember right count of posts in category is stored persistently in category object. So use <a href=\"http://cod...
2011/06/24
[ "https://wordpress.stackexchange.com/questions/20984", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/370/" ]
I'm working on trying to get my homepage template to display post-format 'gallery' a little different than the other formats but having no luck so far. Here is a snippet 'inside the loop' that shows what I am trying to accomplish. Basically saying if post-format = 'aside' do x, elseif post-format is gallery, then I wa...
If I remember right count of posts in category is stored persistently in category object. So use [`get_category()`](http://codex.wordpress.org/Function_Reference/get_category) or variation of it and fetch the number out of object. Example code (not tested): ``` $category = get_category($id); $count = $category->categ...
20,987
<p>I have SQL file with US zip codes (over 41000 lines of code). I want make a plugin that inserts this SQL file into WP database so user can do a search by zip codes. I want to insert SQL with PHP rather than PhpMyAdmin</p>
[ { "answer_id": 20977, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 5, "selected": true, "text": "<p>If I remember right count of posts in category is stored persistently in category object. So use <a href=\"http://cod...
2011/06/24
[ "https://wordpress.stackexchange.com/questions/20987", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4678/" ]
I have SQL file with US zip codes (over 41000 lines of code). I want make a plugin that inserts this SQL file into WP database so user can do a search by zip codes. I want to insert SQL with PHP rather than PhpMyAdmin
If I remember right count of posts in category is stored persistently in category object. So use [`get_category()`](http://codex.wordpress.org/Function_Reference/get_category) or variation of it and fetch the number out of object. Example code (not tested): ``` $category = get_category($id); $count = $category->categ...
20,992
<p>When viewing non-custom Posts, you get the likes of this submenu:</p> <p><img src="https://i.stack.imgur.com/MDUzC.png" alt="submenu"></p> <p>I'm not using a title - I'm using custom columns with two fields concatenated:</p> <p><img src="https://i.stack.imgur.com/4N86p.png" alt="my species profiles"></p> <p>Is t...
[ { "answer_id": 21106, "author": "turbonerd", "author_id": 6344, "author_profile": "https://wordpress.stackexchange.com/users/6344", "pm_score": 2, "selected": true, "text": "<p>In the end, I went for this:</p>\n\n<pre><code>function species_custom_columns($column){\n global $post;...
2011/06/25
[ "https://wordpress.stackexchange.com/questions/20992", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6344/" ]
When viewing non-custom Posts, you get the likes of this submenu: ![submenu](https://i.stack.imgur.com/MDUzC.png) I'm not using a title - I'm using custom columns with two fields concatenated: ![my species profiles](https://i.stack.imgur.com/4N86p.png) Is there any quick and easy way of adding the submenu to my cus...
In the end, I went for this: ``` function species_custom_columns($column){ global $post; if (!isset($title)) { $title = $this->getValue('genus',$post->ID,TRUE) . ' ' . $this->getValue('species',$post->ID,TRUE); } if (!isset($post_url)) { $post_url = get_site_url() . "/wp-ad...
20,996
<p>I'm trying to do a query on wpdb to get the posts commented on most in the past week... Any ideas what I'm doing wrong?</p> <pre><code>$querystr = "SELECT comment_count, ID, post_title FROM $wpdb-&gt;posts wposts, $wpdb-&gt;comments wcomments WHERE wposts.ID = wcomments.comment_post_ID AND w...
[ { "answer_id": 21106, "author": "turbonerd", "author_id": 6344, "author_profile": "https://wordpress.stackexchange.com/users/6344", "pm_score": 2, "selected": true, "text": "<p>In the end, I went for this:</p>\n\n<pre><code>function species_custom_columns($column){\n global $post;...
2011/06/25
[ "https://wordpress.stackexchange.com/questions/20996", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6490/" ]
I'm trying to do a query on wpdb to get the posts commented on most in the past week... Any ideas what I'm doing wrong? ``` $querystr = "SELECT comment_count, ID, post_title FROM $wpdb->posts wposts, $wpdb->comments wcomments WHERE wposts.ID = wcomments.comment_post_ID AND wcomments.comment_dat...
In the end, I went for this: ``` function species_custom_columns($column){ global $post; if (!isset($title)) { $title = $this->getValue('genus',$post->ID,TRUE) . ' ' . $this->getValue('species',$post->ID,TRUE); } if (!isset($post_url)) { $post_url = get_site_url() . "/wp-ad...
20,998
<p><em>In regards to image attachments inserted into a post</em>, I would like to wrap the <strong>img</strong> tag inside a <strong>div</strong> tag for specific design purpose.</p> <p>Is there a way to do this <strong>automatically</strong> after attaching the image file, like through <em>hooks/filters</em> maybe?</...
[ { "answer_id": 20999, "author": "MartinJJ", "author_id": 3710, "author_profile": "https://wordpress.stackexchange.com/users/3710", "pm_score": 1, "selected": false, "text": "<p>Not looked into hooks and filters, but it is easily achievable by css alone. </p>\n\n<p>Using the <code>2010 t...
2011/06/25
[ "https://wordpress.stackexchange.com/questions/20998", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1044/" ]
*In regards to image attachments inserted into a post*, I would like to wrap the **img** tag inside a **div** tag for specific design purpose. Is there a way to do this **automatically** after attaching the image file, like through *hooks/filters* maybe? Thanks in advanced!!
It's the [image\_send\_to\_editor](http://core.trac.wordpress.org/browser/tags/3.1.3/wp-admin/includes/media.php#L103) filter: ``` if(is_admin()){ add_filter('image_send_to_editor', 'wrap_my_div', 10, 8); function wrap_my_div($html, $id, $caption, $title, $align, $url, $size, $alt){ return '<div class="mydiv...
21,000
<p>The Codex <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_wrappers">promotes</a> this method of using <code>$</code> inside a plugin/theme JavaScript file:</p> <pre><code>jQuery(document).ready(function($) { // $() will work as an alias for jQuery() inside of this func...
[ { "answer_id": 21002, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 4, "selected": true, "text": "<p>You don't need <code>$ = jQuery.noConflict();</code></p>\n\n<p>Just wrap any functions outside document.read...
2011/06/25
[ "https://wordpress.stackexchange.com/questions/21000", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3898/" ]
The Codex [promotes](http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_wrappers) this method of using `$` inside a plugin/theme JavaScript file: ``` jQuery(document).ready(function($) { // $() will work as an alias for jQuery() inside of this function }); ``` But if you do that yo...
You don't need `$ = jQuery.noConflict();` Just wrap any functions outside document.ready() within: ``` (function($){ // use $ here safely })(jQuery); ```
21,004
<p>I am using the following permalinks structure: /%postname%/ and I also have some multi-page posts that look like /%postname%/2.</p> <p>The problem is I see a lot of 404 errors in webmaster tools for urls like /post-name/random stuff here</p> <p>How can I redirect all wrong URLs to the correct ones ?</p>
[ { "answer_id": 21002, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 4, "selected": true, "text": "<p>You don't need <code>$ = jQuery.noConflict();</code></p>\n\n<p>Just wrap any functions outside document.read...
2011/06/25
[ "https://wordpress.stackexchange.com/questions/21004", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5810/" ]
I am using the following permalinks structure: /%postname%/ and I also have some multi-page posts that look like /%postname%/2. The problem is I see a lot of 404 errors in webmaster tools for urls like /post-name/random stuff here How can I redirect all wrong URLs to the correct ones ?
You don't need `$ = jQuery.noConflict();` Just wrap any functions outside document.ready() within: ``` (function($){ // use $ here safely })(jQuery); ```
21,007
<p>I've read the codex section on wp-enqeue, but am still struggling.</p> <p>Basically, I would like to get the following to display properly in my theme's widget area (on every page):</p> <pre><code>&lt;link rel="stylesheet" type="text/css" href="/wp-content/uploads/social_counter/css/styles.css" /&gt; &lt;link rel=...
[ { "answer_id": 21008, "author": "Daryl", "author_id": 9184, "author_profile": "https://wordpress.stackexchange.com/users/9184", "pm_score": 1, "selected": false, "text": "<p>Best place is in your <strong>functions.php</strong>.</p>\n\n<p><strong>Example:</strong></p>\n\n<pre><code>wp_enq...
2011/03/21
[ "https://wordpress.stackexchange.com/questions/21007", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4822/" ]
I've read the codex section on wp-enqeue, but am still struggling. Basically, I would like to get the following to display properly in my theme's widget area (on every page): ``` <link rel="stylesheet" type="text/css" href="/wp-content/uploads/social_counter/css/styles.css" /> <link rel="stylesheet" type="text/css" h...
You actually don't need to worry about conflicting with the admin pages anymore. There is a "wp\_enqueue\_scripts" hook that makes sure the scripts aren't called on admin pages. From WP Codex: ``` <?php function my_scripts_method() { wp_deregister_script( 'jquery' ); wp_register_script( 'jquery', 'http://ajax....
21,022
<p>Basically I want to achieve a glossary using custom post types and have some issues setting up rewrites the way I want them to be. I want it like that:</p> <p>The main glossary URL: <code>http://example.com/glossary/</code></p> <p>Glossary terms starting with letter <strong>A</strong>: <code>http://example.com/glo...
[ { "answer_id": 21498, "author": "eeMZee", "author_id": 4471, "author_profile": "https://wordpress.stackexchange.com/users/4471", "pm_score": 0, "selected": false, "text": "<p>I haven't personally used this, but what you may want to look at is \"add_rewrite_rule\"</p>\n\n<p><a href=\"http...
2011/06/25
[ "https://wordpress.stackexchange.com/questions/21022", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2637/" ]
Basically I want to achieve a glossary using custom post types and have some issues setting up rewrites the way I want them to be. I want it like that: The main glossary URL: `http://example.com/glossary/` Glossary terms starting with letter **A**: `http://example.com/glossary/a/` The URL for a single glossary term:...
You can always override the template that will be called with the `template_include` or a related filter, but this might hide deeper problems with custom archives. As I understand it, you want to use the following structure: * `/glossary/` should be an archive page for all `sumo-glossary-term` posts * `/glossary/[let...
21,049
<p>The following functions.php edit (contributed by helgatheviking on the themeshaper forums) allows the use of a "Read More" link with custom excerpts.</p> <p>My problem is simply this: I'm inept at editing functions.php code, but I'd like to safely remove the "wrap excerpt in p tag" portion of this script.</p> <p>H...
[ { "answer_id": 21054, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": 3, "selected": true, "text": "<p>This should remove the <code>&lt;p&gt;</code> tags, but leave the styling by replacing the paragraph tag wit...
2011/06/25
[ "https://wordpress.stackexchange.com/questions/21049", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5486/" ]
The following functions.php edit (contributed by helgatheviking on the themeshaper forums) allows the use of a "Read More" link with custom excerpts. My problem is simply this: I'm inept at editing functions.php code, but I'd like to safely remove the "wrap excerpt in p tag" portion of this script. How would I do so?...
This should remove the `<p>` tags, but leave the styling by replacing the paragraph tag with a `<span>` class: ``` function all_excerpts_get_more_link($post_excerpt) { return '' . $post_excerpt . '' . '<span class="readmore"><a href="'. get_permalink($post->ID) . '">' . 'Continue Reading &raquo' . '</span>'; } add...
21,050
<p>Maybe this is super obvious and staring me in the face, but I'm stumped. Is there a way to pull and sort posts by ID? I'd like to grab an arbitrary post, and then x number of posts after it.</p> <p>Specifically what I'm trying to do is a build a carousel of posts, and I'd like the first item on every individual pos...
[ { "answer_id": 21074, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 1, "selected": false, "text": "<p>I think you're on the right path with <code>posts_where</code>, something like this should work:</p>\n\n<pre><code>...
2011/06/25
[ "https://wordpress.stackexchange.com/questions/21050", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6373/" ]
Maybe this is super obvious and staring me in the face, but I'm stumped. Is there a way to pull and sort posts by ID? I'd like to grab an arbitrary post, and then x number of posts after it. Specifically what I'm trying to do is a build a carousel of posts, and I'd like the first item on every individual post to be th...
I think you're on the right path with `posts_where`, something like this should work: ``` <?php function my_filter_where($where){ global $my_current_id; $where .= " AND ID >= ".$my_current_id; return $where; } // random number I chose for sake of example $my_current_id = 30; add_filter('posts_where', 'my...
21,084
<p>there will be lot of users on my site who will be author uploading their posts. right now, they can upload as many images / videos per post as they want. i want to restrict them to upload maximum 4 images / videos per post. can anybody help me please ?</p>
[ { "answer_id": 21092, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": false, "text": "<p>try this:</p>\n\n<pre><code>add_filter('wp_handle_upload_prefilter', 'limit_wp_handle_upload_prefilter');\nfu...
2011/06/26
[ "https://wordpress.stackexchange.com/questions/21084", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6331/" ]
there will be lot of users on my site who will be author uploading their posts. right now, they can upload as many images / videos per post as they want. i want to restrict them to upload maximum 4 images / videos per post. can anybody help me please ?
try this: ``` add_filter('wp_handle_upload_prefilter', 'limit_wp_handle_upload_prefilter'); function yoursite_wp_handle_upload_prefilter($file) { // This bit is for the flash uploader if ($file['type']=='application/octet-stream' && isset($file['tmp_name'])) { $file_size = getimagesize($file['tmp_name']); ...
21,086
<p>I built something like this:</p> <p><strong>Index Container Widgets Area</strong></p> <p>and I created a widget for that -</p> <p><strong>Categories Widget - Index Container .php</strong> </p> <p>with this in:</p> <pre><code>&lt;?php include (TEMPLATEPATH . '/includes/containers/container-grid-categories.php');...
[ { "answer_id": 21093, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>There are several way to acchieve this:</p>\n\n<pre><code> TEMPLATEPATH // Path to your (parent) themes root dir...
2011/06/26
[ "https://wordpress.stackexchange.com/questions/21086", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5910/" ]
I built something like this: **Index Container Widgets Area** and I created a widget for that - **Categories Widget - Index Container .php** with this in: ``` <?php include (TEMPLATEPATH . '/includes/containers/container-grid-categories.php'); ?> <?php ///include (TEMPLATEPATH . '/includes/containers/container-li...
**Long answer short: the absolute-best answer, for template-part files in a subdirectory, is to use `locate_template()`** I would recommend referencing the *stylesheet* path for *template file* includes, so that those template part files can be easily over-ridden by Child Themes. So, ideally, you should use `get_style...
21,108
<p>We wish to have ALL external links within a Wordpress site have a simple mouseover tooltip without having to place a title tag or rel or class tag within it. I've tried several methods using the $('a[href=http]') selector but can not for the life of me get anything to work. </p> <p>Here is the code I came up with t...
[ { "answer_id": 21119, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>If your code is working in general, but not in WP then this is very likely caused by jQuery being run in <em>no conf...
2011/06/26
[ "https://wordpress.stackexchange.com/questions/21108", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6514/" ]
We wish to have ALL external links within a Wordpress site have a simple mouseover tooltip without having to place a title tag or rel or class tag within it. I've tried several methods using the $('a[href=http]') selector but can not for the life of me get anything to work. Here is the code I came up with that does w...
If your code is working in general, but not in WP then this is very likely caused by jQuery being run in *no conflict* mode by WP. You will need to use [appropriate wrapper](http://codex.wordpress.org/Function_Reference/wp_enqueue_script#jQuery_noConflict_wrappers) to use it as usual (with `$` sign).
21,123
<p>How should I completely disable the visual <em>and</em> html editor from pages? I know I can disable the visual editor in my profile, but I am trying to lock down the content input areas so that my client doesn't muck things up.</p>
[ { "answer_id": 21128, "author": "MartinJJ", "author_id": 3710, "author_profile": "https://wordpress.stackexchange.com/users/3710", "pm_score": 0, "selected": false, "text": "<p>Think this might be what your looking for, code and more info from <a href=\"http://wpsnipp.com/index.php/funct...
2011/06/26
[ "https://wordpress.stackexchange.com/questions/21123", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6318/" ]
How should I completely disable the visual *and* html editor from pages? I know I can disable the visual editor in my profile, but I am trying to lock down the content input areas so that my client doesn't muck things up.
Why not use custom post types and don't add any support for the editor, that is afterall what they are for and the easiest way . The answer in this post covers how to do that, [Hide content box with Custom Post Type?](https://wordpress.stackexchange.com/questions/18101/hide-content-box-with-custom-post-type) <http...
21,133
<p>I'm currently working with the 2010 theme and want to modify the nav bar so that when you click on a page that is listed on the navbar, it takes you to one of my categories pages (example, clicking on 'swag', will take you to the swag category page). How would I go about doing this? I've included my website:</p> <p...
[ { "answer_id": 21134, "author": "40XUserNotFound", "author_id": 5871, "author_profile": "https://wordpress.stackexchange.com/users/5871", "pm_score": 1, "selected": false, "text": "<p>You shouldn't need to modify the php code to do this, you can set up a custom link in the menu through t...
2011/06/26
[ "https://wordpress.stackexchange.com/questions/21133", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I'm currently working with the 2010 theme and want to modify the nav bar so that when you click on a page that is listed on the navbar, it takes you to one of my categories pages (example, clicking on 'swag', will take you to the swag category page). How would I go about doing this? I've included my website: <http://w...
Posting this as a separate answer, because it's actually different from @Keoki Zee's answer. You *do* need to create a custom menu, but you do *not* need to use a custom link. 1. Go to `Dashboard -> Appearance -> Menus` 2. If necessary, Create a new menu 3. Add whatever Pages to the menu that you want 4. To add a Cat...
21,136
<p>I've created a new custom post type and I need the post thumbnails or featured images generated by the <code>get_the_post_thumbnail()</code> function to be set in percent, rather than pixels, as I'm using a fluid grid. Ideally I would only set the width (to 100%). Is there a way to do this? Potentially using <code>a...
[ { "answer_id": 21138, "author": "Reigel Gallarde", "author_id": 974, "author_profile": "https://wordpress.stackexchange.com/users/974", "pm_score": 5, "selected": true, "text": "<p>have you tried,</p>\n\n<pre><code>if(has_post_thumbnail()) { \n $image_src = wp_get_a...
2011/06/27
[ "https://wordpress.stackexchange.com/questions/21136", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6389/" ]
I've created a new custom post type and I need the post thumbnails or featured images generated by the `get_the_post_thumbnail()` function to be set in percent, rather than pixels, as I'm using a fluid grid. Ideally I would only set the width (to 100%). Is there a way to do this? Potentially using `add_image_size()`?
have you tried, ``` if(has_post_thumbnail()) { $image_src = wp_get_attachment_image_src( get_post_thumbnail_id(),'full' ); echo '<img src="' . $image_src[0] . '" width="100%" />'; } ```
21,144
<p>I'm using</p> <pre><code>echo get_the_term_list( $post-&gt;ID, 'trpropcity', '', ' ', '' ); </code></pre> <p>to show a taxonomy link, I'd like to make this instance of it only have the first letter capitalized, Cleveland not CLEVELAND, I realize I could just change the taxonomy, but I actually want it all caps eve...
[ { "answer_id": 21147, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 3, "selected": true, "text": "<p>Build the links yourself:</p>\n\n<pre><code>$terms = get_the_terms($post-&gt;ID, 'trpropcity');\nif($terms)\...
2011/06/27
[ "https://wordpress.stackexchange.com/questions/21144", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4090/" ]
I'm using ``` echo get_the_term_list( $post->ID, 'trpropcity', '', ' ', '' ); ``` to show a taxonomy link, I'd like to make this instance of it only have the first letter capitalized, Cleveland not CLEVELAND, I realize I could just change the taxonomy, but I actually want it all caps everywhere else on the site, so ...
Build the links yourself: ``` $terms = get_the_terms($post->ID, 'trpropcity'); if($terms) foreach($terms as $term) echo '<a href="'.get_term_link($term, 'trpropcity').'">'.ucwords(strtolower($term->name)).'</a>'; ```
21,153
<p>Is there a plugin that makes external links open in new window, BUT only on the pages or domains or links I specify?</p>
[ { "answer_id": 21147, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 3, "selected": true, "text": "<p>Build the links yourself:</p>\n\n<pre><code>$terms = get_the_terms($post-&gt;ID, 'trpropcity');\nif($terms)\...
2011/06/27
[ "https://wordpress.stackexchange.com/questions/21153", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4088/" ]
Is there a plugin that makes external links open in new window, BUT only on the pages or domains or links I specify?
Build the links yourself: ``` $terms = get_the_terms($post->ID, 'trpropcity'); if($terms) foreach($terms as $term) echo '<a href="'.get_term_link($term, 'trpropcity').'">'.ucwords(strtolower($term->name)).'</a>'; ```
21,159
<p>I have my Reading settings set to Static pages and blog is set to a page called What's New.</p> <p>When I go to this What's New page I can see the post content but the post title with link to post page is not displaying. I can only see the post content.</p> <p>I have done everything I can think of to find the erro...
[ { "answer_id": 21147, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 3, "selected": true, "text": "<p>Build the links yourself:</p>\n\n<pre><code>$terms = get_the_terms($post-&gt;ID, 'trpropcity');\nif($terms)\...
2011/06/27
[ "https://wordpress.stackexchange.com/questions/21159", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2770/" ]
I have my Reading settings set to Static pages and blog is set to a page called What's New. When I go to this What's New page I can see the post content but the post title with link to post page is not displaying. I can only see the post content. I have done everything I can think of to find the error, with no luck, ...
Build the links yourself: ``` $terms = get_the_terms($post->ID, 'trpropcity'); if($terms) foreach($terms as $term) echo '<a href="'.get_term_link($term, 'trpropcity').'">'.ucwords(strtolower($term->name)).'</a>'; ```
21,163
<p>I am new in WordPress, I want to write short code with parameters in function. That is in </p> <pre><code>add_shortcode('short code name','function name','parameter1,parameter2'); </code></pre> <p>In <code>add_shortcode()</code>, I want to pass parameters and this must get in function used for creating short code....
[ { "answer_id": 21164, "author": "40XUserNotFound", "author_id": 5871, "author_profile": "https://wordpress.stackexchange.com/users/5871", "pm_score": 2, "selected": true, "text": "<p>According to <a href=\"http://codex.wordpress.org/Shortcode_API\" rel=\"nofollow\">the WordPress document...
2011/06/25
[ "https://wordpress.stackexchange.com/questions/21163", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I am new in WordPress, I want to write short code with parameters in function. That is in ``` add_shortcode('short code name','function name','parameter1,parameter2'); ``` In `add_shortcode()`, I want to pass parameters and this must get in function used for creating short code. Here is the function ``` function ...
According to [the WordPress documentation](http://codex.wordpress.org/Shortcode_API), "a minimal example of the PHP code required to create shortcode with attributes" is ``` // [bartag foo="foo-value"] function bartag_func( $atts ) { extract( shortcode_atts( array( 'foo' => 'something', 'bar' => 's...
21,172
<p>I am having vendor address field for each post using custom field plugin. In single post page.I want to generate bar code.When its scanned by mobile phone.It should display the address of the vendor in text format.</p> <p>Is there any existing plugin.Or any gold suggestions are appreciated.</p> <p>Thanks in advanc...
[ { "answer_id": 21175, "author": "Rev. Voodoo", "author_id": 3429, "author_profile": "https://wordpress.stackexchange.com/users/3429", "pm_score": 0, "selected": false, "text": "<p><a href=\"http://wordpress.org/extend/plugins/wcs-qr-code-generator/\" rel=\"nofollow\">http://wordpress.org...
2011/06/27
[ "https://wordpress.stackexchange.com/questions/21172", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4022/" ]
I am having vendor address field for each post using custom field plugin. In single post page.I want to generate bar code.When its scanned by mobile phone.It should display the address of the vendor in text format. Is there any existing plugin.Or any gold suggestions are appreciated. Thanks in advance !
No need for a plugin if you use the Google Chart tool api its very simple, i have a function that i wrote a while back: ``` /* * function to get QR code Image from google chart API * @Params: * $content - (string) the content to store inside the QR code (eg: url,address,string..) * $size - (string) the size of the QR...
21,174
<p>This seems to be an easy one but its giving me quite a hard time. <a href="http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail">get_the_post_thumbnail()</a> suppose to take attribute as an array. Well, everything working right but when i pass style attr its doesn't work. </p> <pre><code>$attr = arr...
[ { "answer_id": 21178, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 4, "selected": true, "text": "<p><code>get_the_post_thumbnail</code> attribute array doesn't know <code>STYLE</code> , the fields that are avai...
2011/06/27
[ "https://wordpress.stackexchange.com/questions/21174", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3094/" ]
This seems to be an easy one but its giving me quite a hard time. [get\_the\_post\_thumbnail()](http://codex.wordpress.org/Function_Reference/get_the_post_thumbnail) suppose to take attribute as an array. Well, everything working right but when i pass style attr its doesn't work. ``` $attr = array( ...
`get_the_post_thumbnail` attribute array doesn't know `STYLE` , the fields that are available for you to use are: * `src` * `class` * `alt` * `title` so just use the class and define you class to it: ``` $attr = array( 'title' => get_the_title(), 'alt' ...
21,181
<p>I have a custom post type called <code>video</code>. Would like to paginate its archive page, showing <strong>only 3 posts</strong> on each page.</p> <p>There is also a custom loop on the archive page that outputs <strong>all</strong> the video posts (for a thumbnail gallery).</p> <p>This is the <code>archive-vide...
[ { "answer_id": 21183, "author": "MartinJJ", "author_id": 3710, "author_profile": "https://wordpress.stackexchange.com/users/3710", "pm_score": 1, "selected": false, "text": "<p>Try <code>'paged' =&gt; $paged,</code> after <code>new WP_Query( array('post_type' =&gt; 'video',</code> and ch...
2011/06/27
[ "https://wordpress.stackexchange.com/questions/21181", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6524/" ]
I have a custom post type called `video`. Would like to paginate its archive page, showing **only 3 posts** on each page. There is also a custom loop on the archive page that outputs **all** the video posts (for a thumbnail gallery). This is the `archive-video.php`: ``` <?php while( have_posts() ) : the_post(); ?> ...
The code in the link you posted will (using `pre_get_posts`) will always change the number of posts\_per\_page to 3 if you are querying posts from that type. So a better solution would be to not use that code and simply above you code, before : `<?php while( have_posts() ) : the_post(); ?>` add: ``` if ( get_query_v...
21,191
<p>I have come across a problem whilst using the next_post_link() function. It seems that this function automatically echo's, for position reasons I need this to just return the link. Is there any available function or workaround that I can use to achieve this result?</p>
[ { "answer_id": 21194, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 2, "selected": false, "text": "<p>If you take a look at the source, <code>next_post_link</code> is just a wrapper for <code>adjacent_post_lin...
2011/06/27
[ "https://wordpress.stackexchange.com/questions/21191", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6529/" ]
I have come across a problem whilst using the next\_post\_link() function. It seems that this function automatically echo's, for position reasons I need this to just return the link. Is there any available function or workaround that I can use to achieve this result?
try to work with <http://codex.wordpress.org/Function_Reference/get_adjacent_post>; example: ``` $next_post_link_url = get_permalink( get_adjacent_post(false,'',false)->ID ); $prev_post_link_url = get_permalink( get_adjacent_post(false,'',true)->ID ); ```
21,217
<p>I have a normal textbox widget that I am using in certain sidebars. The text widget generates a div within a ul. Is there anyway to make the widget generate another ul li instead? </p> <pre><code>&lt;ul&gt;&lt;h3&gt;Heading&lt;/h3&gt; &lt;div class="textwidget"&gt; </code></pre>
[ { "answer_id": 21228, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 2, "selected": false, "text": "<p>check your <code>sidebar.php</code> and <code>functions.php</code> of the theme, the sidebar define the markup out...
2011/06/27
[ "https://wordpress.stackexchange.com/questions/21217", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1538/" ]
I have a normal textbox widget that I am using in certain sidebars. The text widget generates a div within a ul. Is there anyway to make the widget generate another ul li instead? ``` <ul><h3>Heading</h3> <div class="textwidget"> ```
check your `sidebar.php` and `functions.php` of the theme, the sidebar define the markup outside the widget; the function `register_sidebar()` defines the markup before content of the widgets; this markup you must change. See the codex for this function: [codex register\_sidebar()](http://codex.wordpress.org/Function_R...
21,218
<p>I have one stylesheet linked to my Wordpress page in header section:</p> <pre><code>&lt;link rel="stylesheet" type="text/css" href="&lt;?php bloginfo('template_directory'); ?&gt;/style.css" /&gt; </code></pre> <p>Now, I want to load different stylesheets on a few pages or sub-pages.</p> <p>What's the best/correct...
[ { "answer_id": 21219, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 3, "selected": true, "text": "<p>Don't use a shortcode for <code>wp_enqueue_style()</code>; it won't do any good, because by the time the sho...
2011/06/27
[ "https://wordpress.stackexchange.com/questions/21218", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1869/" ]
I have one stylesheet linked to my Wordpress page in header section: ``` <link rel="stylesheet" type="text/css" href="<?php bloginfo('template_directory'); ?>/style.css" /> ``` Now, I want to load different stylesheets on a few pages or sub-pages. What's the best/correct way of achieving this? I'm thinking about w...
Don't use a shortcode for `wp_enqueue_style()`; it won't do any good, because by the time the shortcode is parsed, all the relevant hooks ( `wp_head`, `wp_print_styles`) will have already fired. Write a function, in `functions.php`, to enqueue different style sheets based on `is_page( $id )` (where `$id` can be an ID,...
21,232
<p>I have the index.php in themes directory as my homepage. How can I confirm programmatically that the homepage was called in my functions.php? is_home() and is_front_page() is true for other pages and PHP_SELF always shows index.php.</p> <p>[More info]</p> <p>What I'm trying to do is show some Google Web Optimizer ...
[ { "answer_id": 21233, "author": "supertrue", "author_id": 3564, "author_profile": "https://wordpress.stackexchange.com/users/3564", "pm_score": 3, "selected": false, "text": "<p>If you are using the default home page, which in most cases is a list of most recent posts, is_home() should w...
2011/06/27
[ "https://wordpress.stackexchange.com/questions/21232", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3880/" ]
I have the index.php in themes directory as my homepage. How can I confirm programmatically that the homepage was called in my functions.php? is\_home() and is\_front\_page() is true for other pages and PHP\_SELF always shows index.php. [More info] What I'm trying to do is show some Google Web Optimizer Control scrip...
If you are using the default home page, which in most cases is a list of most recent posts, is\_home() should work. If you have set a static page to be your front page (in Settings >> Reading), is\_front\_page() should work. If you are not getting the results you expect using this: ``` if (is_front_page()) { //the ...
21,277
<p>Is there anyway to echo a function into a wordpress shortcode? heres my code:</p> <pre><code>&lt;div id="subscription"&gt; &lt;?php echo do_shortcode('[nggallery id=$ID]');?&gt; &lt;/div&gt; </code></pre> <p>$ID is a function that grabs a number generated in the url</p> <p>Thanks</p>
[ { "answer_id": 21266, "author": "mike23", "author_id": 1381, "author_profile": "https://wordpress.stackexchange.com/users/1381", "pm_score": 0, "selected": false, "text": "<p>I suggest you checkout some multilingual plugins for Wordpress. For example <a href=\"http://wpml.org/\" rel=\"no...
2011/06/27
[ "https://wordpress.stackexchange.com/questions/21277", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37920/" ]
Is there anyway to echo a function into a wordpress shortcode? heres my code: ``` <div id="subscription"> <?php echo do_shortcode('[nggallery id=$ID]');?> </div> ``` $ID is a function that grabs a number generated in the url Thanks
For example: I'm a Hungarian user, but my IP shows I'm in Germany while I use an English browser. The most convenient would be English for me, because that is my choice. There's a PHP superglobal variable, called `$_SERVER`. It stores information about the server running the page and about the client who requested the...
21,279
<p>Anyone know of a way to change the title of the core Wordpress metaboxes on a post edit screen? I'm trying to alter the title of the "Featured Image" metabox and have found a way to edit the contents (via *admin_post_thumbnail_html*) but not the title itself.</p>
[ { "answer_id": 21283, "author": "anmari", "author_id": 3569, "author_profile": "https://wordpress.stackexchange.com/users/3569", "pm_score": 1, "selected": false, "text": "<p>If, like me, you like things to work without js, you can provide your own text for ALL translateable text.</p>\n\...
2011/06/28
[ "https://wordpress.stackexchange.com/questions/21279", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
Anyone know of a way to change the title of the core Wordpress metaboxes on a post edit screen? I'm trying to alter the title of the "Featured Image" metabox and have found a way to edit the contents (via \*admin\_post\_thumbnail\_html\*) but not the title itself.
The "Right way" to do this is hooking to the 'add\_meta\_boxes' action, like so: ``` add_action('add_meta_boxes', 'my_metabox_titles', 10, 2); function my_metabox_titles($post_type, $post) { global $wp_meta_boxes; // array of defined metaboxes // cycle through the array, change the titles you want } ```
21,305
<p>I have a number of custom of post types - i.e. <code>'windows'</code>, <code>'doors'</code>, <code>'garages'</code></p> <p>and I want to load a custom template (<code>special.php</code>) whenever my wordpress site has a url that looks like this:</p> <pre><code>www.mysite.com/windows/ www.mysite.com/doors/ www.mysi...
[ { "answer_id": 21306, "author": "bingjie2680", "author_id": 6496, "author_profile": "https://wordpress.stackexchange.com/users/6496", "pm_score": 0, "selected": false, "text": "<p>move all your script in single.php to anthor template called say \"narmol.php\"</p>\n\n<p>and in the single....
2011/06/28
[ "https://wordpress.stackexchange.com/questions/21305", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4816/" ]
I have a number of custom of post types - i.e. `'windows'`, `'doors'`, `'garages'` and I want to load a custom template (`special.php`) whenever my wordpress site has a url that looks like this: ``` www.mysite.com/windows/ www.mysite.com/doors/ www.mysite.com/garages/ ``` I don't want to use pages, as it is not app...
I assume that your custom post type windows would map onto /windows/ etc? You can customise the template for individual custom post types via single-posttype.php in your theme, e.g. single-windows.php single-doors.php and single-garages.php Wordpress will automatically pick these up You could also use custom page tem...
21,315
<p>After adding support for a selection of post formats like this:</p> <pre><code>add_theme_support( 'post-formats', array( 'aside', 'video' ) ); </code></pre> <p>how can I then get the list of supported post formats back?</p> <p>I'm building a theme where the user can toggle support for postformat, and I want other...
[ { "answer_id": 21319, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 4, "selected": true, "text": "<p>Taken from <code>post_format_meta_box</code>;</p>\n\n<pre><code>if ( current_theme_supports( 'post-formats' ...
2011/06/28
[ "https://wordpress.stackexchange.com/questions/21315", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2071/" ]
After adding support for a selection of post formats like this: ``` add_theme_support( 'post-formats', array( 'aside', 'video' ) ); ``` how can I then get the list of supported post formats back? I'm building a theme where the user can toggle support for postformat, and I want other admin elements to reflect what p...
Taken from `post_format_meta_box`; ``` if ( current_theme_supports( 'post-formats' ) ) { $post_formats = get_theme_support( 'post-formats' ); if ( is_array( $post_formats[0] ) ) { print_r( $post_formats[0] ); // Array( supported_format_1, supported_format_2 ... ) } } ```
21,316
<p>the wordpress admin already uses some kind of toggle on the menu and on metaboxes.. w/ "Click to Toggle" buttons that remember the open versus closed state. Does anybody know what code is responible for this? I'd like to implement it into sections of my custom metaboxs, and it doesn't seem like I should need to add ...
[ { "answer_id": 21317, "author": "mike23", "author_id": 1381, "author_profile": "https://wordpress.stackexchange.com/users/1381", "pm_score": 1, "selected": false, "text": "<p>Checkout the HTML for a WP meta-box :</p>\n\n<pre><code>&lt;div id=\"my_div\" class=\"postbox \"&gt;\n &lt;div...
2011/06/28
[ "https://wordpress.stackexchange.com/questions/21316", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6477/" ]
the wordpress admin already uses some kind of toggle on the menu and on metaboxes.. w/ "Click to Toggle" buttons that remember the open versus closed state. Does anybody know what code is responible for this? I'd like to implement it into sections of my custom metaboxs, and it doesn't seem like I should need to add a s...
Checkout the HTML for a WP meta-box : ``` <div id="my_div" class="postbox "> <div class="handlediv" title="Click to toggle."><br></div> <h3 class="hndle"><span>title</span></h3> <div class="inside"> ... </div> </div> ``` If you follow that structure (and CSS classes) in your custom meta-box, ...
21,333
<p>I'm developing a theme which supports WordPress' post formats. As a result I am using a big if statement, which can be found below.</p> <ul> <li>I would like to link my post titles to the posts while maintaining my theme as XHTML valid.</li> <li>I would like to call images (with classes) in the if statement while ...
[ { "answer_id": 21336, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 2, "selected": true, "text": "<p>I don't know what you mean by \"call images\", but this will display the title as a link.</p>\n\n<pre><code>if ( has...
2011/06/28
[ "https://wordpress.stackexchange.com/questions/21333", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6565/" ]
I'm developing a theme which supports WordPress' post formats. As a result I am using a big if statement, which can be found below. * I would like to link my post titles to the posts while maintaining my theme as XHTML valid. * I would like to call images (with classes) in the if statement while maintaining my theme a...
I don't know what you mean by "call images", but this will display the title as a link. ``` if ( has_post_format( 'video' )) { ?><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a><?php the_excerpt(); } ```
21,334
<p>I have a few sites in a network. I don't want the site administrators to manage things like network plugins, but I would like them to be able to edit profiles of all network users, not use those on their site.</p> <p>At the top of the <code>/wp-admin/network/users.php</code> file is this:</p> <pre> if ( ! current_...
[ { "answer_id": 35065, "author": "Michael", "author_id": 10693, "author_profile": "https://wordpress.stackexchange.com/users/10693", "pm_score": 4, "selected": true, "text": "<p>Here's a solution that worked for me:</p>\n\n<p><a href=\"http://thereforei.am/2011/03/15/how-to-allow-administ...
2011/06/28
[ "https://wordpress.stackexchange.com/questions/21334", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4400/" ]
I have a few sites in a network. I don't want the site administrators to manage things like network plugins, but I would like them to be able to edit profiles of all network users, not use those on their site. At the top of the `/wp-admin/network/users.php` file is this: ``` if ( ! current_user_can( 'manage_network_...
Here's a solution that worked for me: <http://thereforei.am/2011/03/15/how-to-allow-administrators-to-edit-users-in-a-wordpress-network/> Pretty elegant and doesn't involve messing with core.
21,352
<p>Tearing my hair out a little bit here! I'm trying to create multiple image-selection boxes so users can upload as many images as they like to the species profile they've created.</p> <p>I'm using the following code in a .js file:</p> <p>jQuery(document).ready(function() {</p> <pre><code> var i = 2; jQuery...
[ { "answer_id": 21361, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 2, "selected": false, "text": "<pre><code>jQuery('a#add_media').click(function() {\n input_code = '&lt;p&gt;' +\n '&lt;input id=\"upload_im...
2011/06/28
[ "https://wordpress.stackexchange.com/questions/21352", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6344/" ]
Tearing my hair out a little bit here! I'm trying to create multiple image-selection boxes so users can upload as many images as they like to the species profile they've created. I'm using the following code in a .js file: jQuery(document).ready(function() { ``` var i = 2; jQuery('a#add_media').click(functi...
OK, I've made the changes Otto suggested and it's working nicely - thanks. ``` var uploadClickHandler = function() { str = jQuery(this).attr('id'); substring = str.substring(str.length, str.length - 1); id_to_pass = 'upload_image-' + substring; tb_show('', 'media-upload.php?type=image&amp;TB_iframe=tru...
21,353
<p>How I could made a sql query who retrieve all the sticky post in a wordpress database? This is because we use a new app over the old wordpress website database, and I don't know where Wordpress "store" the sticky attribute.</p> <p>Thanks in advance</p>
[ { "answer_id": 21354, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": true, "text": "<p>It's not stored as attribute, but as list of all stickies. Snippet from core:</p>\n\n<pre><code>$sticky_posts = get_o...
2011/06/28
[ "https://wordpress.stackexchange.com/questions/21353", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3251/" ]
How I could made a sql query who retrieve all the sticky post in a wordpress database? This is because we use a new app over the old wordpress website database, and I don't know where Wordpress "store" the sticky attribute. Thanks in advance
It's not stored as attribute, but as list of all stickies. Snippet from core: ``` $sticky_posts = get_option('sticky_posts'); ``` So look for the option and then use IDs to retrieve posts.
21,355
<p>Im trying to remove / filter our all the classes from the wp_nav_menu, EXCEPT the custom ones that i insert (in the "CSS Classes (optional)" field) when creating the menu in the admin.</p> <p>I found a function that removes EVERYTHING, but thats no good</p> <p>anybody got any ideas?</p> <p>thanks!</p>
[ { "answer_id": 23749, "author": "fad.lee", "author_id": 4967, "author_profile": "https://wordpress.stackexchange.com/users/4967", "pm_score": 1, "selected": false, "text": "<p>I'm trying to answer.</p>\n\n<p>The function that responsible to generate classes for menu items is <code>_wp_me...
2011/06/28
[ "https://wordpress.stackexchange.com/questions/21355", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6574/" ]
Im trying to remove / filter our all the classes from the wp\_nav\_menu, EXCEPT the custom ones that i insert (in the "CSS Classes (optional)" field) when creating the menu in the admin. I found a function that removes EVERYTHING, but thats no good anybody got any ideas? thanks!
One of the darker corners of the code. :) Here is my take: ``` add_filter('nav_menu_css_class', 'discard_menu_classes', 10, 2); function discard_menu_classes($classes, $item) { return (array)get_post_meta( $item->ID, '_menu_item_classes', true ); } ```
21,366
<p>How can I build a query to find posts that DO NOT contain a certain meta key or meta value? </p> <p>for example:</p> <pre><code>query_posts( array( 'meta_query' =&gt; array( array( 'key' =&gt; 'feature', 'value' =&gt; '_wp_zero_value', 'compare' =&gt; '!=' ) ) ) ); </code></pre>
[ { "answer_id": 21369, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 4, "selected": true, "text": "<p>Getting posts without a certain meta <em>key</em> is a little tricky, namely due to the database design and ...
2011/06/28
[ "https://wordpress.stackexchange.com/questions/21366", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4229/" ]
How can I build a query to find posts that DO NOT contain a certain meta key or meta value? for example: ``` query_posts( array( 'meta_query' => array( array( 'key' => 'feature', 'value' => '_wp_zero_value', 'compare' => '!=' ) ) ) ); ```
Getting posts without a certain meta *key* is a little tricky, namely due to the database design and the nature of SQL joins. AFAIK, the most efficient way would be to actually grab the post IDs that *do* have the meta key, and then exclude them from your query. ``` // get all post IDs that *have* 'meta_key' with a n...
21,379
<p>Yo, Sidebar login used to say "Welcome %username%" without a problem until I applied __() to the "Welcome" string. Since then the welcome message just says "Welcome" (in all languages) but i can't bring that username back in there to save my life. What am I doing wrong? Here's how it looks:</p> <p>function widget_...
[ { "answer_id": 21388, "author": "Ramkumar M", "author_id": 5669, "author_profile": "https://wordpress.stackexchange.com/users/5669", "pm_score": -1, "selected": false, "text": "<p>I Don't know about your codings.but i have another one suggestion.just try to install plugin and welcome you...
2011/06/29
[ "https://wordpress.stackexchange.com/questions/21379", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6436/" ]
Yo, Sidebar login used to say "Welcome %username%" without a problem until I applied \_\_() to the "Welcome" string. Since then the welcome message just says "Welcome" (in all languages) but i can't bring that username back in there to save my life. What am I doing wrong? Here's how it looks: function widget\_wp\_sid...
Change ``` $user_info->user_login ``` To ``` $current_user->login ```
21,383
<p>Hey guys i recently created a theme. I want to show home.php when a visitor visit home page but all my blog posts are listed in index.php file. Can someone suggest me how to display index.php i tried <a href="http://www.mysiteurl.com/index.php" rel="nofollow">http://www.mysiteurl.com/index.php</a> but it redirecting...
[ { "answer_id": 21388, "author": "Ramkumar M", "author_id": 5669, "author_profile": "https://wordpress.stackexchange.com/users/5669", "pm_score": -1, "selected": false, "text": "<p>I Don't know about your codings.but i have another one suggestion.just try to install plugin and welcome you...
2011/06/29
[ "https://wordpress.stackexchange.com/questions/21383", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5074/" ]
Hey guys i recently created a theme. I want to show home.php when a visitor visit home page but all my blog posts are listed in index.php file. Can someone suggest me how to display index.php i tried <http://www.mysiteurl.com/index.php> but it redirecting me to <http://www.mysiteurl.com/home.php> Please advise me. Than...
Change ``` $user_info->user_login ``` To ``` $current_user->login ```
21,399
<p>I installed the <a href="http://wordpress.org/extend/plugins/wp-system-health/" rel="nofollow">Wordpress System Health Plugin</a> and it says that the revisions table in my database is at 70% capacity with 994 rows. I don't fully understand what this means. I anticipate that my site will get much larger than it is...
[ { "answer_id": 21403, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 1, "selected": false, "text": "<p>Is it possible it's telling you that 994 rows equal 70% of the total data in your database? I'm not sure what \"70%...
2011/06/29
[ "https://wordpress.stackexchange.com/questions/21399", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2107/" ]
I installed the [Wordpress System Health Plugin](http://wordpress.org/extend/plugins/wp-system-health/) and it says that the revisions table in my database is at 70% capacity with 994 rows. I don't fully understand what this means. I anticipate that my site will get much larger than it is today. Questions * Am I goin...
SQL query to run via phpmyadmin ``` DELETE a,b,c FROM wp_posts a LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id) LEFT JOIN wp_postmeta c ON (a.ID = c.post_id) WHERE a.post_type = 'revision' ``` That query will remove all post revisions from your wp database,, **But remember always back up your database ...
21,411
<p>I can't see to get it. The capabilities fail to appear when using plugins like "Capability Manager" or "Members" to view a list of available capabilities.</p> <p>This is the code I'm attempting to use:</p> <pre><code>add_action( 'init', 'register_taxonomy_spot_tag' ); function register_taxonomy_spot_tag() { ...
[ { "answer_id": 21413, "author": "MartinJJ", "author_id": 3710, "author_profile": "https://wordpress.stackexchange.com/users/3710", "pm_score": 1, "selected": false, "text": "<p>Try using add_cap .... <a href=\"http://www.garyc40.com/2010/04/ultimate-guide-to-roles-and-capabilities/#add-...
2011/06/29
[ "https://wordpress.stackexchange.com/questions/21411", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1226/" ]
I can't see to get it. The capabilities fail to appear when using plugins like "Capability Manager" or "Members" to view a list of available capabilities. This is the code I'm attempting to use: ``` add_action( 'init', 'register_taxonomy_spot_tag' ); function register_taxonomy_spot_tag() { $labels = array( ...
Try using add\_cap .... [**adding new capability**](http://www.garyc40.com/2010/04/ultimate-guide-to-roles-and-capabilities/#add-capability) and creating the capability first in functions.php, i cant locate anything that says capabilities can be created in registering a taxonomy, but you can certainly assign them there...
21,414
<p>I notice that theres invalid markup in my shortcode. Its ok if I disable <code>wpautop</code> tho</p> <pre><code>function shortcode_banner($attrs, $content = '') { echo ' --- ' . $content . ' --- '; $html = '&lt;section id="banner"&gt;&lt;div class="wrap"&gt;' . do_shortcode($content) . '&lt;/div&gt;&lt;/se...
[ { "answer_id": 21429, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 1, "selected": false, "text": "<p>Try this:</p>\n\n<pre><code>// replaces [banner ...] .. [/banner] with &lt;!--banner ID--&gt; before the_co...
2011/06/29
[ "https://wordpress.stackexchange.com/questions/21414", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3788/" ]
I notice that theres invalid markup in my shortcode. Its ok if I disable `wpautop` tho ``` function shortcode_banner($attrs, $content = '') { echo ' --- ' . $content . ' --- '; $html = '<section id="banner"><div class="wrap">' . do_shortcode($content) . '</div></section>'; die($html); } ``` When autop is...
Try this: ``` // replaces [banner ...] .. [/banner] with <!--banner ID--> before the_content filters run add_filter('the_content', 'protect_my_shortcode', -100); function protect_my_shortcode($content){ return preg_replace_callback('/\[(banner)\b(.*?)(?:(\/))?\](.+?)\[\/\1\]/s', 'protect_my_shortcode_callback', $con...
21,417
<p>If I disable autop entirely, I need to add <code>&lt;p&gt;</code> everywhere I want a paragraph. Is it possibe to disable autop temporarily? Like in a shortcode</p>
[ { "answer_id": 40096, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 1, "selected": false, "text": "<p>yes, you can deactivate the autop for shortcode via filter</p>\n\n<pre><code>add_filter( 'the_content', 'shortcode...
2011/06/29
[ "https://wordpress.stackexchange.com/questions/21417", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3788/" ]
If I disable autop entirely, I need to add `<p>` everywhere I want a paragraph. Is it possibe to disable autop temporarily? Like in a shortcode
yes, you can deactivate the autop for shortcode via filter ``` add_filter( 'the_content', 'shortcode_unautop' ); ```
21,418
<p>I have page called "Apple", the page's ID id 2533.</p> <p>In page.php file I have line:</p> <pre><code>echo $bannerimg </code></pre> <p>And this function in functions.php:</p> <pre><code>if ( is_page( '2533' ) ) { // also tested with 'Apple' $bannerimg = 'apple.jpg'; } elseif ( is_page( 'test' ) ) ...
[ { "answer_id": 21419, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 5, "selected": true, "text": "<p><code>functions.php</code> is processed way before you can know which page is being loaded. Instead of assigning valu...
2011/06/29
[ "https://wordpress.stackexchange.com/questions/21418", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1869/" ]
I have page called "Apple", the page's ID id 2533. In page.php file I have line: ``` echo $bannerimg ``` And this function in functions.php: ``` if ( is_page( '2533' ) ) { // also tested with 'Apple' $bannerimg = 'apple.jpg'; } elseif ( is_page( 'test' ) ) { $bannerimg = 'test.jpg'; } elseif...
`functions.php` is processed way before you can know which page is being loaded. Instead of assigning value to variable put your code into function and use that function in `page.php` template.
21,427
<p>I want to get all featured items using query post. featured is meta_key using custom field plugin.</p> <p>I tried bellow,but it failed</p> <pre><code>$featured_item = new WP_Query('posts_per_page=-1&amp;cat=3&amp;meta_key=&gt;Featured List&amp;meta_value=&gt;Yes'); </code></pre> <p>my wp version is 3.1.3</p> <p>...
[ { "answer_id": 21430, "author": "anu", "author_id": 490, "author_profile": "https://wordpress.stackexchange.com/users/490", "pm_score": 1, "selected": false, "text": "<p>The documentation for WP_Query is here: <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Pa...
2011/06/29
[ "https://wordpress.stackexchange.com/questions/21427", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4022/" ]
I want to get all featured items using query post. featured is meta\_key using custom field plugin. I tried bellow,but it failed ``` $featured_item = new WP_Query('posts_per_page=-1&cat=3&meta_key=>Featured List&meta_value=>Yes'); ``` my wp version is 3.1.3 **EDIT:** ``` $arg2 = array( 'posts_per_page'=>'5', ...
Your `meta_query` needs to be a *nested* array, like so; ``` $args = array( 'posts_per_page' => '5', 'cat' => '3', 'orderby' => 'rand', 'meta_query' => array( array( 'key' => 'Featured List', 'value' => 'Yes' ) ) ); ``` And I get the feeling you do...
21,431
<p>I'm using a script that is based on jQuery, so I'm not enqueue-ing jQuery directly, but via passing it in the array of dependent scripts:</p> <pre><code> wp_enqueue_script("jquery-plugin-name",'http://hostname.il/blogname/wp-content/themes/twentyten/js/jquery-plugin-name.js', array('jquery'), '1'); </code></pre> <...
[ { "answer_id": 21433, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 3, "selected": true, "text": "<p>That's the size of the minified jQuery nowadays :)</p>\n\n<p>You can load the latest from Google:</p>\n\n<pr...
2011/06/29
[ "https://wordpress.stackexchange.com/questions/21431", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/373/" ]
I'm using a script that is based on jQuery, so I'm not enqueue-ing jQuery directly, but via passing it in the array of dependent scripts: ``` wp_enqueue_script("jquery-plugin-name",'http://hostname.il/blogname/wp-content/themes/twentyten/js/jquery-plugin-name.js', array('jquery'), '1'); ``` This is loading jQuery v...
That's the size of the minified jQuery nowadays :) You can load the latest from Google: ``` wp_deregister_script('jquery'); wp_register_script('jquery', ("http://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js"), false, '1.8.2'); ``` Please keep in mind that this can cause issues moving forward, as you are...
21,432
<p>I'd like to have a query that returns posts grouped five by five. </p> <p>Right now I have a simple query loop like this one :</p> <pre><code>&lt;?php if( $query-&gt;have_posts() ) : ?&gt; &lt;ul class="posts"&gt; &lt;?php while ( $query-&gt;have_posts() ) : $query-&gt;the_post(); ?&gt; &lt...
[ { "answer_id": 21435, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": true, "text": "<p>you can create a simple counter and condition:</p>\n\n<pre><code> &lt;?php $count = 0; ?&gt;\n &lt;?php if(...
2011/06/29
[ "https://wordpress.stackexchange.com/questions/21432", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1381/" ]
I'd like to have a query that returns posts grouped five by five. Right now I have a simple query loop like this one : ``` <?php if( $query->have_posts() ) : ?> <ul class="posts"> <?php while ( $query->have_posts() ) : $query->the_post(); ?> <li> <?php the_title(); ?> ...
you can create a simple counter and condition: ``` <?php $count = 0; ?> <?php if( $query->have_posts() ) : ?> <ul class="posts"> <?php while ( $query->have_posts() ) : $query->the_post(); if ($count < 5){ ?> <li> <?php the_title(...
21,436
<p>I prefer not to use asterisk markers on required fields in the comment form.</p> <p>So I'd like to remove or alter the 'required fields are marked (*)' message. </p> <p>Being a good wordpress user, I'd like to do it with my functions.php. I can work out how to filter most areas of the form, but not this. I'm guess...
[ { "answer_id": 21435, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": true, "text": "<p>you can create a simple counter and condition:</p>\n\n<pre><code> &lt;?php $count = 0; ?&gt;\n &lt;?php if(...
2011/06/29
[ "https://wordpress.stackexchange.com/questions/21436", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1692/" ]
I prefer not to use asterisk markers on required fields in the comment form. So I'd like to remove or alter the 'required fields are marked (\*)' message. Being a good wordpress user, I'd like to do it with my functions.php. I can work out how to filter most areas of the form, but not this. I'm guessing it will invo...
you can create a simple counter and condition: ``` <?php $count = 0; ?> <?php if( $query->have_posts() ) : ?> <ul class="posts"> <?php while ( $query->have_posts() ) : $query->the_post(); if ($count < 5){ ?> <li> <?php the_title(...
21,459
<p>could you figure out why I'm unable to get shortcode filters applied in ajax inclusion of posts?</p> <p>Let me explain better: I've managed to include a post from within another post, through <strong>admin-ajax.php</strong>, as recommended in the famous <a href="http://www.garyc40.com/2010/03/5-tips-for-using-ajax-...
[ { "answer_id": 21461, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 2, "selected": false, "text": "<p>When WordPress displays post content, it's not running <code>do_shortcode()</code> on the post content, it's running ...
2011/06/29
[ "https://wordpress.stackexchange.com/questions/21459", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6606/" ]
could you figure out why I'm unable to get shortcode filters applied in ajax inclusion of posts? Let me explain better: I've managed to include a post from within another post, through **admin-ajax.php**, as recommended in the famous [5 tips](http://www.garyc40.com/2010/03/5-tips-for-using-ajax-in-wordpress/). Obviou...
Awww... in **admin-ajax.php**: ``` define('WP_ADMIN', true); ``` in **cleaner-gallery.php**: ``` function cleaner_gallery_setup() { if ( is_admin() ) { require_once( CLEANER_GALLERY_DIR . 'admin.php' ); } else { require_once( CLEANER_GALLERY_DIR . 'gallery.php' ); } } ``` So I have...
21,470
<p>In the multi-site wordpress install, you get a very nice "upload settings" in the network admin settings. (see attached image).</p> <p>I am trying to change these settings without using php.ini for a single-site wordpress install and I can't find them anywhere... help?</p> <p>Tim</p> <p>Attached: Network Admin S...
[ { "answer_id": 21545, "author": "Lea Cohen", "author_id": 373, "author_profile": "https://wordpress.stackexchange.com/users/373", "pm_score": 0, "selected": false, "text": "<p>Maybe this thread can help you? <a href=\"http://wordpress.org/support/topic/how-do-i-change-my-upload-limit?rep...
2011/06/29
[ "https://wordpress.stackexchange.com/questions/21470", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5861/" ]
In the multi-site wordpress install, you get a very nice "upload settings" in the network admin settings. (see attached image). I am trying to change these settings without using php.ini for a single-site wordpress install and I can't find them anywhere... help? Tim Attached: Network Admin Settings Example: ![Networ...
create an file `php.ini` and copy via ftp or ssh to wp-admin; inside this file the follow values; play with values for test and see the result. ``` memory_limit = 32M upload_max_filesize = 32M post_max_size = 32M file_uploads = On ```
21,474
<p>When I add an image to a post I want it to be in a div e.g. , and I want that to be done automatically, so I don't have to do that in HTML editor. I don't want to use js to accomplish this and by the way I want to know how to automatically add custom classes to a image in a post. Cheers!</p>
[ { "answer_id": 21480, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 3, "selected": true, "text": "<p>By default images already have unique class's but this depends on your theme. Use firebug and hover over the images ...
2011/06/29
[ "https://wordpress.stackexchange.com/questions/21474", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6609/" ]
When I add an image to a post I want it to be in a div e.g. , and I want that to be done automatically, so I don't have to do that in HTML editor. I don't want to use js to accomplish this and by the way I want to know how to automatically add custom classes to a image in a post. Cheers!
By default images already have unique class's but this depends on your theme. Use firebug and hover over the images and you should see stuff like `class="aligncenter size-full wp-image-1525"`. If you want to change the class or id or alter any attributes of the image you can use the `get_image_tag` filter. For exampl...
21,483
<p>I created my own custom Wordpress theme for my website, everything is great. However, I have a strange need, I have one category which is kind of a 'placeholder' for content which is automated and used by an automated background process. Each time this process finds new content to put into that category I end up wit...
[ { "answer_id": 21489, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>The only solution I could imagine is <em>removing, rewriting, replacing</em> the meta box.</p>\n\n<pre><code>// Fir...
2011/06/29
[ "https://wordpress.stackexchange.com/questions/21483", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6610/" ]
I created my own custom Wordpress theme for my website, everything is great. However, I have a strange need, I have one category which is kind of a 'placeholder' for content which is automated and used by an automated background process. Each time this process finds new content to put into that category I end up with a...
The only solution I could imagine is *removing, rewriting, replacing* the meta box. ``` // First remove the original one function wpse21483_remove_catbox() { remove_meta_box( 'post_categories_meta_box', 'post', 'side' ); } add_action( 'admin_menu', 'wpse21483_remove_catbox' ); // not sure about the hook function ...
21,487
<p>I'm currently displaying custom taxonomies in a drop down menu. Each taxonomy has its own little wrapper in the sidebar. Is it possible to move the taxonomy to <em>inside</em> of my custom write box for ease-of-use purposes?</p> <p><img src="https://i.stack.imgur.com/0jApe.png" alt="enter image description here"></...
[ { "answer_id": 21490, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 4, "selected": true, "text": "<p>The following is taken from a \"move author to publish box\" task, but it should give you a starting point. Next you...
2011/06/29
[ "https://wordpress.stackexchange.com/questions/21487", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1057/" ]
I'm currently displaying custom taxonomies in a drop down menu. Each taxonomy has its own little wrapper in the sidebar. Is it possible to move the taxonomy to *inside* of my custom write box for ease-of-use purposes? ![enter image description here](https://i.stack.imgur.com/0jApe.png)
The following is taken from a "move author to publish box" task, but it should give you a starting point. Next you should take a look at "/wp-admin/edit-form-advanced.php" where you'll find something about `get_object_taxonomies()` to see how your stuff get's named, so you can remove and add stuff. ``` function wpse_r...
21,505
<p>I've just created a rewrite rules to integrate pagination in my page music (displaying custom post_type "music") in order to : 1. displaying a specific page from a long musical playlist. 2. in this page, playing a specified track</p> <p>Here is the rule for pagination :</p> <p><code>add_rewrite_rule('music/page/(...
[ { "answer_id": 41546, "author": "Yoav Aner", "author_id": 4741, "author_profile": "https://wordpress.stackexchange.com/users/4741", "pm_score": 0, "selected": false, "text": "<p>hard to tell without looking closer at your code, but I have a sneaky suspicion it might somehow relate to the...
2011/06/29
[ "https://wordpress.stackexchange.com/questions/21505", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6550/" ]
I've just created a rewrite rules to integrate pagination in my page music (displaying custom post\_type "music") in order to : 1. displaying a specific page from a long musical playlist. 2. in this page, playing a specified track Here is the rule for pagination : `add_rewrite_rule('music/page/([0-9])+/([^/]+)/?', '...
I believe this problem is less to do with the rewrite rule, which on the face of it looks like it should work, and more to do with WordPress' canonical redirect. Basically when WordPress receives an url - it interprets it as a query. It then looks again at the url to check that the url is 'correct' (or canonical). For...
21,507
<p>I'm one of the contributors for the Meta Box Class here on Github (<a href="https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress">link</a>) and before I get too deep, I wanted to ask if anyone knew of a straight forward way to allow users to add additional fields "on the fly", having an "add" butto...
[ { "answer_id": 21511, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 2, "selected": true, "text": "<p>Agreed, I've seen it too, but I don't think there's any readily available API or method.</p>\n\n<p>For me, I...
2011/06/29
[ "https://wordpress.stackexchange.com/questions/21507", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/403/" ]
I'm one of the contributors for the Meta Box Class here on Github ([link](https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress)) and before I get too deep, I wanted to ask if anyone knew of a straight forward way to allow users to add additional fields "on the fly", having an "add" button with a text ...
Agreed, I've seen it too, but I don't think there's any readily available API or method. For me, I use a lick of jQuery; ``` <input type="text" class="list-item" name="list_items[]" /> <input type="button" class="button-secondary" id="add-list" /> <script type="text/javascript"> ( function( $ ) { $( '#ad...
21,508
<p>I just created a web page that uses a lot of JavaScript to build a fancy form that helps build an build the object/html behind an mp3 player for a user. I got it working and tested in a plain-html page outside of WordPress. </p> <p>I then copied into a WordPress "page", took out the &lt;head&gt; tag, changed &lt;b...
[ { "answer_id": 21510, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 2, "selected": true, "text": "<p>You'd be much better off <a href=\"http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates\" rel=\...
2011/06/29
[ "https://wordpress.stackexchange.com/questions/21508", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2550/" ]
I just created a web page that uses a lot of JavaScript to build a fancy form that helps build an build the object/html behind an mp3 player for a user. I got it working and tested in a plain-html page outside of WordPress. I then copied into a WordPress "page", took out the <head> tag, changed <body> to a <div>, but...
You'd be much better off [creating a custom page template](http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates), pasting your HTML into the file, then simply attaching the template to a page in the admin. WordPress applies a lot of filtering on post/page *content*, and it's probably wreaking havoc with y...
21,516
<p>I've recently been redesigning a site for a college radio, switching from Drupal to Wordpress from scratch. The site is based on the radio station, but each specialty show will also have its own blog. However, I want the layout to be the same from the main content to each blog. Categories more or less work, but thin...
[ { "answer_id": 21527, "author": "Murilo", "author_id": 6619, "author_profile": "https://wordpress.stackexchange.com/users/6619", "pm_score": 0, "selected": false, "text": "<p>Categories is ok for one blog, but if you have more, then multisite is the best option. It's easy to setup the th...
2011/06/29
[ "https://wordpress.stackexchange.com/questions/21516", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6617/" ]
I've recently been redesigning a site for a college radio, switching from Drupal to Wordpress from scratch. The site is based on the radio station, but each specialty show will also have its own blog. However, I want the layout to be the same from the main content to each blog. Categories more or less work, but things ...
Categories are meta data for n:n relations: Each category can be related to multiple posts, and each post to multiple categories. So categories aren’t what you need. I would set up a multi site installation. Use the main site for everything related to all sub sites and the subdomains or sub blogs for each section. To...
21,543
<p>What are the best practices for using post_id? Can I use this safely in my templates to call specific posts, or will these post_id's ever change?</p> <p>The reason I ask is that randomly today the post_id's changed on my site, and I'm wondering what could have caused it. It didn't mess up any of the permalinks (t...
[ { "answer_id": 28586, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 1, "selected": true, "text": "<p>Post ID's do not change. The reason behind this is the ID column in MYSQL is the primary key for the table. ...
2011/06/30
[ "https://wordpress.stackexchange.com/questions/21543", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5861/" ]
What are the best practices for using post\_id? Can I use this safely in my templates to call specific posts, or will these post\_id's ever change? The reason I ask is that randomly today the post\_id's changed on my site, and I'm wondering what could have caused it. It didn't mess up any of the permalinks (thankfully...
Post ID's do not change. The reason behind this is the ID column in MYSQL is the primary key for the table. It is auto incremented when a new row is added. It is improbable that a post ID would change programatically unless someone is doing something rogue in the database.
21,546
<p>We would like to know that how we occur error when we implement this code in our sidebar.php</p> <pre><code>$categories = get_categories(); foreach($categories as $category) { printf('&lt;h2&gt;%s&lt;/h2&gt;&lt;ul&gt;', $category-&gt;cat_name); $posts = new WP_Query('cat='.$category-&gt;cat_ID); while($pos...
[ { "answer_id": 21551, "author": "Ramkumar M", "author_id": 5669, "author_profile": "https://wordpress.stackexchange.com/users/5669", "pm_score": 0, "selected": false, "text": "<p>hi rodger,</p>\n\n<pre><code> $query = new WP_Query( array( 'meta_key' =&gt; 'Old ID', 'meta_value' =&gt; $a...
2011/06/30
[ "https://wordpress.stackexchange.com/questions/21546", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6624/" ]
We would like to know that how we occur error when we implement this code in our sidebar.php ``` $categories = get_categories(); foreach($categories as $category) { printf('<h2>%s</h2><ul>', $category->cat_name); $posts = new WP_Query('cat='.$category->cat_ID); while($posts->have_posts()) { $posts-...
a possible conflict with the name `$posts` which is used by wp core; try, for instance: ``` $categories = get_categories(); foreach($categories as $category) { printf('<h2>%s</h2><ul>', $category->cat_name); $cat_posts = new WP_Query('cat='.$category->cat_ID); while($cat_posts->have_posts()) {...
21,549
<p>I want to change the search URL from <code>example.com/search/keyword</code> to <code>example.com/result</code> or <code>topic/keyword</code>.</p>
[ { "answer_id": 21594, "author": "Ramkumar M", "author_id": 5669, "author_profile": "https://wordpress.stackexchange.com/users/5669", "pm_score": -1, "selected": false, "text": "<p>Just install this plugin, <a href=\"http://wordpress.org/extend/plugins/search-permalink/\" rel=\"nofollow\"...
2011/06/30
[ "https://wordpress.stackexchange.com/questions/21549", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6626/" ]
I want to change the search URL from `example.com/search/keyword` to `example.com/result` or `topic/keyword`.
You can change the `/search/` part to something else, like `/topic/`, but it will be harder to remove it completely, since that will conflict with WordPress Pages (is `/banana/` a Page with the title "Banana" or is it the result page for the search term "Banana"?). To change the part, hook into the `init` action and c...
21,556
<p>I looked at the included scripts in WordPress (<a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script" rel="nofollow"><code>wp_enqueue_script</code></a>) and didnt find what I should include to use jQuery UI Autocomplete</p> <p>I am using it in the admin area. Should I just include jQuery UI from ...
[ { "answer_id": 21567, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": 0, "selected": false, "text": "<p>I'm just beginning to play around with registering scripts, adding my own etc. I believe it's OK to use the...
2011/06/30
[ "https://wordpress.stackexchange.com/questions/21556", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3788/" ]
I looked at the included scripts in WordPress ([`wp_enqueue_script`](http://codex.wordpress.org/Function_Reference/wp_enqueue_script)) and didnt find what I should include to use jQuery UI Autocomplete I am using it in the admin area. Should I just include jQuery UI from Google CDN? I think it will conflict with WordP...
The jQuery autocomplete is not come with WP package. So you have to download this component from jQuery UI and enqueue it for use. Using jQuery UI at Google CDN also works, but in my opinion, that's not very good, because you will load whole the jQuery UI lib while you need only **one** component. This is the code I u...
21,563
<p>I would like to know why we get an error when we implement this code in our <code>sidebar.php</code>:</p> <pre><code>$categories = get_categories(); foreach($categories as $category) { printf('&lt;h2&gt;%s&lt;/h2&gt;&lt;ul&gt;', $category-&gt;cat_name); $posts = new WP_Query('cat='.$category-&gt;cat_ID); w...
[ { "answer_id": 21564, "author": "bingjie2680", "author_id": 6496, "author_profile": "https://wordpress.stackexchange.com/users/6496", "pm_score": 1, "selected": false, "text": "<p>sometimes, probably if you have two queries in one page, you need to reset the query data, try to insert the...
2011/06/30
[ "https://wordpress.stackexchange.com/questions/21563", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6624/" ]
I would like to know why we get an error when we implement this code in our `sidebar.php`: ``` $categories = get_categories(); foreach($categories as $category) { printf('<h2>%s</h2><ul>', $category->cat_name); $posts = new WP_Query('cat='.$category->cat_ID); while($posts->have_posts()) { $posts->t...
I was having a similar error when using a WP\_Query as given at <https://wordpress.stackexchange.com/a/42334/16898>. I replaced the variable name $posts with an arbitrary name $mposts and the error was gone.
21,574
<p>Is there a way to wrap a wordpress shortcode around a div in a template file? Here is my code:</p> <pre><code>&lt;div id="subscription"&gt; &lt;?php do_shortcode('[subscribe]');?&gt; &lt;p&gt;This is subscription text&lt;/p&gt; &lt;/div&gt; </code></pre> <p>I've also tried</p> <pre><code>&lt;div id="subscription"...
[ { "answer_id": 21575, "author": "Femi", "author_id": 6634, "author_profile": "https://wordpress.stackexchange.com/users/6634", "pm_score": 2, "selected": true, "text": "<p>If by template file you mean a php file in the themes folder, you can call <a href=\"http://codex.wordpress.org/Func...
2011/06/29
[ "https://wordpress.stackexchange.com/questions/21574", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37920/" ]
Is there a way to wrap a wordpress shortcode around a div in a template file? Here is my code: ``` <div id="subscription"> <?php do_shortcode('[subscribe]');?> <p>This is subscription text</p> </div> ``` I've also tried ``` <div id="subscription"> <?php do_shortcode('[subscribe]');?> <p>This is subscription text</p...
If by template file you mean a php file in the themes folder, you can call [do\_shortcode](http://codex.wordpress.org/Function_Reference/do_shortcode) to have the shortcode processor do its magic on your div. EDIT: not entirely sure I understand what you want, but you could try this: ``` <div id="subscription"> <?php...
21,581
<p>On my author page I currently have a list of categories the author has posted in generated by the following code:</p> <pre><code>&lt;?php $categories = $wpdb-&gt;get_results(" SELECT DISTINCT(terms.term_id) as ID, terms.name, terms.slug FROM $wpdb-&gt;posts as posts LEFT JOIN $wpdb-&gt;term_relationship...
[ { "answer_id": 21588, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 0, "selected": false, "text": "<p>why not use <a href=\"http://codex.wordpress.org/Template_Tags/wp_list_categories\" rel=\"nofollow\"><code>...
2011/06/30
[ "https://wordpress.stackexchange.com/questions/21581", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3670/" ]
On my author page I currently have a list of categories the author has posted in generated by the following code: ``` <?php $categories = $wpdb->get_results(" SELECT DISTINCT(terms.term_id) as ID, terms.name, terms.slug FROM $wpdb->posts as posts LEFT JOIN $wpdb->term_relationships as relationships ON post...
you can try a much less elegant but a working solution which is to get all of the users posts and count their categories: ``` $query = new WP_Query(array( 'author' => $curauth->ID, 'posts_per_page' => -1 ) ); if ($query->have_posts()){ $u_cats = array(); while ($query->have_posts()){ $q...
21,586
<p>I need WP to show an embedded representation of a url such as <a href="http://domain.com/1121" rel="nofollow">http://domain.com/1121</a> using oembed.</p> <p>I have setup <a href="http://domain.com/1121" rel="nofollow">http://domain.com/1121</a> with a discovery link:</p> <pre><code>&lt;link href="http://www.domai...
[ { "answer_id": 21597, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 2, "selected": false, "text": "<p>Two things:</p>\n\n<ol>\n<li><p>WordPress' oEmbed implementation prefers and works better with JSON.</p></li>\n<li>...
2011/06/30
[ "https://wordpress.stackexchange.com/questions/21586", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6632/" ]
I need WP to show an embedded representation of a url such as <http://domain.com/1121> using oembed. I have setup <http://domain.com/1121> with a discovery link: ``` <link href="http://www.domain.com/generator/oembed/?url=http%3A//domain.com/1121" rel="alternate" type="text/xml+oembed" /> ``` I'm aware that WP no l...
Your XML root element was 'OEmbed', not 'oembed', as given in the spec. XML element names are case-sensitive, per the XML spec.
21,589
<p>I am trying to outline a new project where I want to give my users the ability to customize their 'profile' pages in my website theme. Concepts like adding in their own background images, choosing templates etc.</p> <p>It seemed logical to me to store this information in the author meta, as that seems to be the onl...
[ { "answer_id": 21601, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p><code>/wp-admin/user-edit.php</code>: <code>do_action( 'show_user_profile', $profileuser );</code>. Try hooking you...
2011/06/30
[ "https://wordpress.stackexchange.com/questions/21589", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/370/" ]
I am trying to outline a new project where I want to give my users the ability to customize their 'profile' pages in my website theme. Concepts like adding in their own background images, choosing templates etc. It seemed logical to me to store this information in the author meta, as that seems to be the only table th...
Authors are rather simple content objects in WordPress. They have [roles and capabilities](http://codex.wordpress.org/Roles_and_Capabilities), some basic meta data and their own edit screens. That’s it pretty much. If you want to add a custom taxonomy to authors you have to mirror each user with a (hidden) custom post ...
21,606
<p>I'm trying to exclude certain categories from the mydomain.com/feed</p> <p>Researching online I came across this code:</p> <pre><code>&lt;a href="&lt;?php bloginfo('url'); ?&gt;/feed?cat=-3&amp;cat=-12"&gt;Entries (RSS)&lt;/a&gt; </code></pre> <p>Now the question is should I create a function (if yes what functio...
[ { "answer_id": 21611, "author": "Daniel Sachs", "author_id": 4451, "author_profile": "https://wordpress.stackexchange.com/users/4451", "pm_score": 3, "selected": false, "text": "<p>In your functions.php add:</p>\n\n<pre><code>function excludeFeedCats($query) {\n if ($query-&gt;is_feed...
2011/06/30
[ "https://wordpress.stackexchange.com/questions/21606", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5411/" ]
I'm trying to exclude certain categories from the mydomain.com/feed Researching online I came across this code: ``` <a href="<?php bloginfo('url'); ?>/feed?cat=-3&cat=-12">Entries (RSS)</a> ``` Now the question is should I create a function (if yes what function to create) so I can exclude categories without having...
In your functions.php add: ``` function excludeFeedCats($query) { if ($query->is_feed) { $query->set('cat','-3, -12'); } return $query; } add_filter('pre_get_posts','excludeFeedCats'); ``` Or use [Simply Exclude](http://wordpress.org/extend/plugins/simply-exclude/) for more flexibility.
21,626
<p>I have my own SQL string to select Custom Post Type posts with specific WHERE clause. I've used the offset and limit to return appropriate posts depending on a page being displayed. That's working fine.</p> <p>Now, I would like to make <code>previous_posts_link()</code> and <code>next_posts_link()</code> functions ...
[ { "answer_id": 21627, "author": "anu", "author_id": 490, "author_profile": "https://wordpress.stackexchange.com/users/490", "pm_score": 1, "selected": false, "text": "<p>Take a look at <a href=\"http://codex.wordpress.org/Custom_Queries\" rel=\"nofollow\">Custom Queries</a> - which allow...
2011/06/30
[ "https://wordpress.stackexchange.com/questions/21626", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1343/" ]
I have my own SQL string to select Custom Post Type posts with specific WHERE clause. I've used the offset and limit to return appropriate posts depending on a page being displayed. That's working fine. Now, I would like to make `previous_posts_link()` and `next_posts_link()` functions work. They both are called from ...
Ok, I got there at the end. I couldn't use `WP_Query` class as I really needed to have my own pretty big and complex SQL. Here is what I ended up having: In `functions.php` I have my custom SQL and logic for counting the values needed for the WP pagination logic: ``` function vacancies_current( ){ global $wpdb, $...
21,628
<p>I'm working with post formats, most of my code looks similar to this:</p> <pre><code>if ( has_post_format( 'standard' )) { echo '&lt;?php get_sidebar(); ?&gt;'; } if ( has_post_format( 'aside' )) { echo 'this is an aside'; } if ( has_post_format( 'chat' )) { echo 'this is the video format'; } </code></pre> <...
[ { "answer_id": 21630, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": true, "text": "<p>use <a href=\"http://codex.wordpress.org/Function_Reference/get_post_format\" rel=\"nofollow\"><code>get_post_format...
2011/06/30
[ "https://wordpress.stackexchange.com/questions/21628", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6565/" ]
I'm working with post formats, most of my code looks similar to this: ``` if ( has_post_format( 'standard' )) { echo '<?php get_sidebar(); ?>'; } if ( has_post_format( 'aside' )) { echo 'this is an aside'; } if ( has_post_format( 'chat' )) { echo 'this is the video format'; } ``` But I also want one of the if ...
use [`get_post_format`](http://codex.wordpress.org/Function_Reference/get_post_format): ``` $format = get_post_format(); if ( false === $format ) echo "no post format"; ``` EDIT - an example using a switch statement: ``` $format = get_post_format(); switch( $format ){ case "aside": echo "aside"; ...
21,636
<p>On one of my page templates I need to include the contents of several other pages. For example, if my page template is called Fruit, I need to pull in page content from pages named Apple, Pear, Orange, Lime, etc. This gives my user the ability to edit Apple and Lime individually from admin area.<br> I'm trying to us...
[ { "answer_id": 21653, "author": "David Nguyen", "author_id": 6649, "author_profile": "https://wordpress.stackexchange.com/users/6649", "pm_score": 2, "selected": true, "text": "<p>get_page_by_title returns an id not content. here is an example of what I use to get content from a certain ...
2011/06/30
[ "https://wordpress.stackexchange.com/questions/21636", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6646/" ]
On one of my page templates I need to include the contents of several other pages. For example, if my page template is called Fruit, I need to pull in page content from pages named Apple, Pear, Orange, Lime, etc. This gives my user the ability to edit Apple and Lime individually from admin area. I'm trying to use **...
get\_page\_by\_title returns an id not content. here is an example of what I use to get content from a certain page id. call the function ``` $page_id = get_page_by_title('title'); $excerpt = get_excerpt_by_id($page_id); ``` in functions.php ``` function get_excerpt_by_id($post_id) { global $wpdb; $query = ...
21,641
<p>Been looking around for an alternative to this method: <a href="http://allcreatives.net/2011/02/02/using-the-native-wordpress-tinymce-wysiwyg-editor-with-your-custom-post-meta-textareas/" rel="nofollow">http://allcreatives.net/2011/02/02/using-the-native-wordpress-tinymce-wysiwyg-editor-with-your-custom-post-meta-te...
[ { "answer_id": 21665, "author": "Daniel Sachs", "author_id": 4451, "author_profile": "https://wordpress.stackexchange.com/users/4451", "pm_score": 3, "selected": true, "text": "<p>Use this class: <a href=\"http://www.deluxeblogtips.com/p/meta-box-script-for-wordpress.html\" rel=\"nofollo...
2011/06/30
[ "https://wordpress.stackexchange.com/questions/21641", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2830/" ]
Been looking around for an alternative to this method: <http://allcreatives.net/2011/02/02/using-the-native-wordpress-tinymce-wysiwyg-editor-with-your-custom-post-meta-textareas/> To add the WYSIWYG capability to custom metaboxes. You get so little control with this method, is there any other way?
Use this class: <http://www.deluxeblogtips.com/p/meta-box-script-for-wordpress.html> and then call the metabox like this (don't forget to read the manual and view some examples): ``` $meta_boxes[] = array( 'id' => 'textmetabox', 'title' => 'Your Meta Box Title', 'pages' => array('post', 'slider', 'whateve...
21,662
<p>I am working on a project that has </p> <ul> <li>a custom post type called 'Experience Statement'</li> <li>Custom Taxonomy attached to that post type called 'Expertise'</li> <li>6 different terms for the custom taxonomy: Coastal, inland, marine, waterway, ship, telecommunications</li> </ul> <p>So, I have created t...
[ { "answer_id": 21667, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 1, "selected": false, "text": "<p>There are several ways to do this, one method is to use <code>get_the_terms</code>.</p>\n\n<p>The logic would be to...
2011/06/30
[ "https://wordpress.stackexchange.com/questions/21662", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3836/" ]
I am working on a project that has * a custom post type called 'Experience Statement' * Custom Taxonomy attached to that post type called 'Expertise' * 6 different terms for the custom taxonomy: Coastal, inland, marine, waterway, ship, telecommunications So, I have created this loop, that works great and I have crea...
There are several ways to do this, one method is to use `get_the_terms`. The logic would be to run the loop and customize the output based on the terms for that taxonomy ( this will probably not work out of the box). ``` //do a custom query here if needed if ( have_posts() ) : while ( have_posts() ) : the_post(); ...
21,679
<p>I know how to get the value of a custom field, using code like <code>get_post_meta($post-&gt;ID, 'company', true);</code>. Is there a way to get the name of the custom field?</p>
[ { "answer_id": 21681, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": true, "text": "<p>to get a post custom fields name you can use <a href=\"http://codex.wordpress.org/Function_Reference/get_post_...
2011/07/01
[ "https://wordpress.stackexchange.com/questions/21679", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6389/" ]
I know how to get the value of a custom field, using code like `get_post_meta($post->ID, 'company', true);`. Is there a way to get the name of the custom field?
to get a post custom fields name you can use [**get\_post\_custom**](http://codex.wordpress.org/Function_Reference/get_post_custom) eg: ``` $post_meta = get_post_custom($post->ID); foreach ( $post_meta as $key => $value ) echo $key . " => " . $value . "<br />"; ``` this will print a list of custom\_field\_name ...
21,690
<p>I am working on the WordPress Twenty Ten theme, and I want to display post thumbnails. I have followed the steps below:</p> <ul> <li><p>Added following code in functions.php file:</p> <pre><code>if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post-thumbnails' ); } </code></pre></li> <li>...
[ { "answer_id": 21691, "author": "Murilo", "author_id": 6619, "author_profile": "https://wordpress.stackexchange.com/users/6619", "pm_score": 1, "selected": false, "text": "<p>Maybe it's just a typo, use </p>\n\n<pre><code>the_post_thumbnail(array(150,150));\n</code></pre>\n\n<p>instead o...
2011/06/30
[ "https://wordpress.stackexchange.com/questions/21690", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I am working on the WordPress Twenty Ten theme, and I want to display post thumbnails. I have followed the steps below: * Added following code in functions.php file: ``` if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post-thumbnails' ); } ``` * I have also defined post thumbnail size, ```...
IF you want to retrieve thumbnail in size that you had set with `set_post_thumbnail_size()` then call `the_post_thumbnail()` without passing any arguments. That will default to named `post-thumbnail` size that that `set_post_thumbnail_size()` actually creates. Also crop for this will be determined by third argument i...
21,693
<p>I've been writing some Wordpress plugins, and I've been having some problem with Wordpress putting magic quotes on POST and GET data.</p> <p>Specifically, the "wp_magic_quotes" function in \wp-includes\load.php, which is called (presumably on every response) in wp-settings.php. This function adds magic quotes to t...
[ { "answer_id": 21694, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>I think the following links might help:</p>\n\n<ul>\n<li><a href=\"http://wordpress.org/extend/plugins/hungred-sma...
2011/07/01
[ "https://wordpress.stackexchange.com/questions/21693", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6668/" ]
I've been writing some Wordpress plugins, and I've been having some problem with Wordpress putting magic quotes on POST and GET data. Specifically, the "wp\_magic\_quotes" function in \wp-includes\load.php, which is called (presumably on every response) in wp-settings.php. This function adds magic quotes to the data e...
Simply put WP turns indeterminate situation (magic quotes might or might not be enabled in server configuration) into determinate (magic quotes are always present and server configuration does not matter). Rather than messing with this for all WP core it makes much more sense to simply strip slashes in your code on yo...
21,700
<p>I am running wordpress 3.2rc2 multisite.</p> <p>I inserted a few .mp4 videos into the root of my domain so that I can run a few basic tests with the jw player. </p> <p>When I try to access the url to the .mp4 video, I somehow end up with a wordpress 404 page. This is also causing errors within the jw player saying...
[ { "answer_id": 21711, "author": "Chris_O", "author_id": 251, "author_profile": "https://wordpress.stackexchange.com/users/251", "pm_score": 2, "selected": true, "text": "<p>A missing mime type should not cause a 404 page but the AddType needs to be wrapped in <code>&lt;IfModule mod_mime....
2011/07/01
[ "https://wordpress.stackexchange.com/questions/21700", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/370/" ]
I am running wordpress 3.2rc2 multisite. I inserted a few .mp4 videos into the root of my domain so that I can run a few basic tests with the jw player. When I try to access the url to the .mp4 video, I somehow end up with a wordpress 404 page. This is also causing errors within the jw player saying that either the ...
A missing mime type should not cause a 404 page but the AddType needs to be wrapped in `<IfModule mod_mime.c>` tags. ``` <IfModule mod_mime.c> AddType video/mp4 .mp4 .m4v AddType video/mpeg .mpeg .mpg .mpe AddType video/asf .asf .asx .wax .wmv .wmx AddType video/avi .avi AddType video/quicktime .mo...
21,702
<p>Been playing around with the Settings API and found that messages (for success or errors) are only displayed when a settings page is hooked into WordPress menu via add_options_page(). Anything else will not work e.g. add_dashboard_page(). Would like to know if this is true? Sample code I tried with is the answer con...
[ { "answer_id": 21703, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 3, "selected": false, "text": "<p>I use Settings API integration with my Theme,use <code>add_theme_page()</code>, and have no problem display...
2011/07/01
[ "https://wordpress.stackexchange.com/questions/21702", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6667/" ]
Been playing around with the Settings API and found that messages (for success or errors) are only displayed when a settings page is hooked into WordPress menu via add\_options\_page(). Anything else will not work e.g. add\_dashboard\_page(). Would like to know if this is true? Sample code I tried with is the answer co...
Thanks Chip (*excellent Settings API tutorial*) and t31os (*great snippet of code for quick testing*) for both your suggestions. I did some further digging and found that the default messages can indeed be displayed if I hook into any menu but only if the function [settings\_errors()](https://codex.wordpress.org/Func...
21,721
<p>I use hack of <a href="https://wordpress.stackexchange.com/users/251/chris-o">Chris_O</a> for highlighting the search terms. When a user enters the search keywords without any blank space in the beginning or at end of the search string it retrieves and highlights the search terms in the corresponding records nicely....
[ { "answer_id": 21708, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": 3, "selected": true, "text": "<p>Some are attempting to leave their links behind, they believe the quantity not quality approach will actual ...
2011/07/01
[ "https://wordpress.stackexchange.com/questions/21721", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5021/" ]
I use hack of [Chris\_O](https://wordpress.stackexchange.com/users/251/chris-o) for highlighting the search terms. When a user enters the search keywords without any blank space in the beginning or at end of the search string it retrieves and highlights the search terms in the corresponding records nicely. But if the ...
Some are attempting to leave their links behind, they believe the quantity not quality approach will actual help increase SEO rankings. The other reason would be affiliate marketing garbage links trying to make a penny.
21,752
<p>I am trying to set cookies to re-route returning users to my a specific page within my Wordpress site.</p> <p>I'd like some advice with these 2 things:</p> <ol> <li>Where in the Wordpress php files should cookies be checked before loading any content to handle a redirect? Is there a good file this should exist in ...
[ { "answer_id": 21996, "author": "Atticus", "author_id": 6744, "author_profile": "https://wordpress.stackexchange.com/users/6744", "pm_score": 4, "selected": true, "text": "<p>Ah, realized I needed to hook this into the <code>init()</code>. </p>\n\n<p>SOLUTION: I created a function in fun...
2011/07/02
[ "https://wordpress.stackexchange.com/questions/21752", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6744/" ]
I am trying to set cookies to re-route returning users to my a specific page within my Wordpress site. I'd like some advice with these 2 things: 1. Where in the Wordpress php files should cookies be checked before loading any content to handle a redirect? Is there a good file this should exist in over others? 2. How ...
Ah, realized I needed to hook this into the `init()`. SOLUTION: I created a function in functions.php that would set and check the cookie. for this to work properly, after defining the function, outside the function call this: ``` add_action('init', 'function-name'); ```
21,753
<p>My shared hoster is continually disabling my site as it appears there is a run away plugin that is pegging mysql.</p> <p>In their logs, I'm seeing these:</p> <pre><code># Wed Jun 29 00:00:33 2011 # Query_time: 22.923943 Lock_time: 4.941786 Rows_sent: 100 Rows_examined: 808400 use FOO_wrdp2; SELECT * FROM wp_slim...
[ { "answer_id": 21754, "author": "ChiCgi", "author_id": 6847, "author_profile": "https://wordpress.stackexchange.com/users/6847", "pm_score": 2, "selected": false, "text": "<p>Sometimes plugins add tables to your database automatically when you install, but they are not removed when you d...
2011/07/01
[ "https://wordpress.stackexchange.com/questions/21753", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6807/" ]
My shared hoster is continually disabling my site as it appears there is a run away plugin that is pegging mysql. In their logs, I'm seeing these: ``` # Wed Jun 29 00:00:33 2011 # Query_time: 22.923943 Lock_time: 4.941786 Rows_sent: 100 Rows_examined: 808400 use FOO_wrdp2; SELECT * FROM wp_slimex_stats LIMIT 808300...
Sometimes plugins add tables to your database automatically when you install, but they are not removed when you disable the plugin. If I were you, I'd open my site in an HTML editor and do a global search for slimex\_stats (or $wpdb->slimex\_stats or wp\_slimex\_stats) to try to find where in your code that SELECT stat...
21,768
<p>I'm currently using some JS to pop open the WordPress Media Library in a thickbox container and return the URL of a selected image, then display it.</p> <pre><code>window.send_to_editor = function(html) { imgurl = jQuery('img',html).attr('src'); jQuery('#upload_image-' + id_to_pass).val(imgurl); output...
[ { "answer_id": 58439, "author": "Laurence Tuck", "author_id": 1426, "author_profile": "https://wordpress.stackexchange.com/users/1426", "pm_score": 2, "selected": true, "text": "<p>You could add an htaccess redirect or try out the theme my login plugin: <a href=\"http://wordpress.org/ext...
2011/07/02
[ "https://wordpress.stackexchange.com/questions/21768", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6344/" ]
I'm currently using some JS to pop open the WordPress Media Library in a thickbox container and return the URL of a selected image, then display it. ``` window.send_to_editor = function(html) { imgurl = jQuery('img',html).attr('src'); jQuery('#upload_image-' + id_to_pass).val(imgurl); output_code = '<img ...
You could add an htaccess redirect or try out the theme my login plugin: <http://wordpress.org/extend/plugins/theme-my-login/>. It has options for custom redirection.
21,769
<p>I am creating a plugin to add some javascript to Wordpress's theme header and footer.</p> <p>I'm doing this through the following wordpress hooks:</p> <pre><code>add action(wp_head,function_name) add action(wp_footer,function_name) </code></pre> <p>However my plugin can't add script if the clients theme does not ...
[ { "answer_id": 21771, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": -1, "selected": false, "text": "<p>Why not try using:</p>\n\n<blockquote>\n if(function_exists('wp_head')) {\n //do something\n }else{\n ...
2011/06/30
[ "https://wordpress.stackexchange.com/questions/21769", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I am creating a plugin to add some javascript to Wordpress's theme header and footer. I'm doing this through the following wordpress hooks: ``` add action(wp_head,function_name) add action(wp_footer,function_name) ``` However my plugin can't add script if the clients theme does not have `wp_head()` and `wp_footer()...
Technically to check if theme runs `wp_head` and `wp_footer` hooks you can: 1. hook into `shutdown` 2. check that you are in front end 3. use [`did_action()`](http://codex.wordpress.org/Function_Reference/did_action) to determine if hooks fired 4. save the result (in option for example) with theme name to access and u...
21,774
<p>Is it possible to let a non-admin user (e.g an editor / author or another role) manage the users? I am working on a Wordpress website where multiple people manage the website, and there will be someone who must be able to manage the users, but does not need access to all the admin features.</p> <p>Thanks.</p>
[ { "answer_id": 21775, "author": "JCL1178", "author_id": 6146, "author_profile": "https://wordpress.stackexchange.com/users/6146", "pm_score": 1, "selected": false, "text": "<p>Yes, this is very possible and quite simple. </p>\n\n<p>You will want to use the <a href=\"http://agapetry.net/...
2011/07/01
[ "https://wordpress.stackexchange.com/questions/21774", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
Is it possible to let a non-admin user (e.g an editor / author or another role) manage the users? I am working on a Wordpress website where multiple people manage the website, and there will be someone who must be able to manage the users, but does not need access to all the admin features. Thanks.
First off, there is no generic "manage users" ability. There are several individual abilities under that rubric. See <http://codex.wordpress.org/Roles_and_Capabilities> Anyway, you have a couple options. 1. You can add certain capabilities to existing users or 2. you can create a new custom role with the capabilities...
21,781
<p>I'm developing a theme for a customer in which i need several versions of the same image.</p> <p>In my functions.php file i've added all the image sizes i need. For instance:</p> <pre><code>if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post-thumbnails' ); } if ( function_exists( 'add_imag...
[ { "answer_id": 21782, "author": "Michal Mau", "author_id": 2110, "author_profile": "https://wordpress.stackexchange.com/users/2110", "pm_score": 0, "selected": false, "text": "<p>Maybe this is a way too obvious, but have you tried calling your size by name?</p>\n\n<pre><code>&lt;?php ech...
2011/07/02
[ "https://wordpress.stackexchange.com/questions/21781", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82/" ]
I'm developing a theme for a customer in which i need several versions of the same image. In my functions.php file i've added all the image sizes i need. For instance: ``` if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post-thumbnails' ); } if ( function_exists( 'add_image_size' ) ) { add...
It turns out WP got confused because i used the settings> medias screen to also set the "medium" dimensions to 670x290. This redundance seems to disable entirely both the "medium" and the "listing-post-thumbnail" dimensions. Replacing the medium dimension values to 0 and then regenerating the thumbnails solved the issu...
21,805
<p>I'm trying to setup a function in functions.php that removes an image from the post_content on save. Everything works up until the time I'm trying to save the content, the page just hangs and I get a '500 Internal Server' error.</p> <pre><code>function remove_post_image( $post_ID ){ // get the post $the_post =...
[ { "answer_id": 21806, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>Your function calls <code>wp_update_post()</code>, which calls <code>wp_insert_post()</code> which runs <code>save_p...
2011/07/02
[ "https://wordpress.stackexchange.com/questions/21805", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6483/" ]
I'm trying to setup a function in functions.php that removes an image from the post\_content on save. Everything works up until the time I'm trying to save the content, the page just hangs and I get a '500 Internal Server' error. ``` function remove_post_image( $post_ID ){ // get the post $the_post = get_post($po...
`content_save_pre` would be a much better hook for stripping the images, and as for setting post thumbnail as post Meta you can use `save_post` since the first hook gets fired before post Id is set and you need that for `update_post_meta`.
21,811
<p>how are you?</p> <p>I want to using a string query to list tags in array and using it.</p> <p>I write this query but dosen't work</p> <pre><code>$tags= $wpdb-&gt;query("SELECT * FROM $wpdb-&gt;term_taxonomy , $wpdb-&gt;term_taxonomy WHERE $wpdb-&gt;term_taxonomy.taxonomy = post_tag"); foreach...
[ { "answer_id": 21812, "author": "scribu", "author_id": 205, "author_profile": "https://wordpress.stackexchange.com/users/205", "pm_score": 4, "selected": true, "text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/get_terms\" rel=\"noreferrer\">get_terms()</a>.</p>\n" ...
2011/07/02
[ "https://wordpress.stackexchange.com/questions/21811", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2076/" ]
how are you? I want to using a string query to list tags in array and using it. I write this query but dosen't work ``` $tags= $wpdb->query("SELECT * FROM $wpdb->term_taxonomy , $wpdb->term_taxonomy WHERE $wpdb->term_taxonomy.taxonomy = post_tag"); foreach($tags as $tag){ echo $tag; } ``` plea...
Use [get\_terms()](http://codex.wordpress.org/Function_Reference/get_terms).
21,825
<p>Here's what I have in my sidebar.php:</p> <pre><code> &lt;aside id="sidebar"&gt; &lt;?php if ( is_user_logged_in() ) { echo '&lt;a href="/community"&gt;&lt;img id="visit-the-forums" src="'. bloginfo('template_url') . '/images/visit-the-forums.png" alt="Check out the Forums!" /&gt;&lt;/a&gt;' } else {...
[ { "answer_id": 21812, "author": "scribu", "author_id": 205, "author_profile": "https://wordpress.stackexchange.com/users/205", "pm_score": 4, "selected": true, "text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/get_terms\" rel=\"noreferrer\">get_terms()</a>.</p>\n" ...
2011/07/02
[ "https://wordpress.stackexchange.com/questions/21825", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3714/" ]
Here's what I have in my sidebar.php: ``` <aside id="sidebar"> <?php if ( is_user_logged_in() ) { echo '<a href="/community"><img id="visit-the-forums" src="'. bloginfo('template_url') . '/images/visit-the-forums.png" alt="Check out the Forums!" /></a>' } else { echo '<a href="/community"><img id...
Use [get\_terms()](http://codex.wordpress.org/Function_Reference/get_terms).
21,829
<p>For some reason I can'g get pagination using previous_posts_link and next_posts_link working.</p> <p>Here is the code I have...</p> <pre><code>&lt;?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?&gt; &lt;?php // The Query $the_query = new WP_Query( array( 'post_type'=&gt;'article', '...
[ { "answer_id": 21858, "author": "Roman", "author_id": 3817, "author_profile": "https://wordpress.stackexchange.com/users/3817", "pm_score": 4, "selected": true, "text": "<p>The pagination works only, if the <code>paged</code> attribute in the the global <code>$wp_query</code> variable is...
2011/07/03
[ "https://wordpress.stackexchange.com/questions/21829", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6694/" ]
For some reason I can'g get pagination using previous\_posts\_link and next\_posts\_link working. Here is the code I have... ``` <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ?> <?php // The Query $the_query = new WP_Query( array( 'post_type'=>'article', 'posts_per_page'=>2, 'orde...
The pagination works only, if the `paged` attribute in the the global `$wp_query` variable is set. You could store your query manually in this global or just use `query_posts()` instead of `new WP_Query()`. ``` <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $the_query = query_posts( ...
21,838
<p><strong>The problem:</strong><br> I'm posting from the Wordpress iPhone app. When adding an image, the image shows up in the description itself, which I don't like. </p> <p><strong>What I'm trying to do:</strong><br> Remove the image from the description and do one of the following (don't know the benefits of one o...
[ { "answer_id": 57636, "author": "chrismou", "author_id": 8960, "author_profile": "https://wordpress.stackexchange.com/users/8960", "pm_score": 0, "selected": false, "text": "<p>Not sure if it's any use in your particular scenario, but might be worth checking out the get_the_image plugin<...
2011/07/03
[ "https://wordpress.stackexchange.com/questions/21838", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6483/" ]
**The problem:** I'm posting from the Wordpress iPhone app. When adding an image, the image shows up in the description itself, which I don't like. **What I'm trying to do:** Remove the image from the description and do one of the following (don't know the benefits of one option over the other): 1. Get the im...
Why not utilize two hooks, one before post saved and one after post saved? content\_save\_pre : Function attached with this hook will remove image from content and store it in session/[transient](http://codex.wordpress.org/Transients_API). save\_post : With this hook you will have id of post. Function attached with t...
21,842
<p>I am currently developing a WordPress website with a custom post_type called "music". I use the plugin wp-pagenavi to paginate content "music".</p> <p>When I link on the first page, it's OK (see link below) <a href="http://carbonpaper-dev.imperatorium.org/music/page/1" rel="nofollow">http://carbonpaper-dev.imperato...
[ { "answer_id": 21853, "author": "andreeib", "author_id": 6701, "author_profile": "https://wordpress.stackexchange.com/users/6701", "pm_score": 1, "selected": false, "text": "<p>Try this for the loop code.</p>\n\n<pre><code>&lt;?php\n$paged = (get_query_var('paged')) ? get_query_var('page...
2011/06/27
[ "https://wordpress.stackexchange.com/questions/21842", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6550/" ]
I am currently developing a WordPress website with a custom post\_type called "music". I use the plugin wp-pagenavi to paginate content "music". When I link on the first page, it's OK (see link below) <http://carbonpaper-dev.imperatorium.org/music/page/1> But when I link on the 2nd page: <http://carbonpaper-dev.imper...
Try this for the loop code. ``` <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $loop = new WP_Query( array( 'post_type' => 'music', 'paged' => $paged ) ); ?> ```
21,856
<p>I'm experiencing some problems with my pagination when displaying custom post types. I would like to display 9 posts and then display a numeric pagination. This is working, some links are generated with (for me) correct URLs : <a href="http://mywebsite/tutorial/page/2" rel="nofollow">http://mywebsite/tutorial/page/2...
[ { "answer_id": 22671, "author": "Dale-Anthony", "author_id": 6911, "author_profile": "https://wordpress.stackexchange.com/users/6911", "pm_score": 0, "selected": false, "text": "<p>Hey I had a similar issue.</p>\n\n<p>The problem was WordPress is setup to show 10 posts per page by defaul...
2011/07/03
[ "https://wordpress.stackexchange.com/questions/21856", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6476/" ]
I'm experiencing some problems with my pagination when displaying custom post types. I would like to display 9 posts and then display a numeric pagination. This is working, some links are generated with (for me) correct URLs : <http://mywebsite/tutorial/page/2> or <http://mywebsite/tutorial/taxonomy/page/2> but it alwa...
Change predefined posts\_per\_page to minimum value in wordpress settings or add code below to functions.php. Wordpress using default parameter. For example: 10. And if your settings in query\_posts or WP\_Query look like "posts\_per\_page=>2" and number of posts in custom post type less then 10, after clicking to /pag...
21,859
<p>I'm trying to delete around 250 posts at once, but the next page I am taken to displays the error:</p> <blockquote> <p><strong>Request-URI Too Large</strong></p> <p><strong>The requested URL's length exceeds the capacity limit for this server</strong></p> </blockquote> <p>Does Wordpress need to use a HTTP P...
[ { "answer_id": 22671, "author": "Dale-Anthony", "author_id": 6911, "author_profile": "https://wordpress.stackexchange.com/users/6911", "pm_score": 0, "selected": false, "text": "<p>Hey I had a similar issue.</p>\n\n<p>The problem was WordPress is setup to show 10 posts per page by defaul...
2011/07/03
[ "https://wordpress.stackexchange.com/questions/21859", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3206/" ]
I'm trying to delete around 250 posts at once, but the next page I am taken to displays the error: > > **Request-URI Too Large** > > > **The requested URL's length exceeds the capacity limit for this server** > > > Does Wordpress need to use a HTTP Post action to delete posts?
Change predefined posts\_per\_page to minimum value in wordpress settings or add code below to functions.php. Wordpress using default parameter. For example: 10. And if your settings in query\_posts or WP\_Query look like "posts\_per\_page=>2" and number of posts in custom post type less then 10, after clicking to /pag...
21,861
<p>I'm building a custom search page and what I need is to sort results by relevancy (eg. occurences of a keyword)</p> <p>Using <a href="http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html" rel="nofollow">MySQL docs</a> I've built this query:</p> <pre><code>SELECT ID FROM $wpdb-&gt;posts WHERE MATCH (post_tit...
[ { "answer_id": 21865, "author": "Aleh", "author_id": 6706, "author_profile": "https://wordpress.stackexchange.com/users/6706", "pm_score": 1, "selected": false, "text": "<p>You may want to check the Sphinx search engine\n<a href=\"http://sphinxsearch.com/\" rel=\"nofollow\">http://sphinx...
2011/07/03
[ "https://wordpress.stackexchange.com/questions/21861", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6693/" ]
I'm building a custom search page and what I need is to sort results by relevancy (eg. occurences of a keyword) Using [MySQL docs](http://dev.mysql.com/doc/refman/5.0/en/fulltext-search.html) I've built this query: ``` SELECT ID FROM $wpdb->posts WHERE MATCH (post_title, post_content) AGAINST ('$keyword_list') AND po...
You may want to check the Sphinx search engine <http://sphinxsearch.com/> It took me about one day to set it up and learn how to use, but it does really good job with sorting by relevancy and grammar stemming. Also it is faster than fulltext search for big data sets thanks to indexing.
21,863
<p>When I echo get_permalink() in a function that's called from archive.php, it reflects the permalink of the last post that's assigned to the category.</p> <p>How can I echo the permalink of the category page instead?</p>
[ { "answer_id": 21866, "author": "scribu", "author_id": 205, "author_profile": "https://wordpress.stackexchange.com/users/205", "pm_score": 2, "selected": true, "text": "<p>Like so:</p>\n\n<pre><code>echo get_category_link( get_queried_object() );\n</code></pre>\n" }, { "answer_id...
2011/07/03
[ "https://wordpress.stackexchange.com/questions/21863", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6620/" ]
When I echo get\_permalink() in a function that's called from archive.php, it reflects the permalink of the last post that's assigned to the category. How can I echo the permalink of the category page instead?
Like so: ``` echo get_category_link( get_queried_object() ); ```
21,874
<p>i have a wordpress site that has around 20000 post it gets slow at generating pagination. i have traced the problem. </p> <pre><code>$my_query = new WP_Query($query_string ."&amp;posts_per_page=-1"); $total_posts = $my_query-&gt;post_count; </code></pre> <p>is there any other faster way to get total post on a sele...
[ { "answer_id": 21875, "author": "Banago", "author_id": 6612, "author_profile": "https://wordpress.stackexchange.com/users/6612", "pm_score": 0, "selected": false, "text": "<p>It seems there isn't one. The default WordPress count function does not support category posts count: </p>\n\n<p>...
2011/07/03
[ "https://wordpress.stackexchange.com/questions/21874", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6709/" ]
i have a wordpress site that has around 20000 post it gets slow at generating pagination. i have traced the problem. ``` $my_query = new WP_Query($query_string ."&posts_per_page=-1"); $total_posts = $my_query->post_count; ``` is there any other faster way to get total post on a selected category.
I have one solution for you. This code will show and unordered list with the name of the category and the count of posts containded in it. ``` <ul class="myClass"> <?php $categories = get_categories('number=100'); foreach ($categories as $cat) { echo "<li>". $cat->cat_name . " Total posts: ". $cat->cat...
21,882
<p>I have the following issue:</p> <p>I am creating a custom-meta-box for the user to add custom fields in a friendly way.<br> I want to generate a drop-down box with all posts that fall under category 10.<br> I have created a loop inside the functions file for retrieving the posts I want and to create a dropdown sele...
[ { "answer_id": 21926, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": false, "text": "<p>I am not sure about the issue, but my advice would be to try and refactor this to use <code>get_posts()</code> and t...
2011/07/03
[ "https://wordpress.stackexchange.com/questions/21882", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6379/" ]
I have the following issue: I am creating a custom-meta-box for the user to add custom fields in a friendly way. I want to generate a drop-down box with all posts that fall under category 10. I have created a loop inside the functions file for retrieving the posts I want and to create a dropdown select list. S...
I am not sure about the issue, but my advice would be to try and refactor this to use `get_posts()` and template tags that can work without `$post` global variable. Basically do not touch globals at all. Loops in front-end are almost civilized nowadays, but internals of admin are still very wild. :)