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
48,299
<p>I get this error while trying to load wordpress in a smarty template. But when I visit wordpress I dont get that error any where.</p> <p>the code I use to load wordpress is :</p> <pre><code>{php}include $_SERVER['DOCUMENT_ROOT'].'/wordpress/wp-load.php'; get_header();{/php} </code></pre> <p>The Error : Fatal erro...
[ { "answer_id": 48302, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p>Read <a href=\"http://ottopress.com/2010/dont-include-wp-load-please/\" rel=\"nofollow noreferrer\">Don’t include wp-l...
2012/04/07
[ "https://wordpress.stackexchange.com/questions/48299", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13285/" ]
I get this error while trying to load wordpress in a smarty template. But when I visit wordpress I dont get that error any where. the code I use to load wordpress is : ``` {php}include $_SERVER['DOCUMENT_ROOT'].'/wordpress/wp-load.php'; get_header();{/php} ``` The Error : Fatal error: Call to a member function add\...
Found the solution. just add this code before including wp-blog-header.php. ``` global $wp_rewrite; ``` source: <https://github.com/kayue/WordpressBundle/issues/2>
48,304
<p>Im trying to wrap video urls and embed code in a classed div so that I can style it. The vid code is being pulled from the custom meta value I've setup for the video post type. Nothing I've been able to find via the forum or google seems to quite answer my question. </p> <p>Use case: The user either enters a youtub...
[ { "answer_id": 48308, "author": "David", "author_id": 11218, "author_profile": "https://wordpress.stackexchange.com/users/11218", "pm_score": 1, "selected": false, "text": "<p>I wrote a very quick and simple mark-up that works -- I know WordPress has a built in <a href=\"http://codex.wor...
2012/04/07
[ "https://wordpress.stackexchange.com/questions/48304", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13551/" ]
Im trying to wrap video urls and embed code in a classed div so that I can style it. The vid code is being pulled from the custom meta value I've setup for the video post type. Nothing I've been able to find via the forum or google seems to quite answer my question. Use case: The user either enters a youtube url into...
I wrote a very quick and simple mark-up that works -- I know WordPress has a built in [oEmbed](http://codex.wordpress.org/Embeds) system, this doesn't follow it - **at all**. However, I'd be a fool not to share it if you can adapt a solution that works *for me at least*. **Sampled Code Notes:** For this project I had...
48,314
<p>I migrated a site from my testing server to the live server. Everything transferred normally only the featured images are broken and not displaying. The URL's are being rendered incorrectly even if i re-upload the image.</p> <p>the testing server is dave-conner.com</p> <p>the live server is qmpdirect.com</p> <p>...
[ { "answer_id": 48342, "author": "brasofilo", "author_id": 12615, "author_profile": "https://wordpress.stackexchange.com/users/12615", "pm_score": 1, "selected": false, "text": "<p>I'd recommend taking a look at the database.</p>\n\n<p>1) check the upload_path option and correct directly ...
2012/04/08
[ "https://wordpress.stackexchange.com/questions/48314", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14975/" ]
I migrated a site from my testing server to the live server. Everything transferred normally only the featured images are broken and not displaying. The URL's are being rendered incorrectly even if i re-upload the image. the testing server is dave-conner.com the live server is qmpdirect.com the page where the issue ...
I'd recommend taking a look at the database. 1) check the upload\_path option and correct directly if needed *(well, this one can be altered here too: wp-admin/options.php)* ``` SELECT * FROM `wp_options` WHERE `option_name` = 'upload_path' ``` 2) check the guid of the attachments and use [this plugin](http://word...
48,329
<p>This isn't a question about how to build a WordPress plugin. Rather, what, if any, guides could be applied to how to put together the file architecture of any plugin.</p> <p>Some other programming languages or libraries have very controlled ways of organizing directories and files. Sometimes this is annoying and hig...
[ { "answer_id": 48366, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 3, "selected": false, "text": "<p>It depends on the plugin. This is my basic structure for nearly every plugin:</p>\n\n<pre><code>my-plugi...
2012/04/08
[ "https://wordpress.stackexchange.com/questions/48329", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3293/" ]
This isn't a question about how to build a WordPress plugin. Rather, what, if any, guides could be applied to how to put together the file architecture of any plugin. Some other programming languages or libraries have very controlled ways of organizing directories and files. Sometimes this is annoying and highlights t...
Note that plugins are all "controllers" by WP standards. It depends on what the plugin is supposed to do, but in all cases I would try to separate the screen output from the PHP code as much as possible. Here's one way to do that easily - first, define a function that loads the template: ``` function my_plugin_load_...
48,332
<p>Is there code or a plugin that would make it possible to add default backgrounds, like you can with default headers in Twenty ten. Seems like the same frame work for backgrounds and headers.</p>
[ { "answer_id": 48333, "author": "developdaly", "author_id": 3293, "author_profile": "https://wordpress.stackexchange.com/users/3293", "pm_score": 3, "selected": true, "text": "<p>There's no default way to do that yet, though there is a <a href=\"http://core.trac.wordpress.org/ticket/1862...
2012/04/08
[ "https://wordpress.stackexchange.com/questions/48332", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4418/" ]
Is there code or a plugin that would make it possible to add default backgrounds, like you can with default headers in Twenty ten. Seems like the same frame work for backgrounds and headers.
There's no default way to do that yet, though there is a [Trac ticket](http://core.trac.wordpress.org/ticket/18623). I found this (untested) that may work for you: <http://www.devblog.fr/2011/05/16/plusieurs-fonds-personnalises-wordpress-add_custom_background/> It's also worth noting the 3.4's [new way of defining a d...
48,334
<p>Is it possible to force previous/next navigation to browse through the posts (back and forth) that are only inside the same category (and to exclude other categories)?</p>
[ { "answer_id": 116519, "author": "Amit Sharma", "author_id": 28093, "author_profile": "https://wordpress.stackexchange.com/users/28093", "pm_score": 3, "selected": false, "text": "<p>The <a href=\"http://codex.wordpress.org/Function_Reference/previous_post_link\" rel=\"nofollow\">functio...
2012/04/08
[ "https://wordpress.stackexchange.com/questions/48334", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14941/" ]
Is it possible to force previous/next navigation to browse through the posts (back and forth) that are only inside the same category (and to exclude other categories)?
The [functions](http://codex.wordpress.org/Function_Reference/previous_post_link) accept an `$in_same_cat` argument, the default value of which is false. Just set that to true. ``` previous_post_link($format, $link, true); next_post_link($format, $link, true); ```
48,337
<p>I created a widget that uses a jquery plugin, and I used is_active_widget to enqueue the script, it's working fine but it's also including the script even on pages that doesn't show this widget. so is there a way to only enqueue the script if this widget is showing ?</p> <p>thanks in advance.</p>
[ { "answer_id": 48346, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 5, "selected": true, "text": "<p>You should be able to call <code>wp_enqueue_script()</code> as part of your Widget output.</p>\n\n<h3>Edit</...
2012/04/08
[ "https://wordpress.stackexchange.com/questions/48337", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14490/" ]
I created a widget that uses a jquery plugin, and I used is\_active\_widget to enqueue the script, it's working fine but it's also including the script even on pages that doesn't show this widget. so is there a way to only enqueue the script if this widget is showing ? thanks in advance.
You should be able to call `wp_enqueue_script()` as part of your Widget output. ### Edit Quick-and-dirty, using the bare-bones [Widgets API](http://codex.wordpress.org/Widgets_API) class example: ``` <?php class wpse48337_Widget extends WP_Widget { public function __construct() { // widget actual proces...
48,348
<p>The line breaks on my comments are not being considered. I've inspected the elements in google chrome and it seems that wordpress is not adding paragraph tags <code>&lt;p&gt;</code> to them, while in the body text it does.</p> <p>The comments.php in my template has the following snippet:</p> <pre><code>&lt;ol clas...
[ { "answer_id": 48351, "author": "Sagive", "author_id": 7990, "author_profile": "https://wordpress.stackexchange.com/users/7990", "pm_score": -1, "selected": false, "text": "<p><strong>When ever your css isnt updated (and as a developer this happens!) you must have...</strong> </p>\n\n<...
2012/04/08
[ "https://wordpress.stackexchange.com/questions/48348", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13147/" ]
The line breaks on my comments are not being considered. I've inspected the elements in google chrome and it seems that wordpress is not adding paragraph tags `<p>` to them, while in the body text it does. The comments.php in my template has the following snippet: ``` <ol class="commentlist"> <?php wp_list_commen...
for the widget html, don't forget to update/change the code of `register_sidebar()` in functions.php of your theme: <http://codex.wordpress.org/Function_Reference/register_sidebar>
48,356
<p>Is there a way to define <code>wp_editor()</code> with custom tinyMCE buttons?</p> <p>I've noticed the <a href="http://codex.wordpress.org/Function_Reference/wp_editor">wp_editor function reference</a> mentions that one of the <code>$settings</code> arguments can be <code>tinymce (array) (optional) Load TinyMCE, ca...
[ { "answer_id": 48709, "author": "Tomas Buteler", "author_id": 5552, "author_profile": "https://wordpress.stackexchange.com/users/5552", "pm_score": 5, "selected": true, "text": "<p>You pretty much had it, according to the description.</p>\n\n<p>Here's what you might be looking for for in...
2012/04/08
[ "https://wordpress.stackexchange.com/questions/48356", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6344/" ]
Is there a way to define `wp_editor()` with custom tinyMCE buttons? I've noticed the [wp\_editor function reference](http://codex.wordpress.org/Function_Reference/wp_editor) mentions that one of the `$settings` arguments can be `tinymce (array) (optional) Load TinyMCE, can be used to pass settings directly to TinyMCE ...
You pretty much had it, according to the description. Here's what you might be looking for for instances 2 and 3 (for instance 1 you can leave the settings empty to get the default set of buttons): Instance 2: ``` wp_editor( $distribution, 'distribution', array( 'media_buttons' => false, 'tex...
48,362
<p>There doesn't seem to be a standard technique for differentiating first/top posts. After looking around, I found this method:</p> <pre><code>$current_query = new WP_Query('post_type=current&amp;post_status=publish'); // Pull out top/first post $first_post = ( $paged == 0 ) ? $posts[0]-&gt;ID : ''; while ($curren...
[ { "answer_id": 48365, "author": "aaronwaggs", "author_id": 5376, "author_profile": "https://wordpress.stackexchange.com/users/5376", "pm_score": 3, "selected": true, "text": "<p>You shouldn't need to do any special queries for this. Here is one way to accomplish it</p>\n\n<pre><code>/**\...
2012/04/09
[ "https://wordpress.stackexchange.com/questions/48362", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14751/" ]
There doesn't seem to be a standard technique for differentiating first/top posts. After looking around, I found this method: ``` $current_query = new WP_Query('post_type=current&post_status=publish'); // Pull out top/first post $first_post = ( $paged == 0 ) ? $posts[0]->ID : ''; while ($current_query->have_posts()...
You shouldn't need to do any special queries for this. Here is one way to accomplish it ``` /** * conditional check ensures special class only shows on top post on first page. * if you want top post on page 2, etc. to have special class, just set $first_post to true */ if( (int) get_query_var( 'paged' ) > 1 ){ ...
48,377
<p>We have started with a lot of users who writes articles for the site. We want now rate every article internally for haveing an overview of the users with the best articles. Does someone know a plugin to rate articles internally, so they will not show up on the site, only in the dashboard of WP.</p> <p>Thanks,</p>...
[ { "answer_id": 48383, "author": "offroff", "author_id": 13073, "author_profile": "https://wordpress.stackexchange.com/users/13073", "pm_score": 0, "selected": false, "text": "<p>You have several options but I think a good and easy solution for you would be to add a custom taxonomy. </p>\...
2012/04/09
[ "https://wordpress.stackexchange.com/questions/48377", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15002/" ]
We have started with a lot of users who writes articles for the site. We want now rate every article internally for haveing an overview of the users with the best articles. Does someone know a plugin to rate articles internally, so they will not show up on the site, only in the dashboard of WP. Thanks, Tom
My solution to this question would be to add a custom field / metabox to all of your posts where you can select a desired rating from a drop down menu. I would also then add the internal rating that you assign to post within the posts list screen so you can see at a glance each posts rating instead of having to click...
48,397
<p>I am soooo close to getting this to work but I have one outstanding issues.</p> <ol> <li>The featured posts code keeps repeating itself before/after each post.</li> </ol> <p>Any help would be greatly appreciated. The code below is what is currently in my loop.</p> <p><strong>NEW CODE per CHIP</strong></p> <pre><...
[ { "answer_id": 48400, "author": "Michelle", "author_id": 16, "author_profile": "https://wordpress.stackexchange.com/users/16", "pm_score": 1, "selected": false, "text": "<p>Here you go: <a href=\"http://pastebin.com/dsZEbC6a\" rel=\"nofollow\">http://pastebin.com/dsZEbC6a</a></p>\n\n<p>F...
2012/04/09
[ "https://wordpress.stackexchange.com/questions/48397", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1623/" ]
I am soooo close to getting this to work but I have one outstanding issues. 1. The featured posts code keeps repeating itself before/after each post. Any help would be greatly appreciated. The code below is what is currently in my loop. **NEW CODE per CHIP** ``` <?php // Define featured posts query $featured_query ...
After discussing in chat and seeing the parent index.php file: <http://pastebin.com/27r0FJ3x> The main loop in loop.php is not actually the main loop at all: ``` <div id="main" class="<?php echo $containerWidth; ?>" role="main"> <?php get_template_part('breadcrumbs'); ?> <?php if ( have_pos...
48,409
<p>I have a custom post type that I want to do a type of news feed for, but I only want to show the ones with the most views. I know I can do a query for an "archive" of my post types, but my question is "how to sort the query by views"?</p>
[ { "answer_id": 48414, "author": "Hiren Makwana", "author_id": 14501, "author_profile": "https://wordpress.stackexchange.com/users/14501", "pm_score": 1, "selected": false, "text": "<p>Hope this code will helpful...</p>\n\n<pre><code> $right_now = gmdate(\"Y-m-d\");\n$qstr = \"\n SE...
2012/04/09
[ "https://wordpress.stackexchange.com/questions/48409", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13170/" ]
I have a custom post type that I want to do a type of news feed for, but I only want to show the ones with the most views. I know I can do a query for an "archive" of my post types, but my question is "how to sort the query by views"?
[WP post views](http://wordpress.org/extend/plugins/wp-postviews/) plugin already does this job very well. So just install that plugin , then use function like this ``` <?php if (function_exists('get_most_viewed')): ?> <ul> <?php get_most_viewed('custom post type name',20); ?> </ul> <?php endif; ?> `...
48,415
<p>Right now I'm doing this (pseudo code)</p> <pre><code>posts = content_type("special_stuff"); $i = 0; $n = 5; $while(have_posts) { if($i == $n) { // print the content } ++$i; } </code></pre> <p>This is what I'm doing to always get the <code>n</code>th item. I'm sure there is a better way, but I'...
[ { "answer_id": 48431, "author": "keatch", "author_id": 2727, "author_profile": "https://wordpress.stackexchange.com/users/2727", "pm_score": 1, "selected": false, "text": "<p>Suggestion:</p>\n\n<p>I suppose that you have a backend interface that use custom fields to do this. </p>\n\n<p>D...
2012/04/09
[ "https://wordpress.stackexchange.com/questions/48415", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13170/" ]
Right now I'm doing this (pseudo code) ``` posts = content_type("special_stuff"); $i = 0; $n = 5; $while(have_posts) { if($i == $n) { // print the content } ++$i; } ``` This is what I'm doing to always get the `n`th item. I'm sure there is a better way, but I'm kind of a WP noob. Related: 1. (t...
Managed to work this out. I have posted the step on [stackoverflow](https://stackoverflow.com/questions/10086115/wordpress-is-cut-off-when-linking-to-pages-using-index-php-page-name). Hope it helps someone.
48,416
<p>What is the proper way to include a stylesheet with my options panels in wp-admin for a given plugin or theme. In other words -- the stylesheet that styles the panels.</p> <p>I mean, in my panel template code, I'm doing something like...</p> <pre><code>&lt;style type="text/css"&gt; @import url("../wp-content/plugi...
[ { "answer_id": 48431, "author": "keatch", "author_id": 2727, "author_profile": "https://wordpress.stackexchange.com/users/2727", "pm_score": 1, "selected": false, "text": "<p>Suggestion:</p>\n\n<p>I suppose that you have a backend interface that use custom fields to do this. </p>\n\n<p>D...
2012/04/09
[ "https://wordpress.stackexchange.com/questions/48416", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13/" ]
What is the proper way to include a stylesheet with my options panels in wp-admin for a given plugin or theme. In other words -- the stylesheet that styles the panels. I mean, in my panel template code, I'm doing something like... ``` <style type="text/css"> @import url("../wp-content/plugins/myplugin/panels/style.cs...
Managed to work this out. I have posted the step on [stackoverflow](https://stackoverflow.com/questions/10086115/wordpress-is-cut-off-when-linking-to-pages-using-index-php-page-name). Hope it helps someone.
48,422
<p>I'm trying to block any admin of a Wordpress install from being able to modify certain pages, the sort of stuff detailed here: <a href="http://wackao.com/be-a-wordpress-super-administrator/" rel="nofollow">http://wackao.com/be-a-wordpress-super-administrator/</a> . Is this even possible? Thank you.</p> <p>I would l...
[ { "answer_id": 48423, "author": "RyanS", "author_id": 15464, "author_profile": "https://wordpress.stackexchange.com/users/15464", "pm_score": 1, "selected": false, "text": "<p>Yes, anything is possible with the use of the internet combined with precise and thought-out questions. Here's a...
2012/04/05
[ "https://wordpress.stackexchange.com/questions/48422", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15386/" ]
I'm trying to block any admin of a Wordpress install from being able to modify certain pages, the sort of stuff detailed here: <http://wackao.com/be-a-wordpress-super-administrator/> . Is this even possible? Thank you. I would like to do this by modifying the core word press files.
I would recommend creating a **Custom User Role**, using the [`add_role()`](http://codex.wordpress.org/Function_Reference/add_role) function, such as a "*Site Admin*" or "*Sub-Admin*" (or whatever you want to call it). Then, you can [*assign specific user capabilities*](http://codex.wordpress.org/Roles_and_Capabilities...
48,435
<p>I created custom post types &amp; custom taxonomies for these.</p> <p>Example: <code>actors</code> (taxonomy) for <code>movies</code> (post type).</p> <p>Now I want to show up in my widget some terms and a <code>more</code> link for the <code>actors</code> terms archive.</p> <p>How do I get the taxonomy archive l...
[ { "answer_id": 48436, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 1, "selected": false, "text": "<p>The archive link for any taxonomy follows this pattern:</p>\n\n<pre><code>http://{siteurl}/{taxonomy}/{term}\n</code>...
2012/04/09
[ "https://wordpress.stackexchange.com/questions/48435", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10468/" ]
I created custom post types & custom taxonomies for these. Example: `actors` (taxonomy) for `movies` (post type). Now I want to show up in my widget some terms and a `more` link for the `actors` terms archive. How do I get the taxonomy archive link / url?
Use `get_term_link` e.g. to print out a list of actors terms linking to the archives: ``` $terms = get_terms('actors'); echo '<ul>'; foreach ($terms as $term) { echo '<li><a href="'.get_term_link($term).'">'.$term->name.'</a></li>'; } echo '</ul>'; ``` However! If what you really mean is the equivilant of the ...
48,458
<p>i am using a front built in (article directory plugin) tinymce with wp_editor.<br> what ever i tried i cant get the word counter to work automatically.. </p> <p>i can count the words fine in the HTML tab using a jquery word counter but not<br> in the wysisyg tab since its an iframe... </p> <p>i got some new white ...
[ { "answer_id": 48473, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 0, "selected": false, "text": "<p>You find my solution for counter on words for comments in <a href=\"https://wordpress.stackexchange.com/a/38764/17...
2012/04/10
[ "https://wordpress.stackexchange.com/questions/48458", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7990/" ]
i am using a front built in (article directory plugin) tinymce with wp\_editor. what ever i tried i cant get the word counter to work automatically.. i can count the words fine in the HTML tab using a jquery word counter but not in the wysisyg tab since its an iframe... i got some new white hairs dealing with...
**A while later i decided to try it again... (needed it for a project) this time i went for clean jquery and i got it to work!** here it is: the working & easy to use way to count words while they are being written inside a wp\_editor both in the html editor and visual editor. ``` <script type="text/javascr...
48,481
<p>I want to access my post with id 17 like this:</p> <p><a href="http://localhost/archives/17/moot-bla-foo-ramble" rel="nofollow">http://localhost/archives/17/moot-bla-foo-ramble</a></p> <p>In other words, the id shall decide, everything thereafter may (or may not) be the slug or anything else. Much like these links...
[ { "answer_id": 48482, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 3, "selected": true, "text": "<p>You shouldn't use the htaccess instead you should use the WordPress APIs</p>\n\n<p>e.g.</p>\n\n<pre><code>func...
2012/04/10
[ "https://wordpress.stackexchange.com/questions/48481", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13561/" ]
I want to access my post with id 17 like this: <http://localhost/archives/17/moot-bla-foo-ramble> In other words, the id shall decide, everything thereafter may (or may not) be the slug or anything else. Much like these links leading to the same page (many other sites do the same): * <http://www.amazon.de/pair-of-b...
You shouldn't use the htaccess instead you should use the WordPress APIs e.g. ``` function custom_rewrite( $wp_rewrite ) { $feed_rules = array( 'archives/(\d+)(?:/.*)+' => 'index.php?p='. $wp_rewrite->preg_index(1) ); // ( array merge must be done this way, to ensure new rule comes first ) $...
48,484
<p>I have no idea how to do this and really need your help please …</p> <p>First I created a custom-post-template called "wr_event" - then I added a custom taxonomy (like categories) to this post-template!</p> <pre><code>register_taxonomy( 'Type of event', 'wr_event', array( 'taxonomy' =&gt; 'even...
[ { "answer_id": 48482, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 3, "selected": true, "text": "<p>You shouldn't use the htaccess instead you should use the WordPress APIs</p>\n\n<p>e.g.</p>\n\n<pre><code>func...
2012/04/10
[ "https://wordpress.stackexchange.com/questions/48484", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3529/" ]
I have no idea how to do this and really need your help please … First I created a custom-post-template called "wr\_event" - then I added a custom taxonomy (like categories) to this post-template! ``` register_taxonomy( 'Type of event', 'wr_event', array( 'taxonomy' => 'event_type', 'label...
You shouldn't use the htaccess instead you should use the WordPress APIs e.g. ``` function custom_rewrite( $wp_rewrite ) { $feed_rules = array( 'archives/(\d+)(?:/.*)+' => 'index.php?p='. $wp_rewrite->preg_index(1) ); // ( array merge must be done this way, to ensure new rule comes first ) $...
48,491
<p>I'm using a shortcode to pull in different loops via the loops-name.php. For some reason it is always at the top of the page. I googled it and using echo instead of return causes that problem but with my code I am not using echo. Here's the shortcode:</p> <pre><code>// setup the shortcode for use function friendly_...
[ { "answer_id": 48493, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 4, "selected": false, "text": "<p>Your included file is essentially echo-ing HTML. For instance</p>\n\n<pre><code>&lt;?php\n //Some PHP\n e...
2012/04/10
[ "https://wordpress.stackexchange.com/questions/48491", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13392/" ]
I'm using a shortcode to pull in different loops via the loops-name.php. For some reason it is always at the top of the page. I googled it and using echo instead of return causes that problem but with my code I am not using echo. Here's the shortcode: ``` // setup the shortcode for use function friendly_loop_shortcode...
You can buffer the output like this: ``` ob_start(); include(locate_template('loop-'.$module.'.php')); return ob_get_clean(); ``` EDIT. I tried this, worked fine. ``` function friendly_loop_shortcode( $atts, $content = null ) { extract( shortcode_atts( array( 'category' => '', 'module' => '' ...
48,514
<p>How can get a modal window to work from within the wordpress admin?</p> <p>I want to create a modal window that will work from a meta box within the wp-admin.</p> <p>Any ideas?</p>
[ { "answer_id": 48519, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 5, "selected": true, "text": "<p>Give the anchor a class of thickbox and make sure that the thickbox script is enqueued on your admin page usin...
2012/04/10
[ "https://wordpress.stackexchange.com/questions/48514", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3246/" ]
How can get a modal window to work from within the wordpress admin? I want to create a modal window that will work from a meta box within the wp-admin. Any ideas?
Give the anchor a class of thickbox and make sure that the thickbox script is enqueued on your admin page using `add_thickbox` ``` add_thickbox(); ``` and ``` <a href="your url" class="thickbox">click here</a> ``` You can see what `add_thickbox` does here: <http://hitchhackerguide.com/2011/02/11/add_thickbox/>
48,516
<p>I want to filter posts in such a way that only posts, for which <code>get_post_meta($post->ID, "project_cat", true)</code> (it returns a post ID) is equal to my specified value, are shown.</p> <p>Any way to do this?</p> <p>I am especially interested in ways to do it compatible with <a href="http://www.ericmmartin....
[ { "answer_id": 48521, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 5, "selected": true, "text": "<p>The <code>WP_Query</code> object accepts a post meta argument. Generally speaking you want to do the follo...
2012/04/10
[ "https://wordpress.stackexchange.com/questions/48516", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13880/" ]
I want to filter posts in such a way that only posts, for which `get_post_meta($post->ID, "project_cat", true)` (it returns a post ID) is equal to my specified value, are shown. Any way to do this? I am especially interested in ways to do it compatible with [WP-Paginate plugin](http://www.ericmmartin.com/projects/wp-...
The `WP_Query` object accepts a post meta argument. Generally speaking you want to do the following: ``` $my_query = new WP_Query( array( 'post_type' => 'post', 'meta_query' => array( array( 'key' => 'project_cat', 'value' => 'my-value', ) ), // Oth...
48,530
<pre><code>function load_my_script(){ wp_register_script( 'my_script', get_template_directory_uri() . '/js/myscript.js', 'jquery' ); wp_enqueue_script( 'my_script', 'jquery'); } add_action('wp_enqueue_scripts', 'load_my_script'); </code></pre> <p>myscript.js is loading before jquery, why? And how do I make it load AFT...
[ { "answer_id": 48531, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 4, "selected": false, "text": "<p>You have a typo in your code. It <em>should</em> be:</p>\n\n<pre><code>function load_my_script(){\n wp_register_s...
2012/04/10
[ "https://wordpress.stackexchange.com/questions/48530", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11059/" ]
``` function load_my_script(){ wp_register_script( 'my_script', get_template_directory_uri() . '/js/myscript.js', 'jquery' ); wp_enqueue_script( 'my_script', 'jquery'); } add_action('wp_enqueue_scripts', 'load_my_script'); ``` myscript.js is loading before jquery, why? And how do I make it load AFTER jquery? Thanks.
You have a typo in your code. It *should* be: ``` function load_my_script(){ wp_register_script( 'my_script', get_template_directory_uri() . '/js/myscript.js', array( 'jquery' ) ); wp_enqueue_script( 'my_script' ); } add_action('wp_enqueue_scripts', 'load_my_script'); ``` The j...
48,537
<p>Its a <strong>wordpress+jQuery</strong> question. Can't post it on stackoverflow because i believe it involves wordpress knowledge too.</p> <p><strong>What I am trying to achieve:</strong> I am attaching the wordpress async media uploader on "add post" page metabox so user can upload lots of images simply drag and ...
[ { "answer_id": 48539, "author": "Thomas", "author_id": 9610, "author_profile": "https://wordpress.stackexchange.com/users/9610", "pm_score": 0, "selected": false, "text": "<p>Can you specify the type of response sent back? JSON would definitely be preferred here over HTML. If not, I don'...
2012/04/10
[ "https://wordpress.stackexchange.com/questions/48537", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3094/" ]
Its a **wordpress+jQuery** question. Can't post it on stackoverflow because i believe it involves wordpress knowledge too. **What I am trying to achieve:** I am attaching the wordpress async media uploader on "add post" page metabox so user can upload lots of images simply drag and drop them into the uploader and don'...
I could but i really don't want to post the work of others here, even if it's open source code. Rilwis Meta Box Class has a plupload field, which has a custom upload handler. If you mind to take a look: <https://github.com/rilwis/meta-box> resp: <https://github.com/rilwis/meta-box/blob/master/inc/fields/plupload-ima...
48,554
<p>I am trying to display 3 post_thumbnails from a custom post type "portfolio" on my homepage template. So one from post 'A' , one from post 'B' and one from post 'C' The image from post A will be set as post_thumbnail('large') while B &amp; C need to be set to post_thumbnail('thumbnail').</p> <p>I've set a custom WP...
[ { "answer_id": 48583, "author": "Ben Huddleston", "author_id": 15062, "author_profile": "https://wordpress.stackexchange.com/users/15062", "pm_score": 0, "selected": false, "text": "<p>mattc,</p>\n\n<p>You're problem is that you have all of the elements inside the loop. You need to set ...
2012/04/10
[ "https://wordpress.stackexchange.com/questions/48554", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8663/" ]
I am trying to display 3 post\_thumbnails from a custom post type "portfolio" on my homepage template. So one from post 'A' , one from post 'B' and one from post 'C' The image from post A will be set as post\_thumbnail('large') while B & C need to be set to post\_thumbnail('thumbnail'). I've set a custom WP\_Query loo...
Try this: ``` <?php get_header(); ?> <div id="content" class="clearfix row"> <article id="post-<?php the_ID(); ?>" <?php post_class('clearfix'); ?> role="article"> <section id="work" class="row"> <div class="span3"> <h3>Recent Work</h3> <p>Intro Lorem ipsum</p> <...
48,557
<p>I am looking for a way to display the most used tags over the last 30 days. I am no coder, but I have come up with this mashup to display a list of the most used 28 tags (preference to fit my theme). I cannot, for the life of me, figure out how to limit the tags to the most used in the last 30 days.</p> <p>Here is ...
[ { "answer_id": 48603, "author": "Rajeev Vyas", "author_id": 6961, "author_profile": "https://wordpress.stackexchange.com/users/6961", "pm_score": 0, "selected": false, "text": "<p>You can limit tags using \"number\" parameter...</p>\n\n<pre><code> $tags = get_tags( array('orderby' =&gt; ...
2012/04/10
[ "https://wordpress.stackexchange.com/questions/48557", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14558/" ]
I am looking for a way to display the most used tags over the last 30 days. I am no coder, but I have come up with this mashup to display a list of the most used 28 tags (preference to fit my theme). I cannot, for the life of me, figure out how to limit the tags to the most used in the last 30 days. Here is what I hav...
The problem was that the SQL query code was getting the `term_taxonomy_id`, not the actual tag ID. I added an additional INNER JOIN using the `term_taxonomy` table to get the `term_id`. This seems to work, but if a mod can improve this, please do! ``` <ul id="footer-tags"> <?php $wpdb->show_errors(); ?> <?php global...
48,558
<p>I have a custom taxonomy named <code>location</code> and I want to add sections like 'news' and 'marketplace' for each term, so my url looks like <code>/location/montreal/news/</code></p> <p>It works perfectly until I try to add pagination. Here is my code : </p> <pre><code>add_action( 'init', 'region_rewrite' ); ...
[ { "answer_id": 71472, "author": "Olivier", "author_id": 23275, "author_profile": "https://wordpress.stackexchange.com/users/23275", "pm_score": 2, "selected": false, "text": "<p>I believe you could just call the paged <code>add_rewrite_url</code> <strong>last</strong> so that it is check...
2012/04/10
[ "https://wordpress.stackexchange.com/questions/48558", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15056/" ]
I have a custom taxonomy named `location` and I want to add sections like 'news' and 'marketplace' for each term, so my url looks like `/location/montreal/news/` It works perfectly until I try to add pagination. Here is my code : ``` add_action( 'init', 'region_rewrite' ); function region_rewrite() { global $wp;...
I believe you could just call the paged `add_rewrite_url` **last** so that it is checked first. Otherwise the paged version will never get any match, since the non-paged one will always match first. Should also work if you remove 'top' from your arguments. Also, check out this page for a nice way of debugging those 40...
48,560
<p>When I go to the url <code>mysite.com/photos/120</code> I'm <em>wanting</em> to get the <code>120</code> out.</p> <p>In the PHP I want to be able to grab these "parameters" like the url was <code>mysite.com?page=photos&amp;id=120</code> or even just <code>mysite.com/photos?id=120</code></p> <p>Can I leverage <stro...
[ { "answer_id": 48563, "author": "Daniel Bachhuber", "author_id": 135, "author_profile": "https://wordpress.stackexchange.com/users/135", "pm_score": 2, "selected": false, "text": "<p>Depending on how the rules are being generated, you can use the <a href=\"http://codex.wordpress.org/Func...
2012/04/10
[ "https://wordpress.stackexchange.com/questions/48560", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13170/" ]
When I go to the url `mysite.com/photos/120` I'm *wanting* to get the `120` out. In the PHP I want to be able to grab these "parameters" like the url was `mysite.com?page=photos&id=120` or even just `mysite.com/photos?id=120` Can I leverage **rewrite rules**? Or do I need to do **regex** in php to get what I want? \...
After many days of doing research on this, the answer was this simple: ``` $wp_query->query_vars['page'] ``` wrap that in an `intval` and viola.
48,571
<p>I have been using wp-caption for so long but for a template I am working on I want to delete this tag and only show the image, I used display:none; function but it does not show the image , any help ?</p>
[ { "answer_id": 48579, "author": "zyzzyzus", "author_id": 15008, "author_profile": "https://wordpress.stackexchange.com/users/15008", "pm_score": 0, "selected": false, "text": "<p>This code found on the WP Support forums (<a href=\"http://wordpress.org/support/topic/can-you-remove-caption...
2012/04/11
[ "https://wordpress.stackexchange.com/questions/48571", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15059/" ]
I have been using wp-caption for so long but for a template I am working on I want to delete this tag and only show the image, I used display:none; function but it does not show the image , any help ?
You'll need to use the img\_caption\_shortcode filter to do this. Pretty certain the alignment of the image (floating left/right) is part of the caption so you'll lose the ability to do that with this code. ``` function imageOnly($deprecated, $attr, $content = null) { return do_shortcode( $content ); } add_filte...
48,572
<p>Check the line; list($term_id,$taxonomy_id) = $result in the code snippet below. ( towards the bottom ). Why am I missing the term_id &amp; the $taxonomy_id when I echo their values? Aren't they supposed to be populated by the wp_insert them? </p> <p><code></p> <pre><code>$term_name = 'Uncategorized'; $te...
[ { "answer_id": 48574, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 2, "selected": true, "text": "<p>The problem is the use of the php function <code>list</code>. If successful, <code>wp_insert_term</code> r...
2012/04/11
[ "https://wordpress.stackexchange.com/questions/48572", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14967/" ]
Check the line; list($term\_id,$taxonomy\_id) = $result in the code snippet below. ( towards the bottom ). Why am I missing the term\_id & the $taxonomy\_id when I echo their values? Aren't they supposed to be populated by the wp\_insert them? ``` $term_name = 'Uncategorized'; $term_slug = sanitize_title('Uncateg...
The problem is the use of the php function `list`. If successful, `wp_insert_term` returns something of the form: ``` array(2) { ["term_id"]=> int(307) ["term_taxonomy_id"]=> int(325) } ``` You can't use [`list`](http://php.net/manual/en/function.list.php) with this as `list` only works for numerical arrays. Instead...
48,581
<p>I want to load a different css for IE 9 below so I have two files : - style.css - ie.css</p> <p>I used this code : </p> <pre><code>&lt;!--[if !IE]&gt; --&gt; style.css &lt;!-- &lt;![endif]--&gt; </code></pre> <p>and used this for IE</p> <pre><code>&lt;!--[if IE]&gt; ie.css &lt;![endif]--&gt; </code></pre> <p>...
[ { "answer_id": 48586, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 0, "selected": false, "text": "<p>You don't load different CSS files, you create different classes. Add this function to your <code>functions.php</code>...
2012/04/11
[ "https://wordpress.stackexchange.com/questions/48581", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15061/" ]
I want to load a different css for IE 9 below so I have two files : - style.css - ie.css I used this code : ``` <!--[if !IE]> --> style.css <!-- <![endif]--> ``` and used this for IE ``` <!--[if IE]> ie.css <![endif]--> ``` but I dont know how to use this condition to use **style.css** for both non-IE and IE9
While [basic use of CSS IE conditionals](http://css-tricks.com/how-to-create-an-ie-only-stylesheet/) is **off-topic** for WPSE, WordPress *does* include a method for *enqueueing* stylesheets conditionally, based on CSS IE conditionals. First, you need to use the correct conditionals: ``` <!--[if lt IE 9]> ie.css <![...
48,592
<p>I am trying to custom sort taxonomies on a custom query I have written for one of my website</p> <p>I cannot use any custom plugin as I have tried and they do not work with my current setup.</p> <pre><code>add_action('init', 'ecommerce_create_post_type', 1); function ecommerce_create_post_type() { // Create new L...
[ { "answer_id": 48596, "author": "Rajeev Vyas", "author_id": 6961, "author_profile": "https://wordpress.stackexchange.com/users/6961", "pm_score": 2, "selected": true, "text": "<pre><code>$args = array(\n 'post_type' =&gt; 'product',\n 'tax_query' =&gt; array(\n array(\n ...
2012/04/11
[ "https://wordpress.stackexchange.com/questions/48592", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15030/" ]
I am trying to custom sort taxonomies on a custom query I have written for one of my website I cannot use any custom plugin as I have tried and they do not work with my current setup. ``` add_action('init', 'ecommerce_create_post_type', 1); function ecommerce_create_post_type() { // Create new Latest-News custom pos...
``` $args = array( 'post_type' => 'product', 'tax_query' => array( array( 'taxonomy' => 'icomcat', 'field' => 'id', 'terms' => array($prodcatid) ) ) ); $postslist = get_posts( $args ); ```
48,609
<p>I have added some text on tinymce editor on load.<br /> (Every time you click on Add new the tinymce editor load with this text.) </p> <p>but problem is how to enable css class which are using in default text.</p> <p>Thanks </p>
[ { "answer_id": 48610, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 5, "selected": true, "text": "<p>Use <code>add_editor_style</code></p>\n\n<p>e.g.: functions.php</p>\n\n<pre><code>add_editor_style('custom-edi...
2012/04/11
[ "https://wordpress.stackexchange.com/questions/48609", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15068/" ]
I have added some text on tinymce editor on load. (Every time you click on Add new the tinymce editor load with this text.) but problem is how to enable css class which are using in default text. Thanks
Use `add_editor_style` e.g.: functions.php ``` add_editor_style('custom-editor-style.css'); ``` <http://codex.wordpress.org/Function_Reference/add_editor_style>
48,611
<p>probably a weird question. I'm using the custom <a href="https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress" rel="nofollow">MetaBox and CustomFields Class</a> by jaredatch on Github.</p> <p>I have this "event-date" metabox:</p> <pre><code>$meta_boxes[] = array( 'id' =&gt; 'event...
[ { "answer_id": 48610, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 5, "selected": true, "text": "<p>Use <code>add_editor_style</code></p>\n\n<p>e.g.: functions.php</p>\n\n<pre><code>add_editor_style('custom-edi...
2012/04/11
[ "https://wordpress.stackexchange.com/questions/48611", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3529/" ]
probably a weird question. I'm using the custom [MetaBox and CustomFields Class](https://github.com/jaredatch/Custom-Metaboxes-and-Fields-for-WordPress) by jaredatch on Github. I have this "event-date" metabox: ``` $meta_boxes[] = array( 'id' => 'event_date', 'title' => 'Event Date', ...
Use `add_editor_style` e.g.: functions.php ``` add_editor_style('custom-editor-style.css'); ``` <http://codex.wordpress.org/Function_Reference/add_editor_style>
48,618
<p>I am using wordpress as my CMS. I am thinking, that the left panel has titles of my "posts" under its relevant category and the right side as the title of the post and its content.</p> <p>I have tried to put the following code in a page (after enabling a php plugin for wordpress). But since I dont know php, I tried...
[ { "answer_id": 48610, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 5, "selected": true, "text": "<p>Use <code>add_editor_style</code></p>\n\n<p>e.g.: functions.php</p>\n\n<pre><code>add_editor_style('custom-edi...
2012/04/11
[ "https://wordpress.stackexchange.com/questions/48618", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15073/" ]
I am using wordpress as my CMS. I am thinking, that the left panel has titles of my "posts" under its relevant category and the right side as the title of the post and its content. I have tried to put the following code in a page (after enabling a php plugin for wordpress). But since I dont know php, I tried the below...
Use `add_editor_style` e.g.: functions.php ``` add_editor_style('custom-editor-style.css'); ``` <http://codex.wordpress.org/Function_Reference/add_editor_style>
48,623
<p>I am using WordPress multisite (3.3.1) and am trying to protect uploads from certain blogs from being hotlinked and directly accessed. This is loosely related to <a href="https://wordpress.stackexchange.com/questions/37144/how-to-protect-uploads-if-user-is-not-logged-in">How to Protect Uploads, if User is not Logged...
[ { "answer_id": 48814, "author": "OleVik", "author_id": 2983, "author_profile": "https://wordpress.stackexchange.com/users/2983", "pm_score": 0, "selected": false, "text": "<p>There are a few ways to effectively handle this, most of which requires the use of a plugin or plugin-like behavi...
2012/04/11
[ "https://wordpress.stackexchange.com/questions/48623", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2983/" ]
I am using WordPress multisite (3.3.1) and am trying to protect uploads from certain blogs from being hotlinked and directly accessed. This is loosely related to [How to Protect Uploads, if User is not Logged In?](https://wordpress.stackexchange.com/questions/37144/how-to-protect-uploads-if-user-is-not-logged-in), but ...
You've got some issues in your underlying objective ... > > For example, I have a filed called 40c.jpg located at `localhost/files/2011/07/40c.jpg` > > > OK, this makes sense and is where the image should be in the first place. > > I want the file to show up only when called by HTML on the local domain (here: l...
48,624
<p>I've built this responsive site on WordPress and got a little curious as to how I can set the post thumbnails in percentages. Any help would be much appreciated.</p>
[ { "answer_id": 48814, "author": "OleVik", "author_id": 2983, "author_profile": "https://wordpress.stackexchange.com/users/2983", "pm_score": 0, "selected": false, "text": "<p>There are a few ways to effectively handle this, most of which requires the use of a plugin or plugin-like behavi...
2012/04/11
[ "https://wordpress.stackexchange.com/questions/48624", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15074/" ]
I've built this responsive site on WordPress and got a little curious as to how I can set the post thumbnails in percentages. Any help would be much appreciated.
You've got some issues in your underlying objective ... > > For example, I have a filed called 40c.jpg located at `localhost/files/2011/07/40c.jpg` > > > OK, this makes sense and is where the image should be in the first place. > > I want the file to show up only when called by HTML on the local domain (here: l...
48,628
<p>I have a menu:</p> <pre><code>Activities Projects About Us News </code></pre> <p>(not counting submenu items).</p> <p>Now "Activities" has no submenu.</p> <p>I created custom content type "project".</p> <p>My boss want to fill the menu "Activities" with the list of all projects automatically.</p> <p>Can it be ...
[ { "answer_id": 48634, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p>Yes! Yes it can, you will need to hook into the filter used by the walker, e.g.:</p>\n\n<pre><code>add_filter...
2012/04/11
[ "https://wordpress.stackexchange.com/questions/48628", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13880/" ]
I have a menu: ``` Activities Projects About Us News ``` (not counting submenu items). Now "Activities" has no submenu. I created custom content type "project". My boss want to fill the menu "Activities" with the list of all projects automatically. Can it be done without rewriting anew all WP menu output code?
Yes! Yes it can, you will need to hook into the filter used by the walker, e.g.: ``` add_filter( 'walker_nav_menu_start_el', 'menu_show_project_post', 10, 4 ); function menu_show_project_post( $item_output = '', $item = '', $depth = '', $args = '' ) { global $post; if ( is_array( $item->classes ) ) { ...
48,640
<p>I am attempting to do something similar to the accepted answer on this question <a href="https://wordpress.stackexchange.com/questions/42461/is-it-possible-to-use-a-single-custom-post-as-the-site-front-page">Is it possible to use a single custom post as the site front page</a></p> <p>My problem is that this impleme...
[ { "answer_id": 48642, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 1, "selected": false, "text": "<p>I'll just copy/paste my answer to that question, here:</p>\n\n<p>There are many ways to accomplish this, th...
2012/04/11
[ "https://wordpress.stackexchange.com/questions/48640", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6811/" ]
I am attempting to do something similar to the accepted answer on this question [Is it possible to use a single custom post as the site front page](https://wordpress.stackexchange.com/questions/42461/is-it-possible-to-use-a-single-custom-post-as-the-site-front-page) My problem is that this implementation causes a redi...
I'll just copy/paste my answer to that question, here: There are many ways to accomplish this, though some are more advanced than others: 1. Mark the blog post as **sticky**, and then set Posts per Page to **1** (`Dashboard -> Settings -> Reading`) 2. Create a custom `front-page.php` template, and query the post in q...
48,643
<p>I was coding my recent comments widget, and using $wpdb->get_results and I wanted t use cache so it doesn't perform the query every time the page loads, so I used:</p> <pre><code>$comments = wp_cache_get('mycomments'); if ($comments == false) { $query = //some sql stuff $comments = $wpdb-&gt;get_results($qu...
[ { "answer_id": 48648, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 4, "selected": true, "text": "<p>In WordPress v2.5+ the object cache is not persistent. It will save things in memory, but for persistent cachi...
2012/04/11
[ "https://wordpress.stackexchange.com/questions/48643", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14490/" ]
I was coding my recent comments widget, and using $wpdb->get\_results and I wanted t use cache so it doesn't perform the query every time the page loads, so I used: ``` $comments = wp_cache_get('mycomments'); if ($comments == false) { $query = //some sql stuff $comments = $wpdb->get_results($query); wp_cac...
In WordPress v2.5+ the object cache is not persistent. It will save things in memory, but for persistent caching across page loads you will need a plugin see here: <http://codex.wordpress.org/Class_Reference/WP_Object_Cache#Persistent_Caching> Alternatively, use transients, which are persistent. The identifier must b...
48,652
<p>this question is strongly related to this <a href="https://wordpress.stackexchange.com/questions/48607/custom-wp-query-breaks-default-behaviour-of-viewing-right-post-associated-with-t">question</a> where I already got a working answer.</p> <p>I have a custom-post-template named "wr_event" and a custom-taxonomy name...
[ { "answer_id": 48658, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 4, "selected": true, "text": "<p>Just use the <a href=\"http://codex.wordpress.org/Conditional_Tags\" rel=\"noreferrer\">appropriate condit...
2012/04/11
[ "https://wordpress.stackexchange.com/questions/48652", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3529/" ]
this question is strongly related to this [question](https://wordpress.stackexchange.com/questions/48607/custom-wp-query-breaks-default-behaviour-of-viewing-right-post-associated-with-t) where I already got a working answer. I have a custom-post-template named "wr\_event" and a custom-taxonomy named "event\_type". T...
Just use the [appropriate conditionals](http://codex.wordpress.org/Conditional_Tags): ``` function change_order_for_events( $query ) { //only show future events and events in the last 24hours $yesterday = current_time('timestamp') - 24*60*60; if ( $query->is_main_query() && (is_tax('event_type') || is_po...
48,660
<p>I am trying to understand data sanitization (not data validation) to help me write secure themes for WordPress. I have searched the Internet trying to find a comprehnsive guide for theme developers detailing best practices. There were couple of resources I came across including the codex page titled Data Validation,...
[ { "answer_id": 48666, "author": "onetrickpony", "author_id": 1986, "author_profile": "https://wordpress.stackexchange.com/users/1986", "pm_score": 5, "selected": true, "text": "<p>This <a href=\"http://codex.wordpress.org/Data_Validation\" rel=\"nofollow noreferrer\">codex page</a> expla...
2012/04/11
[ "https://wordpress.stackexchange.com/questions/48660", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9094/" ]
I am trying to understand data sanitization (not data validation) to help me write secure themes for WordPress. I have searched the Internet trying to find a comprehnsive guide for theme developers detailing best practices. There were couple of resources I came across including the codex page titled Data Validation, th...
This [codex page](http://codex.wordpress.org/Data_Validation) explains it pretty well I think. The most important and commonly used function is probably [`esc_attr`](http://codex.wordpress.org/Function_Reference/esc_attr). Take this example: ``` <a href="<?php print $author_url; ?>" title="<?php print $author_name; ...
48,677
<p>I find myself needing to pass custom data to a filter provided by a 3rd party plugin. All of the ways I've seen to do this are really complicated and hard to wrap my head around.</p> <p>Take this example:</p> <pre><code>$score = 42; //Some crazy calculation I don't want to repeat. function add_score_to_title($tit...
[ { "answer_id": 48679, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 5, "selected": true, "text": "<p>You have at least two options:</p>\n\n<ol>\n<li>Globalize the desired variable, and then reference it inside...
2012/04/11
[ "https://wordpress.stackexchange.com/questions/48677", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2744/" ]
I find myself needing to pass custom data to a filter provided by a 3rd party plugin. All of the ways I've seen to do this are really complicated and hard to wrap my head around. Take this example: ``` $score = 42; //Some crazy calculation I don't want to repeat. function add_score_to_title($title) { return 'Qui...
You have at least two options: 1. Globalize the desired variable, and then reference it inside the callback 2. Wrap the score calculation logic with a function, then reference it inside the callback ### Globalize the Variable ``` <?php global $score; $score = 42; //Some crazy calculation I don't want to repeat. fun...
48,678
<p>Is it possible within the save_post action to determine whether it's a new post being created or an existing post being update?</p>
[ { "answer_id": 48724, "author": "moraleida", "author_id": 7890, "author_profile": "https://wordpress.stackexchange.com/users/7890", "pm_score": 0, "selected": false, "text": "<p>When save_post is triggered, all information about that post is already available, so in theory you could use<...
2012/04/11
[ "https://wordpress.stackexchange.com/questions/48678", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3032/" ]
Is it possible within the save\_post action to determine whether it's a new post being created or an existing post being update?
Since WordPress version 3.7. - IIRC - the `save_post` hook - more information about the hook and its usage at [Code Reference: `save_post`](https://developer.wordpress.org/reference/hooks/save_post/) and [Codex: `save_post`](https://codex.wordpress.org/Plugin_API/Action_Reference/save_post) - has a third parameter `$up...
48,680
<p>I have a custom post type with a metabox text input area that I want to have a shortcode inserted into from a thickbox when a link is clicked on from the modal window. Using the code below right now it just closes the modal window when the insert button is clicked. Please tell me where I am going wrong.</p> <p>I ha...
[ { "answer_id": 48724, "author": "moraleida", "author_id": 7890, "author_profile": "https://wordpress.stackexchange.com/users/7890", "pm_score": 0, "selected": false, "text": "<p>When save_post is triggered, all information about that post is already available, so in theory you could use<...
2012/04/11
[ "https://wordpress.stackexchange.com/questions/48680", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15091/" ]
I have a custom post type with a metabox text input area that I want to have a shortcode inserted into from a thickbox when a link is clicked on from the modal window. Using the code below right now it just closes the modal window when the insert button is clicked. Please tell me where I am going wrong. I have the thi...
Since WordPress version 3.7. - IIRC - the `save_post` hook - more information about the hook and its usage at [Code Reference: `save_post`](https://developer.wordpress.org/reference/hooks/save_post/) and [Codex: `save_post`](https://codex.wordpress.org/Plugin_API/Action_Reference/save_post) - has a third parameter `$up...
48,686
<p>I'm seeing a lot of jobs on elance and vWorker for converting html to wordpress? what's the general process for doiing this? hunting and pecking through the codex? what happens when you get to some javascript or php? how long should a job like this take?</p>
[ { "answer_id": 48691, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 1, "selected": false, "text": "<p>One way to access WordPress core functionality outside of your WordPress directory is to use the following exampl...
2012/04/11
[ "https://wordpress.stackexchange.com/questions/48686", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13134/" ]
I'm seeing a lot of jobs on elance and vWorker for converting html to wordpress? what's the general process for doiing this? hunting and pecking through the codex? what happens when you get to some javascript or php? how long should a job like this take?
One way to access WordPress core functionality outside of your WordPress directory is to use the following example; ``` <?php require( '../path-to-your-wordpress-install/wp-load.php' ); get_header(); // do your magic here... get_footer(); ?> ``` However converting HTML to WordPress shouldn't really requir...
48,701
<p>Like it says on the tin - Im trying to create a list of post attachments that includes everything except say audio, which I'll feed into a player instead. </p> <ul> <li>The filter needs to be generic: 'audio' not 'audio/mpeg'.</li> </ul> <p>(For some reason <code>if ( $mime !== 'audio/mpeg' )</code> will filter ou...
[ { "answer_id": 48717, "author": "Nate Cook", "author_id": 1313, "author_profile": "https://wordpress.stackexchange.com/users/1313", "pm_score": 2, "selected": false, "text": "<p>Looks like this is two questions: how to get all the children that are audio, and how to get all the children ...
2012/04/11
[ "https://wordpress.stackexchange.com/questions/48701", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13551/" ]
Like it says on the tin - Im trying to create a list of post attachments that includes everything except say audio, which I'll feed into a player instead. * The filter needs to be generic: 'audio' not 'audio/mpeg'. (For some reason `if ( $mime !== 'audio/mpeg' )` will filter out valid mp3 files –– weird.) So the fo...
Looks like this is two questions: how to get all the children that are audio, and how to get all the children that *aren't* audio. 1) The `post_mime_type` parameter of `get_children` can actually take a wildcard, so you could use: ``` $children = get_children(array( 'post_parent' => $post->ID, 'post_status'...
48,708
<p>I have a client who bought a wordpress theme that is built for posting job listings, a user can create an account and then post job listings but my client wants it converted to post Wheel listings (car wheels).</p> <p>I have converted it pretty well so far but I need to allow the user to upload an image for a listi...
[ { "answer_id": 48718, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 3, "selected": true, "text": "<p>You might want to check out this resource which provides a relatively simple and easy to understand snippet to ach...
2012/04/11
[ "https://wordpress.stackexchange.com/questions/48708", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8668/" ]
I have a client who bought a wordpress theme that is built for posting job listings, a user can create an account and then post job listings but my client wants it converted to post Wheel listings (car wheels). I have converted it pretty well so far but I need to allow the user to upload an image for a listing. A list...
You might want to check out this resource which provides a relatively simple and easy to understand snippet to achieve just that! [Link to the original source from @Matthew Price.](http://matthewaprice.com/upload-image-attach-to-wordpress-post-from-template/) I have pasted the code below for the purpose longevity bu...
48,715
<p>So long story short, im a noob WP dev and im like on my 2nd custom WP site so sorry if i sound a bit lost.</p> <p>As i was doing my first WP custom site, i noticed that for example, on the default theme and any other themes i tried out, when you add a menu item that has child options, they wrap under the parent opt...
[ { "answer_id": 48716, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 2, "selected": false, "text": "<p>This appears to be a CSS related issue. </p>\n\n<p>You need to <code>clear:both</code> your <code>&lt;li&gt;</cod...
2012/04/12
[ "https://wordpress.stackexchange.com/questions/48715", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12944/" ]
So long story short, im a noob WP dev and im like on my 2nd custom WP site so sorry if i sound a bit lost. As i was doing my first WP custom site, i noticed that for example, on the default theme and any other themes i tried out, when you add a menu item that has child options, they wrap under the parent option, think...
This appears to be a CSS related issue. You need to `clear:both` your `<li>` elements which contain your `<a href=links...>` Make sure you apply that `clear` property to your sub-menu `<li>` elements only and not your top level parent items. Without knowing or seeing the exact theme you are working with, be it cust...
48,725
<p>I have quite a few old posts that contain an img tag with height and width with no double quotes around the numbers. For example:</p> <pre><code>&lt;img height=319 alt="" src="http://www.example.com/images/myexample.jpg" width=496&gt; </code></pre> <p>I am not sure how to write a MySQL query that can find the heig...
[ { "answer_id": 48753, "author": "Alex Thomas", "author_id": 6243, "author_profile": "https://wordpress.stackexchange.com/users/6243", "pm_score": 0, "selected": false, "text": "<p>Here's your started for 10...</p>\n\n<p>You can use the REGEXP operator in a MySQL query, then do an update ...
2012/04/12
[ "https://wordpress.stackexchange.com/questions/48725", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13253/" ]
I have quite a few old posts that contain an img tag with height and width with no double quotes around the numbers. For example: ``` <img height=319 alt="" src="http://www.example.com/images/myexample.jpg" width=496> ``` I am not sure how to write a MySQL query that can find the height and width numbers, and surrou...
You are simply going to love this one First of all, here is a sample table with data loaded: ``` mysql> use junk Database changed mysql> drop table todd; Query OK, 0 rows affected (0.01 sec) mysql> create table todd (id int not null auto_increment,url VARCHAR(255), -> primary key (id)) ENGINE=MyISAM; Query OK, 0...
48,727
<p>My WP 3.3 setup involves several post types and customized edit panels with Advanced Custom Fields plugin (which creates many metaboxes) and other plugins such as SEO metabox panel, Scribu's Posts2Posts connections and more. </p> <p>The problem is, the appearance order of these panels is often quite random (even if...
[ { "answer_id": 48732, "author": "Travis Pflanz", "author_id": 14558, "author_profile": "https://wordpress.stackexchange.com/users/14558", "pm_score": 3, "selected": false, "text": "<p>You can remove the default meta boxes with remove_meta_box and re-add them in a different position with ...
2012/04/12
[ "https://wordpress.stackexchange.com/questions/48727", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8421/" ]
My WP 3.3 setup involves several post types and customized edit panels with Advanced Custom Fields plugin (which creates many metaboxes) and other plugins such as SEO metabox panel, Scribu's Posts2Posts connections and more. The problem is, the appearance order of these panels is often quite random (even if Adavanced...
You can remove the default meta boxes with remove\_meta\_box and re-add them in a different position with add\_meta\_box: ``` add_action('do_meta_boxes', 'wpse33063_move_meta_box'); function wpse33063_move_meta_box(){ remove_meta_box( 'postimagediv', 'post', 'side' ); add_meta_box('postimagediv', __('Featured...
48,731
<p>On my NFL football blog all users are allowed to make blog posts. New registrants are given contributor status. When users make a post it is reviewed by an editor, then the editor schedules the post to publish at a time fitting our blog schedule.</p> <p>Multiple editors have asked me if they could make a comment on...
[ { "answer_id": 48766, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 2, "selected": false, "text": "<p>It depends on who the comments are for, are they for the administrators and editors or are they also for the cont...
2012/04/12
[ "https://wordpress.stackexchange.com/questions/48731", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14558/" ]
On my NFL football blog all users are allowed to make blog posts. New registrants are given contributor status. When users make a post it is reviewed by an editor, then the editor schedules the post to publish at a time fitting our blog schedule. Multiple editors have asked me if they could make a comment on the artic...
Through the [thought process initiated by userabuser](https://wordpress.stackexchange.com/questions/48731/how-can-i-allow-editors-to-leave-comments-on-posts-that-have-not-yet-been-publis#48766), more research and trial and error, I have come up with a solution. I have added a custom meta field using [Easy Content Type...
48,735
<p>Does anyone know how to exclude/filter a tag from the HTML string generated by get_the_tag_list()?</p> <p><a href="http://codex.wordpress.org/Function_Reference/get_the_tag_list" rel="nofollow">http://codex.wordpress.org/Function_Reference/get_the_tag_list</a></p> <p>Any help much appreciated.</p>
[ { "answer_id": 48736, "author": "Eugene Manuilov", "author_id": 8170, "author_profile": "https://wordpress.stackexchange.com/users/8170", "pm_score": 2, "selected": true, "text": "<pre><code>function mytheme_filter_tags( $term_links ) {\n $result = array();\n $exclude_tags = array(...
2012/04/12
[ "https://wordpress.stackexchange.com/questions/48735", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14170/" ]
Does anyone know how to exclude/filter a tag from the HTML string generated by get\_the\_tag\_list()? <http://codex.wordpress.org/Function_Reference/get_the_tag_list> Any help much appreciated.
``` function mytheme_filter_tags( $term_links ) { $result = array(); $exclude_tags = array( 'some tag', 'another tag', 'third tag' ); foreach ( $term_links as $link ) { foreach ( $exclude_tags as $tag ) { if ( stripos( $link, $tag ) !== false ) continue 2; } $result[] = $...
48,761
<p>I have the following code but I always get an error, it's the first time I've tried to merge HTML with PHP:</p> <pre><code>&lt;?php if(get_field('post_image')) { echo '&lt;img src="'. get_field('post_image') .'" /&gt;'; } else { echo '&lt;img src="&lt;?php bloginfo('template_url'); ?&gt;/images/images/defau...
[ { "answer_id": 48762, "author": "janw", "author_id": 10911, "author_profile": "https://wordpress.stackexchange.com/users/10911", "pm_score": 0, "selected": false, "text": "<p>bloginfo() echo's its result you need <a href=\"http://codex.wordpress.org/Function_Reference/get_bloginfo\" rel=...
2012/04/12
[ "https://wordpress.stackexchange.com/questions/48761", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15109/" ]
I have the following code but I always get an error, it's the first time I've tried to merge HTML with PHP: ``` <?php if(get_field('post_image')) { echo '<img src="'. get_field('post_image') .'" />'; } else { echo '<img src="<?php bloginfo('template_url'); ?>/images/images/default.jpg" />'; } ?> ``` Is there...
You get the error because you try to call php inside php. Try to use this snippet and see what is different: ``` <?php if(get_field('post_image')) { echo '<img src="'. get_field('post_image') .'" />'; } else { echo '<img src="' . get_bloginfo('template_url') . '/images/images/default.jpg" />'; } ?> ``` Also ...
48,767
<p>When I query the category (category.php), how do I get the title of the current category, ie., the one that is being queried?</p> <p>And how do I get the title for tag and date (be it the day, the month or the year)?</p>
[ { "answer_id": 48768, "author": "Eugene Manuilov", "author_id": 8170, "author_profile": "https://wordpress.stackexchange.com/users/8170", "pm_score": 5, "selected": true, "text": "<p>For category use <code>single_cat_title</code> function:<br> <a href=\"http://codex.wordpress.org/Functio...
2012/04/12
[ "https://wordpress.stackexchange.com/questions/48767", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15113/" ]
When I query the category (category.php), how do I get the title of the current category, ie., the one that is being queried? And how do I get the title for tag and date (be it the day, the month or the year)?
For category use `single_cat_title` function: <http://codex.wordpress.org/Function_Reference/single_cat_title> For tag use `single_tag_title` function: <http://codex.wordpress.org/Function_Reference/single_tag_title> For date use `get_the_date` function: <http://codex.wordpress.org/Function_Reference/get_the...
48,769
<p>I'm using the Types Plugin for Wordpress and created a custom field. I would like to display this custom field in the sidebar of all of my pages. The problem is that it only displays in the sidebar of the page I created the custom field on. It does NOT display in the sidebar on any of the other pages. Here's the cod...
[ { "answer_id": 48768, "author": "Eugene Manuilov", "author_id": 8170, "author_profile": "https://wordpress.stackexchange.com/users/8170", "pm_score": 5, "selected": true, "text": "<p>For category use <code>single_cat_title</code> function:<br> <a href=\"http://codex.wordpress.org/Functio...
2012/04/12
[ "https://wordpress.stackexchange.com/questions/48769", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15114/" ]
I'm using the Types Plugin for Wordpress and created a custom field. I would like to display this custom field in the sidebar of all of my pages. The problem is that it only displays in the sidebar of the page I created the custom field on. It does NOT display in the sidebar on any of the other pages. Here's the code I...
For category use `single_cat_title` function: <http://codex.wordpress.org/Function_Reference/single_cat_title> For tag use `single_tag_title` function: <http://codex.wordpress.org/Function_Reference/single_tag_title> For date use `get_the_date` function: <http://codex.wordpress.org/Function_Reference/get_the...
48,772
<p>I am working on a client's site and they need to select a Template whenever they are adding a new page; the "Default Template" is not a valid choice.</p> <p>I would like to rename "Default Template" to something like "-- Select Template --".</p> <p>Searching the WordPress codebase I found references to "Default Te...
[ { "answer_id": 48776, "author": "Travis Pflanz", "author_id": 14558, "author_profile": "https://wordpress.stackexchange.com/users/14558", "pm_score": 2, "selected": false, "text": "<p>Your request, if I'm not mistaken, is to create an empty selection as the default for the page template ...
2012/04/12
[ "https://wordpress.stackexchange.com/questions/48772", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/112/" ]
I am working on a client's site and they need to select a Template whenever they are adding a new page; the "Default Template" is not a valid choice. I would like to rename "Default Template" to something like "-- Select Template --". Searching the WordPress codebase I found references to "Default Template" are hard-...
There is a filter for this since version 4.1; cf. <https://github.com/WordPress/WordPress/commit/7cdbac53e8497b346d1009375d36586fb6e5197c> You can now use: ``` add_filter('default_page_template_title', function() { return __('My default template name', 'your_text_domain'); }); ```
48,774
<p>I have the following code to display tagged articles with the same name as the page title, but I only want the to appear if the tag exists, otherwise it just says 'Related Articles' with no content. I have tried using some conditionals with no luck. Is there a way to do this? I have found no examples or questions h...
[ { "answer_id": 48775, "author": "janw", "author_id": 10911, "author_profile": "https://wordpress.stackexchange.com/users/10911", "pm_score": 2, "selected": false, "text": "<p>Try this</p>\n\n<pre><code>&lt;?php $related = new WP_Query( 'tag=' . get_the_title() . '' );\nif( $related-&gt;h...
2012/04/12
[ "https://wordpress.stackexchange.com/questions/48774", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15109/" ]
I have the following code to display tagged articles with the same name as the page title, but I only want the to appear if the tag exists, otherwise it just says 'Related Articles' with no content. I have tried using some conditionals with no luck. Is there a way to do this? I have found no examples or questions here ...
Try this ``` <?php $related = new WP_Query( 'tag=' . get_the_title() . '' ); if( $related->have_posts() ): <h1>Related Articles</h1> while ( $related->have_posts() ) : the_post(); ?> <li><a href="<?php the_permalink() ?>"><?php the_title(); ?></a> </li> <?php endwhile; else: //there are no related...
48,782
<p>Thanks to <a href="https://wordpress.stackexchange.com/a/48709/6344">this answer here</a>, I am able to use different instances of <code>wp_editor</code> to determine which buttons each of my differing TinyMCE instances use.</p> <p>However, I'm struggling to actually get my buttons registered - they're simply not a...
[ { "answer_id": 49085, "author": "Boone Gorges", "author_id": 14052, "author_profile": "https://wordpress.stackexchange.com/users/14052", "pm_score": 3, "selected": true, "text": "<p>I copied your code into my functions.php, and added a simple admin panel ('Foo') to display the editor. Th...
2012/04/12
[ "https://wordpress.stackexchange.com/questions/48782", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6344/" ]
Thanks to [this answer here](https://wordpress.stackexchange.com/a/48709/6344), I am able to use different instances of `wp_editor` to determine which buttons each of my differing TinyMCE instances use. However, I'm struggling to actually get my buttons registered - they're simply not appearing on the TinyMCE interfac...
I copied your code into my functions.php, and added a simple admin panel ('Foo') to display the editor. Then I created a new directory inside my current theme for the editor button, and put the editor button JS into the relevant file: `/wp-content/themes/[my-theme-dir]/tinymce_buttons/pH/editor_plugin.js`. Result: whe...
48,785
<p>I created a custom-taxonomy for a custom-post-type which functions as kind of categories for this post-type. </p> <p>The Metabox for my taxonomy has two tabs. One for my Categories and a second tab called "Most Used" just like the normal categories for normal posts has.</p> <p>Is there a way to get rid of this "Mo...
[ { "answer_id": 49085, "author": "Boone Gorges", "author_id": 14052, "author_profile": "https://wordpress.stackexchange.com/users/14052", "pm_score": 3, "selected": true, "text": "<p>I copied your code into my functions.php, and added a simple admin panel ('Foo') to display the editor. Th...
2012/04/12
[ "https://wordpress.stackexchange.com/questions/48785", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3529/" ]
I created a custom-taxonomy for a custom-post-type which functions as kind of categories for this post-type. The Metabox for my taxonomy has two tabs. One for my Categories and a second tab called "Most Used" just like the normal categories for normal posts has. Is there a way to get rid of this "Most Used" tab? Th...
I copied your code into my functions.php, and added a simple admin panel ('Foo') to display the editor. Then I created a new directory inside my current theme for the editor button, and put the editor button JS into the relevant file: `/wp-content/themes/[my-theme-dir]/tinymce_buttons/pH/editor_plugin.js`. Result: whe...
48,799
<p>I won't lie - I don't know php but I enjoy digging around trying to find ways to customize themes so that they behave how I want them to. Any help would be very much appreciated.</p> <p>What I am trying to do:</p> <p>There is a section in a wordpress theme I am using which allows you to publish portfolios. </p> <...
[ { "answer_id": 48831, "author": "Tom Kiddle", "author_id": 6939, "author_profile": "https://wordpress.stackexchange.com/users/6939", "pm_score": 0, "selected": false, "text": "<p>Could you not just do this with Permalink? </p>\n\n<p><a href=\"http://codex.wordpress.org/Using_Permalinks\"...
2012/04/12
[ "https://wordpress.stackexchange.com/questions/48799", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15119/" ]
I won't lie - I don't know php but I enjoy digging around trying to find ways to customize themes so that they behave how I want them to. Any help would be very much appreciated. What I am trying to do: There is a section in a wordpress theme I am using which allows you to publish portfolios. The URL for any portfo...
add ``` 'rewrite' => array('slug' => 'portfolio-categories'), ``` but be sure to remove (not sure why that's there, it tries hides the slug yet tries to rename it to "products" at the same time?): ``` 'rewrite' => array( 'with_front' => false, 'slug' => 'products' ), ``` So it looks like this: ``` function mysi...
48,805
<p>any way would be acceptable for me, even hacking the DB.</p> <p>I have messed up the roles with MEMBERS plugin, and i need a way of reseting the roles somehow. i can't seem to find a proper way.</p> <p>basically, I need to flush all roles, capabilities, and custom post type at once. it wouldn't cause any trouble ...
[ { "answer_id": 48807, "author": "Ehab Fawzy", "author_id": 13486, "author_profile": "https://wordpress.stackexchange.com/users/13486", "pm_score": 1, "selected": false, "text": "<p>You can delete or add again the Roles and/or the Capabilities:</p>\n\n<ul>\n<li><a href=\"http://codex.word...
2012/04/12
[ "https://wordpress.stackexchange.com/questions/48805", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3603/" ]
any way would be acceptable for me, even hacking the DB. I have messed up the roles with MEMBERS plugin, and i need a way of reseting the roles somehow. i can't seem to find a proper way. basically, I need to flush all roles, capabilities, and custom post type at once. it wouldn't cause any trouble with the one's wh...
The easiest way I know to reset roles and their associated capabilities is to use [wp-cli](https://developer.wordpress.org/cli/commands/role/). wp-cli has a built-in method for resetting roles. You can specify any that you want to reset. For example: ``` wp role reset author contributor editor subscriber ``` There ...
48,808
<p>I'm using Buddypress for wordpress and I'm trying to show a loop on the profile page of a user. I use infinite scroll to load more pages but the link to page 2 doesn't point to a group of posts and instead takes me to a blank page template but I do get this link. </p> <pre><code>"http://mysite.com/exampleuser/page/...
[ { "answer_id": 48842, "author": "Boone Gorges", "author_id": 14052, "author_profile": "https://wordpress.stackexchange.com/users/14052", "pm_score": 0, "selected": false, "text": "<p>I'm not sure how your infinite scroll script interacts with <code>WP_Query</code>. But the root problem a...
2012/04/12
[ "https://wordpress.stackexchange.com/questions/48808", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12700/" ]
I'm using Buddypress for wordpress and I'm trying to show a loop on the profile page of a user. I use infinite scroll to load more pages but the link to page 2 doesn't point to a group of posts and instead takes me to a blank page template but I do get this link. ``` "http://mysite.com/exampleuser/page/2" ``` Any i...
(btw hi boone, im jacob, from vancouver). ( keyword "nice!" :) I am facing the exact same problem. Your implementation of the infinitescroll plugin seems ok. but it doesn seem to be an inifinitescroll prob to me. btw I disabled it, by simply uncommenting my item container and when i try to navigate through the pages w...
48,810
<p>I have some clients that are going to be using wordpress for their sites. I created custom fields for them to input data in so they don't have to use the editor. How do I hide the page editor completely? I want it completely hidden so they don't accidentally muck things up. Thanks!</p>
[ { "answer_id": 48811, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 4, "selected": true, "text": "<p>For posts:</p>\n\n<pre><code>add_action('init', 'my_custom_init');\nfunction my_custom_init() {\n remov...
2012/04/12
[ "https://wordpress.stackexchange.com/questions/48810", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15114/" ]
I have some clients that are going to be using wordpress for their sites. I created custom fields for them to input data in so they don't have to use the editor. How do I hide the page editor completely? I want it completely hidden so they don't accidentally muck things up. Thanks!
For posts: ``` add_action('init', 'my_custom_init'); function my_custom_init() { remove_post_type_support( 'post', 'editor' ); } ``` [See Codex](http://codex.wordpress.org/Function_Reference/remove_post_type_support). For custom post types that you register, you can specify what 'features' it supports when you [...
48,824
<p>I have a site that uses custom database tables to manage info that is inserted by a process completely independent from Wordpress. The data from the table is used in the Wordpress site but it is not manageable through the Admin interface.</p> <p>I want to make it manageable via the admin backend. What is the basic ...
[ { "answer_id": 48835, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 3, "selected": true, "text": "<p>Some notes before: This is only <em>how I'd approach it</em> - I'm not going to step more into detail, because basic...
2012/04/12
[ "https://wordpress.stackexchange.com/questions/48824", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4176/" ]
I have a site that uses custom database tables to manage info that is inserted by a process completely independent from Wordpress. The data from the table is used in the Wordpress site but it is not manageable through the Admin interface. I want to make it manageable via the admin backend. What is the basic process fo...
Some notes before: This is only *how I'd approach it* - I'm not going to step more into detail, because basically it's a list of plugins you'll have to code. Build a Back-End page ===================== Use the function [`add_menu_page`](http://codex.wordpress.org/Function_Reference/add_menu_page) to add a page. Then ...
48,826
<p>I've installed the Roots theme (version 4 so I can use the 1140px Grid) on Wordpress 3.3.1, and want to edit the CSS. Initially I only get the style.css file in the editor and can't see the others.</p> <p>The css files I need are located in a subfolder marked 'css', and I see from a quick Google search that there i...
[ { "answer_id": 48827, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 2, "selected": false, "text": "<h2>1. Don't edit your theme using the WordPress editor.</h2>\n<p>This is a quick-and-dirty approach to development, but...
2012/04/12
[ "https://wordpress.stackexchange.com/questions/48826", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15132/" ]
I've installed the Roots theme (version 4 so I can use the 1140px Grid) on Wordpress 3.3.1, and want to edit the CSS. Initially I only get the style.css file in the editor and can't see the others. The css files I need are located in a subfolder marked 'css', and I see from a quick Google search that there is a known ...
1. Don't edit your theme using the WordPress editor. ---------------------------------------------------- This is a quick-and-dirty approach to development, but you can easily destroy your entire site by mistake with this tool. Instead, edit the files on your machine locally and then use FTP to upload the changed file...
48,837
<p>Yesterday I logged onto my site and found that when I log in as an admin I get a 404 error as seen below:</p> <p><img src="https://i.stack.imgur.com/6vWqC.png" alt="404 Error"></p> <p>I have done a bit of research and uploaded a backup, modified my <code>.htaccess</code> file to below:</p> <pre><code># BEGIN Word...
[ { "answer_id": 48827, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 2, "selected": false, "text": "<h2>1. Don't edit your theme using the WordPress editor.</h2>\n<p>This is a quick-and-dirty approach to development, but...
2012/04/12
[ "https://wordpress.stackexchange.com/questions/48837", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10119/" ]
Yesterday I logged onto my site and found that when I log in as an admin I get a 404 error as seen below: ![404 Error](https://i.stack.imgur.com/6vWqC.png) I have done a bit of research and uploaded a backup, modified my `.htaccess` file to below: ``` # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On Rewri...
1. Don't edit your theme using the WordPress editor. ---------------------------------------------------- This is a quick-and-dirty approach to development, but you can easily destroy your entire site by mistake with this tool. Instead, edit the files on your machine locally and then use FTP to upload the changed file...
48,846
<p>I am new to WordPress, and have been asked to change a value in the title tag. The title tag is of the format: "site name | slogan" which is set dynamically in the header.php (seems standard code for WordPress from what I can see from other posts).</p> <p>It is the slogan on the home page only that I need to change...
[ { "answer_id": 48848, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 2, "selected": false, "text": "<p>You can do one of two things. The first, recommended way would be to use a plugin like <a href=\"http://...
2012/04/13
[ "https://wordpress.stackexchange.com/questions/48846", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15139/" ]
I am new to WordPress, and have been asked to change a value in the title tag. The title tag is of the format: "site name | slogan" which is set dynamically in the header.php (seems standard code for WordPress from what I can see from other posts). It is the slogan on the home page only that I need to change. All othe...
You can do one of two things. The first, recommended way would be to use a plugin like [WordPress SEO](http://wordpress.org/extend/plugins/wordpress-seo/). Install it, and replace the `<title>` tag in your `header.php` file with: ``` <title><?php wp_title(''); ?></title> ``` Or you can change the title only for the ...
48,853
<p>I'm trying to use <code>is_plugin_active</code> within functions.php.</p> <p>I need to wrap my <code>useragent_shortcode</code> function within <code>is_plugin_active</code> because when Contact Form 7 gets deactivated, I get a white screen.</p> <p>I've included <code>wp-admin/includes/plugin.php</code> as shown i...
[ { "answer_id": 48851, "author": "Travis Pflanz", "author_id": 14558, "author_profile": "https://wordpress.stackexchange.com/users/14558", "pm_score": 1, "selected": false, "text": "<p>Maybe it is the \"Site Name\" in the settings?</p>\n\n<p>In the admin area, go to Settings >> General >>...
2012/04/13
[ "https://wordpress.stackexchange.com/questions/48853", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/268/" ]
I'm trying to use `is_plugin_active` within functions.php. I need to wrap my `useragent_shortcode` function within `is_plugin_active` because when Contact Form 7 gets deactivated, I get a white screen. I've included `wp-admin/includes/plugin.php` as shown in other WPSE answers because this is outside of admin, but no...
Go to admin dashboard > Settings > General You are getting General Settings...
48,871
<p>I'm using Contact Form 7 and can display the form by putting the following in the content text field <code>[contact-form-7 id="453" title="Contact form 1"]</code>.</p> <p>Now I need to display the form outside the loop.</p> <p>How can I execute a short code from within my template code?</p> <p><strong>Update</str...
[ { "answer_id": 48872, "author": "Eugene Manuilov", "author_id": 8170, "author_profile": "https://wordpress.stackexchange.com/users/8170", "pm_score": 1, "selected": false, "text": "<ol>\n<li>Dig into the <code>Contact Form 7</code> plugin; </li>\n<li>Find occurrence of <code>add_shortcod...
2012/04/13
[ "https://wordpress.stackexchange.com/questions/48871", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1447/" ]
I'm using Contact Form 7 and can display the form by putting the following in the content text field `[contact-form-7 id="453" title="Contact form 1"]`. Now I need to display the form outside the loop. How can I execute a short code from within my template code? **Update** I found some suggestions to execute shor...
[do\_shortcode](http://codex.wordpress.org/Function_Reference/do_shortcode) should do the trick. I don't think you need the 'echo' before it though, I have never done so myself and never had any problems.
48,878
<p>I know you can use the wordpress methods for getting a featured image, however with this particular project I need to get the featured image via mysql query. Can anyone point me in the right direction. Thank you.</p> <p>This is what I have so far but my query is not doing the trick. I have the $post->id stored as a...
[ { "answer_id": 48880, "author": "Eugene Manuilov", "author_id": 8170, "author_profile": "https://wordpress.stackexchange.com/users/8170", "pm_score": 4, "selected": true, "text": "<pre><code>$Featured_image = $wpdb-&gt;get_results(\"\n SELECT p.*\n FROM net_5_postmeta AS pm\n ...
2012/04/13
[ "https://wordpress.stackexchange.com/questions/48878", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15069/" ]
I know you can use the wordpress methods for getting a featured image, however with this particular project I need to get the featured image via mysql query. Can anyone point me in the right direction. Thank you. This is what I have so far but my query is not doing the trick. I have the $post->id stored as a variable ...
``` $Featured_image = $wpdb->get_results(" SELECT p.* FROM net_5_postmeta AS pm INNER JOIN net_5_posts AS p ON pm.meta_value=p.ID WHERE pm.post_id = $da_id AND pm.meta_key = '_thumbnail_id' ORDER BY p.post_date DESC LIMIT 15 ",'ARRAY_A'); ```
48,884
<p>Is there a hook/function combination that can be added to my theme's <code>functions.php</code> to properly disable REVISIONS and AUTOSAVE for the entire wordpress installation? What about if just for a certain custom post type? Searching online gives various hacks from deregistering scripts to tampering with core f...
[ { "answer_id": 48903, "author": "wikicms", "author_id": 15155, "author_profile": "https://wordpress.stackexchange.com/users/15155", "pm_score": 0, "selected": false, "text": "<p>I'm also looking for how to disable autosave. But here's what I was told in a <a href=\"http://core.trac.wordp...
2012/04/13
[ "https://wordpress.stackexchange.com/questions/48884", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14804/" ]
Is there a hook/function combination that can be added to my theme's `functions.php` to properly disable REVISIONS and AUTOSAVE for the entire wordpress installation? What about if just for a certain custom post type? Searching online gives various hacks from deregistering scripts to tampering with core files. What's t...
This should be placed in your `wp-config.php` (and no where else): ``` define( 'AUTOSAVE_INTERVAL', 60*60*60*24*365 ); // Set autosave interval to 1x per year define( 'EMPTY_TRASH_DAYS', 0 ); // Empty trash now: Zero days define( 'WP_POST_REVISIONS', false ); // Do not save andy revisions ```
48,892
<p>I'm using WordPress E-Commerce (<a href="http://getshopped.org/" rel="nofollow" title="Get Shopped">get shopped</a>) and would like to get a list of items that a user has purchased, just a list of post IDs would be perfect. Is there any way for me to get this?</p> <p>It must be stored somewhere.. has anyone attempt...
[ { "answer_id": 48898, "author": "amolv", "author_id": 9262, "author_profile": "https://wordpress.stackexchange.com/users/9262", "pm_score": -1, "selected": false, "text": "<pre><code>global $wpsc_cart; \n</code></pre>\n\n<p>This is the global variable , looping through this will get all...
2012/04/13
[ "https://wordpress.stackexchange.com/questions/48892", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14633/" ]
I'm using WordPress E-Commerce ([get shopped](http://getshopped.org/ "Get Shopped")) and would like to get a list of items that a user has purchased, just a list of post IDs would be perfect. Is there any way for me to get this? It must be stored somewhere.. has anyone attempted this before?
Query the table wp\_wpsc\_purchase\_logs, it contains all information about previous purchases. add this to your themes functions.php: ``` /********************************************************* Get purchased articles by user_id or for the current user *********************************************************/ fu...
48,901
<p>I'm trying to create a archive list with only my "normal" post format articles (not link, aside, quote, etc formats).</p> <p>How would I implement <code>has_post_format( 'standard' )</code>, or something similar, into the code below?</p> <p>I haven't been able to find a query for <code>get_posts</code> that only r...
[ { "answer_id": 48906, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>For two different taxonomies. For a single one, you can leave the <code>relation</code> arg out.</p>\n\n<pre><code>...
2012/04/13
[ "https://wordpress.stackexchange.com/questions/48901", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15145/" ]
I'm trying to create a archive list with only my "normal" post format articles (not link, aside, quote, etc formats). How would I implement `has_post_format( 'standard' )`, or something similar, into the code below? I haven't been able to find a query for `get_posts` that only requests specific format types. ``` <?p...
~~You can't actually pass a taxonomy-related argument to [`get_posts()`](http://codex.wordpress.org/Template_Tags/get_posts).~~ **(Edit: actually, yes you can. The Codex is just somewhat unclear. Looking at source, `get_posts()` is, at its heart, just a wrapper for `WP_Query()`.)** You can pass meta keys/values, and po...
48,909
<p>I have the following query and i can't find where is executed</p> <pre><code>SELECT count(ID) FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') ORDER BY wp_posts.post_date DESC; </code></pre> <p>Does anybody know where could be executed?</p>
[ { "answer_id": 48912, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>It is not hard to log queries performed by WordPress. Simplest way would be to use plugin such as <a href=\"http://w...
2012/04/13
[ "https://wordpress.stackexchange.com/questions/48909", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14636/" ]
I have the following query and i can't find where is executed ``` SELECT count(ID) FROM wp_posts WHERE 1=1 AND wp_posts.post_type = 'post' AND (wp_posts.post_status = 'publish') ORDER BY wp_posts.post_date DESC; ``` Does anybody know where could be executed?
It is not hard to log queries performed by WordPress. Simplest way would be to use plugin such as [Debug Bar](http://wordpress.org/extend/plugins/debug-bar/) that collects backtrace information about where in code was query performed.
48,921
<p>I'm looking for a plugin to let users choose which widgets appear on individual pages. </p> <p>There's some solutions out there, none of which that I've found are truly easy for a non-technical user. I've tried </p> <ul> <li><strong><a href="http://www.woothemes.com/videos/the-sidebar-manager-overview/" rel="nofol...
[ { "answer_id": 48924, "author": "moraleida", "author_id": 7890, "author_profile": "https://wordpress.stackexchange.com/users/7890", "pm_score": 0, "selected": false, "text": "<p>Try <a href=\"http://wordpress.org/extend/plugins/display-widgets/\" rel=\"nofollow\">Display Widgets</a>. It'...
2012/04/13
[ "https://wordpress.stackexchange.com/questions/48921", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15162/" ]
I'm looking for a plugin to let users choose which widgets appear on individual pages. There's some solutions out there, none of which that I've found are truly easy for a non-technical user. I've tried * **[Woo Themes Sidebar manager](http://www.woothemes.com/videos/the-sidebar-manager-overview/)** - Great functio...
You can create your own sidebar if you want. add the following to your `functions.php` ``` register_sidebar(array('name'=>'Sidebar ', 'before_widget' => '<div class="widget">', 'after_widget' => '</div>', 'before_title' => '<p>', 'after_title' => '</p>', )); ``` and you can use this widget by using...
48,933
<p>I can't seem to figure out how to change the default view for <em>"Pages"</em> in the admin menu.</p> <p>The initial view is the <em>"Pages"</em> view (<code>/wp-admin/edit.php?post_type=page</code>)</p> <p>How could it change this to something else?<br> Like <em>"Add New Page"</em>? (<code>/wp-admin/post-new.php?...
[ { "answer_id": 48938, "author": "developdaly", "author_id": 3293, "author_profile": "https://wordpress.stackexchange.com/users/3293", "pm_score": 0, "selected": false, "text": "<p>In a custom plugin, use this PHP to remove the Pages page.</p>\n\n<pre><code>add_action( 'admin_menu', 'my_c...
2012/04/13
[ "https://wordpress.stackexchange.com/questions/48933", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3246/" ]
I can't seem to figure out how to change the default view for *"Pages"* in the admin menu. The initial view is the *"Pages"* view (`/wp-admin/edit.php?post_type=page`) How could it change this to something else? Like *"Add New Page"*? (`/wp-admin/post-new.php?post_type=page`) I've tried several different options ...
**[Update]** *Answer rewritten, based on [this other Q&A](https://wordpress.stackexchange.com/q/73006/12615).* --- To achieve this: ![default pages menu view](https://i.stack.imgur.com/BU0fJ.png) Use this code: ``` add_filter( 'custom_menu_order', 'wpse_48933_submenu_order' ); function wpse_48933_submenu_order...
48,983
<p>I have a long list of taxonomy terms that all look like City-ST-Zip, ie: Phoenix-AZ-85043 or San-Diego-CA-92037</p> <p>How do I print the list of terms so that the link URL remains intact but the link text is just the city name? ie: </p> <pre><code>&lt;li&gt;&lt;a href="http://mydomain/zip/phoenix-az-85043"&gt;Pho...
[ { "answer_id": 48991, "author": "Rajeev Vyas", "author_id": 6961, "author_profile": "https://wordpress.stackexchange.com/users/6961", "pm_score": 2, "selected": false, "text": "<pre><code>&lt;?php \n $terms = get_terms( $taxonomies, $args );\n $term_name_array = array();\n forea...
2012/04/14
[ "https://wordpress.stackexchange.com/questions/48983", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2107/" ]
I have a long list of taxonomy terms that all look like City-ST-Zip, ie: Phoenix-AZ-85043 or San-Diego-CA-92037 How do I print the list of terms so that the link URL remains intact but the link text is just the city name? ie: ``` <li><a href="http://mydomain/zip/phoenix-az-85043">Phoenix</a></li> ``` Also - A lot ...
``` <?php $terms = get_terms( $taxonomies, $args ); $term_name_array = array(); foreach($terms as $term){ $term_name_explode = explode("-",$term->term_name); $myterm_name=''; for($i=0;$i<count($term_name_explode)-2;$i++){ $myterm_name.=" ".$term_name_explode[$...
48,992
<p>I have my blog page limited to 5 posts on the main page, which I'm happy with. However, I want my tag pages to list much more, maybe 15 or so. How do I most easily make this change? There's no option on the reading page.</p> <p>thx!</p>
[ { "answer_id": 48997, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 1, "selected": false, "text": "<p>There are so many ways you can actually go about this and here's ONE...</p>\n\n<p>Create a file called <code>tag....
2012/04/14
[ "https://wordpress.stackexchange.com/questions/48992", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7958/" ]
I have my blog page limited to 5 posts on the main page, which I'm happy with. However, I want my tag pages to list much more, maybe 15 or so. How do I most easily make this change? There's no option on the reading page. thx!
I would put this in functions.php: ``` function main_query_mods( $query ) { // check http://codex.wordpress.org/Conditional_Tags to play with other queries if(!$query->is_main_query()) { return; } if(is_tag()) { $query->set('posts_per_page',15); } } add_action( 'pre_get_posts', 'mai...
48,999
<p>I've seen a lot of code on how to add a <code>first</code> and <code>last</code> class to a WordPress menu, but in my instance I would like to add a <code>last</code> class to the last li in the sub-menu that WP generates. Here's what I would like to achieve in it's simplest form.</p> <pre><code>&lt;ul&gt; &lt;...
[ { "answer_id": 49000, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 2, "selected": false, "text": "<p>The jQuery would look something like this;</p>\n\n<pre><code>jQuery(document).ready( function($) {\n $('.sub-m...
2012/04/14
[ "https://wordpress.stackexchange.com/questions/48999", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4999/" ]
I've seen a lot of code on how to add a `first` and `last` class to a WordPress menu, but in my instance I would like to add a `last` class to the last li in the sub-menu that WP generates. Here's what I would like to achieve in it's simplest form. ``` <ul> <li>Menu item one</li> <li class="has-sub-menu">Menu ...
Put the following in your `functions.php` ``` class SH_Last_Walker extends Walker_Nav_Menu{ function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) { $id_field = $this->db_fields['id']; //If the current element has children, add class 'sub-menu' if( ...
49,003
<p>I'm writing a new theme from scratch, based off the Toolbox theme. My installation of WP is straight out of the box. I added add_theme_support('custom-header'); to my functions.php file, but the "header" options screen does not appear in the dashboard. I can see it if I visit the site, in the toolbar at the top, but...
[ { "answer_id": 49000, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 2, "selected": false, "text": "<p>The jQuery would look something like this;</p>\n\n<pre><code>jQuery(document).ready( function($) {\n $('.sub-m...
2012/04/14
[ "https://wordpress.stackexchange.com/questions/49003", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11363/" ]
I'm writing a new theme from scratch, based off the Toolbox theme. My installation of WP is straight out of the box. I added add\_theme\_support('custom-header'); to my functions.php file, but the "header" options screen does not appear in the dashboard. I can see it if I visit the site, in the toolbar at the top, but ...
Put the following in your `functions.php` ``` class SH_Last_Walker extends Walker_Nav_Menu{ function display_element( $element, &$children_elements, $max_depth, $depth=0, $args, &$output ) { $id_field = $this->db_fields['id']; //If the current element has children, add class 'sub-menu' if( ...
49,014
<p>I have a multi-author website and I use the <a href="http://wordpress.org/extend/plugins/wypiekacz/" rel="nofollow noreferrer">WyPiekacz plugin</a> to require that authors add 1-5 tags, select only a single category, and include a featured image (<a href="https://wordpress.stackexchange.com/questions/46930/require-m...
[ { "answer_id": 49033, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 4, "selected": true, "text": "<p>You should never edit the core files of WordPress.</p>\n<p>Instead you should only ever edit Plugin files and or T...
2012/04/14
[ "https://wordpress.stackexchange.com/questions/49014", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14558/" ]
I have a multi-author website and I use the [WyPiekacz plugin](http://wordpress.org/extend/plugins/wypiekacz/) to require that authors add 1-5 tags, select only a single category, and include a featured image ([and require minimum dimensions for the featured image](https://wordpress.stackexchange.com/questions/46930/re...
You should never edit the core files of WordPress. Instead you should only ever edit Plugin files and or Theme files (Plugins or Themes folder) One of the easiest was to achieve this would be via jQuery; ``` jQuery('<div/>', { id: 'your-note', text: 'Add up to 5 tags...etc' }).appendTo('#tagsdiv-post_tag .in...
49,019
<p>I'd like to pull in profile info (name, web address, etc. + some custom-made fields) for specific users onto some of my category pages. </p> <p>I realize I can pull in profile info using "current author," but this won't help in this case because the user won't be associated with the category page as an author. </p>...
[ { "answer_id": 49043, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p><a href=\"https://wordpress.stackexchange.com/a/6817/73\">Add a metabox to the category edit screen</a> with a <a href...
2012/04/14
[ "https://wordpress.stackexchange.com/questions/49019", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15196/" ]
I'd like to pull in profile info (name, web address, etc. + some custom-made fields) for specific users onto some of my category pages. I realize I can pull in profile info using "current author," but this won't help in this case because the user won't be associated with the category page as an author. For example,...
[Add a metabox to the category edit screen](https://wordpress.stackexchange.com/a/6817/73) with a [user dropdown](http://codex.wordpress.org/Function_Reference/wp_dropdown_users). Save the user ID as meta data. In your category template use the meta user ID as argument for [`get_user_by()`](http://codex.wordpress.org...
49,020
<p>In plugin development, what is the best practice to prevent jQuery component collision on the front end?</p> <p>For instance, let's say I include the jQuery Apprise dialog in a plugin that loads this on the front-end for something, yet another plugin may do the same. Because this gets loaded and declared twice, or ...
[ { "answer_id": 49043, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 2, "selected": false, "text": "<p><a href=\"https://wordpress.stackexchange.com/a/6817/73\">Add a metabox to the category edit screen</a> with a <a href...
2012/04/14
[ "https://wordpress.stackexchange.com/questions/49020", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13/" ]
In plugin development, what is the best practice to prevent jQuery component collision on the front end? For instance, let's say I include the jQuery Apprise dialog in a plugin that loads this on the front-end for something, yet another plugin may do the same. Because this gets loaded and declared twice, or perhaps on...
[Add a metabox to the category edit screen](https://wordpress.stackexchange.com/a/6817/73) with a [user dropdown](http://codex.wordpress.org/Function_Reference/wp_dropdown_users). Save the user ID as meta data. In your category template use the meta user ID as argument for [`get_user_by()`](http://codex.wordpress.org...
49,026
<p>I’ve hit another small rock in my current project! </p> <p>I’m trying to list (and link) to the archive page for the top 4 most used terms for a custom post type. I have this;</p> <pre><code>get_terms('trade',array('orderby'=&gt;'count','order'=&gt;'DESC','number'=&gt;4)) </code></pre> <p>..which is along the rig...
[ { "answer_id": 49036, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 3, "selected": true, "text": "<p>I if were you, I'd have two options in my mind. Both hinge on the fact thsi is an inherently expensive computa...
2012/04/14
[ "https://wordpress.stackexchange.com/questions/49026", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12350/" ]
I’ve hit another small rock in my current project! I’m trying to list (and link) to the archive page for the top 4 most used terms for a custom post type. I have this; ``` get_terms('trade',array('orderby'=>'count','order'=>'DESC','number'=>4)) ``` ..which is along the right lines but I can’t seem to find a way to...
I if were you, I'd have two options in my mind. Both hinge on the fact thsi is an inherently expensive computation and no mysql trickery will reduce the load with the data you have. So **Option 1, do it the expensive way and store the data for a rainy day** You're going to have to swallow the cost of calculating thi...
49,077
<p>I'm using <a href="http://wordpress.org/extend/plugins/black-studio-tinymce-widget/" rel="nofollow">Black Studio TinyMCE Widget</a> as a rich text editor widget. In a sidebar I inserted the TinyMCE widget with a <code>[testimonial]</code> shortcode and some content after it.</p> <p>For example:</p> <pre><code>[tes...
[ { "answer_id": 49080, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p>A <code>blockquote</code> is a block element, and shouldn't be put inside a <code>&lt;p&gt;</code> tag, what ...
2012/04/15
[ "https://wordpress.stackexchange.com/questions/49077", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1343/" ]
I'm using [Black Studio TinyMCE Widget](http://wordpress.org/extend/plugins/black-studio-tinymce-widget/) as a rich text editor widget. In a sidebar I inserted the TinyMCE widget with a `[testimonial]` shortcode and some content after it. For example: ``` [testimonial] Read more client testimonials (as a link) ``` ...
There actually are several ways to handle the Wordpress editor wrapping shortcodes in `<p>` tags. This code shows probably the simplest way to do it...just a simple and short function you need to drop into your *functions.php* file. Once you do, no more tags around your shortcodes that are on their own line! ``` fun...
49,086
<p>I would like to get monthly archives for static pages. I tried to use the next code:</p> <pre><code>add_filter('getarchives_where','my_archives_filter'); function my_archives_filter($where_clause) { return "WHERE post_type = 'page' AND post_status = 'publish'"; } </code></pre> <p>and in the sidebar I write:</p> <...
[ { "answer_id": 49087, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 2, "selected": false, "text": "<p><code>wp_get_archives</code> already have <code>post_type = 'post'</code> by default and to replace it try th...
2012/04/15
[ "https://wordpress.stackexchange.com/questions/49086", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15206/" ]
I would like to get monthly archives for static pages. I tried to use the next code: ``` add_filter('getarchives_where','my_archives_filter'); function my_archives_filter($where_clause) { return "WHERE post_type = 'page' AND post_status = 'publish'"; } ``` and in the sidebar I write: ``` add_filter('getarchives_whe...
`wp_get_archives` already have `post_type = 'post'` by default and to replace it try this: ``` add_filter('getarchives_where','my_archives_filter'); function my_archives_filter($where_clause) { str_replace( "post_type = 'post'" , "post_type = 'page'" , $where ); } ``` in sidebar: ``` add_filter('getarchives_whe...
49,094
<p>I have content locker plugin.</p> <p>For locking contents, im using this shortcode:</p> <p><strong>[wp-like-locker]</strong> Your locked content here... <strong>[/wp-like-locker]</strong></p> <p>and I need lock every post on my blog. How could I instert this shortcodes into theme and lock:</p> <p><strong>Thank...
[ { "answer_id": 49104, "author": "Wyck", "author_id": 1509, "author_profile": "https://wordpress.stackexchange.com/users/1509", "pm_score": 2, "selected": false, "text": "<p>You can hardcode shortcodes into a theme using <code>do_shortcode</code>.\n<a href=\"http://codex.wordpress.org/Fun...
2012/04/15
[ "https://wordpress.stackexchange.com/questions/49094", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15229/" ]
I have content locker plugin. For locking contents, im using this shortcode: **[wp-like-locker]** Your locked content here... **[/wp-like-locker]** and I need lock every post on my blog. How could I instert this shortcodes into theme and lock: **Thank you very very very much for your answer and time!**
You can hardcode shortcodes into a theme using `do_shortcode`. <http://codex.wordpress.org/Function_Reference/do_shortcode> ``` echo do_shortcode('[wp-like-locker] Your locked content here... [/wp-like-locker]'); ``` You will most likely want to replace the hard-coded "Your locked content here..." with the function ...
49,108
<p>I need a 3 part conditional statement with all negatives but I can't get it to work. I need to say that the post isnt in category 'videos' or its child categories and isn't from the author with the id of 3. This is what I had but obviously doesn't do the trick.</p> <pre><code>if (!in_category('videos') || !post_is_...
[ { "answer_id": 49109, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 0, "selected": false, "text": "<pre><code>if (\n ( ! in_category( 'videos' ) OR ! post_is_in_descendant_category( 9 ) )\n AND ! is_author('3')\...
2012/04/15
[ "https://wordpress.stackexchange.com/questions/49108", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12700/" ]
I need a 3 part conditional statement with all negatives but I can't get it to work. I need to say that the post isnt in category 'videos' or its child categories and isn't from the author with the id of 3. This is what I had but obviously doesn't do the trick. ``` if (!in_category('videos') || !post_is_in_descendant_...
I like to split this kind of thing to more than one conditional, as it makes it easier for me to read. ``` if( !( in_category( 'videos' ) || post_is_in_descendant_category( 9 ) ) ) { if( get_the_author_meta( 'ID' ) != 3 ) { } } ``` Given, it's a bit more code, but that's the way it reads best to my eyes.
49,116
<p>I'm almost finished with this one, just a small problem left. Hope you can help me.</p> <p>I've got two very simple, custom loops. One for sticky posts, and one for non-sticky. I've manage to get the sticky posts to only show up on page 1, and not on the rest of the pages (when using pagination), which is just what...
[ { "answer_id": 49304, "author": "Stephen Harris", "author_id": 9364, "author_profile": "https://wordpress.stackexchange.com/users/9364", "pm_score": 1, "selected": false, "text": "<p>The problem is that on your first page you ask for, lets say, 7 'normal' posts. So it displays the latest...
2012/04/15
[ "https://wordpress.stackexchange.com/questions/49116", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15228/" ]
I'm almost finished with this one, just a small problem left. Hope you can help me. I've got two very simple, custom loops. One for sticky posts, and one for non-sticky. I've manage to get the sticky posts to only show up on page 1, and not on the rest of the pages (when using pagination), which is just what I want. T...
The problem is that on your first page you ask for, lets say, 7 'normal' posts. So it displays the latest 7 posts: e.g. 15-9. On page two you are telling WordPress I want 8 posts per page and I want the second page. The internal logic is that if you have 8 posts per page and you are on the second page then you want t...
49,146
<p>Been looking for someone with this same problem for hours now so I decided to post my own thread. </p> <p>I have a hierachical custom post type called contact-information. Using this I have parentpages which contain no information, and childpages which does! In the single-contact-information.php I've set a redirect...
[ { "answer_id": 49144, "author": "Mahmudur", "author_id": 9767, "author_profile": "https://wordpress.stackexchange.com/users/9767", "pm_score": 0, "selected": false, "text": "<p>There is a good article about hardening your WordPress website. I have found this article very useful and follo...
2012/04/16
[ "https://wordpress.stackexchange.com/questions/49146", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15251/" ]
Been looking for someone with this same problem for hours now so I decided to post my own thread. I have a hierachical custom post type called contact-information. Using this I have parentpages which contain no information, and childpages which does! In the single-contact-information.php I've set a redirect rule that...
Look at this answer I wrote for a more extensive explanation: [Malware on site](https://wordpress.stackexchange.com/questions/46972/malware-on-site/46980#46980) For a summary: * Add a login limiting plugin * Move wp-config.php out of the public html folder ( WordPress will look one folder up from its root directory ...
49,154
<p>I intended to run a multi-author site, I don't want the posts from other authors to be shown in <code>/wp-admin/edit.php</code> page.</p> <p>I managed solve this problem by the codes from <a href="http://wordpress.org/support/topic/how-to-hide-other-users-posts-in-admin-panel-1" rel="noreferrer">this thread</a>. Th...
[ { "answer_id": 49200, "author": "Bainternet", "author_id": 2487, "author_profile": "https://wordpress.stackexchange.com/users/2487", "pm_score": 4, "selected": false, "text": "<p>Here is what I use:</p>\n\n<pre><code>// Show only posts and media related to logged in author\nadd_action('p...
2012/04/16
[ "https://wordpress.stackexchange.com/questions/49154", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14728/" ]
I intended to run a multi-author site, I don't want the posts from other authors to be shown in `/wp-admin/edit.php` page. I managed solve this problem by the codes from [this thread](http://wordpress.org/support/topic/how-to-hide-other-users-posts-in-admin-panel-1). The code is like this: ``` function posts_for_curr...
Here is what I use: ``` // Show only posts and media related to logged in author add_action('pre_get_posts', 'query_set_only_author' ); function query_set_only_author( $wp_query ) { global $current_user; if( is_admin() && !current_user_can('edit_others_posts') ) { $wp_query->set( 'author', $current_use...
49,173
<p>Is it possible to remove the <code>Visual</code> \ <code>HTML</code> tabs from <code>wp_editor</code> and display only the TinyMCE editor?</p> <p>Basically, right now, I'm using <code>wp_editor</code> to display the smallest possible TinyMCE editor I can - only one button is needed, italics.</p> <p><img src="https...
[ { "answer_id": 49179, "author": "Travis Pflanz", "author_id": 14558, "author_profile": "https://wordpress.stackexchange.com/users/14558", "pm_score": 0, "selected": false, "text": "<p>You can hide both from view using this code in your theme's functions.php file:</p>\n\n<pre><code>//Hide...
2012/04/16
[ "https://wordpress.stackexchange.com/questions/49173", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6344/" ]
Is it possible to remove the `Visual` \ `HTML` tabs from `wp_editor` and display only the TinyMCE editor? Basically, right now, I'm using `wp_editor` to display the smallest possible TinyMCE editor I can - only one button is needed, italics. ![Current TinyMCE instnace](https://i.stack.imgur.com/LH1dD.png) What I'd l...
Just set 'quicktags' parameter of the settings array to false. ``` wp_editor('', 'some-id', array('quicktags' => false) ); ```
49,175
<p><em>Firstly, I have done my research as thoroughly as I possibly can. Searches have been made, but I have not found any advice or solution as to my exact issue.</em></p> <p>Ok, time to explain.</p> <p>Currently I am working on a gallery theme for a client (I am not the original developer of this theme, it was crea...
[ { "answer_id": 49179, "author": "Travis Pflanz", "author_id": 14558, "author_profile": "https://wordpress.stackexchange.com/users/14558", "pm_score": 0, "selected": false, "text": "<p>You can hide both from view using this code in your theme's functions.php file:</p>\n\n<pre><code>//Hide...
2012/04/16
[ "https://wordpress.stackexchange.com/questions/49175", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15257/" ]
*Firstly, I have done my research as thoroughly as I possibly can. Searches have been made, but I have not found any advice or solution as to my exact issue.* Ok, time to explain. Currently I am working on a gallery theme for a client (I am not the original developer of this theme, it was created by another developer...
Just set 'quicktags' parameter of the settings array to false. ``` wp_editor('', 'some-id', array('quicktags' => false) ); ```
49,178
<p>Does someone know any plugin available that can allow any users to create a post and publish it without even registering?? In fact, I want to use it with wp-ecommerce wordpress plugin found <a href="http://wordpress.org/extend/plugins/wp-e-commerce/" rel="nofollow">here</a></p>
[ { "answer_id": 49179, "author": "Travis Pflanz", "author_id": 14558, "author_profile": "https://wordpress.stackexchange.com/users/14558", "pm_score": 0, "selected": false, "text": "<p>You can hide both from view using this code in your theme's functions.php file:</p>\n\n<pre><code>//Hide...
2012/04/16
[ "https://wordpress.stackexchange.com/questions/49178", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12000/" ]
Does someone know any plugin available that can allow any users to create a post and publish it without even registering?? In fact, I want to use it with wp-ecommerce wordpress plugin found [here](http://wordpress.org/extend/plugins/wp-e-commerce/)
Just set 'quicktags' parameter of the settings array to false. ``` wp_editor('', 'some-id', array('quicktags' => false) ); ```
49,182
<p>This is an example of how I'm grabbing images from my custom post type now, using <code>query_posts();</code></p> <pre><code>// query_posts stuff made up here. $my_array = get_custom_field('image:to_array', 'to_image_array'); // $my_array is now all my images from that post. </code></pre> <p>What I want to do is ...
[ { "answer_id": 49184, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p><code>get_custom_field</code> is not a standard wordpress function, unless given the source code we cannot he...
2012/04/16
[ "https://wordpress.stackexchange.com/questions/49182", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13169/" ]
This is an example of how I'm grabbing images from my custom post type now, using `query_posts();` ``` // query_posts stuff made up here. $my_array = get_custom_field('image:to_array', 'to_image_array'); // $my_array is now all my images from that post. ``` What I want to do is pull out an image from a custom post ...
`get_custom_field` is not a standard wordpress function, unless given the source code we cannot help you with it. But I can tell you, that it is not getting its data from the post object, but the post meta. e.g. ``` $value = get_post_meta($post->ID,'key name',true); // where true indicates there is only a single key...
49,185
<p>I have a custom post type called 'episode'. Attached to 'episode' I have a custom taxonomy called 'video_type' that contains two terms: "bonus-footage" and "episode"; "episode" contains two child terms "season-1" and "season-2" (other seasons will be added in the future). I want to grab only the most recent post of ...
[ { "answer_id": 49186, "author": "Chip Bennett", "author_id": 3966, "author_profile": "https://wordpress.stackexchange.com/users/3966", "pm_score": 7, "selected": true, "text": "<p>The <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters\"><code>tax_query</cod...
2012/04/16
[ "https://wordpress.stackexchange.com/questions/49185", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5242/" ]
I have a custom post type called 'episode'. Attached to 'episode' I have a custom taxonomy called 'video\_type' that contains two terms: "bonus-footage" and "episode"; "episode" contains two child terms "season-1" and "season-2" (other seasons will be added in the future). I want to grab only the most recent post of th...
The [`tax_query` parameter is an *array of arrays*](http://codex.wordpress.org/Class_Reference/WP_Query#Taxonomy_Parameters), not just an array. This: ``` 'tax_query' => array( 'taxonomy' => 'video_type', 'terms' => 'episode', 'field' => 'slug', 'include_children' => true, 'ope...
49,223
<p>I'd like to test some theme changes on my live site, but I obviously don't want regular users seeing any errors that may arise from it. I'd like to just duplicate my theme folder and if I'm logged in as admin, then that theme is shown to me, otherwise, the old theme is shown to my users. </p> <p>Is there a plugin t...
[ { "answer_id": 49226, "author": "kaiser", "author_id": 385, "author_profile": "https://wordpress.stackexchange.com/users/385", "pm_score": 1, "selected": false, "text": "<p>You got <a href=\"http://codex.wordpress.org/Function_Reference/switch_theme\" rel=\"nofollow\"><code>switch_theme(...
2012/04/16
[ "https://wordpress.stackexchange.com/questions/49223", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12476/" ]
I'd like to test some theme changes on my live site, but I obviously don't want regular users seeing any errors that may arise from it. I'd like to just duplicate my theme folder and if I'm logged in as admin, then that theme is shown to me, otherwise, the old theme is shown to my users. Is there a plugin to do this?
I just wrote this quick plugin and it seems to work. Let me know if there is a better way. ``` <?php /* Plugin Name: Theme Switch if Admin Description: Display different theme to user if logged in as admin Author: Kyle Barber */ add_filter('template', 'change_theme'); add_filter('option_template', 'change_the...
49,248
<p>I feel like this should be a simple question, but I can't figure it out.</p> <p>If I have a post_id, how can I remove a particular tag from that post in php?? I know how to update meta information, but tag information is different.</p>
[ { "answer_id": 49256, "author": "Alexander Bird", "author_id": 9142, "author_profile": "https://wordpress.stackexchange.com/users/9142", "pm_score": 3, "selected": true, "text": "<p>Below is code that works:</p>\n\n<pre><code>function untag_posts($post_ids, $tags) {\n global $wpdb;\n ...
2012/04/17
[ "https://wordpress.stackexchange.com/questions/49248", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9142/" ]
I feel like this should be a simple question, but I can't figure it out. If I have a post\_id, how can I remove a particular tag from that post in php?? I know how to update meta information, but tag information is different.
Below is code that works: ``` function untag_posts($post_ids, $tags) { global $wpdb; if(! is_array($post_ids) ) { $post_ids = array($post_ids); } $in_post_ids = implode("','", $post_ids); if(! is_array($tags) ) { $tags = array($tags); } $in_tag_names = "'" . implode...