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
69,927
<p>I am using a carousel to display latest jposts on my front page and I am using the following code but it's not working.</p> <pre><code>function my_load_caroufredsel() { // Enqueue carouFredSel, note that we specify 'jquery' as a dependency, and we set 'true' for loading in the footer: wp_register_sc...
[ { "answer_id": 69930, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 1, "selected": false, "text": "<p>You only register your first script, but don't enqueue it. Change <code>wp_register_script</code> to <code>wp_enque...
2012/10/20
[ "https://wordpress.stackexchange.com/questions/69927", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20406/" ]
I am using a carousel to display latest jposts on my front page and I am using the following code but it's not working. ``` function my_load_caroufredsel() { // Enqueue carouFredSel, note that we specify 'jquery' as a dependency, and we set 'true' for loading in the footer: wp_register_script( 'caroufr...
You only register your first script, but don't enqueue it. Change `wp_register_script` to `wp_enqueue_script` and it should work. Registering it is useful if you may possibly enqueue it at different times/conditions, but in this case you can just enqueue it straight away.
69,928
<p>I am smashing my head against some code. Here is the situation: I have one post in 3 different categories, this post has to be visible in "category 1" with the single1.php, in "category 2" with single2.php and in "category 3" with single3.php.</p> <p>Obviously the 3 single.php pages have a different template inside...
[ { "answer_id": 69969, "author": "Md Toufiqul Islam", "author_id": 21268, "author_profile": "https://wordpress.stackexchange.com/users/21268", "pm_score": 2, "selected": false, "text": "<p>You can use the filter hook for 'single_template'. Create single-cat1.php, single-cat2.php and singl...
2012/10/20
[ "https://wordpress.stackexchange.com/questions/69928", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22715/" ]
I am smashing my head against some code. Here is the situation: I have one post in 3 different categories, this post has to be visible in "category 1" with the single1.php, in "category 2" with single2.php and in "category 3" with single3.php. Obviously the 3 single.php pages have a different template inside. For exam...
Instead of making it category specific you could use post formats and use different content-templates. In single.php you can write ``` <?php get_template_part( 'content', get_post_format() ); ?> ``` Then create different post formats ``` add_theme_support( 'post-formats', array( 'withpictures', 'withcomments' ) ); ...
69,940
<p>I'm working on a site where I'd like anyone to be able to sign up, but people who sign up with an invite code would automatically be promoted to a role with more privileges.</p> <p>I'm aware that there are plugins that handle invite codes, but so far I haven't found any that will do quite this.</p> <p>For my purpo...
[ { "answer_id": 69969, "author": "Md Toufiqul Islam", "author_id": 21268, "author_profile": "https://wordpress.stackexchange.com/users/21268", "pm_score": 2, "selected": false, "text": "<p>You can use the filter hook for 'single_template'. Create single-cat1.php, single-cat2.php and singl...
2012/10/20
[ "https://wordpress.stackexchange.com/questions/69940", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13603/" ]
I'm working on a site where I'd like anyone to be able to sign up, but people who sign up with an invite code would automatically be promoted to a role with more privileges. I'm aware that there are plugins that handle invite codes, but so far I haven't found any that will do quite this. For my purposes, one invite c...
Instead of making it category specific you could use post formats and use different content-templates. In single.php you can write ``` <?php get_template_part( 'content', get_post_format() ); ?> ``` Then create different post formats ``` add_theme_support( 'post-formats', array( 'withpictures', 'withcomments' ) ); ...
69,944
<p>I've been reading this by <a href="https://wordpress.stackexchange.com/questions/50761/when-to-use-wp-query-query-posts-and-pre-get-posts">@nacin</a> and getting to grips with wp_query over query_posts that I used to use. </p> <p>What I want is:</p> <ol> <li><p>to put this in a template file</p></li> <li><p>to que...
[ { "answer_id": 69945, "author": "mirage", "author_id": 22505, "author_profile": "https://wordpress.stackexchange.com/users/22505", "pm_score": 2, "selected": true, "text": "<p>you could use <code>wp_list_pluck();</code></p>\n\n<pre><code>if ( $exclude_featured )\n $args['post__not_in'...
2012/10/20
[ "https://wordpress.stackexchange.com/questions/69944", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5089/" ]
I've been reading this by [@nacin](https://wordpress.stackexchange.com/questions/50761/when-to-use-wp-query-query-posts-and-pre-get-posts) and getting to grips with wp\_query over query\_posts that I used to use. What I want is: 1. to put this in a template file 2. to query all posts of this category, in this case '...
you could use `wp_list_pluck();` ``` if ( $exclude_featured ) $args['post__not_in'] = wp_list_pluck( $exclude_featured->posts, 'ID' ); $args['posts_per_page'] = 999; query_posts( $args ); endif; while ( have_posts() ) : the_post(); ... ```
69,948
<p>I have searched the net with no success on what should be an easy thing.</p> <p>I have a highly customized blog with pages, sub pages and posts. While I rely heavily on the use of categories and tags I don't want them to be viewable in a url. The same goes for authors and date categories. Basically I wan't to throw ...
[ { "answer_id": 69949, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 3, "selected": false, "text": "<p>I wrote a <a href=\"http://wordpress.org/extend/plugins/archive-disabler/\" rel=\"noreferrer\">plugin for...
2012/10/20
[ "https://wordpress.stackexchange.com/questions/69948", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22724/" ]
I have searched the net with no success on what should be an easy thing. I have a highly customized blog with pages, sub pages and posts. While I rely heavily on the use of categories and tags I don't want them to be viewable in a url. The same goes for authors and date categories. Basically I wan't to throw a 404 err...
building on chrisguitarguy's answer here is a quick snippet you can drop in your theme's functions.php file to do job ``` add_action('template_redirect', 'wpse69948_archive_disabler'); function wpse69948_archive_disabler() { if(is_tag() || is_category() || is_date() || is_author()) { global $wp_query; ...
69,966
<p>How can I show the update message only to super admin in the network wordpress ? I don't want the other admins/users see the update message that shows the current version. Is there any plugin to do this or I have to changes the core?</p>
[ { "answer_id": 69968, "author": "Miha Rekar", "author_id": 20791, "author_profile": "https://wordpress.stackexchange.com/users/20791", "pm_score": 0, "selected": false, "text": "<p>Lower the level of those users to <code>Editor</code> as the users you are referring to are probably not me...
2012/10/21
[ "https://wordpress.stackexchange.com/questions/69966", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17946/" ]
How can I show the update message only to super admin in the network wordpress ? I don't want the other admins/users see the update message that shows the current version. Is there any plugin to do this or I have to changes the core?
Create your own plugin with this code or put this in theme's functions.php ``` add_action('init', 'remove_update_notification', 1) function remove_update_notification() { if (!current_user_can('manage_network')) { // checks to see if current user can update plugins add_action( 'init', create_function( '$a...
69,987
<p>I want wordpress to stop making multiple size images cause it's going to eat up my storage space. So I went Settings > Media and then set all the sizes to 0. When I uploaded a new image it still is making 2 copies for example:</p> <pre><code>achannel.jpg achannel-346x288.jpg </code></pre> <p>although they are both...
[ { "answer_id": 69989, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 4, "selected": true, "text": "<pre><code>add_filter('intermediate_image_sizes_advanced', 'filter_image_sizes');\nfunction filter_image_s...
2012/10/21
[ "https://wordpress.stackexchange.com/questions/69987", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17971/" ]
I want wordpress to stop making multiple size images cause it's going to eat up my storage space. So I went Settings > Media and then set all the sizes to 0. When I uploaded a new image it still is making 2 copies for example: ``` achannel.jpg achannel-346x288.jpg ``` although they are both full size images so why d...
``` add_filter('intermediate_image_sizes_advanced', 'filter_image_sizes'); function filter_image_sizes( $sizes) { unset( $sizes['thumbnail']); unset( $sizes['medium']); unset( $sizes['large']); return $sizes; } ```
69,993
<p>In my plugin, I use these instructions to obtain a list of posts:</p> <pre><code>$args = array( 'numberposts' =&gt; -1, 'offset' =&gt; 0, 'meta_query' =&gt; array( array( 'key' =&gt; 'metadata1', 'value' =&gt; '80', 'compare' =&gt; '&lt;=', ...
[ { "answer_id": 69994, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 4, "selected": true, "text": "<p>Try meta_value_num</p>\n\n<pre><code>'meta_key' =&gt; 'metadata1',\n'orderby' =&gt; 'meta_value_num'\n<...
2012/10/21
[ "https://wordpress.stackexchange.com/questions/69993", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20974/" ]
In my plugin, I use these instructions to obtain a list of posts: ``` $args = array( 'numberposts' => -1, 'offset' => 0, 'meta_query' => array( array( 'key' => 'metadata1', 'value' => '80', 'compare' => '<=', 'type' => 'UNSIGNED' ...
Try meta\_value\_num ``` 'meta_key' => 'metadata1', 'orderby' => 'meta_value_num' ``` Add these 2 parameters to $args. This does the sorting considering metadata1 as numeric
70,000
<p>Is there a way to add support for a custom feature for a custom post type, after it has been created?</p> <p>I know how to create a custom post type using register_post_type(), and how to use the supports parameter to specify what the CPT should support;</p> <pre><code>'supports' =&gt; array( 'title', 'editor', 'a...
[ { "answer_id": 70001, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 5, "selected": true, "text": "<p>Yes, there's a function called <a href=\"http://codex.wordpress.org/Function_Reference/add_post_type_suppo...
2012/10/21
[ "https://wordpress.stackexchange.com/questions/70000", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2071/" ]
Is there a way to add support for a custom feature for a custom post type, after it has been created? I know how to create a custom post type using register\_post\_type(), and how to use the supports parameter to specify what the CPT should support; ``` 'supports' => array( 'title', 'editor', 'author', 'thumbnail', '...
Yes, there's a function called [`add_post_type_support`](http://codex.wordpress.org/Function_Reference/add_post_type_support) Hook into `init` -- late, after the post types have been created -- and add support. Adding support for excerpts to pages for instance: ``` <?php add_action('init', 'wpse70000_add_excerpt', 1...
70,002
<p>I'm making a plugin that emails the site webmaster when I go to the 404 page. The script checks if the referring link is on our site, and then sends an email to the webmaster.</p> <pre><code>$message = " &lt;html&gt; &lt;head&gt; &lt;title&gt;Alton Bible Church - Broken Link&lt;/title&gt; &...
[ { "answer_id": 70003, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": true, "text": "<p>Use <a href=\"https://wordpress.stackexchange.com/questions/45289/what-is-the-advantage-of-using-wp-mail/45291#45291\">...
2012/10/21
[ "https://wordpress.stackexchange.com/questions/70002", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22743/" ]
I'm making a plugin that emails the site webmaster when I go to the 404 page. The script checks if the referring link is on our site, and then sends an email to the webmaster. ``` $message = " <html> <head> <title>Alton Bible Church - Broken Link</title> <style type=\"text/css\"> ...
Use [`wp_mail()`](https://wordpress.stackexchange.com/questions/45289/what-is-the-advantage-of-using-wp-mail/45291#45291), not just `mail()`. It is a wrapper for [PHPMailer](http://sourceforge.net/projects/phpmailer/), a class that takes care for many problems the native `mail()` function often gets. See my plugin [40...
70,017
<p>I am working on an online store using Woocommerce, many products have variations in size and price. Is there a way to have the range of prices (highest to lowest) of the variations on the product page? </p>
[ { "answer_id": 101913, "author": "Nicolai Grossherr", "author_id": 22534, "author_profile": "https://wordpress.stackexchange.com/users/22534", "pm_score": 3, "selected": true, "text": "<p>try it like this:</p>\n\n<pre><code>/**\n* This code should be added to functions.php of your theme\...
2012/10/21
[ "https://wordpress.stackexchange.com/questions/70017", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22749/" ]
I am working on an online store using Woocommerce, many products have variations in size and price. Is there a way to have the range of prices (highest to lowest) of the variations on the product page?
try it like this: ``` /** * This code should be added to functions.php of your theme **/ add_filter('woocommerce_variable_price_html', 'custom_variation_price', 10, 2); function custom_variation_price( $price, $product ) { $price = ''; if ( !$product->min_variation_price || $product->min_variation_price !== $product...
70,027
<p>I am using this code to show 3 most popular posts based on number of comments :</p> <pre><code>&lt;?php $pop_posts = 3; $popularposts = "SELECT $wpdb-&gt;posts.ID, $wpdb-&gt;posts.post_title, COUNT($wpdb-&gt;comments.comment_post_ID) AS 'stammy' FROM $wpdb-&gt;posts, $wpdb-&gt;comments ...
[ { "answer_id": 70030, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>Here's your code wrapped up in a plugin. The important thing is that it <code>prepare()</code>s the input, so the q...
2012/10/22
[ "https://wordpress.stackexchange.com/questions/70027", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20460/" ]
I am using this code to show 3 most popular posts based on number of comments : ``` <?php $pop_posts = 3; $popularposts = "SELECT $wpdb->posts.ID, $wpdb->posts.post_title, COUNT($wpdb->comments.comment_post_ID) AS 'stammy' FROM $wpdb->posts, $wpdb->comments WHERE comment_approved = '1' AND...
Here's your code wrapped up in a plugin. The important thing is that it `prepare()`s the input, so the query is safe. You can define 2 arguments: Offset & Limit. Those are basically just the SQL `LIMIT`. If you don't have any use for the plugin, just deactivate it, as it won't do anything - its output is attached to a...
70,028
<p>I have recently invested a bunch of hours updating the alt text of all the images in a media library, only to realise that the changes are not reflected on posts/pages.</p> <p>Whoops!</p> <p>Is there any way to force these changes across? Or have I no choice but to edit each page manually?</p> <p>Hope someone has...
[ { "answer_id": 70030, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>Here's your code wrapped up in a plugin. The important thing is that it <code>prepare()</code>s the input, so the q...
2012/10/22
[ "https://wordpress.stackexchange.com/questions/70028", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15621/" ]
I have recently invested a bunch of hours updating the alt text of all the images in a media library, only to realise that the changes are not reflected on posts/pages. Whoops! Is there any way to force these changes across? Or have I no choice but to edit each page manually? Hope someone has good news for me! Than...
Here's your code wrapped up in a plugin. The important thing is that it `prepare()`s the input, so the query is safe. You can define 2 arguments: Offset & Limit. Those are basically just the SQL `LIMIT`. If you don't have any use for the plugin, just deactivate it, as it won't do anything - its output is attached to a...
70,033
<p>The code below from WPSnipps provides an excerpt character counter, but I'd like to count <strong>words</strong> instead. Does anybody have an idea of how to do this?</p> <pre><code>// Excerpt character count function excerpt_count_js(){ echo '&lt;script&gt;jQuery(document).ready(function(){ jQuery("#postexc...
[ { "answer_id": 70030, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>Here's your code wrapped up in a plugin. The important thing is that it <code>prepare()</code>s the input, so the q...
2012/10/22
[ "https://wordpress.stackexchange.com/questions/70033", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5205/" ]
The code below from WPSnipps provides an excerpt character counter, but I'd like to count **words** instead. Does anybody have an idea of how to do this? ``` // Excerpt character count function excerpt_count_js(){ echo '<script>jQuery(document).ready(function(){ jQuery("#postexcerpt .handlediv").after("<div styl...
Here's your code wrapped up in a plugin. The important thing is that it `prepare()`s the input, so the query is safe. You can define 2 arguments: Offset & Limit. Those are basically just the SQL `LIMIT`. If you don't have any use for the plugin, just deactivate it, as it won't do anything - its output is attached to a...
70,048
<p><img src="https://i.stack.imgur.com/8xYfy.gif" alt="Removing default image size list in Media Box"></p> <p>I trying to remove unused image size (Thumbnail, Medium, Large) in MediaBox</p> <p>Any function can i use in functions.php ? or some trick ?</p> <p>PS : I know i can use jQuery trick but any better function ...
[ { "answer_id": 70051, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 1, "selected": false, "text": "<pre><code>function remove_default_image_sizes($sizes) {\n unset($sizes['thumbnail']);\n unset($siz...
2012/10/22
[ "https://wordpress.stackexchange.com/questions/70048", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6332/" ]
![Removing default image size list in Media Box](https://i.stack.imgur.com/8xYfy.gif) I trying to remove unused image size (Thumbnail, Medium, Large) in MediaBox Any function can i use in functions.php ? or some trick ? PS : I know i can use jQuery trick but any better function to use ?
Exactly the same code as Mridul, but different filter: ``` function wp_70048_remove_image_sizes($sizes) { unset($sizes['thumbnail']); unset($sizes['medium']); unset($sizes['large']); return $sizes; } add_filter('image_size_names_choose', 'wp_70048_remove_image_sizes'); ``` Tested with WP 3.4.2 ![r...
70,055
<p>I've created a plugin, and of course being me, I wanted to go with a nice OO approach. Now what I've been doing is to create this class and then just below create an instance of this class:</p> <pre><code>class ClassName { public function __construct(){ } } $class_instance = new ClassName(); </code></p...
[ { "answer_id": 70057, "author": "Tim S.", "author_id": 20639, "author_profile": "https://wordpress.stackexchange.com/users/20639", "pm_score": 2, "selected": false, "text": "<p>It all depends on functionality.</p>\n\n<p>I once made a plugin that registered scripts when the constructor wa...
2012/10/22
[ "https://wordpress.stackexchange.com/questions/70055", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22762/" ]
I've created a plugin, and of course being me, I wanted to go with a nice OO approach. Now what I've been doing is to create this class and then just below create an instance of this class: ``` class ClassName { public function __construct(){ } } $class_instance = new ClassName(); ``` I'm assuming there...
Good question, there are a number of approaches and it depends on what you want to achieve. I often do; ``` add_action( 'plugins_loaded', array( 'someClassy', 'init' )); class someClassy { public static function init() { $class = __CLASS__; new $class; } public function __construct() { ...
70,067
<p>I basically have the same problem like in <a href="https://wordpress.stackexchange.com/questions/30851/how-to-use-a-custom-post-type-archive-as-front-page/30854#30854">this question</a>, but the <em>correct</em> answer doesn't work for me. Yes, I get a list of posts from my CPT, but the <code>archive-{post-type}.php...
[ { "answer_id": 70069, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 2, "selected": false, "text": "<p>Why don't you try using a <code>home.php</code> file and place your desired loop/query within that file or altern...
2012/10/22
[ "https://wordpress.stackexchange.com/questions/70067", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22765/" ]
I basically have the same problem like in [this question](https://wordpress.stackexchange.com/questions/30851/how-to-use-a-custom-post-type-archive-as-front-page/30854#30854), but the *correct* answer doesn't work for me. Yes, I get a list of posts from my CPT, but the `archive-{post-type}.php` is not used to render th...
Why don't you try using a `home.php` file and place your desired loop/query within that file or alternatively use `get_template_part` to retrieve a file that contains your loop. Can you please show us your code? What I frequently do is structure my `index.php` like so, ``` <?php get_header(); ?> <?php if ( is...
70,072
<p>I am using Wordpress Gallery shortcode and I was wondering if there is a way to navigate using the arrow keys? Like if I view an single image and used the right arrow to navigate to the next image in the gallery set. Any idea how to do this?</p>
[ { "answer_id": 72417, "author": "jzatt", "author_id": 22620, "author_profile": "https://wordpress.stackexchange.com/users/22620", "pm_score": 3, "selected": true, "text": "<p>The <a href=\"http://underscores.me/\" rel=\"nofollow\">Underscores (_s)</a> starter theme comes with a keyboard ...
2012/10/22
[ "https://wordpress.stackexchange.com/questions/70072", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17971/" ]
I am using Wordpress Gallery shortcode and I was wondering if there is a way to navigate using the arrow keys? Like if I view an single image and used the right arrow to navigate to the next image in the gallery set. Any idea how to do this?
The [Underscores (\_s)](http://underscores.me/) starter theme comes with a keyboard navigation script for this. I haven't tested this myself though. But the JS file looks like this: ``` jQuery( document ).ready( function( $ ) { $( document ).keydown( function( e ) { var url = false; if ( e.which ==...
70,073
<p>Update / Question clarification: How could you modify the following code from this thread: <a href="https://wordpress.stackexchange.com/questions/14403/force-category-choice-before-creating-new-post">Force category choice before creating new post?</a> which offers a drop-down menu to choose a category BEFORE creatin...
[ { "answer_id": 72417, "author": "jzatt", "author_id": 22620, "author_profile": "https://wordpress.stackexchange.com/users/22620", "pm_score": 3, "selected": true, "text": "<p>The <a href=\"http://underscores.me/\" rel=\"nofollow\">Underscores (_s)</a> starter theme comes with a keyboard ...
2012/10/22
[ "https://wordpress.stackexchange.com/questions/70073", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22537/" ]
Update / Question clarification: How could you modify the following code from this thread: [Force category choice before creating new post?](https://wordpress.stackexchange.com/questions/14403/force-category-choice-before-creating-new-post) which offers a drop-down menu to choose a category BEFORE creating a new post t...
The [Underscores (\_s)](http://underscores.me/) starter theme comes with a keyboard navigation script for this. I haven't tested this myself though. But the JS file looks like this: ``` jQuery( document ).ready( function( $ ) { $( document ).keydown( function( e ) { var url = false; if ( e.which ==...
70,080
<p>I'm making a website for a small church. They would like to upload sermons to their site. I've looked for a WP plugin to do that, but none of them did exactly what they wanted. So, I'm making a plugin to do what they want.</p> <p>I've made a page called 'sermons' that has a page template 'sermon archive'. That ...
[ { "answer_id": 70081, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 1, "selected": false, "text": "<p>You have to either work it out with the <a href=\"http://codex.wordpress.org/Class_Reference/WP_Rewrit...
2012/10/22
[ "https://wordpress.stackexchange.com/questions/70080", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22743/" ]
I'm making a website for a small church. They would like to upload sermons to their site. I've looked for a WP plugin to do that, but none of them did exactly what they wanted. So, I'm making a plugin to do what they want. I've made a page called 'sermons' that has a page template 'sermon archive'. That file will disp...
You have to either work it out with the [WP\_Rewrite](http://codex.wordpress.org/Class_Reference/WP_Rewrite) class or add this to the .htaccess file ``` Options +FollowSymLinks RewriteEngine On RewriteRule ^sermon/(.*)/ /sermon?name=$1 [L] ``` UPDATE ------ Forgot to mention that the htaccess code is supposed to be...
70,092
<p>I have an odd problem with the author list. I am using the below code in my sidebar to pull in the gravatar and link to author's profile. However, the links it's actually generating are wrong. It just generates links to the page that it's on. So when you're on the blog page, all the author links are www.mysite.com/b...
[ { "answer_id": 70091, "author": "Louis", "author_id": 22771, "author_profile": "https://wordpress.stackexchange.com/users/22771", "pm_score": 1, "selected": false, "text": "<p>Editing the <code>functions.php</code> file of your theme is not as bad as it sounds.</p>\n\n<p>The article I ha...
2012/10/22
[ "https://wordpress.stackexchange.com/questions/70092", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19794/" ]
I have an odd problem with the author list. I am using the below code in my sidebar to pull in the gravatar and link to author's profile. However, the links it's actually generating are wrong. It just generates links to the page that it's on. So when you're on the blog page, all the author links are www.mysite.com/blog...
Editing the `functions.php` file of your theme is not as bad as it sounds. The article I had found detailed the right solution. The `functions.php` file is not a WP core file, but part of your theme. So when WordPress updates itself, it does not touch those files. When the plugin is updated, it doesn't affect thes...
70,093
<p>When I upload images, Wordpress 3.4.2 sets the Title to the base of the filename, such as "DSCN1234" or "IMG_1234". I'd like the Title to be left blank.</p> <p>The code that sets the Title during the upload seems to be in "wp-admin/includes/media.php" in the function <code>media_handle_upload()</code>, here:</p> <...
[ { "answer_id": 70098, "author": "mirage", "author_id": 22505, "author_profile": "https://wordpress.stackexchange.com/users/22505", "pm_score": 0, "selected": false, "text": "<p>There is a plugin you could use for this purpose <a href=\"http://wordpress.org/extend/plugins/img-title-remova...
2012/10/22
[ "https://wordpress.stackexchange.com/questions/70093", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22770/" ]
When I upload images, Wordpress 3.4.2 sets the Title to the base of the filename, such as "DSCN1234" or "IMG\_1234". I'd like the Title to be left blank. The code that sets the Title during the upload seems to be in "wp-admin/includes/media.php" in the function `media_handle_upload()`, here: ``` // Construct the atta...
(Answering my own question, with help from @brasofilo) Wordpress 3.5 has a great new Media manager, and it no longer requires the Title to be filled in for images. It also no longer fills in the Title automatically when reorganizing images in a Gallery. It does, however, still fill in the Title with the image filename...
70,096
<p>It's easier if I made an example:</p> <p>I have a custom post type <strong>MYPOSTTYPE</strong>, with 3 taxonomies <strong>TAX_1</strong>, <strong>TAX_2</strong> and <strong>TAX_3</strong></p> <p>If I have 3 terms: 'TERM_TAX_1' in <strong>TAX_1</strong>, 'TERM_TAX_2' in <strong>TAX_2</strong>, and 'TERM_TAX_3' in <...
[ { "answer_id": 70102, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 2, "selected": false, "text": "<p>Do a <a href=\"/questions/tagged/tax-query\" class=\"post-tag\" title=\"show questions tagged 'tax-query'\" rel=\"t...
2012/10/22
[ "https://wordpress.stackexchange.com/questions/70096", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22547/" ]
It's easier if I made an example: I have a custom post type **MYPOSTTYPE**, with 3 taxonomies **TAX\_1**, **TAX\_2** and **TAX\_3** If I have 3 terms: 'TERM\_TAX\_1' in **TAX\_1**, 'TERM\_TAX\_2' in **TAX\_2**, and 'TERM\_TAX\_3' in **TAX\_3**, how can I count how many MYPOSTTYPE have all the 3 terms with a SQL query...
Do a [tax-query](/questions/tagged/tax-query "show questions tagged 'tax-query'") and then `count` the result. No need for a custom query with dozens of `JOINS`. ``` $posts = new WP_Query( array( 'post_type' => 'MYPOSTTYPE', 'tax_query' => array( array( 'taxonomy' => 'TAX_1',...
70,117
<p>I have a weird problem, which I could not solve yet. I installed wordpress 3.4.1 and made an own template. I use one plugin - qTranslate. Everything is fine on my local copy and also on my dev copy dev.mysite.cz.</p> <p>When I copied wordpress and log in on the main site, <a href="http://www.mysite.cz" rel="nofollo...
[ { "answer_id": 70131, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 0, "selected": false, "text": "<p>When you say \"copied\" Wordpress, what do you mean?</p>\n\n<p>Do you mean,</p>\n\n<p>A) I copied my entire Wordp...
2012/10/22
[ "https://wordpress.stackexchange.com/questions/70117", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22787/" ]
I have a weird problem, which I could not solve yet. I installed wordpress 3.4.1 and made an own template. I use one plugin - qTranslate. Everything is fine on my local copy and also on my dev copy dev.mysite.cz. When I copied wordpress and log in on the main site, <http://www.mysite.cz>, the dashboard does not show u...
The problem was in .htaccess. There was an old global .htaccess file (from the old website) besides the wordpress one which was hidden on the sever (by admins of the hosting company) which rewrite rules harmed the ones in wordpress. I actually had to contact the admins and ask them to remove those rewrite rules.
70,125
<p>I have created a function that takes one parameter - post type, and will output each posts with some html and title, content etc within that. However, I want to be able to use functions associated with <code>$post</code>, especially <code>the_excerpt</code>. However, when I try to use my function in my sidebar php...
[ { "answer_id": 70127, "author": "Michael", "author_id": 4884, "author_profile": "https://wordpress.stackexchange.com/users/4884", "pm_score": 0, "selected": false, "text": "<p><code>setup_postdata($post);</code> seems to require that <code>$post</code> is set as a global variable:</p>\n\...
2012/10/22
[ "https://wordpress.stackexchange.com/questions/70125", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14739/" ]
I have created a function that takes one parameter - post type, and will output each posts with some html and title, content etc within that. However, I want to be able to use functions associated with `$post`, especially `the_excerpt`. However, when I try to use my function in my sidebar php widget, it simply outputs ...
Your function works in your page template but not in the sidebar because at the point that your template is processed, $post already contains the post that has been loaded for the page. I tried your code and, just like Michael said, all I needed to add was the global declaration of $post ***inside the function***, and...
70,129
<p>I have a network of two sites, <code>A.example.com</code> and <code>B.example.com</code>. I'd like it so that if I create a page on <code>A</code> with a permalink of <code>/Widgets</code> I can access it on <code>B</code> using the same relative permalink but without having to actually create the content on <code>B...
[ { "answer_id": 70127, "author": "Michael", "author_id": 4884, "author_profile": "https://wordpress.stackexchange.com/users/4884", "pm_score": 0, "selected": false, "text": "<p><code>setup_postdata($post);</code> seems to require that <code>$post</code> is set as a global variable:</p>\n\...
2012/10/22
[ "https://wordpress.stackexchange.com/questions/70129", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12496/" ]
I have a network of two sites, `A.example.com` and `B.example.com`. I'd like it so that if I create a page on `A` with a permalink of `/Widgets` I can access it on `B` using the same relative permalink but without having to actually create the content on `B`. (One site has user profiles that we'd like to continue to ma...
Your function works in your page template but not in the sidebar because at the point that your template is processed, $post already contains the post that has been loaded for the page. I tried your code and, just like Michael said, all I needed to add was the global declaration of $post ***inside the function***, and...
70,140
<p>I am using the following code to print out the last 8 published post in columns of 3 so 3 column and 3 rows : </p> <pre><code>&lt;?php $args = array( 'post_type' =&gt; 'post', 'posts_per_page' =&gt; 8, 'paged' =&gt; ( get_query_var('paged') ? get_query_var('paged') : 1...
[ { "answer_id": 70127, "author": "Michael", "author_id": 4884, "author_profile": "https://wordpress.stackexchange.com/users/4884", "pm_score": 0, "selected": false, "text": "<p><code>setup_postdata($post);</code> seems to require that <code>$post</code> is set as a global variable:</p>\n\...
2012/10/23
[ "https://wordpress.stackexchange.com/questions/70140", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20460/" ]
I am using the following code to print out the last 8 published post in columns of 3 so 3 column and 3 rows : ``` <?php $args = array( 'post_type' => 'post', 'posts_per_page' => 8, 'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1) ); quer...
Your function works in your page template but not in the sidebar because at the point that your template is processed, $post already contains the post that has been loaded for the page. I tried your code and, just like Michael said, all I needed to add was the global declaration of $post ***inside the function***, and...
70,143
<p>I am using someone else's WP plugin which stores lots of related data in <code>wp_postmeta</code> using an "artificial key". So effectively we hijack <code>wp_postmeta</code> to create a nested relational database. So one row will have </p> <pre><code> meta_id = 999 post_id = 130 meta_key = 'event_id' meta...
[ { "answer_id": 70146, "author": "Pieter", "author_id": 20277, "author_profile": "https://wordpress.stackexchange.com/users/20277", "pm_score": 0, "selected": false, "text": "<p>You can select your posts by using the meta_query parameter in the <a href=\"http://codex.wordpress.org/Class_R...
2012/10/23
[ "https://wordpress.stackexchange.com/questions/70143", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22799/" ]
I am using someone else's WP plugin which stores lots of related data in `wp_postmeta` using an "artificial key". So effectively we hijack `wp_postmeta` to create a nested relational database. So one row will have ``` meta_id = 999 post_id = 130 meta_key = 'event_id' meta_value = '19' ``` Then 4 other a...
If I understand your question correctly, this should work: ``` function get_event_info($event_id = 0, $info = '' ) { global $wpdb; return $wpdb->get_col( $wpdb->prepare( "SELECT meta_value from $wpdb->postmeta WHERE meta_key = '%s' AND post_id IN (SELECT DISTINCT post_id FROM $wpdb->postmeta...
70,149
<p>I have updated my permalink structure to <code>/archive/%post_id%</code>, but if someone uses a URL like <code>/archive/456857</code> instead of the full URL of <code>/blog-test</code>, WordPress shows the post without giving a 301 to the full URL. Isn't this poor SEO? Sites like tumblr and stackexchange automatical...
[ { "answer_id": 70146, "author": "Pieter", "author_id": 20277, "author_profile": "https://wordpress.stackexchange.com/users/20277", "pm_score": 0, "selected": false, "text": "<p>You can select your posts by using the meta_query parameter in the <a href=\"http://codex.wordpress.org/Class_R...
2012/10/23
[ "https://wordpress.stackexchange.com/questions/70149", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22801/" ]
I have updated my permalink structure to `/archive/%post_id%`, but if someone uses a URL like `/archive/456857` instead of the full URL of `/blog-test`, WordPress shows the post without giving a 301 to the full URL. Isn't this poor SEO? Sites like tumblr and stackexchange automatically send a 301 to the full URL. Any h...
If I understand your question correctly, this should work: ``` function get_event_info($event_id = 0, $info = '' ) { global $wpdb; return $wpdb->get_col( $wpdb->prepare( "SELECT meta_value from $wpdb->postmeta WHERE meta_key = '%s' AND post_id IN (SELECT DISTINCT post_id FROM $wpdb->postmeta...
70,169
<p>Is it possible to allow a user to select which theme they would like installed from the new site signup page? And once the site is created, it obviously installs whichever theme they chose.</p> <p>I found <a href="http://codex.wordpress.org/Function_Reference/wp_get_themes">wp_get_themes</a>. Is this how you would ...
[ { "answer_id": 70534, "author": "Nohl", "author_id": 2469, "author_profile": "https://wordpress.stackexchange.com/users/2469", "pm_score": 0, "selected": false, "text": "<p>This kind of answers your question:\nWe put a plugin called '<a href=\"http://www.nkuttler.de/wordpress/nkthemeswit...
2012/10/23
[ "https://wordpress.stackexchange.com/questions/70169", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4999/" ]
Is it possible to allow a user to select which theme they would like installed from the new site signup page? And once the site is created, it obviously installs whichever theme they chose. I found [wp\_get\_themes](http://codex.wordpress.org/Function_Reference/wp_get_themes). Is this how you would go about pre-popula...
In order to do what you want , you can add whatever fields you want, and then store them in the `user_meta` ... (One could also store them in the `$user_info` array/object, but I am not sure what would be the benefit .. ) ``` // Render Form Fields add_action('register_form','k99_register_form_add_theme_field'); // ...
70,191
<p>I don't know whats causing the problem but the <code>echo do_shortcode</code> is not working on my theme's template, but its working on my plugin's template and the shortcode is working on my posts and pages. Pretty weird. Here's the code </p> <pre><code>&lt;?php $my_query = new WP_Query('category_name=video po...
[ { "answer_id": 71339, "author": "david", "author_id": 22546, "author_profile": "https://wordpress.stackexchange.com/users/22546", "pm_score": 1, "selected": true, "text": "<p><a href=\"http://www.longtailvideo.com/support/forums/jw-player/setup-issues-and-embedding/20472/wordpress-doshor...
2012/10/23
[ "https://wordpress.stackexchange.com/questions/70191", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9583/" ]
I don't know whats causing the problem but the `echo do_shortcode` is not working on my theme's template, but its working on my plugin's template and the shortcode is working on my posts and pages. Pretty weird. Here's the code ``` <?php $my_query = new WP_Query('category_name=video post&posts_per_page=10'); while (...
[According to the developer](http://www.longtailvideo.com/support/forums/jw-player/setup-issues-and-embedding/20472/wordpress-doshortcode-not-working) of the jwPlayer it was necessary to implement the plugin as a filter to be able to support '.' in tag attributes. Hence `do_shortcode(..)` does not work but `jwplayer_ta...
70,193
<p>Once a minute I get the following notice sequence in debug.log:</p> <pre><code>[23-Oct-2012 13:27:33 UTC] PHP Notice: Trying to get property of non-object in mysite/wp-includes/capabilities.php on line 1022 [23-Oct-2012 13:27:33 UTC] PHP Notice: Trying to get property of non-object in mysite/wp-includes/capabilit...
[ { "answer_id": 70209, "author": "Johannes Pille", "author_id": 9745, "author_profile": "https://wordpress.stackexchange.com/users/9745", "pm_score": 2, "selected": false, "text": "<p>The actual \"sequence\" of notices is half of what you posted above (see the 2 second offset for one, and...
2012/10/23
[ "https://wordpress.stackexchange.com/questions/70193", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16352/" ]
Once a minute I get the following notice sequence in debug.log: ``` [23-Oct-2012 13:27:33 UTC] PHP Notice: Trying to get property of non-object in mysite/wp-includes/capabilities.php on line 1022 [23-Oct-2012 13:27:33 UTC] PHP Notice: Trying to get property of non-object in mysite/wp-includes/capabilities.php on lin...
The actual "sequence" of notices is half of what you posted above (see the 2 second offset for one, and for another the repeating line numbers). This notice is from the [`map_meta_cap()`](http://codex.wordpress.org/Function_Reference/map_meta_cap) function which maps custom post type capabilities to the regular or pri...
70,201
<p>When you login to the admin you see the Welcome page by default. A client of mine requested to see the "Pages" page by default, he had seen it somewhere else.</p> <p>Is this possible, and if so, how? Tried searching but found nothing relevant, didn't find it in the settings either.</p>
[ { "answer_id": 70229, "author": "Ben HartLenn", "author_id": 6645, "author_profile": "https://wordpress.stackexchange.com/users/6645", "pm_score": 4, "selected": true, "text": "<p>This should work for you if you put it in your themes functions.php file, but you may want to modify the con...
2012/10/23
[ "https://wordpress.stackexchange.com/questions/70201", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22530/" ]
When you login to the admin you see the Welcome page by default. A client of mine requested to see the "Pages" page by default, he had seen it somewhere else. Is this possible, and if so, how? Tried searching but found nothing relevant, didn't find it in the settings either.
This should work for you if you put it in your themes functions.php file, but you may want to modify the conditions, and the url to redirect to depending on your set up. ``` function loginRedirect( $redirect_to, $request, $user ){ if( is_array( $user->roles ) ) { // check if user has a role return "/wp-adm...
70,202
<p>How do I display trackbacks (the link and the date) outside of the twentyeleven comment loop?</p> <p>The function below is from the twentyeleven functions.php file. I'm using the standard comments.php file from twentyeleven, and the trackbacks are shown under the comments when using <code>&lt;?php comments_template...
[ { "answer_id": 70468, "author": "versvs", "author_id": 16582, "author_profile": "https://wordpress.stackexchange.com/users/16582", "pm_score": 2, "selected": false, "text": "<p>In your comments.php (child theme) you can use something like that:</p>\n\n<pre><code>&lt;ol class=\"commentlis...
2012/10/23
[ "https://wordpress.stackexchange.com/questions/70202", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/268/" ]
How do I display trackbacks (the link and the date) outside of the twentyeleven comment loop? The function below is from the twentyeleven functions.php file. I'm using the standard comments.php file from twentyeleven, and the trackbacks are shown under the comments when using `<?php comments_template( '', true ); ?>` ...
Use the `type`param in the function `wp_list_comments()`. Copy the comments.php to your Child Theme. search for `wp_list_comments`. Find this: ``` <ol class="commentlist"> <?php /* Loop through and list the comments. Tell wp_list_comments() * to use twentyeleven_comment() to format...
70,208
<p>Tried to make a simple redirect for some users I don't want to access the wp-admin/, so I did this code:</p> <pre><code>function no_admin_access() { if ( !current_user_can( 'delete_posts' ) ) { wp_redirect( site_url( '/' ) ); exit; } } add_action('admin_init', 'no_admin_access'); </code></pre> <p>B...
[ { "answer_id": 70221, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": true, "text": "<p>You can and a check for the <code>DOING_AJAX</code> constant which is defined on an Ajax in your conditional c...
2012/10/23
[ "https://wordpress.stackexchange.com/questions/70208", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20135/" ]
Tried to make a simple redirect for some users I don't want to access the wp-admin/, so I did this code: ``` function no_admin_access() { if ( !current_user_can( 'delete_posts' ) ) { wp_redirect( site_url( '/' ) ); exit; } } add_action('admin_init', 'no_admin_access'); ``` But when I then try to make...
You can and a check for the `DOING_AJAX` constant which is defined on an Ajax in your conditional check: ``` function no_admin_access() { if ( // Don't do this for AJAX calls ! defined( 'DOING_AJAX' ) // Capability check && ! current_user_can( 'delete_posts' ) ) { ...
70,214
<p>Referencing <a href="http://wordpress-hackers.1065353.n5.nabble.com/Multiple-orderby-and-order-options-in-WP-Query-tp36938p36944.html" rel="nofollow">@Otto's response</a> to a question I also had about ordering by multiple fields, here is what he said:</p> <blockquote> <p>Can't do it with a naive WP_Query. Use th...
[ { "answer_id": 70220, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 2, "selected": false, "text": "<p>Never forget that there're actually <strong>two filters</strong></p>\n\n<pre><code>// Add additional query args tha...
2012/10/23
[ "https://wordpress.stackexchange.com/questions/70214", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9605/" ]
Referencing [@Otto's response](http://wordpress-hackers.1065353.n5.nabble.com/Multiple-orderby-and-order-options-in-WP-Query-tp36938p36944.html) to a question I also had about ordering by multiple fields, here is what he said: > > Can't do it with a naive WP\_Query. Use the posts\_orderby filter to add > your own o...
Never forget that there're actually **two filters** ``` // Add additional query args that are allowed by the API by default pre_get_posts // Modify the query herself posts_clauses // Inspect the resulting string - test this one in for e.g. phpMyAdmin posts_request ``` So everything you can achieve using the `pre_get...
70,215
<p>I want to add the featured image URL of a post to the header. When a Facebook user shares a Wordpress page, this code in the header:</p> <p>The <code>rel="image_src"</code> attribute is what facebook is searching for.</p> <pre><code>&lt;link rel="image_src" href="FEATUREDIMAGEURL"&gt; </code></pre> <p>Will return...
[ { "answer_id": 70217, "author": "Michael", "author_id": 4884, "author_profile": "https://wordpress.stackexchange.com/users/4884", "pm_score": 2, "selected": false, "text": "<p>there was a closing bracket missing in the second line; and you need to reference the first array element of <co...
2012/10/23
[ "https://wordpress.stackexchange.com/questions/70215", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22585/" ]
I want to add the featured image URL of a post to the header. When a Facebook user shares a Wordpress page, this code in the header: The `rel="image_src"` attribute is what facebook is searching for. ``` <link rel="image_src" href="FEATUREDIMAGEURL"> ``` Will return a specific image for the share. However, I cannot...
To answer this one and point to the *real* problem: As the `<head>` HTML tag comes far before the actual loop, you'll need something else than the `global $post`. ``` get_queried_object(); get_queried_object_id(); ``` The plugin ---------- *The code is tested and works.* As you might want to keep this functionali...
70,224
<p>i've been organizing my sites template files into a sub directory, which is now possible with wordpress 3.4. but when i move a custom post-type single file (ie. single-news.php) into the sub directory, it is not recognized. anybody have any experience with this new feature?</p>
[ { "answer_id": 70233, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 1, "selected": false, "text": "<p>Yeah only the page templates are recognized &amp; not the archive,single etc. templates. Your single f...
2012/10/23
[ "https://wordpress.stackexchange.com/questions/70224", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22828/" ]
i've been organizing my sites template files into a sub directory, which is now possible with wordpress 3.4. but when i move a custom post-type single file (ie. single-news.php) into the sub directory, it is not recognized. anybody have any experience with this new feature?
The solution shared in this answer on StackOverflow works for me: <https://stackoverflow.com/questions/4647604/wp-use-file-in-plugin-directory-as-custom-page-template#answer-8255556> ``` function get_book_post_type_template($single_template) { global $post; if ($post->post_type == 'books') { $single_...
70,230
<p>I created a Custom Post type and in that custom post type have a hierarchical taxonomy (categories).</p> <p>Here's an example of the categories I made:</p> <pre><code>Hats - Mens - Womens Shoes - Mens - Womens </code></pre> <p>The problem is that when I go to the "Mens" sub-category of the "Shoes" Main categ...
[ { "answer_id": 70231, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 2, "selected": true, "text": "<p>This is a problem with wordpress that happened to me as well. If the titles of 2 terms (even if they ar...
2012/10/23
[ "https://wordpress.stackexchange.com/questions/70230", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10298/" ]
I created a Custom Post type and in that custom post type have a hierarchical taxonomy (categories). Here's an example of the categories I made: ``` Hats - Mens - Womens Shoes - Mens - Womens ``` The problem is that when I go to the "Mens" sub-category of the "Shoes" Main category it goes to the Mens category ...
This is a problem with wordpress that happened to me as well. If the titles of 2 terms (even if they are from different taxonomy), wordpress will not create another term in the database, instead link the previous term to taxonomy. If you look in your database, you'll find only 1 term with title "Mens" which will be a c...
70,232
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://wordpress.stackexchange.com/questions/4696/pagination-not-working-with-custom-loop">Pagination not working with custom loop</a> </p> </blockquote> <p>Apparently this is very popular issue. There are already bunch of people offering answer...
[ { "answer_id": 70234, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 1, "selected": false, "text": "<p>From the codex <a href=\"http://codex.wordpress.org/Using_Permalinks\" rel=\"nofollow\">http://codex.w...
2012/10/23
[ "https://wordpress.stackexchange.com/questions/70232", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14728/" ]
> > **Possible Duplicate:** > > [Pagination not working with custom loop](https://wordpress.stackexchange.com/questions/4696/pagination-not-working-with-custom-loop) > > > Apparently this is very popular issue. There are already bunch of people offering answers for this. But somehow after hours of searching I ...
Try the following and see how you go.. ``` <?php global $paged; global $wp_query; $temp = $wp_query; $wp_query = null; $wp_query = new WP_Query(); $wp_query->query('posts_per_page=10&post_type=your_post_type'.'&paged='.$paged); while ($wp_query->have_posts()) : $wp_query->the_post(); ?> <!-- do you...
70,243
<p>I'm trying to run a function when deleting a comment. This entails <a href="http://hitchhackerguide.com/2011/02/12/wp_delete_comment/" rel="nofollow">hooking into "delete_comment" if I'm not mistaken</a>.</p> <p>Theoretically, this should work as a plugin, so when you delete a comment, it emails me. But when I inst...
[ { "answer_id": 70258, "author": "dmarges", "author_id": 22636, "author_profile": "https://wordpress.stackexchange.com/users/22636", "pm_score": 0, "selected": false, "text": "<p>I would have just added as a comment to this, but I can't comment...</p>\n\n<p>A few things I would try are:</...
2012/10/23
[ "https://wordpress.stackexchange.com/questions/70243", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22825/" ]
I'm trying to run a function when deleting a comment. This entails [hooking into "delete\_comment" if I'm not mistaken](http://hitchhackerguide.com/2011/02/12/wp_delete_comment/). Theoretically, this should work as a plugin, so when you delete a comment, it emails me. But when I install and activate it, nothing happen...
Unless you're passing `$force_delete` as `true` when calling `wp_delete_comment()`, the `delete_comment` hook doesn't fire. This is because WordPress calls `wp_trash_comment()` at the beginning of `wp_delete_comment()` if `$force_delete` isn't set `true`. Try hooking into the `trash_comment` action hook: ``` functio...
70,246
<p>I'm creating a site where a central question will be posed on the front page with excerpted first-tier comments linking to a page with the full first-tier comment, presented almost as a post, with nested replies to that comment below. Why a comment as a post? Seemed like a good way to let users author content witho...
[ { "answer_id": 70257, "author": "dmarges", "author_id": 22636, "author_profile": "https://wordpress.stackexchange.com/users/22636", "pm_score": 1, "selected": false, "text": "<p>checkout the <a href=\"http://codex.wordpress.org/Function_Reference/comment_reply_link\" rel=\"nofollow\"><co...
2012/10/23
[ "https://wordpress.stackexchange.com/questions/70246", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22831/" ]
I'm creating a site where a central question will be posed on the front page with excerpted first-tier comments linking to a page with the full first-tier comment, presented almost as a post, with nested replies to that comment below. Why a comment as a post? Seemed like a good way to let users author content without g...
checkout the [`comment_reply_link`](http://codex.wordpress.org/Function_Reference/comment_reply_link) function... An example would be: ``` comment_reply_link( array_merge( $args, array( 'depth' => $depth, 'max_depth' => $args['max_depth'], ) ) ); ```
70,252
<p>If post content exists, do not display featured image, if it does not exists, then display featured image or url. So, basically I want featured image to be displayed only if nothing else in post content to be displayed. Thanks!!!!</p>
[ { "answer_id": 70253, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": true, "text": "<p>Just check the raw post content without any filters:</p>\n\n<pre><code>if ( \"\" === $post-&gt;post_content )\n{\n ...
2012/10/23
[ "https://wordpress.stackexchange.com/questions/70252", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22835/" ]
If post content exists, do not display featured image, if it does not exists, then display featured image or url. So, basically I want featured image to be displayed only if nothing else in post content to be displayed. Thanks!!!!
Just check the raw post content without any filters: ``` if ( "" === $post->post_content ) { the_post_thumbnail(); } else { the_content(); } ```
70,280
<p>The main "Forums" page where all forums are supposed to be listed is empty. <img src="https://i.stack.imgur.com/dVE8b.png" alt="enter image description here"> What have I missed here or the combination of BuddyPress and bbPress caused this page not to work anymore?</p> <p>I have followed the installation guide here...
[ { "answer_id": 70253, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": true, "text": "<p>Just check the raw post content without any filters:</p>\n\n<pre><code>if ( \"\" === $post-&gt;post_content )\n{\n ...
2012/10/24
[ "https://wordpress.stackexchange.com/questions/70280", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6986/" ]
The main "Forums" page where all forums are supposed to be listed is empty. ![enter image description here](https://i.stack.imgur.com/dVE8b.png) What have I missed here or the combination of BuddyPress and bbPress caused this page not to work anymore? I have followed the installation guide here <http://codex.buddypres...
Just check the raw post content without any filters: ``` if ( "" === $post->post_content ) { the_post_thumbnail(); } else { the_content(); } ```
70,287
<p>So, I get how to easily create separate blog "feeds" in a single blog by using categories. While I can style the category feed pages differently, unfortunately they both just provide links to the same style/theming of individual posts. I'm curious if there is any way for me to style the individual posts differently ...
[ { "answer_id": 70291, "author": "Gunslinger", "author_id": 10721, "author_profile": "https://wordpress.stackexchange.com/users/10721", "pm_score": -1, "selected": false, "text": "<p>You could write different css-code for each and place all of these in your style.css.\nMake each separate ...
2012/10/24
[ "https://wordpress.stackexchange.com/questions/70287", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18683/" ]
So, I get how to easily create separate blog "feeds" in a single blog by using categories. While I can style the category feed pages differently, unfortunately they both just provide links to the same style/theming of individual posts. I'm curious if there is any way for me to style the individual posts differently bas...
I suspect I do not entirely follow your meaning when you say 'feeds'. However, you say that you want a > > way for me to style the individual posts differently based on what feed category they were viewed from? > > > I may be off base, but if you really mean to say that you want to style a post differently based...
70,290
<p>I've built a super-crazy Wordpress framework that has a million and one shortcodes, one of those is a columns shortcode which supports a count parameter that allows you to define a column and the appropriate class will be added.</p> <p><strong>My shortcode is as follows:</strong></p> <pre><code>add_shortcode('colu...
[ { "answer_id": 70306, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 3, "selected": true, "text": "<p>This is a known issue. If you have one shortcode inside another which has the same name, the wordpress ...
2012/10/24
[ "https://wordpress.stackexchange.com/questions/70290", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1687/" ]
I've built a super-crazy Wordpress framework that has a million and one shortcodes, one of those is a columns shortcode which supports a count parameter that allows you to define a column and the appropriate class will be added. **My shortcode is as follows:** ``` add_shortcode('column', 'column_shortcode'); function...
This is a known issue. If you have one shortcode inside another which has the same name, the wordpress parser will not be able to handle them correctly. This is also mentioned in the [codex page for shortcode API](http://codex.wordpress.org/Shortcode_API#Nested_Shortcodes) under limitations. From the linked page `Howe...
70,304
<p>I have 700 posts mostly in excess of 1000 words each. I'm setting this up as a membership site. I'm using wishlist member and would like to protect all the content after the first 350 words. This requires placing a short tag after the 350th word and another short tag at the very end of the post.</p> <p>Adding t...
[ { "answer_id": 70309, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 0, "selected": false, "text": "<p>Instead of going to the database, what's the problem in doing it directly on the front-end when displa...
2012/10/24
[ "https://wordpress.stackexchange.com/questions/70304", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22858/" ]
I have 700 posts mostly in excess of 1000 words each. I'm setting this up as a membership site. I'm using wishlist member and would like to protect all the content after the first 350 words. This requires placing a short tag after the 350th word and another short tag at the very end of the post. Adding the shortcode a...
The following will allow you to limit content to any word count you like based upon whether the user is part of a certain user role or not. The function can be improved and or made more efficient but at least it provides you the basis for filtering your content without having to physically edit the content or run any c...
70,308
<p>I have the following custom post-type and custom taxonomy setup:</p> <pre><code>add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( 'system', array( 'labels' =&gt; array( 'name' =&gt; __( 'Systems' ), 'singular_name' =&g...
[ { "answer_id": 70327, "author": "Daniel Sachs", "author_id": 4451, "author_profile": "https://wordpress.stackexchange.com/users/4451", "pm_score": 1, "selected": false, "text": "<p>This can be a bit challenging for WordPress, because it wouldn't know whether you are referring to post, pa...
2012/10/24
[ "https://wordpress.stackexchange.com/questions/70308", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4588/" ]
I have the following custom post-type and custom taxonomy setup: ``` add_action( 'init', 'create_post_type' ); function create_post_type() { register_post_type( 'system', array( 'labels' => array( 'name' => __( 'Systems' ), 'singular_name' => __( 'System' ) ...
This can be a bit challenging for WordPress, because it wouldn't know whether you are referring to post, page or taxonomy. Nevertheless, rename your taxonomy to something like `product_category` and try changing the slug in your post type arguments to `system/%product_category%`, and slug in your taxonomy arguments to ...
70,317
<p>I'm making a one page site. On the page I want to run WP_Query three or four times to pull in those 3-4 pages. </p> <p>The page looks a bit like this: </p> <pre><code>&lt;div class="row"&gt; &lt;?php $args = array( 'pagename' =&gt; 'page-1'); $the_query = new WP_Query( $args ); // The Loop if ...
[ { "answer_id": 70321, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 3, "selected": true, "text": "<h2>How-to simplify your life</h2>\n\n<p>I'd go a fairly simpler route:</p>\n\n<ul>\n<li>Add a \"main/parent\" page</li...
2012/10/24
[ "https://wordpress.stackexchange.com/questions/70317", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3877/" ]
I'm making a one page site. On the page I want to run WP\_Query three or four times to pull in those 3-4 pages. The page looks a bit like this: ``` <div class="row"> <?php $args = array( 'pagename' => 'page-1'); $the_query = new WP_Query( $args ); // The Loop if ( $the_query->have_posts() ) : ...
How-to simplify your life ------------------------- I'd go a fairly simpler route: * Add a "main/parent" page * Apply your template there * Add "child" pages to this main page * Alter the query to include them Code example as plugin for a quick test --------------------------------------- Here's an (untested) plugi...
70,336
<p>My Title tags same sentence show twice. <a href="http://www.desyfun.tk/wp-content/uploads/2012/10/2012-10-24_210647.jpg" rel="nofollow">please see it</a>. how i can solve this problem . <a href="http://dewdropzone.com/" rel="nofollow">my site</a> </p>
[ { "answer_id": 70339, "author": "Pieter", "author_id": 20277, "author_profile": "https://wordpress.stackexchange.com/users/20277", "pm_score": 2, "selected": true, "text": "<p>Go to the header.php file in your template folder and make sure that between the title tags, there's only this c...
2012/10/24
[ "https://wordpress.stackexchange.com/questions/70336", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22576/" ]
My Title tags same sentence show twice. [please see it](http://www.desyfun.tk/wp-content/uploads/2012/10/2012-10-24_210647.jpg). how i can solve this problem . [my site](http://dewdropzone.com/)
Go to the header.php file in your template folder and make sure that between the title tags, there's only this code: ``` <?php wp_title('');?> ``` That should do the trick. This error is a combination of your template files with standard settings of the Yoast SEO plugin.
70,342
<p>I am trying to get posts with an author's ID as a meta value in the <code>author.php</code> template using additional request parameter.</p> <p>For example I want posts with john's ID as a meta value using a request like this</p> <pre><code>http://localhost:8888/twitgreen/author/john/?eco=somemetakey </code></pre>...
[ { "answer_id": 70339, "author": "Pieter", "author_id": 20277, "author_profile": "https://wordpress.stackexchange.com/users/20277", "pm_score": 2, "selected": true, "text": "<p>Go to the header.php file in your template folder and make sure that between the title tags, there's only this c...
2012/10/24
[ "https://wordpress.stackexchange.com/questions/70342", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6383/" ]
I am trying to get posts with an author's ID as a meta value in the `author.php` template using additional request parameter. For example I want posts with john's ID as a meta value using a request like this ``` http://localhost:8888/twitgreen/author/john/?eco=somemetakey ``` So far I can make it using a `new WP_qu...
Go to the header.php file in your template folder and make sure that between the title tags, there's only this code: ``` <?php wp_title('');?> ``` That should do the trick. This error is a combination of your template files with standard settings of the Yoast SEO plugin.
70,355
<p>I am wondering if there is any reason why the following code would not work?</p> <p>My situation: I have a custom category set up called 'Issue'. What I want to do is get the most newly created category (which is 'Volume 2 Issue 1') and get its ID so that I can run the <a href="http://zahlan.net/blog/2012/06/catego...
[ { "answer_id": 70365, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 1, "selected": false, "text": "<p>You can use this function <a href=\"http://codex.wordpress.org/Function_Reference/get_categories\" rel...
2012/10/24
[ "https://wordpress.stackexchange.com/questions/70355", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9264/" ]
I am wondering if there is any reason why the following code would not work? My situation: I have a custom category set up called 'Issue'. What I want to do is get the most newly created category (which is 'Volume 2 Issue 1') and get its ID so that I can run the [plugin](http://zahlan.net/blog/2012/06/categories-image...
Removed the single quotes I had been adding to `$newtax` got it to work (as following:) ``` $taxonomy=wp_list_categories('taxonomy=issue&echo=0&number=1&orderby=ID&order=DESC&show_count=0&style=none&title_li='); $tax = strip_tags($taxonomy); $newtax = trim($tax); $getID = get_term_by('name', $newtax, 'issue'); $curren...
70,364
<p>The TinyMCE Editor has a great button in the kitchen sink to insert custom characters / symbols.</p> <p>Is there a way to control what symbols show up in this pop-up? (Specifically I need some unique Hawaiian language characters 'okina and macrons).</p> <pre><code>Code Character &amp;#256; Ā &amp;#257; ā &am...
[ { "answer_id": 70367, "author": "brandoncamenisch", "author_id": 43795, "author_profile": "https://wordpress.stackexchange.com/users/43795", "pm_score": 2, "selected": false, "text": "<p>This has to do with your character map for tinyMCE it's located inside:</p>\n\n<blockquote>\n <p>wp-...
2012/10/24
[ "https://wordpress.stackexchange.com/questions/70364", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2932/" ]
The TinyMCE Editor has a great button in the kitchen sink to insert custom characters / symbols. Is there a way to control what symbols show up in this pop-up? (Specifically I need some unique Hawaiian language characters 'okina and macrons). ``` Code Character &#256; Ā &#257; ā &#274; Ē &#275; ē &#298; Ī &#2...
This has to do with your character map for tinyMCE it's located inside: > > wp-includes/js/tinymce/themes/advanced/js/charmap.js > > > Although I wouldn't recommend editing the WP-Core you could theoretically just add new characters there like so: ``` ['&#298;', '&#298;', true,'I kahako'], ['&#332;', '&...
70,371
<p>I've written several plugins using the structure :</p> <p>/plugins/myplugin/myplugin.php /plugins/myplugin/class/class-myclass.php</p> <p>So as to take advantage of OO and overall structuring my code</p> <p>From within the class file there are times I need to get the URL of the base plugin... I have been using t...
[ { "answer_id": 70372, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": false, "text": "<p>You should make all of your classes independent of their actual location, so you can move them around easily and maybe...
2012/10/24
[ "https://wordpress.stackexchange.com/questions/70371", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8756/" ]
I've written several plugins using the structure : /plugins/myplugin/myplugin.php /plugins/myplugin/class/class-myclass.php So as to take advantage of OO and overall structuring my code From within the class file there are times I need to get the URL of the base plugin... I have been using the following, but I'm sur...
In a subdirectory within your plugin directory you can use the following code: ``` $this->plugin_location = plugin_dir_url(dirname(__FILE__)); ```
70,383
<p>I want to set up a function that notifies me when a core update is available. But i can't find any functions that check for updates.</p> <p>I have looked at list_core_updates() and it may be possible to check if it returns anything, but i don't know if that is smart.</p>
[ { "answer_id": 70386, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 4, "selected": true, "text": "<p>There is <a href=\"http://queryposts.com/function/get_core_updates/\"><code>get_core_updates()</code></a>.</p>\n\n<p>...
2012/10/24
[ "https://wordpress.stackexchange.com/questions/70383", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11861/" ]
I want to set up a function that notifies me when a core update is available. But i can't find any functions that check for updates. I have looked at list\_core\_updates() and it may be possible to check if it returns anything, but i don't know if that is smart.
There is [`get_core_updates()`](http://queryposts.com/function/get_core_updates/). Note that you might need to manually include admin file that declares it, if running in front end and such. Example use: ``` require_once ABSPATH . '/wp-admin/includes/update.php'; print_r( get_core_updates() ); ``` Example return: ...
70,409
<p>I'm setting up a website which will track the users by their role in relationship to the company. I want to use the built-in WP user functionality, but I don't want to send out notifications to all these people that I'm mucking around with the backend, when I have no intention of giving them edit access at all. I ju...
[ { "answer_id": 70410, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": true, "text": "<p>Maybe the simplest way is to <a href=\"http://codex.wordpress.org/Writing_a_Plugin\" rel=\"nofollow\">make a quick p...
2012/10/25
[ "https://wordpress.stackexchange.com/questions/70409", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20348/" ]
I'm setting up a website which will track the users by their role in relationship to the company. I want to use the built-in WP user functionality, but I don't want to send out notifications to all these people that I'm mucking around with the backend, when I have no intention of giving them edit access at all. I just ...
Maybe the simplest way is to [make a quick plugin](http://codex.wordpress.org/Writing_a_Plugin) that has your own form for inserting users. [`wp_insert_user()`](http://codex.wordpress.org/Function_Reference/wp_insert_user) doesn't require an email address or password, and doesn't generate an email notification. ``` f...
70,415
<p>I have a blog that I write up entries for that sometimes has programming code as part of the text within my writing's. Normally I use the quote function to give it a bit of highlighting, but was wondering if there's a better way that anyone has come across in their travels. Something that could do this for example:<...
[ { "answer_id": 70429, "author": "Pavel Petrov", "author_id": 22750, "author_profile": "https://wordpress.stackexchange.com/users/22750", "pm_score": 2, "selected": false, "text": "<p>Try <a href=\"http://wordpress.org/extend/plugins/syntaxhighlighter/\" rel=\"nofollow\">SyntaxHighlighter...
2012/10/25
[ "https://wordpress.stackexchange.com/questions/70415", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3051/" ]
I have a blog that I write up entries for that sometimes has programming code as part of the text within my writing's. Normally I use the quote function to give it a bit of highlighting, but was wondering if there's a better way that anyone has come across in their travels. Something that could do this for example: ``...
Try [SyntaxHighlighter Evolved](http://wordpress.org/extend/plugins/syntaxhighlighter/). I believe it will work for your needs.
70,451
<p>I'm trying to grab all image id's that are associated with the [gallery] shortcode that are listed as exclude. For example: if my post has <code>[gallery exclude="1,2,3"]</code> I'd like to get a variable that would echo like this <code>echo $excludes;</code> result <code>1,2,3</code> thank you for any help you can ...
[ { "answer_id": 70454, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 1, "selected": false, "text": "<p>If you also need to display the content on the same page, what about using the <code>post_gallery</cod...
2012/10/25
[ "https://wordpress.stackexchange.com/questions/70451", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11087/" ]
I'm trying to grab all image id's that are associated with the [gallery] shortcode that are listed as exclude. For example: if my post has `[gallery exclude="1,2,3"]` I'd like to get a variable that would echo like this `echo $excludes;` result `1,2,3` thank you for any help you can offer.
It took me a while to find a solution that worked for me, but since all I was looking for was the delimited list of attachment id's associated with a certain attribute like `exclude` or `hide`, this worked for me: ``` # Grab the list of "hide" attribute $regex_pattern = get_shortcode_regex(); preg_match ('/'.$regex_pa...
70,458
<p>I am trying to find out if it is possible to pass certain parameters to next_post_link() and previous_post_link() to make it only show other custom posts that have the same custom taxonomy values choosen?</p> <p>In my case i have a custom post type named "houses" and two custom taxonomies called "num_floors" and "c...
[ { "answer_id": 70454, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 1, "selected": false, "text": "<p>If you also need to display the content on the same page, what about using the <code>post_gallery</cod...
2012/10/25
[ "https://wordpress.stackexchange.com/questions/70458", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22907/" ]
I am trying to find out if it is possible to pass certain parameters to next\_post\_link() and previous\_post\_link() to make it only show other custom posts that have the same custom taxonomy values choosen? In my case i have a custom post type named "houses" and two custom taxonomies called "num\_floors" and "collec...
It took me a while to find a solution that worked for me, but since all I was looking for was the delimited list of attachment id's associated with a certain attribute like `exclude` or `hide`, this worked for me: ``` # Grab the list of "hide" attribute $regex_pattern = get_shortcode_regex(); preg_match ('/'.$regex_pa...
70,509
<p>I have a custom application with thousands of users who already have a password stored. I would like to set up a self hosted wordpress site to accompany that application and to use the usernames and encrypted passwords that already exist in that database.</p> <p>Is there a way to configure Wordpress to not use the...
[ { "answer_id": 70523, "author": "Roman", "author_id": 18658, "author_profile": "https://wordpress.stackexchange.com/users/18658", "pm_score": 3, "selected": false, "text": "<p>Actually you can bypass login mechanism of wordpress by login user automatically (after they succesfuly passed w...
2012/10/25
[ "https://wordpress.stackexchange.com/questions/70509", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22916/" ]
I have a custom application with thousands of users who already have a password stored. I would like to set up a self hosted wordpress site to accompany that application and to use the usernames and encrypted passwords that already exist in that database. Is there a way to configure Wordpress to not use the normal lis...
Investigating the filter `authenticate`, we can find that it is called [inside](http://core.trac.wordpress.org/browser/tags/3.4.2/wp-includes/pluggable.php#L460) the function [`wp_authenticate`](http://codex.wordpress.org/Function_Reference/wp_authenticate), which is a [pluggable function](http://codex.wordpress.org/Pl...
70,519
<p>I have two wordpress installations with same host with different folders. Each installation uses its own database. I mean, database are separated. I am not using one database for two wordpress installations. </p> <p>My Problem: I have two different member databases. Because my wordpress installation databases are n...
[ { "answer_id": 70522, "author": "Scott Hack", "author_id": 22604, "author_profile": "https://wordpress.stackexchange.com/users/22604", "pm_score": 0, "selected": false, "text": "<p>Since they are on the same server, I think you can probably do this. However, my PHP is not that great, so...
2012/10/25
[ "https://wordpress.stackexchange.com/questions/70519", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22917/" ]
I have two wordpress installations with same host with different folders. Each installation uses its own database. I mean, database are separated. I am not using one database for two wordpress installations. My Problem: I have two different member databases. Because my wordpress installation databases are not shared....
I had to do something similar. What you need to do first is in each of your config files define the table prefix ... make sure that they are different. Example: WordPress installation 1: `wp123_` WordPress installation 2: `wp124_` Your first installation would be your main installation the one with the user table you...
70,549
<p>I am trying to make a so called featured category on my theme homepage. In that category I would like to display 6 posts from same category. The problem is that, I would like to devide these posts into three different html blocks. For example:</p> <pre><code>&lt;div&gt;first 2 posts goes here&lt;/div&gt; &lt;div&gt...
[ { "answer_id": 70552, "author": "xsonic", "author_id": 18247, "author_profile": "https://wordpress.stackexchange.com/users/18247", "pm_score": 1, "selected": false, "text": "<p><strike>Just add a counter to the loop.</strike></p>\n\n<p>Just use <code>$wp_query-&gt;current_post</code></p>...
2012/10/26
[ "https://wordpress.stackexchange.com/questions/70549", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20159/" ]
I am trying to make a so called featured category on my theme homepage. In that category I would like to display 6 posts from same category. The problem is that, I would like to devide these posts into three different html blocks. For example: ``` <div>first 2 posts goes here</div> <div>second 2 posts goes here</div> ...
Just add a counter to the loop. Just use `$wp_query->current_post` ``` while ( have_posts() ) : the_post(); if($wp_query->current_post <= 1) // 1 because counter starts at 0 // <div>first 2 posts go here</div> if($wp_query->current_post > 1 <= 3) // <div>second 2 posts go here</div> if($...
70,573
<p>I'm creating custom files in a plugin and adding them to the Media Library using the code provided in the Wordpress Codex for wp_insert_attachment. However, my plugin occasionally overwrites those files. I need to make sure that the files are not added again to the Media Library. Here is the current code:</p> <p...
[ { "answer_id": 70575, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 4, "selected": true, "text": "<pre><code>global $wpdb;\n$image_src = wp_upload_dir()['baseurl'] . '/' . _wp_relative_upload_path( $filen...
2012/10/26
[ "https://wordpress.stackexchange.com/questions/70573", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8901/" ]
I'm creating custom files in a plugin and adding them to the Media Library using the code provided in the Wordpress Codex for wp\_insert\_attachment. However, my plugin occasionally overwrites those files. I need to make sure that the files are not added again to the Media Library. Here is the current code: ``` $wp_fi...
``` global $wpdb; $image_src = wp_upload_dir()['baseurl'] . '/' . _wp_relative_upload_path( $filename ); $query = "SELECT COUNT(*) FROM {$wpdb->posts} WHERE guid='$image_src'"; $count = intval($wpdb->get_var($query)); ``` You can use this at the top of your code. Then check the value of `$count`. If it's 0, then you ...
70,606
<p>I added a new custom post type to my Wordpress theme but it refuses to show on the homepage. I tried setting </p> <pre><code>&lt;?php query_posts( array( 'post_type' =&gt; array('post', 'reviews') ) );?&gt; </code></pre> <p>but it doesn't seem to work, it just loops my normal posts. Any suggestions would be greatl...
[ { "answer_id": 70609, "author": "Manu", "author_id": 22963, "author_profile": "https://wordpress.stackexchange.com/users/22963", "pm_score": 0, "selected": false, "text": "<p>I would try this first:</p>\n\n<pre><code>global $wp_query;\n$args = array_merge( $wp_query-&gt;query, array( \n ...
2012/10/26
[ "https://wordpress.stackexchange.com/questions/70606", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22961/" ]
I added a new custom post type to my Wordpress theme but it refuses to show on the homepage. I tried setting ``` <?php query_posts( array( 'post_type' => array('post', 'reviews') ) );?> ``` but it doesn't seem to work, it just loops my normal posts. Any suggestions would be greatly helpful. Here's a pastie of my i...
I would avoid the use of query\_posts -- it forces another database hit. There are plenty of other ways to hook in and change the query before posts are fetches. `pre_get_posts` is one of them. To display multiple post types on the home page (pages and posts in this example): ``` <?php add_action('pre_get_posts', 'wp...
70,627
<p>I'm running the latest version of WordPress with pretty permalinks enabled.</p> <p>I'm looking for a way to include the Post Format type (eg: link, status, quote) in the post's permalink. When the post has no format assigned, or uses the 'standard' format, I want that part of the permalink to empty.</p> <p>Example...
[ { "answer_id": 71219, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": -1, "selected": false, "text": "<p>You can add a custom slug to the permalinks via plugin and use this inside your custom permalinks; dont forgett t...
2012/10/27
[ "https://wordpress.stackexchange.com/questions/70627", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19726/" ]
I'm running the latest version of WordPress with pretty permalinks enabled. I'm looking for a way to include the Post Format type (eg: link, status, quote) in the post's permalink. When the post has no format assigned, or uses the 'standard' format, I want that part of the permalink to empty. Example using the link p...
While researching this topic myself, I found a plugin called [Post Format Permalink](http://wordpress.org/extend/plugins/post-format-permalink/). However, this plugin is not compatible with recent versions of WordPress; it is also filled with unnecessary code. I [forked](https://github.com/bungeshea/post-format-permal...
70,634
<p>I am looking to create a behavior as shown in the following link:</p> <p><a href="http://www.javaexperience.com/java-role-of-serialversionuid-in-serialization/" rel="nofollow noreferrer">http://www.javaexperience.com/java-role-of-serialversionuid-in-serialization/</a></p> <p>Here all posts from the same category a...
[ { "answer_id": 70641, "author": "swtshweta", "author_id": 14123, "author_profile": "https://wordpress.stackexchange.com/users/14123", "pm_score": -1, "selected": false, "text": "<p>You can do this using Wp_query() by passing the category name as an argument:</p>\n\n<pre><code>&lt;?php $m...
2012/10/27
[ "https://wordpress.stackexchange.com/questions/70634", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13571/" ]
I am looking to create a behavior as shown in the following link: <http://www.javaexperience.com/java-role-of-serialversionuid-in-serialization/> Here all posts from the same category are being displayed. Currently, it is handwritten HTML code, I want to mimic this behavior using PHP code in my single.php. ![posts](...
Try this: ``` $cat = get_query_var('cat'); $PozCat = get_category ($cat); $PozCat->id // give to us current cat id. ``` Then use this hook in your query: ``` <ul> <?php $cat = get_query_var('cat'); $PozCat = get_category ($cat); //$PozCat->id query_posts('posts_per_page=-1&cat='.$PozCat->id); ...
70,651
<p>I have a custom loop to show posts that meet a certain set of $args like this:</p> <pre><code>&lt;?php $recent = new WP_Query( $orderargs ); while($recent-&gt;have_posts()) : $recent-&gt;the_post();?&gt; </code></pre> <p>This works great when the $orderargs bring up posts, but in some situations, ther...
[ { "answer_id": 70641, "author": "swtshweta", "author_id": 14123, "author_profile": "https://wordpress.stackexchange.com/users/14123", "pm_score": -1, "selected": false, "text": "<p>You can do this using Wp_query() by passing the category name as an argument:</p>\n\n<pre><code>&lt;?php $m...
2012/10/27
[ "https://wordpress.stackexchange.com/questions/70651", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22974/" ]
I have a custom loop to show posts that meet a certain set of $args like this: ``` <?php $recent = new WP_Query( $orderargs ); while($recent->have_posts()) : $recent->the_post();?> ``` This works great when the $orderargs bring up posts, but in some situations, there will be no posts, and I want to show...
Try this: ``` $cat = get_query_var('cat'); $PozCat = get_category ($cat); $PozCat->id // give to us current cat id. ``` Then use this hook in your query: ``` <ul> <?php $cat = get_query_var('cat'); $PozCat = get_category ($cat); //$PozCat->id query_posts('posts_per_page=-1&cat='.$PozCat->id); ...
70,671
<p>I'm helping with a custom multi language site. We have one page in English, then an equivalent page in French. I've got a "SWITCH LANGUAGE" link in the main container (next to the breadcrumbs) that takes you to the English home page if on any French page, and vice versa.</p> <p>Aside from using a plugin, how can I ...
[ { "answer_id": 70663, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": true, "text": "<p>This is not a WordPress error, it is <a href=\"http://dev.mysql.com/doc/refman/5.0/en/gone-away.html\" rel=\"nofollow\"...
2012/10/27
[ "https://wordpress.stackexchange.com/questions/70671", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10663/" ]
I'm helping with a custom multi language site. We have one page in English, then an equivalent page in French. I've got a "SWITCH LANGUAGE" link in the main container (next to the breadcrumbs) that takes you to the English home page if on any French page, and vice versa. Aside from using a plugin, how can I make this ...
This is not a WordPress error, it is [from MySQL](http://dev.mysql.com/doc/refman/5.0/en/gone-away.html): > > The most common reason for the MySQL server has gone away error is that the server timed out and closed the connection. > > > Talk with your host again.
70,676
<p>Right now for my plugin, I am using <code>in_admin()</code> to determine if the user is in the frontend of the site or in the admin area. However, the problem occurs when plugins use <code>admin-ajax.php</code> to process ajax requests. </p> <p>I need a way to register hooks and plugins only when processing <code>a...
[ { "answer_id": 70677, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 7, "selected": true, "text": "<p>Check the constant <code>DOING_AJAX</code>. Its definition is the first working code in <code>wp-admin/admin-ajax.php</...
2012/10/27
[ "https://wordpress.stackexchange.com/questions/70676", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/945/" ]
Right now for my plugin, I am using `in_admin()` to determine if the user is in the frontend of the site or in the admin area. However, the problem occurs when plugins use `admin-ajax.php` to process ajax requests. I need a way to register hooks and plugins only when processing `admin-ajax.php` file or in the fronten...
Check the constant `DOING_AJAX`. Its definition is the first working code in `wp-admin/admin-ajax.php`. Some very weird plugins, like Jetpack, are [defining that constant in unexpected places](https://github.com/Automattic/jetpack/blob/95d0f7a6210c4c570b6f8bb0fb8bf81256f47cea/modules/infinite-scroll/infinity.php#L674),...
70,696
<p>@Milo Problem solved, found spaces in the array $arrname.</p> <p>I was trying to get post id using post_name. First of all I stored all post_name in an array an then loop through the array to use the key variable in a wpdb query to get post id, really strange though, it only returns the first post id. </p> <p>As y...
[ { "answer_id": 70736, "author": "krembo99", "author_id": 13256, "author_profile": "https://wordpress.stackexchange.com/users/13256", "pm_score": 0, "selected": false, "text": "<p>I believe your problem is data validation -\nYou should always use <a href=\"http://codex.wordpress.org/Data_...
2012/10/27
[ "https://wordpress.stackexchange.com/questions/70696", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22991/" ]
@Milo Problem solved, found spaces in the array $arrname. I was trying to get post id using post\_name. First of all I stored all post\_name in an array an then loop through the array to use the key variable in a wpdb query to get post id, really strange though, it only returns the first post id. As you can see I tr...
OP found the solution: > > Problem solved, found spaces in the array $arrname. > > > I'm posting as a brief answer to tidy up our site. If anyone would like to up vote it to get the question closed then that would be great :-) Alternatively, express your view on the quality of question.
70,698
<p>I have an old website that I'm revamping with a custom new Wordpress theme. The old site had a custom (non-WP based) downloads archive that mapped URLs like this:</p> <p><code>/downloads/view.php?id=2</code></p> <p>The ID maps to a download item in a separate MySQL database.</p> <p>I'd like to move everything ove...
[ { "answer_id": 70712, "author": "shea", "author_id": 19726, "author_profile": "https://wordpress.stackexchange.com/users/19726", "pm_score": 0, "selected": false, "text": "<p>To redirect <code>/downloads/view.php?id={some-name}</code> to <code>/downloads/{some-name}/</code>, add the foll...
2012/10/27
[ "https://wordpress.stackexchange.com/questions/70698", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6167/" ]
I have an old website that I'm revamping with a custom new Wordpress theme. The old site had a custom (non-WP based) downloads archive that mapped URLs like this: `/downloads/view.php?id=2` The ID maps to a download item in a separate MySQL database. I'd like to move everything over to Wordpress in this refresh and ...
I ended up solving the issue by hooking onto the "`template_redirect`" action. After that, I check if the page `is_404()` and then check if the URL matches my pattern. I set the appropriate header (`301` versus the `404` that normally would be triggered) and perform my redirect. My code is below. ``` add_action('templ...
70,701
<p>Personal blog with occasional guest authors (non-commercial) self hosted Wordpress. I create a bespoke author PHP file for each author (<a href="http://www.phoneographer.org/author/michelle-robinson/" rel="nofollow">example</a>).<br> I use Yoast SEO and set a default image for meta property='og:image' where one isn'...
[ { "answer_id": 70702, "author": "AndrettiMilas", "author_id": 5205, "author_profile": "https://wordpress.stackexchange.com/users/5205", "pm_score": 0, "selected": false, "text": "<p>If I understand correctly, you want to change the default image for each author on a WP install? Try this...
2012/10/27
[ "https://wordpress.stackexchange.com/questions/70701", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22993/" ]
Personal blog with occasional guest authors (non-commercial) self hosted Wordpress. I create a bespoke author PHP file for each author ([example](http://www.phoneographer.org/author/michelle-robinson/)). I use Yoast SEO and set a default image for meta property='og:image' where one isn't specified for a post or page...
Try copying the following code into your functions.php file. It adds a custom og:image property for the authors with nicenames of `michelle-robinson`, `mystery-man`, `john-smith`, and a default fallback image, respectively. You can easily change this to suit your needs. ``` add_action( 'wp_head', 'wpse_70701_author_...
70,721
<p>Is there a way to remove the post title? or atleast not require me to enter a post title. I have migrated from tumblr to wordpress and I didn't need to have a title with tumblr so I was wondering if I could do the same with wordpress?</p>
[ { "answer_id": 70723, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 0, "selected": false, "text": "<p>You could my plugin <a href=\"https://gist.github.com/1332713\" rel=\"nofollow\">Fix Empty Titles</a>. It creates a po...
2012/10/28
[ "https://wordpress.stackexchange.com/questions/70721", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17971/" ]
Is there a way to remove the post title? or atleast not require me to enter a post title. I have migrated from tumblr to wordpress and I didn't need to have a title with tumblr so I was wondering if I could do the same with wordpress?
Wordpress does not require entering post titles, at least not in the backend. You can leave that part of the form blank. As far as your theme is concerned, that will depend on the theme author and whether they've considered someone not entering a title. The default twentyeleven theme handles it fine, linking to the p...
70,732
<p>I need to know if it is safe to use <code>user_activation_key</code> (from <code>WP_User</code>) for other purpose like email verification (a functionality that I would be creating that would send an email verification first before activating the account created)?</p> <p>So here's how things will work. A user will ...
[ { "answer_id": 70733, "author": "Ajay Kumar Maheshwari", "author_id": 23003, "author_profile": "https://wordpress.stackexchange.com/users/23003", "pm_score": 1, "selected": false, "text": "<p>No it is not safe, because anyone use this. but if you can you give your email id then it is ref...
2012/10/28
[ "https://wordpress.stackexchange.com/questions/70732", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23002/" ]
I need to know if it is safe to use `user_activation_key` (from `WP_User`) for other purpose like email verification (a functionality that I would be creating that would send an email verification first before activating the account created)? So here's how things will work. A user will register using my custom registr...
> > Do you think this will be safe? > > > Maybe. Two issues. You also need to make sure the key isn't guessable. No incrementing numbers. You can use something like [`wp_generate_password`](http://codex.wordpress.org/Function_Reference/wp_generate_password) to get some psuedo random characters. Use a random "salt...
70,734
<p>How do I revise a theme so that I can publish my event hooks and anyone can build a plugin to add new functionality easily to my theme?</p>
[ { "answer_id": 70735, "author": "Volomike", "author_id": 13, "author_profile": "https://wordpress.stackexchange.com/users/13", "pm_score": -1, "selected": false, "text": "<p>1) Separate every theme file so that you have PHP at the top, and HTML at the bottom. Then, in the HTML portion, i...
2012/10/28
[ "https://wordpress.stackexchange.com/questions/70734", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13/" ]
How do I revise a theme so that I can publish my event hooks and anyone can build a plugin to add new functionality easily to my theme?
After working on several projects so big I didn’t even know all the people involved, I came to one conclusion: **Keep it simple, write great documentation.** Code is simple if it is easy to read, to learn and to extend. Do not reinvent the wheel: Use the given hooks wherever possible, add new ones in a predictable ...
70,740
<p>I started using this functions for my "search results"-page.</p> <pre><code>#SearchRewrite add_action('generate_rewrite_rules', 'my_rewrite_rules'); function my_rewrite_rules( $wp_rewrite ) { //RewriteRule ^icerik/(.+)?$ /index.php?s=$1 [QSA,L] $new_rules = array( 'icerik/(.+).html' =&gt; 'index.php?s='...
[ { "answer_id": 70746, "author": "Abdussamad", "author_id": 12839, "author_profile": "https://wordpress.stackexchange.com/users/12839", "pm_score": 1, "selected": false, "text": "<p>wp_rewrite doesn't redirect. It simply parses requested URLs into query strings that wordpress understands....
2012/10/28
[ "https://wordpress.stackexchange.com/questions/70740", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7394/" ]
I started using this functions for my "search results"-page. ``` #SearchRewrite add_action('generate_rewrite_rules', 'my_rewrite_rules'); function my_rewrite_rules( $wp_rewrite ) { //RewriteRule ^icerik/(.+)?$ /index.php?s=$1 [QSA,L] $new_rules = array( 'icerik/(.+).html' => 'index.php?s=' . $wp_rewrit...
Fatih, Use str\_replace for Turkish chars issue. Change code like this; ``` /* Plugin Name: Redirect Search Results Author: Abdussamad Plugin URI: http://wordpress.stackexchange.com/questions/70740/search-url-wp-rewrite-after-redirect */ class redirect_search_results { function __construct() { add_action( 'init'...
70,752
<p>For Wordpress, I want to auto generate thumb of the video embedded on a page using oembed? And then save it as a featured image of the post.</p> <p>Any idea how to do this?</p>
[ { "answer_id": 71086, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 2, "selected": false, "text": "<p>Interesting Question, but quoting Mike Schinkel answering a <a href=\"https://wordpress.stackexchange.com/q/...
2012/10/28
[ "https://wordpress.stackexchange.com/questions/70752", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22618/" ]
For Wordpress, I want to auto generate thumb of the video embedded on a page using oembed? And then save it as a featured image of the post. Any idea how to do this?
I needed *just this* for a recent project, so here's my plugin! The code should be self-explanatory, but if there are any questions ask away. ``` <?php /** * Plugin Name: oEmbed Featured Image * Plugin URI: http://wordpress.stackexchange.com/q/70752/1685 * Description: Automatically set the featured image if an oE...
70,758
<p><strong>UPDATE: For anyone following this thread, the plugin solution does work, but seems to have a problem on my multisite format. I have now tested on 3 individual installs and on 3 multisites. On the multisites, the red "undeletable" marker appears next to the categories in the array, but they can get deleted. T...
[ { "answer_id": 72390, "author": "Roman", "author_id": 18658, "author_profile": "https://wordpress.stackexchange.com/users/18658", "pm_score": 1, "selected": false, "text": "<p>Maybee you can hook to wp_delete_term function with action \"delete_term\" (see info at: <a href=\"http://adambr...
2012/10/28
[ "https://wordpress.stackexchange.com/questions/70758", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22537/" ]
**UPDATE: For anyone following this thread, the plugin solution does work, but seems to have a problem on my multisite format. I have now tested on 3 individual installs and on 3 multisites. On the multisites, the red "undeletable" marker appears next to the categories in the array, but they can get deleted. This may w...
Extending @Roman's answer. --- ***The following was developed and tested in a Multisite environment - local and live WP installs.*** --- Looking at the [source](http://core.trac.wordpress.org/browser/tags/3.4.2/wp-includes/taxonomy.php#L1718) of [`wp_delete_term`](http://codex.wordpress.org/Function_Reference/wp_de...
70,792
<p>What I'd like to do: on index.php, a loop that shows a selectable number of full posts using <code>the_content</code> and then below that shows a selectable number (the number of posts can be hardcoded in the function) of excerpts (using <code>the_excerpt</code>) in a grid pattern 2 excerpts wide. Any <code>paged</c...
[ { "answer_id": 70818, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 2, "selected": false, "text": "<h2>The <code>$wp_query</code> properties allow <em>\"alot\"</em></h2>\n\n<p>Actually it's not that hard if you use pa...
2012/10/29
[ "https://wordpress.stackexchange.com/questions/70792", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/268/" ]
What I'd like to do: on index.php, a loop that shows a selectable number of full posts using `the_content` and then below that shows a selectable number (the number of posts can be hardcoded in the function) of excerpts (using `the_excerpt`) in a grid pattern 2 excerpts wide. Any `paged` page of posts only uses the gri...
The `$wp_query` properties allow *"alot"* ----------------------------------------- Actually it's not that hard if you use parts of the `$wp_query` object like `current_post`. Here you can see some examples that make some tricky use of things like `is_paged()`, `$wp_query->current_post` and `$wp_query->posts_per_page...
70,797
<p>I created the WordPress editor using <a href="http://codex.wordpress.org/Function_Reference/wp_editor" rel="nofollow">wp_editor</a> function dynamically. While i click add more button i just cloned editor and append new editor using jquery. While i am cloning editor i just changing id distribution_<em>0 to distribut...
[ { "answer_id": 70799, "author": "Mridul Aggarwal", "author_id": 22495, "author_profile": "https://wordpress.stackexchange.com/users/22495", "pm_score": 0, "selected": false, "text": "<p>I'm not sure about it but codex said \"Once instantiated, the WYSIWYG editor cannot be moved around in...
2012/10/29
[ "https://wordpress.stackexchange.com/questions/70797", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4022/" ]
I created the WordPress editor using [wp\_editor](http://codex.wordpress.org/Function_Reference/wp_editor) function dynamically. While i click add more button i just cloned editor and append new editor using jquery. While i am cloning editor i just changing id distribution\_*0 to distribution*\_1 etc. Editor Properly c...
The problem is that the `wp_editor()` automatic load the scripts and this is not possible dynamic. You must enhance your plugin, code and add the scripts also dynamic or via ajax. WP include the scripts and styles via `wp_enqueue_script()` and this is not usable in a dynamic change of DOM, it was registered for better ...
70,807
<p>Recently I've been developing sites for WordPress that are both increasingly complex but also have much higher rates of traffic. I remember when I was learning the ropes from another about PHP, that in cases of optimisation, "cases" are a better option than "IFs", as they put less load on the server.</p> <p>I've su...
[ { "answer_id": 70811, "author": "vstm", "author_id": 22540, "author_profile": "https://wordpress.stackexchange.com/users/22540", "pm_score": 1, "selected": false, "text": "<p>Instead of writing the code for every case, why not just extract the post type specific information like the cate...
2012/10/29
[ "https://wordpress.stackexchange.com/questions/70807", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17780/" ]
Recently I've been developing sites for WordPress that are both increasingly complex but also have much higher rates of traffic. I remember when I was learning the ropes from another about PHP, that in cases of optimisation, "cases" are a better option than "IFs", as they put less load on the server. I've successfully...
If you're using it on single templates, the easiest & most efficient way would be to switch based on the value of `get_post_type()`. ``` switch(get_post_type()) { case 'news' : // some statement for news type break; case 'sports' : // some statement for sports type break; default: ...
70,812
<p>I am writing a query to retrieve instances of a custom post type I created called "Specialist". In the query I specify a name and more than one taxonomy.<br> I want to retrieve just those <code>specialist</code> which respect <strong>both</strong> parameters.<br> If I run the two queries separately, the correct spec...
[ { "answer_id": 70811, "author": "vstm", "author_id": 22540, "author_profile": "https://wordpress.stackexchange.com/users/22540", "pm_score": 1, "selected": false, "text": "<p>Instead of writing the code for every case, why not just extract the post type specific information like the cate...
2012/10/29
[ "https://wordpress.stackexchange.com/questions/70812", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23033/" ]
I am writing a query to retrieve instances of a custom post type I created called "Specialist". In the query I specify a name and more than one taxonomy. I want to retrieve just those `specialist` which respect **both** parameters. If I run the two queries separately, the correct specialists are returned but when...
If you're using it on single templates, the easiest & most efficient way would be to switch based on the value of `get_post_type()`. ``` switch(get_post_type()) { case 'news' : // some statement for news type break; case 'sports' : // some statement for sports type break; default: ...
70,813
<p>Is there any mean to exclude a <code>*.php</code> file to <a href="http://wordpress.org/extend/plugins/wp-super-cache/" rel="nofollow">WP Super Cache</a>?<br> I've in my <code>single.php</code> page an <code>include news.php</code>, the file <code>news.php</code> contains ten links to my last articles.</p> <p>So I ...
[ { "answer_id": 70816, "author": "shea", "author_id": 19726, "author_profile": "https://wordpress.stackexchange.com/users/19726", "pm_score": 1, "selected": false, "text": "<p>Follow the steps below to prevent caching of the <code>news.php</code> file:</p>\n\n<ol>\n<li><p>Visit the WP Sup...
2012/10/29
[ "https://wordpress.stackexchange.com/questions/70813", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23032/" ]
Is there any mean to exclude a `*.php` file to [WP Super Cache](http://wordpress.org/extend/plugins/wp-super-cache/)? I've in my `single.php` page an `include news.php`, the file `news.php` contains ten links to my last articles. So I want to cache `single.php` but to exclude `news.php` that is included in `single....
Rather than incorporating [dynamic content into cached pages](http://ocaoimh.ie/2013/10/21/shiny-new-dynamic-content-wp-super-cache/), you are better off using AJAX to pull dynamic content onto those pages in the browser. In your `news.php` file, simply have an empty element that will contain the content. Better still...
70,824
<p>I have a custom made Twitter stream on my site.</p> <p>I want to have a permalink for each tweet which would go to a page which would display only the tweet - no other content - surrounded by my custom theme.</p> <p>Ideally I would get Wordpress to display a Page Template on a certain url (something like /tweet/&l...
[ { "answer_id": 70816, "author": "shea", "author_id": 19726, "author_profile": "https://wordpress.stackexchange.com/users/19726", "pm_score": 1, "selected": false, "text": "<p>Follow the steps below to prevent caching of the <code>news.php</code> file:</p>\n\n<ol>\n<li><p>Visit the WP Sup...
2012/10/29
[ "https://wordpress.stackexchange.com/questions/70824", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23035/" ]
I have a custom made Twitter stream on my site. I want to have a permalink for each tweet which would go to a page which would display only the tweet - no other content - surrounded by my custom theme. Ideally I would get Wordpress to display a Page Template on a certain url (something like /tweet/<tweet\_id>), but I...
Rather than incorporating [dynamic content into cached pages](http://ocaoimh.ie/2013/10/21/shiny-new-dynamic-content-wp-super-cache/), you are better off using AJAX to pull dynamic content onto those pages in the browser. In your `news.php` file, simply have an empty element that will contain the content. Better still...
70,833
<p>I'd like to create a button for admins to be able to delete from table wp_usermeta -> key: 'ref_credit' for all users.</p> <p>Is there simple resource friendly way to do this? does wp have built in function for this?</p> <p>I found this: <a href="http://codex.wordpress.org/Function_Reference/delete_user_meta" rel=...
[ { "answer_id": 70839, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 3, "selected": false, "text": "<p>A simple example would be to get all users for a specific role, iterate over the returned results and apply the <...
2012/10/29
[ "https://wordpress.stackexchange.com/questions/70833", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I'd like to create a button for admins to be able to delete from table wp\_usermeta -> key: 'ref\_credit' for all users. Is there simple resource friendly way to do this? does wp have built in function for this? I found this: <http://codex.wordpress.org/Function_Reference/delete_user_meta> But this is only for singl...
A simple example would be to get all users for a specific role, iterate over the returned results and apply the `delete_user_meta` function for the given `meta_key`. Stir and let simmer for a fraction of a second and all user meta for that key shall be gone. ``` function say_goodby_to_the_meta(){ $role = 'subscr...
70,840
<p>I'm trying to add a feature to my loop.php to use with a custom post type. However, I don't want it displayed on all posts, just the ones that are the custom post type (let's say its called "review").</p> <p>Is there a way to say if post type = review then show this new section, otherwise hide?</p> <p>I tried usin...
[ { "answer_id": 70841, "author": "Halaster", "author_id": 23027, "author_profile": "https://wordpress.stackexchange.com/users/23027", "pm_score": 0, "selected": false, "text": "<p>try <a href=\"http://codex.wordpress.org/Function_Reference/get_post_type\" rel=\"nofollow\">http://codex.wor...
2012/10/29
[ "https://wordpress.stackexchange.com/questions/70840", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22961/" ]
I'm trying to add a feature to my loop.php to use with a custom post type. However, I don't want it displayed on all posts, just the ones that are the custom post type (let's say its called "review"). Is there a way to say if post type = review then show this new section, otherwise hide? I tried using ``` <?php if(...
Try the following: ``` if ( have_posts() ) { while( have_posts() ) { the_post(); if ( 'reviews' === get_post_type( get_the_ID() ) { echo 'I am a post of the post type &rdquo;reviews&ldquo;'; // We're done here, continue to next post continue; ...
70,844
<p>I'm looking for an solution how I can count and display all queries in a WordPress site. Does anybody know, if there is an good plugin?</p> <p>Otherwise it would be an solution to check the queries on the console, because I'm working a lot with the console.</p>
[ { "answer_id": 70847, "author": "Michael Ecklund", "author_id": 9579, "author_profile": "https://wordpress.stackexchange.com/users/9579", "pm_score": 4, "selected": true, "text": "<p>You can paste this block of code in your currently active WordPress theme <code>functions.php</code> file...
2012/10/29
[ "https://wordpress.stackexchange.com/questions/70844", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22456/" ]
I'm looking for an solution how I can count and display all queries in a WordPress site. Does anybody know, if there is an good plugin? Otherwise it would be an solution to check the queries on the console, because I'm working a lot with the console.
You can paste this block of code in your currently active WordPress theme `functions.php` file: ``` function wpse_footer_db_queries(){ echo '<!-- '.get_num_queries().' queries in '.timer_stop(0).' seconds. -->'.PHP_EOL; } add_action('wp_footer', 'wpse_footer_db_queries'); ``` The above block of code, will render...
70,864
<p>I noticed that there are bunch of operator can be use for compare in meta_query. However, I am not quite sure what operator I should use, it is somehow confusing like <code>=</code> and <code>LIKE</code> operator. </p> <p>I would like to know what exactly each operator mean, and in what condition I should use them...
[ { "answer_id": 70870, "author": "Jen", "author_id": 13810, "author_profile": "https://wordpress.stackexchange.com/users/13810", "pm_score": 8, "selected": true, "text": "<p>The first several work as you would expect:</p>\n\n<pre><code>= equals\n!= does not equal\n&gt; greater than\n...
2012/10/29
[ "https://wordpress.stackexchange.com/questions/70864", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14728/" ]
I noticed that there are bunch of operator can be use for compare in meta\_query. However, I am not quite sure what operator I should use, it is somehow confusing like `=` and `LIKE` operator. I would like to know what exactly each operator mean, and in what condition I should use them. ``` = != > >= < <= LIKE NOT...
The first several work as you would expect: ``` = equals != does not equal > greater than >= greater than or equal to < less than <= less than or equal to ``` --- **LIKE** and **NOT LIKE** `LIKE` and `NOT LIKE` are SQL operators that let you add in wild-card symbols, so you could have a meta query that l...
70,865
<p>We have a WordPress-based website that provides documentation to our REST API. Since our API is constantly changing, so is the documentation. However, we would like to keep the documentation version controlled so it can be matched against API commits. Is there a way to have WordPress pages get their content from a r...
[ { "answer_id": 70866, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 3, "selected": false, "text": "<p>You already got something like this built in: <a href=\"http://codex.wordpress.org/Revision_Management\" rel=\"nofo...
2012/10/29
[ "https://wordpress.stackexchange.com/questions/70865", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23048/" ]
We have a WordPress-based website that provides documentation to our REST API. Since our API is constantly changing, so is the documentation. However, we would like to keep the documentation version controlled so it can be matched against API commits. Is there a way to have WordPress pages get their content from a remo...
You already got something like this built in: [Revisions](http://codex.wordpress.org/Revision_Management). ``` // Define the nr of saved revisions in your wp-config.php define( 'WP_POST_REVISIONS', 30 ); ``` You can simply grab them by calling `get_posts()` with a `post_type` of `revision`. To show the difference b...
70,874
<p>How to disable categories/most used in 'add new post'? I tried function: remove_meta_box(), but it doesn't work for me, i tried it in functions.php for my theme, it's mistake?</p>
[ { "answer_id": 70900, "author": "Gaia", "author_id": 5090, "author_profile": "https://wordpress.stackexchange.com/users/5090", "pm_score": 1, "selected": false, "text": "<p>In <em>Add New Post</em>, click on the <em>Screen Options</em> tab om the top right then uncheck <em>Categories</em...
2012/10/29
[ "https://wordpress.stackexchange.com/questions/70874", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18000/" ]
How to disable categories/most used in 'add new post'? I tried function: remove\_meta\_box(), but it doesn't work for me, i tried it in functions.php for my theme, it's mistake?
`remove_meta_box` removes the whole Categories box. The `Most used` tab don't have any hook. **Don't modify WordPress core files**, there's always a way to modify WP behavior without touching the core. ``` /** * Place the script in the theme's functions.php file */ add_action( 'admin_head-post-new.php', 'wpse_708...
70,875
<p>I'm trying to query the wordpress database for the post and what category they belong in. Is there a sql query that I can use for this?</p> <p>Thanks,</p>
[ { "answer_id": 70900, "author": "Gaia", "author_id": 5090, "author_profile": "https://wordpress.stackexchange.com/users/5090", "pm_score": 1, "selected": false, "text": "<p>In <em>Add New Post</em>, click on the <em>Screen Options</em> tab om the top right then uncheck <em>Categories</em...
2012/10/29
[ "https://wordpress.stackexchange.com/questions/70875", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13952/" ]
I'm trying to query the wordpress database for the post and what category they belong in. Is there a sql query that I can use for this? Thanks,
`remove_meta_box` removes the whole Categories box. The `Most used` tab don't have any hook. **Don't modify WordPress core files**, there's always a way to modify WP behavior without touching the core. ``` /** * Place the script in the theme's functions.php file */ add_action( 'admin_head-post-new.php', 'wpse_708...
70,879
<p>I have multi-author website and I am not very comfortable for allowing all members to enter SEO details in the posts they are publishing. I would like this would be visible only to Administrator of the website. Any ideas?</p>
[ { "answer_id": 70888, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 4, "selected": false, "text": "<p>It didn't say in the API docs on the Yoast SEO plugin site what the <code>ID</code> was and I don't have a copy o...
2012/10/29
[ "https://wordpress.stackexchange.com/questions/70879", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23052/" ]
I have multi-author website and I am not very comfortable for allowing all members to enter SEO details in the posts they are publishing. I would like this would be visible only to Administrator of the website. Any ideas?
It didn't say in the API docs on the Yoast SEO plugin site what the `ID` was and I don't have a copy of Yoast at installed at disposal, but according to `yoas-plugin-dir/admin/class-metabox.php` line 144, the meta\_box registered is; ``` add_meta_box( 'wpseo_meta', ...etc ); ... ``` Which is hooked onto `add_meta_bo...
70,887
<p>I have following query to select posts by my custom post-type. This works fine while being on the frontpage (the snippet is included in the sidebar). As soon it gets executed on a category page the <code>post_type</code> attribute is ignored and posts of the type "post" are returned. I guess this has to do with mult...
[ { "answer_id": 70953, "author": "Janine", "author_id": 23075, "author_profile": "https://wordpress.stackexchange.com/users/23075", "pm_score": 1, "selected": false, "text": "<p>Have you tried using get_posts() instead?</p>\n\n<pre><code> //#get access to post settings\n global $post;\...
2012/10/29
[ "https://wordpress.stackexchange.com/questions/70887", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22546/" ]
I have following query to select posts by my custom post-type. This works fine while being on the frontpage (the snippet is included in the sidebar). As soon it gets executed on a category page the `post_type` attribute is ignored and posts of the type "post" are returned. I guess this has to do with multiple loops but...
Have you tried using get\_posts() instead? ``` //#get access to post settings global $post; //#set parameters for extra loop $args = array( 'post_type' => 'mycustomtype', 'posts_per_page' => 12, 'orderby' => 'date', 'order' => 'DESC', 'post_status' => 'publish' ); //#get po...
70,889
<p>Should be simple - I'd like WP to tweet the content of a post once (when it's published the first time) if the post format is 'status'.</p> <p>The code below isn't returning an error on publish, nor is it tweeting OR updating the post metadata, which leads me to believe I'm either using the hook incorrectly or ther...
[ { "answer_id": 70953, "author": "Janine", "author_id": 23075, "author_profile": "https://wordpress.stackexchange.com/users/23075", "pm_score": 1, "selected": false, "text": "<p>Have you tried using get_posts() instead?</p>\n\n<pre><code> //#get access to post settings\n global $post;\...
2012/10/29
[ "https://wordpress.stackexchange.com/questions/70889", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13027/" ]
Should be simple - I'd like WP to tweet the content of a post once (when it's published the first time) if the post format is 'status'. The code below isn't returning an error on publish, nor is it tweeting OR updating the post metadata, which leads me to believe I'm either using the hook incorrectly or there's someth...
Have you tried using get\_posts() instead? ``` //#get access to post settings global $post; //#set parameters for extra loop $args = array( 'post_type' => 'mycustomtype', 'posts_per_page' => 12, 'orderby' => 'date', 'order' => 'DESC', 'post_status' => 'publish' ); //#get po...
70,905
<p>I am trying to create a metabox input field in a custom post type and it does not work even if I followed the instructions the best I could. I am not a PHP dev so I guess it could be just a small thing that is missing or it is wrong. </p> <p>By not working I mean, I does not show at all in the WP UI.</p> <p>Here i...
[ { "answer_id": 70980, "author": "truemedia", "author_id": 23054, "author_profile": "https://wordpress.stackexchange.com/users/23054", "pm_score": 0, "selected": false, "text": "<p>In the code, you are trying to pass <a href=\"https://stackoverflow.com/questions/2700433/pass-function-as-p...
2012/10/30
[ "https://wordpress.stackexchange.com/questions/70905", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5789/" ]
I am trying to create a metabox input field in a custom post type and it does not work even if I followed the instructions the best I could. I am not a PHP dev so I guess it could be just a small thing that is missing or it is wrong. By not working I mean, I does not show at all in the WP UI. Here is the code: ``` ...
The custom post type is being register as `name`, not `snippet` as is being called in `add_meta_boxes` action. This is because a PHP var is passed inside single quotes and it is not being interpreted. Change this: ``` register_post_type('$name', $args); ``` To: ``` register_post_type($name, $args); ``` This also...
70,912
<p>I want to call custom field in <code>single.php</code> template to complete a short code and thus show a menu.</p> <p>I places the below code but it is not working</p> <pre><code>&lt;?php echo do_shortcode("[custommenu menu=&lt;?php echo get_post_meta($post-&gt;ID, ‘tabmenu’, true); ?&gt;]?&gt;") </code></pre>
[ { "answer_id": 70915, "author": "dipali", "author_id": 20711, "author_profile": "https://wordpress.stackexchange.com/users/20711", "pm_score": 0, "selected": false, "text": "<p>Try using this code. Hope this will work.</p>\n\n<pre><code>$post_meta_value = get_post_meta($post-&gt;ID, 'tab...
2012/10/30
[ "https://wordpress.stackexchange.com/questions/70912", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23063/" ]
I want to call custom field in `single.php` template to complete a short code and thus show a menu. I places the below code but it is not working ``` <?php echo do_shortcode("[custommenu menu=<?php echo get_post_meta($post->ID, ‘tabmenu’, true); ?>]?>") ```
I believe you forgot to add quotes around the menu parameter. ``` <?php $post_meta_value = get_post_meta($post->ID, 'tabmenu', true); echo do_shortcode('[custommenu menu="'.$post_meta_value.'"]'); ?> ```
70,913
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://wordpress.stackexchange.com/questions/69436/excerpt-in-characters">excerpt in characters</a> </p> </blockquote> <p>I have a question after reading this post (<a href="https://wordpress.stackexchange.com/questions/16070/how-to-highlight-se...
[ { "answer_id": 70914, "author": "dipali", "author_id": 20711, "author_profile": "https://wordpress.stackexchange.com/users/20711", "pm_score": 5, "selected": true, "text": "<p>add these lines in function.php file </p>\n\n<pre><code>function custom_excerpt_length( $length ) {\n r...
2012/10/30
[ "https://wordpress.stackexchange.com/questions/70913", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23036/" ]
> > **Possible Duplicate:** > > [excerpt in characters](https://wordpress.stackexchange.com/questions/69436/excerpt-in-characters) > > > I have a question after reading this post ([How to highlight search terms without plugin](https://wordpress.stackexchange.com/questions/16070/how-to-highlight-search-terms-wi...
add these lines in function.php file ``` function custom_excerpt_length( $length ) { return 20; } add_filter( 'excerpt_length', 'custom_excerpt_length', 999 ); ```
70,916
<p>I'm developing a child-theme using <em>Wordpress 3.4.2</em> and the development version of the <em>Options Framework</em> by <em>David Price</em>. This is my first theme and I'm relatively new to this, so I've had a look into the <em>Wordpress Codex</em> and checked out registering items into the API. </p> <p>With...
[ { "answer_id": 70948, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 2, "selected": false, "text": "<p>Here's an example;</p>\n\n<p>First to figure out the order of the sub menu items based upon its array key you can...
2012/10/30
[ "https://wordpress.stackexchange.com/questions/70916", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16795/" ]
I'm developing a child-theme using *Wordpress 3.4.2* and the development version of the *Options Framework* by *David Price*. This is my first theme and I'm relatively new to this, so I've had a look into the *Wordpress Codex* and checked out registering items into the API. Without tampering with any external files o...
Here's an example; First to figure out the order of the sub menu items based upon its array key you can do a `var_dump` on the $submenu global variable which will output the following; (I'm using the Posts menu and sub menu as an example) ``` //shortened for brevity.... ["edit.php"]=> array(6) { [5]=> ...
70,931
<p>I have edited the comments form to remove a few fields and now the approved comments don't show up, just the form itself.</p> <p>What am I missing from this?</p> <pre><code>&lt;?php $comment_args = array( 'fields' =&gt; apply_filters( 'comment_form_default_fields', array( 'author' =&gt; '&l...
[ { "answer_id": 70948, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 2, "selected": false, "text": "<p>Here's an example;</p>\n\n<p>First to figure out the order of the sub menu items based upon its array key you can...
2012/10/30
[ "https://wordpress.stackexchange.com/questions/70931", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4630/" ]
I have edited the comments form to remove a few fields and now the approved comments don't show up, just the form itself. What am I missing from this? ``` <?php $comment_args = array( 'fields' => apply_filters( 'comment_form_default_fields', array( 'author' => '<p class="comment-form-author">'...
Here's an example; First to figure out the order of the sub menu items based upon its array key you can do a `var_dump` on the $submenu global variable which will output the following; (I'm using the Posts menu and sub menu as an example) ``` //shortened for brevity.... ["edit.php"]=> array(6) { [5]=> ...
70,935
<p>I have a situation where I need to provide a dropdown of pages in a widget, based on whether they are using a specific template. In other words, for all pages using template 'Foo', get the post ID. </p> <p>I have coded the rest of the widget, but I'm using an input field for entering a page ID (which can get messy ...
[ { "answer_id": 70937, "author": "Michal Mau", "author_id": 2110, "author_profile": "https://wordpress.stackexchange.com/users/2110", "pm_score": 4, "selected": true, "text": "<p>WP_Query goes only through posts by default. </p>\n\n<p>Try adding <code>page</code> as your post type: </p>\...
2012/10/30
[ "https://wordpress.stackexchange.com/questions/70935", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14454/" ]
I have a situation where I need to provide a dropdown of pages in a widget, based on whether they are using a specific template. In other words, for all pages using template 'Foo', get the post ID. I have coded the rest of the widget, but I'm using an input field for entering a page ID (which can get messy with non-t...
WP\_Query goes only through posts by default. Try adding `page` as your post type: ``` $the_query = new WP_Query(array( 'post_type' => 'page', /* overrides default 'post' */ 'meta_key' => '_wp_page_template', 'meta_value' => 'templates/_partner.php' )); ``` See: [WP\_Query - Type Parameters](http:...