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
8,481
<p>I came across <a href="https://wordpress.stackexchange.com/questions/6884/add-common-post-actions-to-custom-meta-column">this question</a> while writing this question. I have one question that extends upon that question.</p> <p>I figured out that you use the <code>get_delete_post_link</code> filter to create a new ...
[ { "answer_id": 8494, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 4, "selected": true, "text": "<p>The main problem is that $actions accepts the whole anchor tag for the link and get_delete_post_link function ...
2011/02/03
[ "https://wordpress.stackexchange.com/questions/8481", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2322/" ]
I came across [this question](https://wordpress.stackexchange.com/questions/6884/add-common-post-actions-to-custom-meta-column) while writing this question. I have one question that extends upon that question. I figured out that you use the `get_delete_post_link` filter to create a new url for my actions (or a similar...
The main problem is that $actions accepts the whole anchor tag for the link and get\_delete\_post\_link function outputs just the url. So if You are just looking to replace the label "Trash" then you can use the post\_row\_actions filter hook with a simple function Something like this ``` add_filter( 'post_row_a...
8,482
<p>For some reason the below code works until I hit the third page and gives 404. Is it possible to fix it without using any plugins? </p> <pre><code>&lt;?php $temp = $wp_query; $wp_query = null; $wp_query = new WP_Query('cat='. $id .'&amp;posts_per_page=4&amp;paged='.$paged); while ($wp_query-&gt;have...
[ { "answer_id": 8494, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 4, "selected": true, "text": "<p>The main problem is that $actions accepts the whole anchor tag for the link and get_delete_post_link function ...
2011/02/03
[ "https://wordpress.stackexchange.com/questions/8482", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2313/" ]
For some reason the below code works until I hit the third page and gives 404. Is it possible to fix it without using any plugins? ``` <?php $temp = $wp_query; $wp_query = null; $wp_query = new WP_Query('cat='. $id .'&posts_per_page=4&paged='.$paged); while ($wp_query->have_posts()) : $wp_query->the_p...
The main problem is that $actions accepts the whole anchor tag for the link and get\_delete\_post\_link function outputs just the url. So if You are just looking to replace the label "Trash" then you can use the post\_row\_actions filter hook with a simple function Something like this ``` add_filter( 'post_row_a...
8,483
<p>I'm writing a plugin for work because our main website is being ported to WordPress eventually. I've got multiple custom post types planned for this plugin and would like to group them all into one main menu.</p> <p>Basically, <strong>I want the "Visitors" link to be placed under "Argus Admin".</strong> The other l...
[ { "answer_id": 8486, "author": "John P Bloch", "author_id": 11, "author_profile": "https://wordpress.stackexchange.com/users/11", "pm_score": 1, "selected": false, "text": "<p>If this is going to be ported to WordPress eventually (as in, not for another few weeks), I'd suggest waiting fo...
2011/02/03
[ "https://wordpress.stackexchange.com/questions/8483", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2322/" ]
I'm writing a plugin for work because our main website is being ported to WordPress eventually. I've got multiple custom post types planned for this plugin and would like to group them all into one main menu. Basically, **I want the "Visitors" link to be placed under "Argus Admin".** The other links aren't necessary t...
You got it right but you need to wait for WordPress 3.1 where its actually implemented. if you can't wait you can change 'show\_in\_menu' to false and use add\_submenu\_page() function define 'argus' as top page and add the Visitors "manually" under Argus Admin menu. so your code would be: ``` $v_args = array( ...
8,503
<p><em>(<strong>Moderator's note:</strong> Title was originally: "query/database optimisation")</em></p> <p>I'm written a function for a custom "filter" search panel that allows users to select terms from up to four custom taxonomies. I'm running the queries directly against the database and the query is averaging hal...
[ { "answer_id": 8519, "author": "scribu", "author_id": 205, "author_profile": "https://wordpress.stackexchange.com/users/205", "pm_score": 3, "selected": false, "text": "<p>Unless you need to stay backwards compatible with WP 3.0, you can just take advantage of the <a href=\"http://ottopr...
2011/02/04
[ "https://wordpress.stackexchange.com/questions/8503", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1890/" ]
*(**Moderator's note:** Title was originally: "query/database optimisation")* I'm written a function for a custom "filter" search panel that allows users to select terms from up to four custom taxonomies. I'm running the queries directly against the database and the query is averaging half a second to execute (with te...
While this is really a MySQL question it does help to understand the WordPress SQL schema and also I love trying to optimize SQL queries so rather than send you off to [StackOverflow](https://stackoverflow.com/) I'll try to answer you here. You may still want to post it over there to get some other opinions. And while...
8,517
<p>I'm adding a TinyMCE button to my plugin. So far, I've been able to add the button and call my editor_plugin.js file and it's command. Not an easy mission btw...</p> <p>I want this button to show a Dialog box, which gives the user several options. These are dropdown boxes which I need to fill and some text boxes fo...
[ { "answer_id": 10225, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>[edit: missed part of the question]</p>\n\n<p>Can't swear to this being a best practice, but the solution I've see...
2011/02/04
[ "https://wordpress.stackexchange.com/questions/8517", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/298/" ]
I'm adding a TinyMCE button to my plugin. So far, I've been able to add the button and call my editor\_plugin.js file and it's command. Not an easy mission btw... I want this button to show a Dialog box, which gives the user several options. These are dropdown boxes which I need to fill and some text boxes for the use...
Instead of requireing admin.php you just can use WP built-in ajax functionality, even if it's not ajax in this case. **Add a hook** ``` add_action('wp_ajax_my_plugin_function', 'my_plugin_function_callback'); ``` **Create your output function (callback)** ``` function my_plugin_function_callback() { // do stu...
8,540
<p>I have been looking for hours for an example on how to do this. I have 2 simple taxonomies, Type, Size. I need to create a custom form with the 2 taxonomies available as Select list/filter.</p> <p>Please help!</p> <p>tx in advance</p> <pre><code>&lt;form role="search" method="get" id="searchform" action="&lt;?php...
[ { "answer_id": 8548, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 2, "selected": true, "text": "<p>take a look at scribu <a href=\"http://wordpress.org/extend/plugins/query-multiple-taxonomies/\" rel=\"nofollow...
2011/02/04
[ "https://wordpress.stackexchange.com/questions/8540", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2597/" ]
I have been looking for hours for an example on how to do this. I have 2 simple taxonomies, Type, Size. I need to create a custom form with the 2 taxonomies available as Select list/filter. Please help! tx in advance ``` <form role="search" method="get" id="searchform" action="<?php bloginfo('home'); ?>"> ...
take a look at scribu [Query Multiple Taxonomies](http://wordpress.org/extend/plugins/query-multiple-taxonomies/) plugin it creates a drill-down navigation widget
8,544
<p>Specifically, I am making a custom rss feed. I have modeled it after the rss2 feed that is in the wp-includes folder. I can successfully retrieve all posts using the standard query_posts('posts_per_page=-1').</p> <p>Here is how I am attempting to get just the ones posted in the past year:</p> <pre><code>$today =...
[ { "answer_id": 8548, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 2, "selected": true, "text": "<p>take a look at scribu <a href=\"http://wordpress.org/extend/plugins/query-multiple-taxonomies/\" rel=\"nofollow...
2011/02/04
[ "https://wordpress.stackexchange.com/questions/8544", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2946/" ]
Specifically, I am making a custom rss feed. I have modeled it after the rss2 feed that is in the wp-includes folder. I can successfully retrieve all posts using the standard query\_posts('posts\_per\_page=-1'). Here is how I am attempting to get just the ones posted in the past year: ``` $today = date('Y-m-d'); $new...
take a look at scribu [Query Multiple Taxonomies](http://wordpress.org/extend/plugins/query-multiple-taxonomies/) plugin it creates a drill-down navigation widget
8,569
<p>The WordPress function is used for submitting data programatically. Standard fields to submit to incude the content, excerpt, title, date and many more.</p> <p>What there is no documentation for is how to submit to a custom field. I know it is possible with the <code>add_post_meta($post_id, $meta_key, $meta_value, ...
[ { "answer_id": 8572, "author": "Micah Ernst", "author_id": 322, "author_profile": "https://wordpress.stackexchange.com/users/322", "pm_score": 1, "selected": false, "text": "<p>Use <code>save_post</code> filter, then call <code>add_post_meta</code> in your filter function.</p>\n" }, ...
2011/02/04
[ "https://wordpress.stackexchange.com/questions/8569", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2957/" ]
The WordPress function is used for submitting data programatically. Standard fields to submit to incude the content, excerpt, title, date and many more. What there is no documentation for is how to submit to a custom field. I know it is possible with the `add_post_meta($post_id, $meta_key, $meta_value, $unique);` func...
If you read the documentation for [`wp_insert_post`](http://codex.wordpress.org/Function_Reference/wp_insert_post), it returns the post ID of the post you just created. If you combine that with the following function `__update_post_meta` (a custom function I acquired from this site and adapted a bit) ``` /** * Upd...
8,576
<p>I've recently tried to add a user registration form to the front end of my site and have used the following form code (based upon <a href="http://digwp.com/2010/12/login-register-password-code" rel="nofollow noreferrer">this</a> I discovered in an answer by <a href="https://wordpress.stackexchange.com/users/2110/mau...
[ { "answer_id": 8579, "author": "aendra", "author_id": 1682, "author_profile": "https://wordpress.stackexchange.com/users/1682", "pm_score": 1, "selected": false, "text": "<p>Hook into registration_errors (The WP Codex is woefully incomplete on this, but see links below). </p>\n\n<p>Sorry...
2011/02/04
[ "https://wordpress.stackexchange.com/questions/8576", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2923/" ]
I've recently tried to add a user registration form to the front end of my site and have used the following form code (based upon [this](http://digwp.com/2010/12/login-register-password-code) I discovered in an answer by [maugly](https://wordpress.stackexchange.com/users/2110/maugly "maugly") in question [Front-end Reg...
Hook into registration\_errors (The WP Codex is woefully incomplete on this, but see links below). Sorry this isn't more helpful -- the issue is a little more complex than it seems at the outset. I'll look into it more later. Links: * <http://adambrown.info/p/wp_hooks/hook/registration_errors> * <http://core.trac.w...
8,577
<p>I know that this topic is already on the Forum but the solution simply don't work for me.</p> <p>I have a few pages where I would like to split content using read more.</p> <p>So I have done recommended hack by adding global</p> <pre><code>$more; and $more = 0; the_content(); </code></pre> <p>and everything seem...
[ { "answer_id": 8581, "author": "Lynne", "author_id": 2479, "author_profile": "https://wordpress.stackexchange.com/users/2479", "pm_score": 0, "selected": false, "text": "<p>The only reason to use a $more variable is if you feel the need to edit the 'read more' text that displays automati...
2011/02/04
[ "https://wordpress.stackexchange.com/questions/8577", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2960/" ]
I know that this topic is already on the Forum but the solution simply don't work for me. I have a few pages where I would like to split content using read more. So I have done recommended hack by adding global ``` $more; and $more = 0; the_content(); ``` and everything seem to look ok although every time I click ...
Better to use `<!--nextpage-->` if you want to split content. See theme requirement: <http://codex.wordpress.org/Template_Tags/wp_link_pages> I don't understand why people keep wanting "Read more" to work in Pages.
8,612
<p>While moving a client's WP site to a new host (single site, not multi), I found that Dashboard>>Users lists two admin accounts (above the detailed shows All(2) Administrator (2) ) but only shows one in the detailed list below; and only one admin account shows in the wp_users table with the ID of 1. Where is this ext...
[ { "answer_id": 8616, "author": "hakre", "author_id": 178, "author_profile": "https://wordpress.stackexchange.com/users/178", "pm_score": 0, "selected": false, "text": "<p>This is probably a bug. Something similar had been reported in <a href=\"http://core.trac.wordpress.org/ticket/16367\...
2011/02/05
[ "https://wordpress.stackexchange.com/questions/8612", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/268/" ]
While moving a client's WP site to a new host (single site, not multi), I found that Dashboard>>Users lists two admin accounts (above the detailed shows All(2) Administrator (2) ) but only shows one in the detailed list below; and only one admin account shows in the wp\_users table with the ID of 1. Where is this extra...
That's typically the result of users deleting accounts directly in the database. The functions that count users queries to the usermeta table to determine how many users are of a given type, when users do manual deletion they often forget to remove relational data left in the meta table, which in turn throws off the co...
8,636
<p>An item in SideBarOther shows up on the main article listing page, but when I select an article (same page layout, the article replaces the listing), the item isn't there. There are two items in SideBarOther, and only the 2nd one has this problem (see code below). If I remove the first one, it is correctly gone from...
[ { "answer_id": 8625, "author": "Zack", "author_id": 2322, "author_profile": "https://wordpress.stackexchange.com/users/2322", "pm_score": 0, "selected": false, "text": "<p>You might want to check out the following article. I think it's what you want.</p>\n\n<ul>\n<li><a href=\"http://jus...
2011/02/05
[ "https://wordpress.stackexchange.com/questions/8636", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
An item in SideBarOther shows up on the main article listing page, but when I select an article (same page layout, the article replaces the listing), the item isn't there. There are two items in SideBarOther, and only the 2nd one has this problem (see code below). If I remove the first one, it is correctly gone from fr...
Wordpress has no multi-level user and group ownerships / permissions by default. So what you are asking for you need to implement on your own by extending the database and the program. You can then fine-grained control what users are allowed to do and what not. Like Zack suggested, this can be combined with custom use...
8,650
<p>I'd like to find a way to fill some of the fields from the <code>/wp-admin/post-new.php</code> page from an external source.</p> <p>It works for the title: loading <code>/wp-admin/post-new.php?post_title=title1</code> fills the title input with <code>title1</code>. </p> <p>You get the idea, what would be great is ...
[ { "answer_id": 8653, "author": "MikeSchinkel", "author_id": 89, "author_profile": "https://wordpress.stackexchange.com/users/89", "pm_score": 2, "selected": false, "text": "<p>If this is to add end-users then maybe the easiest thing to do is to create a jQuery script to assign the values...
2011/02/05
[ "https://wordpress.stackexchange.com/questions/8650", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I'd like to find a way to fill some of the fields from the `/wp-admin/post-new.php` page from an external source. It works for the title: loading `/wp-admin/post-new.php?post_title=title1` fills the title input with `title1`. You get the idea, what would be great is something like `/wp-admin/post-new.php?post_title=...
An empty post is created by [`get_default_post_to_edit()`](http://core.trac.wordpress.org/browser/tags/3.0.5/wp-admin/includes/post.php#L351). This function reads the `post_title`, `content` and `excerpt` values in the `$_REQUEST` array, and also filters them through `default_title`, `default_content` and `default_exce...
8,655
<p>I've got a working piece of javascript that contains an object literal. But I need to localize it, and I'm ytrying to figure out how to rewrite it so that I can get wp_localize_script() to accet it, and output the correct format.</p> <p>The non-localized (non dynamic) version looks like this:</p> <pre><code>var la...
[ { "answer_id": 8666, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>Disclaimer - I am out of my depth on JS security stuff here.</p>\n\n<p>First, to match your desired output you are of...
2011/02/06
[ "https://wordpress.stackexchange.com/questions/8655", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2071/" ]
I've got a working piece of javascript that contains an object literal. But I need to localize it, and I'm ytrying to figure out how to rewrite it so that I can get wp\_localize\_script() to accet it, and output the correct format. The non-localized (non dynamic) version looks like this: ``` var layoyt_config = { ...
Indeed, [`wp_localize_script()` is simple](http://core.trac.wordpress.org/browser/tags/3.0.5/wp-includes/class.wp-scripts.php#L50), it just adds quotes around the values and escapes the content, expecting all of them to be strings. However, there is the `l10n_print_after` key of the array, which will be printed withou...
8,665
<p>I've changed our "category base" in WP settings from the default "category" to "customname".</p> <p>Now there are 404 errors to links containing the old category slug eg. mysite.com/category/names</p> <p>What do I enter in .htaccss to 301 redirect </p> <p>mysite.com/<strong>category</strong>/xxx</p> <p>to</p> <...
[ { "answer_id": 8670, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 4, "selected": false, "text": "<p>Htaccess is your friend in this case.\nYou can create 301 form your old category base to the new like so:</p>\...
2011/02/06
[ "https://wordpress.stackexchange.com/questions/8665", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2980/" ]
I've changed our "category base" in WP settings from the default "category" to "customname". Now there are 404 errors to links containing the old category slug eg. mysite.com/category/names What do I enter in .htaccss to 301 redirect mysite.com/**category**/xxx to mysite.com/**customname**/xxx Thanks,
Htaccess is your friend in this case. You can create 301 form your old category base to the new like so: ``` RewriteEngine on RewriteBase / RewriteRule ^old_dir/(.*) http://www.example.com/new_dir/$1 [R=301,L] ``` Change old\_dir to category example.com to your domain and new\_dir to your custom name. Hope this hel...
8,669
<p>I changed the wordpress category slug from "sci-fi" to "scifi" a few months back by accident. </p> <p>How can I redirect</p> <p><code>/category/sci-fi/</code> to <code>/category/scifi/</code></p> <p>so that <code>/category/sci-fi/page/2/</code>, <code>/category/sci-fi/page/3/</code> etc stops resulting in 404 err...
[ { "answer_id": 8670, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 4, "selected": false, "text": "<p>Htaccess is your friend in this case.\nYou can create 301 form your old category base to the new like so:</p>\...
2011/02/06
[ "https://wordpress.stackexchange.com/questions/8669", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2980/" ]
I changed the wordpress category slug from "sci-fi" to "scifi" a few months back by accident. How can I redirect `/category/sci-fi/` to `/category/scifi/` so that `/category/sci-fi/page/2/`, `/category/sci-fi/page/3/` etc stops resulting in 404 errors? Thanks
Htaccess is your friend in this case. You can create 301 form your old category base to the new like so: ``` RewriteEngine on RewriteBase / RewriteRule ^old_dir/(.*) http://www.example.com/new_dir/$1 [R=301,L] ``` Change old\_dir to category example.com to your domain and new\_dir to your custom name. Hope this hel...
8,675
<p>I've seen some examples that use $_post instead of $post. What's the difference and when would you use $_post instead of $post?</p> <p>Example:</p> <pre><code>if (have_posts()) : while (have_posts()) : the_post(); if(!in_category("some-category", $_post )) { do_something(); } </code></pre>
[ { "answer_id": 8677, "author": "Pabline", "author_id": 2908, "author_profile": "https://wordpress.stackexchange.com/users/2908", "pm_score": 4, "selected": true, "text": "<p>I'm not certain, but if you're talking about $_post as seen here:</p>\n\n<p><a href=\"http://codex.wordpress.org/F...
2011/02/06
[ "https://wordpress.stackexchange.com/questions/8675", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/366/" ]
I've seen some examples that use $\_post instead of $post. What's the difference and when would you use $\_post instead of $post? Example: ``` if (have_posts()) : while (have_posts()) : the_post(); if(!in_category("some-category", $_post )) { do_something(); } ```
I'm not certain, but if you're talking about $\_post as seen here: <http://codex.wordpress.org/Function_Reference/in_category> It's referring to a post ID so they've probably added the underscore to avoid confusion. The $post variable is a post object with all the details of the post. However, $\_POST is a global PH...
8,698
<p>Easy question. Where does the self-hosted WordPress store version information?</p>
[ { "answer_id": 8699, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": false, "text": "<p>The codex says its in wp-includes/version.php.</p>\n" }, { "answer_id": 8700, "author": "hakre", ...
2011/02/06
[ "https://wordpress.stackexchange.com/questions/8698", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2989/" ]
Easy question. Where does the self-hosted WordPress store version information?
If you need to get the wordpress version in your script, there is a global variable: `$wp_version` (right now it's something like `'3.1-RC3-17376'`) It contains the wordpress version. If you need to acquire if from a file, you can read it from `/wp-includes/version.php`: ``` function getWPVersion() { $path = '...
8,709
<p>I created one custom post type and two custom taxonomies.</p> <pre><code>register_post_type('blocks',array( 'labels' =&gt; array( 'name' =&gt; __( 'Blocks' ), 'singular_name' =&gt; __( 'Block' ), 'add_new_item' =&gt; 'Add New Block', 'edit_item' =&gt; 'Edit Block', ...
[ { "answer_id": 8727, "author": "janoChen", "author_id": 781, "author_profile": "https://wordpress.stackexchange.com/users/781", "pm_score": 2, "selected": false, "text": "<p>Well, downloading Wordpress 3.1 RC3 solved the problem.</p>\n" }, { "answer_id": 8730, "author": "Simo...
2011/02/07
[ "https://wordpress.stackexchange.com/questions/8709", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/781/" ]
I created one custom post type and two custom taxonomies. ``` register_post_type('blocks',array( 'labels' => array( 'name' => __( 'Blocks' ), 'singular_name' => __( 'Block' ), 'add_new_item' => 'Add New Block', 'edit_item' => 'Edit Block', 'new_item' => 'New Block', ...
Well, downloading Wordpress 3.1 RC3 solved the problem.
8,713
<p>So I have this code that queries a custom plugin generated table in the wp database. It works perfectly as is. But I'm trying to adjust it to use $wpdb instead of the $con function I have set up.</p> <p>Here is the code that works perfectly, but not using $wpdb:</p> <pre><code>&lt;?php $q = strtolower($_GET["q"]);...
[ { "answer_id": 8715, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>Try this:</p>\n\n<pre><code>$sql = $wpdb-&gt;prepare( \"SELECT en_word, ar_word FROM {$wpdb-&gt;prefix}enar_words WHE...
2011/02/07
[ "https://wordpress.stackexchange.com/questions/8713", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2995/" ]
So I have this code that queries a custom plugin generated table in the wp database. It works perfectly as is. But I'm trying to adjust it to use $wpdb instead of the $con function I have set up. Here is the code that works perfectly, but not using $wpdb: ``` <?php $q = strtolower($_GET["q"]); if (!$q) return; $isAra...
Your error message means that $wpdb in your code is currently pointing to a null pointer. Either WP is not loaded, or you're missing a simple `global $wpdb;` statement, or both. If you need to load WP, include wp-load.php. Or better, in your JS, use ajaxurl: ``` url = ajaxurl + '?action=youraction' ``` alongside (...
8,716
<p>I have a plugin that creates a custom post type called Squeeze Pages. It has various short codes users can enter to make a squeeze page but I'm not sure how I can go about making the squeeze pages have a custom design, completely different from the homepage.</p> <p>Is this possible? If so, how can it be done?</p>
[ { "answer_id": 8715, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>Try this:</p>\n\n<pre><code>$sql = $wpdb-&gt;prepare( \"SELECT en_word, ar_word FROM {$wpdb-&gt;prefix}enar_words WHE...
2011/02/07
[ "https://wordpress.stackexchange.com/questions/8716", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2415/" ]
I have a plugin that creates a custom post type called Squeeze Pages. It has various short codes users can enter to make a squeeze page but I'm not sure how I can go about making the squeeze pages have a custom design, completely different from the homepage. Is this possible? If so, how can it be done?
Your error message means that $wpdb in your code is currently pointing to a null pointer. Either WP is not loaded, or you're missing a simple `global $wpdb;` statement, or both. If you need to load WP, include wp-load.php. Or better, in your JS, use ajaxurl: ``` url = ajaxurl + '?action=youraction' ``` alongside (...
8,736
<p>I'd like to add custom fields to a certain category. A category only has the following fields:</p> <p>Name:</p> <p>Slug:</p> <p>Parent:</p> <p>Description:</p> <p>Since I have a TV Series Site, I want to add some more fields, I want something like this, when I create a new category (Category=Series)</p> <p>Nam...
[ { "answer_id": 8738, "author": "t31os", "author_id": 31073, "author_profile": "https://wordpress.stackexchange.com/users/31073", "pm_score": 1, "selected": false, "text": "<p>Paul Menard provided an example of how to create and use term meta in his blog...<br>\n<a href=\"http://www.codeh...
2011/02/07
[ "https://wordpress.stackexchange.com/questions/8736", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I'd like to add custom fields to a certain category. A category only has the following fields: Name: Slug: Parent: Description: Since I have a TV Series Site, I want to add some more fields, I want something like this, when I create a new category (Category=Series) Name: Artist: Year: Type: Genre: Summary: ...
I posted an How To about it a week ago <http://en.bainternet.info/2011/wordpress-category-extra-fields> hope this helps. Ohad. --- Here are the details of the post: --------------------------------- The first thing we need to do is add the extra fields to the category edit form using the hook edit\_category\_form\...
8,743
<p>I want to change the default "Excerpts are optional hand-crafted summaries of your content that can be used in your theme. Learn more about manual excerpts." help text below the Excerpt input area to something more meaningful for my Custom Post Type.</p> <p>I've done something similar with Post Title, using a "tran...
[ { "answer_id": 8751, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 4, "selected": true, "text": "<p>This description is generated by <code>post_excerpt_meta_box()</code> function and is not passed through any explicit ...
2011/02/07
[ "https://wordpress.stackexchange.com/questions/8743", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1118/" ]
I want to change the default "Excerpts are optional hand-crafted summaries of your content that can be used in your theme. Learn more about manual excerpts." help text below the Excerpt input area to something more meaningful for my Custom Post Type. I've done something similar with Post Title, using a "translation" f...
This description is generated by `post_excerpt_meta_box()` function and is not passed through any explicit filters. It is however echoed by translation-related [`_e()`](http://codex.wordpress.org/Function_Reference/_e) function and so passes through `gettext` filter (which from your question you are already familiar wi...
8,754
<p>I have two categories on a site - news which contains news posts and blog - which contains blog posts. Each page has a wp_get_archives in the sidebar. I'd like to limit the archive listing by category but after looking at the codex this does not seem possible. <a href="http://codex.wordpress.org/Function_Reference/...
[ { "answer_id": 8757, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>I use this code on my site to pull from a specific category (this is in the sidebar - shows just my 'blog' posts an...
2011/02/07
[ "https://wordpress.stackexchange.com/questions/8754", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2862/" ]
I have two categories on a site - news which contains news posts and blog - which contains blog posts. Each page has a wp\_get\_archives in the sidebar. I'd like to limit the archive listing by category but after looking at the codex this does not seem possible. <http://codex.wordpress.org/Function_Reference/wp_get_arc...
Basically this is possible, but somewhat messy. This function relies on direct SQL query to database, which you can change via `getarchives_where` and `getarchives_join` filters.
8,764
<p>I have a page that I access at /category/tasks and the file is located at wp-content/themes/my-theme/tasks.php. I would like to make it so I can add a flag after tasks and pick up the query strong in tasks.php. This works fine when I access the page with /category/tasks/?when=upcoming.</p> <p>Can someone tell me ho...
[ { "answer_id": 8766, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": true, "text": "<p>Try this:</p>\n\n<pre><code>function when_rewrite_rules( $wp_rewrite ) {\n $new_rules = array();\n $new_rules...
2011/02/07
[ "https://wordpress.stackexchange.com/questions/8764", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1462/" ]
I have a page that I access at /category/tasks and the file is located at wp-content/themes/my-theme/tasks.php. I would like to make it so I can add a flag after tasks and pick up the query strong in tasks.php. This works fine when I access the page with /category/tasks/?when=upcoming. Can someone tell me how to use r...
Try this: ``` function when_rewrite_rules( $wp_rewrite ) { $new_rules = array(); $new_rules['category/tasks/(\d*)$'] = 'index.php?when=$matches[1]'; $wp_rewrite->rules = $new_rules + $wp_rewrite->rules; } add_filter('generate_rewrite_rules','when_rewrite_rules'); ```
8,769
<p>If my category URL is:</p> <p>/blogs/category/foo</p> <p>and my archive URL is:</p> <p>/blogs/2011/02/</p> <p>what's the URL for 'foo' blogs from February 2011?</p>
[ { "answer_id": 8770, "author": "Jan Fabry", "author_id": 8, "author_profile": "https://wordpress.stackexchange.com/users/8", "pm_score": 2, "selected": false, "text": "<p>There is no date-based archive for a category. The <code>/category/[slug]/</code> pages are already \"archives\", in ...
2011/02/07
[ "https://wordpress.stackexchange.com/questions/8769", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119/" ]
If my category URL is: /blogs/category/foo and my archive URL is: /blogs/2011/02/ what's the URL for 'foo' blogs from February 2011?
There is no date-based archive for a category. The `/category/[slug]/` pages are already "archives", in that they display old posts over different pages. The different pages can be accessed by adding `page/2/`, `page/3/`, ... to the URL. The template tags to add these links are [`next_posts_link()`](http://codex.wordp...
8,776
<p>I have a (client) site located at <a href="http://internationalgateway.us/" rel="nofollow">http://internationalgateway.us/</a>. We are using the <a href="http://wordpress.org/extend/plugins/sitepress-multilingual-cms/" rel="nofollow">WPML Multilingual CMS</a> plugin. When choosing another language from the homepage ...
[ { "answer_id": 8770, "author": "Jan Fabry", "author_id": 8, "author_profile": "https://wordpress.stackexchange.com/users/8", "pm_score": 2, "selected": false, "text": "<p>There is no date-based archive for a category. The <code>/category/[slug]/</code> pages are already \"archives\", in ...
2011/02/07
[ "https://wordpress.stackexchange.com/questions/8776", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49/" ]
I have a (client) site located at <http://internationalgateway.us/>. We are using the [WPML Multilingual CMS](http://wordpress.org/extend/plugins/sitepress-multilingual-cms/) plugin. When choosing another language from the homepage (in this case French, since that's the only one enabled), I encounter a redirect loop. T...
There is no date-based archive for a category. The `/category/[slug]/` pages are already "archives", in that they display old posts over different pages. The different pages can be accessed by adding `page/2/`, `page/3/`, ... to the URL. The template tags to add these links are [`next_posts_link()`](http://codex.wordp...
8,778
<p>Am I smoking crack or why wouldn't this work? :/ This all seems pretty straightforward:</p> <pre><code>function admin_head() { ?&gt; &lt;link type="text/css" rel="stylesheet" href="&lt;?php bloginfo('template_url'); ?&gt;/css/jquery-ui-1.8.9.custom.css" /&gt; &lt;script type="text/javascript" src="&lt;?php blogin...
[ { "answer_id": 8781, "author": "Noel Tock", "author_id": 2393, "author_profile": "https://wordpress.stackexchange.com/users/2393", "pm_score": 1, "selected": true, "text": "<p>Duh, if you're <strong>image path is bust</strong> and it's the only way it activates, it just won't load.</p>\n...
2011/02/07
[ "https://wordpress.stackexchange.com/questions/8778", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2393/" ]
Am I smoking crack or why wouldn't this work? :/ This all seems pretty straightforward: ``` function admin_head() { ?> <link type="text/css" rel="stylesheet" href="<?php bloginfo('template_url'); ?>/css/jquery-ui-1.8.9.custom.css" /> <script type="text/javascript" src="<?php bloginfo('template_url'); ?>/js/jquery-ui...
Duh, if you're **image path is bust** and it's the only way it activates, it just won't load.
8,787
<p>So I'm trying to do an if / else statement on an archive.php template. I setting up my archives using WP Smart archives reloaded (http://wordpress.org/extend/plugins/smart-archives-reloaded/) </p> <p>The code from my archive.php is as follows:</p> <pre><code>&lt;?php if (in_category('166')) { include 'archive-b...
[ { "answer_id": 8791, "author": "Denis de Bernardy", "author_id": 1208, "author_profile": "https://wordpress.stackexchange.com/users/1208", "pm_score": 2, "selected": false, "text": "<p>If memory serves, in_category() is for use within the loop and returns true when the current post is in...
2011/02/07
[ "https://wordpress.stackexchange.com/questions/8787", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2862/" ]
So I'm trying to do an if / else statement on an archive.php template. I setting up my archives using WP Smart archives reloaded (http://wordpress.org/extend/plugins/smart-archives-reloaded/) The code from my archive.php is as follows: ``` <?php if (in_category('166')) { include 'archive-blog.php'; } else { e...
If memory serves, in\_category() is for use within the loop and returns true when the current post is in that particular category. You're probably for is\_category(166).
8,796
<p>Is is possible to override the set # of blog posts to show per page (as defined under Reading Settings in the WordPress admin)? I want to make it so a custom loop that I am using will show an unlimited number.</p>
[ { "answer_id": 8800, "author": "eileencodes", "author_id": 1352, "author_profile": "https://wordpress.stackexchange.com/users/1352", "pm_score": 0, "selected": false, "text": "<p>Sure, change the query by adding </p>\n\n<p><code>&lt;?php query_posts('post_type=post&amp;numberposts=-1'); ...
2011/02/07
[ "https://wordpress.stackexchange.com/questions/8796", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1462/" ]
Is is possible to override the set # of blog posts to show per page (as defined under Reading Settings in the WordPress admin)? I want to make it so a custom loop that I am using will show an unlimited number.
The argument that controls how many posts are shown in the query is posts\_per\_page ``` <?php query_posts( array( 'post_type' => 'post', 'posts_per_page' => -1 ) ); ?> ``` Also to note is that there is a bug in the 3.0 branch which prevents the -1 integer f...
8,809
<p>I'm trying to add a custom feed format to my site (basically exporting data to an Excel file) and I'm getting confused by the feed caching settings. I can't figure out how to flush the cached feeds, or to turn off feed caching altogether while I'm in development.</p> <p>I've tried deleting all the <code>_transient_...
[ { "answer_id": 8822, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 2, "selected": false, "text": "<p>try </p>\n\n<pre><code> function do_not_cache_feeds(&amp;$feed) {\n $feed-&gt;enable_cache(false);\n }\n\n a...
2011/02/07
[ "https://wordpress.stackexchange.com/questions/8809", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/290/" ]
I'm trying to add a custom feed format to my site (basically exporting data to an Excel file) and I'm getting confused by the feed caching settings. I can't figure out how to flush the cached feeds, or to turn off feed caching altogether while I'm in development. I've tried deleting all the `_transient_feed...`, `_tra...
It definitely might be a caching issue. I find [REDbot](http://redbot.org/) is excellent for quick check of how result is served and what are its caching settings.
8,817
<p>I am trying to remove the "Click here to cancel reply" link from the Wordpress comment form on my posts. In the document there is an argument you can supply to the comment form function to remove the link, but it doesn't appear to be working. The documentation link: <a href="http://codex.wordpress.org/Function_Refer...
[ { "answer_id": 8840, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>When you pass <code>false</code> to that argument <code>get_cancel_comment_reply_link()</code> function that is used ...
2011/02/08
[ "https://wordpress.stackexchange.com/questions/8817", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1687/" ]
I am trying to remove the "Click here to cancel reply" link from the Wordpress comment form on my posts. In the document there is an argument you can supply to the comment form function to remove the link, but it doesn't appear to be working. The documentation link: <http://codex.wordpress.org/Function_Reference/commen...
``` add_filter( 'cancel_comment_reply_link', '__return_false' ); ``` See `/wp-includes/comment-template.php#function get_cancel_comment_reply_link()` for more background. But if you do that the reply form will not move to the comment. The more interesting question is: Why doesn’t the link work for you? Do you have t...
8,825
<p>I'd like to use a LIKE %text% statement while still using the WordPress $wpdb class to sanitize and prepare input.</p> <pre><code>SELECT column_1 from `prefix_my_table` WHERE column_2 LIKE '%something%'; </code></pre> <p>I've tried something like this to no avail:</p> <pre><code>$wpdb-&gt;prepare( "SELECT column_...
[ { "answer_id": 8834, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": false, "text": "<p>You need to double percent so they are no treated like fragment markers by <code>wpdb-&gt;prepare()</code>:</p>\n\n<p...
2011/02/08
[ "https://wordpress.stackexchange.com/questions/8825", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1860/" ]
I'd like to use a LIKE %text% statement while still using the WordPress $wpdb class to sanitize and prepare input. ``` SELECT column_1 from `prefix_my_table` WHERE column_2 LIKE '%something%'; ``` I've tried something like this to no avail: ``` $wpdb->prepare( "SELECT column_1 from `{$wpdb->base_prefix}my_table` WH...
The `$wpdb->esc_like` function exists in WordPress because the regular database escaping does not escape `%` and `_` characters. This means you can add them in your arguments to `wpdb::prepare()` without problem. This is also [what I see in the core WordPress code](http://core.trac.wordpress.org/browser/tags/3.0.5/wp-a...
8,862
<p><em>(<strong>Moderator's note:</strong> Original title was "Getting error: You do not have sufficient permissions to access this page. Trying to build custom plugin")</em></p> <p>I'm trying to write my own custom WordPress plugin, but as soon as I click on the menu I get the following error:</p> <blockquote> <p>...
[ { "answer_id": 8863, "author": "MikeSchinkel", "author_id": 89, "author_profile": "https://wordpress.stackexchange.com/users/89", "pm_score": 3, "selected": true, "text": "<p>I think the issue may be in your call to <code>add_submenu_page()</code>:</p>\n<pre><code>add_submenu_page('wpsc-...
2011/02/08
[ "https://wordpress.stackexchange.com/questions/8862", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2719/" ]
*(**Moderator's note:** Original title was "Getting error: You do not have sufficient permissions to access this page. Trying to build custom plugin")* I'm trying to write my own custom WordPress plugin, but as soon as I click on the menu I get the following error: > > *You do not have sufficient permissions to acce...
I think the issue may be in your call to `add_submenu_page()`: ``` add_submenu_page('wpsc-sales-logs',... ``` The first parameter needs to be a reference to your Menu Page's "slug", i.e. if you use `'edit.php'` instead you'll see that you get a menu option under the *"Posts"* menu page: ``` add_submenu_page('edit.p...
8,876
<p>Bear with me here..</p> <p>The default posts per page in the admin area is 10. During some testing I wanted to change the posts per page for my custom post archive to 2 (in WP 3.1).</p> <p>The problem is that I only have 4 posts, so there should be 2 pages with 2 posts on each, but because the default is at 10, go...
[ { "answer_id": 8909, "author": "Andrew Lawson", "author_id": 3014, "author_profile": "https://wordpress.stackexchange.com/users/3014", "pm_score": 2, "selected": true, "text": "<p>There's a discussion on Wordpress.org support forums about this exact issue. The OP on that discussion has c...
2011/02/08
[ "https://wordpress.stackexchange.com/questions/8876", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3014/" ]
Bear with me here.. The default posts per page in the admin area is 10. During some testing I wanted to change the posts per page for my custom post archive to 2 (in WP 3.1). The problem is that I only have 4 posts, so there should be 2 pages with 2 posts on each, but because the default is at 10, going to /page/2 re...
There's a discussion on Wordpress.org support forums about this exact issue. The OP on that discussion has come up with an answer but is yet to post it. <http://wordpress.org/support/topic/error-404-on-pagination-when-changing-posts_per_page-on-query_posts> Thanks for your help anyway.
8,883
<p>I've been trying to add a field to Quick Edit. Somehow it works: it is displayed and if you enter a value in the input field, the value is saved into a custom field. However, can't seem to find a way to retrieve the value of the custom field. Here's what I got so far:</p> <pre><code>add_action('quick_edit_custom_bo...
[ { "answer_id": 8899, "author": "Zack", "author_id": 2322, "author_profile": "https://wordpress.stackexchange.com/users/2322", "pm_score": 0, "selected": false, "text": "<p>This is <strong>untested</strong> code. See if it works for you. Basically, as you'll read below, I globalize <code>...
2011/02/08
[ "https://wordpress.stackexchange.com/questions/8883", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3013/" ]
I've been trying to add a field to Quick Edit. Somehow it works: it is displayed and if you enter a value in the input field, the value is saved into a custom field. However, can't seem to find a way to retrieve the value of the custom field. Here's what I got so far: ``` add_action('quick_edit_custom_box', 'ilc_quick...
Ok, I got it, here's the code: ``` function ilc_quickedit_save($post_id, $post) { if( $post->post_type != 'evento' ) return; if (isset($_POST['is_quickedit'])) update_post_meta($post_id, 'eventdate', $_POST['eventdate']); } function ilc_quickedit_get() { $html = '<script type="text/javascript">';...
8,889
<p>Have been trying to figure out the issue with this for the past hour, but hitting a wall. Basically I'm just trying to query my custom post type based on some custom date fields and then displaying each. Anyone have an idea where I'm going wrong?</p> <pre><code>&lt;?php // - query - global $wpd...
[ { "answer_id": 8891, "author": "Ethan Seifert", "author_id": 984, "author_profile": "https://wordpress.stackexchange.com/users/984", "pm_score": 3, "selected": true, "text": "<p>I would check the output of <code>$querystr</code>. It looks like you have the table name twice. <code>$wpdb-&...
2011/02/08
[ "https://wordpress.stackexchange.com/questions/8889", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2393/" ]
Have been trying to figure out the issue with this for the past hour, but hitting a wall. Basically I'm just trying to query my custom post type based on some custom date fields and then displaying each. Anyone have an idea where I'm going wrong? ``` <?php // - query - global $wpdb; ...
I would check the output of `$querystr`. It looks like you have the table name twice. `$wpdb->postmeta` resolves to something like `wp_postmeta` and then you have `postmeta` again. This gives you `wp_postmetapostmeta` which isn't a valid table. I highly recommend you try out [Debug Bar](http://wordpress.org/extend/plu...
8,900
<p>When my script runs the 4th line below in WP 2.9.2, its causing my web app to throw an "Apache HTTP Service has stopped working" error</p> <pre><code>$cat=get_cat_ID('top-menu'); $catHidden=get_cat_ID('hidden'); $myqueryCurrent = new WP_Query(); $myqueryCurrent-&gt;query(array('cat'=&gt;"$cat,-$catHidden",'post__no...
[ { "answer_id": 8979, "author": "hakre", "author_id": 178, "author_profile": "https://wordpress.stackexchange.com/users/178", "pm_score": 1, "selected": true, "text": "<p>Executing the code you posted results in a crash inside the PHP module. I assume you're running PHP as module inside a...
2011/02/08
[ "https://wordpress.stackexchange.com/questions/8900", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/366/" ]
When my script runs the 4th line below in WP 2.9.2, its causing my web app to throw an "Apache HTTP Service has stopped working" error ``` $cat=get_cat_ID('top-menu'); $catHidden=get_cat_ID('hidden'); $myqueryCurrent = new WP_Query(); $myqueryCurrent->query(array('cat'=>"$cat,-$catHidden",'post__not_in'=>get_option('s...
Executing the code you posted results in a crash inside the PHP module. I assume you're running PHP as module inside apache on windows, if the module crashes, apache crashes as well. Ensure that you're using the right PHP modules here. Are you sure you need the Thread-Safe variant of PHP for apache? Those are reported...
8,903
<p>I found this on wordpress.org forums. tested it and works fine. When i changed the variables to my own it failed. I checked it thoroughly (!) for hours. i can't see where it's going wrong.</p> <pre><code>register_post_type( 'book', array( 'labels' =&gt; array( 'name' =&gt; 'Books', 'singular_nam...
[ { "answer_id": 8904, "author": "scribu", "author_id": 205, "author_profile": "https://wordpress.stackexchange.com/users/205", "pm_score": 1, "selected": false, "text": "<p>That script doesn't allow sorting, just displaying a custom column. Is that the original script or the modified one?...
2011/02/08
[ "https://wordpress.stackexchange.com/questions/8903", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I found this on wordpress.org forums. tested it and works fine. When i changed the variables to my own it failed. I checked it thoroughly (!) for hours. i can't see where it's going wrong. ``` register_post_type( 'book', array( 'labels' => array( 'name' => 'Books', 'singular_name' => 'Book', ...
That script doesn't allow sorting, just displaying a custom column. Is that the original script or the modified one? Note that register\_post\_type() and register\_taxonomy() shouldn't be called directly, but in a callback hooked to the 'init' action. Working version: ``` function my_init() { register_post_type( ...
8,912
<p>I have a client who wants to register users and give them a unique ID number when they complete registration. (Kind of a member number sort of thing) </p> <p>Can I just setup the WP member table to start id numbers in the high 10 digit range?</p> <p>User experience would be:</p> <ol> <li>user would visit the site...
[ { "answer_id": 8913, "author": "Peter Rowell", "author_id": 1958, "author_profile": "https://wordpress.stackexchange.com/users/1958", "pm_score": 2, "selected": false, "text": "<p>The ID field will definitely work. If you wanted a larger number you could just add 10,000 to it and it will...
2011/02/08
[ "https://wordpress.stackexchange.com/questions/8912", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2469/" ]
I have a client who wants to register users and give them a unique ID number when they complete registration. (Kind of a member number sort of thing) Can I just setup the WP member table to start id numbers in the high 10 digit range? User experience would be: 1. user would visit the site 2. user would register 3. ...
The `ID` column of the `users` table is `AUTO_INCREMENT`, so [you can set the base counter to a high number](http://dev.mysql.com/doc/refman/5.5/en/alter-table.html): ``` ALTER TABLE wp_users AUTO_INCREMENT = 1000000000; ``` All new users will have an `ID` that is higher than this value. Calling this operation is sa...
8,915
<p>I'm trying to use varnish with a wp 3.0.5 site with Network (Multisite), when I access the varnish URL, I get this message: </p> <pre><code>Multisite only works without the port number in the URL. </code></pre> <p>Do I need a custom VCL to make this work? I'm using the same backend config for other wordpress sites...
[ { "answer_id": 8920, "author": "hakre", "author_id": 178, "author_profile": "https://wordpress.stackexchange.com/users/178", "pm_score": 2, "selected": false, "text": "<p>that Wordpress error message is probably misleading.</p>\n\n<p>Wordpress looks for the domain name in <a href=\"http:...
2011/02/08
[ "https://wordpress.stackexchange.com/questions/8915", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34/" ]
I'm trying to use varnish with a wp 3.0.5 site with Network (Multisite), when I access the varnish URL, I get this message: ``` Multisite only works without the port number in the URL. ``` Do I need a custom VCL to make this work? I'm using the same backend config for other wordpress sites that work fine.. If I n...
I found a fix here: <http://core.trac.wordpress.org/ticket/15936> You basically need to modify wp-includes/ms-settings.php like this (remove '-' lines; add the '+' line): ``` @@ -26,18 +26,8 @@ if ( !isset( $current_site ) || !isset( $current_blog ) ) { + $_SERVER['HTTP_HOST'] = preg_replace( '|:\d+$|', '', ...
8,924
<p>How can I call the_tags as a list without hyperlinks?</p>
[ { "answer_id": 8925, "author": "Ethan Seifert", "author_id": 984, "author_profile": "https://wordpress.stackexchange.com/users/984", "pm_score": 4, "selected": true, "text": "<pre><code>&lt;ul&gt;\n &lt;?php\n $tags = get_tags();\n\n foreach($tags as $tag) {\n echo \"&lt;l...
2011/02/09
[ "https://wordpress.stackexchange.com/questions/8924", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/366/" ]
How can I call the\_tags as a list without hyperlinks?
``` <ul> <?php $tags = get_tags(); foreach($tags as $tag) { echo "<li>$tag->name</li>"; } ?> </ul> ```
8,936
<p>I am using something like this on one of my plugins:</p> <pre><code>$myOption_def = "myOption Default Value"; $myOption = get_option( 'myOption' ) ? get_option( 'myOption' ) : $myOption_def; </code></pre> <p>That works fine, but the problem is that I need to be able to set the option to "empty", but when I do that...
[ { "answer_id": 8937, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": -1, "selected": false, "text": "<p>Oops, figure out myself:</p>\n\n<pre><code>$myOption = (get_option( 'myOption' )==FALSE) ? get_option( 'myOption' ...
2011/02/09
[ "https://wordpress.stackexchange.com/questions/8936", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I am using something like this on one of my plugins: ``` $myOption_def = "myOption Default Value"; $myOption = get_option( 'myOption' ) ? get_option( 'myOption' ) : $myOption_def; ``` That works fine, but the problem is that I need to be able to set the option to "empty", but when I do that (from a textarea on my pl...
Basically to distinguish between `false` boolean value and `''` empty string you must use more strict [comparison operator](http://php.net/manual/en/language.operators.comparison.php). ``` var_dump( '' == false ); // this is 'true', treated like two 'empty()' values var_dump( '' === false ); // this is 'false', becau...
8,949
<p>Website: [removed]</p> <p>If you goto the above post you will see that there are some comments which when posted appears as admin comments for some reason.</p> <p>If you are having problem finding that specific comment you can also press CTRL+F to find it using the following words Test Comment or Guest which i pos...
[ { "answer_id": 8937, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": -1, "selected": false, "text": "<p>Oops, figure out myself:</p>\n\n<pre><code>$myOption = (get_option( 'myOption' )==FALSE) ? get_option( 'myOption' ...
2011/02/09
[ "https://wordpress.stackexchange.com/questions/8949", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1804/" ]
Website: [removed] If you goto the above post you will see that there are some comments which when posted appears as admin comments for some reason. If you are having problem finding that specific comment you can also press CTRL+F to find it using the following words Test Comment or Guest which i posted myself for te...
Basically to distinguish between `false` boolean value and `''` empty string you must use more strict [comparison operator](http://php.net/manual/en/language.operators.comparison.php). ``` var_dump( '' == false ); // this is 'true', treated like two 'empty()' values var_dump( '' === false ); // this is 'false', becau...
8,960
<p>Please read this carefully as it is not what you might be expecting. </p> <p>I'm building my site in a development sub domain. I don't want to have to go through the complications of running find and replace plugins after moving the site to the live area (as this can often go wrong on some serialized data). </p> <...
[ { "answer_id": 8961, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>Likely this will make more sense with JS, but that is not my area.</p>\n\n<p>In PHP you can <a href=\"http://php.net/...
2011/02/09
[ "https://wordpress.stackexchange.com/questions/8960", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1925/" ]
Please read this carefully as it is not what you might be expecting. I'm building my site in a development sub domain. I don't want to have to go through the complications of running find and replace plugins after moving the site to the live area (as this can often go wrong on some serialized data). I want to enter...
I use these two defines in my wp-config.php file: ``` define('WP_HOME', 'http://dev.mysite.com'); define('WP_SITEURL', 'http://dev.mysite.com'); ``` Mind the trailing slash (or rather, the lack thereof), else you'll get permalink bugs. Also note that they'll actually get used as is if you insert images and so forth...
8,968
<p>i did a fresh wordpress install on my NAS and on my local machine (notebook). on my notebook anything is running perfect (takes ~3 secs to load) but from my NAS it is really extremely slow :( (taking ~12 secs)</p> <p>it's the same setup and i couldn't find out the reason .. :(</p> <p>it seems like that the problem...
[ { "answer_id": 8969, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 2, "selected": true, "text": "<p>I guess you already answered the question yourself. The other thing could be that your NAS has a slow harddrive (5.40...
2011/02/09
[ "https://wordpress.stackexchange.com/questions/8968", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3030/" ]
i did a fresh wordpress install on my NAS and on my local machine (notebook). on my notebook anything is running perfect (takes ~3 secs to load) but from my NAS it is really extremely slow :( (taking ~12 secs) it's the same setup and i couldn't find out the reason .. :( it seems like that the problem is the internal ...
I guess you already answered the question yourself. The other thing could be that your NAS has a slow harddrive (5.400 rpm) or that your connection is slow. --- Edit: Speed up with removing unwanted dashboard items... ``` <?php /* Plugin Name: Dashboard-Widgets Removal Plugin Plugin URI: http://example.com De...
8,982
<p>I'm using this script on my archive.php in order to list a link list of all posts contained in the current category. However, its limiting the result count relative to the number assigned to "Settings > Reading > Blog Pages Show At Most <em>_</em> posts".</p> <p>In other words, there may be 10 posts that are in thi...
[ { "answer_id": 8984, "author": "editor", "author_id": 1860, "author_profile": "https://wordpress.stackexchange.com/users/1860", "pm_score": 3, "selected": true, "text": "<p>Instead of using the default loop, perhaps try <a href=\"http://codex.wordpress.org/Function_Reference/query_posts\...
2011/02/09
[ "https://wordpress.stackexchange.com/questions/8982", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/366/" ]
I'm using this script on my archive.php in order to list a link list of all posts contained in the current category. However, its limiting the result count relative to the number assigned to "Settings > Reading > Blog Pages Show At Most *\_* posts". In other words, there may be 10 posts that are in this category, but ...
Instead of using the default loop, perhaps try [building](http://codex.wordpress.org/Function_Reference/query_posts) your own [query.](http://codex.wordpress.org/Function_Reference/WP_Query) Basically, it'll look something like this: ``` $your_posts = get_posts('cat=123&posts_per_page=123'); foreach ($your_post as $p...
8,990
<p>In my homepage loop, I have something that will show which category the post is in. It will say something like "Posted 4 hours ago in Sports by ...". However, when there is no category set, it will omit the category (obviously) and just say "Posted 4 hours ago in by ...". My question is: how do I check if a post bel...
[ { "answer_id": 8993, "author": "editor", "author_id": 1860, "author_profile": "https://wordpress.stackexchange.com/users/1860", "pm_score": 1, "selected": false, "text": "<p>Instead of using <code>get_category()</code> or whatever to echo it out directly, try using <code>get_the_category...
2011/02/09
[ "https://wordpress.stackexchange.com/questions/8990", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2347/" ]
In my homepage loop, I have something that will show which category the post is in. It will say something like "Posted 4 hours ago in Sports by ...". However, when there is no category set, it will omit the category (obviously) and just say "Posted 4 hours ago in by ...". My question is: how do I check if a post belong...
You can use [`is_object_in_term()`](http://codex.wordpress.org/Function_Reference/is_object_in_term). Despite name it can also check for taxonomy match if terms are omitted. ``` is_object_in_term( get_the_ID(), 'category' ); ```
8,996
<p>I have a mult-author site where the author page gets high traffic. People want to know more about them. I have modified the author page to show more info, some custom fields, etc. but what I'd really like to do is turn on Comments for the author.php page (so that OTHER logged in users can leave review-like message...
[ { "answer_id": 9002, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>Yep, mechanics of comments in WP are tightly tied to posts. Which things like archives aren't.</p>\n\n<p>Your options...
2011/02/09
[ "https://wordpress.stackexchange.com/questions/8996", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1663/" ]
I have a mult-author site where the author page gets high traffic. People want to know more about them. I have modified the author page to show more info, some custom fields, etc. but what I'd really like to do is turn on Comments for the author.php page (so that OTHER logged in users can leave review-like messages for...
just to add to what Rarst answered, you can create Custom Post Type not to emulate Comments but as stub posts with no ui. then to every Author on your site add a custom user metadata that will hold a post id of your newly made post type (one per each author) and in your author template before you call the comment loop...
8,997
<p>I'm trying to pull just the tag names as an array collection in order to write them out as a simple listing, without links, but the array that's returned does not send the name as an indexible item.</p> <pre><code>array(2) { [0]=&gt; string(129) "&lt;a href='#' class='tag-link-31' title='1 topic' style='font-size...
[ { "answer_id": 9005, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": true, "text": "<p>try :</p>\n\n<pre><code>function my_tag_list_123($sep){\n $tags = get_tags();\n\n foreach ($tags as $tag)...
2011/02/09
[ "https://wordpress.stackexchange.com/questions/8997", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/366/" ]
I'm trying to pull just the tag names as an array collection in order to write them out as a simple listing, without links, but the array that's returned does not send the name as an indexible item. ``` array(2) { [0]=> string(129) "<a href='#' class='tag-link-31' title='1 topic' style='font-size: 8pt;'>tag 1</a>" ...
try : ``` function my_tag_list_123($sep){ $tags = get_tags(); foreach ($tags as $tag){ $ret[]= $tag->name; } return implode($sep, $ret); } ``` and call it when you need like this ``` echo my_tag_list_123(','); ``` hope this helps.
8,998
<p>I am using a plugin modified for my purposes. </p> <p>What I am after is after the user has registered for it to automatically log them in and return them to the current page. At the moment it sends them an email with their username and password. They then have to log in using those details.</p>
[ { "answer_id": 9010, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": false, "text": "<p>Basically to log a user in you can use:</p>\n\n<pre><code> //Login the user\n $creds = array();\...
2011/02/09
[ "https://wordpress.stackexchange.com/questions/8998", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2957/" ]
I am using a plugin modified for my purposes. What I am after is after the user has registered for it to automatically log them in and return them to the current page. At the moment it sends them an email with their username and password. They then have to log in using those details.
Basically to log a user in you can use: ``` //Login the user $creds = array(); $creds['user_login'] = $login; $creds['user_password'] = $password; if ( !empty( $remember ) ){ $creds['remember'] = true; } $user = wp_signon( $creds, true ); ``` but that is only when you hav...
9,003
<p>I am trying to find out whether or not a post has images. If it does, I then want to know if a featured image was specified for the thumbnail - if not, the get_thumb() function will assign an image from the gallery of that post. However, if a post doesn't have images, I want to use a span class to occupy the thumbna...
[ { "answer_id": 9006, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/is_attachment\" rel=\"nofollow\"><code>is_attachment()</code>...
2011/02/09
[ "https://wordpress.stackexchange.com/questions/9003", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3040/" ]
I am trying to find out whether or not a post has images. If it does, I then want to know if a featured image was specified for the thumbnail - if not, the get\_thumb() function will assign an image from the gallery of that post. However, if a post doesn't have images, I want to use a span class to occupy the thumbnail...
``` function has_image_attachment($post_id) { $args = array( 'post_type' => 'attachment', 'post_mime_type' => 'image/jpeg', 'numberposts' => -1, 'post_status' => null, 'post_parent' => $post_id ); $attachments = get_posts($args); if(is_array($attachments) && co...
9,015
<p>I've roughly followed the <a href="http://shibashake.com/wordpress-theme/wordpress-custom-taxonomy-input-panels" rel="nofollow noreferrer">tutorial here</a> on how to create "custom taxonomy input panels". I'm using a custom post type of <code>homes</code> and a custom taxonomy called <code>beds</code> (used to reco...
[ { "answer_id": 9021, "author": "Zack", "author_id": 2322, "author_profile": "https://wordpress.stackexchange.com/users/2322", "pm_score": 2, "selected": true, "text": "<p>I believe your problem might be nonce-related. I see you're doing what I did at one point with <a href=\"https://word...
2011/02/09
[ "https://wordpress.stackexchange.com/questions/9015", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49/" ]
I've roughly followed the [tutorial here](http://shibashake.com/wordpress-theme/wordpress-custom-taxonomy-input-panels) on how to create "custom taxonomy input panels". I'm using a custom post type of `homes` and a custom taxonomy called `beds` (used to record the number of beds in a house). I've got the taxonomy terms...
I believe your problem might be nonce-related. I see you're doing what I did at one point with [a problem I had](https://wordpress.stackexchange.com/questions/6902/updating-post-meta-for-custom-post-types) when I tried doing nonces the way you're using them. I'll quote @**EAMann** on this: > > The standard way to cr...
9,016
<p>Hey there, I am sooo frustrated, asked and asked and can't seem to get an answer. Pleaseeeee help, I'll be very very clean whith my problem. I'll give hundreds of bears to the one who can help:)</p> <ol> <li><p>I have a blog installed <a href="http://www.myblog.com" rel="nofollow">http://www.myblog.com</a> - <stron...
[ { "answer_id": 9021, "author": "Zack", "author_id": 2322, "author_profile": "https://wordpress.stackexchange.com/users/2322", "pm_score": 2, "selected": true, "text": "<p>I believe your problem might be nonce-related. I see you're doing what I did at one point with <a href=\"https://word...
2011/02/09
[ "https://wordpress.stackexchange.com/questions/9016", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2979/" ]
Hey there, I am sooo frustrated, asked and asked and can't seem to get an answer. Pleaseeeee help, I'll be very very clean whith my problem. I'll give hundreds of bears to the one who can help:) 1. I have a blog installed <http://www.myblog.com> - **it's part of a network, I use wordpress multisite** 2. **I created a ...
I believe your problem might be nonce-related. I see you're doing what I did at one point with [a problem I had](https://wordpress.stackexchange.com/questions/6902/updating-post-meta-for-custom-post-types) when I tried doing nonces the way you're using them. I'll quote @**EAMann** on this: > > The standard way to cr...
9,020
<p>I've been puzzling over this one for two days. Still can't figure it out.</p> <p>I'm testing a theme release in multiple versions of WordPress using xampplite on localhost on a PC.</p> <p>I'm having a problem on WP 2.9.2 that does not occur on any other newer installations of WP.</p> <p>Take a look at the query b...
[ { "answer_id": 9022, "author": "editor", "author_id": 1860, "author_profile": "https://wordpress.stackexchange.com/users/1860", "pm_score": 2, "selected": true, "text": "<p>The only thing I see as even close to syntactically questionable is that <code>showposts</code> could be replaced w...
2011/02/09
[ "https://wordpress.stackexchange.com/questions/9020", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/366/" ]
I've been puzzling over this one for two days. Still can't figure it out. I'm testing a theme release in multiple versions of WordPress using xampplite on localhost on a PC. I'm having a problem on WP 2.9.2 that does not occur on any other newer installations of WP. Take a look at the query below. As long as I leave...
The only thing I see as even close to syntactically questionable is that `showposts` could be replaced with `posts_per_page`.
9,044
<p>Im trying to make my next and previous post buttons display my custom field but for some reason it doesnt display the custom field its just blank. Heres my code.</p> <pre><code>&lt;div id="next-prev-links"&gt; &lt;?php $previous_post = previous_post_link('%link', ''.$image_prev.'', TRUE); $next_p...
[ { "answer_id": 9057, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>I think you are trying to retrieve <code>ID</code> from link string that <code>*_post_link()</code> functions return,...
2011/02/10
[ "https://wordpress.stackexchange.com/questions/9044", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2635/" ]
Im trying to make my next and previous post buttons display my custom field but for some reason it doesnt display the custom field its just blank. Heres my code. ``` <div id="next-prev-links"> <?php $previous_post = previous_post_link('%link', ''.$image_prev.'', TRUE); $next_post = next_post_link('%...
Here's the code for what you're trying to do (accessing post custom value): ``` <?php global $post; $prev_post = get_adjacent_post(); $next_post = get_adjacent_post( false, '', false ); $prev_post_id = $prev_post->ID; $next_post_id = $next_post->ID; // this should, according to your code above...
9,076
<p>I've created a site in WordPress on our development machine. In the theme we're using there are numerous widget zones to display text in (sidebar and front page). I've used simple Text widgets in all of these zones to put our display information.</p> <p>When I migrated the site to production, I used the WP-DB-Backu...
[ { "answer_id": 9097, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 7, "selected": true, "text": "<p>This is where your problem is:</p>\n\n<blockquote>\n <p>I then edited the resulting .sql file\n to update all of th...
2011/02/10
[ "https://wordpress.stackexchange.com/questions/9076", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1165/" ]
I've created a site in WordPress on our development machine. In the theme we're using there are numerous widget zones to display text in (sidebar and front page). I've used simple Text widgets in all of these zones to put our display information. When I migrated the site to production, I used the WP-DB-Backup plugin t...
This is where your problem is: > > I then edited the resulting .sql file > to update all of the file paths and > URL references to point to our > production site. > > > You can't do that. WordPress stores many options as "serialized data", which contains both the string content of things *and their length*. So...
9,079
<p>I want to be able to edit the post_parent of a custom post type. Basically in my use case I want to mimic how WordPress uses attachments: have a custom post type that is sort of a subtype to post or any other post type. WordPress uses the post_parent field on the wp_posts table to link attachments to their parent ...
[ { "answer_id": 9083, "author": "MikeSchinkel", "author_id": 89, "author_profile": "https://wordpress.stackexchange.com/users/89", "pm_score": 3, "selected": true, "text": "<p>Hi <strong>@Manny Fleurmond</strong>:</p>\n\n<p>You can add the following HTML to a <a href=\"http://codex.wordpr...
2011/02/10
[ "https://wordpress.stackexchange.com/questions/9079", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2234/" ]
I want to be able to edit the post\_parent of a custom post type. Basically in my use case I want to mimic how WordPress uses attachments: have a custom post type that is sort of a subtype to post or any other post type. WordPress uses the post\_parent field on the wp\_posts table to link attachments to their parent po...
Hi **@Manny Fleurmond**: You can add the following HTML to a [**post metabox**](http://codex.wordpress.org/Function_Reference/add_meta_box) you'll have an edit field that lets you edit the raw `post_parent` ID. Maybe with this knowledge you can build what you need? ``` <input type="text" id="parent_id" name="parent_i...
9,081
<p>HI there,</p> <p>I want to remove the actions added to wp_head by a plugin but only in certain circumstances.</p> <p>Here is code that doesn't work:</p> <pre><code>if (is_single() &amp;&amp; get_post_type() == 'tenant') { $row = $wpdb-&gt;get_row("SELECT * FROM Events WHERE WP_ID='$post-&gt;ID'",ARRAY_A); re...
[ { "answer_id": 9084, "author": "John P Bloch", "author_id": 11, "author_profile": "https://wordpress.stackexchange.com/users/11", "pm_score": 1, "selected": false, "text": "<p>My guess is that it's not working because the action name is <code>'wp_head'</code>, not <code>'wp-head'</code>....
2011/02/10
[ "https://wordpress.stackexchange.com/questions/9081", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2911/" ]
HI there, I want to remove the actions added to wp\_head by a plugin but only in certain circumstances. Here is code that doesn't work: ``` if (is_single() && get_post_type() == 'tenant') { $row = $wpdb->get_row("SELECT * FROM Events WHERE WP_ID='$post->ID'",ARRAY_A); remove_action('wp-head',array($aiosp, 'wp_h...
Sorted it, turns out all-in-one-seo-pack can be disabled on a post by post basis, so I used: add\_post\_meta($post->ID,'\_aioseop\_disable',true); inside the if parameter and before setting my own title, works a charm. PS $post is gotten with global $post;
9,086
<p>What is the code i have to put in the <code>page</code> to show the posts from custom post type?</p>
[ { "answer_id": 9087, "author": "Fernando Briano", "author_id": 298, "author_profile": "https://wordpress.stackexchange.com/users/298", "pm_score": 1, "selected": false, "text": "<p>If you look at the <a href=\"http://codex.wordpress.org/Custom_Fields\" rel=\"nofollow\">Custom Fields page...
2011/02/10
[ "https://wordpress.stackexchange.com/questions/9086", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2215/" ]
What is the code i have to put in the `page` to show the posts from custom post type?
Easy: modify the query... (and add some comment on top to make a template out of this...) ``` $query_default = new WP_Query( array( 'orderby' => 'menu_order' ,'order' => 'ASC' ,'post_type' => 'custompost' // THIS IS WHAT YOU'RE SEARCHING FOR ,'post_status' => 'publish' ) ); if ( $q...
9,093
<p>I am about to press the "upgrade" button in my Wordpress MU 2.8 install.</p> <p>What is going to happen to the mu-plugins folder? And is there an equivalent way for me to automatically activate a plugin across all my sites?</p>
[ { "answer_id": 9087, "author": "Fernando Briano", "author_id": 298, "author_profile": "https://wordpress.stackexchange.com/users/298", "pm_score": 1, "selected": false, "text": "<p>If you look at the <a href=\"http://codex.wordpress.org/Custom_Fields\" rel=\"nofollow\">Custom Fields page...
2011/02/10
[ "https://wordpress.stackexchange.com/questions/9093", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3058/" ]
I am about to press the "upgrade" button in my Wordpress MU 2.8 install. What is going to happen to the mu-plugins folder? And is there an equivalent way for me to automatically activate a plugin across all my sites?
Easy: modify the query... (and add some comment on top to make a template out of this...) ``` $query_default = new WP_Query( array( 'orderby' => 'menu_order' ,'order' => 'ASC' ,'post_type' => 'custompost' // THIS IS WHAT YOU'RE SEARCHING FOR ,'post_status' => 'publish' ) ); if ( $q...
9,099
<p>Looking for a plugin to ensure that casual (NOT logged in) users of my site will agree to the Terms of use. That is, first time they try to access ANY page on site, display terms and prompt for agreement. If suer agrees, store that in DB (preferable) or cookie.</p> <p>I came across "Terms of Use" plugin, but it ha...
[ { "answer_id": 9101, "author": "editor", "author_id": 1860, "author_profile": "https://wordpress.stackexchange.com/users/1860", "pm_score": 0, "selected": false, "text": "<p>I've done a more general survey of ToS plugins in the past, but found them lacking features beyond putting an extr...
2011/02/10
[ "https://wordpress.stackexchange.com/questions/9099", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3076/" ]
Looking for a plugin to ensure that casual (NOT logged in) users of my site will agree to the Terms of use. That is, first time they try to access ANY page on site, display terms and prompt for agreement. If suer agrees, store that in DB (preferable) or cookie. I came across "Terms of Use" plugin, but it has not been ...
I wrote something like that in the past that check for a cookie before loading the page and if the cookie wasn't found the page would display something like the terms of services and a checkbox to agree, so only after the guest agrees he can see the content. i'll see if i can find that code. UPDATE ------ O.k found ...
9,102
<p>When I use <code>wp_mail( $to, $subject, $message, $headers )</code> (with values in place, of course), the email gets sent with a from name and email that isn't set anywhere I can find (not even in PHP or Apache settings). However, using <code>mail( $to, $subject, $message, $headers )</code> instead works just fine...
[ { "answer_id": 9104, "author": "MikeSchinkel", "author_id": 89, "author_profile": "https://wordpress.stackexchange.com/users/89", "pm_score": 7, "selected": true, "text": "<p>Hi <strong>@helenyhou:</strong></p>\n\n<p>You can set the header, just not with a parameter. WordPress uses <em>...
2011/02/10
[ "https://wordpress.stackexchange.com/questions/9102", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2226/" ]
When I use `wp_mail( $to, $subject, $message, $headers )` (with values in place, of course), the email gets sent with a from name and email that isn't set anywhere I can find (not even in PHP or Apache settings). However, using `mail( $to, $subject, $message, $headers )` instead works just fine. What could be happening...
Hi **@helenyhou:** You can set the header, just not with a parameter. WordPress uses *[**"hooks"**](http://www.raymondselda.com/understanding-filter-hooks-in-wordpress/)* and the hooks you need are `'wp_mail_from'` and `'wp_mail_from_name'` hooks. Here are the hooks you might add to your theme's `functions.php` file ...
9,110
<p>I'm a bit confused.</p> <p>I have my own custom post type - products.</p> <p>I'm listing all the products on page-products.php.</p> <p>Every product has also it's own page - single-products.php.</p> <p>And the big and strange thing is... I'm using more quicktag:</p> <pre><code>&lt;!-- more --&gt; </code></pre> ...
[ { "answer_id": 9113, "author": "Peter Rowell", "author_id": 1958, "author_profile": "https://wordpress.stackexchange.com/users/1958", "pm_score": 1, "selected": false, "text": "<p>All we have to go on is <code>&lt;!-- more --&gt;</code>. If that's what you are actually doing, try this fr...
2011/02/10
[ "https://wordpress.stackexchange.com/questions/9110", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1869/" ]
I'm a bit confused. I have my own custom post type - products. I'm listing all the products on page-products.php. Every product has also it's own page - single-products.php. And the big and strange thing is... I'm using more quicktag: ``` <!-- more --> ``` And it doesn't work on both single-products and page-pro...
The "read more" link is essentially a navigational device meant to point visitors to a full version of a piece of some excerpted content. A single.php of any post type is the full version, therefore it is 100% in the nature of `<!-- more -->` to not appear on single custom post type pages. If you're just looking to di...
9,132
<p>I'm trying to retrieve the terms of a page's custom taxonomy.</p> <p>When I'm in a post this works just fine:</p> <pre><code>$args=array('orderby' =&gt; 'none'); $terms = wp_get_post_terms( $post-&gt;ID , 'custom_taxonomy', $args); </code></pre> <p>But this won't work on a page.</p> <p>I've tried also with: <st...
[ { "answer_id": 9127, "author": "scribu", "author_id": 205, "author_profile": "https://wordpress.stackexchange.com/users/205", "pm_score": 4, "selected": true, "text": "<p>For each propery, ask yourself these questions:</p>\n\n<ol>\n<li>Is it likely that, on average, more than 1-2 posts w...
2011/02/11
[ "https://wordpress.stackexchange.com/questions/9132", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I'm trying to retrieve the terms of a page's custom taxonomy. When I'm in a post this works just fine: ``` $args=array('orderby' => 'none'); $terms = wp_get_post_terms( $post->ID , 'custom_taxonomy', $args); ``` But this won't work on a page. I've tried also with: **get\_the\_terms** & **wp\_get\_object\_terms** ...
For each propery, ask yourself these questions: 1. Is it likely that, on average, more than 1-2 posts will have the same value for this property? 2. If so, do I need to filter posts based on this property, or is it just for display? If you answered both with 'yes', then make it a taxonomy, otherwise a custom field. ...
9,140
<p>I'm running a WP 3.0.5 website and here is my problem: I define a custom post type with 2 custom taxonomies and I've got to develop a search engine based upon these taxonomies. Until there, no problem :</p> <pre><code>$args = array( 'my_post_type' =&gt; 'post_type_name', 'my_taxo_1' =&gt; 'taxo-1-...
[ { "answer_id": 9141, "author": "Jan Fabry", "author_id": 8, "author_profile": "https://wordpress.stackexchange.com/users/8", "pm_score": 3, "selected": true, "text": "<p>You can do this in 3.0 with <a href=\"http://wordpress.org/extend/plugins/query-multiple-taxonomies/\" rel=\"nofollow\...
2011/02/11
[ "https://wordpress.stackexchange.com/questions/9140", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3071/" ]
I'm running a WP 3.0.5 website and here is my problem: I define a custom post type with 2 custom taxonomies and I've got to develop a search engine based upon these taxonomies. Until there, no problem : ``` $args = array( 'my_post_type' => 'post_type_name', 'my_taxo_1' => 'taxo-1-slug', 'my_...
You can do this in 3.0 with [the Query Multiple Taxonomies plugin](http://wordpress.org/extend/plugins/query-multiple-taxonomies/).
9,155
<p>I've handrolled a form for posting from the front-end, with some custom functions that I needed. However, I've made the form only accessible when a user is logged in, and I'd like to have the articles show up as being posted by that user. Thoughts?? Here is my current code:</p> <p>backend:</p> <pre><code>if( 'POST...
[ { "answer_id": 9159, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 1, "selected": false, "text": "<p>Assuming the user is logged in, then wp_insert_post should automatically set the post author field properly. Have yo...
2011/02/11
[ "https://wordpress.stackexchange.com/questions/9155", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2881/" ]
I've handrolled a form for posting from the front-end, with some custom functions that I needed. However, I've made the form only accessible when a user is logged in, and I'd like to have the articles show up as being posted by that user. Thoughts?? Here is my current code: backend: ``` if( 'POST' == $_SERVER['REQUES...
you can use ``` global $current_user; get_currentuserinfo(); ``` and then add ``` 'post_author' => $current_user->ID ``` to your $new\_post array. then you can use ``` <p>Posted by: <?php the_author(); ?></p> ```
9,175
<p>I want to know how to get just the image URL from <code>the_post_thumbnail()</code>. The default output of <code>the_post_thumbnail()</code> is:</p> <pre><code>&lt;img width=&quot;800&quot; height=&quot;533&quot; src=&quot;http://example.com/wp-content/uploads/2011/02/book06.jpg&quot; class=&quot;attachment-post-thu...
[ { "answer_id": 9177, "author": "haha", "author_id": 2163, "author_profile": "https://wordpress.stackexchange.com/users/2163", "pm_score": 1, "selected": false, "text": "<p>Ok got it using <a href=\"http://php.net/manual/en/function.simplexml-load-string.php\" rel=\"nofollow\"><code>simpl...
2011/02/12
[ "https://wordpress.stackexchange.com/questions/9175", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2163/" ]
I want to know how to get just the image URL from `the_post_thumbnail()`. The default output of `the_post_thumbnail()` is: ``` <img width="800" height="533" src="http://example.com/wp-content/uploads/2011/02/book06.jpg" class="attachment-post-thumbnail wp-post-image" alt="book06" title="book06" /> ``` Here I want gr...
You might also try: If you only have one size thumbnail: ``` $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ) ); ``` Or...if you have multiple sizes: ``` $thumbnail = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), "size" ); ``` Note that wp\_get\_attachment\_image\_...
9,185
<p>I have a custom page where I try to change the page title.<br> The function executes, but the title is not changed. This is the code I'm using:</p> <pre><code> add_filter('wp_title', set_page_title($brand)); function set_page_title($brand) { $title = 'Designer '.$brand['name'].' - '.get_bloginfo('name'); ...
[ { "answer_id": 9189, "author": "keatch", "author_id": 2727, "author_profile": "https://wordpress.stackexchange.com/users/2727", "pm_score": 2, "selected": false, "text": "<p>You cannot pass an array to set_page_title, the filters callback accept only the original title as input parameter...
2011/02/12
[ "https://wordpress.stackexchange.com/questions/9185", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1447/" ]
I have a custom page where I try to change the page title. The function executes, but the title is not changed. This is the code I'm using: ``` add_filter('wp_title', set_page_title($brand)); function set_page_title($brand) { $title = 'Designer '.$brand['name'].' - '.get_bloginfo('name'); //Here I can...
`wp_title` filter is deprecated since WordPress 4.4 (see [here](https://developer.wordpress.org/reference/hooks/wp_title/#div-comment-1076)). You can use [document\_title\_parts](https://developer.wordpress.org/reference/hooks/document_title_parts/) instead ``` function custom_title($title_parts) { $title_parts['t...
9,186
<p>I am new to wordpress development, just trying to convert my HTML into a WordPress theme, I started with Chris Coyer's blank theme. </p> <pre class="lang-hmtl prettyprint-override"><code>&lt;div class="navigation"&gt; &lt;div class="next-posts"&gt; &lt;?php next_posts_link('&amp;laquo; Older Entries') ?...
[ { "answer_id": 9187, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 5, "selected": true, "text": "<p>You can use <code>get_previous_posts_link</code> and <code>get_next_posts_link</code>\nto determine if they exi...
2011/02/12
[ "https://wordpress.stackexchange.com/questions/9186", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/794/" ]
I am new to wordpress development, just trying to convert my HTML into a WordPress theme, I started with Chris Coyer's blank theme. ```hmtl <div class="navigation"> <div class="next-posts"> <?php next_posts_link('&laquo; Older Entries') ?> </div> <div class="prev-posts"> <?php previous_pos...
You can use `get_previous_posts_link` and `get_next_posts_link` to determine if they exists like this: ``` $prev_link = get_previous_posts_link(__('&laquo; Older Entries')); $next_link = get_next_posts_link(__('Newer Entries &raquo;')); // as suggested in comments if ($prev_link || $next_link) { echo '<ul class="nav...
9,195
<p>I am unable to install any theme/plugin to my wordpress 3.0 </p> <pre><code>Downloading install package from http://downloads.wordpress.org/plugin/contact-form-7.2.3.1.zip… Unpacking the package… Installing the plugin… Could not copy file. /public_html/blog/wp-content/plugins/contact-form-7/languages/wp...
[ { "answer_id": 9196, "author": "Graviton", "author_id": 133, "author_profile": "https://wordpress.stackexchange.com/users/133", "pm_score": 1, "selected": false, "text": "<p>Check your folder permission. Most likely your folder doesn't have correct permission.</p>\n\n<p>The permission sh...
2010/08/10
[ "https://wordpress.stackexchange.com/questions/9195", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/258/" ]
I am unable to install any theme/plugin to my wordpress 3.0 ``` Downloading install package from http://downloads.wordpress.org/plugin/contact-form-7.2.3.1.zip… Unpacking the package… Installing the plugin… Could not copy file. /public_html/blog/wp-content/plugins/contact-form-7/languages/wpcf7-lt_LT.po ...
*headdesk* Permissions on all WordPress files should be 644. Permissions on all WordPress directories should be 755. Exceptions: * The uploads directory may need to be 775 or 777, depending on your server configuration. * wp-config.php should be 600, 640, or 644, whatever is the lowest number that works. Never, e...
9,202
<p>I'm using this code to display the thumbnail (featured picture) of the previous and next post (a custom post type called Blocks).</p> <p>(A custom loop)</p> <pre><code>&lt;?php // Create and run custom loop $custom_posts = new WP_Query(); $custom_posts-&gt;query('post_type=blocks&amp;location=Front Page&am...
[ { "answer_id": 9204, "author": "Pabline", "author_id": 2908, "author_profile": "https://wordpress.stackexchange.com/users/2908", "pm_score": 2, "selected": false, "text": "<p>It looks like you're setting up 2 loops when you don't need to. If you're in a template that's displaying a 'bloc...
2011/02/12
[ "https://wordpress.stackexchange.com/questions/9202", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/781/" ]
I'm using this code to display the thumbnail (featured picture) of the previous and next post (a custom post type called Blocks). (A custom loop) ``` <?php // Create and run custom loop $custom_posts = new WP_Query(); $custom_posts->query('post_type=blocks&location=Front Page&section=Mainbar'); while ($cu...
**Update:** OK. If you get to keep changing the question, I get to delete what I had written before and start all over again. To be honest, I'm a bit confused about what you are trying to do. Since this *appears* to be for a single post (based on the comment at the top of your template), it is unclear to me what your ...
9,209
<p>I'm trying to do something I assumed would be easy. I assumed wrong. What I want to do is list all the authors of a site on the sidebar, with a link to their respective author page, number of posts written, and gravatar. wp_list_authors doesn't give me an option to include the gravatar at all. Here is what I have</p...
[ { "answer_id": 9215, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p><code>get_users_of_blog()</code> may be deprecated per documentation, but it is actually what <code>wp_list_authors()...
2011/02/12
[ "https://wordpress.stackexchange.com/questions/9209", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/403/" ]
I'm trying to do something I assumed would be easy. I assumed wrong. What I want to do is list all the authors of a site on the sidebar, with a link to their respective author page, number of posts written, and gravatar. wp\_list\_authors doesn't give me an option to include the gravatar at all. Here is what I have ``...
To answer your problems: Sorting by post count --------------------- You can collect all the information you need in to an array and sort that array by number of posts , like this: ``` //function to sort array by filed function authors_orderBy($data, $field){ $code = "if (\$a['$field'] == \$b['$field...
9,211
<p>I have spent the last day using the functions.php file to fully customize WordPress for my client sites. I am amazed at how much I have been able to accomplish and how much easier it will make things for my clients.</p> <p>I have removed certain menu items for users that are not logged in as an admin. What I am hop...
[ { "answer_id": 9213, "author": "Ross", "author_id": 3111, "author_profile": "https://wordpress.stackexchange.com/users/3111", "pm_score": 2, "selected": false, "text": "<p>I agree.. The <code>functions.php</code> file gives lots of flexibility. I've needed some of the same functionality...
2011/02/12
[ "https://wordpress.stackexchange.com/questions/9211", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3110/" ]
I have spent the last day using the functions.php file to fully customize WordPress for my client sites. I am amazed at how much I have been able to accomplish and how much easier it will make things for my clients. I have removed certain menu items for users that are not logged in as an admin. What I am hoping (and f...
Here's the process to change the labels (I changed posts to "contacts" in my example) ``` function change_post_menu_label() { global $menu; global $submenu; $menu[5][0] = 'Contacts'; $submenu['edit.php'][5][0] = 'Contacts'; $submenu['edit.php'][10][0] = 'Add Contacts'; $submenu['edit.php'][15][...
9,217
<p><strong>This is my single.php file:</strong></p> <p>I'm using <code>previous_post_link();</code> and <code>next_post_link();</code>.</p> <p>In the Worpress codex it says that <a href="http://codex.wordpress.org/Template_Tags/previous_post_link" rel="nofollow">it only works inside the loop</a>.</p> <pre><code>&lt;...
[ { "answer_id": 9218, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": true, "text": "<p>\"Inside the Loop\" essentially means that function relies on data from global variables (such as <code>$post</code>) ...
2011/02/12
[ "https://wordpress.stackexchange.com/questions/9217", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/781/" ]
**This is my single.php file:** I'm using `previous_post_link();` and `next_post_link();`. In the Worpress codex it says that [it only works inside the loop](http://codex.wordpress.org/Template_Tags/previous_post_link). ``` <?php /** * The Template for displaying all single posts. * * @package WordPress * @subpa...
"Inside the Loop" essentially means that function relies on data from global variables (such as `$post`) that are set up when Loop runs. Note that this is not necessarily done by main Loop of `query_posts()`. In your specific code those variables are filled by `$custom_posts->the_post()` calls and after that `wp_reset...
9,239
<p>I am trying to utilize this function. I cannot figure out why I am still getting the PHP error. All I can figure out is that for some reason the template isn't able to access $wpdb. I don't know what line needs to be placed in the functions.php (in theme folder) file that contains this function. Please help me!!...
[ { "answer_id": 9244, "author": "Ethan Seifert", "author_id": 984, "author_profile": "https://wordpress.stackexchange.com/users/984", "pm_score": 0, "selected": false, "text": "<p>It's likely that $wpdb has been globalized when it hits your particular function. Try checking $GLOBALS and i...
2011/02/13
[ "https://wordpress.stackexchange.com/questions/9239", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3118/" ]
I am trying to utilize this function. I cannot figure out why I am still getting the PHP error. All I can figure out is that for some reason the template isn't able to access $wpdb. I don't know what line needs to be placed in the functions.php (in theme folder) file that contains this function. Please help me!! ``` f...
You did everything right with the globalize, the error message is just telling you that you called a function on $wpdb which does not exists. Just check prior you do that $wpdb contains the object you're intersted in: ``` if (is_object($wpdb) && is_a($wpdb, 'wpdb')) { $result = $wpdb->insert( 'wp_weights', array(...
9,240
<p>I'm putting to getter a landing page theme in WP. On the start page of the theme there should be three different boxes of text, where I can describe the product. The thing is that this boxes should be static and not be included in a blog role.</p> <p>So the most common scenario is that I only add the text once to t...
[ { "answer_id": 9244, "author": "Ethan Seifert", "author_id": 984, "author_profile": "https://wordpress.stackexchange.com/users/984", "pm_score": 0, "selected": false, "text": "<p>It's likely that $wpdb has been globalized when it hits your particular function. Try checking $GLOBALS and i...
2011/02/13
[ "https://wordpress.stackexchange.com/questions/9240", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I'm putting to getter a landing page theme in WP. On the start page of the theme there should be three different boxes of text, where I can describe the product. The thing is that this boxes should be static and not be included in a blog role. So the most common scenario is that I only add the text once to this three ...
You did everything right with the globalize, the error message is just telling you that you called a function on $wpdb which does not exists. Just check prior you do that $wpdb contains the object you're intersted in: ``` if (is_object($wpdb) && is_a($wpdb, 'wpdb')) { $result = $wpdb->insert( 'wp_weights', array(...
9,252
<p>How should I handle post thumbnails? Do most people put them in custom fields? Use a plugin? How do themes on ThemeForest handle this? </p> <p>Also different theme will have different size requirements? So moving from 1 theme to the next could cause alot of problems?</p> <p>Thumbnails may come in different sizes t...
[ { "answer_id": 9254, "author": "Fernando Briano", "author_id": 298, "author_profile": "https://wordpress.stackexchange.com/users/298", "pm_score": 4, "selected": true, "text": "<p>Since WordPress 2.9, you can add thumbnail support to your theme by adding this to the theme's functions.php...
2011/02/13
[ "https://wordpress.stackexchange.com/questions/9252", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/794/" ]
How should I handle post thumbnails? Do most people put them in custom fields? Use a plugin? How do themes on ThemeForest handle this? Also different theme will have different size requirements? So moving from 1 theme to the next could cause alot of problems? Thumbnails may come in different sizes too
Since WordPress 2.9, you can add thumbnail support to your theme by adding this to the theme's functions.php file: ``` if ( function_exists( 'add_theme_support' ) ) { add_theme_support( 'post-thumbnails' ); } ``` When this is done, you'll be able to add a feature image to your post on Posts, Pages or Custom Post...
9,264
<p>I am trying to customize the admin area using the functions.php file to make things easier for my clients. One request I have got before and hope to be able to accomplish, is to move some of the sub menus into the main navigation.</p> <p>For instance I would like to make Widgets and Menus appear in the main naviga...
[ { "answer_id": 9377, "author": "Norcross", "author_id": 403, "author_profile": "https://wordpress.stackexchange.com/users/403", "pm_score": 3, "selected": true, "text": "<p>OK, it's a bit messy, but it works. Take a look</p>\n\n<pre><code>function remove_submenus() {\n global $submenu;\...
2011/02/13
[ "https://wordpress.stackexchange.com/questions/9264", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3110/" ]
I am trying to customize the admin area using the functions.php file to make things easier for my clients. One request I have got before and hope to be able to accomplish, is to move some of the sub menus into the main navigation. For instance I would like to make Widgets and Menus appear in the main navigation as opp...
OK, it's a bit messy, but it works. Take a look ``` function remove_submenus() { global $submenu; unset($submenu['themes.php'][10]); // Removes Menu } add_action('admin_menu', 'remove_submenus'); function new_nav_menu () { global $menu; $menu[99] = array('', 'read', 'separator', '', 'menu-top menu-nav')...
9,277
<p>I need an help with this code.</p> <p>This one works perfectly, but I have this problem</p> <p>I have one category (A) and 2 subcat (C) &amp; (D)...</p> <p>so when I watching the post on a category (C) , I would to show only relative in a category (D).</p> <p>What I Have to add at this code ?? something like "no...
[ { "answer_id": 9297, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>There is <code>category__not_in</code> (see <a href=\"http://codex.wordpress.org/Function_Reference/query_posts#Categ...
2011/02/13
[ "https://wordpress.stackexchange.com/questions/9277", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I need an help with this code. This one works perfectly, but I have this problem I have one category (A) and 2 subcat (C) & (D)... so when I watching the post on a category (C) , I would to show only relative in a category (D). What I Have to add at this code ?? something like "not\_in\_category > current.. is it p...
There is `category__not_in` (see [Category Parameters](http://codex.wordpress.org/Function_Reference/query_posts#Category_Parameters)), but I am not entirely sure if it will work properly if you try to include and exclude category at the same time. If you want to skip some category with your current arguments I think ...
9,285
<p>I know I can control the length of excerpts using a <a href="http://codex.wordpress.org/Function_Reference/the_excerpt#Control_Excerpt_Length_using_Filters" rel="nofollow">filter</a>, however it sets the length globally. In my case I have different lengths of excerpts on three different pages. </p> <p>This is what ...
[ { "answer_id": 9286, "author": "Fernando Briano", "author_id": 298, "author_profile": "https://wordpress.stackexchange.com/users/298", "pm_score": 1, "selected": false, "text": "<p>I know I've seen this question on StackOverflow before. Not specific to WordPress excerpt, but on truncatin...
2011/02/14
[ "https://wordpress.stackexchange.com/questions/9285", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2313/" ]
I know I can control the length of excerpts using a [filter](http://codex.wordpress.org/Function_Reference/the_excerpt#Control_Excerpt_Length_using_Filters), however it sets the length globally. In my case I have different lengths of excerpts on three different pages. This is what I have now. I'd like to improve it s...
Set the filter dynamically based on the page you are loading. If category archive pages have a 100 word excerpt, but posts have a 10 word excerpt, and everything else uses the default: ``` function my_custom_excerpt_length( $orig ) { if( is_category() ) { return 100; } elseif( is_single() ) { r...
9,301
<p>As as title, how to prevent wp not to encode html in a post?</p> <p>currently i just need to prevent <strong>'&amp;'</strong> changed to <code>&amp;amp;</code> The result need to be looks like on editor with html tab mode selected.</p> <pre><code>$content = $wpdb-&gt;get_row("SELECT post_content FROM $wpdb-&gt;pos...
[ { "answer_id": 9302, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>Save post when in HTML tab of editor. It should be saved as close to what you see in editor as possible. I had run co...
2011/02/14
[ "https://wordpress.stackexchange.com/questions/9301", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
As as title, how to prevent wp not to encode html in a post? currently i just need to prevent **'&'** changed to `&amp;` The result need to be looks like on editor with html tab mode selected. ``` $content = $wpdb->get_row("SELECT post_content FROM $wpdb->posts WHERE ID=xxx"); $content = str_replace('amp;','',$conten...
Save post when in HTML tab of editor. It should be saved as close to what you see in editor as possible. I had run couple of quick tests and ampersands are not encoded in this case (as you want to). I am not sure how to prevent this for visual editor, because a lot of formatting-related stuff in editor is handled by J...
9,308
<p>If I have a loop running from a category query like :</p> <pre><code>&lt;?php $the_query = new WP_Query('cat=1&amp;showposts=50&amp;orderby=title&amp;order=asc');?&gt; &lt;ul&gt; &lt;?php while ($the_query-&gt;have_posts()) : $the_query-&gt;the_post();?&gt; &lt;li&gt;.. &lt;/li&gt;&lt;?php wp_reset_query(); ?&gt; &...
[ { "answer_id": 9309, "author": "Jan Fabry", "author_id": 8, "author_profile": "https://wordpress.stackexchange.com/users/8", "pm_score": 2, "selected": false, "text": "<p>This is more a general programming question, but here is the basic idea:</p>\n\n<pre><code>&lt;?php $the_query = new ...
2011/02/14
[ "https://wordpress.stackexchange.com/questions/9308", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2661/" ]
If I have a loop running from a category query like : ``` <?php $the_query = new WP_Query('cat=1&showposts=50&orderby=title&order=asc');?> <ul> <?php while ($the_query->have_posts()) : $the_query->the_post();?> <li>.. </li><?php wp_reset_query(); ?> <?php endwhile; ?> </ul> ``` How would I create an if clause that b...
Create Columns for your query and easy display ============================================== In themes is probably more useful to have something that fits well into template tags and the loop. My first answer didn't focus on that much. Additionally I thought it's a bit too complicated for a quick adoption. An easier...
9,327
<p>I need to find if a post with a custom field X equal to Y exists in a wordpress installation.</p> <p>Should I do it with a simple sql query or is there something build in that can help me achieve it?</p>
[ { "answer_id": 9328, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 4, "selected": true, "text": "<p>You can use the <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query\" rel=\"nofollow\">WP_Query</a>()...
2011/02/14
[ "https://wordpress.stackexchange.com/questions/9327", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I need to find if a post with a custom field X equal to Y exists in a wordpress installation. Should I do it with a simple sql query or is there something build in that can help me achieve it?
You can use the [WP\_Query](http://codex.wordpress.org/Class_Reference/WP_Query)(); to check that like this: ``` $my_query = new WP_Query(); $my_query->query(array( 'meta_key' => 'X', 'meta_value' => 'Y')); if ( $my_query->have_posts() ){ //it exists } else { //it's not here } ``` Hope this helps.
9,332
<p>I'm building a custom homepage for a client where they want to have a few changeable boxes to link to specific pages, or posts, within the site. I've added custom fields to the homepage so that they need only enter the page/post ID, and then it will display the proper post or page. And I'd like it to be flexible eno...
[ { "answer_id": 9333, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 4, "selected": true, "text": "<p>Try this:</p>\n\n<pre><code>query_posts(array(\n 'p' =&gt; $topright,\n 'post_type' =&gt; array('post', 'page'),...
2011/02/14
[ "https://wordpress.stackexchange.com/questions/9332", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2041/" ]
I'm building a custom homepage for a client where they want to have a few changeable boxes to link to specific pages, or posts, within the site. I've added custom fields to the homepage so that they need only enter the page/post ID, and then it will display the proper post or page. And I'd like it to be flexible enough...
Try this: ``` query_posts(array( 'p' => $topright, 'post_type' => array('post', 'page'), )); ```
9,345
<p>I'm using WordPress 3.0.5 and have tested with 3.1rc4. In the main PHP file of my plugin, when I try to call is_plugin_active I get <code>Call to undefined function is_plugin_active()</code>. I can call add_action and add_filter. What should I check/change to fix this?</p> <p>This is happening inside of the admin o...
[ { "answer_id": 9348, "author": "hakre", "author_id": 178, "author_profile": "https://wordpress.stackexchange.com/users/178", "pm_score": 1, "selected": false, "text": "<p>To debug active plugins:</p>\n\n<pre><code>var_dump(get_option(...));\n</code></pre>\n\n<p>To check for a specific pl...
2011/02/14
[ "https://wordpress.stackexchange.com/questions/9345", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3168/" ]
I'm using WordPress 3.0.5 and have tested with 3.1rc4. In the main PHP file of my plugin, when I try to call is\_plugin\_active I get `Call to undefined function is_plugin_active()`. I can call add\_action and add\_filter. What should I check/change to fix this? This is happening inside of the admin on the Plugins pag...
That's because the file in which is\_plugin\_active() is defined - `wp-admin/includes/plugin.php` - is only loaded in the admin, after your plugin is loaded. Thus, you can only call it after 'admin\_init' has fired: ``` function check_some_other_plugin() { if ( is_plugin_active('some-plugin.php') ) { ... } } ...
9,346
<p>I would like to have the option to use taxonomy in the url instead of only having category like "uncategorized." Note that I have multiple taxonomies (countries, states etc), some of which have thousands of terms (if that even matters).</p> <p>Edit: I failed to mention that this is an offshoot of another question: ...
[ { "answer_id": 9543, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>I did something similar. This article showed me the way:</p>\n\n<p><a href=\"http://shibashake.com/wordpress-theme/...
2011/02/15
[ "https://wordpress.stackexchange.com/questions/9346", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1697/" ]
I would like to have the option to use taxonomy in the url instead of only having category like "uncategorized." Note that I have multiple taxonomies (countries, states etc), some of which have thousands of terms (if that even matters). Edit: I failed to mention that this is an offshoot of another question: [Pros and ...
Changing the URL structure of a post always consists of two parts: writing the new URL in your links, and handling the new structure. Handling the new structure ========================== Handling the new structure is easy: because the post name (slug) is enough to identify a post, we can ignore the taxonomy you are ...
9,347
<p>I'm looking for a way to change the WordPress favicon. Any hints how to do this?</p>
[ { "answer_id": 9349, "author": "Fernando Briano", "author_id": 298, "author_profile": "https://wordpress.stackexchange.com/users/298", "pm_score": 4, "selected": true, "text": "<p>You should add it on your theme's header.php file with this code (W3C standard code):</p>\n\n<pre><code>&lt;...
2011/02/14
[ "https://wordpress.stackexchange.com/questions/9347", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2912/" ]
I'm looking for a way to change the WordPress favicon. Any hints how to do this?
You should add it on your theme's header.php file with this code (W3C standard code): ``` <link rel="icon" type="image/png" href="http://yourblog.com/favicon.png"> ```
9,353
<p>I want to be able to customize the WordPress edit posts screen to filter based on a custom field (or whatever). </p> <p>Unfortunately I'm not sure what filter or hook to use here, and instead of opening the code myself, figured I'd throw the question out here.</p> <p>Just to be clear, I'm talking about this screen...
[ { "answer_id": 9354, "author": "Abhishek Bhardwaj", "author_id": 344, "author_profile": "https://wordpress.stackexchange.com/users/344", "pm_score": 1, "selected": false, "text": "<p>I found a plugin that might be a solution to your problem: <a href=\"http://wordpress.org/extend/plugins/...
2011/02/15
[ "https://wordpress.stackexchange.com/questions/9353", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2576/" ]
I want to be able to customize the WordPress edit posts screen to filter based on a custom field (or whatever). Unfortunately I'm not sure what filter or hook to use here, and instead of opening the code myself, figured I'd throw the question out here. Just to be clear, I'm talking about this screen. Essentially I w...
You need a to use a few hooks for that take a look at [mike's answer](https://wordpress.stackexchange.com/questions/45/how-to-sort-the-admin-area-of-a-wordpress-custom-post-type-by-a-custom-field/159#159) to a similar question. Hope this Helps
9,358
<p>I'm trying to create a forum system using WP's custom post types - two post types as Topic/Reply and a Forum taxonomy.</p> <p>I have created a singular template for the topic post type, in which I added a reply form. The problem is that when I submit the form I get a 404 page.</p> <p>This is the form template:</p>...
[ { "answer_id": 9446, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 3, "selected": true, "text": "<p>it was the \"topic\" name field. It seems you can't use <a href=\"http://codex.wordpress.org/Function_Referen...
2011/02/15
[ "https://wordpress.stackexchange.com/questions/9358", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1986/" ]
I'm trying to create a forum system using WP's custom post types - two post types as Topic/Reply and a Forum taxonomy. I have created a singular template for the topic post type, in which I added a reply form. The problem is that when I submit the form I get a 404 page. This is the form template: ``` <div class="top...
it was the "topic" name field. It seems you can't use [reserved terms](http://codex.wordpress.org/Function_Reference/register_taxonomy#Reserved_Terms) in $\_POST, and "topic" is a post type name, so its probably one of them...
9,380
<p>I am having a problem. I am running WP 3.05 with one custom taxonomy.</p> <p>Here is the code to create the taxonomy:</p> <pre><code>function create_property_taxonomies() { // Add new taxonomy, make it hierarchical (like categories) $labels = array( 'name' =&gt; _x( 'Property Types', 'taxonomy general nam...
[ { "answer_id": 9378, "author": "keatch", "author_id": 2727, "author_profile": "https://wordpress.stackexchange.com/users/2727", "pm_score": 2, "selected": false, "text": "<p>Wordpress.com is a hosted blogging service based, of course, on Wordpress. You can register and open your blog, ch...
2011/02/15
[ "https://wordpress.stackexchange.com/questions/9380", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2911/" ]
I am having a problem. I am running WP 3.05 with one custom taxonomy. Here is the code to create the taxonomy: ``` function create_property_taxonomies() { // Add new taxonomy, make it hierarchical (like categories) $labels = array( 'name' => _x( 'Property Types', 'taxonomy general name' ), 'singular_name...
* WordPress.com is **web service**. * WordPress.org is **software product**. Think bus vs car. You can ride both, but bus is owned by someone else and what you can do with it is limited.
9,385
<p>i've downloaded a wordpress web to my local machine and tried setting it up. the problem: when trying to login, wordpress will always redirect to the online url. the only way i found was changing the siteurl manually in phpmyadmin to my local machine's ip address. is there a better solution? the problem about doing ...
[ { "answer_id": 9386, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>If I understand right you had restored backup of live site to local installation?</p>\n\n<p>Basically you have two wa...
2011/02/15
[ "https://wordpress.stackexchange.com/questions/9385", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3030/" ]
i've downloaded a wordpress web to my local machine and tried setting it up. the problem: when trying to login, wordpress will always redirect to the online url. the only way i found was changing the siteurl manually in phpmyadmin to my local machine's ip address. is there a better solution? the problem about doing tha...
Open up your `wp-config.php` file Try adding the following to it: ``` define( 'WP_SITEURL', 'http://localhost/your_wordpress_folder' ); define( 'WP_HOME', 'http://localhost/your_wordpress_folder' ); ```
9,390
<p>I transferred a website to VPS and when I open that website, the home page takes too long to load, for me its taking 30-35 secs just to display the home page, but when I navigate the internal pages it loads in normal speed, I also tried this when all of my plugins were deactivated, but no change, it was taking time ...
[ { "answer_id": 9391, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": true, "text": "<p>There was a thread on wp-hackers in December which could be related: <a href=\"http://lists.automattic.com/pipermail/wp-...
2011/02/15
[ "https://wordpress.stackexchange.com/questions/9390", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1743/" ]
I transferred a website to VPS and when I open that website, the home page takes too long to load, for me its taking 30-35 secs just to display the home page, but when I navigate the internal pages it loads in normal speed, I also tried this when all of my plugins were deactivated, but no change, it was taking time to ...
There was a thread on wp-hackers in December which could be related: [Avoid query\_post on frontpage on wp initialization](http://lists.automattic.com/pipermail/wp-hackers/2010-December/036960.html). You may give [Sergey Biryukov’s code](http://lists.automattic.com/pipermail/wp-hackers/2010-December/036963.html) a try:...
9,394
<p>I know how to get a custom field value for a specific post. </p> <pre><code>get_post_meta($post_id, $key, $single); </code></pre> <p>What I need is to get all the values associated with a specific custom post key, <strong>across all posts</strong>.</p> <p>Anyone knows of an efficient way to do this? I wouldn't wa...
[ { "answer_id": 9406, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 2, "selected": false, "text": "<p>the fastest way would be a custom sql query and i'm not sure but you can try</p>\n\n<pre><code>$wpdb-&gt;get_r...
2011/02/15
[ "https://wordpress.stackexchange.com/questions/9394", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2071/" ]
I know how to get a custom field value for a specific post. ``` get_post_meta($post_id, $key, $single); ``` What I need is to get all the values associated with a specific custom post key, **across all posts**. Anyone knows of an efficient way to do this? I wouldn't want to loop through all post id's in the DB. E...
One possible approach would be to use one of the helper methods in the [WPDB class](https://developer.wordpress.org/reference/classes/wpdb/) to do a more refined meta-based query. Using the `$wpdb` function [`get_col`](https://developer.wordpress.org/reference/classes/wpdb/#select-a-column) it's possible return a simp...
9,414
<p>I need to display the current term in my custom taxonomy in a single post.</p> <p><strong>example:</strong></p> <ul> <li>My custom taxonomy is <em>products</em> and term of them is <em>product-1</em>, <em>product-2</em> and <em>products-3</em>.</li> <li>My post is assigned to <em>product-2</em></li> <li>And I want...
[ { "answer_id": 9415, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>I found it:</p>\n\n<pre><code>&lt;?php \n//list terms in a given taxonomy using wp_list_categories (also useful as ...
2011/02/15
[ "https://wordpress.stackexchange.com/questions/9414", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I need to display the current term in my custom taxonomy in a single post. **example:** * My custom taxonomy is *products* and term of them is *product-1*, *product-2* and *products-3*. * My post is assigned to *product-2* * And I want to print the current products = *products-2* in my post In fact, I need a functio...
I found it: ``` <?php //list terms in a given taxonomy using wp_list_categories (also useful as a widget if using a PHP Code plugin) $taxonomy = 'genre'; $orderby = 'name'; $show_count = 0; // 1 for yes, 0 for no $pad_counts = 0; // 1 for yes, 0 for no $hierarchical = 1; // 1 for yes, 0 ...
9,419
<p>I created a 'forum' taxonomy, using these rules:</p> <pre><code>register_taxonomy( 'forum', array('topic'), array( 'public' =&gt; true, 'name' =&gt; _a('Forums'), 'singular_name' =&gt; _a('Forum'), 'show_ui' =&gt; true, 'show_in_nav_menus' =&gt; true, 'hierarchical' =&gt; true, 'l...
[ { "answer_id": 9421, "author": "Pabline", "author_id": 2908, "author_profile": "https://wordpress.stackexchange.com/users/2908", "pm_score": 2, "selected": false, "text": "<p>I'd take a look at the code of the top level cats plugin:</p>\n\n<p><a href=\"http://fortes.com/projects/wordpres...
2011/02/15
[ "https://wordpress.stackexchange.com/questions/9419", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1986/" ]
I created a 'forum' taxonomy, using these rules: ``` register_taxonomy( 'forum', array('topic'), array( 'public' => true, 'name' => _a('Forums'), 'singular_name' => _a('Forum'), 'show_ui' => true, 'show_in_nav_menus' => true, 'hierarchical' => true, 'labels' => array( 'name' =>...
UPDATE ------ Since writing this WordPress core has added the `'do_parse_request'` hook that allows URL routing to be handled elegantly and without the need to extend the `WP` class. I covered the topic in-depth in my 2014 Atlanta WordCamp talk entitled [*"**Hardcore URL Routing**"*](http://hardcorewp.com/2014/hardcor...
9,453
<p>Using the Wordpress default theme 2010 1.1, shortcodes work on the main blog page and individual post pages, but are being stripped out on category and archive pages. </p> <p>For example, stick in the theme's functions.php:</p> <pre><code>add_shortcode('tsc', 'tsc_process_shortcode' ); function tsc_process_short...
[ { "answer_id": 9435, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 3, "selected": false, "text": "<p>I've not actually done it myself, but there is a testing environment for WordPress unit testing. It's meant for core...
2011/02/15
[ "https://wordpress.stackexchange.com/questions/9453", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3202/" ]
Using the Wordpress default theme 2010 1.1, shortcodes work on the main blog page and individual post pages, but are being stripped out on category and archive pages. For example, stick in the theme's functions.php: ``` add_shortcode('tsc', 'tsc_process_shortcode' ); function tsc_process_shortcode($atts, $content =...
As an ex-software engineer building large business types who landed in an interactive agency let me give you a few thoughts on testing when developing for Wordpress: 1. Your Unit Testing should test the smallest amount of behavior that a class can perform. Each class should be able to be tested independently of Wordpr...
9,463
<p>We are building a site that will have 10-15 photographers posting content. There will be a common blog + each admin has their own portfolio to manage. "Portfolio galleries" and "portfolio pages" are two custom types and they are categorized using "Artist", a custom taxonomy.</p> <p>We would like all admins:</p> <...
[ { "answer_id": 9482, "author": "Ardee Aram", "author_id": 2630, "author_profile": "https://wordpress.stackexchange.com/users/2630", "pm_score": 2, "selected": false, "text": "<p>If I will be the one building that site, this is what I'll do for the \"View Portfolio Pages and Galleries tha...
2011/02/16
[ "https://wordpress.stackexchange.com/questions/9463", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3086/" ]
We are building a site that will have 10-15 photographers posting content. There will be a common blog + each admin has their own portfolio to manage. "Portfolio galleries" and "portfolio pages" are two custom types and they are categorized using "Artist", a custom taxonomy. We would like all admins: 1. to be able t...
If I will be the one building that site, this is what I'll do for the "View Portfolio Pages and Galleries that belong to them": 1.) I'll create a new page template, say `template-portfolio.php` inside your themes directory, that goes something like this: ``` <?php /* Template Name: Portfolio */ if(is_user_logged_in()...
9,464
<p>I'm having an issue with using wp_insert_post. I'm adding the ability for a post of one type to create a post of another type with the first post as the post parent. I was testing out a few things using the save_posts filter. I created a function that simply creates a post and then hooked that function to the sav...
[ { "answer_id": 9482, "author": "Ardee Aram", "author_id": 2630, "author_profile": "https://wordpress.stackexchange.com/users/2630", "pm_score": 2, "selected": false, "text": "<p>If I will be the one building that site, this is what I'll do for the \"View Portfolio Pages and Galleries tha...
2011/02/16
[ "https://wordpress.stackexchange.com/questions/9464", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2234/" ]
I'm having an issue with using wp\_insert\_post. I'm adding the ability for a post of one type to create a post of another type with the first post as the post parent. I was testing out a few things using the save\_posts filter. I created a function that simply creates a post and then hooked that function to the save\_...
If I will be the one building that site, this is what I'll do for the "View Portfolio Pages and Galleries that belong to them": 1.) I'll create a new page template, say `template-portfolio.php` inside your themes directory, that goes something like this: ``` <?php /* Template Name: Portfolio */ if(is_user_logged_in()...
9,468
<p>Every time I attempt to upload a plugin or theme, I am asked for the FTP password. Is there a way to save this within Wordpress, or do I have to enter it every time? Thanks.</p>
[ { "answer_id": 9469, "author": "Fernando Briano", "author_id": 298, "author_profile": "https://wordpress.stackexchange.com/users/298", "pm_score": 5, "selected": true, "text": "<p>You can save this information on your wp-config.php file:</p>\n<pre><code>define('FTP_HOST', 'ftp_host');\nd...
2011/02/16
[ "https://wordpress.stackexchange.com/questions/9468", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3206/" ]
Every time I attempt to upload a plugin or theme, I am asked for the FTP password. Is there a way to save this within Wordpress, or do I have to enter it every time? Thanks.
You can save this information on your wp-config.php file: ``` define('FTP_HOST', 'ftp_host'); define('FTP_USER', 'ftp_username'); define('FTP_PASS', 'ftp_password'); ``` [More info](https://developer.wordpress.org/apis/wp-config-php/#wordpress-upgrade-constants) (WordPress Developer Resources)