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
21,887
<p>I have a script that I wrote some time ago, and have just decided to "port" it into a WP plugin.</p> <p>Everything works great, except for one piece of vital core functionality.</p> <p>The script uses mod_rewrite to allow for virtual URLs to be used, that include a "keyword" that the script then uses later for oth...
[ { "answer_id": 21888, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>If the user decides not to enable pretty permalinks, then I would respect their decision not to enable them...
2011/07/03
[ "https://wordpress.stackexchange.com/questions/21887", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6712/" ]
I have a script that I wrote some time ago, and have just decided to "port" it into a WP plugin. Everything works great, except for one piece of vital core functionality. The script uses mod\_rewrite to allow for virtual URLs to be used, that include a "keyword" that the script then uses later for other functions. I...
If the user decides not to enable pretty permalinks, then I would respect their decision not to enable them. Two potential options: 1. Simply state that the Plugin requires pretty permalinks to be enabled in order to work 2. As a fallback, just append the keyword as a query string if pretty permalinks are not enabled...
21,908
<p>I have a meta_query like this , but 'relation' => 'OR' NOT WORKING, Does meta_query only do 'both/and' checks and don't do 'either/or' ?</p> <pre><code>$args = array( 'post_type' =&gt; 'post', 'posts_per_page' =&gt; -1, 'meta_query' =&gt; array( 'relation' =&gt; 'OR', array( 'key' =&gt; 'app_os', ...
[ { "answer_id": 21909, "author": "Ramkumar M", "author_id": 5669, "author_profile": "https://wordpress.stackexchange.com/users/5669", "pm_score": 2, "selected": false, "text": "<p>meta_query works on 'both/and' checks and also 'either/or'.so don't worry.your coding was correct.this is the...
2011/07/04
[ "https://wordpress.stackexchange.com/questions/21908", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6720/" ]
I have a meta\_query like this , but 'relation' => 'OR' NOT WORKING, Does meta\_query only do 'both/and' checks and don't do 'either/or' ? ``` $args = array( 'post_type' => 'post', 'posts_per_page' => -1, 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'app_os', 'compare' => 'LIKE', ...
meta\_query works on 'both/and' checks and also 'either/or'.so don't worry.your coding was correct.this is the actual format... ``` $a = new WP_Query( array( 'fields' => 'ids', 'ignore_sticky_posts' => true, 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'foo', ...
21,911
<p>i'm getting myself pretty confused. i'm trying to modify a template to show more than one post from the loop. </p> <p>here is the code from the template</p> <pre><code>&lt;?php $wp_query = new WP_Query(array('cat'=&gt;ot_option('hp_mid_cat'),'showposts'=&gt;ot_option('hp_mid_num'),'paged'=&gt;$paged)); ?&gt; ...
[ { "answer_id": 21912, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>Give this a go.</p>\n\n<pre><code>&lt;?php\n\n $postsPerPage = 10;\n\n $wp_query = new WP_Query(\n ar...
2011/07/04
[ "https://wordpress.stackexchange.com/questions/21911", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
i'm getting myself pretty confused. i'm trying to modify a template to show more than one post from the loop. here is the code from the template ``` <?php $wp_query = new WP_Query(array('cat'=>ot_option('hp_mid_cat'),'showposts'=>ot_option('hp_mid_num'),'paged'=>$paged)); ?> <?php if($wp_query->have_posts())...
I think you can define posts number from Theme Options panel if so use `ot_option('hp_mid_num')` as `posts_per_page` parameter to get more flexible query final code here ``` <?php $wp_query = new WP_Query( array( 'posts_per_page' => ot_option( 'hp_mid_num' ), 'cat' => ot_option( 'hp_mid_cat' ), 'pag...
21,932
<p>This may be obvious to someone other than myself. I think I remember reading somewhere that an "image" is indeed a form of "post".</p> <ul> <li>I have a custom post type called "listing"</li> <li>I have a custom WP role of "client"</li> </ul> <p>When I'm logged in as the "client", and I launch the media popup, bro...
[ { "answer_id": 21936, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": true, "text": "<p>If I had to guess: because <em>images</em> are <em>Attachments</em>, and <em>Attachments</em> are a <em>Post...
2011/07/04
[ "https://wordpress.stackexchange.com/questions/21932", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4999/" ]
This may be obvious to someone other than myself. I think I remember reading somewhere that an "image" is indeed a form of "post". * I have a custom post type called "listing" * I have a custom WP role of "client" When I'm logged in as the "client", and I launch the media popup, browse to an image, click "show" to op...
If I had to guess: because *images* are *Attachments*, and *Attachments* are a *Post-Type*. Thus, in order to edit an image, which is an attachment, which is a post, requires the `edit_post` capability. **EDIT** Don't you have your `capability` mapping array keys/values reversed? e.g. you have `'edit_posts' => 'edit...
21,960
<p>Why is my table row background image not appearing in Wordpress.</p> <p>Is the stylesheet for the theme suppressing it in some way and if so, how can one override that to make the image show, or is there some other fault causing it not to appear?</p> <p>Note the other image in the table does display properly so th...
[ { "answer_id": 21961, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": true, "text": "<p>What does Firebug or Chrome Developer Tools report on the rendered background image URL? Does it return a 40...
2011/07/04
[ "https://wordpress.stackexchange.com/questions/21960", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6732/" ]
Why is my table row background image not appearing in Wordpress. Is the stylesheet for the theme suppressing it in some way and if so, how can one override that to make the image show, or is there some other fault causing it not to appear? Note the other image in the table does display properly so the path to the fil...
What does Firebug or Chrome Developer Tools report on the rendered background image URL? Does it return a 404? Try changing this: ``` style="background-image:url(/wp-content/plugins/xxxxxxwidget/image2.png) ``` to this: ``` style="background-image:url(<?php echo wp_plugins_dir(); ?>/xxxxxxwidget/image2.png) ```
21,967
<p>I'm trying to load a file via require_once() to handle some enhanced functionality in my theme. I could place all the code directly inside functions.php, but I'm trying to isolate this code into its own script.</p> <p>The file is widget_context.php (see code below) and right now I'm just trying to echo some text ba...
[ { "answer_id": 42136, "author": "Matthew Boynes", "author_id": 12324, "author_profile": "https://wordpress.stackexchange.com/users/12324", "pm_score": 0, "selected": false, "text": "<p>If you ever resolved this, please share the answer for others. One potential reason for what you were e...
2011/07/04
[ "https://wordpress.stackexchange.com/questions/21967", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6620/" ]
I'm trying to load a file via require\_once() to handle some enhanced functionality in my theme. I could place all the code directly inside functions.php, but I'm trying to isolate this code into its own script. The file is widget\_context.php (see code below) and right now I'm just trying to echo some text back to ea...
I'm not sure why, but for some reason you have to use `include()` or `require()` inside `form()`, instead of `include_once()` and `require_once()`. I'm guessing that form() is being called multiple times, and so the external view file only gets included the first time. `include_once()` and `require_once()` will work fi...
21,990
<p>I've added a few checkbox options to the default widget form. But I'm stuck on how to access these option states and pass them along during the widget save event (<code>widget_update_callback</code>) so that they can be saved by WP to the DB.</p> <p>How do I pass my custom form values to WP to save as widget option...
[ { "answer_id": 58653, "author": "Hosh Sadiq", "author_id": 12817, "author_profile": "https://wordpress.stackexchange.com/users/12817", "pm_score": 2, "selected": false, "text": "<p>Not sure if you're still struggling with this, but for anyone that is, here's the solution:</p>\n\n<p>Add t...
2011/07/05
[ "https://wordpress.stackexchange.com/questions/21990", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6620/" ]
I've added a few checkbox options to the default widget form. But I'm stuck on how to access these option states and pass them along during the widget save event (`widget_update_callback`) so that they can be saved by WP to the DB. How do I pass my custom form values to WP to save as widget options for each widget? I...
Not sure if you're still struggling with this, but for anyone that is, here's the solution: Add the following arguments to `wse_widget_context_form()`: `$widget`, `$return` and `$instance` Then use the following to get field IDs and field names: `<?php echo $widget->get_field_id('field_name'); ?>` and `<?php echo $wi...
22,006
<p>Hi all I have this template page which get the page's post and then a list of posts from the category news.</p> <pre><code>&lt;?php /* * Template Name: News &amp; Info */ get_header(); ?&gt; &lt;div id="cLeft"&gt; &lt;?php if (function_exists('yoast_breadcrumb')) { yoast_breadcrumb('&lt;p id="b...
[ { "answer_id": 22008, "author": "zac", "author_id": 2661, "author_profile": "https://wordpress.stackexchange.com/users/2661", "pm_score": 0, "selected": false, "text": "<p>I agree with One Trick Pony.. what if you try this?</p>\n\n<pre><code> &lt;?php if (have_posts()) : while (have_p...
2011/07/05
[ "https://wordpress.stackexchange.com/questions/22006", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6452/" ]
Hi all I have this template page which get the page's post and then a list of posts from the category news. ``` <?php /* * Template Name: News & Info */ get_header(); ?> <div id="cLeft"> <?php if (function_exists('yoast_breadcrumb')) { yoast_breadcrumb('<p id="breadcrumb">', '</p>'); } ?> ...
It was correctly pointed out what the issue is, but I also want to explain it so you have better idea of mechanics: * when you use `query_posts()` it writes down generated `WP_Query` object into global `$wp_query` variable; * `have_posts()` and `the_post()` functions are wrappers for methods of same name called using ...
22,013
<p>I'm trying to get the post thumbnail in the sidebar which is in essence outside the loop.<br> For some reason it seems impossible!!!<br> I have tried all kinds of ways.<br> Here is the wirking code: (I have edited the code now that I found it)</p> <pre><code>global $wp_query; $post_id = $wp_query-&gt;post-&gt;ID; ...
[ { "answer_id": 22018, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": false, "text": "<p>try: </p>\n\n<pre><code>global $post;\n\n\nif (has_post_thumbnail( $post-&gt;ID ) ){\n// \n get_the_p...
2011/07/05
[ "https://wordpress.stackexchange.com/questions/22013", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6379/" ]
I'm trying to get the post thumbnail in the sidebar which is in essence outside the loop. For some reason it seems impossible!!! I have tried all kinds of ways. Here is the wirking code: (I have edited the code now that I found it) ``` global $wp_query; $post_id = $wp_query->post->ID; if (has_post_thumbnail(...
try: ``` global $post; if (has_post_thumbnail( $post->ID ) ){ // get_the_post_thumbnail($post->ID); // } ```
22,020
<p>my plugin uses add_action for <code>wp_ajax_cl_ajax</code> and <code>wp_ajax_nopriv_cl_ajax</code> in it's code and on the few thousand sites that are using it, it is fine but one site is not working for logged out users</p> <p>a logged in user is fine, the code sends a request to ajax and everything gets returned ...
[ { "answer_id": 22925, "author": "Rob", "author_id": 4588, "author_profile": "https://wordpress.stackexchange.com/users/4588", "pm_score": 1, "selected": true, "text": "<p>It seems as though it was a personal problem. A knew install solved the problem so it must've been clashing with some...
2011/07/05
[ "https://wordpress.stackexchange.com/questions/22020", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/699/" ]
my plugin uses add\_action for `wp_ajax_cl_ajax` and `wp_ajax_nopriv_cl_ajax` in it's code and on the few thousand sites that are using it, it is fine but one site is not working for logged out users a logged in user is fine, the code sends a request to ajax and everything gets returned fine. on other blogs, a logged...
It seems as though it was a personal problem. A knew install solved the problem so it must've been clashing with some legacy data.
22,021
<p>I need to give <em>each</em> post a <em>unique</em> post order for multiple Categories (per post) it is in. I can imagine a solution using custom fields whereby for each Category there is a corresponding custom field for the order.</p> <p>E.g. </p> <p>Categories: Playlist1 Playlist2 Playlist3</p> <p>Custom fiel...
[ { "answer_id": 52262, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 1, "selected": false, "text": "<p>Things like this get complex really fast, this is maybe why the OP never returned because organizing live broadcast...
2011/07/05
[ "https://wordpress.stackexchange.com/questions/22021", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6756/" ]
I need to give *each* post a *unique* post order for multiple Categories (per post) it is in. I can imagine a solution using custom fields whereby for each Category there is a corresponding custom field for the order. E.g. Categories: Playlist1 Playlist2 Playlist3 Custom fields for the post: Playlist1\_Order Pla...
### I recently overcame this same challenge. We needed a way to save a different sort order for each post in multiple categories. There is an unused column in the wp\_term\_relationships table, `term_order` which defaults to 0 and is already cast as an integer. When a term is assigned to a post it gets an entry in th...
22,027
<p>I am trying to add the embedded TinyMCE editor to content area using the code:</p> <pre><code>add_action( 'comment_form_after', 'tinyMCE_comment_form' ); function tinyMCE_comment_form() { wp_tiny_mce(false, array( 'mode' =&gt; 'exact', 'elements' =&gt; 'comment', 'height' =&gt; 200, ...
[ { "answer_id": 22088, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": 0, "selected": false, "text": "<p>I'm not sure if this meets your specific requirements, but I've used this to get a \"condensed\" version of...
2011/07/05
[ "https://wordpress.stackexchange.com/questions/22027", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36/" ]
I am trying to add the embedded TinyMCE editor to content area using the code: ``` add_action( 'comment_form_after', 'tinyMCE_comment_form' ); function tinyMCE_comment_form() { wp_tiny_mce(false, array( 'mode' => 'exact', 'elements' => 'comment', 'height' => 200, 'plugins' => 'inl...
If you're using WP 3.3+ I would recommend giving the new "wp\_editor()" function a shot. I've used it in several plugins and even on the front end of sites and it's pretty handy. More detail on how to use it can be found here <http://soderlind.no/archives/2011/09/25/front-end-editor-in-wordpress-3-3/>
22,031
<p>I want to use jQuery UI tabs in my WordPress 3.1.4 pages. I write programming tutorials for a VB .NET audience but like to provide C# source as well, and I want to use the tabs to let the readers switch between the two. I could probably make my own given time, but this was supposed to be a "learn things about jQuery...
[ { "answer_id": 22032, "author": "Jared Cobb", "author_id": 6737, "author_profile": "https://wordpress.stackexchange.com/users/6737", "pm_score": 4, "selected": true, "text": "<p>The short answer is that you need to include a jQuery UI CSS \"Theme\" with your code. The jQuery UI framewor...
2011/07/04
[ "https://wordpress.stackexchange.com/questions/22031", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6760/" ]
I want to use jQuery UI tabs in my WordPress 3.1.4 pages. I write programming tutorials for a VB .NET audience but like to provide C# source as well, and I want to use the tabs to let the readers switch between the two. I could probably make my own given time, but this was supposed to be a "learn things about jQuery" p...
The short answer is that you need to include a jQuery UI CSS "Theme" with your code. The jQuery UI framework is actually a combination of JavaScript and CSS (and it looks like you've only included the JavaScript). As a quick test, I just applied the "Base" theme to your code [here](http://jsfiddle.net/ATx2x/). (Notice...
22,037
<p>I want list the popular posts.popular post is defined by number of comments.If number of comment is high it will consider as popular.</p> <p>How can i do this ! </p>
[ { "answer_id": 22041, "author": "Niraj Chauhan", "author_id": 1743, "author_profile": "https://wordpress.stackexchange.com/users/1743", "pm_score": 0, "selected": false, "text": "<p>Copy paste the following code, where you want to display the popular posts</p>\n\n<pre><code>$popular = $w...
2011/07/05
[ "https://wordpress.stackexchange.com/questions/22037", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4022/" ]
I want list the popular posts.popular post is defined by number of comments.If number of comment is high it will consider as popular. How can i do this !
You can easily sort by native post fields, so try something like this: ``` $posts = get_posts( array( 'numberposts' => 10, 'orderby' => 'comment_count', ) ); ```
22,047
<p>I'm getting a problem displaying tweets that include reply's (ie when you @username someone). It's showing the @ symbol but then cutting off the rest of the tweet. (Check out <a href="http://www.teamworksdesign.com" rel="nofollow">www.teamworksdesign.com</a> in the bottom right hand corner)</p> <p>Can anyone help w...
[ { "answer_id": 22041, "author": "Niraj Chauhan", "author_id": 1743, "author_profile": "https://wordpress.stackexchange.com/users/1743", "pm_score": 0, "selected": false, "text": "<p>Copy paste the following code, where you want to display the popular posts</p>\n\n<pre><code>$popular = $w...
2011/07/05
[ "https://wordpress.stackexchange.com/questions/22047", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4588/" ]
I'm getting a problem displaying tweets that include reply's (ie when you @username someone). It's showing the @ symbol but then cutting off the rest of the tweet. (Check out [www.teamworksdesign.com](http://www.teamworksdesign.com) in the bottom right hand corner) Can anyone help with this or suggest a good plugin? ...
You can easily sort by native post fields, so try something like this: ``` $posts = get_posts( array( 'numberposts' => 10, 'orderby' => 'comment_count', ) ); ```
22,073
<p>I'm creating my own wordpress theme. I've decided to use a different way to handle the theming and not use the standard get_header() and so functions.</p> <p>What i do is have a general main.php page that is loaded by every page like blog.php, index.php, page.php and more. This main page, will be then responsible f...
[ { "answer_id": 22078, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>You can simply use the query for such a thing. In reality the different pages don't exist. The get only loaded if t...
2011/07/05
[ "https://wordpress.stackexchange.com/questions/22073", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6329/" ]
I'm creating my own wordpress theme. I've decided to use a different way to handle the theming and not use the standard get\_header() and so functions. What i do is have a general main.php page that is loaded by every page like blog.php, index.php, page.php and more. This main page, will be then responsible for creati...
First, Why this is a *bad* idea ------------------------------- WordPress already provides a rich templating API that allows for other plugins to hook in to your theme where needed. If a plugin needs to provide additional JavaScript or CSS, they tie in to `wp_head`. If they need to defer some JavaScript to the bottom ...
22,093
<p>I have a page that displays a list of all tags of my blog. Iuse this code which works fine:</p> <pre><code>&lt;?php $poststocount=get_tags($args); echo '&lt;h2&gt;Alphabetic Index of All '&lt;/h2&gt;'; ?&gt; &lt;?php $taxonomy = 'post_tag'; $tax_terms = get_terms($taxonomy); ?&gt; &lt;ul&gt; &lt;?php foreach ($ta...
[ { "answer_id": 22101, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": true, "text": "<p>you could paginate your page by simply adding <code>/page/n</code> to the end of the URL, where <code>n</code> is th...
2011/07/05
[ "https://wordpress.stackexchange.com/questions/22093", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5021/" ]
I have a page that displays a list of all tags of my blog. Iuse this code which works fine: ``` <?php $poststocount=get_tags($args); echo '<h2>Alphabetic Index of All '</h2>'; ?> <?php $taxonomy = 'post_tag'; $tax_terms = get_terms($taxonomy); ?> <ul> <?php foreach ($tax_terms as $tax_term) { echo '<li>' . '<a href="...
you could paginate your page by simply adding `/page/n` to the end of the URL, where `n` is the desired page number. creating your next/prev links will be a manual affair though. the page number will then be accessible via `get_query_var('paged')`. then use the `number` argument for [`get_terms`](http://codex.wordpress...
22,094
<p>So I originally designed the site without the www. I've since realized that it's going to cause more problems than necessary.</p> <p>I created a rewrite rule that converts to www. </p> <p>I then changed the domain in wp-config</p> <pre><code>define( 'DOMAIN_CURRENT_SITE', 'openeye.net' ); define( 'PATH_CURRENT_SI...
[ { "answer_id": 22096, "author": "Jared Cobb", "author_id": 6737, "author_profile": "https://wordpress.stackexchange.com/users/6737", "pm_score": 1, "selected": false, "text": "<p>Are you able to access your DB? Check that your site url is correct in the wp_options table.</p>\n\n<p>From ...
2011/07/05
[ "https://wordpress.stackexchange.com/questions/22094", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3296/" ]
So I originally designed the site without the www. I've since realized that it's going to cause more problems than necessary. I created a rewrite rule that converts to www. I then changed the domain in wp-config ``` define( 'DOMAIN_CURRENT_SITE', 'openeye.net' ); define( 'PATH_CURRENT_SITE', '/' ); define( 'SITE_ID...
You don't need a rewrite rule in .htaccess to add www back in. Remove the rewrite rule, remove all the defines in wp-config and try to login. If that doesn't work, delete permalinks in .htaccess to force them back to default. After you're in, add the www in Dashboard>>Settings and save. Then reset permalinks.
22,123
<p>I am using the brand new twenty eleven theme, my home page is set to show latest posts, but it displays the entire posts,</p> <p>I want to only show the excerpts, not the entire content,</p> <p>Here is the index.php code</p> <pre><code>&lt;div id="content" role="main"&gt; &lt;?php if ( have_posts() )...
[ { "answer_id": 22125, "author": "aprea", "author_id": 1144, "author_profile": "https://wordpress.stackexchange.com/users/1144", "pm_score": 4, "selected": true, "text": "<p>The template you're actually after is \"content.php\"</p>\n\n<p>You'll want to change this line:</p>\n\n<pre><code>...
2011/07/06
[ "https://wordpress.stackexchange.com/questions/22123", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1743/" ]
I am using the brand new twenty eleven theme, my home page is set to show latest posts, but it displays the entire posts, I want to only show the excerpts, not the entire content, Here is the index.php code ``` <div id="content" role="main"> <?php if ( have_posts() ) : ?> <?php twentyel...
The template you're actually after is "content.php" You'll want to change this line: ``` <?php if ( is_search() ) : // Only display Excerpts for Search ?> <div class="entry-summary"> <?php the_excerpt(); ?> </div><!-- .entry-summary --> <?php else : ?> <div class="entry-content"> <?php the_content( __( 'Conti...
22,145
<p>How do I change my index.php to display only the desired categories posts in the main page ?</p> <p>I tought that changing this would workout but instead it just print nothing:</p> <pre><code> query_posts( array( 'post_type' =&gt; array( 'post', ...
[ { "answer_id": 22149, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 2, "selected": true, "text": "<p>Your syntax is wrong, change:</p>\n\n<pre><code> query_posts( array(\n 'post_type' =&gt; array(...
2011/07/06
[ "https://wordpress.stackexchange.com/questions/22145", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1332/" ]
How do I change my index.php to display only the desired categories posts in the main page ? I tought that changing this would workout but instead it just print nothing: ``` query_posts( array( 'post_type' => array( 'post', $include_reviews, ...
Your syntax is wrong, change: ``` query_posts( array( 'post_type' => array( 'post', $include_reviews, $include_screenshots, $include_videos ), ...
22,164
<p>I'm looking for an action hook to link my function to when a completely new post is created with a status of <code>pending</code>? </p> <p>I'm aware of 'save_post' and others but want to target specifically when a post is new. </p> <p>Found this on a previous question:</p> <pre><code>add_action('new_to_publish', ...
[ { "answer_id": 22149, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 2, "selected": true, "text": "<p>Your syntax is wrong, change:</p>\n\n<pre><code> query_posts( array(\n 'post_type' =&gt; array(...
2011/07/06
[ "https://wordpress.stackexchange.com/questions/22164", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/912/" ]
I'm looking for an action hook to link my function to when a completely new post is created with a status of `pending`? I'm aware of 'save\_post' and others but want to target specifically when a post is new. Found this on a previous question: ``` add_action('new_to_publish', 'your_function'); add_action('draft_to...
Your syntax is wrong, change: ``` query_posts( array( 'post_type' => array( 'post', $include_reviews, $include_screenshots, $include_videos ), ...
22,173
<p>I'm creating a custom taxonomy whose terms must remain fixed by all users. Once I've set up the starting set of terms, I want them to be immutable. I also don't want to clutter up the Admin UI with additional links and metaboxes where they're not needed.</p> <p>However, setting <code>public =&gt; 'false'</code>, or...
[ { "answer_id": 31960, "author": "EarnestoDev", "author_id": 8211, "author_profile": "https://wordpress.stackexchange.com/users/8211", "pm_score": -1, "selected": false, "text": "<p>You talking categories <em>(hierarchical)</em> or tags? You just need a hidden taxonomy + custom widget. If...
2011/07/06
[ "https://wordpress.stackexchange.com/questions/22173", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3687/" ]
I'm creating a custom taxonomy whose terms must remain fixed by all users. Once I've set up the starting set of terms, I want them to be immutable. I also don't want to clutter up the Admin UI with additional links and metaboxes where they're not needed. However, setting `public => 'false'`, or `show_ui => 'false'` no...
A bit late but thought this could use updating. Create your custom taxonomy and add the terms you need, then go back to your `register_taxonomy()` function and set the `capabilities` argument (which itself accepts an array of capabilities). You can see how I setup sex for dogs which can only ever have two values–"Male...
22,181
<p>What is the best way to filter the posts being displayed? </p> <p>For example in my functions.php file I want to have something like</p> <pre><code>add_filter( $tag, 'filter_posts'); function filter_posts(){ if(is_home()){ //return custom post query that will be used in loop } } </code></pre>
[ { "answer_id": 22194, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 3, "selected": true, "text": "<p>Actually, you're going about this the wrong way. Don't filter the posts in <code>functions.php</code>, instead, defin...
2011/07/06
[ "https://wordpress.stackexchange.com/questions/22181", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6798/" ]
What is the best way to filter the posts being displayed? For example in my functions.php file I want to have something like ``` add_filter( $tag, 'filter_posts'); function filter_posts(){ if(is_home()){ //return custom post query that will be used in loop } } ```
Actually, you're going about this the wrong way. Don't filter the posts in `functions.php`, instead, define custom loops and [include them when needed](http://codex.wordpress.org/Function_Reference/get_template_part). In a simplified example, let's say your theme only has `header.php`, `footer.php`, `sidebar.php`, and...
22,190
<p>I have a custom meta box that is supposed to accept HTML, but the text I'm trying to input contains both double and single quotes (and ampersands), and it's messing up the saved data - each time I reload the post, the data is duplicated with an extra single quote (and angle bracket) inserted at the end. I'm guessing...
[ { "answer_id": 22202, "author": "gillespieza", "author_id": 1118, "author_profile": "https://wordpress.stackexchange.com/users/1118", "pm_score": 3, "selected": true, "text": "<p>If I'm allowed to answer my own question here: I found a way to stop the conversion of my html entities back ...
2011/07/06
[ "https://wordpress.stackexchange.com/questions/22190", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1118/" ]
I have a custom meta box that is supposed to accept HTML, but the text I'm trying to input contains both double and single quotes (and ampersands), and it's messing up the saved data - each time I reload the post, the data is duplicated with an extra single quote (and angle bracket) inserted at the end. I'm guessing it...
If I'm allowed to answer my own question here: I found a way to stop the conversion of my html entities back to characters by using `<?php esc_textarea( $text ) ?>`, as detailed by the codex here: <http://codex.wordpress.org/Function_Reference/esc_textarea>. Not sure if this is the right way of doing it, but its worki...
22,212
<p>On the Reading Settings page I have clicked <strong><em>Your latest posts</em></strong> under <strong><em>Front page displays</em></strong>. I am wondering how I can filter the query that displays these posts before it gets to the loop.</p> <p>I have tried to use the <strong>pre_get_posts</strong> filter but that d...
[ { "answer_id": 22215, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 0, "selected": false, "text": "<p>How are you using it?</p>\n\n<p>Here's a example:</p>\n\n<pre><code>add_filter('pre_get_posts', 'change_que...
2011/07/06
[ "https://wordpress.stackexchange.com/questions/22212", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6798/" ]
On the Reading Settings page I have clicked ***Your latest posts*** under ***Front page displays***. I am wondering how I can filter the query that displays these posts before it gets to the loop. I have tried to use the **pre\_get\_posts** filter but that does not seem to have access to this query. Is there anyway ...
``` <?php global $query_string; ?> <?php if (is_home()) query_posts($query_string . 'order=DESC&orderby=modified'); ?> ``` Try the above code in your index.php. Put it just above: ``` <?php if (have_posts()) : while (have_posts()) : the_post(); ?> ```
22,237
<p>I am using the below function to update the post meta from the front end. How can I add add best a textarea that updates <code>the_content()</code> using <a href="http://codex.wordpress.org/Function_Reference/wp_update_post" rel="noreferrer"><code>wp_update_post()</code></a>?</p> <pre><code>if ( isset( $_POST['albu...
[ { "answer_id": 23877, "author": "rocketman27", "author_id": 2647, "author_profile": "https://wordpress.stackexchange.com/users/2647", "pm_score": 2, "selected": true, "text": "<p>It depends on where you're using this. Is global $post giving you the specific post that you want to update? ...
2011/07/07
[ "https://wordpress.stackexchange.com/questions/22237", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1057/" ]
I am using the below function to update the post meta from the front end. How can I add add best a textarea that updates `the_content()` using [`wp_update_post()`](http://codex.wordpress.org/Function_Reference/wp_update_post)? ``` if ( isset( $_POST['albums'] ) && wp_verify_nonce($_POST['albums'],'update_albums_postme...
It depends on where you're using this. Is global $post giving you the specific post that you want to update? Your Wordpress update post code looks right to me, but is the if-statement valid, and is $post->ID yielding the correct int?
22,247
<p>Is there a way to display, via a PHP function, the author posts link (myblog.com/author/jason) of the current logged in user ?</p> <p>In fact, I would like to display, for every logged in user, a "My personnal page" link which links toward his author page.</p> <p>Thanks !</p>
[ { "answer_id": 22251, "author": "mike23", "author_id": 1381, "author_profile": "https://wordpress.stackexchange.com/users/1381", "pm_score": 2, "selected": false, "text": "<p>Try this :</p>\n\n<pre><code>&lt;a href=\"&lt;?php echo home_url() . '/author/' . get_the_author_meta( 'user_logi...
2011/07/06
[ "https://wordpress.stackexchange.com/questions/22247", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
Is there a way to display, via a PHP function, the author posts link (myblog.com/author/jason) of the current logged in user ? In fact, I would like to display, for every logged in user, a "My personnal page" link which links toward his author page. Thanks !
``` <?php global $current_user; get_currentuserinfo(); echo get_author_posts_url($current_user->ID); ?> ```
22,248
<p>I need to create a paid subscription directory where people can register their business and enter its details.</p> <p>Subscriptions should be paid on a monthly or yearly basis.</p> <p>Business details include typical fields such as: description, address, phone number, zip code, etc.</p> <p>The idea is that people...
[ { "answer_id": 22251, "author": "mike23", "author_id": 1381, "author_profile": "https://wordpress.stackexchange.com/users/1381", "pm_score": 2, "selected": false, "text": "<p>Try this :</p>\n\n<pre><code>&lt;a href=\"&lt;?php echo home_url() . '/author/' . get_the_author_meta( 'user_logi...
2011/07/06
[ "https://wordpress.stackexchange.com/questions/22248", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/129172/" ]
I need to create a paid subscription directory where people can register their business and enter its details. Subscriptions should be paid on a monthly or yearly basis. Business details include typical fields such as: description, address, phone number, zip code, etc. The idea is that people can create their user a...
``` <?php global $current_user; get_currentuserinfo(); echo get_author_posts_url($current_user->ID); ?> ```
22,257
<p>The question title says it all. Myself I just stick with the default code from one of the packaged templates that comes with WordPress out of the box:</p> <pre><code>&lt;title&gt;&lt;?php /* * Print the &lt;title&gt; tag based on what is being viewed. */ global $page, $paged; wp_title( '|', t...
[ { "answer_id": 22278, "author": "DOA", "author_id": 5859, "author_profile": "https://wordpress.stackexchange.com/users/5859", "pm_score": 1, "selected": false, "text": "<pre><code>&lt;title&gt;&lt;?php wp_title(''); ?&gt;&lt;?php if(wp_title('', false)) { echo ' :: '; } ?&gt;&lt;?php bl...
2011/07/07
[ "https://wordpress.stackexchange.com/questions/22257", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4610/" ]
The question title says it all. Myself I just stick with the default code from one of the packaged templates that comes with WordPress out of the box: ``` <title><?php /* * Print the <title> tag based on what is being viewed. */ global $page, $paged; wp_title( '|', true, 'right' ); // Add t...
Mine is: ``` function getDocumentTitle($separator = " &laquo; "){ $title = get_bloginfo('name'); $desc = get_bloginfo('description'); if(is_front_page() && is_home() && !empty($desc)){ $title .= $separator.$desc; }elseif(is_home() || is_singular()){ $id = $GLOBALS['wp_query']->get_quer...
22,260
<p>I'm pretty new to WordPress and I'm trying to customize my theme to send an email to myself when an upgrade is required. I'd rather not use a plugin as this means I have to install it for each WordPress site. The code below is based from the <a href="http://wordpress.org/extend/plugins/update-notifier" rel="nofollow...
[ { "answer_id": 22278, "author": "DOA", "author_id": 5859, "author_profile": "https://wordpress.stackexchange.com/users/5859", "pm_score": 1, "selected": false, "text": "<pre><code>&lt;title&gt;&lt;?php wp_title(''); ?&gt;&lt;?php if(wp_title('', false)) { echo ' :: '; } ?&gt;&lt;?php bl...
2011/07/07
[ "https://wordpress.stackexchange.com/questions/22260", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6824/" ]
I'm pretty new to WordPress and I'm trying to customize my theme to send an email to myself when an upgrade is required. I'd rather not use a plugin as this means I have to install it for each WordPress site. The code below is based from the [update notifier](http://wordpress.org/extend/plugins/update-notifier) plugin....
Mine is: ``` function getDocumentTitle($separator = " &laquo; "){ $title = get_bloginfo('name'); $desc = get_bloginfo('description'); if(is_front_page() && is_home() && !empty($desc)){ $title .= $separator.$desc; }elseif(is_home() || is_singular()){ $id = $GLOBALS['wp_query']->get_quer...
22,263
<p>i have a wordpress site that has more than 3000 pending and 0 spam comments. i want to identify and delete only spams. there are ways to delete all pending but i want to first identify spams and then delte them. There was no spam guard plugin earlier. I have just installed akismet. using wordpress 3.2. Please guide ...
[ { "answer_id": 22278, "author": "DOA", "author_id": 5859, "author_profile": "https://wordpress.stackexchange.com/users/5859", "pm_score": 1, "selected": false, "text": "<pre><code>&lt;title&gt;&lt;?php wp_title(''); ?&gt;&lt;?php if(wp_title('', false)) { echo ' :: '; } ?&gt;&lt;?php bl...
2011/07/07
[ "https://wordpress.stackexchange.com/questions/22263", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6028/" ]
i have a wordpress site that has more than 3000 pending and 0 spam comments. i want to identify and delete only spams. there are ways to delete all pending but i want to first identify spams and then delte them. There was no spam guard plugin earlier. I have just installed akismet. using wordpress 3.2. Please guide me.
Mine is: ``` function getDocumentTitle($separator = " &laquo; "){ $title = get_bloginfo('name'); $desc = get_bloginfo('description'); if(is_front_page() && is_home() && !empty($desc)){ $title .= $separator.$desc; }elseif(is_home() || is_singular()){ $id = $GLOBALS['wp_query']->get_quer...
22,268
<p>I know this is a vague question, please just spend time on it if you are in the mood, I don't need to be flamed for not being more precise.</p> <p>I'm having a problem with a theme I'm developing, for some reason it breaks the export function of WordPress.</p> <p>I'm not asking for anyone to solve my problems here...
[ { "answer_id": 22274, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": true, "text": "<p>The basic idea for debug here is that theme apparently influences something it totally should not. Either something i...
2011/07/07
[ "https://wordpress.stackexchange.com/questions/22268", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2071/" ]
I know this is a vague question, please just spend time on it if you are in the mood, I don't need to be flamed for not being more precise. I'm having a problem with a theme I'm developing, for some reason it breaks the export function of WordPress. I'm not asking for anyone to solve my problems here, but after havin...
The basic idea for debug here is that theme apparently influences something it totally should not. Either something is done in a wrong way or in a wrong place. 1. Check that theme is not running any functionality directly in `functions.php`. 2. Check that all of theme's functionality runs on appropriate hooks. 3. For ...
22,270
<p>I've got jwplayer installed in wordpress and have it showing in a single.php page... the way I have it I need to get a custom field in the javascript and I;m having no luck echoing it in there. I know you cant straight up run PHP in a javascript function, hence I'm here asking noob questions :)</p> <pre><code>&lt;s...
[ { "answer_id": 22275, "author": "tim", "author_id": 6791, "author_profile": "https://wordpress.stackexchange.com/users/6791", "pm_score": 0, "selected": false, "text": "<p>Echo out the JavaScript in your header.php file</p>\n\n<pre><code>&lt;?php \n\necho '&lt;script type=\"text/javascri...
2011/07/07
[ "https://wordpress.stackexchange.com/questions/22270", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5859/" ]
I've got jwplayer installed in wordpress and have it showing in a single.php page... the way I have it I need to get a custom field in the javascript and I;m having no luck echoing it in there. I know you cant straight up run PHP in a javascript function, hence I'm here asking noob questions :) ``` <script type='text/...
Have a read through this article: [Adding Scripts Properly to WordPress Part 2 – JavaScript Localization](http://weblogtoolscollection.com/archives/2010/05/07/adding-scripts-properly-to-wordpress-part-2-javascript-localization/) What you are doing here is passing your PHP values to the WordPress JS localization syste...
22,287
<p>I cannot upload the .webm video format on WordPress. This is after adding: AddType video/webm .webm</p> <p>into both: my .htaccess file (on the root folder of the WordPress installation) the mime type handler of our apache server (via our site cpanel)</p> <p>As far as i remember, at first this message instantly ga...
[ { "answer_id": 22288, "author": "Pablo Olmos de Aguilera C.", "author_id": 1055, "author_profile": "https://wordpress.stackexchange.com/users/1055", "pm_score": 0, "selected": false, "text": "<p>Are you using MU? Because I was having a similar problem; and it solved when I added the exte...
2010/08/16
[ "https://wordpress.stackexchange.com/questions/22287", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4700/" ]
I cannot upload the .webm video format on WordPress. This is after adding: AddType video/webm .webm into both: my .htaccess file (on the root folder of the WordPress installation) the mime type handler of our apache server (via our site cpanel) As far as i remember, at first this message instantly gave me the error, ...
On a multisite install, go to the Network Admin area and add the webm file extension to the allowed extensions list. On a single-site install, add this to your wp-config.php file: `define('ALLOW_UNFILTERED_UPLOADS',true);` That will allow administrator level users to upload files without the file type restrictions. ...
22,292
<p>I am trying to find a way to get the current page number of an article that has been splitted into several pages with the use of:</p> <pre><code>&lt;!-- nextpage --&gt; </code></pre> <p>There is an example that can be found here: <a href="http://codex.wordpress.org/Conditional_Tags#Testing_for_paginated_Pages" rel...
[ { "answer_id": 22309, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 3, "selected": true, "text": "<p>For multi-page posts:</p>\n\n<ul>\n<li>The <code>$page</code> global variable returns the current page of a ...
2011/07/07
[ "https://wordpress.stackexchange.com/questions/22292", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6832/" ]
I am trying to find a way to get the current page number of an article that has been splitted into several pages with the use of: ``` <!-- nextpage --> ``` There is an example that can be found here: <http://codex.wordpress.org/Conditional_Tags#Testing_for_paginated_Pages> But this doesn't work for me – it always r...
For multi-page posts: * The `$page` global variable returns the current page of a multi-page post. * The `$numpages` global variable returns the total number of pages in a multi-page post. For paginated archive index pages: * The `$paged` global variable returns the current page number of a paginated archive index. ...
22,296
<p>In my wordpress theme, I have a custom options panel with textareas that utilize the tinymce script included with wordpress.</p> <p>This was working fine until I upgraded to the latest version of wordpress (3.2). Now the editor still works, however it is removing all paragraph and line-break tags once I save my cod...
[ { "answer_id": 22303, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>You may need to use one of the following configuration parameters:</p>\n\n<pre><code>// Don't remove line b...
2011/07/07
[ "https://wordpress.stackexchange.com/questions/22296", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6560/" ]
In my wordpress theme, I have a custom options panel with textareas that utilize the tinymce script included with wordpress. This was working fine until I upgraded to the latest version of wordpress (3.2). Now the editor still works, however it is removing all paragraph and line-break tags once I save my code. While p...
You may need to use one of the following configuration parameters: ``` // Don't remove line breaks 'remove_linebreaks' => false; // Convert newline characters to BR tags 'convert_newlines_to_brs' => true; ``` WordPress passes an `$init` argument array to TinyMCE that sets the opposite value for each of these param...
22,302
<p>How can I remove the width and height attributes from the post_thumbnail when inserting with <code>&lt;?php the_post_thumbnail(); ?&gt;</code>?</p> <pre><code>&lt;img width="800" height="533" src="http://domain.com/wp-content/uploads/2011/02/image.jpg" class="attachment-post-thumbnail wp-post-image" /&gt; </code></...
[ { "answer_id": 22304, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": false, "text": "<p>you could just grab the url of the thumb and put it in an img tag yourself:</p>\n\n<pre><code>&lt;?php\n$thumbnail ...
2011/07/07
[ "https://wordpress.stackexchange.com/questions/22302", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2429/" ]
How can I remove the width and height attributes from the post\_thumbnail when inserting with `<?php the_post_thumbnail(); ?>`? ``` <img width="800" height="533" src="http://domain.com/wp-content/uploads/2011/02/image.jpg" class="attachment-post-thumbnail wp-post-image" /> ```
Related: [Filter to remove image dimension attributes?](https://wordpress.stackexchange.com/questions/5568/filter-to-remove-image-dimension-attributes) There's a filter on `post_thumbnail_html` which receives as its argument the full html element representing the post thumbnail image before it's echoed to the page. Yo...
22,305
<p>I have a question.</p> <p>I made a simply ajax function. When I'm logged in, it works perfectly. When I'm logged out, it returns me -1 (since Wordpress 3.1)</p> <p>Why ? I don't understand. Precisely, it returns -1 and my entire HTML code. (lol) I'm gonna be crazy again.</p> <p><strong>PHP (in functions.php)</str...
[ { "answer_id": 22318, "author": "t31os", "author_id": 31073, "author_profile": "https://wordpress.stackexchange.com/users/31073", "pm_score": 2, "selected": false, "text": "<p>Rarst said it worked for him both logged in and logged out, i can also confirm the same, here's my ugly test cod...
2011/07/07
[ "https://wordpress.stackexchange.com/questions/22305", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2000/" ]
I have a question. I made a simply ajax function. When I'm logged in, it works perfectly. When I'm logged out, it returns me -1 (since Wordpress 3.1) Why ? I don't understand. Precisely, it returns -1 and my entire HTML code. (lol) I'm gonna be crazy again. **PHP (in functions.php)** ``` function say_coucou(){ che...
**Found It!** I had done a redirect, so my ajax function status was 302... I deleted the redirect and it worked ! Thanks guys.
22,312
<p>I want to remove some characters from the slug, like "¿" that we use in spanish for opening a question.</p> <p>If I go to wp-includes/formatting.php and in</p> <pre><code>function sanitize_title_with_dashes($title) </code></pre> <p>line 820 wp32 I add this</p> <pre><code>$title = str_replace('¿', '', $title); </...
[ { "answer_id": 22316, "author": "Javier Villanueva", "author_id": 3893, "author_profile": "https://wordpress.stackexchange.com/users/3893", "pm_score": 0, "selected": false, "text": "<p>The problem is that the function <code>sanitize_title_with_dashes</code> doesn't use filters (which is...
2011/07/07
[ "https://wordpress.stackexchange.com/questions/22312", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3712/" ]
I want to remove some characters from the slug, like "¿" that we use in spanish for opening a question. If I go to wp-includes/formatting.php and in ``` function sanitize_title_with_dashes($title) ``` line 820 wp32 I add this ``` $title = str_replace('¿', '', $title); ``` just before $title = preg\_replace('|%(...
Following on from my comment on your question. The solution would be to hook your own filter onto the same functions `sanitize_title_with_dashes` does, in this case i think you're just aiming to hook onto `sanitize_title` as is done with `sanitize_title_with_dashes`. Simply ensure you hook on after `sanitize_title_wi...
22,324
<p>I'm using the WordPress <code>selected()</code> function to display the current option in a dropdown list. The issue I am having is that for some reason WordPress is printing out <code>selected='selected'</code> above the form in addition to in the actual <code>&lt;option&gt;</code> elements. This is how I am using ...
[ { "answer_id": 22326, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>Where are your PHP tags?</p>\n\n<pre><code>&lt;select name=\"gender\"&gt;\n&lt;option value=\"male\" &lt;?p...
2011/07/07
[ "https://wordpress.stackexchange.com/questions/22324", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6156/" ]
I'm using the WordPress `selected()` function to display the current option in a dropdown list. The issue I am having is that for some reason WordPress is printing out `selected='selected'` above the form in addition to in the actual `<option>` elements. This is how I am using the `selected()` function. ``` <select na...
The selected function causes immediate output, it does not return a string. Therefore you can't use it like that, in a string building mode. If you want it to return a string instead of immediately outputting the text, pass false to the $echo parameter. ``` $string = " <select name='gender'> <option value='male' " . ...
22,327
<p>In the parent theme, the following is at the bottom of the <strong>functions.php</strong> file.</p> <pre><code>require_once(TEMPLATEPATH . '/admin/admin-menu.php'); </code></pre> <p>In the child theme's <strong>function.php</strong>, this code will include the child admin panel.</p> <pre><code>require_once(STYLES...
[ { "answer_id": 22329, "author": "Otto", "author_id": 2232, "author_profile": "https://wordpress.stackexchange.com/users/2232", "pm_score": 4, "selected": true, "text": "<p>For cases where you want to require/include PHP files, but still allow child themes to replace those PHP files outri...
2011/07/07
[ "https://wordpress.stackexchange.com/questions/22327", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6000/" ]
In the parent theme, the following is at the bottom of the **functions.php** file. ``` require_once(TEMPLATEPATH . '/admin/admin-menu.php'); ``` In the child theme's **function.php**, this code will include the child admin panel. ``` require_once(STYLESHEETPATH . '/admin/admin-menu.php'); ``` As you can see, I sh...
For cases where you want to require/include PHP files, but still allow child themes to replace those PHP files outright, then you should use the locate\_template function. Example: Parent does this: `locate_template( 'admin/file.php', true );` This finds the admin/file.php file in either the child or the parent them...
22,335
<p>I'm trying to make <a href="http://yoast.com/custom-rss-feeds-wordpress/" rel="nofollow noreferrer">Yoast's Custom RSS feeds</a> post display in an add_feed function. </p> <p>Just putting Yoast's snippet inside add_feed results in: </p> <blockquote> <p>ERROR: feedname is not a valid feed template.</p> </blockquo...
[ { "answer_id": 22337, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>First, correct way is to use <a href=\"http://codex.wordpress.org/Rewrite_API/add_feed\" rel=\"nofollow\"><code>add_...
2011/07/07
[ "https://wordpress.stackexchange.com/questions/22335", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1057/" ]
I'm trying to make [Yoast's Custom RSS feeds](http://yoast.com/custom-rss-feeds-wordpress/) post display in an add\_feed function. Just putting Yoast's snippet inside add\_feed results in: > > ERROR: feedname is not a valid feed template. > > > I have tried two rewrite functions, but to no avail. What could I ...
You have `add_feed('feedname', 'my_feed');` but no my\_feed function to actually generate the feed output. Create a my\_feed function and have it call the template to generate the feed output. Like this: ``` function my_feed() { include 'path-to-that-template-file.php'; } add_feed('feedname','my_feed'); ``` Then...
22,341
<p>Hallo,</p> <p>I have in my blog now add a Plugin [Custom Post Type UI] and have great a Post type movies and taxonomies like genre,actors,directer..... like this all ok now i have great a test post min add Movie and add info now come my big problem it show noting in post just a error</p> <blockquote> <p>Catchabl...
[ { "answer_id": 22412, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>Essentially somewhere in that code one of function fails to do what it should and informs about that by returning ob...
2011/07/07
[ "https://wordpress.stackexchange.com/questions/22341", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6844/" ]
Hallo, I have in my blog now add a Plugin [Custom Post Type UI] and have great a Post type movies and taxonomies like genre,actors,directer..... like this all ok now i have great a test post min add Movie and add info now come my big problem it show noting in post just a error > > Catchable fatal error: Object of cl...
``` $cat = $cat[0]->cat_ID; ``` of course if $cat is not empty
22,344
<p>I just moved a site (by exporting &amp; importing all posts &amp; pages, and copying theme files over), and on the new site the various page and post templates are unavailable for selection on post and page edit screens.</p> <p>The files did have Windows line endings, which I fixed, but that did not eliminate the p...
[ { "answer_id": 22884, "author": "Lucas", "author_id": 6565, "author_profile": "https://wordpress.stackexchange.com/users/6565", "pm_score": 0, "selected": false, "text": "<p>I'd try this... delete it then reupload it.</p>\n" }, { "answer_id": 22886, "author": "markratledge", ...
2011/07/07
[ "https://wordpress.stackexchange.com/questions/22344", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49/" ]
I just moved a site (by exporting & importing all posts & pages, and copying theme files over), and on the new site the various page and post templates are unavailable for selection on post and page edit screens. The files did have Windows line endings, which I fixed, but that did not eliminate the problem. Any other ...
Sounds like it could be an issue with the database and serialization of the plugin options. I've had problems before with plugin settings etc when moving a site using the xml export. The category templates plugin writes a lot of options to the db and they could be corrupted. As a test try creating a php file and putti...
22,348
<p>I've created a custom post, <code>events</code>, and saved the meta data <code>event_year</code> to each event. I'm trying to get a year's event archive. When I go the the following URL, the <code>meta_key</code> and <code>meta_value</code> are not set for some reason, and thus the event archive is unfiltered.</p>...
[ { "answer_id": 22349, "author": "scribu", "author_id": 205, "author_profile": "https://wordpress.stackexchange.com/users/205", "pm_score": 3, "selected": true, "text": "<p>That's because 'meta_key' and 'meta_value' are not public query vars. In other words, you can't use them in URLs dir...
2011/07/07
[ "https://wordpress.stackexchange.com/questions/22348", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6843/" ]
I've created a custom post, `events`, and saved the meta data `event_year` to each event. I'm trying to get a year's event archive. When I go the the following URL, the `meta_key` and `meta_value` are not set for some reason, and thus the event archive is unfiltered. ``` /?post_type=events&meta_key=event_year&meta_val...
That's because 'meta\_key' and 'meta\_value' are not public query vars. In other words, you can't use them in URLs directly, nor should you. Instead, register a specific query var, like so: ``` function register_my_qv() { global $wp; $wp->add_query_var( 'my_qv' ); } add_action( 'init', 'register_my_qv' ); ``` T...
22,352
<p>I'd like to force a user to a specific page upon login based on their role using</p> <pre><code>if ( current_user_can('contributor') ) </code></pre> <p>and the main login function</p> <pre><code>function wp_loginout($redirect = '', $echo = true) { if ( ! is_user_logged_in() ) $link = '&lt;a href="' . ...
[ { "answer_id": 22357, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 4, "selected": true, "text": "<p>filter <code>login_redirect</code>:</p>\n\n<pre><code>function my_login_redirect_contributors() {\n if ( current_us...
2011/07/07
[ "https://wordpress.stackexchange.com/questions/22352", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3296/" ]
I'd like to force a user to a specific page upon login based on their role using ``` if ( current_user_can('contributor') ) ``` and the main login function ``` function wp_loginout($redirect = '', $echo = true) { if ( ! is_user_logged_in() ) $link = '<a href="' . esc_url( wp_login_url(get_permalink()) )...
filter `login_redirect`: ``` function my_login_redirect_contributors() { if ( current_user_can('contributor') ){ return 'url-to-redirect-to'; } } add_filter('login_redirect', 'my_login_redirect_contributors'); ```
22,354
<p>I have a plugin that will allow administrators to perform certain actions when adding or editing a post. I use a stylesheet and a javascript for this plugin that I want to include <em>only</em> when a post is being added or edited. Am I right to use the following action hooks?</p> <pre><code>add_action('load-post...
[ { "answer_id": 22356, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": false, "text": "<p>you want to use <code>admin_print_scripts-(page_hook)</code> and <code>admin_print_styles-(page_hook)</code>, so in...
2011/07/07
[ "https://wordpress.stackexchange.com/questions/22354", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6847/" ]
I have a plugin that will allow administrators to perform certain actions when adding or editing a post. I use a stylesheet and a javascript for this plugin that I want to include *only* when a post is being added or edited. Am I right to use the following action hooks? ``` add_action('load-post.php', 'call_my_functio...
you want to use `admin_print_scripts-(page_hook)` and `admin_print_styles-(page_hook)`, so in your case: ``` add_action('admin_print_scripts-post.php', 'call_my_function'); add_action('admin_print_scripts-post-new.php', 'call_my_function'); add_action('admin_print_styles-post.php', 'call_my_styles_function'); add_act...
22,368
<p>Under "Personal Options" on user profile page, there are: (1) disable visual editor (2) admin color scheme (3) keyboard shortcuts (4) show admin bar</p> <p>I can remove admin color scheme using remove_action, but not the rest.</p> <p>Is there a way to remove them all at once? Or one by one using remove_action or s...
[ { "answer_id": 22369, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": 1, "selected": false, "text": "<p>This might not be the most elegant solution, but it works. I made a simple plug-in for customizing the Word...
2011/07/08
[ "https://wordpress.stackexchange.com/questions/22368", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6851/" ]
Under "Personal Options" on user profile page, there are: (1) disable visual editor (2) admin color scheme (3) keyboard shortcuts (4) show admin bar I can remove admin color scheme using remove\_action, but not the rest. Is there a way to remove them all at once? Or one by one using remove\_action or style or js?
I think this is the kind of thing you had in mind. ``` add_action( 'admin_print_styles-profile.php', 'remove_profile_fields' ); add_action( 'admin_print_styles-user-edit.php', 'remove_profile_fields' ); function remove_profile_fields( $hook ) { ?> <style type="text/css"> form#your-profile p+h3, ...
22,381
<p>I want to remove the below text links in Edit Post screen:</p> <p>All (8) | Published (5) | Draft (1) | Pending (2) | Trash (2)</p> <p>After searching, i found that this can be done by this code <a href="http://code.garyjones.co.uk/remove-post-views-from-wordpress/" rel="nofollow">here</a>, but sadly it only works...
[ { "answer_id": 22414, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 4, "selected": true, "text": "<p>Further down on the page you linked to is this comment:</p>\n\n<blockquote>\n <p>Similar views can be edited by hooki...
2011/07/08
[ "https://wordpress.stackexchange.com/questions/22381", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6783/" ]
I want to remove the below text links in Edit Post screen: All (8) | Published (5) | Draft (1) | Pending (2) | Trash (2) After searching, i found that this can be done by this code [here](http://code.garyjones.co.uk/remove-post-views-from-wordpress/), but sadly it only works with 'post' type. I'm failed to make it wo...
Further down on the page you linked to is this comment: > > Similar views can be edited by hooking into 'views\_' . $screen->id where $screen is the global $current\_screen (or get\_current\_screen()). Draft, Pending, Mine and Sticky could all be removed in a similar manner. > > > When you're editing a post, you'...
22,386
<p>Would it be possible to make the link post format work the way links are shared in Facebook, i.e. auto-populate a title, description, and thumbnail?</p> <p>A plugin for BuddyPress (<a href="http://wordpress.org/extend/plugins/buddypress-links/" rel="nofollow">Buddypress Links</a>, see screenshots) makes this possib...
[ { "answer_id": 49938, "author": "David K.", "author_id": 7249, "author_profile": "https://wordpress.stackexchange.com/users/7249", "pm_score": 1, "selected": false, "text": "<p>Grab whatever Meta information you like:</p>\n\n<pre><code>&lt;?php\n $tags = get_meta_tags('http://www.cnn.co...
2011/07/08
[ "https://wordpress.stackexchange.com/questions/22386", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6864/" ]
Would it be possible to make the link post format work the way links are shared in Facebook, i.e. auto-populate a title, description, and thumbnail? A plugin for BuddyPress ([Buddypress Links](http://wordpress.org/extend/plugins/buddypress-links/), see screenshots) makes this possible for community links... any ideas ...
I have a class i coded when i was first played around with the WordPress HTTP API Which does just about what you need: ``` <?php /** * WebPage_Info class * * @version 0.1 * @author Ohad Raz <admin@bainternet.info> * @package WebPage_Info * @copyright Ohad Raz 2011 * */ if (!class_exists('webpage_info'...
22,394
<p>What happens, when I click <code>Save Changes</code> on a option page, which was created by <code>add_menu_page()</code>? Where is the submitted data stored <em>before</em> the database transmission?</p> <p>A <code>print_r($_REQUEST)</code> returns only the two <code>$_GET</code> parameters <code>page</code> and <c...
[ { "answer_id": 22397, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": false, "text": "<p>You only need <em>one</em> callback function, as defined in your call to <code>register_setting()</code> (<...
2011/07/08
[ "https://wordpress.stackexchange.com/questions/22394", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3817/" ]
What happens, when I click `Save Changes` on a option page, which was created by `add_menu_page()`? Where is the submitted data stored *before* the database transmission? A `print_r($_REQUEST)` returns only the two `$_GET` parameters `page` and `settings-updated`. I've checked the manual for `add_settings_field` and ...
I've finally found my fault. The "problem" with `Zend_View` and `Zend_Form` is, that you have to check and save the submitted settings by yourself. But if you register a sanitize hook with `register_setting()`, WordPress will indeed not return any `$_POST` array and will immediatly submit the data to the defined opti...
22,399
<p>I use this in <code>functions.php</code> to change "<em>howdy</em>" to "<em>Logged in as....</em>" But now under 3.1 I get "<em>Logged in as Your Profile</em>" rather than "<em>Logged in as <code>&lt;current user&gt;</code>"</em></p> <p>What needs to be changed so that "user" below (commented below as <code>//get c...
[ { "answer_id": 22402, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 1, "selected": false, "text": "<pre><code>if (is_admin()) {\n add_action('init', 'better_howdy_h');\n add_action('admin_footer', 'better_howdy_...
2011/07/08
[ "https://wordpress.stackexchange.com/questions/22399", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/268/" ]
I use this in `functions.php` to change "*howdy*" to "*Logged in as....*" But now under 3.1 I get "*Logged in as Your Profile*" rather than "*Logged in as `<current user>`"* What needs to be changed so that "user" below (commented below as `//get current user?)` returns the current user in 3.1? ``` if (is_admin()) { ...
Why fiddle around with jQuery when you could just run a filter on `gettext` to specifically target that text? Perhaps you simply don't know you can do that, so here's how.. ``` add_filter( 'gettext', 'change_howdy_text', 10, 2 ); function change_howdy_text( $translation, $original ) { if( 'Howdy, %1$s' == $origina...
22,407
<p>I'd like to be able to have a workflow that works like so:</p> <ol> <li>Create a post and assign it a password</li> <li>Have a single-field form on the home page</li> <li>User enters password on home page, and is sent to the corresponding post</li> </ol> <p>Does anyone know if this is possible?</p>
[ { "answer_id": 22409, "author": "anu", "author_id": 490, "author_profile": "https://wordpress.stackexchange.com/users/490", "pm_score": 2, "selected": false, "text": "<p>Yes, but you'll need to hold the details of how a password maps to a post.</p>\n\n<p>So:</p>\n\n<ul>\n<li>store mappin...
2011/07/08
[ "https://wordpress.stackexchange.com/questions/22407", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49/" ]
I'd like to be able to have a workflow that works like so: 1. Create a post and assign it a password 2. Have a single-field form on the home page 3. User enters password on home page, and is sent to the corresponding post Does anyone know if this is possible?
Thanks to Tom's help, here's what I ended up with. This uses the built in functionality for password-protecting a post, so a visitor only has to enter a password on the home page, then they are taken to the post and are able to directly view the post content without re-entering the password. On home page: ``` <form m...
22,415
<p>I've been trying to get the TinyMCE editor working in the comments field but I've been unable to do so. Another suggestion I found was <a href="http://nicedit.com" rel="nofollow">http://nicedit.com</a>, the editor is working but the comments are not saved in rich text.</p> <p>TinyMCEComments seems to do it but hasn...
[ { "answer_id": 22409, "author": "anu", "author_id": 490, "author_profile": "https://wordpress.stackexchange.com/users/490", "pm_score": 2, "selected": false, "text": "<p>Yes, but you'll need to hold the details of how a password maps to a post.</p>\n\n<p>So:</p>\n\n<ul>\n<li>store mappin...
2011/07/08
[ "https://wordpress.stackexchange.com/questions/22415", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4284/" ]
I've been trying to get the TinyMCE editor working in the comments field but I've been unable to do so. Another suggestion I found was <http://nicedit.com>, the editor is working but the comments are not saved in rich text. TinyMCEComments seems to do it but hasn't been updated in a while, it's not working for 3.2. D...
Thanks to Tom's help, here's what I ended up with. This uses the built in functionality for password-protecting a post, so a visitor only has to enter a password on the home page, then they are taken to the post and are able to directly view the post content without re-entering the password. On home page: ``` <form m...
22,416
<p>There are several threads on Wordpress.org about this problem, but none with solutions. I just went from localhost (MAMP) to a live server (Dreamhost) and I'm getting constant 404s when submitting actions (such as changing a title) or trying to load pages in the admin (such as post/page/cpt lists).</p> <p>The probl...
[ { "answer_id": 22409, "author": "anu", "author_id": 490, "author_profile": "https://wordpress.stackexchange.com/users/490", "pm_score": 2, "selected": false, "text": "<p>Yes, but you'll need to hold the details of how a password maps to a post.</p>\n\n<p>So:</p>\n\n<ul>\n<li>store mappin...
2011/07/08
[ "https://wordpress.stackexchange.com/questions/22416", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3564/" ]
There are several threads on Wordpress.org about this problem, but none with solutions. I just went from localhost (MAMP) to a live server (Dreamhost) and I'm getting constant 404s when submitting actions (such as changing a title) or trying to load pages in the admin (such as post/page/cpt lists). The problem is WP i...
Thanks to Tom's help, here's what I ended up with. This uses the built in functionality for password-protecting a post, so a visitor only has to enter a password on the home page, then they are taken to the post and are able to directly view the post content without re-entering the password. On home page: ``` <form m...
22,438
<p>I use WordPress as a CMS.</p> <p>I need to show page instead of category when they have same slug.</p> <ul> <li>I have category called "vertical machining centers" with the slug "vertical-machining-centers"</li> </ul> <p>This category is ranking in the second page in google and I want to optimize more. So I creat...
[ { "answer_id": 22481, "author": "Jan Fabry", "author_id": 8, "author_profile": "https://wordpress.stackexchange.com/users/8", "pm_score": 5, "selected": true, "text": "<p>You will need to enable <em>verbose page rules</em>, which make sure that all pages are explicitly defined (instead o...
2011/07/08
[ "https://wordpress.stackexchange.com/questions/22438", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6876/" ]
I use WordPress as a CMS. I need to show page instead of category when they have same slug. * I have category called "vertical machining centers" with the slug "vertical-machining-centers" This category is ranking in the second page in google and I want to optimize more. So I create a page.. So as you see the page...
You will need to enable *verbose page rules*, which make sure that all pages are explicitly defined (instead of using a generic rule). But in addition to that, you need to move these page rules above the taxonomy rules. This is [a fairly recent change](http://core.trac.wordpress.org/changeset/15825), I believe it was b...
22,453
<p>I have a custom post type set up with the following in my functions.php. The problem is that the post thumbnail box doesn't show up in the dashboard in the "Talent" section even after I specified <code>'supports' =&gt; array('title','editor','thumbnail'),</code>. Is there something I'm missing?</p> <p><code>add_the...
[ { "answer_id": 22455, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>Try changing this:</p>\n\n<pre><code>add_theme_support( 'post-thumbnails', array( 'post' ) );\n</code></pre...
2011/07/08
[ "https://wordpress.stackexchange.com/questions/22453", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6880/" ]
I have a custom post type set up with the following in my functions.php. The problem is that the post thumbnail box doesn't show up in the dashboard in the "Talent" section even after I specified `'supports' => array('title','editor','thumbnail'),`. Is there something I'm missing? `add_theme_support( 'post-thumbnails'...
Try changing this: ``` add_theme_support( 'post-thumbnails', array( 'post' ) ); ``` to this: ``` add_theme_support( 'post-thumbnails' ); ``` IIRC, that array is *explicit*, meaning that by including *only* `post`, everything else is *excluded*. But if you omit the array, then post-thumbnail support is added for a...
22,461
<p>How could wp-query be used to show posts month by month, and have it only show the past year? Or is it possible some wp_archive hack could handle this?</p>
[ { "answer_id": 22465, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 2, "selected": false, "text": "<p>Well it's not a hack it's a function. You can simply use <code>wp_get_archives</code> </p>\n\n<p><a href=\"http://c...
2011/07/09
[ "https://wordpress.stackexchange.com/questions/22461", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6886/" ]
How could wp-query be used to show posts month by month, and have it only show the past year? Or is it possible some wp\_archive hack could handle this?
Well it's not a hack it's a function. You can simply use `wp_get_archives` <http://codex.wordpress.org/Function_Reference/wp_get_archives> Alternatively you can use a `wp_query` with a time format for actual content, for instance, ``` //December $query = new WP_Query( 'monthnum=12' ); ``` <http://codex.wordpress...
22,472
<p>I am looking for a solution to returning multiple get_post_meta values...</p> <p>Current I am using a meta box array as follows:</p> <pre><code>$meta_boxes[] = array( 'id' =&gt; 'setlist', 'title' =&gt; 'Setlist Information', 'pages' =&gt; array('post'), 'fields' =&gt; array( array( 'name' =&gt; 'Setli...
[ { "answer_id": 22465, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 2, "selected": false, "text": "<p>Well it's not a hack it's a function. You can simply use <code>wp_get_archives</code> </p>\n\n<p><a href=\"http://c...
2011/07/09
[ "https://wordpress.stackexchange.com/questions/22472", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6423/" ]
I am looking for a solution to returning multiple get\_post\_meta values... Current I am using a meta box array as follows: ``` $meta_boxes[] = array( 'id' => 'setlist', 'title' => 'Setlist Information', 'pages' => array('post'), 'fields' => array( array( 'name' => 'Setlist 1', // field n...
Well it's not a hack it's a function. You can simply use `wp_get_archives` <http://codex.wordpress.org/Function_Reference/wp_get_archives> Alternatively you can use a `wp_query` with a time format for actual content, for instance, ``` //December $query = new WP_Query( 'monthnum=12' ); ``` <http://codex.wordpress...
22,505
<p>I have a template set up and I've created a page in WordPress and have chosen the corresponding template in the drop down. I have created templates for several pages of this site and they've all worked fine; however, this one template is causing problems. WordPress keeps fetching the archive page for some reason. Th...
[ { "answer_id": 40029, "author": "Neil Davidson", "author_id": 12426, "author_profile": "https://wordpress.stackexchange.com/users/12426", "pm_score": 1, "selected": false, "text": "<p>The most basic approach to this is to do what I do: when building template pages I precede them with \"...
2011/07/09
[ "https://wordpress.stackexchange.com/questions/22505", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6906/" ]
I have a template set up and I've created a page in WordPress and have chosen the corresponding template in the drop down. I have created templates for several pages of this site and they've all worked fine; however, this one template is causing problems. WordPress keeps fetching the archive page for some reason. The e...
My issue was `research` was not using `page-research.php` but instead using `archive.php` I resolved it not by the "Static Pages and Custom Post Types cannot have the same slug" solution, but on the dashboard in Settings -> Permalinks. It was on "Day and name" and I changed it to "Numeric" and the research page load...
22,511
<p>I'm creating a very basic Wordpress plugin whose purpose is to display a numerical value beside each post.</p> <p>My Logic for the plugin function (<strong>plugin.php</strong>) is this:</p> <pre><code>&lt;?php function foo($post_id){ $somevalue=1 //Some random value add_post_meta($post_id, 'posts_numericalvalue', ...
[ { "answer_id": 28393, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 2, "selected": true, "text": "<p>When hooking the save_post action, you really need to isolate your operations so that every page/post/post_t...
2011/07/09
[ "https://wordpress.stackexchange.com/questions/22511", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4746/" ]
I'm creating a very basic Wordpress plugin whose purpose is to display a numerical value beside each post. My Logic for the plugin function (**plugin.php**) is this: ``` <?php function foo($post_id){ $somevalue=1 //Some random value add_post_meta($post_id, 'posts_numericalvalue', '0', true) or update_post_meta($_post...
When hooking the save\_post action, you really need to isolate your operations so that every page/post/post\_type save doesn't try to add your post meta to the post. ``` function foo_save(){ if(isset($_REQUEST['bar') update_post_meta($_REQUEST['post_ID'], 'bar', $_REQUEST['bar']); } add_action('save_post',...
22,517
<p>I'm trying to create a taxonomy that is sort of hidden.. meaning i intend to adjust the metabox so that you can only select a unique term from 3 options. "featured","normal" or "excluded". but i can't figure out how to remove the administration menu.</p> <p>the following removes the Tags menu item from underneath...
[ { "answer_id": 38400, "author": "benz001", "author_id": 11864, "author_profile": "https://wordpress.stackexchange.com/users/11864", "pm_score": 4, "selected": false, "text": "<p>You can use <code>remove_submenu_page()</code>, but getting the submenu slug correct is tricky and it has to b...
2011/07/09
[ "https://wordpress.stackexchange.com/questions/22517", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6477/" ]
I'm trying to create a taxonomy that is sort of hidden.. meaning i intend to adjust the metabox so that you can only select a unique term from 3 options. "featured","normal" or "excluded". but i can't figure out how to remove the administration menu. the following removes the Tags menu item from underneath Posts: ```...
following Bainternet's comment, i registered the taxonomy without showing any of the UI elements ``` add_action( 'init', 'kia_register_featured_tax', 0 ); function kia_register_featured_tax(){ if(!taxonomy_exists('portfolio_featured')){ $labels = array( 'name' => _x( 'Featured', $this->plugin_...
22,524
<p>I'm trying to use Custom Field types to embed Youtube videos in a more organized fashion and using the Do_Shortcode() would seem to work perfectly, however this:</p> <pre><code>&lt;?php echo do_shortcode('[embed]http://www.youtube.com/watch?v=K0M09Ws8vpc&amp;feature=player_embedded[/embed]'); ?&gt; </code></pre> <...
[ { "answer_id": 23181, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 3, "selected": false, "text": "<p>Your code should work, possibly an idea for a trac ticket.</p>\n\n<p>In the meantime you can try:</p>\n\n<pre><code...
2011/07/09
[ "https://wordpress.stackexchange.com/questions/22524", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6910/" ]
I'm trying to use Custom Field types to embed Youtube videos in a more organized fashion and using the Do\_Shortcode() would seem to work perfectly, however this: ``` <?php echo do_shortcode('[embed]http://www.youtube.com/watch?v=K0M09Ws8vpc&feature=player_embedded[/embed]'); ?> ``` Does not seem to work, however in...
Simply put `[embed]` is not a regular shortcode. Most of the time it does nothing. What happens when post content goes through `the_content` filter is following: 1. `[emded]` is currently registered to do nothing ( `__return_false()` ) 2. `WP_Embed->run_shortcode()` filter runs with low `8` priority 3. all shortcodes ...
22,526
<p>Are there any hosting companies out there that cater to users who want to utilize TLD domain mapping and WordPress Multisite? Or will you have to go the route of building, configuring, and maintaing your own server configuration with a service provider, like SliceHost?</p>
[ { "answer_id": 23181, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 3, "selected": false, "text": "<p>Your code should work, possibly an idea for a trac ticket.</p>\n\n<p>In the meantime you can try:</p>\n\n<pre><code...
2011/07/10
[ "https://wordpress.stackexchange.com/questions/22526", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3736/" ]
Are there any hosting companies out there that cater to users who want to utilize TLD domain mapping and WordPress Multisite? Or will you have to go the route of building, configuring, and maintaing your own server configuration with a service provider, like SliceHost?
Simply put `[embed]` is not a regular shortcode. Most of the time it does nothing. What happens when post content goes through `the_content` filter is following: 1. `[emded]` is currently registered to do nothing ( `__return_false()` ) 2. `WP_Embed->run_shortcode()` filter runs with low `8` priority 3. all shortcodes ...
22,527
<p>I'm trying to use my category.php file to display all posts of a certain custom post type (say "Company") with a given category. However, when I try to use it by navigating to domain.com/category/company/category1, which is the link automatically generated by wp_list_categories(), no posts appear.</p> <p>The code I...
[ { "answer_id": 22530, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 0, "selected": false, "text": "<p>Are you using the core <code>category</code> taxonomy, by applying it to your Custom Post Type, or have you...
2011/07/10
[ "https://wordpress.stackexchange.com/questions/22527", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6389/" ]
I'm trying to use my category.php file to display all posts of a certain custom post type (say "Company") with a given category. However, when I try to use it by navigating to domain.com/category/company/category1, which is the link automatically generated by wp\_list\_categories(), no posts appear. The code I'm using...
I figured it out! For anyone having the same problem, I solved it by adding ``` $cat_id = get_query_var('cat'); query_posts("post_type=company&cat=$cat_id"); ``` right in front of the loop. Anyone having the same problem would probably also benefit from looking at [this](http://www.slideshare.net/williamsba/custom...
22,535
<p>I am trying to integrate the <a href="http://jquery-ui.googlecode.com/svn/branches/labs/selectmenu/index.html" rel="nofollow">Jquery UI select menu</a> ("dropdown" Style), in my wordpress site.</p> <p>But I am not able to do it, in widget area I created a select box and gave it respective ID of that css and jquery,...
[ { "answer_id": 22536, "author": "Javier Villanueva", "author_id": 3893, "author_profile": "https://wordpress.stackexchange.com/users/3893", "pm_score": 0, "selected": false, "text": "<p>Try using <code>jQuery</code> instead of <code>JQuery</code></p>\n" }, { "answer_id": 22551, ...
2011/07/10
[ "https://wordpress.stackexchange.com/questions/22535", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1743/" ]
I am trying to integrate the [Jquery UI select menu](http://jquery-ui.googlecode.com/svn/branches/labs/selectmenu/index.html) ("dropdown" Style), in my wordpress site. But I am not able to do it, in widget area I created a select box and gave it respective ID of that css and jquery, but its not getting loaded with jqu...
This works for me locally in testing.. ``` add_action('wp_enqueue_scripts','enq_menu_scripts_and_styles'); function enq_menu_scripts_and_styles() { // UI Core, loads jQuery as a dependancy wp_enqueue_script( 'uicore', 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js', ...
22,537
<p>I am using Gravity Forms to allow users to create posts from the front end.</p> <p>However, the way this site I am building is going to work, one specific Post_Type is essentially just a "Data" post. There is a specific Taxonomy who's Terms are actually the "Title" of the data set. </p> <p>I have already figured...
[ { "answer_id": 22540, "author": "Manny Fleurmond", "author_id": 2234, "author_profile": "https://wordpress.stackexchange.com/users/2234", "pm_score": 1, "selected": false, "text": "<p>I've pieced together a solution. Let me know if it's what you need:</p>\n\n<pre><code>add_filter('the_t...
2011/07/10
[ "https://wordpress.stackexchange.com/questions/22537", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3247/" ]
I am using Gravity Forms to allow users to create posts from the front end. However, the way this site I am building is going to work, one specific Post\_Type is essentially just a "Data" post. There is a specific Taxonomy who's Terms are actually the "Title" of the data set. I have already figured out a way to hide...
Well, since I essentially came up with my own answer using what was posted (which didn't really work) plus some extra research, I am going to close this question, even though I sort of added an additional question; OK, using code from @Manny Fleurmond below, and from this post: Title\_save\_pre - Simple problem that u...
22,539
<p>I'm working on a custom dropline menu using wp_nav_menu.</p> <p>Using <code>wp_nav_menu( array( 'theme_location' =&gt; 'primary', 'after' =&gt; '|' ) );</code>, I can put separators after every item. However, I'm only wanting them after the child items in the sub-menu. </p> <p>Is there any way I can be more specif...
[ { "answer_id": 23745, "author": "aendra", "author_id": 1682, "author_profile": "https://wordpress.stackexchange.com/users/1682", "pm_score": 0, "selected": false, "text": "<p>For a similar project, I used a single line of jQuery to selectively add spacers:</p>\n\n<pre><code>jQuery('ul#me...
2011/07/10
[ "https://wordpress.stackexchange.com/questions/22539", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1682/" ]
I'm working on a custom dropline menu using wp\_nav\_menu. Using `wp_nav_menu( array( 'theme_location' => 'primary', 'after' => '|' ) );`, I can put separators after every item. However, I'm only wanting them after the child items in the sub-menu. Is there any way I can be more specific about which items have separa...
Why not use a purely CSS-based solution, using the `:after` pseudo-element? e.g. ``` #nav li li a:after { content: '|'; } ```
22,543
<p>For example:</p> <p><code>site.com/contact</code> (or <code>site.com/?page=contact</code> if not using permalinks)</p> <p>when someone goes to that page I want to load a theme template, like <code>page-contact.php</code></p> <p>But I don't want to create a page in the dashboard for this work. How can I do this in...
[ { "answer_id": 22561, "author": "danielwiener", "author_id": 6817, "author_profile": "https://wordpress.stackexchange.com/users/6817", "pm_score": 0, "selected": false, "text": "<p>You can do this just as you said. It is built into the template hierarchy of Wordpress since 2.9.</p>\n\n<p...
2011/07/10
[ "https://wordpress.stackexchange.com/questions/22543", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6914/" ]
For example: `site.com/contact` (or `site.com/?page=contact` if not using permalinks) when someone goes to that page I want to load a theme template, like `page-contact.php` But I don't want to create a page in the dashboard for this work. How can I do this internally, within functions.php ? I know it's possible be...
This is the technique I'm using on a site right now. It involves registering a query var for "template", and registering an endpoint called `/contact`, which rewrites internally to `?template=contact`. Then you just check for that query variable at the template\_redirect hook, and if its present, include the page templ...
22,549
<p>Wordpress changed quite a bit from 3.1 to 3.2. I have played for an hour to find the plugin section but not success. Usually they would be on the left hand side in the menu. Now they are not there. Anyone knows where to find them and how to install them on xyz.wordpress site?</p> <p>This image is from 3.1. Plugin o...
[ { "answer_id": 22561, "author": "danielwiener", "author_id": 6817, "author_profile": "https://wordpress.stackexchange.com/users/6817", "pm_score": 0, "selected": false, "text": "<p>You can do this just as you said. It is built into the template hierarchy of Wordpress since 2.9.</p>\n\n<p...
2011/07/10
[ "https://wordpress.stackexchange.com/questions/22549", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6944/" ]
Wordpress changed quite a bit from 3.1 to 3.2. I have played for an hour to find the plugin section but not success. Usually they would be on the left hand side in the menu. Now they are not there. Anyone knows where to find them and how to install them on xyz.wordpress site? This image is from 3.1. Plugin option is s...
This is the technique I'm using on a site right now. It involves registering a query var for "template", and registering an endpoint called `/contact`, which rewrites internally to `?template=contact`. Then you just check for that query variable at the template\_redirect hook, and if its present, include the page templ...
22,555
<p>I was exploring and ran across this post: <a href="https://wordpress.stackexchange.com/questions/22423/grab-first-link-from-a-post-grab-first-blockquote">https://wordpress.stackexchange.com/questions/22423/grab-first-link-from-a-post-grab-first-blockquote</a></p> <p>I would basically like to do the same thing, but ...
[ { "answer_id": 22647, "author": "Lucas", "author_id": 6565, "author_profile": "https://wordpress.stackexchange.com/users/6565", "pm_score": 0, "selected": false, "text": "<p>I'm actually trying to do this too.</p>\n\n<p>The following code calls up the link, but not like you're asking (wi...
2011/07/10
[ "https://wordpress.stackexchange.com/questions/22555", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6902/" ]
I was exploring and ran across this post: <https://wordpress.stackexchange.com/questions/22423/grab-first-link-from-a-post-grab-first-blockquote> I would basically like to do the same thing, but have it call not only the URL but also the link, since I am using the link as an excerpt title. For example; if my link is ...
maybe try with php [DOMDocument](http://php.net/manual/en/class.domdocument.php) rather than regex. I don't think all DOMDocument methods will work with just an html fragment and not a complete document, but for your needs it may be enough: ``` <?php $dom= new DOMDocument(); $html = '<p>Some html with a <a href="http:...
22,577
<p>I know how to keep track on the 'index' of the current post when running the loop using</p> <pre><code>$wp_query-&gt;current_post </code></pre> <p>Bu this restarts the count from zero on subsequent paged pages. So if I have 20 posts, and show 5 posts per page, then on page 2 the posts are again numbered 0-4 instea...
[ { "answer_id": 22582, "author": "mikkelbreum", "author_id": 2071, "author_profile": "https://wordpress.stackexchange.com/users/2071", "pm_score": 2, "selected": false, "text": "<p>hopefully someone will provide a better answer, but for now I'm doing this:</p>\n\n<pre><code>// We're about...
2011/07/10
[ "https://wordpress.stackexchange.com/questions/22577", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2071/" ]
I know how to keep track on the 'index' of the current post when running the loop using ``` $wp_query->current_post ``` Bu this restarts the count from zero on subsequent paged pages. So if I have 20 posts, and show 5 posts per page, then on page 2 the posts are again numbered 0-4 instead of 5-9. My question is: Is...
hopefully someone will provide a better answer, but for now I'm doing this: ``` // We're about top start The Loop. // Setting up a counter to keep track of the posts being processed // We can't just use current_post as it start from zero on subsequent paged pages. $paged_no = ($wp_query->query_vars['paged'] < 2 ) ? 0...
22,583
<p>I have 15 custom fields that I use to generate reviews for my site. Currently I access each field like this:</p> <pre><code>//Buy or rent, type home, price if ( get_post_meta(get_the_ID(), 'survey_home_type', true) ) { echo get_post_meta(get_the_ID(), 'survey_home_type', true) ....
[ { "answer_id": 22587, "author": "Pippin", "author_id": 2418, "author_profile": "https://wordpress.stackexchange.com/users/2418", "pm_score": 2, "selected": false, "text": "<p>You could use <a href=\"http://codex.wordpress.org/Function_Reference/get_post_custom\" rel=\"nofollow\">get_post...
2011/07/10
[ "https://wordpress.stackexchange.com/questions/22583", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6641/" ]
I have 15 custom fields that I use to generate reviews for my site. Currently I access each field like this: ``` //Buy or rent, type home, price if ( get_post_meta(get_the_ID(), 'survey_home_type', true) ) { echo get_post_meta(get_the_ID(), 'survey_home_type', true) . " - "; ...
I would write a function to handle the monotony of this task. ``` function my_print_meta($id, $key, $alternate = '') { if($value = get_post_meta($id, $key, true)) echo $value; else echo $alternate; } ``` Notice in the function that I only call `get_post_meta` once and store the value in a var...
22,591
<p>Can someone please assist with how to remove from my theme, whilst in author mode, the edit_post_link (Edit link), throughout all my pages. Which php files in the Twenty Eleven theme (WordPress v3.2) do I need to comment out to no longer display this edit link?</p> <p>I realise that you only see this during author ...
[ { "answer_id": 22592, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 3, "selected": true, "text": "<p>It's the <a href=\"http://codex.wordpress.org/Function_Reference/edit_post_link\" rel=\"nofollow\"><code>edit_post_l...
2011/07/11
[ "https://wordpress.stackexchange.com/questions/22591", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1053/" ]
Can someone please assist with how to remove from my theme, whilst in author mode, the edit\_post\_link (Edit link), throughout all my pages. Which php files in the Twenty Eleven theme (WordPress v3.2) do I need to comment out to no longer display this edit link? I realise that you only see this during author mode but...
It's the [`edit_post_link()`](http://codex.wordpress.org/Function_Reference/edit_post_link) function. You'll find lines like the following, that you need to comment out: ``` // from /twentyeleven/content-intro.php edit_post_link( __( 'Edit', 'twentyeleven' ), '<span class="edit-link">', '</span>' ); ```
22,594
<p>I'm using a plugin that failed after upgrade to wp3.2.</p> <p>The error log shows:</p> <blockquote> <p>WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 for <code>query SELECT post_id, meta_v...
[ { "answer_id": 22612, "author": "Bitmap Media", "author_id": 6928, "author_profile": "https://wordpress.stackexchange.com/users/6928", "pm_score": 0, "selected": false, "text": "<p>If you can log in to your WP Admin, remove the plugin from there. Otherwise, go through FTP and remove the ...
2011/07/11
[ "https://wordpress.stackexchange.com/questions/22594", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6851/" ]
I'm using a plugin that failed after upgrade to wp3.2. The error log shows: > > WordPress database error You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 1 for `query SELECT post_id, meta_value, post_status FROM bxxoai_po...
I ran into this as well... I am using the SQL query, but not the wpfp\_list\_most\_favorited() function, so this may or may not work for you, but worth a shot. Try updating the SQL query in wp-favorite-posts.php (around line 206) from: ``` $query = "SELECT post_id, meta_value, post_status FROM $wpdb->postmeta"; ``` ...
22,599
<p>My code was working up until the 3.2 update, where I noticed that tinyMCE has been updated too.</p> <p>Does anyone have any ideas why this may not work now? I don't get any console errors but I don't get any tinyMCE editors on the page either!</p> <p><strong>CLARIFICATION: every instance of the TinyMCE editor has ...
[ { "answer_id": 22692, "author": "danielwiener", "author_id": 6817, "author_profile": "https://wordpress.stackexchange.com/users/6817", "pm_score": 0, "selected": false, "text": "<p>There is a problem with WP 3.2 and the Visual Editor</p>\n\n<p>Try this:</p>\n\n<blockquote>\n <p>Anyway, ...
2011/07/11
[ "https://wordpress.stackexchange.com/questions/22599", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6344/" ]
My code was working up until the 3.2 update, where I noticed that tinyMCE has been updated too. Does anyone have any ideas why this may not work now? I don't get any console errors but I don't get any tinyMCE editors on the page either! **CLARIFICATION: every instance of the TinyMCE editor has disappeared!** **FURTH...
I found [some info on changes in 3.2](http://dannyvankooten.com/450/tinymce-wysiwyg-editor-in-wordpress-plugin/) that might be relevant: > > Aparrently, `wp_tiny_mce_preload_dialogs()` no longer exists from WP3.2 on. It got replaced by `wp_preload_dialogs()` which is now being called from `wp_quicktags()`. `wp_quickt...
22,619
<p>On the site I'm currently developing I have created a theme options page (under Appearance). All there is on this page is a text area so the client can add some summary text to appear above their posts.</p> <p>I am using TinyMCE on this textarea so they can format their text, but if I have TinyMCE enabled the 'Save...
[ { "answer_id": 22627, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>What output do you get on-submit, if you add the following to the top of your sanitization callback:</p>\n\...
2011/07/11
[ "https://wordpress.stackexchange.com/questions/22619", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3670/" ]
On the site I'm currently developing I have created a theme options page (under Appearance). All there is on this page is a text area so the client can add some summary text to appear above their posts. I am using TinyMCE on this textarea so they can format their text, but if I have TinyMCE enabled the 'Save Options' ...
What output do you get on-submit, if you add the following to the top of your sanitization callback: ``` var_dump( $input ); die; ``` i.e. add it here: ``` function theme_options_validate( $input ) { var_dump( $input ); die; ``` Compare the results **with** and **without TinyMCE**. Let's figure out what's cha...
22,625
<p>I changed the name of two of my custom post types. The original slugs for them did not properly reflect the post type. So I need to redirect requests for posts beginning with <code>designer_lingerie</code> (the old post type slug) to just <code>designer</code>. All of the posts are the same just the post type slug h...
[ { "answer_id": 22628, "author": "BjornW", "author_id": 637, "author_profile": "https://wordpress.stackexchange.com/users/637", "pm_score": 1, "selected": false, "text": "<p>If you change the permalinks but not the underlying structure WordPress should be able to find your posts, since th...
2011/07/11
[ "https://wordpress.stackexchange.com/questions/22625", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5391/" ]
I changed the name of two of my custom post types. The original slugs for them did not properly reflect the post type. So I need to redirect requests for posts beginning with `designer_lingerie` (the old post type slug) to just `designer`. All of the posts are the same just the post type slug has changed. I am sure I...
All you need to do is add a line like: ``` RewriteRule ^aboutus$ /about-us [R=301,L] ``` In to your .htaccess file. The old url should go between the ^ and $ and then new url after the slash.
22,643
<p>With WP 3.2, WordPress maybe has a new function to add Link-Quicktags to the editor. But I found an function to set defaults for the link-button: </p> <p>Take a look at <a href="http://wpseek.com/source/wp/latest/nav.html?wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js.source.html">wplink.js Line 278</a>.</p...
[ { "answer_id": 60568, "author": "Joshua Abenazer", "author_id": 10251, "author_profile": "https://wordpress.stackexchange.com/users/10251", "pm_score": 2, "selected": false, "text": "<p>Put the following in your <code>functions.php</code>; better is a custom plugin.</p>\n\n<pre><code>add...
2011/07/11
[ "https://wordpress.stackexchange.com/questions/22643", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170/" ]
With WP 3.2, WordPress maybe has a new function to add Link-Quicktags to the editor. But I found an function to set defaults for the link-button: Take a look at [wplink.js Line 278](http://wpseek.com/source/wp/latest/nav.html?wp-includes/js/tinymce/plugins/wplink/js/wplink.dev.js.source.html). ``` setDefaultValu...
Also an small example for change the url in link-button to use the url from installed blog. Use print JS in footer, not an include from js file via `wp_enqueue_script()` - ist faster vor development, specially for this small requirement, but not so on standard and fine, how the example from the other answer. ![enter i...
22,644
<p>Very odd problem with wp_signon </p> <p>Below I pass a users credentials to wp_check_password and it returns true proving the password is correct.... however when i try to signin it return wp_error with<br> "ERROR: The password you entered for the username XXXXXXX is incorrect."</p> <p>Please, can anybody explain ...
[ { "answer_id": 38190, "author": "lkraav", "author_id": 11614, "author_profile": "https://wordpress.stackexchange.com/users/11614", "pm_score": 0, "selected": false, "text": "<p>What function are you adding your users with? I just ran into a <a href=\"https://core.trac.wordpress.org/ticke...
2011/07/11
[ "https://wordpress.stackexchange.com/questions/22644", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6933/" ]
Very odd problem with wp\_signon Below I pass a users credentials to wp\_check\_password and it returns true proving the password is correct.... however when i try to signin it return wp\_error with "ERROR: The password you entered for the username XXXXXXX is incorrect." Please, can anybody explain why this is? a...
Pretty sure wp\_check\_password() is not meant to be used the way you're using it. From the looks of [the documentation](http://codex.wordpress.org/Function_Reference/wp_check_password), and as far as I can tell by looking at the source, this function is only meant to compare the plaintext password you provide against...
22,694
<p>Why doesn't this work?! <code>&lt;?php echo get_post_format_link('standard');?&gt;</code> </p> <p>:( Any hints? All the other formats work.</p>
[ { "answer_id": 22696, "author": "shawn", "author_id": 370, "author_profile": "https://wordpress.stackexchange.com/users/370", "pm_score": 0, "selected": false, "text": "<pre><code>&lt;?php\n$args = array(\n'showposts' =&gt; 9,\n'tax_query' =&gt; array(\n array( 'taxonomy' =&gt; 'p...
2011/07/12
[ "https://wordpress.stackexchange.com/questions/22694", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/676/" ]
Why doesn't this work?! `<?php echo get_post_format_link('standard');?>` :( Any hints? All the other formats work.
Put this in your function.php ``` function akv3_query_format_standard($query) { if (isset($query->query_vars['post_format']) && $query->query_vars['post_format'] == 'post-format-standard') { if (($post_formats = get_theme_support('post-formats')) && is_array($post_formats[0]) && count...
22,697
<p>I am trying to make a child theme of the <a href="http://wordpress.org/extend/themes/toolbox/" rel="nofollow">toolbox</a> theme and use it in my multisite WP 3.2 install.</p> <p>I created a folder called <code>wp-content/themes/charlie-repair-toolkit/</code> then I created <code>style.css</code> in the folder with ...
[ { "answer_id": 22699, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": 3, "selected": true, "text": "<p>You're missing the Template Name for the parent theme. It should look like this:</p>\n\n<pre><code>/*\nTheme...
2011/07/12
[ "https://wordpress.stackexchange.com/questions/22697", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104/" ]
I am trying to make a child theme of the [toolbox](http://wordpress.org/extend/themes/toolbox/) theme and use it in my multisite WP 3.2 install. I created a folder called `wp-content/themes/charlie-repair-toolkit/` then I created `style.css` in the folder with the following information (some of which is copied from th...
You're missing the Template Name for the parent theme. It should look like this: ``` /* Theme Name: Charlie's Repair Theme URI: http://wordpress.org/extend/themes/toolbox/ Author: Mike Wills Author URI: http://mikewills.me Template: toolbox Description: Based on the Toolbox theme from Automatic. This site is for Charl...
22,698
<p>I'm using <a href="http://codex.wordpress.org/Function_Reference/get_the_terms" rel="nofollow">get_the_terms</a> to display 2 terms on a post, associated with the taxonomy "location". The terms are the suburb and the city. The location taxonomy is hierarchical so the suburb is a child of the city. </p> <p>In the po...
[ { "answer_id": 22701, "author": "tollmanz", "author_id": 4850, "author_profile": "https://wordpress.stackexchange.com/users/4850", "pm_score": 1, "selected": false, "text": "<p>I think the easiest way to accomplish this in your case would be to reverse the array.</p>\n\n<pre><code>foreac...
2011/07/12
[ "https://wordpress.stackexchange.com/questions/22698", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4999/" ]
I'm using [get\_the\_terms](http://codex.wordpress.org/Function_Reference/get_the_terms) to display 2 terms on a post, associated with the taxonomy "location". The terms are the suburb and the city. The location taxonomy is hierarchical so the suburb is a child of the city. In the post edit screen a user selects thei...
I managed to hack this together using wp\_get\_object\_terms. The `'orderby' => 'term_id'` was most helpful. It's probably not the best method, but seems to work fine. Because the child terms (suburbs) are always created after the parent terms (Cities), they will always have a higher ID. ``` <?php $terms = wp_get_obj...
22,707
<p>If I wanted to remove 1 or more sidebars when a certain page is called what is the best way to go about doing that?</p>
[ { "answer_id": 22709, "author": "Rajeev Vyas", "author_id": 6961, "author_profile": "https://wordpress.stackexchange.com/users/6961", "pm_score": 0, "selected": false, "text": "<p>Copy page.php from your theme and rename to create your custom template.\nassociate this template with page ...
2011/07/12
[ "https://wordpress.stackexchange.com/questions/22707", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5825/" ]
If I wanted to remove 1 or more sidebars when a certain page is called what is the best way to go about doing that?
If you are creating your own theme you could add this to your `page.php` template file ``` if(!is_page('999')) { //Page to exclude sidebar from dynamic_sidebar('sidebarID'); } ``` Replace `999` with the page ID you wish to exclude, and `sidebarID` with the sidebar you want to show.
22,724
<p>I'm having a problem with Wordpress permalinks. I change the permalinks to pretty permalinks but I am just getting 404s for the pages now. The strange thing is when I use /index.php/%postname% the page links work fine, but I need to get rid of the index.php part.</p> <p>I read about making changes to httpd.conf fil...
[ { "answer_id": 22757, "author": "derek", "author_id": 5825, "author_profile": "https://wordpress.stackexchange.com/users/5825", "pm_score": 0, "selected": false, "text": "<p>Try setting the htaccess to 777 then go in and update the permalink settings to what you want, then if it works go...
2011/07/12
[ "https://wordpress.stackexchange.com/questions/22724", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6966/" ]
I'm having a problem with Wordpress permalinks. I change the permalinks to pretty permalinks but I am just getting 404s for the pages now. The strange thing is when I use /index.php/%postname% the page links work fine, but I need to get rid of the index.php part. I read about making changes to httpd.conf file but can'...
I had all the correct code in the `.htaccess` file, but it ended up being completely overridden in the Ubuntu default `/etc/apache2/apache2.conf` file as well. Changed the entry for `/` and `/var/www` from `AllowOverride None` to `AllowOverride All`, restarted Apache and now everything works just fine.
22,728
<p>I used a WP hack for displaying author's pics. For example, my single.php has an author slug which displays the author's pic.</p> <p>I created a folder called authors in my theme/images folder. Based on the author's ID, I name the file 1.jpg, 2.jpg and so on.</p> <p>So I call this image as </p> <pre><code>&lt;img...
[ { "answer_id": 22729, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 4, "selected": true, "text": "<p>The <code>get_avatar()</code> function applies a <code>get_avatar</code> filter hook, that you can use to ch...
2011/07/12
[ "https://wordpress.stackexchange.com/questions/22728", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5411/" ]
I used a WP hack for displaying author's pics. For example, my single.php has an author slug which displays the author's pic. I created a folder called authors in my theme/images folder. Based on the author's ID, I name the file 1.jpg, 2.jpg and so on. So I call this image as ``` <img src="<?php bloginfo('template_...
The `get_avatar()` function applies a `get_avatar` filter hook, that you can use to change the avatar markup: ``` return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt); ``` I *think* this would be the correct way to hook into this filter: ``` function mytheme_get_avatar( $avatar ) { $...
22,734
<p>This is probably really simple, but I just can't figure it out. So I change the input form on my comment form php. The changed snipped looks like this:</p> <p><a href="http://pastebin.com/3Mj1XHGJ" rel="nofollow">http://pastebin.com/3Mj1XHGJ</a></p> <p>Yet when somebody doesn't click on "Website" at all, still a "...
[ { "answer_id": 22729, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 4, "selected": true, "text": "<p>The <code>get_avatar()</code> function applies a <code>get_avatar</code> filter hook, that you can use to ch...
2011/07/12
[ "https://wordpress.stackexchange.com/questions/22734", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6903/" ]
This is probably really simple, but I just can't figure it out. So I change the input form on my comment form php. The changed snipped looks like this: <http://pastebin.com/3Mj1XHGJ> Yet when somebody doesn't click on "Website" at all, still a "http://Website" link will be generated for some. Is there any way to make...
The `get_avatar()` function applies a `get_avatar` filter hook, that you can use to change the avatar markup: ``` return apply_filters('get_avatar', $avatar, $id_or_email, $size, $default, $alt); ``` I *think* this would be the correct way to hook into this filter: ``` function mytheme_get_avatar( $avatar ) { $...
22,735
<p>i am writing a plugin inside a class and i have created my $meta_boxes, i am able to retrieve all fields but they are duplicated and in the same table.</p> <p>this is my code for add $meta_boxes</p> <pre><code>function ri_add_custom_box() { global $prefix, $meta_box, $meta_boxes; $prefix = '_ri_custom_meta_'...
[ { "answer_id": 22740, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 1, "selected": false, "text": "<p>The Problem is in your <code>ri_display_metaboxes()</code> function more specifically this line:</p>\n\n<pre>...
2011/07/12
[ "https://wordpress.stackexchange.com/questions/22735", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4537/" ]
i am writing a plugin inside a class and i have created my $meta\_boxes, i am able to retrieve all fields but they are duplicated and in the same table. this is my code for add $meta\_boxes ``` function ri_add_custom_box() { global $prefix, $meta_box, $meta_boxes; $prefix = '_ri_custom_meta_'; // a custom prefix...
The Problem is in your `ri_display_metaboxes()` function more specifically this line: ``` foreach ($meta_boxes as $meta_box) { ``` Which tells WordPress to render both/all metaboxes on every single metabox display callback. to get over it you can use the `$callback_args` parameter of `add_meta_box` function so try...
22,739
<p>I have a script that I'd like to call via AJAX from my WordPress theme, it relies upon some core WordPress functions so I am including WordPress blog header like so:</p> <pre><code>define( 'WP_USE_THEMES', false ); require( '../../../../wp-blog-header.php' ); </code></pre> <p>Somewhere during the processing of <co...
[ { "answer_id": 22743, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 1, "selected": false, "text": "<p>Yes there is a recommend solution for using WordPress Function via AJAX and that is using the <code>wp_ajax<...
2011/07/12
[ "https://wordpress.stackexchange.com/questions/22739", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5689/" ]
I have a script that I'd like to call via AJAX from my WordPress theme, it relies upon some core WordPress functions so I am including WordPress blog header like so: ``` define( 'WP_USE_THEMES', false ); require( '../../../../wp-blog-header.php' ); ``` Somewhere during the processing of `wp-blog-header.php` WordPres...
You should be including `wp-load.php`, not `wp-blog-header.php` (which is reserved for use by WordPress only). This is most likely the cause of your problem.
22,754
<p>When creating a user in Wordpress an email address is required for that user. The website I'm working on requires that users remain anonymous (it's part of a research study) and I'd consider email to be an identifying piece of data. Users will be added manually, so email is not required to confirm accounts or preven...
[ { "answer_id": 22770, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 4, "selected": true, "text": "<p>It's possible, just not so easily via the Users page without some hackery.</p>\n<p>The WordPress Function wp_create_...
2011/07/12
[ "https://wordpress.stackexchange.com/questions/22754", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6976/" ]
When creating a user in Wordpress an email address is required for that user. The website I'm working on requires that users remain anonymous (it's part of a research study) and I'd consider email to be an identifying piece of data. Users will be added manually, so email is not required to confirm accounts or prevent s...
It's possible, just not so easily via the Users page without some hackery. The WordPress Function wp\_create\_user will let you insert users without email addresses, so a little custom plugin to accept a login name and password, and a call to `wp_insert_user` or `wp_update_user` should work for you. Unfortunately I do...
22,758
<p>We have customers that come from other sites and I would like to retain a url parameter <a href="http://openeye.net/?lead=openeye" rel="nofollow">/?lead=openeye</a> throughout the time that they're browsing. That way when they fill out a form I can capture the lead for sales. </p> <p>How do I retain url parameters ...
[ { "answer_id": 22759, "author": "mitchellhislop", "author_id": 6978, "author_profile": "https://wordpress.stackexchange.com/users/6978", "pm_score": 0, "selected": false, "text": "<p>The best way to do that is to capture the query with a tool like Google Analytics, and set up your site t...
2011/07/12
[ "https://wordpress.stackexchange.com/questions/22758", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3296/" ]
We have customers that come from other sites and I would like to retain a url parameter [/?lead=openeye](http://openeye.net/?lead=openeye) throughout the time that they're browsing. That way when they fill out a form I can capture the lead for sales. How do I retain url parameters the entire time they're browsing the...
Better Answer: `session_start(); $lead = $_GET['lead']; $_SESSION['lead'] = $lead;` Then, create an additional field on the form, with the input hidden. For the value, I would echo out the $\_SESSION, with a name that is easy to grab (lead works). then, wherever the form is processed, just add a line to grab the lead...
22,763
<p>Short and sweet &mdash; I wanted to deliver up the excerpt of a post in the place of <code>the_content</code> on certain pages. Naturally, if no excerpt is present one would be generated from the content. I understand I can just go in and edit the theme files, but I'd like a less-invasive method.</p> <p>Seeing how ...
[ { "answer_id": 22767, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>Actually, <code>the_excerpt()</code> calls <code>get_the_excerpt()</code>, which outputs <code>$post-&gt;po...
2011/07/12
[ "https://wordpress.stackexchange.com/questions/22763", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/92/" ]
Short and sweet — I wanted to deliver up the excerpt of a post in the place of `the_content` on certain pages. Naturally, if no excerpt is present one would be generated from the content. I understand I can just go in and edit the theme files, but I'd like a less-invasive method. Seeing how something like the followin...
All good examples. But they weren't working for me with the theme (pinboard) and plugin I was using (secondary-html-content) and what I wanted to do. The first challenge was to make sure that I get both pieces of content instead of just one. The second challenge was to replace the excerpt on the homepage with the actu...
22,764
<p>My theme gives the site owner the option of using each post's "Excerpt" field to fill in the "meta description" tag for each page.</p> <p>It would be helpful if I can filter the text label and description text that appears on the default Excerpt input control when viewed inside the post editor.</p> <p>Does a filte...
[ { "answer_id": 22787, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 5, "selected": true, "text": "<p>there is a filter hook you can use and it is <code>gettext</code>\nhere:</p>\n\n<pre><code>add_filter( 'gettex...
2011/07/12
[ "https://wordpress.stackexchange.com/questions/22764", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6620/" ]
My theme gives the site owner the option of using each post's "Excerpt" field to fill in the "meta description" tag for each page. It would be helpful if I can filter the text label and description text that appears on the default Excerpt input control when viewed inside the post editor. Does a filter or hook exist f...
there is a filter hook you can use and it is `gettext` here: ``` add_filter( 'gettext', 'wpse22764_gettext', 10, 2 ); function wpse22764_gettext( $translation, $original ) { if ( 'Excerpt' == $original ) { return 'My Excerpt label'; }else{ $pos = strpos($original, 'Excerpts are optional hand-cr...
22,765
<p>I found this wonderdul script that @Bainternet here at Wordpress Answers created, that makes it possible to attach images into posts from a html form..</p> <p>I tried to combine in into my "html form to post" script.. I does create a post as draft in the backend.. but the image does not show up, and it doesn't show...
[ { "answer_id": 22787, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 5, "selected": true, "text": "<p>there is a filter hook you can use and it is <code>gettext</code>\nhere:</p>\n\n<pre><code>add_filter( 'gettex...
2011/07/12
[ "https://wordpress.stackexchange.com/questions/22765", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5778/" ]
I found this wonderdul script that @Bainternet here at Wordpress Answers created, that makes it possible to attach images into posts from a html form.. I tried to combine in into my "html form to post" script.. I does create a post as draft in the backend.. but the image does not show up, and it doesn't show in "media...
there is a filter hook you can use and it is `gettext` here: ``` add_filter( 'gettext', 'wpse22764_gettext', 10, 2 ); function wpse22764_gettext( $translation, $original ) { if ( 'Excerpt' == $original ) { return 'My Excerpt label'; }else{ $pos = strpos($original, 'Excerpts are optional hand-cr...
22,771
<p>As I already used the featured image for something else, I want to add another image and display it in one of the sizes defined in my functions.php with add_image_size().</p> <p>I know how to do that with a featured image : I just have to use the_post_thumbnail() function and indicate the size I want in the paramet...
[ { "answer_id": 22772, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 0, "selected": false, "text": "<p>Yes, more or less. The $name parameter of <code>add_image_size</code> with can be called like this, </p>\n\n<pre><c...
2011/07/12
[ "https://wordpress.stackexchange.com/questions/22771", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5915/" ]
As I already used the featured image for something else, I want to add another image and display it in one of the sizes defined in my functions.php with add\_image\_size(). I know how to do that with a featured image : I just have to use the\_post\_thumbnail() function and indicate the size I want in the parameters. B...
Try using `wp_get_attachment_image()` ([Codex ref](http://codex.wordpress.org/Function_Reference/wp_get_attachment_image))? ``` echo wp_get_attachment_image( $attachmentid, $imagesize ); ``` Where `$attachmentid` is the attachment ID, and `$imagesize` is the name of the image size in the `add_image_size()` call. **...
22,776
<p>When you create a plugin and set up a process function, Wordpress will run the plugin process function twice upon clicking the update button. I believe the first process is for the versioning (revision) post, and the second the actual post.</p> <p>Now, I've got an INSERT function in my process, so it is now inserti...
[ { "answer_id": 22781, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 1, "selected": false, "text": "<p>you can avoid autosave using a simple check in your function, something like </p>\n\n<pre><code>if (defined('...
2011/07/12
[ "https://wordpress.stackexchange.com/questions/22776", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6348/" ]
When you create a plugin and set up a process function, Wordpress will run the plugin process function twice upon clicking the update button. I believe the first process is for the versioning (revision) post, and the second the actual post. Now, I've got an INSERT function in my process, so it is now inserting the dat...
@Steve Functions hook to save\_post are always called twice, Wordpress call functions hooked to save\_post twice because: * first time it saves the post revision. * second time it saves the actual post. **NOTE:** If you have disabled post revisions using `define('WP_POST_REVISIONS', false);` then the save\_post hook ...
22,782
<p>I have a Multi-Site installation of Wordpress, with multiple subdomains, but only one of the subdomains has an SSL certificate.</p> <p>The domains are such:</p> <pre> www.example.com blog1.example.com blog2.example.com secure.example.com </pre> <p><code>secure.example.com</code> is the subdomain which has a SSL...
[ { "answer_id": 27622, "author": "Elliott", "author_id": 6824, "author_profile": "https://wordpress.stackexchange.com/users/6824", "pm_score": 2, "selected": true, "text": "<p>I would recommend using <a href=\"http://wordpress.org/extend/plugins/peters-login-redirect/\" rel=\"nofollow\">P...
2011/07/12
[ "https://wordpress.stackexchange.com/questions/22782", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4400/" ]
I have a Multi-Site installation of Wordpress, with multiple subdomains, but only one of the subdomains has an SSL certificate. The domains are such: ``` www.example.com blog1.example.com blog2.example.com secure.example.com ``` `secure.example.com` is the subdomain which has a SSL cert installed. If someone typ...
I would recommend using [Peters Login Redirect](http://wordpress.org/extend/plugins/peters-login-redirect/) to redirect users after login I have used it before and works well. You could redirect users to the secure area by adding the below to your .htaccess file : ``` Redirect 301 blog1.example.com/wp-admin/dashboard...
22,788
<p>have spent half an hour hunting around on Google to solve this so any ideas greatly appreciated! <hr /> I'm using a bought theme running wp3.2 and the theme includes a few extra features Testimonials, Portfolio and Slider (they show in the admin, but aren't plugins)</p> <p>I'm comfortable using <code>$role_objet-&g...
[ { "answer_id": 22794, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 0, "selected": false, "text": "<p>If the theme is coded the right way then these features should by default only be available to users with <co...
2011/07/13
[ "https://wordpress.stackexchange.com/questions/22788", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4386/" ]
have spent half an hour hunting around on Google to solve this so any ideas greatly appreciated! --- I'm using a bought theme running wp3.2 and the theme includes a few extra features Testimonials, Portfolio and Slider (they show in the admin, but aren't plugins) I'm comfortable using `$role_objet->remove_cap();` in...
If what you want to do is to hide the menu items you can make use of `remove_menu_page` and `remove_submenu_page` by hooking into `admin_menu`. In order to hide certain links based on the user's role (in your case, Editor): ``` function custom_remove_menus(){ // Get current user's data $current_user = wp_get...
22,802
<p>Hierarchical taxonomy of custom post type 'projects' > 'projects_category'.</p> <p>Two example 'projects_category' hierarchies would be:</p> <blockquote> <p>Big Corporates > 1st Company Name > A Post Title</p> <p>Small Business > 2nd Company Name > Another Post Title</p> </blockquote> <p>I can get <strong>...
[ { "answer_id": 22807, "author": "Nsokyi", "author_id": 6787, "author_profile": "https://wordpress.stackexchange.com/users/6787", "pm_score": 1, "selected": false, "text": "<p>If you read this article on custom post types it should help: <strong><a href=\"http://mondaybynoon.com/2011/05/2...
2011/07/13
[ "https://wordpress.stackexchange.com/questions/22802", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4316/" ]
Hierarchical taxonomy of custom post type 'projects' > 'projects\_category'. Two example 'projects\_category' hierarchies would be: > > Big Corporates > 1st Company Name > A Post Title > > > Small Business > 2nd Company Name > Another Post Title > > > I can get **'1st Company Name'** with the following: ``` <...
I've marked up anu's answer and get\_ancestors explanation, however this is how I solved it: ``` <?php $terms = wp_get_object_terms($post->ID, 'projects_category', array('orderby' => 'term_id', 'order' => 'ASC') ); if ( !empty( $terms ) ) : $project = array(); foreach ( $terms as $term ) { $projec...
22,804
<p>It seems that $post is only available to hooks executing at certain times. I have an "init" hook that needs to pull some data from the database using the $post->ID. </p> <p>So far my only workaround has been to add another filter on the_content, that uses $post to get the information I need. Unfortunately, it als...
[ { "answer_id": 30660, "author": "JVC", "author_id": 7162, "author_profile": "https://wordpress.stackexchange.com/users/7162", "pm_score": 4, "selected": false, "text": "<p>Turns out the answer was simply to use <a href=\"https://developer.wordpress.org/reference/functions/url_to_postid/\...
2011/07/13
[ "https://wordpress.stackexchange.com/questions/22804", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6990/" ]
It seems that $post is only available to hooks executing at certain times. I have an "init" hook that needs to pull some data from the database using the $post->ID. So far my only workaround has been to add another filter on the\_content, that uses $post to get the information I need. Unfortunately, it also echoes th...
Turns out the answer was simply to use [`url_to_postid`](https://developer.wordpress.org/reference/functions/url_to_postid/) like this: ``` $keyword = get_post_meta( url_to_postid( "http://".$_SERVER['SERVER_NAME'].$_SERVER['REQUEST_URI'] ), '_wpg_def_keyword', true ); ``` Works perfectly even from `init`.