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
4,991
<p>Call me stupid but I coudn't figure out how to do it. For text input I would just: </p> <pre><code>&lt;input type="text" name="option_name" value="&lt;?php echo get_option( 'option_name' ); ?&gt;" /&gt; </code></pre> <p>and then hook it into workdpress using <code>register_setting()</code>. I could then get its v...
[ { "answer_id": 4992, "author": "t31os", "author_id": 31073, "author_profile": "https://wordpress.stackexchange.com/users/31073", "pm_score": 6, "selected": true, "text": "<p>I tend to store multiple options as an array, so i'd have something like this..</p>\n\n<pre><code>&lt;?php $option...
2010/12/07
[ "https://wordpress.stackexchange.com/questions/4991", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1649/" ]
Call me stupid but I coudn't figure out how to do it. For text input I would just: ``` <input type="text" name="option_name" value="<?php echo get_option( 'option_name' ); ?>" /> ``` and then hook it into workdpress using `register_setting()`. I could then get its value thru `get_option('option_name')`. How should...
I tend to store multiple options as an array, so i'd have something like this.. ``` <?php $options = get_option( 'myoption' ); ?> <input type="checkbox" name="myoption[option_one]" value="1"<?php checked( 1 == $options['option_one'] ); ?> /> <input type="checkbox" name="myoption[option_two]" value="1"<?php checked( 1 ...
4,998
<h2>How can I extend the functions of the WordPress 3.1 admin bar in my plugins?</h2> <p>I am looking for specific hooks and filters to use in adding links or other features to the admin bar.</p> <p>A good example of what has already been done is the Yoast <a href="http://wordpress.org/extend/plugins/wordpress-seo/" re...
[ { "answer_id": 5004, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 3, "selected": false, "text": "<p>Download the nightly build, and check out these two files;</p>\n\n<ul>\n<li>wp-includes/admin-bar.php</li>\n...
2010/12/07
[ "https://wordpress.stackexchange.com/questions/4998", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/251/" ]
How can I extend the functions of the WordPress 3.1 admin bar in my plugins? ---------------------------------------------------------------------------- I am looking for specific hooks and filters to use in adding links or other features to the admin bar. A good example of what has already been done is the Yoast [Wo...
Yoast's plug-in is actually a very good example if all you want to do is add menus. Basically, the admin bar is just an alternate set of links to the same plug-in admin pages you have in the sidebar. To add the top-level SEO menu, Yoast does the following: ``` $wp_admin_bar->add_menu( array( 'id' => 'wpseo-menu', 'tit...
4,999
<p>Is it possible to get a page's permalink from the slug alone? I'm aware that you can get the page's permalink from the ID using <code>get_page_link()</code>:</p> <pre><code>&lt;a href="&lt;?php echo get_page_link(40); ?&gt;"&gt;Map&lt;/a&gt; </code></pre> <p>I'm curious if there is any way to do the same with the ...
[ { "answer_id": 5002, "author": "zeo", "author_id": 1241, "author_profile": "https://wordpress.stackexchange.com/users/1241", "pm_score": 9, "selected": true, "text": "<p>Is this what you are looking for:</p>\n<ul>\n<li><code>get_permalink( get_page_by_path( 'map' ) )</code></li>\n<li><co...
2010/12/07
[ "https://wordpress.stackexchange.com/questions/4999", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/92/" ]
Is it possible to get a page's permalink from the slug alone? I'm aware that you can get the page's permalink from the ID using `get_page_link()`: ``` <a href="<?php echo get_page_link(40); ?>">Map</a> ``` I'm curious if there is any way to do the same with the slug of a page - like this: ``` <a href="<?php echo ge...
Is this what you are looking for: * `get_permalink( get_page_by_path( 'map' ) )` * `get_permalink( get_page_by_title( 'Map' ) )` * `home_url( '/map/' )` ### References: * [`get_permalink` documentation](https://developer.wordpress.org/reference/functions/get_permalink/) * [`get_page_by_path` documentation](https://d...
5,012
<p>I would like to provide our WP users (authors) with a tinyMCE editor instead of standard <code>textarea</code> for their "Biographical Info" on the <strong>Profile</strong> page.</p> <p>I have spent a lot of time searching online for plugins and references for how to accomplish this without a satisfying solution.</...
[ { "answer_id": 5018, "author": "jessegavin", "author_id": 193, "author_profile": "https://wordpress.stackexchange.com/users/193", "pm_score": 3, "selected": true, "text": "<p>I found <strong><a href=\"http://www.keighl.com/2010/01/tinymce-in-wordpress-plugins/\" rel=\"nofollow\">a very h...
2010/12/07
[ "https://wordpress.stackexchange.com/questions/5012", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/193/" ]
I would like to provide our WP users (authors) with a tinyMCE editor instead of standard `textarea` for their "Biographical Info" on the **Profile** page. I have spent a lot of time searching online for plugins and references for how to accomplish this without a satisfying solution. Any tips would be appreciated.
I found **[a very helpful blog post](http://www.keighl.com/2010/01/tinymce-in-wordpress-plugins/)** which shows exactly how to accomplish what I am after with only three small changes to the `user-edit.php` page. ### First Change I had to add a class name to the `<textarea>` tag for the description. ``` <textarea na...
5,013
<p>I'm setting up a site with a theme that takes advantage of the "featured image" feature of WordPress. Since my end users are not the most tech saavy in the world, I'd like to set things up so that the categories would have a default "featured image" assigned to the post. In the event of multiple categories assigned ...
[ { "answer_id": 5014, "author": "matt", "author_id": 765, "author_profile": "https://wordpress.stackexchange.com/users/765", "pm_score": 5, "selected": true, "text": "<p>In your template where you have the Featured Image displayed: <code>&lt;?php the_post_thumbnail( 'thumbnail' ); ?&gt;</...
2010/12/07
[ "https://wordpress.stackexchange.com/questions/5013", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1165/" ]
I'm setting up a site with a theme that takes advantage of the "featured image" feature of WordPress. Since my end users are not the most tech saavy in the world, I'd like to set things up so that the categories would have a default "featured image" assigned to the post. In the event of multiple categories assigned to ...
In your template where you have the Featured Image displayed: `<?php the_post_thumbnail( 'thumbnail' ); ?>` you can make it conditional on whether the Featured Image is set, then have it default to whatever you want if it's not set. One way to do this is to put all the default images in a directory and name them for ...
5,029
<p>How can I make a link like this?</p> <p><code>http://www.lifecellskin.us/Dev/About</code></p> <p>the "Using_Permalinks" part, A is Capital letters. But WP automatically convert upper case to lower case.</p> <p>I'm trying to convert an old site that made by only html to a WP platform site. Some links to the site l...
[ { "answer_id": 5030, "author": "superUntitled", "author_id": 1489, "author_profile": "https://wordpress.stackexchange.com/users/1489", "pm_score": 1, "selected": false, "text": "<p>As far as I figure, search engines are not case specific, although URL's are case sensitive. I would recomm...
2010/12/08
[ "https://wordpress.stackexchange.com/questions/5029", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1850/" ]
How can I make a link like this? `http://www.lifecellskin.us/Dev/About` the "Using\_Permalinks" part, A is Capital letters. But WP automatically convert upper case to lower case. I'm trying to convert an old site that made by only html to a WP platform site. Some links to the site look like this: `http://www.lifece...
The page URLs are defined by the slugs, and by default they are formatted and lower-cased by the function [`sanitize_title_with_dashes()`](http://core.trac.wordpress.org/browser/tags/3.0.2/wp-includes/formatting.php#L814). However, this function is called via a filter, and you can *unhook* the filter so it doesn't get ...
5,044
<p>I've created my own custom post type using this tutorial: <a href="http://thinkvitamin.com/code/create-your-first-wordpress-custom-post-type/" rel="nofollow">http://thinkvitamin.com/code/create-your-first-wordpress-custom-post-type/</a></p> <p>Everything works fine, but I'm having major problem with "Read more" fea...
[ { "answer_id": 5045, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>So, two separate issues - links not displaying and faulty markup?</p>\n\n<p>For links not displaying - check if your ...
2010/12/08
[ "https://wordpress.stackexchange.com/questions/5044", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1869/" ]
I've created my own custom post type using this tutorial: <http://thinkvitamin.com/code/create-your-first-wordpress-custom-post-type/> Everything works fine, but I'm having major problem with "Read more" feature. As we all know `<!--more-->` adds `<span id="more-[number]" />` at the start of hidden more paragraph. In...
The quicktag will not operate and is ignored in Templates, such as single.php, where just one post is displayed. <http://codex.wordpress.org/Function_Reference/the_content>
5,047
<p>I have a pretty specific requirement to show different text in a field label on the user profile page based on the current user's role. I can't seem to figure out how to check whether the current use is an "author". </p> <p>I am looking for a function like:</p> <pre><code>is_user_in_role($user, "author"); </code><...
[ { "answer_id": 5048, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 9, "selected": true, "text": "<p>If you only need this for current user <a href=\"http://codex.wordpress.org/Function_Reference/current_user_can\"><cod...
2010/12/08
[ "https://wordpress.stackexchange.com/questions/5047", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/193/" ]
I have a pretty specific requirement to show different text in a field label on the user profile page based on the current user's role. I can't seem to figure out how to check whether the current use is an "author". I am looking for a function like: ``` is_user_in_role($user, "author"); ``` I imagine this is prett...
If you only need this for current user [`current_user_can()`](http://codex.wordpress.org/Function_Reference/current_user_can) accepts both roles and capabilities. **UPDATE**: Passing a role name to `current_user_can()` is no longer guaranteed to work correctly (see [#22624](https://core.trac.wordpress.org/ticket/22624...
5,053
<p>I'm not sure if this setting is handled in my wordpress installation or by Feedburner but right now my feedburner feed is displaying the feedburner favicon. How can I set it to use my blogs favicon?</p>
[ { "answer_id": 5083, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 4, "selected": true, "text": "<p>As @Rarst pointed out, there is no implementation of a favicon in the RSS spec (although there does <a href=\...
2010/12/08
[ "https://wordpress.stackexchange.com/questions/5053", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/765/" ]
I'm not sure if this setting is handled in my wordpress installation or by Feedburner but right now my feedburner feed is displaying the feedburner favicon. How can I set it to use my blogs favicon?
As @Rarst pointed out, there is no implementation of a favicon in the RSS spec (although there does [seem to be one for Atom](http://atomenabled.org/developers/syndication/#optionalFeedElements)). Feedburner (and other readers) rely on the de-facto standard that the favicon exists at the website root; ``` http://exam...
5,058
<p>I've been bashing my head against my desk all afternoon trying to figure this out. I've got a custom post type all set up, with hierarchical set to "true" and I can assign parents and see the relationship in the back end. Which is great.</p> <p>Except I want to list the children (and siblings) of my special new pos...
[ { "answer_id": 5059, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": true, "text": "<p>As name hints <code>wp_list_pages()</code> is intended for use with pages. As in \"a page page\". It uses <code>get_pa...
2010/12/08
[ "https://wordpress.stackexchange.com/questions/5058", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I've been bashing my head against my desk all afternoon trying to figure this out. I've got a custom post type all set up, with hierarchical set to "true" and I can assign parents and see the relationship in the back end. Which is great. Except I want to list the children (and siblings) of my special new post type. I ...
As name hints `wp_list_pages()` is intended for use with pages. As in "a page page". It uses `get_pages()` internally, which has `post_type` argument that defaults to `page`. I am not sure at all this is supposed to work for non-pages, but you can try to pass your custom post type as that `post_type` argument.
5,067
<p>How can I set up wordpress to recognize </p> <pre><code>www.example.com/wp-content/uploads/2010/12/history.pdf </code></pre> <p>as something like</p> <pre><code>www.example.com/about/pdf-download/ </code></pre> <p>I also want the user not to see the actual link but the new one.</p>
[ { "answer_id": 5068, "author": "jalefkowit", "author_id": 1782, "author_profile": "https://wordpress.stackexchange.com/users/1782", "pm_score": 3, "selected": true, "text": "<p>Do you just need to redirect that one specific request (for /wp-content/uploads/2010/12/history.pdf to /about/h...
2010/12/09
[ "https://wordpress.stackexchange.com/questions/5067", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1878/" ]
How can I set up wordpress to recognize ``` www.example.com/wp-content/uploads/2010/12/history.pdf ``` as something like ``` www.example.com/about/pdf-download/ ``` I also want the user not to see the actual link but the new one.
Do you just need to redirect that one specific request (for /wp-content/uploads/2010/12/history.pdf to /about/history.pdf)? Or do you need to to handle many requests (say, for /wp-content/uploads/2010/12/\* to /about/\*)? If it's the former, use a [symbolic link](http://en.wikipedia.org/wiki/Symbolic_link) (or, if you...
5,078
<p>Well, I'm using my own taxonomy for custom post type. It looks like this:</p> <pre><code>register_taxonomy("our_gallery", array("gallery"), array("hierarchical" =&gt; true, "label" =&gt; "Types", "singular_label" =&gt; "Type", "rewrite" =&gt; true)); </code></pre> <p>I have created a few "types"/categories in my a...
[ { "answer_id": 5079, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 4, "selected": true, "text": "<p>I think you are getting confused by terminology here.</p>\n\n<p><em>Category</em> is a <code>taxonomy</code>. Specific...
2010/12/09
[ "https://wordpress.stackexchange.com/questions/5078", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1869/" ]
Well, I'm using my own taxonomy for custom post type. It looks like this: ``` register_taxonomy("our_gallery", array("gallery"), array("hierarchical" => true, "label" => "Types", "singular_label" => "Type", "rewrite" => true)); ``` I have created a few "types"/categories in my admin panel like "Black and white", "La...
I think you are getting confused by terminology here. *Category* is a `taxonomy`. Specific categories you create are `terms`. *our\_gallery* is `taxonomy`. *Landscapes* is `term`. *our\_gallery* is **not** `category`. It is its own `taxonomy` and has nothing to do with *category* `taxonomy`. [`get_the_category()`](h...
5,084
<p>This code:</p> <pre><code>&lt;?php the_terms($post-&gt;ID, 'type') ?&gt; </code></pre> <p>Gives:</p> <pre><code>&lt;a href="/archives/type/image" rel="tag"&gt;Tag&lt;/a&gt; </code></pre> <p>What do to if I want to display only "Tag" word, not link eg.</p> <pre><code>Tag </code></pre> <p>Thanks!</p>
[ { "answer_id": 5086, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 4, "selected": true, "text": "<p>While you can specify separators and such in <code>the_terms()</code> arguments, it assumes that you actually want lin...
2010/12/09
[ "https://wordpress.stackexchange.com/questions/5084", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1869/" ]
This code: ``` <?php the_terms($post->ID, 'type') ?> ``` Gives: ``` <a href="/archives/type/image" rel="tag">Tag</a> ``` What do to if I want to display only "Tag" word, not link eg. ``` Tag ``` Thanks!
While you can specify separators and such in `the_terms()` arguments, it assumes that you actually want links. You can discard unwanted HTML by using filter: ``` add_filter('the_terms', 'no_terms_links', 10, 2); function no_terms_links($term_list, $taxonomy) { if ('type' == $taxonomy) return wp_filter_n...
5,088
<p>Ok it is pretty simple. Every post of my blog has a specific country. So i have the custom field country and then, when i write the article i add: japan, argentina, usa, italy etc. to the post. Now in home i like to have a box like that:</p> <p>Post By Country:</p> <p>Japan (130 posts) Usa (104 posts) Argentina (9...
[ { "answer_id": 5091, "author": "matt", "author_id": 765, "author_profile": "https://wordpress.stackexchange.com/users/765", "pm_score": 1, "selected": false, "text": "<p>Here's a loop that pulls all your post with the custom field key \"Country\"...</p>\n\n<pre><code>&lt;?php\n$countryPo...
2010/12/09
[ "https://wordpress.stackexchange.com/questions/5088", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
Ok it is pretty simple. Every post of my blog has a specific country. So i have the custom field country and then, when i write the article i add: japan, argentina, usa, italy etc. to the post. Now in home i like to have a box like that: Post By Country: Japan (130 posts) Usa (104 posts) Argentina (90 posts) Italy (4...
Here's a loop that pulls all your post with the custom field key "Country"... ``` <?php $countryPosts = new WP_Query(); $countryPosts->query('meta_key=country'); ?> <?php while ($countryPosts->have_posts()) : $countryPosts->the_post(); ?> CONTENT STUFF HERE <?php endwhile; ?> ``` Now to order that you can add `order...
5,094
<p>How can one get the blog ID as well as the database prefix of the main blog in a wordpress multisite installation? Is the main blog's ID always 1? Also how can the main blog's table prefix be acquired from within the mu-plugin's code?</p>
[ { "answer_id": 5096, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 4, "selected": true, "text": "<p>Use the constant <code>BLOG_ID_CURRENT_SITE</code>. And to get the database table prefix, use;</p>\n\n<pre><c...
2010/12/09
[ "https://wordpress.stackexchange.com/questions/5094", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/353/" ]
How can one get the blog ID as well as the database prefix of the main blog in a wordpress multisite installation? Is the main blog's ID always 1? Also how can the main blog's table prefix be acquired from within the mu-plugin's code?
Use the constant `BLOG_ID_CURRENT_SITE`. And to get the database table prefix, use; ``` $main_blog_prefix = $wpdb->get_blog_prefix(BLOG_ID_CURRENT_SITE); ```
5,098
<p>I am trying to modify the support links under the help section (Contextual help).I want to replace these <a href="http://codex.wordpress.org/Using_Themes" rel="nofollow">Documentation on Using Themes</a> and <a href="http://wordpress.org/support/" rel="nofollow">Support Forums</a> with my own .So I removed the link...
[ { "answer_id": 5100, "author": "RodeoRamsey", "author_id": 1663, "author_profile": "https://wordpress.stackexchange.com/users/1663", "pm_score": 3, "selected": false, "text": "<p>Put this in your theme's function.php file:</p>\n\n<pre><code>//function to edit help screen contents\n fu...
2010/12/09
[ "https://wordpress.stackexchange.com/questions/5098", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/391/" ]
I am trying to modify the support links under the help section (Contextual help).I want to replace these [Documentation on Using Themes](http://codex.wordpress.org/Using_Themes) and [Support Forums](http://wordpress.org/support/) with my own .So I removed the links in wp-admin folder from many pages under admin section...
> > But for plugin pages,I can't able to find the files to remove. > > > For dealing with plugin/registered pages that you won't necessarily know the hooks for, something like this will work... ``` add_action( 'admin_head', 'set_plugin_help_text'); function set_plugin_help_text() { global $_registered_pages; ...
5,102
<p>I have a function that defines a custom field on a post type. Say the field is "subhead".</p> <p>When the post is saved, I want to do some validation on the input, and display an error message on the post edit screen if necessary. Something like:</p> <pre><code>// Handle post updating function wpse_update_post_cus...
[ { "answer_id": 5103, "author": "Denis de Bernardy", "author_id": 1208, "author_profile": "https://wordpress.stackexchange.com/users/1208", "pm_score": 4, "selected": true, "text": "<p>Store errors in your class or as a global, possibly in a transient or meta, and display them in admin no...
2010/12/09
[ "https://wordpress.stackexchange.com/questions/5102", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1537/" ]
I have a function that defines a custom field on a post type. Say the field is "subhead". When the post is saved, I want to do some validation on the input, and display an error message on the post edit screen if necessary. Something like: ``` // Handle post updating function wpse_update_post_custom_values($post_id, ...
Store errors in your class or as a global, possibly in a transient or meta, and display them in admin notices on POST requests. WP does not feature any flash message handler.
5,105
<p>i'm using this sql.. but it does not work</p> <pre><code>UPDATE wp_options SET option_value = replace(option_value, 'http://old.com, 'http://new.com') WHERE option_name = 'home' OR option_name = 'siteurl'; UPDATE wp_options SET option_value = replace(option_value, 'http://old.com', 'http://new.com') WHERE option_n...
[ { "answer_id": 5106, "author": "Vinicius Pinto", "author_id": 41384, "author_profile": "https://wordpress.stackexchange.com/users/41384", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://codex.wordpress.org/Moving_WordPress\" rel=\"nofollow\">http://codex.wordpress.org/Movi...
2010/12/09
[ "https://wordpress.stackexchange.com/questions/5105", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1295/" ]
i'm using this sql.. but it does not work ``` UPDATE wp_options SET option_value = replace(option_value, 'http://old.com, 'http://new.com') WHERE option_name = 'home' OR option_name = 'siteurl'; UPDATE wp_options SET option_value = replace(option_value, 'http://old.com', 'http://new.com') WHERE option_name = 'home' O...
I do this all the time to move a site from our staging server to the live domain. I use PHPMyAdmin to export the database as an SQL file, then open it up in a text editor and do a global find and replace on the old url to change it to the new url. The use the SQL script to import the new SQL file to the new database...
5,116
<p>All right, so we're probably all familiar with the typical way to ensure that your main CSS file is refreshed when you load the page (busting the browser cache), right?</p> <pre><code>&lt;link rel="stylesheet" type="text/css" media="all" href="&lt;?php echo get_stylesheet_uri(); echo '?'.filemtime( get_styles...
[ { "answer_id": 5117, "author": "Denis de Bernardy", "author_id": 1208, "author_profile": "https://wordpress.stackexchange.com/users/1208", "pm_score": 4, "selected": true, "text": "<p>You're using the file's path in the first call, but its URL in the second. So it won't work.</p>\n" },...
2010/12/09
[ "https://wordpress.stackexchange.com/questions/5116", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/456/" ]
All right, so we're probably all familiar with the typical way to ensure that your main CSS file is refreshed when you load the page (busting the browser cache), right? ``` <link rel="stylesheet" type="text/css" media="all" href="<?php echo get_stylesheet_uri(); echo '?'.filemtime( get_stylesheet_directory() . '...
You're using the file's path in the first call, but its URL in the second. So it won't work.
5,123
<p>Like mentioned in the title, i think this is by far one problem Automattic or Wordpress team cannot solve until no matter what version Wordpress will go in future. In this question, i am focusing to the white screen of death that i get whenever i want to activate certain plugins. I am developing a site that requires...
[ { "answer_id": 5126, "author": "John P Bloch", "author_id": 11, "author_profile": "https://wordpress.stackexchange.com/users/11", "pm_score": 4, "selected": false, "text": "<p>To get WordPress to display errors, edit the <code>wp-config.php</code> file to say</p>\n\n<pre><code>define( 'W...
2010/12/10
[ "https://wordpress.stackexchange.com/questions/5123", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
Like mentioned in the title, i think this is by far one problem Automattic or Wordpress team cannot solve until no matter what version Wordpress will go in future. In this question, i am focusing to the white screen of death that i get whenever i want to activate certain plugins. I am developing a site that requires me...
To get WordPress to display errors, edit the `wp-config.php` file to say ``` define( 'WP_DEBUG', true ); ``` By default, this is set to `false` and should be towards the bottom of the file. That will allow you to see which errors are being produced. Also, whitespace at the end of files almost never causes the WSOD;...
5,136
<pre><code>function validate_username( $username ) { $sanitized = sanitize_user( $username, true ); $valid = ( $sanitized == $username ); return apply_filters( 'validate_username', $valid, $username ); } </code></pre> <p>in wp-includes/registration.php i want to change </p> <pre><code>$sanitized = saniti...
[ { "answer_id": 5137, "author": "Denis de Bernardy", "author_id": 1208, "author_profile": "https://wordpress.stackexchange.com/users/1208", "pm_score": 3, "selected": true, "text": "<p>Like so:</p>\n\n<pre><code>function my_validate_username( $valid, $username ) {\n $sanitized = saniti...
2010/12/10
[ "https://wordpress.stackexchange.com/questions/5136", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1372/" ]
``` function validate_username( $username ) { $sanitized = sanitize_user( $username, true ); $valid = ( $sanitized == $username ); return apply_filters( 'validate_username', $valid, $username ); } ``` in wp-includes/registration.php i want to change ``` $sanitized = sanitize_user( $username, true ); `...
Like so: ``` function my_validate_username( $valid, $username ) { $sanitized = sanitize_user( $username, false ); $valid = ( $sanitized == $username ); return $valid; } add_filter('validate_username', 'my_validate_username', 10, 2); ```
5,144
<p>What is the correct method to refer to images from within your plugin code, so that no matter what the folder is named, they resolve correctly?</p> <p>I had an issue where a user downloaded my plugin twice, then used the 2nd downloaded file to install it. Since Windows automatically named duplicate files foldername...
[ { "answer_id": 5147, "author": "PNMG", "author_id": 1756, "author_profile": "https://wordpress.stackexchange.com/users/1756", "pm_score": 0, "selected": false, "text": "<p>This should work for you.</p>\n\n<p><a href=\"http://codex.wordpress.org/Function_Reference/plugin_basename\" rel=\"...
2010/12/10
[ "https://wordpress.stackexchange.com/questions/5144", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/366/" ]
What is the correct method to refer to images from within your plugin code, so that no matter what the folder is named, they resolve correctly? I had an issue where a user downloaded my plugin twice, then used the 2nd downloaded file to install it. Since Windows automatically named duplicate files foldername(2).zip, w...
I am not sure about this specific example but in general [`plugins_url()`](http://codex.wordpress.org/Function_Reference/plugins_url) is fitting function for this. Example from Codex: ``` plugins_url('/images/wordpress.png', __FILE__); ```
5,154
<p>Generally on our WordPress blogs, there is a label <code>WordPress</code> displayed in the title bar. Does anybody have an idea on how to hide or remove it?</p> <p>My website is powered by WordPress multisite installation and like many people I wanted it as self-branded even though I keep a link back to wordpress.o...
[ { "answer_id": 5158, "author": "Trevor", "author_id": 1900, "author_profile": "https://wordpress.stackexchange.com/users/1900", "pm_score": 1, "selected": false, "text": "<p>Best I can tell, by default Wordpress displays the Blog Title (<em>Settings->General</em>). Have you changed that ...
2010/12/10
[ "https://wordpress.stackexchange.com/questions/5154", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/391/" ]
Generally on our WordPress blogs, there is a label `WordPress` displayed in the title bar. Does anybody have an idea on how to hide or remove it? My website is powered by WordPress multisite installation and like many people I wanted it as self-branded even though I keep a link back to wordpress.org in the footer. Is...
I personaly don't think you should really do this, and I would leave it there if I were you - it is in fact a way to support WordPress, and don't forget you got it for free. ;) but, if you really want to do it, go to /wp-admin/admin-header.php and remove `&#8212; WordPress` from this line: ``` <title><?php echo $tit...
5,155
<p>I display a random post loop on a page. I'd like to put a "refresh" link to refresh the content of the loop via ajax.</p> <p>Is this possible?</p> <p>This is my loop if it helps: </p> <pre><code> &lt;ul id="content-inner" class="thumb-grid clearfix"&gt; &lt;?php query_posts('posts_per_page=...
[ { "answer_id": 5159, "author": "PNMG", "author_id": 1756, "author_profile": "https://wordpress.stackexchange.com/users/1756", "pm_score": 1, "selected": false, "text": "<p>This plugin seems like it would do what you are looking for.</p>\n\n<p><a href=\"http://wordpress.org/extend/plugins...
2010/12/10
[ "https://wordpress.stackexchange.com/questions/5155", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1778/" ]
I display a random post loop on a page. I'd like to put a "refresh" link to refresh the content of the loop via ajax. Is this possible? This is my loop if it helps: ``` <ul id="content-inner" class="thumb-grid clearfix"> <?php query_posts('posts_per_page=20&orderby=rand'); ?> <?p...
Shouldn't be too tricky. First: create a javascript file and add this: ``` jQuery(document).ready(function($){ $('#refresh-links-id').click(function(e){ e.preventDefault(); $.post(ajaxurl,{action:'jpb_random_loop'}, function(data){ $('#content-inner').fadeOut(250).empty().append( data ).fadeIn(250); ...
5,157
<p>I'm simply looking to set certain meta boxes inactive. I know about remove_meta_box() but I only want to make them inactive so that the user is still able to turn them back on from the screen options tab at the top.</p> <p>I've used the Adminimize plugin (<a href="http://wordpress.org/extend/plugins/adminimize/" re...
[ { "answer_id": 5169, "author": "Denis de Bernardy", "author_id": 1208, "author_profile": "https://wordpress.stackexchange.com/users/1208", "pm_score": 2, "selected": false, "text": "<p>There's a default_hidden_meta_boxes filter which allows you to do that. It gets called like so:</p>\n\n...
2010/12/10
[ "https://wordpress.stackexchange.com/questions/5157", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1899/" ]
I'm simply looking to set certain meta boxes inactive. I know about remove\_meta\_box() but I only want to make them inactive so that the user is still able to turn them back on from the screen options tab at the top. I've used the Adminimize plugin (<http://wordpress.org/extend/plugins/adminimize/>) and it functions ...
There's a default\_hidden\_meta\_boxes filter which allows you to do that. It gets called like so: ``` $hidden = apply_filters('default_hidden_meta_boxes', $hidden, $screen); ```
5,160
<p>How difficult would it be to add an option for "nofollow" to the Link editor's existing "Link Relationship(XFN) options list?</p> <p>Alternately, or better yet, in addition, add an item to the "Bulk Actions" listing called "Make links no follow" that would make all selected links rel="nofollow".</p> <p>I'd like to...
[ { "answer_id": 5166, "author": "Denis de Bernardy", "author_id": 1208, "author_profile": "https://wordpress.stackexchange.com/users/1208", "pm_score": 0, "selected": false, "text": "<p>I'm not sure there's a filter or action in there. If so, reasonably easy. If not, use my External Links...
2010/12/10
[ "https://wordpress.stackexchange.com/questions/5160", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/366/" ]
How difficult would it be to add an option for "nofollow" to the Link editor's existing "Link Relationship(XFN) options list? Alternately, or better yet, in addition, add an item to the "Bulk Actions" listing called "Make links no follow" that would make all selected links rel="nofollow". I'd like to add this feature...
Alternatively you can undo the code that disables the relationship box by re-pointing the enqueue to the xfn.js script.. First create a modified version of that script, like so.. ``` jQuery(document).ready( function($) { //$('#link_rel').attr('readonly', 'readonly'); $('#linkxfndiv input').bind('click keyup',...
5,161
<p>I have a custom field called expiry_date with a value of let's say 2010-12-11 00:00:00.</p> <p>What I would like to do is, in my query loop, only return posts with this expiry_date custom field attached to posts and the following condition:</p> <ul> <li>The date in the expiry_date custom field has to be within 24 ...
[ { "answer_id": 5164, "author": "Denis de Bernardy", "author_id": 1208, "author_profile": "https://wordpress.stackexchange.com/users/1208", "pm_score": 0, "selected": false, "text": "<p>You're looking for a BETWEEN clause, which isn't supported off the top of my head.</p>\n\n<p>You might ...
2010/12/10
[ "https://wordpress.stackexchange.com/questions/5161", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18051/" ]
I have a custom field called expiry\_date with a value of let's say 2010-12-11 00:00:00. What I would like to do is, in my query loop, only return posts with this expiry\_date custom field attached to posts and the following condition: * The date in the expiry\_date custom field has to be within 24 hours of expiring,...
I agree with Denis, I don't like using custom fields for this kind of stuff, but I'm not aware of any other way yet... What you what can be done by altering the SQL query for the loop, something like this: ``` add_filter('posts_join', 'my_post_filter_join'); function my_post_filter_join($join) { global $wpdb; if(...
5,181
<p>i just want this code to be added in my functions.php, so that it will directly display after my post ends currently i am adding this code to my single.php, but i want to add this is in functions.php, this code is use to fetch all the tweets of the respective account, the code is here</p> <pre><code>&lt;?php functi...
[ { "answer_id": 5188, "author": "Denis de Bernardy", "author_id": 1208, "author_profile": "https://wordpress.stackexchange.com/users/1208", "pm_score": 2, "selected": false, "text": "<p>Using FTP, grab your theme's functions.php, and add the above code within it, minus the leading <code>&...
2010/12/11
[ "https://wordpress.stackexchange.com/questions/5181", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1743/" ]
i just want this code to be added in my functions.php, so that it will directly display after my post ends currently i am adding this code to my single.php, but i want to add this is in functions.php, this code is use to fetch all the tweets of the respective account, the code is here ``` <?php function parse_twitter_...
I'm not sure why you don't just insert the code in the single.php, or use Denis's solution, but if you want to hook into `the_content` you can do so by putting the following in your functions.php file: ``` function append_the_content($content) { $content .= 'PUT YOUR FUNCTION HERE'; return $content; } add_f...
5,182
<p>I am using Manifest 1.01 by Jim Barraud on my site www.inteftrust.org.</p> <p>I'd like to know how can I get full width with this theme. Thanks.</p>
[ { "answer_id": 5187, "author": "Denis de Bernardy", "author_id": 1208, "author_profile": "https://wordpress.stackexchange.com/users/1208", "pm_score": 0, "selected": false, "text": "<p>You would need to edit the css files and adjust width declarations as needed. Consider creating a child...
2010/12/11
[ "https://wordpress.stackexchange.com/questions/5182", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1677/" ]
I am using Manifest 1.01 by Jim Barraud on my site www.inteftrust.org. I'd like to know how can I get full width with this theme. Thanks.
yes, go to your /wp-content/themes/manifest\_v1.1/style.css and edit the following IDs to look like this: ``` #siteWrapper{ margin: 0 auto; padding-top: 15px; width: 97%; text-align: center; position: relative; } #coreContent{ float: auto; width: auto; margin-top: 8px; } #footer{ width: 97%; mar...
5,232
<p>I'd like to have my header banner change every day, chosen (e.g. randomly) from a list/folder of images.</p> <p>So far I only found plugins that select a random banner per post or per page view, neither is what I want. Do you know of a plugin, or any other way?</p> <p>Edit: Example. I'm adding a folder to my wordp...
[ { "answer_id": 5234, "author": "Denis de Bernardy", "author_id": 1208, "author_profile": "https://wordpress.stackexchange.com/users/1208", "pm_score": 1, "selected": false, "text": "<p>If you can't code, sorry no.</p>\n\n<p>If you can code, look at which hook these plugins are using, and...
2010/12/12
[ "https://wordpress.stackexchange.com/questions/5232", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/271/" ]
I'd like to have my header banner change every day, chosen (e.g. randomly) from a list/folder of images. So far I only found plugins that select a random banner per post or per page view, neither is what I want. Do you know of a plugin, or any other way? Edit: Example. I'm adding a folder to my wordpress installation...
``` <div id="header"> <?php mt_srand((int)date('z')); $headers=glob(PATH_TO_FILES .'/*.jpg'); $header=mt_rand(0,count($headers)-1 ); ?> <img id="header-image" `src="<?php echo URL_TO_FILES . '/'.basename($headers[$header]); ?>" alt="header" /> </div> ``` replace ...
5,237
<p>I am looking for a wordpress plugin that allows my users to customize which posts are appearing on the home page. The users should have a settings page where they can select which categories and tags they´d like to see posts from.</p> <p>Do you know if anything like that has been developed? Free or premium.</p>
[ { "answer_id": 5258, "author": "Steven", "author_id": 1447, "author_profile": "https://wordpress.stackexchange.com/users/1447", "pm_score": 0, "selected": false, "text": "<p>This code is untested, but put it in your function.php file ans see what happends.</p>\n\n<p>In theory this should...
2010/12/12
[ "https://wordpress.stackexchange.com/questions/5237", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I am looking for a wordpress plugin that allows my users to customize which posts are appearing on the home page. The users should have a settings page where they can select which categories and tags they´d like to see posts from. Do you know if anything like that has been developed? Free or premium.
> > I am looking for a wordpress plugin that allows my users to customize which posts are appearing on the home page. > > > Not sure there's any particular plugins for this, but it's certainly possible with a few functions. > > The users should have a settings page where they can select which categories and tags...
5,244
<p>I have a custom page template that loops through all custom posts with the post_type of "product_listing" AND the custom taxonomy "product_cat" of "shirts" and returns 4 posts per page (as seen below:)</p> <pre><code>&lt;?php $loop = new WP_Query( array( 'post_type' =&gt; 'product_listing', 'product_cat' =&gt; 'shi...
[ { "answer_id": 5258, "author": "Steven", "author_id": 1447, "author_profile": "https://wordpress.stackexchange.com/users/1447", "pm_score": 0, "selected": false, "text": "<p>This code is untested, but put it in your function.php file ans see what happends.</p>\n\n<p>In theory this should...
2010/12/13
[ "https://wordpress.stackexchange.com/questions/5244", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1663/" ]
I have a custom page template that loops through all custom posts with the post\_type of "product\_listing" AND the custom taxonomy "product\_cat" of "shirts" and returns 4 posts per page (as seen below:) ``` <?php $loop = new WP_Query( array( 'post_type' => 'product_listing', 'product_cat' => 'shirts', 'posts_per_pag...
> > I am looking for a wordpress plugin that allows my users to customize which posts are appearing on the home page. > > > Not sure there's any particular plugins for this, but it's certainly possible with a few functions. > > The users should have a settings page where they can select which categories and tags...
5,245
<p>How can I create a form that allows people to submit questions / ideas that once submitted creates a post in wordpress?</p>
[ { "answer_id": 5258, "author": "Steven", "author_id": 1447, "author_profile": "https://wordpress.stackexchange.com/users/1447", "pm_score": 0, "selected": false, "text": "<p>This code is untested, but put it in your function.php file ans see what happends.</p>\n\n<p>In theory this should...
2010/12/13
[ "https://wordpress.stackexchange.com/questions/5245", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1931/" ]
How can I create a form that allows people to submit questions / ideas that once submitted creates a post in wordpress?
> > I am looking for a wordpress plugin that allows my users to customize which posts are appearing on the home page. > > > Not sure there's any particular plugins for this, but it's certainly possible with a few functions. > > The users should have a settings page where they can select which categories and tags...
5,250
<p>I wonder if someone could help me.</p> <p>I just upgrade my wordpress and start to use taxonomy.</p> <p>what I want to do is to query posts from different categories.</p> <p>I used to do it like this <code>query_posts('cat=5');</code></p> <p>but with taxonomy added to my categories, doesnt work anymore for exam...
[ { "answer_id": 5301, "author": "joelhaus", "author_id": 164, "author_profile": "https://wordpress.stackexchange.com/users/164", "pm_score": 1, "selected": false, "text": "<p>As Bloch commented, 3.1 provides a way to easily accomplish this. Here's a terrific article describing exactly how...
2010/12/13
[ "https://wordpress.stackexchange.com/questions/5250", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I wonder if someone could help me. I just upgrade my wordpress and start to use taxonomy. what I want to do is to query posts from different categories. I used to do it like this `query_posts('cat=5');` but with taxonomy added to my categories, doesnt work anymore for example if I go to a category page the link go...
As Bloch commented, 3.1 provides a way to easily accomplish this. Here's a terrific article describing exactly how to execute [advanced taxonomy queries](http://ottopress.com/2010/wordpress-3-1-advanced-taxonomy-queries/). Here's the [plugin to run the 3.1 beta](http://wordpress.org/extend/plugins/wordpress-beta-tester...
5,256
<p>What is the "best" setup for <code>robots.txt</code>?<br> I'm using the following permalink structure <code>/%category%/%postname%/</code>.</p> <p>My <code>robots.txt</code> currently looks like this (copied from somewhere a long time ago):</p> <pre class="lang-bash prettyprint-override"><code>User-agent: * Disall...
[ { "answer_id": 5265, "author": "ZaMoose", "author_id": 61, "author_profile": "https://wordpress.stackexchange.com/users/61", "pm_score": 2, "selected": false, "text": "<p>Have you looked at Yoast's <a href=\"http://yoast.com/wordpress/seo/\" rel=\"nofollow\">WordPress SEO plugin</a>? It ...
2010/12/13
[ "https://wordpress.stackexchange.com/questions/5256", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1447/" ]
What is the "best" setup for `robots.txt`? I'm using the following permalink structure `/%category%/%postname%/`. My `robots.txt` currently looks like this (copied from somewhere a long time ago): ```bash User-agent: * Disallow: /cgi-bin Disallow: /wp-admin Disallow: /wp-includes Disallow: /wp-content/plugins Disa...
FWIW, trackback URLs issue redirects and have no content, so they won't get indexed. And at the risk of not answering the question, RE your points 2 and 3: <http://googlewebmastercentral.blogspot.com/2008/09/demystifying-duplicate-content-penalty.html> Put otherwise, I think you're wasting your time worrying about d...
5,289
<p>I am looking for SQL code that I can run from phpmyadmin to remove all registered users on the blog that do not have any post associated with them. </p>
[ { "answer_id": 5294, "author": "danhgilmore", "author_id": 819, "author_profile": "https://wordpress.stackexchange.com/users/819", "pm_score": 0, "selected": false, "text": "<p>I don't have ready access to the code, so I don't want to get too specific and quote the wrong functions, but i...
2010/12/13
[ "https://wordpress.stackexchange.com/questions/5289", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1945/" ]
I am looking for SQL code that I can run from phpmyadmin to remove all registered users on the blog that do not have any post associated with them.
``` <?php /** * Plugin Name: Delete Non Authors */ function delete_non_authors() { global $wpdb; $non_authors = $wpdb->get_col( "SELECT DISTINCT $wpdb->users.ID FROM $wpdb->users LEFT JOIN $wpdb->posts ON $wpdb->users.ID = $wpdb->posts.post_author WHERE $wpdb->posts.ID IS NULL" )...
5,297
<p>Here is my form:</p> <pre><code>&lt;form action="&lt;?php echo get_option('siteurl'); ?&gt;/wp-comments-post.php" method="post" id="commentform" class="validate"&gt; &lt;?php if($user_ID) : ?&gt; &lt;?php else : ?&gt; &lt;div class="label_container"&gt; &lt;div class="left"&gt; &lt;label...
[ { "answer_id": 5299, "author": "John P Bloch", "author_id": 11, "author_profile": "https://wordpress.stackexchange.com/users/11", "pm_score": 4, "selected": true, "text": "<p>First of all, I highly recommend using the <code>comment_form()</code> function. It's all of the above code in on...
2010/12/13
[ "https://wordpress.stackexchange.com/questions/5297", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1956/" ]
Here is my form: ``` <form action="<?php echo get_option('siteurl'); ?>/wp-comments-post.php" method="post" id="commentform" class="validate"> <?php if($user_ID) : ?> <?php else : ?> <div class="label_container"> <div class="left"> <label for="author" class="label label_name">Name*</label> ...
First of all, I highly recommend using the `comment_form()` function. It's all of the above code in one line (more if you need to tweak parts of the code). You can designate name and email as required in the settings section of your admin area: ![Discussion settings](https://i.stack.imgur.com/1yKva.png)
5,302
<p>I just installed a friends blog on my LAMP stack, which has mod_rewrite enabled (I'm using it for clean URLs on my Drupal installs on the same server). For some reason, WordPress (3.0.3) isn't recognizing that mod_rewrite is enabled. In the Permalinks menu it's displaying options for PATHINFO permalinks (with index....
[ { "answer_id": 5315, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 3, "selected": true, "text": "<blockquote>\n <p>The output of $_SERVER['SERVER_SOFTWARE'] is WebServerX</p>\n</blockquote>\n\n<p>That looks l...
2010/12/13
[ "https://wordpress.stackexchange.com/questions/5302", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1113/" ]
I just installed a friends blog on my LAMP stack, which has mod\_rewrite enabled (I'm using it for clean URLs on my Drupal installs on the same server). For some reason, WordPress (3.0.3) isn't recognizing that mod\_rewrite is enabled. In the Permalinks menu it's displaying options for PATHINFO permalinks (with index.p...
> > The output of $\_SERVER['SERVER\_SOFTWARE'] is WebServerX > > > That looks like your problem - check out this line in `wp-includes/vars.php`: ``` /** * Whether the server software is Apache or something else * @global bool $is_apache */ $is_apache = (strpos($_SERVER['SERVER_SOFTWARE'], 'Apache') !== false ...
5,305
<p>I have a plugin that expects there to be a default "uncategorized" category with ID=1. I've inadvertantly deleted the uncategorized category. Is it possible to recreate the category as ID=1?</p> <p>When I look at a default WP install, I see that the table "wp_terms" has uncategorized as the first record with id 1. ...
[ { "answer_id": 5306, "author": "Denis de Bernardy", "author_id": 1208, "author_profile": "https://wordpress.stackexchange.com/users/1208", "pm_score": 2, "selected": false, "text": "<p>It's an auto incrementing integer, so you can't using WP. But you can edit the term id and its taxonomy...
2010/12/13
[ "https://wordpress.stackexchange.com/questions/5305", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/366/" ]
I have a plugin that expects there to be a default "uncategorized" category with ID=1. I've inadvertantly deleted the uncategorized category. Is it possible to recreate the category as ID=1? When I look at a default WP install, I see that the table "wp\_terms" has uncategorized as the first record with id 1. It also a...
You need 3 steps: 1.Creating a term in wp\_terms with ID is 1 2.Insert a term\_taxanomy into wp\_term\_taxonomy with term\_id is 1, and taxonomy must be category 3.Insert a term\_relationships into wp\_term\_relationships with object\_id is 1 and term\_taxonomy\_id is 1 Run below code in PHPMYADMIN to re-create this...
5,308
<p>This is driving me nuts and I'm sure it's simple but nothing I search for comes up with a simple structure (everything is very complex).</p> <p>I have a custom post type <code>product_listing</code> and a custom taxonomy of <code>product_cat</code> (which is hierarchical and should be have like categories).</p> <p...
[ { "answer_id": 5309, "author": "Chris", "author_id": 1714, "author_profile": "https://wordpress.stackexchange.com/users/1714", "pm_score": 2, "selected": false, "text": "<p>I'm not sure wp supports that structure out of the box - but you can very easily create your own rewrite rules to d...
2010/12/13
[ "https://wordpress.stackexchange.com/questions/5308", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1663/" ]
This is driving me nuts and I'm sure it's simple but nothing I search for comes up with a simple structure (everything is very complex). I have a custom post type `product_listing` and a custom taxonomy of `product_cat` (which is hierarchical and should be have like categories). I simply want my URLs to look like thi...
Change `slug` in your post type arguments to `products/%product_cat%`, and `slug` in your taxonomy arguments to just `products`, then flush your rewrite rules. WordPress should now handle `/products/my-product-cat/post-name/`! Now finally, we need to help WordPress a little with generating permalinks (out of the box, ...
5,318
<p>The dashboard conveniently tells me how many posts, pages, and comments I have. I would like it to tell me how many articles, videos and cartoons I have too (three custom post types registered with my theme). How would I go about including these into the <em>"Right Now"</em> panel on the dashboard?</p> <p><img src=...
[ { "answer_id": 5320, "author": "Annika Backstrom", "author_id": 66, "author_profile": "https://wordpress.stackexchange.com/users/66", "pm_score": 4, "selected": true, "text": "<p>Yes, there are several actions within that widget, including <a href=\"http://core.trac.wordpress.org/browser...
2010/12/14
[ "https://wordpress.stackexchange.com/questions/5318", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/92/" ]
The dashboard conveniently tells me how many posts, pages, and comments I have. I would like it to tell me how many articles, videos and cartoons I have too (three custom post types registered with my theme). How would I go about including these into the *"Right Now"* panel on the dashboard? ![alt text](https://i.stac...
Yes, there are several actions within that widget, including [`right_now_content_table_end`](http://core.trac.wordpress.org/browser/tags/3.0.3/wp-admin/includes/dashboard.php#L285). Example: ``` function my_right_now() { $num_widgets = wp_count_posts( 'widget' ); $num = number_format_i18n( $num_widgets->publi...
5,331
<p>i have a function in my plugin <code>append_the_content($content)</code> this is used to display my function inside the post, but it is coming before the post, i want to make it after the post, for this i tried this code, but then too its not coming</p> <pre><code>function parse_twitter_feed($feed, $prefix, $tweetp...
[ { "answer_id": 5329, "author": "wilwaldon", "author_id": 1972, "author_profile": "https://wordpress.stackexchange.com/users/1972", "pm_score": 0, "selected": false, "text": "<p>I've used IMGUR plugin before and it worked without a hitch. </p>\n\n<p>Here's the plugin.</p>\n\n<p><a href=\"...
2010/12/14
[ "https://wordpress.stackexchange.com/questions/5331", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1743/" ]
i have a function in my plugin `append_the_content($content)` this is used to display my function inside the post, but it is coming before the post, i want to make it after the post, for this i tried this code, but then too its not coming ``` function parse_twitter_feed($feed, $prefix, $tweetprefix, $tweetsuffix, $suf...
Its not recommended often enough, but Flickr is an excellent image host for blogs as well. Their pro account costs only $25/year. You get unlimited image, video uploads and no bandwidth limit. If you don't want your blog image uploads populating your personal photostream, you can easily create a separate account for ...
5,349
<p>I have a PHP script that I need to run as a cron job. However this script needs access to the WP API (<code>get_pages()</code>, <code>get_post_meta()</code> and <code>get_permalink()</code> specifically). I've followed the instructions at <a href="http://codex.wordpress.org/Integrating_WordPress_with_Your_Website"...
[ { "answer_id": 5352, "author": "prettyboymp", "author_id": 203, "author_profile": "https://wordpress.stackexchange.com/users/203", "pm_score": 5, "selected": true, "text": "<p>WordPress expects the $_SERVER variables to be setup as if it were a normal web request. Also, I would suggest ...
2010/12/14
[ "https://wordpress.stackexchange.com/questions/5349", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1979/" ]
I have a PHP script that I need to run as a cron job. However this script needs access to the WP API (`get_pages()`, `get_post_meta()` and `get_permalink()` specifically). I've followed the instructions at <http://codex.wordpress.org/Integrating_WordPress_with_Your_Website>, but to no avail. Code: ``` require_once('....
WordPress expects the $\_SERVER variables to be setup as if it were a normal web request. Also, I would suggest loading wp-load.php instead of wp-blog-header.php since you probably don't need the WP class or the template loader to run. Here is how I normally start any scripts I need to interact with WP from command lin...
5,353
<p>I'm testing a script to create a database insert. Is this the correct syntax for the insert or do I need to obtain a reference to global $wpdb and use that?</p> <pre><code>&lt;?php /* Plugin Name: Test Database Insert */ function test_db_insert() { INSERT wp_terms(term_id, 'name', slug) VALUES (1, 'test', 'test');...
[ { "answer_id": 5355, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": true, "text": "<p>This seems like raw SQL that won't make sense to PHP at all.</p>\n\n<p>You can run this queries, as raw queries using ...
2010/12/14
[ "https://wordpress.stackexchange.com/questions/5353", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/366/" ]
I'm testing a script to create a database insert. Is this the correct syntax for the insert or do I need to obtain a reference to global $wpdb and use that? ``` <?php /* Plugin Name: Test Database Insert */ function test_db_insert() { INSERT wp_terms(term_id, 'name', slug) VALUES (1, 'test', 'test'); INSERT wp_term_t...
This seems like raw SQL that won't make sense to PHP at all. You can run this queries, as raw queries using `$wpdb->query()` but it's more proper to use its `$wpdb->insert()` method. See [wpdb Class > INSERT rows](http://codex.wordpress.org/Function_Reference/wpdb_Class#INSERT_rows) in Codex.
5,357
<p>I'm using wordpress for a large non-profit with many sites. I'd like to decrease the amount of installation steps for the people setting up their sites. Is it possible to make a WP install that automatically activates the plugins, themes and default content I choose?</p>
[ { "answer_id": 5360, "author": "Denis de Bernardy", "author_id": 1208, "author_profile": "https://wordpress.stackexchange.com/users/1208", "pm_score": 4, "selected": true, "text": "<p>Sure. <code>wp_install_defaults()</code> is a pluggable function. (As are wp_new_blog_notification() and...
2010/12/14
[ "https://wordpress.stackexchange.com/questions/5357", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1925/" ]
I'm using wordpress for a large non-profit with many sites. I'd like to decrease the amount of installation steps for the people setting up their sites. Is it possible to make a WP install that automatically activates the plugins, themes and default content I choose?
Sure. `wp_install_defaults()` is a pluggable function. (As are wp\_new\_blog\_notification() and wp\_upgrade(), in case you ever need to override those too.) ``` # in wp-config.php if ( defined('WP_INSTALLING') && WP_INSTALLING ) { include_once dirname(__FILE__) . '/wp-content/install.php'; } # in wp-content/instal...
5,358
<p>Basically I want to develop the ability to search comments on my site. A form with input field where the visitor can enter a search string, which tells WP to display only comments that contain that search phrase.</p> <p>I think the best way to do this is by making a custom <a href="http://core.trac.wordpress.org/br...
[ { "answer_id": 5377, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 3, "selected": true, "text": "<p>You create your own <code>comments_template</code>, it can be a duplicate function of the default one, the on...
2010/12/14
[ "https://wordpress.stackexchange.com/questions/5358", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/600/" ]
Basically I want to develop the ability to search comments on my site. A form with input field where the visitor can enter a search string, which tells WP to display only comments that contain that search phrase. I think the best way to do this is by making a custom [comments\_template()](http://core.trac.wordpress.or...
You create your own `comments_template`, it can be a duplicate function of the default one, the only changes are the database queries anyway. But you need your own function as WP doesn't help you with filters here. SO, name it `my_comments_template()`: ``` $filter = mysql_real_escape_string($_POST['comment-filter'])...
5,362
<p>I'm having a problem here:</p> <p>I am passing this through a custom field: <code>http://www.youtube.com/watch?v=E6P1Q-UycHA&amp;autoplay=1</code></p> <p>(notice the <code>autoplay=1</code>) </p> <p>But when I load the video on my theme using wp_oembed_get... it displays the video fine, but it does not listen to ...
[ { "answer_id": 5369, "author": "t31os", "author_id": 31073, "author_profile": "https://wordpress.stackexchange.com/users/31073", "pm_score": 0, "selected": false, "text": "<p>Anything <strong>after the first parameter</strong> must be sent as an array of arguments. </p>\n\n<p>See the ex...
2010/12/14
[ "https://wordpress.stackexchange.com/questions/5362", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1983/" ]
I'm having a problem here: I am passing this through a custom field: `http://www.youtube.com/watch?v=E6P1Q-UycHA&autoplay=1` (notice the `autoplay=1`) But when I load the video on my theme using wp\_oembed\_get... it displays the video fine, but it does not listen to the `autoplay=1` variable I am passing through. ...
Those are not really arguments like for YouTube, more of arguments for WordPress itself. One way to handle it would be to access your argument later inside of a filter and modify HTML output. Pass in arguments array: ``` wp_oembed_get( 'http://www.youtube.com/watch?v=', array( 'autoplay' => 1 ) ); ``` And filter: ...
5,365
<p>I am looking for a way that I could add some code to my wordpress template to display the time of a post in relative terms. So if, for example, I posted something 5 minutes ago it would say something along the lines of Posted 6 minutes ago or 2 days ago, or 1 week ago. You get the idea. Could anyone give me some gui...
[ { "answer_id": 5366, "author": "John P Bloch", "author_id": 11, "author_profile": "https://wordpress.stackexchange.com/users/11", "pm_score": 3, "selected": true, "text": "<p>WordPress actually has an obscure and little known function called <code>human_time_diff()</code> that does this....
2010/12/14
[ "https://wordpress.stackexchange.com/questions/5365", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1333/" ]
I am looking for a way that I could add some code to my wordpress template to display the time of a post in relative terms. So if, for example, I posted something 5 minutes ago it would say something along the lines of Posted 6 minutes ago or 2 days ago, or 1 week ago. You get the idea. Could anyone give me some guidan...
WordPress actually has an obscure and little known function called `human_time_diff()` that does this. It takes two arguments; the first is the earlier timestamp, and the second is the later timestamp. Both should be Unix timestamps. The first argument is required, but the second is optional, and will use `time()` if l...
5,394
<p>I would very much like to know if there is a widget that exists that would let me show the current page's associated taxonomy terms (preferably hierarchically) in a widget.</p> <p>For example, if the current post has a Taxonomy term "Tom Hanks" in the Taxonomy of "Actor", the widget would list "Actor" then "Tom Han...
[ { "answer_id": 5399, "author": "Niraj Chauhan", "author_id": 1743, "author_profile": "https://wordpress.stackexchange.com/users/1743", "pm_score": 0, "selected": false, "text": "<p>if i am not wrong you want something like this:\nthere is a plugin which displays the custom taxonomy which...
2010/12/15
[ "https://wordpress.stackexchange.com/questions/5394", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1990/" ]
I would very much like to know if there is a widget that exists that would let me show the current page's associated taxonomy terms (preferably hierarchically) in a widget. For example, if the current post has a Taxonomy term "Tom Hanks" in the Taxonomy of "Actor", the widget would list "Actor" then "Tom Hanks". Even ...
This is a simple conversion of the Taxonomy terms list plugin to a widget: ``` class WPSE_5394_Widget extends WP_Widget { public function __construct() { parent::__construct( 'wpse5394_widget', 'Taxonomy Terms List' ); } public function widget( $sidebar_args, $widget_options ) { if...
5,400
<p>Just a quick question that might help a tad bit with security. I noticed that the readme.html file has the version number listed. It reappears after each upgrade and so do the licence.txt, and wp-config-sample.php.</p> <p>Is there a easy way to have WordPress auto remove these files after an upgrade?</p> <p>I alr...
[ { "answer_id": 5402, "author": "Atif", "author_id": 1555, "author_profile": "https://wordpress.stackexchange.com/users/1555", "pm_score": 2, "selected": false, "text": "<pre><code>add_action('core_upgrade_preamble','my_function_to_delete_files');\n</code></pre>\n\n<p>Edit : you can also ...
2010/12/15
[ "https://wordpress.stackexchange.com/questions/5400", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1493/" ]
Just a quick question that might help a tad bit with security. I noticed that the readme.html file has the version number listed. It reappears after each upgrade and so do the licence.txt, and wp-config-sample.php. Is there a easy way to have WordPress auto remove these files after an upgrade? I already block the ver...
You don't really need to remove these files. It's much easier to just block access to them. If you are using pretty URL's you already have an .htaccess file. Using .htaccess to block the files is secure and you only have to add a directive once. Blocking files is done by adding a directive to .htaccess like this: ```...
5,419
<p>How do I add a link to a PDF in the content, so that it downloads rather than opens in the browser windows? (I've uploaded the PDF to the media library and can insert the link but can't find an option to prevent it opening in the browser window).</p> <p>Thanks,</p> <p>Lucy</p>
[ { "answer_id": 5420, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 2, "selected": false, "text": "<p>Actually, that's entirely dependent on the browser. Some browsers will open a PDF in the window using a built-in PDF ...
2010/12/15
[ "https://wordpress.stackexchange.com/questions/5419", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1786/" ]
How do I add a link to a PDF in the content, so that it downloads rather than opens in the browser windows? (I've uploaded the PDF to the media library and can insert the link but can't find an option to prevent it opening in the browser window). Thanks, Lucy
you may try to add this to your .htaccess : ``` <FilesMatch "\.(?i:pdf)$"> # Force File Download ForceType application/octet-stream Header set Content-Disposition attachment </FilesMatch> ```
5,426
<p>I have a little bug on my WordPress...</p> <p>When I added a custom field, I have no ajax, I need to saved the draft or publish to see the update.</p> <p>And after I saved my post, the custom field display twice.</p> <pre><code>name : Steffi name : Steffi </code></pre> <p>Help, please ! Thanks </p> <p><str...
[ { "answer_id": 5429, "author": "kevin", "author_id": 1997, "author_profile": "https://wordpress.stackexchange.com/users/1997", "pm_score": 0, "selected": false, "text": "<p>Try this:</p>\n\n<p>Add this to your config.php file: </p>\n\n<p>define( 'CONCATENATE_SCRIPTS', false );</p>\n\n<p>...
2010/12/15
[ "https://wordpress.stackexchange.com/questions/5426", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2000/" ]
I have a little bug on my WordPress... When I added a custom field, I have no ajax, I need to saved the draft or publish to see the update. And after I saved my post, the custom field display twice. ``` name : Steffi name : Steffi ``` Help, please ! Thanks **Update :** *Console with Firebug* ``` _ajax_non...
Hey guys, I found **THE** solution. Problems : * Custom field display twice. * No Ajax/jQuery visual feedback. If you've been working on the file `function.php`, make sure you remove extra line breaks. Particularly at the top and `the bottom of your file`... If you have some line breaks, your xml got an error : `...
5,444
<p>I'm creating a separate (simple) directory that does not use any internal WP permalinks or pretty link structure. I've been studying how to make my own custom SEF URLs for <em>this</em> part of my site, and almost have it (or thought so). </p> <p>I have a separate table with records like this:</p> <pre><code>id ...
[ { "answer_id": 5429, "author": "kevin", "author_id": 1997, "author_profile": "https://wordpress.stackexchange.com/users/1997", "pm_score": 0, "selected": false, "text": "<p>Try this:</p>\n\n<p>Add this to your config.php file: </p>\n\n<p>define( 'CONCATENATE_SCRIPTS', false );</p>\n\n<p>...
2010/12/15
[ "https://wordpress.stackexchange.com/questions/5444", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2006/" ]
I'm creating a separate (simple) directory that does not use any internal WP permalinks or pretty link structure. I've been studying how to make my own custom SEF URLs for *this* part of my site, and almost have it (or thought so). I have a separate table with records like this: ``` id | section | category ...
Hey guys, I found **THE** solution. Problems : * Custom field display twice. * No Ajax/jQuery visual feedback. If you've been working on the file `function.php`, make sure you remove extra line breaks. Particularly at the top and `the bottom of your file`... If you have some line breaks, your xml got an error : `...
5,450
<p>This plugin is a simple demo test to see if I can dynamically populate a pre-existing widget area with text. In this case, my theme has created the widget area "home-header-widget" and I'm trying to populate it with the contents of 'text' below. I'm stuck at the line...</p> <pre><code>$sidebars_widgets[$sidebar_id]...
[ { "answer_id": 5429, "author": "kevin", "author_id": 1997, "author_profile": "https://wordpress.stackexchange.com/users/1997", "pm_score": 0, "selected": false, "text": "<p>Try this:</p>\n\n<p>Add this to your config.php file: </p>\n\n<p>define( 'CONCATENATE_SCRIPTS', false );</p>\n\n<p>...
2010/12/15
[ "https://wordpress.stackexchange.com/questions/5450", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/366/" ]
This plugin is a simple demo test to see if I can dynamically populate a pre-existing widget area with text. In this case, my theme has created the widget area "home-header-widget" and I'm trying to populate it with the contents of 'text' below. I'm stuck at the line... ``` $sidebars_widgets[$sidebar_id] = "widget_tex...
Hey guys, I found **THE** solution. Problems : * Custom field display twice. * No Ajax/jQuery visual feedback. If you've been working on the file `function.php`, make sure you remove extra line breaks. Particularly at the top and `the bottom of your file`... If you have some line breaks, your xml got an error : `...
5,453
<p>I don't need to search for pages in my site and only want to search posts, is there a way to do it? Thanks</p>
[ { "answer_id": 5457, "author": "andrewk", "author_id": 1043, "author_profile": "https://wordpress.stackexchange.com/users/1043", "pm_score": 1, "selected": false, "text": "<p>put this in your search.php </p>\n\n<p><code>&lt;?php if (is_search() &amp;&amp; ($post-&gt;post_type=='page')) c...
2010/12/16
[ "https://wordpress.stackexchange.com/questions/5453", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I don't need to search for pages in my site and only want to search posts, is there a way to do it? Thanks
The below should make the page post type no longer search-able. ``` function remove_pages_from_search() { global $wp_post_types; $wp_post_types['page']->exclude_from_search = true; } add_action('init', 'remove_pages_from_search'); ```
5,477
<p>my question may look like <a href="https://wordpress.stackexchange.com/questions/4696/pagination-not-working-with-custom-loop">Pagination not working with custom loop</a>, but there is a different. I use the custom loop for display flash game. I want to make a pagination on page games by category. category.php :</p>...
[ { "answer_id": 5479, "author": "Steven", "author_id": 1447, "author_profile": "https://wordpress.stackexchange.com/users/1447", "pm_score": 0, "selected": false, "text": "<p>Looks like youa re using <a href=\"http://lesterchan.net/wordpress\" rel=\"nofollow\">wp-pagenavi from Lester Chan...
2010/12/16
[ "https://wordpress.stackexchange.com/questions/5477", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1301/" ]
my question may look like [Pagination not working with custom loop](https://wordpress.stackexchange.com/questions/4696/pagination-not-working-with-custom-loop), but there is a different. I use the custom loop for display flash game. I want to make a pagination on page games by category. category.php : ``` <?php if ($c...
If this is the main loop you use to display posts on your page, you should not execute a new loop but modify the existing loop that WordPress will execute anyway. This way you can be sure that all extra query parameters will be taken into account. Here we want to display posts of type `game` and limit the number of po...
5,483
<p>I'm using a custom post type for a portfolio. I have a few option in there, bring saved by <code>update_post_meta()</code>, it seems to work fine, but then out of the blue (within the hour), the data deletes its self. I have looked in the DB and all custom metadata values are empty.</p> <p>I'm a little stumped real...
[ { "answer_id": 5479, "author": "Steven", "author_id": 1447, "author_profile": "https://wordpress.stackexchange.com/users/1447", "pm_score": 0, "selected": false, "text": "<p>Looks like youa re using <a href=\"http://lesterchan.net/wordpress\" rel=\"nofollow\">wp-pagenavi from Lester Chan...
2010/12/16
[ "https://wordpress.stackexchange.com/questions/5483", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1095/" ]
I'm using a custom post type for a portfolio. I have a few option in there, bring saved by `update_post_meta()`, it seems to work fine, but then out of the blue (within the hour), the data deletes its self. I have looked in the DB and all custom metadata values are empty. I'm a little stumped really. Here's the code ...
If this is the main loop you use to display posts on your page, you should not execute a new loop but modify the existing loop that WordPress will execute anyway. This way you can be sure that all extra query parameters will be taken into account. Here we want to display posts of type `game` and limit the number of po...
5,495
<p>I have a need to customize some posts from the loop.<br> Here's the deal: My site is set to 10 posts per page. On post #2,#5, #7 (on every page), I want to display specific background. What's the best solution for this kind of problem?</p>
[ { "answer_id": 5496, "author": "John P Bloch", "author_id": 11, "author_profile": "https://wordpress.stackexchange.com/users/11", "pm_score": 3, "selected": true, "text": "<p>This should do it:</p>\n\n<pre><code>$real_current_post = $wp_query-&gt;current_post + 1;\nswitch( $real_current_...
2010/12/16
[ "https://wordpress.stackexchange.com/questions/5495", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/127/" ]
I have a need to customize some posts from the loop. Here's the deal: My site is set to 10 posts per page. On post #2,#5, #7 (on every page), I want to display specific background. What's the best solution for this kind of problem?
This should do it: ``` $real_current_post = $wp_query->current_post + 1; switch( $real_current_post ){ case 2: // Do something for 2 break; case 5: // Do something for 5 break; case 7: // Do something for 7 break; } ``` You may need to globalize $wp\_query, but as long as you're using t...
5,503
<p>Basically we're (ab)using Category to determine whether a post is a News post or a Blog post, and so it's not a category in the traditional sense to the outside world. I'd like the category to not be indexed by feed-readers/crawlers, only the tags. </p> <p>I found an easy way to do it with an easy change to 1 fun...
[ { "answer_id": 5507, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": true, "text": "<p>Tricky. It lumps categories and tags together pretty good. Had couple of approaches here is least messy:</p>\n\n<pre><...
2010/12/16
[ "https://wordpress.stackexchange.com/questions/5503", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1803/" ]
Basically we're (ab)using Category to determine whether a post is a News post or a Blog post, and so it's not a category in the traditional sense to the outside world. I'd like the category to not be indexed by feed-readers/crawlers, only the tags. I found an easy way to do it with an easy change to 1 function in the...
Tricky. It lumps categories and tags together pretty good. Had couple of approaches here is least messy: ``` add_filter('the_category_rss', 'remove_rss_categories'); function remove_rss_categories( $the_list ) { $categories = get_the_category(); foreach ($categories as $category) $the_list = str_rep...
5,508
<p>What’s the best way to make Wordpress accept non-unique sub-category slugs?</p> <p>By default, Wordpress ensures that every ‘slug’ portion of permalink URLs is unique, and is very savvy about using this to ensure you never see a 404 from omitting a portion of the URL. This means if my permalink structure is…</p> <...
[ { "answer_id": 5507, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": true, "text": "<p>Tricky. It lumps categories and tags together pretty good. Had couple of approaches here is least messy:</p>\n\n<pre><...
2010/12/16
[ "https://wordpress.stackexchange.com/questions/5508", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2027/" ]
What’s the best way to make Wordpress accept non-unique sub-category slugs? By default, Wordpress ensures that every ‘slug’ portion of permalink URLs is unique, and is very savvy about using this to ensure you never see a 404 from omitting a portion of the URL. This means if my permalink structure is… <http://site-ro...
Tricky. It lumps categories and tags together pretty good. Had couple of approaches here is least messy: ``` add_filter('the_category_rss', 'remove_rss_categories'); function remove_rss_categories( $the_list ) { $categories = get_the_category(); foreach ($categories as $category) $the_list = str_rep...
5,515
<p>I've posted a bug-report about this a few months ago (<a href="http://core.trac.wordpress.org/ticket/14686">on WordPress trac (Widget Instance Form Update Bug)</a>) and I thought I'd try writing about it here too. Maybe someone has a better solution to this issue than me.</p> <p>Basically the problem is that if you...
[ { "answer_id": 10586, "author": "mfields", "author_id": 11019, "author_profile": "https://wordpress.stackexchange.com/users/11019", "pm_score": 4, "selected": true, "text": "<p>I did battle with a similar situation recently. Ajax in widgets is no joke! Need to write some pretty crazy cod...
2010/12/17
[ "https://wordpress.stackexchange.com/questions/5515", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1986/" ]
I've posted a bug-report about this a few months ago ([on WordPress trac (Widget Instance Form Update Bug)](http://core.trac.wordpress.org/ticket/14686)) and I thought I'd try writing about it here too. Maybe someone has a better solution to this issue than me. Basically the problem is that if you drop a widget into a...
I did battle with a similar situation recently. Ajax in widgets is no joke! Need to write some pretty crazy code to get things to work across instances. I'm not familiar with live query, but if you say it checks the DOM every second, I might have a less intense solution for you: ``` var get_widget_id = function ( sele...
5,536
<p>I'm trying to output a unique widget ID inside my mult-instance widgets. So far the following hasn't worked. Is there a unique ID and how do I call it?</p> <p>Thanks.</p> <pre><code>function widget($args, $instance) { // outputs the content of the widget extract( $args ); $widget_id = $instance['widget_id'...
[ { "answer_id": 5538, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 5, "selected": true, "text": "<p>You can get the instance ID with <code>echo $this-&gt;id;</code> (<code>$this</code> is the class instance)</...
2010/12/17
[ "https://wordpress.stackexchange.com/questions/5536", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1925/" ]
I'm trying to output a unique widget ID inside my mult-instance widgets. So far the following hasn't worked. Is there a unique ID and how do I call it? Thanks. ``` function widget($args, $instance) { // outputs the content of the widget extract( $args ); $widget_id = $instance['widget_id']; ?> <?php echo ...
You can get the instance ID with `echo $this->id;` (`$this` is the class instance) The only time you can't get this id is from the `form()` function, right after you just dropped the widget ([here](https://wordpress.stackexchange.com/questions/5515/update-widget-form-after-drag-and-drop-wp-save-bug)'s the reason why)
5,544
<p>I'm curious if its possible (and advisable) to change certain directory names and URL structure via customization by themes or plugins. For example, say I wanted the list of all a user's posts to appear at blog.com/people/username instead of at blog.com/author/username...is this possible via customization? If so, ...
[ { "answer_id": 5550, "author": "kureikain", "author_id": 1969, "author_profile": "https://wordpress.stackexchange.com/users/1969", "pm_score": 0, "selected": false, "text": "<p>You can use filter generate_rewrite_rules to add new custom url! The first, you add filter to create url! Secon...
2010/12/17
[ "https://wordpress.stackexchange.com/questions/5544", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I'm curious if its possible (and advisable) to change certain directory names and URL structure via customization by themes or plugins. For example, say I wanted the list of all a user's posts to appear at blog.com/people/username instead of at blog.com/author/username...is this possible via customization? If so, would...
@kureikain's answer looks great, and it probably works really well in a wide variety of circumstances. But for author URLs specifically, there's a simpler way. Change the author\_base, like so: ``` global $wp_rewrite; $wp_rewrite->author_base = "people"; $wp_rewrite->flush_rules(); ``` You should only need to run t...
5,545
<p>I have a bunch of pages and I only want to include 2 or 3 pages on my main menu. How would I do that? Currently my code looks like this:</p> <pre><code>wp_page_menu('include=156,572,542&amp;sort_column=menu_order&amp;echo=0'); </code></pre> <p>If I am going to insert <code>exclude=x pages</code>, it wouldn't make ...
[ { "answer_id": 5548, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 2, "selected": true, "text": "<p>try</p>\n\n<pre><code> ...\n echo preg_replace('/&lt;ul&gt;/', '&lt;ul class=\"sf-menu\"&gt;', \n w...
2010/12/17
[ "https://wordpress.stackexchange.com/questions/5545", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1649/" ]
I have a bunch of pages and I only want to include 2 or 3 pages on my main menu. How would I do that? Currently my code looks like this: ``` wp_page_menu('include=156,572,542&sort_column=menu_order&echo=0'); ``` If I am going to insert `exclude=x pages`, it wouldn't make sense because there's just too many of them. ...
try ``` ... echo preg_replace('/<ul>/', '<ul class="sf-menu">', wp_page_menu( array( 'include' => '11,13,7,9,4', 'sort_column' => 'menu_order', 'echo' => 0)), 1); ``` or ``` ... echo preg_replace('/<ul>/', '<ul class="sf-menu">', wp_page_menu( ...
5,546
<p>Currently I have the loop listing posts between two dates using the <code>posts_where</code> filter: </p> <pre><code> function filter_where( $where = '' ) { $where .= " AND post_date &gt;= '2000-01-01' AND post_date &lt;= 2004-12-31' "; return where; } add_filter('posts_where', 'filter_where'); query_posts(...
[ { "answer_id": 5558, "author": "maduroblanco", "author_id": 2039, "author_profile": "https://wordpress.stackexchange.com/users/2039", "pm_score": 4, "selected": true, "text": "<p>Thanks to <a href=\"https://wordpress.stackexchange.com/users/1986/ambitiousamoeba\">AmbitiousAmoeba</a> for ...
2010/12/17
[ "https://wordpress.stackexchange.com/questions/5546", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2039/" ]
Currently I have the loop listing posts between two dates using the `posts_where` filter: ``` function filter_where( $where = '' ) { $where .= " AND post_date >= '2000-01-01' AND post_date <= 2004-12-31' "; return where; } add_filter('posts_where', 'filter_where'); query_posts($query_string); while (have_pos...
Thanks to [AmbitiousAmoeba](https://wordpress.stackexchange.com/users/1986/ambitiousamoeba) for the answer. The following improved code solves the problem: ``` function filter_where( $where = '' ) { global $wpdb; $where .= " AND (($wpdb->postmeta.meta_key = 'original_date' AND $wpdb->postmeta.meta_value >= '200...
5,547
<p>The following url resolves to the category template: <a href="http://localhost/author/myusername/?category_name=somecategory" rel="nofollow">http://localhost/author/myusername/?category_name=somecategory</a></p> <p>I have a <code>category-somecategory.php</code> template and just a generic <code>author.php</code> t...
[ { "answer_id": 5560, "author": "matt", "author_id": 765, "author_profile": "https://wordpress.stackexchange.com/users/765", "pm_score": 0, "selected": false, "text": "<p>Seems like this could be done with <a href=\"http://codex.wordpress.org/Custom_Queries\" rel=\"nofollow\">Custom Queri...
2010/12/17
[ "https://wordpress.stackexchange.com/questions/5547", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1803/" ]
The following url resolves to the category template: <http://localhost/author/myusername/?category_name=somecategory> I have a `category-somecategory.php` template and just a generic `author.php` template. Is there any way to make such a url use the `author.php` template instead of the `category-somecategory.php`? If ...
You could change the template loaded by hooking onto `template_include`, checking if `is_author` and `is_category` are both set, then switch the template for inclusion to the author template instead. Give this a shot.. ``` add_filter( 'template_include', 'my_template_setter' ); function my_template_setter( $template ...
5,568
<p>I'm working on a site based on a fluid width css template which sets a max-width on images to the width of the column containing them, and I need to remove the inline <strong>width</strong> and <strong>height</strong> dimension attributes that WordPress adds to images.</p> <p>I'm doing it with my featured images wi...
[ { "answer_id": 5574, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 0, "selected": false, "text": "<p>Applying that filter to <code>the_content</code> will fire it for all content. This will be effective, but could affe...
2010/12/18
[ "https://wordpress.stackexchange.com/questions/5568", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/290/" ]
I'm working on a site based on a fluid width css template which sets a max-width on images to the width of the column containing them, and I need to remove the inline **width** and **height** dimension attributes that WordPress adds to images. I'm doing it with my featured images with this filter: ``` add_filter( 'po...
Thanks all! The **image\_send\_to\_editor** filter was the one I was looking for... thanks @t31os for pointing it out. Here's my functions now. ``` add_filter( 'post_thumbnail_html', 'remove_thumbnail_dimensions', 10 ); add_filter( 'image_send_to_editor', 'remove_thumbnail_dimensions', 10 ); function remove_thumbna...
5,584
<p>So I'm having an issue with my custom fields in my custom post type. For whatever reason the fields save and then clear somewhat randomly... I'm sure it's not random but I'm not sure what's triggering this to happen. Here's the code for my custom post type:</p> <pre><code> // Custom Post Type: Strategic Giving a...
[ { "answer_id": 5589, "author": "t31os", "author_id": 31073, "author_profile": "https://wordpress.stackexchange.com/users/31073", "pm_score": 2, "selected": false, "text": "<p>Apparently de-registering the autosave javascript will essentially stop the autosave routine running. It won't ne...
2010/12/18
[ "https://wordpress.stackexchange.com/questions/5584", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2050/" ]
So I'm having an issue with my custom fields in my custom post type. For whatever reason the fields save and then clear somewhat randomly... I'm sure it's not random but I'm not sure what's triggering this to happen. Here's the code for my custom post type: ``` // Custom Post Type: Strategic Giving add_action('ini...
That's an easy one :) ``` add_action( 'admin_enqueue_scripts', 'my_admin_enqueue_scripts' ); function my_admin_enqueue_scripts() { if ( 'your_post_type' == get_post_type() ) wp_dequeue_script( 'autosave' ); } ```
5,595
<p>I want to edit my permalink structure so that individual post URLs are structured like this...blog.com/p1, blog.com/p2, blog.com/p523, etc</p> <p>I also want to edit my permalink structure so that comment URLs are structured like this this...blog.com/c1, blog.com/c2, blog.com/c324, etc</p> <p>Are these two things ...
[ { "answer_id": 5596, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>Separate pages for individual comments seems like what <a href=\"http://wordpress.org/extend/plugins/seo-super-commen...
2010/12/18
[ "https://wordpress.stackexchange.com/questions/5595", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I want to edit my permalink structure so that individual post URLs are structured like this...blog.com/p1, blog.com/p2, blog.com/p523, etc I also want to edit my permalink structure so that comment URLs are structured like this this...blog.com/c1, blog.com/c2, blog.com/c324, etc Are these two things possible via the ...
You can change the permalink setting to `/p%post_id%`, but this will also set the `front` property of the `WP_Rewrite` object to `/p`, so some URLs will also get this in front (`/pauthor` for example). You can counter this by changing the `$wp_rewrite->front` property again: ``` add_action( 'permalink_structure_change...
5,600
<p>I have this loop in my wordpress site which displays the latest posts with their titles, I want to display the post content after the title. I normally retrieve it with the function get_the_content but I cannot make it work in this case. This is the loop:</p> <pre><code> while ( $q_query-&gt;have_posts() ) { ...
[ { "answer_id": 5602, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 3, "selected": true, "text": "<p>try this instead:</p>\n\n<pre><code>...\n\nglobal $post;\nwhile ($q_query-&gt;have_posts()){\n $q_query-&gt;...
2010/12/18
[ "https://wordpress.stackexchange.com/questions/5600", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I have this loop in my wordpress site which displays the latest posts with their titles, I want to display the post content after the title. I normally retrieve it with the function get\_the\_content but I cannot make it work in this case. This is the loop: ``` while ( $q_query->have_posts() ) { $q_query->n...
try this instead: ``` ... global $post; while ($q_query->have_posts()){ $q_query->the_post(); $loophtml .= "<li><span class='list-question-title'>" . "<a class='list-answer-link' href='" . get_permalink() ."'>" . get_the_title() . "</a></span>"; $loophtml .= get_the_content(); $loophtml .= "<span class='list...
5,610
<p>let's say I have posts with hundreds of comments, and that I want to show only the last N comments and then a link to a page read them all. How would I display the last N comments?</p> <p>Thank you, Dino. </p>
[ { "answer_id": 5611, "author": "t31os", "author_id": 31073, "author_profile": "https://wordpress.stackexchange.com/users/31073", "pm_score": 1, "selected": false, "text": "<p>See.<br>\n<a href=\"http://codex.wordpress.org/Function_Reference/get_comments\" rel=\"nofollow\">http://codex.wo...
2010/12/19
[ "https://wordpress.stackexchange.com/questions/5610", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2057/" ]
let's say I have posts with hundreds of comments, and that I want to show only the last N comments and then a link to a page read them all. How would I display the last N comments? Thank you, Dino.
See. <http://codex.wordpress.org/Function_Reference/get_comments> Set the orderby parameter to your desired value, possible values are. ``` comment_agent comment_approved comment_author comment_author_email comment_author_IP comment_author_url comment_content comment_date comment_date_gmt comment_ID comment_karma ...
5,616
<p>Hi I made a theme options by <a href="http://www.vitali-software.com/web-design/wordpress-tutorial-add-an-options-page-to-your-wp-theme/" rel="nofollow noreferrer">this tutorial</a></p> <p>This options have multicheck type by checkboxes. I don't know how to make it work. I'm try to exclude page using this multichec...
[ { "answer_id": 5618, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 1, "selected": false, "text": "<p><strike>Assuming your back-end works, and you can check multiple fields, and that the field values are reall...
2010/12/19
[ "https://wordpress.stackexchange.com/questions/5616", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1752/" ]
Hi I made a theme options by [this tutorial](http://www.vitali-software.com/web-design/wordpress-tutorial-add-an-options-page-to-your-wp-theme/) This options have multicheck type by checkboxes. I don't know how to make it work. I'm try to exclude page using this multicheck. This is my array with options: ``` $pages =...
Want some honest advice? Work from a better code base.. Though, it's not your fault, there are hundreds of blogs with variations of similar code, i'm not sure where it originated, but i see similar code "alot"... If you can get by without the hand holding and just manage with a good code base, i'd suggest the followi...
5,624
<p>I was editing a wordpress theme. Where i need to replace default wp login link with custom login link.</p> <p>Problem is, <code>comment_reply_link()</code> function is returning the default link. And i dont want to edit wp-include/comment-template.php</p> <p>Is there any other way, so that without manipulation of ...
[ { "answer_id": 5625, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>I am not sure if you copy/pasted wrong line or misunderstanding how to add filter. <a href=\"http://codex.wordpress.o...
2010/12/19
[ "https://wordpress.stackexchange.com/questions/5624", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/958/" ]
I was editing a wordpress theme. Where i need to replace default wp login link with custom login link. Problem is, `comment_reply_link()` function is returning the default link. And i dont want to edit wp-include/comment-template.php Is there any other way, so that without manipulation of any wordpress file i can rep...
you can simple make a check if user is logged in and show him the reply button, if is not you can show him a custom link to your login file. something like this: ``` <?php if ( !is_user_logged_in() ) : ?> <a href="<?php bloginfo('url'); ?>/login"><?php _e('Reply', 'artdev'); ?></a> <?php else : ?> <?php comme...
5,629
<p>Does anyone know of a galley plug-in which would have this kind of functionality?</p> <pre><code>------------------------------------------- | | | | | | | |...
[ { "answer_id": 5631, "author": "Grant Palin", "author_id": 99, "author_profile": "https://wordpress.stackexchange.com/users/99", "pm_score": 1, "selected": false, "text": "<p>If you use Flickr, you can use the <a href=\"http://tantannoodles.com/toolkit/photo-album/\" rel=\"nofollow\">Fli...
2010/12/19
[ "https://wordpress.stackexchange.com/questions/5629", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/394/" ]
Does anyone know of a galley plug-in which would have this kind of functionality? ``` ------------------------------------------- | | | | | | | | | ...
Photospace <http://wordpress.org/extend/plugins/photospace/> If you want to just use jquery I recommend <http://www.twospy.com/galleriffic/> galleriffic.
5,638
<p>I'd like to give users a little welcome message on their first login to the admin area. Once they hide the message it should not appear again. I noticed admin_notice is a hook but don't know where to start. Thanks.</p>
[ { "answer_id": 5640, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 4, "selected": true, "text": "<p>something like:</p>\n\n<pre><code>add_action('admin_notices', 'my_notice'); \nadd_action('wp_ajax_hide_my_...
2010/12/20
[ "https://wordpress.stackexchange.com/questions/5638", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1925/" ]
I'd like to give users a little welcome message on their first login to the admin area. Once they hide the message it should not appear again. I noticed admin\_notice is a hook but don't know where to start. Thanks.
something like: ``` add_action('admin_notices', 'my_notice'); add_action('wp_ajax_hide_my_notice', 'hide_my_notice'); function hide_my_notice(){ check_ajax_referer('hide-my-notice'); $user = wp_get_current_user(); // update status for this user $seen_notice = get_option('my_notice'); $seen_notice[$user...
5,642
<p>I am using wordpress Multisite installation .</p> <p>1)I want to run my website faster .Especially the main site.There are near about 50 plugins .I want to exclude many of these plugins on Main site and activate to other sub-sites.Could any body tell me how to do it?</p> <p>I have other three questions related to ...
[ { "answer_id": 5640, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 4, "selected": true, "text": "<p>something like:</p>\n\n<pre><code>add_action('admin_notices', 'my_notice'); \nadd_action('wp_ajax_hide_my_...
2010/12/20
[ "https://wordpress.stackexchange.com/questions/5642", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/391/" ]
I am using wordpress Multisite installation . 1)I want to run my website faster .Especially the main site.There are near about 50 plugins .I want to exclude many of these plugins on Main site and activate to other sub-sites.Could any body tell me how to do it? I have other three questions related to plugins on multis...
something like: ``` add_action('admin_notices', 'my_notice'); add_action('wp_ajax_hide_my_notice', 'hide_my_notice'); function hide_my_notice(){ check_ajax_referer('hide-my-notice'); $user = wp_get_current_user(); // update status for this user $seen_notice = get_option('my_notice'); $seen_notice[$user...
5,650
<p>I have a problem with WP that need your help. Some of my posts have content that was applied "wp_autop" filters already. This filter turned all double break lines into <code>&lt;p&gt;</code> tag. I want to the opposite thing: turn all <code>&lt;p&gt;</code> tag into double break lines.</p> <p>Do you have any sugges...
[ { "answer_id": 5660, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 2, "selected": false, "text": "<p>The filter write not in the database, filter on frontend, when view the post or other content. You deactivate the f...
2010/12/20
[ "https://wordpress.stackexchange.com/questions/5650", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2051/" ]
I have a problem with WP that need your help. Some of my posts have content that was applied "wp\_autop" filters already. This filter turned all double break lines into `<p>` tag. I want to the opposite thing: turn all `<p>` tag into double break lines. Do you have any suggestions? Thank you.
I just ran into this situation. Here is a function I used to undo wpautop. I might be missing something, but this is a good start: ``` function reverse_wpautop($s) { //remove any new lines already in there $s = str_replace("\n", "", $s); //remove all <p> $s = str_replace("<p>", "", $s); //replace...
5,661
<p>Can anyone advise on how I can remove the preceding <code>&lt;br&gt;</code> tag when a post's "read more..." tag is generated?</p> <p>Any advice appreciated!</p> <p>This is the code that's generated -</p> <pre><code>&lt;p&gt;blah blah blah blah&lt;br&gt; &lt;a class="more-link" href="blahblahblahblah"&gt; …Read ...
[ { "answer_id": 5669, "author": "Denis Belousov", "author_id": 1752, "author_profile": "https://wordpress.stackexchange.com/users/1752", "pm_score": 2, "selected": false, "text": "<p>Can you show us your generated source code with more tag and code which you use for this?</p>\n\n<p><stron...
2010/12/20
[ "https://wordpress.stackexchange.com/questions/5661", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
Can anyone advise on how I can remove the preceding `<br>` tag when a post's "read more..." tag is generated? Any advice appreciated! This is the code that's generated - ``` <p>blah blah blah blah<br> <a class="more-link" href="blahblahblahblah"> …Read more</a></p> ``` It's that annoying little I want rid of,...
Can you show us your generated source code with more tag and code which you use for this? **UPDATE** Try this: ``` function clear_br($excerpt){ return str_replace("<br>","", $excerpt); } add_filter('the_excerpt', 'clear_br'); ``` Paste this code in your **functions.php**
5,664
<p>WP loops are widely used to print lists of posts in Wordpress:</p> <pre><code>&lt;?php $loop = new WP_Query( array( 'post_type' =&gt; 'ff', 'ff' =&gt; 'show_ff', 'orderby' =&gt; 'menu_order', 'order' =&gt; 'ASC' )); while ( $loop-&gt;have_posts() ) : $loop-&gt;the_post(); ?&gt; &lt;!-- here we're going ...
[ { "answer_id": 5666, "author": "kevin", "author_id": 1997, "author_profile": "https://wordpress.stackexchange.com/users/1997", "pm_score": 0, "selected": false, "text": "<p>You can limit the number of posts to three in the first loop:</p>\n\n<pre><code> &lt;?php $args = array('showposts'...
2010/12/20
[ "https://wordpress.stackexchange.com/questions/5664", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1869/" ]
WP loops are widely used to print lists of posts in Wordpress: ``` <?php $loop = new WP_Query( array( 'post_type' => 'ff', 'ff' => 'show_ff', 'orderby' => 'menu_order', 'order' => 'ASC' )); while ( $loop->have_posts() ) : $loop->the_post(); ?> <!-- here we're going to have all posts from show_ff category o...
I don't think i've fully grasped how you want this to work, but if i assume for a moment that as long as the loop has at least 6 posts, you want to insert extra markup after the third result in the loop.. Example ======= Insert extra markup after the third post, when the current iteration has at least 6 posts ``` <?...
5,673
<p>I'm tring to upload image in wordpress by using some function ..</p> <p>I found the way to upload images but there are one problem ..</p> <p>when the user upload his image , wordpress create more than one image diffrent sizes, this is a problem because I want one image only ..</p> <p>this is wp-conent/uploads/201...
[ { "answer_id": 5686, "author": "MathSmath", "author_id": 1537, "author_profile": "https://wordpress.stackexchange.com/users/1537", "pm_score": 2, "selected": false, "text": "<p>If you're using WordPress 3.x, go to Admin > Settings > Media.</p>\n\n<p>Under \"Image Sizes\", set all the val...
2010/12/20
[ "https://wordpress.stackexchange.com/questions/5673", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2076/" ]
I'm tring to upload image in wordpress by using some function .. I found the way to upload images but there are one problem .. when the user upload his image , wordpress create more than one image diffrent sizes, this is a problem because I want one image only .. this is wp-conent/uploads/2010/10 folder .. look at t...
**HTML Markup:** ``` <p> <label for="custom-upload">Upload New Image:</label> <input type="file" tabindex="3" name="custom-upload" id="custom-upload" /> </p> <?php /*Retrieving the image*/ $attachment = get_post_meta($postid, 'custom_image'); if($attachment[0]!='') { echo wp_get_attachment_link($attac...
5,679
<p>Currently my theme calls upon <code>get_comments_link()</code> to create the standard anchor <strong>#comments</strong> to link to the comments below the post, as does the <code>get_comments_pagenum_link()</code> function on paginated comments.</p> <p>I would like to replace the <strong>#comments</strong> anchor in...
[ { "answer_id": 5682, "author": "hakre", "author_id": 178, "author_profile": "https://wordpress.stackexchange.com/users/178", "pm_score": 1, "selected": false, "text": "<p>For the function <code>get_comments_link()</code> no such filter exists. You might want to use an alternative functio...
2010/12/20
[ "https://wordpress.stackexchange.com/questions/5679", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2039/" ]
Currently my theme calls upon `get_comments_link()` to create the standard anchor **#comments** to link to the comments below the post, as does the `get_comments_pagenum_link()` function on paginated comments. I would like to replace the **#comments** anchor in these functions with any other string, without of course ...
So the solution to the `get_comments_pagenum_link()` function is straightforward enough: ``` add_filter('get_comments_pagenum_link' , 'new_get_comments_pagenum_link'); function new_get_comments_pagenum_link($content) { $content = str_ireplace('#comments' , '#other', $content); return $content; } ``` Which fi...
5,688
<p>What hook gets called when I edit or publish a custom post type of name 'episode gallery' ? </p> <p>I tried following but none worked.</p> <pre><code>add_action('save_post', 'update_custom_ngg_table'); add_action('update_postmeta', 'update_custom_ngg_table'); add_action('publish_post', 'update_custom_ngg_table'); ...
[ { "answer_id": 5695, "author": "MathSmath", "author_id": 1537, "author_profile": "https://wordpress.stackexchange.com/users/1537", "pm_score": 2, "selected": false, "text": "<p>It's always save_post, no matter what the post type. save_post also runs when creating and publishing a new pos...
2010/12/20
[ "https://wordpress.stackexchange.com/questions/5688", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
What hook gets called when I edit or publish a custom post type of name 'episode gallery' ? I tried following but none worked. ``` add_action('save_post', 'update_custom_ngg_table'); add_action('update_postmeta', 'update_custom_ngg_table'); add_action('publish_post', 'update_custom_ngg_table'); add_action('edit_post...
Unless I misunderstand your question, you want {$new\_status}\_{my-custom-post-type} Take a look at the [hook registration](http://adambrown.info/p/wp_hooks/hook/%7B%24new_status%7D_%7B%24post-%3Epost_type%7D). [This page (from Pippin's Posts)](http://pippinspages.com/tutorials/publish-action-hook-for-custom-post-typ...
5,704
<p>I just noticed 55.000 entries(!) in my wp_options table. I had not been there for a while.</p> <p>So I ran:</p> <pre><code>delete from `wp_options` where `option_name` like '_transient_timeout_rss%' delete from `wp_options` where `option_name` like '_transient_rss_%' </code></pre> <p>And... it is now back to 645 ...
[ { "answer_id": 5714, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": true, "text": "<p>Yep, this does seem like a cron issue.</p>\n\n<p><a href=\"http://wordpress.org/extend/plugins/core-control/\" rel=\"n...
2010/12/21
[ "https://wordpress.stackexchange.com/questions/5704", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/576/" ]
I just noticed 55.000 entries(!) in my wp\_options table. I had not been there for a while. So I ran: ``` delete from `wp_options` where `option_name` like '_transient_timeout_rss%' delete from `wp_options` where `option_name` like '_transient_rss_%' ``` And... it is now back to 645 entries... How can I have these...
Yep, this does seem like a cron issue. [Core Control](http://wordpress.org/extend/plugins/core-control/) plugin is good to diagnose cron tasks (among other things). I am still unsure what is the reason of you getting overrun with feed transients. However I had written some [code that might help with automatic cleanup...
5,708
<p>I've got a great Comment Form and Threaded Comments setup by using the native WordPress functions: <code>comment_form</code> and <code>wp_list_comments</code>.</p> <p>However, I'm trying to also create a custom Contest Comment template for certain posts. I call <code>comments_template('/contest-comments.php', true)...
[ { "answer_id": 5710, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 4, "selected": true, "text": "<p>Short answer: It doesn't, but you can get around this:</p>\n\n<pre><code>add_filter('comment_form_field_comme...
2010/12/21
[ "https://wordpress.stackexchange.com/questions/5708", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1493/" ]
I've got a great Comment Form and Threaded Comments setup by using the native WordPress functions: `comment_form` and `wp_list_comments`. However, I'm trying to also create a custom Contest Comment template for certain posts. I call `comments_template('/contest-comments.php', true);` conditionally based on whether a c...
Short answer: It doesn't, but you can get around this: ``` add_filter('comment_form_field_comment', 'my_comment_form_field_comment'); function my_comment_form_field_comment($default){ return false; } add_action('pre_comment_on_post', 'my_pre_comment_on_post'); function my_pre_comment_on_post($post_id){ $some_rand...
5,711
<p>I have a custom plugin which queries users and usermeta, but I now need to filter admins out of the results. A very simplified version of my sql query is:</p> <pre><code>SELECT * FROM usermeta LEFT JOIN users ON users.ID = user_id WHERE meta_key = 'last_name' AND user_role != 'admin' ORDER BY meta_value ASC LIM...
[ { "answer_id": 5712, "author": "Anh Tran", "author_id": 2051, "author_profile": "https://wordpress.stackexchange.com/users/2051", "pm_score": 4, "selected": true, "text": "<p>You can use this function:</p>\n\n<pre><code>// get users with specified roles\nfunction getUsersWithRole( $roles...
2010/12/21
[ "https://wordpress.stackexchange.com/questions/5711", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2092/" ]
I have a custom plugin which queries users and usermeta, but I now need to filter admins out of the results. A very simplified version of my sql query is: ``` SELECT * FROM usermeta LEFT JOIN users ON users.ID = user_id WHERE meta_key = 'last_name' AND user_role != 'admin' ORDER BY meta_value ASC LIMIT 0, 25 ``` ...
You can use this function: ``` // get users with specified roles function getUsersWithRole( $roles ) { global $wpdb; if ( ! is_array( $roles ) ) $roles = array_walk( explode( ",", $roles ), 'trim' ); $sql = ' SELECT ID, display_name FROM ' . $wpdb->users . ' INNER JOIN ' . $...
5,713
<p>How to filter WP_Query for posts having a certain meta-value, without using a Custom Select Query?</p> <p>I have a custom posttype with meta-key: "open", and meta-value options: "yes" or "no".</p> <p>I would like to show posts only with meta_value = yes, for meta_key = "open".</p> <pre><code>function filter_where...
[ { "answer_id": 5715, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 5, "selected": true, "text": "<p>I am not sure from your wording if you hadn't tried it with query argument or it didn't work?</p>\n\n<pre><code>$the_q...
2010/12/21
[ "https://wordpress.stackexchange.com/questions/5713", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1866/" ]
How to filter WP\_Query for posts having a certain meta-value, without using a Custom Select Query? I have a custom posttype with meta-key: "open", and meta-value options: "yes" or "no". I would like to show posts only with meta\_value = yes, for meta\_key = "open". ``` function filter_where($where = '') { ...
I am not sure from your wording if you hadn't tried it with query argument or it didn't work? ``` $the_query = new WP_Query(array( 'meta_key' => 'open', 'meta_value' => 'yes' )); ``` [Custom Field Parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters) in Codex.
5,721
<p>How to, using PHP scripting or WordPress overwrite all of the posts (permamently, so it takes effect on database) with some static text such as "Content removed."?</p>
[ { "answer_id": 5730, "author": "t31os", "author_id": 31073, "author_profile": "https://wordpress.stackexchange.com/users/31073", "pm_score": 1, "selected": false, "text": "<p>Do not run this on a live site until you're tested it on a backup or local installation and confirmed valid resul...
2010/12/21
[ "https://wordpress.stackexchange.com/questions/5721", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1454/" ]
How to, using PHP scripting or WordPress overwrite all of the posts (permamently, so it takes effect on database) with some static text such as "Content removed."?
Do not run this on a live site until you're tested it on a backup or local installation and confirmed valid results, i won't take any resposibility for lost data, should that occur. SQL Query ========= To run from PhpMyAdmin ``` UPDATE wp_posts SET post_content = 'your_content' WHERE post_type = 'post' ``` Inside ...
5,726
<p>I'd like this code to only run inside the admin area as it is resorting the items on the public side admin bar too.</p> <pre><code> /* Reorder Admin Menu to put "Pages" at the top */ function menu_order_filter($menu) { $content_menu = array('edit.php?post_type=page'); array_splice($menu, 2, 0, $content_menu)...
[ { "answer_id": 5727, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 4, "selected": true, "text": "<p>There is very little overhead to assigning couple of filters on hooks that simply won't fire on front end.</p>\n\n<p>I...
2010/12/21
[ "https://wordpress.stackexchange.com/questions/5726", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1925/" ]
I'd like this code to only run inside the admin area as it is resorting the items on the public side admin bar too. ``` /* Reorder Admin Menu to put "Pages" at the top */ function menu_order_filter($menu) { $content_menu = array('edit.php?post_type=page'); array_splice($menu, 2, 0, $content_menu); return arr...
There is very little overhead to assigning couple of filters on hooks that simply won't fire on front end. In general it would be something like this: ``` add_action('init', 'admin_only'); function admin_only() { if( !is_admin() ) return; // filter assignemnts and such go here } ``` Also `create_...
5,742
<p>Hi to the community,<br> is it possible to change the default username slug to nickname if is available? </p> <p>By default the url is something like: <a href="http://domain.tld/author/(admin">http://domain.tld/author/(admin</a>) ,<br> is it possible to rewrite and change to <a href="http://domain.tld/author/(nick...
[ { "answer_id": 5753, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": -1, "selected": false, "text": "<p>a easy way is the <a href=\"http://wordpress.org/extend/plugins/author-slug/\" rel=\"nofollow\">plugin Author Slug...
2010/12/21
[ "https://wordpress.stackexchange.com/questions/5742", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2048/" ]
Hi to the community, is it possible to change the default username slug to nickname if is available? By default the url is something like: <http://domain.tld/author/(admin>) , is it possible to rewrite and change to <http://domain.tld/author/(nickname>) so if a user change his nickname from the profile page the...
I see two ways to solve this problem: changing the data that forms the author URL, or changing the author URL. You probably should handle redirects too, so old URLs to user archives keep working when a user changes their nickname. Changing the author URL ----------------------- There are two parts to this question: h...
5,750
<p>(My first WP question ever asked! Be gentle!)</p> <p>I'm building a site that is mostly pages (i.e., static), using WP as CMS. At the bottom of several of the pages, there will appear 1, 2, or 3 "promo boxes" -- basically button-images that link to other parts of the site. Though only up to 3 promo boxes will app...
[ { "answer_id": 5765, "author": "farinspace", "author_id": 466, "author_profile": "https://wordpress.stackexchange.com/users/466", "pm_score": 4, "selected": true, "text": "<p>As the <a href=\"http://farinspace.com/about/\">author</a> of <a href=\"http://farinspace.com/wpalchemy-metabox/\...
2010/12/22
[ "https://wordpress.stackexchange.com/questions/5750", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2103/" ]
(My first WP question ever asked! Be gentle!) I'm building a site that is mostly pages (i.e., static), using WP as CMS. At the bottom of several of the pages, there will appear 1, 2, or 3 "promo boxes" -- basically button-images that link to other parts of the site. Though only up to 3 promo boxes will appear on any g...
As the [author](http://farinspace.com/about/) of [WPAlchemy](http://farinspace.com/wpalchemy-metabox/), I'm a bit bias, but you essentially have a good working model outlined to follow depending on what ever route you choose. However, if using WPAlchemy, you would basically do something like the following (step #2): ...
5,752
<p>I would like to know why my page navigation within a particular category doesn't work. </p> <p>The code seems correct but I never see the pagination links.</p> <pre><code>&lt;?php $my_query = new WP_Query('cat=18&amp;showposts=8'); while ($my_query-&gt;have_posts()) : $my_query-&gt;the_post(); ?&gt; &lt;article...
[ { "answer_id": 5765, "author": "farinspace", "author_id": 466, "author_profile": "https://wordpress.stackexchange.com/users/466", "pm_score": 4, "selected": true, "text": "<p>As the <a href=\"http://farinspace.com/about/\">author</a> of <a href=\"http://farinspace.com/wpalchemy-metabox/\...
2010/12/22
[ "https://wordpress.stackexchange.com/questions/5752", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I would like to know why my page navigation within a particular category doesn't work. The code seems correct but I never see the pagination links. ``` <?php $my_query = new WP_Query('cat=18&showposts=8'); while ($my_query->have_posts()) : $my_query->the_post(); ?> <article id="post-<?php the_ID(); ?>" <?php post...
As the [author](http://farinspace.com/about/) of [WPAlchemy](http://farinspace.com/wpalchemy-metabox/), I'm a bit bias, but you essentially have a good working model outlined to follow depending on what ever route you choose. However, if using WPAlchemy, you would basically do something like the following (step #2): ...
5,755
<p>Does anyone know how the navigation on this site was made?<br> <a href="http://www.thinkingforaliving.org" rel="nofollow">http://www.thinkingforaliving.org</a></p>
[ { "answer_id": 5756, "author": "Tom", "author_id": 1931, "author_profile": "https://wordpress.stackexchange.com/users/1931", "pm_score": 1, "selected": false, "text": "<p>Its jquery, dont think there is a plugin for it. There are a handful of them here\n<a href=\"http://vandelaydesign.co...
2010/12/22
[ "https://wordpress.stackexchange.com/questions/5755", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2106/" ]
Does anyone know how the navigation on this site was made? <http://www.thinkingforaliving.org>
That sliding navigation is a feature built-in to the theme used by the Thinking for a Living website. If you view the source code, you can see that each panel in the slider is defined by similar code starting with: ``` <div id="covers" scope="Covers"> <div class="cover-index grid4 column page"> <div class...
5,758
<p>I would like to update the coding on the wp-admin-bar. Since its positioned absolute, I would like to put a div around it that is relative and or just in a normal div.</p> <p>Or, I see you can hide the bar, does anyone have link structure for the admin bar?</p> <p>Ex:</p> <pre><code>&lt;ul&gt; &lt;li&gt;&lt;a hre...
[ { "answer_id": 5820, "author": "Mark", "author_id": 2129, "author_profile": "https://wordpress.stackexchange.com/users/2129", "pm_score": 1, "selected": false, "text": "<p>Have a look at the functions in this file: </p>\n\n<p>buddypress/bp-core/bp-core-adminbar.php</p>\n\n<p>That's where...
2010/12/22
[ "https://wordpress.stackexchange.com/questions/5758", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1931/" ]
I would like to update the coding on the wp-admin-bar. Since its positioned absolute, I would like to put a div around it that is relative and or just in a normal div. Or, I see you can hide the bar, does anyone have link structure for the admin bar? Ex: ``` <ul> <li><a href="http://www.siteurl.com/members/%username...
Have a look at the functions in this file: buddypress/bp-core/bp-core-adminbar.php That's where you'll find what you're looking for most likely.
5,761
<p>I am trying to display different things to new users that have not created a post versus users who have created a post. </p> <p>I tried this, but it did not work for custom post types (only normal posts) and it does not account for drafts or pending posts: </p> <pre><code>&lt;?php if (count_user_posts(1)&gt;=1) {...
[ { "answer_id": 5763, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 1, "selected": false, "text": "<p>see <a href=\"https://wordpress.stackexchange.com/questions/1567/best-collection-of-code-for-your-functions-...
2010/12/22
[ "https://wordpress.stackexchange.com/questions/5761", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2107/" ]
I am trying to display different things to new users that have not created a post versus users who have created a post. I tried this, but it did not work for custom post types (only normal posts) and it does not account for drafts or pending posts: ``` <?php if (count_user_posts(1)>=1) { blah blah blah } else {Welc...
Hi **@Carson:** A simple function to address what you are asking for might be the function `yoursite_user_has_posts()` which leverages the built in `WP_Query` class: ``` function yoursite_user_has_posts($user_id) { $result = new WP_Query(array( 'author'=>$user_id, 'post_type'=>'any', 'post_status'=>'pub...
5,775
<p>What is the best way to pass arguments to another page in wordpress. I did it this way :</p> <pre><code>&lt;a href="get_permalinka(id_of_page).'/&amp;i=2&amp;j=3&amp;k=4'"&gt;Link/a&gt; </code></pre> <p>I get this arguments with $_GET['i'],$_GET['j'],$_GET['k'],problem is : this works just with default permalinks,...
[ { "answer_id": 5776, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 3, "selected": true, "text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/add_query_arg\" rel=\"nofollow\">add_query_arg()<...
2010/12/22
[ "https://wordpress.stackexchange.com/questions/5775", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1147/" ]
What is the best way to pass arguments to another page in wordpress. I did it this way : ``` <a href="get_permalinka(id_of_page).'/&i=2&j=3&k=4'">Link/a> ``` I get this arguments with $\_GET['i'],$\_GET['j'],$\_GET['k'],problem is : this works just with default permalinks,but when I change it to some other permalink...
Use [add\_query\_arg()](http://codex.wordpress.org/Function_Reference/add_query_arg) to do this. Here's a useful function if you need to get the current page URL (when get\_permalink is inaccesible, like on Archives): ``` function get_current_page_url() { $request = esc_url($_SERVER["REQUEST_URI"]); $pageURL = (...
5,780
<p>I have a class that handles AJAX requests for my plugin. The class has a __callStatic wrapper for all actions, which subsequently calls non-static methods for each action, like so:</p> <pre><code>class TP_AJAX_wrapper { public static function __callStatic( $name, $args = null ) { check_ajax_referer( 'tp_ajax_no...
[ { "answer_id": 5782, "author": "t31os", "author_id": 31073, "author_profile": "https://wordpress.stackexchange.com/users/31073", "pm_score": 0, "selected": false, "text": "<p><a href=\"http://php.net/manual/en/keyword.class.php\" rel=\"nofollow\">http://php.net/manual/en/keyword.class.ph...
2010/12/22
[ "https://wordpress.stackexchange.com/questions/5780", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2113/" ]
I have a class that handles AJAX requests for my plugin. The class has a \_\_callStatic wrapper for all actions, which subsequently calls non-static methods for each action, like so: ``` class TP_AJAX_wrapper { public static function __callStatic( $name, $args = null ) { check_ajax_referer( 'tp_ajax_nonce' ); $...
There is no `__callStatic` magic function in PHP < 5.3. As so, it can not be identified as callback. As WordPress does not validate prior to invoke a callback with filters and hooks, you get the PHP warning because running on PHP < 5.3 it is not a valid callback. You can change the design of your callbacks to be non-...
5,781
<p>I'm having a custom sidebar called Footer. I'm displaying this sidebar using this code:</p> <pre><code>&lt;?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer') ) : ?&gt; (maybe I should do something in this line?) :) &lt;?php endif; ?&gt; </code></pre> <p>This works smoothly, but alm...
[ { "answer_id": 5789, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": true, "text": "<p>Use three sidebars an let them float. Anything else will break depending on the widgets your users insert.</p>\n" }, ...
2010/12/22
[ "https://wordpress.stackexchange.com/questions/5781", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1869/" ]
I'm having a custom sidebar called Footer. I'm displaying this sidebar using this code: ``` <?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar('Footer') ) : ?> (maybe I should do something in this line?) :) <?php endif; ?> ``` This works smoothly, but almost every theme nowadays allow users t...
Use three sidebars an let them float. Anything else will break depending on the widgets your users insert.
5,800
<p><em>(<strong>Moderator's Note:</strong> The original title was "using archive by date with a custom date")</em></p> <p>I'm adding an additional date to posts as a custom field. Now I want the archive to show posts by the custom date and not by the published date. For example I've got a post published today <em>(22n...
[ { "answer_id": 5818, "author": "Mark", "author_id": 2129, "author_profile": "https://wordpress.stackexchange.com/users/2129", "pm_score": 0, "selected": false, "text": "<p>Yes - you'll need to either use <a href=\"http://codex.wordpress.org/Function_Reference/query_posts\" rel=\"nofollow...
2010/12/22
[ "https://wordpress.stackexchange.com/questions/5800", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2038/" ]
*(**Moderator's Note:** The original title was "using archive by date with a custom date")* I'm adding an additional date to posts as a custom field. Now I want the archive to show posts by the custom date and not by the published date. For example I've got a post published today *(22nd December)* but the custom date ...
As with many things in WordPress there are several ways to do what you want. I'm going to explain one of them. ![](https://mikeschinkel.com/websnaps/Edit_Post_%E2%80%B9_WordPress_3.0_Test_Site_%E2%80%94_WordPress-20101223-002845.jpg) Remove the `'year'`, `'monthnum'` and `'day'` Query Variables ----------------------...
5,803
<p>So i'm trying to create a WordPress plugin and I've created some menu pages using this provided function:</p> <pre><code>add_submenu_page('my_plugin_menu', 'Edit record page', 'Edit record page', 'manage_options', 'edit_record_page', array(&amp;$this, 'display_edit_record_page'); </code></pre> <p>and when I go to ...
[ { "answer_id": 5804, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 5, "selected": true, "text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/admin_url\" rel=\"noreferrer\"><code>admin_url()</cod...
2010/12/22
[ "https://wordpress.stackexchange.com/questions/5803", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2123/" ]
So i'm trying to create a WordPress plugin and I've created some menu pages using this provided function: ``` add_submenu_page('my_plugin_menu', 'Edit record page', 'Edit record page', 'manage_options', 'edit_record_page', array(&$this, 'display_edit_record_page'); ``` and when I go to the page I notice on the addre...
[`admin_url()`](http://codex.wordpress.org/Function_Reference/admin_url) gets you the correct administration page URL (and [`network_admin_url()`](http://codex.wordpress.org/Function_Reference/network_admin_url) to get a network administration page URL) Optionally, you can use [`add_query_arg()`](http://codex.wordpres...
5,806
<p>I'm looking for a way to sanitize the filename of user uploaded attachments.</p> <p>I thought that wordpress already did it but I faced preblems after an user uploaded an attachment containing a '°' . That way the attachment is not downloadable.</p> <p>I found out this wp function:</p> <pre><code>sanitize_file_na...
[ { "answer_id": 5804, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 5, "selected": true, "text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/admin_url\" rel=\"noreferrer\"><code>admin_url()</cod...
2010/12/22
[ "https://wordpress.stackexchange.com/questions/5806", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2038/" ]
I'm looking for a way to sanitize the filename of user uploaded attachments. I thought that wordpress already did it but I faced preblems after an user uploaded an attachment containing a '°' . That way the attachment is not downloadable. I found out this wp function: ``` sanitize_file_name($filename) ``` is there...
[`admin_url()`](http://codex.wordpress.org/Function_Reference/admin_url) gets you the correct administration page URL (and [`network_admin_url()`](http://codex.wordpress.org/Function_Reference/network_admin_url) to get a network administration page URL) Optionally, you can use [`add_query_arg()`](http://codex.wordpres...