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
30,309
<p>When logged in, the admin bar adds the following to my page <code>&lt;head&gt;</code> section:</p> <pre><code>&lt;style media="screen" type="text/css"&gt; html { margin-top: 28px !important; } * html body { margin-top: 28px !important; } &lt;/style&gt; </code></pre> <p>Now, I can remove this by disabling t...
[ { "answer_id": 30312, "author": "Maxim Krizhanovsky", "author_id": 8294, "author_profile": "https://wordpress.stackexchange.com/users/8294", "pm_score": 6, "selected": true, "text": "<pre><code>function hide_admin_bar_from_front_end(){\n if (is_blog_admin()) {\n return true;\n }\n ...
2011/10/05
[ "https://wordpress.stackexchange.com/questions/30309", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1447/" ]
When logged in, the admin bar adds the following to my page `<head>` section: ``` <style media="screen" type="text/css"> html { margin-top: 28px !important; } * html body { margin-top: 28px !important; } </style> ``` Now, I can remove this by disabling the admin bar ``` /* Disable the Admin Bar. */ add_filt...
``` function hide_admin_bar_from_front_end(){ if (is_blog_admin()) { return true; } return false; } add_filter( 'show_admin_bar', 'hide_admin_bar_from_front_end' ); ``` Edit: As @Walf suggested in the comments, this could be writen as: ``` add_filter('show_admin_bar', 'is_blog_admin'); ```
30,313
<p>Is there a function that allows me to change the filename of an attachment, based on the Attachment ID I have?</p> <p>Thanks! Dennis</p>
[ { "answer_id": 30708, "author": "Naoise Golden", "author_id": 5048, "author_profile": "https://wordpress.stackexchange.com/users/5048", "pm_score": 2, "selected": false, "text": "<p>I'd use PHP's <a href=\"http://php.net/manual/es/function.rename.php\" rel=\"nofollow\"><code>rename</code...
2011/10/05
[ "https://wordpress.stackexchange.com/questions/30313", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4284/" ]
Is there a function that allows me to change the filename of an attachment, based on the Attachment ID I have? Thanks! Dennis
This will allow you to rename an attachment as soon as its uploaded: ``` add_action('add_attachment', 'rename_attachment'); function rename_attachment($post_ID){ $file = get_attached_file($post_ID); $path = pathinfo($file); //dirname = File Path //basename = Filename.Extension //ext...
30,314
<p>When I create a new page and put <code>&lt;br class="clear"&gt;</code> into the HTML view it gets rendered as </p> <pre><code>&lt;p&gt; &lt;br class="clear"&gt; &lt;/p&gt; </code></pre> <p>This causes problems with the theme <code>http://www.gallyapp.com/tf_themes/?theme=Lotus</code> where the <code>&lt;br&gt;</...
[ { "answer_id": 30708, "author": "Naoise Golden", "author_id": 5048, "author_profile": "https://wordpress.stackexchange.com/users/5048", "pm_score": 2, "selected": false, "text": "<p>I'd use PHP's <a href=\"http://php.net/manual/es/function.rename.php\" rel=\"nofollow\"><code>rename</code...
2011/10/05
[ "https://wordpress.stackexchange.com/questions/30314", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8839/" ]
When I create a new page and put `<br class="clear">` into the HTML view it gets rendered as ``` <p> <br class="clear"> </p> ``` This causes problems with the theme `http://www.gallyapp.com/tf_themes/?theme=Lotus` where the `<br>` is not wrapped. How can remove the wrapping?
This will allow you to rename an attachment as soon as its uploaded: ``` add_action('add_attachment', 'rename_attachment'); function rename_attachment($post_ID){ $file = get_attached_file($post_ID); $path = pathinfo($file); //dirname = File Path //basename = Filename.Extension //ext...
30,318
<p>I'm following <a href="http://hv-designs.co.uk/2010/01/13/learn-how-to-add-a-jquery-fade-in-and-out-effect/" rel="nofollow">a tutorial</a>.</p> <p>I've included the hover.js with the following code:</p> <pre><code>$(function() { // OPACITY OF BUTTON SET TO 50% $(".imgopacity").css("opacity","0.5"); //...
[ { "answer_id": 30319, "author": "cillierscharl", "author_id": 9187, "author_profile": "https://wordpress.stackexchange.com/users/9187", "pm_score": 4, "selected": true, "text": "<p>Going through your source - <a href=\"http://bottlelesscoolerreview.bottleless.com/wp-includes/js/jquery/jq...
2011/10/05
[ "https://wordpress.stackexchange.com/questions/30318", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9011/" ]
I'm following [a tutorial](http://hv-designs.co.uk/2010/01/13/learn-how-to-add-a-jquery-fade-in-and-out-effect/). I've included the hover.js with the following code: ``` $(function() { // OPACITY OF BUTTON SET TO 50% $(".imgopacity").css("opacity","0.5"); // ON MOUSE OVER $(".imgopacity").hover(funct...
Going through your source - [jQuery Source](http://bottlelesscoolerreview.bottleless.com/wp-includes/js/jquery/jquery.js?ver=1.6.1) - it seeems that `noConflict()` is getting called right at the end. To fix your hover.js then would look something like this: ``` jQuery(function($) { //Allow the use of $ namespace i...
30,331
<p>I am working on a multi-user WordPress setup and have made it so a particular type of user can only see and interact with posts, images, pages etc that they have authored. The code to make this happen looks like this:</p> <pre><code>add_filter('pre_get_posts', 'current_author_posts'); function current_author_posts...
[ { "answer_id": 53791, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 4, "selected": true, "text": "<p>I got this almost working, but refinements are needed to fit the specifics of the question and to deal with A...
2011/10/05
[ "https://wordpress.stackexchange.com/questions/30331", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3310/" ]
I am working on a multi-user WordPress setup and have made it so a particular type of user can only see and interact with posts, images, pages etc that they have authored. The code to make this happen looks like this: ``` add_filter('pre_get_posts', 'current_author_posts'); function current_author_posts($query) { ...
I got this almost working, but refinements are needed to fit the specifics of the question and to deal with Attachments and Post-Types differently (see comments in code)... --- First, I think it's worth noting how I found the filter: `apply_filters( 'views_' . $screen->id, $views )` * inspect element ![subsubs...
30,332
<pre><code>Warning: Cannot modify header information - headers already sent by (output started at /home/ezekiel/public_html/boxsponsive/wp- content/themes/BoxSponsive-Portfolio/class.wp-less-styles.php:3) in /home/ezekiel/public_html/boxsponsive/wp-includes/pluggable.php on line 934 </code></pre> <p>So, I'm sure that ...
[ { "answer_id": 53791, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 4, "selected": true, "text": "<p>I got this almost working, but refinements are needed to fit the specifics of the question and to deal with A...
2011/10/05
[ "https://wordpress.stackexchange.com/questions/30332", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9194/" ]
``` Warning: Cannot modify header information - headers already sent by (output started at /home/ezekiel/public_html/boxsponsive/wp- content/themes/BoxSponsive-Portfolio/class.wp-less-styles.php:3) in /home/ezekiel/public_html/boxsponsive/wp-includes/pluggable.php on line 934 ``` So, I'm sure that you've all seen thi...
I got this almost working, but refinements are needed to fit the specifics of the question and to deal with Attachments and Post-Types differently (see comments in code)... --- First, I think it's worth noting how I found the filter: `apply_filters( 'views_' . $screen->id, $views )` * inspect element ![subsubs...
30,347
<p>I need to add a <strong>meta box</strong> to the <strong>backend menu page</strong>, in <em>Appearance->Menus</em> (<code>/wp-admin/nav-menus.php</code>), to list all the available <strong>post types</strong>, both the defaults &amp; the custom ones. </p> <p>It will contain a list that contains a link to the <stron...
[ { "answer_id": 33973, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 3, "selected": false, "text": "<p>Here is an example metabox that displays at the very top of the left hand side in the nav menus interface:</p...
2011/10/05
[ "https://wordpress.stackexchange.com/questions/30347", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1044/" ]
I need to add a **meta box** to the **backend menu page**, in *Appearance->Menus* (`/wp-admin/nav-menus.php`), to list all the available **post types**, both the defaults & the custom ones. It will contain a list that contains a link to the **archive pages only** of the respective post types to be added to the nav me...
Here is an example metabox that displays at the very top of the left hand side in the nav menus interface: ``` /** * Instantiates the class */ add_action( 'admin_init', array( 'call_someClass', 'init' ) ); /** * The Class */ class call_someClass { const LANG = 'exch_lang'; public static function init() {...
30,349
<p>I already know how to remove a metabox from my custom post type edit page. However I want to remove the comments metabox but still allow commenting for the post. Because I notice when I do remove it, it disables comments. Any function I can use?</p>
[ { "answer_id": 30353, "author": "Alexey", "author_id": 7314, "author_profile": "https://wordpress.stackexchange.com/users/7314", "pm_score": 0, "selected": false, "text": "<p>Add this in <code>functions.php</code> of your theme</p>\n\n<pre><code>function tune_admin_area() {\n echo...
2011/10/05
[ "https://wordpress.stackexchange.com/questions/30349", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5698/" ]
I already know how to remove a metabox from my custom post type edit page. However I want to remove the comments metabox but still allow commenting for the post. Because I notice when I do remove it, it disables comments. Any function I can use?
Don't remove this via CSS. The \_POST part is also active and WP save the data! Use the hooks to remove meta boxes; code by scratch. ``` function fb_remove_comments_meta_boxes() { remove_meta_box( 'commentstatusdiv', 'post', 'normal' ); remove_meta_box( 'commentstatusdiv', 'page', 'normal' ); // remove tra...
30,356
<p>Good Afternoon,</p> <p>In my theme I have two separate pages for blogs. The main blog page, "news.php", holds our standard news, thoughts, events type of posts. The second blog, "questions.php", holds blog postings of only the "Ask a Question" category. In my sidebar I've included the default "Recent Posts" widg...
[ { "answer_id": 30371, "author": "andresmijares", "author_id": 4907, "author_profile": "https://wordpress.stackexchange.com/users/4907", "pm_score": 0, "selected": false, "text": "<p>that is really weird, I would start for the basis, maybe the query is carry something else, try adding </p...
2011/10/05
[ "https://wordpress.stackexchange.com/questions/30356", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9199/" ]
Good Afternoon, In my theme I have two separate pages for blogs. The main blog page, "news.php", holds our standard news, thoughts, events type of posts. The second blog, "questions.php", holds blog postings of only the "Ask a Question" category. In my sidebar I've included the default "Recent Posts" widget. On the m...
The `$wp_query` object is used to store the *main page query*, so when you're using ``` $wp_query = new WP_Query( $args ); ``` you're wiping out the defaults. Hence, the `wp_reset_query()` has nothing to reset. To fix the problem, save your custom query object with a different name, maybe `$mr_custom_query`, and th...
30,360
<p>What im trying to do is echo a class depending on witch of 3 Main "Parent" Categories the content was posted in , here is my code so far</p> <pre><code>&lt;article class="post &lt;?php if ( in_category( 'dream-it' )){ echo 'dreamit'; } if ( in_category( 'build-it' )){ echo 'buildit'; } if ( in_category( 'get-the...
[ { "answer_id": 30371, "author": "andresmijares", "author_id": 4907, "author_profile": "https://wordpress.stackexchange.com/users/4907", "pm_score": 0, "selected": false, "text": "<p>that is really weird, I would start for the basis, maybe the query is carry something else, try adding </p...
2011/10/05
[ "https://wordpress.stackexchange.com/questions/30360", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6381/" ]
What im trying to do is echo a class depending on witch of 3 Main "Parent" Categories the content was posted in , here is my code so far ``` <article class="post <?php if ( in_category( 'dream-it' )){ echo 'dreamit'; } if ( in_category( 'build-it' )){ echo 'buildit'; } if ( in_category( 'get-the-hell-out' )){ echo ...
The `$wp_query` object is used to store the *main page query*, so when you're using ``` $wp_query = new WP_Query( $args ); ``` you're wiping out the defaults. Hence, the `wp_reset_query()` has nothing to reset. To fix the problem, save your custom query object with a different name, maybe `$mr_custom_query`, and th...
30,363
<p>I have a Custom Post Type set up with a Custom Taxonomy. For this Custom Taxonomy, I'm trying to figure out how to echo out the titles of the parent category and current child category within it.</p> <p>This is the set-up:</p> <p>prints (registered custom post type)</p> <p>print_type (registered custom taxonomy)<...
[ { "answer_id": 30368, "author": "andresmijares", "author_id": 4907, "author_profile": "https://wordpress.stackexchange.com/users/4907", "pm_score": 0, "selected": false, "text": "<p>just a single question, how do you want to set a category to a post-type? post-type are already categories...
2011/10/05
[ "https://wordpress.stackexchange.com/questions/30363", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7198/" ]
I have a Custom Post Type set up with a Custom Taxonomy. For this Custom Taxonomy, I'm trying to figure out how to echo out the titles of the parent category and current child category within it. This is the set-up: prints (registered custom post type) print\_type (registered custom taxonomy) * Prints & Note Cards ...
Are you sure you are not using a custom taxonomy in your custom post type? Taxonomies for Custom Post Types have to use get\_terms instead of get\_category. More information on get\_terms from the WordPress Codex: <http://codex.wordpress.org/Function_Reference/get_terms>
30,386
<p>I need to add a RewriteRule to my site. I have tried in .htaccess with no luck, it doesn't get parsed, so I'm all but giving up on that. I found the documentation on add_rewrite_rule, but have no idea where I'm supposed to use it. I am not writing a plugin. I need to put in one simple rule.</p> <p>I went to the...
[ { "answer_id": 30390, "author": "w3uiguru", "author_id": 8982, "author_profile": "https://wordpress.stackexchange.com/users/8982", "pm_score": 1, "selected": false, "text": "<p>If possible Can you please show your .htaccess code so we can see that what exactly problem you are facing.</p>...
2011/10/06
[ "https://wordpress.stackexchange.com/questions/30386", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9208/" ]
I need to add a RewriteRule to my site. I have tried in .htaccess with no luck, it doesn't get parsed, so I'm all but giving up on that. I found the documentation on add\_rewrite\_rule, but have no idea where I'm supposed to use it. I am not writing a plugin. I need to put in one simple rule. I went to the functions.p...
`add_rewrite_rule` is for converting a URL structure to query vars and routing requests through `index.php`, you can't point to other URLs and use flags like you would in htaccess rewrites. for what you're trying to achieve, doing it via htaccess is the simplest way. your rule should work if you just remove the leadin...
30,419
<p>first of all I'd like to thank you for all the great work you're doing. I've found a lot of useful infos and tricks taking a look around in Wordpress Answers.</p> <p>Well, I'm here to ask so that's my question:</p> <p>I need to make several "sort by" pages with different criteria.</p> <p>The first I made was "sor...
[ { "answer_id": 30420, "author": "Jeremy Felt", "author_id": 9203, "author_profile": "https://wordpress.stackexchange.com/users/9203", "pm_score": 0, "selected": false, "text": "<p>[addendum] - Sorry, I lost track of the question in the title as I read the description of your problem. I'd...
2011/10/06
[ "https://wordpress.stackexchange.com/questions/30419", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9217/" ]
first of all I'd like to thank you for all the great work you're doing. I've found a lot of useful infos and tricks taking a look around in Wordpress Answers. Well, I'm here to ask so that's my question: I need to make several "sort by" pages with different criteria. The first I made was "sort by title" and I use a ...
after some trials I've got one solution that seems to be good but I need some tweaking help ``` <ul class="list-ensemble"> <?php $terms = get_terms("production_co_type"); $count = count($terms); if ( $count > 0 ){ echo "<ul>"; foreach ( $terms as $term ) { echo '<li c...
30,431
<p>I'm trying to get info into my network sites page in a column. Below works great to grab the network site ID for each site.</p> <p>How can I make it display the option_value for the item (blog_expire) in the option_name column within my blogname_options table? </p> <pre><code>class Add_Blog_ID { public static fun...
[ { "answer_id": 30825, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 4, "selected": true, "text": "<p>here is a modified version of your class that should work:</p>\n\n<pre><code>class Add_Blog_ID {\n public s...
2011/10/06
[ "https://wordpress.stackexchange.com/questions/30431", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5698/" ]
I'm trying to get info into my network sites page in a column. Below works great to grab the network site ID for each site. How can I make it display the option\_value for the item (blog\_expire) in the option\_name column within my blogname\_options table? ``` class Add_Blog_ID { public static function init() { ...
here is a modified version of your class that should work: ``` class Add_Blog_ID { public static function init() { $class = __CLASS__ ; if ( empty( $GLOBALS[ $class ] ) ) $GLOBALS[ $class ] = new $class; } public function __construct() { add_filter( 'wpmu_blogs_columns',...
30,436
<p>I'm wondering if there is a good way to tell which archive page a post came from. I essentially just need the post's position in the total order, then divide it by the 'posts_per_page' option. The hangup I'm having is getting that position or offset of where the post sits.</p> <p>EDIT: All while being on the SINGLE...
[ { "answer_id": 30438, "author": "Drew Gourley", "author_id": 4282, "author_profile": "https://wordpress.stackexchange.com/users/4282", "pm_score": 2, "selected": true, "text": "<p>Alright, nevermind. I got this solved by doing this at the top of the single post template:</p>\n\n<pre><cod...
2011/10/06
[ "https://wordpress.stackexchange.com/questions/30436", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4282/" ]
I'm wondering if there is a good way to tell which archive page a post came from. I essentially just need the post's position in the total order, then divide it by the 'posts\_per\_page' option. The hangup I'm having is getting that position or offset of where the post sits. EDIT: All while being on the SINGLE POST te...
Alright, nevermind. I got this solved by doing this at the top of the single post template: ``` $position_query = array( 'post_type' => 'portfolio', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => -1 ); $position_posts = get_posts($position_query); $count = 0; foreach ($position_posts as $position_post) ...
30,450
<p>I've been working with Wordpress off and on for years now, but I haven't gotten entirely immersed with the framework. I have no problem creating plugins that use custom post types, but I'm looking to add a new section in the admin that isn't for posts, but rather my own custom tables.</p> <p>I know how to create th...
[ { "answer_id": 30438, "author": "Drew Gourley", "author_id": 4282, "author_profile": "https://wordpress.stackexchange.com/users/4282", "pm_score": 2, "selected": true, "text": "<p>Alright, nevermind. I got this solved by doing this at the top of the single post template:</p>\n\n<pre><cod...
2011/10/07
[ "https://wordpress.stackexchange.com/questions/30450", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6348/" ]
I've been working with Wordpress off and on for years now, but I haven't gotten entirely immersed with the framework. I have no problem creating plugins that use custom post types, but I'm looking to add a new section in the admin that isn't for posts, but rather my own custom tables. I know how to create the custom t...
Alright, nevermind. I got this solved by doing this at the top of the single post template: ``` $position_query = array( 'post_type' => 'portfolio', 'orderby' => 'menu_order', 'order' => 'ASC', 'numberposts' => -1 ); $position_posts = get_posts($position_query); $count = 0; foreach ($position_posts as $position_post) ...
30,452
<p>Is it possible to change the fields that are available in the comments form? By default my comments form is asking for Name, Email, Website, and then the actual message. I'd like to remove website and replace it with a new field of my choosing.</p> <p>What's the best way to accomplish this?</p>
[ { "answer_id": 30455, "author": "Jeremy Felt", "author_id": 9203, "author_profile": "https://wordpress.stackexchange.com/users/9203", "pm_score": 3, "selected": false, "text": "<p>This answer can change depending on the theme or plugins you have installed, but the code can usually be fou...
2011/10/07
[ "https://wordpress.stackexchange.com/questions/30452", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7298/" ]
Is it possible to change the fields that are available in the comments form? By default my comments form is asking for Name, Email, Website, and then the actual message. I'd like to remove website and replace it with a new field of my choosing. What's the best way to accomplish this?
This answer can change depending on the theme or plugins you have installed, but the code can usually be found in similar places of the theme editor. For example, if you are using the default Twenty Eleven theme in WordPress 3.2.1, you can verify the location of the comments call by checking here: 1. Login to your ad...
30,468
<p>As usual, rewrite stumped me! I've built a custom search for searching through comments and comment meta, using a flat table. I'm using a rewrite rule as follows:</p> <pre><code>..../search/reviews/&lt;parameters&gt; </code></pre> <p>I'm sending a query var 'args' which is group of key/val pairs to search against,...
[ { "answer_id": 30463, "author": "w3uiguru", "author_id": 8982, "author_profile": "https://wordpress.stackexchange.com/users/8982", "pm_score": 1, "selected": false, "text": "<p>To create form in wordpress there are two ways either use plugins or custom templates.</p>\n\n<p>If you want go...
2011/10/07
[ "https://wordpress.stackexchange.com/questions/30468", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4740/" ]
As usual, rewrite stumped me! I've built a custom search for searching through comments and comment meta, using a flat table. I'm using a rewrite rule as follows: ``` ..../search/reviews/<parameters> ``` I'm sending a query var 'args' which is group of key/val pairs to search against, to my custom template which has...
To create form in wordpress there are two ways either use plugins or custom templates. If you want good plugin to create form then contact for 7 is the best. Url: <http://wordpress.org/extend/plugins/contact-form-7/> Website: <http://contactform7.com/> Documentation: <http://contactform7.com/docs/> To create custo...
30,476
<p>I have a custom post type called <code>portfolio</code> and a custom taxonomy called <code>build-type</code> (acting as categories)</p> <p>I am trying to query <code>portfolio</code> posts by <code>build-type</code> ID e.g. all Portfolio posts in "Hotels" (id=4 for that taxonomy)</p> <pre><code>// gets the ID from...
[ { "answer_id": 30484, "author": "Drew Gourley", "author_id": 4282, "author_profile": "https://wordpress.stackexchange.com/users/4282", "pm_score": 5, "selected": true, "text": "<p>The reason this isn't working is because 'tax_query' needs to be an array of arrays (confusing, I know).</p>...
2011/10/07
[ "https://wordpress.stackexchange.com/questions/30476", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9244/" ]
I have a custom post type called `portfolio` and a custom taxonomy called `build-type` (acting as categories) I am trying to query `portfolio` posts by `build-type` ID e.g. all Portfolio posts in "Hotels" (id=4 for that taxonomy) ``` // gets the ID from a custom field to show posts on a specific page $buildType = ...
The reason this isn't working is because 'tax\_query' needs to be an array of arrays (confusing, I know). ``` ... 'tax_query' => array( array( 'taxonomy' => 'build-type', ... ``` It is that way so you can group a few different rules together.
30,496
<p>Does it matter if I enqueue a script on just the page I need it to be used? As opposed to <code>functions.php</code>?</p> <p>Or, what is the best practice? In this example I need a rotator just on the front page of my site. </p> <p>And if I do enqueue it on the page, is there a best place to put it?</p>
[ { "answer_id": 30499, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 3, "selected": true, "text": "<p>Go with functions.php.</p>\n\n<blockquote>\n <p>Use the wp_enqueue_scripts action to call this function, or\...
2011/10/07
[ "https://wordpress.stackexchange.com/questions/30496", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8678/" ]
Does it matter if I enqueue a script on just the page I need it to be used? As opposed to `functions.php`? Or, what is the best practice? In this example I need a rotator just on the front page of my site. And if I do enqueue it on the page, is there a best place to put it?
Go with functions.php. > > Use the wp\_enqueue\_scripts action to call this function, or > admin\_enqueue\_scripts to call it on the admin side. Calling it outside > of an action can lead to problems. See #11526 for details. > > > Source: <http://codex.wordpress.org/Function_Reference/wp_enqueue_script> ``` fu...
30,502
<p>I am very new to WordPress. How can I use post custom metadata in place of Post Titles, and as the Post Permalink? For example, instead of <code>domain.com/the-post-title</code>, the permalink would be <code>domain.com/$postcustommetadata</code>.</p> <p>I <a href="http://wordpress.org/support/topic/want-to-customiz...
[ { "answer_id": 61503, "author": "ifdion", "author_id": 6383, "author_profile": "https://wordpress.stackexchange.com/users/6383", "pm_score": 2, "selected": false, "text": "<p>This will do.</p>\n\n<p>The slug is saved on the wp_posts while custom fields are on the wp_posts_meta. If you wa...
2011/10/07
[ "https://wordpress.stackexchange.com/questions/30502", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9255/" ]
I am very new to WordPress. How can I use post custom metadata in place of Post Titles, and as the Post Permalink? For example, instead of `domain.com/the-post-title`, the permalink would be `domain.com/$postcustommetadata`. I [posted my idea in the WPORG support forums](http://wordpress.org/support/topic/want-to-cust...
This will do. The slug is saved on the wp\_posts while custom fields are on the wp\_posts\_meta. If you want to make it like that you can use an action hook on save\_post that will get the value of the custom fields and saves it as the post slug. Here is the code ``` add_action('save_post', 'set_slug'); function se...
30,529
<p>How to change just wordpress post title but not menu items. </p> <pre><code>add_filter('the_title', 'wordpress_title'); function wordpress_title(){ return 'New title'; } </code></pre> <p><img src="https://i.stack.imgur.com/UtVPI.png" alt="enter image description here"></p>
[ { "answer_id": 30534, "author": "Mohit Bumb", "author_id": 8184, "author_profile": "https://wordpress.stackexchange.com/users/8184", "pm_score": 0, "selected": false, "text": "<pre><code>&lt;?php add_filter('the_title', function($title) { return '&lt;b&gt;'. $title. '&lt;/b&gt;';}) ?&gt;...
2011/10/08
[ "https://wordpress.stackexchange.com/questions/30529", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8729/" ]
How to change just wordpress post title but not menu items. ``` add_filter('the_title', 'wordpress_title'); function wordpress_title(){ return 'New title'; } ``` ![enter image description here](https://i.stack.imgur.com/UtVPI.png)
``` add_filter('the_title', 'wordpress_title'); function wordpress_title($title){ //Return new title if called inside loop if ( in_the_loop() ) return 'New title'; //Else return regular return $title; } ``` Have you tried the *[`in_the_loop()`](http://codex.wordpress.org/Function_Referen...
30,542
<p>How do I make it so the thumbnails in the list of blog posts on my blog are clickable, so that when the user clicks the thumbnail image, the blog post opens up?</p> <p>If it helps, this is the blog: <a href="http://wordfruit.com/blog" rel="nofollow">http://wordfruit.com/blog</a></p>
[ { "answer_id": 30543, "author": "Mohit Bumb", "author_id": 8184, "author_profile": "https://wordpress.stackexchange.com/users/8184", "pm_score": 0, "selected": false, "text": "<pre><code>if ( function_exists( 'add_theme_support' ) ) { \n add_theme_support( 'post-thumbnails' ); \n}\n</co...
2011/10/08
[ "https://wordpress.stackexchange.com/questions/30542", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7692/" ]
How do I make it so the thumbnails in the list of blog posts on my blog are clickable, so that when the user clicks the thumbnail image, the blog post opens up? If it helps, this is the blog: <http://wordfruit.com/blog>
Do you want to make all the thumbnails link to their respective blog posts? If so, use the following code in the `functions.php` file: ``` add_filter( 'post_thumbnail_html', 'my_post_image_html', 10, 3 ); function my_post_image_html( $html, $post_id, $post_image_id ) { $html = '<a href="' . get_permalink( $post_i...
30,544
<p>Is it possible to add thumbnails to blog post listings independent of images in a blog post -- e.g. if there is no image in the blog post, can I add a thumbnail image?</p>
[ { "answer_id": 30545, "author": "Jamal Jama", "author_id": 2474, "author_profile": "https://wordpress.stackexchange.com/users/2474", "pm_score": 0, "selected": false, "text": "<p>You can use the <code>has_post_thumbnail()</code> conditional tag to check if the post has a thumbnail, if th...
2011/10/08
[ "https://wordpress.stackexchange.com/questions/30544", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7692/" ]
Is it possible to add thumbnails to blog post listings independent of images in a blog post -- e.g. if there is no image in the blog post, can I add a thumbnail image?
> > Is it possible to add thumbnails to blog post listings independent of > images in a blog post > > > set the 'featured image' when writing/editing your post; and use [`the_post_thumbnail()`](http://codex.wordpress.org/Function_Reference/the_post_thumbnail) within the loop, in the template. > > e.g. if there ...
30,555
<p><a href="http://wordpress.org/extend/plugins/bbpress/" rel="nofollow noreferrer">bbPress</a>' language folder (<code>wp-content/plugins/bbpress/bbp-languages</code>) has that warning:</p> <pre class="lang-php prettyprint-override"><code>/** * Do not put custom translations here. They will be deleted on bbPress upda...
[ { "answer_id": 30559, "author": "Odys", "author_id": 8435, "author_profile": "https://wordpress.stackexchange.com/users/8435", "pm_score": 2, "selected": false, "text": "<p>What you have to do is to create a simple plugin that will manage the text_domain of the installed plugins.\nIf you...
2011/10/08
[ "https://wordpress.stackexchange.com/questions/30555", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1372/" ]
[bbPress](http://wordpress.org/extend/plugins/bbpress/)' language folder (`wp-content/plugins/bbpress/bbp-languages`) has that warning: ```php /** * Do not put custom translations here. They will be deleted on bbPress updates. * * Keep custom bbPress translations in /wp-content/languages/ */ ``` Actually, this i...
You have to replace the call to BBpress’ language file. A good place to do this is a language specific file in your general languages directory. For Turkish it would probably be a file named `tr_TR.php`. This will be loaded automatically and *only* if it matches the language of your blog. It will not be overwritten. ...
30,556
<p>I use this to call posts:</p> <pre><code>&lt;?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $per_page = get_option('to_count_archives'); query_posts("posts_per_page=".$per_page."&amp;paged=".$paged."&amp;cat=".$cat); if (have_posts()) ?&gt; &lt;?php while (have_posts()) : the_post(); ?&gt; </c...
[ { "answer_id": 30597, "author": "Brooke.", "author_id": 2204, "author_profile": "https://wordpress.stackexchange.com/users/2204", "pm_score": 0, "selected": false, "text": "<p>Why not use <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query\" rel=\"nofollow\">WP_Query</a> and do...
2011/10/08
[ "https://wordpress.stackexchange.com/questions/30556", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5205/" ]
I use this to call posts: ``` <?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; $per_page = get_option('to_count_archives'); query_posts("posts_per_page=".$per_page."&paged=".$paged."&cat=".$cat); if (have_posts()) ?> <?php while (have_posts()) : the_post(); ?> ``` And it works great for categori...
It's because when you call `query_posts`, you're overwriting the original query with a new one, you have to get the original query and reset the things you want to change. ``` global $query_string; $per_page = get_option( 'to_count_archives' ); query_posts( $query_string . '&posts_per_page=' . $per_page ); ```
30,561
<p>I have the admin section of my site using HTTPS. This works pretty well except that the images inside the TinyMCE editor (the post and page rich text editor) load with http instead of https and so I get an "insecure content" warning.</p> <p>I don't want to change the actual url of the image for front-end users; tha...
[ { "answer_id": 30597, "author": "Brooke.", "author_id": 2204, "author_profile": "https://wordpress.stackexchange.com/users/2204", "pm_score": 0, "selected": false, "text": "<p>Why not use <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query\" rel=\"nofollow\">WP_Query</a> and do...
2011/10/08
[ "https://wordpress.stackexchange.com/questions/30561", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4400/" ]
I have the admin section of my site using HTTPS. This works pretty well except that the images inside the TinyMCE editor (the post and page rich text editor) load with http instead of https and so I get an "insecure content" warning. I don't want to change the actual url of the image for front-end users; that is to sa...
It's because when you call `query_posts`, you're overwriting the original query with a new one, you have to get the original query and reset the things you want to change. ``` global $query_string; $per_page = get_option( 'to_count_archives' ); query_posts( $query_string . '&posts_per_page=' . $per_page ); ```
30,563
<p>I read the following and try to apply this scheme to my website running WordPress: <a href="http://code.google.com/intl/fr-CA/web/ajaxcrawling/index.html">http://code.google.com/intl/fr-CA/web/ajaxcrawling/index.html</a></p> <p>If you visit my website at <a href="http://www.visualise.ca/">http://www.visualise.ca/</...
[ { "answer_id": 37197, "author": "brandwaffle", "author_id": 11372, "author_profile": "https://wordpress.stackexchange.com/users/11372", "pm_score": 1, "selected": false, "text": "<p>If you're specifically referring to Facebook not properly showing the meta info for your page, you should ...
2011/08/12
[ "https://wordpress.stackexchange.com/questions/30563", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7838/" ]
I read the following and try to apply this scheme to my website running WordPress: <http://code.google.com/intl/fr-CA/web/ajaxcrawling/index.html> If you visit my website at <http://www.visualise.ca/> you will see that it loads the posts within the home page and the url becomes <http://visualise.ca/#!/anne-au-cherry> ...
What I did actually is to not use hashbangs like WraithKenny suggested. Using the jQuery address plugin with the $.address.state(value) method in order to set the base path of the website that is utilized in HTML5 state management and the $.address.value(value) method in order to set the current deep linking value I w...
30,570
<p>I am currently writing a plugin that contains a report based on a mysql query. I would like to export this query information to CSV. Simple enough, I've done it many times outside of WordPress.</p> <p>I'm currently receiving an error regarding headers already sent. I know what causes this error, but cannot find i...
[ { "answer_id": 30571, "author": "Hung Nguyen", "author_id": 9277, "author_profile": "https://wordpress.stackexchange.com/users/9277", "pm_score": 0, "selected": false, "text": "<p>I've seen this now and again back in my days of developing in PHP. Usually when something comes up like thi...
2011/10/08
[ "https://wordpress.stackexchange.com/questions/30570", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8882/" ]
I am currently writing a plugin that contains a report based on a mysql query. I would like to export this query information to CSV. Simple enough, I've done it many times outside of WordPress. I'm currently receiving an error regarding headers already sent. I know what causes this error, but cannot find in my code wh...
I figured out what the problem was. In the end, I added &noheader=true to my form action. This allowed me to submit my own headers without calling the WP admin headers.
30,606
<p>I have created a custom post type called Products, on the product pages i have a menu in the left sidebar. This menu is made up of categories for the products.</p> <p>Is it possible to have my products automatically added to the category menu based the category of the product?</p> <p>For example, i make a product,...
[ { "answer_id": 30571, "author": "Hung Nguyen", "author_id": 9277, "author_profile": "https://wordpress.stackexchange.com/users/9277", "pm_score": 0, "selected": false, "text": "<p>I've seen this now and again back in my days of developing in PHP. Usually when something comes up like thi...
2011/10/09
[ "https://wordpress.stackexchange.com/questions/30606", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9218/" ]
I have created a custom post type called Products, on the product pages i have a menu in the left sidebar. This menu is made up of categories for the products. Is it possible to have my products automatically added to the category menu based the category of the product? For example, i make a product, i give it a cate...
I figured out what the problem was. In the end, I added &noheader=true to my form action. This allowed me to submit my own headers without calling the WP admin headers.
30,616
<p>I am using a custom page template for my portfolio. The code is calling the correct number of posts per page but for some reason the pagination links won't show up :-S</p> <p>My query</p> <pre><code>&lt;?php $loop = new WP_Query(array('post_type' =&gt; 'portfolio', 'posts_per_page' =&gt; 2)); ?&gt; &lt;?php...
[ { "answer_id": 30621, "author": "Mohit Bumb", "author_id": 8184, "author_profile": "https://wordpress.stackexchange.com/users/8184", "pm_score": 3, "selected": false, "text": "<p>Well that is a real problem and many peoples facing it when they change theme but there is a simple solutions...
2011/10/09
[ "https://wordpress.stackexchange.com/questions/30616", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5205/" ]
I am using a custom page template for my portfolio. The code is calling the correct number of posts per page but for some reason the pagination links won't show up :-S My query ``` <?php $loop = new WP_Query(array('post_type' => 'portfolio', 'posts_per_page' => 2)); ?> <?php while ( $loop->have_posts() ) : $loo...
The difference between theme and non-theme code is organizational rather than technical. Any code that is active contributes to resulting environment, does not matter where it is loaded from. There is number of places where code gets loaded from, which are not part of WordPress core: * `wp-config.php` configuration f...
30,625
<p>Okay Now I'm editing old problem because its done but now i've new problem I've knowledge of mysql queries but not wordpress queries I'm doing this with mysql queries and its working well but server is going damn slow i know i'm running about 30 query per page load so is there any way to do it easily with help of wo...
[ { "answer_id": 30643, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>Creation of new post should be done with <a href=\"http://codex.wordpress.org/Function_Reference/wp_insert_post\" re...
2011/10/09
[ "https://wordpress.stackexchange.com/questions/30625", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8184/" ]
Okay Now I'm editing old problem because its done but now i've new problem I've knowledge of mysql queries but not wordpress queries I'm doing this with mysql queries and its working well but server is going damn slow i know i'm running about 30 query per page load so is there any way to do it easily with help of wordp...
You can do this on background using some ajax on page load, here is an untested example to show the idea. ``` jQuery(function() { jQuery.get('http://domain.tld/remote'); }); <?php function is_ajax() { return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) and strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhtt...
30,634
<pre><code>function save_details( $post_id ){ if ( wp_is_post_revision( $post_id ) ) $post_id = wp_is_post_revision( $post_id ); update_post_meta( $post_id, "testimonyname", $_POST["testimonyname"] ); } add_action('save_post', 'save_details', 10, 1); </code></pre> <p>I have a custom post type with a custom f...
[ { "answer_id": 30643, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>Creation of new post should be done with <a href=\"http://codex.wordpress.org/Function_Reference/wp_insert_post\" re...
2011/10/09
[ "https://wordpress.stackexchange.com/questions/30634", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9017/" ]
``` function save_details( $post_id ){ if ( wp_is_post_revision( $post_id ) ) $post_id = wp_is_post_revision( $post_id ); update_post_meta( $post_id, "testimonyname", $_POST["testimonyname"] ); } add_action('save_post', 'save_details', 10, 1); ``` I have a custom post type with a custom field, but after add...
You can do this on background using some ajax on page load, here is an untested example to show the idea. ``` jQuery(function() { jQuery.get('http://domain.tld/remote'); }); <?php function is_ajax() { return (isset($_SERVER['HTTP_X_REQUESTED_WITH']) and strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhtt...
30,638
<p>I am developing an admin-only plugin, which uses some ajax calls in its interface. The website itself also relies on ajax calls on its front-end, too.</p> <p>I'd like to be able to identify when the WP is loaded due to "simple backend call", "AJAX backend call" or "AJAX frontend call". The use case, in its simplest...
[ { "answer_id": 30641, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<blockquote>\n <p><code>is_admin()</code> returns true on all AJAX calls (which is strange, imho)</p>\n</blockquote>\n...
2011/10/09
[ "https://wordpress.stackexchange.com/questions/30638", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3915/" ]
I am developing an admin-only plugin, which uses some ajax calls in its interface. The website itself also relies on ajax calls on its front-end, too. I'd like to be able to identify when the WP is loaded due to "simple backend call", "AJAX backend call" or "AJAX frontend call". The use case, in its simplest form, cou...
I understand the problem you are having, I was thinking of the same thing. It is not really a problem tho, it's more a matter of good programming design and have a good separation of front-end and back-end. Now the way I have managed to solve this is doing the following: I hope you are calling your AJAX action with...
30,659
<p>It's normal that a developer or a shop will spend several hours on each project running the same configuration options (for permalinks, SEO options, user roles, plugins that you always use etc.).</p> <p>I'm coming from Drupal, where installation profiles have allowed me to preconfigure a set of configuration option...
[ { "answer_id": 30664, "author": "Fiona", "author_id": 9300, "author_profile": "https://wordpress.stackexchange.com/users/9300", "pm_score": 0, "selected": false, "text": "<p>I'm not sure of a script per say, but I currently use the default-blog plugin to duplicate as many settings as I c...
2011/10/10
[ "https://wordpress.stackexchange.com/questions/30659", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9299/" ]
It's normal that a developer or a shop will spend several hours on each project running the same configuration options (for permalinks, SEO options, user roles, plugins that you always use etc.). I'm coming from Drupal, where installation profiles have allowed me to preconfigure a set of configuration options that I c...
Not exactly what you are asking for, but very close. There is a concept of 'dropin' plugins that exists primarily to override or add to core functions The dropins will always load. So one ftp's up wordpress including whatever plugin files you want that will create your default environment. These should be in the top...
30,694
<p>I have a function retrieving ID's of posts by very specific means.</p> <p>I need to be able to set the <code>global $post</code> in order to use functions like <code>the_content()</code>, which does not allow an ID as a parameter.</p> <p>How can I achieve this?</p>
[ { "answer_id": 30764, "author": "wdalhaj", "author_id": 9098, "author_profile": "https://wordpress.stackexchange.com/users/9098", "pm_score": 2, "selected": false, "text": "<p>To work with posts <i>outta loop </i> try using:</p>\n\n<p><code>get_post(post_id)</code></p>\n\n<p>to get a pos...
2011/10/10
[ "https://wordpress.stackexchange.com/questions/30694", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/784/" ]
I have a function retrieving ID's of posts by very specific means. I need to be able to set the `global $post` in order to use functions like `the_content()`, which does not allow an ID as a parameter. How can I achieve this?
When your going through your loop add this: ``` global $post; $post = get_post( $ID, OBJECT ); setup_postdata( $post ); //Do something wp_reset_postdata(); ```
30,724
<p>I'm using WordPress to organize documentation for a software product I'm supporting and have hit a bit of a snag. I have multiple FAQ documents (saved as pages) that I need to be separate pages but that I want to be able aggregate them into one FAQ master list.</p> <p>To do this, I installed the "Ninja Page Catego...
[ { "answer_id": 30931, "author": "Michael", "author_id": 4884, "author_profile": "https://wordpress.stackexchange.com/users/4884", "pm_score": 2, "selected": false, "text": "<p>use:</p>\n\n<p><code>$ancestors = get_ancestors($id,'page');</code> </p>\n\n<p><a href=\"http://codex.wordpress....
2011/10/10
[ "https://wordpress.stackexchange.com/questions/30724", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2355/" ]
I'm using WordPress to organize documentation for a software product I'm supporting and have hit a bit of a snag. I have multiple FAQ documents (saved as pages) that I need to be separate pages but that I want to be able aggregate them into one FAQ master list. To do this, I installed the "Ninja Page Categories and Ta...
use: `$ancestors = get_ancestors($id,'page');` [get\_ancestors()](http://codex.wordpress.org/Function_Reference/get_ancestors)
30,739
<p>I have a custom query to get the post title, permalink, and featured image. However the Post title is displaying but not in the container I want it in. here is the query</p> <pre><code> &lt;ul class="updatelist"&gt; &lt;?php $portquery = new WP_Query(); ...
[ { "answer_id": 30750, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 0, "selected": false, "text": "<p>The only 3 I know of are:</p>\n\n<p><a href=\"http://wordpress.org/extend/plugins/collabpress/\" rel=\"nofollow\">C...
2011/10/10
[ "https://wordpress.stackexchange.com/questions/30739", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8039/" ]
I have a custom query to get the post title, permalink, and featured image. However the Post title is displaying but not in the container I want it in. here is the query ``` <ul class="updatelist"> <?php $portquery = new WP_Query(); $portquery->...
Check out <http://editflow.org/> - a project launched by newsroom programmers. It's something that addresses the entire editorial workflow, from scheduling to attribution. Bonus: it now has WP Document Revisions integration.
30,757
<p>In the wordpress <strong>settings</strong> => <strong>Reading</strong> => <strong>Blog pages show at most</strong> [input field] <strong>posts</strong> </p> <p>I have it set to 3 posts at the moment. </p> <p>On my index, date archives, tag archives, category archives, search results, etc... All pages that use th...
[ { "answer_id": 30763, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 6, "selected": true, "text": "<p>This will do it: (add to your theme's functions.php)</p>\n\n<pre><code>add_action( 'pre_get_posts', 'set_pos...
2011/10/11
[ "https://wordpress.stackexchange.com/questions/30757", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8668/" ]
In the wordpress **settings** => **Reading** => **Blog pages show at most** [input field] **posts** I have it set to 3 posts at the moment. On my index, date archives, tag archives, category archives, search results, etc... All pages that use the loop and paging, it shows 3 posts per page now. My goal is to be abl...
This will do it: (add to your theme's functions.php) ``` add_action( 'pre_get_posts', 'set_posts_per_page' ); function set_posts_per_page( $query ) { global $wp_the_query; if ( ( ! is_admin() ) && ( $query === $wp_the_query ) && ( $query->is_search() ) ) { $query->set( 'posts_per_page', 3 ); } elseif (...
30,802
<p>Hi I'm trying to select users with a particular role only, using the following sql statement...</p> <pre><code>SELECT DISTINCT ID, u.user_login, u.user_nicename, u.user_email FROM wp_users u, wp_usermeta m WHERE m.meta_key = 'wp_capabilities' AND m.meta_value LIKE '%supplier%' ORDER BY u.user_registered </code></p...
[ { "answer_id": 30807, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 4, "selected": true, "text": "<p>Double-check your SQL syntax. It sounds like you want to do a <a href=\"http://dev.mysql.com/doc/refman/5.0/en/join.h...
2011/10/11
[ "https://wordpress.stackexchange.com/questions/30802", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7626/" ]
Hi I'm trying to select users with a particular role only, using the following sql statement... ``` SELECT DISTINCT ID, u.user_login, u.user_nicename, u.user_email FROM wp_users u, wp_usermeta m WHERE m.meta_key = 'wp_capabilities' AND m.meta_value LIKE '%supplier%' ORDER BY u.user_registered ``` However, it reurns ...
Double-check your SQL syntax. It sounds like you want to do a [`JOIN`](http://dev.mysql.com/doc/refman/5.0/en/join.html) ... But you're not building the query correctly. It should be something more like: ``` SELECT u.ID, u.user_login, u.user_nicename, u.user_email FROM $wpdb->users u INNER JOIN $wpdb->usermeta m ON m...
30,810
<p>I'd like to have the emails displayed on my pages/posts in such a way that they to not be able to be read/used by bots/spammers. So for instance I can use some plugin which replace "@" with "[at]" and so on, but in that case I am no longer able to automatically use mailto, like:</p> <pre><code>&lt;a href="javascrip...
[ { "answer_id": 30811, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 0, "selected": false, "text": "<p>There's a core function for that: <a href=\"http://codex.wordpress.org/Function_Reference/wp_mail\" rel=\"nofollow\...
2011/10/11
[ "https://wordpress.stackexchange.com/questions/30810", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9354/" ]
I'd like to have the emails displayed on my pages/posts in such a way that they to not be able to be read/used by bots/spammers. So for instance I can use some plugin which replace "@" with "[at]" and so on, but in that case I am no longer able to automatically use mailto, like: ``` <a href="javascript:void(0)" target...
Spam prevention should be done on the email's servers side, by that I mean you should not disrupt your usability because of spam, instead you should use a proper spam block or filtering service on your email side. For example I have been using Postini for years and have pretty much no spam to contend with. Another op...
30,824
<p>I am trying to conditionally change a link based on what page a user is on, but I am having trouble finding the correct code to perform the action. </p> <p>Here is what I want to do (In English to explain the code)</p> <p>If a user is not logged-in and on a page that is either keyword or a child of keyword (for e...
[ { "answer_id": 30830, "author": "Brian Fegter", "author_id": 4793, "author_profile": "https://wordpress.stackexchange.com/users/4793", "pm_score": 0, "selected": false, "text": "<p>I'm assuming you are referring to pages and child pages. If so, you can use this in your template within th...
2011/10/11
[ "https://wordpress.stackexchange.com/questions/30824", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/919/" ]
I am trying to conditionally change a link based on what page a user is on, but I am having trouble finding the correct code to perform the action. Here is what I want to do (In English to explain the code) If a user is not logged-in and on a page that is either keyword or a child of keyword (for example, domain.net...
If it is about child post types\* or taxonomies\*\*: ``` // page/post/cpt parent check: $post_object = get_queried_object(); // check if the page has a parent if ( $post_object->post_parent ) // do stuff // cat/tax parent check: $taxonomy_object = get_the_category( get_query_var('cat') ); // check if the cat/tag/...
30,834
<p>I must say that I am a complete nooby at Wordpress custom URL rewrites. I have searched for past many days to find a clear explanation of how to determine and write correct pattern for URL rewrites. I have a custom page template that uses query var passed to it, e.g. <a href="http://example.com/pagename?user=usernam...
[ { "answer_id": 30846, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 0, "selected": false, "text": "<p>I have had a similar problem and successfully solved it. In fact I recently wrote <a href=\"http://www.ha...
2011/10/11
[ "https://wordpress.stackexchange.com/questions/30834", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9094/" ]
I must say that I am a complete nooby at Wordpress custom URL rewrites. I have searched for past many days to find a clear explanation of how to determine and write correct pattern for URL rewrites. I have a custom page template that uses query var passed to it, e.g. <http://example.com/pagename?user=username>. In this...
Extending @Stephen Harris' excellent answer, I would opt for; ``` add_action( 'generate_rewrite_rules', 'my_rewrite_rules' ); function my_rewrite_rules( $wp_rewrite ) { $wp_rewrite->rules = array( 'mypageslug/([^/]+)/page/?([0-9]{1,})/?$' => $wp_rewrite->index . '?pagename=mypageslug&user=' . $wp_rewrite->...
30,847
<p>im trying to get a post info when I click a button on the post and make it echo out the the same info it has in the else function, I tried adding in a query but in return it makes it echo back all the post instead of just the one im clicking on </p> <pre><code> &lt;?php $cb_bp_x_points = cp_displayPoints($bp...
[ { "answer_id": 31001, "author": "Jeremy Love", "author_id": 2635, "author_profile": "https://wordpress.stackexchange.com/users/2635", "pm_score": 0, "selected": false, "text": "<p>define( 'BP_DISABLE_ADMIN_BAR', false); or just delete that code might work, also check in your options on y...
2011/10/11
[ "https://wordpress.stackexchange.com/questions/30847", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2635/" ]
im trying to get a post info when I click a button on the post and make it echo out the the same info it has in the else function, I tried adding in a query but in return it makes it echo back all the post instead of just the one im clicking on ``` <?php $cb_bp_x_points = cp_displayPoints($bp->loggedin_user->...
In your `wp-config.php`, put this: `define( 'BP_USE_WP_ADMIN_BAR', true );` Note you must put it in wp-config.php, I had it in functions.php first and it did not work.
30,851
<p>I'd like to use a custom post type archive as a site's front page, so that </p> <pre><code> http://the_site.com/ </code></pre> <p>is a custom post type archive displayed according to my <code>archive-{post-type}.php</code> file.</p> <p>Ideally I would like to alter the query using <code>is_front_page()</code> in ...
[ { "answer_id": 30854, "author": "Ijaas", "author_id": 9085, "author_profile": "https://wordpress.stackexchange.com/users/9085", "pm_score": 6, "selected": true, "text": "<p>After you have set a static page as your home page you can add this to your <code>functions.php</code> and you are ...
2011/10/12
[ "https://wordpress.stackexchange.com/questions/30851", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2150/" ]
I'd like to use a custom post type archive as a site's front page, so that ``` http://the_site.com/ ``` is a custom post type archive displayed according to my `archive-{post-type}.php` file. Ideally I would like to alter the query using `is_front_page()` in my `functions.php` file. I tried the following, with a ...
After you have set a static page as your home page you can add this to your `functions.php` and you are good to go. This will call the `archive-POSTTYPE.php` template correctly as well. ``` add_action("pre_get_posts", "custom_front_page"); function custom_front_page($wp_query){ //Ensure this filter isn't applied t...
30,861
<p>I would like to use PHP in some posts. These posts should look like normal posts, be in the archive and categories like normal posts an have tags. </p> <p>I don't need PHP in every post, but it would be great if I could use it in some.</p> <p>I saw that it is possible to create <a href="http://codex.wordpress.org/...
[ { "answer_id": 30854, "author": "Ijaas", "author_id": 9085, "author_profile": "https://wordpress.stackexchange.com/users/9085", "pm_score": 6, "selected": true, "text": "<p>After you have set a static page as your home page you can add this to your <code>functions.php</code> and you are ...
2011/10/12
[ "https://wordpress.stackexchange.com/questions/30861", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7289/" ]
I would like to use PHP in some posts. These posts should look like normal posts, be in the archive and categories like normal posts an have tags. I don't need PHP in every post, but it would be great if I could use it in some. I saw that it is possible to create [custom page templates](http://codex.wordpress.org/Pa...
After you have set a static page as your home page you can add this to your `functions.php` and you are good to go. This will call the `archive-POSTTYPE.php` template correctly as well. ``` add_action("pre_get_posts", "custom_front_page"); function custom_front_page($wp_query){ //Ensure this filter isn't applied t...
30,869
<p>I would like to set a site's front page to be a single post from a custom post type. I have been able to alter the request for my front page to a Custom Post Type <em>archive</em> with the following code (originally <a href="https://wordpress.stackexchange.com/questions/30851/how-to-use-a-custom-post-type-archive-as...
[ { "answer_id": 30870, "author": "dwaser", "author_id": 8199, "author_profile": "https://wordpress.stackexchange.com/users/8199", "pm_score": 2, "selected": false, "text": "<p>I had to do the same for a customer and I have found two resources which helped me:</p>\n\n<p><a href=\"https://w...
2011/10/12
[ "https://wordpress.stackexchange.com/questions/30869", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2150/" ]
I would like to set a site's front page to be a single post from a custom post type. I have been able to alter the request for my front page to a Custom Post Type *archive* with the following code (originally [posted here](https://wordpress.stackexchange.com/questions/30851/how-to-use-a-custom-post-type-archive-as-fron...
Easiest way to display single post on front page would be: ``` global $wp_query; $wp_query = new WP_Query( array( 'p' => 'POST ID HERE' ) ); include( 'single-POSTTYPE.php' ); ```
30,873
<p>i have try many methods after searching on internet but unable to ramove Nothing Found from my 404 page title how to do it please help me</p> <p>even i have us this in my 404 page header <code> if( is_404() ) echo '404 message goes here | '; else wp_title( '|', true, 'right' ); </code></p> <p>i also ramove php tit...
[ { "answer_id": 30878, "author": "dwaser", "author_id": 8199, "author_profile": "https://wordpress.stackexchange.com/users/8199", "pm_score": 0, "selected": false, "text": "<p>The following code works fine with the twenty eleven theme:</p>\n\n<pre><code>if ( is_404() ) { \n echo __('Noth...
2011/10/12
[ "https://wordpress.stackexchange.com/questions/30873", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9255/" ]
i have try many methods after searching on internet but unable to ramove Nothing Found from my 404 page title how to do it please help me even i have us this in my 404 page header `if( is_404() ) echo '404 message goes here | '; else wp_title( '|', true, 'right' );` i also ramove php title function and five their my ...
I would use the `wp_title` filter hook: ``` function theme_slug_filter_wp_title( $title ) { if ( is_404() ) { $title = 'ADD 404 TITLE TEXT HERE'; } // You can do other filtering here, or // just return $title return $title; } // Hook into wp_title filter hook add_filter( 'wp_title', 'theme_...
30,888
<p>I'm trying to password protect a page but it doesn't seem to be working. I've set the password for the page but when you navigate to it it just loads up like normal and doesn't ask for any passwords.</p> <p>This is the loop I have on my page:</p> <pre><code>&lt;?php /** * @package WordPress * @subpackage Default...
[ { "answer_id": 30896, "author": "chifliiiii", "author_id": 4130, "author_profile": "https://wordpress.stackexchange.com/users/4130", "pm_score": 1, "selected": false, "text": "<blockquote>\n <p>Hi Rob i can not comment yet as i dont have enough privilegie so i\n will add an answer inst...
2011/10/12
[ "https://wordpress.stackexchange.com/questions/30888", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4588/" ]
I'm trying to password protect a page but it doesn't seem to be working. I've set the password for the page but when you navigate to it it just loads up like normal and doesn't ask for any passwords. This is the loop I have on my page: ``` <?php /** * @package WordPress * @subpackage Default_Theme * Template Name:...
One solution would be to [create a *custom Page template*](http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates) for Pages that you intend to password protect. Start by creating your custom Page template, perhaps named `template-password-protected.php`, and add the `Template:` file-docblock tag at the top...
30,894
<p>i'm trying to add image size in media library screen so will be simply to handle images. Anyone does it before me? Any help appreciated. Francesco</p>
[ { "answer_id": 30916, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": false, "text": "<p>Code based on <a href=\"http://scribu.net/wordpress/custom-sortable-columns.html\" rel=\"nofollow noreferrer\">Custo...
2011/10/12
[ "https://wordpress.stackexchange.com/questions/30894", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9388/" ]
i'm trying to add image size in media library screen so will be simply to handle images. Anyone does it before me? Any help appreciated. Francesco
Code based on [Custom Sortable Columns](http://scribu.net/wordpress/custom-sortable-columns.html) ``` add_filter('manage_upload_columns', 'size_column_register'); function size_column_register($columns) { $columns['dimensions'] = 'Dimensions'; return $columns; } add_action('manage_media_custom_column', 'si...
30,899
<p>Seriously, I hate flyout menus with a passion, and now they're popping up all over the place in the admin screen. (They are particularly heinous when you use the blue admin theme, because they add a dark arrow. Eye dirt.)</p> <p>How do I disable the flyout menu? They add zero functionality and usability to my workf...
[ { "answer_id": 30909, "author": "Annika Backstrom", "author_id": 66, "author_profile": "https://wordpress.stackexchange.com/users/66", "pm_score": 1, "selected": false, "text": "<p>Aaron Campbell <a href=\"https://gist.github.com/1281508\" rel=\"nofollow\">wrote a gist</a> to expand all ...
2011/10/12
[ "https://wordpress.stackexchange.com/questions/30899", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10/" ]
Seriously, I hate flyout menus with a passion, and now they're popping up all over the place in the admin screen. (They are particularly heinous when you use the blue admin theme, because they add a dark arrow. Eye dirt.) How do I disable the flyout menu? They add zero functionality and usability to my workflow. Than...
It's a bit of a workarround but here you go: ``` function remove_flyout() { echo '<style type="text/css"> .js #adminmenu .wp-submenu.sub-open { display: none; } </style>'; } add_action('admin_head', 'remove_flyout'); ``` Put it in your functions.php
30,904
<p>Where you can see it: <a href="http://themeforward.com/demo2/functional-codes" rel="nofollow">http://themeforward.com/demo2/functional-codes</a></p> <p>The first button is my code, as it should appear. The second button is within <code>&lt;pre&gt;&lt;code&gt;&lt;/pre&gt;&lt;/code&gt;</code> tags to show users how ...
[ { "answer_id": 30907, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": 0, "selected": false, "text": "<p>You can convert the tags to HTML so it will display as you want. There are some generators online for this....
2011/10/12
[ "https://wordpress.stackexchange.com/questions/30904", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5205/" ]
Where you can see it: <http://themeforward.com/demo2/functional-codes> The first button is my code, as it should appear. The second button is within `<pre><code></pre></code>` tags to show users how I made the button appear. But instead of showing the code, the button is generated. **How can I get WordPress' code tag...
You can display a shortcode by using two (or three) square brackets at the open and close, e.g. `[[[pdf href="http://www.constitution.org/usdeclar.pdf"]Declaration of Independence[/pdf]]]` In my experience, a standalone shortcode just needs two whereas one that wraps needs three on each end, even though I've seen it ...
30,947
<p>Any suggestions on the simplest way to display tags using get_tags in an html table (4 columns across) ?</p> <p>Example: <br> Tag 1 | Tag2 | Tag 3 | Tag 4 <br> Tag 5 | Tag 6 | Tag 7 | Tag 8 </p> <p>I'm using the following code to display tags, I found it in <a href="http://codex.wordpress.org/Function_Refere...
[ { "answer_id": 30957, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>WordPress is not a simplistic script, it is a extensive web app. It includes own time zone settings and own function...
2011/10/13
[ "https://wordpress.stackexchange.com/questions/30947", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4194/" ]
Any suggestions on the simplest way to display tags using get\_tags in an html table (4 columns across) ? Example: Tag 1 | Tag2 | Tag 3 | Tag 4 Tag 5 | Tag 6 | Tag 7 | Tag 8 I'm using the following code to display tags, I found it in [codex](http://codex.wordpress.org/Function_Reference/get_tags).: ``` $ta...
Somehow I missed the current\_time function, which gives a good description of the situation and how to properly deal with the need to get the current blog-local time. <http://codex.wordpress.org/Function_Reference/current_time> Though the purist in me still hates how WP makes the time zone setting in php.ini obsolet...
30,965
<p>How do I set the medium and large images sizes in WP to hard crop?</p> <p>In my theme I can set the thumbnail size to hard crop using this:</p> <pre><code>add_theme_support('post-thumbnails'); set_post_thumbnail_size( 96, 96, true ); </code></pre> <p>But I can see no way to make the medium and large images to har...
[ { "answer_id": 30966, "author": "Sisir", "author_id": 3094, "author_profile": "https://wordpress.stackexchange.com/users/3094", "pm_score": 5, "selected": true, "text": "<p>You can over write the default like this:</p>\n\n<pre><code>add_image_size( 'medium', 200, 200, true );\n</code></p...
2011/10/13
[ "https://wordpress.stackexchange.com/questions/30965", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4610/" ]
How do I set the medium and large images sizes in WP to hard crop? In my theme I can set the thumbnail size to hard crop using this: ``` add_theme_support('post-thumbnails'); set_post_thumbnail_size( 96, 96, true ); ``` But I can see no way to make the medium and large images to hard crop. Is there possibly a way ...
You can over write the default like this: ``` add_image_size( 'medium', 200, 200, true ); ```
30,970
<p>I am using get posts, but I need to refine the query based on posts where a certain meta_key has a certain value.</p> <p>Something like this</p> <pre><code>&lt;?php $reviews = get_posts('post_type=reviews&amp;numberposts=-1&amp; // eg. // location=berkshire'); </code></pre> <p>Is it possible to do this and if s...
[ { "answer_id": 30975, "author": "Jamal Jama", "author_id": 2474, "author_profile": "https://wordpress.stackexchange.com/users/2474", "pm_score": 1, "selected": false, "text": "<p>Yes. Its possible. Use <code>meta_key</code> and <code>meta_value</code> parameters. <code>meta_key</code> is...
2011/10/13
[ "https://wordpress.stackexchange.com/questions/30970", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9405/" ]
I am using get posts, but I need to refine the query based on posts where a certain meta\_key has a certain value. Something like this ``` <?php $reviews = get_posts('post_type=reviews&numberposts=-1& // eg. // location=berkshire'); ``` Is it possible to do this and if so how? Marvellous
`get_posts` accepts any of the arguments that [WP\_Query](http://codex.wordpress.org/Class_Reference/WP_Query) accepts. So there's a few options. **1. `meta_key` and `meta_value`** ``` <?php get_posts(array( // some more args here 'meta_key' => 'some_key', 'meta_value' => 'some value' )); ``` **2. `meta_...
30,977
<p>How can I list users by last name ASC when using <a href="http://codex.wordpress.org/Class_Reference/WP_User_Query">WP_User_Query</a>?</p> <p>There is an orderby parameter but looking in core it doesn't accept ordering my user meta. Anyone know how to extend WP to allow this ordering by last name?</p>
[ { "answer_id": 30980, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>Filter the string <code>'query'</code> and change the <code>ORDER BY</code> part. See <a href=\"https://gist.github.co...
2011/10/13
[ "https://wordpress.stackexchange.com/questions/30977", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4610/" ]
How can I list users by last name ASC when using [WP\_User\_Query](http://codex.wordpress.org/Class_Reference/WP_User_Query)? There is an orderby parameter but looking in core it doesn't accept ordering my user meta. Anyone know how to extend WP to allow this ordering by last name?
There is a **better way to do this as of Wordpress version 3.7.** Use the Wordpress property meta\_key to select the last name property and then orderby => meta\_value with an ascending order. ``` <?php $args = array( 'meta_key' => 'last_name', 'orderby' => 'meta_value', 'order' => 'ASC' ); $user_query = ...
30,985
<p>I'm trying to manually display the link of a custom taxonomy term that I have created. The taxonomy is 'event-themes' and the term is 'Boat'. Here's my code:</p> <pre><code>&lt;?php $themeOne = array( 'tax_query' =&gt; array( array( 'taxonomy' =&gt; 'event-themes', ...
[ { "answer_id": 30996, "author": "chifliiiii", "author_id": 4130, "author_profile": "https://wordpress.stackexchange.com/users/4130", "pm_score": 0, "selected": false, "text": "<p>You are mixing functions. The tax query array is intented to modify the query that affect the loop.\nTo just ...
2011/10/13
[ "https://wordpress.stackexchange.com/questions/30985", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5883/" ]
I'm trying to manually display the link of a custom taxonomy term that I have created. The taxonomy is 'event-themes' and the term is 'Boat'. Here's my code: ``` <?php $themeOne = array( 'tax_query' => array( array( 'taxonomy' => 'event-themes', 'fiel...
In your code you are just storing an "array" in the variable $themeOne. The code you should be using to make the query is: ``` $themeOne = new WP_Query(array( 'tax_query' => array( array( 'taxonomy' => 'event-themes', 'terms' => 'boat-theme' ) ) )); ``` The result should be an array of object...
31,002
<p>I created a custom theme for my wordpress blog, and my widgets keep showing up in an unordered list form. I didn't program my widgets to appear this way. And I can't figure out how to remove the bullets from my widgets.</p> <p>I tried editing the widgets.php file in the wp-includes folder by removing the beforewige...
[ { "answer_id": 31014, "author": "Devise", "author_id": 3899, "author_profile": "https://wordpress.stackexchange.com/users/3899", "pm_score": 0, "selected": false, "text": "<p>How do you want your widgets to show (if not list form - what) and can you show the code that you mention using t...
2011/10/13
[ "https://wordpress.stackexchange.com/questions/31002", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8720/" ]
I created a custom theme for my wordpress blog, and my widgets keep showing up in an unordered list form. I didn't program my widgets to appear this way. And I can't figure out how to remove the bullets from my widgets. I tried editing the widgets.php file in the wp-includes folder by removing the beforewiget and afte...
If you want the bullet points to disappear, simply edit your themes style.css file. If you use a debugging tool you can find exactly where in style.css to edit. As you say, set list-style to none (though you might want to specify a class to ensure it doesn't effect lists where you do want bullet points.
31,007
<p>I'd like to remove the header image on all the pages except my "home"-page.</p> <p>Any ideas?</p> <p>Thks</p>
[ { "answer_id": 31017, "author": "Devise", "author_id": 3899, "author_profile": "https://wordpress.stackexchange.com/users/3899", "pm_score": 0, "selected": false, "text": "<p>Remove the header image code from your category, post, single, etc files (leaving it in the index.php file). </p>...
2011/10/13
[ "https://wordpress.stackexchange.com/questions/31007", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9414/" ]
I'd like to remove the header image on all the pages except my "home"-page. Any ideas? Thks
Edit the `header.php` file and modify the following lines (probably around line 78-82): **Before** ``` <?php // Check to see if the header image has been removed $header_image = get_header_image(); if ( ! empty( $header_image ) ) : ?> ``` **After** ``` <?...
31,012
<p>Upgraded to 3.2 from 3.1 and lost the featured image panel in admin that was running in a custom post type. </p> <pre><code>add_action( 'init', 'create_my_post_types' ); function create_my_post_types() { register_post_type( 'header_image_gallery', array( 'labels' =&gt; array( 'n...
[ { "answer_id": 31021, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 4, "selected": true, "text": "<p>Change this:</p>\n\n<pre><code>// This theme uses post thumbnails\nadd_theme_support( 'post-thumbnails', arr...
2011/10/13
[ "https://wordpress.stackexchange.com/questions/31012", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3899/" ]
Upgraded to 3.2 from 3.1 and lost the featured image panel in admin that was running in a custom post type. ``` add_action( 'init', 'create_my_post_types' ); function create_my_post_types() { register_post_type( 'header_image_gallery', array( 'labels' => array( 'name' => __( 'Head...
Change this: ``` // This theme uses post thumbnails add_theme_support( 'post-thumbnails', array('post', 'page') ); ``` To this: ``` // This theme uses post thumbnails add_theme_support( 'post-thumbnails' ); ``` The problem is that the array is *explicit*, when used. So, post-thumbnail support will *only* be added...
31,064
<p>I want to set up my template so that Pages show a list of posts where the category slug matches the page slug. So on the Page "About Us" ('about'), posts tagged with the category-slug 'about'. The sidebar should show a list of these posts (I need to hardcode this. NO PLUGINS). Index.php should show all posts, EXclud...
[ { "answer_id": 31070, "author": "Scott", "author_id": 4610, "author_profile": "https://wordpress.stackexchange.com/users/4610", "pm_score": 0, "selected": false, "text": "<p>I'm assuming that your page slug is the same as the category slug? Anyway here is the code. It should be self expl...
2011/10/14
[ "https://wordpress.stackexchange.com/questions/31064", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9288/" ]
I want to set up my template so that Pages show a list of posts where the category slug matches the page slug. So on the Page "About Us" ('about'), posts tagged with the category-slug 'about'. The sidebar should show a list of these posts (I need to hardcode this. NO PLUGINS). Index.php should show all posts, EXcluding...
If this is going in a page.php (or similar) template, then using `query_posts()` is a bad idea and could have some pretty bad consequences. I also prefer [`WP_Query`](http://codex.wordpress.org/Class_Reference/WP_Query) over `get_posts()` as it easily allows you to use template tags and it explicitly exists for running...
31,065
<p>How do I determine if I'm on the very first page of pagination? I'm using WP_Pagenavi. I want to run a function only on the first page of the pagination. I checked the query_var 'paged', it's set to 0 on this page, and then 2, 3 and so on in the later pages (1 is missing!)... Anyone knows a clean solution?</p> <p>T...
[ { "answer_id": 31069, "author": "Scott", "author_id": 4610, "author_profile": "https://wordpress.stackexchange.com/users/4610", "pm_score": 6, "selected": true, "text": "<pre><code>// get current page we are on. If not set we can assume we are on page 1.\n$paged = (get_query_var('paged')...
2011/10/14
[ "https://wordpress.stackexchange.com/questions/31065", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4740/" ]
How do I determine if I'm on the very first page of pagination? I'm using WP\_Pagenavi. I want to run a function only on the first page of the pagination. I checked the query\_var 'paged', it's set to 0 on this page, and then 2, 3 and so on in the later pages (1 is missing!)... Anyone knows a clean solution? Thanks.
``` // get current page we are on. If not set we can assume we are on page 1. $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // are we on page one? if(1 == $paged) { //true } ```
31,073
<p>I need this for menu "red car", "blue car", "green car".</p> <p>Information is retrieving from a single category (cars). But the output on pages depending on the values ​​in the metaboxes (colors). On the page with blue cars shouldn't be a green cars.</p> <p>Cars and colors for illustrative purposes only.</p> <p>...
[ { "answer_id": 31069, "author": "Scott", "author_id": 4610, "author_profile": "https://wordpress.stackexchange.com/users/4610", "pm_score": 6, "selected": true, "text": "<pre><code>// get current page we are on. If not set we can assume we are on page 1.\n$paged = (get_query_var('paged')...
2011/10/14
[ "https://wordpress.stackexchange.com/questions/31073", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5645/" ]
I need this for menu "red car", "blue car", "green car". Information is retrieving from a single category (cars). But the output on pages depending on the values ​​in the metaboxes (colors). On the page with blue cars shouldn't be a green cars. Cars and colors for illustrative purposes only. How can I do this?
``` // get current page we are on. If not set we can assume we are on page 1. $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; // are we on page one? if(1 == $paged) { //true } ```
31,077
<p>I am developing a common theme for 25 websites, the default requirements are done. Each site has got different single post template. I need to group it as a single theme so i don't need to hard-code every time and maintain a common platform.</p> <p>The various single posts template are normal-blog / tab structure /...
[ { "answer_id": 31083, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": -1, "selected": false, "text": "<p>Your question is slightly unclear, but if I'm following you correctly: you need one Theme, that has severa...
2011/10/14
[ "https://wordpress.stackexchange.com/questions/31077", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7376/" ]
I am developing a common theme for 25 websites, the default requirements are done. Each site has got different single post template. I need to group it as a single theme so i don't need to hard-code every time and maintain a common platform. The various single posts template are normal-blog / tab structure / List view...
It sounds like you want users to be able alter the structure of the single.php format without much WordPress know-how (perhaps it's for clients?). You could create an options page for this, and allow the user to select the structure they prefer. In your `functions.php` or a plugin, you use a hook to call a function...
31,089
<p>So I have several CPTs set up but I want to have all my default posts listed under /blog.</p> <p>I was hoping I could somehow enable has_archive for the default post type but I have yet to succeed.</p> <p>Any ideas? </p> <pre><code>add_action( 'init', 'enhance_post' ); function enhance_post( ) { global $wp_p...
[ { "answer_id": 31083, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": -1, "selected": false, "text": "<p>Your question is slightly unclear, but if I'm following you correctly: you need one Theme, that has severa...
2011/10/14
[ "https://wordpress.stackexchange.com/questions/31089", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8045/" ]
So I have several CPTs set up but I want to have all my default posts listed under /blog. I was hoping I could somehow enable has\_archive for the default post type but I have yet to succeed. Any ideas? ``` add_action( 'init', 'enhance_post' ); function enhance_post( ) { global $wp_post_types; $wp_post_ty...
It sounds like you want users to be able alter the structure of the single.php format without much WordPress know-how (perhaps it's for clients?). You could create an options page for this, and allow the user to select the structure they prefer. In your `functions.php` or a plugin, you use a hook to call a function...
31,100
<p>I'd like to set up my WP so that urls ending in <code>/last</code> would return the most recent post in that set of posts. For example, <code>/last</code> returns the most recent post of any type, <code>archives/category/trivia/last</code> would return the most recent post categorized as trivia, and <code>archives/...
[ { "answer_id": 31522, "author": "Manny Fleurmond", "author_id": 2234, "author_profile": "https://wordpress.stackexchange.com/users/2234", "pm_score": 2, "selected": true, "text": "<pre><code>add_action( 'init', 'ASHmostrecent_init' );\nfunction ASHmostrecent_init(){\n add_rewrite_rule...
2011/10/14
[ "https://wordpress.stackexchange.com/questions/31100", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3644/" ]
I'd like to set up my WP so that urls ending in `/last` would return the most recent post in that set of posts. For example, `/last` returns the most recent post of any type, `archives/category/trivia/last` would return the most recent post categorized as trivia, and `archives/LoomSong/last` would return the most recen...
``` add_action( 'init', 'ASHmostrecent_init' ); function ASHmostrecent_init(){ add_rewrite_rule( 'last/?$', 'index.php?post_type=post&posts_per_page=1'); } ``` A query already pulls up posts starting from the latest to the oldest, so all you have to do is limit what's returned by one. `posts_per_page` does this; ...
31,101
<p>I'm not sure if this is possible but after extensive searching I can't find an answer.</p> <p>What I want to do is to get all images from a NextGEN gallery so I can display them in a custom slideshow within a page/post.</p> <p>Is it possible to load them into an array or edit the HTML in some way?</p> <p>Any help...
[ { "answer_id": 31117, "author": "digout", "author_id": 7008, "author_profile": "https://wordpress.stackexchange.com/users/7008", "pm_score": 1, "selected": false, "text": "<p>A quick and dirty way would be to use $wpdb to get them from the wp_ngg_pictures table and the shortcode for a si...
2011/10/14
[ "https://wordpress.stackexchange.com/questions/31101", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9437/" ]
I'm not sure if this is possible but after extensive searching I can't find an answer. What I want to do is to get all images from a NextGEN gallery so I can display them in a custom slideshow within a page/post. Is it possible to load them into an array or edit the HTML in some way? Any help is greatly appreciated!
For anyone interested I found a solution to what I wanted. You simply need to create a [custom template](http://nextgen-gallery.com/templates/) Then I accessed the images like this: ``` <?php foreach ($images as $image) : ?> <?php echo do_shortcode('[singlepic id="' . $image->pid . '"]'); ?> <?php endforeach; ?> `...
31,104
<p>I have just created a custom database table and would now like to output every inserted row from it into a predefined format using a foreach statement.</p> <p>Some guidance in this matter would be great.</p> <p>Thanks, Ashley</p>
[ { "answer_id": 31113, "author": "digout", "author_id": 7008, "author_profile": "https://wordpress.stackexchange.com/users/7008", "pm_score": 0, "selected": false, "text": "<p>Use the wpdb class with something like:</p>\n\n<pre><code>global $wpdb;\n\n$results = $wpdb-&gt;get_results(\"SEL...
2011/10/14
[ "https://wordpress.stackexchange.com/questions/31104", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9017/" ]
I have just created a custom database table and would now like to output every inserted row from it into a predefined format using a foreach statement. Some guidance in this matter would be great. Thanks, Ashley
Thanks to Rutwick Gangurde, I found out how to do it. ``` <?php $mylistitems = $wpdb->get_results("SELECT * FROM wp_mytable"); foreach ( $mylistitems as $mylistitem ) { echo $currency->somefield; } ?> ```
31,108
<p>Im Getting a couple of warnings when creating custom post types, someone referred me to using a plug in but since i'm new to this i want to know what is going on so i want to do it manually. This are the warnings i get.</p> <pre><code>Warning: Missing argument 2 for _x(), called in C:\xampp\htdocs\wordpress\wp-cont...
[ { "answer_id": 31111, "author": "Rutwick Gangurde", "author_id": 4740, "author_profile": "https://wordpress.stackexchange.com/users/4740", "pm_score": 3, "selected": true, "text": "<p>Wherever you're using <code>_x('lorem')</code>, use <code>_x('lorem', 'models');</code> instead. Models ...
2011/10/14
[ "https://wordpress.stackexchange.com/questions/31108", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9439/" ]
Im Getting a couple of warnings when creating custom post types, someone referred me to using a plug in but since i'm new to this i want to know what is going on so i want to do it manually. This are the warnings i get. ``` Warning: Missing argument 2 for _x(), called in C:\xampp\htdocs\wordpress\wp-content\themes\pos...
Wherever you're using `_x('lorem')`, use `_x('lorem', 'models');` instead. Models is actually supposed to be a context, but I don't know your context, hence using models. Try this.
31,112
<p>I am trying to use wp_query (or another native Wordpress query class) to do the following:</p> <p>get all posts WHERE ( post_type = 'post' AND category = 7 ) OR ( post_type = 'case-studies' AND meta_key = 'homeslide' AND meta_value = 1 )</p> <p>I am not sure any of them can handle this yet. </p> <p><strong>Tryin...
[ { "answer_id": 31116, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 2, "selected": false, "text": "<p>For that kind of complex query, I'd recommend running two queries and then merging the results.</p>\n\n<p>First, get ...
2011/10/14
[ "https://wordpress.stackexchange.com/questions/31112", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7008/" ]
I am trying to use wp\_query (or another native Wordpress query class) to do the following: get all posts WHERE ( post\_type = 'post' AND category = 7 ) OR ( post\_type = 'case-studies' AND meta\_key = 'homeslide' AND meta\_value = 1 ) I am not sure any of them can handle this yet. **Trying with WP Query:** ``` $...
Ok I put together a solution using get\_posts & query\_posts to return the arrays for each: posts and case-studies. Then array\_merged them (thanks for the heads up EAMann), then using uasort() with a custom compare function to sort them by post\_date. It's not the most attractive solution, but since it works and I'm ...
31,124
<p>Using twenty-eleven theme, need to change default template for new page from standard to sidebar.</p> <p>anyone?</p>
[ { "answer_id": 31129, "author": "Nicole", "author_id": 8337, "author_profile": "https://wordpress.stackexchange.com/users/8337", "pm_score": 0, "selected": false, "text": "<p>If it wont mess you up you could switch the template file names. Although every time the theme is updated you wou...
2011/10/14
[ "https://wordpress.stackexchange.com/questions/31124", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9445/" ]
Using twenty-eleven theme, need to change default template for new page from standard to sidebar. anyone?
I would hook into the `new_page` action, and then use [`update_post_meta()`](http://codex.wordpress.org/Function_Reference/update_post_meta) to update the post meta value for `_wp_page_template`: ``` <?php function wpse31124_set_page_default_template( $page_id ) { update_post_meta( $page_id, '_wp_page_template', '...
31,130
<p>I am using the UserPhoto plugin which allows users to upload a photo which can be used in many ways. (It's awesome) But I would also like when the admins look at the list of users the column displays this users photo instead of the Gravatar. Is there a hook? </p> <p>I'm a little closer...</p> <pre><code>function c...
[ { "answer_id": 33080, "author": "Dimi", "author_id": 10059, "author_profile": "https://wordpress.stackexchange.com/users/10059", "pm_score": -1, "selected": false, "text": "<p>ok i solved this problem through hacking around</p>\n\n<p>in the \nwp-admin/includes/class-wp-users-list-table.p...
2011/10/14
[ "https://wordpress.stackexchange.com/questions/31130", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4418/" ]
I am using the UserPhoto plugin which allows users to upload a photo which can be used in many ways. (It's awesome) But I would also like when the admins look at the list of users the column displays this users photo instead of the Gravatar. Is there a hook? I'm a little closer... ``` function change_user_avatar_col...
Not tested, but much probably this works: Instead of trying to add/change the columns, change the `get_avatar` behavior. For one, it is a pluggable function, so it can be overridden. And second, there are many Questions in this Stack on how to modify/customize the avatars. Check this two: * [Upload gravatar in WP p...
31,162
<p>I am a newb in writing this and since this is dangerous stuff to fidlle with (if you are not sure what you are doing) can you please verify it?</p> <p>I use wordpress multisite, this is why I chose to allow blogs.dir</p> <p>I want only my posts and categories indexed. That's it:)</p> <pre><code>User-agent: * Dis...
[ { "answer_id": 33080, "author": "Dimi", "author_id": 10059, "author_profile": "https://wordpress.stackexchange.com/users/10059", "pm_score": -1, "selected": false, "text": "<p>ok i solved this problem through hacking around</p>\n\n<p>in the \nwp-admin/includes/class-wp-users-list-table.p...
2011/10/15
[ "https://wordpress.stackexchange.com/questions/31162", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2979/" ]
I am a newb in writing this and since this is dangerous stuff to fidlle with (if you are not sure what you are doing) can you please verify it? I use wordpress multisite, this is why I chose to allow blogs.dir I want only my posts and categories indexed. That's it:) ``` User-agent: * Disallow: /cron/ Disallow: /lo/...
Not tested, but much probably this works: Instead of trying to add/change the columns, change the `get_avatar` behavior. For one, it is a pluggable function, so it can be overridden. And second, there are many Questions in this Stack on how to modify/customize the avatars. Check this two: * [Upload gravatar in WP p...
31,164
<p>I have the code to remove the editor from the Appearance menu. But I can't find anyway to remove the editor from the Plugins.</p> <pre><code> // Remove Editor from Apperance Menu function remove_editor_menu() { remove_action('admin_menu', '_add_themes_utility_last', 101); } add_action('_admin_menu', 'remov...
[ { "answer_id": 31165, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 2, "selected": false, "text": "<p>Here ya go, </p>\n\n<pre><code> function my_remove_menu_elements()\n {\n remove_submenu_page( 'plugins....
2011/10/15
[ "https://wordpress.stackexchange.com/questions/31164", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4418/" ]
I have the code to remove the editor from the Appearance menu. But I can't find anyway to remove the editor from the Plugins. ``` // Remove Editor from Apperance Menu function remove_editor_menu() { remove_action('admin_menu', '_add_themes_utility_last', 101); } add_action('_admin_menu', 'remove_editor_menu'...
Here ya go, ``` function my_remove_menu_elements() { remove_submenu_page( 'plugins.php', 'plugin-editor.php' ); } add_action('admin_init', 'my_remove_menu_elements'); ```
31,178
<p>I have 3000 posts with that custom field name 'refer' and i need to change it to 'ref' for theme needs, instead of doing it manually i need a query or technique to change them all.</p> <p><strong>Question 1</strong> <br> I am trying to rename a custom field, from 'refer' to ref. what is the query needed to rename...
[ { "answer_id": 31186, "author": "Rutwick Gangurde", "author_id": 4740, "author_profile": "https://wordpress.stackexchange.com/users/4740", "pm_score": 0, "selected": false, "text": "<p>If you're trying to delete a post's custom field, then please edit your post, select '<strong>Custom Fi...
2011/10/15
[ "https://wordpress.stackexchange.com/questions/31178", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7376/" ]
I have 3000 posts with that custom field name 'refer' and i need to change it to 'ref' for theme needs, instead of doing it manually i need a query or technique to change them all. **Question 1** I am trying to rename a custom field, from 'refer' to ref. what is the query needed to rename a custom filed. it would...
I found the answer ``` UPDATE `wp_postmeta` SET `meta_key` = 'ref' WHERE `meta_key` = 'refer' ``` use this part in your SQL [Reference](https://stackoverflow.com/questions/6649285/renaming-custom-fields)
31,181
<pre><code>function the_category_filter($thelist,$separator=' ') { if(!defined('WP_ADMIN')) { //list the category names to exclude $exclude = array('Something','Something Else','Blah','YAY'); $cats = explode($separator,$thelist); $newlist = array(); foreach($cats as $cat) { ...
[ { "answer_id": 31182, "author": "Rutwick Gangurde", "author_id": 4740, "author_profile": "https://wordpress.stackexchange.com/users/4740", "pm_score": 3, "selected": false, "text": "<p>Try using the filter <code>get_the_categories</code> and replace every occurrence of <code>the_category...
2011/10/15
[ "https://wordpress.stackexchange.com/questions/31181", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8854/" ]
``` function the_category_filter($thelist,$separator=' ') { if(!defined('WP_ADMIN')) { //list the category names to exclude $exclude = array('Something','Something Else','Blah','YAY'); $cats = explode($separator,$thelist); $newlist = array(); foreach($cats as $cat) { ...
Try using the filter `get_the_categories` and replace every occurrence of `the_category` by `echo get_the_category()` (just to be sure !) This is what I cooked: ``` <?php add_filter('get_the_categories', 'exc_cat'); function exc_cat($cats) { //not on admin pages if(!is_admin()){ $exc = ar...
31,196
<p>I am using the Twenty Eleven theme and need to show the full content of the latest post and then show the rest as summary. I'm looking for instructions/help on how to display, on the home page, the full post of the most recent article and then just the summary of the older the posts.</p> <p>For Example (Post #5 bei...
[ { "answer_id": 31203, "author": "Michael", "author_id": 4884, "author_profile": "https://wordpress.stackexchange.com/users/4884", "pm_score": 3, "selected": true, "text": "<p>after creating a <a href=\"http://codex.wordpress.org/Child_Themes\" rel=\"nofollow\">child theme</a> for Twenty ...
2011/10/15
[ "https://wordpress.stackexchange.com/questions/31196", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9464/" ]
I am using the Twenty Eleven theme and need to show the full content of the latest post and then show the rest as summary. I'm looking for instructions/help on how to display, on the home page, the full post of the most recent article and then just the summary of the older the posts. For Example (Post #5 being the new...
after creating a [child theme](http://codex.wordpress.org/Child_Themes) for Twenty Eleven, copy ***content.php*** from the Twenty Eleven theme into your child theme to edit it; find (line 35): ``` <?php if ( is_search() ) : // Only display Excerpts for Search ?> ``` change to: ``` <?php if ( is_search() ||...
31,207
<p>I'm setting up a Wordpress Network and wanted all new sites to have the same permalink structure (i.e. "/%year%/%monthnum%/%postname%/"). I'm wondering if this is possible to do via hooks or hacks in functions.php, without having to rely on users to choose that structure.</p>
[ { "answer_id": 31248, "author": "soulseekah", "author_id": 9480, "author_profile": "https://wordpress.stackexchange.com/users/9480", "pm_score": 5, "selected": true, "text": "<p>You can set the permalink structure by calling on the <code>set_permalink_structure()</code> method of the glo...
2011/10/15
[ "https://wordpress.stackexchange.com/questions/31207", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5552/" ]
I'm setting up a Wordpress Network and wanted all new sites to have the same permalink structure (i.e. "/%year%/%monthnum%/%postname%/"). I'm wondering if this is possible to do via hooks or hacks in functions.php, without having to rely on users to choose that structure.
You can set the permalink structure by calling on the `set_permalink_structure()` method of the global `$wp_rewrite` object. ``` add_action( 'init', function() { global $wp_rewrite; $wp_rewrite->set_permalink_structure( '/%year%/%monthnum%/%postname%/' ); } ); ``` Here's a PHP < 5.3 version of the code in ca...
31,209
<p>Having a bit of trouble using all the Wordpress ajax hooks, and functions.</p> <p>Been reading this post: <a href="http://www.garyc40.com/2010/03/5-tips-for-using-ajax-in-wordpress/" rel="nofollow">5 Tips for Using Ajax in Wordpress</a></p> <p>But became confused after trying all the code and applying it to an Aja...
[ { "answer_id": 31219, "author": "Rutwick Gangurde", "author_id": 4740, "author_profile": "https://wordpress.stackexchange.com/users/4740", "pm_score": 3, "selected": true, "text": "<p>Things you can check:</p>\n\n<ol>\n<li>View the page source, and look for your <code>js</code> files, if...
2011/10/15
[ "https://wordpress.stackexchange.com/questions/31209", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5391/" ]
Having a bit of trouble using all the Wordpress ajax hooks, and functions. Been reading this post: [5 Tips for Using Ajax in Wordpress](http://www.garyc40.com/2010/03/5-tips-for-using-ajax-in-wordpress/) But became confused after trying all the code and applying it to an Ajax form. I am calling a function from my pl...
Things you can check: 1. View the page source, and look for your `js` files, if they're included or not, and whether their order is proper. 2. Use `console.log(SwoonAjax.ajaxurl)` to check if you're getting the proper path in your `js` file. 3. In Firebug, switch to `Console` tab, and then try firing your AJAX request...
31,221
<p>i'm working on a child theme for the "news" template.</p> <p>my problem is that there are some functions in the parent theme that are defined in different php files. these files are called in functions.php with require_once.</p> <p>i think i understand how to unload functions and define my own functions, but how d...
[ { "answer_id": 31223, "author": "chifliiiii", "author_id": 4130, "author_profile": "https://wordpress.stackexchange.com/users/4130", "pm_score": 0, "selected": false, "text": "<p>Just think of the require_once like a method to organize your functions. At the end everything is located in ...
2011/10/16
[ "https://wordpress.stackexchange.com/questions/31221", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9472/" ]
i'm working on a child theme for the "news" template. my problem is that there are some functions in the parent theme that are defined in different php files. these files are called in functions.php with require\_once. i think i understand how to unload functions and define my own functions, but how do i point the re...
The functions.php file in child themes is run *before* the parent theme's functions.php. There are a [few more details in the codex](http://codex.wordpress.org/Child_Themes#Using_functions.php). IF the parent theme follows development standards, each of their custom functions should work like this: ``` if( !function_...
31,229
<p>I've been working on this for many, many, many weeks already. I've already asked similar questions here and elsewhere, but nobody seems to be able to sovle this problem. Maybe it's not possible anyways?</p> <p>My related posts are tag based and the code looks like this:</p> <pre><code>&lt;?php ...
[ { "answer_id": 31277, "author": "Kimzi", "author_id": 9492, "author_profile": "https://wordpress.stackexchange.com/users/9492", "pm_score": 0, "selected": false, "text": "<p>You can simply try the code from here <a href=\"http://www.khapay.com/wordpress/show-related-post-wordpress.html\"...
2011/10/16
[ "https://wordpress.stackexchange.com/questions/31229", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6903/" ]
I've been working on this for many, many, many weeks already. I've already asked similar questions here and elsewhere, but nobody seems to be able to sovle this problem. Maybe it's not possible anyways? My related posts are tag based and the code looks like this: ``` <?php $backup = $post; ...
Do you mean you want to display three blocks of four related posts, and flip between the three blocks using scrollable? If so, does the below help (not tested)? Assuming scrollable needs its content in separate divs, you could do something like this. It should produce a containing div with up to three divs inside, eac...
31,234
<p>For an indie rock agenda I created event posts. With the help of javascript, the custom fields values (bands, places and date info picked in select boxes) are copied as the post title when publishing or updating the post.There is also a custom function which update the slug every time the title changes. Problem: if ...
[ { "answer_id": 31243, "author": "soulseekah", "author_id": 9480, "author_profile": "https://wordpress.stackexchange.com/users/9480", "pm_score": 1, "selected": false, "text": "<p>You'd be surprised at how tricky this one turns out to be. Closest I'm getting is hooking into the <code>save...
2011/10/16
[ "https://wordpress.stackexchange.com/questions/31234", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5702/" ]
For an indie rock agenda I created event posts. With the help of javascript, the custom fields values (bands, places and date info picked in select boxes) are copied as the post title when publishing or updating the post.There is also a custom function which update the slug every time the title changes. Problem: if an ...
**The Ajax way** (a little bit dirty, but you can easily enhance it) In your functions.php (or in a plugin, or every where else) : ``` function my_ajax_update(){ if (isset($_POST['title'])){ global $wpdb; $title = esc_sql($_POST['title']); if(!$title) return; $page = $wpdb->get_res...
31,236
<p>I've set up a custom walker, and it works as desired when I hard code my variable.</p> <p>What I want is to be able to call my walker and pass it a variable that is used in the walker.</p> <p>For example:</p> <pre><code> 'walker' =&gt; new Plus_walker($refine =&gt; 'review'), </code></pre> <p>The walke...
[ { "answer_id": 31267, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": true, "text": "<p>Native walker are triggered with <code>walk()</code> method and are not set up to receive data on creation. You can d...
2011/10/16
[ "https://wordpress.stackexchange.com/questions/31236", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6353/" ]
I've set up a custom walker, and it works as desired when I hard code my variable. What I want is to be able to call my walker and pass it a variable that is used in the walker. For example: ``` 'walker' => new Plus_walker($refine => 'review'), ``` The walker I've tweaked to output <http://URL/review> i...
Native walker are triggered with `walk()` method and are not set up to receive data on creation. You can define custom property and constructor method for this purpose: ``` class plus_walker extends Walker_Nav_Menu { var $refine; function __construct($refine) { $this->refine = $refine; } } //s...
31,247
<p>I know how to create pages automatically when a theme is activated, but I need help to figure out how to also programmatically create child pages at the same time.</p> <p>For example:</p> <pre><code>- Page 1 - Page 1.1 - Page 1.2 - Page 2 - Page 2.1 - Page 2.2 - Page 2.3 - Page 3 - Page 3.1 - Page 4 ...
[ { "answer_id": 31251, "author": "Tareq", "author_id": 7156, "author_profile": "https://wordpress.stackexchange.com/users/7156", "pm_score": 2, "selected": false, "text": "<p>As @Soulseekah said, you can do this with post_parent. I didn't test with the following code, but it should work</...
2011/10/16
[ "https://wordpress.stackexchange.com/questions/31247", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9485/" ]
I know how to create pages automatically when a theme is activated, but I need help to figure out how to also programmatically create child pages at the same time. For example: ``` - Page 1 - Page 1.1 - Page 1.2 - Page 2 - Page 2.1 - Page 2.2 - Page 2.3 - Page 3 - Page 3.1 - Page 4 - Page 4.1 - Page 4...
The example by @Tareq was very helpful, but instead of creating multiple child pages for the parent page, it would make each child page a sub-parent page. ``` Page 1 - Page 1.1 -- Page 1.2 --- Page 1.3 Page 2 - Page 2.1 -- Page 2.2 etc. ``` Here is the fixed/improved function (I'm sure that this can be imp...
31,254
<p>I'm trying to get a count of the current posts inside of a loop. I'm using multiple loops on one page in my theme. So far I have:</p> <pre><code>$my_post_count = $wp_query-&gt;post_count; </code></pre> <p>But when I print $my_post_count, it returns the number all of the posts on my WP site. Could it have something...
[ { "answer_id": 31262, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 3, "selected": false, "text": "<p>I believe the post_count is stored in the global, so before the custom loop you should set it to <code>0</code>, si...
2011/10/16
[ "https://wordpress.stackexchange.com/questions/31254", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6154/" ]
I'm trying to get a count of the current posts inside of a loop. I'm using multiple loops on one page in my theme. So far I have: ``` $my_post_count = $wp_query->post_count; ``` But when I print $my\_post\_count, it returns the number all of the posts on my WP site. Could it have something to do with using multiple ...
`$wp_query` hold main loop of page and should not be used to create multiple loops. If you are using new `WP_Query` object then your variable that holds it will have according count: ``` $my_query = new WP_Query(); // stuff $count = $my_query->post_count; ``` If you are using `get_posts()` then `WP_Query` object is...
31,255
<p>So I found some handy snippets to help remove admin menu items. However, I'm having trouble with the sub menu items. I want to keep the appearance menu, but get rid of the Themes, Widgets, and Editor. </p> <pre><code>function remove_menus() { global $menu; global $current_user; get_currentuserinfo(); if($current_us...
[ { "answer_id": 31262, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 3, "selected": false, "text": "<p>I believe the post_count is stored in the global, so before the custom loop you should set it to <code>0</code>, si...
2011/10/16
[ "https://wordpress.stackexchange.com/questions/31255", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9487/" ]
So I found some handy snippets to help remove admin menu items. However, I'm having trouble with the sub menu items. I want to keep the appearance menu, but get rid of the Themes, Widgets, and Editor. ``` function remove_menus() { global $menu; global $current_user; get_currentuserinfo(); if($current_user->user_login...
`$wp_query` hold main loop of page and should not be used to create multiple loops. If you are using new `WP_Query` object then your variable that holds it will have according count: ``` $my_query = new WP_Query(); // stuff $count = $my_query->post_count; ``` If you are using `get_posts()` then `WP_Query` object is...
31,274
<p>I would like to suppress the output of one of my custom fields. Is there a way to do this using the <code>&lt;?php the_meta(); ?&gt;</code>command?</p>
[ { "answer_id": 31276, "author": "andresmijares", "author_id": 4907, "author_profile": "https://wordpress.stackexchange.com/users/4907", "pm_score": 0, "selected": false, "text": "<p>Have you tried with <code>delete_post_meta($post_id, $key, $value);</code>?</p>\n\n<p>Since <code>the_meta...
2011/10/16
[ "https://wordpress.stackexchange.com/questions/31274", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5278/" ]
I would like to suppress the output of one of my custom fields. Is there a way to do this using the `<?php the_meta(); ?>`command?
The function, `the_meta()` allows you to hook to the `the_meta_key` filter (which currently is not documented in the Codex); this is where it fires off: ``` // wp-includes/post-templates.php @line 744 echo apply_filters('the_meta_key', "<li><span class='post-meta-key'>$key:</span> $value</li>\n", $key, $value); ``` ...
31,298
<p>I have to get some custom post types and need to do that with WP_Query (query_posts doesn't work).</p> <p>How can I do the pagination? Whatever I tried didn't work... any help would be awesome I can't crack this alone...</p> <pre><code>$args = array( 'tax_query' =&gt; array( 'posts_per_page' =&gt; 5, array(...
[ { "answer_id": 31299, "author": "Rutwick Gangurde", "author_id": 4740, "author_profile": "https://wordpress.stackexchange.com/users/4740", "pm_score": 3, "selected": true, "text": "<p>If you could tell us what you're exactly trying to achieve, we can help you better!</p>\n\n<pre><code>&l...
2011/10/17
[ "https://wordpress.stackexchange.com/questions/31298", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9499/" ]
I have to get some custom post types and need to do that with WP\_Query (query\_posts doesn't work). How can I do the pagination? Whatever I tried didn't work... any help would be awesome I can't crack this alone... ``` $args = array( 'tax_query' => array( 'posts_per_page' => 5, array( 'author' => $user_id...
If you could tell us what you're exactly trying to achieve, we can help you better! ``` <?php $paged = get_query_var('paged') ? get_query_var('paged') : 1; $args = array( 'post_type' => 'question', 'posts_per_page' => -1, 'paged' => $paged, 'author' => $user_...
31,300
<p>I have a theme that does not work in IE so I would like to be able to detect the browser and redirect to a "sorry this doesn't work for your browser" type or what ever solution you guys can suggest for this. </p> <p>Any ideas on the best way to go about this?</p>
[ { "answer_id": 31301, "author": "Rutwick Gangurde", "author_id": 4740, "author_profile": "https://wordpress.stackexchange.com/users/4740", "pm_score": 1, "selected": true, "text": "<p>Try using this code to check if it's IE (<a href=\"http://www.anyexample.com/programming/php/how_to_dete...
2011/10/17
[ "https://wordpress.stackexchange.com/questions/31300", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9500/" ]
I have a theme that does not work in IE so I would like to be able to detect the browser and redirect to a "sorry this doesn't work for your browser" type or what ever solution you guys can suggest for this. Any ideas on the best way to go about this?
Try using this code to check if it's IE ([original source](http://www.anyexample.com/programming/php/how_to_detect_internet_explorer_with_php.xml))... ``` <?php if (isset($_SERVER['HTTP_USER_AGENT']) && (strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false)) return true; else return false; ?> ...
31,308
<p>I have a really annoying problem.</p> <p>If there are no comments, comments won't show up. If there are no pingbacks, won't show up.</p> <p>However, if there are pingbacks and I have a lot of comments, so there's a page 2, page 3 etc. of comments, then the following happens: The pingbacks show up properly on <a hr...
[ { "answer_id": 31316, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": true, "text": "<p>Since you're listing pings separately from comments, you probably need to filter <code>get_comments_number</...
2011/10/17
[ "https://wordpress.stackexchange.com/questions/31308", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6903/" ]
I have a really annoying problem. If there are no comments, comments won't show up. If there are no pingbacks, won't show up. However, if there are pingbacks and I have a lot of comments, so there's a page 2, page 3 etc. of comments, then the following happens: The pingbacks show up properly on [page 1](http://www.zo...
Since you're listing pings separately from comments, you probably need to filter `get_comments_number` to exclude pings. [Here's how I do it](https://github.com/chipbennett/oenology/blob/master/functions/wordpress-hooks.php#L135): ``` <?php function oenology_comment_count( $count ) { // Only filter the comments numb...
31,317
<p>I have a menu. It has two items:</p> <ul> <li>the first is a link ("Index", www.domain.com)</li> <li>the second one is a link to a category page</li> </ul> <p>I have the requirement to remove the first link when I'm on the index page and remove the second link when I'm on that category.</p> <p>Ideas?</p>
[ { "answer_id": 31316, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": true, "text": "<p>Since you're listing pings separately from comments, you probably need to filter <code>get_comments_number</...
2011/10/17
[ "https://wordpress.stackexchange.com/questions/31317", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7200/" ]
I have a menu. It has two items: * the first is a link ("Index", www.domain.com) * the second one is a link to a category page I have the requirement to remove the first link when I'm on the index page and remove the second link when I'm on that category. Ideas?
Since you're listing pings separately from comments, you probably need to filter `get_comments_number` to exclude pings. [Here's how I do it](https://github.com/chipbennett/oenology/blob/master/functions/wordpress-hooks.php#L135): ``` <?php function oenology_comment_count( $count ) { // Only filter the comments numb...
31,333
<p>I' would like to remove the "site"-inputfield in the comment form in Wordpress twenty eleven. Someone who knows the answer? Thanks in advance.</p>
[ { "answer_id": 31336, "author": "Webord", "author_id": 454, "author_profile": "https://wordpress.stackexchange.com/users/454", "pm_score": 2, "selected": false, "text": "<p>To remove any field you should pass the $args of which fields you want to be showed in your form. </p>\n\n<p>Exempl...
2011/10/17
[ "https://wordpress.stackexchange.com/questions/31333", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9414/" ]
I' would like to remove the "site"-inputfield in the comment form in Wordpress twenty eleven. Someone who knows the answer? Thanks in advance.
To remove any field you should pass the $args of which fields you want to be showed in your form. Exemple: ``` <?php $args = array( 'fields' =>array( 'author' => '<p class="comment-form-author">' . '<label for="author">' . __( 'Name' ) . '</label> ' . ( $req ? '<span class="required">*</span>...
31,338
<p>I have been searching high and low for a way to count the amount of results from a get_users query.</p> <p>Most of what I found is to count the total number of posts in a post query, but nothing for counting the total number of users in the get_users query.</p> <p>Can someone point it out for me? Thanks a lot.</p>...
[ { "answer_id": 31340, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": true, "text": "<p>when you use <a href=\"http://codex.wordpress.org/Function_Reference/get_users\" rel=\"nofollow\"><strong><cod...
2011/10/17
[ "https://wordpress.stackexchange.com/questions/31338", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1893/" ]
I have been searching high and low for a way to count the amount of results from a get\_users query. Most of what I found is to count the total number of posts in a post query, but nothing for counting the total number of users in the get\_users query. Can someone point it out for me? Thanks a lot.
when you use [**`get_users()`**](http://codex.wordpress.org/Function_Reference/get_users) it retrieves an array of users matching the criteria given in `$args` which means you can simply use PHP's `count()` function e.g: ``` $users = get_users($args); $number_of_users = count($users); ```
31,361
<p>This is my archive page codes </p> <p>i want to avoid duplicate posts in 4th loop &amp; i want to count post in 3rd loop</p> <p>there are 4 loops</p> <p>1 first loop count : 1 post </p> <pre><code> &lt;?php $count = 1; if (have_posts()) : while (have_posts()) : the_post(); if($count == 1) : ?...
[ { "answer_id": 31362, "author": "endle.winters", "author_id": 9355, "author_profile": "https://wordpress.stackexchange.com/users/9355", "pm_score": 0, "selected": false, "text": "<p>For your 4th loop you can possibly use another query_post and offset by 7 (the first 7 posts in your other...
2011/10/18
[ "https://wordpress.stackexchange.com/questions/31361", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8503/" ]
This is my archive page codes i want to avoid duplicate posts in 4th loop & i want to count post in 3rd loop there are 4 loops 1 first loop count : 1 post ``` <?php $count = 1; if (have_posts()) : while (have_posts()) : the_post(); if($count == 1) : ?> <a href="<?php the_permalink() ?>" rel...
I would avoid this kind of excess indentation at all costs, however this should work although I haven't tested it. Please let me know if there are syntax errors so that I can correct them. ``` <!-- first loop : 1 post --> <?php if ( have_posts() ): the_post(); ?> <a href="<?php the_permalin...
31,368
<p>I have <code>WordPress 3.2.1</code> and I have created a personal shortcode, everything works fine until I change the <code>Permalink Settings</code> from <code>Default</code> to <code>Custom Structure</code>. The shortcodes stop to work permanently, instead I turn back to <code>Default</code> setting.</p> <blockqu...
[ { "answer_id": 31376, "author": "Jonathan Liuti", "author_id": 9531, "author_profile": "https://wordpress.stackexchange.com/users/9531", "pm_score": 0, "selected": false, "text": "<p>Have you tried to use the html view to paste the shortcode ? Sometimes html tags are copied when you copy...
2011/10/18
[ "https://wordpress.stackexchange.com/questions/31368", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5287/" ]
I have `WordPress 3.2.1` and I have created a personal shortcode, everything works fine until I change the `Permalink Settings` from `Default` to `Custom Structure`. The shortcodes stop to work permanently, instead I turn back to `Default` setting. > > Hello, I'm [birthday year="1975-03-25"] years old. > > > I've...
This is how your shortcode should be set up: ``` function short_birthday( $atts, $content = NULL ) { extract( shortcode_atts( array( 'year' => 'default value' ), $atts ) ); list( $Y, $m, $d ) = explode( "-", $year ); $data = date( "md" ) < $m.$d ? date( "Y" )-$Y-1 : date( "Y" )-$Y; return ...
31,386
<p>I'm using a class to retrieve values from custom tables that I need to use in different files of my WordPress Theme and im not sure which is the best approach for this.</p> <p>This is the class i got right now (dont blame as im a bit noob :D)</p> <pre><code>class Plans { public $free_plans; public $purcha...
[ { "answer_id": 31390, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>If you need a variable to be available throughout all template files, <em>globalize</em> it, and call it in...
2011/10/18
[ "https://wordpress.stackexchange.com/questions/31386", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4130/" ]
I'm using a class to retrieve values from custom tables that I need to use in different files of my WordPress Theme and im not sure which is the best approach for this. This is the class i got right now (dont blame as im a bit noob :D) ``` class Plans { public $free_plans; public $purchased_plans; priva...
The easiest way to have access to your variable in other files is to do exactly what Chip suggested, *globalize* the variable. This is the same thing WordPress does to make *global* variables like `$wpdb` available in other files. I can already see you're making calls to the global `$wpdb` variable in your class. You ...
31,407
<p>I essentially want password protected/private pages/posts in WP to work as they currently do, but completely disregard the functionality for certain IP addresses. </p> <p>I've looked into filters/actions and don't see anything that seems promising, again I would prefer to do this without creating a specific categor...
[ { "answer_id": 31390, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>If you need a variable to be available throughout all template files, <em>globalize</em> it, and call it in...
2011/10/18
[ "https://wordpress.stackexchange.com/questions/31407", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9540/" ]
I essentially want password protected/private pages/posts in WP to work as they currently do, but completely disregard the functionality for certain IP addresses. I've looked into filters/actions and don't see anything that seems promising, again I would prefer to do this without creating a specific category or anyth...
The easiest way to have access to your variable in other files is to do exactly what Chip suggested, *globalize* the variable. This is the same thing WordPress does to make *global* variables like `$wpdb` available in other files. I can already see you're making calls to the global `$wpdb` variable in your class. You ...
31,422
<p>I am currently looking at creating a new type of site archive within WordPress that allows users to filter by category AND by year rather than the default category OR year. </p> <p>I am hoping to build a sidebar widget that creates the interface but I am looking for ideas and advice on creating the custom permalink...
[ { "answer_id": 31428, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 2, "selected": false, "text": "<p>This isn't tested, but try (after you added the code you'll need to go to settings> Permalinks and click ...
2011/10/18
[ "https://wordpress.stackexchange.com/questions/31422", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3310/" ]
I am currently looking at creating a new type of site archive within WordPress that allows users to filter by category AND by year rather than the default category OR year. I am hoping to build a sidebar widget that creates the interface but I am looking for ideas and advice on creating the custom permalink setup. Id...
Following the suggestions of @StephenHarris I have developed the code a little further and come up with the following: ``` add_action('generate_rewrite_rules', 'my_rewrite_rules'); function my_rewrite_rules( $wp_rewrite ) { // handles paged/pagination requests $new_rules = array('news/(.+)/year/(.+)/page/?([2...
31,445
<p>I have a problem with output text. When I editing text in the WordPress control panel everything looks normal:</p> <p><a href="https://i.stack.imgur.com/GaIut.png" rel="nofollow noreferrer">http://i.stack.imgur.com/GaIut.png</a></p> <p>but when I output it to the html:</p> <pre><code>&lt;?php esc_html( wp_richedi...
[ { "answer_id": 31460, "author": "soulseekah", "author_id": 9480, "author_profile": "https://wordpress.stackexchange.com/users/9480", "pm_score": 1, "selected": false, "text": "<p>Assuming that <code>$_product-&gt;details</code> contains what can be referred to as <em>post content</em>, a...
2011/10/18
[ "https://wordpress.stackexchange.com/questions/31445", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9553/" ]
I have a problem with output text. When I editing text in the WordPress control panel everything looks normal: [http://i.stack.imgur.com/GaIut.png](https://i.stack.imgur.com/GaIut.png) but when I output it to the html: ``` <?php esc_html( wp_richedit_pre( $_product->details ) ); ?> ``` It looks like this: [http:/...
hmm ... strange. I looked to the file '*wp-includes/formatting.php*' on the functions *wp\_richedit\_pre*: ``` function wp_richedit_pre($text) { // Filtering a blank results in an annoying <br />\n if ( empty($text) ) return apply_filters('richedit_pre', ''); $output = convert_chars($text); $o...
31,448
<p>Another one of these paging errors you see here so often. I searched high and low for a fix but have come up with nada so far.</p> <p>I am paging CPT results using my archive-{$post_type}.php template and getting an incomplete return of posts. I have set posts_per_page to 8, and am return 3 pages to get 24 results....
[ { "answer_id": 31466, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": true, "text": "<p>I think <a href=\"http://codex.wordpress.org/Function_Reference/next_posts_link\" rel=\"nofollow\"><code>next_posts_...
2011/10/18
[ "https://wordpress.stackexchange.com/questions/31448", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6068/" ]
Another one of these paging errors you see here so often. I searched high and low for a fix but have come up with nada so far. I am paging CPT results using my archive-{$post\_type}.php template and getting an incomplete return of posts. I have set posts\_per\_page to 8, and am return 3 pages to get 24 results. There ...
I think [`next_posts_link()`](http://codex.wordpress.org/Function_Reference/next_posts_link) is using the global `$wp_query` to determine pagination, but you've created a new query here. Try passing `max_num_pages` from your `$loop` query to it: ``` next_posts_link( '<span class="nextpost">Next</span>', $loop->max_num...