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 |
|---|---|---|---|---|---|---|
10,413 | <p>I've found this new plugin</p>
<p><a href="http://wpsmith.net/wordpress/creating-multiple-custom-menus-in-wordpress-3-1" rel="nofollow">http://wpsmith.net/wordpress/creating-multiple-custom-menus-in-wordpress-3-1</a></p>
<p>that is using a new 3.1 hook (wp_nav_menu_objects) to remove specific nav-menu-items from t... | [
{
"answer_id": 10878,
"author": "aendra",
"author_id": 1682,
"author_profile": "https://wordpress.stackexchange.com/users/1682",
"pm_score": 0,
"selected": false,
"text": "<p>What happens if you change the priority to, say, 11?</p>\n\n<pre><code>add_filter(‘wp_nav_menu_objects’, ‘do_shor... | 2011/02/25 | [
"https://wordpress.stackexchange.com/questions/10413",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3349/"
] | I've found this new plugin
<http://wpsmith.net/wordpress/creating-multiple-custom-menus-in-wordpress-3-1>
that is using a new 3.1 hook (wp\_nav\_menu\_objects) to remove specific nav-menu-items from the nav-menu-item array before they are parsed by the walker class, if a user isn't logged in. The plugin uses a specif... | The problem is that `do_shortcode()` expects a string in it's first parameters while `wp_nav_menu_objects` get's passed an array of menu objects.
Sou you'd have to write your own wrapper function to `do_shortcode`, something like this...
```
function my_nav_menu_objects_shortcode_mangler($items) {
foreach ($items... |
10,437 | <p>I unfortunately have authors with a lot of unreadable/spam posts published (thousands some of them)</p>
<p>I have tried deleting through admin,but its a slow painful process-does anyone have a specific SQL command i can use that can be edited for each authors name,and delete all posts associated with that author?</... | [
{
"answer_id": 10440,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 0,
"selected": false,
"text": "<p>Not an SQL command but a simple function that gets an author id and deletes all of his posts, that way you de... | 2011/02/25 | [
"https://wordpress.stackexchange.com/questions/10437",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I unfortunately have authors with a lot of unreadable/spam posts published (thousands some of them)
I have tried deleting through admin,but its a slow painful process-does anyone have a specific SQL command i can use that can be edited for each authors name,and delete all posts associated with that author?
Thanks in ... | This removes the posts and all associated post meta data:
```
DELETE a,b,c FROM `wp_posts` a
LEFT JOIN wp_term_relationships b ON (a.ID = b.object_id)
LEFT JOIN wp_postmeta c ON (a.ID = c.post_id)
WHERE a.post_author = '0';
```
Replace the 0 with the ID number for the post\_author you wish to remove. |
10,438 | <p>How to display a list of posts from today date to future?
I am actually using this code:</p>
<pre><code><div id="news-loop">
<?php if (have_posts()) : ?>
<?php query_posts('cat=4&showposts=6&orderby=date&order=DESC&post_status=future&post_status=published'); while ... | [
{
"answer_id": 10444,
"author": "konus",
"author_id": 3414,
"author_profile": "https://wordpress.stackexchange.com/users/3414",
"pm_score": 2,
"selected": true,
"text": "<p>According to <a href=\"http://codex.wordpress.org/Function_Reference/query_posts\" rel=\"nofollow\">query_posts</a>... | 2011/02/25 | [
"https://wordpress.stackexchange.com/questions/10438",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2119/"
] | How to display a list of posts from today date to future?
I am actually using this code:
```
<div id="news-loop">
<?php if (have_posts()) : ?>
<?php query_posts('cat=4&showposts=6&orderby=date&order=DESC&post_status=future&post_status=published'); while (have_posts()) : the_post(); ?>
<... | According to [query\_posts](http://codex.wordpress.org/Function_Reference/query_posts) you could do a filtering function like:
```
function filter_where( $where = '' ) {
// where post_date > today
$where .= " AND post_date >= '" . date('Y-m-d') . "'";
return $where;
}
add_filter( 'posts_where', 'filter_wh... |
10,463 | <p>I had a close look at Wordpress memory consumption. On my site, it seems that for each page hit 20MB of RAM gets allocated, just to prepare comfy environment for all the plugins to run in. I plotted it thusly:</p>
<p><img src="https://i.stack.imgur.com/VD0sa.gif"/></p>
<p>There is no single spot to optimize, no si... | [
{
"answer_id": 10466,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 5,
"selected": false,
"text": "<p>Not worth the trouble. WordPress doesn't eat a lot of memory just-because. It eats a lot of memory because it runs a... | 2011/02/25 | [
"https://wordpress.stackexchange.com/questions/10463",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3515/"
] | I had a close look at Wordpress memory consumption. On my site, it seems that for each page hit 20MB of RAM gets allocated, just to prepare comfy environment for all the plugins to run in. I plotted it thusly:

There is no single spot to optimize, no single bad guy who eats mos... | Not worth the trouble. WordPress doesn't eat a lot of memory just-because. It eats a lot of memory because it runs a lot of functionality under the hood.
It is far more easier and efficient to cache results (page generated) with static cache plugin and serve that. That way most visitor will not even hit WP itself. |
10,477 | <p>I'm looking for the best way to inject CSS into WordPress' Admin CP.</p>
<p>Currently, I'm using the <code>admin_head</code> action hook and in this hook, I'm using <code>dirname( __FILE__ )</code> to retrieve the directory for the stylesheets. However, <code>dirname()</code> does retrieve the server's path. <stron... | [
{
"answer_id": 10479,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": true,
"text": "<p>See <a href=\"http://codex.wordpress.org/Function_Reference/plugins_url\" rel=\"nofollow\"><code>plugins_url()</code>... | 2011/02/25 | [
"https://wordpress.stackexchange.com/questions/10477",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2322/"
] | I'm looking for the best way to inject CSS into WordPress' Admin CP.
Currently, I'm using the `admin_head` action hook and in this hook, I'm using `dirname( __FILE__ )` to retrieve the directory for the stylesheets. However, `dirname()` does retrieve the server's path. **Is this the recommended way or is there some so... | See [`plugins_url()`](http://codex.wordpress.org/Function_Reference/plugins_url). It's perfect and engineered to link to files in plugin folders.
PS also [`wp_enqueue_style()`](http://codex.wordpress.org/Function_Reference/wp_enqueue_style) might make sense in the mix. |
10,478 | <p>I have created a site and would like to create another version of the same site using the same exact database (db location, users, everything). The two sites would share one database. I already have one site created and wanted to know how feasible it is to do, and instructions on how to do it.</p>
<p>Currently, the... | [
{
"answer_id": 10480,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>There is not quite enough specific of what you have planned to suggest best approach.</p>\n\n<p>For example:</p>\n\n... | 2011/02/25 | [
"https://wordpress.stackexchange.com/questions/10478",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1893/"
] | I have created a site and would like to create another version of the same site using the same exact database (db location, users, everything). The two sites would share one database. I already have one site created and wanted to know how feasible it is to do, and instructions on how to do it.
Currently, the site up n... | There are a couple of ways you can achieve what you asked for but the latter is what I'd recommend:
1. **Set up a copy of the site** in a different directory and using your web host's control panel map the different domains to the appropriate directories. Use the same `DB_NAME`/`DB_USER`/`DB_PASSWORD`/`DB_HOST` in the... |
10,500 | <p>I'm constantly running into the same annoyance, so i thought i'd see if there's any ideas or experience out there...</p>
<p>I've created a plugin that uses it's own admin page. It has to. Now that i sorted out the WP_List_Table() stuff, i must say it's great...but....</p>
<p>Custom plugin pages always load as <cod... | [
{
"answer_id": 10767,
"author": "Jan Fabry",
"author_id": 8,
"author_profile": "https://wordpress.stackexchange.com/users/8",
"pm_score": 6,
"selected": true,
"text": "<p>As a rule of thumb, you should use a POST request for most actions, to make sure they are not <a href=\"http://blog.m... | 2011/02/26 | [
"https://wordpress.stackexchange.com/questions/10500",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3104/"
] | I'm constantly running into the same annoyance, so i thought i'd see if there's any ideas or experience out there...
I've created a plugin that uses it's own admin page. It has to. Now that i sorted out the WP\_List\_Table() stuff, i must say it's great...but....
Custom plugin pages always load as `admin.php?page=...... | As a rule of thumb, you should use a POST request for most actions, to make sure they are not [executed by accident](http://blog.moertel.com/posts/2005-10-25-google-web-accelerator-vs-unsafe-linking-round-two.html). But it is also a good practice to redirect to a normal page after a POST request, to prevent duplicate e... |
10,505 | <p>I have created PHP scripts before to export a database table to .xls format like this:</p>
<pre><code>$select = "SELECT * FROM tracking";
$export = mysql_query ( $select ) or die ( "Sql error : " . mysql_error( ) );
$fields = mysql_num_fields ( $export );
$file = 'export';
for ( $i = 0; $i < $fields; $i++ )
{
$... | [
{
"answer_id": 10508,
"author": "Ashfame",
"author_id": 1521,
"author_profile": "https://wordpress.stackexchange.com/users/1521",
"pm_score": 1,
"selected": false,
"text": "<p>If you have phpmyadmin, then just go to export and select <strong>Excel</strong> instead of <strong>SQL</strong>... | 2011/02/26 | [
"https://wordpress.stackexchange.com/questions/10505",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2026/"
] | I have created PHP scripts before to export a database table to .xls format like this:
```
$select = "SELECT * FROM tracking";
$export = mysql_query ( $select ) or die ( "Sql error : " . mysql_error( ) );
$fields = mysql_num_fields ( $export );
$file = 'export';
for ( $i = 0; $i < $fields; $i++ )
{
$header .= mysql_f... | Why not use the `SELECT INTO OUTFILE` syntax:
```
$wpdb->query("SELECT * INTO OUTFILE '/path/to/file'
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n'
FROM tracking");
``` |
10,506 | <p>Is there a way I can display all categories in the categories widget that comes with wordpress. I do not want to have to edit the core files and I want to stay away from rewriting the widget, but if need be I will. Is there anyway to hook into the widget just to get this functionality.</p>
| [
{
"answer_id": 10508,
"author": "Ashfame",
"author_id": 1521,
"author_profile": "https://wordpress.stackexchange.com/users/1521",
"pm_score": 1,
"selected": false,
"text": "<p>If you have phpmyadmin, then just go to export and select <strong>Excel</strong> instead of <strong>SQL</strong>... | 2011/02/26 | [
"https://wordpress.stackexchange.com/questions/10506",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1878/"
] | Is there a way I can display all categories in the categories widget that comes with wordpress. I do not want to have to edit the core files and I want to stay away from rewriting the widget, but if need be I will. Is there anyway to hook into the widget just to get this functionality. | Why not use the `SELECT INTO OUTFILE` syntax:
```
$wpdb->query("SELECT * INTO OUTFILE '/path/to/file'
FIELDS TERMINATED BY '\t'
LINES TERMINATED BY '\n'
FROM tracking");
``` |
10,510 | <p>I want to display the direct category ancestor of a given post. An illustrative example:</p>
<p>These are the categories I have: </p>
<ul>
<li>Cat1</li>
<li>Cat2
<ul>
<li>Cat2.1
<ul>
<li>Cat2.1.1</li>
<li>Cat2.1.2</li>
</ul></li>
<li>Cat2.2
<ul>
<li>Cat2.2.1</li>
<li>Cat2.2.2.</li>
</ul></li>
<li>Cat2.3</li>
</ul>... | [
{
"answer_id": 10511,
"author": "peroyomas",
"author_id": 2201,
"author_profile": "https://wordpress.stackexchange.com/users/2201",
"pm_score": 2,
"selected": false,
"text": "<p>Well, I guess I found how (not completely tested):</p>\n\n<pre><code><?php\n$category = get_the_category($p... | 2011/02/26 | [
"https://wordpress.stackexchange.com/questions/10510",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2201/"
] | I want to display the direct category ancestor of a given post. An illustrative example:
These are the categories I have:
* Cat1
* Cat2
+ Cat2.1
- Cat2.1.1
- Cat2.1.2
+ Cat2.2
- Cat2.2.1
- Cat2.2.2.
+ Cat2.3
* Cat3
* Cat4
I only put the posts in a single category between a same "level", but when the cate... | I come to this post as i was looking for the code. But the marked answer not working for me anymore.
I have wrote a function to get the deepest level category assigned to a post.
```
function post_deepest_level_cat($post_categories) {
foreach ($post_categories as $category) {
$cat_ids[] = $category->term_i... |
10,520 | <p>This seems like a fairly common problem, but I'm posting this as I've yet to find a solution to my problem here on WP Answers - any help is HUGELY appreciated!</p>
<p>Ok - so I have a custom post type of 'events' where I capture the date of the event using a custom field and store it as a unix timestamp. Filtering ... | [
{
"answer_id": 10527,
"author": "wyrfel",
"author_id": 3104,
"author_profile": "https://wordpress.stackexchange.com/users/3104",
"pm_score": 0,
"selected": false,
"text": "<p>Use <code>current_time('mysql')</code> instead of <code>time()</code>.</p>\n\n<p><code>time()</code> returns a un... | 2011/02/26 | [
"https://wordpress.stackexchange.com/questions/10520",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3430/"
] | This seems like a fairly common problem, but I'm posting this as I've yet to find a solution to my problem here on WP Answers - any help is HUGELY appreciated!
Ok - so I have a custom post type of 'events' where I capture the date of the event using a custom field and store it as a unix timestamp. Filtering posts on t... | Second try: ;-)
`pre_get_posts` runs AFTER `parse_query()`. `parse_query()` transforms 'meta\_key' etc. into 'meta\_query'. `get_posts()` doesn't seem to react on 'meta\_key' etc. directly. So try adding `$query->parse_query()` after your `$query->set()` calls or use filter that runs before `parse_query` (edited, the ... |
10,524 | <p>hey guys,
i really need your help.</p>
<p>Whenever I use a gallery in wordpress and set it's columns to just 1 Wordpress automatically adds <code><br style="clear: both"/></code> after every <code><dl class="gallery-item"></code>. I really need to prevent this behaviour and therefore I'd like to add a f... | [
{
"answer_id": 10526,
"author": "keatch",
"author_id": 2727,
"author_profile": "https://wordpress.stackexchange.com/users/2727",
"pm_score": 2,
"selected": true,
"text": "<p>EDIT:\nyou must call your filter after the shortcode is processed, giving it priority > 10, and you must match on... | 2011/02/26 | [
"https://wordpress.stackexchange.com/questions/10524",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3529/"
] | hey guys,
i really need your help.
Whenever I use a gallery in wordpress and set it's columns to just 1 Wordpress automatically adds `<br style="clear: both"/>` after every `<dl class="gallery-item">`. I really need to prevent this behaviour and therefore I'd like to add a filter to my functions.php
The following to ... | EDIT:
you must call your filter after the shortcode is processed, giving it priority > 10, and you must match on a multiline expression.
Try this work with my installation and using the standard gallery shortag:
```
add_filter( 'the_content', 'remove_br_gallery', 11, 2);
function remove_br_gallery($output) {
retu... |
10,537 | <p>I've found this to display the current name of the file used in template:</p>
<pre><code>function get_template_name () {
foreach ( debug_backtrace() as $called_file ) {
foreach ( $called_file as $index ) {
if ( !is_array($index[0]) AND strstr($index[0],'/themes/') AND !strstr($index[0],'foot... | [
{
"answer_id": 10543,
"author": "wyrfel",
"author_id": 3104,
"author_profile": "https://wordpress.stackexchange.com/users/3104",
"pm_score": 0,
"selected": false,
"text": "<p>There's an issue with the <code>preg_match_all</code> line. Try this instead:</p>\n\n<pre><code>preg_match_all(\"... | 2011/02/26 | [
"https://wordpress.stackexchange.com/questions/10537",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1244/"
] | I've found this to display the current name of the file used in template:
```
function get_template_name () {
foreach ( debug_backtrace() as $called_file ) {
foreach ( $called_file as $index ) {
if ( !is_array($index[0]) AND strstr($index[0],'/themes/') AND !strstr($index[0],'footer.php') ) {
... | apparently this is enough:
```
add_action('wp_head', 'show_template');
function show_template() {
global $template;
echo basename($template);
}
```
or just use it directly in template (I tend to echo in footer.php in HTML comment)
```
<?php global $template; echo basename($template); ?>
``` |
10,544 | <p>I am now developing a wordpress site that will be something like a directory. People will be able to submit walkthroughs, advanced reviews, as well as cheat codes for games. We were going to make a different form for each page, but now we've decided that one form with a drop down will be just fine.</p>
<p>There doe... | [
{
"answer_id": 10551,
"author": "Simon Blackbourn",
"author_id": 2877,
"author_profile": "https://wordpress.stackexchange.com/users/2877",
"pm_score": 3,
"selected": true,
"text": "<p>It looks like <a href=\"http://gravityforms.com\" rel=\"nofollow\">Gravity Forms</a> can do this. I just... | 2011/02/26 | [
"https://wordpress.stackexchange.com/questions/10544",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2479/"
] | I am now developing a wordpress site that will be something like a directory. People will be able to submit walkthroughs, advanced reviews, as well as cheat codes for games. We were going to make a different form for each page, but now we've decided that one form with a drop down will be just fine.
There doesn't seem ... | It looks like [Gravity Forms](http://gravityforms.com) can do this. I just did a quick search on the support forums and found this, an answer to someone asking almost exactly the same question as you:
>
> Gravity Forms can be used to create
> custom post types as well as custom
> taxonomies, however it doesn't do s... |
10,553 | <p>My redirection are working until parameters are added to the end of the source URL. What will be the proper way of implementing a redirect were the target will be a different URL but I want to pass the parameters untouched.</p>
<p><a href="http://www.kiragiannis.com/2009/03/windows-restarts-at-ec2.html?action=backl... | [
{
"answer_id": 10573,
"author": "wyrfel",
"author_id": 3104,
"author_profile": "https://wordpress.stackexchange.com/users/3104",
"pm_score": 1,
"selected": false,
"text": "<p>Your problem ain't the parameters...it's that your parametrized URL points to the wrong target...it has a <code>.... | 2011/02/26 | [
"https://wordpress.stackexchange.com/questions/10553",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3536/"
] | My redirection are working until parameters are added to the end of the source URL. What will be the proper way of implementing a redirect were the target will be a different URL but I want to pass the parameters untouched.
[Post with Parameters goes to 404 page](http://www.kiragiannis.com/2009/03/windows-restarts-at-... | Your problem ain't the parameters...it's that your parametrized URL points to the wrong target...it has a `.html` where it should have a slash.
```
.../windows-restarts-at-ec2.html?action=backlinks&wid...
```
Change it to
```
..../windows-restarts-at-ec2/?action=backlinks&wid...
```
and you'll see it works. |
10,558 | <p>I have a post that includes a relatively large table that gets updated frequently. Instead of using the (slower) web interface to update the post each time, I installed one of the “run PHP” plugins and put a short bit of PHP code in the table body that opens an external file on the server and puts that in the table ... | [
{
"answer_id": 10573,
"author": "wyrfel",
"author_id": 3104,
"author_profile": "https://wordpress.stackexchange.com/users/3104",
"pm_score": 1,
"selected": false,
"text": "<p>Your problem ain't the parameters...it's that your parametrized URL points to the wrong target...it has a <code>.... | 2011/02/26 | [
"https://wordpress.stackexchange.com/questions/10558",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/121/"
] | I have a post that includes a relatively large table that gets updated frequently. Instead of using the (slower) web interface to update the post each time, I installed one of the “run PHP” plugins and put a short bit of PHP code in the table body that opens an external file on the server and puts that in the table in ... | Your problem ain't the parameters...it's that your parametrized URL points to the wrong target...it has a `.html` where it should have a slash.
```
.../windows-restarts-at-ec2.html?action=backlinks&wid...
```
Change it to
```
..../windows-restarts-at-ec2/?action=backlinks&wid...
```
and you'll see it works. |
10,561 | <p>i'm listing all posts of my custom post type "person" alphabetically sorted by the custom field <code>last_name</code> on a page.</p>
<p><strong>How would i insert a divider (e.g. an image of the letter) before a letter range starts?</strong> </p>
<p>Here's what i'm trying to do: </p>
<p><img src="https://i.sta... | [
{
"answer_id": 10587,
"author": "trusktr",
"author_id": 1226,
"author_profile": "https://wordpress.stackexchange.com/users/1226",
"pm_score": 0,
"selected": false,
"text": "<p>Well since Wordpress's sorting features don't include that kind of functionality, you should probably ask Matt M... | 2011/02/26 | [
"https://wordpress.stackexchange.com/questions/10561",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3480/"
] | i'm listing all posts of my custom post type "person" alphabetically sorted by the custom field `last_name` on a page.
**How would i insert a divider (e.g. an image of the letter) before a letter range starts?**
Here's what i'm trying to do:

... | Try this:
```
<ul class="list-ensemble">
<?php query_posts('post_type=person&post_status=publish&meta_key=last_name&orderby=meta_value&order=ASC');
$current_letter = '';
if ( have_posts() ) while ( have_posts() ) : the_post();
$last_name = get_post_meta( $post->ID, 'last_name', true );
$letter = strtolower( s... |
10,570 | <p>I'm using WordPress as a CMS and would like to have categories selectable from multiple selections i.e <code><option></code>. </p>
<p><img src="https://i.stack.imgur.com/b97Wg.jpg" alt="enter image description here"><img src="https://i.stack.imgur.com/KrA6n.png" alt="enter image description here"></p>
<p>As ... | [
{
"answer_id": 10631,
"author": "wyrfel",
"author_id": 3104,
"author_profile": "https://wordpress.stackexchange.com/users/3104",
"pm_score": 1,
"selected": false,
"text": "<pre><code><form action=\"<?php echo remove_query_arg(array('mycat_go', 'cat')); ?>\" method=\"get\">\n ... | 2011/02/27 | [
"https://wordpress.stackexchange.com/questions/10570",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3296/"
] | I'm using WordPress as a CMS and would like to have categories selectable from multiple selections i.e `<option>`.

As a usage example, The first dropdown would contain parent categ... | ```
function parent_child_cat_select() { ?>
<script type="text/javascript">
/* <![CDATA[ */
jQuery(document).ready(function() {
jQuery('#parent_cat').change(function(){
var parentCat=jQuery('#parent_cat').val();
// call ajax
... |
10,580 | <p>I'm not very familiar with the bbPress plugin.
I would like to list two or three recent topics below the title of the forum
(as well as the number of their replies):</p>
<p><img src="https://i.stack.imgur.com/RXZYB.png" alt="enter image description here"></p>
<p>This is <strong>loop-bbp_forums.php</strong>:</p>
<... | [
{
"answer_id": 10779,
"author": "John James Jacoby",
"author_id": 3588,
"author_profile": "https://wordpress.stackexchange.com/users/3588",
"pm_score": 3,
"selected": true,
"text": "<p>scribu is correct. The code to do this does exist within the plugin, but that code is subject to change... | 2011/02/27 | [
"https://wordpress.stackexchange.com/questions/10580",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/781/"
] | I'm not very familiar with the bbPress plugin.
I would like to list two or three recent topics below the title of the forum
(as well as the number of their replies):

This is **loop-bbp\_forums.php**:
```
<?php
/**
* Forums Loop
*
* @package bbP... | scribu is correct. The code to do this does exist within the plugin, but that code is subject to change as the bbPress plugin continues to be developed.
If you're comfortable snooping through code and finding the functions to make this happen, we're happy to fix any bugs you might find along the way. You may also have... |
10,582 | <p>I must be blind but I can't find for the life of me the full instructions for getting Disqus comment count to work.</p>
<p>All I want displayed is just the comment count number.</p>
<p>I've checked the "Output JavaScript in footer" option. I have custom loops but I have no idea what I supposed to put in them to ac... | [
{
"answer_id": 10588,
"author": "anu",
"author_id": 490,
"author_profile": "https://wordpress.stackexchange.com/users/490",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://docs.disqus.com/developers/universal/#comment-count\" rel=\"nofollow\">http://docs.disqus.com/develop... | 2011/02/27 | [
"https://wordpress.stackexchange.com/questions/10582",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3545/"
] | I must be blind but I can't find for the life of me the full instructions for getting Disqus comment count to work.
All I want displayed is just the comment count number.
I've checked the "Output JavaScript in footer" option. I have custom loops but I have no idea what I supposed to put in them to activate the commen... | I have the same problem with displaying number of comments in the loop.
I solve this by turn off two filters in file *plugins/disqus/disqus.php* at line 1124:
```
<?php
#add_filter('comments_number', 'dsq_comments_text');
#add_filter('get_comments_number', 'dsq_comments_number');
```
And I have added to my template... |
10,583 | <p>This is how you do it for Wordpress posts:</p>
<pre><code> $my_query = new WP_Query( "cat=3" );
if ( $my_query->have_posts() ) {
while ( $my_query->have_posts() ) {
$my_query->the_post();
the_content();
}
}
wp_reset_postdata();
</code></pre>
<p>I would like... | [
{
"answer_id": 10588,
"author": "anu",
"author_id": 490,
"author_profile": "https://wordpress.stackexchange.com/users/490",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://docs.disqus.com/developers/universal/#comment-count\" rel=\"nofollow\">http://docs.disqus.com/develop... | 2011/02/27 | [
"https://wordpress.stackexchange.com/questions/10583",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/781/"
] | This is how you do it for Wordpress posts:
```
$my_query = new WP_Query( "cat=3" );
if ( $my_query->have_posts() ) {
while ( $my_query->have_posts() ) {
$my_query->the_post();
the_content();
}
}
wp_reset_postdata();
```
I would like to know how to do that in bbPress ... | I have the same problem with displaying number of comments in the loop.
I solve this by turn off two filters in file *plugins/disqus/disqus.php* at line 1124:
```
<?php
#add_filter('comments_number', 'dsq_comments_text');
#add_filter('get_comments_number', 'dsq_comments_number');
```
And I have added to my template... |
10,592 | <p>I have multiple sidebars, based on different pages. How can I get <a href="http://wordpress.org/extend/plugins/wp125/" rel="nofollow">the WP125 widget</a> to show on all of them?? Once I add it to one sidebar, it is unavailable to put on others (like many other widgets by the way).</p>
<p>Just to clarify, just mult... | [
{
"answer_id": 10595,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 1,
"selected": false,
"text": "<p>You have two options:</p>\n\n<p>Create the widget yourself with the <a href=\"http://codex.wordpress.org/Widg... | 2011/02/27 | [
"https://wordpress.stackexchange.com/questions/10592",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3536/"
] | I have multiple sidebars, based on different pages. How can I get [the WP125 widget](http://wordpress.org/extend/plugins/wp125/) to show on all of them?? Once I add it to one sidebar, it is unavailable to put on others (like many other widgets by the way).
Just to clarify, just multiple instances of the widget with th... | You have two options:
Create the widget yourself with the ["new" widget api](http://codex.wordpress.org/Widgets_API) as a class an it will be multiple instance widget.
Or find the line that registers the widget and register the same widget with a new name for example find:
```
register_sidebar_widget(array('Content ... |
10,622 | <p>Is it possible to get paged outside of the standard WP loop?</p>
<p>I already use this inside the loop:</p>
<pre><code><?php if ( $paged >= 2 ) { ?> Some text for the 2nd page on up <?php } ?>
</code></pre>
<p>But I'd like to be able to echo some text outside the loop on all pages two and greater... | [
{
"answer_id": 10629,
"author": "Guru 2.0",
"author_id": 3550,
"author_profile": "https://wordpress.stackexchange.com/users/3550",
"pm_score": -1,
"selected": false,
"text": "<p>You can make a \"second\" Loop like this:</p>\n\n<pre><code><?php $posts = query_posts($query_string); if (... | 2011/02/27 | [
"https://wordpress.stackexchange.com/questions/10622",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/268/"
] | Is it possible to get paged outside of the standard WP loop?
I already use this inside the loop:
```
<?php if ( $paged >= 2 ) { ?> Some text for the 2nd page on up <?php } ?>
```
But I'd like to be able to echo some text outside the loop on all pages two and greater. Possible? Or a better way? | Here you go:
```
<?php
if ( is_paged() )
echo 'some text';
```
See <http://codex.wordpress.org/Conditional_Tags#A_Paged_Page> |
10,626 | <p>How does <a href="http://api2.wpquickinstall.com/what-version/" rel="nofollow">DD32's tool</a> determine the WordPress version of an installation. Its not working fine for WP 3.1 but it doesn't uses meta generator tag or the readme.txt of WP. So what else can it be?</p>
| [
{
"answer_id": 10637,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 3,
"selected": true,
"text": "<p>I'm just assuming here but this is usually done by fingerprinting for specific version files/directory's/code and so... | 2011/02/27 | [
"https://wordpress.stackexchange.com/questions/10626",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1521/"
] | How does [DD32's tool](http://api2.wpquickinstall.com/what-version/) determine the WordPress version of an installation. Its not working fine for WP 3.1 but it doesn't uses meta generator tag or the readme.txt of WP. So what else can it be? | I'm just assuming here but this is usually done by fingerprinting for specific version files/directory's/code and sometimes even size.
For example you can remove all the meta versions tags ( isn't there like 12 places) and .txt file for 3.1 but since 3.1 is the only version to include the following new file by default... |
10,650 | <p>I'm trying to remove old post tags from a few WP installs. In some instances, I have over 20k tags for a few thousand posts. I've tried the following code:</p>
<pre><code>delete t.*,tt.*,tr.*
FROM wp_terms AS t
INNER JOIN wp_term_taxonomy as tt
INNER JOIN wp_term_relationships as tr
WHERE tt.term_id = t.term_id
AND... | [
{
"answer_id": 10657,
"author": "wyrfel",
"author_id": 3104,
"author_profile": "https://wordpress.stackexchange.com/users/3104",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not sure about this, but the way the tables are setup, WordPress can re-use the same <code>terms</code> recor... | 2011/02/28 | [
"https://wordpress.stackexchange.com/questions/10650",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3560/"
] | I'm trying to remove old post tags from a few WP installs. In some instances, I have over 20k tags for a few thousand posts. I've tried the following code:
```
delete t.*,tt.*,tr.*
FROM wp_terms AS t
INNER JOIN wp_term_taxonomy as tt
INNER JOIN wp_term_relationships as tr
WHERE tt.term_id = t.term_id
AND tr.term_taxon... | I'm not sure about this, but the way the tables are setup, WordPress can re-use the same `terms` record (with the same `term_id`) within different taxonomies. That is, if you have a `post_tag` called `favorites` and you also have a `category` called `favorites`, it can well be that WP uses the same `terms` record for b... |
10,652 | <p>I've created a custom query to pull all posts from a custom post type, ordered by comment count. It's your run-of-the-mills custom query:</p>
<pre><code> <?php
$querystr = "
SELECT wposts.*
FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
WHERE wposts.ID = wpostmeta.post_id
AND wpost... | [
{
"answer_id": 10653,
"author": "Lynne",
"author_id": 2479,
"author_profile": "https://wordpress.stackexchange.com/users/2479",
"pm_score": 0,
"selected": false,
"text": "<p>I had to define some post meta field (custom field, taxonomy, or tag) and add it to the query select:</p>\n\n<pre>... | 2011/02/28 | [
"https://wordpress.stackexchange.com/questions/10652",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2479/"
] | I've created a custom query to pull all posts from a custom post type, ordered by comment count. It's your run-of-the-mills custom query:
```
<?php
$querystr = "
SELECT wposts.*
FROM $wpdb->posts wposts, $wpdb->postmeta wpostmeta
WHERE wposts.ID = wpostmeta.post_id
AND wposts.post_status = 'publis... | There is really no reason to use raw sql to query posts. You can accomplish just about any type of query using the WordPress API. For full reference see the codex, [Function Reference query posts](http://codex.wordpress.org/Function_Reference/query_posts). Try the following:
```
global $post;
$args=array(
'po... |
10,656 | <p>How do I stop the editor from stripping my <code><p></code> tags and "empty (& nbsp;)" divs on pages?</p>
<p>Since @scribu asked for a sample code here it is:</p>
<p>Input:</p>
<pre><code><p>text</p>
<div>&nbsp;</div>
</code></pre>
<p>Output:</p>
<pre><code>text
</code></pr... | [
{
"answer_id": 10660,
"author": "markratledge",
"author_id": 268,
"author_profile": "https://wordpress.stackexchange.com/users/268",
"pm_score": 1,
"selected": false,
"text": "<p>1) Try a few different plugins that disable formatting and stop WP's built-in stripping of extra paragraphs a... | 2011/02/28 | [
"https://wordpress.stackexchange.com/questions/10656",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2313/"
] | How do I stop the editor from stripping my `<p>` tags and "empty (& nbsp;)" divs on pages?
Since @scribu asked for a sample code here it is:
Input:
```
<p>text</p>
<div> </div>
```
Output:
```
text
``` | I had problems with TinyMCE Advanced. I struggled with this for a while. Finally discovered a simple solution - Use Shortcodes!
Place this code into functions.php and enter [br] wherever you want a br tag to appear.
```
add_shortcode("br", "br_tag");
function br_tag(){
return("<br/>"); ... |
10,676 | <p>I want to turn this off as I have a custom ordering process using custom fields.</p>
| [
{
"answer_id": 10694,
"author": "t31os",
"author_id": 31073,
"author_profile": "https://wordpress.stackexchange.com/users/31073",
"pm_score": 3,
"selected": false,
"text": "<p>You can't turn it off, because it's hard-coded into the submit metabox for the <strong>post</strong> post type, ... | 2011/02/28 | [
"https://wordpress.stackexchange.com/questions/10676",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/970/"
] | I want to turn this off as I have a custom ordering process using custom fields. | You can't turn it off, because it's hard-coded into the submit metabox for the **post** post type, you can however hide the sticky checkbox and update the sticky array to unstick any currently stuck posts.
Hide the sticky checkbox
========================
Add additional CSS to the post and post-new pages
```
add_act... |
10,677 | <p>how would I go about creating a filter for the <code>body_class()</code> tag that allows me to add the the parent pages slug name as a class to the body whenever visiting a subpage or post?</p>
| [
{
"answer_id": 10696,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 1,
"selected": true,
"text": "<p>here:</p>\n\n<pre><code>add_filter('body_class','body_class_slugs');\nfunction body_class_slugs($classes) {\n ... | 2011/02/28 | [
"https://wordpress.stackexchange.com/questions/10677",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3567/"
] | how would I go about creating a filter for the `body_class()` tag that allows me to add the the parent pages slug name as a class to the body whenever visiting a subpage or post? | here:
```
add_filter('body_class','body_class_slugs');
function body_class_slugs($classes) {
global $posts,$post;
if(is_single() || is_page()){ //only on a single post or page
if (isset($posts)){
$classes[] = $post[0]->post_name; //posts is an array of posts so we use the first one by call... |
10,678 | <p>Hi is there an action which can be performed while a post is moved to trash .... I tried delete_post and deleted_post. It works but twice for each action ( before and after the action as written in codex ) and the output is shown only when the post is deleted from trash. Example i want to send an email to the author... | [
{
"answer_id": 10692,
"author": "Simon Blackbourn",
"author_id": 2877,
"author_profile": "https://wordpress.stackexchange.com/users/2877",
"pm_score": 2,
"selected": false,
"text": "<p>That action will be called once when the post is moved to the trash, and then again when the trash is e... | 2011/02/28 | [
"https://wordpress.stackexchange.com/questions/10678",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3468/"
] | Hi is there an action which can be performed while a post is moved to trash .... I tried delete\_post and deleted\_post. It works but twice for each action ( before and after the action as written in codex ) and the output is shown only when the post is deleted from trash. Example i want to send an email to the author ... | This will do the trick!
```
add_action('trash_post','my_trash_post_function',1,1);
function my_trash_post_function($post_id){
if(!did_action('trash_post')){
// do stuff
}
}
```
Here we add the function, and to prevent the hook from executing more than once using did\_action:
<http://codex.wordpress.... |
10,680 | <p>Is it possible to have my custom permalink structure on title tag of my blog?</p>
<p>my current permalink structure is this
<code>/%postname%/%location%/%mba_courses%/</code> where my location and mba_courses are custom taxonomies</p>
<p>Now I want this on my title tag, can I write something like this in title tag... | [
{
"answer_id": 10686,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 0,
"selected": false,
"text": "<p>If your not using an SEO plugin you can use wp_title to put the permalink url as the tile.</p>\n\n<pre><code><t... | 2011/02/28 | [
"https://wordpress.stackexchange.com/questions/10680",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1743/"
] | Is it possible to have my custom permalink structure on title tag of my blog?
my current permalink structure is this
`/%postname%/%location%/%mba_courses%/` where my location and mba\_courses are custom taxonomies
Now I want this on my title tag, can I write something like this in title tag?
```
<title><?php echo (/... | There is no way to cause your permalink structure to be reflected automatically in the title tag. Instead, you must create it yourself. This might get you started: (I had to make a lot of assumptions in this code.)
```
function my_title() {
$post = get_queried_object();
$locations = wp_get_object_terms( $post-... |
10,706 | <p>I noticed that WP 3.1 supposedly has '<a href="http://wordpress.org/news/2011/02/threeone/" rel="nofollow">new CMS capabilities like archive pages for custom content types</a>', however, I can't see that implemented yet?</p>
<p>I've been using a plugin called 'Simple Custom Post Type Archives' to view custom posts ... | [
{
"answer_id": 10707,
"author": "Simon Blackbourn",
"author_id": 2877,
"author_profile": "https://wordpress.stackexchange.com/users/2877",
"pm_score": 1,
"selected": false,
"text": "<p>Yes, that is implemented in 3.1, you have to make sure that the arguments passed to <code>register_post... | 2011/02/28 | [
"https://wordpress.stackexchange.com/questions/10706",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2685/"
] | I noticed that WP 3.1 supposedly has '[new CMS capabilities like archive pages for custom content types](http://wordpress.org/news/2011/02/threeone/)', however, I can't see that implemented yet?
I've been using a plugin called 'Simple Custom Post Type Archives' to view custom posts at the url <http://www.domainname.co... | Yes, you'll just need to set the `has_archive` parameter to true or your chosen slug when registering your custom post type.
So firstly add the `has_archive` parameter to your post type, here's an example...
```
add_action( 'init', 'question_10706_init' );
function question_10706_init() {
register_post_type( 'e... |
10,714 | <p>I have read every wordpress solution and tried them all (at least most), but I CAN NOT get my site to run faster. I am using the couponpress theme, which is a coupon listing theme where users can list different offers and coupons. I'm finished customizing it but I'm having real speed issue!</p>
<p>I included a quer... | [
{
"answer_id": 10715,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>I'm no expert but using the permalink structure you have on a large site can cause problems (you should start the ... | 2011/02/28 | [
"https://wordpress.stackexchange.com/questions/10714",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I have read every wordpress solution and tried them all (at least most), but I CAN NOT get my site to run faster. I am using the couponpress theme, which is a coupon listing theme where users can list different offers and coupons. I'm finished customizing it but I'm having real speed issue!
I included a query count an... | I could be wrong, but I don't think your queries are the problem here. Seeing the result "36 queries in 8.291 seconds" is scary, but that only measures the time in between the start of the first query and the completion of the last query. There are a lot of other things in there slowing your page loads down. If you wan... |
10,718 | <p>I'm trying to get the custom archives per post-type working, but after a week of trying, searching and scratching head I still cannot get it working. I'm mainly talking about the <code>{post-type}/{year}</code> or <code>{post-type}/{year}/{month}</code> permalinks. They always throw a <code>404</code>. Only <code>in... | [
{
"answer_id": 10715,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>I'm no expert but using the permalink structure you have on a large site can cause problems (you should start the ... | 2011/02/28 | [
"https://wordpress.stackexchange.com/questions/10718",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3323/"
] | I'm trying to get the custom archives per post-type working, but after a week of trying, searching and scratching head I still cannot get it working. I'm mainly talking about the `{post-type}/{year}` or `{post-type}/{year}/{month}` permalinks. They always throw a `404`. Only `index.php?year={year}&monthnum={month}&post... | I could be wrong, but I don't think your queries are the problem here. Seeing the result "36 queries in 8.291 seconds" is scary, but that only measures the time in between the start of the first query and the completion of the last query. There are a lot of other things in there slowing your page loads down. If you wan... |
10,725 | <p>Plugin queries remote API and under certain circumstances (mostly errors) displays textual messages from API responses. All messages in API responses are in English, but since they are more or less integrated in plugin it would make sense to make them localized and display-able in different language to match plugin'... | [
{
"answer_id": 10726,
"author": "wyrfel",
"author_id": 3104,
"author_profile": "https://wordpress.stackexchange.com/users/3104",
"pm_score": -1,
"selected": false,
"text": "<p>I think use <code>__( $message )</code> is totally fine. I also think one would expect the API messages to be re... | 2011/02/28 | [
"https://wordpress.stackexchange.com/questions/10725",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/847/"
] | Plugin queries remote API and under certain circumstances (mostly errors) displays textual messages from API responses. All messages in API responses are in English, but since they are more or less integrated in plugin it would make sense to make them localized and display-able in different language to match plugin's i... | >
> Should such messages be localized at all or are they out of scope for localization?
>
>
>
Yes, they should be localized ... but don't depend on the text returned by the API.
>
> Does something like `__( $message );` even make sense?
>
>
>
Not really. First of all, you're not providing a text domain for t... |
10,734 | <p>I've set up a redesign of a site in the subdomain to work out any kinks and to make sure everythings working ok before setting it up on the root domain. I've looked up transfers but have only found info on transfering from host to host or from local to host.</p>
<p>I've set up a wordpress site that was previously l... | [
{
"answer_id": 10743,
"author": "Guru 2.0",
"author_id": 3550,
"author_profile": "https://wordpress.stackexchange.com/users/3550",
"pm_score": 1,
"selected": false,
"text": "<p>After copying to the main-directory change the values in then <code>wp-config.php</code> and <code>.htaccess</c... | 2011/02/28 | [
"https://wordpress.stackexchange.com/questions/10734",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I've set up a redesign of a site in the subdomain to work out any kinks and to make sure everythings working ok before setting it up on the root domain. I've looked up transfers but have only found info on transfering from host to host or from local to host.
I've set up a wordpress site that was previously locally hos... | After copying to the main-directory change the values in then `wp-config.php` and `.htaccess` files for the new localtion. Then you have to change the values in the database. You need 3 SQL-Statements, which you can execute with `phpMyAdmin` for example.
First change the options-Table
```
UPDATE wp_options
SET option... |
10,742 | <p><em>(<strong>Moderator's note:</strong> Original title was "Remove Admin from User Menu")</em></p>
<p>I have created a client administrator role which is essentially an Editor with ability to add/remove users. The article <em>"<a href="https://wordpress.stackexchange.com/questions/4479/editor-can-create-any-new-use... | [
{
"answer_id": 10748,
"author": "MikeSchinkel",
"author_id": 89,
"author_profile": "https://wordpress.stackexchange.com/users/89",
"pm_score": 5,
"selected": true,
"text": "<p>Hi <strong>@Carlos:</strong></p>\n\n<p>Try adding the following to your theme's <code>functions.php</code> file,... | 2011/02/28 | [
"https://wordpress.stackexchange.com/questions/10742",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3580/"
] | *(**Moderator's note:** Original title was "Remove Admin from User Menu")*
I have created a client administrator role which is essentially an Editor with ability to add/remove users. The article *"[Editor can create any new user except administrator](https://wordpress.stackexchange.com/questions/4479/editor-can-create... | Hi **@Carlos:**
Try adding the following to your theme's `functions.php` file, or in a `.php` file within a plugin that you might be writing *(which works for WordPress 3.1.x):*
```
add_action('pre_user_query','yoursite_pre_user_query');
function yoursite_pre_user_query($user_search) {
$user = wp_get_current_user()... |
10,744 | <p>I've got an action set up on <code>admin_menu</code> to modify it as needed. I successfully removed the themes menu with the following:</p>
<pre><code>remove_submenu_page('themes.php', 'themes.php');
</code></pre>
<p>Now I want to get rid of the useless yet dangerous theme editor.</p>
<pre><code>remove_submenu_pa... | [
{
"answer_id": 10746,
"author": "wyrfel",
"author_id": 3104,
"author_profile": "https://wordpress.stackexchange.com/users/3104",
"pm_score": 0,
"selected": false,
"text": "<p>In WP 3.1, you should be able to use the <code>views_users</code> filter to limit the views displayed on the user... | 2011/02/28 | [
"https://wordpress.stackexchange.com/questions/10744",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3579/"
] | I've got an action set up on `admin_menu` to modify it as needed. I successfully removed the themes menu with the following:
```
remove_submenu_page('themes.php', 'themes.php');
```
Now I want to get rid of the useless yet dangerous theme editor.
```
remove_submenu_page('themes.php', 'theme-editor.php');
```
This... | Use this to get rid of the theme editor but it also gets rid of the plugin editor.
Paste in your *wp-config.php*:
`define('DISALLOW_FILE_EDIT', true)` |
10,756 | <p>My Query </p>
<pre><code>$my_query = array(
'posts_per_page' => 10,
'tax_query' => array(
array(
'taxonomy' => 'country',
'field' => 'id',
... | [
{
"answer_id": 10746,
"author": "wyrfel",
"author_id": 3104,
"author_profile": "https://wordpress.stackexchange.com/users/3104",
"pm_score": 0,
"selected": false,
"text": "<p>In WP 3.1, you should be able to use the <code>views_users</code> filter to limit the views displayed on the user... | 2011/02/28 | [
"https://wordpress.stackexchange.com/questions/10756",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1555/"
] | My Query
```
$my_query = array(
'posts_per_page' => 10,
'tax_query' => array(
array(
'taxonomy' => 'country',
'field' => 'id',
'terms' => array(4)
... | Use this to get rid of the theme editor but it also gets rid of the plugin editor.
Paste in your *wp-config.php*:
`define('DISALLOW_FILE_EDIT', true)` |
10,764 | <p>I've been looking all over to find a solution for SSL with WordPress MultiSite and Domain Mapping. Ideally, I'd like to purchase an SSL cert for each domain (or potentially a wildcard cert) anyone have a solution that has worked for them. </p>
<p>I'm fearing that I overlooked this detail and will now have to spli... | [
{
"answer_id": 13532,
"author": "Andy",
"author_id": 498,
"author_profile": "https://wordpress.stackexchange.com/users/498",
"pm_score": 2,
"selected": false,
"text": "<p>On WordPress.com we have domain mapping and we have SSL but the two don't mix because we don't manage certs for mappe... | 2011/02/28 | [
"https://wordpress.stackexchange.com/questions/10764",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3111/"
] | I've been looking all over to find a solution for SSL with WordPress MultiSite and Domain Mapping. Ideally, I'd like to purchase an SSL cert for each domain (or potentially a wildcard cert) anyone have a solution that has worked for them.
I'm fearing that I overlooked this detail and will now have to split up my happ... | On WordPress.com we have domain mapping and we have SSL but the two don't mix because we don't manage certs for mapped domains (AFAIK). We use SSL for wp-admin but not for blogs. Example:
```
http://andyskelton.com/
https://andyskelton.wordpress.com/wp-admin/
```
The SSL cert is for \*.wordpress.com. If you try to v... |
10,772 | <p>At the moment I run PHP code in my side bars. Even though I have the following</p>
<pre><code>header("Pragma: no-cache");
header("cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
</code></pre>
<p>It still appears to serve cached content.... | [
{
"answer_id": 10775,
"author": "Ross",
"author_id": 3111,
"author_profile": "https://wordpress.stackexchange.com/users/3111",
"pm_score": 0,
"selected": false,
"text": "<p>You'll probably need to find a solution that loads this content via JavaScript...unfortunately. That's the only wa... | 2011/02/28 | [
"https://wordpress.stackexchange.com/questions/10772",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2966/"
] | At the moment I run PHP code in my side bars. Even though I have the following
```
header("Pragma: no-cache");
header("cache-Control: no-cache, must-revalidate"); // HTTP/1.1
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT"); // Date in the past
```
It still appears to serve cached content. | This can be accomplished with fragment caching feature that W3TC has. Had been [asked/answered](https://wordpress.stackexchange.com/search?q=%22fragment%20caching%22) couple times. |
10,792 | <p>We're creating a site to showcase a series of archival recordings covering a wide variety of topics. We'd like to have a page in the main navigation (e.g. recordings) to display these by title, w/a browse by category option, and have heard the best way to do this is w/custom post types. We're able to start this setu... | [
{
"answer_id": 10800,
"author": "jboutros",
"author_id": 3605,
"author_profile": "https://wordpress.stackexchange.com/users/3605",
"pm_score": 1,
"selected": true,
"text": "<p>In the template for your recordings page you'll want to specify a custom query for the post type in question.</p... | 2011/03/01 | [
"https://wordpress.stackexchange.com/questions/10792",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2815/"
] | We're creating a site to showcase a series of archival recordings covering a wide variety of topics. We'd like to have a page in the main navigation (e.g. recordings) to display these by title, w/a browse by category option, and have heard the best way to do this is w/custom post types. We're able to start this setup b... | In the template for your recordings page you'll want to specify a custom query for the post type in question.
```
$rec_query = new WP_Query('post_type=recording');
```
And then later in your template, you will refer to the query object you created directly instead of relying on the default. For example:
```
while (... |
10,793 | <p>I am having some trouble with scheduling posts to automatically expire (either by deleting or going to draft), every plugin I have tried does nothing and when it reaches the scheduled time nothing happens, which is making me think its probably some simple thing I keep overlooking.. </p>
<p>I thought I might be a pr... | [
{
"answer_id": 10803,
"author": "Guru 2.0",
"author_id": 3550,
"author_profile": "https://wordpress.stackexchange.com/users/3550",
"pm_score": 2,
"selected": false,
"text": "<p>create for these posts a customfield with the name <code>expires</code> and the value is the date for disabling... | 2011/03/01 | [
"https://wordpress.stackexchange.com/questions/10793",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3181/"
] | I am having some trouble with scheduling posts to automatically expire (either by deleting or going to draft), every plugin I have tried does nothing and when it reaches the scheduled time nothing happens, which is making me think its probably some simple thing I keep overlooking..
I thought I might be a problem with... | I got it working using the Post Expirator plugin, which also had the same problem, but by adding the following code to each loop right after 'the\_post();' it checks the posts status on each page load, it is a temporary solution which seems to work for the moment.
```
// check to see whether post has expired
$expirati... |
10,804 | <p>Is it possible for a custom post type to have a permalink as <code>domain.com/custom-slug/</code> instead of <code>domain.com/custom/custom-slug/</code>?</p>
<p>I can't seem to achieve it. <code>rewrite</code> argument while registering it either defaults to the latter one or a custom one by using <code>'rewrite' =... | [
{
"answer_id": 10806,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 0,
"selected": false,
"text": "<p>To completely remove the slug so that the URL structure would look like:</p>\n\n<blockquote>\n <p><a href=\"... | 2011/03/01 | [
"https://wordpress.stackexchange.com/questions/10804",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1521/"
] | Is it possible for a custom post type to have a permalink as `domain.com/custom-slug/` instead of `domain.com/custom/custom-slug/`?
I can't seem to achieve it. `rewrite` argument while registering it either defaults to the latter one or a custom one by using `'rewrite' => array( 'slug' => 'blah-blah' )` | Take a look at [**my answer**](https://wordpress.stackexchange.com/questions/9419/remove-taxonomy-slug-from-a-custom-hierarchical-taxonomy-permalink/10162#10162) to the following question. You can modify my `parse_request()` to get what you need:
* [*"Remove taxonomy slug from a custom hierarchical taxonomy permalink"... |
10,810 | <p>I had added some content to <a href="http://codex.wordpress.org/Adding_Contextual_Help_to_Administration_Menus" rel="nofollow">contextual help section</a> for plugin options page.</p>
<p>Now I'd like that page defaulted/toggled to contextual help section open on specific condition in my PHP code. My only issue is t... | [
{
"answer_id": 10806,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 0,
"selected": false,
"text": "<p>To completely remove the slug so that the URL structure would look like:</p>\n\n<blockquote>\n <p><a href=\"... | 2011/03/01 | [
"https://wordpress.stackexchange.com/questions/10810",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/847/"
] | I had added some content to [contextual help section](http://codex.wordpress.org/Adding_Contextual_Help_to_Administration_Menus) for plugin options page.
Now I'd like that page defaulted/toggled to contextual help section open on specific condition in my PHP code. My only issue is that I am not strong with JS and don'... | Take a look at [**my answer**](https://wordpress.stackexchange.com/questions/9419/remove-taxonomy-slug-from-a-custom-hierarchical-taxonomy-permalink/10162#10162) to the following question. You can modify my `parse_request()` to get what you need:
* [*"Remove taxonomy slug from a custom hierarchical taxonomy permalink"... |
10,821 | <p>is there a way to store the input value from multiple custom meta box fields with the same <code>meta_key</code>?
I use the following code to store ONE value for the <code>meta_key</code> 'startdate':</p>
<pre><code>function startdate() {
global $post;
$custom = get_post_custom($post->ID);
$startdate = $cu... | [
{
"answer_id": 10834,
"author": "supermethod",
"author_id": 3358,
"author_profile": "https://wordpress.stackexchange.com/users/3358",
"pm_score": 0,
"selected": false,
"text": "<p>As mentioned by <a href=\"https://wordpress.stackexchange.com/users/1468/t31os\">t31os</a> try changing your... | 2011/03/01 | [
"https://wordpress.stackexchange.com/questions/10821",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3480/"
] | is there a way to store the input value from multiple custom meta box fields with the same `meta_key`?
I use the following code to store ONE value for the `meta_key` 'startdate':
```
function startdate() {
global $post;
$custom = get_post_custom($post->ID);
$startdate = $custom["startdate"][0];
?>
<label>Star... | Change your form as suggested:
```
function startdate() {
global $post;
$custom = get_post_custom($post->ID);
echo "<label>Startdates</label><br/>";
for ($i=0; $i<count($custom["startdate"]);$i++) {
echo "<input type=\"text\" name=\"startdate[".$i."]\" value=\"".$custom["startdate"][$i]."\" />"... |
10,823 | <p>i've implemented a jQuery gallery for displaying several images within a post.
the problem is that the_content(); also displays the post image.
any ideas how to filter it?
thanks</p>
| [
{
"answer_id": 10824,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": true,
"text": "<p>you can add a filter to the_content hook to strip the images</p>\n\n<p>something like:</p>\n\n<pre><code>add_f... | 2011/03/01 | [
"https://wordpress.stackexchange.com/questions/10823",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3030/"
] | i've implemented a jQuery gallery for displaying several images within a post.
the problem is that the\_content(); also displays the post image.
any ideas how to filter it?
thanks | you can add a filter to the\_content hook to strip the images
something like:
```
add_filter('the_content', 'strip_images',2);
function strip_images($content){
return preg_replace('/<img[^>]+./','',$content);
}
``` |
10,829 | <p>I can't seem to get this to work — I'm trying to show posts that have the meta 'featured_image' value set to anything. From what I can tell, it's set up correctly, but I'm in a little over my head. Here's what I have:</p>
<pre><code> <ul>
<?php
global $post;
$myposts = get_posts(array(
'sho... | [
{
"answer_id": 10830,
"author": "t31os",
"author_id": 31073,
"author_profile": "https://wordpress.stackexchange.com/users/31073",
"pm_score": 0,
"selected": false,
"text": "<p>Firstly your <code>get_post_meta</code> call doesn't have a key, shouldn't that be <code>get_post_meta( $post-&g... | 2011/03/01 | [
"https://wordpress.stackexchange.com/questions/10829",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20013/"
] | I can't seem to get this to work — I'm trying to show posts that have the meta 'featured\_image' value set to anything. From what I can tell, it's set up correctly, but I'm in a little over my head. Here's what I have:
```
<ul>
<?php
global $post;
$myposts = get_posts(array(
'showposts' => 5,
'o... | Not possible with an empty value. See: [How can I show posts only if meta\_value is not empty](https://wordpress.stackexchange.com/questions/10881/how-can-i-show-posts-only-if-meta-value-is-not-empty) |
10,839 | <p>I was wondering if anyone knew of a plugin or a way programmatically to change the the default admin page for a specific user/role?</p>
<p>I have a master panel page for my plugin currently setup with custom roles and permissions for the plugin using the <a href="http://wordpress.org/extend/plugins/members" rel="no... | [
{
"answer_id": 10843,
"author": "wyrfel",
"author_id": 3104,
"author_profile": "https://wordpress.stackexchange.com/users/3104",
"pm_score": 2,
"selected": false,
"text": "<p>Use the <a href=\"http://wordpress.org/extend/plugins/theme-my-login/\" rel=\"nofollow noreferrer\">Theme My Logi... | 2011/03/01 | [
"https://wordpress.stackexchange.com/questions/10839",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2322/"
] | I was wondering if anyone knew of a plugin or a way programmatically to change the the default admin page for a specific user/role?
I have a master panel page for my plugin currently setup with custom roles and permissions for the plugin using the [Members Plugin](http://wordpress.org/extend/plugins/members) and would... | In your theme's *functions.php*:
```
function hide_the_dashboard()
{
global $current_user;
// is there a user ?
if ( is_array( $current_user->roles ) ) {
// substitute your role(s):
if ( in_array( 'custom_role', $current_user->roles ) ) {
// hide the dashboard:
remov... |
10,847 | <p>When using wp_nav_menu how do I make it so 'after' => does not show on the last element of the list?</p>
| [
{
"answer_id": 10851,
"author": "Jeff",
"author_id": 3226,
"author_profile": "https://wordpress.stackexchange.com/users/3226",
"pm_score": 1,
"selected": false,
"text": "<pre><code>$('#menu-top-menu-1').children().last().each( function(){\n var endHtml = $(this).html().replace('<te... | 2011/03/01 | [
"https://wordpress.stackexchange.com/questions/10847",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3226/"
] | When using wp\_nav\_menu how do I make it so 'after' => does not show on the last element of the list? | You can hide it with CSS. For example, if your `after` looks like:
```
<?php wp_nav_menu(array('after' => '<span>|</span>')); ?>
```
Then your css:
```
.menu-item-num span { display: none; }
``` |
10,853 | <p>I've got some custom fields that I would like a user to be able to edit in Quick Edit, I can manage the columns but I'm unable to edit them if Quick Edit is clicked current code with custom fields I'd like to be able to edit:</p>
<pre><code>/* custom columns */
add_filter("manage_edit-programmes_columns", "edit_col... | [
{
"answer_id": 10854,
"author": "Zack",
"author_id": 2322,
"author_profile": "https://wordpress.stackexchange.com/users/2322",
"pm_score": 1,
"selected": true,
"text": "<p>A couple things, </p>\n\n<ol>\n<li>Make sure in your <code>save_post</code> hook you're checking for <code>DOING_AJA... | 2011/03/01 | [
"https://wordpress.stackexchange.com/questions/10853",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31057/"
] | I've got some custom fields that I would like a user to be able to edit in Quick Edit, I can manage the columns but I'm unable to edit them if Quick Edit is clicked current code with custom fields I'd like to be able to edit:
```
/* custom columns */
add_filter("manage_edit-programmes_columns", "edit_columns" );
add_a... | A couple things,
1. Make sure in your `save_post` hook you're checking for `DOING_AJAX` which is used for saving in quick-edit.
2. Check out my other question: [Quick edit screen customization](https://wordpress.stackexchange.com/questions/7291/quick-edit-screen-customization). The answer I received worked, but I hav... |
10,855 | <p>I am trying to query for all posts with a post format of 'quote.' I have added the post formats to my functions.php with</p>
<pre><code>add_theme_support( 'post-formats', array( 'image', 'video', 'gallery', 'quote' ) );
</code></pre>
<p>I have selected 'quote' as the format for the post in the admin. The last exam... | [
{
"answer_id": 10856,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>in <code>tax_query</code> \"terms\" accepts array so you need to put <code>post-format-quote</code> in an arr... | 2011/03/01 | [
"https://wordpress.stackexchange.com/questions/10855",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1756/"
] | I am trying to query for all posts with a post format of 'quote.' I have added the post formats to my functions.php with
```
add_theme_support( 'post-formats', array( 'image', 'video', 'gallery', 'quote' ) );
```
I have selected 'quote' as the format for the post in the admin. The last example under [Taxonomy\_Param... | This code is incorrect! You have
```
'taxonomy' => 'post-format'
```
But it really needs to be:
```
'taxonomy' => 'post_format'
```
Without the underscore, the query will be invalid. I just tested this on my WordPress 3.1 install after pulling my hair out for hours.
Hope that helps!! |
10,858 | <p>I run a multisite install and I have removed the page attributes meta box from view for my users because I don't want them to be able to change templates. I would like them to be able to change the page parent though. I need to add a new meta box for pages that adds just the page parent selector back. </p>
| [
{
"answer_id": 10864,
"author": "wyrfel",
"author_id": 3104,
"author_profile": "https://wordpress.stackexchange.com/users/3104",
"pm_score": 2,
"selected": false,
"text": "<p>Did just that for one of my plugins, recently...</p>\n\n<pre><code>function render($post) {\n $pages = wp_drop... | 2011/03/01 | [
"https://wordpress.stackexchange.com/questions/10858",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I run a multisite install and I have removed the page attributes meta box from view for my users because I don't want them to be able to change templates. I would like them to be able to change the page parent though. I need to add a new meta box for pages that adds just the page parent selector back. | Did just that for one of my plugins, recently...
```
function render($post) {
$pages = wp_dropdown_pages(array('post_type' => 'page', 'exclude_tree' => $post->ID, 'selected' => $post->post_parent, 'name' => 'parent_id', 'show_option_none' => __('(no parent)'), 'sort_column'=> 'menu_order, post_title', 'echo' => 0)... |
10,863 | <p>I've been looking for a list all WP_Query arguments.</p>
<p>This looks obvious, but <a href="http://codex.wordpress.org/Function_Reference/WP_Query" rel="nofollow">http://codex.wordpress.org/Function_Reference/WP_Query</a> isn't helpful at all, "post_type" is mentioned only in an example, and arguments like "posts_... | [
{
"answer_id": 10864,
"author": "wyrfel",
"author_id": 3104,
"author_profile": "https://wordpress.stackexchange.com/users/3104",
"pm_score": 2,
"selected": false,
"text": "<p>Did just that for one of my plugins, recently...</p>\n\n<pre><code>function render($post) {\n $pages = wp_drop... | 2011/03/02 | [
"https://wordpress.stackexchange.com/questions/10863",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1869/"
] | I've been looking for a list all WP\_Query arguments.
This looks obvious, but <http://codex.wordpress.org/Function_Reference/WP_Query> isn't helpful at all, "post\_type" is mentioned only in an example, and arguments like "posts\_per\_page" aren't even there. | Did just that for one of my plugins, recently...
```
function render($post) {
$pages = wp_dropdown_pages(array('post_type' => 'page', 'exclude_tree' => $post->ID, 'selected' => $post->post_parent, 'name' => 'parent_id', 'show_option_none' => __('(no parent)'), 'sort_column'=> 'menu_order, post_title', 'echo' => 0)... |
10,866 | <p>I am creating a plugin which uses a custom post type. My question is two folds:</p>
<p>(1) upon activation of my plugin how do I create the items of my custom post types. For example: if my post type was say... "Best Restaurants". I want to create 10 custom post types items since my plugin will need this informatio... | [
{
"answer_id": 10868,
"author": "wyrfel",
"author_id": 3104,
"author_profile": "https://wordpress.stackexchange.com/users/3104",
"pm_score": 0,
"selected": false,
"text": "<p>For (1): use <code>wp_insert_post()</code>.</p>\n\n<p>For (2): One idea would be to insert the posts as above and... | 2011/03/02 | [
"https://wordpress.stackexchange.com/questions/10866",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/413/"
] | I am creating a plugin which uses a custom post type. My question is two folds:
(1) upon activation of my plugin how do I create the items of my custom post types. For example: if my post type was say... "Best Restaurants". I want to create 10 custom post types items since my plugin will need this information. How wou... | Yes @wyrfel is right, you use `wp_insert_post()` to create your posts. Using your 50 US States example I've created some code you can drop into your theme's `functions.php` to see how it works *(although you'll probably not want to call `add_states_if_not_yet_added()` for every page load, but the example is easier to s... |
10,869 | <p>My client isn't a great fan of updates so I want to assure him that the next major upgrade will be at least 3-4 months down the line. I just upgraded his blog to 3.1 - (YAY!)</p>
<p>Would anyone concur with this or is this just wishful thinking on my part?</p>
| [
{
"answer_id": 10868,
"author": "wyrfel",
"author_id": 3104,
"author_profile": "https://wordpress.stackexchange.com/users/3104",
"pm_score": 0,
"selected": false,
"text": "<p>For (1): use <code>wp_insert_post()</code>.</p>\n\n<p>For (2): One idea would be to insert the posts as above and... | 2011/03/02 | [
"https://wordpress.stackexchange.com/questions/10869",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3361/"
] | My client isn't a great fan of updates so I want to assure him that the next major upgrade will be at least 3-4 months down the line. I just upgraded his blog to 3.1 - (YAY!)
Would anyone concur with this or is this just wishful thinking on my part? | Yes @wyrfel is right, you use `wp_insert_post()` to create your posts. Using your 50 US States example I've created some code you can drop into your theme's `functions.php` to see how it works *(although you'll probably not want to call `add_states_if_not_yet_added()` for every page load, but the example is easier to s... |
10,881 | <p>Three people have already tried to solve this, and we're coming up nil. I want to show only posts that have a value in the meta_key 'featured_image'.</p>
<p>So... if 'featured_image' is not empty, show the post. Here's the code:</p>
<pre><code> <ul>
<?php
$args = array(
'showposts... | [
{
"answer_id": 10882,
"author": "MikeSchinkel",
"author_id": 89,
"author_profile": "https://wordpress.stackexchange.com/users/89",
"pm_score": 4,
"selected": true,
"text": "<p>Hi <strong>@Rob:</strong></p>\n\n<p>The reason you can't figure out how to do it is because it's not possible, a... | 2011/03/02 | [
"https://wordpress.stackexchange.com/questions/10881",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20013/"
] | Three people have already tried to solve this, and we're coming up nil. I want to show only posts that have a value in the meta\_key 'featured\_image'.
So... if 'featured\_image' is not empty, show the post. Here's the code:
```
<ul>
<?php
$args = array(
'showposts' => 5,
'meta_query... | Hi **@Rob:**
The reason you can't figure out how to do it is because it's not possible, at least not without resorting to SQL. Try adding the following to your theme's `functions.php` file:
```
add_filter('posts_where','yoursite_posts_where',10,2);
function yoursite_posts_where($where,$query) {
global $wpdb;
$new... |
10,891 | <p>I created a custom post type "landing_page" to hold content I want to display on the top of category archive pages.</p>
<p>So for each category, I have one landing_page entry tagged with that category. What do I have to add to the category archive.php template to get it to show that category's (or custom taxonomy t... | [
{
"answer_id": 10893,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 0,
"selected": false,
"text": "<p>You can get the current category with </p>\n\n<p>and since you are using archive.php and not category.php che... | 2011/03/02 | [
"https://wordpress.stackexchange.com/questions/10891",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3564/"
] | I created a custom post type "landing\_page" to hold content I want to display on the top of category archive pages.
So for each category, I have one landing\_page entry tagged with that category. What do I have to add to the category archive.php template to get it to show that category's (or custom taxonomy term's) l... | I'd suggest adding something like this to the top of the theme file or wherever you want this content to appear in the archive, category or whatever..
```
// Check if it's a category or taxonomy archive
if( is_category() || is_tax() ) {
// Grab the queried data, slug, tax, etc..
$queried = $wp_query->get_queri... |
10,895 | <pre><code>function themeperauthor_need_switch() {
global $post;
if ( $get_post_type == 'weblogs' ) {
return get_the_author_meta('themeperauthor', $user->ID);
}
return "";
}
</code></pre>
<p>It doesn't return anything</p>
| [
{
"answer_id": 10896,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 1,
"selected": false,
"text": "<p>You are using get_post_type as variable instead of a function try:</p>\n\n<pre><code>function themeperauthor_... | 2011/03/02 | [
"https://wordpress.stackexchange.com/questions/10895",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3615/"
] | ```
function themeperauthor_need_switch() {
global $post;
if ( $get_post_type == 'weblogs' ) {
return get_the_author_meta('themeperauthor', $user->ID);
}
return "";
}
```
It doesn't return anything | You are using get\_post\_type as variable instead of a function try:
```
function themeperauthor_need_switch() {
global $post;
if ( get_post_type($post) == 'weblogs' ) {
return get_the_author_meta('themeperauthor', $user->ID);
}
return "";
}
``` |
10,900 | <p>Ok I have a WP site using the permalink structure of <code>/%category%/%postname%/</code></p>
<p>I have built it in the way of page templates, using category queries inside, i.e.</p>
<p><strong>page-help.php</strong></p>
<pre><code><?php $my_query = new WP_Query('category_name=help');
while ($my_query->have... | [
{
"answer_id": 10896,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 1,
"selected": false,
"text": "<p>You are using get_post_type as variable instead of a function try:</p>\n\n<pre><code>function themeperauthor_... | 2011/03/02 | [
"https://wordpress.stackexchange.com/questions/10900",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1956/"
] | Ok I have a WP site using the permalink structure of `/%category%/%postname%/`
I have built it in the way of page templates, using category queries inside, i.e.
**page-help.php**
```
<?php $my_query = new WP_Query('category_name=help');
while ($my_query->have_posts()) : $my_query->the_post(); ?>
<!--content-->
... | You are using get\_post\_type as variable instead of a function try:
```
function themeperauthor_need_switch() {
global $post;
if ( get_post_type($post) == 'weblogs' ) {
return get_the_author_meta('themeperauthor', $user->ID);
}
return "";
}
``` |
10,907 | <p>If there is a network (multisite installation) with 10 sites inside. Is there a clean way to separate that site to its own site in a different server?</p>
<p>How?</p>
| [
{
"answer_id": 10918,
"author": "Dougal Campbell",
"author_id": 65,
"author_profile": "https://wordpress.stackexchange.com/users/65",
"pm_score": 1,
"selected": false,
"text": "<p>We might need more details, but I'm going to assume that you are using subdomains, and that you want to reta... | 2011/03/02 | [
"https://wordpress.stackexchange.com/questions/10907",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3536/"
] | If there is a network (multisite installation) with 10 sites inside. Is there a clean way to separate that site to its own site in a different server?
How? | We might need more details, but I'm going to assume that you are using subdomains, and that you want to retain the site's subdomain name on the new server. If that's the case, then all you should need to do is export the site, then import it on the new server. Then set up a new DNS 'A' record to point that specific sit... |
10,917 | <p>Let's assume I have a widget that displays only its name:</p>
<pre><code> <p>
<?php echo $args['widget_id'] ?>
</p>
</code></pre>
<p>So when I drag & drop my widget to any sidebar it shows:</p>
<pre><code><p>
myWidget-number
</p>
</code></pre>
<p>The problem... | [
{
"answer_id": 11092,
"author": "Wordpressor",
"author_id": 1869,
"author_profile": "https://wordpress.stackexchange.com/users/1869",
"pm_score": 2,
"selected": true,
"text": "<p>I believe @One Trick Pony was right.</p>\n\n<p>Shortcode widgets have no ID, so I've found a way around.</p>\... | 2011/03/02 | [
"https://wordpress.stackexchange.com/questions/10917",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1869/"
] | Let's assume I have a widget that displays only its name:
```
<p>
<?php echo $args['widget_id'] ?>
</p>
```
So when I drag & drop my widget to any sidebar it shows:
```
<p>
myWidget-number
</p>
```
The problem is I want to call this widget with a shortcode:
```
(...)
ob_star... | I believe @One Trick Pony was right.
Shortcode widgets have no ID, so I've found a way around.
Firstly I used PHP rand function:
```
$var = rand();
```
And then added the "var" to the ID, so it doesn't collide with other shortcodes calling the same widget (each one has different random number at the end of the ID)... |
10,941 | <p>Is it possible to order my list of custom posts, after filtering it with meta_query, by the meta data of my choice?</p>
<p>For example, I have a custom post type called webinars. I am trying to list all upcoming webinars, and have them ordered by the custom meta field called webinar_startDate.</p>
<p>Using the fol... | [
{
"answer_id": 10944,
"author": "Guru 2.0",
"author_id": 3550,
"author_profile": "https://wordpress.stackexchange.com/users/3550",
"pm_score": 1,
"selected": false,
"text": "<p>I'm using the following code for my custom posts called <code>events</code>, to get all posts in a Loop. </p>\n... | 2011/03/02 | [
"https://wordpress.stackexchange.com/questions/10941",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3645/"
] | Is it possible to order my list of custom posts, after filtering it with meta\_query, by the meta data of my choice?
For example, I have a custom post type called webinars. I am trying to list all upcoming webinars, and have them ordered by the custom meta field called webinar\_startDate.
Using the following query, I... | the new `meta_query` array selects which posts the query returns. So yes, you are indicating the 'key' within that `meta_query`, but you can still use the old method of
```
'orderby' => 'meta_value',
'meta_key' => '_events_meta',
```
in addition to the meta\_query, as these lines indicate how to *sort* the resulti... |
10,953 | <p>Somehow my post counts are incorrect due to inserting rows via php. I have the following code to update the count, is it correct?</p>
<pre><code>global $wpdb;
$result = mysql_query("SELECT term_id,term_taxonomy_id FROM $wpdb->term_taxonomy where taxonomy = 'category'");
while ($row = mysql_fetch_array($result)) ... | [
{
"answer_id": 10959,
"author": "goldenapples",
"author_id": 290,
"author_profile": "https://wordpress.stackexchange.com/users/290",
"pm_score": 4,
"selected": true,
"text": "<p>If you just want to update the counts of posts in each term, <code>wp_update_term_count_now( $terms, $taxonomy... | 2011/03/02 | [
"https://wordpress.stackexchange.com/questions/10953",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1426/"
] | Somehow my post counts are incorrect due to inserting rows via php. I have the following code to update the count, is it correct?
```
global $wpdb;
$result = mysql_query("SELECT term_id,term_taxonomy_id FROM $wpdb->term_taxonomy where taxonomy = 'category'");
while ($row = mysql_fetch_array($result)) {
$term_taxonom... | If you just want to update the counts of posts in each term, `wp_update_term_count_now( $terms, $taxonomy )` should do it... just pass the terms affected as an array and run it once for each taxonomy you have.
You can also call `wp_defer_term_counting( true )` before inserting new rows, and then after adding your post... |
10,973 | <p>Is there a way of creating an empty attribute for a shortcode?</p>
<p>Example:</p>
<pre><code>function paragraph_shortcode( $atts, $content = null ) {
return '<p class="super-p">' . do_shortcode($content) . '</p>';
}
add_shortcode('paragraph', 'paragraph_shortcode');
</code></pre>
<p>User types ... | [
{
"answer_id": 10976,
"author": "SethMerrick",
"author_id": 15,
"author_profile": "https://wordpress.stackexchange.com/users/15",
"pm_score": 2,
"selected": true,
"text": "<p>There could be a couple ways to do this. Unfortunately, I don't think any will result in exactly what you're goin... | 2011/03/03 | [
"https://wordpress.stackexchange.com/questions/10973",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1869/"
] | Is there a way of creating an empty attribute for a shortcode?
Example:
```
function paragraph_shortcode( $atts, $content = null ) {
return '<p class="super-p">' . do_shortcode($content) . '</p>';
}
add_shortcode('paragraph', 'paragraph_shortcode');
```
User types
>
> [paragraph] something [/paragraph]
>
... | There could be a couple ways to do this. Unfortunately, I don't think any will result in exactly what you're going for. ( `[paragraph last]` )
1. You could just create separate shortcodes for `[paragraph_first]` `[paragraph_last]` `[paragraph_foobar]` that handle $content without needing any attributes
2. You could se... |
10,979 | <p>How do I display this page in a Wordpress site? What do i need to add or remove? This is for a static page not a blog post.</p>
<p>(FYI: I want to use this to display a family tree on my website). I'm a wordpress beginner so please explain this at a beginner level if possible thanks</p>
<pre><code><html>... | [
{
"answer_id": 10991,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 1,
"selected": false,
"text": "<p>The fastest way would be an iframe plugin ( like \"Embed Iframe\") , you can then just copy past it all and cross y... | 2011/03/03 | [
"https://wordpress.stackexchange.com/questions/10979",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | How do I display this page in a Wordpress site? What do i need to add or remove? This is for a static page not a blog post.
(FYI: I want to use this to display a family tree on my website). I'm a wordpress beginner so please explain this at a beginner level if possible thanks
```
<html>
<head>
<script type='tex... | The fastest way would be an iframe plugin ( like "Embed Iframe") , you can then just copy past it all and cross your fingers.
You might also be able to just copy/past from the script tag to /script into the html editor of a post.
The alternative and best method is to make your own custom template page and throw it i... |
10,998 | <p>Basically I have a custom post type of 'products' which has two taxonomies attached to it...the normal 'category' and a custom taxonomy called 'brands'.</p>
<p>I have a page which is 'brand' specific. On this page I'd like to list all the 'categories' that have a 'product' in them with a term of the 'brand' whos pa... | [
{
"answer_id": 11005,
"author": "MikeSchinkel",
"author_id": 89,
"author_profile": "https://wordpress.stackexchange.com/users/89",
"pm_score": 3,
"selected": true,
"text": "<p>Hi <strong>@daveaspi:</strong></p>\n\n<p>What you want to do is common but not well handled in WordPress core. T... | 2011/03/03 | [
"https://wordpress.stackexchange.com/questions/10998",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/912/"
] | Basically I have a custom post type of 'products' which has two taxonomies attached to it...the normal 'category' and a custom taxonomy called 'brands'.
I have a page which is 'brand' specific. On this page I'd like to list all the 'categories' that have a 'product' in them with a term of the 'brand' whos page I'm on ... | Hi **@daveaspi:**
What you want to do is common but not well handled in WordPress core. There are probably ways to do it without custom SQL but I don't think they would scale for a large number of posts. Below is a function I wrote called `get_cross_referenced_terms()` that will get what you want, complete with an exa... |
10,999 | <p>(repost from <a href="http://themehybrid.com/community/topic/how-to-auto-activate-plugins-from-child-themes" rel="nofollow">Theme Hybrid Community</a>)</p>
<p>Let's assume a plugin or multiple-plugins are hosted on WordPress.org. Can you automatically activate plugins with the functions.php of a child theme? Is the... | [
{
"answer_id": 11060,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 2,
"selected": true,
"text": "<p>include this function in your theme and use this hookfunction </p>\n\n<pre><code>wp_register_theme_activation_hook(... | 2011/03/03 | [
"https://wordpress.stackexchange.com/questions/10999",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1809/"
] | (repost from [Theme Hybrid Community](http://themehybrid.com/community/topic/how-to-auto-activate-plugins-from-child-themes))
Let's assume a plugin or multiple-plugins are hosted on WordPress.org. Can you automatically activate plugins with the functions.php of a child theme? Is there any problem with doing such a thi... | include this function in your theme and use this hookfunction
```
wp_register_theme_activation_hook($code, $function) {
$optionKey="theme_is_activated_" . $code;
if(!get_option($optionKey)) {
call_user_func($function);
update_option($optionKey , 1);
}
}
```
functions and examples:
```
<... |
11,003 | <p>Is there a way to prevent the Visual Editor from modifying my HTML when creating a post or a page? I know it has good intentions in doing what it does, but sometimes I'd prefer it not to touch my HTML, yet render the HTML in visual mode. </p>
<p>Thank you!</p>
<p><strong>Sample of code used in editor:</strong></p>... | [
{
"answer_id": 11043,
"author": "Dalton Rooney",
"author_id": 799,
"author_profile": "https://wordpress.stackexchange.com/users/799",
"pm_score": 1,
"selected": false,
"text": "<p>I don't think there's a way to get TinyMCE to leave your HTML alone. This has been discussed in the WP Forum... | 2011/03/03 | [
"https://wordpress.stackexchange.com/questions/11003",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2630/"
] | Is there a way to prevent the Visual Editor from modifying my HTML when creating a post or a page? I know it has good intentions in doing what it does, but sometimes I'd prefer it not to touch my HTML, yet render the HTML in visual mode.
Thank you!
**Sample of code used in editor:**
```
<td width="124" align="left"... | This wordpress plugin seems to do the trick for my problem...
<http://wordpress.org/extend/plugins/raw-html/>
It does seem wrong that if I enter code in the html editor it then strips it unless I resort to cheats like the pluging or adding class tags that do nothing. |
11,006 | <p>Trying to get my head round a request from a client, and thought I'd try to hivemind the solution a little bit.</p>
<p>The client requires a two column post layout, with images down the right and text on the left.</p>
<p>Now, that bit it relatively straight forward (he says, having not tried it yet), but the real ... | [
{
"answer_id": 11010,
"author": "wyrfel",
"author_id": 3104,
"author_profile": "https://wordpress.stackexchange.com/users/3104",
"pm_score": 1,
"selected": false,
"text": "<p>This is more of a CSS question. You put your image tag into the paragraph (<code><p><img/>....</p&... | 2011/03/03 | [
"https://wordpress.stackexchange.com/questions/11006",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/784/"
] | Trying to get my head round a request from a client, and thought I'd try to hivemind the solution a little bit.
The client requires a two column post layout, with images down the right and text on the left.
Now, that bit it relatively straight forward (he says, having not tried it yet), but the real trouble is the ne... | I'd have thought it's just a matter of formulating your HTML in a way that accomodates the image alignment requirement..
You could have two seperate elements, one for the post's image, one for paragraph(s) of content, and float them side by side. Add a wrapper around the two..
So you basically have two elements, side... |
11,009 | <p>I am merging Wordpress into a existing system and require our users to be able to make posts to a multi-site WP install. I have a database table that will link our own member to specific blog IDs and stuff, so there will be no need for user/logins as far as WP is concerned.</p>
<p>What I really need to know is how ... | [
{
"answer_id": 11128,
"author": "Dunhamzzz",
"author_id": 3669,
"author_profile": "https://wordpress.stackexchange.com/users/3669",
"pm_score": 3,
"selected": true,
"text": "<p>Ok I have cracked it, by spoofing the $_SERVER variable and pre-defing some constants, I was able to prevent Wo... | 2011/03/03 | [
"https://wordpress.stackexchange.com/questions/11009",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3669/"
] | I am merging Wordpress into a existing system and require our users to be able to make posts to a multi-site WP install. I have a database table that will link our own member to specific blog IDs and stuff, so there will be no need for user/logins as far as WP is concerned.
What I really need to know is how to run cer... | Ok I have cracked it, by spoofing the $\_SERVER variable and pre-defing some constants, I was able to prevent Wordpress from redirecting after the inclusion of wp-load.php.
```
define('WP_USE_THEMES', false);
define( 'DOMAIN_CURRENT_SITE', $siteRow['domain'] );
define( 'PATH_CURRENT_SITE', '/' );
define( 'SITE_ID_CURR... |
11,035 | <p>I'm working on a site at the moment for an orchestra. The various members need to be listed, according to their instrument. The members have a custom post type of biography and I'm capturing the instrument value via a custom field.</p>
<p>The only way I can figure out how to display the relevant people in their rel... | [
{
"answer_id": 11036,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>Ehm... you don't need to write a loop again and again. Only work on the part that get's changed. The loop will thro... | 2011/03/03 | [
"https://wordpress.stackexchange.com/questions/11035",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3430/"
] | I'm working on a site at the moment for an orchestra. The various members need to be listed, according to their instrument. The members have a custom post type of biography and I'm capturing the instrument value via a custom field.
The only way I can figure out how to display the relevant people in their relevant sect... | You could do it with one loop, you just need a valid sort order right? Players with one instrument, followed by the next and so on..
**UPDATE:** *Following on the asker's comment, you can still use one query and use `rewind_posts()` to iterate the loop as many times as you need, ie. do something like this to get a cus... |
11,052 | <p>I set the jQuery Datepicker format to <strong>D d.m.</strong> displayed as <strong>Th 3.3.</strong> for a custom meta field that I want to use to sort posts. In SQL, the custom meta field is saved as <strong>D d.m.</strong></p>
<p>I would like to display the <strong>D d.m.</strong> format on the front end and store... | [
{
"answer_id": 11105,
"author": "wyrfel",
"author_id": 3104,
"author_profile": "https://wordpress.stackexchange.com/users/3104",
"pm_score": 2,
"selected": false,
"text": "<p>please view the 'alternate Field' example and source code on <a href=\"http://jqueryui.com/demos/datepicker/#alt-... | 2011/03/03 | [
"https://wordpress.stackexchange.com/questions/11052",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2650/"
] | I set the jQuery Datepicker format to **D d.m.** displayed as **Th 3.3.** for a custom meta field that I want to use to sort posts. In SQL, the custom meta field is saved as **D d.m.**
I would like to display the **D d.m.** format on the front end and store it as mm-dd-yy or 03-03-2011 in my SQL database.
Any ideas?... | Firstly you'll need to stop storing the dates in `D d.m` format, the queries aren't going to be able to sort based on that data.
As wyrfel pointed out, you'll need to use the alternate field option to have two fields, one that shows the pretty(or your chosen) date format, and another that holds the value you store in ... |
11,054 | <p>I'm trying to 'break apart', (think explode is the correct terminology), wp_list_pages in order to add some definition list code into it, (dl, dt, dd).</p>
<p>Here is the html code that I'm trying to output:</p>
<pre><code><div id="nav">
<ul id="drop-nav">
... | [
{
"answer_id": 11065,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": true,
"text": "<p>This is one of those question where solid answer is not an easy one to follow. This function is powered by <a href=\"... | 2011/03/03 | [
"https://wordpress.stackexchange.com/questions/11054",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3362/"
] | I'm trying to 'break apart', (think explode is the correct terminology), wp\_list\_pages in order to add some definition list code into it, (dl, dt, dd).
Here is the html code that I'm trying to output:
```
<div id="nav">
<ul id="drop-nav">
<li><a href="#">Abo... | This is one of those question where solid answer is not an easy one to follow. This function is powered by [`Walker_Page`](http://core.trac.wordpress.org/browser/tags/3.1/wp-includes/post-template.php#L958) class and you can replace it with your own walker (extended from `Walker_Page` or just `Walker`) by passing its n... |
11,055 | <p>I'm trying to create a loop of explicity ordered posts, for example: </p>
<pre><code><?php $args = array(
'include' => '1,3,8,4,12' ); ?>
<?php get_posts( $args ); ?>
</code></pre>
<p>The results are ordered by date by default, and there is no orderby option to return the posts in the ... | [
{
"answer_id": 11074,
"author": "Dougal Campbell",
"author_id": 65,
"author_profile": "https://wordpress.stackexchange.com/users/65",
"pm_score": 0,
"selected": false,
"text": "<p>How about just clearing the <code>orderby</code> with a filter? Right before you query your posts, put in:</... | 2011/03/03 | [
"https://wordpress.stackexchange.com/questions/11055",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/799/"
] | I'm trying to create a loop of explicity ordered posts, for example:
```
<?php $args = array(
'include' => '1,3,8,4,12' ); ?>
<?php get_posts( $args ); ?>
```
The results are ordered by date by default, and there is no orderby option to return the posts in the order they were entered. There have been ... | Okay, I was determined to find a way to do this, and I think I've got it. I had hoped to find a simpler solution and avoid having to use a new WP\_Query object, but it's just too ingrained into how the loop works. First, we have a couple of utility functions:
```
// Set post menu order based on our list
function set... |
11,069 | <p>So I have a section on my site that specifically searches a custom post type for YouTube videos. I'm absolutely able to search the custom type. However, I'm unsure how to create a search page that has custom formatting geared toward this type of search.</p>
<p>I've created a custom loop-youtube.php and modified wit... | [
{
"answer_id": 11077,
"author": "starepod",
"author_id": 3684,
"author_profile": "https://wordpress.stackexchange.com/users/3684",
"pm_score": 3,
"selected": true,
"text": "<p>How are you restricting the search to your custom post type? If you are doing it by passing an additional argume... | 2011/03/03 | [
"https://wordpress.stackexchange.com/questions/11069",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3296/"
] | So I have a section on my site that specifically searches a custom post type for YouTube videos. I'm absolutely able to search the custom type. However, I'm unsure how to create a search page that has custom formatting geared toward this type of search.
I've created a custom loop-youtube.php and modified within search... | How are you restricting the search to your custom post type? If you are doing it by passing an additional argument, i.e. &type=myCustomPostType, you could use a conditional test, like:
```
if(isset($_GET['type'] && $_GET['type'] == 'myCustomPostType')):
get_template_part('loop','youtube');
else:
get_template_part(l... |
11,091 | <p>I'm wondering how to write a list of sub-pages of actually visited page.</p>
<p>So I have 2 pages and 3 sub-pages for each:</p>
<pre><code>Colors [page]
- Red [child of Colors - subpage]
- Blue [child of Colors - subpage]
- Green [child of Colors - subpage]
Numbers [page]
- One [child of Numbers - subpage]
- Two ... | [
{
"answer_id": 11093,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 3,
"selected": true,
"text": "<p>easy just pass it the $id off which to get the children</p>\n\n<pre><code> global $id;\n wp_list_pages(\"tit... | 2011/03/04 | [
"https://wordpress.stackexchange.com/questions/11091",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1869/"
] | I'm wondering how to write a list of sub-pages of actually visited page.
So I have 2 pages and 3 sub-pages for each:
```
Colors [page]
- Red [child of Colors - subpage]
- Blue [child of Colors - subpage]
- Green [child of Colors - subpage]
Numbers [page]
- One [child of Numbers - subpage]
- Two [child of Numbers - s... | easy just pass it the $id off which to get the children
```
global $id;
wp_list_pages("title_li=&child_of=$id");
```
of if you want in the loop then
```
wp_list_pages("title_li=&child_of=$post->ID");
``` |
11,134 | <p>I coded a wordpress shortcode for columns that basically inserts html via a shortcode. Problem is that wpautop adds stray p elements that renders the code invalid.</p>
<p>To test put this into your functions.php:</p>
<pre><code>function static_col_container($atts, $content) {
extract(shortcode_atts(array(
... | [
{
"answer_id": 11137,
"author": "keatch",
"author_id": 2727,
"author_profile": "https://wordpress.stackexchange.com/users/2727",
"pm_score": 4,
"selected": true,
"text": "<p>Remove the filter from the the_content and run it after the shortcode are processed.</p>\n\n<p>Try:</p>\n\n<pre><c... | 2011/03/04 | [
"https://wordpress.stackexchange.com/questions/11134",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3701/"
] | I coded a wordpress shortcode for columns that basically inserts html via a shortcode. Problem is that wpautop adds stray p elements that renders the code invalid.
To test put this into your functions.php:
```
function static_col_container($atts, $content) {
extract(shortcode_atts(array(
'foo' => 'bar'
... | Remove the filter from the the\_content and run it after the shortcode are processed.
Try:
```
remove_filter( 'the_content', 'wpautop' );
add_filter( 'the_content', 'wpautop' , 12);
```
Usually shortcodes are processed after wpautop is applied to the content. See <http://core.trac.wordpress.org/browser/tags/3.1/wp-... |
11,141 | <p>I am running some of the WP functions directly inside a plugin, including wp_insert_post(), if something goes wrong, this returns a WP Error object, what is the correct method to catch this error? Either using built in WP functions or PHP exceptions or whatnot..</p>
| [
{
"answer_id": 11142,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 6,
"selected": true,
"text": "<ol>\n<li><p>Assign return of the function to the variable.</p></li>\n<li><p>Check the variable with <a href=\"http://co... | 2011/03/04 | [
"https://wordpress.stackexchange.com/questions/11141",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3669/"
] | I am running some of the WP functions directly inside a plugin, including wp\_insert\_post(), if something goes wrong, this returns a WP Error object, what is the correct method to catch this error? Either using built in WP functions or PHP exceptions or whatnot.. | 1. Assign return of the function to the variable.
2. Check the variable with [`is_wp_error()`](http://codex.wordpress.org/Function_Reference/is_wp_error).
3. If `true` handle accordingly, for example [`trigger_error()`](http://php.net/manual/en/function.trigger-error.php) with message from [`WP_Error->get_error_message... |
11,145 | <p>My sidebar widget code in functions.php looks like this...</p>
<pre><code>if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Home Sidebar',
'id' => 'home-sidebar-widget',
'before_widget' => '<div class="menu side %2$s">',
'after_widget' => '</div>',... | [
{
"answer_id": 11148,
"author": "wyrfel",
"author_id": 3104,
"author_profile": "https://wordpress.stackexchange.com/users/3104",
"pm_score": 4,
"selected": true,
"text": "<p>There doesn't seem to be an easy way to do this. However, you can try this rather hackish approach:</p>\n\n<pre><c... | 2011/03/04 | [
"https://wordpress.stackexchange.com/questions/11145",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/366/"
] | My sidebar widget code in functions.php looks like this...
```
if ( function_exists('register_sidebar') )
register_sidebar(array(
'name' => 'Home Sidebar',
'id' => 'home-sidebar-widget',
'before_widget' => '<div class="menu side %2$s">',
'after_widget' => '</div>',
'before_title' => '<h4 class="sid... | There doesn't seem to be an easy way to do this. However, you can try this rather hackish approach:
```
add_filter('dynamic_sidebar_params', 'my_sidebar_params_cb');
function my_sidebar_params_cb($params) {
global $my_widget_counter;
if (empty($my_widget_counter)) $my_widget_counter = 1;
else $my_widget_c... |
11,158 | <p>I'm trying to import independent stylesheets for the blog page, gallery page and the contact page but I'm having some trouble getting this to work.</p>
<pre><code><link rel="stylesheet" type="text/css" href="<?php bloginfo('http://www.dannysgallery.com/tracy/wp-content/themes/infocus/styles/deep_blue.css'); ?... | [
{
"answer_id": 11162,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>First, your usage of <a href=\"http://codex.wordpress.org/Function_Reference/bloginfo\" rel=\"nofollow\"><code>blogi... | 2011/03/04 | [
"https://wordpress.stackexchange.com/questions/11158",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I'm trying to import independent stylesheets for the blog page, gallery page and the contact page but I'm having some trouble getting this to work.
```
<link rel="stylesheet" type="text/css" href="<?php bloginfo('http://www.dannysgallery.com/tracy/wp-content/themes/infocus/styles/deep_blue.css'); ?>" media="screen" />... | There's a part in your header template that's already doing conditional loading:
```
<?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
```
This code loads the JavaScript for comments into the queue; WordPress then loads all of the scripts when it fires the `wp_head()` trigger.
My recommendation wo... |
11,161 | <p>I've searched and found posts that have asked and answered how to merge different categories into an RSS feed. <strong>What I need to know is how to exclude specific categories from the RSS feed?</strong> </p>
<p>Specifically, I use WP to post blog articles and to post portfolio items onto my site. I want to excl... | [
{
"answer_id": 11162,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>First, your usage of <a href=\"http://codex.wordpress.org/Function_Reference/bloginfo\" rel=\"nofollow\"><code>blogi... | 2011/03/04 | [
"https://wordpress.stackexchange.com/questions/11161",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2709/"
] | I've searched and found posts that have asked and answered how to merge different categories into an RSS feed. **What I need to know is how to exclude specific categories from the RSS feed?**
Specifically, I use WP to post blog articles and to post portfolio items onto my site. I want to exclude the portfolio categor... | There's a part in your header template that's already doing conditional loading:
```
<?php if ( is_singular() ) wp_enqueue_script( 'comment-reply' ); ?>
```
This code loads the JavaScript for comments into the queue; WordPress then loads all of the scripts when it fires the `wp_head()` trigger.
My recommendation wo... |
11,168 | <p>how do I match an image title from the media library to a variable then echo that image? this is my current code... </p>
<pre><code> <?php
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => null,
);
$attachments = get_posts... | [
{
"answer_id": 11169,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p><code>$attachments</code> holds array of posts, you are missing something like:</p>\n\n<pre><code>$attachment = $att... | 2011/03/04 | [
"https://wordpress.stackexchange.com/questions/11168",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31057/"
] | how do I match an image title from the media library to a variable then echo that image? this is my current code...
```
<?php
$args = array(
'post_type' => 'attachment',
'numberposts' => -1,
'post_status' => null,
'post_parent' => null,
);
$attachments = get_posts( $args );
if ($attachment->... | `$attachments` holds array of posts, you are missing something like:
```
$attachment = $attachments[0];
```
or
```
foreach( $attachments as $attachment )
```
**Update**
Nope, like this:
```
foreach( $attachments as $attachment )
if ($attachment->post_title == $programme) {
echo the_attachment_link(... |
11,173 | <p>I have a query_posts call in a WP template. Through the use of the More Fields Plugin I can give the site admin the ability to create an event (custom post type) and then enter a date which is formatted: YYYY/mm/dd.</p>
<p>The main question is; what value should I pass to the value option in the meta_query array? ... | [
{
"answer_id": 11183,
"author": "wyrfel",
"author_id": 3104,
"author_profile": "https://wordpress.stackexchange.com/users/3104",
"pm_score": 3,
"selected": false,
"text": "<p>It largely depends on how your date is stored in the meta value in the first place. In general, it is a good idea... | 2011/03/04 | [
"https://wordpress.stackexchange.com/questions/11173",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2755/"
] | I have a query\_posts call in a WP template. Through the use of the More Fields Plugin I can give the site admin the ability to create an event (custom post type) and then enter a date which is formatted: YYYY/mm/dd.
The main question is; what value should I pass to the value option in the meta\_query array? I am curr... | I wound up going with the following. I setup a event-momth field and comparing from there. thanks for the help
```
<?php
$event_query = new WP_Query(
array(
'post_type' => 'event', // only query events
'meta_key' => 'event-month', // load up the event_date meta
... |
11,199 | <p>Is it possible to display a wordpress category page but have it pull posts from mulitple categories? </p>
<p>For example, let's say I need to pass in params for <code>cat_id</code> in this fashion </p>
<pre><code>/category/dining/?location=2&activity=2
</code></pre>
<p>And have the resulting page produce a l... | [
{
"answer_id": 13024,
"author": "petermolnar",
"author_id": 4209,
"author_profile": "https://wordpress.stackexchange.com/users/4209",
"pm_score": 2,
"selected": false,
"text": "<p>Yes, it is.</p>\n\n<p>You'll need a template page for the category (for example, category-30.php, where 30 i... | 2011/03/04 | [
"https://wordpress.stackexchange.com/questions/11199",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | Is it possible to display a wordpress category page but have it pull posts from mulitple categories?
For example, let's say I need to pass in params for `cat_id` in this fashion
```
/category/dining/?location=2&activity=2
```
And have the resulting page produce a list of posts from the categories specified by `lo... | Yes, it is.
You'll need a template page for the category (for example, category-30.php, where 30 is the id of the category you want to show with multiple subcategories).
In the template, run through the standard loop for post from the original category if you want to, if not, the magic function will be wp\_reset\_que... |
11,203 | <p>Is it possible to only display the author's name and description (aka bio) <em>if</em> the description contains text? </p>
<p>This code doesn't work (it doesn't return the name or description) but hopefully it can be edited to accomplish this goal:</p>
<pre><code><?php
$authorDesc = the_author_meta($post->ID... | [
{
"answer_id": 11205,
"author": "Cronco",
"author_id": 1695,
"author_profile": "https://wordpress.stackexchange.com/users/1695",
"pm_score": 1,
"selected": false,
"text": "<p>First, you need to use <code>get_the_author_meta</code> instead of <code>the_autho_meta</code> to give a vakue to... | 2011/03/04 | [
"https://wordpress.stackexchange.com/questions/11203",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3711/"
] | Is it possible to only display the author's name and description (aka bio) *if* the description contains text?
This code doesn't work (it doesn't return the name or description) but hopefully it can be edited to accomplish this goal:
```
<?php
$authorDesc = the_author_meta($post->ID, 'description', true);
if (!empty... | ```
<?php
$authordesc = get_the_author_meta( 'description' );
if ( ! empty ( $authordesc ) )
{
?>
<a href="<?php
echo get_author_posts_url( get_the_author_meta( 'id' ) );
?>"><?php
the_author();
?></a>
<?php
echo wpautop( $authordesc );
}
``` |
11,222 | <p>I don't want any comment querys to run. I don't wont anything about comments to be shown in wordpress admin area.</p>
<p><strong>Is this possible in any way?</strong></p>
<p><strong>EDIT:</strong> Remove all links to the comments from admin bar, and all of the backend section.</p>
| [
{
"answer_id": 11225,
"author": "goldenapples",
"author_id": 290,
"author_profile": "https://wordpress.stackexchange.com/users/290",
"pm_score": 3,
"selected": false,
"text": "<p>This should remove support for comments on your site:</p>\n\n<pre><code>add_action('admin_menu', 'remove_comm... | 2011/03/05 | [
"https://wordpress.stackexchange.com/questions/11222",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3216/"
] | I don't want any comment querys to run. I don't wont anything about comments to be shown in wordpress admin area.
**Is this possible in any way?**
**EDIT:** Remove all links to the comments from admin bar, and all of the backend section. | Here is a list of all of the above answers and a removal of the admin bar link. Just add it to your themes function file or make it a plugin. I will mark this as a community wiki as everyone's answer is right just no one added it all together.
```
<?php
// Removes from admin menu
add_action( 'admin_menu', 'my_remove_... |
11,223 | <p>I've been reading through this <a href="https://wordpress.stackexchange.com/questions/5413/need-help-with-add-rewrite-rule">question and answer</a> with great interest as I'm trying to achieve something very similar, but I'm failing and was wondering if someone could help me out.</p>
<p>I am also using a custom plu... | [
{
"answer_id": 11230,
"author": "Joe Hoyle",
"author_id": 150,
"author_profile": "https://wordpress.stackexchange.com/users/150",
"pm_score": 1,
"selected": false,
"text": "<p>In regards to when you need to be flushing the rewrite rules:</p>\n\n<p>This should only happen once, make sure ... | 2011/03/05 | [
"https://wordpress.stackexchange.com/questions/11223",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3681/"
] | I've been reading through this [question and answer](https://wordpress.stackexchange.com/questions/5413/need-help-with-add-rewrite-rule) with great interest as I'm trying to achieve something very similar, but I'm failing and was wondering if someone could help me out.
I am also using a custom plug which is querying a... | In regards to when you need to be flushing the rewrite rules:
This should only happen once, make sure you are **not** calling `flush_rules()` on init, as this will really kill performance for high traffic sites.
WordPress stores all of the rewrites in an array in the database, so all you need to do is hook in just be... |
11,231 | <p><code>add_action()</code> and <code>add_filter()</code> are major functions. However in some scenarios <em>add one more function and hook it somewhere</em> approach gets bulky and inconvenient.</p>
<p>I had determined for myself several use cases that can streamline code with wrappers on top of <code>add_*</code> f... | [
{
"answer_id": 11239,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>For simple return values you don’t need a lot of extra functions. There is the handy <a href=\"http://codex.wordpress.... | 2011/03/05 | [
"https://wordpress.stackexchange.com/questions/11231",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/847/"
] | `add_action()` and `add_filter()` are major functions. However in some scenarios *add one more function and hook it somewhere* approach gets bulky and inconvenient.
I had determined for myself several use cases that can streamline code with wrappers on top of `add_*` functions. Things that are better handled with sing... | I had released my code as [Advanced Hooks API](https://github.com/Rarst/advanced-hooks-api) library.
Some examples:
```
add_action_with_arguments('test', 'printf', 10, 'boo%s', '<br />');
do_action('test');
// boo
add_filter_return('test2',10,'boo');
echo apply_filters('test2','not boo') . '<br />';
// boo
add_filt... |
11,235 | <p>I generated a new MetaBox for all standard posts in WordPress 3.1. There I generate a input:text field with the ID <code>_meta_fotos[pic]</code>, which should hould the image url generated by the standard media-uploader.
I want to use the standard media-uploader from the standard post window. So I generated the foll... | [
{
"answer_id": 11245,
"author": "t31os",
"author_id": 31073,
"author_profile": "https://wordpress.stackexchange.com/users/31073",
"pm_score": 1,
"selected": false,
"text": "<p>I did something similar for a theme settings page i helped someone with, it looked a little different to what yo... | 2011/03/05 | [
"https://wordpress.stackexchange.com/questions/11235",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3550/"
] | I generated a new MetaBox for all standard posts in WordPress 3.1. There I generate a input:text field with the ID `_meta_fotos[pic]`, which should hould the image url generated by the standard media-uploader.
I want to use the standard media-uploader from the standard post window. So I generated the following JavaScri... | I hate it to answer my own question.
But after hours of searching and trying I found a solution that works. I offer this solution, because it can't be interesting for others having the same problem. And for discussion, if there is a better way to get rid of the problem. Perhaps it is not very elegant, but it works ;-)
... |
11,241 | <p>I've asked a question about listing all sub-pages before:</p>
<p><a href="https://wordpress.stackexchange.com/questions/11091/listing-all-sub-pages">Listing all sub-pages?</a></p>
<p>But all the questions were wrong.</p>
<p>Anyways, I have now simpler question.</p>
<pre><code>global $post;
echo $post>ID
</cod... | [
{
"answer_id": 11245,
"author": "t31os",
"author_id": 31073,
"author_profile": "https://wordpress.stackexchange.com/users/31073",
"pm_score": 1,
"selected": false,
"text": "<p>I did something similar for a theme settings page i helped someone with, it looked a little different to what yo... | 2011/03/05 | [
"https://wordpress.stackexchange.com/questions/11241",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1869/"
] | I've asked a question about listing all sub-pages before:
[Listing all sub-pages?](https://wordpress.stackexchange.com/questions/11091/listing-all-sub-pages)
But all the questions were wrong.
Anyways, I have now simpler question.
```
global $post;
echo $post>ID
```
Works totally fine, but while on pages sidebars ... | I hate it to answer my own question.
But after hours of searching and trying I found a solution that works. I offer this solution, because it can't be interesting for others having the same problem. And for discussion, if there is a better way to get rid of the problem. Perhaps it is not very elegant, but it works ;-)
... |
11,244 | <p>How would we restrict access to the WP admin area to all users except admins?<br>
The users on our site have their own profile pages which do all the functions they need.</p>
<p>So admin should be off limits to all except admins.</p>
<p>How to do that?</p>
| [
{
"answer_id": 11251,
"author": "goofydg1",
"author_id": 3739,
"author_profile": "https://wordpress.stackexchange.com/users/3739",
"pm_score": 2,
"selected": false,
"text": "<p>Try the <a href=\"http://wordpress.org/extend/plugins/adminimize/\" rel=\"nofollow\">Adminimize</a> plugin.<br>... | 2011/03/05 | [
"https://wordpress.stackexchange.com/questions/11244",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2957/"
] | How would we restrict access to the WP admin area to all users except admins?
The users on our site have their own profile pages which do all the functions they need.
So admin should be off limits to all except admins.
How to do that? | We can hook to the [`admin_init`](http://codex.wordpress.org/Plugin_API/Action_Reference/admin_init#Example:_Access_control) action and check if the user is an administrator by using the `current_user_can()` function to see if the current user can `manage_options`, which is something only an administrator can do.
This... |
11,249 | <p>Struggling with this code, the conditions work, the only way I can get the wp_get_attachment_url is to loop through it but then this outputs as many images from the media library and I only want one?</p>
<pre><code> <div class="tvimage">
<?php
if ($imgurlbase != '' ) { ?>
<img src="<?p... | [
{
"answer_id": 11265,
"author": "erichmond",
"author_id": 31057,
"author_profile": "https://wordpress.stackexchange.com/users/31057",
"pm_score": -1,
"selected": false,
"text": "<p>Sorted this is the new code:</p>\n\n<pre><code><?php\n if ($imgurlbase != '' ) { ?>\n\n ... | 2011/03/05 | [
"https://wordpress.stackexchange.com/questions/11249",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31057/"
] | Struggling with this code, the conditions work, the only way I can get the wp\_get\_attachment\_url is to loop through it but then this outputs as many images from the media library and I only want one?
```
<div class="tvimage">
<?php
if ($imgurlbase != '' ) { ?>
<img src="<?php bloginfo('template_url'); ... | If you want to exit the loop after you find an attachment, use `break`.
```
// Define $programme and pull up $attachments as above
$attachment_url = '';
foreach ( $attachments as $attachment ) {
if ($attachment->post_title == $programme) {
$attachment_url = wp_get_attachment_url($attachment->ID);
... |
11,267 | <p>question is simple (i don't know is aswer too ;)<br>
I just want to check that, does a category has child (or is ancestor) from its cat-id with a function.<br>
Eg.<br>
<code>function check_category ($catid){<br>............<br>...//true if is ancestor, false if not<br>return $result;<br>}
</code>
<br>Note: I can onl... | [
{
"answer_id": 11284,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": true,
"text": "<p>You can do something like this:</p>\n\n<pre><code>function category_has_parent($catid){\n $category = get_c... | 2011/03/06 | [
"https://wordpress.stackexchange.com/questions/11267",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3405/"
] | question is simple (i don't know is aswer too ;)
I just want to check that, does a category has child (or is ancestor) from its cat-id with a function.
Eg.
`function check_category ($catid){
............
...//true if is ancestor, false if not
return $result;
}`
Note: I can only pass cat-id parameter f... | You can do something like this:
```
function category_has_parent($catid){
$category = get_category($catid);
if ($category->category_parent > 0){
return true;
}
return false;
}
```
and use it like this:
```
if (category_has_parent('22')){
//true there is a parent category
}else{
//false... |
11,271 | <p>OK, I'm using posts_query() to display posts.</p>
<p>The problem is, at least in my case, posts_query() always outputs something.</p>
<p>For example:</p>
<pre><code><?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts("posts_per_page=1&paged=$paged");
global $more;... | [
{
"answer_id": 12263,
"author": "SteveLambert",
"author_id": 2357,
"author_profile": "https://wordpress.stackexchange.com/users/2357",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure what problem you're trying to solve, but this may be worth looking at:</p>\n\n<p><a href=\"htt... | 2011/03/06 | [
"https://wordpress.stackexchange.com/questions/11271",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1869/"
] | OK, I'm using posts\_query() to display posts.
The problem is, at least in my case, posts\_query() always outputs something.
For example:
```
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts("posts_per_page=1&paged=$paged");
global $more;
$more = 0;
while ( have... | Unfortunately, there's really nothing out there that's going to solve all of your problems out of the box. Whatever calender solution you choose will require some amount of customization.
The one that I've found fills *most* needs is [The Events Calendar](http://wordpress.org/extend/plugins/the-events-calendar/). It's... |
11,288 | <p>Basically I want to display a form on my blog (on a certain page) that will allow anyone to fill it out and it will create a post in a custom post type.</p>
<p>I saw the answer once before but I can't find it now.</p>
| [
{
"answer_id": 11289,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 5,
"selected": true,
"text": "<p>posting from the front-end is a matter of displaying a form and processing it:</p>\n\n<p>form:</p>\n\n<pre><co... | 2011/03/06 | [
"https://wordpress.stackexchange.com/questions/11288",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2415/"
] | Basically I want to display a form on my blog (on a certain page) that will allow anyone to fill it out and it will create a post in a custom post type.
I saw the answer once before but I can't find it now. | posting from the front-end is a matter of displaying a form and processing it:
form:
```
<!-- New Post Form -->
<div id="postbox">
<form id="new_post" name="new_post" method="post" action="">
<!-- post name -->
<p><label for="title">Title</label><br />
<input type="text" id="title" value="" tabindex="1" size="20" na... |
11,292 | <p>I've scoured the Codex, failed to get get_page_by_title() to work and am quite surprised that there doesn't seem to be a standard WP function for this task.</p>
<p>I need to get the ID of any given post/ cpt or page using either the slug of the post/ page title. Ideally I'm looking for the following:</p>
<p><code>... | [
{
"answer_id": 11296,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 5,
"selected": true,
"text": "<p><strong>Update:</strong> As of WordPress 3.0 you can use the <em>built-in</em> function <a href=\"https://deve... | 2011/03/06 | [
"https://wordpress.stackexchange.com/questions/11292",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1341/"
] | I've scoured the Codex, failed to get get\_page\_by\_title() to work and am quite surprised that there doesn't seem to be a standard WP function for this task.
I need to get the ID of any given post/ cpt or page using either the slug of the post/ page title. Ideally I'm looking for the following:
`get_post_ID_by_titl... | **Update:** As of WordPress 3.0 you can use the *built-in* function [`get_page_by_title`](https://developer.wordpress.org/reference/functions/get_page_by_title/) with the third parameter `$post_type`:
```
$post = get_page_by_title( 'Post Title', OBJECT, 'post_type' );
$post_id = $post ? $post->ID : 0;
```
---
**Or... |
11,331 | <p>Well I made a plugin that uses <code>template_redirect</code> for the custom post type <code>squeezepages</code> and it works all fine and dandy, but I copied the exact same code, put it in a new plugin, activated it (with a few minor adjustments, for example I changed the custom post type to <code>newpages</code> a... | [
{
"answer_id": 11339,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>Not much code here... Let's break it down into things that can go wrong:</p>\n\n<ol>\n<li><p>Verify that <code>ifp_d... | 2011/03/07 | [
"https://wordpress.stackexchange.com/questions/11331",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2415/"
] | Well I made a plugin that uses `template_redirect` for the custom post type `squeezepages` and it works all fine and dandy, but I copied the exact same code, put it in a new plugin, activated it (with a few minor adjustments, for example I changed the custom post type to `newpages` and the `template_redirect` is taking... | I solved my own problem. I needed to put `flush_rewrite_rules( false );` after my `register_post_type` function. The reason it wasn't working is because it was returning the page with a 404 error, so I figured out it was a permalinks problem and the code above solved it for me. |
11,349 | <p>I am having trouble with multiple loops and sticky posts in wordpress.</p>
<p>The first loop I just want all the sticky posts.</p>
<pre><code><?php query_posts(array('post__in'=>get_option('sticky_posts'), 'cat' => '-15,-17, -5, -2')) ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(... | [
{
"answer_id": 11345,
"author": "anu",
"author_id": 490,
"author_profile": "https://wordpress.stackexchange.com/users/490",
"pm_score": 2,
"selected": false,
"text": "<p>You can create a child theme AND have it override any of the template php files in the parent theme.</p>\n\n<p>So, as ... | 2011/03/07 | [
"https://wordpress.stackexchange.com/questions/11349",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3766/"
] | I am having trouble with multiple loops and sticky posts in wordpress.
The first loop I just want all the sticky posts.
```
<?php query_posts(array('post__in'=>get_option('sticky_posts'), 'cat' => '-15,-17, -5, -2')) ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<?php $do_not_duplicate = ... | **Is it ok to not a have child theme and just create a theme from scratch?**
*Yes of course, you'll just have to cover alot of ground, most developers work from a code base, so even if you're not using a child theme, it does help save alot of time by building on top of a theme **[framework](https://wordpress.stackexch... |
11,354 | <p>I include this logic in my template all the time</p>
<pre><code>if ( have_posts() ):
//show content
else:
//show content not found
endif;
</code></pre>
<p>But recently I began to doubt its necessity, WordPress will turn to 404.php when no post found, it seems no need to add this logic in normal templates, <code>... | [
{
"answer_id": 11355,
"author": "scribu",
"author_id": 205,
"author_profile": "https://wordpress.stackexchange.com/users/205",
"pm_score": 2,
"selected": false,
"text": "<p>No, in most cases it's not needed.</p>\n\n<p><code>if ( have_posts() )</code> would only be useful on the index.php... | 2011/03/07 | [
"https://wordpress.stackexchange.com/questions/11354",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2426/"
] | I include this logic in my template all the time
```
if ( have_posts() ):
//show content
else:
//show content not found
endif;
```
But recently I began to doubt its necessity, WordPress will turn to 404.php when no post found, it seems no need to add this logic in normal templates, `else` will never be triggered, ... | When I look at [`WP::handle_404()`](http://core.trac.wordpress.org/browser/tags/3.1.2/wp-includes/class-wp.php#L457), I think that the `404.php` template will not be loaded, even if there are no posts, if:
* We are on the homepage
* It is a search
* It is a taxonomy term that exists, but has no posts attached to it (a... |