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
16,809
<p>Let me preface by saying I don't really understand Add_Filter, but I think that I want to be using it here. If not please let me know. </p> <p>I want to modify <a href="http://codex.wordpress.org/Function_Reference/wp_get_attachment_link" rel="nofollow">wp_get_attachment_link</a> so that the link url changes. So fo...
[ { "answer_id": 16812, "author": "dpgtfc", "author_id": 4834, "author_profile": "https://wordpress.stackexchange.com/users/4834", "pm_score": 1, "selected": false, "text": "<pre><code>add_filter( 'wp_get_attachment_link', 'modify_attachment_link', 10, 5 );\n\nfunction modify_attachment_li...
2011/05/10
[ "https://wordpress.stackexchange.com/questions/16809", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4013/" ]
Let me preface by saying I don't really understand Add\_Filter, but I think that I want to be using it here. If not please let me know. I want to modify [wp\_get\_attachment\_link](http://codex.wordpress.org/Function_Reference/wp_get_attachment_link) so that the link url changes. So for example if I click on a thumbn...
Look at the function in `wp-includes/post-template.php`. There you see what information you can get: ``` apply_filters( 'wp_get_attachment_link' , "<a href='$url' title='$post_title'>$link_text</a>" , $id , $size , $permalink , $icon , $text ); ``` Note that you cannot access the `$link_text` and th...
16,818
<p>I'm writing a customised walker class for wp_nav_menu and want to be able to specify if an li contains a submenu. So I want my markup to be:</p> <pre><code>&lt;li class="has_children [other-wordpress-classes]"&gt; &lt;a class="parent-link"&gt;Some item&lt;/a&gt; &lt;ul class="sub-menu"&gt; </code></pre> <p...
[ { "answer_id": 16820, "author": "alexndm", "author_id": 4678, "author_profile": "https://wordpress.stackexchange.com/users/4678", "pm_score": 1, "selected": false, "text": "<p>if you want to make drop down, you can do it with css only.\nmake custom nav in WP with children, WordPress auto...
2011/05/10
[ "https://wordpress.stackexchange.com/questions/16818", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4093/" ]
I'm writing a customised walker class for wp\_nav\_menu and want to be able to specify if an li contains a submenu. So I want my markup to be: ``` <li class="has_children [other-wordpress-classes]"> <a class="parent-link">Some item</a> <ul class="sub-menu"> ``` I know how to add and remove the classes fine, ...
`start_el()` should get this information in its `$args` parameter, but it appears [WordPress only fills this in if `$args` is an array](http://core.trac.wordpress.org/browser/tags/3.1.2/wp-includes/class-wp-walker.php#L126), while for the custom navigation menus it is an object. This is reported in [a Trac ticket](http...
16,835
<p>I'm still struggling to get my head around this whole hooking into things, so I'm really stuck on trying to do the following task:</p> <p>If <code>update_post_meta</code> is fired then check to see if the <code>meta_key</code> is equal to something (I want to trigger some code if a particular meta_key is used). If ...
[ { "answer_id": 16840, "author": "Jan Fabry", "author_id": 8, "author_profile": "https://wordpress.stackexchange.com/users/8", "pm_score": 7, "selected": true, "text": "<p>The <code>update_post_meta</code> hooks are called from the more generic <a href=\"http://core.trac.wordpress.org/bro...
2011/05/10
[ "https://wordpress.stackexchange.com/questions/16835", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4610/" ]
I'm still struggling to get my head around this whole hooking into things, so I'm really stuck on trying to do the following task: If `update_post_meta` is fired then check to see if the `meta_key` is equal to something (I want to trigger some code if a particular meta\_key is used). If the meta key I'm looking for th...
The `update_post_meta` hooks are called from the more generic [`update_metadata()`](http://core.trac.wordpress.org/browser/tags/3.1.2/wp-includes/meta.php#L79) function, so you might not have found it directly. The three hooks are: * [`update_post_metadata`](http://core.trac.wordpress.org/browser/tags/3.1.2/wp-include...
16,854
<p>Is there a plugin or a hack such that I can make short updates similar to twitter's on my own wordpress blog?</p> <p>Perhaps making use of a custom post type or something on those lines?</p> <p>What i'm trying to achieve is to create short (150 character limit) posts different to the regular posts on the blog. Onc...
[ { "answer_id": 16855, "author": "anu", "author_id": 490, "author_profile": "https://wordpress.stackexchange.com/users/490", "pm_score": 2, "selected": false, "text": "<p>WordPress now has a post format called <code>status</code> which is meant to be used for short status updates. </p>\n\...
2011/05/10
[ "https://wordpress.stackexchange.com/questions/16854", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5265/" ]
Is there a plugin or a hack such that I can make short updates similar to twitter's on my own wordpress blog? Perhaps making use of a custom post type or something on those lines? What i'm trying to achieve is to create short (150 character limit) posts different to the regular posts on the blog. Once these short upd...
If you just want to add a character counter for your excerpt, use this function and js. ### The Php for your functions.php ``` // This goes in your functions.php file inside your themes folder // Add theme support for post formats add_theme_support( 'post-formats', array( 'aside', 'status' ) ); // Add the characte...
16,868
<p>I'm displaying a comment outside the comment template, getting it with <code>get_comments()</code> and echoing the <code>comment_content</code>. My problem is that the comment loses the formatting (paragraphs, line breaks, etc...). In my template I'm using <a href="http://wordpress.org/extend/plugins/tinymcecomments...
[ { "answer_id": 16873, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 0, "selected": false, "text": "<p>Try <code>$GLOBALS['comment'] = $comment</code> above that function.</p>\n" }, { "answer_id": 16877, "a...
2011/05/10
[ "https://wordpress.stackexchange.com/questions/16868", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2119/" ]
I'm displaying a comment outside the comment template, getting it with `get_comments()` and echoing the `comment_content`. My problem is that the comment loses the formatting (paragraphs, line breaks, etc...). In my template I'm using [TinyMCEComments](http://wordpress.org/extend/plugins/tinymcecomments/) (TinyMCE on c...
applying the 'the\_content' filter could work: ``` <?php echo apply_filters('the_content', $comment->comment_content); ?> ```
16,889
<p>I'm building a category picker select list. I just need to populate an array of categorys like so:</p> <pre><code>$myCats = array("null" =&gt; "None (default)", "1" =&gt; "Uncategorized", "2" =&gt; "Second Category", etc..) </code></pre> <p>Does WP have an existing method call I can use to pull this data alone? I ...
[ { "answer_id": 16891, "author": "MZAweb", "author_id": 5223, "author_profile": "https://wordpress.stackexchange.com/users/5223", "pm_score": 3, "selected": true, "text": "<p>Can't you use <a href=\"http://codex.wordpress.org/Function_Reference/wp_dropdown_categories\" rel=\"nofollow\">wp...
2011/05/10
[ "https://wordpress.stackexchange.com/questions/16889", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/366/" ]
I'm building a category picker select list. I just need to populate an array of categorys like so: ``` $myCats = array("null" => "None (default)", "1" => "Uncategorized", "2" => "Second Category", etc..) ``` Does WP have an existing method call I can use to pull this data alone? I may need to exclude some categories...
Can't you use [wp\_dropdown\_categories](http://codex.wordpress.org/Function_Reference/wp_dropdown_categories)? ``` wp_dropdown_categories('show_option_none=Select category&exclude=1,2,3&selected=6'); ```
16,893
<p>I've a class which has a function that check and creates table in database. In order to do so i need to use WordPress $wpdb object.</p> <p>I need the function to run only on first plugin activation, so i use the function:</p> <pre><code>register_activation_hook ( __FILE__, array( 'MemorialCandles', 'dbInstall' ...
[ { "answer_id": 16891, "author": "MZAweb", "author_id": 5223, "author_profile": "https://wordpress.stackexchange.com/users/5223", "pm_score": 3, "selected": true, "text": "<p>Can't you use <a href=\"http://codex.wordpress.org/Function_Reference/wp_dropdown_categories\" rel=\"nofollow\">wp...
2011/05/10
[ "https://wordpress.stackexchange.com/questions/16893", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5274/" ]
I've a class which has a function that check and creates table in database. In order to do so i need to use WordPress $wpdb object. I need the function to run only on first plugin activation, so i use the function: ``` register_activation_hook ( __FILE__, array( 'MemorialCandles', 'dbInstall' ) ); ``` The proble...
Can't you use [wp\_dropdown\_categories](http://codex.wordpress.org/Function_Reference/wp_dropdown_categories)? ``` wp_dropdown_categories('show_option_none=Select category&exclude=1,2,3&selected=6'); ```
16,895
<p>I recently adjusted the twentyten theme to display archives in a three column grid. In doing so, it seems that the archive has lost the ability to display posts from the specified taxonomy.</p> <p>For instance, a taxonomy type is 'Flowers', with a specific flower being 'Rose'. When the 'Rose' archive is displayed...
[ { "answer_id": 16898, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": true, "text": "<p>you can add the current term to you query so if its category, tag or custom taxonomy you will get the posts wi...
2011/05/10
[ "https://wordpress.stackexchange.com/questions/16895", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5019/" ]
I recently adjusted the twentyten theme to display archives in a three column grid. In doing so, it seems that the archive has lost the ability to display posts from the specified taxonomy. For instance, a taxonomy type is 'Flowers', with a specific flower being 'Rose'. When the 'Rose' archive is displayed, it simply ...
you can add the current term to you query so if its category, tag or custom taxonomy you will get the posts with the current term, try changing this: ``` query_posts('cat=0&posts_per_page=12&paged='.$paged); ``` with this: ``` $term_slug = get_query_var( 'term' ); $taxonomyName = get_query_var( 'taxonomy' ); query_...
16,901
<p>This isn't as simple of a question as you may think. Basically I have a C# program that is hitting the worpdress site and the wp_schedule doesn't seem to fire off. If I go to the site with my firefox browser then it seems to fire-off. Soooo what's the difference here? What exactly causes the cron to fire? Is it the ...
[ { "answer_id": 16905, "author": "MZAweb", "author_id": 5223, "author_profile": "https://wordpress.stackexchange.com/users/5223", "pm_score": 0, "selected": false, "text": "<p>Are you following redirects?</p>\n\n<p>In cron.php you can see that the spawn_cron function is doing</p>\n\n<pre>...
2011/05/10
[ "https://wordpress.stackexchange.com/questions/16901", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4119/" ]
This isn't as simple of a question as you may think. Basically I have a C# program that is hitting the worpdress site and the wp\_schedule doesn't seem to fire off. If I go to the site with my firefox browser then it seems to fire-off. Soooo what's the difference here? What exactly causes the cron to fire? Is it the HT...
The WP-Cron functions are not actually cron functions. Instead of a cron running and executing tasks precisely as scheduled, it waits until the frontend or admin is loaded, checks if any jobs are scheduled and then fires as needed. To execute the cron jobs, WP loads `wp-cron.php`, which is located in the root folder. M...
16,903
<p>In my theme I want to display the featured image, but I also want to display the title attribute (of the image, not of the post/page) beside the image itself.</p> <p>Is there a simple way to do this? Where should I be looking?</p> <p>Thanks, John.</p>
[ { "answer_id": 16904, "author": "John Hunt", "author_id": 4916, "author_profile": "https://wordpress.stackexchange.com/users/4916", "pm_score": 2, "selected": false, "text": "<p>Easy!</p>\n\n<pre><code>&lt;?php the_post_thumbnail();\necho get_post(get_post_thumbnail_id())-&gt;post_excerp...
2011/05/11
[ "https://wordpress.stackexchange.com/questions/16903", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4916/" ]
In my theme I want to display the featured image, but I also want to display the title attribute (of the image, not of the post/page) beside the image itself. Is there a simple way to do this? Where should I be looking? Thanks, John.
post\_excerpt is actually the caption attribute. Here is the correct answer: ``` $title = get_post(get_post_thumbnail_id())->post_title; //The Title $caption = get_post(get_post_thumbnail_id())->post_excerpt; //The Caption $description = get_post(get_post_thumbnail_id())->post_content; // The Description ```
16,907
<p>I'm a bit new to php and am having some trouble combining the functionality of two custom queries in Wordpress in order to (1) get pagination to work properly, and (2) sort my posts according to a voting plugin.</p> <p><strong>(1) The following is a custom query, which is working with pagination, but does not sort ...
[ { "answer_id": 16908, "author": "Denis de Bernardy", "author_id": 1208, "author_profile": "https://wordpress.stackexchange.com/users/1208", "pm_score": 1, "selected": false, "text": "<p>You should probably be using the WP_Query object and have it order your posts by a meta field:</p>\n\n...
2011/05/08
[ "https://wordpress.stackexchange.com/questions/16907", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7772/" ]
I'm a bit new to php and am having some trouble combining the functionality of two custom queries in Wordpress in order to (1) get pagination to work properly, and (2) sort my posts according to a voting plugin. **(1) The following is a custom query, which is working with pagination, but does not sort my posts accordi...
You should probably be using the WP\_Query object and have it order your posts by a meta field: <http://codex.wordpress.org/Function_Reference/WP_Query#Parameters> Doing so will handle sorting and pagination out of the box.
16,913
<p>Ok so i am trying to use WordPress's custom fields and have them working but now i have some php code i need help with.</p> <pre><code>&lt;a href="&lt;?php echo get_post_meta( $post-&gt;ID, '_ct_text_4dc9e9f74d000', true ); ?&gt;"&gt;Go To Store!&lt;/a&gt; </code></pre> <p>The above code is what i have for right n...
[ { "answer_id": 16914, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 3, "selected": true, "text": "<p>You mean something like this?</p>\n\n<pre><code>$customhref = get_post_meta( $post-&gt;ID, '_ct_text_4dc9e9f...
2011/05/11
[ "https://wordpress.stackexchange.com/questions/16913", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4998/" ]
Ok so i am trying to use WordPress's custom fields and have them working but now i have some php code i need help with. ``` <a href="<?php echo get_post_meta( $post->ID, '_ct_text_4dc9e9f74d000', true ); ?>">Go To Store!</a> ``` The above code is what i have for right now. Is there a way to setup a if and else state...
You mean something like this? ``` $customhref = get_post_meta( $post->ID, '_ct_text_4dc9e9f74d000', true ); if ( $customhref ) { ?> <a href="<?php echo $customhref; ?>">Go To Store!</a> <?php } else { echo 'N/A'; } ```
16,921
<p>I'm using get_pages() function to get all subpages from a page like this:</p> <pre><code>$childrens = get_pages(array('child_of' =&gt; 7, 'sort_column' =&gt; 'post_date', 'sort_order' =&gt; 'DESC', 'depth' =&gt; -1)); </code><...
[ { "answer_id": 16935, "author": "Jan Fabry", "author_id": 8, "author_profile": "https://wordpress.stackexchange.com/users/8", "pm_score": 2, "selected": false, "text": "<p>This is indeed an error, and probably caused by the <code>child_of</code> argument.</p>\n\n<p>Because <code>child_of...
2011/05/11
[ "https://wordpress.stackexchange.com/questions/16921", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3893/" ]
I'm using get\_pages() function to get all subpages from a page like this: ``` $childrens = get_pages(array('child_of' => 7, 'sort_column' => 'post_date', 'sort_order' => 'DESC', 'depth' => -1)); ``` This is supossed to get me ...
after looking around a bit I managed it to make it work using the following: ``` function sort_pages_by_date($a, $b){ if ($a->post_date == $b->post_date) return 0; if ($a->post_date < $b->post_date) return -1; return 1; } function get_filtered_news($pages) { usort($pages, 'sort_pages_b...
16,925
<p>I'm new to SQL and am wondering if I need to use <code>wpdb-&gt;prepare</code> for the following query to a table I've created</p> <pre><code>global $wpdb; $tablename = $wpdb-&gt;prefix . "my_custom_table"; $sql = "SELECT * FROM " . $tablename . " ORDER BY date_created DESC"; $resulst = $wpdb-&gt;get_results( $sql ...
[ { "answer_id": 16926, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 7, "selected": true, "text": "<p>It's best practice to always use <code>prepare</code> but the main use of it is to prevent against SQL injecti...
2011/05/11
[ "https://wordpress.stackexchange.com/questions/16925", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3430/" ]
I'm new to SQL and am wondering if I need to use `wpdb->prepare` for the following query to a table I've created ``` global $wpdb; $tablename = $wpdb->prefix . "my_custom_table"; $sql = "SELECT * FROM " . $tablename . " ORDER BY date_created DESC"; $resulst = $wpdb->get_results( $sql , ARRAY_A ); ``` Do I need to us...
It's best practice to always use `prepare` but the main use of it is to prevent against SQL injection attacks, and since there is no input from the users/visitors or they can't effect the query then that is not an issue in your current example. But like I said before it's best practice to use it and once you start usi...
16,927
<p>Have a custom page template and trying to make the excerpt length dynamical depending on what page you are in.</p> <p>Functions.php</p> <pre><code>&lt;?php function custom_excerpt_length($length){ if (is_page(15)) { return 20; } else { return 150; } } add_filter ( 'excerpt_length', 'custom_ex...
[ { "answer_id": 16930, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 2, "selected": false, "text": "<p>Using <code>is_page()</code> inside functions.php is fine, possible and working, and if you are echoing <code...
2011/05/11
[ "https://wordpress.stackexchange.com/questions/16927", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4190/" ]
Have a custom page template and trying to make the excerpt length dynamical depending on what page you are in. Functions.php ``` <?php function custom_excerpt_length($length){ if (is_page(15)) { return 20; } else { return 150; } } add_filter ( 'excerpt_length', 'custom_excerpt_length'); ?> ```...
Using `is_page()` inside functions.php is fine, possible and working, and if you are echoing `is_page(15)` and getting true, that means you are on a page with the ID of 15. the problem could be the priority parameter of the add\_filter call, form the codex: > > Make sure to set the priority > correctly, else the de...
16,934
<p>I have an two wordpress sites that I would like to host on the same domain. One is already up and running, the other is sitting in waiting.</p> <p>Can I get the second as a subdomain, or simple within a folder, to run on the same domain (different DB) without converting to multisite?</p>
[ { "answer_id": 16936, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": true, "text": "<p>Point the subdomain to the same directory as the main site, and define different settings in your <strong>wp-config.php...
2011/05/11
[ "https://wordpress.stackexchange.com/questions/16934", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/784/" ]
I have an two wordpress sites that I would like to host on the same domain. One is already up and running, the other is sitting in waiting. Can I get the second as a subdomain, or simple within a folder, to run on the same domain (different DB) without converting to multisite?
Point the subdomain to the same directory as the main site, and define different settings in your **wp-config.php** per `$_SERVER['HTTP_HOST']`: Example from my local setup: ``` switch ( $_SERVER['HTTP_HOST'] ) { case 'zzl.dev': $table_prefix = 'zzl_'; $table_name = 'zzl'; break; ca...
16,939
<p>I made a WordPress plugin like this:</p> <pre><code>Class MY_CLASS { //codes } Global $myclass; $myclass = New MY_CLASS (); </code></pre> <p>After installed and activated the plugin, can I use this class in other plugins without including the myclass.php file? For example, in another plugin:</p> <pre><code>Global...
[ { "answer_id": 16940, "author": "Jan Fabry", "author_id": 8, "author_profile": "https://wordpress.stackexchange.com/users/8", "pm_score": 2, "selected": false, "text": "<p>Only the main plugin file will be included automatically. So if your plugin is structured like this:</p>\n\n<ul>\n<l...
2011/05/11
[ "https://wordpress.stackexchange.com/questions/16939", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5210/" ]
I made a WordPress plugin like this: ``` Class MY_CLASS { //codes } Global $myclass; $myclass = New MY_CLASS (); ``` After installed and activated the plugin, can I use this class in other plugins without including the myclass.php file? For example, in another plugin: ``` Global $myclass; $myclass->a = 'dog'; ```
Technically, it is possible. But I would use a slightly different approach. If your second plugin is loaded first you get an error. If you want to replace the class in another plugin, it is hard to do this. So hook into `plugins_loaded` with a specific priority to create the object and use the object in your second pl...
16,950
<p>What's the best way to ensure that post and page slugs use underscores instead of hyphens, without needing to edit the slug manually (or updating the page manually)</p> <p>Current permalink:</p> <pre><code>www.&lt;domain&gt;.com/2011/05/this-is-a-test-post/ </code></pre> <p>Desired permalink</p> <pre><code>www.&...
[ { "answer_id": 16957, "author": "mfields", "author_id": 11019, "author_profile": "https://wordpress.stackexchange.com/users/11019", "pm_score": 4, "selected": true, "text": "<p>IMO hooking into sanitize_title is probably the best way to go here. Check out this plugin by Mark Jaquith whic...
2011/05/11
[ "https://wordpress.stackexchange.com/questions/16950", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/490/" ]
What's the best way to ensure that post and page slugs use underscores instead of hyphens, without needing to edit the slug manually (or updating the page manually) Current permalink: ``` www.<domain>.com/2011/05/this-is-a-test-post/ ``` Desired permalink ``` www.<domain>.com/2011/05/this_is_a_test_post/ ``` One...
IMO hooking into sanitize\_title is probably the best way to go here. Check out this plugin by Mark Jaquith which does something similar: <http://txfx.net/files/wordpress/periods-in-titles.phps> As for updating the old posts, I would just write a simple script that would generate sql to manually update everything. (co...
16,977
<p>I am using the members plugin and have a custom post type of "listing"</p> <p>When I navigate to listings in the backend, I can edit. quickedit, and view. There is no option to trash. I am logged in as the admin. </p> <pre><code>add_action('init', 'listing_init'); function listing_init() { $labels = array( ...
[ { "answer_id": 16983, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": true, "text": "<p>Might you need <a href=\"http://codex.wordpress.org/Roles_and_Capabilities#Administrator\" rel=\"nofollow\">...
2011/05/11
[ "https://wordpress.stackexchange.com/questions/16977", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5181/" ]
I am using the members plugin and have a custom post type of "listing" When I navigate to listings in the backend, I can edit. quickedit, and view. There is no option to trash. I am logged in as the admin. ``` add_action('init', 'listing_init'); function listing_init() { $labels = array( 'name' => _x('Listin...
Might you need [one of these Admin capabilities](http://codex.wordpress.org/Roles_and_Capabilities#Administrator)? * delete\_others\_pages * delete\_others\_posts * delete\_pages * delete\_plugins * delete\_posts * delete\_private\_pages * delete\_private\_posts * delete\_published\_pages * delete\_published\_posts U...
16,982
<p>Mike Schindel provided me this code long time ago:</p> <pre><code>&lt;?php /** * Create the Blocks custom post type and the Sections custom taxonomy */ add_action('init', 'my_init_method'); if (!class_exists('YourSite_Blocks')) { class YourSite_Blocks { static function on_load() { add_act...
[ { "answer_id": 16985, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": true, "text": "<p>What is the error message being generated?</p>\n\n<p>Also, to avoid conflicts, <em>all custom Theme function...
2011/05/11
[ "https://wordpress.stackexchange.com/questions/16982", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/781/" ]
Mike Schindel provided me this code long time ago: ``` <?php /** * Create the Blocks custom post type and the Sections custom taxonomy */ add_action('init', 'my_init_method'); if (!class_exists('YourSite_Blocks')) { class YourSite_Blocks { static function on_load() { add_action('init',array(...
What is the error message being generated? Also, to avoid conflicts, *all custom Theme functions, classes, options, constants, etc.* should be *prefixed uniquely*, e.g. using `theme-slug`. It is highly likely that a generic function name like `my_init_method` is used by another Plugin or Theme. Try renaming it to `my...
16,993
<p>I'm trying to migrate from multiple subdomain blogs to WP multisite. The one stumbling block is that I'm pretty sure the static files and directories on my subdomains will not be found; each of my blogs has its own set of static files (downloads, mp3 archives, scripts, etc.). What would be a way to maintain these?...
[ { "answer_id": 16996, "author": "NW Tech", "author_id": 5295, "author_profile": "https://wordpress.stackexchange.com/users/5295", "pm_score": 0, "selected": false, "text": "<p>what I've done in the past is from the subdomain, I've exported all content. Then in the WP multisite, I've impo...
2011/05/11
[ "https://wordpress.stackexchange.com/questions/16993", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5294/" ]
I'm trying to migrate from multiple subdomain blogs to WP multisite. The one stumbling block is that I'm pretty sure the static files and directories on my subdomains will not be found; each of my blogs has its own set of static files (downloads, mp3 archives, scripts, etc.). What would be a way to maintain these? Wi...
The standard WP RewriteRules ignore files and directories that "exist". Example: ``` # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> # END WordPress ...
17,012
<p>I like to use the new taxonomy to make a little CRM, really simple</p> <pre><code>contact - name - tel - email - company </code></pre> <p>Fine, the secretary will enter all the name in the database of the cms (WordPress), and i will have all those in, able to display it like a list or whatever i like</p> <p>1) fi...
[ { "answer_id": 17013, "author": "MZAweb", "author_id": 5223, "author_profile": "https://wordpress.stackexchange.com/users/5223", "pm_score": 2, "selected": true, "text": "<p>I used <a href=\"http://rolopress.com/\" rel=\"nofollow\">http://rolopress.com/</a> a while back and have nice fea...
2011/05/11
[ "https://wordpress.stackexchange.com/questions/17012", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3969/" ]
I like to use the new taxonomy to make a little CRM, really simple ``` contact - name - tel - email - company ``` Fine, the secretary will enter all the name in the database of the cms (WordPress), and i will have all those in, able to display it like a list or whatever i like 1) first question, do i reinvent the w...
I used <http://rolopress.com/> a while back and have nice features for contact administration
17,022
<p>I'm trying to test my wordpress page with some simple jQuery script but it won't work.</p> <p>I've loaded the script with <code>wp_enqueue_script('jquery');</code> in <code>functions.php</code> as explained in the <a href="http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Load_a_default_WordPress_scri...
[ { "answer_id": 17024, "author": "Chris_O", "author_id": 251, "author_profile": "https://wordpress.stackexchange.com/users/251", "pm_score": 4, "selected": true, "text": "<p>jQuery needs to be outside the wrapper like so:</p>\n\n<pre><code>&lt;script type=\"text/javascript\"&gt;\n(functio...
2011/05/12
[ "https://wordpress.stackexchange.com/questions/17022", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5287/" ]
I'm trying to test my wordpress page with some simple jQuery script but it won't work. I've loaded the script with `wp_enqueue_script('jquery');` in `functions.php` as explained in the [wordpress guide](http://codex.wordpress.org/Function_Reference/wp_enqueue_script#Load_a_default_WordPress_script_from_a_non-default_l...
jQuery needs to be outside the wrapper like so: ``` <script type="text/javascript"> (function($) { $(document).ready(function() { alert('hello?'); }); })(jQuery); </script> ``` ### Edit: ***A better way would be:*** ``` jQuery(document).ready(function($) { // $() will work as an alias for jQuery() ...
17,025
<p>Is there someway to change the title in wp-admin? Been looking all over google but no one seem to mention it.</p> <p>I simply want to get rid of "&#8212; WordPress" and possibly change the "&lsaquo;" into some other symbol.</p> <p>Any ideas?</p>
[ { "answer_id": 17034, "author": "Geert", "author_id": 4936, "author_profile": "https://wordpress.stackexchange.com/users/4936", "pm_score": 6, "selected": true, "text": "<pre><code>add_filter('admin_title', 'my_admin_title', 10, 2);\n\nfunction my_admin_title($admin_title, $title)\n{\n ...
2011/05/12
[ "https://wordpress.stackexchange.com/questions/17025", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2830/" ]
Is there someway to change the title in wp-admin? Been looking all over google but no one seem to mention it. I simply want to get rid of "— WordPress" and possibly change the "‹" into some other symbol. Any ideas?
``` add_filter('admin_title', 'my_admin_title', 10, 2); function my_admin_title($admin_title, $title) { return get_bloginfo('name').' &bull; '.$title; } ``` You could also do a `str_replace` on `$admin_title` to remove "— WordPress" and change "‹". Look at the top of the `wp-admin/admin-header.php` file to see ...
17,046
<p>I am using the Custom Post Type feature in Wordpress 3 to create an Events section for my website. I am able to get this to display by using the relevante template files, but I also want the event listings visible on other pages.</p> <p>I've done this with the normal post types but these are based on category IDs ...
[ { "answer_id": 17048, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>Every taxonomy (built in like 'tags', 'post-formats', 'category', as well as custom) have an ID, so you can get thi...
2011/05/12
[ "https://wordpress.stackexchange.com/questions/17046", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1020/" ]
I am using the Custom Post Type feature in Wordpress 3 to create an Events section for my website. I am able to get this to display by using the relevante template files, but I also want the event listings visible on other pages. I've done this with the normal post types but these are based on category IDs which Custo...
I've figured out the answer using the Wordpress forum. Solution below: ``` <?php query_posts( array( 'country' => 'event-england' ) ); ?> <?php if( is_tax() ) { global $wp_query; $term = $wp_query->get_queried_object(); $title = $term->name; } ?> <u...
17,047
<p>In the Admin section I'm using quesry posts to get the title and content of a custom post</p> <p>this query_posts('post_type=sfnewsletter'); will get me the content I need but unfortunately what I need to do now is to pass the ID of the custom post via a form and then retrieve that content </p> <p>I've tried </p> ...
[ { "answer_id": 17055, "author": "Shelly", "author_id": 5014, "author_profile": "https://wordpress.stackexchange.com/users/5014", "pm_score": 0, "selected": false, "text": "<p>The example queries you've posted are for <em>Pages</em>, not custom post types. \"p\" is for \"post\" post type,...
2011/05/12
[ "https://wordpress.stackexchange.com/questions/17047", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3732/" ]
In the Admin section I'm using quesry posts to get the title and content of a custom post this query\_posts('post\_type=sfnewsletter'); will get me the content I need but unfortunately what I need to do now is to pass the ID of the custom post via a form and then retrieve that content I've tried ``` query_posts('p...
``` query_posts('post_type=sfnewsletter&p=32'); ```
17,053
<p>I'm trying to be a good thememaker and pass all my settings through the Settings API, but I'm running into some difficulty in the sanitization callback function. </p> <p>The core of the problem is this: the $input variable, passed in by default, is empty. My $_POST[options group] is coming through just fine (it has...
[ { "answer_id": 17054, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": false, "text": "<p>The <code>$input</code> variable is <em>not</em> passed to the validate function by <em>default</em>. You n...
2011/05/12
[ "https://wordpress.stackexchange.com/questions/17053", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/61/" ]
I'm trying to be a good thememaker and pass all my settings through the Settings API, but I'm running into some difficulty in the sanitization callback function. The core of the problem is this: the $input variable, passed in by default, is empty. My $\_POST[options group] is coming through just fine (it has everythi...
Answering my own question by way of an answer Chip has embedded in his excellent [settings tutorial](http://www.chipbennett.net/2011/02/17/incorporating-the-settings-api-in-wordpress-themes/?all=1&doing_wp_cron "settings tutorial"), namely: it's all about Correlating Function Arguments. Apparently some of the variable ...
17,056
<p>How do I create a random post but it shouldnt be change when the page is refreshed </p> <p>I want a random post that will last for a day and after 24 hours or a day, it will change randomly the post , will be that possible? or are there a plugin that exactly does that , </p> <p>actually what Im trying to create ...
[ { "answer_id": 17060, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>Interact with <a href=\"http://codex.wordpress.org/Transients_API\" rel=\"nofollow\">the Transients API</a>. You co...
2011/05/12
[ "https://wordpress.stackexchange.com/questions/17056", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2210/" ]
How do I create a random post but it shouldnt be change when the page is refreshed I want a random post that will last for a day and after 24 hours or a day, it will change randomly the post , will be that possible? or are there a plugin that exactly does that , actually what Im trying to create is like a "Random...
Here is some code doing what you've asked and using the ideas others have highlighted: ``` <?php if ( false === ( $totd_trans_post_id = get_transient( 'totd_trans_post_id' ) ) ) { $args = array('numberposts' => 1, 'orderby' => 'rand'); $totd = get_posts($args); $midnight = strtotime('midnight +1 day'); ...
17,058
<p>I'm writing a theme where I'd like to give users the ability, via a theme option, to specify a typeface for their site with <a href="http://www.google.com/webfonts" rel="nofollow">Google Web Fonts</a>.</p> <p>If a user wants to embed a font like, say, <a href="http://www.google.com/webfonts/family?family=News+Cycle...
[ { "answer_id": 17061, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 3, "selected": true, "text": "<p>Wouldn't a better solution be to build your own list of available fonts, and then let the user select which ...
2011/05/12
[ "https://wordpress.stackexchange.com/questions/17058", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2666/" ]
I'm writing a theme where I'd like to give users the ability, via a theme option, to specify a typeface for their site with [Google Web Fonts](http://www.google.com/webfonts). If a user wants to embed a font like, say, [News Cycle](http://www.google.com/webfonts/family?family=News+Cycle&subset=latin#code), then the co...
Wouldn't a better solution be to build your own list of available fonts, and then let the user select which font to use? That way, your validation is much easier, and also, you have more control over how you use/implement the specific setting. In any case, you should be able to do what you want, within your sanitizati...
17,069
<p>I am working on a custom theme where there is option to upload images . I have certain check-boxes in the form which the users select as per where the image has to go. My form code is as follows :</p> <pre><code>&lt;input type="checkbox" class="input" name="vtype[]" value="3"/&gt; &lt;input type="checkbox" class="i...
[ { "answer_id": 17074, "author": "Geert", "author_id": 4936, "author_profile": "https://wordpress.stackexchange.com/users/4936", "pm_score": 2, "selected": true, "text": "<p>Currently you are passing on this value:</p>\n\n<pre><code>'post_category' =&gt; array('3,4,5') // This is a single...
2011/05/12
[ "https://wordpress.stackexchange.com/questions/17069", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3468/" ]
I am working on a custom theme where there is option to upload images . I have certain check-boxes in the form which the users select as per where the image has to go. My form code is as follows : ``` <input type="checkbox" class="input" name="vtype[]" value="3"/> <input type="checkbox" class="input" name="vtype[]" va...
Currently you are passing on this value: ``` 'post_category' => array('3,4,5') // This is a single string ``` While you should be doing this: ``` 'post_category' => array(3,4,5) // Three separate values ``` Don't forget to sanitize the POST values neither: ``` // Initialize categories $post_category = array(); ...
17,072
<p>I have a custom post type called 'Venue' and I would like my users to be able to create a map to that venue, basically just a marker on a map with the name of the venue and its address. The thing is that I want to create a small snapshot of the map and on hover the website user would click and open the full map in a...
[ { "answer_id": 17076, "author": "NW Tech", "author_id": 5295, "author_profile": "https://wordpress.stackexchange.com/users/5295", "pm_score": 0, "selected": false, "text": "<p>Are you wanting them to go to a larger map on your site or to something like maps.google.com? If you want to lin...
2011/05/12
[ "https://wordpress.stackexchange.com/questions/17072", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5317/" ]
I have a custom post type called 'Venue' and I would like my users to be able to create a map to that venue, basically just a marker on a map with the name of the venue and its address. The thing is that I want to create a small snapshot of the map and on hover the website user would click and open the full map in a ne...
So, the issue is that if you use a google custom embed code, then the iframe sucks up all the clicks, so you can't trigger a link. The solution I've found is to use [Google Static Maps](http://code.google.com/apis/maps/documentation/staticmaps/) which I discovered via [Simple Static Googlemaps Plugin](http://www.grimm...
17,104
<p>I am wondering if there is a way to give users the option of choosing between two formats of displaying posts (index/archive/search result template options) - either view full post, or excerpts?</p> <p>So on the home page you could have a setting "view full posts" and save that setting so that each time the viewer ...
[ { "answer_id": 17105, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 0, "selected": false, "text": "<p>you could set a cookie and then check it in the loop. I've done this in the past with a check box hooked to an ajax...
2011/05/12
[ "https://wordpress.stackexchange.com/questions/17104", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5146/" ]
I am wondering if there is a way to give users the option of choosing between two formats of displaying posts (index/archive/search result template options) - either view full post, or excerpts? So on the home page you could have a setting "view full posts" and save that setting so that each time the viewer visits, th...
Milo beat me to the punch while I was writing this but I will expand on his answer. To set your cookie an easy method would be to use [jQuery Cookie](http://plugins.jquery.com/project/Cookie). Download the plugin and include the cookie js via wp\_enqueue\_script with jquery as a dependency. For your buttons: ``` <...
17,113
<p>Is there a way to have specific css on the homepage and use a different one for all the other pages?</p>
[ { "answer_id": 17105, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 0, "selected": false, "text": "<p>you could set a cookie and then check it in the loop. I've done this in the past with a check box hooked to an ajax...
2011/05/13
[ "https://wordpress.stackexchange.com/questions/17113", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2106/" ]
Is there a way to have specific css on the homepage and use a different one for all the other pages?
Milo beat me to the punch while I was writing this but I will expand on his answer. To set your cookie an easy method would be to use [jQuery Cookie](http://plugins.jquery.com/project/Cookie). Download the plugin and include the cookie js via wp\_enqueue\_script with jquery as a dependency. For your buttons: ``` <...
17,130
<p>I build a lot of websites with Wordpress, and my initial setup is basically always the same : </p> <ul> <li>Latest version of WP</li> <li>Latest versions of about 5 plugins </li> <li>My naked development theme</li> </ul> <p>Instead of downloading/uploading these things separately and do that by hand each time I st...
[ { "answer_id": 17132, "author": "Scott", "author_id": 4610, "author_profile": "https://wordpress.stackexchange.com/users/4610", "pm_score": 2, "selected": false, "text": "<p>To always get latest plugin take for example my plugin:</p>\n\n<p><a href=\"http://wordpress.org/extend/plugins/wo...
2011/05/13
[ "https://wordpress.stackexchange.com/questions/17130", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1381/" ]
I build a lot of websites with Wordpress, and my initial setup is basically always the same : * Latest version of WP * Latest versions of about 5 plugins * My naked development theme Instead of downloading/uploading these things separately and do that by hand each time I start a new project, I'd like to create a bas...
To always get latest plugin take for example my plugin: <http://wordpress.org/extend/plugins/wordpress-file-monitor-plus/> the download link for the latest is: <http://downloads.wordpress.org/plugin/wordpress-file-monitor-plus.1.1.zip> but if you remove the version from the download link you always get the latest v...
17,131
<p>How can I get all enqueued styles or scripts and then deregister them all at once?</p>
[ { "answer_id": 17138, "author": "Hameedullah Khan", "author_id": 5337, "author_profile": "https://wordpress.stackexchange.com/users/5337", "pm_score": 6, "selected": true, "text": "<p>I hope you know what you are doing. You can use the <a href=\"https://developer.wordpress.org/reference/...
2011/05/13
[ "https://wordpress.stackexchange.com/questions/17131", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1226/" ]
How can I get all enqueued styles or scripts and then deregister them all at once?
I hope you know what you are doing. You can use the [`wp_print_styles`](https://developer.wordpress.org/reference/hooks/wp_print_styles/) and [`wp_print_scripts`](https://developer.wordpress.org/reference/hooks/wp_print_scripts/) action hooks and then get the global [`$wp_styles`](https://developer.wordpress.org/refere...
17,135
<p>Just noticed that 3.1 added a new filter to customize queries: posts_clauses. All I could find about it is that instead of using the separate query filters like posts_where or posts_join, you can edit them all in one go. I was wondering if someone could give an example of the usage of the new "posts_clauses" filte...
[ { "answer_id": 17136, "author": "Hameedullah Khan", "author_id": 5337, "author_profile": "https://wordpress.stackexchange.com/users/5337", "pm_score": 4, "selected": true, "text": "<p>Below is the query I found somewhere and was going through it. The purpose of query is to sort the posts...
2011/05/13
[ "https://wordpress.stackexchange.com/questions/17135", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2234/" ]
Just noticed that 3.1 added a new filter to customize queries: posts\_clauses. All I could find about it is that instead of using the separate query filters like posts\_where or posts\_join, you can edit them all in one go. I was wondering if someone could give an example of the usage of the new "posts\_clauses" filter...
Below is the query I found somewhere and was going through it. The purpose of query is to sort the posts based on taxonomy. So, I am sharing the code so it might help you understand the use of posts\_clauses. ``` function color_clauses_mike( $clauses, $query ) { global $wpdb; if ( isset( $query->query['orderby'] ) &&...
17,146
<p>Im using a WordPress transient, which expires after an hour, to store a value which is an integer. Im trying to use <code>switch()</code> and multiple <code>case()</code> statements to evaluate if the transient exists or not (i.e true or false).</p> <p>Here are my questions:</p> <ol> <li>Which comparison operator ...
[ { "answer_id": 17147, "author": "Scott", "author_id": 4610, "author_profile": "https://wordpress.stackexchange.com/users/4610", "pm_score": 3, "selected": true, "text": "<p>Does it have to use a switch?</p>\n\n<p>why not something like this:</p>\n\n<pre><code>if ( false === ( $value = ge...
2011/05/13
[ "https://wordpress.stackexchange.com/questions/17146", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5018/" ]
Im using a WordPress transient, which expires after an hour, to store a value which is an integer. Im trying to use `switch()` and multiple `case()` statements to evaluate if the transient exists or not (i.e true or false). Here are my questions: 1. Which comparison operator (`=`, `==`, `===`), in example 2, is ideal...
Does it have to use a switch? why not something like this: ``` if ( false === ( $value = get_transient( 'value' ) ) ) { // this code runs when there is no valid transient set } else { // this code runs when there is a valid transient set } ``` If the a transient returns a value it will not return true. It ...
17,162
<p>I'm writing a plugin, <em>bar</em>, which is dependent on another plugin, <em>foo</em>, being activated, and I need the functions from <em>foo</em> to be available when <em>bar</em> loads. Normally plugins are loaded in alphabetical order based on the directory name, so <em>bar</em> is loaded before <em>foo</em>. If...
[ { "answer_id": 18352, "author": "Mike", "author_id": 5709, "author_profile": "https://wordpress.stackexchange.com/users/5709", "pm_score": 3, "selected": false, "text": "<p>No matter what, your constructor of bar will always run before the action is called in your code.</p>\n\n<p>I ran i...
2011/05/13
[ "https://wordpress.stackexchange.com/questions/17162", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3898/" ]
I'm writing a plugin, *bar*, which is dependent on another plugin, *foo*, being activated, and I need the functions from *foo* to be available when *bar* loads. Normally plugins are loaded in alphabetical order based on the directory name, so *bar* is loaded before *foo*. If I rename the *bar* directory to *zbar* then ...
Don’t touch the load order, change the activation order instead. A working example can be found in [this answer](https://wordpress.stackexchange.com/questions/16939/does-an-activated-plugin-automatically-mean-its-methods-are-available-to-other-wp/16941#16941).
17,165
<p>When editing categories for my custom post type the selected admin menu is the one for posts (see screenshot). Is this a bug. If not it's kind of non intuitive, and not so good for the end users experience.</p> <p><a href="https://i.stack.imgur.com/aBQpb.png" rel="nofollow noreferrer">Screenshot</a></p> <p>Code:</...
[ { "answer_id": 17166, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>You need to set up a custom taxonomy and then add the name of the custom tax via the \"taxonomies\" arg when regist...
2011/05/13
[ "https://wordpress.stackexchange.com/questions/17165", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5347/" ]
When editing categories for my custom post type the selected admin menu is the one for posts (see screenshot). Is this a bug. If not it's kind of non intuitive, and not so good for the end users experience. [Screenshot](https://i.stack.imgur.com/aBQpb.png) Code: ``` function product_register_product_post_type() { ...
You need to set up a custom taxonomy and then add the name of the custom tax via the "taxonomies" arg when registering the custom post type.
17,201
<p>I'm looking for a simple way for a Wordpress plugin to process <code>$_POST</code> data from a <strong>user</strong> submitted form. Back end processing will be performed and then I'll redirect to a new page as appropriate — so during processing there is no UI.</p> <p>Basically, I want to take a form submit such a...
[ { "answer_id": 17216, "author": "Hameedullah Khan", "author_id": 5337, "author_profile": "https://wordpress.stackexchange.com/users/5337", "pm_score": 2, "selected": false, "text": "<p>The best way to process the custom form is the following. If you are using nonce then you don't really ...
2011/05/14
[ "https://wordpress.stackexchange.com/questions/17201", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5356/" ]
I'm looking for a simple way for a Wordpress plugin to process `$_POST` data from a **user** submitted form. Back end processing will be performed and then I'll redirect to a new page as appropriate — so during processing there is no UI. Basically, I want to take a form submit such as... ``` <form method="post" ac...
The best way to process the custom form is the following. If you are using nonce then you don't really have to check $\_POST['checkbox'], the code below can be used simply to verify\_nonce and then process the form. ``` function process_my_form() { if ( wp_verify_nonce( $_POST['my_nonce_field'], 'my_nonce' ) ) { ...
17,217
<p>I'm probably doing this all wrong, and there'll be a much simpler solution. Basically, I'm trying to build a table of tour dates that'll be editable by someone with little technical knowledge, but can handle shortcodes. There's also some custom functions in the table (with regards to displaying the date, and having ...
[ { "answer_id": 17221, "author": "Digitalchild", "author_id": 3170, "author_profile": "https://wordpress.stackexchange.com/users/3170", "pm_score": 0, "selected": false, "text": "<p>Have you heard of <a href=\"http://gigpress.com/\" rel=\"nofollow\">gigpress</a> ? This would give you the ...
2011/05/14
[ "https://wordpress.stackexchange.com/questions/17217", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5363/" ]
I'm probably doing this all wrong, and there'll be a much simpler solution. Basically, I'm trying to build a table of tour dates that'll be editable by someone with little technical knowledge, but can handle shortcodes. There's also some custom functions in the table (with regards to displaying the date, and having an ...
The extra space comes from `wpautop()`, which inserts `<br />` on every line break. You have to strip these out before calling `do_shortcode()`. Additionally, use `add_filter( 'the_content', 'shortcode_unautop' );`. From my experience, you need both. Probably a bug. See my [shortcode plugin](https://github.com/tosch...
17,218
<p>How can I add a CSS Class to the <code>previous_post_link</code> output or just get the URL and create the HTML markup myself</p>
[ { "answer_id": 17219, "author": "Digitalchild", "author_id": 3170, "author_profile": "https://wordpress.stackexchange.com/users/3170", "pm_score": 3, "selected": false, "text": "<p>You could put an element around the function call and style it that way. Like this: </p>\n\n<pre><code>&lt;...
2011/05/14
[ "https://wordpress.stackexchange.com/questions/17218", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/794/" ]
How can I add a CSS Class to the `previous_post_link` output or just get the URL and create the HTML markup myself
You can use the more native function that is "below" the `previous_/next_post_link();`: ``` # get_adjacent_post( $in_same_cat = false, $excluded_categories = '', $previous = true ) $next_post_obj = get_adjacent_post( '', '', false ); $next_post_ID = isset( $next_post_obj->ID ) ? $next_post_obj->ID : ''; $next_post_...
17,222
<p>Is there a way to show a list of all categories available even if there are no posts associated with them. So if there is a post in that category then it echos a link and if not it just echos out the name of the category?</p> <p>I'm using wp_list_categories() to show them...</p>
[ { "answer_id": 17223, "author": "Geert", "author_id": 4936, "author_profile": "https://wordpress.stackexchange.com/users/4936", "pm_score": 4, "selected": true, "text": "<p>There's an argument called <code>hide_empty</code> which is true by default.</p>\n\n<pre><code>$args = array('hide_...
2011/05/14
[ "https://wordpress.stackexchange.com/questions/17222", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2496/" ]
Is there a way to show a list of all categories available even if there are no posts associated with them. So if there is a post in that category then it echos a link and if not it just echos out the name of the category? I'm using wp\_list\_categories() to show them...
There's an argument called `hide_empty` which is true by default. ``` $args = array('hide_empty' => FALSE); wp_list_categories($args); ``` Codex: [`wp_list_categories()`](http://codex.wordpress.org/Template_Tags/wp_list_categories)
17,224
<p>I created 1 custom post type with 2 custom taxonomy. Installed <a href="http://wordpress.org/extend/plugins/json-api/">http://wordpress.org/extend/plugins/json-api/</a> and tried to reach result with: <a href="http://example.com/api/get_recent_posts?dev=1&amp;post_type=myposttype">http://example.com/api/get_recent_...
[ { "answer_id": 18175, "author": "Dan Gayle", "author_id": 10, "author_profile": "https://wordpress.stackexchange.com/users/10", "pm_score": 0, "selected": false, "text": "<p>There ARE hooks available. <a href=\"http://wordpress.org/extend/plugins/json-api/other_notes/#Filter:-json_api_co...
2011/05/14
[ "https://wordpress.stackexchange.com/questions/17224", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1372/" ]
I created 1 custom post type with 2 custom taxonomy. Installed <http://wordpress.org/extend/plugins/json-api/> and tried to reach result with: <http://example.com/api/get_recent_posts?dev=1&post_type=myposttype> well it gives me custom posts but not giving those post's custom taxonomies "categories": [], "tags": []...
I would have done it as following, I am sure experts here will have a better way but following is what I could come up with in hurry. First create your controller file in your theme directory (or any other if you like) with the following content. For this example the file name is korkmaz.php **UPDATE 1:** Please repl...
17,233
<p>I am working on a custom job board for a client that wants to deploy this job board on a multi-site network. Here is my problem, I need to store certain jobs in a table that would be accessible to all sites in the network (e.g. a nationwide listing) instead of just locally (e.g. local listing).</p> <p>My question: ...
[ { "answer_id": 17239, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 1, "selected": false, "text": "<p>I don't see any reason why you should not stay with a regular custom post type, that is how the data is stored in t...
2011/05/14
[ "https://wordpress.stackexchange.com/questions/17233", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5366/" ]
I am working on a custom job board for a client that wants to deploy this job board on a multi-site network. Here is my problem, I need to store certain jobs in a table that would be accessible to all sites in the network (e.g. a nationwide listing) instead of just locally (e.g. local listing). My question: can data f...
You certainly can save the data however you choose using the save\_post action. Simply, place this in your functions.php file. ``` add_action('save_post', 'foo_save_custom_post_type'); function foo_save_custom_post_type(){ //Use the following debug code to see what information is available to you /* echo "...
17,240
<p>Every time I edit a WordPress post or page that has a google map embedded in it - useing the "visual" edit mode - wordpress deletes part of the data. </p> <p>for example: this</p> <pre><code>&lt;iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google....
[ { "answer_id": 17243, "author": "mrtsherman", "author_id": 4013, "author_profile": "https://wordpress.stackexchange.com/users/4013", "pm_score": 1, "selected": false, "text": "<p>I don't know for certain, but I think it may be related to the allowed tags for posts. See my question from a...
2011/05/14
[ "https://wordpress.stackexchange.com/questions/17240", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4900/" ]
Every time I edit a WordPress post or page that has a google map embedded in it - useing the "visual" edit mode - wordpress deletes part of the data. for example: this ``` <iframe width="425" height="350" frameborder="0" scrolling="no" marginheight="0" marginwidth="0" src="http://maps.google.com/maps/ms?ie=UTF8&amp;...
The issue is WordPress' core configuration of TinyMCE, which strips IFRAME tags. You can modify this configuration, to allow IFRAME tags, by hooking into `tiny_mce_before_init`. For example, the following code will prevent TinyMCE from stripping IFRAME, PRE, and DIV tags: ``` function mytheme_tinymce_config( $init ) ...
17,241
<p>I would like to remove some of the media upload buttons just above TinyMCE in the Add post screen, how can I do that? Thanks.</p>
[ { "answer_id": 17244, "author": "Geert", "author_id": 4936, "author_profile": "https://wordpress.stackexchange.com/users/4936", "pm_score": 2, "selected": false, "text": "<p>If you want to get rid all <em>all</em> media buttons, you can remove the <code>media_buttons</code> action:</p>\n...
2011/05/14
[ "https://wordpress.stackexchange.com/questions/17241", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5370/" ]
I would like to remove some of the media upload buttons just above TinyMCE in the Add post screen, how can I do that? Thanks.
If you want to get rid all *all* media buttons, you can remove the `media_buttons` action: ``` add_action('admin_init', 'remove_all_media_buttons'); function remove_all_media_buttons() { remove_all_actions('media_buttons'); } ``` Since you only want to remove some buttons, I suggest adding an admin stylesheet: ...
17,250
<p>I'm writing my own plugin.</p> <p>works like this:</p> <pre><code>function myfunc (){ $a = 'hello'; // the sentence what Am looking for: if ( user is logged and is the author of current post / page ){ $a= 'author'; } return $a; } </code></pre> <p>Wondering how I can do that sencence ...
[ { "answer_id": 17244, "author": "Geert", "author_id": 4936, "author_profile": "https://wordpress.stackexchange.com/users/4936", "pm_score": 2, "selected": false, "text": "<p>If you want to get rid all <em>all</em> media buttons, you can remove the <code>media_buttons</code> action:</p>\n...
2011/05/14
[ "https://wordpress.stackexchange.com/questions/17250", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3294/" ]
I'm writing my own plugin. works like this: ``` function myfunc (){ $a = 'hello'; // the sentence what Am looking for: if ( user is logged and is the author of current post / page ){ $a= 'author'; } return $a; } ``` Wondering how I can do that sencence / function?
If you want to get rid all *all* media buttons, you can remove the `media_buttons` action: ``` add_action('admin_init', 'remove_all_media_buttons'); function remove_all_media_buttons() { remove_all_actions('media_buttons'); } ``` Since you only want to remove some buttons, I suggest adding an admin stylesheet: ...
17,254
<p>So... what I'm trying to do is simple - get the post content for all posts, but only in a given category. Simple - filter the loop using in_category. So I did this (this is actually a stripped version of the loop I used to try to troubleshoot this): </p> <pre><code> &lt;?php if ( have_posts() ) : while ( have_po...
[ { "answer_id": 17260, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 1, "selected": false, "text": "<p>The problem is that you are using a conditional tag only after querying the posts, so you are getting post fr...
2011/05/14
[ "https://wordpress.stackexchange.com/questions/17254", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2624/" ]
So... what I'm trying to do is simple - get the post content for all posts, but only in a given category. Simple - filter the loop using in\_category. So I did this (this is actually a stripped version of the loop I used to try to troubleshoot this): ``` <?php if ( have_posts() ) : while ( have_posts() ) : the_po...
it should be ``` in_category(7) ``` integer, not string. but a better way to do this is: ``` query_posts('cat=7'); if ( have_posts() ) : while ( have_posts() ) : the_post(); endwhile; endif; ```
17,265
<p>I am moving my site from olddomain.com to newdomain.com. I want to keep all of the content at olddomain.com but I want the canonical version in google to be recognized as newdomain.com/whatever-post/ instead of the same thing at olddomain.com.</p> <p>How can I modify the rel=canonical in the section of olddomain.c...
[ { "answer_id": 17267, "author": "goldenapples", "author_id": 290, "author_profile": "https://wordpress.stackexchange.com/users/290", "pm_score": 3, "selected": true, "text": "<p>Unfortunately, there's no filter in the <code>rel_canonical()</code> function. But you can remove that functio...
2011/05/14
[ "https://wordpress.stackexchange.com/questions/17265", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3271/" ]
I am moving my site from olddomain.com to newdomain.com. I want to keep all of the content at olddomain.com but I want the canonical version in google to be recognized as newdomain.com/whatever-post/ instead of the same thing at olddomain.com. How can I modify the rel=canonical in the section of olddomain.com to make ...
Unfortunately, there's no filter in the `rel_canonical()` function. But you can remove that function from wp\_head altogether and write your own. Try adding this to the functions.php at your old domain: ``` remove_action( 'wp_head', 'rel_canonical' ); add_action( 'wp_head', 'new_rel_canonical' ); function new_rel_can...
17,268
<p>Here is what I want to have</p> <p>My category Structure in WP admin</p> <pre><code>Cat Parent -Cat Child 1 -Cat Child 2 -Cat Child 3 -Cat Child 1 </code></pre> <p>This what I want to have in one template:</p> <p>It show the list of post in Cat Parent Children Category</p> <pre><code>Cat Child 1 -Post1...
[ { "answer_id": 17279, "author": "Michael", "author_id": 4884, "author_profile": "https://wordpress.stackexchange.com/users/4884", "pm_score": 3, "selected": true, "text": "<p>get the child categories, using <a href=\"http://codex.wordpress.org/Function_Reference/get_categories\" rel=\"no...
2011/05/15
[ "https://wordpress.stackexchange.com/questions/17268", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/420/" ]
Here is what I want to have My category Structure in WP admin ``` Cat Parent -Cat Child 1 -Cat Child 2 -Cat Child 3 -Cat Child 1 ``` This what I want to have in one template: It show the list of post in Cat Parent Children Category ``` Cat Child 1 -Post1 Child 1 -Post2 Child 1 -Post3 Child 1 -So on......
get the child categories, using [get\_categories()](http://codex.wordpress.org/Function_Reference/get_categories); then loop through them with a foreach loop, using [WP\_Query()](http://codex.wordpress.org/Function_Reference/WP_Query) : ``` <?php $cats = get_categories('child_of='.get_query_var('cat')); foreach...
17,273
<p>I dont know why my custom post types render the Page not found. This is the code I am using to register custom posts.</p> <p><code>www.example.com/products/product1/</code> renders 404 where as <code>www.example.com/?products=product1</code> is perfectly fine.</p> <pre><code>add_action( 'init', 'create_post_type' ...
[ { "answer_id": 17274, "author": "aaronwaggs", "author_id": 5376, "author_profile": "https://wordpress.stackexchange.com/users/5376", "pm_score": 2, "selected": false, "text": "<p>Have you refreshed your rewrite rules? You can do this by resaving your permalink settings under Settings>Per...
2011/05/15
[ "https://wordpress.stackexchange.com/questions/17273", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1555/" ]
I dont know why my custom post types render the Page not found. This is the code I am using to register custom posts. `www.example.com/products/product1/` renders 404 where as `www.example.com/?products=product1` is perfectly fine. ``` add_action( 'init', 'create_post_type' ); function create_post_type() { regist...
Have you refreshed your rewrite rules? You can do this by resaving your permalink settings under Settings>Permalinks in the admin. If it is a plugin or theme you are distributing you can call `$wp_rewrite->flush_rules();` upon activation.
17,285
<p>I have a search function on my blog. If I enter a value, say 'fruits' in the search box and it doesn't match in any of the posts but it is the name of a category in the blog then I want the posts that belong to that category to be displayed.</p> <p>Is it possible to amend the search functionality so it covers the s...
[ { "answer_id": 17297, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<pre><code>// Above the loop on your search result template:\nif ( is_search() ) // Are we on a search result page?\n{...
2011/05/15
[ "https://wordpress.stackexchange.com/questions/17285", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5162/" ]
I have a search function on my blog. If I enter a value, say 'fruits' in the search box and it doesn't match in any of the posts but it is the name of a category in the blog then I want the posts that belong to that category to be displayed. Is it possible to amend the search functionality so it covers the searching o...
``` // Above the loop on your search result template: if ( is_search() ) // Are we on a search result page? { global $wp_query, $query_string; // now modify/filter the query (result) query_posts( $query_string . 'cat=1&tag=apples+apples' ); } ```
17,286
<p>I use a function in my blog (getImage) to call thumbnails in the loop (it calls the 1st image on the post) but instead of link to the post, i would want the thumbnail to link to its full image src.</p> <p>The function is this one:</p> <pre><code>function getImages($num) { global $more; $more = 1; $link = get_perma...
[ { "answer_id": 17297, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<pre><code>// Above the loop on your search result template:\nif ( is_search() ) // Are we on a search result page?\n{...
2011/05/15
[ "https://wordpress.stackexchange.com/questions/17286", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5386/" ]
I use a function in my blog (getImage) to call thumbnails in the loop (it calls the 1st image on the post) but instead of link to the post, i would want the thumbnail to link to its full image src. The function is this one: ``` function getImages($num) { global $more; $more = 1; $link = get_permalink(); -> NO IDEA IF...
``` // Above the loop on your search result template: if ( is_search() ) // Are we on a search result page? { global $wp_query, $query_string; // now modify/filter the query (result) query_posts( $query_string . 'cat=1&tag=apples+apples' ); } ```
17,287
<p>I am actually displaying a number beside my comments putting <code>$counter = 0;</code> before wp_list_comments in comments.php and</p> <pre><code>global $counter; $counter++; </code></pre> <p>inside the comments callback function in functions.php</p> <p>Now this is working fine, but since I'm using threaded com...
[ { "answer_id": 17297, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<pre><code>// Above the loop on your search result template:\nif ( is_search() ) // Are we on a search result page?\n{...
2011/05/15
[ "https://wordpress.stackexchange.com/questions/17287", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2119/" ]
I am actually displaying a number beside my comments putting `$counter = 0;` before wp\_list\_comments in comments.php and ``` global $counter; $counter++; ``` inside the comments callback function in functions.php Now this is working fine, but since I'm using threaded comments, my numbers are looking strange (1,4...
``` // Above the loop on your search result template: if ( is_search() ) // Are we on a search result page? { global $wp_query, $query_string; // now modify/filter the query (result) query_posts( $query_string . 'cat=1&tag=apples+apples' ); } ```
17,303
<p>My theme automatically assign before of <code>&lt;!--more--&gt;</code> tags, as excerpt.And showing excerpt on home page. Now i want to add Google Adsense after <code>&lt;!-- more --&gt;</code> code. I'm wrote this function and add it to functions.php</p> <pre><code>function google_adsense($content) { if(is_sin...
[ { "answer_id": 17310, "author": "Michael", "author_id": 4884, "author_profile": "https://wordpress.stackexchange.com/users/4884", "pm_score": 2, "selected": true, "text": "<p>you have forgotten to return the unaltered $content if this is not a single post:</p>\n\n<pre><code>function goog...
2011/05/15
[ "https://wordpress.stackexchange.com/questions/17303", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3552/" ]
My theme automatically assign before of `<!--more-->` tags, as excerpt.And showing excerpt on home page. Now i want to add Google Adsense after `<!-- more -->` code. I'm wrote this function and add it to functions.php ``` function google_adsense($content) { if(is_single()) { global $post; $theP...
you have forgotten to return the unaltered $content if this is not a single post: ``` function google_adsense($content) { if(is_single()) { global $post; $thePostID = $post->ID; $more_span = '<span id="more-' .$thePostID.'"></span>' ; return str_replace($mo...
17,313
<p><strong>What I want:</strong></p> <p>Two wordpress blogs with separate cats and tags</p> <pre><code>reggi.com/portfolio/category/example reggi.com/blog/category/example reggi.com/portfolio/tags/example reggi.com/blog/tags/example </code></pre> <p>Site root to not be wordpress or to be a static page with custom te...
[ { "answer_id": 17316, "author": "Steven", "author_id": 1447, "author_profile": "https://wordpress.stackexchange.com/users/1447", "pm_score": 0, "selected": false, "text": "<p>Then I suggest you use WP for you main site as well.</p>\n\n<p>Just create a custom template like this:</p>\n\n<p...
2011/05/15
[ "https://wordpress.stackexchange.com/questions/17313", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5396/" ]
**What I want:** Two wordpress blogs with separate cats and tags ``` reggi.com/portfolio/category/example reggi.com/blog/category/example reggi.com/portfolio/tags/example reggi.com/blog/tags/example ``` Site root to not be wordpress or to be a static page with custom template ``` reggi.com/ <-- NOT wordpress reggi...
Create two custom post types, one for each blog. Then you can add custom taxonomies to each one of them.
17,318
<p>What is the best way to disable feeds per post type but keep has_archive enabled?</p>
[ { "answer_id": 41775, "author": "Tomas Buteler", "author_id": 5552, "author_profile": "https://wordpress.stackexchange.com/users/5552", "pm_score": 2, "selected": true, "text": "<p>I ran into this issue today. I don't know if it's the best way, but here's how I solved it (with <code>has_...
2011/05/15
[ "https://wordpress.stackexchange.com/questions/17318", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1057/" ]
What is the best way to disable feeds per post type but keep has\_archive enabled?
I ran into this issue today. I don't know if it's the best way, but here's how I solved it (with `has_archive` still set to true, of course): ``` // First we remove WP default feed actions // If we stop here, feeds would be disabled altogether remove_action('do_feed_rdf', 'do_feed_rdf', 10, 1); remove_action('do_feed_...
17,325
<p>If you have a category called "term" and a subcategory called "subterm", your can access subterm posts at /cat/subcat. But this doesn't work out of the box with custom taxonomies. They are accessible at /taxonomy/subterm, but not /taxonomy/term/subterm.</p> <p>They've gone over this in the Wordpress Trac (<a href...
[ { "answer_id": 17329, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 4, "selected": true, "text": "<p>This is implemented in WordPress now as of 3.1.</p>\n\n<p>When you <a href=\"http://codex.wordpress.org/Function_Ref...
2011/05/15
[ "https://wordpress.stackexchange.com/questions/17325", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3564/" ]
If you have a category called "term" and a subcategory called "subterm", your can access subterm posts at /cat/subcat. But this doesn't work out of the box with custom taxonomies. They are accessible at /taxonomy/subterm, but not /taxonomy/term/subterm. They've gone over this in the Wordpress Trac (<http://core.trac.w...
This is implemented in WordPress now as of 3.1. When you [register your taxonomy](http://codex.wordpress.org/Function_Reference/register_taxonomy), make sure to set rewrite hierarchical to true as well as the taxonomy itself: ``` <?php register_taxonomy('genre',array('book'), array( 'hierarchical' => true, // this ma...
17,332
<p>I have just started a programming blog and I am using the SyntaxHightlighter Evolved plugin to format my code. On most browsers this is working just fine. However if I attempt to view the site from either an iPhone or iPad the line numbers and code are no longer aligned. Basically the problem seems to be that the li...
[ { "answer_id": 17329, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 4, "selected": true, "text": "<p>This is implemented in WordPress now as of 3.1.</p>\n\n<p>When you <a href=\"http://codex.wordpress.org/Function_Ref...
2011/05/15
[ "https://wordpress.stackexchange.com/questions/17332", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5382/" ]
I have just started a programming blog and I am using the SyntaxHightlighter Evolved plugin to format my code. On most browsers this is working just fine. However if I attempt to view the site from either an iPhone or iPad the line numbers and code are no longer aligned. Basically the problem seems to be that the line ...
This is implemented in WordPress now as of 3.1. When you [register your taxonomy](http://codex.wordpress.org/Function_Reference/register_taxonomy), make sure to set rewrite hierarchical to true as well as the taxonomy itself: ``` <?php register_taxonomy('genre',array('book'), array( 'hierarchical' => true, // this ma...
17,355
<p>There is a site at <code>http://theprimarkonlineshop.com</code> that I want to be redirected to <code>http://theprimarkonlineshop.com/category/blog</code> when a user enters the site. I've tried some stuff like </p> <pre><code>RewriteEngine on RewriteCond %{REQUEST_FILENAME} ^/$ [OR] RewriteCond %{REQUEST_FILENAME...
[ { "answer_id": 18498, "author": "Manuel", "author_id": 5753, "author_profile": "https://wordpress.stackexchange.com/users/5753", "pm_score": 2, "selected": false, "text": "<p>See Codex for running a development copy of wordpress. You can make all the changes you want on the blog without ...
2011/05/16
[ "https://wordpress.stackexchange.com/questions/17355", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5409/" ]
There is a site at `http://theprimarkonlineshop.com` that I want to be redirected to `http://theprimarkonlineshop.com/category/blog` when a user enters the site. I've tried some stuff like ``` RewriteEngine on RewriteCond %{REQUEST_FILENAME} ^/$ [OR] RewriteCond %{REQUEST_FILENAME} ^$ RewriteRule . http://theprimar...
See Codex for running a development copy of wordpress. You can make all the changes you want on the blog without affecting the production site by testing out new themes/etc which is what it seems like you're looking to do. <http://codex.wordpress.org/Running_a_Development_Copy_of_WordPress#WordPress_2.7_-_3.0>
17,358
<p>The following code was mentioned from one of the commentors, however it is breaking the pagination. Any corrections please</p> <pre><code> &lt;?php include(TEMPLATEPATH. '/includes/headline.php'); rewind_posts(); if (have_posts()) { echo '&lt;div class="gridrow clear"&gt;'; while (have_posts()...
[ { "answer_id": 17361, "author": "Hameedullah Khan", "author_id": 5337, "author_profile": "https://wordpress.stackexchange.com/users/5337", "pm_score": 3, "selected": true, "text": "<p>You need to tell Wordpress to get only 5 posts per page. The parameter to do this is posts_per_page. You...
2011/05/16
[ "https://wordpress.stackexchange.com/questions/17358", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5411/" ]
The following code was mentioned from one of the commentors, however it is breaking the pagination. Any corrections please ``` <?php include(TEMPLATEPATH. '/includes/headline.php'); rewind_posts(); if (have_posts()) { echo '<div class="gridrow clear">'; while (have_posts()) : the_post(); glo...
You need to tell Wordpress to get only 5 posts per page. The parameter to do this is posts\_per\_page. You should use query\_posts() function before your have posts as in the following example. ``` <?php // your includes and stuff global $query_string; query_posts( $query_string . '&posts_per_page=5' ); ...
17,367
<p>How do I hide the page editor (WYSIWYG editor) if the current page is set to a certain template.</p> <p>I have the following code already to add in custom meta boxes when certain templates are chosen:</p> <pre><code>add_action('admin_init','my_meta_init'); function my_meta_init() { $post_id = $_GET['post'] ? $...
[ { "answer_id": 17368, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 2, "selected": false, "text": "<p>you can add a simple CSS rule with <code>display:none;</code> in your metabox function code:</p>\n\n<pre><cod...
2011/05/16
[ "https://wordpress.stackexchange.com/questions/17367", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4610/" ]
How do I hide the page editor (WYSIWYG editor) if the current page is set to a certain template. I have the following code already to add in custom meta boxes when certain templates are chosen: ``` add_action('admin_init','my_meta_init'); function my_meta_init() { $post_id = $_GET['post'] ? $_GET['post'] : $_POST...
``` add_action( 'init', 'remove_editor_init' ); function remove_editor_init() { // If not in the admin, return. if ( ! is_admin() ) { return; } // Get the post ID on edit post with filter_input super global inspection. $current_post_id = filter_input( INPUT_GET, 'post', FILTER_SANITIZE_NUMB...
17,369
<p>I'm using a custom post type to let contributors have a personal page on the site.</p> <p>Any time a user registers on my site a script creates a custom type post that has the registering user as the author.</p> <p>To moderate users' entries this post is published by an editor.</p> <p>I would like users (contribu...
[ { "answer_id": 17396, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 4, "selected": true, "text": "<p>Using Role editor or role scope you can set contributors to edit you custom post type but not publish so every...
2011/05/16
[ "https://wordpress.stackexchange.com/questions/17369", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4155/" ]
I'm using a custom post type to let contributors have a personal page on the site. Any time a user registers on my site a script creates a custom type post that has the registering user as the author. To moderate users' entries this post is published by an editor. I would like users (contributors) to be: * unable t...
Using Role editor or role scope you can set contributors to edit you custom post type but not publish so every change will be set as draft until approval, and to limit the creation of new posts of your custom post type you can use my plugin [**Bainternet Posts Creation Limits**](http://wordpress.org/extend/plugins/bain...
17,377
<p>I know there are other, maybe better ways to do what I want to achieve, but I have to use this solution.</p> <p>I have two stylesheets:</p> <ul> <li><code>style.css</code> - normal stylesheet</li> <li><code>style-dynamic.php</code> - dynamic stylesheet linked to the first one</li> </ul> <p>I'm using some PHP code...
[ { "answer_id": 17378, "author": "Wordpressor", "author_id": 1869, "author_profile": "https://wordpress.stackexchange.com/users/1869", "pm_score": 4, "selected": true, "text": "<p>Christ, once again I was fighting with something for a few days straight and found a solution 20 minutes afte...
2011/05/16
[ "https://wordpress.stackexchange.com/questions/17377", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1869/" ]
I know there are other, maybe better ways to do what I want to achieve, but I have to use this solution. I have two stylesheets: * `style.css` - normal stylesheet * `style-dynamic.php` - dynamic stylesheet linked to the first one I'm using some PHP code in the second one, like: ``` #body { background-color: <?p...
Christ, once again I was fighting with something for a few days straight and found a solution 20 minutes after asking on StackExchange. WHY? ``` require_once('../../../wp-load.php'); ```
17,385
<p>I'd like to offer my custom post type as a Plugin, so that people can use it without touching their theme folder. But custom post type templates -- such as single-movies.php -- reside in the theme folder. Is there a way to get WP to check for a single-movies.php in the plugin's folder? Hooking a function into the <...
[ { "answer_id": 17388, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 8, "selected": true, "text": "<p>You can use <code>single_template</code> filter hook.</p>\n\n<pre><code>/* Filter the single_template with our...
2011/05/16
[ "https://wordpress.stackexchange.com/questions/17385", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5285/" ]
I'd like to offer my custom post type as a Plugin, so that people can use it without touching their theme folder. But custom post type templates -- such as single-movies.php -- reside in the theme folder. Is there a way to get WP to check for a single-movies.php in the plugin's folder? Hooking a function into the [File...
You can use `single_template` filter hook. ``` /* Filter the single_template with our custom function*/ add_filter('single_template', 'my_custom_template'); function my_custom_template($single) { global $post; /* Checks for single template by post type */ if ( $post->post_type == 'POST TYPE NAME' ) { ...
17,394
<p>Is there a way to know what functions are hooked to a particular hook? For example if I'd like to know what functions are hooked to the <code>wp_head</code> hook.</p>
[ { "answer_id": 17397, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 5, "selected": true, "text": "<p>Look into the global variable <code>$wp_filter</code>. See my <a href=\"https://gist.github.com/867302\" rel=\"nofollow...
2011/05/16
[ "https://wordpress.stackexchange.com/questions/17394", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3893/" ]
Is there a way to know what functions are hooked to a particular hook? For example if I'd like to know what functions are hooked to the `wp_head` hook.
Look into the global variable `$wp_filter`. See my [plugin for a list of all comment filters](https://gist.github.com/867302) for an example: ``` <?php /* Plugin Name: List Comment Filters Description: List all comment filters on wp_footer Version: 1.1 Author: Fuxia Scholz License: GPL v2 */ add_action( ...
17,400
<p>I have learned how to create a post from the frontend but how about editing it ? This is the code <a href="https://wordpress.stackexchange.com/questions/15283/i-am-trying-to-create-a-simple-frontend-form-for-posting/15288#15288">I am trying to create a simple frontend form for posting</a></p> <p>Thank you</p>
[ { "answer_id": 17403, "author": "MartinJJ", "author_id": 3710, "author_profile": "https://wordpress.stackexchange.com/users/3710", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://scribu.net/wordpress/front-end-editor\" rel=\"nofollow\"><strong>Scribu Front End Editor</stro...
2011/05/16
[ "https://wordpress.stackexchange.com/questions/17400", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4448/" ]
I have learned how to create a post from the frontend but how about editing it ? This is the code [I am trying to create a simple frontend form for posting](https://wordpress.stackexchange.com/questions/15283/i-am-trying-to-create-a-simple-frontend-form-for-posting/15288#15288) Thank you
Just like the example you linked, but instead of using `wp_insert_post()` you use: `wp_update_post()` so your form becomes: ``` <?php $post_to_edit = get_post($post_id); ?> <!-- edit Post Form --> <div id="postbox"> <form id="new_post" name="new_post" method="post" action=""> <p> <label for="...
17,413
<p>Currently I'm using Simple Local Avatars on several of my blogs allowing people to upload their own custom avatar.</p> <p>As far as I know Simple Local Avatars uses <code>get_avatar</code> to check whether a custom avatar is selected, if not defaults to Gravatar.com.</p> <p>Would it be possible to disable the Grav...
[ { "answer_id": 17433, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 4, "selected": true, "text": "<p>If you want a super-lightweight solution and don't mind dabbling in a little code, drop this in your <code>f...
2011/05/16
[ "https://wordpress.stackexchange.com/questions/17413", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
Currently I'm using Simple Local Avatars on several of my blogs allowing people to upload their own custom avatar. As far as I know Simple Local Avatars uses `get_avatar` to check whether a custom avatar is selected, if not defaults to Gravatar.com. Would it be possible to disable the Gravatar.com bit somehow, disabl...
If you want a super-lightweight solution and don't mind dabbling in a little code, drop this in your `functions.php`; ``` function __default_local_avatar() { // this assumes default_avatar.png is in wp-content/themes/active-theme/images return get_bloginfo('template_directory') . '/images/default_avatar.png'; ...
17,419
<p>I'm looking to create individual archives for each category of my website, but want to them to break into weeks. Check out the linked image (can't embed images as a new user?):</p> <p><a href="https://i.stack.imgur.com/ynHWb.png" rel="nofollow noreferrer">http://i.stack.imgur.com/ynHWb.png</a></p> <p>I'm finding r...
[ { "answer_id": 17424, "author": "alexndm", "author_id": 4678, "author_profile": "https://wordpress.stackexchange.com/users/4678", "pm_score": 1, "selected": false, "text": "<pre><code>&lt;?php $args = array(\n 'type' =&gt; 'weekly',\n 'limit' =&gt; ,\n 'form...
2011/05/16
[ "https://wordpress.stackexchange.com/questions/17419", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5425/" ]
I'm looking to create individual archives for each category of my website, but want to them to break into weeks. Check out the linked image (can't embed images as a new user?): [http://i.stack.imgur.com/ynHWb.png](https://i.stack.imgur.com/ynHWb.png) I'm finding real difficulties here: 1) Breaking archives out weekl...
``` <?php $args = array( 'type' => 'weekly', 'limit' => , 'format' => 'html', 'before' => , 'after' => , 'show_post_count' => false, 'echo' => 1 ); ?> <?php wp_get_archives( $args ); ?> ``` See this Codex article: [`wp_get_archiv...
17,421
<p>I'm trying to make something more meaningful out of the <a href="http://codex.wordpress.org/Template_Tags/wp_link_pages" rel="nofollow"><code>wp_link_pages()</code></a> result:</p> <pre><code>$paged_page_nav = wp_link_pages( array( 'echo' =&gt; false ) ); // Now let's wrap the nav inside &lt;li&gt;-elements $paged_...
[ { "answer_id": 17424, "author": "alexndm", "author_id": 4678, "author_profile": "https://wordpress.stackexchange.com/users/4678", "pm_score": 1, "selected": false, "text": "<pre><code>&lt;?php $args = array(\n 'type' =&gt; 'weekly',\n 'limit' =&gt; ,\n 'form...
2011/05/16
[ "https://wordpress.stackexchange.com/questions/17421", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/385/" ]
I'm trying to make something more meaningful out of the [`wp_link_pages()`](http://codex.wordpress.org/Template_Tags/wp_link_pages) result: ``` $paged_page_nav = wp_link_pages( array( 'echo' => false ) ); // Now let's wrap the nav inside <li>-elements $paged_page_nav = str_replace( '<a', '<li class="'.$classes.'"><a',...
``` <?php $args = array( 'type' => 'weekly', 'limit' => , 'format' => 'html', 'before' => , 'after' => , 'show_post_count' => false, 'echo' => 1 ); ?> <?php wp_get_archives( $args ); ?> ``` See this Codex article: [`wp_get_archiv...
17,434
<p>I'm trying to add a new menu item to the WordPress admin bar. The sub menu item contains a select drop down to switch themes. In Firefox with <code>href =&gt; false</code> it generated <code>&lt;a href=""&gt;</code> and when I clicked the select it reloaded the page. I changed it to <code>&lt;a href="#"&gt;</code>. ...
[ { "answer_id": 17447, "author": "pixeline", "author_id": 82, "author_profile": "https://wordpress.stackexchange.com/users/82", "pm_score": 2, "selected": false, "text": "<p>Obviously you cannot put a select tag inside a A anchor. What happens is related to event bubbling: Firefox takes t...
2011/05/16
[ "https://wordpress.stackexchange.com/questions/17434", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5435/" ]
I'm trying to add a new menu item to the WordPress admin bar. The sub menu item contains a select drop down to switch themes. In Firefox with `href => false` it generated `<a href="">` and when I clicked the select it reloaded the page. I changed it to `<a href="#">`. That fixed the page reload when clicking on the sel...
Obviously you cannot put a select tag inside a A anchor. What happens is related to event bubbling: Firefox takes the A anchor click into account, not the select control. Change your html to: ``` <li id="wp-admin-bar-abstractambienceantisocialapertureapzauldbackstagebig-easybiznizzbloggingstreamboastbold-newsbusy-b...
17,443
<p>I'm attempting to set up a wiki within a Wordpress install and love the way codex.wordpress.org is set up. Are they using a specific plugin to accomplish that or just well structured pages? Is there a similar plugin available to users?</p>
[ { "answer_id": 17445, "author": "MartinJJ", "author_id": 3710, "author_profile": "https://wordpress.stackexchange.com/users/3710", "pm_score": 3, "selected": true, "text": "<p>Hi in the wordpress.org header is this:</p>\n\n<pre><code>&lt;meta name=\"generator\" content=\"MediaWiki 1.15.5...
2011/05/17
[ "https://wordpress.stackexchange.com/questions/17443", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5438/" ]
I'm attempting to set up a wiki within a Wordpress install and love the way codex.wordpress.org is set up. Are they using a specific plugin to accomplish that or just well structured pages? Is there a similar plugin available to users?
Hi in the wordpress.org header is this: ``` <meta name="generator" content="MediaWiki 1.15.5" /> ``` which leads me to think that it is this that is used [**MediaWiki**](http://www.mediawiki.org/wiki/MediaWiki) regards Martin edit: something similar was aked before and it looks like a plugin solution was found [*...
17,444
<p>I have several sites with custom post types and taxonomies registered by different plugins. Is there a way to add or change a parameter like this:</p> <pre class="lang-php prettyprint-override"><code>'rewrite' =&gt; array( 'hierarchical' =&gt; true ) </code></pre> <p>by adding something to functions.php—without c...
[ { "answer_id": 43327, "author": "helgatheviking", "author_id": 6477, "author_profile": "https://wordpress.stackexchange.com/users/6477", "pm_score": 3, "selected": true, "text": "<p>you could modify the global variable $wp_post_types or in the case of taxonomies, $wp_taxonomies</p>\n\n<p...
2011/05/17
[ "https://wordpress.stackexchange.com/questions/17444", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3564/" ]
I have several sites with custom post types and taxonomies registered by different plugins. Is there a way to add or change a parameter like this: ```php 'rewrite' => array( 'hierarchical' => true ) ``` by adding something to functions.php—without completely re-registering the type/taxonomy? I want to continue to us...
you could modify the global variable $wp\_post\_types or in the case of taxonomies, $wp\_taxonomies for example, this will change the menu name and all the labels for the default Posts to Bacon: ``` function change_post_menu_label() { global $menu; global $submenu; $menu[5][0] = 'Bacon'; $submenu['edi...
17,449
<p>I'm trying to disable a few plugins when my mobile theme is loaded. I read somewhere about using this particular function in my mobile theme functions.php file to remove scripts and css.</p> <pre><code>//Disable plugins add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 ); function my_deregister_javas...
[ { "answer_id": 17477, "author": "Jan Fabry", "author_id": 8, "author_profile": "https://wordpress.stackexchange.com/users/8", "pm_score": 3, "selected": true, "text": "<p>You can store the chosen color in a meta field. We have a question about <a href=\"https://wordpress.stackexchange.co...
2011/05/17
[ "https://wordpress.stackexchange.com/questions/17449", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5411/" ]
I'm trying to disable a few plugins when my mobile theme is loaded. I read somewhere about using this particular function in my mobile theme functions.php file to remove scripts and css. ``` //Disable plugins add_action( 'wp_print_scripts', 'my_deregister_javascript', 100 ); function my_deregister_javascript() { ...
You can store the chosen color in a meta field. We have a question about [adding a custom field to attachments](https://wordpress.stackexchange.com/questions/14500/custom-fields-for-attachments), it contains an example. The hooks you need are `attachment_fields_to_edit` and `attachment_fields_to_save`.
17,455
<p>I've been strugling with the following issue for over a week now so please excuse the long description. I want it to be as accurate and clear as possible:</p> <p>I'm using the "simplr registration form" plugin to register new users. I need to add to the form an "address" field for the users to fill, and when the su...
[ { "answer_id": 17459, "author": "Scott", "author_id": 4610, "author_profile": "https://wordpress.stackexchange.com/users/4610", "pm_score": 0, "selected": false, "text": "<p>I feel this question doesn't belong here but never the less.</p>\n\n<p>OK Ash try your logic like this:</p>\n\n<pr...
2011/05/17
[ "https://wordpress.stackexchange.com/questions/17455", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5171/" ]
I've been strugling with the following issue for over a week now so please excuse the long description. I want it to be as accurate and clear as possible: I'm using the "simplr registration form" plugin to register new users. I need to add to the form an "address" field for the users to fill, and when the submit butto...
The php function which handles the submitted values in this plugin checks first if the button's value `isset`. When using the original submit it is. When using `preventDefault()` and then calling `submit()` it isn't and therefor the php doesn't handle the submitted form but rebuilds it. To fix this I just added to the ...
17,457
<p>I'm adding a custom profile field to users of a specific role, like this :</p> <pre><code>function add_custom_profile_fields( $fields ) { // get current user ID $user = new WP_User( $_GET['user_id'] ); // get current user role if ( !empty( $user-&gt;roles ) &amp;&amp; is_array( $user-&gt;roles ) )...
[ { "answer_id": 17471, "author": "Dave Konopka", "author_id": 3837, "author_profile": "https://wordpress.stackexchange.com/users/3837", "pm_score": 2, "selected": false, "text": "<p>You can skip the looping over roles and use <a href=\"http://codex.wordpress.org/Function_Reference/user_ca...
2011/05/17
[ "https://wordpress.stackexchange.com/questions/17457", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1381/" ]
I'm adding a custom profile field to users of a specific role, like this : ``` function add_custom_profile_fields( $fields ) { // get current user ID $user = new WP_User( $_GET['user_id'] ); // get current user role if ( !empty( $user->roles ) && is_array( $user->roles ) ) { foreach ( $user->...
Ok, I was doing it wrong, here's a working solution, based on Justin Tadlock's [tutorial](http://justintadlock.com/archives/2009/09/10/adding-and-using-custom-user-profile-fields). ``` <?php /* Add custom profile fields (call in theme : echo $curauth->fieldname;) */ add_action( 'show_user_profile', 'my_show_extra_pr...
17,462
<p>I have in the following code in the template:</p> <pre><code>&lt;img src="&lt;?php header_image(); ?&gt;" /&gt; </code></pre> <p>However, I want to change this image according to the language selected (through GET parameter lang).</p> <p>The question is, how to change this function to look for different images ac...
[ { "answer_id": 17465, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": true, "text": "<p>Filter the <code>get_theme_mod()</code> function (<code>wp-includes/theme.php</code>):</p>\n\n<pre><code>add_filter( 't...
2011/05/17
[ "https://wordpress.stackexchange.com/questions/17462", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5417/" ]
I have in the following code in the template: ``` <img src="<?php header_image(); ?>" /> ``` However, I want to change this image according to the language selected (through GET parameter lang). The question is, how to change this function to look for different images according to the received GET parameter? I tho...
Filter the `get_theme_mod()` function (`wp-includes/theme.php`): ``` add_filter( 'theme_mod_header_image', 'localized_header' ); function localized_header( $img ) { // Do something awesome with the $img path. return $img; } ```
17,463
<p>So i got the RSS feed which output some custom post types, but the GUID looks bad to me, it's like:</p> <pre><code>?post_type=mycustompost&amp;p=124 </code></pre> <p>The reason i want to change this is that I don't need people to know it's Wordpress or to see my custom post type name (this is very important in thi...
[ { "answer_id": 17469, "author": "MZAweb", "author_id": 5223, "author_profile": "https://wordpress.stackexchange.com/users/5223", "pm_score": 0, "selected": false, "text": "<p>I didn't get where you see that GUID. But if it's the title link, you can try:</p>\n\n<pre><code>function my_perm...
2011/05/17
[ "https://wordpress.stackexchange.com/questions/17463", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5200/" ]
So i got the RSS feed which output some custom post types, but the GUID looks bad to me, it's like: ``` ?post_type=mycustompost&p=124 ``` The reason i want to change this is that I don't need people to know it's Wordpress or to see my custom post type name (this is very important in this project) Is there a filter ...
The feed template files call `the_guid()`, [which calls `get_the_guid()`](http://core.trac.wordpress.org/browser/tags/3.1.2/wp-includes/post-template.php#L122), which has a filter named (surprisingly) `get_the_guid`. You can hook into this filter to change the output. The filter only gets the current GUID, not the post...
17,466
<p>Problem: Configure wordpress to use a remote mysql database only available using and SSH tunneling.</p> <p>Stage: I have a wordpress instance over an apache server on machine (called WP_server). WP_server, does not have Mysql server and has blocked port except 80 (http) and 22 (ssh).</p> <p>In other place is anoth...
[ { "answer_id": 17467, "author": "Denis de Bernardy", "author_id": 1208, "author_profile": "https://wordpress.stackexchange.com/users/1208", "pm_score": 1, "selected": false, "text": "<p>You can use a custom DB handler in wordpress. Extend the wpdb class located in <code>wp-includes/wpdb....
2011/05/17
[ "https://wordpress.stackexchange.com/questions/17466", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
Problem: Configure wordpress to use a remote mysql database only available using and SSH tunneling. Stage: I have a wordpress instance over an apache server on machine (called WP\_server). WP\_server, does not have Mysql server and has blocked port except 80 (http) and 22 (ssh). In other place is another machine (Mys...
You should create a [ssh tunnel](http://en.wikipedia.org/wiki/Tunneling_protocol) between the 2 serves. Then you can connect from the WP with only the mysql server ip. ``` ssh -f user@personal-server.com -L 2000:personal-server.com:25 -N ``` The `-f` tells ssh to go into the background just before it executes the co...
17,494
<p>I've used the wordpress plugin - <a href="http://plugins.elliotcondon.com/advanced-custom-fields/" rel="nofollow">advanced custom field</a> and would like to show an array of a child, here's my code:</p> <p>I'm using this code to show the custom fields data from a specific page ID's children:</p> <pre><code>&lt;?p...
[ { "answer_id": 17506, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 0, "selected": false, "text": "<p>Try this code:</p>\n\n<pre><code>&lt;?php $args = array(\n 'depth' =&gt; 0,\n 'child_of' =&g...
2011/05/17
[ "https://wordpress.stackexchange.com/questions/17494", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4588/" ]
I've used the wordpress plugin - [advanced custom field](http://plugins.elliotcondon.com/advanced-custom-fields/) and would like to show an array of a child, here's my code: I'm using this code to show the custom fields data from a specific page ID's children: ``` <?php $args = array( 'depth' => 0, 'ch...
This will show the checkboxes that have been ticked (much simpler!!): ``` <?php $categories = get_field('categories'); $elements = array(); foreach($categories as $category) { //do something $elements[] = '<a href="/tags/design/' . strtolower($category) . '" title="' . $category . '">' . $c...
17,496
<p>I have create a category by using Custom Post Type plugin, and now only the 5 most recent posts of the category are showing.<br> What I want is to show all posts for the category.<br> For examle, suppose I have movies category - I want all movies in that category.<br> What code should I use and where?<br> I don't k...
[ { "answer_id": 17497, "author": "Alexcp", "author_id": 5906, "author_profile": "https://wordpress.stackexchange.com/users/5906", "pm_score": 2, "selected": false, "text": "<p>It is quite easy to do it with wordpress. You have to understand that post are normally display within a \"loop\"...
2011/05/17
[ "https://wordpress.stackexchange.com/questions/17496", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I have create a category by using Custom Post Type plugin, and now only the 5 most recent posts of the category are showing. What I want is to show all posts for the category. For examle, suppose I have movies category - I want all movies in that category. What code should I use and where? I don't know much...
``` <?php $args = array( 'category' => 7, 'post_type' => 'post' ); $postslist = get_posts( $args ); foreach ($postslist as $post) : setup_postdata($post); ?> <h2><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h2> <?php the_excerpt(); ?> <?php endforeach; ?> ...
17,501
<p>OK, a pretty dorky question, but I am new to PHP so bear with me.</p> <p>How would I add an a href link to the code below so the custom meta field is linked on the front-end?</p> <pre><code>&lt;?php if ( get_post_meta( $post-&gt;ID, "leetpress_website", true ) ){ ?&gt; &lt;div class="pros"&gt;&lt;p&gt;&lt;strong&g...
[ { "answer_id": 17507, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 0, "selected": false, "text": "<p>It looks like something happened to the code you pasted, it's not complete, but here's an example of a meta field i...
2011/05/17
[ "https://wordpress.stackexchange.com/questions/17501", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5450/" ]
OK, a pretty dorky question, but I am new to PHP so bear with me. How would I add an a href link to the code below so the custom meta field is linked on the front-end? ``` <?php if ( get_post_meta( $post->ID, "leetpress_website", true ) ){ ?> <div class="pros"><p><strong>Movie Website: </strong> <?php echo get_pos...
Use another custom field with the URL and call it something like `leetpress_website_url` then change your code to this: ``` <?php if ( get_post_meta( $post->ID, "leetpress_website", true ) ){ echo '<div class="pros"><p><strong>Movie Website: </strong><a href="' . get_post_meta( $post->ID, "leetpress_website_url",...
17,513
<p>Wondering how I can add a stylesheet to wp_head section via shortcode, since shortcodes are parsed after wp_head, I've hearing about output buffering but I Am not sure.</p> <p>Any idea?</p>
[ { "answer_id": 17518, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 2, "selected": false, "text": "<p>here is a handy function i use a lot which is based on <code>the_posts</code> hook</p>\n\n<pre><code>function...
2011/05/17
[ "https://wordpress.stackexchange.com/questions/17513", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3294/" ]
Wondering how I can add a stylesheet to wp\_head section via shortcode, since shortcodes are parsed after wp\_head, I've hearing about output buffering but I Am not sure. Any idea?
here is a handy function i use a lot which is based on `the_posts` hook ``` function check_for_shortcode($posts) { if ( empty($posts) ) return $posts; $flag = false; foreach ($posts as $post) { if ( stripos($post->post_content, '[YOUR_SHORTCODE_HERE') ) $flag = true; ...
17,517
<p>I am using <a href="http://wordpress.org/extend/plugins/mailchimp/" rel="nofollow">the MailChimp WordPress plugin</a> so that user's can sign up to a MailChimp mailing list. I want the signups to go into a specific group in my list. The plugin doesn't appear to work correctly with mailing list groups.</p> <p>Can I ...
[ { "answer_id": 18031, "author": "edzillion", "author_id": 4675, "author_profile": "https://wordpress.stackexchange.com/users/4675", "pm_score": 1, "selected": false, "text": "<p>IIRC I had this same problem and I just created my own plugin by creating the signup form on the mailchimp web...
2011/05/17
[ "https://wordpress.stackexchange.com/questions/17517", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2668/" ]
I am using [the MailChimp WordPress plugin](http://wordpress.org/extend/plugins/mailchimp/) so that user's can sign up to a MailChimp mailing list. I want the signups to go into a specific group in my list. The plugin doesn't appear to work correctly with mailing list groups. Can I just dive into the plugin code and a...
IIRC I had this same problem and I just created my own plugin by creating the signup form on the mailchimp website: Create Form > Signup Form > create embed code for small form Then create the form elements you need and copy that embed code into your plugin .php file. My test of this created the following html: ``` ...
17,521
<p>I am using this plugin: <a href="http://www.megatome.com/syntaxhighlighter/" rel="nofollow">http://www.megatome.com/syntaxhighlighter/</a></p> <p>Which appears to work ok, minus a few glitches here and there.</p> <p>My problem, is that I think WordPress is rewriting <code>&lt;?php</code> with <code>&lt;!--?php</co...
[ { "answer_id": 17584, "author": "Jan Fabry", "author_id": 8, "author_profile": "https://wordpress.stackexchange.com/users/8", "pm_score": 2, "selected": false, "text": "<p>Indeed, you need to <a href=\"http://codex.wordpress.org/Writing_Code_in_Your_Posts\" rel=\"nofollow\">convert the c...
2011/05/17
[ "https://wordpress.stackexchange.com/questions/17521", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5457/" ]
I am using this plugin: <http://www.megatome.com/syntaxhighlighter/> Which appears to work ok, minus a few glitches here and there. My problem, is that I think WordPress is rewriting `<?php` with `<!--?php` and other tags, presumably for security. Is there any way to disable this functionality, so that I can show co...
Indeed, you need to [convert the code to their HTML entities](http://codex.wordpress.org/Writing_Code_in_Your_Posts) to prevent WordPress (or the TinyMCE editor) from stripping it out. The Visual editor does some of this work for you, in the HTML editor you must do this yourself. Fortunately, there are syntax highligh...
17,531
<p>I hope this makes any type of sense. I want to be able to add clauses to a specific query object without effecting the main loop on a page, for example for content in a side bar or footer. Is it possible?</p>
[ { "answer_id": 17537, "author": "scribu", "author_id": 205, "author_profile": "https://wordpress.stackexchange.com/users/205", "pm_score": 3, "selected": true, "text": "<p>The most reliable way is to define your own query var and then check it:</p>\n\n<pre><code>$my_query = new WP_Query(...
2011/05/18
[ "https://wordpress.stackexchange.com/questions/17531", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2234/" ]
I hope this makes any type of sense. I want to be able to add clauses to a specific query object without effecting the main loop on a page, for example for content in a side bar or footer. Is it possible?
The most reliable way is to define your own query var and then check it: ``` $my_query = new WP_Query( array( ... 'context' => 'my_query' ) ); ``` Then, from your callback: ``` function alter_post_clauses( $clauses, $wp_query ) { if ( 'my_query' == $wp_query->get( 'context' ) ) { // do stuff } return...
17,532
<p>I am using products as a 'custom post type' then I'm displaying a gallery of all products on the home page with a buy button next to each one. When the buy button is clicked, I would like it to redirect to a page with some more info of that product and a checkout form. What do I need to send to the URL using the b...
[ { "answer_id": 17537, "author": "scribu", "author_id": 205, "author_profile": "https://wordpress.stackexchange.com/users/205", "pm_score": 3, "selected": true, "text": "<p>The most reliable way is to define your own query var and then check it:</p>\n\n<pre><code>$my_query = new WP_Query(...
2011/05/18
[ "https://wordpress.stackexchange.com/questions/17532", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5416/" ]
I am using products as a 'custom post type' then I'm displaying a gallery of all products on the home page with a buy button next to each one. When the buy button is clicked, I would like it to redirect to a page with some more info of that product and a checkout form. What do I need to send to the URL using the button...
The most reliable way is to define your own query var and then check it: ``` $my_query = new WP_Query( array( ... 'context' => 'my_query' ) ); ``` Then, from your callback: ``` function alter_post_clauses( $clauses, $wp_query ) { if ( 'my_query' == $wp_query->get( 'context' ) ) { // do stuff } return...
17,534
<p>I have a wp_nav_menu "Main Menu" such as the following:</p> <ul> <li>Top Level (#menu-item-1) <ul> <li>Sub Item</li> <li>Sub Item</li> </ul></li> <li>Top Level (#menu-item-2) <ul> <li>Sub Item</li> </ul></li> <li>Top Level (#menu-item-3) <ul> <li>Sub Item A</li> <li>Sub Item B <ul> <li>Sub Item a.1</li> </ul></li> ...
[ { "answer_id": 17551, "author": "Ian Dunn", "author_id": 3898, "author_profile": "https://wordpress.stackexchange.com/users/3898", "pm_score": 2, "selected": false, "text": "<p>If I understand what you want correctly, you can do this with CSS. You'll call wp_nav_menu normally and let it ...
2011/05/18
[ "https://wordpress.stackexchange.com/questions/17534", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5465/" ]
I have a wp\_nav\_menu "Main Menu" such as the following: * Top Level (#menu-item-1) + Sub Item + Sub Item * Top Level (#menu-item-2) + Sub Item * Top Level (#menu-item-3) + Sub Item A + Sub Item B - Sub Item a.1 + Sub Item C Then in my template I want to be able to echo wp\_nav\_menu Main Menu sub items for ...
If I understand what you want correctly, you can do this with CSS. You'll call wp\_nav\_menu normally and let it generate all of the links, but then you'll hide all of them except for the submenu of the current page. You're CSS would look something like this, ``` #sidebar ul.menu li { display: none; } #sideb...
17,569
<p>I have a custom post type whose permalink needs to sit in the same space as pages, like so:</p> <pre><code>/an-example-thing &lt;-- custom post type 'thing' /about-the-things &lt;-- a normal page </code></pre> <p>I'm well aware that <a href="http://ottopress.com/2010/category-in-permalinks-considered-harmful/"...
[ { "answer_id": 17580, "author": "Jan Fabry", "author_id": 8, "author_profile": "https://wordpress.stackexchange.com/users/8", "pm_score": 3, "selected": true, "text": "<p>You start with one bonus point for using my rewrite analyzer :-)</p>\n\n<p>Indeed, even if you use verbose page rules...
2011/05/18
[ "https://wordpress.stackexchange.com/questions/17569", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3828/" ]
I have a custom post type whose permalink needs to sit in the same space as pages, like so: ``` /an-example-thing <-- custom post type 'thing' /about-the-things <-- a normal page ``` I'm well aware that [this isn't the recommended way to do it](http://ottopress.com/2010/category-in-permalinks-considered-harmful/...
You start with one bonus point for using my rewrite analyzer :-) Indeed, even if you use verbose page rules, since version 3.1 (or something around that) the taxonomy rewrite rules come even before that. I [recently answered another question](https://wordpress.stackexchange.com/questions/16902/permalink-rewrite-404-co...
17,571
<p>Hi I am trying to use ternary operators with <a href="http://codex.wordpress.org/Conditional_Tags" rel="nofollow">WordPress condtionals</a>, using the code below, but it's giving me a PHP error, what am I doing wrong?</p> <pre><code>echo is_home() : '1' ? '0'; </code></pre>
[ { "answer_id": 17573, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": false, "text": "<p>Syntax is wrong you need to phrase it like so:</p>\n\n<pre><code>condition ? TRUE : FALSE\n</code></pre>\n\n<...
2011/05/18
[ "https://wordpress.stackexchange.com/questions/17571", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5317/" ]
Hi I am trying to use ternary operators with [WordPress condtionals](http://codex.wordpress.org/Conditional_Tags), using the code below, but it's giving me a PHP error, what am I doing wrong? ``` echo is_home() : '1' ? '0'; ```
Syntax is wrong you need to phrase it like so: ``` condition ? TRUE : FALSE ``` so change your code to : ``` echo is_home() ? '1' : '0'; ```
17,582
<p>What would be the best solution for a wp (cms style) site containing a sub site for consumers and businesses.</p> <p>I've made a wp theme and its almost finished. In essence its gives you two choice to visit as a consumers or as an business.</p> <p>Both have the same theme style but differ in some content used out...
[ { "answer_id": 17573, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": false, "text": "<p>Syntax is wrong you need to phrase it like so:</p>\n\n<pre><code>condition ? TRUE : FALSE\n</code></pre>\n\n<...
2011/05/17
[ "https://wordpress.stackexchange.com/questions/17582", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
What would be the best solution for a wp (cms style) site containing a sub site for consumers and businesses. I've made a wp theme and its almost finished. In essence its gives you two choice to visit as a consumers or as an business. Both have the same theme style but differ in some content used out of the wp databa...
Syntax is wrong you need to phrase it like so: ``` condition ? TRUE : FALSE ``` so change your code to : ``` echo is_home() ? '1' : '0'; ```
17,587
<p><a href="http://goldenapplesdesign.com/2010/07/03/front-end-file-uploads-in-wordpress/" rel="nofollow">Golden Apples Design</a> created (as far as I know) the media upload function that many people on WP.A and elsewhere seem to recommend. But all of the Q&amp;As I can find on StackExchange deal with creating an enti...
[ { "answer_id": 18577, "author": "Hameedullah Khan", "author_id": 5337, "author_profile": "https://wordpress.stackexchange.com/users/5337", "pm_score": 1, "selected": false, "text": "<p>In your header change <code>$post_id</code> to <code>$post-&gt;ID</code>.</p>\n\n<pre><code>// set $pos...
2011/05/18
[ "https://wordpress.stackexchange.com/questions/17587", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1057/" ]
[Golden Apples Design](http://goldenapplesdesign.com/2010/07/03/front-end-file-uploads-in-wordpress/) created (as far as I know) the media upload function that many people on WP.A and elsewhere seem to recommend. But all of the Q&As I can find on StackExchange deal with creating an entirely new post. What is the best ...
@AboSami actually [answered this question](https://wordpress.stackexchange.com/questions/5673/using-upload-image-with-media-handle-upload-but) in an older post that was not showing up in my search diligence. While he was actually looking for something else his example code worked great. Here's the script: ``` <?php $...
17,594
<p>I'm looking for a way to add body class depending on the User Agent of the client with php.</p> <p>I'm looking to implement it this way:</p> <p><strong>page.php:</strong></p> <p><code>&lt;body id="front" &lt;?php ( function_exists ( 'body_class' ) : body_class($classes) ? NULL ); ?&gt; &gt;</code></p> <p>Or by...
[ { "answer_id": 17599, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 4, "selected": true, "text": "<p>something like this maybe:</p>\n\n<pre><code>function my_class_names($classes) {\n $useragent = $_SERVER['HTTP_US...
2011/05/18
[ "https://wordpress.stackexchange.com/questions/17594", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5149/" ]
I'm looking for a way to add body class depending on the User Agent of the client with php. I'm looking to implement it this way: **page.php:** `<body id="front" <?php ( function_exists ( 'body_class' ) : body_class($classes) ? NULL ); ?> >` Or by using adding it to the functions.php file FYI: The whole purpose of...
something like this maybe: ``` function my_class_names($classes) { $useragent = $_SERVER['HTTP_USER_AGENT']; if(strchr($useragent,'Safari')) $classes[] = 'Safari'; // etc.. return $classes; } add_filter('body_class','my_class_names'); ``` **Edit** - as per Chip's suggestion, here's the function using...
17,601
<p>Here's another story for my Custom Pagination on Custom Author's Page. What I want to happen there is display the Author's avatar, description, website, and some additional fields, and of course list his post and paginate it....</p> <p>Here's the screenshot of my custom author page:</p> <p><img src="https://i.stac...
[ { "answer_id": 17599, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 4, "selected": true, "text": "<p>something like this maybe:</p>\n\n<pre><code>function my_class_names($classes) {\n $useragent = $_SERVER['HTTP_US...
2011/05/18
[ "https://wordpress.stackexchange.com/questions/17601", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5475/" ]
Here's another story for my Custom Pagination on Custom Author's Page. What I want to happen there is display the Author's avatar, description, website, and some additional fields, and of course list his post and paginate it.... Here's the screenshot of my custom author page: ![](https://i.stack.imgur.com/sUYuv.png) ...
something like this maybe: ``` function my_class_names($classes) { $useragent = $_SERVER['HTTP_USER_AGENT']; if(strchr($useragent,'Safari')) $classes[] = 'Safari'; // etc.. return $classes; } add_filter('body_class','my_class_names'); ``` **Edit** - as per Chip's suggestion, here's the function using...
17,617
<p>I've created a page that loops posts. Each post acts as a category link so that when you click it brings you to a category archive.</p> <p>My issue is that wordpress somehow overrides my htaccess and redirects me to the single.php post.</p> <p>So ill have a category page called 'Neighborhoods'. Within 'Neighborhoo...
[ { "answer_id": 17968, "author": "maryisdead", "author_id": 2637, "author_profile": "https://wordpress.stackexchange.com/users/2637", "pm_score": 2, "selected": false, "text": "<p>I'm using a generic redirect solution in my templates that uses custom fields. In my <strong>functions.php</s...
2011/05/18
[ "https://wordpress.stackexchange.com/questions/17617", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5478/" ]
I've created a page that loops posts. Each post acts as a category link so that when you click it brings you to a category archive. My issue is that wordpress somehow overrides my htaccess and redirects me to the single.php post. So ill have a category page called 'Neighborhoods'. Within 'Neighborhoods' I have a post...
I'm using a generic redirect solution in my templates that uses custom fields. In my **functions.php** I have this function: ```php if (!function_exists('sumo_redirect')): /** * Put this at the very top of a page and give it the current page id. It then * checks if there is a redirect_to custom field with another pa...
17,625
<p>I have a lot of custom post types and I have them showing in my "Right Now" Dashboard but it's gotten pretty long so I want to separate them to a custom widget within the dash. </p> <p>See example below:</p> <p><img src="https://i.stack.imgur.com/ge0Yy.png" alt="enter image description here"></p> <p>So my questio...
[ { "answer_id": 17627, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 0, "selected": false, "text": "<p>I think this will work.</p>\n\n<pre><code>// wp_dashboard_setup is the action hook\n\nadd_action('wp_dashboard_setu...
2011/05/18
[ "https://wordpress.stackexchange.com/questions/17625", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4640/" ]
I have a lot of custom post types and I have them showing in my "Right Now" Dashboard but it's gotten pretty long so I want to separate them to a custom widget within the dash. See example below: ![enter image description here](https://i.stack.imgur.com/ge0Yy.png) So my question is how do I add the CPTs to a custom...
Lokks like you have a function declared inside another function, your code is wrong, try this: ``` // wp_dashboard_setup is the action hook add_action('wp_dashboard_setup', 'mycustom_moviestats'); // add dashboard widget function mycustom_moviestats() { wp_add_dashboard_widget('custom_movie_widget', 'Movie Stats'...
17,639
<p>On the WordPress archive template I am using a custom excerpt function that includes a reference to <code>strip_shortcodes()</code>. For some reason, shortcodes are being rendered and displayed in the archive.</p> <p>Example: <a href="http://arisehub.org/blog/page/2/" rel="nofollow">http://arisehub.org/blog/page/2/...
[ { "answer_id": 18342, "author": "Matthew Muro", "author_id": 1511, "author_profile": "https://wordpress.stackexchange.com/users/1511", "pm_score": 0, "selected": false, "text": "<p>There's a function on the <a href=\"http://codex.wordpress.org/Function_Reference/strip_shortcodes\" rel=\"...
2011/05/19
[ "https://wordpress.stackexchange.com/questions/17639", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1766/" ]
On the WordPress archive template I am using a custom excerpt function that includes a reference to `strip_shortcodes()`. For some reason, shortcodes are being rendered and displayed in the archive. Example: <http://arisehub.org/blog/page/2/> Scroll down to "Sing a New Song with Joshua Cunningham" Notice the script ...
[JW Player Plugin for WordPress](http://wordpress.org/extend/plugins/jw-player-plugin-for-wordpress/) does not register its shortcode like all other shortcodes, so `strip_shortcodes()` will not know about it and not strip it. In [the code](http://plugins.trac.wordpress.org/browser/jw-player-plugin-for-wordpress/tags/1....
17,640
<p>I've run into another wonderful 404 issue. I'm trying to have 2 seperate post types that share the same rewrite slug. I've flushed my rewrite rules, and when I test only 1 of the CPT works- the other gets a 404. My rewrite that I wish to use for both is:</p> <pre><code>'rewrite' =&gt; array('slug' =&gt; 'team/%...
[ { "answer_id": 17645, "author": "MZAweb", "author_id": 5223, "author_profile": "https://wordpress.stackexchange.com/users/5223", "pm_score": 1, "selected": false, "text": "<p>As far as I know, you can't do that. Every slug is converted to a query_vars item that queries a specific object...
2011/05/19
[ "https://wordpress.stackexchange.com/questions/17640", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2811/" ]
I've run into another wonderful 404 issue. I'm trying to have 2 seperate post types that share the same rewrite slug. I've flushed my rewrite rules, and when I test only 1 of the CPT works- the other gets a 404. My rewrite that I wish to use for both is: ``` 'rewrite' => array('slug' => 'team/%teamtype%'), ``` Anyon...
I've just done a project where two Custom Post Types needed to share the same slug. **The trick is to overwrite the query vars via the `request` filter**. Let's call the post types 'foo' and 'bar', and they will share slug 'foo'. The following code is rough and from memory for example only. Salt to taste, do not copy-...
17,647
<p>I am fairly new to WordPress, and I would like to have a list of the most recent posts in a certain category appear in a right-hand panel (I can do this with all posts, but not specific categories)</p> <p>I am using the Twenty Ten theme, on wordpress.com. I have found the following code, but unsure if or where this...
[ { "answer_id": 17648, "author": "MZAweb", "author_id": 5223, "author_profile": "https://wordpress.stackexchange.com/users/5223", "pm_score": 2, "selected": true, "text": "<p>The fastest way, a plugin:</p>\n\n<p><a href=\"http://wordpress.org/extend/plugins/category-posts/\" rel=\"nofollo...
2011/05/19
[ "https://wordpress.stackexchange.com/questions/17647", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5493/" ]
I am fairly new to WordPress, and I would like to have a list of the most recent posts in a certain category appear in a right-hand panel (I can do this with all posts, but not specific categories) I am using the Twenty Ten theme, on wordpress.com. I have found the following code, but unsure if or where this can be ad...
The fastest way, a plugin: <http://wordpress.org/extend/plugins/category-posts/>