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
52,752
<p>Is it possible to hide the dashboard completely from the Non-admin users and give them access to only New post and edit posts page? Thanks.</p>
[ { "answer_id": 52753, "author": "Rutwick Gangurde", "author_id": 4740, "author_profile": "https://wordpress.stackexchange.com/users/4740", "pm_score": 0, "selected": false, "text": "<p>Those 2 pages too are a part of the dashboard! If you're giving access to edit posts, means you're givi...
2012/05/21
[ "https://wordpress.stackexchange.com/questions/52752", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16307/" ]
Is it possible to hide the dashboard completely from the Non-admin users and give them access to only New post and edit posts page? Thanks.
As far as ease of use, especially for WordPress Admins not too firm in PHP, I second brasoflo's plugin recommendation ([Adminimize](http://wordpress.org/extend/plugins/adminimize/)). For the sake of completeness, this is how it'd be done programmatically: ``` /* Remove the "Dashboard" from the admin menu for non-admi...
52,774
<p>I am trying to build a custom view of categories, I want to have all 'post's show their thumbnail within a jQuery carosel (4 in each slide) , I have got it to a stage where it visually looks how I want it to look, but it's showing ALL posts rather then the category your on, I have a big feeling this is due to my cus...
[ { "answer_id": 52753, "author": "Rutwick Gangurde", "author_id": 4740, "author_profile": "https://wordpress.stackexchange.com/users/4740", "pm_score": 0, "selected": false, "text": "<p>Those 2 pages too are a part of the dashboard! If you're giving access to edit posts, means you're givi...
2012/05/21
[ "https://wordpress.stackexchange.com/questions/52774", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16318/" ]
I am trying to build a custom view of categories, I want to have all 'post's show their thumbnail within a jQuery carosel (4 in each slide) , I have got it to a stage where it visually looks how I want it to look, but it's showing ALL posts rather then the category your on, I have a big feeling this is due to my custom...
As far as ease of use, especially for WordPress Admins not too firm in PHP, I second brasoflo's plugin recommendation ([Adminimize](http://wordpress.org/extend/plugins/adminimize/)). For the sake of completeness, this is how it'd be done programmatically: ``` /* Remove the "Dashboard" from the admin menu for non-admi...
52,787
<p>I am currently calling a user's nicename in a function I have:</p> <pre><code>$users = $user_query-&gt;get_results(); foreach( $users as $user ): echo $user-&gt;user_nicename; </code></pre> <p>I'm trying to call the user's Nickname instead, but nothing I do is working such as:</p> <pre><code>echo $user-&gt;user_nick...
[ { "answer_id": 52788, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": false, "text": "<p>If you want to query <em>all</em> users, try using the <a href=\"http://codex.wordpress.org/Function_Refere...
2012/05/21
[ "https://wordpress.stackexchange.com/questions/52787", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16323/" ]
I am currently calling a user's nicename in a function I have: ``` $users = $user_query->get_results(); foreach( $users as $user ): echo $user->user_nicename; ``` I'm trying to call the user's Nickname instead, but nothing I do is working such as: ``` echo $user->user_nickname; ``` Is there a special way you have...
Try ``` echo the_author_meta( 'nickname', $current_user->ID ); ``` or you can also use; ``` $current_user = wp_get_current_user(); echo $current_user->nickname; ```
52,793
<p>I want to set up a page with a form the visitor needs to fill out and accept terms before going on to another page. Is there a plugin to do this? If no plug in, is there another way?</p> <p>Any help would be appreciated!</p> <p>Greg</p>
[ { "answer_id": 52795, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 1, "selected": false, "text": "<p>Place this into your <code>functions.php</code> file</p>\n\n<pre><code>function redirect_to($location, $status) {...
2012/05/21
[ "https://wordpress.stackexchange.com/questions/52793", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16326/" ]
I want to set up a page with a form the visitor needs to fill out and accept terms before going on to another page. Is there a plugin to do this? If no plug in, is there another way? Any help would be appreciated! Greg
I would use a shortcode for this. Wrap the content you want behind the "terms\_required" shortcode, if the user hasn't agreed to the terms, show them the form. The form would submit to a custom rewrite rule (url endpoint) that validates the form and sets a cookie if everything checks out. Let's start by wrapping ever...
52,794
<p>I've trying to get a showreel title and video id into an URL that can then be accessed by the page.</p> <p>i have the two in the same URL and it either doesn't work or only one comes in. Currently the page isn't being found ? (i am constantly flushing the permalinks)</p> <p>Url i want to get variables from will lo...
[ { "answer_id": 52797, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 2, "selected": false, "text": "<p>WordPress will strip of query variables that it doesn't understand by default. So in addition to registering your cu...
2012/05/21
[ "https://wordpress.stackexchange.com/questions/52794", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3978/" ]
I've trying to get a showreel title and video id into an URL that can then be accessed by the page. i have the two in the same URL and it either doesn't work or only one comes in. Currently the page isn't being found ? (i am constantly flushing the permalinks) Url i want to get variables from will look like directors...
This seems to work! ?**post\_type**=directors&**name**=$matches[1] seems to be the key ``` add_rewrite_rule( 'directors/([^/]*)/showreels/([^/]*)/video/([^/]*)/?', 'index.php?post_type=directors&name=$matches[1]&showreel=$matches[2]&video=$matches[3]', 'top' ); ``` so final code now; ``` function wpse13483_init() ...
52,801
<p>In a <a href="https://wordpress.stackexchange.com/q/52096/4090" title="previous question">previous question</a> I was trying to solve an issue where WordPress was using the wrong url in sortable column headers &amp; pagination in the admin when behind a proxy, the only solution that worked involved modifying core fi...
[ { "answer_id": 52802, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 5, "selected": true, "text": "<p>I threw this question around on Twitter and asked for feedback from some other core developers. My gut instinct was t...
2012/05/21
[ "https://wordpress.stackexchange.com/questions/52801", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4090/" ]
In a [previous question](https://wordpress.stackexchange.com/q/52096/4090 "previous question") I was trying to solve an issue where WordPress was using the wrong url in sortable column headers & pagination in the admin when behind a proxy, the only solution that worked involved modifying core files, specifically On li...
I threw this question around on Twitter and asked for feedback from some other core developers. My gut instinct was to make `$current_url` either filterable or generated by a function that could be overridden. This is, apparently, the wrong way about it. > > **[@markoheijnen](https://twitter.com/#!/markoheijnen):** ...
52,823
<p>I've created a custom menu using pages. For a lot of the list items, I've specified a custom menu title for the page... So, the <em>About Us</em> page becomes <em>About</em> on the menu, for example. Then, when the page title is changed, it's changing the title on the menu as well. So if I change <em>About Us</em> t...
[ { "answer_id": 52828, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": 0, "selected": false, "text": "<p>Check that the option to Automatically update Top Level Menu Item's isn't selected in the Nav Menu options ...
2012/05/21
[ "https://wordpress.stackexchange.com/questions/52823", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14700/" ]
I've created a custom menu using pages. For a lot of the list items, I've specified a custom menu title for the page... So, the *About Us* page becomes *About* on the menu, for example. Then, when the page title is changed, it's changing the title on the menu as well. So if I change *About Us* to *About Our Company* th...
Are you in Appearance > Menus? Is that what you mean by custom menu? Can you share the code you are using to make the menu display? I have this in my header: ``` wp_nav_menu( array('menu' => 'topnav' )); ``` Where topnav is the name of my custom menu. You have to add the pages to the custom menu in the "Custom Link...
52,825
<p>Is there a function that does something like:</p> <pre><code>is_in_taxonomy($term, $taxonomy) </code></pre> <p>Where it returns true if <code>$taxonomy</code> has that <code>$term</code>. ????</p> <p>Thanks!</p>
[ { "answer_id": 52826, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 1, "selected": false, "text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/term_exists\" rel=\"nofollow\"><code>term_exists</code></a>...
2012/05/21
[ "https://wordpress.stackexchange.com/questions/52825", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/325/" ]
Is there a function that does something like: ``` is_in_taxonomy($term, $taxonomy) ``` Where it returns true if `$taxonomy` has that `$term`. ???? Thanks!
You're probably looking for [**`term_exists()`**](http://codex.wordpress.org/Function_Reference/term_exists): ``` <?php term_exists( $term, $taxonomy, $parent ); ?> ``` `$term` is **required** (obviously). Both `$taxonomy` and `$parent` are optional, but if you want to determine if a *specific* taxonomy has a given...
52,840
<p>I would like to make sure no email address is published in plain. So i developed a plugin that replace all email addresses by a spambot-safe alternative.</p> <p>But some users put their email address in their blog header, outside the post loop. How can i capture and filter that? </p> <p>This works:</p> <pre><code...
[ { "answer_id": 60064, "author": "presdec", "author_id": 18639, "author_profile": "https://wordpress.stackexchange.com/users/18639", "pm_score": -1, "selected": false, "text": "<p>The short answer is that it is possible. The long answer is that you'll likely have to adjust one or the othe...
2012/05/21
[ "https://wordpress.stackexchange.com/questions/52840", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82/" ]
I would like to make sure no email address is published in plain. So i developed a plugin that replace all email addresses by a spambot-safe alternative. But some users put their email address in their blog header, outside the post loop. How can i capture and filter that? This works: ``` add_filter('the_con...
Get [redirection](http://wordpress.org/extend/plugins/redirection/) plugin to redirect the /profile.php to bbpress profile. Then there is a plugin called [admin menu editor](http://wordpress.org/extend/plugins/admin-menu-editor/) where you can completely remove the profile the admin menu (and other unwanted admin menu ...
52,878
<p>I want to keep this category title on my pages, but I don't want it to be a link.</p> <pre><code>&lt;?php echo get_the_term_list( get_the_ID(), 'portfolio_cats', ' ', ' , ', ' '); ?&gt; </code></pre> <p>Can anyone help? Thanks</p>
[ { "answer_id": 52880, "author": "Rutwick Gangurde", "author_id": 4740, "author_profile": "https://wordpress.stackexchange.com/users/4740", "pm_score": 0, "selected": false, "text": "<p>Why not use this?</p>\n\n<pre><code>&lt;?php\n$portfolio_cats = wp_get_object_terms(get_the_ID(), 'port...
2012/05/22
[ "https://wordpress.stackexchange.com/questions/52878", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16349/" ]
I want to keep this category title on my pages, but I don't want it to be a link. ``` <?php echo get_the_term_list( get_the_ID(), 'portfolio_cats', ' ', ' , ', ' '); ?> ``` Can anyone help? Thanks
You could use [`get_the_terms()`](http://codex.wordpress.org/Function_Reference/get_the_terms) and [`wp_sprintf_l()`](http://andy.wordpress.com/2011/01/05/wp_sprintf/): ``` function wpse_52878_term_list( $args = array() ) { $default = array ( 'id' => get_the_ID(), 'taxonomy' =...
52,885
<p>i can't manage to "see" the value of <code>$originalArticle</code> in <code>echo '/'.$originalArticle.'== &amp;'.$sameArticle;</code> : i tried with "global" before, but it does not work... The output is for example : </p> <blockquote> <p>/== &amp;48</p> </blockquote> <p>Any help?</p> <pre><code>&lt;div id="pos...
[ { "answer_id": 52886, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 3, "selected": true, "text": "<p>Use <code>get_the_ID()</code>, not <code>the_ID()</code>. The latter just prints the value, it does not return a value ...
2012/05/22
[ "https://wordpress.stackexchange.com/questions/52885", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8432/" ]
i can't manage to "see" the value of `$originalArticle` in `echo '/'.$originalArticle.'== &'.$sameArticle;` : i tried with "global" before, but it does not work... The output is for example : > > /== &48 > > > Any help? ``` <div id="post-<?php the_ID(); ?>" <?php post_class(); ?>> <?php $origin...
Use `get_the_ID()`, not `the_ID()`. The latter just prints the value, it does not return a value you can store in a variable. So … ``` $originalArticle = get_the_ID(); ```
52,894
<p>I can't find a comprehensive list of criteria for how WordPress determines which archive type template it chooses.</p> <p>From what I understand it uses URL forms for this purpose, like:</p> <pre><code>example.com/category/some-category -&gt; category.php (i guess tags work similarly) example.com/2012 -&gt; date.p...
[ { "answer_id": 52899, "author": "Monirul Islam", "author_id": 9456, "author_profile": "https://wordpress.stackexchange.com/users/9456", "pm_score": 0, "selected": false, "text": "<pre><code> 1. category-{slug}.php - If the category's slug were news, WordPress would look for cat...
2012/05/22
[ "https://wordpress.stackexchange.com/questions/52894", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16352/" ]
I can't find a comprehensive list of criteria for how WordPress determines which archive type template it chooses. From what I understand it uses URL forms for this purpose, like: ``` example.com/category/some-category -> category.php (i guess tags work similarly) example.com/2012 -> date.php ``` But what about aut...
WordPress [uses a Template Hierarchy](http://codex.wordpress.org/Template_Hierarchy) to determine which template file to load based on the current context: ![WordPress Template Hierarchy](https://i.stack.imgur.com/5CChj.png) This diagram is a visual representation of [`\wp-includes\template-loader.php`](http://core.t...
52,896
<p>I'm running a property site where many properties are sold in apartment blocks.</p> <p>Because of this what the content editors do is create a post/property with all the details and then use a duplicate post plugin to create the others.</p> <p>Each time they duplicate a post/property they change the title to refle...
[ { "answer_id": 52897, "author": "Eugene Manuilov", "author_id": 8170, "author_profile": "https://wordpress.stackexchange.com/users/8170", "pm_score": 5, "selected": true, "text": "<p>The easiest workaround could be:</p>\n\n<pre><code>function myplugin_update_slug( $data, $postarr ) {\n ...
2012/05/22
[ "https://wordpress.stackexchange.com/questions/52896", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4610/" ]
I'm running a property site where many properties are sold in apartment blocks. Because of this what the content editors do is create a post/property with all the details and then use a duplicate post plugin to create the others. Each time they duplicate a post/property they change the title to reflect the property n...
The easiest workaround could be: ``` function myplugin_update_slug( $data, $postarr ) { if ( ! in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) { $data['post_name'] = sanitize_title( $data['post_title'] ); } return $data; } add_filter( 'wp_insert_post_data', 'myplugin_...
52,910
<p>So Long story short, im working on a custom theme and wrapping the WP hooks onto said theme etc and i noticed that, When writing a post/page etc, that say for example i want to make a word bold/italic etc, That applied styles dont come through.</p> <p>So for example, say i select a word, click the "B" icon to make ...
[ { "answer_id": 52897, "author": "Eugene Manuilov", "author_id": 8170, "author_profile": "https://wordpress.stackexchange.com/users/8170", "pm_score": 5, "selected": true, "text": "<p>The easiest workaround could be:</p>\n\n<pre><code>function myplugin_update_slug( $data, $postarr ) {\n ...
2012/05/22
[ "https://wordpress.stackexchange.com/questions/52910", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12944/" ]
So Long story short, im working on a custom theme and wrapping the WP hooks onto said theme etc and i noticed that, When writing a post/page etc, that say for example i want to make a word bold/italic etc, That applied styles dont come through. So for example, say i select a word, click the "B" icon to make the word b...
The easiest workaround could be: ``` function myplugin_update_slug( $data, $postarr ) { if ( ! in_array( $data['post_status'], array( 'draft', 'pending', 'auto-draft' ) ) ) { $data['post_name'] = sanitize_title( $data['post_title'] ); } return $data; } add_filter( 'wp_insert_post_data', 'myplugin_...
52,916
<p>I have been having problems with my website and as a result did a Crawl test in SEOmoz. The test found a 301 Permanently Moved Redirect of all the pages on the website and it appears that they are redirected back to themselves?</p> <p>After completing a crawl of my website I found that there is this huge amount of ...
[ { "answer_id": 52927, "author": "Satish Gandham", "author_id": 2193, "author_profile": "https://wordpress.stackexchange.com/users/2193", "pm_score": 0, "selected": false, "text": "<p>Delete your htaccess file and update your permalinks option and see if it fixes the problem.</p>\n" }, ...
2012/05/22
[ "https://wordpress.stackexchange.com/questions/52916", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16360/" ]
I have been having problems with my website and as a result did a Crawl test in SEOmoz. The test found a 301 Permanently Moved Redirect of all the pages on the website and it appears that they are redirected back to themselves? After completing a crawl of my website I found that there is this huge amount of what appea...
I know that this is an ancient thread but I ran across it searching for the exact solution in March 2017. I hope this solution is the trial fix that works for someone and saves a little sanity. I posted it in the X Theme support forum since I had been asking for help there, and decided that it needed wider exposure. T...
52,938
<p>I'm using WPAlchemy on a project.</p> <p>For a template, I need to use a custom metabox which is working fine with a tinyMCE editor.</p> <p>Code to insert the meta box on the template (this is a piece of code from <a href="https://github.com/helgatheviking/WP-Alchemy-Holy-Grail-Theme/" rel="nofollow noreferrer">ht...
[ { "answer_id": 52927, "author": "Satish Gandham", "author_id": 2193, "author_profile": "https://wordpress.stackexchange.com/users/2193", "pm_score": 0, "selected": false, "text": "<p>Delete your htaccess file and update your permalinks option and see if it fixes the problem.</p>\n" }, ...
2012/05/22
[ "https://wordpress.stackexchange.com/questions/52938", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9458/" ]
I'm using WPAlchemy on a project. For a template, I need to use a custom metabox which is working fine with a tinyMCE editor. Code to insert the meta box on the template (this is a piece of code from <https://github.com/helgatheviking/WP-Alchemy-Holy-Grail-Theme/> because I end up trying it after a looooog search, bu...
I know that this is an ancient thread but I ran across it searching for the exact solution in March 2017. I hope this solution is the trial fix that works for someone and saves a little sanity. I posted it in the X Theme support forum since I had been asking for help there, and decided that it needed wider exposure. T...
53,005
<p>I've included the code I'm working with below. I had some custom work done on a wordpress site of mine. This is a page that shows an list of the categories along with images and a short description. I'm not quite sure how to go about exclude a single category from showing up on this page. </p> <p>This is a media si...
[ { "answer_id": 53006, "author": "Nasir Zia", "author_id": 16309, "author_profile": "https://wordpress.stackexchange.com/users/16309", "pm_score": 0, "selected": false, "text": "<p>you can use this code...</p>\n\n<pre><code>&lt;?php $categories = get_categories( $args ); ?&gt; \n\n&lt;?ph...
2012/05/23
[ "https://wordpress.stackexchange.com/questions/53005", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16384/" ]
I've included the code I'm working with below. I had some custom work done on a wordpress site of mine. This is a page that shows an list of the categories along with images and a short description. I'm not quite sure how to go about exclude a single category from showing up on this page. This is a media site, so all...
If everything else is doing what you want, change this line: ``` $categories = get_categories('hide_empty=0'); ``` To this: ``` $categories = get_categories('hide_empty=0&exclude=10'); ``` Swap '10' with the category number you want to exclude.
53,015
<p>I have a <a href="http://eren.0fees.net/blog/" rel="nofollow">blog</a> that is working on wordpress installation and now I want to transfer it to the my new blog under WordPress.com domain name. Is it possible to carry all the content to new WordPress blog?</p>
[ { "answer_id": 53006, "author": "Nasir Zia", "author_id": 16309, "author_profile": "https://wordpress.stackexchange.com/users/16309", "pm_score": 0, "selected": false, "text": "<p>you can use this code...</p>\n\n<pre><code>&lt;?php $categories = get_categories( $args ); ?&gt; \n\n&lt;?ph...
2012/05/22
[ "https://wordpress.stackexchange.com/questions/53015", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16391/" ]
I have a [blog](http://eren.0fees.net/blog/) that is working on wordpress installation and now I want to transfer it to the my new blog under WordPress.com domain name. Is it possible to carry all the content to new WordPress blog?
If everything else is doing what you want, change this line: ``` $categories = get_categories('hide_empty=0'); ``` To this: ``` $categories = get_categories('hide_empty=0&exclude=10'); ``` Swap '10' with the category number you want to exclude.
53,021
<p>I try this:<br></p> <pre><code>add_action('admin_print_scripts', 'custom_admin_scripts' ); function custom_admin_scripts() { echo '&lt;script type="text/javascript" src="' . get_bloginfo('stylesheet_directory') . /admin-scripts.js"&gt;&lt;/script&gt;'; } </code></pre> <p>but by this way it doesn't recogni...
[ { "answer_id": 53023, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 4, "selected": true, "text": "<p>The problem is that you are loading your script before jQuery has been loaded.</p>\n\n<p><strong>Do not pr...
2012/05/23
[ "https://wordpress.stackexchange.com/questions/53021", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16331/" ]
I try this: ``` add_action('admin_print_scripts', 'custom_admin_scripts' ); function custom_admin_scripts() { echo '<script type="text/javascript" src="' . get_bloginfo('stylesheet_directory') . /admin-scripts.js"></script>'; } ``` but by this way it doesn't recognize jQuery. So I get `Uncaught ReferenceE...
The problem is that you are loading your script before jQuery has been loaded. **Do not print scripts directly**. You should (register and then) enqueue them using the provided API. jQuery is already a registered script, so you can just enqueue it (say on the `admin_enqueue_scripts` hook). However you only need to ...
53,027
<p>I'm trying to get a list of posts from one category, echo the title and the permalink of all posts on that category but exclude the permalink and the post name IF the current post is on that list.</p> <p>It will be displayed on single.php after or inside the loop</p> <p>Anyone knows if it is possible, if so how?</...
[ { "answer_id": 53031, "author": "Johannes Pille", "author_id": 9745, "author_profile": "https://wordpress.stackexchange.com/users/9745", "pm_score": 4, "selected": true, "text": "<p>First off, note that, since your custom loop is a secondary loop/query, you should use the <a href=\"http:...
2012/05/23
[ "https://wordpress.stackexchange.com/questions/53027", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15704/" ]
I'm trying to get a list of posts from one category, echo the title and the permalink of all posts on that category but exclude the permalink and the post name IF the current post is on that list. It will be displayed on single.php after or inside the loop Anyone knows if it is possible, if so how? Thanks in advance...
First off, note that, since your custom loop is a secondary loop/query, you should use the [`WP_Query`](http://codex.wordpress.org/Function_Reference/WP_Query) class instead of `query_posts()`. [Read why](https://wordpress.stackexchange.com/questions/1753/when-should-you-use-wp-query-vs-query-posts-vs-get-posts). That...
53,029
<p>I have a problem with search queries. Anytime you put additional queries, like:</p> <blockquote> <p>mywebsite.com/?s=wordpress&amp;post_type=page</p> <p>mywebsite.com/?s=wordpress&amp;post_type=page,post </p> <p>mywebsite.net/?s=wordpress&amp;cat=1</p> <p>mywebsite.net/?s=wordpress&amp;post_type=po...
[ { "answer_id": 53031, "author": "Johannes Pille", "author_id": 9745, "author_profile": "https://wordpress.stackexchange.com/users/9745", "pm_score": 4, "selected": true, "text": "<p>First off, note that, since your custom loop is a secondary loop/query, you should use the <a href=\"http:...
2012/05/23
[ "https://wordpress.stackexchange.com/questions/53029", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16393/" ]
I have a problem with search queries. Anytime you put additional queries, like: > > mywebsite.com/?s=wordpress&post\_type=page > > > mywebsite.com/?s=wordpress&post\_type=page,post > > > mywebsite.net/?s=wordpress&cat=1 > > > mywebsite.net/?s=wordpress&post\_type=post&tag=genesis-post > > > mywebsite.net/?s=...
First off, note that, since your custom loop is a secondary loop/query, you should use the [`WP_Query`](http://codex.wordpress.org/Function_Reference/WP_Query) class instead of `query_posts()`. [Read why](https://wordpress.stackexchange.com/questions/1753/when-should-you-use-wp-query-vs-query-posts-vs-get-posts). That...
53,035
<p>Is there a way to add a banner to the WP dashboard? I don't mean in a custom widget or anything, just a simple image banner.</p>
[ { "answer_id": 53079, "author": "kingkool68", "author_id": 2744, "author_profile": "https://wordpress.stackexchange.com/users/2744", "pm_score": 0, "selected": false, "text": "<p>You could hook into the <code>admin_head</code> action and include some custom CSS to attach a background ima...
2012/05/23
[ "https://wordpress.stackexchange.com/questions/53035", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16394/" ]
Is there a way to add a banner to the WP dashboard? I don't mean in a custom widget or anything, just a simple image banner.
Workaround using jQuery DOM insertion. *Note the use of PHP [Heredoc sintax](http://php.net/manual/en/language.types.string.php) to print the script.* ``` function wpse_53035_script_enqueuer(){ echo <<<HTML <script type="text/javascript"> jQuery(document).ready( function($) { $('<div style="widt...
53,048
<p>I am interested in:</p> <ol> <li>how can we change the default login url <code>/wp-admin</code> to <code>/login</code></li> <li>how can we add another url for login so that both <code>/wp-admin</code> and <code>/login</code> would work</li> </ol> <p>I tried to use a custom filter and .htaccess as in the following ...
[ { "answer_id": 53059, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 1, "selected": false, "text": "<p>I use just this at the top of my .htaccess file:<br>\n<code>RewriteRule ^login/?$ /wp-login.php [NC,L]</code...
2012/05/23
[ "https://wordpress.stackexchange.com/questions/53048", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13375/" ]
I am interested in: 1. how can we change the default login url `/wp-admin` to `/login` 2. how can we add another url for login so that both `/wp-admin` and `/login` would work I tried to use a custom filter and .htaccess as in the following example but without success. functions.php ``` add_filter('admin_url', 'my_...
another option - redirect `/admin/` to `wp-login.php` with a `parse_query` action hook: ``` function wpa53048_parse_query( $query ){ if( $query->query_vars['pagename'] == 'admin' ): wp_redirect( wp_login_url() ); exit; endif; } add_action( 'parse_query', 'wpa53048_parse_query' ); ``` **EDIT**...
53,052
<p>In <a href="http://html5boilerplate.com/" rel="nofollow">HTML5 Boilerplate</a> it Grab Google CDN's jQuery with this JS code </p> <pre><code>&lt;!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline --&gt; &lt;script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js...
[ { "answer_id": 53072, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": false, "text": "<p>Scripts don't get <strong>printed</strong> at the <code>wp_enqueue_scripts</code> hook, but rather at the <...
2012/05/23
[ "https://wordpress.stackexchange.com/questions/53052", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12076/" ]
In [HTML5 Boilerplate](http://html5boilerplate.com/) it Grab Google CDN's jQuery with this JS code ``` <!-- Grab Google CDN's jQuery, with a protocol relative URL; fall back to local if offline --> <script src="//ajax.googleapis.com/ajax/libs/jquery/1.7.1/jquery.min.js"></script> <script>window.jQuery || document.wri...
Scripts don't get **printed** at the `wp_enqueue_scripts` hook, but rather at the `wp_print_scripts` hook. That said: **don't echo/print scripts, period**. Instead, **enqueue** them properly. **Caveat**: This method is Plugin territory, and should not be included as Theme code in a publicly distributed Theme. You *de...
53,069
<p>I wish to export all of my posts as individual plain text files. So, the format may be something like:</p> <pre><code>title.txt </code></pre> <p>&nbsp;</p> <pre><code>Title: title Pub date: date Category: cat Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et ...
[ { "answer_id": 53071, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 2, "selected": false, "text": "<p>A cursory search doesn't turn up any plugins that do this ... but you could use the built-in exporter as an example f...
2012/05/23
[ "https://wordpress.stackexchange.com/questions/53069", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16406/" ]
I wish to export all of my posts as individual plain text files. So, the format may be something like: ``` title.txt ``` ``` Title: title Pub date: date Category: cat Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et ``` Is this possible? Is there a plugin or ...
Try this (you may need to bootstrap WP by loading `wp-load.php`, depending on where you put this code). ``` $args = array( 'post_type' => 'post', 'post_status' => 'publish', //'posts_per_page' => -1 //uncomment this to get all posts ); $query = new WP_Query($args); while ( $query->have_posts() ) : $query-...
53,091
<p>Shopify's Cycle lets you alternate between things within a loop. Here's my example:</p> <pre><code> &lt;div class="{% cycle 'first', 'second', 'third' %}"&gt; {% include 'product-grid-item' %} &lt;/div&gt; </code></pre> <p>My question, is there anything like this for Wordpress? I'd love to be able to ...
[ { "answer_id": 53085, "author": "kingkool68", "author_id": 2744, "author_profile": "https://wordpress.stackexchange.com/users/2744", "pm_score": 2, "selected": false, "text": "<p>Have you tried the External Database Authentication plugin? Just because it hasn't been updated in a while do...
2012/05/23
[ "https://wordpress.stackexchange.com/questions/53091", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15695/" ]
Shopify's Cycle lets you alternate between things within a loop. Here's my example: ``` <div class="{% cycle 'first', 'second', 'third' %}"> {% include 'product-grid-item' %} </div> ``` My question, is there anything like this for Wordpress? I'd love to be able to cycle through some kind of setting - s...
You can override the core wp\_authenticate function. You would need to create a custom plugin and declare a new version of wp\_authenticate. The function accepts a username and a password and returns a WP $user object. wp\_authenticate is a 'pluggable' function and it is found in the wp-includes/pluggable.php file.
53,094
<p>The order of categories on dashboard is alphabetical. Can I change it to custom order?</p>
[ { "answer_id": 53097, "author": "user1337", "author_id": 16338, "author_profile": "https://wordpress.stackexchange.com/users/16338", "pm_score": -1, "selected": false, "text": "<p>There's no default option for it, but there's two other ways.</p>\n\n<ol>\n<li>Change it in the theme files ...
2012/05/23
[ "https://wordpress.stackexchange.com/questions/53094", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16331/" ]
The order of categories on dashboard is alphabetical. Can I change it to custom order?
Found an answer in [this answer](https://wordpress.stackexchange.com/a/30963/12615). ``` add_filter( 'get_terms_args', 'wpse_53094_sort_get_terms_args', 10, 2 ); function wpse_53094_sort_get_terms_args( $args, $taxonomies ) { global $pagenow; if( !is_admin() || ('post.php' != $pagenow && 'post-new.php' != $pa...
53,106
<p>I'm a little new to Wordpress and the JSON API so forgive me if this is a newbie question but i'm trying to get <em>all</em> of the posts of a few different custom post types and return them as JSON via my own JSON controller (extending the JSON API)</p> <p>if I do this:</p> <pre><code>$posts = $json_api-&gt;intro...
[ { "answer_id": 53148, "author": "Alex", "author_id": 14485, "author_profile": "https://wordpress.stackexchange.com/users/14485", "pm_score": 2, "selected": true, "text": "<p>I'm answering my own question because it might be useful to someone else sometime.</p>\n\n<p>After reading through...
2012/05/23
[ "https://wordpress.stackexchange.com/questions/53106", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14485/" ]
I'm a little new to Wordpress and the JSON API so forgive me if this is a newbie question but i'm trying to get *all* of the posts of a few different custom post types and return them as JSON via my own JSON controller (extending the JSON API) if I do this: ``` $posts = $json_api->introspector->get_posts(array('post_...
I'm answering my own question because it might be useful to someone else sometime. After reading through the somewhat sparse documentation on the wordpress plugin directory and getting nowhere. I found a variable in the JSON API code here's how it works PS -1 just mean "all": ``` $json_api->query->count=-1; $posts = ...
53,109
<p>I am working on a plugin where the user can define shortcode tags himself. What would you suggest to allow in there? My thought is only allow ascii characters.</p> <p>So how do I sanitize? <code>strip_tags</code> and then regex to allow only <code>a-z, 0-9</code> or is there a better solution? Does WordPress have f...
[ { "answer_id": 53120, "author": "Jeremy", "author_id": 15519, "author_profile": "https://wordpress.stackexchange.com/users/15519", "pm_score": 2, "selected": false, "text": "<p>It seems WordPress has <a href=\"http://codex.wordpress.org/Shortcode_API#Hyphens\" rel=\"nofollow\">some issue...
2012/05/23
[ "https://wordpress.stackexchange.com/questions/53109", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15642/" ]
I am working on a plugin where the user can define shortcode tags himself. What would you suggest to allow in there? My thought is only allow ascii characters. So how do I sanitize? `strip_tags` and then regex to allow only `a-z, 0-9` or is there a better solution? Does WordPress have filter for that? Could I maybe us...
You can use almost every character. Just the character `/` is dangerous. Do not allow it. WordPress is using [`preg_quote`](http://php.net/preg-quote) to escape the shortcode name, but it doesn't include its own regex delimiter `/` when doing that. So the shortcode will not be properly escaped and you get a PHP warning...
53,122
<p>I am using a wordpress plugin called "<a href="http://wordpress.org/extend/plugins/add-linked-images-to-gallery-v01/" rel="nofollow">Add Linked Images To Gallery</a>" in order to save a local copy of images posted on my site. I uploaded all my files in a different hosting and I was testing this plugin in localhost t...
[ { "answer_id": 53139, "author": "user983248", "author_id": 15704, "author_profile": "https://wordpress.stackexchange.com/users/15704", "pm_score": 0, "selected": false, "text": "<p>Try replacing:</p>\n\n<pre><code>rename($file_array['tmp_name'], $file_array['tmp_name'] . $ext);\n</code><...
2012/05/24
[ "https://wordpress.stackexchange.com/questions/53122", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15061/" ]
I am using a wordpress plugin called "[Add Linked Images To Gallery](http://wordpress.org/extend/plugins/add-linked-images-to-gallery-v01/)" in order to save a local copy of images posted on my site. I uploaded all my files in a different hosting and I was testing this plugin in localhost to see if it does the job . ...
Use [`sanitize_file_name( $filename )`](http://queryposts.com/function/sanitize_file_name/). This function doesn't just catch white space, it removes other special characters too: ``` $special_chars = array( "?", "[", "]", "/", "\\", "=", "<", ">", ":", ";", ",", "'", "\"", "&", "$", "#", "*", "(", ")", "|", ...
53,144
<p>I'm using a custom search filter (using my custom query var <code>type</code>), like so:</p> <pre><code>function fteh_pre_get_posts( $query ){ if( isset( $query-&gt;query_vars['type'] ) ) $types = explode( ',', $query-&gt;query_vars['type'] ); $query-&gt;set( 'post_type', $types ); return $...
[ { "answer_id": 53147, "author": "Sisir", "author_id": 3094, "author_profile": "https://wordpress.stackexchange.com/users/3094", "pm_score": 4, "selected": false, "text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/is_main_query\" rel=\"noreferrer\"><code>is_main_query...
2012/05/24
[ "https://wordpress.stackexchange.com/questions/53144", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16393/" ]
I'm using a custom search filter (using my custom query var `type`), like so: ``` function fteh_pre_get_posts( $query ){ if( isset( $query->query_vars['type'] ) ) $types = explode( ',', $query->query_vars['type'] ); $query->set( 'post_type', $types ); return $query; } if ( ! is_admin() ) { ...
Use [`is_main_query()`](http://codex.wordpress.org/Function_Reference/is_main_query) to modify only the main query so menu will stay not affected. **Try This:** ``` add_action( 'pre_get_posts', 'fteh_pre_get_posts' ); function fteh_pre_get_posts( $query ){ if( !is_admin() && $query->is_main_query() && is...
53,152
<p>I'm new to template editing in wordpress and I'm trying to get a page description to show up on my site but it is not appearing. The URL I'm trying to get to display the description is here:</p> <p><a href="http://fourwallsla.com/category/the-neighborhood/east-side/" rel="nofollow noreferrer">http://fourwallsla.com...
[ { "answer_id": 53147, "author": "Sisir", "author_id": 3094, "author_profile": "https://wordpress.stackexchange.com/users/3094", "pm_score": 4, "selected": false, "text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/is_main_query\" rel=\"noreferrer\"><code>is_main_query...
2012/05/24
[ "https://wordpress.stackexchange.com/questions/53152", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16435/" ]
I'm new to template editing in wordpress and I'm trying to get a page description to show up on my site but it is not appearing. The URL I'm trying to get to display the description is here: <http://fourwallsla.com/category/the-neighborhood/east-side/> and I've attached the screenshot of the page description within w...
Use [`is_main_query()`](http://codex.wordpress.org/Function_Reference/is_main_query) to modify only the main query so menu will stay not affected. **Try This:** ``` add_action( 'pre_get_posts', 'fteh_pre_get_posts' ); function fteh_pre_get_posts( $query ){ if( !is_admin() && $query->is_main_query() && is...
53,155
<p>I'm running WordPress 3.3.2 with my own custom-built theme that has 4 custom post types. Currently, I'm looking for a way to replace the search link from <code>example.com/blog/?s=findme</code> with <code>example.com/search/findme</code>.</p> <p>I've seen that WordPress already has the possibility to generate searc...
[ { "answer_id": 53147, "author": "Sisir", "author_id": 3094, "author_profile": "https://wordpress.stackexchange.com/users/3094", "pm_score": 4, "selected": false, "text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/is_main_query\" rel=\"noreferrer\"><code>is_main_query...
2012/05/24
[ "https://wordpress.stackexchange.com/questions/53155", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14288/" ]
I'm running WordPress 3.3.2 with my own custom-built theme that has 4 custom post types. Currently, I'm looking for a way to replace the search link from `example.com/blog/?s=findme` with `example.com/search/findme`. I've seen that WordPress already has the possibility to generate search results by using the pretty pe...
Use [`is_main_query()`](http://codex.wordpress.org/Function_Reference/is_main_query) to modify only the main query so menu will stay not affected. **Try This:** ``` add_action( 'pre_get_posts', 'fteh_pre_get_posts' ); function fteh_pre_get_posts( $query ){ if( !is_admin() && $query->is_main_query() && is...
53,180
<p><a href="http://dyluxept.com/blog/" rel="nofollow">Live site.</a></p> <p>My blog page is showing only the very first published page, and not the subsequent posts. I've noticed, too, that when viewing the page source, the blog page seems to be using single.php instead of index.php which is what I've set the template...
[ { "answer_id": 53183, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": true, "text": "<p>It appears that <code>blog.php</code> is <a href=\"http://codex.wordpress.org/Pages#Creating_Your_Own_Page_T...
2012/05/24
[ "https://wordpress.stackexchange.com/questions/53180", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14606/" ]
[Live site.](http://dyluxept.com/blog/) My blog page is showing only the very first published page, and not the subsequent posts. I've noticed, too, that when viewing the page source, the blog page seems to be using single.php instead of index.php which is what I've set the template to be. Could this be the issue? Be...
It appears that `blog.php` is [a custom static page template](http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates), yes? If so, then the primary loop will display the **post content of the static page** to which it is applied. If you want to create a custom page template that displays blog posts, you wi...
53,194
<p>Due to a complex multisite config, I have a query which combines the posts from two blogs and I would like to <strong>paginate the results</strong>. I am grateful for any help. I have posted my query.</p> <pre><code> $latestposts = $wpdb-&gt;get_results( " (SELECT * FROM net_5_po...
[ { "answer_id": 53195, "author": "getWeberForStackExchange", "author_id": 5927, "author_profile": "https://wordpress.stackexchange.com/users/5927", "pm_score": 5, "selected": true, "text": "<h2>Update</h2>\n\n<p>I've tested this and it works on my site. A few things:</p>\n\n<ul>\n<li>Repl...
2012/05/24
[ "https://wordpress.stackexchange.com/questions/53194", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15069/" ]
Due to a complex multisite config, I have a query which combines the posts from two blogs and I would like to **paginate the results**. I am grateful for any help. I have posted my query. ``` $latestposts = $wpdb->get_results( " (SELECT * FROM net_5_posts INNER JOIN net...
Update ------ I've tested this and it works on my site. A few things: * Replace my `$query` with yours * `global $wpdb` (per your comment regarding global variables) since it's out of scope! * `get_results()` returns an object when not told otherwise (second parameter is the return type) * I placed this in a plugin, ...
53,208
<p>I browsed through the suggested posts, and couldn't find anything that was exactly answering my question. I apologize in advance if I'm reposting something obvious here, but there you have it.</p> <p>I want to make a theme that makes it easy to hand-craft my (single page) posts as if I was living without a CMS at a...
[ { "answer_id": 53195, "author": "getWeberForStackExchange", "author_id": 5927, "author_profile": "https://wordpress.stackexchange.com/users/5927", "pm_score": 5, "selected": true, "text": "<h2>Update</h2>\n\n<p>I've tested this and it works on my site. A few things:</p>\n\n<ul>\n<li>Repl...
2012/05/24
[ "https://wordpress.stackexchange.com/questions/53208", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16447/" ]
I browsed through the suggested posts, and couldn't find anything that was exactly answering my question. I apologize in advance if I'm reposting something obvious here, but there you have it. I want to make a theme that makes it easy to hand-craft my (single page) posts as if I was living without a CMS at all. I do s...
Update ------ I've tested this and it works on my site. A few things: * Replace my `$query` with yours * `global $wpdb` (per your comment regarding global variables) since it's out of scope! * `get_results()` returns an object when not told otherwise (second parameter is the return type) * I placed this in a plugin, ...
53,216
<p>Here's what I am trying to do:</p> <p>I am trying to get one page in wordpress to pull data from custom fields in other pages. So that when a user creates a page and uses a particular custom field (in this case multiedit_Info), it will populate in the "target" page.</p> <p>Here's my code that I am working with:</...
[ { "answer_id": 53217, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 2, "selected": false, "text": "<p>When you set the third parameter of <code>get_post_meta()</code> to <code>false</code>, it returns an array of all th...
2012/05/24
[ "https://wordpress.stackexchange.com/questions/53216", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16452/" ]
Here's what I am trying to do: I am trying to get one page in wordpress to pull data from custom fields in other pages. So that when a user creates a page and uses a particular custom field (in this case multiedit\_Info), it will populate in the "target" page. Here's my code that I am working with: ``` <?php $item =...
When you set the third parameter of `get_post_meta()` to `false`, it returns an array of all the values mapped to that key - setting this parameter to `true` returns a single value. So your code is correct. You'd get the exact same thing if you did something like this: ``` $test = array( "1", "2", "3" ); echo $test; ...
53,260
<p>why if im add size like :</p> <pre><code>add_image_size( 'featured1', 466, 316, false); add_image_size( 'featured2', 466, 260, false); </code></pre> <p>the seconde size Does not generated</p> <p>What is the problem ?</p>
[ { "answer_id": 53291, "author": "MathSmath", "author_id": 1537, "author_profile": "https://wordpress.stackexchange.com/users/1537", "pm_score": 2, "selected": true, "text": "<p>Probably because your sizes both have the same width, and you have it set to \"proportional crop\", which won't...
2012/05/25
[ "https://wordpress.stackexchange.com/questions/53260", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16468/" ]
why if im add size like : ``` add_image_size( 'featured1', 466, 316, false); add_image_size( 'featured2', 466, 260, false); ``` the seconde size Does not generated What is the problem ?
Probably because your sizes both have the same width, and you have it set to "proportional crop", which won't necessarily crop to your *exact* dimensions. ([See the Codex](http://codex.wordpress.org/Function_Reference/add_image_size)) In all likelihood, it *is* actually creating both images--but they're both the exact...
53,261
<p>I added a .htaccess file to a wordpress website I'm working on, to show nice urls instead of page ids.</p> <p>The content of the .htaccess is this:</p> <pre><code>&lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /ind...
[ { "answer_id": 53291, "author": "MathSmath", "author_id": 1537, "author_profile": "https://wordpress.stackexchange.com/users/1537", "pm_score": 2, "selected": true, "text": "<p>Probably because your sizes both have the same width, and you have it set to \"proportional crop\", which won't...
2012/05/25
[ "https://wordpress.stackexchange.com/questions/53261", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13206/" ]
I added a .htaccess file to a wordpress website I'm working on, to show nice urls instead of page ids. The content of the .htaccess is this: ``` <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.php [L] </IfModule> ```...
Probably because your sizes both have the same width, and you have it set to "proportional crop", which won't necessarily crop to your *exact* dimensions. ([See the Codex](http://codex.wordpress.org/Function_Reference/add_image_size)) In all likelihood, it *is* actually creating both images--but they're both the exact...
53,262
<pre><code>$term_id .= $_POST['main_brand_id']; $term = get_term( $term_id, 'state' ); $slug = $term-&gt;slug; global $post; $args = array( 'post_type' =&gt;'dealers','taxonomy'=&gt;'state', 'term' =&gt; $slug ); $myposts = get_posts( $args ); foreach( $myposts as $post )...
[ { "answer_id": 53263, "author": "Chris_O", "author_id": 251, "author_profile": "https://wordpress.stackexchange.com/users/251", "pm_score": 2, "selected": true, "text": "<p><code>$post-&gt;id</code> needs to be <code>$post-&gt;ID</code></p>\n\n<p>You can also use <code>get_the_ID()</code...
2012/05/25
[ "https://wordpress.stackexchange.com/questions/53262", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14583/" ]
``` $term_id .= $_POST['main_brand_id']; $term = get_term( $term_id, 'state' ); $slug = $term->slug; global $post; $args = array( 'post_type' =>'dealers','taxonomy'=>'state', 'term' => $slug ); $myposts = get_posts( $args ); foreach( $myposts as $post ) : setup_postdata(...
`$post->id` needs to be `$post->ID` You can also use `get_the_ID()` Since your calling `setup_postdata()` you need to call `wp_reset_postdata()` after your foreach loop. You also need to echo the value of $options somewhere. ``` foreach( $myposts as $post ) : setup_postdata($post); $options .= '<o...
53,280
<p>I am using the Woocommerce plugin to facilitate a small e-commerce part of a site and need to add products to its cart via some call or function rather than using its own 'add-to-cart' buttons.</p> <p>By this I basically mean send Woocommerce a SKU and quantity for example and have the cart update.</p> <pre><code>...
[ { "answer_id": 53276, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>If you hard-coded your custom query directly in the page template, then you're going to need to duplicate t...
2012/05/25
[ "https://wordpress.stackexchange.com/questions/53280", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16467/" ]
I am using the Woocommerce plugin to facilitate a small e-commerce part of a site and need to add products to its cart via some call or function rather than using its own 'add-to-cart' buttons. By this I basically mean send Woocommerce a SKU and quantity for example and have the cart update. ``` sendToCart('123456', ...
If you hard-coded your custom query directly in the page template, then you're going to need to duplicate that custom query in a custom Widget. On the other hand, if you've abstracted the custom query (either into a template-part file, or better yet, a custom function), then you can simply include the template-part fi...
53,281
<p>I am looking for a way to output some html (javascript actually) on a post view only and not on a main page, tag, category view (where WP outputs several posts).</p> <p>E.g it would be output on this page</p> <p>blog.yourdomain.com/2012/05/some-post/</p> <p>But not on blog.yourdomain.com/ blog.yourdomain.com/cate...
[ { "answer_id": 53282, "author": "Eugene Manuilov", "author_id": 8170, "author_profile": "https://wordpress.stackexchange.com/users/8170", "pm_score": 2, "selected": false, "text": "<p>If you want to load your js only on page/post view you can do it like this:</p>\n\n<pre><code>function m...
2012/05/25
[ "https://wordpress.stackexchange.com/questions/53281", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1705/" ]
I am looking for a way to output some html (javascript actually) on a post view only and not on a main page, tag, category view (where WP outputs several posts). E.g it would be output on this page blog.yourdomain.com/2012/05/some-post/ But not on blog.yourdomain.com/ blog.yourdomain.com/category/xxx/ blog.yourdomai...
Eugene's answer was a little over complex for my needs so here's what I did (though +1 to Eugene as it got me looking in the right places) I first added **a custom field called singlePostHTML** to the posts that I wanted to add script to - put the script in the value. [Wordpress - Using Custom Fields](http://codex.wo...
53,297
<p>Examining the following sample code snippet from the WP codex,</p> <pre><code>$post = array( 'ID' =&gt; [ &lt;post id&gt; ] //Are you updating an existing post? 'post_author' =&gt; [ &lt;user ID&gt; ] //The user ID number of the author. 'post_category' =&gt; [ array(&lt;category id&gt;, &lt;...&gt;) ] //Add s...
[ { "answer_id": 53308, "author": "Mamaduka", "author_id": 888, "author_profile": "https://wordpress.stackexchange.com/users/888", "pm_score": 3, "selected": false, "text": "<p>Right there is no big difference between them, actually <code>wp_set_post_terms()</code> uses <code>wp_set_object...
2012/05/25
[ "https://wordpress.stackexchange.com/questions/53297", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14967/" ]
Examining the following sample code snippet from the WP codex, ``` $post = array( 'ID' => [ <post id> ] //Are you updating an existing post? 'post_author' => [ <user ID> ] //The user ID number of the author. 'post_category' => [ array(<category id>, <...>) ] //Add some categories. 'post_content' => [ <the text...
Right there is no big difference between them, actually `wp_set_post_terms()` uses `wp_set_object_terms()` but does few extra check for you. That's also noted on `wp_set_object_terms()` Codex page: > > Perhaps the wp\_set\_post\_terms() is a more useful function, since it > checks the values​​, converting taxonomies ...
53,298
<p>I setup a custom post type for my portfolio projects. The main URL for this is located at <code>/projects/</code></p> <p>Now I've also setup my blog posts permalink to <code>/articles/*/</code> for the permalink structure. This means when I go to view a portfolio project the URL changes to <code>/articles/projects/...
[ { "answer_id": 53303, "author": "cmegown", "author_id": 13252, "author_profile": "https://wordpress.stackexchange.com/users/13252", "pm_score": 4, "selected": false, "text": "<p>I had this problem literally 3 days ago, then I stumbled across a series over at <a href=\"http://wp.tutsplus....
2012/05/25
[ "https://wordpress.stackexchange.com/questions/53298", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8922/" ]
I setup a custom post type for my portfolio projects. The main URL for this is located at `/projects/` Now I've also setup my blog posts permalink to `/articles/*/` for the permalink structure. This means when I go to view a portfolio project the URL changes to `/articles/projects/project-name/` I know there must be ...
When you register the custom post type, you have to specify that the rewrite rule shouldn't be prepended with the existing URL structure. In short, this means that this line in your `register_post_type` call: ``` 'rewrite' => array('slug' => 'projects'), ``` should turn into this: ``` 'rewrite' => array('slug' => ...
53,309
<p><strong>tl;dr:</strong> Contact Form 7's shortcode doesn't work in an AJAX request when called with <code>do_shortcode</code></p> <p><em>functions.php</em></p> <pre><code>add_action('wp_ajax_ps_get_survey_form', 'ps_get_survey_form'); add_action('wp_ajax_nopriv_ps_get_survey_form', 'ps_get_survey_form'); function...
[ { "answer_id": 53324, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 3, "selected": false, "text": "<p>WP Ajax runs both public as well as closed calls via <code>admin.php</code>. This means that you don't have access ...
2012/05/25
[ "https://wordpress.stackexchange.com/questions/53309", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7905/" ]
**tl;dr:** Contact Form 7's shortcode doesn't work in an AJAX request when called with `do_shortcode` *functions.php* ``` add_action('wp_ajax_ps_get_survey_form', 'ps_get_survey_form'); add_action('wp_ajax_nopriv_ps_get_survey_form', 'ps_get_survey_form'); function ps_get_survey_form() { echo do_shortcode( '[con...
The answer is to sidestep admin-ajax restrictions by handling it yourself, as @OneTrickPony suggests. ``` add_action( 'init', function() { ps_register_shortcode_ajax( 'ps_get_survey_form', 'ps_get_survey_form' ); } ); function ps_register_shortcode_ajax( $callable, $action ) { if ( empty( $_POST['action'] ) ||...
53,315
<p>I had links like <code>example.com/?location=boston</code> on my site. These were indexed by Google. Due to obvious SEO reasons, I had to change the URL structure to <code>example.com/deals/boston</code>. The old URLs are there on Google results and redirect correctly to new URL. </p> <p>What I want to know is: whi...
[ { "answer_id": 53324, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 3, "selected": false, "text": "<p>WP Ajax runs both public as well as closed calls via <code>admin.php</code>. This means that you don't have access ...
2012/05/25
[ "https://wordpress.stackexchange.com/questions/53315", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6076/" ]
I had links like `example.com/?location=boston` on my site. These were indexed by Google. Due to obvious SEO reasons, I had to change the URL structure to `example.com/deals/boston`. The old URLs are there on Google results and redirect correctly to new URL. What I want to know is: while doing the redirect, is WordPr...
The answer is to sidestep admin-ajax restrictions by handling it yourself, as @OneTrickPony suggests. ``` add_action( 'init', function() { ps_register_shortcode_ajax( 'ps_get_survey_form', 'ps_get_survey_form' ); } ); function ps_register_shortcode_ajax( $callable, $action ) { if ( empty( $_POST['action'] ) ||...
53,331
<p>I have made a wordpress plugin following standard wordpress tutorials. This plugin add a file upload to the comment form by using simply this function:</p> <pre><code>add_action( 'comment_form_logged_in_after', array(&amp;$this, 'add_to_comment_form') ); </code></pre> <p>. But when I activate some themes it won't ...
[ { "answer_id": 53332, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 2, "selected": false, "text": "<p><code>comment_form_logged_in_after</code> action hook was added to WordPress When <a href=\"http://codex.word...
2012/05/25
[ "https://wordpress.stackexchange.com/questions/53331", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15600/" ]
I have made a wordpress plugin following standard wordpress tutorials. This plugin add a file upload to the comment form by using simply this function: ``` add_action( 'comment_form_logged_in_after', array(&$this, 'add_to_comment_form') ); ``` . But when I activate some themes it won't show on the comment form. Any...
`comment_form_logged_in_after` action hook was added to WordPress When [**`comment_form()`**](http://codex.wordpress.org/Function_Reference/comment_form) was introduced at version 3.0. So the themes where your plugin doesn't work are probably outdated themes that don't use `comment_form`.
53,336
<p>I thought I was making my life easy and being future-conscious by saving some content as bits of JSON in custom post_meta fields. Unfortunately, WordPress doesn't agree and is making my life incredibly difficult.</p> <p>I have a JSON string that looks essentially like this. This is just one bit, and the comment str...
[ { "answer_id": 53339, "author": "MathSmath", "author_id": 1537, "author_profile": "https://wordpress.stackexchange.com/users/1537", "pm_score": 5, "selected": true, "text": "<p>Doesn't look like there's any way to avoid it.</p>\n\n<p>The update_metadata() function, which is ultimately re...
2012/05/25
[ "https://wordpress.stackexchange.com/questions/53336", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10823/" ]
I thought I was making my life easy and being future-conscious by saving some content as bits of JSON in custom post\_meta fields. Unfortunately, WordPress doesn't agree and is making my life incredibly difficult. I have a JSON string that looks essentially like this. This is just one bit, and the comment string is ju...
Doesn't look like there's any way to avoid it. The update\_metadata() function, which is ultimately responsible for saving the meta, explicitly runs a stripslashes\_deep() on the meta value. This function will even strip slashes from array elements, if the value were an array. Theres a filter that's run AFTER that ca...
53,338
<p>I am trying to setup a wordpress slider, how can I achieve exact below result within a wordpress loop</p> <pre><code> &lt;div id="carousel"&gt; &lt;img src="slide1.png" alt="" class="slide" /&gt; &lt;img src="slide2.png" alt="" class="slide" /&gt; &lt;img s...
[ { "answer_id": 53341, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": true, "text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/rewind_posts\" rel=\"nofollow\"><code>rewind_posts()</co...
2012/05/25
[ "https://wordpress.stackexchange.com/questions/53338", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16482/" ]
I am trying to setup a wordpress slider, how can I achieve exact below result within a wordpress loop ``` <div id="carousel"> <img src="slide1.png" alt="" class="slide" /> <img src="slide2.png" alt="" class="slide" /> <img src="slide3.png" alt="" class="slide...
Use [`rewind_posts()`](http://codex.wordpress.org/Function_Reference/rewind_posts) to reset a loop and run it multiple times: ``` <?php $my_query = new WP_Query('cat=49&showposts=4&orderby=RAND'); ?> <div id="carousel"> <?php while ($my_query->have_posts()) : $my_query->the_post(); // output each slide endwhile; ...
53,395
<p>I have set up a meta box to hold additional information that my client can put in, and it will appear in a different section of the page.</p> <p>The page shows up at <code>http://96.125.170.106/~prestonp/?project=360</code></p> <p>The data shows on the right hand side of the page, but also in this data, I would li...
[ { "answer_id": 53422, "author": "screeneyes", "author_id": 16506, "author_profile": "https://wordpress.stackexchange.com/users/16506", "pm_score": 0, "selected": false, "text": "<p>The following is an adaptation of the code <a href=\"http://www.thecreatology.com/add-multiple-image-upload...
2012/05/26
[ "https://wordpress.stackexchange.com/questions/53395", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I have set up a meta box to hold additional information that my client can put in, and it will appear in a different section of the page. The page shows up at `http://96.125.170.106/~prestonp/?project=360` The data shows on the right hand side of the page, but also in this data, I would like to include photos that wo...
There're 2 things you should consider: 1. **change `send_to_editor` inside `click` callback**. This will change this function only when needed, e.g. when uploader is shown. This also prevent unwanted things with global variables. 2. You should **always** backup the `send_to_editor`. Here's my sample code (not *tested...
53,398
<p>I'm building a site with a lot of widgets. They have been highly customized.</p> <p>Several admins/editors will have to edit these widgets when the site is live.</p> <p>Right now I'm scared to see a widget (and its configuration) can be fully erased in a single mouse move (dropping it off the side bar).</p> <p>Is...
[ { "answer_id": 53422, "author": "screeneyes", "author_id": 16506, "author_profile": "https://wordpress.stackexchange.com/users/16506", "pm_score": 0, "selected": false, "text": "<p>The following is an adaptation of the code <a href=\"http://www.thecreatology.com/add-multiple-image-upload...
2012/05/26
[ "https://wordpress.stackexchange.com/questions/53398", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16498/" ]
I'm building a site with a lot of widgets. They have been highly customized. Several admins/editors will have to edit these widgets when the site is live. Right now I'm scared to see a widget (and its configuration) can be fully erased in a single mouse move (dropping it off the side bar). Is there any way to preven...
There're 2 things you should consider: 1. **change `send_to_editor` inside `click` callback**. This will change this function only when needed, e.g. when uploader is shown. This also prevent unwanted things with global variables. 2. You should **always** backup the `send_to_editor`. Here's my sample code (not *tested...
53,404
<p>In a perfect world, WordPress would take what I enter into the HTML editor and write it verbatim into the post/page document received by the browser. Disabling <code>wpautop</code> has already helped me slightly to this end. Alas..</p> <p><strong>Setup:</strong> I write some HTML into the editor and click UPDATE. M...
[ { "answer_id": 53422, "author": "screeneyes", "author_id": 16506, "author_profile": "https://wordpress.stackexchange.com/users/16506", "pm_score": 0, "selected": false, "text": "<p>The following is an adaptation of the code <a href=\"http://www.thecreatology.com/add-multiple-image-upload...
2012/05/26
[ "https://wordpress.stackexchange.com/questions/53404", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10690/" ]
In a perfect world, WordPress would take what I enter into the HTML editor and write it verbatim into the post/page document received by the browser. Disabling `wpautop` has already helped me slightly to this end. Alas.. **Setup:** I write some HTML into the editor and click UPDATE. My post/page is formatted correctly...
There're 2 things you should consider: 1. **change `send_to_editor` inside `click` callback**. This will change this function only when needed, e.g. when uploader is shown. This also prevent unwanted things with global variables. 2. You should **always** backup the `send_to_editor`. Here's my sample code (not *tested...
53,410
<p>I a using an image carousel to display some pictures on my website. The carousel I am using is called: Jcarousellite (<a href="http://www.gmarwaha.com/jquery/jcarousellite/" rel="nofollow">http://www.gmarwaha.com/jquery/jcarousellite/</a>). I have the carousel setup, styled, and configured...but am having trouble ge...
[ { "answer_id": 53422, "author": "screeneyes", "author_id": 16506, "author_profile": "https://wordpress.stackexchange.com/users/16506", "pm_score": 0, "selected": false, "text": "<p>The following is an adaptation of the code <a href=\"http://www.thecreatology.com/add-multiple-image-upload...
2012/05/26
[ "https://wordpress.stackexchange.com/questions/53410", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9820/" ]
I a using an image carousel to display some pictures on my website. The carousel I am using is called: Jcarousellite (<http://www.gmarwaha.com/jquery/jcarousellite/>). I have the carousel setup, styled, and configured...but am having trouble getting through the last little bit of the code to work. The code I am using ...
There're 2 things you should consider: 1. **change `send_to_editor` inside `click` callback**. This will change this function only when needed, e.g. when uploader is shown. This also prevent unwanted things with global variables. 2. You should **always** backup the `send_to_editor`. Here's my sample code (not *tested...
53,426
<p>Recently I have been working on an advanced WordPress project, and I'm stuck with changing permalink structure for custom post types.</p> <p>I have created 3 post types lets say: <em>type1, type2, type3</em> and a taxonomy <em>test</em> registered for all of them. I have 3 terms in the custom taxonomy <em>cat1, cat...
[ { "answer_id": 63365, "author": "mltsy", "author_id": 19654, "author_profile": "https://wordpress.stackexchange.com/users/19654", "pm_score": 0, "selected": false, "text": "<p>Without having more specific terms to help me understand what you're actually trying to organize, I'm not sure I...
2012/05/27
[ "https://wordpress.stackexchange.com/questions/53426", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16510/" ]
Recently I have been working on an advanced WordPress project, and I'm stuck with changing permalink structure for custom post types. I have created 3 post types lets say: *type1, type2, type3* and a taxonomy *test* registered for all of them. I have 3 terms in the custom taxonomy *cat1, cat2 ,cat3* Here's what I wan...
Here is part of the code from one of my projects to setup a similar structure for permalinks (same base slug for both the post type and the taxonomy archives), please note the values of 'has\_archive' and 'rewrite' parameters of both the post type and the taxonomy: ``` add_action( 'init', 'register_my_post_types' ); f...
53,433
<p>How to display user role on author page.</p> <p>I have created my own role (group) so I want to display the user role on below the post and on author list.</p> <p>I have tried this code but not working as its calling current_user and its showing current user role in all authors profile</p> <pre><code>&lt;?php ...
[ { "answer_id": 53434, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 3, "selected": true, "text": "<p>Change:</p>\n\n<pre><code>$user_roles = $current_user-&gt;roles;\n</code></pre>\n\n<p>with </p>\n\n<pre><code>...
2012/05/27
[ "https://wordpress.stackexchange.com/questions/53433", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9821/" ]
How to display user role on author page. I have created my own role (group) so I want to display the user role on below the post and on author list. I have tried this code but not working as its calling current\_user and its showing current user role in all authors profile ``` <?php $user_roles = $current_user-...
Change: ``` $user_roles = $current_user->roles; ``` with ``` $user = new WP_User( $user_id ); $user_roles = $user->roles; ``` and the $user\_id should e the actual user id who's role you are trying to get. **Update,** Sorry i just read the author template part so try this: ``` //first get the current author w...
53,440
<p>I dont understand why my sidebar isn't changing over to the second one on the other pages. I've gone in an told the pages that if your not on this page show sidebar 2. So the home page and blog page have a sidebar 1 and the rest of the pages have sidebar 2. But it's not working. </p> <p>My code on my main theme lay...
[ { "answer_id": 53443, "author": "James", "author_id": 10774, "author_profile": "https://wordpress.stackexchange.com/users/10774", "pm_score": 0, "selected": false, "text": "<p>Do you have the blog page selected under the \"Posts page\" option of the \"Front page displays\" Reading Settin...
2012/05/27
[ "https://wordpress.stackexchange.com/questions/53440", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25108/" ]
I dont understand why my sidebar isn't changing over to the second one on the other pages. I've gone in an told the pages that if your not on this page show sidebar 2. So the home page and blog page have a sidebar 1 and the rest of the pages have sidebar 2. But it's not working. My code on my main theme layout looks ...
Your main problem is that the [`is_page()`](http://codex.wordpress.org/Function_Reference/is_page) conditional will not return true if it is included inside or after the loop. Your other issue which is not necessarily related to the issue at hand is the way you are including your sidebars. WordPress comes with a handy...
53,462
<p>I'm working with this code snippet for an "on this day" type post. However it is only showing 1 year in the past. I'm looking to automate this so it shows on this day in 2009, 2010, 2011... and as the years advance, keep these years showing. With the way it's written as a -1, -2, it will be a dynamic "year ago" rath...
[ { "answer_id": 53619, "author": "moraleida", "author_id": 7890, "author_profile": "https://wordpress.stackexchange.com/users/7890", "pm_score": 3, "selected": false, "text": "<p>Adapted <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Time_Parameters\" rel=\"noreferrer\">fro...
2012/05/27
[ "https://wordpress.stackexchange.com/questions/53462", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12920/" ]
I'm working with this code snippet for an "on this day" type post. However it is only showing 1 year in the past. I'm looking to automate this so it shows on this day in 2009, 2010, 2011... and as the years advance, keep these years showing. With the way it's written as a -1, -2, it will be a dynamic "year ago" rather ...
I took the code provided by the answer from @moraleida and improved it so that it would look at the post dates, and not the server dates. I also modified it so that it would look for all posts on that post Month and Day, and link to them as long as it's not the same post ID that's being displayed on. Afterall, since ...
53,463
<p>I'm not sure how to word my question and I have been searching all day, to no avail.</p> <p>I am looking for a method to create two versions of my RSS feeds, one with the full content and one with only the excerpt.</p> <p>Mainly, I want to do this for the "Author" feeds. I would like two feeds created for each Aut...
[ { "answer_id": 60231, "author": "Michael Ecklund", "author_id": 9579, "author_profile": "https://wordpress.stackexchange.com/users/9579", "pm_score": 0, "selected": false, "text": "<p>There is actually quite an easy approach to accomplish this particular task. </p>\n\n<h2>METHOD ONE</h2>...
2012/05/27
[ "https://wordpress.stackexchange.com/questions/53463", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14558/" ]
I'm not sure how to word my question and I have been searching all day, to no avail. I am looking for a method to create two versions of my RSS feeds, one with the full content and one with only the excerpt. Mainly, I want to do this for the "Author" feeds. I would like two feeds created for each Author. One with the...
My approach would be to: 1. On the Reading Options page, set the `For each article in a feed, show...` option to `Full Text` so that, by default, feeds will include the entire post. 2. Pass a custom URL parameter to each individual feed when you want the excerpt instead of the full text. e.g., `http://example.com/auth...
53,474
<p>The default is singular, e.g.</p> <pre><code>http://example.com/category/apple/ </code></pre> <p>But I am wondering if it is better to use the plural form, e.g.</p> <pre><code>http://example.com/categories/apple/ </code></pre> <p>Are there any guideline on this?</p>
[ { "answer_id": 53478, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 4, "selected": false, "text": "<p>There are two reasons to keep the singular:</p>\n\n<ol>\n<li><p>It is a common practice to use the singular. Don't bre...
2012/05/28
[ "https://wordpress.stackexchange.com/questions/53474", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16037/" ]
The default is singular, e.g. ``` http://example.com/category/apple/ ``` But I am wondering if it is better to use the plural form, e.g. ``` http://example.com/categories/apple/ ``` Are there any guideline on this?
There's a simple rule that I follow (it's hard to explain, so I'll give examples): * `http://example.com/categories/` <-- This plural form should mean that the page shows a list of all the categories in use on your site. Similarly, if it's "authors" (as in `http://example.com/authors/`), I'd expect the page to show a...
53,485
<p>is it possible to get wordpress on the posts page to do the following example.</p> <p>the first three posts need to have a large image spanning the width of the title box and a longer excerpt.</p> <p>the rest of the posts need to be thinner and a smaller featured image floated left.</p> <p>How would I go about ch...
[ { "answer_id": 53601, "author": "user16562", "author_id": 16562, "author_profile": "https://wordpress.stackexchange.com/users/16562", "pm_score": 0, "selected": false, "text": "<p>Hard without having more info like how is your loop? Do you have two loops, one for the first 3 posts and a ...
2012/05/28
[ "https://wordpress.stackexchange.com/questions/53485", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16532/" ]
is it possible to get wordpress on the posts page to do the following example. the first three posts need to have a large image spanning the width of the title box and a longer excerpt. the rest of the posts need to be thinner and a smaller featured image floated left. How would I go about changing this in the templ...
First, you need to filter [**`excerpt_length`**](http://codex.wordpress.org/Plugin_API/Filter_Reference/excerpt_length). Assuming you want your default excerpt length to be **50 words**: ``` <?php function wpse53485_filter_excerpt_length( $length ) { return 50; } add_filter( 'excerpt_length', 'wpse53485_filter_e...
53,486
<p>How to add a meta box for a particular page, say: for only <em>About Us</em> page.</p> <p>How shall i do?</p> <p>The current code adds the metaboxes for all pages:</p> <pre><code>function myplugin_add_custom_box() { add_meta_box( 'myplugin_sectionid', __( 'My Post Section Title', 'myplugin_te...
[ { "answer_id": 53601, "author": "user16562", "author_id": 16562, "author_profile": "https://wordpress.stackexchange.com/users/16562", "pm_score": 0, "selected": false, "text": "<p>Hard without having more info like how is your loop? Do you have two loops, one for the first 3 posts and a ...
2012/05/28
[ "https://wordpress.stackexchange.com/questions/53486", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14865/" ]
How to add a meta box for a particular page, say: for only *About Us* page. How shall i do? The current code adds the metaboxes for all pages: ``` function myplugin_add_custom_box() { add_meta_box( 'myplugin_sectionid', __( 'My Post Section Title', 'myplugin_textdomain' ), 'myplugin_inne...
First, you need to filter [**`excerpt_length`**](http://codex.wordpress.org/Plugin_API/Filter_Reference/excerpt_length). Assuming you want your default excerpt length to be **50 words**: ``` <?php function wpse53485_filter_excerpt_length( $length ) { return 50; } add_filter( 'excerpt_length', 'wpse53485_filter_e...
53,496
<p>I have create a plugin that I want to redirect to the options page of that plugin after the user activates it. This works fine when I test it locally. However, on a live installation of wordpress, it does not behave in the same manner. </p> <p>Here is my code below:</p> <pre><code> register_activation_hook(...
[ { "answer_id": 53506, "author": "Liam Bailey", "author_id": 2911, "author_profile": "https://wordpress.stackexchange.com/users/2911", "pm_score": 1, "selected": false, "text": "<p>You add this as your activation hook:</p>\n\n<pre><code> register_activation_hook(__FILE__, 'srpt_plugin_...
2012/05/28
[ "https://wordpress.stackexchange.com/questions/53496", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16501/" ]
I have create a plugin that I want to redirect to the options page of that plugin after the user activates it. This works fine when I test it locally. However, on a live installation of wordpress, it does not behave in the same manner. Here is my code below: ``` register_activation_hook(__FILE__, 'srpt_plugi...
You add this as your activation hook: ``` register_activation_hook(__FILE__, 'srpt_plugin_activate'); ``` but the function is `my_plugin_activate` not `srpt_plugin_activate`. This is based on the fact that there is no function `srpt_plugin_activate`, and looking at the code `my_plugin_activate` fills its place i...
53,509
<p>I need an alternative function to use with textareas in meta boxes instead of esc_textarea. </p> <p>The problem is that when I use this function with textarea's it removes line breaks and paragraphs. Is there an alternative function that will keep the line breaks and paragraphs.</p> <p>I have tried the validation ...
[ { "answer_id": 53510, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 2, "selected": false, "text": "<p><code>esc_textarea</code> shouldn't strip out newlines -- It's just a thin wrapper around <code>htmlspeci...
2012/05/28
[ "https://wordpress.stackexchange.com/questions/53509", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15992/" ]
I need an alternative function to use with textareas in meta boxes instead of esc\_textarea. The problem is that when I use this function with textarea's it removes line breaks and paragraphs. Is there an alternative function that will keep the line breaks and paragraphs. I have tried the validation reference page i...
`esc_textarea` shouldn't strip out newlines -- It's just a thin wrapper around `htmlspecialchars`: <http://core.trac.wordpress.org/browser/tags/3.3.2/wp-includes/formatting.php#L2536> ``` <?php function esc_textarea( $text ) { $safe_text = htmlspecialchars( $text, ENT_QUOTES ); return apply_filters( 'esc_texta...
53,515
<p>I know people have asked this before and have gone as far as adding the custom post type, and rewrite for permalink. </p> <p>The problem is I have 340 existing categories which I would like to continue using. I used to be able to see /category/subcategory/postname</p> <p>Now I have the slug of customposttype/postn...
[ { "answer_id": 53711, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": -1, "selected": false, "text": "<p>You have several errors with your code. I cleaned up your existing code:</p>\n\n<pre><code>&lt;?php\nfunct...
2012/05/28
[ "https://wordpress.stackexchange.com/questions/53515", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16541/" ]
I know people have asked this before and have gone as far as adding the custom post type, and rewrite for permalink. The problem is I have 340 existing categories which I would like to continue using. I used to be able to see /category/subcategory/postname Now I have the slug of customposttype/postname. Selecting th...
There are 2 points of attack to cover when you are adding custom post type rewrite rules: Rewrite rules ============= This happens when the rewrite rules are being generated in `wp-includes/rewrite.php` in `WP_Rewrite::rewrite_rules()`. WordPress allows you to filter the rewrite rules for specific elements like posts...
53,531
<p>My friend asked me to activate a site that someone else did it. The problem is that when I try to run it, and I go to <code>mysite.com</code> I arrive to <code>mysite.com/wp-login.php?redirect_to=/</code> Where and how can I fix it?</p>
[ { "answer_id": 53711, "author": "Jeremy Jared", "author_id": 5339, "author_profile": "https://wordpress.stackexchange.com/users/5339", "pm_score": -1, "selected": false, "text": "<p>You have several errors with your code. I cleaned up your existing code:</p>\n\n<pre><code>&lt;?php\nfunct...
2012/05/28
[ "https://wordpress.stackexchange.com/questions/53531", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16331/" ]
My friend asked me to activate a site that someone else did it. The problem is that when I try to run it, and I go to `mysite.com` I arrive to `mysite.com/wp-login.php?redirect_to=/` Where and how can I fix it?
There are 2 points of attack to cover when you are adding custom post type rewrite rules: Rewrite rules ============= This happens when the rewrite rules are being generated in `wp-includes/rewrite.php` in `WP_Rewrite::rewrite_rules()`. WordPress allows you to filter the rewrite rules for specific elements like posts...
53,544
<p>In a theme I'm building, I have this structure for detecting what type of page something is. However, if I visit mydomain.com/category/ or mydomain.com/tag/, all I get is the "nothing found" message I have in the have_posts()'s else statement. Is there a way to detect when these links are visited and display somethi...
[ { "answer_id": 53552, "author": "Liam Bailey", "author_id": 2911, "author_profile": "https://wordpress.stackexchange.com/users/2911", "pm_score": 1, "selected": false, "text": "<p>There is no good way to do this, but it can be done in a way. When you visit /category/ it serves it as thou...
2012/05/28
[ "https://wordpress.stackexchange.com/questions/53544", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7332/" ]
In a theme I'm building, I have this structure for detecting what type of page something is. However, if I visit mydomain.com/category/ or mydomain.com/tag/, all I get is the "nothing found" message I have in the have\_posts()'s else statement. Is there a way to detect when these links are visited and display something...
If I put this above the htaccess block of wordpress rules, I'm able to redirect the tag and category base pages back to the homepage. ``` RewriteCond %{HTTP_HOST} ^mydomain.com$ [OR] RewriteCond %{HTTP_HOST} ^localhost$ RewriteRule ^category/?$ "http://mydomain.com" [R=301,L] RewriteRule ^tag/?$ "http://mydomain.com" ...
53,546
<p>I lifted the "continue reading" link functions from the Twenty Eleven theme and for the most part, it is working (works in RSS feeds).</p> <p>I created a shortcode to display the latest post on the front static page using <code>get_posts</code>, however, the "continue reading" link just links to the front page inst...
[ { "answer_id": 53552, "author": "Liam Bailey", "author_id": 2911, "author_profile": "https://wordpress.stackexchange.com/users/2911", "pm_score": 1, "selected": false, "text": "<p>There is no good way to do this, but it can be done in a way. When you visit /category/ it serves it as thou...
2012/05/28
[ "https://wordpress.stackexchange.com/questions/53546", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7466/" ]
I lifted the "continue reading" link functions from the Twenty Eleven theme and for the most part, it is working (works in RSS feeds). I created a shortcode to display the latest post on the front static page using `get_posts`, however, the "continue reading" link just links to the front page instead of the post page....
If I put this above the htaccess block of wordpress rules, I'm able to redirect the tag and category base pages back to the homepage. ``` RewriteCond %{HTTP_HOST} ^mydomain.com$ [OR] RewriteCond %{HTTP_HOST} ^localhost$ RewriteRule ^category/?$ "http://mydomain.com" [R=301,L] RewriteRule ^tag/?$ "http://mydomain.com" ...
53,549
<p>After finding a couple of leads on how to do this, I'm coming up blank. What I am trying to accomplish is to add the post to a new category based on camera name. If the category doesn't exist, then to create it and add. </p> <p>Essentially what I have below grabs the attachment meta information and saves the camera...
[ { "answer_id": 53552, "author": "Liam Bailey", "author_id": 2911, "author_profile": "https://wordpress.stackexchange.com/users/2911", "pm_score": 1, "selected": false, "text": "<p>There is no good way to do this, but it can be done in a way. When you visit /category/ it serves it as thou...
2012/05/28
[ "https://wordpress.stackexchange.com/questions/53549", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12920/" ]
After finding a couple of leads on how to do this, I'm coming up blank. What I am trying to accomplish is to add the post to a new category based on camera name. If the category doesn't exist, then to create it and add. Essentially what I have below grabs the attachment meta information and saves the camera informati...
If I put this above the htaccess block of wordpress rules, I'm able to redirect the tag and category base pages back to the homepage. ``` RewriteCond %{HTTP_HOST} ^mydomain.com$ [OR] RewriteCond %{HTTP_HOST} ^localhost$ RewriteRule ^category/?$ "http://mydomain.com" [R=301,L] RewriteRule ^tag/?$ "http://mydomain.com" ...
53,575
<p>I have added custom metaboxes into the wp-admin page and post editors. There is a metabox with the ability to enter in a person's first name (ex. "John") and last name (ex. "Doe"). </p> <p>I want to set that particular post's/page's title to the combined values of those form entries (ex. "John Doe") without havin...
[ { "answer_id": 53576, "author": "Ben Lobaugh", "author_id": 10314, "author_profile": "https://wordpress.stackexchange.com/users/10314", "pm_score": 0, "selected": false, "text": "<p>This does not solve your permalinks issue, but there is a built-in filter for tweaking the titles before b...
2012/05/28
[ "https://wordpress.stackexchange.com/questions/53575", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32212/" ]
I have added custom metaboxes into the wp-admin page and post editors. There is a metabox with the ability to enter in a person's first name (ex. "John") and last name (ex. "Doe"). I want to set that particular post's/page's title to the combined values of those form entries (ex. "John Doe") without having to enter i...
Simply filter [**`the_title`**](http://codex.wordpress.org/Plugin_API/Filter_Reference/the_title) to replace/append the post title with this post custom meta data. I assume that you already know how to query your post custom meta data, and as such, that querying will be outside the scope of this answer. Let's assume t...
53,589
<p>I wonder how I can link manually to the smallest filesize for <code>the_post_thumbnail()</code> within its filter function …</p> <pre><code>add_filter( 'post_thumbnail_html', 'post_thumbnail_html', 10, 3 ); function post_thumbnail_html( $html, $post_id, $post_image_id ) { $html = '&lt;a href="' . get_permalin...
[ { "answer_id": 53590, "author": "janw", "author_id": 10911, "author_profile": "https://wordpress.stackexchange.com/users/10911", "pm_score": 0, "selected": false, "text": "<p><code>post_thumbnail_html</code> has 5 arguments not 3 like you use, in arg #5 are the attributes.<br/>\nThe thum...
2012/05/29
[ "https://wordpress.stackexchange.com/questions/53589", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3529/" ]
I wonder how I can link manually to the smallest filesize for `the_post_thumbnail()` within its filter function … ``` add_filter( 'post_thumbnail_html', 'post_thumbnail_html', 10, 3 ); function post_thumbnail_html( $html, $post_id, $post_image_id ) { $html = '<a href="' . get_permalink( $post_id ) . '" title="' ...
Since you already know your $post\_image\_id, you can use [wp\_get\_attachment\_src()](http://codex.wordpress.org/Function_Reference/wp_get_attachment_image_src) ``` $small = wp_get_attachment_src($post_image_id, 'smallest-size'); $large = wp_get_attachment_src($post_image_id, 'full'); $smallURL = $small[0]; $largeUR...
53,595
<p>I just tried to add a simple help tab, from within a class (example to test below). I wanted to use a helper/callback fn to prepare the content for different help tabs. According to core, the function takes some args:</p> <blockquote> <p>WP 3.3 /wp-admin/includes/screen.php LINE 722</p> </blockquote> <pre><code>...
[ { "answer_id": 53598, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 3, "selected": true, "text": "<p>Ok. The answer is <strong>NOT</strong> simple, but after some try and error, reading core, etc. I found out what the...
2012/05/29
[ "https://wordpress.stackexchange.com/questions/53595", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/385/" ]
I just tried to add a simple help tab, from within a class (example to test below). I wanted to use a helper/callback fn to prepare the content for different help tabs. According to core, the function takes some args: > > WP 3.3 /wp-admin/includes/screen.php LINE 722 > > > ``` // If it exists, fire tab callb...
Ok. The answer is **NOT** simple, but after some try and error, reading core, etc. I found out what the problem is: The callback (which should be used *instead* of the `content`) accepts two arguments: `$current_screen` and `$tab`. Here's what `$tab` looks like, when dumped for a single tab. ``` Array ( [title] ...
53,599
<p>I'm having some difficulty to find an example of how to create a loop with posts that had been updated in the last 24 hours.</p> <p>My idea is to have a page of posts or perhaps on the index.php a lists of posts that had been updated in the last day (24 hours from the time the query is done)</p> <p>Is this possibl...
[ { "answer_id": 53765, "author": "krembo99", "author_id": 13256, "author_profile": "https://wordpress.stackexchange.com/users/13256", "pm_score": 1, "selected": false, "text": "<pre><code>&lt;?php\n$timelimit=1 * 86400; //days * seconds per day\n$post_age = date('U') - get_post_time('U');...
2012/05/29
[ "https://wordpress.stackexchange.com/questions/53599", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16562/" ]
I'm having some difficulty to find an example of how to create a loop with posts that had been updated in the last 24 hours. My idea is to have a page of posts or perhaps on the index.php a lists of posts that had been updated in the last day (24 hours from the time the query is done) Is this possible ? Is there any ...
``` <?php $timelimit=1 * 86400; //days * seconds per day $post_age = date('U') - get_post_time('U'); if ($post_age < $timelimit) { echo 'this post is within my time limits '; //DO SOMETHING } ?> ```
53,610
<p>I have seen similar questions but none with a definitive answer. I host dozens of WP sites on a cloud server (all latest version) however this causes a lot of unnecessary backup activity. I am not a fan of multisite. Really I am just looking to simplify by keeping a core set of files in a central location that can ...
[ { "answer_id": 53872, "author": "Refiner", "author_id": 7652, "author_profile": "https://wordpress.stackexchange.com/users/7652", "pm_score": -1, "selected": false, "text": "<p>I think you find Mark Jaquith's WP skeleton along with a symlinked 'wp' folder should do the trick, though plug...
2012/05/29
[ "https://wordpress.stackexchange.com/questions/53610", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16565/" ]
I have seen similar questions but none with a definitive answer. I host dozens of WP sites on a cloud server (all latest version) however this causes a lot of unnecessary backup activity. I am not a fan of multisite. Really I am just looking to simplify by keeping a core set of files in a central location that can be r...
Sharing single set of core files without multisite is a setup technique that kind of make sense, yet kind of very under explored - exactly because multisite exists. The latest iteration of it (that I know of) has been [suggested by Mark Jaquith](https://gist.github.com/markjaquith/6225805) to be: ``` sites |__ ms.d...
53,612
<p>I'm using wp_mail filter function. </p> <p><code>add_filter('wp_mail','check_the_mail_content');</code></p> <p>If my condition satisfied then the mail should go, otherwise I need to stop, my function is</p> <pre><code>add_filter('wp_mail','check_the_mail_content'); function check_the_mail_content($query){ if(...
[ { "answer_id": 53615, "author": "JeanDavidDaviet", "author_id": 15879, "author_profile": "https://wordpress.stackexchange.com/users/15879", "pm_score": -1, "selected": false, "text": "<pre><code>if(mycondition){\n wp_mail(themail@youwant, $subject, $message)\n}else{\n // NOTHING SP...
2012/05/29
[ "https://wordpress.stackexchange.com/questions/53612", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15761/" ]
I'm using wp\_mail filter function. `add_filter('wp_mail','check_the_mail_content');` If my condition satisfied then the mail should go, otherwise I need to stop, my function is ``` add_filter('wp_mail','check_the_mail_content'); function check_the_mail_content($query){ if(mycondition){ //mail should g...
Filter `'phpmailer_init'`, not `'wp_mail'`. To prevent sending the mail out reset the PHPMailer object. *Prototype (not tested):* ``` add_action( 'phpmailer_init', 'wpse_53612_conditional_mail_stop' ); function wpse_53612_conditional_mail_stop( $phpmailer ) { ! my_condition() and $phpmailer = new stdClass; } ``...
53,617
<p>I have downloaded my site to a production environment. I have set up both the live site and the production site to use the same DB. When i login to the admin panel i get redirected to the live site. I know that wordpress stores URLs in the DB so i want to modify (hard code) my production site not to redirect anywher...
[ { "answer_id": 53615, "author": "JeanDavidDaviet", "author_id": 15879, "author_profile": "https://wordpress.stackexchange.com/users/15879", "pm_score": -1, "selected": false, "text": "<pre><code>if(mycondition){\n wp_mail(themail@youwant, $subject, $message)\n}else{\n // NOTHING SP...
2012/05/29
[ "https://wordpress.stackexchange.com/questions/53617", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16567/" ]
I have downloaded my site to a production environment. I have set up both the live site and the production site to use the same DB. When i login to the admin panel i get redirected to the live site. I know that wordpress stores URLs in the DB so i want to modify (hard code) my production site not to redirect anywhere. ...
Filter `'phpmailer_init'`, not `'wp_mail'`. To prevent sending the mail out reset the PHPMailer object. *Prototype (not tested):* ``` add_action( 'phpmailer_init', 'wpse_53612_conditional_mail_stop' ); function wpse_53612_conditional_mail_stop( $phpmailer ) { ! my_condition() and $phpmailer = new stdClass; } ``...
53,629
<p>I have multiple stage process that integrates complex faceting into WP queries. Problem is - the deeper I get the more fuzzy I become on how it is <em>supposed</em> to work and I could use a guideline rather than being inventive (and digging myself a hole).</p> <p>General stages I have (pseudo-code, but close to re...
[ { "answer_id": 53910, "author": "Joshua", "author_id": 10119, "author_profile": "https://wordpress.stackexchange.com/users/10119", "pm_score": 0, "selected": false, "text": "<p>I would have assumed it be done via <code>$_GET</code> and/or <code>$_POST</code>, then manipulate accordingly....
2012/05/29
[ "https://wordpress.stackexchange.com/questions/53629", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/847/" ]
I have multiple stage process that integrates complex faceting into WP queries. Problem is - the deeper I get the more fuzzy I become on how it is *supposed* to work and I could use a guideline rather than being inventive (and digging myself a hole). General stages I have (pseudo-code, but close to real): 1. retrieve...
I think the WP function you are looking for is [add\_rewrite\_tag](http://codex.wordpress.org/Rewrite_API/add_rewrite_tag). It aims to add custom GET params to your URL and include it automatically in `query_vars`. For example, you can add the following to the init hook : ``` add_rewrite_tag('%person%','([^&]+)'); `...
53,654
<p>A friend of mine pointed me towards using child elements to style my index page so that I could have one loop and several different visual styles (a featured post, a smaller sub-featured post, and several smaller thumbnails). This is very helpful in that I can add posts and the existing posts will just flow through ...
[ { "answer_id": 53656, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": true, "text": "<p>Your theme's <a href=\"http://codex.wordpress.org/Function_Reference/body_class\" rel=\"nofollow\"><code>body_class<...
2012/05/29
[ "https://wordpress.stackexchange.com/questions/53654", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16279/" ]
A friend of mine pointed me towards using child elements to style my index page so that I could have one loop and several different visual styles (a featured post, a smaller sub-featured post, and several smaller thumbnails). This is very helpful in that I can add posts and the existing posts will just flow through thi...
Your theme's [`body_class`](http://codex.wordpress.org/Function_Reference/body_class) can be used to target specific pages: ``` body.home /* front and subsequent pages */ body.paged /* any page *except* front page */ ```
53,662
<p>I have a wordpress page where I want to include a <a href="http://www.thecreditguy.tv/free-budget-tool/" rel="nofollow">budget calculation tool</a>.</p> <p>This budget calculation tool is of course tied to a php script that executes the fields in the budget calculation tool. This php script lives in the file "view....
[ { "answer_id": 53656, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": true, "text": "<p>Your theme's <a href=\"http://codex.wordpress.org/Function_Reference/body_class\" rel=\"nofollow\"><code>body_class<...
2012/05/29
[ "https://wordpress.stackexchange.com/questions/53662", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10275/" ]
I have a wordpress page where I want to include a [budget calculation tool](http://www.thecreditguy.tv/free-budget-tool/). This budget calculation tool is of course tied to a php script that executes the fields in the budget calculation tool. This php script lives in the file "view.php" My question is: how can I exec...
Your theme's [`body_class`](http://codex.wordpress.org/Function_Reference/body_class) can be used to target specific pages: ``` body.home /* front and subsequent pages */ body.paged /* any page *except* front page */ ```
53,681
<p>I'm trying to find out the PHP code that will get the current URL and add a hash ID onto the end of it so a link can be generated and linked to.</p> <p>The end goal is to create a link that returns: <a href="http://mydomain.com/news#postID-123" rel="nofollow">http://mydomain.com/news#postID-123</a>. This should a) ...
[ { "answer_id": 53656, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": true, "text": "<p>Your theme's <a href=\"http://codex.wordpress.org/Function_Reference/body_class\" rel=\"nofollow\"><code>body_class<...
2012/05/29
[ "https://wordpress.stackexchange.com/questions/53681", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14149/" ]
I'm trying to find out the PHP code that will get the current URL and add a hash ID onto the end of it so a link can be generated and linked to. The end goal is to create a link that returns: <http://mydomain.com/news#postID-123>. This should a) take users to the news page and b) jump to the part of the news page wher...
Your theme's [`body_class`](http://codex.wordpress.org/Function_Reference/body_class) can be used to target specific pages: ``` body.home /* front and subsequent pages */ body.paged /* any page *except* front page */ ```
53,682
<p>So my script is simple right now just to test out the $entry field id's.</p> <pre><code>add_action("gform_after_submission_3", "set_post_content", 10, 2); function set_post_content($entry, $form){ $subject = $entry["28"] . 'Applied as: ' . $entry["2"]; mail( $emailremoved, $subject, $message); } </code></pre> <p>...
[ { "answer_id": 53656, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": true, "text": "<p>Your theme's <a href=\"http://codex.wordpress.org/Function_Reference/body_class\" rel=\"nofollow\"><code>body_class<...
2012/05/29
[ "https://wordpress.stackexchange.com/questions/53682", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16584/" ]
So my script is simple right now just to test out the $entry field id's. ``` add_action("gform_after_submission_3", "set_post_content", 10, 2); function set_post_content($entry, $form){ $subject = $entry["28"] . 'Applied as: ' . $entry["2"]; mail( $emailremoved, $subject, $message); } ``` Right now entry 28 is a dr...
Your theme's [`body_class`](http://codex.wordpress.org/Function_Reference/body_class) can be used to target specific pages: ``` body.home /* front and subsequent pages */ body.paged /* any page *except* front page */ ```
53,683
<p>hope you can help me. users can chose between subscriber and editor role on my website. now, i'd like to send a register welcome mail to EDITORS only (WITH a specific) text. subscribers must not receive a welcome mail. </p> <p>any chance?</p> <p>looking forward hearing from you! THANKS!!!</p>
[ { "answer_id": 53656, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": true, "text": "<p>Your theme's <a href=\"http://codex.wordpress.org/Function_Reference/body_class\" rel=\"nofollow\"><code>body_class<...
2012/05/29
[ "https://wordpress.stackexchange.com/questions/53683", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16585/" ]
hope you can help me. users can chose between subscriber and editor role on my website. now, i'd like to send a register welcome mail to EDITORS only (WITH a specific) text. subscribers must not receive a welcome mail. any chance? looking forward hearing from you! THANKS!!!
Your theme's [`body_class`](http://codex.wordpress.org/Function_Reference/body_class) can be used to target specific pages: ``` body.home /* front and subsequent pages */ body.paged /* any page *except* front page */ ```
53,687
<p>I would like to remove the email field in the comment form. It works for <code>url</code> but not for <code>email</code> : the email field is still there. Do you know why?</p> <pre><code>&lt;?php function url_filtered($fields) { if(isset($fields['url'])) { unset($fields['url']); } if(isset($fields['email'...
[ { "answer_id": 53692, "author": "Tara", "author_id": 5021, "author_profile": "https://wordpress.stackexchange.com/users/5021", "pm_score": 1, "selected": false, "text": "<p>try this:</p>\n\n<pre><code>add_filter('comment_form_default_fields', 'remove_email');\nfunction remove_email($val)...
2012/05/29
[ "https://wordpress.stackexchange.com/questions/53687", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8432/" ]
I would like to remove the email field in the comment form. It works for `url` but not for `email` : the email field is still there. Do you know why? ``` <?php function url_filtered($fields) { if(isset($fields['url'])) { unset($fields['url']); } if(isset($fields['email'])){ unset($fields['email']); } ...
This works fine for me: ``` <?php add_filter('comment_form_default_fields', 'wpse53687_filter_fields'); /** * Unsets the email field from the comment form. */ function wpse53687_filter_fields($fields) { if(isset($fields['email'])) unset($fields['email']); return $fields; } ``` One reason that it co...
53,690
<p>I want to modify TinyMCE in WordPress so that it inserts media (image etc.) always at the beginning of post contents. For this I need to change the cursor position to the beginning, insert media and possibly restore old cursor position. I am not sure how to achieve it. Please advise.</p>
[ { "answer_id": 53694, "author": "mrwweb", "author_id": 9844, "author_profile": "https://wordpress.stackexchange.com/users/9844", "pm_score": 1, "selected": false, "text": "<p>If your goal is to get a photo at the top of every post, I'd encourage you to use the featured image instead. It ...
2012/05/29
[ "https://wordpress.stackexchange.com/questions/53690", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6076/" ]
I want to modify TinyMCE in WordPress so that it inserts media (image etc.) always at the beginning of post contents. For this I need to change the cursor position to the beginning, insert media and possibly restore old cursor position. I am not sure how to achieve it. Please advise.
I found [this](http://www.tinymce.com/forum/viewtopic.php?id=6140) which helped me moving caret to start of post before inserting media. My modified code is: ``` var root = ed.dom.getRoot(); var node = root.childNodes[0]; if (tinymce.isGecko) { node = node.childNodes[0]; } ed.selection.select(node); ed.selection.c...
53,698
<p>im trying to lock my admin panel from my users with adding htpsswrd file to wp-admin folder. but also i want my users can edit their profiles. so i create this file (htaccess)</p> <p>AuthName "Username and password required" AuthUserFile ...../wp-admin/.htpasswd Require valid-user AuthType Basic</p> <p> Order deny...
[ { "answer_id": 53694, "author": "mrwweb", "author_id": 9844, "author_profile": "https://wordpress.stackexchange.com/users/9844", "pm_score": 1, "selected": false, "text": "<p>If your goal is to get a photo at the top of every post, I'd encourage you to use the featured image instead. It ...
2012/05/30
[ "https://wordpress.stackexchange.com/questions/53698", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16564/" ]
im trying to lock my admin panel from my users with adding htpsswrd file to wp-admin folder. but also i want my users can edit their profiles. so i create this file (htaccess) AuthName "Username and password required" AuthUserFile ...../wp-admin/.htpasswd Require valid-user AuthType Basic Order deny,allow Allow from ...
I found [this](http://www.tinymce.com/forum/viewtopic.php?id=6140) which helped me moving caret to start of post before inserting media. My modified code is: ``` var root = ed.dom.getRoot(); var node = root.childNodes[0]; if (tinymce.isGecko) { node = node.childNodes[0]; } ed.selection.select(node); ed.selection.c...
53,710
<p>I'm building site (dummy site is up at www.teamcoding.ca/corporate) and would like to include in the upper-right hand part of the screen, "Switch to Lifestyle Site" with a link to a different site.</p> <p>My impression is that to do this I need to edit one of my .php files.</p> <p>I tried to edit page.php, full-wi...
[ { "answer_id": 53694, "author": "mrwweb", "author_id": 9844, "author_profile": "https://wordpress.stackexchange.com/users/9844", "pm_score": 1, "selected": false, "text": "<p>If your goal is to get a photo at the top of every post, I'd encourage you to use the featured image instead. It ...
2012/05/30
[ "https://wordpress.stackexchange.com/questions/53710", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14342/" ]
I'm building site (dummy site is up at www.teamcoding.ca/corporate) and would like to include in the upper-right hand part of the screen, "Switch to Lifestyle Site" with a link to a different site. My impression is that to do this I need to edit one of my .php files. I tried to edit page.php, full-width-page.php (the...
I found [this](http://www.tinymce.com/forum/viewtopic.php?id=6140) which helped me moving caret to start of post before inserting media. My modified code is: ``` var root = ed.dom.getRoot(); var node = root.childNodes[0]; if (tinymce.isGecko) { node = node.childNodes[0]; } ed.selection.select(node); ed.selection.c...
53,732
<p>I've been writing up some code which enables two post types to share a custom taxonomy. From the admin side, it works fantastically - but for some reason, when I look at the taxonomy archive itself on the site, </p> <p>/country/{country} , despite the fact that there are two posts (one from each type) in the taxono...
[ { "answer_id": 54182, "author": "anu", "author_id": 490, "author_profile": "https://wordpress.stackexchange.com/users/490", "pm_score": 1, "selected": true, "text": "<p>As the page is returning with \"no posts found\", it's possible that whatever template page is generating term archives...
2012/05/30
[ "https://wordpress.stackexchange.com/questions/53732", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7434/" ]
I've been writing up some code which enables two post types to share a custom taxonomy. From the admin side, it works fantastically - but for some reason, when I look at the taxonomy archive itself on the site, /country/{country} , despite the fact that there are two posts (one from each type) in the taxonomy, it com...
As the page is returning with "no posts found", it's possible that whatever template page is generating term archives isn't including your custom post types in its query. If you take a look at the template that should be easy to see.
53,753
<p>Howdi,</p> <p>I am trying to fire some code that will occur when I save an image in the media library, as per usual, I select the file, upload, enter the meta data and then click save. At this point I want to hook into wordpress, and redirect wordpress to another URL. This is so that rather than taking the user t...
[ { "answer_id": 56614, "author": "eddiemoya", "author_id": 51, "author_profile": "https://wordpress.stackexchange.com/users/51", "pm_score": 2, "selected": false, "text": "<p>Looks like there is no action on media save, but there is a filter. Unfortunately that means you can do some stuff...
2012/05/30
[ "https://wordpress.stackexchange.com/questions/53753", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15462/" ]
Howdi, I am trying to fire some code that will occur when I save an image in the media library, as per usual, I select the file, upload, enter the meta data and then click save. At this point I want to hook into wordpress, and redirect wordpress to another URL. This is so that rather than taking the user to a list of ...
Actually there are no hook fired after media file(s) upload, at least as far as I know. The problem with the hooks available along the way of uploading and saving media files and data is that they are limited to one portion of the process, and so using any of them is not reliable. For example, `add_attachment` is fired...
53,766
<p>I would like to limit characters in BuddyPress posts to certain limit . Ex: Set it to the limit of 150 ... just like twitter's 140.</p> <p>Googled about it and found nothing. Does any one have Idea on this?</p> <p>Thanks</p>
[ { "answer_id": 61797, "author": "John Peter", "author_id": 19237, "author_profile": "https://wordpress.stackexchange.com/users/19237", "pm_score": 1, "selected": false, "text": "<p>Just Try With the following plugin.,</p>\n\n<p><a href=\"http://bavotasan.com/2009/excerpt-and-content-word...
2012/05/30
[ "https://wordpress.stackexchange.com/questions/53766", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2078/" ]
I would like to limit characters in BuddyPress posts to certain limit . Ex: Set it to the limit of 150 ... just like twitter's 140. Googled about it and found nothing. Does any one have Idea on this? Thanks
Simple solution is to add a maxlength attribute to the textarea field. For example ``` <textarea maxlength="140"> </textarea> ```
53,767
<p>I'm building a custom jQuery form and I need to specify the siteurl in the url that loads /wp-admin/admin-ajax.php.</p> <p>I place this code in the template that has the form:</p> <pre><code>&lt;script type="text/javascript"&gt; jQuery('#newFeedbackForm').submit(ajaxSubmit); function ajaxSubmit(){ var newFeed...
[ { "answer_id": 53768, "author": "MathSmath", "author_id": 1537, "author_profile": "https://wordpress.stackexchange.com/users/1537", "pm_score": 1, "selected": true, "text": "<p>If your JavaScript is running in the admin, you don't need to set an explicit path to admin-ajax.php. It's alwa...
2012/05/30
[ "https://wordpress.stackexchange.com/questions/53767", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10099/" ]
I'm building a custom jQuery form and I need to specify the siteurl in the url that loads /wp-admin/admin-ajax.php. I place this code in the template that has the form: ``` <script type="text/javascript"> jQuery('#newFeedbackForm').submit(ajaxSubmit); function ajaxSubmit(){ var newFeedbackForm = jQuery(this).ser...
If your JavaScript is running in the admin, you don't need to set an explicit path to admin-ajax.php. It's always available as a JS variable called "ajaxurl". You can see [an example of this in the Codex](http://codex.wordpress.org/AJAX_in_Plugins#Ajax_on_the_Administration_Side), under the heading "AJAX on the Adminis...
53,783
<p>I'm trying to run a query to get all attachments and I'd like to sort by the post mime type. This query isn't working. Any ideas?</p> <pre><code>$query_args = array( 'post_type' =&gt; 'attachment', 'numberposts' =&gt; -1, 'post_status' =&gt; null, 'post_parent' =&gt; null, // any parent 'orderby' =&gt; "post_mime_t...
[ { "answer_id": 53790, "author": "mrwweb", "author_id": 9844, "author_profile": "https://wordpress.stackexchange.com/users/9844", "pm_score": 0, "selected": false, "text": "<p><code>get_posts()</code> allows the same parameters and valueas <code>WP_Query</code>. As you can see <a href=\"h...
2012/05/30
[ "https://wordpress.stackexchange.com/questions/53783", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6932/" ]
I'm trying to run a query to get all attachments and I'd like to sort by the post mime type. This query isn't working. Any ideas? ``` $query_args = array( 'post_type' => 'attachment', 'numberposts' => -1, 'post_status' => null, 'post_parent' => null, // any parent 'orderby' => "post_mime_type" ); $attachments = get_p...
As told by mrwweb you have to plug into Wp\_Query orderby statement. ``` add_filter( 'posts_orderby', 'wpse53783_order_by_post_mime_type' ); function wpse53783_order_by_post_mime_type( $orderby ) { global $wpdb; $order = substr( $orderby, strpos( $orderby, ' ' ) ); $orderby = "$wpdb->posts.post_mime_ty...
53,796
<p>I have the following directory structure:</p> <p>Root Install: /Users/philipdowner/Sites/montanaliving</p> <p>Within the root installation I have the following plugin structure:</p> <p>/wp-content/plugins/manifest-rets/</p> <p>Then, within the plugin folder I have 2 php files manifest-rets.php phrets.php</p> <p...
[ { "answer_id": 53798, "author": "Chris_O", "author_id": 251, "author_profile": "https://wordpress.stackexchange.com/users/251", "pm_score": 0, "selected": false, "text": "<p>Sounds like a problem with the way MAMP is setup. Do you have any problems with any of the theme functions like <...
2012/05/31
[ "https://wordpress.stackexchange.com/questions/53796", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/947/" ]
I have the following directory structure: Root Install: /Users/philipdowner/Sites/montanaliving Within the root installation I have the following plugin structure: /wp-content/plugins/manifest-rets/ Then, within the plugin folder I have 2 php files manifest-rets.php phrets.php In the main plugin file, I have the f...
I'm not sure why this isn't working for you. I usually set the plugin path constant using dirname(**FILE**) You could try: ``` define('MR_PLUGIN_PATH', dirname(__FILE__)); //echo MR_PLUGIN_PATH; include_once(MR_PLUGIN_PATH.'/phprets.php'); ``` Also: Are you sure phprets.php exists. You say you have phrets.p...
53,827
<p>Why, when I want to use </p> <pre><code>add_filter( 'author_link', 'foo', 10, 3 ); function foo ( $link, $author_id, $author_nicename ) {} </code></pre> <p>I have to use 3 required parametres? Why cant I do this:</p> <pre><code>add_filter( 'author_link', 'foo' ); function foo ( $author_id ) {} </code></pre> <p>...
[ { "answer_id": 53834, "author": "Eugene Manuilov", "author_id": 8170, "author_profile": "https://wordpress.stackexchange.com/users/8170", "pm_score": 2, "selected": false, "text": "<p>Pay attention that <code>wp_query()</code> doesn't exist in WP core, so I think almost nobody of us can ...
2012/05/31
[ "https://wordpress.stackexchange.com/questions/53827", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16633/" ]
Why, when I want to use ``` add_filter( 'author_link', 'foo', 10, 3 ); function foo ( $link, $author_id, $author_nicename ) {} ``` I have to use 3 required parametres? Why cant I do this: ``` add_filter( 'author_link', 'foo' ); function foo ( $author_id ) {} ``` If you can, please give me some literature about ...
The `wpdb` class is the interface with the database. `WP_Query` uses `wpdb` to query the database. You should use `WP_Query` when dealing with the native WordPress tables, to integrate your code properly with the WordPress environment. Use `wpdb` directly when you need to access data in your own tables.
53,829
<p>Currently all the below bit of code is doing is showing 3 random posts from the same category that the current page resides in. So if the current page falls in the artists category, for example, show 3 random posts from the artists category down the side of the page. The problem I have is that the current post keeps...
[ { "answer_id": 53840, "author": "Bruce Pearson", "author_id": 16534, "author_profile": "https://wordpress.stackexchange.com/users/16534", "pm_score": -1, "selected": false, "text": "<p>I think you need to us the 'post__not_in' parameter.\neg your first query would be something like this:...
2012/05/31
[ "https://wordpress.stackexchange.com/questions/53829", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14149/" ]
Currently all the below bit of code is doing is showing 3 random posts from the same category that the current page resides in. So if the current page falls in the artists category, for example, show 3 random posts from the artists category down the side of the page. The problem I have is that the current post keeps ap...
First, [**do not use `query_posts()` for secondary loops**](http://codex.wordpress.org/Function_Reference/query_posts#Caveats). The `query_posts()` function is intended *only* to modify the primary loop query. Use [`WP_Query()`](http://codex.wordpress.org/Class_Reference/WP_Query) or [`get_posts()`](http://codex.wordpr...
53,841
<p>I'm making a custom RSS feed where I want the full article to display. The problem is that when I use the_content() to output the article, it will only show the excerpt if there is a 'more' tag in that article. How do I force the_content() to output the full article, or is there another function that will achieve th...
[ { "answer_id": 53844, "author": "greatwitenorth", "author_id": 14385, "author_profile": "https://wordpress.stackexchange.com/users/14385", "pm_score": 3, "selected": true, "text": "<p>Setting the $more variable to 0 seem to solve the problem for me. I put the following at the top of my f...
2012/05/31
[ "https://wordpress.stackexchange.com/questions/53841", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14385/" ]
I'm making a custom RSS feed where I want the full article to display. The problem is that when I use the\_content() to output the article, it will only show the excerpt if there is a 'more' tag in that article. How do I force the\_content() to output the full article, or is there another function that will achieve thi...
Setting the $more variable to 0 seem to solve the problem for me. I put the following at the top of my function which output the RSS feed: ``` function outputRSS(){ global $more; $more = 0; //Output my RSS below... } ```
53,849
<p>I want to upload images in my custom plugin options page.</p> <pre><code>&lt;form action="?page=slideshow_options" method="post"&gt; &lt;input type="file" name="async-upload" id="async-upload"&gt; &lt;input type="submit" name="html-upload" id="html-upload" class="button" value="Upload"&gt; &lt;/form&gt; </c...
[ { "answer_id": 53898, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 3, "selected": true, "text": "<p>Wow... this one is not a simple one... it's not a matter of calling the magic function <code>uploadimages()</...
2012/05/31
[ "https://wordpress.stackexchange.com/questions/53849", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4085/" ]
I want to upload images in my custom plugin options page. ``` <form action="?page=slideshow_options" method="post"> <input type="file" name="async-upload" id="async-upload"> <input type="submit" name="html-upload" id="html-upload" class="button" value="Upload"> </form> ``` If I try to check wether submit but...
Wow... this one is not a simple one... it's not a matter of calling the magic function `uploadimages()`... I wish it would :) I've learned from a tutorial I cannot seem to find (but [this one](http://www.webmaster-source.com/2010/01/08/using-the-wordpress-uploader-in-your-plugin-or-theme) seems fair) and from analyzin...
53,852
<p>First of all thank you everyone for all the knowledge base i got reading trough stackexchange. For the first time i couldn't find an answer to my problem.</p> <p>The matter is that with this custom query (which has the purpose to search trough the posts with multiple taxonomy fields):</p> <pre><code>global $wp_que...
[ { "answer_id": 53857, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 2, "selected": false, "text": "<p>Don't stomp on the <code>$wp_query</code> global. Use your own variable to hold your query instead:</p>\n\n...
2012/05/31
[ "https://wordpress.stackexchange.com/questions/53852", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/16637/" ]
First of all thank you everyone for all the knowledge base i got reading trough stackexchange. For the first time i couldn't find an answer to my problem. The matter is that with this custom query (which has the purpose to search trough the posts with multiple taxonomy fields): ``` global $wp_query; $tax_query = arra...
Don't stomp on the `$wp_query` global. Use your own variable to hold your query instead: ``` $custom_query = new WP_Query( $args ); ``` Then, you can use a little trick to fix pagination. Do this *before* the loop: ``` global $wp_query; // Store it for safekeeping $temp_wp_query = $wp_query; // Now blank it out $wp...
53,866
<p>When solving this issue ( <a href="https://wordpress.stackexchange.com/q/53326/12615">Change admin language based on user (in single-site)</a> ), I did a function so that the plugin would auto-hide from all users except one (me:).</p> <p>The flaw is that it only auto-hides when <em>active</em>.</p> <p>At first, it...
[ { "answer_id": 53867, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 3, "selected": true, "text": "<p>Apparently, there's no way to remove <em>one</em> plugin from the Must-Use list...</p>\n\n<p>But then, found ...
2012/05/31
[ "https://wordpress.stackexchange.com/questions/53866", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12615/" ]
When solving this issue ( [Change admin language based on user (in single-site)](https://wordpress.stackexchange.com/q/53326/12615) ), I did a function so that the plugin would auto-hide from all users except one (me:). The flaw is that it only auto-hides when *active*. At first, it was a mu-plugin, but I had to enab...
Apparently, there's no way to remove *one* plugin from the Must-Use list... But then, found a filter that does even better: `show_advanced_plugins` will completely hide the sight of the Must-Use plugins. After all, if you're trying to hide something of this nature, then hide it all... It's inside the class `WP_P...
53,871
<p>How can I display a post with a certain category in the page template instead of default category template.</p> <p>For an example, I want to show all posts under category "Scott" with the page template ("page.php").</p>
[ { "answer_id": 53874, "author": "user1337", "author_id": 16338, "author_profile": "https://wordpress.stackexchange.com/users/16338", "pm_score": 0, "selected": false, "text": "<p>There's two different types of content:\n1. Pages <a href=\"http://codex.wordpress.org/Pages\" rel=\"nofollow...
2012/05/31
[ "https://wordpress.stackexchange.com/questions/53871", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13434/" ]
How can I display a post with a certain category in the page template instead of default category template. For an example, I want to show all posts under category "Scott" with the page template ("page.php").
I'm pretty sure you could also do what you want by filtering `template_include`. This is super-untested, but maybe this can get you headed in the right direction: ``` function wpse53871( $template ) { global $post; // check if is a Post and in the 'scott' category if( is_single( $post->ID ) && has_category...
53,904
<p>Every time I call WP_Query() in the function below, Wordpress leaks 8 megs of memory. And since I call this function a lot, things get hairy pretty quickly... :( I've tried unsetting the resulting $queryObject as well as periodically calling wp_cache_flush(), but neither seems to have any effect. Any thoughts?</p...
[ { "answer_id": 54405, "author": "rinogo", "author_id": 10388, "author_profile": "https://wordpress.stackexchange.com/users/10388", "pm_score": 5, "selected": true, "text": "<p>Excellent responses on WP Hackers:\n<a href=\"http://lists.automattic.com/pipermail/wp-hackers/2012-June/043213....
2012/06/01
[ "https://wordpress.stackexchange.com/questions/53904", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10388/" ]
Every time I call WP\_Query() in the function below, Wordpress leaks 8 megs of memory. And since I call this function a lot, things get hairy pretty quickly... :( I've tried unsetting the resulting $queryObject as well as periodically calling wp\_cache\_flush(), but neither seems to have any effect. Any thoughts? ``` ...
Excellent responses on WP Hackers: <http://lists.automattic.com/pipermail/wp-hackers/2012-June/043213.html> > > What you're doing with that query, is loading EVERY matching post into > memory, including the full post contents. > As you can imagine, this is probably quite a lot of items. > > > You can pass 'fields...
53,943
<p>Hope you can assist.</p> <p><strong>Background:</strong></p> <p>I have a multisite config. Users need to be able to update their profile from the frontend, via their profile page, which is something like, <code>http://example.com/forum/user/fred@example.com</code> thanks to bbpress.</p> <p>However only Super-Admi...
[ { "answer_id": 54136, "author": "Pontus Abrahamsson", "author_id": 16722, "author_profile": "https://wordpress.stackexchange.com/users/16722", "pm_score": -1, "selected": false, "text": "<p>Is there something like current_user_can()... or is_super_admin near the edit link? cus it sounds ...
2012/06/01
[ "https://wordpress.stackexchange.com/questions/53943", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15069/" ]
Hope you can assist. **Background:** I have a multisite config. Users need to be able to update their profile from the frontend, via their profile page, which is something like, `http://example.com/forum/user/fred@example.com` thanks to bbpress. However only Super-Admins can edit their profile. There is a little edi...
Only super users can edit profiles in Wordpress Multisite. This is because user profiles are site-independent in multisite. A user has one profile, but may be a member of multiple sites with multiple owners. You can't let one of them screw around with the user's profile... If you really want to take control of this, y...