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
1,014
<p>Ok, so I'm using the <a href="http://farinspace.com/wpalchemy-metabox" rel="nofollow noreferrer"><strong>WPAlchemy class</strong></a> to create custom field write panels in the write post page, and so far everything has gone great... However, there's one issue I can't seem to figure out. I'm trying to use the custom...
[ { "answer_id": 1015, "author": "2ndkauboy", "author_id": 462, "author_profile": "https://wordpress.stackexchange.com/users/462", "pm_score": 2, "selected": false, "text": "<p>I also got a blog with custom fields regarding event. Here is the query I used in combination with the query_post...
2010/08/29
[ "https://wordpress.stackexchange.com/questions/1014", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/460/" ]
Ok, so I'm using the [**WPAlchemy class**](http://farinspace.com/wpalchemy-metabox) to create custom field write panels in the write post page, and so far everything has gone great... However, there's one issue I can't seem to figure out. I'm trying to use the custom field values of "event dates" to sort events on a cu...
Josh, take a look at: <http://farinspace.com/wpalchemy-metabox-data-storage-modes/> ... I am thinking I will be changing how WPAlchemy stores values by default ... making EXTRACT mode default ...
1,027
<p>I upgraded a client's WordPress from 2.8 to 3.0.1 and after upgrading I am now receiving this message in the dashboard:</p> <blockquote> <p>Your backup folder MIGHT be visible to the public</p> <p>To correct this issue, move the .htaccess file from wp-content/plugins/wp-dbmanager to /home/usearname/p...
[ { "answer_id": 1028, "author": "MikeSchinkel", "author_id": 89, "author_profile": "https://wordpress.stackexchange.com/users/89", "pm_score": 3, "selected": false, "text": "<p>gear-solid**:</p>\n\n<h2>Looking in the Source Code...</h2>\n\n<p>Here's the function from <a href=\"http://word...
2010/08/30
[ "https://wordpress.stackexchange.com/questions/1027", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32/" ]
I upgraded a client's WordPress from 2.8 to 3.0.1 and after upgrading I am now receiving this message in the dashboard: > > Your backup folder MIGHT be visible to > the public > > > To correct this issue, move the > .htaccess file from > wp-content/plugins/wp-dbmanager to > /home/usearname/public\_html/wp-conte...
gear-solid\*\*: Looking in the Source Code... ----------------------------- Here's the function from [**WP-DBManager Plugin**](http://wordpress.org/extend/plugins/wp-dbmanager/) that generates that error: ``` function dbmanager_admin_notices() { $backup_options = get_option('dbmanager_options'); if(!@file_exists...
1,030
<p>The pages like "about" will be created automatically when a new blog is created. Likewise I need some other pages which should appear automatically when a blog is created under my multisites.</p> <p>How can I configure the default pages to be created with a new blog under a multisite?</p> <p>For ex.: If I have a m...
[ { "answer_id": 1031, "author": "kevtrout", "author_id": 58, "author_profile": "https://wordpress.stackexchange.com/users/58", "pm_score": 5, "selected": true, "text": "<p>I recommend creating a function in your functions.php file that ties to the action hook <code>activate_blog</code>. ...
2010/08/30
[ "https://wordpress.stackexchange.com/questions/1030", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/391/" ]
The pages like "about" will be created automatically when a new blog is created. Likewise I need some other pages which should appear automatically when a blog is created under my multisites. How can I configure the default pages to be created with a new blog under a multisite? For ex.: If I have a multisite on `exam...
I recommend creating a function in your functions.php file that ties to the action hook `activate_blog`. Use the WordPress functions [get\_pages()](http://codex.wordpress.org/Function_Reference/get_pages) to see if your default pages exist. If they do not, create them with [wp\_insert\_post](http://codex.wordpress.org/...
1,033
<p>I currently have this:</p> <pre><code>mysite.com/product-name mysite.com/another-product </code></pre> <p>etc where product-name and another-product are posts.</p> <p>I then have a custom post type called Changelogs, which I have for each product, is it possible to have the url something like:</p> <pre><code>mys...
[ { "answer_id": 1036, "author": "hakre", "author_id": 178, "author_profile": "https://wordpress.stackexchange.com/users/178", "pm_score": 3, "selected": true, "text": "<p>There is no such thing as <em>&quot;Sub Posts&quot;</em> in Wordpress already built in.</p>\n<p>But it could be possib...
2010/08/30
[ "https://wordpress.stackexchange.com/questions/1033", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/110/" ]
I currently have this: ``` mysite.com/product-name mysite.com/another-product ``` etc where product-name and another-product are posts. I then have a custom post type called Changelogs, which I have for each product, is it possible to have the url something like: ``` mysite.com/product-name/changelog mysite.com/an...
There is no such thing as *"Sub Posts"* in Wordpress already built in. But it could be possible that you create a plugin that is introducing *"Sub Posts"* in the style you describe them. Technically you're not talking about subposts but about the URL-Layout. So in Wordpress you add an endpoint ("changelog") that you ...
1,034
<p>We have template tags and some functions that start with get. Sometimes it would be just nice in themes to do like:</p> <pre><code>$title = the_title(); </code></pre> <p>to use the html later on. This is just a simplified example, naturally there is some function like get_the_title(); But that works for that funct...
[ { "answer_id": 1048, "author": "kevtrout", "author_id": 58, "author_profile": "https://wordpress.stackexchange.com/users/58", "pm_score": 2, "selected": false, "text": "<p>I would argue that <code>get_posts</code> is the WP answer for your request. Template tags have been created for us...
2010/08/30
[ "https://wordpress.stackexchange.com/questions/1034", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/178/" ]
We have template tags and some functions that start with get. Sometimes it would be just nice in themes to do like: ``` $title = the_title(); ``` to use the html later on. This is just a simplified example, naturally there is some function like get\_the\_title(); But that works for that function only. I'm wondering...
In direct response to the question, WordPress does not include a function for this partly because it does not specifically apply to WordPress functionality. I.e. it's a PHP (potential) problem, not WordPress. Also, I wouldn't say it's WordPress' responsibility to provide workarounds for plugins etc that don't provide...
1,037
<p>I started developing a site with over a dozen custom post types. I'd like to rename a few of them, not just the display value, but the actual custom post type name. I'm worried however that by just running a SQL update query that I'll miss some places where I need to change things or overwrite part of serialized dat...
[ { "answer_id": 1038, "author": "John P Bloch", "author_id": 11, "author_profile": "https://wordpress.stackexchange.com/users/11", "pm_score": 7, "selected": true, "text": "<p>SQL query for renaming the posts:</p>\n\n<pre><code>UPDATE `wp_posts` SET `post_type` = '&lt;new post type nam...
2010/08/30
[ "https://wordpress.stackexchange.com/questions/1037", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/472/" ]
I started developing a site with over a dozen custom post types. I'd like to rename a few of them, not just the display value, but the actual custom post type name. I'm worried however that by just running a SQL update query that I'll miss some places where I need to change things or overwrite part of serialized data. ...
SQL query for renaming the posts: ``` UPDATE `wp_posts` SET `post_type` = '<new post type name>' WHERE `post_type` = '<old post type name>'; ``` SQL query for renaming taxonomy: ``` UPDATE `wp_term_taxonomy` SET `taxonomy` = '<new taxonomy name>' WHERE `taxonomy` = '<old taxonomy name>'; ``` That should t...
1,039
<p>Is there a way to add a arbitrary hyperlink to the WordPress admin menu (I mean the menu on the left when you log into the admin dashboard)? For example, can one add a link to Google?</p> <p>In my particular case, I'd like to add a styleguide page for a Wordpress theme I'm working on so I can show the user how diff...
[ { "answer_id": 1042, "author": "MikeSchinkel", "author_id": 89, "author_profile": "https://wordpress.stackexchange.com/users/89", "pm_score": 5, "selected": true, "text": "<p>Hi <strong>@Tom</strong>,</p>\n\n<p>If I understand your question correctly you don't so much need to know how to...
2010/08/30
[ "https://wordpress.stackexchange.com/questions/1039", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24/" ]
Is there a way to add a arbitrary hyperlink to the WordPress admin menu (I mean the menu on the left when you log into the admin dashboard)? For example, can one add a link to Google? In my particular case, I'd like to add a styleguide page for a Wordpress theme I'm working on so I can show the user how different HTML...
Hi **@Tom**, If I understand your question correctly you don't so much need to know how to add a link to the menu (it seems you already know that) but instead need to learn how to get your link to redirect correctly, right? Redirecting to an External URL from an Admin Menu Item ---------------------------------------...
1,051
<p>I am using an attachment.php file to show large versions of images that have been clicked on elsewhere. I'd like to pull the image alt text as a caption under the image with javascript, but the alt text isn't included when when wp_get_attachment_image_src() is used. I don't think WP has a function to retrieve it, ...
[ { "answer_id": 1065, "author": "MikeSchinkel", "author_id": 89, "author_profile": "https://wordpress.stackexchange.com/users/89", "pm_score": 7, "selected": true, "text": "<p>I recently did some research for a client project recently so <em>lo-and-behold</em> I get to use it here!</p>\n<...
2010/08/30
[ "https://wordpress.stackexchange.com/questions/1051", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58/" ]
I am using an attachment.php file to show large versions of images that have been clicked on elsewhere. I'd like to pull the image alt text as a caption under the image with javascript, but the alt text isn't included when when wp\_get\_attachment\_image\_src() is used. I don't think WP has a function to retrieve it, s...
I recently did some research for a client project recently so *lo-and-behold* I get to use it here! After the text you'll see a categorized list of most (all?) of the image handling functions from within WordPress 3.0.1 (I grouped them in some semblance of order but don't put too much credence in my categorization.) ...
1,058
<p>So I continue to run into this issue and I just looking for the best and simplest solution to solve this problem.</p> <p>I have come to make use of custom post types in many different projects and have extended these with custom metaboxes which I have then further extended by adding custom scripts such as jQuery eve...
[ { "answer_id": 1061, "author": "MikeSchinkel", "author_id": 89, "author_profile": "https://wordpress.stackexchange.com/users/89", "pm_score": 5, "selected": true, "text": "<p>First, I assume you <a href=\"https://wordpress.stackexchange.com/questions/556/#562\"><strong>are using <code>wp...
2010/08/31
[ "https://wordpress.stackexchange.com/questions/1058", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/479/" ]
So I continue to run into this issue and I just looking for the best and simplest solution to solve this problem. I have come to make use of custom post types in many different projects and have extended these with custom metaboxes which I have then further extended by adding custom scripts such as jQuery event calend...
First, I assume you [**are using `wp_enqueue_script()` to load your scripts**](https://wordpress.stackexchange.com/questions/556/#562), right? That said, if I understand your question then **what you need is something like the following**. You'll have to edit it for your details, of course, but it gives you the genera...
1,069
<p>I've just created a draft on my blog, and it's post ID is 1. After creating another draft, the post id for this last post is 3! I was hoping to see them in sequential order, so in the future I'll have a nice auto-incremented numbering like</p> <pre><code>../archives/1 ../archives/2 </code></pre> <p>some month...
[ { "answer_id": 1099, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 0, "selected": false, "text": "<p>WPtex is an old project and is a solution for your question, please google for this. Maybe i can send my version vi...
2010/08/31
[ "https://wordpress.stackexchange.com/questions/1069", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/485/" ]
I've just created a draft on my blog, and it's post ID is 1. After creating another draft, the post id for this last post is 3! I was hoping to see them in sequential order, so in the future I'll have a nice auto-incremented numbering like ``` ../archives/1 ../archives/2 ``` some months later... ``` ../archive...
I'm developer of [WP-QuickLaTeX](http://www.holoborodko.com/pavel/quicklatex/) plugin. It is developed for mathematicians driven by feeling that math doesn't deserve to be published with poor quality on the Web. In fact, besides correct formula positioning and meaningful error messages, WP-QuickLaTeX **can store imag...
1,076
<p>No matter what url somebody uses to access my site, I'd like it to redirect to www.MyUrl.com. Is this possible?</p>
[ { "answer_id": 1078, "author": "Matt Elliott", "author_id": 505, "author_profile": "https://wordpress.stackexchange.com/users/505", "pm_score": 3, "selected": false, "text": "<p>As far as i know there is no way to force the url to uppercase.</p>\n\n<p>As for forcing the www. this can var...
2010/08/31
[ "https://wordpress.stackexchange.com/questions/1076", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/517/" ]
No matter what url somebody uses to access my site, I'd like it to redirect to www.MyUrl.com. Is this possible?
As far as i know there is no way to force the url to uppercase. As for forcing the www. this can vary as to where you are hosting etc. Here is one generic way of doing this using your .htaccess file. ``` # Forcing www. infront of domain RewriteEngine On Options +FollowSymLinks RewriteCond %{HTTP_HOST} ^(domain\.com)...
1,092
<p>I'm looking for something like they are using here:</p> <p><a href="http://www.jennyreviews.com/as-seen-on-tv/triple-joint-formula/" rel="nofollow">http://www.jennyreviews.com/as-seen-on-tv/triple-joint-formula/</a></p> <p>Look under "Related Product Reviews"</p> <p>I checked the source but could not find the plu...
[ { "answer_id": 1095, "author": "Doug", "author_id": 43, "author_profile": "https://wordpress.stackexchange.com/users/43", "pm_score": 0, "selected": false, "text": "<p>\"<a href=\"http://wordpress.org/extend/plugins/yet-another-related-posts-plugin/\" rel=\"nofollow\">Yet Another Related...
2010/08/31
[ "https://wordpress.stackexchange.com/questions/1092", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/366/" ]
I'm looking for something like they are using here: <http://www.jennyreviews.com/as-seen-on-tv/triple-joint-formula/> Look under "Related Product Reviews" I checked the source but could not find the plugin code listed. Maybe its a widget?
**@Scott B**, It looks like they are using a related posts query based on category. When a single Item (post) is being displayed the query looks up the category id then displays posts from the same category. ***Add The following code to your sidebar or even to the bottom of single.php depending on where you want to d...
1,097
<p>I am building a website for a charity event and i would like for people to register for this event. </p> <p>The form should contain name, email and other custom questions. Also I would like a page where to list the persons registered. I was thinking of using the user system + a plugin for listing the user list.</p>...
[ { "answer_id": 1098, "author": "Doug", "author_id": 43, "author_profile": "https://wordpress.stackexchange.com/users/43", "pm_score": 2, "selected": false, "text": "<p>You can modify the standard WordPresss user registration form to require more data than the usual username + email addre...
2010/08/31
[ "https://wordpress.stackexchange.com/questions/1097", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/275/" ]
I am building a website for a charity event and i would like for people to register for this event. The form should contain name, email and other custom questions. Also I would like a page where to list the persons registered. I was thinking of using the user system + a plugin for listing the user list. What plugins...
Hi **solomongaby:** Forms ----- For the form I would suggestion using [GravityForms](http://www.gravityforms.com/). It's super easy to use to design and post a form, and here's [an example form we made for requests to be a presenter](http://www.thebusinessof.net/wordpress/presenting/). GravityForms is $39 per server...
1,123
<p>I have written a plugin that puts a (google) favicon in front of each link in my blog. Really simple. Just uses a simple preg_replace_callback on hrefs:</p> <pre><code>$changed_html_reference = preg_replace_callback(self::HTML_REF_REGEX, array($this,'AddExtraHtmlToOneHref'), $strHtmlBodyText); </code></pre> <p...
[ { "answer_id": 1706, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": true, "text": "<p>Most of WordPress caching functionality is set up with text (serialized if needed) in mind. Since you need to store bi...
2010/08/31
[ "https://wordpress.stackexchange.com/questions/1123", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/576/" ]
I have written a plugin that puts a (google) favicon in front of each link in my blog. Really simple. Just uses a simple preg\_replace\_callback on hrefs: ``` $changed_html_reference = preg_replace_callback(self::HTML_REF_REGEX, array($this,'AddExtraHtmlToOneHref'), $strHtmlBodyText); ``` with a ``` add_filter(...
Most of WordPress caching functionality is set up with text (serialized if needed) in mind. Since you need to store binary data it is probably better to maintain own cache. As for location of cache I think it depends: * for single personal installation I would pick directory that is short and makes nice URL, for exam...
1,151
<p>Is this a good example of usage of <a href="http://codex.wordpress.org/Function_Reference/current_filter" rel="nofollow"><code>current_filter()</code></a>?</p> <pre><code>&lt;?php add_filter("_my_filter", "common_function"); add_filter("_another_filter", "common_function"); function common_function(){ $currentFil...
[ { "answer_id": 1154, "author": "MikeSchinkel", "author_id": 89, "author_profile": "https://wordpress.stackexchange.com/users/89", "pm_score": 4, "selected": true, "text": "<p>Hi <strong>@Raj Sekharan</strong>:</p>\n\n<p>Looks good to me, but is wanting to know the current usage really yo...
2010/09/01
[ "https://wordpress.stackexchange.com/questions/1151", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/353/" ]
Is this a good example of usage of [`current_filter()`](http://codex.wordpress.org/Function_Reference/current_filter)? ``` <?php add_filter("_my_filter", "common_function"); add_filter("_another_filter", "common_function"); function common_function(){ $currentFilter = current_filter(); switch ($currentFilter) { ...
Hi **@Raj Sekharan**: Looks good to me, but is wanting to know the current usage really your question or do you want to understand where `current_filter()` gets it's information from? If the latter, here's basically what happens in all the different hook processing functions, e.g. `do_action()`, `apply_filters()`, `...
1,172
<p>Can custom fields be used to determine specific actions upon saving a post to the database? </p> <p>Which action(s) make this possible, since adding post medata seems to always occur after saving a post and thus any plugin hooking into <code>wp_insert_post</code> is activated before the post meta data has been adde...
[ { "answer_id": 1176, "author": "Doug", "author_id": 43, "author_profile": "https://wordpress.stackexchange.com/users/43", "pm_score": 1, "selected": false, "text": "<p>If you are wanting to run the function after the post meta data has been added/updated, use:</p>\n\n<pre><code>add_actio...
2010/09/01
[ "https://wordpress.stackexchange.com/questions/1172", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/637/" ]
Can custom fields be used to determine specific actions upon saving a post to the database? Which action(s) make this possible, since adding post medata seems to always occur after saving a post and thus any plugin hooking into `wp_insert_post` is activated before the post meta data has been added to the post.
If you are wanting to run the function after the post meta data has been added/updated, use: ``` add_action( 'updated_post_meta', 'my_post_meta_function' ); ```
1,174
<p>I have my wordpress install under svn. I was on version 2.9.2. These were the steps I took:</p> <ul> <li>saved a copy of my current wordpress directory</li> <li>cd into my top level wordpress directory</li> <li><code>svn up</code> (just to make sure that I have the latest of 2.9)</li> <li><code>svn sw <a href="htt...
[ { "answer_id": 1179, "author": "Annika Backstrom", "author_id": 66, "author_profile": "https://wordpress.stackexchange.com/users/66", "pm_score": 1, "selected": false, "text": "<p>Sounds like you ran <code>svn sw</code> in a subdirectory, rather than the top-level WordPress directory. We...
2010/09/01
[ "https://wordpress.stackexchange.com/questions/1174", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/448/" ]
I have my wordpress install under svn. I was on version 2.9.2. These were the steps I took: * saved a copy of my current wordpress directory * cd into my top level wordpress directory * `svn up` (just to make sure that I have the latest of 2.9) * `svn sw <http://core.svn.wordpress.org/tags/3.0.1/> .` (upgrade) * run w...
I also used SVN before to update my wordpress installation. Up the working copied will get messed up very quickly with all the manual updates or files created by plugins. I would always recommend to use the update functionality of wordpress if you only want to step from one tagged version to another one. Although, I ...
1,188
<p>I'm creating a <em>"Share this Page"</em>- widget that needs to <strong>grab the current URL</strong> and append it to a Facebook URL like this:</p> <blockquote> <p><code>http://www.facebook.com/sharer.php?u=http://myurl.com/a-specific-page</code></p> </blockquote> <p>I'm using a regular text widget. How can I a...
[ { "answer_id": 1190, "author": "Joe Hoyle", "author_id": 150, "author_profile": "https://wordpress.stackexchange.com/users/150", "pm_score": 2, "selected": false, "text": "<p>Just use the $_SERVER variables:</p>\n\n<pre><code>$url = add_query_arg( 'u', $_SERVER[\"SERVER_NAME\"].$_SERVER[...
2010/09/01
[ "https://wordpress.stackexchange.com/questions/1188", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I'm creating a *"Share this Page"*- widget that needs to **grab the current URL** and append it to a Facebook URL like this: > > `http://www.facebook.com/sharer.php?u=http://myurl.com/a-specific-page` > > > I'm using a regular text widget. How can I access the current URL and put it into the sharing link?
Just use the $\_SERVER variables: ``` $url = add_query_arg( 'u', $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"], 'http://www.facebook.com/sharer.php' ); ```
1,195
<p>I am wondering how to prevent WordPress from applying in-line styles to image enclosing div's in posts.</p> <pre><code>&lt;div class="img size-medium wp-image-3267 alignright" style="width:190px;"&gt; </code></pre> <p><strong>Edit:</strong> The post is generated in the theme file by using <code>the_content()</code...
[ { "answer_id": 1190, "author": "Joe Hoyle", "author_id": 150, "author_profile": "https://wordpress.stackexchange.com/users/150", "pm_score": 2, "selected": false, "text": "<p>Just use the $_SERVER variables:</p>\n\n<pre><code>$url = add_query_arg( 'u', $_SERVER[\"SERVER_NAME\"].$_SERVER[...
2010/09/01
[ "https://wordpress.stackexchange.com/questions/1195", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58/" ]
I am wondering how to prevent WordPress from applying in-line styles to image enclosing div's in posts. ``` <div class="img size-medium wp-image-3267 alignright" style="width:190px;"> ``` **Edit:** The post is generated in the theme file by using `the_content()`. That width declaration is causing my post to display...
Just use the $\_SERVER variables: ``` $url = add_query_arg( 'u', $_SERVER["SERVER_NAME"].$_SERVER["REQUEST_URI"], 'http://www.facebook.com/sharer.php' ); ```
1,198
<p>I'm trying to show child-pages in a certain order, in a list.</p> <p>This is my code to output the pages as a list:</p> <pre><code>$parent = $wp_query-&gt;post-&gt;ID; wp_list_pages("title_li=&amp;child_of=$parent&amp;echo=1&amp;sort_column=post_title" ); </code></pre> <p>Now I want to show the first four of the ...
[ { "answer_id": 1202, "author": "prettyboymp", "author_id": 203, "author_profile": "https://wordpress.stackexchange.com/users/203", "pm_score": 2, "selected": false, "text": "<p>The wp_list_pages() function accepts an argument for 'sort_column', this defaults to menu_order then post_title...
2010/09/01
[ "https://wordpress.stackexchange.com/questions/1198", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/394/" ]
I'm trying to show child-pages in a certain order, in a list. This is my code to output the pages as a list: ``` $parent = $wp_query->post->ID; wp_list_pages("title_li=&child_of=$parent&echo=1&sort_column=post_title" ); ``` Now I want to show the first four of the pages in a particular order: --- 1. Summary 2. In...
Based on your comments here is another option , using wp\_list\_pages and without having to work with arrays and pulling content manually, I'm leaving out a bunch of the options, just the bare essentials. ``` <ul> <?php $priority_pages = '5,1,3,7'; wp_list_pages(array('include' => $priority_pages); wp_list_pages...
1,210
<p>Hay I am creating my first wordpress plugin. Everything is going well so far. I have been able to add a new navigation tab to the dashboard which links to a function which basicalliy uses 'include' to spit the content of a HTML page onto the wordpress admin area.</p> <p>Heres my code</p> <pre><code>add_action('adm...
[ { "answer_id": 1217, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 3, "selected": true, "text": "<p>Rather than include an HTML file, include a PHP file instead. Then, at the top of your PHP file you can check to see i...
2010/09/01
[ "https://wordpress.stackexchange.com/questions/1210", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/376/" ]
Hay I am creating my first wordpress plugin. Everything is going well so far. I have been able to add a new navigation tab to the dashboard which links to a function which basicalliy uses 'include' to spit the content of a HTML page onto the wordpress admin area. Heres my code ``` add_action('admin_menu', 'rooms_menu...
Rather than include an HTML file, include a PHP file instead. Then, at the top of your PHP file you can check to see if any data's been submitted and process it before displaying the form. So instead of what you have, try: ``` function show_hotel_dashboard(){ include 'dashboard.php'; } ``` Then on the page do th...
1,216
<p>I am getting a bit frustrated over here after having spent a few hours trying to accomplish this fairly simple task without any luck.</p> <p>Essentially I have 5 custom post types which I created and all I want to do is show each of them in a specific order directly under the <em>"dashboard"</em>.</p> <p>From the ...
[ { "answer_id": 1220, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 5, "selected": false, "text": "<p>Here's a quick walkthrough of how the WordPress admin menu is built - I'm not talking the <code>add_menu_page</code> A...
2010/09/01
[ "https://wordpress.stackexchange.com/questions/1216", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1084/" ]
I am getting a bit frustrated over here after having spent a few hours trying to accomplish this fairly simple task without any luck. Essentially I have 5 custom post types which I created and all I want to do is show each of them in a specific order directly under the *"dashboard"*. From the WordPress documentation ...
Hi **@BinaryBit:** It's no wonder you are a bit frustrated; the admin menu is one of the most obtuse and frustrating implementations through WordPress core. Honestly, I don't know what they were thinking when they designed it that way. *@EAMann* did an ***excellent*** job of explaining how the admin menus work in Wo...
1,233
<p>Given that I can't access the dashboard/admin pages on my blog (that's a future question), and that I have shell access to my hosting server, can I find out the current version of WordPress from the command line?</p> <p>I tried grepping for the string '@since' in all the php files in the top level directory for the...
[ { "answer_id": 1234, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 5, "selected": true, "text": "<p>Just run this <a href=\"https://linux.die.net/man/1/grep\" rel=\"nofollow noreferrer\"><code>grep</code></a> command...
2010/09/02
[ "https://wordpress.stackexchange.com/questions/1233", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/688/" ]
Given that I can't access the dashboard/admin pages on my blog (that's a future question), and that I have shell access to my hosting server, can I find out the current version of WordPress from the command line? I tried grepping for the string '@since' in all the php files in the top level directory for the blog, and...
Just run this [`grep`](https://linux.die.net/man/1/grep) command from the command line: ``` grep wp_version wp-includes/version.php ```
1,235
<p>I have a page structure like this:</p> <pre><code>-Home -Cars -Volvo 640 - Pics - Info -Porsche 911 - Pics - Info </code></pre> <p>I'd like to generate a list of cars on the Cars page of all the cars (which are child pages of Cars). How would I do this? The list is basically a sub-menu which should...
[ { "answer_id": 1234, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 5, "selected": true, "text": "<p>Just run this <a href=\"https://linux.die.net/man/1/grep\" rel=\"nofollow noreferrer\"><code>grep</code></a> command...
2010/09/02
[ "https://wordpress.stackexchange.com/questions/1235", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/394/" ]
I have a page structure like this: ``` -Home -Cars -Volvo 640 - Pics - Info -Porsche 911 - Pics - Info ``` I'd like to generate a list of cars on the Cars page of all the cars (which are child pages of Cars). How would I do this? The list is basically a sub-menu which should show all the cars in alph...
Just run this [`grep`](https://linux.die.net/man/1/grep) command from the command line: ``` grep wp_version wp-includes/version.php ```
1,238
<p>I would like to add a custom logo to my entire blog network's dashboard. I went trough a recipe on smashing magazine and got this code:</p> <pre><code>//hook the administrative header output add_action('admin_head', 'my_custom_logo'); function my_custom_logo() { echo ' &lt;style type="text/css"&gt; ...
[ { "answer_id": 1239, "author": "Eric", "author_id": 656, "author_profile": "https://wordpress.stackexchange.com/users/656", "pm_score": 1, "selected": false, "text": "<p>You might check out the <a href=\"http://wordpress.org/extend/plugins/white-label-cms/\" rel=\"nofollow\">White Label ...
2010/09/02
[ "https://wordpress.stackexchange.com/questions/1238", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/391/" ]
I would like to add a custom logo to my entire blog network's dashboard. I went trough a recipe on smashing magazine and got this code: ``` //hook the administrative header output add_action('admin_head', 'my_custom_logo'); function my_custom_logo() { echo ' <style type="text/css"> #header-logo { back...
If you want this logo to show up across your network sites regardless of the theme I'd advise you to create a new PHP file inside `wp-content/mu-plugins` (create the directory if it doesn't exist) and drop that code inside the new file. You can name your file whatever you like - for example `my-network-tweaks.php`. Tha...
1,241
<p>I would like to "omit" certain blogs from the regular BuddyPress blog loop. Either by blog ID or blog Name is fine. Has anyone had success doing this?</p>
[ { "answer_id": 1930, "author": "rich", "author_id": 917, "author_profile": "https://wordpress.stackexchange.com/users/917", "pm_score": 1, "selected": false, "text": "<p>Currently the bp_has_blogs() loop does not allow an exclude param to remove certain blogs from the listing. By defaul...
2010/09/02
[ "https://wordpress.stackexchange.com/questions/1241", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I would like to "omit" certain blogs from the regular BuddyPress blog loop. Either by blog ID or blog Name is fine. Has anyone had success doing this?
Currently the bp\_has\_blogs() loop does not allow an exclude param to remove certain blogs from the listing. By default all public blogs are listed. You can try a simple hack (but the pagination will be off) <http://buddypress.org/community/groups/how-to-and-troubleshooting/forum/topic/excluding-certain-blogs-from-bp_...
1,248
<p>I'm trying to get WordPress to highlight a specific item in my menu when a post (any post) is viewed. I'm thinking that adding the post to the menu item, then suppressing display of sub-menus might help, but my 'Menus configuration' page doesn't show posts as items to add to the menu.</p> <p>Does anyone know why th...
[ { "answer_id": 1252, "author": "user701", "author_id": 701, "author_profile": "https://wordpress.stackexchange.com/users/701", "pm_score": 3, "selected": true, "text": "<p>You should be able to take the body class (single) and the nav item class (to be determined) and specify the style y...
2010/09/02
[ "https://wordpress.stackexchange.com/questions/1248", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119/" ]
I'm trying to get WordPress to highlight a specific item in my menu when a post (any post) is viewed. I'm thinking that adding the post to the menu item, then suppressing display of sub-menus might help, but my 'Menus configuration' page doesn't show posts as items to add to the menu. Does anyone know why that is, or ...
You should be able to take the body class (single) and the nav item class (to be determined) and specify the style you'd like to show in the stylesheet. Something like this: ``` .single .topnav-item-29 {color: #fff; background: #333;} ```
1,272
<p>I'm using <a href="http://wordpress.org/plugins/syntaxhighlighter/" rel="nofollow">SyntaxHighlighter Evolved</a> to highlight code examples. E.g.</p> <pre><code>[csharp] string s = "text"; List&lt;int&gt; numbers = new List&lt;int&gt;(); [/csharp] </code></pre> <p>When I first save it, it's ok, but when editing wo...
[ { "answer_id": 1301, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 2, "selected": false, "text": "<p>The visual editor will automatically escape HTML tags (the <code>&lt;&gt;</code> brackets in particular) to prevent co...
2010/09/03
[ "https://wordpress.stackexchange.com/questions/1272", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/728/" ]
I'm using [SyntaxHighlighter Evolved](http://wordpress.org/plugins/syntaxhighlighter/) to highlight code examples. E.g. ``` [csharp] string s = "text"; List<int> numbers = new List<int>(); [/csharp] ``` When I first save it, it's ok, but when editing wordpress changes the text to ``` [csharp] string s = &quot;text&...
I just installed *SyntaxHighlighter Evolved*, and while testing on an existing post I was dismayed to find that all the quotes `"` had been converted to `&quot;` (the single quotes were fine). I was using the HTML editor. In case you are also in this position, I found that it's just the post *preview* that is escaped ...
1,294
<p>Let's say we are currently hosting our WordPress blog on certain domain and would like to move it to a new domain. How to do this with the least hassle and SEO hit? </p> <p>Are there any plugins that could help with this? (for example providing automatic cross-domain 301 redirection or similar)</p>
[ { "answer_id": 1295, "author": "Annika Backstrom", "author_id": 66, "author_profile": "https://wordpress.stackexchange.com/users/66", "pm_score": 3, "selected": true, "text": "<p>I recommend handling the 301 redirect in your web server rather than in WordPress. mod_rewrite or RedirectMat...
2010/09/03
[ "https://wordpress.stackexchange.com/questions/1294", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/155/" ]
Let's say we are currently hosting our WordPress blog on certain domain and would like to move it to a new domain. How to do this with the least hassle and SEO hit? Are there any plugins that could help with this? (for example providing automatic cross-domain 301 redirection or similar)
I recommend handling the 301 redirect in your web server rather than in WordPress. mod\_rewrite or RedirectMatch will be much more efficient than spinning up WordPress to deliver a `Location`: header. ``` <VirtualHost *:80> ServerName busted-cheap-url.com # mod_alias RedirectMatch permanent (.*) http://gr...
1,303
<p>By default, my site's RSS feed URLs are in this format:</p> <pre><code>category/[category-name]/feed/ </code></pre> <p>As far as I can tell, that doesn't allow me to view a feed using multiple categories. Is anyone aware of a simple workaround, or is this something I'll need to write myself?</p>
[ { "answer_id": 1306, "author": "Ovidiu Pacuraru", "author_id": 713, "author_profile": "https://wordpress.stackexchange.com/users/713", "pm_score": 0, "selected": false, "text": "<p>I can recommend this plugin: <a href=\"http://wordpress.org/extend/plugins/feed-wrangler/\" rel=\"nofollow\...
2010/09/03
[ "https://wordpress.stackexchange.com/questions/1303", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119/" ]
By default, my site's RSS feed URLs are in this format: ``` category/[category-name]/feed/ ``` As far as I can tell, that doesn't allow me to view a feed using multiple categories. Is anyone aware of a simple workaround, or is this something I'll need to write myself?
Maybe this might help: <http://wordpress.org/support/topic/how-to-create-rss-feed-that-includes-multiple-categories>
1,314
<p>By default, when adding <code>&lt;!--nextpage--&gt;</code>, the following links are displayed: Pages: 1 2</p> <p>I need to replace "Pages:" with a graphic arrow which links back to the previous page, and append a graphic arrow to the end of the links that links to the next page. I'm guessing there's a way to do thi...
[ { "answer_id": 1315, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 0, "selected": false, "text": "<p>I have to admit that <code>&lt;!--nextpage--&gt;</code> isn't a very well-documented feature (there's not even a butto...
2010/09/03
[ "https://wordpress.stackexchange.com/questions/1314", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/30/" ]
By default, when adding `<!--nextpage-->`, the following links are displayed: Pages: 1 2 I need to replace "Pages:" with a graphic arrow which links back to the previous page, and append a graphic arrow to the end of the links that links to the next page. I'm guessing there's a way to do this in the functions file?
Just specify an image as the "nextpagelink" and "previouspagelink" instead of the << or >>: ``` <?php wp_link_pages(array('before' => '<div class="pagenav"><strong>Navigate</strong>', 'after' => '</div>', 'next_or_number' => 'number', 'nextpagelink' => __('<img src="PUT YOUR IMAGE URL HERE" />'), 'previouspagelink' =>...
1,330
<p>I've got a WordPress blog on WordPress.com. When posting something I'm including some sample Java code in the <code>&lt;code</code> tags, is there any way I can have this formatted better? Such as syntax highlighting and line numbers etc?</p> <p>An example of what I have is <a href="http://jameselsey.wordpress.com/...
[ { "answer_id": 1331, "author": "hakre", "author_id": 178, "author_profile": "https://wordpress.stackexchange.com/users/178", "pm_score": 3, "selected": false, "text": "<p>Yes you can. It's <code>[code] *your code here* [/code]</code> and you can even hint the language: <code>[code lang=\...
2010/09/04
[ "https://wordpress.stackexchange.com/questions/1330", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/763/" ]
I've got a WordPress blog on WordPress.com. When posting something I'm including some sample Java code in the `<code` tags, is there any way I can have this formatted better? Such as syntax highlighting and line numbers etc? An example of what I have is [here](http://jameselsey.wordpress.com/2010/08/30/android-impleme...
wordpress.com supports code syntax-highliting. You can read all about it here: <http://en.support.wordpress.com/code/posting-source-code/> for your specific example use: ``` [sourcecode language="java"] package com.jameselsey.domain; import java.util.ArrayList; import java.util.List; import com.google.android.maps.G...
1,339
<p>I have installed WordPress via an auto-installer and later configured it as multisite. But whenever I create the WordPress site using auto-installer it doesn't give me the <code>.htaccess</code> file by default. So I've created an empty file with the name <code>.htaccess</code> in CPanel and pasted this code in to i...
[ { "answer_id": 1347, "author": "matt", "author_id": 765, "author_profile": "https://wordpress.stackexchange.com/users/765", "pm_score": 2, "selected": false, "text": "<p>In my opinion that plugin is useless. The only way that I see to do this is for the Admin (you) to have the ad accoun...
2010/09/04
[ "https://wordpress.stackexchange.com/questions/1339", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/402/" ]
I have installed WordPress via an auto-installer and later configured it as multisite. But whenever I create the WordPress site using auto-installer it doesn't give me the `.htaccess` file by default. So I've created an empty file with the name `.htaccess` in CPanel and pasted this code in to it: ``` RewriteEngine On ...
In my opinion that plugin is useless. The only way that I see to do this is for the Admin (you) to have the ad accounts and for you to distribute the funds to each respective blogger. The problem arises when you have more than one advertising network (Sixapart, Adify, Adsense...) and more than one revenue metric (eg. C...
1,382
<p>There are reports that <a href="http://hakre.wordpress.com/2010/08/09/wp-plugins-how-to-remove-a-filter/" rel="nofollow"><code>remove_filter</code> does not work under some circumstances, and that we should provide alternatives</a>. However, the article does not really make it clear under which circumstances this ha...
[ { "answer_id": 1435, "author": "hakre", "author_id": 178, "author_profile": "https://wordpress.stackexchange.com/users/178", "pm_score": 2, "selected": false, "text": "<p>Well this is somehow a very specific topic that is bound to a Wordpress development issue. I strongly suggest you to ...
2010/09/05
[ "https://wordpress.stackexchange.com/questions/1382", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8/" ]
There are reports that [`remove_filter` does not work under some circumstances, and that we should provide alternatives](http://hakre.wordpress.com/2010/08/09/wp-plugins-how-to-remove-a-filter/). However, the article does not really make it clear under which circumstances this happens. I am looking for code examples t...
Well this is somehow a very specific topic that is bound to a Wordpress development issue. I strongly suggest you to keep track of the trac ticket if you liked my article. That is the best thing you can do I assume for finding out when the problems come into play as well how to circumvent them technically (if you don't...
1,390
<p>I am desperately looking for some way (any way) to set default "screen options" and metabox order through the functions.php file. does anyone have any help they can provide here?</p>
[ { "answer_id": 1402, "author": "sorich87", "author_id": 473, "author_profile": "https://wordpress.stackexchange.com/users/473", "pm_score": 6, "selected": true, "text": "<h2>Setting the order of meta boxes on post edit pages</h2>\n\n<p>You will need to remove the meta boxes, and add them...
2010/09/05
[ "https://wordpress.stackexchange.com/questions/1390", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/479/" ]
I am desperately looking for some way (any way) to set default "screen options" and metabox order through the functions.php file. does anyone have any help they can provide here?
Setting the order of meta boxes on post edit pages -------------------------------------------------- You will need to remove the meta boxes, and add them again in the order you want. To disable meta boxes: (customize to your needs, look at the metabox id in the html code to know which name you should use as first pa...
1,392
<p>I have seen code in an answer to this <a href="https://wordpress.stackexchange.com/questions/1059?tab=newest#tab-top">question</a>, how to remove the promotional back link to WordPress.org in my theme. I have added this to my theme's CSS but there is no change.</p> <p>Am I missing see some thing? Apologies for my ...
[ { "answer_id": 1394, "author": "Chris_O", "author_id": 251, "author_profile": "https://wordpress.stackexchange.com/users/251", "pm_score": 1, "selected": false, "text": "<p>\"site-generator\" is the div id assigned to the Powered by WordPress link in Twentyten, the default theme. Many o...
2010/09/06
[ "https://wordpress.stackexchange.com/questions/1392", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/391/" ]
I have seen code in an answer to this [question](https://wordpress.stackexchange.com/questions/1059?tab=newest#tab-top), how to remove the promotional back link to WordPress.org in my theme. I have added this to my theme's CSS but there is no change. Am I missing see some thing? Apologies for my Ignorance . Code I ha...
Here is the code I always use whenever I setup a new wordpress blog: CUSTOM ADMIN FOOTER TEXT ``` // CUSTOMIZE ADMIN FOOTER TEXT function custom_admin_footer() { echo '<a href="http://www.netconstructor.com/">Website Design by NetConstructor, Inc.</a>'; } add_filter('admin_footer_text', 'custom_admin_foo...
1,395
<p>I am looking to achieve something which I figured would be fairly simple to accomplish but it seems there are no real examples available to achieve my needs.</p> <p>Essentially I have a custom post type of "Articles" for this custom post type I have a new taxonomy which I have registered which was created so that s...
[ { "answer_id": 1405, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p>Your trying to modify the taxonomy by adding something that isn't a taxonomy, which will only confuse.</p>\n\n...
2010/09/06
[ "https://wordpress.stackexchange.com/questions/1395", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/479/" ]
I am looking to achieve something which I figured would be fairly simple to accomplish but it seems there are no real examples available to achieve my needs. Essentially I have a custom post type of "Articles" for this custom post type I have a new taxonomy which I have registered which was created so that source publ...
Hi **@NetConstructor.com**: I wrote this last month for somebody and it may address what you are looking for. It is an example you would modify, not a complete ready-to-use solution: ``` <?php /* * Example code showing how to hook WordPress to add fields to the taxonomny term edit screen. * * This example is mean...
1,396
<p>I have a feeling this is a bug.</p> <p>When you create a new custom post type it does not seem possible to modify the first submenu item text. I am referring to the link which allows you to view the post list.</p> <p>For what I can tell it just seems to be duplicating the name name of the main post type menu which...
[ { "answer_id": 1405, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p>Your trying to modify the taxonomy by adding something that isn't a taxonomy, which will only confuse.</p>\n\n...
2010/09/06
[ "https://wordpress.stackexchange.com/questions/1396", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/479/" ]
I have a feeling this is a bug. When you create a new custom post type it does not seem possible to modify the first submenu item text. I am referring to the link which allows you to view the post list. For what I can tell it just seems to be duplicating the name name of the main post type menu which was created. Do...
Hi **@NetConstructor.com**: I wrote this last month for somebody and it may address what you are looking for. It is an example you would modify, not a complete ready-to-use solution: ``` <?php /* * Example code showing how to hook WordPress to add fields to the taxonomny term edit screen. * * This example is mean...
1,400
<p>I just added <a href="http://wordpress.org/extend/plugins/contact-form-7/" rel="nofollow">Contact Form 7</a> to <a href="http://widerdesign.com.tw/contact" rel="nofollow">my site</a>. I'm using the default configuration (didn't change any setting). The mails are classified as spam in my Gmail inbox. Is there any way...
[ { "answer_id": 1432, "author": "sorich87", "author_id": 473, "author_profile": "https://wordpress.stackexchange.com/users/473", "pm_score": 1, "selected": false, "text": "<p>This maybe a problem with your server. If several sites are hosted on your server (shared hosting) and some of the...
2010/09/06
[ "https://wordpress.stackexchange.com/questions/1400", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/781/" ]
I just added [Contact Form 7](http://wordpress.org/extend/plugins/contact-form-7/) to [my site](http://widerdesign.com.tw/contact). I'm using the default configuration (didn't change any setting). The mails are classified as spam in my Gmail inbox. Is there any way of making them go directly to the inbox?
**@janoChen,** The problem could be that your email server is not using Domain Keys or a valid spf record > > **DomainKeys** is an e-mail authentication system that allows for incoming mail to be checked against the server it was sent from to verify that the mail has not been modified. This ensures that messages are ...
1,403
<p>The more customization I make to WordPress the more I start thinking about if I should be organizing this file or splitting it up.</p> <p>More specifically, if I have a bunch of custom functions which only apply to the admin area and others which just apply to my public website is there any reason to possibly inclu...
[ { "answer_id": 1406, "author": "MikeSchinkel", "author_id": 89, "author_profile": "https://wordpress.stackexchange.com/users/89", "pm_score": 8, "selected": true, "text": "<p>If you are getting to the point where the code in your theme's <code>functions.php</code> is starting to overwhel...
2010/09/06
[ "https://wordpress.stackexchange.com/questions/1403", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/479/" ]
The more customization I make to WordPress the more I start thinking about if I should be organizing this file or splitting it up. More specifically, if I have a bunch of custom functions which only apply to the admin area and others which just apply to my public website is there any reason to possibly include all adm...
If you are getting to the point where the code in your theme's `functions.php` is starting to overwhelm you I would definitely say you are ready to consider splitting it up into multiple files. I tend to do that almost by second nature at this point. ### Use Include Files in your Theme's `functions.php` File I creat...
1,413
<p>What is the recommended way of creating a page with a table, in the style of the tables showing posts or users in the admin area?</p> <p>I am expanding <a href="http://wordpress.org/extend/plugins/cache-images/" rel="noreferrer">the Cache Images plugin</a>, and it contains a table with domains and a number of image...
[ { "answer_id": 1425, "author": "sorich87", "author_id": 473, "author_profile": "https://wordpress.stackexchange.com/users/473", "pm_score": 6, "selected": true, "text": "<p>This is what I generally use:</p>\n\n<pre><code>&lt;table class=\"widefat fixed\" cellspacing=\"0\"&gt;\n &lt;th...
2010/09/06
[ "https://wordpress.stackexchange.com/questions/1413", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8/" ]
What is the recommended way of creating a page with a table, in the style of the tables showing posts or users in the admin area? I am expanding [the Cache Images plugin](http://wordpress.org/extend/plugins/cache-images/), and it contains a table with domains and a number of images from that domain. So there is no equ...
This is what I generally use: ``` <table class="widefat fixed" cellspacing="0"> <thead> <tr> <th id="cb" class="manage-column column-cb check-column" scope="col"></th> // this column contains checkboxes <th id="columnname" class="manage-column column-columnname" scope="col"></th> ...
1,414
<p>Assume I created a new post type <code>'product'</code>. Is there a way to perform a function (user created) when this new <code>'product'</code> post has been created?</p>
[ { "answer_id": 1415, "author": "Jan Fabry", "author_id": 8, "author_profile": "https://wordpress.stackexchange.com/users/8", "pm_score": 2, "selected": false, "text": "<p>The <a href=\"http://core.trac.wordpress.org/browser/branches/3.0/wp-includes/post.php#L2714\" rel=\"nofollow\"><code...
2010/09/06
[ "https://wordpress.stackexchange.com/questions/1414", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/376/" ]
Assume I created a new post type `'product'`. Is there a way to perform a function (user created) when this new `'product'` post has been created?
In functions.php: ``` function mynewproduct(){ myfunction(); } add_action( 'new_product', 'mynewproduct' ); ``` For more and the official documentation, refer here: <http://codex.wordpress.org/Post_Status_Transitions>
1,416
<p>Have developed a site on the production box using a temporary address (<a href="http://IP-adddress" rel="nofollow noreferrer">http://IP-adddress</a>).</p> <p>Now it's time to go live. Once, ages ago, I successfully used phpMyAdmin and did a search/replace, but am wondering if it's still <em>"the best"</em> way to g...
[ { "answer_id": 1423, "author": "sorich87", "author_id": 473, "author_profile": "https://wordpress.stackexchange.com/users/473", "pm_score": 2, "selected": true, "text": "<p>Yes, these queries still work.</p>\n\n<p>This is a complete how-to: <a href=\"http://web-kreation.com/tutorials/mig...
2010/09/06
[ "https://wordpress.stackexchange.com/questions/1416", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/319/" ]
Have developed a site on the production box using a temporary address (<http://IP-adddress>). Now it's time to go live. Once, ages ago, I successfully used phpMyAdmin and did a search/replace, but am wondering if it's still *"the best"* way to go. Will these work okay, still? The site is in WordPress 3.0.1. ``` upda...
Yes, these queries still work. This is a complete how-to: <http://web-kreation.com/tutorials/migrating-a-wordpress-site-ftp-phpmyadmin-and-sql-queries/>
1,445
<p>I recently released a plugin, <a href="http://wordpress.org/extend/plugins/wp-coda-slider/">WP Coda Slider</a>, that uses shortcodes to add a jQuery slider to any post or page. I am adding an options page in the next version and I would like to include some CSS options but I don't want the plugin to add the style c...
[ { "answer_id": 1454, "author": "sorich87", "author_id": 473, "author_profile": "https://wordpress.stackexchange.com/users/473", "pm_score": 2, "selected": false, "text": "<p>This is how I usually do it:</p>\n\n<pre><code>function build_stylesheet_url() {\n echo '&lt;link rel=\"stylesh...
2010/09/07
[ "https://wordpress.stackexchange.com/questions/1445", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/251/" ]
I recently released a plugin, [WP Coda Slider](http://wordpress.org/extend/plugins/wp-coda-slider/), that uses shortcodes to add a jQuery slider to any post or page. I am adding an options page in the next version and I would like to include some CSS options but I don't want the plugin to add the style choices as inlin...
Use [`wp_register_style`](http://codex.wordpress.org/Function_Reference/wp_register_style) and [`wp_enqueue_style`](http://codex.wordpress.org/Function_Reference/wp_enqueue_style) to add the stylesheet. DO NOT simply add a stylesheet link to `wp_head`. Queuing styles allows other plugins or themes to modify the stylesh...
1,457
<p>Hay, I've installed WordPress 3 on my server, and duplicated the stock theme and made some amends to it. However, when i add a post, i don't see an option to add a 'featured image'. Has this featured been removed? How do i reactivate it?</p> <p>Thanks</p>
[ { "answer_id": 1460, "author": "MikeK", "author_id": 319, "author_profile": "https://wordpress.stackexchange.com/users/319", "pm_score": 0, "selected": false, "text": "<p>It's in 3. When you have a post or a page open, in a two-column view, it's on the right, down a bit.</p>\n\n<p>If it'...
2010/09/07
[ "https://wordpress.stackexchange.com/questions/1457", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/376/" ]
Hay, I've installed WordPress 3 on my server, and duplicated the stock theme and made some amends to it. However, when i add a post, i don't see an option to add a 'featured image'. Has this featured been removed? How do i reactivate it? Thanks
Your theme must [indicate that it supports post thumbnails](http://codex.wordpress.org/Post_Thumbnails): ``` if ( function_exists('add_theme_support') ) { add_theme_support('post-thumbnails'); // If not the standard size, state your size too set_post_thumbnail_size( 200, 200, false ); } ```
1,479
<p>I know that it is possible to restrict (or extend) the memory usage of the entire WP site using:</p> <pre><code>define('WP_MEMORY_LIMIT', '64M') </code></pre> <p>Is it possible to do the same for only one plugin that the website uses ?</p>
[ { "answer_id": 1492, "author": "hakre", "author_id": 178, "author_profile": "https://wordpress.stackexchange.com/users/178", "pm_score": 1, "selected": false, "text": "<p>Generally spoken, no, it is not possible for a particular plugin only. The plugin runs in the whole wordpress PHP pro...
2010/09/07
[ "https://wordpress.stackexchange.com/questions/1479", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/161/" ]
I know that it is possible to restrict (or extend) the memory usage of the entire WP site using: ``` define('WP_MEMORY_LIMIT', '64M') ``` Is it possible to do the same for only one plugin that the website uses ?
No and even if you could, if the plugin ran out of available memory then the entire page generation would stop due to the fatal error. You're better off fixing the plugin itself to not use as much memory or to just further increase the total memory allocated to WordPress/PHP.
1,482
<p>I want users to be able to upload photos using <code>add_cap('upload_files')</code> but in their profile page, the Media Library shows every image that's been uploaded. How can I filter that so that they can only view the images <em>they</em> uploaded?</p> <p>Here's my solution for the moment… I'm doing a simple W...
[ { "answer_id": 1621, "author": "TerryMatula", "author_id": 607, "author_profile": "https://wordpress.stackexchange.com/users/607", "pm_score": 1, "selected": false, "text": "<p>I solved my problem with a pretty rough, but workable solution.</p>\n\n<p>1) I installed the WP Hide Dashboard ...
2010/09/07
[ "https://wordpress.stackexchange.com/questions/1482", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/607/" ]
I want users to be able to upload photos using `add_cap('upload_files')` but in their profile page, the Media Library shows every image that's been uploaded. How can I filter that so that they can only view the images *they* uploaded? Here's my solution for the moment… I'm doing a simple WP query, then a loop on the u...
You could always filter the media list using a `pre_get_posts` filter that first determines the page, and the capabilities of the user, and sets the author parameter when certain conditions are met.. Example ======= ``` add_action('pre_get_posts','users_own_attachments'); function users_own_attachments( $wp_query_obj...
1,484
<p>In a previous question I needed to set a future dated post (custom post type) as published on save instead of scheduling it.</p> <p>On the date it's 'scheduled' for I'd like to set it as a draft again. I've been trying to hook into init and wrap it in an if checking for post type. I figured it would compare to serv...
[ { "answer_id": 1491, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 2, "selected": true, "text": "<p>Your query isn't giving you a post ID, it's giving you an entire post. The <code>SELECT *</code> returns all columns, ...
2010/09/07
[ "https://wordpress.stackexchange.com/questions/1484", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/141/" ]
In a previous question I needed to set a future dated post (custom post type) as published on save instead of scheduling it. On the date it's 'scheduled' for I'd like to set it as a draft again. I've been trying to hook into init and wrap it in an if checking for post type. I figured it would compare to server time an...
Your query isn't giving you a post ID, it's giving you an entire post. The `SELECT *` returns all columns, `ID`, `post_status`, etc. So setting `$my_post['ID'] = $a` doesn't do anything for you in this case. Try using: `$my_post['id'] = $a->ID;` instead. That should accurately set your ID before you call `wp_update_po...
1,507
<p>I have a website for which we are trying to be discreet about the fact that we are using WordPress. What steps can we take to make it less obvious?</p> <h1><strong>EDIT- Important security note:</strong></h1> <p>Please understand that doing this perfectly is impossible as per Mark's <a href="https://wordpress.stacke...
[ { "answer_id": 1509, "author": "Chris_O", "author_id": 251, "author_profile": "https://wordpress.stackexchange.com/users/251", "pm_score": 8, "selected": true, "text": "<p>The biggest WordPress giveaways are between the <code>&lt;head&gt; &lt;/head&gt;</code> tags. </p>\n\n<p><strong>Ex...
2010/09/08
[ "https://wordpress.stackexchange.com/questions/1507", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/313/" ]
I have a website for which we are trying to be discreet about the fact that we are using WordPress. What steps can we take to make it less obvious? **EDIT- Important security note:** ================================== Please understand that doing this perfectly is impossible as per Mark's [answer](https://wordpress.s...
The biggest WordPress giveaways are between the `<head> </head>` tags. **Example WordPress head content output by The Twentyten Theme and how to remove:** ``` <link rel="profile" href="http://gmpg.org/xfn/11" /> ``` Remove directly from header.php ``` <link rel="stylesheet" type="text/css" media="all" href="htt...
1,516
<blockquote> <p><strong>Possible Duplicate:</strong><br> <a href="https://wordpress.stackexchange.com/questions/12201/wordpress-multisite-global-categories">WordPress Multisite - global categories</a> </p> </blockquote> <p>I have a series of blogs that will use some, but not all, of the same posts. We have one ...
[ { "answer_id": 2159, "author": "Novaktually", "author_id": 1008, "author_profile": "https://wordpress.stackexchange.com/users/1008", "pm_score": 0, "selected": false, "text": "<p>This might be of help. According to the <a href=\"http://codex.wordpress.org/Function_Reference/register_taxo...
2010/09/08
[ "https://wordpress.stackexchange.com/questions/1516", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/591/" ]
> > **Possible Duplicate:** > > [WordPress Multisite - global categories](https://wordpress.stackexchange.com/questions/12201/wordpress-multisite-global-categories) > > > I have a series of blogs that will use some, but not all, of the same posts. We have one blog where many of the posts are written, and then ...
My recommendation would be to place the code that defines your custom taxonomies into a plug-in and activate the plug-in site wide. This will cause the new taxonomies to become active on *all* the sites in your network.
1,529
<p>I would like to be able to display a list of posts on a page depending on when and how many comments they've got. Something similar to how it is here on stackexchange.</p> <p>To be more specific, I want:</p> <ul> <li>A page with the most commented posts.</li> <li>A page with the most recently commented posts. <...
[ { "answer_id": 1539, "author": "danhgilmore", "author_id": 819, "author_profile": "https://wordpress.stackexchange.com/users/819", "pm_score": 0, "selected": false, "text": "<p>@Patrik - I had a similar problem: In a WPMu installation, show the latest posts in post-order on the main blog...
2010/09/08
[ "https://wordpress.stackexchange.com/questions/1529", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/696/" ]
I would like to be able to display a list of posts on a page depending on when and how many comments they've got. Something similar to how it is here on stackexchange. To be more specific, I want: * A page with the most commented posts. * A page with the most recently commented posts. * A page with all the uncommente...
``` query_posts( array('orderby' => 'comment_count', 'order'=>'DESC') ) ``` This should do it.
1,542
<p>I'm seeking to customize my categories listing (archive.php) so that it shows a thumbnail image of the first image attached to each post</p> <p>However, apparently the archive.php file is one of those that does not natively support the attachment object. For example, the code below will do most of what I want (thou...
[ { "answer_id": 1590, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 0, "selected": false, "text": "<p>WP has core function to view this, see my post <a href=\"http://wpengineer.com/1735/easier-better-solutions-to-get-...
2010/09/08
[ "https://wordpress.stackexchange.com/questions/1542", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/366/" ]
I'm seeking to customize my categories listing (archive.php) so that it shows a thumbnail image of the first image attached to each post However, apparently the archive.php file is one of those that does not natively support the attachment object. For example, the code below will do most of what I want (though if no a...
You could use the WordPress function get\_children. Although I don't think it makes a difference, performance-wise. ``` <?php while (have_posts()) : the_post(); ?> <?php $attachment = array_values( get_children( array( 'post_parent' => $post->ID, 'post_type' => 'attachment', 'post_mime_type' => 'image', 'order' =>...
1,560
<p>As part of my efforts to speed up my themes for my clients I am delivering my CSS via a dynamic PHP file. At the end of the called for example <code>my_theme_css.php</code>:</p> <p>This allows me to add Expiry headers to my CSS and JavaScript like so:</p> <pre><code>&lt;?php header("Expires: Thu, 31 Dec 2020 20:00...
[ { "answer_id": 1561, "author": "dgw", "author_id": 166, "author_profile": "https://wordpress.stackexchange.com/users/166", "pm_score": 0, "selected": false, "text": "<p>Try coding it like:</p>\n\n<pre><code>&lt;?php $my_custom_css = get_theme_mod('my_custom_css');\n if(!empty($my_custom...
2010/09/09
[ "https://wordpress.stackexchange.com/questions/1560", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120/" ]
As part of my efforts to speed up my themes for my clients I am delivering my CSS via a dynamic PHP file. At the end of the called for example `my_theme_css.php`: This allows me to add Expiry headers to my CSS and JavaScript like so: ``` <?php header("Expires: Thu, 31 Dec 2020 20:00:00 GMT"); header('Content-type: te...
Hi **@Ash G:** **I didn't follow 100%** where you were specifically having problems so I'm not sure I really can answer your issues point-by-point **but I can explain how to do this from ground up**. And unless what you are doing is a good bit more involved then you mentioned it's a little bit more work than I think y...
1,563
<p>I'm using add_settings_field to add some more details to a settings menu, but not sure how I save the settings, or call them back in my theme.</p> <p>Here is the code thus far</p> <pre><code>add_action('admin_init','vimeo_setup'); function vimeo_setup(){ add_settings_field('vimeo_id','Vimeo ID','display_vimeo','g...
[ { "answer_id": 1696, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": true, "text": "<p>Documentation for <a href=\"http://codex.wordpress.org/Function_Reference/add_settings_field\" rel=\"nofollow\">add_se...
2010/09/09
[ "https://wordpress.stackexchange.com/questions/1563", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/784/" ]
I'm using add\_settings\_field to add some more details to a settings menu, but not sure how I save the settings, or call them back in my theme. Here is the code thus far ``` add_action('admin_init','vimeo_setup'); function vimeo_setup(){ add_settings_field('vimeo_id','Vimeo ID','display_vimeo','general'); } functi...
Documentation for [add\_settings\_field()](http://codex.wordpress.org/Function_Reference/add_settings_field) Says following: > > **You MUST register any options** used by this function with [register\_setting()](http://codex.wordpress.org/Function_Reference/register_setting) or they won't be saved and updated automat...
1,567
<p>As with many others who are now viewing this post, I have been reading various blogs, forums, and discussion groups to learn and improve my WordPress skills. Over the past 12 months I have been on a mission to substitute my use of plugins by adding code to my <code>functions.php</code> file instead.</p> <p>While I ...
[ { "answer_id": 1568, "author": "NetConstructor.com", "author_id": 479, "author_profile": "https://wordpress.stackexchange.com/users/479", "pm_score": 5, "selected": false, "text": "<h2>Customize the order of the administration menu</h2>\n<p><em><strong>Tested on:</strong> WordPress 3.0.1...
2010/09/09
[ "https://wordpress.stackexchange.com/questions/1567", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/479/" ]
As with many others who are now viewing this post, I have been reading various blogs, forums, and discussion groups to learn and improve my WordPress skills. Over the past 12 months I have been on a mission to substitute my use of plugins by adding code to my `functions.php` file instead. While I completely agree that...
Enable Hidden Administration Feature displaying *All* Site Settings ------------------------------------------------------------------- ***Tested on:*** *WordPress 3.1 RC3* This little piece of code does something pretty cool. It will add an additional option to your settings menu with a link to "all settings" which ...
1,575
<p>I've got a CMS-style wordpress setup where the homepage is not the main blog posts page. </p> <p>However, I would like to display the first paragraph of the latest blog post on the homepage, with a link to the post. How would I do that? </p> <p>I'd also like to display, above this excerpt, the first image within ...
[ { "answer_id": 1582, "author": "Chris_O", "author_id": 251, "author_profile": "https://wordpress.stackexchange.com/users/251", "pm_score": 3, "selected": true, "text": "<p>To show the excerpt from the latest post you can use query_posts.</p>\n\n<p><strong>Example Query Posts Showing the ...
2010/09/09
[ "https://wordpress.stackexchange.com/questions/1575", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/394/" ]
I've got a CMS-style wordpress setup where the homepage is not the main blog posts page. However, I would like to display the first paragraph of the latest blog post on the homepage, with a link to the post. How would I do that? I'd also like to display, above this excerpt, the first image within the post, but I'm ...
To show the excerpt from the latest post you can use query\_posts. **Example Query Posts Showing the Latest Post with the Featured Image:** ``` <?php query_posts('showposts=1'); ?> <?php while (have_posts()) : the_post(); ?> <h3 class="home link"><a href="<?php the_permalink(); ?>"><?php the_title(); ?></a></h3...
1,577
<p>I would like to keep my main theme as the active theme, but allow users to select a slightly different layout via the <em>"Page/Post Attributes"</em> panel. Ideally, I'd like to store this layout under my main theme's <em>"styles"</em> directory, in its own folder.</p> <blockquote> <p>MyTheme > styles > My-specia...
[ { "answer_id": 1581, "author": "John P Bloch", "author_id": 11, "author_profile": "https://wordpress.stackexchange.com/users/11", "pm_score": 3, "selected": true, "text": "<p>You're not doing child themes right. A child theme is a separate theme altogether that everyone must use, but rel...
2010/09/09
[ "https://wordpress.stackexchange.com/questions/1577", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/366/" ]
I would like to keep my main theme as the active theme, but allow users to select a slightly different layout via the *"Page/Post Attributes"* panel. Ideally, I'd like to store this layout under my main theme's *"styles"* directory, in its own folder. > > MyTheme > styles > My-special-Layout > style.css > > > So ...
You're not doing child themes right. A child theme is a separate theme altogether that everyone must use, but relies on another theme for all template parts it doesn't provide. What you want is templates: <http://codex.wordpress.org/Theme_Development#Defining_Custom_Templates> Basically, just create a new theme file ...
1,580
<p>I don't want to edit core files in order to change the page where a user enters new posts, so is there a way to do it within a theme, perhaps within functions.php ..?</p> <p>Specifically, I'm trying to change the wording of the 'Set featured image' text to something like 'Set featured image - 50 pixels by 50 pixe...
[ { "answer_id": 1584, "author": "sorich87", "author_id": 473, "author_profile": "https://wordpress.stackexchange.com/users/473", "pm_score": 5, "selected": true, "text": "<p>You can use the filter <code>admin_post_thumbnail_html</code>:</p>\n\n<pre><code>function custom_admin_post_thumbna...
2010/09/09
[ "https://wordpress.stackexchange.com/questions/1580", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/394/" ]
I don't want to edit core files in order to change the page where a user enters new posts, so is there a way to do it within a theme, perhaps within functions.php ..? Specifically, I'm trying to change the wording of the 'Set featured image' text to something like 'Set featured image - 50 pixels by 50 pixels'
You can use the filter `admin_post_thumbnail_html`: ``` function custom_admin_post_thumbnail_html( $content ) { return $content = str_replace( __( 'Set featured image' ), __( 'Set featured image - 50 pixels by 50 pixels' ), $content ); } add_filter( 'admin_post_thumbnail_html', 'custom_admin_post_thumbnail_html' ...
1,595
<p>I know how to upload multiple images into an existing post, but this is a different scenario. This is for a large catalog of assets, with each custom post-type post representing an image asset (thus a single image is assigned as the "featured image" for each post).</p> <p>The whole system works great for one-at-a-t...
[ { "answer_id": 1813, "author": "hakre", "author_id": 178, "author_profile": "https://wordpress.stackexchange.com/users/178", "pm_score": 1, "selected": false, "text": "<p>The <a href=\"https://wordpress.stackexchange.com/questions/322/cleanup-uploads-folder-media-library-db-structure\">\...
2010/09/09
[ "https://wordpress.stackexchange.com/questions/1595", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/838/" ]
I know how to upload multiple images into an existing post, but this is a different scenario. This is for a large catalog of assets, with each custom post-type post representing an image asset (thus a single image is assigned as the "featured image" for each post). The whole system works great for one-at-a-time asset ...
This script is a proof of concept (tested and working), it is not a plugin and is meant to be hacked with, it assumes a few things: 1. It uses `wp_insert_post` so it's advised you do not hook it into any admin hooks, so just run it once! 2. The images must be in the `wp-content\uploads` folder, changing this would req...
1,596
<p>Does anyone happen to know how I can automatically turn:</p> <p><code>http://www.example.com/wp-content/themes/theme-name/css/stylesheeet.css</code></p> <p>into</p> <p><code>http://www.example.com/css/stylesheet.css</code></p> <p>Naturally I could just create the applicable folder within the root of the website,...
[ { "answer_id": 1813, "author": "hakre", "author_id": 178, "author_profile": "https://wordpress.stackexchange.com/users/178", "pm_score": 1, "selected": false, "text": "<p>The <a href=\"https://wordpress.stackexchange.com/questions/322/cleanup-uploads-folder-media-library-db-structure\">\...
2010/09/09
[ "https://wordpress.stackexchange.com/questions/1596", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/479/" ]
Does anyone happen to know how I can automatically turn: `http://www.example.com/wp-content/themes/theme-name/css/stylesheeet.css` into `http://www.example.com/css/stylesheet.css` Naturally I could just create the applicable folder within the root of the website, place the files there and just reference them but th...
This script is a proof of concept (tested and working), it is not a plugin and is meant to be hacked with, it assumes a few things: 1. It uses `wp_insert_post` so it's advised you do not hook it into any admin hooks, so just run it once! 2. The images must be in the `wp-content\uploads` folder, changing this would req...
1,597
<p>I am having a strange issue with the built in wordpress image editor. I have no problem uploading files or preforming any other media functions. The only thing I seem to be unable to do is utilize the image "edit" capabilities (the area where you can crop, resize, rotate...)</p> <p>When I click on "edit" for an ima...
[ { "answer_id": 1819, "author": "NetConstructor.com", "author_id": 479, "author_profile": "https://wordpress.stackexchange.com/users/479", "pm_score": 5, "selected": true, "text": "<p>I have actually managed to resolve my own problem. For anyone else that might ever read this the problem ...
2010/09/09
[ "https://wordpress.stackexchange.com/questions/1597", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/479/" ]
I am having a strange issue with the built in wordpress image editor. I have no problem uploading files or preforming any other media functions. The only thing I seem to be unable to do is utilize the image "edit" capabilities (the area where you can crop, resize, rotate...) When I click on "edit" for an image I see t...
I have actually managed to resolve my own problem. For anyone else that might ever read this the problem which caused this was that my `functions.php` file had a closing ``` ?> ``` at the very end. For whatever reason this is what cause the issue and by removing this last line it was working again.
1,604
<p>I want to connect <code>wpdb</code> to another database. How do I create the instance and pass it the database name/username/password?</p> <p>Thanks</p>
[ { "answer_id": 1618, "author": "Wadih M.", "author_id": 442, "author_profile": "https://wordpress.stackexchange.com/users/442", "pm_score": 8, "selected": true, "text": "<p>Yes it's possible.</p>\n<p>The wpdb object can be used to access any database and query any table. Absolutely no ne...
2010/09/10
[ "https://wordpress.stackexchange.com/questions/1604", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/442/" ]
I want to connect `wpdb` to another database. How do I create the instance and pass it the database name/username/password? Thanks
Yes it's possible. The wpdb object can be used to access any database and query any table. Absolutely no need to be Wordpress related, which is very interesting. The benefit is the ability to use all the wpdb classes and functions like `get_results`, etc so that there's no need to re-invent the wheel. Here's how: `...
1,620
<p>On my CMS-style setup, I have the standard search box which searches everything.</p> <p>However, on my blog page, I would like to also have another search box which searches just the blog... is this possible, and how would I go about it?</p> <p><strong>EDIT</strong></p> <p>I used this code within a text widget wh...
[ { "answer_id": 1622, "author": "Mild Fuzz", "author_id": 784, "author_profile": "https://wordpress.stackexchange.com/users/784", "pm_score": 0, "selected": false, "text": "<p>I am a little confused. Do you mean that you want the end user to be able to use the image picker from the back e...
2010/09/10
[ "https://wordpress.stackexchange.com/questions/1620", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/394/" ]
On my CMS-style setup, I have the standard search box which searches everything. However, on my blog page, I would like to also have another search box which searches just the blog... is this possible, and how would I go about it? **EDIT** I used this code within a text widget which goes on my blog page: ``` <form ...
The [Image Widget](http://wordpress.org/extend/plugins/image-widget/) plugin uses the media uploader. You may want to look at its code source. It is very simple.
1,635
<p>I've been trying to set up a way to write posts in a series on my site. The idea is that each post can belong to a different series in a custom taxonomy. I've gotten just about everything set up the way I want it ... with one exception.</p> <h3>Registering the Taxonomy</h3> <p>This part is working. I've dropped t...
[ { "answer_id": 1637, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>Here is code I use to modify number of posts on archive pages of categories and tags:</p>\n\n<pre><code>query_posts( ...
2010/09/11
[ "https://wordpress.stackexchange.com/questions/1635", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/46/" ]
I've been trying to set up a way to write posts in a series on my site. The idea is that each post can belong to a different series in a custom taxonomy. I've gotten just about everything set up the way I want it ... with one exception. ### Registering the Taxonomy This part is working. I've dropped the following cod...
Hi **@EAMann**: I cringe anytime I need to do something creative with URLs in WordPress as the URL system is in my opinion by far the most inelegant aspect of WordPress. I always feel like I'm having to fight WordPress to get it to do what I want, and that WordPress is actively fighting me back related to URLs. So wi...
1,644
<p>i dont really understand why the check if the nonce function exists before running it ...</p> <pre><code>if ( function_exists('wp_nonce_field') ) wp_nonce_field('gmp_nonce_check'); </code></pre> <p>i understand its for backwards compatibility ...</p> <blockquote> <p>Also notice how you are verifying that ...
[ { "answer_id": 1645, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>If I understand your question right - you ask why there is no need to check if check_admin_referer() defined as well?...
2010/09/11
[ "https://wordpress.stackexchange.com/questions/1644", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/794/" ]
i dont really understand why the check if the nonce function exists before running it ... ``` if ( function_exists('wp_nonce_field') ) wp_nonce_field('gmp_nonce_check'); ``` i understand its for backwards compatibility ... > > Also notice how you are verifying that > the `wp_nonce_field` function exists > ...
The answer is that you should not check if wp\_nonce\_field() exists before using it! The recommendation to perform the check assumes that you want to be compatible with versions of WordPress from before the function existed. If Rarst is right that it was introduced in 2.0.4 then you should NOT be supporting earlier v...
1,649
<p>I'm reading a book about WordPress and I'm new and confused.</p> <p>Why does the author always not save data in the metadata box when its a revision. just in case its not clear, what i refer to by metadata box is the one added by <code>add_meta_box</code>.</p> <pre><code>//save meta box data function pp_save_meta_b...
[ { "answer_id": 1650, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 4, "selected": true, "text": "<p>You omitted how is this function called. I assume it is added to <code>save_post</code> action.</p>\n\n<p>This action ...
2010/09/11
[ "https://wordpress.stackexchange.com/questions/1649", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/794/" ]
I'm reading a book about WordPress and I'm new and confused. Why does the author always not save data in the metadata box when its a revision. just in case its not clear, what i refer to by metadata box is the one added by `add_meta_box`. ``` //save meta box data function pp_save_meta_box($post_id,$post) { // if...
You omitted how is this function called. I assume it is added to `save_post` action. This action passes current post id as argument. In case of revision that would be revision id and not parent post id. ~~So, as I see it, there is no reason to save additional data for revision (creating duplicate set of it).~~ **Upda...
1,653
<p>I'm trying to tune a wordpress website which suffers slow loading times, and I found out that the home page seems to take a lot more time to load. It's not due to content because I'm just considering the time it takes for the base request to end (viewable via firebug in firefox).</p> <p>Also I tried copying the ind...
[ { "answer_id": 1654, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": false, "text": "<p>By default there isn't any difference for performance of home page. There is however a possibility that some plugin d...
2010/09/11
[ "https://wordpress.stackexchange.com/questions/1653", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/745/" ]
I'm trying to tune a wordpress website which suffers slow loading times, and I found out that the home page seems to take a lot more time to load. It's not due to content because I'm just considering the time it takes for the base request to end (viewable via firebug in firefox). Also I tried copying the index.php cod...
After almost 4 years I got back on this and finally found the problem. Turns out the site had a lot of articles ALL marked as sticky. Due to the unbelievably dumb way wordpress uses to mark sticky posts (a serialized array in wp\_options), the main loop of the dynamic home page took an incredibly long time. Clearing th...
1,656
<p>I want to display posts links from a category group by year. Group by year becouse by default wordpress repeat the date for each post. I try use a code but I got all post in current year. How can I do it? Example I want to do:</p> <p>2010</p> <ul> <li>post link 20 </li> <li>post link 19 </li> <li>post link 1...
[ { "answer_id": 1657, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>Your code got very broken when posted. From what I can see multiple <code>query_posts()</code> are bad idea in most c...
2010/09/11
[ "https://wordpress.stackexchange.com/questions/1656", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I want to display posts links from a category group by year. Group by year becouse by default wordpress repeat the date for each post. I try use a code but I got all post in current year. How can I do it? Example I want to do: 2010 * post link 20 * post link 19 * post link 18 * ... * post link 8 2009 * post link 7 ...
I wrote [that original code on Stack Overflow](https://stackoverflow.com/questions/3397725/wordpress-how-can-i-display-post-link-group-by-year/3477409#3477409), but I didn't see your further replies because you posted them as answers and not as comments to my answer. I have tested the code now with a specific category ...
1,659
<p>I use thickbox in the WP backend for preview or other content. On own pages in the backend works my script very fine and a can use custom width and height for the thickbox. below my code:</p> <pre><code> &lt;script type="text/javascript"&gt; &lt;!-- var viewportwidth; ...
[ { "answer_id": 1662, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": true, "text": "<p><code>plugins.php</code> page calls <code>add_thickbox()</code> function that enqueues WP native thickbox script and s...
2010/09/11
[ "https://wordpress.stackexchange.com/questions/1659", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/170/" ]
I use thickbox in the WP backend for preview or other content. On own pages in the backend works my script very fine and a can use custom width and height for the thickbox. below my code: ``` <script type="text/javascript"> <!-- var viewportwidth; var viewporthei...
`plugins.php` page calls `add_thickbox()` function that enqueues WP native thickbox script and style. It has this in documentation: > > If any of the settings need to be changed, this can be done with another js > file similar to media-upload.js and theme-preview.js. That file should > require array('thickbox') to ...
1,665
<p>When writing WordPress plugins there is often a need to set up options for which roles on the site have access to certain functionality or content. To do this a plugin dev needs to fetch the list of roles that exist on the site to use in the option. Because custom roles can be created we cannot assume the default ro...
[ { "answer_id": 1666, "author": "jerclarke", "author_id": 175, "author_profile": "https://wordpress.stackexchange.com/users/175", "pm_score": 7, "selected": true, "text": "<p>Roles are stored in the global variable <code>$wp_roles</code>.</p>\n\n<p><strong>The ideal function is <a href=\"...
2010/09/11
[ "https://wordpress.stackexchange.com/questions/1665", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/175/" ]
When writing WordPress plugins there is often a need to set up options for which roles on the site have access to certain functionality or content. To do this a plugin dev needs to fetch the list of roles that exist on the site to use in the option. Because custom roles can be created we cannot assume the default roles...
Roles are stored in the global variable `$wp_roles`. **The ideal function is [`get_editable_roles()`](https://codex.wordpress.org/Function_Reference/get_editable_roles)** from `/wp-admin/includes/user.php` ``` function get_editable_roles() { global $wp_roles; $all_roles = $wp_roles->roles; $editable_role...
1,705
<p>Something which I have never seen covered is the best way to validate that specific form fields are filled out correctly for custom post type meta boxes.</p> <p>I am looking to get expert opinions on how best to validate custom fields for any metaboxes that one might create. My interest are to:</p> <ul> <li>ensure...
[ { "answer_id": 2285, "author": "danblaker", "author_id": 750, "author_profile": "https://wordpress.stackexchange.com/users/750", "pm_score": 5, "selected": true, "text": "<p>The easiest way is to add Javascript validation via the <a href=\"http://docs.jquery.com/Plugins/Validation\">jQue...
2010/09/12
[ "https://wordpress.stackexchange.com/questions/1705", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/479/" ]
Something which I have never seen covered is the best way to validate that specific form fields are filled out correctly for custom post type meta boxes. I am looking to get expert opinions on how best to validate custom fields for any metaboxes that one might create. My interest are to: * ensure field validation tak...
The easiest way is to add Javascript validation via the [jQuery Validate plugin](http://docs.jquery.com/Plugins/Validation). Here's the most basic walkthrough: Near your add\_meta\_box call, enqueue the jQuery Validate plugin as well as a JS file for your simple script: ``` add_action('admin_enqueue_scripts', 'add_my...
1,714
<p>I am about to have to write <strong>a script to take a fresh install of WordPress 3.0.1 and add-in all the initial features for a website</strong>. This is for a company that installs lots of similar websites and they need a standard starting point in configuration and data.</p> <ul> <li><strong>I'm wondering if an...
[ { "answer_id": 1715, "author": "MikeSchinkel", "author_id": 89, "author_profile": "https://wordpress.stackexchange.com/users/89", "pm_score": 5, "selected": true, "text": "<p>As I mentioned <strong>I was going to be start working on this need immediately</strong> so I'm making headway. G...
2010/09/13
[ "https://wordpress.stackexchange.com/questions/1714", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/89/" ]
I am about to have to write **a script to take a fresh install of WordPress 3.0.1 and add-in all the initial features for a website**. This is for a company that installs lots of similar websites and they need a standard starting point in configuration and data. * **I'm wondering if anyone else has already done this a...
As I mentioned **I was going to be start working on this need immediately** so I'm making headway. Given that I'm knocking these down I figured it's best to start posting them. *Still, if someone else can/will post (some of) the parts I haven't done I'll be happy to let you copy whatever I'd done you haven't and select...
1,743
<p>i have </p> <pre><code>add_options_page('Post Products Settings', 'Post Products Settings', 'administrator', 'pp_settings', 'pp_settings_page'); </code></pre> <p>anyway i can get whats specified in the 1st parameter for use in my page header? i know i can hard code it tho, but just curious</p>
[ { "answer_id": 2733, "author": "John P Bloch", "author_id": 11, "author_profile": "https://wordpress.stackexchange.com/users/11", "pm_score": 3, "selected": true, "text": "<p>There are a few ways you can do this. My preferred way of doing this is using Object Oriented Programming (OOP) t...
2010/09/13
[ "https://wordpress.stackexchange.com/questions/1743", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/794/" ]
i have ``` add_options_page('Post Products Settings', 'Post Products Settings', 'administrator', 'pp_settings', 'pp_settings_page'); ``` anyway i can get whats specified in the 1st parameter for use in my page header? i know i can hard code it tho, but just curious
There are a few ways you can do this. My preferred way of doing this is using Object Oriented Programming (OOP) to structure the plugin. For example, I might do this: ``` class JPBTitle { var $page_title = "Post Products Settings"; function __construct(){ add_action( 'admin_menu', array( $this, 'admin_menu' )...
1,744
<p>is that possible, without javascript hacks? like this:</p> <pre><code>&lt;ul class="my_menu"&gt; &lt;li class="first"&gt; ... &lt;/li&gt; &lt;li&gt; ... &lt;/li&gt; &lt;li&gt; ... &lt;/li&gt; &lt;li class"with_sub"&gt; ... &lt;ul class="my_menu_sub"&gt; &lt;li class="first"&gt; ... &lt;/li&gt; ...
[ { "answer_id": 1750, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": false, "text": "<p>Here is rough snippet that takes care of modifying menu output and adding first/last to first and last class (outer <...
2010/09/13
[ "https://wordpress.stackexchange.com/questions/1744", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/600/" ]
is that possible, without javascript hacks? like this: ``` <ul class="my_menu"> <li class="first"> ... </li> <li> ... </li> <li> ... </li> <li class"with_sub"> ... <ul class="my_menu_sub"> <li class="first"> ... </li> <li> ... </li> <li> ... </li> <li class="last"> ... </li> </...
A better and simpler approach: ``` function add_first_and_last($items) { $items[1]->classes[] = 'first-menu-item'; $items[count($items)]->classes[] = 'last-menu-item'; return $items; } add_filter('wp_nav_menu_objects', 'add_first_and_last'); ```
1,759
<p>I have a fresh localhost install and when i change the permalink structure from the default to any other structure the links break. I have created new post under the new structure and it doesnt work. When i change the structure i get the "Permalink Structure updated" alert but it does not work. When i switch back...
[ { "answer_id": 1760, "author": "Mild Fuzz", "author_id": 784, "author_profile": "https://wordpress.stackexchange.com/users/784", "pm_score": 1, "selected": false, "text": "<p>First thing I always do is change the permalinks back and forth to different settings a couple of times, which wi...
2010/09/13
[ "https://wordpress.stackexchange.com/questions/1759", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I have a fresh localhost install and when i change the permalink structure from the default to any other structure the links break. I have created new post under the new structure and it doesnt work. When i change the structure i get the "Permalink Structure updated" alert but it does not work. When i switch back to de...
First thing I always do is change the permalinks back and forth to different settings a couple of times, which will cause them to flush and rewrite the rules. Beyond that. what stack are you using? Where have you put the .htaccess?
1,770
<p>I added a page to my site, and suddenly the home page seems to be redirecting to that page (that is, if you go to jesseliberty.com, which should bring you to the home page, you are redirected to jesseliberty.com/newPage (the page I created). </p> <p>To combat this, I've added a 301 redirect from jesseliberty.com/f...
[ { "answer_id": 1786, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>Your home page response is 301 redirect to <code>/categories/</code>, no ideas what is causing it for now (.htaccess?...
2010/09/13
[ "https://wordpress.stackexchange.com/questions/1770", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I added a page to my site, and suddenly the home page seems to be redirecting to that page (that is, if you go to jesseliberty.com, which should bring you to the home page, you are redirected to jesseliberty.com/newPage (the page I created). To combat this, I've added a 301 redirect from jesseliberty.com/foo to jesse...
I think I've had this problem before, but I can't remember exactly how I fixed it. Check a few things: 1. Did you recently or ever make a template/theme file called home.php? That can mess up wordpress because it thinks home means blog home not what you're thinking of as home. If you need a template for your home page...
1,779
<p>I have come across an interesting problem regarding the <code>get_template_part()</code> .</p> <p>I have created a theme options page (named sitewideSettings.php)</p> <p>normally I would include this in functions.php like so:</p> <pre><code>include(TEMPLATEPATH."sitewideSettings.php"); </code></pre> <p>which wor...
[ { "answer_id": 1791, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>Hard to make a guess, it's whole ladder of functions. <code>get_template_part()</code> calls <code>locate_template()<...
2010/09/14
[ "https://wordpress.stackexchange.com/questions/1779", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120/" ]
I have come across an interesting problem regarding the `get_template_part()` . I have created a theme options page (named sitewideSettings.php) normally I would include this in functions.php like so: ``` include(TEMPLATEPATH."sitewideSettings.php"); ``` which works fine. But now I am trying to use `get_template_...
I know you say it's not a nonce issue, but it clearly is. That notice is the default 'This nonce didn't check out' message. I don't know exactly why the nonce is failing, but that is what is happening. I would double check how your nonces are created and checked. If you're using `wp_nonce_field()` make sure both actio...
1,795
<p>I'm unable to load the plugin's locale file <em>(.mo)</em>. I did all the procedues described in the <a href="http://codex.wordpress.org/Writing_a_Plugin" rel="nofollow">http://codex.wordpress.org/Writing_a_Plugin</a> but its not working. If I the lang string to the wordpress default <code>wp-content/language/de_De....
[ { "answer_id": 1796, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>\"All procedures\" is not very descriptive. :)</p>\n\n<p>Are you calling <code>load_plugin_textdomain()</code> functi...
2010/09/14
[ "https://wordpress.stackexchange.com/questions/1795", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/389/" ]
I'm unable to load the plugin's locale file *(.mo)*. I did all the procedues described in the <http://codex.wordpress.org/Writing_a_Plugin> but its not working. If I the lang string to the wordpress default `wp-content/language/de_De.mo` file then its show the correct translated string. but not loading the data from my...
"All procedures" is not very descriptive. :) Are you calling `load_plugin_textdomain()` function? Had you set domain in your plugin's strings? There is also relevant section here: [I18n for theme and plugin developers](http://codex.wordpress.org/I18n_for_WordPress_Developers#I18n_for_theme_and_plugin_developers)
1,810
<p>Some links on my site take the user to a specific post <strong>in context on a category page</strong>. </p> <p>On non-WP sites, this is easily accomplished by including <code>#example-div-id</code> in the url like this:</p> <p><code>http://www.example.com#example-div-id</code></p> <p><strong>But in a WP environm...
[ { "answer_id": 1811, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 2, "selected": false, "text": "<p>First, I'd recommend using \"<a href=\"http://codex.wordpress.org/Using_Permalinks\" rel=\"nofollow\">pretty permalink...
2010/09/14
[ "https://wordpress.stackexchange.com/questions/1810", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58/" ]
Some links on my site take the user to a specific post **in context on a category page**. On non-WP sites, this is easily accomplished by including `#example-div-id` in the url like this: `http://www.example.com#example-div-id` **But in a WP environment, this url isn't working**: `http://www.example.com/?cat=15#po...
As I've stated in updates to my question...other javascript working on the page conflicts with the anchor jump. I implimented *more* js to work around the conflict. The url almost looks the same as before, but with a parameter name inserted before the pound symbol, `http://www.example.com/?cat=15&hi=#post-170` but I...
1,816
<p>I have developed a JavaScript widget which works fine when I embed it in any of my html pages. The code is something like this</p> <pre><code>&lt;script type="text/javascript" charset="utf-8"&gt; var asset_host = 'http://domain.com'; var url = unescape("%3Cscript src='" + asset_host + "/javascripts/widget.js' t...
[ { "answer_id": 1817, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>I assume you talk about widget in general sense and not <a href=\"http://codex.wordpress.org/WordPress_Widgets\" rel=...
2010/09/14
[ "https://wordpress.stackexchange.com/questions/1816", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/880/" ]
I have developed a JavaScript widget which works fine when I embed it in any of my html pages. The code is something like this ``` <script type="text/javascript" charset="utf-8"> var asset_host = 'http://domain.com'; var url = unescape("%3Cscript src='" + asset_host + "/javascripts/widget.js' type='text/javascript...
WordPress.com does not allow you to post javascript. **From WordPress.com Support:** > > Users are not allowed to post JavaScript on WordPress.com blogs. JavaScript can be used for malicious purposes. As an example, JavaScript has taken down sites such as MySpace.com and LiveJournal offline in the past. The security...
1,827
<p>i have a setup like</p> <pre><code>function form($instance) { $defaults = array( 'title' =&gt; 'Recent Products', 'number_products' =&gt; 3 ); $instance = wp_parse_args($instance, $defaults); </code></pre> <p>but my title is ok but number_products always does not show. i debuged in netb...
[ { "answer_id": 1833, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>I am not sure about two runs either. Had you tried just dumping content inside function instead of debug? Something l...
2010/09/15
[ "https://wordpress.stackexchange.com/questions/1827", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/794/" ]
i have a setup like ``` function form($instance) { $defaults = array( 'title' => 'Recent Products', 'number_products' => 3 ); $instance = wp_parse_args($instance, $defaults); ``` but my title is ok but number\_products always does not show. i debuged in netbeans and found that form() is r...
i finally found the answer, its actually not a problem with the code i posted. its in the `update()` function. i have some validation code ``` function update($new_instance, $old_instance) { $instance['title'] = esc_attr(strip_tags($new_instance['title'])); if (is_int($new_instance['number_products'])) { ...
1,854
<p>My theme has code that places a custom meta box on the Page editor interface for toggling noindex and/or nofollow attributes to the page.</p> <p>Its a simple little deal with two checkboxes, one says noindex, the other says nofollow.</p> <p>These work flawlessly in all versions of WP prior to 3.0.1</p> <p>I've fo...
[ { "answer_id": 1855, "author": "EAMann", "author_id": 46, "author_profile": "https://wordpress.stackexchange.com/users/46", "pm_score": 3, "selected": true, "text": "<p>First of all, this isn't using custom post meta ... you're trying to retrieve categories and use the presence of those ...
2010/09/15
[ "https://wordpress.stackexchange.com/questions/1854", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/366/" ]
My theme has code that places a custom meta box on the Page editor interface for toggling noindex and/or nofollow attributes to the page. Its a simple little deal with two checkboxes, one says noindex, the other says nofollow. These work flawlessly in all versions of WP prior to 3.0.1 I've found that in 3.0.1, the v...
First of all, this isn't using custom post meta ... you're trying to retrieve categories and use the presence of those categories to check the boxes. I also don't see any script to save the values once you've clicked them ... When this *did* work, I assume it was a very hackish solution, so I'm not surprised that it's ...
1,862
<p>I want to use a category page as the home page of my blog. Is that possible and how can I do it? It tried it with a .htacces rewrite rule but that didn't worked.</p>
[ { "answer_id": 1865, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<p>Category page can't be home page (just doesn't work like that).</p>\n\n<p>There are two other options:</p>\n\n<ol>\n<...
2010/09/15
[ "https://wordpress.stackexchange.com/questions/1862", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/462/" ]
I want to use a category page as the home page of my blog. Is that possible and how can I do it? It tried it with a .htacces rewrite rule but that didn't worked.
Update ------ Eliminating all of the other solutions, there is at least one remaining: [`template_redirect`](http://codex.wordpress.org/Plugin_API/Action_Reference/template_redirect): ``` function wpse121308_redirect_homepage() { // Check for blog posts index // NOT site front page, // which would be is_...
1,868
<p>I am trying to load a vimeo video into a single page, but it is telling me:</p> <pre><code>Given URL is not allowed by the Application configuration. </code></pre> <p>but on other pages the same iframe, copied and pasted into a page template, works fine.</p> <pre><code>&lt;iframe src="http://player.vimeo.com/vide...
[ { "answer_id": 1870, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>I assume this is message given by Vimeo? In that case it's probably better to ask them.</p>\n\n<p>I know that WP like...
2010/09/15
[ "https://wordpress.stackexchange.com/questions/1868", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/784/" ]
I am trying to load a vimeo video into a single page, but it is telling me: ``` Given URL is not allowed by the Application configuration. ``` but on other pages the same iframe, copied and pasted into a page template, works fine. ``` <iframe src="http://player.vimeo.com/video/4426465" width="400" height="230" fram...
I assume this is message given by Vimeo? In that case it's probably better to ask them. I know that WP likes to strip out iframes completely, but if it did get to display nothing more WP can break.
1,876
<p>Provided you have a 404 page defined in your theme, Wordpress will display a 404 page if "tag" is defined in $wp_query->query_vars, and there are no posts matching that tag.</p> <p>I'm writing a plugin that displays some information on each page, in addition to posts. I'd like to alter the 404 logic so that the 404...
[ { "answer_id": 1877, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>Create <code>404.php</code> template file in your theme and customize as needed (adding your plugin output or whateve...
2010/09/15
[ "https://wordpress.stackexchange.com/questions/1876", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/882/" ]
Provided you have a 404 page defined in your theme, Wordpress will display a 404 page if "tag" is defined in $wp\_query->query\_vars, and there are no posts matching that tag. I'm writing a plugin that displays some information on each page, in addition to posts. I'd like to alter the 404 logic so that the 404 page ge...
After a bit more slogging through code and Googling, I found the answer. It's contained in [this thread](http://core.trac.wordpress.org/ticket/11312) (see Otto42's post), but for the record, adding the following to your plugin will override the 404 handling for the conditions you specify: ``` add_filter('template_redi...
1,878
<p>Lets use the classic example of a custom post type called "movies", with its own taxonomy called "genre". </p> <p>By registering the custom post type (with a "movie" slug), the permalinks are already set up for </p> <pre><code>&lt;domain&gt;/movie/action/ </code></pre> <p>...to see all movies in the action genre...
[ { "answer_id": 1879, "author": "hakre", "author_id": 178, "author_profile": "https://wordpress.stackexchange.com/users/178", "pm_score": 2, "selected": false, "text": "<p>Custom Post Types are not designed to provide archive as the common blog post post type does. This might be something...
2010/09/15
[ "https://wordpress.stackexchange.com/questions/1878", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/843/" ]
Lets use the classic example of a custom post type called "movies", with its own taxonomy called "genre". By registering the custom post type (with a "movie" slug), the permalinks are already set up for ``` <domain>/movie/action/ ``` ...to see all movies in the action genre. But, archives by date, like ``` <d...
Yes, there isn't currently built-in support for CPT archives, but that doesn't mean you can't extend WP to provide it. I just did this myself the other day... This won't create the date-based archives you're looking for, but it will give you virtual archive behavior for custom post types. Adding the date should just b...
1,905
<p>I am aware of the question <a href="https://wordpress.stackexchange.com/questions/725/what-are-options-are-there-to-implement-a-multi-language-site">What are options are there to implement a multi language site</a>, but the answers there are focused on multi-language support on the backend as well as the frontend.</...
[ { "answer_id": 1908, "author": "Sergio Soares", "author_id": 433, "author_profile": "https://wordpress.stackexchange.com/users/433", "pm_score": 0, "selected": false, "text": "<p>I'm using qTranslate plugin for a project that i'm developing and i'm really happy with the results.. </p>\n\...
2010/09/16
[ "https://wordpress.stackexchange.com/questions/1905", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49/" ]
I am aware of the question [What are options are there to implement a multi language site](https://wordpress.stackexchange.com/questions/725/what-are-options-are-there-to-implement-a-multi-language-site), but the answers there are focused on multi-language support on the backend as well as the frontend. I am only conc...
If your just looking for a way for your site to be viewed in other languages I would defiantly recommend using Google Translate Tools. I just add it to the theme: ``` <div id="google_translate_element"><span id="trans">Translate: </span></div> ``` You can hide the Google Logo and funky colors in your css: ``` .goog...
1,907
<p>I use the Members plugin to manage permissions on my site. For standard templates, it works great - when the user doesn't have permission to see a page, they get the following message:</p> <blockquote> <p>Sorry, but you do not have permission to view this content.</p> </blockquote> <p>How can I make sure I still...
[ { "answer_id": 1924, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 0, "selected": false, "text": "<p>You can use the userlevels system, youc an find more information on roles levels and capabilities here:</p>\n\...
2010/09/16
[ "https://wordpress.stackexchange.com/questions/1907", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/562/" ]
I use the Members plugin to manage permissions on my site. For standard templates, it works great - when the user doesn't have permission to see a page, they get the following message: > > Sorry, but you do not have permission to view this content. > > > How can I make sure I still get this message in my custom t...
Message you quoted is being generated by `members_content_permissions_protect()` function. By default it is used as a filter on `the_content()` and `the_excerpt()` functions. Since your custom template doesn't use these - there is no case for function to run. Try something like this in template: ``` $content = 'Conte...
1,931
<p>I am using a slick little piece of code which I have included within my functions file which automatically takes any information entered into the title of a new post and create a slug with specific stop words automatically removed (code included below).</p> <p>The problem is that sometimes after this slug is automa...
[ { "answer_id": 1942, "author": "hakre", "author_id": 178, "author_profile": "https://wordpress.stackexchange.com/users/178", "pm_score": 1, "selected": false, "text": "<p>This is just a first idea: Check if it is the AJAX request.</p>\n\n<pre><code>if ( defined( 'DOING_AJAX' ) &amp;&amp;...
2010/09/17
[ "https://wordpress.stackexchange.com/questions/1931", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/479/" ]
I am using a slick little piece of code which I have included within my functions file which automatically takes any information entered into the title of a new post and create a slug with specific stop words automatically removed (code included below). The problem is that sometimes after this slug is automatically cr...
I ended up using the following code within my functions.php file to get the desired functionality: ``` // AUTOMATICALLY SANITIZE PAGE/POST SEO SLUG FROM SHORT WORDS // SOURCE: http://www.vretoolbar.com/news/seo-slugs-wordpress-plugin add_filter('name_save_pre', 'seo_slugs', 0); function seo_slugs($slug) { //...
1,937
<p>Anyone knows a way of using shortcodes on terms description? This is possible?</p>
[ { "answer_id": 1939, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 0, "selected": false, "text": "<p>I am not sure if it's only code that is needed, but Hybrid has this filter mod for such:</p>\n\n<pre><code>add_filter...
2010/09/17
[ "https://wordpress.stackexchange.com/questions/1937", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/433/" ]
Anyone knows a way of using shortcodes on terms description? This is possible?
I believe the following should work: ``` <?php $content = apply_filters('the_content', $content); $content = str_replace(']]>', ']]&gt;', $content); ?> ``` You could put this in the template of in a hooked functions. I've cribbed this from [here](http://codex.wordpress.org/Function_Reference/get_the_content) an...
1,940
<p>I have an interesting problem which I am sure someone here can solve. I have gone through a bunch of different plugins and code snippets in search for <em>the perfect code to extract a primary image to be associated with a post</em>.</p> <p>If the new WP 3.0 featured image element is used then there is of course no...
[ { "answer_id": 1943, "author": "Chris_O", "author_id": 251, "author_profile": "https://wordpress.stackexchange.com/users/251", "pm_score": 0, "selected": false, "text": "<p><strong>@NetConstructor,</strong></p>\n\n<p>This function will not solve all your issues but I thought it would hel...
2010/09/17
[ "https://wordpress.stackexchange.com/questions/1940", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/479/" ]
I have an interesting problem which I am sure someone here can solve. I have gone through a bunch of different plugins and code snippets in search for *the perfect code to extract a primary image to be associated with a post*. If the new WP 3.0 featured image element is used then there is of course no issue but there ...
Here is the solution to my problem for anyone who is interested. Include this in your functions.php file ``` require_once('custom/extract-post-thumbnail.php'); $extract_img = new extract_post_image(); add_filter( 'post_thumbnail_html', array(&$extract_img, 'get_post_image'),1,5 ); ``` Create a new file and ...
1,952
<p><img src="https://i.stack.imgur.com/tjqez.png" alt="alt text"></p> <p>I keep getting the same error, any ideas?</p> <ol> <li>I have generated a key without a password using <code>ssh-keygen</code></li> <li>I set permissions on the keys to 600</li> <li>I have successfully logged in using <code>ssh -i /root/.ssh/id_...
[ { "answer_id": 1959, "author": "Vid Luther", "author_id": 34, "author_profile": "https://wordpress.stackexchange.com/users/34", "pm_score": 0, "selected": false, "text": "<p>also is php compiled with ssh support? most hosts don't come with the pecl ssh extension..</p>\n" }, { "an...
2010/09/18
[ "https://wordpress.stackexchange.com/questions/1952", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/687/" ]
![alt text](https://i.stack.imgur.com/tjqez.png) I keep getting the same error, any ideas? 1. I have generated a key without a password using `ssh-keygen` 2. I set permissions on the keys to 600 3. I have successfully logged in using `ssh -i /root/.ssh/id_rsa 1**.**.*8.128` 4. I have tried changing hostname to `local...
This Question was answered on ServerFault by the asker. I am adding his answer here as a community wiki. Here is the full solution, thanks to [michaelmior](https://serverfault.com/users/14033/michaelmior) for his help, it got me half way. 1. Run this command to generate keys: `ssh-keygen` You'll get this output: `...
1,962
<p>I'm using Wordpress 3.0.1 with the Twenty Ten theme. I'm trying to change the way the posts in the Category view are displayed (i.e. by going to a url like mywebsite.com/category/mycategory). Currently the posts in the Category view just show the first part of a post, but I'd like to change that so it shows the wh...
[ { "answer_id": 1963, "author": "Chris_O", "author_id": 251, "author_profile": "https://wordpress.stackexchange.com/users/251", "pm_score": 4, "selected": true, "text": "<p><strong>@Ben,</strong></p>\n\n<p>If you look at line 132 of loop.php in Twentyten you will find the conditional stat...
2010/09/19
[ "https://wordpress.stackexchange.com/questions/1962", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/927/" ]
I'm using Wordpress 3.0.1 with the Twenty Ten theme. I'm trying to change the way the posts in the Category view are displayed (i.e. by going to a url like mywebsite.com/category/mycategory). Currently the posts in the Category view just show the first part of a post, but I'd like to change that so it shows the whole t...
**@Ben,** If you look at line 132 of loop.php in Twentyten you will find the conditional statement that is telling WordPress to only display the\_excerpt on category archives. Right below that after `<?php else : ?>` is how all posts that are not on an archive page, in the asides category or in the gallery category wi...
1,974
<p>One my widget bar, I have an image which is hyperlinked. The problem is that CSS underlines it. How do I remove the underline?</p> <p>Update: Just noticed that this is what is causing the underline:</p> <pre><code>} .entry a, .secondaryColumn a, #commentsContainer h3 a, .commentlist .comment-author a { border-...
[ { "answer_id": 1975, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": true, "text": "<p>By definition it isn't really hyperlinked image. It is hyperlink tag <code>a</code> that contains image tag <code>img<...
2010/09/19
[ "https://wordpress.stackexchange.com/questions/1974", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/138/" ]
One my widget bar, I have an image which is hyperlinked. The problem is that CSS underlines it. How do I remove the underline? Update: Just noticed that this is what is causing the underline: ``` } .entry a, .secondaryColumn a, #commentsContainer h3 a, .commentlist .comment-author a { border-bottom: 1px solid #dd...
By definition it isn't really hyperlinked image. It is hyperlink tag `a` that contains image tag `img`. Most probably it is a link that is really underlined, image is just inside it. You need to create new CSS rule that matches your link with image and specifies no underline (it could also be border-bottom property by...
1,976
<p>I don't use WordPress very often... I hope this makes some sense :-)</p> <p>Is there a way to sort media files into categories? I want to give some order to the media that are being uploaded to the website, and 'attaching' media to a Post is not cutting it :-)</p> <p>After a quick search, I found these two plugins...
[ { "answer_id": 2918, "author": "chodorowicz", "author_id": 1244, "author_profile": "https://wordpress.stackexchange.com/users/1244", "pm_score": 2, "selected": false, "text": "<p>I've been using Media Tags plugin with much success - it was very useful for retrieving images belonging to c...
2010/09/19
[ "https://wordpress.stackexchange.com/questions/1976", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I don't use WordPress very often... I hope this makes some sense :-) Is there a way to sort media files into categories? I want to give some order to the media that are being uploaded to the website, and 'attaching' media to a Post is not cutting it :-) After a quick search, I found these two plugins. Does anyone hav...
I've been using Media Tags plugin with much success - it was very useful for retrieving images belonging to certain page with specific tags with following code: ``` $results = get_attachments_by_media_tags(array("media_tags"=>"gallery", "post_parent" => $global_id, "order" => "ASC")); ``` Of course you can easily ta...
1,983
<p>About a year ago I remember seeing a plugin or some code which allowed you to add an author dropdown menu to the post "publishing" metabox instead of it being on its own.</p> <p>I can't seem to find this code anymore and was wondering if anyone knows how to easily do this?</p> <p>In an ideal situation I would like...
[ { "answer_id": 1988, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 4, "selected": true, "text": "<p>I somewhat suck with admin stuff so test this carefully. I had some issues with users not coming up in dropdown, but i...
2010/09/20
[ "https://wordpress.stackexchange.com/questions/1983", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/479/" ]
About a year ago I remember seeing a plugin or some code which allowed you to add an author dropdown menu to the post "publishing" metabox instead of it being on its own. I can't seem to find this code anymore and was wondering if anyone knows how to easily do this? In an ideal situation I would like to essentially a...
I somewhat suck with admin stuff so test this carefully. I had some issues with users not coming up in dropdown, but it fails with default meta box as well - probably because of my messed up test stack. ``` add_action( 'admin_menu', 'remove_author_box' ); add_action( 'post_submitbox_misc_actions', 'author_in_publish' ...
1,992
<p>I'm currently making a worpress theme. In the loop I want to have two "post-entry" divs, one that's small that goes next to my post thumb, and one for without the thumb.</p> <p>I know that I need to do a <code>&lt;?php</code> if which I've done, but I seem to have messed up somewhere and I can't see how. I have set...
[ { "answer_id": 1989, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>WordPress is pretty much framework for itself, it takes care of stuff that is usually covered by framework with own (...
2010/09/20
[ "https://wordpress.stackexchange.com/questions/1992", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I'm currently making a worpress theme. In the loop I want to have two "post-entry" divs, one that's small that goes next to my post thumb, and one for without the thumb. I know that I need to do a `<?php` if which I've done, but I seem to have messed up somewhere and I can't see how. I have set my loop in a `query_pos...
You asked multiple questions at once: Q: I think, the wordpress plug-in architecture is not MVC. A: Yes, that's true. It's not MVC in the Design Pattern Sense. It's MVC in a more general view: Model: Mysql, View: HTML/CSS, Controller: PHP. Main Frontend Controller is index.php, Commands are HTTP requests. The router ...
2,025
<p>Here is an interesting question.</p> <p>I have recently noticed that if you utilize the code</p> <pre><code>remove_meta_box('slugdiv', 'post', 'normal'); </code></pre> <p>you are actually unable to modify the slug when you click on the url slug under the page title.</p> <p>To clarify, when you use remove_meta_b...
[ { "answer_id": 2085, "author": "sorich87", "author_id": 473, "author_profile": "https://wordpress.stackexchange.com/users/473", "pm_score": 3, "selected": false, "text": "<p>The box which allows slug edition under the post title is actually tied to the slug metabox. It needs it to work. ...
2010/09/20
[ "https://wordpress.stackexchange.com/questions/2025", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/479/" ]
Here is an interesting question. I have recently noticed that if you utilize the code ``` remove_meta_box('slugdiv', 'post', 'normal'); ``` you are actually unable to modify the slug when you click on the url slug under the page title. To clarify, when you use remove\_meta\_box for the slugdiv, the metabox and th...
I ended up just adding the following CSS to a css file I was calling in my functions.php file for the admin area: ``` [for="slugdiv-hide"] { display: none; } #slugdiv { display: none; } ``` This removed both the screen options and the metabox while still allowing me to edit the url under the tit...
2,031
<p>The scenario is, some posts have one category, ok. Some others have more than one category. I must create post with content and also slideshow thumbnails for use with Nivo plugin gallery. Ok.</p> <p>I want to filter all the posts in the "slideshow" category when in index pages, so I use a simply </p> <p>query_post...
[ { "answer_id": 2032, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>I think your logic is too complicated. Setting up <code>query_posts()</code> is essentially setting up MySQL query fo...
2010/09/21
[ "https://wordpress.stackexchange.com/questions/2031", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
The scenario is, some posts have one category, ok. Some others have more than one category. I must create post with content and also slideshow thumbnails for use with Nivo plugin gallery. Ok. I want to filter all the posts in the "slideshow" category when in index pages, so I use a simply query\_posts($query\_string...
I think your logic is too complicated. Setting up `query_posts()` is essentially setting up MySQL query for database. No way query would be able to easily count amount of assigned categories on the fly and run conditions against that. Let's flip your condition. Instead of **posts that aren't in slideshow category alon...
2,036
<p>I have made a custom post type called "Case Studies".</p> <p>There is a case studies page which displays the title of every custom post and a small exceprt. However when you click on the title to view the single post, on the navigation the current tab changes from "<code>Case studies</code>" to "<code>News</code>"....
[ { "answer_id": 2187, "author": "Dalton Rooney", "author_id": 799, "author_profile": "https://wordpress.stackexchange.com/users/799", "pm_score": 0, "selected": false, "text": "<p>I believe you want to use the rewrite parameter to change the permalink to your custom post type. As far as c...
2010/09/21
[ "https://wordpress.stackexchange.com/questions/2036", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/957/" ]
I have made a custom post type called "Case Studies". There is a case studies page which displays the title of every custom post and a small exceprt. However when you click on the title to view the single post, on the navigation the current tab changes from "`Case studies`" to "`News`". Where news is the default post ...
``` // Template redirect for custom templates add_action( 'template_redirect', 'template_redirect' ); public function template_redirect() { global $wp_query; if ( $wp_query->query_vars['post_type'] == 'case_studies' ) { get_template_part( 'single-casestudies' ); // a custom page-slug.php template ...