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 |
|---|---|---|---|---|---|---|
32,400 | <p>In educational courses database, institute is used as custom taxonomy. How can I display description of "institute" taxonomy in all related posts as one institute will have at least 50 posts (courses)...</p>
| [
{
"answer_id": 32411,
"author": "endle.winters",
"author_id": 9355,
"author_profile": "https://wordpress.stackexchange.com/users/9355",
"pm_score": 0,
"selected": false,
"text": "<p>Here is the code that I used recently to display each Term within the Custom Taxonomy (called Service Type... | 2011/10/29 | [
"https://wordpress.stackexchange.com/questions/32400",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9711/"
] | In educational courses database, institute is used as custom taxonomy. How can I display description of "institute" taxonomy in all related posts as one institute will have at least 50 posts (courses)... | Assumptions:
* `institute` is the *taxonomy*
* `course` is the *term*
* only one `course` is assigned per post
* you want to display the **course description**?
If so, the simplest way would be to use [`get_the_terms()`](http://codex.wordpress.org/Function_Reference/get_the_terms). If your taxonomy is `institute`, yo... |
32,418 | <p>I'm unable to get my 'next_posts_link()' and 'previous_posts_link()' to display. So far I've tried the standard first debug by deactivating all plugins and clearing the cache, I've also tried removing the optional parameters from the call. And I've also tried using wp-pagenavi, which does display but oddly only when... | [
{
"answer_id": 32424,
"author": "Sagive",
"author_id": 7990,
"author_profile": "https://wordpress.stackexchange.com/users/7990",
"pm_score": 0,
"selected": false,
"text": "<p><strong>Try replacing those next/prev tags with this:</strong></p>\n\n<pre><code><?php next_posts_link('&l... | 2011/10/30 | [
"https://wordpress.stackexchange.com/questions/32418",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8482/"
] | I'm unable to get my 'next\_posts\_link()' and 'previous\_posts\_link()' to display. So far I've tried the standard first debug by deactivating all plugins and clearing the cache, I've also tried removing the optional parameters from the call. And I've also tried using wp-pagenavi, which does display but oddly only whe... | You need to do a little "hack" to get pagination to work for your custom loop.
After you define `$loop`, do the following:
```
<?php
// globalize $wp_query
global $wp_query;
// copy $wp_query into a temporary variable
$temp_wp_query = $wp_query;
// nullify $wp_query
$wp_query = null;
// move $loop into $wp_query
$wp_... |
32,427 | <p>I have this code so far, which adds the classes first, second, and third to every first, second and third post in the loop. It also adds a class to the first 3 posts in the loop. But how can I make it so that it adds another class to the final 3 posts? </p>
<p>
<pre><code>if (have_posts()) :
while (have_posts()) ... | [
{
"answer_id": 32428,
"author": "Tom Auger",
"author_id": 3687,
"author_profile": "https://wordpress.stackexchange.com/users/3687",
"pm_score": 1,
"selected": false,
"text": "<p>The Loop doesn't know how many records it's going to pull up, so you won't be able to tag your last three post... | 2011/10/30 | [
"https://wordpress.stackexchange.com/questions/32427",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9850/"
] | I have this code so far, which adds the classes first, second, and third to every first, second and third post in the loop. It also adds a class to the first 3 posts in the loop. But how can I make it so that it adds another class to the final 3 posts?
```
if (have_posts()) :
while (have_posts()) :
the_post();
... | WP\_Query seems to set two variables, $posts and $post\_count when running(according to the source over at <http://core.trac.wordpress.org/browser/tags/3.2.1/wp-includes/query.php> ). You can access these two and work something out to figure out if you're in the last three posts.
var\_dump those two to see if there's ... |
32,464 | <p>I'm trying to add some string replacements to the_title() - </p>
<pre><code>function format_title($content) {
$content = str_replace('&','&<br>', $content);
$content = str_replace('!','!<br>', $content);
return $content;
}
add_filter('the_title','format_title',11);
</code></pre>
<p>... | [
{
"answer_id": 32465,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": true,
"text": "<p><code>&#38;</code> is essentially synonym of <code>&amp;</code>. In <code>the_title</code> filter <a href=\"h... | 2011/10/30 | [
"https://wordpress.stackexchange.com/questions/32464",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3390/"
] | I'm trying to add some string replacements to the\_title() -
```
function format_title($content) {
$content = str_replace('&','&<br>', $content);
$content = str_replace('!','!<br>', $content);
return $content;
}
add_filter('the_title','format_title',11);
```
When I try and replace ampersands I get an ad... | `&` is essentially synonym of `&`. In `the_title` filter [`wptexturize()`](http://codex.wordpress.org/Function_Reference/wptexturize) runs with priority `1` (important!) and makes this replacement.
So by the time it gets to your `format_title()` at priority `11` - instead of replacing lone `&` symbol you repla... |
32,474 | <p>i want to add a datepicker on a custom page but i doesn not work. WP version is 3.2.1.
Those are the init string i used on wp code:</p>
<pre><code>wp_enqueue_script('jquery');
wp_enqueue_script('jquery-ui-core');
wp_enqueue_script('jquery-ui-datepicker', get_bloginfo('template_url') . '/js/jquery-ui-datepicker.min.... | [
{
"answer_id": 32479,
"author": "Tom Auger",
"author_id": 3687,
"author_profile": "https://wordpress.stackexchange.com/users/3687",
"pm_score": 0,
"selected": false,
"text": "<p>In your example, the jQuery is placed <strong>before</strong> the 'datepicker' <code>div</code> is created. S... | 2011/10/30 | [
"https://wordpress.stackexchange.com/questions/32474",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9477/"
] | i want to add a datepicker on a custom page but i doesn not work. WP version is 3.2.1.
Those are the init string i used on wp code:
```
wp_enqueue_script('jquery');
wp_enqueue_script('jquery-ui-core');
wp_enqueue_script('jquery-ui-datepicker', get_bloginfo('template_url') . '/js/jquery-ui-datepicker.min.js', array('jq... | I often type things wrong. So, I would start debugging you copying and pasting the links to the JS scripts in your browser and make sure they load.
Then in Chrome go to the Wrench Menu -> Tools -> JavaScript Console. Here you will be able to type/execute your JavaScript directly. I would start off my typing `jQuery` i... |
32,499 | <p>I am trying to include user input includes using "get_template_part()" The includes are added in the theme options eg a user inputs.</p>
<pre><code>get_template_part('content/block', 'branding');
get_template_part('content/block', 'footer');
</code></pre>
<p>I need to execute this code as php and have a custom hoo... | [
{
"answer_id": 32504,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": false,
"text": "<p>I don't see any reason whatsoever to use <code>eval()</code> in this circumstance.</p>\n\n<blockquote>\n <... | 2011/10/31 | [
"https://wordpress.stackexchange.com/questions/32499",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9871/"
] | I am trying to include user input includes using "get\_template\_part()" The includes are added in the theme options eg a user inputs.
```
get_template_part('content/block', 'branding');
get_template_part('content/block', 'footer');
```
I need to execute this code as php and have a custom hook for add\_before\_conte... | I see what you're trying to do ... and I don't like it at all. You're including way too much in terms of options for the theme, particularly if you're allowing freeform PHP code on an options screen.
Why this is a bad idea
----------------------
The mantra of the entire WordPress project is "decisions, not options." ... |
32,505 | <p>I have been advised how to add additional contact info fields to the User admin area here (<a href="https://wordpress.stackexchange.com/questions/32496/best-way-to-allow-manageable-social-media-urls/32502#32502">Click here</a>).</p>
<p>However, I am not entirely sure how I can display the the field contents in a li... | [
{
"answer_id": 32537,
"author": "Brad Dalton",
"author_id": 9884,
"author_profile": "https://wordpress.stackexchange.com/users/9884",
"pm_score": 0,
"selected": false,
"text": "<pre><code>// Add/Remove Contact Methods\nfunction add_remove_contactmethods( $contactmethods ) {\n $contact... | 2011/10/31 | [
"https://wordpress.stackexchange.com/questions/32505",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5883/"
] | I have been advised how to add additional contact info fields to the User admin area here ([Click here](https://wordpress.stackexchange.com/questions/32496/best-way-to-allow-manageable-social-media-urls/32502#32502)).
However, I am not entirely sure how I can display the the field contents in a link within my template... | This might help you out if you haven't found an answer yet.
```
/* BEGIN Custom User Contact Info */
function extra_contact_info($contactmethods) {
unset($contactmethods['aim']);
unset($contactmethods['yim']);
unset($contactmethods['jabber']);
$contactmethods['facebook'] = 'Facebook';
$contac... |
32,519 | <p>Is it possible to continually update an xml file on the server with data from a wordpress page? If so, how could I do it?</p>
<p>I use this plugin <a href="http://plugins.elliotcondon.com/advanced-custom-fields/" rel="nofollow">http://plugins.elliotcondon.com/advanced-custom-fields/</a> to create the custom data. W... | [
{
"answer_id": 32520,
"author": "v0idless",
"author_id": 6228,
"author_profile": "https://wordpress.stackexchange.com/users/6228",
"pm_score": 4,
"selected": true,
"text": "<p>The <code>save_post</code> hook gets called each time a post is created or updated. Just hook into that. There y... | 2011/10/31 | [
"https://wordpress.stackexchange.com/questions/32519",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4588/"
] | Is it possible to continually update an xml file on the server with data from a wordpress page? If so, how could I do it?
I use this plugin <http://plugins.elliotcondon.com/advanced-custom-fields/> to create the custom data. Would I be able to save this to an xml file?
It's important that this xml file is updated eve... | The `save_post` hook gets called each time a post is created or updated. Just hook into that. There you can do something like `fputcsv('/tmp/' . $post_id, $post)` or output to XML/JSON.
== EDIT ==
```
add_action( 'save_post', 'wp239s5_post_to_xml', 10, 2 );
function wp239s5_post_to_xml( $post_id, $post ) {
if ( d... |
32,541 | <p>I'd like to enable a shortcode toolbar button, similar to the "More" break, that I can click to mark an insertion point where the text should be broken into columns.</p>
<p>Do shortcodes have encapsulation or would I need to enter an endpoint?</p>
<p>Example:</p>
<pre><code>[column]The column starts here[/column]... | [
{
"answer_id": 32548,
"author": "Steven",
"author_id": 1447,
"author_profile": "https://wordpress.stackexchange.com/users/1447",
"pm_score": 1,
"selected": false,
"text": "<p>Shortcode do have encapsulation. Read more about that here: <a href=\"http://codex.wordpress.org/Shortcode_API\" ... | 2011/10/31 | [
"https://wordpress.stackexchange.com/questions/32541",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6620/"
] | I'd like to enable a shortcode toolbar button, similar to the "More" break, that I can click to mark an insertion point where the text should be broken into columns.
Do shortcodes have encapsulation or would I need to enter an endpoint?
Example:
```
[column]The column starts here[/column]
```
Or
```
[columnBegin]... | Shortcode do have encapsulation. Read more about that here: <http://codex.wordpress.org/Shortcode_API> |
32,558 | <p>I've set up a bunch of additional image sizes in my functions.php theme file, with the crop parameter set to true. However, the images are resized but not cropped.</p>
<pre><code> if (function_exists('add_image_size')) {
add_image_size('frontpage_a-la-une_thumb', 400, 215, true);
add_image_size('... | [
{
"answer_id": 32571,
"author": "Jeremy Jared",
"author_id": 5339,
"author_profile": "https://wordpress.stackexchange.com/users/5339",
"pm_score": 2,
"selected": false,
"text": "<p>You'll need to regenerate the thumbnails for existing images. I use this plugin:\n<a href=\"http://wordpres... | 2011/11/01 | [
"https://wordpress.stackexchange.com/questions/32558",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/82/"
] | I've set up a bunch of additional image sizes in my functions.php theme file, with the crop parameter set to true. However, the images are resized but not cropped.
```
if (function_exists('add_image_size')) {
add_image_size('frontpage_a-la-une_thumb', 400, 215, true);
add_image_size('single_thumb',... | Currently, WordPress core image handling/thumbnail creation does not perform zoom-crop. If you need an intermediate image size to be created explicitly, you will need to ensure that you upload an image with equal or larger dimensions as the intermediate image size. |
32,564 | <p>Am trying to display posts only from the "latest" category on my wordpress blog but am strangely getting the same post displayed twice. What am i doing wrong?
<img src="https://i.stack.imgur.com/RrHXz.gif" alt="enter image description here"></p>
<pre><code>/*
* Theme file:index.php
*/
global $post;
$categor... | [
{
"answer_id": 32604,
"author": "pp19dd",
"author_id": 6555,
"author_profile": "https://wordpress.stackexchange.com/users/6555",
"pm_score": 1,
"selected": false,
"text": "<p>Without looking at the database data (posts, inherits, etc), it's a bit of guesswork.</p>\n\n<p>Try the following... | 2011/11/01 | [
"https://wordpress.stackexchange.com/questions/32564",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9335/"
] | Am trying to display posts only from the "latest" category on my wordpress blog but am strangely getting the same post displayed twice. What am i doing wrong?

```
/*
* Theme file:index.php
*/
global $post;
$categories=get_categories();
fo... | Without looking at the database data (posts, inherits, etc), it's a bit of guesswork.
Try the following:
* Make sure you have `"post_type"=>"post"` specified, so that you don't get auto-saved inherits (if it defaults to 'any').
* If this is an isolated query (not meant to be main loop), use $q = new WP\_Query() and r... |
32,584 | <p>I'd like to have the backend of Wordpress in English and use a different locale for the frontend</p>
<p>so far I figure out perhaps I could do it by setting in the wpconfig the locale I want to use in the frontend, then add in functions.php something like this:</p>
<pre><code>add_filter('locale', 'mytheme_backendl... | [
{
"answer_id": 32586,
"author": "Andy James",
"author_id": 9871,
"author_profile": "https://wordpress.stackexchange.com/users/9871",
"pm_score": 1,
"selected": false,
"text": "<p>There is a plugin that may be what you need.</p>\n\n<p><a href=\"http://wordpress.org/extend/plugins/fe-be-lo... | 2011/11/01 | [
"https://wordpress.stackexchange.com/questions/32584",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8421/"
] | I'd like to have the backend of Wordpress in English and use a different locale for the frontend
so far I figure out perhaps I could do it by setting in the wpconfig the locale I want to use in the frontend, then add in functions.php something like this:
```
add_filter('locale', 'mytheme_backendlocale');
function myt... | Install the plugin [WP Native Dashboard](http://wordpress.org/extend/plugins/wp-native-dashboard/). Then you can set one language for the front-end in your `wp-config.php` and each user can choose another one for the back-end.
See [Change language of comments template](https://wordpress.stackexchange.com/a/52538/73)... |
32,592 | <p>In my blog, I sometimes post "how to" style tutorial posts. I would like to show a difficulty gauge next to the post title like 'assumed knowledge', 'time to complete', 'frustration level', 'cost' etc. They should show up in excerpts, the main page and in posts too.</p>
<p>Unfortunately googling with keywords "word... | [
{
"answer_id": 32593,
"author": "Andy James",
"author_id": 9871,
"author_profile": "https://wordpress.stackexchange.com/users/9871",
"pm_score": 3,
"selected": true,
"text": "<p>You don't need a plugin to do this. Why not just use the wordpress custom fields feature to add your custom me... | 2011/11/01 | [
"https://wordpress.stackexchange.com/questions/32592",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9906/"
] | In my blog, I sometimes post "how to" style tutorial posts. I would like to show a difficulty gauge next to the post title like 'assumed knowledge', 'time to complete', 'frustration level', 'cost' etc. They should show up in excerpts, the main page and in posts too.
Unfortunately googling with keywords "wordpress tuto... | You don't need a plugin to do this. Why not just use the wordpress custom fields feature to add your custom meta data to the posts.
<http://codex.wordpress.org/Custom_Fields>
You can create a custom field for each that the person adding the tutorial fills in. Then take that value that is entered and add it as a class... |
32,622 | <p>... or does <code>wp_title()</code> already handle the various contexts in your blog?</p>
<p>This could clarify for me how I can achieve a reusable <code>index.php</code> file without having all the conditional statements inside it to handle the different title formats in the given context (page, single, posts, sea... | [
{
"answer_id": 32624,
"author": "Joseph Leedy",
"author_id": 8554,
"author_profile": "https://wordpress.stackexchange.com/users/8554",
"pm_score": 0,
"selected": false,
"text": "<p>Correct me if I am wrong, but I do not think that there is a \"clean\" way of doing titles without using co... | 2011/11/01 | [
"https://wordpress.stackexchange.com/questions/32622",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9710/"
] | ... or does `wp_title()` already handle the various contexts in your blog?
This could clarify for me how I can achieve a reusable `index.php` file without having all the conditional statements inside it to handle the different title formats in the given context (page, single, posts, search, archive, date, etc...)
Als... | The [`wp_title()` template tag](http://codex.wordpress.org/Function_Reference/wp_title) does *some* context-based output. From the Codex:
>
> The title text depends on the query:
>
>
> Single post or a Page
>
>
> * the title of the post (or Page)
>
>
> Date-based archive
>
>
> * the date (e.g., "2006", "2006... |
32,646 | <p>How can i use my own (custom) session value in Wordpress?<br>
For example: <code>$_SESSION['myname']="4lvin"</code><br></p>
<p>I've already inserted <code>session_start()</code> at all page i need as following.</p>
<pre><code><?php
session_start();
$_SESSION['myname'] = "4lvin";
?>
</code></pre>
<p>But not ... | [
{
"answer_id": 32658,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 3,
"selected": false,
"text": "<p>WordPress doesn't use sessions, that's why your session variables aren't working.</p>\n\n<p>As a matter of fact, if c... | 2011/11/01 | [
"https://wordpress.stackexchange.com/questions/32646",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35907/"
] | How can i use my own (custom) session value in Wordpress?
For example: `$_SESSION['myname']="4lvin"`
I've already inserted `session_start()` at all page i need as following.
```
<?php
session_start();
$_SESSION['myname'] = "4lvin";
?>
```
But not working Global-wise.
Just working on the self page.
It is ... | **EDIT:** "THE PLUGIN BELOW ISN'T AVAILABLE ANYMORE, SO PLEASE USE THAT PLUGIN INSTEAD: [WordPress Session Plugin](http://wordpress.org/plugins/wp-session-manager/)"
There is a good WordPress Plugin adapted from CodeIgniter Session class: [WP Sessions Plugin](http://codecanyon.net/item/wordpress-sessions-plugin-with-d... |
32,654 | <p>I know this sounds illogical and maybe it is, but the client's asked for it so I'm looking into a solution if possible.</p>
<p>On a section of the site there's a link that leads to category-news.php, which displays all posts belonging to News. The user loads each of these posts dynamically through the use of Infini... | [
{
"answer_id": 32658,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 3,
"selected": false,
"text": "<p>WordPress doesn't use sessions, that's why your session variables aren't working.</p>\n\n<p>As a matter of fact, if c... | 2011/11/01 | [
"https://wordpress.stackexchange.com/questions/32654",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3390/"
] | I know this sounds illogical and maybe it is, but the client's asked for it so I'm looking into a solution if possible.
On a section of the site there's a link that leads to category-news.php, which displays all posts belonging to News. The user loads each of these posts dynamically through the use of InfiniteScroll, ... | **EDIT:** "THE PLUGIN BELOW ISN'T AVAILABLE ANYMORE, SO PLEASE USE THAT PLUGIN INSTEAD: [WordPress Session Plugin](http://wordpress.org/plugins/wp-session-manager/)"
There is a good WordPress Plugin adapted from CodeIgniter Session class: [WP Sessions Plugin](http://codecanyon.net/item/wordpress-sessions-plugin-with-d... |
32,685 | <p>Is there any function/code snippet to retrieve the unix time stamp of the comment on a post? The WordPress default function <code>comment_time();</code> returns the time of the post in 12hr format (not helpful).</p>
| [
{
"answer_id": 32688,
"author": "Andy James",
"author_id": 9871,
"author_profile": "https://wordpress.stackexchange.com/users/9871",
"pm_score": 1,
"selected": false,
"text": "<p>Not sure about how or why you need the unix time stamp.</p>\n\n<p>You can get the ISO 8601 time stamp by usin... | 2011/11/02 | [
"https://wordpress.stackexchange.com/questions/32685",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9094/"
] | Is there any function/code snippet to retrieve the unix time stamp of the comment on a post? The WordPress default function `comment_time();` returns the time of the post in 12hr format (not helpful). | Use:
```
global $comment;
$timestamp = strtotime("{$comment->comment_date_gmt} GMT");
```
Regards. |
32,689 | <p>Let me set the scene:</p>
<p>I have a CPT that will work on a multi-site installation and some of the sites will be in a different language. For example my CPT is <code>Case Studies</code> I would use a URL structure like: <code>/case-studies/%post_id%/%postname%/</code> but if the site language is different then <... | [
{
"answer_id": 32711,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 1,
"selected": false,
"text": "<p>It appears that the <a href=\"http://core.trac.wordpress.org/browser/tags/3.2.1/wp-admin/options-reading.ph... | 2011/11/02 | [
"https://wordpress.stackexchange.com/questions/32689",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4610/"
] | Let me set the scene:
I have a CPT that will work on a multi-site installation and some of the sites will be in a different language. For example my CPT is `Case Studies` I would use a URL structure like: `/case-studies/%post_id%/%postname%/` but if the site language is different then `case-studies` is no longer that.... | I've gone with this the following approach:
I already had a theme options page using the Settings API and because this CPT I have setup is part of the theme it only made sense to add this option to the theme options. Below is the code if anyone wants to use:
```
<?php
// Add settings to menu
add_action( 'admin_menu',... |
32,694 | <p>How-to show last 5 posts that are published after current post?</p>
<p>Explained on image below:</p>
<p><a href="http://s017.radikal.ru/i401/1111/99/6bd645f47f86.jpg" rel="nofollow">IMAGE FOR EXPLAINE</a></p>
| [
{
"answer_id": 32706,
"author": "EarnestoDev",
"author_id": 8211,
"author_profile": "https://wordpress.stackexchange.com/users/8211",
"pm_score": 1,
"selected": true,
"text": "<pre><code>global $wpdb, $post; // Uses current POST here\n$IDs = $wpdb->get_col(\"SELECT `ID` FROM {$wpdb-&g... | 2011/11/02 | [
"https://wordpress.stackexchange.com/questions/32694",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9934/"
] | How-to show last 5 posts that are published after current post?
Explained on image below:
[IMAGE FOR EXPLAINE](http://s017.radikal.ru/i401/1111/99/6bd645f47f86.jpg) | ```
global $wpdb, $post; // Uses current POST here
$IDs = $wpdb->get_col("SELECT `ID` FROM {$wpdb->posts}
WHERE `post_type`='{$post->post_type}' AND `post_status`='publish' AND `ID`<{$post->ID}
ORDER BY `ID` DESC LIMIT 5;");
```
This function lists the 5 posts with IDs lower then `ID 176` that are of `post_ty... |
32,699 | <p>I have a button within a post which a user can click. Once clicked, an AJAX call is made.</p>
<p>My question is, within my PHP AJAX helper function (located in my theme's function.php) how can I retrieve, for instance, the ID of the post that the request was sent from.</p>
<p>I can get the ID from the markup and p... | [
{
"answer_id": 32706,
"author": "EarnestoDev",
"author_id": 8211,
"author_profile": "https://wordpress.stackexchange.com/users/8211",
"pm_score": 1,
"selected": true,
"text": "<pre><code>global $wpdb, $post; // Uses current POST here\n$IDs = $wpdb->get_col(\"SELECT `ID` FROM {$wpdb-&g... | 2011/11/02 | [
"https://wordpress.stackexchange.com/questions/32699",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1144/"
] | I have a button within a post which a user can click. Once clicked, an AJAX call is made.
My question is, within my PHP AJAX helper function (located in my theme's function.php) how can I retrieve, for instance, the ID of the post that the request was sent from.
I can get the ID from the markup and pass it in the AJA... | ```
global $wpdb, $post; // Uses current POST here
$IDs = $wpdb->get_col("SELECT `ID` FROM {$wpdb->posts}
WHERE `post_type`='{$post->post_type}' AND `post_status`='publish' AND `ID`<{$post->ID}
ORDER BY `ID` DESC LIMIT 5;");
```
This function lists the 5 posts with IDs lower then `ID 176` that are of `post_ty... |
32,717 | <p>How can I implement it so that I switch per-post background images from the WP post-edit screen?</p>
<p>A developer helped me built a custom WP theme, but can't help me out right now. On this page: </p>
<p><a href="http://vernisaj.ro/guetlinvelo/a-la-carte/litespeed/" rel="nofollow">http://vernisaj.ro/guetlinvelo/... | [
{
"answer_id": 32720,
"author": "user3960",
"author_id": 3960,
"author_profile": "https://wordpress.stackexchange.com/users/3960",
"pm_score": 0,
"selected": false,
"text": "<p>Well, the CSS is actually pointing to an image on a different site: velo-service.ch</p>\n\n<p>It's not hard to ... | 2011/11/02 | [
"https://wordpress.stackexchange.com/questions/32717",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3951/"
] | How can I implement it so that I switch per-post background images from the WP post-edit screen?
A developer helped me built a custom WP theme, but can't help me out right now. On this page:
<http://vernisaj.ro/guetlinvelo/a-la-carte/litespeed/>
there is a background image on the following CSS element:
```
.page-c... | WordPress does not have such an option by default; you will have to create the functionality for per-post background images - which is entirely possible.
Your best bet might be to use **post custom meta** to link/upload per-post background images, and then enqueue a dynamic stylesheet that applies that image as the ba... |
32,725 | <p>I would like to offer an embed code on my WP blog allowing users to re-publish recent posts on their websites using HTML/ Javascript code snippet that they can copy from my WP site and paste into their non-WP site.</p>
<p>Can you guys help?</p>
| [
{
"answer_id": 32727,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 0,
"selected": false,
"text": "<p>You simply have to take the third-party code, and wrap it inside a WordPress Widget, using the <a href=\"ht... | 2011/11/02 | [
"https://wordpress.stackexchange.com/questions/32725",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1341/"
] | I would like to offer an embed code on my WP blog allowing users to re-publish recent posts on their websites using HTML/ Javascript code snippet that they can copy from my WP site and paste into their non-WP site.
Can you guys help? | You basically need to create an area outside of your current theme in which to create some content that you can stick into an iframe.
You just give your user something like this:
```
<iframe src="http://yoursite.com/iframe/"></iframe>
```
And they have your posts on their site!
Step one is going to be creating a U... |
32,728 | <p>I currently have an ID of a page that I want to use its permalink as the front of a permastruct of a CPT I'm setting up.</p>
<p>Now I can use get_permalink() but that returns the full URL:</p>
<p><code>http://www.example.com/imapage/subpage/subsubpage</code></p>
<p>but all I want to return is <code>imapage/subpag... | [
{
"answer_id": 32729,
"author": "sanchothefat",
"author_id": 1733,
"author_profile": "https://wordpress.stackexchange.com/users/1733",
"pm_score": 4,
"selected": true,
"text": "<p>There's nothing built in to return the bit you want but it should be as easy as using the home_url() functio... | 2011/11/02 | [
"https://wordpress.stackexchange.com/questions/32728",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4610/"
] | I currently have an ID of a page that I want to use its permalink as the front of a permastruct of a CPT I'm setting up.
Now I can use get\_permalink() but that returns the full URL:
`http://www.example.com/imapage/subpage/subsubpage`
but all I want to return is `imapage/subpage/subsubpage`
Is there a function that... | There's nothing built in to return the bit you want but it should be as easy as using the home\_url() function and removing it's output from the full url eg:
```
function get_relative_permalink( $url ) {
return str_replace( home_url(), "", $url );
}
``` |
32,738 | <p>I know that roles in WordPress are not hierarchical, but I'm wondering if there is any type of capability to "assign users to roles". All I can see if being able to add users or not. </p>
<p>The real kicker here is, I've used Justin Tadlock's Members plugin to create a new role, called "Clients" which removes all t... | [
{
"answer_id": 53685,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 4,
"selected": true,
"text": "<h2>The UI select element</h2>\n\n<p>On <code>user-edit.php</code>, you see the drop-down in the UI. The drop down <cod... | 2011/11/02 | [
"https://wordpress.stackexchange.com/questions/32738",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9605/"
] | I know that roles in WordPress are not hierarchical, but I'm wondering if there is any type of capability to "assign users to roles". All I can see if being able to add users or not.
The real kicker here is, I've used Justin Tadlock's Members plugin to create a new role, called "Clients" which removes all the stuff t... | The UI select element
---------------------
On `user-edit.php`, you see the drop-down in the UI. The drop down `<select>` wrapper is hard coded.
Then the admin interface does a nifty thing 1) according to the inline comment: `// Get the highest/primary role for this user`. In fact it is getting the *first* role, tha... |
32,739 | <p>I'm trying to use wp_nav_menu to only display a menu if one exists, otherwise, display nothing.</p>
<p>If I delete the menu, it will output a list of the pages. </p>
<p>My functions.php file contains:</p>
<pre><code>if (function_exists('register_nav_menus')) {
register_nav_menus (
array('main_nav' => 'Main Nav... | [
{
"answer_id": 32741,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 6,
"selected": true,
"text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/has_nav_menu\"><code>has_nav_menu()</code></a>, ... | 2011/11/02 | [
"https://wordpress.stackexchange.com/questions/32739",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3711/"
] | I'm trying to use wp\_nav\_menu to only display a menu if one exists, otherwise, display nothing.
If I delete the menu, it will output a list of the pages.
My functions.php file contains:
```
if (function_exists('register_nav_menus')) {
register_nav_menus (
array('main_nav' => 'Main Navigation Menu'));}
```
How c... | Use [`has_nav_menu()`](http://codex.wordpress.org/Function_Reference/has_nav_menu), and test for `theme_location`, rather than `menu_id`:
```
<?php
if ( has_nav_menu( $theme_location ) ) {
// User has assigned menu to this location;
// output it
wp_nav_menu( array(
'theme_location' => $theme_locat... |
32,771 | <p>I did this:</p>
<pre><code>cd wp-content/themes
cp -R someTheme newTheme
</code></pre>
<p>then:</p>
<pre><code>cd newTheme
vim style.css #changed name of theme in the css comment header
</code></pre>
<p>and then logged into <code>example.com/wp-admin</code>. But when I looked at the list of themes (under the app... | [
{
"answer_id": 32772,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 0,
"selected": false,
"text": "<p>Your theme needs at least an index.php file for WP to recognize it, along with the style.css file. The style.css fi... | 2011/11/03 | [
"https://wordpress.stackexchange.com/questions/32771",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9142/"
] | I did this:
```
cd wp-content/themes
cp -R someTheme newTheme
```
then:
```
cd newTheme
vim style.css #changed name of theme in the css comment header
```
and then logged into `example.com/wp-admin`. But when I looked at the list of themes (under the appearance header in left menu), I did not see it there. What e... | I have Multi-Site enabled.
That means I must first log in as a super admin, then go to "super admin" > "themes" option in left menu (inside wp-admin), and then enable it there first. |
32,777 | <p>Can I add some custom fields to specific taxonomy so when ever I call that taxonomy, custom fields attached to that taxonomy should also appear.</p>
| [
{
"answer_id": 32830,
"author": "Kevin Langley Jr.",
"author_id": 9968,
"author_profile": "https://wordpress.stackexchange.com/users/9968",
"pm_score": 3,
"selected": true,
"text": "<p>You can hook into the edit form field action of that specific taxonomy.</p>\n\n<p>If you look in /wp-ad... | 2011/11/03 | [
"https://wordpress.stackexchange.com/questions/32777",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9711/"
] | Can I add some custom fields to specific taxonomy so when ever I call that taxonomy, custom fields attached to that taxonomy should also appear. | You can hook into the edit form field action of that specific taxonomy.
If you look in /wp-admin/edit-tag-form.php there are hooks for every taxonomy.
Starting at Line 69:
```
if ( 'category' == $taxonomy )
do_action('edit_category_form_fields', $tag);
elseif ( 'link_category' == $taxonomy )
... |
32,785 | <p>I have to remove some profile fields from the 'Profile' page according to the user roles. For removing the color picker I used <code>remove_action("admin_color_scheme_picker", "admin_color_scheme_picker")</code>. I want to remove these fields:</p>
<ol>
<li>Nickname</li>
<li>Display name publicly as</li>
<li>AIM, Ya... | [
{
"answer_id": 32790,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 5,
"selected": true,
"text": "<p>For the contact methods filter: <a href=\"https://developer.wordpress.org/reference/hooks/user_contactmethods/\" re... | 2011/11/03 | [
"https://wordpress.stackexchange.com/questions/32785",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4740/"
] | I have to remove some profile fields from the 'Profile' page according to the user roles. For removing the color picker I used `remove_action("admin_color_scheme_picker", "admin_color_scheme_picker")`. I want to remove these fields:
1. Nickname
2. Display name publicly as
3. AIM, Yahoo, Google talk and About yourself ... | For the contact methods filter: [`user_contactmethods`](https://developer.wordpress.org/reference/hooks/user_contactmethods/):
```
function update_contact_methods( $contactmethods ) {
unset( $contactmethods['aim'] );
unset( $contactmethods['jabber'] );
unset( $contactmethods['yim'] );
return $contact... |
32,803 | <p>I tried with this code:<br/></p>
<pre><code>function home_page_menu_args( $args ) {
$args['show_home'] = true;
return $args;
}
add_filter( 'wp_page_menu_args', 'home_page_menu_args' );
</code></pre>
<p><br/>but gives me this error: <code>Error 404 - Not Found</code><br/></p>
<p>I would like that when I click on "... | [
{
"answer_id": 32810,
"author": "sanchothefat",
"author_id": 1733,
"author_profile": "https://wordpress.stackexchange.com/users/1733",
"pm_score": 3,
"selected": true,
"text": "<p>To add a home link to menus that you create via the menus admin area:</p>\n\n<ol>\n<li>go to the <strong>Pag... | 2011/11/03 | [
"https://wordpress.stackexchange.com/questions/32803",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9963/"
] | I tried with this code:
```
function home_page_menu_args( $args ) {
$args['show_home'] = true;
return $args;
}
add_filter( 'wp_page_menu_args', 'home_page_menu_args' );
```
but gives me this error: `Error 404 - Not Found`
I would like that when I click on "Home Page" menu appears the recent posts.
And I woul... | To add a home link to menus that you create via the menus admin area:
1. go to the **Pages** box,
2. click the 'View All' tab
3. 'Home' will appear, check the box and click 'add to menu'
 |
32,815 | <p>I think that I have a problem with the loop on my taxonomy page. On any part of the code (specially on the sidebar) that I need the permalink, it always return the link of the first item of the taxonomy loop, but the correct, is of the current page.</p>
<p>This is my taxonomy page code:</p>
<pre><code><?php get... | [
{
"answer_id": 32819,
"author": "Daniel",
"author_id": 9060,
"author_profile": "https://wordpress.stackexchange.com/users/9060",
"pm_score": 0,
"selected": false,
"text": "<p>I didn't test your code, but I would check first the follow functions,</p>\n\n<p><code><?php rewind_posts(); ?... | 2011/11/03 | [
"https://wordpress.stackexchange.com/questions/32815",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5403/"
] | I think that I have a problem with the loop on my taxonomy page. On any part of the code (specially on the sidebar) that I need the permalink, it always return the link of the first item of the taxonomy loop, but the correct, is of the current page.
This is my taxonomy page code:
```
<?php get_header(); ?>
<div id="h... | You're trying to build the permalinks yourself? That looks really tricky and fragile.
Also, you're getting a little confused trying to deal with the `$loop` WP\_Query object. When you call `$loop->the_post();`, what you're doing is populating the global variable **$post** with the next post in the **$loop** query obj... |
32,832 | <p>I'm working on creating a custom content type but I'm having a bit of a problem formatting the create and edit views. I want to disable the main editor and focus only on the title, excerpt, and custom fields. I have the following jQuery code that will add the WYSIWYG to my custom fields, and that works fine:</p>
... | [
{
"answer_id": 32836,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 2,
"selected": true,
"text": "<p>I just had the exact same issue. You have to include the editor in the supports argument array to get custom mce b... | 2011/11/03 | [
"https://wordpress.stackexchange.com/questions/32832",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2355/"
] | I'm working on creating a custom content type but I'm having a bit of a problem formatting the create and edit views. I want to disable the main editor and focus only on the title, excerpt, and custom fields. I have the following jQuery code that will add the WYSIWYG to my custom fields, and that works fine:
```
<scri... | I just had the exact same issue. You have to include the editor in the supports argument array to get custom mce boxes to show.
I solved the issue by hiding it with CSS:
```
function move_posteditor( $hook ) {
if ( $hook == 'post.php' OR $hook == 'post-new.php' ) {
add_action( 'admin_print_fo... |
32,840 | <p>I have this wordpress site that I am making where a user has to login to see their specific gallery. My problem is that all our users are members and all the members can see all the other member pages. It's kind of hard to explain so I'll link you guys to what I have.</p>
<p>Once this client is logged in and you ho... | [
{
"answer_id": 32844,
"author": "Kevin Langley Jr.",
"author_id": 9968,
"author_profile": "https://wordpress.stackexchange.com/users/9968",
"pm_score": 0,
"selected": false,
"text": "<p>You could simply use wp_get_current_user() and check against the author of the post or even set a post... | 2011/11/03 | [
"https://wordpress.stackexchange.com/questions/32840",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7355/"
] | I have this wordpress site that I am making where a user has to login to see their specific gallery. My problem is that all our users are members and all the members can see all the other member pages. It's kind of hard to explain so I'll link you guys to what I have.
Once this client is logged in and you hover over "... | Big Question.
So, first, to keep the galleries separate, it would be good to give them their own custom post type. We'll be checking for this later...
```
<?php
add_action( 'init', 'wpse32840_register_post_type' );
function wpse32840_register_post_type()
{
register_post_type(
'client_gallery',
arr... |
32,841 | <p>I want a script in my theme, ajax.php, which I want to load or access from other frontend pages using ajax.</p>
<p>In ajax.php I want access to core WP functions such as get_posts(), do_shortcode() etc. I.e. I need WordPress loaded on the script.</p>
<p>Traditionally I have setup a page in the admin and given it a... | [
{
"answer_id": 32842,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>See the codex page on how to properly use <a href=\"http://codex.wordpress.org/AJAX_in_Plugins\" rel=\"nofollow\">A... | 2011/11/03 | [
"https://wordpress.stackexchange.com/questions/32841",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4093/"
] | I want a script in my theme, ajax.php, which I want to load or access from other frontend pages using ajax.
In ajax.php I want access to core WP functions such as get\_posts(), do\_shortcode() etc. I.e. I need WordPress loaded on the script.
Traditionally I have setup a page in the admin and given it a custom templat... | It is really not best practice to do it this way at all. In fact you don't need to create an ajax.php file unless you're just going to include it in your functions.php file. You need to read up on AJAX in WordPress. You would just add an action on 'wp\_ajax\_name\_of\_action' and just specify the action within the java... |
32,847 | <p>I'm looking for a to hide the text on the dashboard that says "You are using WordPress 3.2.1" in the Right Now widget. Not that we don't love WordPress, but for our use-case (where we'll be providing this WP install to dozens, if not hundreds of people), I'd like to get as much stuff out of there that's not needed (... | [
{
"answer_id": 32848,
"author": "Kevin Langley Jr.",
"author_id": 9968,
"author_profile": "https://wordpress.stackexchange.com/users/9968",
"pm_score": 0,
"selected": false,
"text": "<p>It is located within the update_right_now_message() function in wp-admin/includes/update.php but there... | 2011/11/03 | [
"https://wordpress.stackexchange.com/questions/32847",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9605/"
] | I'm looking for a to hide the text on the dashboard that says "You are using WordPress 3.2.1" in the Right Now widget. Not that we don't love WordPress, but for our use-case (where we'll be providing this WP install to dozens, if not hundreds of people), I'd like to get as much stuff out of there that's not needed (and... | There is a trick to get rid of this using the `gettext` filter for translations.
This basically replaces it with nothing.
```
add_filter('gettext', 'remove_admin_stuff', 20, 3);
function remove_admin_stuff( $translated_text, $untranslated_text, $domain ) {
$custom_field_text = 'You are using <span class="b">Wor... |
32,849 | <p>OK, so I've read like 20 different articles about using a while loop inside another while loop, but still can't get this to work, and I'm about to burst from frustration.</p>
<p>My scenario: using the Advanced Custom Fields plugin along with the WP Coda Slider. My goal is to display a small gallery of images (that... | [
{
"answer_id": 32852,
"author": "Jonnybojangles",
"author_id": 2362,
"author_profile": "https://wordpress.stackexchange.com/users/2362",
"pm_score": 1,
"selected": false,
"text": "<p>I would create a custom query for each nested loop and loop on its post data. Similar to what is written... | 2011/11/03 | [
"https://wordpress.stackexchange.com/questions/32849",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9916/"
] | OK, so I've read like 20 different articles about using a while loop inside another while loop, but still can't get this to work, and I'm about to burst from frustration.
My scenario: using the Advanced Custom Fields plugin along with the WP Coda Slider. My goal is to display a small gallery of images (that are loaded... | I would create a custom query for each nested loop and loop on its post data. Similar to what is written about [here](http://css-tricks.com/snippets/wordpress/custom-loop-based-on-custom-fields/).
You will probably need to save the post global to a temporary variable so it can be set back ( setup\_postdata() ) at the ... |
32,854 | <p>I am developing a plug-in which stores data in a custom table and is joined onto the <code>wp_posts</code> by the post's the id. I then use the <code>posts_join</code> and <code>post_fields</code> filters to join my table and be able retrieve data from it. For example:</p>
<pre><code> add_filter('posts_join', 'm... | [
{
"answer_id": 32852,
"author": "Jonnybojangles",
"author_id": 2362,
"author_profile": "https://wordpress.stackexchange.com/users/2362",
"pm_score": 1,
"selected": false,
"text": "<p>I would create a custom query for each nested loop and loop on its post data. Similar to what is written... | 2011/11/03 | [
"https://wordpress.stackexchange.com/questions/32854",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9364/"
] | I am developing a plug-in which stores data in a custom table and is joined onto the `wp_posts` by the post's the id. I then use the `posts_join` and `post_fields` filters to join my table and be able retrieve data from it. For example:
```
add_filter('posts_join', 'my_join' );
function my_join( $join ){
... | I would create a custom query for each nested loop and loop on its post data. Similar to what is written about [here](http://css-tricks.com/snippets/wordpress/custom-loop-based-on-custom-fields/).
You will probably need to save the post global to a temporary variable so it can be set back ( setup\_postdata() ) at the ... |
32,863 | <p>My users post snippets code in comments.
I created a shortcode for this :</p>
<pre><code>function post_codigo($atts,$content=""){
return '<code>'.$content.'</code>';
}
add_shortcode('codigo','post_codigo');
</code></pre>
<p>Problem is that html gets filtered before its wrapped into the code... | [
{
"answer_id": 33070,
"author": "sxalexander",
"author_id": 1992,
"author_profile": "https://wordpress.stackexchange.com/users/1992",
"pm_score": 0,
"selected": false,
"text": "<p>Is your theme using <a href=\"http://codex.wordpress.org/Function_Reference/comment_text\" rel=\"nofollow\">... | 2011/11/04 | [
"https://wordpress.stackexchange.com/questions/32863",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4130/"
] | My users post snippets code in comments.
I created a shortcode for this :
```
function post_codigo($atts,$content=""){
return '<code>'.$content.'</code>';
}
add_shortcode('codigo','post_codigo');
```
Problem is that html gets filtered before its wrapped into the code tags.
I think that if i can get the ... | You can filter the array **$no\_texturize\_shortcodes**, which is a collection of shortcodes that are excluded from wptexturize. If you do this, everything within `[codigo]` shortcode tags will not be texturized:
```
add_filter( 'no_texturize_shortcodes', 'no_texturize_codigo_shortcode' );
function no_texturize_codig... |
32,870 | <p>I have a function wp_handle_upload() for uploads files. </p>
<pre><code>$file = $_FILES['attachment_icon-' . $i];
$upload = wp_handle_upload($file, array('test_form' => false));
</code></pre>
<p>what is a function for delete a uploaded file?</p>
| [
{
"answer_id": 38228,
"author": "Matanya",
"author_id": 11793,
"author_profile": "https://wordpress.stackexchange.com/users/11793",
"pm_score": 2,
"selected": false,
"text": "<p>there is no designated WP function, simply because you already have a PHP one, with the following syntax:</p>\... | 2011/11/04 | [
"https://wordpress.stackexchange.com/questions/32870",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9983/"
] | I have a function wp\_handle\_upload() for uploads files.
```
$file = $_FILES['attachment_icon-' . $i];
$upload = wp_handle_upload($file, array('test_form' => false));
```
what is a function for delete a uploaded file? | Use `wp_delete_attachment( $post_id )` if you have used `wp_insert_attachment()` before.
`$post_id` is the attachment ID.
If you haven’t used `wp_insert_attachment()` a simple …
```
unlink( $upload['file'] );
```
… will do it. |
32,871 | <p>I have a WordPress option that stores some data, like:</p>
<pre><code><h1>Header</h1>
<p>Paragraph</p>
[shortcodesomething/]
[shortcode]Contents[/shortcode]
</code></pre>
<p>I'm displaying this option's value using <code>echo get_option('my_option'));</code>.</p>
<p>Of course the shortcode... | [
{
"answer_id": 32873,
"author": "Rutwick Gangurde",
"author_id": 4740,
"author_profile": "https://wordpress.stackexchange.com/users/4740",
"pm_score": 0,
"selected": false,
"text": "<p>Store only the <code>Contents</code> (or whatever you want the shortcode to be applied to), don't store... | 2011/11/04 | [
"https://wordpress.stackexchange.com/questions/32871",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1869/"
] | I have a WordPress option that stores some data, like:
```
<h1>Header</h1>
<p>Paragraph</p>
[shortcodesomething/]
[shortcode]Contents[/shortcode]
```
I'm displaying this option's value using `echo get_option('my_option'));`.
Of course the shortcodes doesn't work, and I'm wondering how to force them to do what they ... | Well, as Christopher Davis mentioned - do\_shortcode works fine with extra stuff included, so I decided to reset my server and `echo do_shortcode(get_option('my_option'));` started to work perfectly.
So I guess the answer has always been here, execute shortcodes with `do_shortcode`. |
32,876 | <p>I am trying to display a dropdown select metabox on the "add new" page of a custom post type which displays a drop down list of titles from a separate custom post type ( it's an effort to relate the two CPT's together - one being "clients" and the other being "projects" so that when creating a new project one would ... | [
{
"answer_id": 32910,
"author": "Kevin Langley Jr.",
"author_id": 9968,
"author_profile": "https://wordpress.stackexchange.com/users/9968",
"pm_score": 2,
"selected": true,
"text": "<p>What I would do is just create a custom taxonomy type to share between both custom post types that are ... | 2011/11/04 | [
"https://wordpress.stackexchange.com/questions/32876",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6169/"
] | I am trying to display a dropdown select metabox on the "add new" page of a custom post type which displays a drop down list of titles from a separate custom post type ( it's an effort to relate the two CPT's together - one being "clients" and the other being "projects" so that when creating a new project one would be ... | What I would do is just create a custom taxonomy type to share between both custom post types that are dynamically created when a new post of the Clients type is created with the same title, then you can associate them without any custom meta handling. |
32,885 | <p>The question is simple.<br>
Imagine that I have a post named 'Single Post' which is inside the category 'sub-cat' which is a child of 'parent-cat' which is a child of 'super-cat'.
What I need to do is to display all the related categories within the post page in the following order: </p>
<pre><code>super-cat > ... | [
{
"answer_id": 32900,
"author": "Dominic",
"author_id": 9905,
"author_profile": "https://wordpress.stackexchange.com/users/9905",
"pm_score": 3,
"selected": true,
"text": "<pre><code><?php \n the_category( ' > ', 'multiple', $post->ID); \n echo ' > ';\n the_title();\... | 2011/11/04 | [
"https://wordpress.stackexchange.com/questions/32885",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7410/"
] | The question is simple.
Imagine that I have a post named 'Single Post' which is inside the category 'sub-cat' which is a child of 'parent-cat' which is a child of 'super-cat'.
What I need to do is to display all the related categories within the post page in the following order:
```
super-cat > parent-cat > sub-ca... | ```
<?php
the_category( ' > ', 'multiple', $post->ID);
echo ' > ';
the_title();
?>
```
This works correctly when the post is in just one category. But if it's in multiple categories, or if the category parents are also selected — in your case, if the post is also in super-cat and parent-cat — then it d... |
32,889 | <p>I have the following custom post type</p>
<pre><code> register_post_type('cp_clients', array(
'labels' => array(
'name' => __('Clients'),
'singular_name' => __('Client')
),
'public' => true,
'has_archive' => true,
... | [
{
"answer_id": 32897,
"author": "Dominic",
"author_id": 9905,
"author_profile": "https://wordpress.stackexchange.com/users/9905",
"pm_score": 0,
"selected": false,
"text": "<p>I'm not sure I understand your question.</p>\n\n<p>I've used this <a href=\"http://wordpress.org/extend/plugins/... | 2011/11/04 | [
"https://wordpress.stackexchange.com/questions/32889",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2167/"
] | I have the following custom post type
```
register_post_type('cp_clients', array(
'labels' => array(
'name' => __('Clients'),
'singular_name' => __('Client')
),
'public' => true,
'has_archive' => true,
'supports' => arr... | I don't think you need a redirect. You are missing the rewrite rule for your custom post type.
```
register_post_type('cp_clients', array(
'labels' => array(
'name' => __('Clients'),
'singular_name' => __('Client')
),
'public' => true,
'has_archive' => true,
'supports' => array('thu... |
32,902 | <p>I’m working on a member page where I use a custom post type with a custom taxonomy. My custom post type is called <code>member</code> and my custom taxonomy is called <code>member_groups</code>.</p>
<p>I want to list all the members but group them together into their respective groups.</p>
<p>So to be clear, I’ve ... | [
{
"answer_id": 32904,
"author": "Mestika",
"author_id": 6751,
"author_profile": "https://wordpress.stackexchange.com/users/6751",
"pm_score": 3,
"selected": false,
"text": "<p>I found a solution by using a custom query and then grouping it with the term name:</p>\n\n<pre><code>SELECT * \... | 2011/11/04 | [
"https://wordpress.stackexchange.com/questions/32902",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6751/"
] | I’m working on a member page where I use a custom post type with a custom taxonomy. My custom post type is called `member` and my custom taxonomy is called `member_groups`.
I want to list all the members but group them together into their respective groups.
So to be clear, I’ve 35 members divided into 9 groups – so i... | So, you might consider automating the multiple queries.
First, get the list of terms in your custom taxonomy, using [`get_terms()`](http://codex.wordpress.org/Function_Reference/get_terms):
```
<?php
$member_group_terms = get_terms( 'member_group' );
?>
```
Then, loop through each one, running a new query each time... |
32,908 | <h2>Background</h2>
<p>i have a website running on wordpress and all its files are located in public_html of my host. Within it i created a sub domain "phantomomaga" and redirected an other domain to that sub domain to make it "www.phantomomaga.tk" instead of "phantomomaga.my-domain.com" for this i added some code to ... | [
{
"answer_id": 32920,
"author": "v0idless",
"author_id": 6228,
"author_profile": "https://wordpress.stackexchange.com/users/6228",
"pm_score": 0,
"selected": false,
"text": "<p>Try this: <a href=\"http://wordpress.org/extend/plugins/tantan-s3/\" rel=\"nofollow\">http://wordpress.org/exte... | 2011/11/04 | [
"https://wordpress.stackexchange.com/questions/32908",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9796/"
] | Background
----------
i have a website running on wordpress and all its files are located in public\_html of my host. Within it i created a sub domain "phantomomaga" and redirected an other domain to that sub domain to make it "www.phantomomaga.tk" instead of "phantomomaga.my-domain.com" for this i added some code to ... | I had this same requirement: my VPS lacked disk space, but I still wanted to manage photos with WordPress. tantan-s3 did not suffice, since a copy of every photo is stored locally.
It's possible to abstract file storage using PHP stream wrappers, but a couple pieces of core WordPress are incompatible. So that's the sh... |
32,930 | <p>I'm working on creating a notification that will indicate when a post is less than a few days old. This is specifically for a custom post type called "news". Is there a way to use <code>global $post;</code> with custom post types?</p>
<p>This is my original code.</p>
<pre><code><?php global $post;
$postdate... | [
{
"answer_id": 32956,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 1,
"selected": false,
"text": "<p>How about this? (Add to your theme's functions.php file, or to a plugin.)</p>\n\n<pre><code>function new_pos... | 2011/11/04 | [
"https://wordpress.stackexchange.com/questions/32930",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3296/"
] | I'm working on creating a notification that will indicate when a post is less than a few days old. This is specifically for a custom post type called "news". Is there a way to use `global $post;` with custom post types?
This is my original code.
```
<?php global $post;
$postdate = str_replace("-", " ",substr($pos... | How about this? (Add to your theme's functions.php file, or to a plugin.)
```
function new_post_alert() {
global $post;
$ageunix = get_the_time( 'U' );
$days_old_in_seconds = time() - $ageunix;
$days_old = $days_old_in_seconds / 86400;
$post_type = get_post_type();
if ( ( $days_old < 3 ) && ( ... |
32,934 | <p>I´m trying to create the following URL structure:</p>
<pre><code>example.com/attractions <-- post type archive
example.com/attractions/taxonomy_term <-- taxonomy archive
example.com/attractions/van-gogh-museum <-- custom post type
</code></pre>
<p>Unfortunately this isn´t pos... | [
{
"answer_id": 32956,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 1,
"selected": false,
"text": "<p>How about this? (Add to your theme's functions.php file, or to a plugin.)</p>\n\n<pre><code>function new_pos... | 2011/11/04 | [
"https://wordpress.stackexchange.com/questions/32934",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7584/"
] | I´m trying to create the following URL structure:
```
example.com/attractions <-- post type archive
example.com/attractions/taxonomy_term <-- taxonomy archive
example.com/attractions/van-gogh-museum <-- custom post type
```
Unfortunately this isn´t possible by default: WordPress needs t... | How about this? (Add to your theme's functions.php file, or to a plugin.)
```
function new_post_alert() {
global $post;
$ageunix = get_the_time( 'U' );
$days_old_in_seconds = time() - $ageunix;
$days_old = $days_old_in_seconds / 86400;
$post_type = get_post_type();
if ( ( $days_old < 3 ) && ( ... |
32,957 | <p><a href="http://www.vooshthemes.com/blog/wordpress-tip/create-a-professional-portfolio-using-wordpress-3-0-custom-post-types/" rel="nofollow">http://www.vooshthemes.com/blog/wordpress-tip/create-a-professional-portfolio-using-wordpress-3-0-custom-post-types/</a></p>
<p>I'm using the above tutorial to build custom p... | [
{
"answer_id": 32956,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 1,
"selected": false,
"text": "<p>How about this? (Add to your theme's functions.php file, or to a plugin.)</p>\n\n<pre><code>function new_pos... | 2011/11/05 | [
"https://wordpress.stackexchange.com/questions/32957",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5205/"
] | <http://www.vooshthemes.com/blog/wordpress-tip/create-a-professional-portfolio-using-wordpress-3-0-custom-post-types/>
I'm using the above tutorial to build custom portfolio pages. The custom portfolio pages are working... but I can't figure out how to display the Website URL I enter in my custom post meta field (webs... | How about this? (Add to your theme's functions.php file, or to a plugin.)
```
function new_post_alert() {
global $post;
$ageunix = get_the_time( 'U' );
$days_old_in_seconds = time() - $ageunix;
$days_old = $days_old_in_seconds / 86400;
$post_type = get_post_type();
if ( ( $days_old < 3 ) && ( ... |
32,966 | <p>I want to get the list of categories of a post inside the loop. Normally, I would use</p>
<pre><code>the_category(', ');
</code></pre>
<p>But this does output a link, and I only want the category name.
Any ideas?</p>
| [
{
"answer_id": 32968,
"author": "Sagive",
"author_id": 7990,
"author_profile": "https://wordpress.stackexchange.com/users/7990",
"pm_score": 3,
"selected": true,
"text": "<p>Should be easy enough i think..</p>\n\n<pre><code><?php \nforeach((get_the_category()) as $category) { \n //... | 2011/11/05 | [
"https://wordpress.stackexchange.com/questions/32966",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2167/"
] | I want to get the list of categories of a post inside the loop. Normally, I would use
```
the_category(', ');
```
But this does output a link, and I only want the category name.
Any ideas? | Should be easy enough i think..
```
<?php
foreach((get_the_category()) as $category) {
//this would print cat names.. You can arrange in list or whatever you want..
echo '<span>'.$category->cat_name .'</span>';
}
?>
```
.
Hope This Helps ;) |
32,975 | <p>I want to create a entirely new top level menu in the admin menu section, and have that be an external link, is this even possible with the current system?</p>
<p>The solution that t31os provides in this thread works if you put the link as a submenu under, for example, the dashboard. But this is not what I want to ... | [
{
"answer_id": 32987,
"author": "t31os",
"author_id": 31073,
"author_profile": "https://wordpress.stackexchange.com/users/31073",
"pm_score": 3,
"selected": true,
"text": "<p>Just add your custom item into <code>$menu</code> instead of <code>$submenu</code>.</p>\n\n<p>Use here as a refer... | 2011/11/05 | [
"https://wordpress.stackexchange.com/questions/32975",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2830/"
] | I want to create a entirely new top level menu in the admin menu section, and have that be an external link, is this even possible with the current system?
The solution that t31os provides in this thread works if you put the link as a submenu under, for example, the dashboard. But this is not what I want to do.
[Addi... | Just add your custom item into `$menu` instead of `$submenu`.
Use here as a reference for parent menu structure.
<http://core.trac.wordpress.org/browser/tags/3.2.1/wp-admin/menu.php>
Eg.
```
add_action( 'admin_menu' , 'admin_menu_wpse32975' );
function admin_menu_wpse32975() {
global $menu;
$menu[9999] = ... |
32,992 | <p>I'm trying to build a query that lists posts of a custom type with specific custom field values. Then I need to list children of each of those posts within the post, and those children also need to be filtered by specific custom field values.</p>
<p>Here's my current code, which isn't working. Any help would be gre... | [
{
"answer_id": 32993,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>Your inner query is overwriting the outer, you've assigned both to <code>$the_query</code>.</p>\n"
},
{
"ans... | 2011/11/05 | [
"https://wordpress.stackexchange.com/questions/32992",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10036/"
] | I'm trying to build a query that lists posts of a custom type with specific custom field values. Then I need to list children of each of those posts within the post, and those children also need to be filtered by specific custom field values.
Here's my current code, which isn't working. Any help would be greatly appre... | Your inner query is overwriting the outer, you've assigned both to `$the_query`. |
33,008 | <p>I know I can add a script file to the footer of wordpress that requires jquery using this code:</p>
<pre><code><?php
function my_scripts_method() {
// register your script location, dependencies and version
wp_register_script('custom_script',
get_template_directory_uri() . '/js/custom_script.js',
... | [
{
"answer_id": 33016,
"author": "Rutwick Gangurde",
"author_id": 4740,
"author_profile": "https://wordpress.stackexchange.com/users/4740",
"pm_score": -1,
"selected": false,
"text": "<p>You can use the <code>wp_footer</code> action for doing this. Check the codex for <a href=\"http://cod... | 2011/11/06 | [
"https://wordpress.stackexchange.com/questions/33008",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7781/"
] | I know I can add a script file to the footer of wordpress that requires jquery using this code:
```
<?php
function my_scripts_method() {
// register your script location, dependencies and version
wp_register_script('custom_script',
get_template_directory_uri() . '/js/custom_script.js',
array('jquer... | The easiest way to do this is actually a combination of `wp_enqueue_script` and the footer actions that Saif and v0idless already referenced. I frequently use jQuery in my themes and plugins, but I put all of the other scripts in the footer as well.
The best way to actually queue things up would be this:
```
function... |
33,017 | <p>I have a Custom Post Type "empresa" and would like to send email when a post type is deleted (moved to trash).</p>
<p>I have this function below for my POSTS, How can I use with my Post Type "empresa"?</p>
<pre><code>add_action("trash_post", "my_awesome_publication_notification");
function my_awesome_publication_n... | [
{
"answer_id": 46898,
"author": "codekipple",
"author_id": 14557,
"author_profile": "https://wordpress.stackexchange.com/users/14557",
"pm_score": 1,
"selected": false,
"text": "<p>For any future readers it seems the hook has now changed from 'trash_post' to 'wp_trash_post' <a href=\"htt... | 2011/11/06 | [
"https://wordpress.stackexchange.com/questions/33017",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10043/"
] | I have a Custom Post Type "empresa" and would like to send email when a post type is deleted (moved to trash).
I have this function below for my POSTS, How can I use with my Post Type "empresa"?
```
add_action("trash_post", "my_awesome_publication_notification");
function my_awesome_publication_notification($post_id)... | Use wp\_trash\_post instead, and keep in mind {post\_status}\_{post\_type} so originally it should have been trash\_empresa not trash\_post, try wp\_trash\_empresa too |
33,022 | <p>How are rewrite rules applied in WordPress? I don't see any rules in the .htaccess file...</p>
<p>For example, if I set the address URL to www.example.com, then calls to example.com will 301 redirect to www.example.com, but I don't see any rule for that in the .htaccess:</p>
<pre><code># BEGIN WordPress
<IfModu... | [
{
"answer_id": 33027,
"author": "Sagive",
"author_id": 7990,
"author_profile": "https://wordpress.stackexchange.com/users/7990",
"pm_score": 0,
"selected": false,
"text": "<p><strong>When Your index.php is loaded wordpress askes for your \"website url\"<br>\nThat adress is preDefined in ... | 2011/11/06 | [
"https://wordpress.stackexchange.com/questions/33022",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4197/"
] | How are rewrite rules applied in WordPress? I don't see any rules in the .htaccess file...
For example, if I set the address URL to www.example.com, then calls to example.com will 301 redirect to www.example.com, but I don't see any rule for that in the .htaccess:
```
# BEGIN WordPress
<IfModule mod_rewrite.c>
Rewrit... | `index.php` acts as a router. All requests are sent through index.php which looks up the rules in the database and directs you to the correct location. [This](http://bit.ly/rRe3Y6) should give you an idea of how a PHP router works. The `.htaccess` just removes index.php from the URL. More rules can be created using the... |
33,033 | <p>This is my home page code </p>
<p>here is a feature post section,
i want to exclude post by a category 'Collage' in this section ... </p>
<pre><code><?php
$count = 1;
if (have_posts()) : while (have_posts()) : the_post(); if($count == 1) : ?>
<div id="featurd_post">
<div class="ftrd_image">
&l... | [
{
"answer_id": 33036,
"author": "magicroundabout",
"author_id": 10046,
"author_profile": "https://wordpress.stackexchange.com/users/10046",
"pm_score": 1,
"selected": false,
"text": "<p>To exclude a category you'll need to modify the query that's running. Do this using the query_posts()... | 2011/11/06 | [
"https://wordpress.stackexchange.com/questions/33033",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8503/"
] | This is my home page code
here is a feature post section,
i want to exclude post by a category 'Collage' in this section ...
```
<?php
$count = 1;
if (have_posts()) : while (have_posts()) : the_post(); if($count == 1) : ?>
<div id="featurd_post">
<div class="ftrd_image">
<?php woo_get_image('image',455,245,' '.$G... | To exclude a category you'll need to modify the query that's running. Do this using the query\_posts() function: <http://codex.wordpress.org/Function_Reference/query_posts>
First, you'll need to get the ID of the category you want to exclude:
```
$exclude_category = get_term_by('name', 'collage', 'category');
```
T... |
33,039 | <p>I would like to remove "leave a reply" in the comment form in twenty eleven. How can I do this? Thanks in advance.</p>
| [
{
"answer_id": 33044,
"author": "Michael",
"author_id": 4884,
"author_profile": "https://wordpress.stackexchange.com/users/4884",
"pm_score": 2,
"selected": false,
"text": "<p>edit comments.php, \nand find:\n<code>comment_form()</code>;</p>\n\n<p>edit to:\n<code>comment_form(array('title... | 2011/11/06 | [
"https://wordpress.stackexchange.com/questions/33039",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10047/"
] | I would like to remove "leave a reply" in the comment form in twenty eleven. How can I do this? Thanks in advance. | You can filter the default `comment_form` arguments (which is what's causing the "leave a reply").
Just drop this in `functions.php` or in a plugin file. It would probably be better to put it in a plugin and keep your twenty eleven theme unedited (read: easily updated).
```
<?php
add_filter( 'comment_form_defaults', ... |
33,043 | <p>I have a PHP page at the same level as the template/theme on WordPress.
I need to be able to get the current logged in user details from this page.</p>
<p>I have tried this:</p>
<pre><code>require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );
global $current_user;
$current_user = wp_get_current_user();
var_... | [
{
"answer_id": 33052,
"author": "Sagive",
"author_id": 7990,
"author_profile": "https://wordpress.stackexchange.com/users/7990",
"pm_score": 2,
"selected": false,
"text": "<p>You can...</p>\n\n<p><strong>Load the file into the file where you want to display the 'hey username' message:</s... | 2011/11/06 | [
"https://wordpress.stackexchange.com/questions/33043",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5591/"
] | I have a PHP page at the same level as the template/theme on WordPress.
I need to be able to get the current logged in user details from this page.
I have tried this:
```
require_once( $_SERVER['DOCUMENT_ROOT'] . '/wp-load.php' );
global $current_user;
$current_user = wp_get_current_user();
var_dump( $current_user )... | You can...
**Load the file into the file where you want to display the 'hey username' message:**
```
<?php include(TEMPLATEPATH .'/check-user-hello.php'); ?>
```
.
Then in that file "check-user-hello.php"
You need to put this code
```
<?php
if ( is_user_logged_in() ) {
global $current_user;
get_currentuseri... |
33,056 | <p>I upgraded to Wordpress 3.2 and my server from php4 to php5 and now my site outputs this error; </p>
<p><strong>Warning: getimagesize() [function.getimagesize]: URL file-access is disabled in the server configuration in /homepages/35/d289582498/htdocs/wp-content/themes/NovatorixFullArchive_Version1.4/novatorix/inde... | [
{
"answer_id": 33052,
"author": "Sagive",
"author_id": 7990,
"author_profile": "https://wordpress.stackexchange.com/users/7990",
"pm_score": 2,
"selected": false,
"text": "<p>You can...</p>\n\n<p><strong>Load the file into the file where you want to display the 'hey username' message:</s... | 2011/11/07 | [
"https://wordpress.stackexchange.com/questions/33056",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9594/"
] | I upgraded to Wordpress 3.2 and my server from php4 to php5 and now my site outputs this error;
**Warning: getimagesize() [function.getimagesize]: URL file-access is disabled in the server configuration in /homepages/35/d289582498/htdocs/wp-content/themes/NovatorixFullArchive\_Version1.4/novatorix/index.php on line 9... | You can...
**Load the file into the file where you want to display the 'hey username' message:**
```
<?php include(TEMPLATEPATH .'/check-user-hello.php'); ?>
```
.
Then in that file "check-user-hello.php"
You need to put this code
```
<?php
if ( is_user_logged_in() ) {
global $current_user;
get_currentuseri... |
33,063 | <p>Im wondering if there is a way to change the default position of Wordpresses meta boxes such as "featured image" for custom post types without having to drag them manually?</p>
<p><strong>Example:</strong>
<img src="https://i.stack.imgur.com/SXwOO.jpg" alt="Meta Box Positioning Example"></p>
| [
{
"answer_id": 33065,
"author": "anmari",
"author_id": 3569,
"author_profile": "https://wordpress.stackexchange.com/users/3569",
"pm_score": 3,
"selected": false,
"text": "<p>I struggled with this too. I didn't really find a clean way to redefine the layout/order - particularly since it... | 2011/11/07 | [
"https://wordpress.stackexchange.com/questions/33063",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3567/"
] | Im wondering if there is a way to change the default position of Wordpresses meta boxes such as "featured image" for custom post types without having to drag them manually?
**Example:**
 | You can remove the default meta boxes with remove\_meta\_box and re-add them in a different position with add\_meta\_box:
```
add_action('do_meta_boxes', 'wpse33063_move_meta_box');
function wpse33063_move_meta_box(){
remove_meta_box( 'postimagediv', 'post', 'side' );
add_meta_box('postimagediv', __('Featured... |
33,064 | <p>This function seems like it should work, and it mostly does, but what I'm lacking are the values for the 'author' key that ends the list item, prefaced by the text 'By'.</p>
<p>What I'd like is for the function to loop through the taxonomy and return all the custom posts that are ascribed to it, and for each post I... | [
{
"answer_id": 33066,
"author": "anmari",
"author_id": 3569,
"author_profile": "https://wordpress.stackexchange.com/users/3569",
"pm_score": 0,
"selected": false,
"text": "<p>Well make it easy for yourself,\nuse the wordpress function</p>\n\n<p><a href=\"http://codex.wordpress.org/Functi... | 2011/11/07 | [
"https://wordpress.stackexchange.com/questions/33064",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10057/"
] | This function seems like it should work, and it mostly does, but what I'm lacking are the values for the 'author' key that ends the list item, prefaced by the text 'By'.
What I'd like is for the function to loop through the taxonomy and return all the custom posts that are ascribed to it, and for each post I'd like to... | Your query should work if you call `global $post` and don't reset the query (not needed when using WP\_Query).
You can also try using `tax_query`.
```
$tax = 'issue';
$terms = get_terms( $tax );
foreach ( $terms as $term ) :
echo $term->name;
$args = array(
'post_type' => $post_type,
'post_per_page' =>... |
33,072 | <p>I want to completely remove feeds from WordPress. I am using this little function from <a href="http://wpengineer.com/287/disable-wordpress-feed/">http://wpengineer.com/287/disable-wordpress-feed/</a> </p>
<pre><code>/**
* disable feed
*/
function fb_disable_feed() {
wp_die( __('No feed available,please visit our &... | [
{
"answer_id": 47074,
"author": "fregante",
"author_id": 1861,
"author_profile": "https://wordpress.stackexchange.com/users/1861",
"pm_score": 0,
"selected": false,
"text": "<p>This should do it</p>\n\n<pre><code>/*disable rss*/\nremove_action('wp_head', 'feed_links', 2 );\nadd_filter('p... | 2011/11/07 | [
"https://wordpress.stackexchange.com/questions/33072",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1372/"
] | I want to completely remove feeds from WordPress. I am using this little function from <http://wpengineer.com/287/disable-wordpress-feed/>
```
/**
* disable feed
*/
function fb_disable_feed() {
wp_die( __('No feed available,please visit our <a href="'. get_bloginfo('url') .'">homepage</a>!') );
}
add_action('do_feed'... | First step: remove the feed links from the section of your site.
```
<?php
add_action( 'wp_head', 'wpse33072_wp_head', 1 );
/**
* Remove feed links from wp_head
*/
function wpse33072_wp_head()
{
remove_action( 'wp_head', 'feed_links', 2 );
remove_action( 'wp_head', 'feed_links_extra', 3 );
}
```
Next up, l... |
33,086 | <p>Just wondering what the preferred method of using anonymous functions is.</p>
<p>First I had some code like this:</p>
<pre><code>function page_columns( $columns ) {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => 'Title',
'author' => 'Author',
't... | [
{
"answer_id": 33088,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 1,
"selected": false,
"text": "<p>Use the second option. Adding anonymous functions as filters and actions is <strong><em>highly discouraged!!!</em></... | 2011/11/07 | [
"https://wordpress.stackexchange.com/questions/33086",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7230/"
] | Just wondering what the preferred method of using anonymous functions is.
First I had some code like this:
```
function page_columns( $columns ) {
$columns = array(
'cb' => '<input type="checkbox" />',
'title' => 'Title',
'author' => 'Author',
'template' => 'Template',
'dat... | Use the second option. Adding anonymous functions as filters and actions is ***highly discouraged!!!***
If you add an anonymous function in this fashion, it's impossible to remove later on down the road by other plugins and code. So please, *please*, ***please*** don't do that. |
33,092 | <p>This issue has plagued me over a couple projects. I used the default Wordpress class-based template provided in the Codex to start, and built outward. The only issue I face is that my custom meta boxes will not show when creating a new post (add post). This is usually in conjunction with custom post types, but as th... | [
{
"answer_id": 33102,
"author": "Jared",
"author_id": 2415,
"author_profile": "https://wordpress.stackexchange.com/users/2415",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n <p><strong>Edit:</strong> I was wrong, admin_menu is not what you need. However after researching, I ... | 2011/11/07 | [
"https://wordpress.stackexchange.com/questions/33092",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6348/"
] | This issue has plagued me over a couple projects. I used the default Wordpress class-based template provided in the Codex to start, and built outward. The only issue I face is that my custom meta boxes will not show when creating a new post (add post). This is usually in conjunction with custom post types, but as the c... | I would create the instance of the class on init or even admin\_init and not on 'load-post.php'.
Hooking into load-post.php will not add the boxes to NEW posts and only posts that are already saved. The correct hook to add meta boxes to ONLY new posts is 'load-post-new.php'.
If you want to have the meta box display... |
33,099 | <p>Please can someone help me to clarify what issues i might have when the hosting company changes the DNS settings to point away for the current old site (basic html) and to the new WordPress version of the web site?</p>
<p>Both sites are with the same hosting company (I cannot change hosts or hosting names now, my c... | [
{
"answer_id": 33124,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>See <a href=\"http://codex.wordpress.org/Changing_The_Site_URL\" rel=\"nofollow\">Changing Site URL</a> in Codex for... | 2011/11/07 | [
"https://wordpress.stackexchange.com/questions/33099",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10068/"
] | Please can someone help me to clarify what issues i might have when the hosting company changes the DNS settings to point away for the current old site (basic html) and to the new WordPress version of the web site?
Both sites are with the same hosting company (I cannot change hosts or hosting names now, my client and ... | Old question, but for the record:
Provided that you adjust the WP\_HOME and WP\_SITE urls appropriately, the page links should work just fine when you migrate.
An easy way is to add the following lines to your wp-config.php file after uploading the site to therealwebsitename.co.uk:
```
define('WP_HOME','http://examp... |
33,101 | <p>Is it possible to change the page title with code? </p>
<p>For example, let's say the page's name is "Book your Order", but I want to change it to "Book Order #123".</p>
<p>I Google'd a bit and looked here and didn't see anything. Anyone know of a plugin or hack?</p>
<p>wp_title returns the page title but doesn'... | [
{
"answer_id": 33103,
"author": "Jared",
"author_id": 2415,
"author_profile": "https://wordpress.stackexchange.com/users/2415",
"pm_score": 6,
"selected": true,
"text": "<p>There is no documentation on it but you could always apply a filter to <code>the_title</code> like this:</p>\n\n<pr... | 2011/11/07 | [
"https://wordpress.stackexchange.com/questions/33101",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2333/"
] | Is it possible to change the page title with code?
For example, let's say the page's name is "Book your Order", but I want to change it to "Book Order #123".
I Google'd a bit and looked here and didn't see anything. Anyone know of a plugin or hack?
wp\_title returns the page title but doesn't allow setting the page... | There is no documentation on it but you could always apply a filter to `the_title` like this:
```
add_filter('the_title','some_callback');
function some_callback($data){
global $post;
// where $data would be string(#) "current title"
// Example:
// (you would want to change $post->ID to however you are... |
33,106 | <p>I'm trying to use get_posts to only return posts that have an excerpt. Done lots of searching and have been trying to use "posts_where" filter on the query but my SQL is lacking. This is what I'm using which in theory I think should work, but really I have no idea on the sql and can't work out how to print the sql s... | [
{
"answer_id": 33112,
"author": "Sagive",
"author_id": 7990,
"author_profile": "https://wordpress.stackexchange.com/users/7990",
"pm_score": 0,
"selected": false,
"text": "<p>i Might be mistaken but wont a \"check if empty\" condition do the trick?</p>\n\n<pre><code><?php \nquery_post... | 2011/11/07 | [
"https://wordpress.stackexchange.com/questions/33106",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4093/"
] | I'm trying to use get\_posts to only return posts that have an excerpt. Done lots of searching and have been trying to use "posts\_where" filter on the query but my SQL is lacking. This is what I'm using which in theory I think should work, but really I have no idea on the sql and can't work out how to print the sql st... | The `post_excerpt` column is a string and is not filterable using "IS NOT NULL" . To query for an empty string you can use the `!=` operator.
```
function posts_where_excerpt_not_empty( $where ) {
$where .= " AND post_excerpt != '' ";
return $where;
}
```
Also get\_posts suppresses filters by default so you ... |
33,110 | <p>I have a query that pulls custom post types and regular posts, but how could I tell it to offset just one post type in the query?</p>
<p>My query:</p>
<pre><code><?php query_posts( array(
'posts_per_page' => 10,
'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ),
));
?>
</c... | [
{
"answer_id": 33119,
"author": "patnz",
"author_id": 4093,
"author_profile": "https://wordpress.stackexchange.com/users/4093",
"pm_score": 0,
"selected": false,
"text": "<p>Not quite sure what you mean by If 'Post Type' exists but could you do something like:</p>\n\n<pre><code><?php ... | 2011/11/07 | [
"https://wordpress.stackexchange.com/questions/33110",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9920/"
] | I have a query that pulls custom post types and regular posts, but how could I tell it to offset just one post type in the query?
My query:
```
<?php query_posts( array(
'posts_per_page' => 10,
'paged' => ( get_query_var('paged') ? get_query_var('paged') : 1 ),
));
?>
```
But I want it to include:
If ... | What you're trying to do is not going to be able to be done via a single query. Not sure why you want to get all posts of all post types.
But, in order to do what you want, you will have to just have php logic check if it is the first post in that post type and if so, skip it. |
33,113 | <p>Im looking for a way to add a custom meta box to a custom post type that will allow the user/client order the posts to show up how they want on the site. Is this possible? Basically using a very similar functionality to "page attributes"...</p>
| [
{
"answer_id": 33115,
"author": "helenhousandi",
"author_id": 2226,
"author_profile": "https://wordpress.stackexchange.com/users/2226",
"pm_score": 1,
"selected": false,
"text": "<p>Why not have the custom post type be hierarchical and support the page-attributes box?</p>\n"
},
{
... | 2011/11/07 | [
"https://wordpress.stackexchange.com/questions/33113",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3567/"
] | Im looking for a way to add a custom meta box to a custom post type that will allow the user/client order the posts to show up how they want on the site. Is this possible? Basically using a very similar functionality to "page attributes"... | You can add `page-attributes` support to the post type. This will cause a meta box to appear with an "order" field to do just what you want.
eg.
```
<?php
add_post_type_support('your_custom_post_type', 'page-attributes');
```
Or you add `page-attributes`to the `supports` argument in [register\_post\_type](htt... |
33,116 | <p>I am trying to create a template for a custom page type that will put the same data on every page of this type. The only problem is I see examples of custom page types but only using loops. Do I have to use a loop if it is a single page. How will I fill in the data here like title and content.</p>
<pre><code><?p... | [
{
"answer_id": 33115,
"author": "helenhousandi",
"author_id": 2226,
"author_profile": "https://wordpress.stackexchange.com/users/2226",
"pm_score": 1,
"selected": false,
"text": "<p>Why not have the custom post type be hierarchical and support the page-attributes box?</p>\n"
},
{
... | 2011/11/07 | [
"https://wordpress.stackexchange.com/questions/33116",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8039/"
] | I am trying to create a template for a custom page type that will put the same data on every page of this type. The only problem is I see examples of custom page types but only using loops. Do I have to use a loop if it is a single page. How will I fill in the data here like title and content.
```
<?php
/*
Template Na... | You can add `page-attributes` support to the post type. This will cause a meta box to appear with an "order" field to do just what you want.
eg.
```
<?php
add_post_type_support('your_custom_post_type', 'page-attributes');
```
Or you add `page-attributes`to the `supports` argument in [register\_post\_type](htt... |
33,130 | <p>I have a shortcode that just retrieves some info from the options table in the database.</p>
<p>For whatever reason, when the content reaches a certain character limit the_content() to return blank?</p>
<p>The function is pretty basic and I can't for the life me figure out why this is happening?</p>
<p>Here's an ... | [
{
"answer_id": 33337,
"author": "Cole",
"author_id": 4065,
"author_profile": "https://wordpress.stackexchange.com/users/4065",
"pm_score": 2,
"selected": false,
"text": "<p>Fixed my problem! I was finally able to find some info out there in the vast internet. Visit this site for info on ... | 2011/11/07 | [
"https://wordpress.stackexchange.com/questions/33130",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4065/"
] | I have a shortcode that just retrieves some info from the options table in the database.
For whatever reason, when the content reaches a certain character limit the\_content() to return blank?
The function is pretty basic and I can't for the life me figure out why this is happening?
Here's an example of the code:
`... | Fixed my problem! I was finally able to find some info out there in the vast internet. Visit this site for info on fixing this odd issue.
Over all using the `remove_filter('the_content','wpautop');` did the trick.
<http://www.undermyhat.org/blog/2009/07/sudden-empty-blank-page-for-large-posts-with-wordpress/> |
33,132 | <p>After trouble parsing wrapping and non-wrapping shortcodes on the same page, I came across this trac ticket from 3 years ago: <a href="http://core.trac.wordpress.org/ticket/9264" rel="nofollow">http://core.trac.wordpress.org/ticket/9264</a></p>
<p>The trouble is WP cannot properly parse </p>
<pre><code>[myshortcod... | [
{
"answer_id": 33133,
"author": "Sterling Hamilton",
"author_id": 10075,
"author_profile": "https://wordpress.stackexchange.com/users/10075",
"pm_score": 0,
"selected": false,
"text": "<p>As far as I know, you need to leave a single space between multiple shortcodes.</p>\n\n<p>I believe ... | 2011/11/07 | [
"https://wordpress.stackexchange.com/questions/33132",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3564/"
] | After trouble parsing wrapping and non-wrapping shortcodes on the same page, I came across this trac ticket from 3 years ago: <http://core.trac.wordpress.org/ticket/9264>
The trouble is WP cannot properly parse
```
[myshortcode att="bla"] and
[myshortcode]Enclosed content[/myshortcode]
```
on the same page. The ... | According to a new post by mdawaffe on the [trac ticket](http://core.trac.wordpress.org/ticket/9264) referenced in this question:
>
>
> ```
> [test id="1"/] first self closed, now [test id="2"]with content[/test]
> [foo attr/]bar[foo attr/]bar[/foo]
> [test/]
> [test]foobar[/test]
> [test id="1"][/test]
>
> ```
>
... |
33,159 | <p>I wanted to know how could i display only the children of a nav menu. ive tried a couple of things like :</p>
<pre><code>if($post->post_type == "page"){
$postid = $post->ID;
print_r( get_pages(array("child_of" => $postid)) );
}
</code></pre>
<p>But all i get an empty arr... | [
{
"answer_id": 33169,
"author": "Andy James",
"author_id": 9871,
"author_profile": "https://wordpress.stackexchange.com/users/9871",
"pm_score": 0,
"selected": false,
"text": "<p>This really depends on how the menu is setup, but based on the code in your snippet you are using get_pages()... | 2011/11/08 | [
"https://wordpress.stackexchange.com/questions/33159",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10083/"
] | I wanted to know how could i display only the children of a nav menu. ive tried a couple of things like :
```
if($post->post_type == "page"){
$postid = $post->ID;
print_r( get_pages(array("child_of" => $postid)) );
}
```
But all i get an empty array.
so what i want is something li... | Here you have the solution
```
<ul>
<?php
$children = wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0');
$subpages = ($post->post_parent) ? wp_list_pages('title_li=&child_of='.$post->post_parent.'&echo=0') : wp_list_pages('title_li=&child_of='.$post->ID.'&echo=0') ;
if ($children) { ?>
... |
33,173 | <p>I know that plupload is going to be the new upload engine for WordPress 3.3 but I was wondering if there is any documentation yet on how it integrates with WordPress. </p>
<p>My specifically how to collect a response from the <a href="http://www.plupload.com/">plUpload</a> jQuery object once it has uploaded the med... | [
{
"answer_id": 34771,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 5,
"selected": true,
"text": "<blockquote>\n<p>My specifically how to collect a response from the plUpload jQuery object once it has uploaded the media... | 2011/11/08 | [
"https://wordpress.stackexchange.com/questions/33173",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2234/"
] | I know that plupload is going to be the new upload engine for WordPress 3.3 but I was wondering if there is any documentation yet on how it integrates with WordPress.
My specifically how to collect a response from the [plUpload](http://www.plupload.com/) jQuery object once it has uploaded the media that you want and ... | >
> My specifically how to collect a response from the plUpload jQuery object once it has uploaded the media that you want and how one would use the same functionality in a meta box to create a gallery?
>
>
>
There's a specific file that handles this functionality: `/wp-includes/js/plupload/handlers.dev.js`. This ... |
33,175 | <p>I'm creating a template in HTML5. On navigatiom menu i need to implement something like this</p>
<pre><code><nav>
<a href="url1">url1</a>
<a href="url1">url2</a>
<a href="url1">url3</a>
<a href="url1">url4</a>
...
<a href="urln">urln</a>
</n... | [
{
"answer_id": 33182,
"author": "David Gard",
"author_id": 10097,
"author_profile": "https://wordpress.stackexchange.com/users/10097",
"pm_score": 0,
"selected": false,
"text": "<p>I'd suggest using the <code>wp_nav_menu_items</code> filter.</p>\n"
},
{
"answer_id": 87437,
"a... | 2011/11/08 | [
"https://wordpress.stackexchange.com/questions/33175",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10096/"
] | I'm creating a template in HTML5. On navigatiom menu i need to implement something like this
```
<nav>
<a href="url1">url1</a>
<a href="url1">url2</a>
<a href="url1">url3</a>
<a href="url1">url4</a>
...
<a href="urln">urln</a>
</nav>
```
If i use 'wp\_nav\_menu', it prints
```
<div><ul><li><a>
```
when i ne... | Use a custom walker:
```
class WPSE_33175_Simple_Walker extends Walker
{
public function walk( $elements, $max_depth )
{
$list = array ();
foreach ( $elements as $item )
$list[] = "<a href='$item->url'>$item->title</a>";
return join( "\n", $list );
}
}
```
… and then... |
33,194 | <p>I have a Page layout like this</p>
<pre><code>Parent Page
- Sub page 1
-- sub sub 1
-- sub sub 2
-- sub sub 4
- Sub page 2
-- sub sub 1
-- sub sub 2
-- sub sub 4
</code></pre>
<p>I want to query every single child page, regardless of how deep I go. This is my query but it only returns direct children(sub page 1 an... | [
{
"answer_id": 33241,
"author": "b0li",
"author_id": 10038,
"author_profile": "https://wordpress.stackexchange.com/users/10038",
"pm_score": -1,
"selected": false,
"text": "<p>try this</p>\n\n<pre>\nfunction wpse33151_getSubpages() { \n global $post;\n\n $parents = get_post_an... | 2011/11/08 | [
"https://wordpress.stackexchange.com/questions/33194",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9026/"
] | I have a Page layout like this
```
Parent Page
- Sub page 1
-- sub sub 1
-- sub sub 2
-- sub sub 4
- Sub page 2
-- sub sub 1
-- sub sub 2
-- sub sub 4
```
I want to query every single child page, regardless of how deep I go. This is my query but it only returns direct children(sub page 1 and 2)
```
query_posts('pos... | I'm pretty sure you can use `get_pages` (<http://codex.wordpress.org/Function_Reference/get_pages>) function to solve this. It has `child_of` parameter which does exactly what you wanted.
The only problem is that it returns posts and not set `$wp_query`, so you can't use it as loop, but you can always call `setup_post... |
33,197 | <p>I'm using the latest timthumb script to generate my post thumbnails and include them along with the excerpt. Though I only want the thumbnails to load if their files actually exist, otherwise I don't even want the image placeholder to load.</p>
<p>I'm going to be using this on a multi-user network, which is still i... | [
{
"answer_id": 33202,
"author": "Kevin Langley Jr.",
"author_id": 9968,
"author_profile": "https://wordpress.stackexchange.com/users/9968",
"pm_score": 1,
"selected": false,
"text": "<p>The file_exists() function is a built in php function and should work everywhere. But with the way you... | 2011/11/08 | [
"https://wordpress.stackexchange.com/questions/33197",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8482/"
] | I'm using the latest timthumb script to generate my post thumbnails and include them along with the excerpt. Though I only want the thumbnails to load if their files actually exist, otherwise I don't even want the image placeholder to load.
I'm going to be using this on a multi-user network, which is still in the earl... | file\_exists(); and is\_readable(); (which I've decided to go for instead as it detects if the file is readable as well as if it exists) both require the $\_SERVER['DOCUMENT\_ROOT']; variable to be called as the file is physically stored on the file server's HDD and therefore replaces the need to declare the domain nam... |
33,200 | <p>I am trying to add a function in WordPress <code>functions.php</code> where i want to display an image relevant to my theme folder</p>
<p>here is my code which is not working, it only shows the file name but without the correct path.</p>
<pre><code>add_filter (somefilter_code_here);
function mycustom_func($mycusto... | [
{
"answer_id": 33202,
"author": "Kevin Langley Jr.",
"author_id": 9968,
"author_profile": "https://wordpress.stackexchange.com/users/9968",
"pm_score": 1,
"selected": false,
"text": "<p>The file_exists() function is a built in php function and should work everywhere. But with the way you... | 2011/11/08 | [
"https://wordpress.stackexchange.com/questions/33200",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10105/"
] | I am trying to add a function in WordPress `functions.php` where i want to display an image relevant to my theme folder
here is my code which is not working, it only shows the file name but without the correct path.
```
add_filter (somefilter_code_here);
function mycustom_func($mycustom_field ) {
$capimg = bloginfo(... | file\_exists(); and is\_readable(); (which I've decided to go for instead as it detects if the file is readable as well as if it exists) both require the $\_SERVER['DOCUMENT\_ROOT']; variable to be called as the file is physically stored on the file server's HDD and therefore replaces the need to declare the domain nam... |
33,207 | <p>I'm to implement a theme in wordpress.</p>
<p>Is possible modify a output (html) of widget in wordpress?</p>
<blockquote>
<p>For example, the "recent comments widget"?</p>
</blockquote>
| [
{
"answer_id": 33209,
"author": "Kevin Langley Jr.",
"author_id": 9968,
"author_profile": "https://wordpress.stackexchange.com/users/9968",
"pm_score": 0,
"selected": false,
"text": "<p>Yes, you can <em>modify</em> the output of the widget, but not by modifying core files. What I would ... | 2011/11/08 | [
"https://wordpress.stackexchange.com/questions/33207",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9983/"
] | I'm to implement a theme in wordpress.
Is possible modify a output (html) of widget in wordpress?
>
> For example, the "recent comments widget"?
>
>
> | I would copy the widget from the core as needed, put it in the theme or plugin, but you should also unregister the core widget you are replacing.
That can be done like this:
```
// unregister all default WP Widgets
function unregister_default_wp_widgets() {
unregister_widget('WP_Widget_Pages');
unregister_wid... |
33,208 | <p>It just won't insert anything, if I echo it, it will show everything fine, but it won't insert anything in database. The table name is correct. Code -</p>
<pre><code>global $wpdb;
$meta2 = get_post_meta($post->ID, 'customFields', true);
$metas2 = explode(",", $meta2);
foreach ($meta2 as $meta)
{
$wpdb->qu... | [
{
"answer_id": 33214,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>Consider trying with <a href=\"http://codex.wordpress.org/Class_Reference/wpdb#INSERT_rows\" rel=\"nofollow\"><code>... | 2011/11/08 | [
"https://wordpress.stackexchange.com/questions/33208",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9917/"
] | It just won't insert anything, if I echo it, it will show everything fine, but it won't insert anything in database. The table name is correct. Code -
```
global $wpdb;
$meta2 = get_post_meta($post->ID, 'customFields', true);
$metas2 = explode(",", $meta2);
foreach ($meta2 as $meta)
{
$wpdb->query( $wpdb->prepare(... | Consider trying with [`$wpdb->insert()`](http://codex.wordpress.org/Class_Reference/wpdb#INSERT_rows) method instead of raw query. Using of functions/methods is recommended for interacting with database over raw requests, unless absolutely impossible. |
33,217 | <p>Sorry if this has already been asked, but I am attempting to limit a list of tags to one category, in a couple different spots on my web page. I have this code: </p>
<pre><code> <?php
$tags = get_tags();
$tags_count = count($tags);
$percolumn = ceil($tags_count / 3);
for ($i = 0;$i < $tags... | [
{
"answer_id": 33220,
"author": "dmoz",
"author_id": 10110,
"author_profile": "https://wordpress.stackexchange.com/users/10110",
"pm_score": -1,
"selected": false,
"text": "<p>I was trying to do this exact thing a day or two ago. I ended up using the plugin/widget: <a href=\"http://wordp... | 2011/11/08 | [
"https://wordpress.stackexchange.com/questions/33217",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10109/"
] | Sorry if this has already been asked, but I am attempting to limit a list of tags to one category, in a couple different spots on my web page. I have this code:
```
<?php
$tags = get_tags();
$tags_count = count($tags);
$percolumn = ceil($tags_count / 3);
for ($i = 0;$i < $tags_count;$i++):
if... | You can easily do this without a plugin, but you would need to get all the posts with that specific category and then loop through those to get the tags of each of those specific posts. |
33,236 | <p>Have used emember in the past and looked at Tadlock's membership as well as another premium offering by jigowatt. However, I don't want to just hide the post's content.... I want to hide the entire post... and entire categories/taxonomies. </p>
<p>I'd like the menu to show "Products" and when you visit that parti... | [
{
"answer_id": 33237,
"author": "patnz",
"author_id": 4093,
"author_profile": "https://wordpress.stackexchange.com/users/4093",
"pm_score": 1,
"selected": true,
"text": "<p>The best way to have complete control is to use conditionals in your templates. Look at current_user_can() for spec... | 2011/11/08 | [
"https://wordpress.stackexchange.com/questions/33236",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6477/"
] | Have used emember in the past and looked at Tadlock's membership as well as another premium offering by jigowatt. However, I don't want to just hide the post's content.... I want to hide the entire post... and entire categories/taxonomies.
I'd like the menu to show "Products" and when you visit that particular page y... | The best way to have complete control is to use conditionals in your templates. Look at current\_user\_can() for specific permissions - or if its simply for being logged in you could use is\_user\_logged\_in(). eg:
```
if( is_user_logged_in() ){
// echo product details
}else{
//echo login form and message
}
```... |
33,261 | <p>I am working on wordpress which is new to me
Now I have been provided with site completely designed in wp
But the problem is I am unable to search the query for each functionality/page
I found </p>
<pre><code>$wpdb->get_results
</code></pre>
<p>used for getting result from database
also this is not working</... | [
{
"answer_id": 33289,
"author": "David Gard",
"author_id": 10097,
"author_profile": "https://wordpress.stackexchange.com/users/10097",
"pm_score": 0,
"selected": false,
"text": "<p>The global <code>$wp_query</code> contains everything about the current query, including the arguments, res... | 2011/11/09 | [
"https://wordpress.stackexchange.com/questions/33261",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10166/"
] | I am working on wordpress which is new to me
Now I have been provided with site completely designed in wp
But the problem is I am unable to search the query for each functionality/page
I found
```
$wpdb->get_results
```
used for getting result from database
also this is not working
```
$wpdb->queries
```
Is th... | Debug bar is one of the recommended (by WordPress) plugins to install for theme and plugin development. I also use debug-bar-extender: <http://wordpress.org/extend/plugins/debug-bar-extender/> |
33,270 | <p>Hi I tried to display 5 posts titles from a specific category
also show the date, but it won't display the most recent one
that just published, I had to change the recent post date 2 months
so it'd show up .. </p>
<p>I used in_category to filter the post
does in_category work with sql query ??</p>
<p>Thanks !</... | [
{
"answer_id": 33287,
"author": "David Gard",
"author_id": 10097,
"author_profile": "https://wordpress.stackexchange.com/users/10097",
"pm_score": 2,
"selected": true,
"text": "<p>I'd suggest using the <code>WP_Query()</code> class for this one. Hopefully the below will help you -</p>\n\... | 2011/11/09 | [
"https://wordpress.stackexchange.com/questions/33270",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57196/"
] | Hi I tried to display 5 posts titles from a specific category
also show the date, but it won't display the most recent one
that just published, I had to change the recent post date 2 months
so it'd show up ..
I used in\_category to filter the post
does in\_category work with sql query ??
Thanks !
```
<ul id="wor... | I'd suggest using the `WP_Query()` class for this one. Hopefully the below will help you -
```
<?php
$args = array(
'category_name' => 'photography',
'post_status' => 'publish',
'post_type' => 'post',
'posts_per_page' => 5
)
$work_items = new WP_Query($args);
if($work_items->have_posts()) : while($wor... |
33,274 | <p>I have a website that has a main menu(Top-Horizontal) like this:</p>
<pre><code>Main menu
- Home
- About Us
- contact us
</code></pre>
<p>On Home page I have a link to "Company" page like this www.xyz.com/company.</p>
<p>When I am on this company page I want my website to chnage my menu items and use this:</p... | [
{
"answer_id": 33286,
"author": "David Gard",
"author_id": 10097,
"author_profile": "https://wordpress.stackexchange.com/users/10097",
"pm_score": 0,
"selected": false,
"text": "<p>Conditional tags would liekly be the way froward. How are you calling your menu? <code>wp_list_pages()</cod... | 2011/11/09 | [
"https://wordpress.stackexchange.com/questions/33274",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10131/"
] | I have a website that has a main menu(Top-Horizontal) like this:
```
Main menu
- Home
- About Us
- contact us
```
On Home page I have a link to "Company" page like this www.xyz.com/company.
When I am on this company page I want my website to chnage my menu items and use this:
```
Different menu
- Home (same Ho... | You can try it this way. Now we are talking about pages you can set up a separate template for the page that needs a different menu. This where WordPress's newer menu feature is really nice.
First if you are using the newer menu feature of WordPress place this in place of your current menu:
```
<?php wp_nav_menu( arr... |
33,284 | <p>When you have Pages with children, the permalink structure works something like this:</p>
<blockquote>
<p>example.com/parent-page/child-page/</p>
</blockquote>
<p>All well and good. Trying to go to this URL:</p>
<blockquote>
<p>example.com/child-page/</p>
</blockquote>
<p>doesn't work, which is good, and as ... | [
{
"answer_id": 33293,
"author": "David Gard",
"author_id": 10097,
"author_profile": "https://wordpress.stackexchange.com/users/10097",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n<pre><code>example.com/custom-post-type/parent-page-1/child-page/\nexample.com/custom-post-type/... | 2011/11/09 | [
"https://wordpress.stackexchange.com/questions/33284",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10135/"
] | When you have Pages with children, the permalink structure works something like this:
>
> example.com/parent-page/child-page/
>
>
>
All well and good. Trying to go to this URL:
>
> example.com/child-page/
>
>
>
doesn't work, which is good, and as expected - I only want the one URL for my child page.
Howeve... | I have solved the answer to this problem by doing this:
`echo get_permalink( $page->ID );`
This gave me the right links to the pages. |
33,312 | <p>As the title says: How would you translate...</p>
<ul>
<li><code>_n()</code></li>
<li><code>_n_noop()</code></li>
<li><code>_nc()</code></li>
<li><code>_nx()</code></li>
<li><code>_nx_noop()</code></li>
</ul>
<p>...in your .mo files?</p>
| [
{
"answer_id": 33313,
"author": "onetrickpony",
"author_id": 1986,
"author_profile": "https://wordpress.stackexchange.com/users/1986",
"pm_score": 0,
"selected": false,
"text": "<p>You just need to <a href=\"http://translate.sourceforge.net/wiki/l10n/pluralforms\" rel=\"nofollow\">define... | 2011/11/09 | [
"https://wordpress.stackexchange.com/questions/33312",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/385/"
] | As the title says: How would you translate...
* `_n()`
* `_n_noop()`
* `_nc()`
* `_nx()`
* `_nx_noop()`
...in your .mo files? | ### Step 1
Open your file in [PoEdit](http://www.poedit.net/download.php).
### Step 2
Go to "*Catalogue*" » "*Settings*"
### Step 3
Fill in "*Language*" **and** "*Country*" 1).
### Step 4
Fill "*Pluralform*" (last field).
```
// For 2 plural forms
nplurals=2; plural=n != 1;
// For 3 plural forms (for e.g. rus... |
33,318 | <p>Is there a method to force the refresh of <code>editor-style.css</code>, when I change manually the stylesheet for the TinyMCE editor? Modification doesn't show immediately but they will be cached in the admin side of administration backend.</p>
<p>For example like this:</p>
<pre><code>editor-style.css?ver=3393201... | [
{
"answer_id": 59196,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>There is a hook for that: <code>'mce_css'</code>. It is called in <code>_WP_Editors::editor_settings()</code> and you g... | 2011/11/09 | [
"https://wordpress.stackexchange.com/questions/33318",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2727/"
] | Is there a method to force the refresh of `editor-style.css`, when I change manually the stylesheet for the TinyMCE editor? Modification doesn't show immediately but they will be cached in the admin side of administration backend.
For example like this:
```
editor-style.css?ver=3393201
``` | There is a hook for that: `'mce_css'`. It is called in `_WP_Editors::editor_settings()` and you get all loaded stylesheets comma separated as the first and only parameter.
Now it is easy: Use the global variable `$editor_styles` (here are your theme’s and parent theme’s editor stylesheets stored already), add the time... |
33,319 | <p>This makes no sense, but in looking at my view source across browsers, <code>wp_localize_script()</code> is inserting tags as expected for all browsers other than IE7,8,9. The script tag is simply not there in those browsers. I have it bound to "jquery", since I want to make sure it's included no matter what (rathe... | [
{
"answer_id": 33323,
"author": "David Gard",
"author_id": 10097,
"author_profile": "https://wordpress.stackexchange.com/users/10097",
"pm_score": 1,
"selected": false,
"text": "<p>I do it this way and it works fine. Make sure you don't have jQuery defined anywhere else on your site (lik... | 2011/11/09 | [
"https://wordpress.stackexchange.com/questions/33319",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3687/"
] | This makes no sense, but in looking at my view source across browsers, `wp_localize_script()` is inserting tags as expected for all browsers other than IE7,8,9. The script tag is simply not there in those browsers. I have it bound to "jquery", since I want to make sure it's included no matter what (rather than binding ... | I do it this way and it works fine. Make sure you don't have jQuery defined anywhere else on your site (like manually in the header), as some browsers don't like that.
```
/**
* Load assets on initiation
*/
add_action('init', 'load_assets');
function load_assets(){
wp_enqueue_scripts('jquery');
}
``` |
33,324 | <p>I want to check the if the first letter of a field is capitalized.</p>
<p>Example:</p>
<p>If (First Name field) is capitalized {</p>
<p>Capitalized!</p>
<p>} else {</p>
<p>Not Capitalized!</p>
<p>}</p>
<p>Thanks</p>
<p>Thank you</p>
| [
{
"answer_id": 33323,
"author": "David Gard",
"author_id": 10097,
"author_profile": "https://wordpress.stackexchange.com/users/10097",
"pm_score": 1,
"selected": false,
"text": "<p>I do it this way and it works fine. Make sure you don't have jQuery defined anywhere else on your site (lik... | 2011/11/09 | [
"https://wordpress.stackexchange.com/questions/33324",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1893/"
] | I want to check the if the first letter of a field is capitalized.
Example:
If (First Name field) is capitalized {
Capitalized!
} else {
Not Capitalized!
}
Thanks
Thank you | I do it this way and it works fine. Make sure you don't have jQuery defined anywhere else on your site (like manually in the header), as some browsers don't like that.
```
/**
* Load assets on initiation
*/
add_action('init', 'load_assets');
function load_assets(){
wp_enqueue_scripts('jquery');
}
``` |
33,334 | <p>I have two sites (<a href="http://towermix.com" rel="nofollow">towermix.com</a> and <a href="http://beta.towermix.com" rel="nofollow">beta.towermix.com</a>) running BuddyPress and both are doing the same thing. When a site admin (or contributor or author) logs in using the WordPress login page, they are redirected ... | [
{
"answer_id": 34547,
"author": "Norcross",
"author_id": 403,
"author_profile": "https://wordpress.stackexchange.com/users/403",
"pm_score": 0,
"selected": false,
"text": "<p>That is built-in to BuddyPress, the idea being that the majority of users aren't supposed to be in the admin pane... | 2011/11/09 | [
"https://wordpress.stackexchange.com/questions/33334",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6064/"
] | I have two sites ([towermix.com](http://towermix.com) and [beta.towermix.com](http://beta.towermix.com)) running BuddyPress and both are doing the same thing. When a site admin (or contributor or author) logs in using the WordPress login page, they are redirected to the home page instead of Dashboard. I don't have any ... | ```
remove_filter( 'login_redirect', 'bp_core_login_redirect' );
```
If you place this in your functions.php the default login redirect from WordPress is used. So if you go to /wp-admin/ then you will be redirected to /wp-admin/. |
33,335 | <p>Is it possible to allow users when logged in to switch the entire theme through a theme options panel? I don't want users to use the standard wordpress way, but instead just an option in their panel. Any ideas?</p>
<p>EDIT: This is for a user on their own network site.</p>
| [
{
"answer_id": 34547,
"author": "Norcross",
"author_id": 403,
"author_profile": "https://wordpress.stackexchange.com/users/403",
"pm_score": 0,
"selected": false,
"text": "<p>That is built-in to BuddyPress, the idea being that the majority of users aren't supposed to be in the admin pane... | 2011/11/09 | [
"https://wordpress.stackexchange.com/questions/33335",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5698/"
] | Is it possible to allow users when logged in to switch the entire theme through a theme options panel? I don't want users to use the standard wordpress way, but instead just an option in their panel. Any ideas?
EDIT: This is for a user on their own network site. | ```
remove_filter( 'login_redirect', 'bp_core_login_redirect' );
```
If you place this in your functions.php the default login redirect from WordPress is used. So if you go to /wp-admin/ then you will be redirected to /wp-admin/. |
33,342 | <p>Is it possible to add a custom field to menu items?</p>
<p>What I want to do is be able to add a field for 'French Navigation Label' and a 'French Title Attribute' in the wp menu interface.</p>
| [
{
"answer_id": 33373,
"author": "Sterling Hamilton",
"author_id": 10075,
"author_profile": "https://wordpress.stackexchange.com/users/10075",
"pm_score": -1,
"selected": false,
"text": "<blockquote>\n <p>WordPress has the ability to allow post authors to assign custom fields to a post.<... | 2011/11/09 | [
"https://wordpress.stackexchange.com/questions/33342",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6449/"
] | Is it possible to add a custom field to menu items?
What I want to do is be able to add a field for 'French Navigation Label' and a 'French Title Attribute' in the wp menu interface. | This will add a custom field to the menu item edit. However, you will not see the custom field until you have saved the menu for the newly added menu item. When you first add an item, you will only see the standard fields. After save, the new field will be available also for edit. If you add additional menu items, you ... |
33,344 | <p>I am currently trying to setup a redirect so that my admin users are redirected to a page other than the dashboard within the wordpress administrator interface. </p>
<p>If I leave out my conditional, the redirect works, but then it also redirects non-administrator users as well and I don't want this. </p>
<p>Her... | [
{
"answer_id": 33345,
"author": "Jeremy Jared",
"author_id": 5339,
"author_profile": "https://wordpress.stackexchange.com/users/5339",
"pm_score": 0,
"selected": false,
"text": "<p>Try wrapping the function with this current_user condition:</p>\n\n<pre><code>if (current_user_can('adminis... | 2011/11/09 | [
"https://wordpress.stackexchange.com/questions/33344",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8882/"
] | I am currently trying to setup a redirect so that my admin users are redirected to a page other than the dashboard within the wordpress administrator interface.
If I leave out my conditional, the redirect works, but then it also redirects non-administrator users as well and I don't want this.
Here is the code I hav... | You should not use [Userlevels](http://codex.wordpress.org/User_Levels). Userlevels have been replaced in WP 2.0 and have been officially deprecated since 3.0
```
add_filter( 'login_redirect', 'dashboard_redirect' );
function dashboard_redirect( $url ) {
if ( current_user_can( 'manage_options' ) ) {
$url ... |
33,375 | <p>So, I've been googling and reading and testing and failing. </p>
<p>I'm fairly new to php, so don't expect to much :)</p>
<p>I'm working on a new design, and I want to show content from the about page on my homepage, which is dynamic. So, I've been looking into that the_content thing, but I havent gotten any luck ... | [
{
"answer_id": 33376,
"author": "Sterling Hamilton",
"author_id": 10075,
"author_profile": "https://wordpress.stackexchange.com/users/10075",
"pm_score": 1,
"selected": false,
"text": "<p>The codex is your friend!</p>\n\n<p><a href=\"http://codex.wordpress.org/Function_Reference/get_post... | 2011/11/10 | [
"https://wordpress.stackexchange.com/questions/33375",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10160/"
] | So, I've been googling and reading and testing and failing.
I'm fairly new to php, so don't expect to much :)
I'm working on a new design, and I want to show content from the about page on my homepage, which is dynamic. So, I've been looking into that the\_content thing, but I havent gotten any luck so far.
```
<?... | First off: The ID of a post or page is always an integer. "about" is either your about page's title, [slug](http://codex.wordpress.org/Glossary#Post_Slug) or both.
Including the following in your "homepage's" [page template](http://codex.wordpress.org/Pages#Page_Templates) or in the sidebar combined with [conditional ... |
33,385 | <p>I've setup a custom post type with a series of custom fields using the WPAlchemy class. I'm trying to take the value of one of the custom fields and use that as the post title. So far, though, I've had no success. I've been browsing around and I've tried the following two different blocks of code:</p>
<pre><code>fu... | [
{
"answer_id": 33387,
"author": "chrisguitarguy",
"author_id": 6035,
"author_profile": "https://wordpress.stackexchange.com/users/6035",
"pm_score": 3,
"selected": true,
"text": "<p>So, every time you save a post, you want to replace the value of a title that just got saved with another ... | 2011/11/10 | [
"https://wordpress.stackexchange.com/questions/33385",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1766/"
] | I've setup a custom post type with a series of custom fields using the WPAlchemy class. I'm trying to take the value of one of the custom fields and use that as the post title. So far, though, I've had no success. I've been browsing around and I've tried the following two different blocks of code:
```
function custom_... | So, every time you save a post, you want to replace the value of a title that just got saved with another value from a custom field...
Seems like you should just put whatever you what the title to be in the actual title field.
BUT I'm assuming this is for presentational purposes: you want that custom post type to dis... |
33,395 | <p>I would like to use wp-admin to make a "page" which is used at the very botton of each pages. The bottom part would look like the below</p>
<blockquote>
<p>Home | Tips | Services | Downloads | Workshops | Testimonials | Resources | Contact us </p>
</blockquote>
<p>but on top of that it will be complex. A logo+li... | [
{
"answer_id": 33399,
"author": "Johannes Pille",
"author_id": 9745,
"author_profile": "https://wordpress.stackexchange.com/users/9745",
"pm_score": 3,
"selected": true,
"text": "<p>I don't quite grasp why you'd want to include a page \"on the bottom of each page\", rather than putting t... | 2011/11/10 | [
"https://wordpress.stackexchange.com/questions/33395",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I would like to use wp-admin to make a "page" which is used at the very botton of each pages. The bottom part would look like the below
>
> Home | Tips | Services | Downloads | Workshops | Testimonials | Resources | Contact us
>
>
>
but on top of that it will be complex. A logo+links+images. Something you would ... | I don't quite grasp why you'd want to include a page "on the bottom of each page", rather than putting the "logo+links+images" in the footer and creating a [menu](http://codex.wordpress.org/Function_Reference/wp_nav_menu) below that.
That being said, in order to achieve what you want, create the page and include the f... |
33,396 | <p>I couldn't figure out the best way to write the title, so first of all I hope you understood what i was trying to get across. I have a snippet of code on my template page that fires after the wp_query to display a heading as such:</p>
<p>showing x of y results for ...</p>
<p>and the code:</p>
<pre><code>elseif ($... | [
{
"answer_id": 33398,
"author": "Geert",
"author_id": 4936,
"author_profile": "https://wordpress.stackexchange.com/users/4936",
"pm_score": 1,
"selected": false,
"text": "<p>I once calculated these variables for the <a href=\"https://github.com/kohana/pagination/blob/3.1/master/classes/k... | 2011/11/10 | [
"https://wordpress.stackexchange.com/questions/33396",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I couldn't figure out the best way to write the title, so first of all I hope you understood what i was trying to get across. I have a snippet of code on my template page that fires after the wp\_query to display a heading as such:
showing x of y results for ...
and the code:
```
elseif ($size_option&&!$color_option... | Given your posted query and that you seem to still be trying to figure it out:
First, off you should not use `$wp_query = new WP_Query ();`, since `$wp_query` is a global wordpress core object. Use any other variable to store the custom query in, `$the_query = new WP_Query ();` for instance.
That being said, the belo... |
33,423 | <p>I want to create a badge image for comment author of a certain role, say, Editor. I want to style comments of users with the Editor role differently than comments of non-registered or lower-level users. For instance, I'd like to have an image appear next to his/her name.</p>
<p>I can do the whole thing in CSS, but ... | [
{
"answer_id": 33425,
"author": "Johannes Pille",
"author_id": 9745,
"author_profile": "https://wordpress.stackexchange.com/users/9745",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Conditional_Tags\" rel=\"nofollow\">Conditional tags</a> are used to... | 2011/11/10 | [
"https://wordpress.stackexchange.com/questions/33423",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10174/"
] | I want to create a badge image for comment author of a certain role, say, Editor. I want to style comments of users with the Editor role differently than comments of non-registered or lower-level users. For instance, I'd like to have an image appear next to his/her name.
I can do the whole thing in CSS, but I want a b... | [Conditional tags](http://codex.wordpress.org/Conditional_Tags) are used to change content on the basis of what conditions a page meets. While there are no conditional tags depending on a user's role, this is how you can manipulate content depending on roles:
**Display content to the user, depending on his role**
```... |
33,444 | <p>The most thorough documentation I can find of how to add a new keyboard shortcut to TinyMC is at this page: <a href="http://www.lifeinsuranceonmyterms.com/other/custom-keyboard-shortcuts-for-tinymce-how-to" rel="nofollow">http://www.lifeinsuranceonmyterms.com/other/custom-keyboard-shortcuts-for-tinymce-how-to</a></p... | [
{
"answer_id": 33461,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 2,
"selected": false,
"text": "<p>Last time i added a keybord shortcut it was using jQuery.\ntake a look at <a href=\"https://github.com/jeresi... | 2011/11/10 | [
"https://wordpress.stackexchange.com/questions/33444",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3564/"
] | The most thorough documentation I can find of how to add a new keyboard shortcut to TinyMC is at this page: <http://www.lifeinsuranceonmyterms.com/other/custom-keyboard-shortcuts-for-tinymce-how-to>
It involves adding this code to the main TinyMCE source file, tiny\_mce\_src.js (and then recompressing):
```
t.addShor... | Last time i added a keybord shortcut it was using jQuery.
take a look at [**jquery.hotkeys**](https://github.com/jeresig/jquery.hotkeys) plugin which lets you enable keyboard shortcuts with a simple one liner:
```
$(document).bind('keydown', 'ctrl+a', fn);
```
**update**
if you want to check if the TinyMCE editor i... |
33,452 | <p>I want to use $wpdb in a theme file, but it doesn't work. My code is bellow:</p>
<pre><code><?php
$action = $_POST['action'];
$updateRecordsArray = $_POST['recordsArray'];
if ($action == "updatelist") {
$listingCounter = 1;
$column = $_GET['column'];
foreach ($updateRecordsArray as $key=>$va... | [
{
"answer_id": 33469,
"author": "GavinR",
"author_id": 2001,
"author_profile": "https://wordpress.stackexchange.com/users/2001",
"pm_score": 3,
"selected": true,
"text": "<p>I think the <a href=\"http://wordpress.org/extend/plugins/user-domain-whitelist/\" rel=\"nofollow\">User Domain Wh... | 2011/08/31 | [
"https://wordpress.stackexchange.com/questions/33452",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8299/"
] | I want to use $wpdb in a theme file, but it doesn't work. My code is bellow:
```
<?php
$action = $_POST['action'];
$updateRecordsArray = $_POST['recordsArray'];
if ($action == "updatelist") {
$listingCounter = 1;
$column = $_GET['column'];
foreach ($updateRecordsArray as $key=>$value) {
$wpdb->upd... | I think the [User Domain Whitelist](http://wordpress.org/extend/plugins/user-domain-whitelist/) plugin is exactly what you want:
>
> The User Domain Whitelist/Blacklist plugin limits user registration to
> only registrants with an email address from the domain white list
> below OR prevents registrants with an emai... |
33,455 | <p>Below is the code i use to output the post tag (taxonomy) count/number. I want to be able to split the count based on post type that the taxonomy features in (rather than the total number). </p>
<p>So i have the default "post" Post type, aswell as "blogs", & "pics". I want the taxonomy count to display somethin... | [
{
"answer_id": 33464,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": true,
"text": "<p>I needed to get the number of post per type per term so i created this small function:</p>\n\n<pre><code>funct... | 2011/11/10 | [
"https://wordpress.stackexchange.com/questions/33455",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1778/"
] | Below is the code i use to output the post tag (taxonomy) count/number. I want to be able to split the count based on post type that the taxonomy features in (rather than the total number).
So i have the default "post" Post type, aswell as "blogs", & "pics". I want the taxonomy count to display something like: x post... | I needed to get the number of post per type per term so i created this small function:
```
function get_term_post_count_by_type($term,$taxonomy,$type){
$args = array(
'fields' =>'ids', //we don't really need all post data so just id wil do fine.
'posts_per_page' => -1, //-1 to get all post
... |