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 |
|---|---|---|---|---|---|---|
50,427 | <p>WP Super Cache plugin generate page and save html of this page to static file and if needed this file is served instead of dynamically generate this page each time.</p>
<p><strong>Does WP Super Cache plugin make any extra SQL queries during serving the cached page?</strong></p>
| [
{
"answer_id": 50417,
"author": "Mohit Bumb",
"author_id": 8184,
"author_profile": "https://wordpress.stackexchange.com/users/8184",
"pm_score": 3,
"selected": true,
"text": "<p>Check this reference </p>\n\n<p><a href=\"http://www.wpbeginner.com/wp-themes/how-to-add-custom-dashboard-widg... | 2012/04/27 | [
"https://wordpress.stackexchange.com/questions/50427",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15054/"
] | WP Super Cache plugin generate page and save html of this page to static file and if needed this file is served instead of dynamically generate this page each time.
**Does WP Super Cache plugin make any extra SQL queries during serving the cached page?** | Check this reference
<http://www.wpbeginner.com/wp-themes/how-to-add-custom-dashboard-widgets-in-wordpress/>
for adding dashboard widget
[Remove Widgets in Dashboard](https://wordpress.stackexchange.com/questions/47707/remove-widgets-in-dashboard)
for removing dashboard widget
```
add_action('wp_dashboard_setup',... |
50,433 | <p>I have a multi-author baseball site. I want authors to be able to schedule posts to be published at one of four selected times each day. This is important because some authors write game recaps, and an auto-publish of a game recap once the following game has started is pretty worthless.</p>
<p>I am looking for a plu... | [
{
"answer_id": 51349,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 4,
"selected": true,
"text": "<p>My approach is to create an hourly cron event that loops through all the draft status posts and checks for the publ... | 2012/04/27 | [
"https://wordpress.stackexchange.com/questions/50433",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14558/"
] | I have a multi-author baseball site. I want authors to be able to schedule posts to be published at one of four selected times each day. This is important because some authors write game recaps, and an auto-publish of a game recap once the following game has started is pretty worthless.
I am looking for a plugin to ma... | My approach is to create an hourly cron event that loops through all the draft status posts and checks for the publish month - date and hour saved in post\_meta and publishes if scheduled date is not in the future.
A publish date and time select meta box is added to the publishing div that updates via ajax when a time... |
50,439 | <p>I want to clean up <code><script></code> tags generated by WordPress to produce more semantic output for HTML5.</p>
<p>You can already do this for <code><style></code> tags using this code attached to the <code>style_loader_tag</code> filter:</p>
<pre><code>//clean up the default WordPress style tags
a... | [
{
"answer_id": 50451,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>If you really want to do this, then it should already be possible.</p>\n\n<p>The <code>global $wp_scripts</code> is... | 2012/04/27 | [
"https://wordpress.stackexchange.com/questions/50439",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9605/"
] | I want to clean up `<script>` tags generated by WordPress to produce more semantic output for HTML5.
You can already do this for `<style>` tags using this code attached to the `style_loader_tag` filter:
```
//clean up the default WordPress style tags
add_filter('style_loader_tag', 'clean_style_tag');
function clean_... | If you really want to do this, then it should already be possible.
The `global $wp_scripts` is an *instance* of the `WP_Scripts` class, which is an *instance* of the `WP_Dependencies` class.
So in theory (not tested), you should be able to do something like this:
```
function alter_script_tags()
{
echo '<pre>';... |
50,452 | <p>I have a wordpress website which gets around 20K visits a days and with around 7pages/visit and 62 hits per visit.</p>
<p>My server is :</p>
<blockquote>
<p>8 processors --> Intel(R) Xeon(R) CPU E5405 @ 2.00GHz</p>
<p>8 GB RAM</p>
</blockquote>
<p>Now my users are complaining about that the site takes time... | [
{
"answer_id": 50451,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>If you really want to do this, then it should already be possible.</p>\n\n<p>The <code>global $wp_scripts</code> is... | 2012/04/27 | [
"https://wordpress.stackexchange.com/questions/50452",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15607/"
] | I have a wordpress website which gets around 20K visits a days and with around 7pages/visit and 62 hits per visit.
My server is :
>
> 8 processors --> Intel(R) Xeon(R) CPU E5405 @ 2.00GHz
>
>
> 8 GB RAM
>
>
>
Now my users are complaining about that the site takes time to load sometimes and craches giving the t... | If you really want to do this, then it should already be possible.
The `global $wp_scripts` is an *instance* of the `WP_Scripts` class, which is an *instance* of the `WP_Dependencies` class.
So in theory (not tested), you should be able to do something like this:
```
function alter_script_tags()
{
echo '<pre>';... |
50,455 | <p>I am working on a WP theme/project that includes several custom page templates that will only be used once each. For example, there is a page with a map and search form for finding things on the map. Clearly the map page needs a unique page template, but that template will never be used for any other pages. I wou... | [
{
"answer_id": 50451,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<p>If you really want to do this, then it should already be possible.</p>\n\n<p>The <code>global $wp_scripts</code> is... | 2012/04/27 | [
"https://wordpress.stackexchange.com/questions/50455",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15612/"
] | I am working on a WP theme/project that includes several custom page templates that will only be used once each. For example, there is a page with a map and search form for finding things on the map. Clearly the map page needs a unique page template, but that template will never be used for any other pages. I would lik... | If you really want to do this, then it should already be possible.
The `global $wp_scripts` is an *instance* of the `WP_Scripts` class, which is an *instance* of the `WP_Dependencies` class.
So in theory (not tested), you should be able to do something like this:
```
function alter_script_tags()
{
echo '<pre>';... |
50,478 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://wordpress.stackexchange.com/questions/45529/retrieve-1st-image-in-post-and-set-it-as-featured-image-when-post-is-saved-upda">Retrieve 1st image in post and set it as featured image, when post is saved/updated</a><br>
<a href="https://wordpr... | [
{
"answer_id": 50479,
"author": "Travis Pflanz",
"author_id": 14558,
"author_profile": "https://wordpress.stackexchange.com/users/14558",
"pm_score": 0,
"selected": false,
"text": "<p>This plugin from the Wordpress Plugin Directory seems to do what you need - <a href=\"http://wordpress.o... | 2012/04/27 | [
"https://wordpress.stackexchange.com/questions/50478",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14128/"
] | >
> **Possible Duplicate:**
>
> [Retrieve 1st image in post and set it as featured image, when post is saved/updated](https://wordpress.stackexchange.com/questions/45529/retrieve-1st-image-in-post-and-set-it-as-featured-image-when-post-is-saved-upda)
>
> [VT-resize image and display it](https://wordpress.stackex... | Sorry to not help with your existing code but if you are open to using a plugin I can recommend: <http://wordpress.org/extend/plugins/get-the-image/>
It is great as it grabs the first image, or a featured image if you have one. You can also specify the dimensions to crop the image and an optional fallback image in cas... |
50,494 | <p>I have been on this for a while now and haven't really come across a solution to filter the posts on a category page using a sort of offset in php.</p>
<p>There are plugin for posts and pages but I am trying to achieve this with pure php and specifically for a category page.</p>
<p>Scenario example:
A blog with 7 ... | [
{
"answer_id": 50495,
"author": "Rutwick Gangurde",
"author_id": 4740,
"author_profile": "https://wordpress.stackexchange.com/users/4740",
"pm_score": 3,
"selected": true,
"text": "<p>The 'offset' parameter does what you want. I've written this hack, it should help you...</p>\n\n<pre><co... | 2012/04/28 | [
"https://wordpress.stackexchange.com/questions/50494",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15628/"
] | I have been on this for a while now and haven't really come across a solution to filter the posts on a category page using a sort of offset in php.
There are plugin for posts and pages but I am trying to achieve this with pure php and specifically for a category page.
Scenario example:
A blog with 7 posts, setting th... | The 'offset' parameter does what you want. I've written this hack, it should help you...
```
<?php
//The third parameter corresponds to action priority,
//set it to change the order of execution in case of a conflict
add_action('pre_get_posts', 'the_modified_loop', 10);
function the_modified_loop($que... |
50,505 | <p>When I want to import the XML files with the aid of the WordPress Importer plugin, the blogs imported will lose all the slashes, i.e., "\", which are really contained in the XML files imported.</p>
<p>Since I have to use the LaTeX plug-in (Latex for WordPress plug-in), it becomes terrible.</p>
<p>In fact, maybe we... | [
{
"answer_id": 50560,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>The importer calls <code>wp_insert_post()</code> which runs <code>stripslashes_deep()</code> on the data. But the <em>... | 2012/04/28 | [
"https://wordpress.stackexchange.com/questions/50505",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13841/"
] | When I want to import the XML files with the aid of the WordPress Importer plugin, the blogs imported will lose all the slashes, i.e., "\", which are really contained in the XML files imported.
Since I have to use the LaTeX plug-in (Latex for WordPress plug-in), it becomes terrible.
In fact, maybe weeks ago, it worke... | The importer calls `wp_insert_post()` which runs `stripslashes_deep()` on the data. But the *exporter* doesn't run `addslashes`. Looks like a bug to me.
What you may try is to prepare the data during export.
Create a plugin with the following content and activate it **before** you run the export:
```
<?php
/**
* Pl... |
50,509 | <p>I have set the blog to be a different page other than the home page.</p>
<p>I want to have a link from single.php to this blog page.</p>
<p>Is there any function that pulls out URL for the blog ?</p>
| [
{
"answer_id": 50514,
"author": "Sagive",
"author_id": 7990,
"author_profile": "https://wordpress.stackexchange.com/users/7990",
"pm_score": 2,
"selected": false,
"text": "<p>You can use <code>get_option</code> of <code>page_for_posts</code> to get the page ID to either assign it to a va... | 2012/04/28 | [
"https://wordpress.stackexchange.com/questions/50509",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1555/"
] | I have set the blog to be a different page other than the home page.
I want to have a link from single.php to this blog page.
Is there any function that pulls out URL for the blog ? | As of WordPress 4.5 you can use:
```
get_post_type_archive_link( 'post' );
```
This handles the logic of getting the correct URL regardless of whether posts show up on the homepage or in a specified page. |
50,512 | <p>I have five domains pointing to the same server/wp installation. the domain names are important and my visitors need to be able to stay on their preferred domain as they surf through my site.</p>
<p>how do I set up wp (or .htaccess or...) so that links all point to the domain/host specified by the visitor?</p>
<p>... | [
{
"answer_id": 50571,
"author": "Gregory",
"author_id": 15311,
"author_profile": "https://wordpress.stackexchange.com/users/15311",
"pm_score": 2,
"selected": false,
"text": "<p>I tracked the function calls in my theme (a child theme of Oenology by Chip Bennett) and wp-include that gener... | 2012/04/28 | [
"https://wordpress.stackexchange.com/questions/50512",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15311/"
] | I have five domains pointing to the same server/wp installation. the domain names are important and my visitors need to be able to stay on their preferred domain as they surf through my site.
how do I set up wp (or .htaccess or...) so that links all point to the domain/host specified by the visitor?
right now, if I s... | I tracked the function calls in my theme (a child theme of Oenology by Chip Bennett) and wp-include that generate the links, found the `home_url()` function, and then wrote these functions for my site:
```
function gregory_make_relative($url='') {
return preg_replace( '#^https?://[^/]+/#iu', '/', $url, 1 );
}
add_... |
50,522 | <p>whilst wp_enqueue_script seems to work it's not really elegant. I'm currently making a WP front end which uses MVC (backbone.js) and has literally 30+ seperate Model/View/Collection/Controller scripts and I keep adding to the number. I've used require.js a lot before and really like it, however it seems to completel... | [
{
"answer_id": 50525,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 2,
"selected": true,
"text": "<p>Though WordPress already has a basic .js API (with register and enqueue script), I don't see why you cannot use it ... | 2012/04/28 | [
"https://wordpress.stackexchange.com/questions/50522",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14485/"
] | whilst wp\_enqueue\_script seems to work it's not really elegant. I'm currently making a WP front end which uses MVC (backbone.js) and has literally 30+ seperate Model/View/Collection/Controller scripts and I keep adding to the number. I've used require.js a lot before and really like it, however it seems to completely... | Though WordPress already has a basic .js API (with register and enqueue script), I don't see why you cannot use it in conjunction with require.js, at least at the modular level.
From what I can tell (never used it) it only needs to be loaded, so you can,
```
wp_enqueue_script(
$handle,
'...folder../requi... |
50,524 | <p>I'm using <a href="http://wordpress.org/extend/plugins/wp-postratings/" rel="nofollow">wp-postratings</a> to rate posts which stores the rating as a custom meta value <code>ratings_score</code>. It gives you the option to use <code>r_sortby</code> to order the loop by highest rated but I want to give it a trending f... | [
{
"answer_id": 50538,
"author": "Slubbix",
"author_id": 15434,
"author_profile": "https://wordpress.stackexchange.com/users/15434",
"pm_score": 2,
"selected": true,
"text": "<p>You could do this by sorting on a calculated factor. Dividing the rating by the days gives a good starting poin... | 2012/04/28 | [
"https://wordpress.stackexchange.com/questions/50524",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12700/"
] | I'm using [wp-postratings](http://wordpress.org/extend/plugins/wp-postratings/) to rate posts which stores the rating as a custom meta value `ratings_score`. It gives you the option to use `r_sortby` to order the loop by highest rated but I want to give it a trending feel by dividing the $ratings\_score" by how old the... | You could do this by sorting on a calculated factor. Dividing the rating by the days gives a good starting point:
```
rating/days = factor (e.g. 15/6 = 2.5 or 11/3 = 3.6)
```
You can balance this to your needs by multiplicate the variables (rating and day) with any factor you like.
There are to ways to implement su... |
50,533 | <p>To keep legacy entries on a blog hosted on TypePad on sync with a new WordPress installation...</p>
<p>How do I map this permalink with accented letters:</p>
<pre><code>domain.com/no-es-fácil-alejarse-de-la-política
</code></pre>
<p>to this clean WP permalink without accented letter:</p>
<pre><code>domain.com/no... | [
{
"answer_id": 50534,
"author": "Zombaya",
"author_id": 15663,
"author_profile": "https://wordpress.stackexchange.com/users/15663",
"pm_score": 0,
"selected": false,
"text": "<p>You could make a redirection with .htacces or perhaps try out the wordpress plugin <a href=\"http://wordpress.... | 2012/04/28 | [
"https://wordpress.stackexchange.com/questions/50533",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15653/"
] | To keep legacy entries on a blog hosted on TypePad on sync with a new WordPress installation...
How do I map this permalink with accented letters:
```
domain.com/no-es-fácil-alejarse-de-la-política
```
to this clean WP permalink without accented letter:
```
domain.com/no-es-facil-alejarse-de-la-politica
```
What... | The best way to accomplish this is remove the default sanitize\_title filter and replace it with yours, which will encode those characters properly. Here is an implementation of [using accents in permalinks](http://awordpress.net/blog/accents-in-wordpress-permalinks/).
Example:
```
remove_filter( 'sanitize_title', 's... |
50,551 | <p>I have two plugins, one uses the function wp_insert_post(), the other has a code like this:</p>
<pre><code>add_action('future_to_publish', 'myFunc', 10, 1);
add_action('new_to_publish', 'myFunc', 10, 1);
add_action('draft_to_publish', 'myFunc', 10, 1);
function myFunc( $postID ) {
}
</code></pre>
<p>When the fir... | [
{
"answer_id": 50617,
"author": "Mohit Bumb",
"author_id": 8184,
"author_profile": "https://wordpress.stackexchange.com/users/8184",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"https://developer.wordpress.org/reference/functions/wp_insert_post/\" rel=\"nofollow noreferrer\"><... | 2012/04/29 | [
"https://wordpress.stackexchange.com/questions/50551",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15645/"
] | I have two plugins, one uses the function wp\_insert\_post(), the other has a code like this:
```
add_action('future_to_publish', 'myFunc', 10, 1);
add_action('new_to_publish', 'myFunc', 10, 1);
add_action('draft_to_publish', 'myFunc', 10, 1);
function myFunc( $postID ) {
}
```
When the first plugin runs wp\_inser... | 1. Read the [Codex](http://codex.wordpress.org/%20Post_Status_Transitions),
2. Look at the [function in the core file](http://core.trac.wordpress.org/browser/trunk/wp-includes/post.php#L3226),
3. Modify your code as follows:
```
function myFunc( $post ) {
$postID = $post->ID;
}
```
The post transistion does no... |
50,592 | <p>I'm pretty lost... I'm hoping someone can lead me onto the right track!</p>
<p>I'm trying to achieve the effect of a post timeline, by paginating the posts (1 per page) and rather than displaying the pages as numbered (i.e. 1, 2, 3, etc), I want to display the links as the date of each post, like this:</p>
<p>LATE... | [
{
"answer_id": 50594,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 1,
"selected": false,
"text": "<p>Looks like you asked this question elsewhere,</p>\n\n<ul>\n<li><a href=\"http://wordpress.org/support/topic/post-... | 2012/04/29 | [
"https://wordpress.stackexchange.com/questions/50592",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15662/"
] | I'm pretty lost... I'm hoping someone can lead me onto the right track!
I'm trying to achieve the effect of a post timeline, by paginating the posts (1 per page) and rather than displaying the pages as numbered (i.e. 1, 2, 3, etc), I want to display the links as the date of each post, like this:
LATEST << | **3 Mar**... | Looks like you asked this question elsewhere,
* [PROBLEM: WordPress Support Forum](http://wordpress.org/support/topic/post-timeline)
* [SOLUTION: PasteBin](http://pastebin.com/KZ7drw7w)
* [AUTHOR: Alan Jackson](http://tugbucket.net)
For reference:
```
<?php
echo '<ul id="timeline">';
echo '<li>Latest</li>';
$prev_mo... |
50,593 | <p>Im using a custom filter to change the fields, but can´t figure out how to change the <strong>order</strong> of the fields in the comment form.</p>
<p>Desired order:</p>
<ul>
<li>comment field (first/top)</li>
<li>name</li>
<li>email</li>
<li>website</li>
</ul>
<p>This is the code which I am currently using:</p>
... | [
{
"answer_id": 50597,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 1,
"selected": false,
"text": "<p>the fields od comment form are in the array <code>$fields</code> in function <a href=\"http://m.wpseek.com/?p=deta... | 2012/04/29 | [
"https://wordpress.stackexchange.com/questions/50593",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4571/"
] | Im using a custom filter to change the fields, but can´t figure out how to change the **order** of the fields in the comment form.
Desired order:
* comment field (first/top)
* name
* email
* website
This is the code which I am currently using:
```
function alter_comment_form_fields($fields){
$fields['comments']... | That's pretty simple. You just have to take the `textarea` out of the default fields – filter `'comment_form_defaults'` – and print it on the action `'comment_form_top'`:
```
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 Comment Textarea On Top
* Description: Makes the textarea the first field of the comment f... |
50,618 | <p>I want to show large image in checkout page right now it showing 31x31 size image in <code>wpsc-shopping_cart_page</code> and using <code><img src="<?php echo wpsc_cart_item_image(); ?></code> to call thumbnail image.</p>
<p>what should i do for that?</p>
<p><img src="https://i.stack.imgur.com/osB40.jpg" ... | [
{
"answer_id": 50620,
"author": "Jassi Oberoi",
"author_id": 14547,
"author_profile": "https://wordpress.stackexchange.com/users/14547",
"pm_score": 2,
"selected": true,
"text": "<p>here is the solution i find myself with just 4 easy step</p>\n\n<pre><code>1. go to wp ecommerce plugin fo... | 2012/04/30 | [
"https://wordpress.stackexchange.com/questions/50618",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14547/"
] | I want to show large image in checkout page right now it showing 31x31 size image in `wpsc-shopping_cart_page` and using `<img src="<?php echo wpsc_cart_item_image(); ?>` to call thumbnail image.
what should i do for that?
 | here is the solution i find myself with just 4 easy step
```
1. go to wp ecommerce plugin folder
2. find cart.class.php file
3. find wpsc_cart_item_image function
4. change $width and $height accordingly
``` |
50,637 | <p>I'm migrating a Wordpress install and trying to get down the correct process for doing so.</p>
<p>I've tried using the method I thought would work, but it didn't.</p>
<p>My files and database are in place, but when I visit the wp-admin the theme manager tells me this - The active theme is broken. Reverting to the ... | [
{
"answer_id": 50662,
"author": "cpilko",
"author_id": 7937,
"author_profile": "https://wordpress.stackexchange.com/users/7937",
"pm_score": 1,
"selected": true,
"text": "<p>Try the XCloner plugin: <a href=\"http://wordpress.org/extend/plugins/xcloner-backup-and-restore/\" rel=\"nofollow... | 2012/04/30 | [
"https://wordpress.stackexchange.com/questions/50637",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29582/"
] | I'm migrating a Wordpress install and trying to get down the correct process for doing so.
I've tried using the method I thought would work, but it didn't.
My files and database are in place, but when I visit the wp-admin the theme manager tells me this - The active theme is broken. Reverting to the default theme.
U... | Try the XCloner plugin: <http://wordpress.org/extend/plugins/xcloner-backup-and-restore/>.
I use XCloner to move sites between my live server and my dev server. It takes care of all the migration differences between the domain, database, etc. It preserves all my widget settings, custom menus, etc. |
50,649 | <p>The situation is this: I'm using Video Thumbnails plugin to automatically get and set youtube/vimeo thumbnails as post featured image. The problem is that default youtube/vimeo thumbnail sizes are just a bit smaller than my theme main content width.</p>
<p>So what I need is to scale them up. If I go to the Media Li... | [
{
"answer_id": 50652,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 0,
"selected": false,
"text": "<p>the easiest way would be to add an image-size with 640x298, and use css to resize it. as it is just a minor sca... | 2012/04/30 | [
"https://wordpress.stackexchange.com/questions/50649",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15684/"
] | The situation is this: I'm using Video Thumbnails plugin to automatically get and set youtube/vimeo thumbnails as post featured image. The problem is that default youtube/vimeo thumbnail sizes are just a bit smaller than my theme main content width.
So what I need is to scale them up. If I go to the Media Library, I c... | You can use the native Wordpress **image\_resize** function to scale up images. Wordpress provides a hook called "**image\_resize\_dimensions**" which you can use to overwrite the default cropping settings. Here is a modified function which will support scaling up:
```
function image_crop_dimensions($default, $orig_w,... |
50,674 | <p>I'm building my theme options page and I want to use Wordpress TinyMCE editor here, so I'm calling <code>wp_editor</code>. But when I'm saving data some entities are added to the content for example, lets say I want to add image:</p>
<p><code><img class="" title="" src="path_to_image" alt="" /></code></p>
<p... | [
{
"answer_id": 50683,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 5,
"selected": true,
"text": "<p>WordPress is running <code>addslashes</code> on <code>POST</code> input. The value you get from the data base looks pro... | 2012/04/30 | [
"https://wordpress.stackexchange.com/questions/50674",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15476/"
] | I'm building my theme options page and I want to use Wordpress TinyMCE editor here, so I'm calling `wp_editor`. But when I'm saving data some entities are added to the content for example, lets say I want to add image:
`<img class="" title="" src="path_to_image" alt="" />`
Thats what I've got after clicking save:
`<... | WordPress is running `addslashes` on `POST` input. The value you get from the data base looks probably like:
```
<img title=\"\" …
```
… and the editor tries to enforce valid markup from that.
So … call the editor with …
```
wp_editor( stripslashes( $content ), strtolower($value['id']), $settings );
``` |
50,675 | <p>Here is the loop from my <code>author.php</code> page. It is showing recent posts, but not the MOST recent.</p>
<p>Where is my mistake?</p>
<pre><code> <?php if (have_posts()): the_post(); ?>
<h3>
<?php _e('All posts by'); ?> <?php echo get_the_author(); ?>
... | [
{
"answer_id": 50688,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 3,
"selected": true,
"text": "<p>The mistake is in your first block of code:</p>\n\n<pre><code><?php if (have_posts()): the_post(); ?>\n <h... | 2012/04/30 | [
"https://wordpress.stackexchange.com/questions/50675",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14558/"
] | Here is the loop from my `author.php` page. It is showing recent posts, but not the MOST recent.
Where is my mistake?
```
<?php if (have_posts()): the_post(); ?>
<h3>
<?php _e('All posts by'); ?> <?php echo get_the_author(); ?>
<span class="arrows">»</span>
</h3>
... | The mistake is in your first block of code:
```
<?php if (have_posts()): the_post(); ?>
<h3>
<?php _e('All posts by'); ?> <?php echo get_the_author(); ?>
<span class="arrows">»</span>
</h3>
<?php while (have_posts()) : the_post();?>
```
You call `the_post()` to populate the regular tem... |
50,703 | <p>Currently when logged into the backend, sometimes when a plugin has an update or Wordpress has an update a notification message appears at the top either telling the user to upgrade or if a plugin needs attention like if a setting still needs to be configured or something.</p>
<p>Is there a way to prevent the user ... | [
{
"answer_id": 50709,
"author": "byronyasgur",
"author_id": 6169,
"author_profile": "https://wordpress.stackexchange.com/users/6169",
"pm_score": 0,
"selected": false,
"text": "<p>The easiest way to do this is by installing a suitable plugin. You would want to search for one that did wha... | 2012/04/30 | [
"https://wordpress.stackexchange.com/questions/50703",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15412/"
] | Currently when logged into the backend, sometimes when a plugin has an update or Wordpress has an update a notification message appears at the top either telling the user to upgrade or if a plugin needs attention like if a setting still needs to be configured or something.
Is there a way to prevent the user for seeing... | Add this to your functions.php.
```
if ( !current_user_can( 'edit_users' ) ) { //Change the edit_user" to whatever capability you need to retain the notifications
add_action( 'init', create_function( '$a', "remove_action( 'init', 'wp_version_check' );" ), 2 );
add_filter( 'pre_option_update_core', create_function... |
50,705 | <p>I am currently building a network of blogs for individual real estate agents. Currently, a broker will have a main site, with agents sites added as subdirectories, e.g., www.example.com and www.example.com/agent. Each agent's <code>front-page.php</code> template has an area which displays the agents contact info. I ... | [
{
"answer_id": 50714,
"author": "jessica",
"author_id": 2659,
"author_profile": "https://wordpress.stackexchange.com/users/2659",
"pm_score": 0,
"selected": false,
"text": "<p>If the subdirectory name will <em>always</em> match the username of the person you want to display, you can do t... | 2012/04/30 | [
"https://wordpress.stackexchange.com/questions/50705",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4273/"
] | I am currently building a network of blogs for individual real estate agents. Currently, a broker will have a main site, with agents sites added as subdirectories, e.g., www.example.com and www.example.com/agent. Each agent's `front-page.php` template has an area which displays the agents contact info. I am currently u... | The problem is that the idea of "the user of a specific subdirectory" doesn't really exist natively in WP. There are sites ("subdirectories"), and there are users, and users can be associated with sites (through Roles and Capabilities), but there is no guarantee of a one-to-one correspondence.
If you are running a net... |
50,723 | <p>Is there any way to remove the help tabs?
I'm looking to remove these tabs not to hide them with CSS.</p>
<p>On the <code>wp-admin/includes/screen.php</code> there are a couple of lines that mention this but no idea how to create something to remove the help tab.</p>
<p>Is there any way to create something simila... | [
{
"answer_id": 50740,
"author": "evaqas",
"author_id": 15684,
"author_profile": "https://wordpress.stackexchange.com/users/15684",
"pm_score": 3,
"selected": false,
"text": "<p>Add this you your <code>functions.php</code> file:</p>\n\n<pre><code>add_action('admin_head', 'mytheme_remove_h... | 2012/05/01 | [
"https://wordpress.stackexchange.com/questions/50723",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15704/"
] | Is there any way to remove the help tabs?
I'm looking to remove these tabs not to hide them with CSS.
On the `wp-admin/includes/screen.php` there are a couple of lines that mention this but no idea how to create something to remove the help tab.
Is there any way to create something similar to: `add_filter('screen_op... | You need to use the [`contextual_help`](http://adambrown.info/p/wp_hooks/hook/contextual_help?version=3.3&file=wp-admin/includes/screen.php) help filter.
```
add_filter( 'contextual_help', 'wpse50723_remove_help', 999, 3 );
function wpse50723_remove_help($old_help, $screen_id, $screen){
$screen->remove_help_tabs()... |
50,730 | <p>I would like to make the email field on the profile page for subscribers read only. They can see their email but not change it. I want only admins to to be able to change users email address.</p>
| [
{
"answer_id": 50758,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 3,
"selected": true,
"text": "<p>Although the readonly attribute can be removed using Chrome/Firebug inspector (making the field editable agai... | 2012/05/01 | [
"https://wordpress.stackexchange.com/questions/50730",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7042/"
] | I would like to make the email field on the profile page for subscribers read only. They can see their email but not change it. I want only admins to to be able to change users email address. | Although the readonly attribute can be removed using Chrome/Firebug inspector (making the field editable again), much probably the average user will not know this.
```
<?php
function wpse50730_script_enqueuer(){
if(current_user_can('subscriber')) {
echo '<script type="text/javascript">
jQuery(docum... |
50,732 | <p>Ive searched around and havent been able to find anything regarding using a specific "template" as a target to trigger when to show custom meta boxes...Is this possible, and if so how would you script this out?</p>
<p>If post/page ID's are the only real feasible option then would it be possible to target a... | [
{
"answer_id": 50745,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": true,
"text": "<p>I needed the same thing, showing a metabox based on the selected page template, and since the user has to sele... | 2012/05/01 | [
"https://wordpress.stackexchange.com/questions/50732",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3567/"
] | Ive searched around and havent been able to find anything regarding using a specific "template" as a target to trigger when to show custom meta boxes...Is this possible, and if so how would you script this out?
If post/page ID's are the only real feasible option then would it be possible to target a parent page ID rat... | I needed the same thing, showing a metabox based on the selected page template, and since the user has to select a page template and save and only then i could know which metabox to show i ended up showing all and use some simple jQuery to only show the needed one without having to save first, here:
```
function custo... |
50,735 | <p>I have three pages, and I want them all to display the comments form from a post with id=343. What code would I use within the pages to make that happen?</p>
<p>Here is what I've tried:</p>
<pre><code><?php
$id=343; // sample, I get the latest post id of a particular category
comments_template();
?>
</code><... | [
{
"answer_id": 50737,
"author": "Jassi Oberoi",
"author_id": 14547,
"author_profile": "https://wordpress.stackexchange.com/users/14547",
"pm_score": -1,
"selected": false,
"text": "<p>use this if you want to show comment on a specific post <code>is_single('1')</code></p>\n"
},
{
... | 2012/05/01 | [
"https://wordpress.stackexchange.com/questions/50735",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3811/"
] | I have three pages, and I want them all to display the comments form from a post with id=343. What code would I use within the pages to make that happen?
Here is what I've tried:
```
<?php
$id=343; // sample, I get the latest post id of a particular category
comments_template();
?>
```
But that doesn't work, it jus... | Use `get_comments()` and pass the post ID as parameter:
```
$comments = get_comments(
array (
'post_id' => 343
)
);
foreach ( $comments as $comment )
{
// Just to give you an idea of the available data.
// You will probably do something better with it. :)
var_export( $comment );
}
```
R... |
50,738 | <p>I'm pretty stumped on this one. I'm using add_action inside my plugin class to do certain things- add scripts & styles to the head, wp_ajax, etc. Here's the actions, in the __construct:</p>
<pre><code>function __construct(){
add_action('admin_menu', array($this, 'sph_admin_menu'));
add_action('sph_heade... | [
{
"answer_id": 52473,
"author": "Michael Ecklund",
"author_id": 9579,
"author_profile": "https://wordpress.stackexchange.com/users/9579",
"pm_score": 3,
"selected": false,
"text": "<p>Sometimes certain hooks need to be fired at certain times. Example, some hooks need to be fired upon <st... | 2012/05/01 | [
"https://wordpress.stackexchange.com/questions/50738",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15707/"
] | I'm pretty stumped on this one. I'm using add\_action inside my plugin class to do certain things- add scripts & styles to the head, wp\_ajax, etc. Here's the actions, in the \_\_construct:
```
function __construct(){
add_action('admin_menu', array($this, 'sph_admin_menu'));
add_action('sph_header', array($thi... | Sometimes certain hooks need to be fired at certain times. Example, some hooks need to be fired upon **init**.
Add this to your `__construct()`
```
add_action('init', array(&$this, 'init'));
```
Then add this function, which will contain all hooks that need to be fired upon **init**.
```
public function init(){
... |
50,747 | <p>I've been given an old Wordpress installation to setup on a new server. After setting <strong>wp-config.php</strong> and the values for the URLs in the db, <strong>wp_options.siteurl</strong> and <strong>wp_options.home</strong> (the usual process I do for something like this) I just get a blank screen on Safari, on... | [
{
"answer_id": 50777,
"author": "cpilko",
"author_id": 7937,
"author_profile": "https://wordpress.stackexchange.com/users/7937",
"pm_score": 0,
"selected": false,
"text": "<p>I had a \"white screen of death\" problem once when migrating a site. </p>\n\n<p>The root cause turned out to be ... | 2012/05/01 | [
"https://wordpress.stackexchange.com/questions/50747",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15712/"
] | I've been given an old Wordpress installation to setup on a new server. After setting **wp-config.php** and the values for the URLs in the db, **wp\_options.siteurl** and **wp\_options.home** (the usual process I do for something like this) I just get a blank screen on Safari, on Chrome I get
>
> The website encount... | 1. Add the following to `wp_config.php`:
```
define( 'WP_DEBUG', true );
```
2. [Reset the Plugins folder](http://codex.wordpress.org/FAQ_Troubleshooting#How_to_deactivate_all_plugins_when_not_able_to_access_the_administrative_menus.3F)
3. Revert to the default Theme (currently *Twenty Eleven*), using a similar metho... |
50,757 | <p>I'm new in WordPress
what I want is my website only can be opened by who was invited by me..
and but I want using an image as my invitation,, not mere a link..
so the image is used to login password
but I want to member's comments also connected to their Facebook and or twitter account</p>
<p>I will create just 5 t... | [
{
"answer_id": 50777,
"author": "cpilko",
"author_id": 7937,
"author_profile": "https://wordpress.stackexchange.com/users/7937",
"pm_score": 0,
"selected": false,
"text": "<p>I had a \"white screen of death\" problem once when migrating a site. </p>\n\n<p>The root cause turned out to be ... | 2012/05/01 | [
"https://wordpress.stackexchange.com/questions/50757",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15718/"
] | I'm new in WordPress
what I want is my website only can be opened by who was invited by me..
and but I want using an image as my invitation,, not mere a link..
so the image is used to login password
but I want to member's comments also connected to their Facebook and or twitter account
I will create just 5 to 6 pages ... | 1. Add the following to `wp_config.php`:
```
define( 'WP_DEBUG', true );
```
2. [Reset the Plugins folder](http://codex.wordpress.org/FAQ_Troubleshooting#How_to_deactivate_all_plugins_when_not_able_to_access_the_administrative_menus.3F)
3. Revert to the default Theme (currently *Twenty Eleven*), using a similar metho... |
50,761 | <p>I read <a href="https://twitter.com/nacin" rel="noreferrer">@nacin's</a> <a href="http://www.slideshare.net/andrewnacin/you-dont-know-query-wordcamp-netherlands-2012" rel="noreferrer">You don't know Query</a> yesterday and was sent down a bit of a querying rabbit hole. Before yesterday, I was (wrongly) using <a href... | [
{
"answer_id": 50762,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 8,
"selected": true,
"text": "<p>You are right to say:</p>\n\n<blockquote>\n <p>Never use <code>query_posts</code> anymore</p>\n</blockquo... | 2012/05/01 | [
"https://wordpress.stackexchange.com/questions/50761",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3877/"
] | I read [@nacin's](https://twitter.com/nacin) [You don't know Query](http://www.slideshare.net/andrewnacin/you-dont-know-query-wordcamp-netherlands-2012) yesterday and was sent down a bit of a querying rabbit hole. Before yesterday, I was (wrongly) using [`query_posts()`](http://codex.wordpress.org/Function_Reference/qu... | You are right to say:
>
> Never use `query_posts` anymore
>
>
>
### pre\_get\_posts
[`pre_get_posts`](http://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) is a filter, for altering **any** query. It is most often used to alter only the 'main query':
```
add_action('pre_get_posts','wpse50761_alt... |
50,770 | <p>I am trying to add javascript when a post has been published so that it's more noticable for my user but I can't figure out what to use.
I tryed with publish_post and save_post, but it doesn't work unless I put die; at the end of the code.
I've tryed so hard to stay out of the wordpress core code, and I really don't... | [
{
"answer_id": 50788,
"author": "Azizur Rahman",
"author_id": 3797,
"author_profile": "https://wordpress.stackexchange.com/users/3797",
"pm_score": 0,
"selected": false,
"text": "<p>Here is an example of how you can have custom message for custom post_type 'book'. Note the array index 6 ... | 2012/05/01 | [
"https://wordpress.stackexchange.com/questions/50770",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15722/"
] | I am trying to add javascript when a post has been published so that it's more noticable for my user but I can't figure out what to use.
I tryed with publish\_post and save\_post, but it doesn't work unless I put die; at the end of the code.
I've tryed so hard to stay out of the wordpress core code, and I really don't ... | To enqueue scripts on the admin side, you should use the [`admin_enqueue_scripts`](http://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts) hook. In this callback I check that are on the appropriate page (i.e. the page where you edit posts / post types), using the passed `$hook` argument.
Optional... |
50,779 | <p>I am making a Wordpress Theme for a website with video tutorials. I would like to put the video that is embedded in the content (with <a href="http://codex.wordpress.org/Embeds">oEmbed</a>) in a apart div.</p>
<p><strong>An example</strong></p>
<p>The full content (output from <code>the_content()</code>) is someth... | [
{
"answer_id": 50780,
"author": "Paul Wenzel",
"author_id": 14356,
"author_profile": "https://wordpress.stackexchange.com/users/14356",
"pm_score": -1,
"selected": false,
"text": "<p>If you are attempting to use oEmbed in your Wordpress theme template, try this:</p>\n\n<pre><code><asi... | 2012/05/01 | [
"https://wordpress.stackexchange.com/questions/50779",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15725/"
] | I am making a Wordpress Theme for a website with video tutorials. I would like to put the video that is embedded in the content (with [oEmbed](http://codex.wordpress.org/Embeds)) in a apart div.
**An example**
The full content (output from `the_content()`) is something like this:
```
<p><iframe src="http://player.vi... | The [`embed_oembed_html`](http://core.trac.wordpress.org/browser/tags/3.3.2/wp-includes/media.php#L1183) filter runs before an oEmbed resource's HTML is outputted, so you could hook into this and wrap the output in a `div` as below. I can't think of a simple way of wrapping the other content.
```
add_filter('embed_oem... |
50,783 | <p>Not sure if im going about this in the right way but, overall, ive been told to create, kind of like a news box on my home page and so, the "latest news" is going to be this clients posts.</p>
<p>now i know i can control <code>the_excerpts();</code> content length etc but, i cant seem to find any way for it to also... | [
{
"answer_id": 50794,
"author": "SickHippie",
"author_id": 5434,
"author_profile": "https://wordpress.stackexchange.com/users/5434",
"pm_score": 2,
"selected": false,
"text": "<p>Have you tried using <code>get_the_post_thumbnail()</code>? You can read more about it on the <a href=\"http... | 2012/05/01 | [
"https://wordpress.stackexchange.com/questions/50783",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12944/"
] | Not sure if im going about this in the right way but, overall, ive been told to create, kind of like a news box on my home page and so, the "latest news" is going to be this clients posts.
now i know i can control `the_excerpts();` content length etc but, i cant seem to find any way for it to also allow an image.
whe... | Ensure that your Theme supports [Post Thumbnails](http://codex.wordpress.org/Post_Thumbnails), and that the client sets a "Featured Image" for each post. Then, combine [`the_excerpt()`](http://codex.wordpress.org/Function_Reference/the_excerpt) with [`the_post_thumbnail()`](http://codex.wordpress.org/Function_Reference... |
50,827 | <p>I want to be able to select a subscriber an author of a post in the admin so it displays their name as having written the post, but I do not want to give them any additional privileges (if they login the only thing they can access is their profile).</p>
<p>Is there a simple way to do this without having to change r... | [
{
"answer_id": 50870,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 1,
"selected": false,
"text": "<p>This is a <a href=\"https://wordpress.stackexchange.com/a/39107/12615\">code linked</a> by @Innate in a comm... | 2012/05/02 | [
"https://wordpress.stackexchange.com/questions/50827",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1063/"
] | I want to be able to select a subscriber an author of a post in the admin so it displays their name as having written the post, but I do not want to give them any additional privileges (if they login the only thing they can access is their profile).
Is there a simple way to do this without having to change roles and c... | This is a simple hack I wrote in a similar situation. It will display all the `Subscribers` in the `Author` dropdown on edit/add post/page, from where you can select any one you want. I think it should work for you...
```
add_filter('wp_dropdown_users', 'MySwitchUser');
function MySwitchUser($output)
{
//global $... |
50,857 | <p>I want to list 'n' number of posts (ordered by latest first) -- post's title linked to the post's permalink -- from a tag on my WordPress blog. I also want to assign each link its own class or ID.</p>
<p>I checked this doc on <a href="http://codex.wordpress.org/Template_Tags/get_posts" rel="nofollow">WordPress Code... | [
{
"answer_id": 50865,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 1,
"selected": false,
"text": "<p><code>get_posts()</code> is for 'secondary' loops - ones that exist along-side the main Loop, usually in ... | 2012/05/02 | [
"https://wordpress.stackexchange.com/questions/50857",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10691/"
] | I want to list 'n' number of posts (ordered by latest first) -- post's title linked to the post's permalink -- from a tag on my WordPress blog. I also want to assign each link its own class or ID.
I checked this doc on [WordPress Codex](http://codex.wordpress.org/Template_Tags/get_posts), which is very relevant to wha... | I don't know PHP, so'll try to explain after showing you the example PHP code that's needed to do what's asked in the question.
**CODE:**
```
<!-- Featured Posts -->
<div id="featured-posts">
<?php
$count = 0;
$some_featured_posts = new WP_Query(array('tag' => 'example2', 'posts_per_page' => 7));
while ($... |
50,873 | <p>Here is what I am doing:</p>
<p>I Added wordpress media upload with iframe popup when a button or link clicked. And with click of insert into post the image url placed on a textbox. </p>
<p><strong><code>send_to_editor()</code> function handles image insertion to editor</strong></p>
<pre><code>window.send_to_edit... | [
{
"answer_id": 50934,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": true,
"text": "<p>only overwrite the send_to_editor function when your link or button is click but store the old function to re... | 2012/05/02 | [
"https://wordpress.stackexchange.com/questions/50873",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3094/"
] | Here is what I am doing:
I Added wordpress media upload with iframe popup when a button or link clicked. And with click of insert into post the image url placed on a textbox.
**`send_to_editor()` function handles image insertion to editor**
```
window.send_to_editor = function(html) {
var imgurl = jQuery('img'... | only overwrite the send\_to\_editor function when your link or button is click but store the old function to restore it so try this on a click event:
```
//store old send to editor function
window.restore_send_to_editor = window.send_to_editor;
//overwrite send to editor function
window.send_to_editor = function(html)... |
50,876 | <p>Is it possible for the_category to display a post count within a post.</p>
<p>Looks like Posted In: Category Name (3),Category Name (2) etc etc</p>
<p>Possible or not?</p>
<p>I would just use wp_list_categories but it needs to appear on a post by post basis like this post is posted in category x and y not just al... | [
{
"answer_id": 50934,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": true,
"text": "<p>only overwrite the send_to_editor function when your link or button is click but store the old function to re... | 2012/05/02 | [
"https://wordpress.stackexchange.com/questions/50876",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7384/"
] | Is it possible for the\_category to display a post count within a post.
Looks like Posted In: Category Name (3),Category Name (2) etc etc
Possible or not?
I would just use wp\_list\_categories but it needs to appear on a post by post basis like this post is posted in category x and y not just all of them... | only overwrite the send\_to\_editor function when your link or button is click but store the old function to restore it so try this on a click event:
```
//store old send to editor function
window.restore_send_to_editor = window.send_to_editor;
//overwrite send to editor function
window.send_to_editor = function(html)... |
50,877 | <p>My website file structure is like this:</p>
<pre><code>index.php
wp/wp files ...
</code></pre>
<p>In general in Site Address (URL) I have ...site.com</p>
<p>In index.php I have:</p>
<pre><code> define('WP_USE_THEMES', true);
require('./wp/wp-blog-header.php');
</code></pre>
<p>Everything works fine but f... | [
{
"answer_id": 50888,
"author": "mor7ifer",
"author_id": 11740,
"author_profile": "https://wordpress.stackexchange.com/users/11740",
"pm_score": 1,
"selected": false,
"text": "<p>You should be able to regex it with <code>/wp/(wp-admin/.*)</code> and point that to <code>/$1</code>, thus r... | 2012/05/02 | [
"https://wordpress.stackexchange.com/questions/50877",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14418/"
] | My website file structure is like this:
```
index.php
wp/wp files ...
```
In general in Site Address (URL) I have ...site.com
In index.php I have:
```
define('WP_USE_THEMES', true);
require('./wp/wp-blog-header.php');
```
Everything works fine but for wp-admin i have ...site.com/wp/wp-admin/
My question... | You should be able to regex it with `/wp/(wp-admin/.*)` and point that to `/$1`, thus removing the /wp/. You can do this either via `.htaccess` or via wordpress' rewrite API. |
50,883 | <p>I'm trying to pull some custom data from a <a href="http://www.cart66.com" rel="nofollow">Cart66</a> table.</p>
<p>My code works whenever I pull results from standard WP table in (my array is populated and the print_r shows that data), but not with any Cart66 tables (it prints an empty array).</p>
<p>I am absolute... | [
{
"answer_id": 50884,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 3,
"selected": true,
"text": "<p>you do not have to specify the $wpdb again in your query, but be sure that your table uses the prefix, if it has... | 2012/05/02 | [
"https://wordpress.stackexchange.com/questions/50883",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12660/"
] | I'm trying to pull some custom data from a [Cart66](http://www.cart66.com) table.
My code works whenever I pull results from standard WP table in (my array is populated and the print\_r shows that data), but not with any Cart66 tables (it prints an empty array).
I am absolutely certain that I've got data in these tab... | you do not have to specify the $wpdb again in your query, but be sure that your table uses the prefix, if it has one. if it doesn't, skip the part with the prefix.
also, you should always prepare a manually added query first.
this should do it:
```
global $wpdb;
$query = $wpdb->prepare( "SELECT * FROM %s", "{$wpdb->pr... |
50,887 | <p>Is it possible to create a user account without an email. Just a username?</p>
<p>I saw that there is a plugin to allow multiple authors under one email. Does anyone have any recommendations on other ways to do this. I know this not ideal but I have one user who will posting on behalf of multiple users. Having the ... | [
{
"answer_id": 50895,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>As far as I'm aware, it's not possible via Add New under the Users tab, however, the <a href=\"http://codex.wordpres... | 2012/05/02 | [
"https://wordpress.stackexchange.com/questions/50887",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1538/"
] | Is it possible to create a user account without an email. Just a username?
I saw that there is a plugin to allow multiple authors under one email. Does anyone have any recommendations on other ways to do this. I know this not ideal but I have one user who will posting on behalf of multiple users. Having the user verif... | As far as I'm aware, it's not possible via Add New under the Users tab, however, the [`wp_create_user`](http://codex.wordpress.org/Function_Reference/wp_create_user) function will let you create users without an email address:
```
$username = 'someuser';
$pass = 'swordfish';
$new_user_id = wp_create_user( $username, $... |
50,898 | <p>I've created a Custom Taxonomy and I want to hook a function when User adds new Term to my Custom Taxonomy. Can someone please show me how to use following actions in Wordpress?</p>
<ol>
<li>create_term</li>
<li>edit_term</li>
<li>delete term</li>
</ol>
<p>All these actions are defined in wp-includes/taxonomy.php ... | [
{
"answer_id": 50914,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>There's not much to it, you don't need to return anything. Note that you also can't output anything to the browser, ... | 2012/05/02 | [
"https://wordpress.stackexchange.com/questions/50898",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13540/"
] | I've created a Custom Taxonomy and I want to hook a function when User adds new Term to my Custom Taxonomy. Can someone please show me how to use following actions in Wordpress?
1. create\_term
2. edit\_term
3. delete term
All these actions are defined in wp-includes/taxonomy.php as follows:
```
do_action("create_te... | There's not much to it, you don't need to return anything. Note that you also can't output anything to the browser, that will cause it to fail.
```
function my_create( $term_id, $tt_id, $taxonomy ){
// do some stuff
}
add_action( 'create_term', 'my_create', 10, 3 );
```
You mention using this with a custom taxon... |
50,902 | <p>I'm currently using this code to display a menu of pages. I'm using CSS to target the class <code>current_page_item</code> which works fine until you're on a page with a custom post type. </p>
<p>How can I target that class when the page the user is on is a custom post-type such as news or events?</p>
<pre><code>&... | [
{
"answer_id": 51261,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 2,
"selected": false,
"text": "<p>I believe this has been reported as a bug. The only solutions I've seen is on the trac ticket <a href=\"http://core... | 2012/05/02 | [
"https://wordpress.stackexchange.com/questions/50902",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4588/"
] | I'm currently using this code to display a menu of pages. I'm using CSS to target the class `current_page_item` which works fine until you're on a page with a custom post type.
How can I target that class when the page the user is on is a custom post-type such as news or events?
```
<div id="menu-repeat">
<?php $arg... | If this is for a one-off site, I would suggest doing this with CSS. Philosophically, adding the `current_page_item` class to a menu item when that's not true feels a bit wrong too.
As long as you're using the `body_class()` function on your `<body>` element in the theme, there should be a class called `single-{event}`... |
50,904 | <p>I would like to add the dimensions of each image to the media library tab in the media uploader.</p>
<p>I have a multi-author website, where I <a href="https://wordpress.stackexchange.com/q/46930/14558">require users to add a featured image with minimum dimensions.</a> To make it even easier for them, I would like ... | [
{
"answer_id": 51164,
"author": "Michelle",
"author_id": 16,
"author_profile": "https://wordpress.stackexchange.com/users/16",
"pm_score": 1,
"selected": false,
"text": "<p>[EDIT: This works for the main media library but not the media uploader as requested - I'm going to test and see if... | 2012/05/02 | [
"https://wordpress.stackexchange.com/questions/50904",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14558/"
] | I would like to add the dimensions of each image to the media library tab in the media uploader.
I have a multi-author website, where I [require users to add a featured image with minimum dimensions.](https://wordpress.stackexchange.com/q/46930/14558) To make it even easier for them, I would like to include the dimens... | IMHO, I think there's no much of a solution in the WordPress filters realm...
I managed to make it work using jQuery. Maybe there's a cleaner way to write this, but it is functional as it is now. Tested in WP 3.1 through 3.4-alpha4
```
/*
* Display Image Dimensions on Media Uploader tabs (Gallery and Library)
* A... |
50,911 | <p>How can I make all gallery images to open the high resolution image in a new window?</p>
| [
{
"answer_id": 51064,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p><em>(Update 04.05.2012: Include captions)</em></p>\n\n<p>Let's start with a solution …</p>\n\n<p>There is no filter esp... | 2012/05/02 | [
"https://wordpress.stackexchange.com/questions/50911",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15760/"
] | How can I make all gallery images to open the high resolution image in a new window? | *(Update 04.05.2012: Include captions)*
Let's start with a solution …
There is no filter especially for gallery image links. There is also no filter for the gallery shortcode output. So we have to fake one:
```
add_action( 'after_setup_theme', 'wpse_50911_replace_img_shortcodes' );
/**
* Replace the default shortc... |
50,943 | <p>I am using the Wordpress SEO plug in and for some reason the plug in is not longer adding title tags to any posts or pages. I just updated my theme, and something has changed between this version and the last one regarding the way it works with the Wordpress SEO plugin. I checked the header.php and as far as I can t... | [
{
"answer_id": 50952,
"author": "markratledge",
"author_id": 268,
"author_profile": "https://wordpress.stackexchange.com/users/268",
"pm_score": 2,
"selected": false,
"text": "<p>Try getting rid of the single quotes: <code><?php wp_title(); ?></code></p>\n"
},
{
"answer_id"... | 2012/05/02 | [
"https://wordpress.stackexchange.com/questions/50943",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13390/"
] | I am using the Wordpress SEO plug in and for some reason the plug in is not longer adding title tags to any posts or pages. I just updated my theme, and something has changed between this version and the last one regarding the way it works with the Wordpress SEO plugin. I checked the header.php and as far as I can tell... | It turns out there was an issue with a plug in (Wordpress SEO) and the theme. I had to click the check box for "enable title rewrite" within the plug in settings in order to get it to work. |
50,945 | <p>I am asking for advice on best practices on how to write this code. Currently I have simple theme options with text fields, outputting the info in my template. I am currently using this code for the settings api and sanitization of the plain text. My questions is, an additional settings field is a website field, and... | [
{
"answer_id": 51239,
"author": "Pierre",
"author_id": 14490,
"author_profile": "https://wordpress.stackexchange.com/users/14490",
"pm_score": 3,
"selected": true,
"text": "<p>Instead of using add_settings_section() and add_settings_field() every time, create a function that returns an a... | 2012/05/03 | [
"https://wordpress.stackexchange.com/questions/50945",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4273/"
] | I am asking for advice on best practices on how to write this code. Currently I have simple theme options with text fields, outputting the info in my template. I am currently using this code for the settings api and sanitization of the plain text. My questions is, an additional settings field is a website field, and al... | Instead of using add\_settings\_section() and add\_settings\_field() every time, create a function that returns an array of options for example:
```
function my_theme_options() {
$options = array();
$options[] = array(
'id' => 'ID',
'title' => 'Title',
'type' => 'text_f... |
50,970 | <p>I have a personal blog where I write general posts. I decided I'd like to seldom post about some other topic (let's say it's cats), that interests a very different audience then my current one. So I want to sometimes write about cats, but I want those cats posts not to appear in the main posts page on my home page. ... | [
{
"answer_id": 50979,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 1,
"selected": false,
"text": "<p>The best way would be to just add a cats category and filter those out from the home page using the pre_get_posts ... | 2012/05/03 | [
"https://wordpress.stackexchange.com/questions/50970",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4927/"
] | I have a personal blog where I write general posts. I decided I'd like to seldom post about some other topic (let's say it's cats), that interests a very different audience then my current one. So I want to sometimes write about cats, but I want those cats posts not to appear in the main posts page on my home page. I'd... | The best way would be to just add a cats category and filter those out from the home page using the pre\_get\_posts filter.
```
function kill_kittens( $query ) {
if ( $query->is_home ) {
$query->set( 'cat', '-23' ); //assumes the cats category id is 23
}
}
add_action( 'pre_get_posts', 'kill_kittens' );... |
50,980 | <p>we have a couple of custom meta boxes for product (custom post type).
one custom meta box key is area_required_width, and we have numbers input for it when publishing products, now we want to have a dropdown including <5, 5-10, 10-20, 20-50, >50 to search this key value of area_required_width at frontend for user... | [
{
"answer_id": 50979,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 1,
"selected": false,
"text": "<p>The best way would be to just add a cats category and filter those out from the home page using the pre_get_posts ... | 2012/05/03 | [
"https://wordpress.stackexchange.com/questions/50980",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15781/"
] | we have a couple of custom meta boxes for product (custom post type).
one custom meta box key is area\_required\_width, and we have numbers input for it when publishing products, now we want to have a dropdown including <5, 5-10, 10-20, 20-50, >50 to search this key value of area\_required\_width at frontend for users.... | The best way would be to just add a cats category and filter those out from the home page using the pre\_get\_posts filter.
```
function kill_kittens( $query ) {
if ( $query->is_home ) {
$query->set( 'cat', '-23' ); //assumes the cats category id is 23
}
}
add_action( 'pre_get_posts', 'kill_kittens' );... |
50,992 | <p>Wordpress does not use sessions. </p>
<p>I always wondered what mechanism does WP use to maintain a user state when user goes from page to page?</p>
| [
{
"answer_id": 50996,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 4,
"selected": false,
"text": "<p>It uses bare cookies and stores the login state information client side.</p>\n\n<p><img src=\"https://i.stack.imgu... | 2012/05/03 | [
"https://wordpress.stackexchange.com/questions/50992",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14967/"
] | Wordpress does not use sessions.
I always wondered what mechanism does WP use to maintain a user state when user goes from page to page? | It uses bare cookies and stores the login state information client side.

+
=

=
=
>
> wordpress\_7339a175323c25a8547b5a6d26c49afa=yourusername%7C1457109155%7C170f103ef3dc57cdb18... |
50,995 | <p>What is the best way of linking to WordPress pages with PHP? Considering that I move the page from a local server to a live server to another URL?</p>
<pre><code><a href="/wordpress/services" title="Read More" class="yellowButton">Read more</a>
</code></pre>
<p>How could you replace this code with PHP... | [
{
"answer_id": 51040,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 4,
"selected": true,
"text": "<h1>Page Permalink from $id</h1>\n\n<p>If you know the Page <code>$id</code>, use <a href=\"http://codex.wordpr... | 2012/05/03 | [
"https://wordpress.stackexchange.com/questions/50995",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14625/"
] | What is the best way of linking to WordPress pages with PHP? Considering that I move the page from a local server to a live server to another URL?
```
<a href="/wordpress/services" title="Read More" class="yellowButton">Read more</a>
```
How could you replace this code with PHP linking to the WordPress page.
```
/... | Page Permalink from $id
=======================
If you know the Page `$id`, use [`get_permalink()`](http://codex.wordpress.org/Function_Reference/get_permalink):
```
<?php $permalink = get_permalink( $id ); ?>
```
Page Permalink from $slug
=========================
If you know the Page `$slug`, such as `/about` (i... |
50,998 | <p>I need a custom WP-Query written that will display a list of paginated pages (custom post type) in a custom order.</p>
<p>I have a custom post type called "courses"
I have a custom post type called "events"</p>
<p>The "courses" custom post type has a meta key called "course_id".
The "events" custom post type has a... | [
{
"answer_id": 51002,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 0,
"selected": false,
"text": "<p>First of all, <a href=\"https://wordpress.stackexchange.com/questions/50761/when-to-use-wp-query-query-po... | 2012/05/03 | [
"https://wordpress.stackexchange.com/questions/50998",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10713/"
] | I need a custom WP-Query written that will display a list of paginated pages (custom post type) in a custom order.
I have a custom post type called "courses"
I have a custom post type called "events"
The "courses" custom post type has a meta key called "course\_id".
The "events" custom post type has a meta key called... | As it's not clearly stated, how (in code) the "related" CPTs are interconnected, I want to post a mostly overseen possibility for CPTs.
When you [`register_post_type()`](http://codex.wordpress.org/Function_Reference/register_post_type), you have the argument of `hierarchical` that should be set to `true` to allow for ... |
51,004 | <p>I am running a fresh install of Wordpress 3.3.2 and the only plugin enabled is one I'm developing, but I can't seem to get past a permissions issue in <code>add_menu_page</code>. With the exception of using anonymous functions instead of named functions, I'm following the <a href="http://codex.wordpress.org/Function... | [
{
"answer_id": 51007,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 5,
"selected": true,
"text": "<p>You want the <code>admin_menu</code> hook, rather than <code>admin_init</code>. </p>\n\n<p>Also, you shoul... | 2012/05/03 | [
"https://wordpress.stackexchange.com/questions/51004",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1571/"
] | I am running a fresh install of Wordpress 3.3.2 and the only plugin enabled is one I'm developing, but I can't seem to get past a permissions issue in `add_menu_page`. With the exception of using anonymous functions instead of named functions, I'm following the [documentation](http://codex.wordpress.org/Function_Refere... | You want the `admin_menu` hook, rather than `admin_init`.
Also, you shouldn't use anonymous functions. Instead, use:
```
function wpse51004_add_menu_page() {
add_menu_page('Some Page', 'Some Page', 'manage_options', 'some-slug', 'wpse51004_some_page_callback');
};
add_action('admin_menu', 'wpse51004_add_menu_pag... |
51,005 | <p>For some reason my RSS feed is repeating the site title twice without a space, obviously quite annoying.</p>
<p>BlognameBlogname for example.</p>
<p>Is there any hook i can use to have a custom title for the RSS Feed?</p>
<p>So i could have a title 'This is My RSS Feed for Blogname' or anything i wanted?</p>
<p>... | [
{
"answer_id": 51007,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 5,
"selected": true,
"text": "<p>You want the <code>admin_menu</code> hook, rather than <code>admin_init</code>. </p>\n\n<p>Also, you shoul... | 2012/05/03 | [
"https://wordpress.stackexchange.com/questions/51005",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7384/"
] | For some reason my RSS feed is repeating the site title twice without a space, obviously quite annoying.
BlognameBlogname for example.
Is there any hook i can use to have a custom title for the RSS Feed?
So i could have a title 'This is My RSS Feed for Blogname' or anything i wanted?
Is this possible or am i stuck ... | You want the `admin_menu` hook, rather than `admin_init`.
Also, you shouldn't use anonymous functions. Instead, use:
```
function wpse51004_add_menu_page() {
add_menu_page('Some Page', 'Some Page', 'manage_options', 'some-slug', 'wpse51004_some_page_callback');
};
add_action('admin_menu', 'wpse51004_add_menu_pag... |
51,025 | <p>I have a custom taxonomy for a group of posts, and I also have a need to show these posts on a custom page template. I want to show one post at a time, with pagination, so that the user can click through them like a slide show. </p>
<p>My template correctly grabs the right category and display one (the first) post,... | [
{
"answer_id": 51026,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p><code>previous_posts()</code> and <code>next_posts()</code> are deprecated. Try these instead:</p>\n\n<p><a href=\... | 2012/05/03 | [
"https://wordpress.stackexchange.com/questions/51025",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34828/"
] | I have a custom taxonomy for a group of posts, and I also have a need to show these posts on a custom page template. I want to show one post at a time, with pagination, so that the user can click through them like a slide show.
My template correctly grabs the right category and display one (the first) post, but when ... | query\_posts = [\_your\_doing\_it\_wrong](https://wordpress.stackexchange.com/q/50761/251)
==========================================================================================
as soon as you throw in that nasty query\_posts you are killing off all the global variables and your paging will not work.
change:
```... |
51,031 | <p>How can I connect to the database using the wp-config.php file ?</p>
<p>I'm trying to make a script more Wordpress friendly, and I need to connect to the database, but without installing the script as a plugin.</p>
<p>Basically I have on my script</p>
<pre><code>$host = "xxxxxxxxxxx"; //database location
$user = ... | [
{
"answer_id": 51079,
"author": "akamaozu",
"author_id": 13176,
"author_profile": "https://wordpress.stackexchange.com/users/13176",
"pm_score": 5,
"selected": true,
"text": "<p>Using the defines the user sets in wp-config:</p>\n\n<pre><code>mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);\... | 2012/05/03 | [
"https://wordpress.stackexchange.com/questions/51031",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15704/"
] | How can I connect to the database using the wp-config.php file ?
I'm trying to make a script more Wordpress friendly, and I need to connect to the database, but without installing the script as a plugin.
Basically I have on my script
```
$host = "xxxxxxxxxxx"; //database location
$user = "xxxxxxxxxxx"; //database us... | Using the defines the user sets in wp-config:
```
mysql_connect(DB_HOST, DB_USER, DB_PASSWORD);
```
**EDIT**:
Since your script is outside the Wordpress environment, what you want to do is initiate it before using the defines in wp-config.
```
require_once('./path/to/the/wp-config.php');
mysql_connect(DB_HOST, DB_U... |
51,036 | <p>How do you create %post_type%/%postname%/ permalink structure?</p>
<p><strong>This is what is not working:</strong></p>
<p>eg. ( domain.com/blog/ ) -> <em>"click on post"</em> -> ( domain.com/post-name ) </p>
<p><strong>How do I make "blog post" permalinks work like this...</strong></p>
<p>eg. ( domain.com/blog/... | [
{
"answer_id": 51048,
"author": "mor10",
"author_id": 14325,
"author_profile": "https://wordpress.stackexchange.com/users/14325",
"pm_score": 3,
"selected": true,
"text": "<p>Beyond the fact that disabling 'pretty' permalinks in the Settings > Permalink page disables pretty permalinks fo... | 2012/05/03 | [
"https://wordpress.stackexchange.com/questions/51036",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14625/"
] | How do you create %post\_type%/%postname%/ permalink structure?
**This is what is not working:**
eg. ( domain.com/blog/ ) -> *"click on post"* -> ( domain.com/post-name )
**How do I make "blog post" permalinks work like this...**
eg. ( domain.com/blog/ ) -> *"click on post"* -> ( domain.com/**blog**/post-name )
-... | Beyond the fact that disabling 'pretty' permalinks in the Settings > Permalink page disables pretty permalinks for all post types and taxonomies, the options do not effect custom post types or taxonomies.
If you set the permalinks to `blog/%postname%` then your posts will have the structure: `www.yoursite.com/blog/he... |
51,076 | <p>I'm trying to find a way that changes the classes of the different nav menu items, based on the value of a meta key in the page.</p>
<p>The menu currently looks like this:</p>
<pre><code><li class="menu-item-1">Menu item 1</li>
<li class="menu-item-2">Menu item 2</li>
<li class="menu-ite... | [
{
"answer_id": 51221,
"author": "janw",
"author_id": 10911,
"author_profile": "https://wordpress.stackexchange.com/users/10911",
"pm_score": 0,
"selected": false,
"text": "<p>Try this, not tested.<br/>\nI replaced <code>$post->ID</code> with <code>$item->ID</code>, should work.</p>... | 2012/05/03 | [
"https://wordpress.stackexchange.com/questions/51076",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2830/"
] | I'm trying to find a way that changes the classes of the different nav menu items, based on the value of a meta key in the page.
The menu currently looks like this:
```
<li class="menu-item-1">Menu item 1</li>
<li class="menu-item-2">Menu item 2</li>
<li class="menu-item-3">Menu item 3</li>
<li class="menu-item-4">Me... | Your code doesn't because the global `$post` refers to the post/page being viewed (if there is one...). What is passed with `nav_menu_css_class` is a menu item - this is a particular post type. Among its properties are:
`object` which stores:
* the post type if the link refers to a post
* the taxonomy if the link refe... |
51,077 | <p><strong>Preamble</strong></p>
<p><em>I tried to make sure this question was not asked before. I'm new to using StackExchange so I may have failed in doing so. I don't mind rebukes; thick skin and I learn fast :)</em></p>
<p><strong>THE PROBLEM</strong></p>
<p>I wrote a function and placed in my theme's functions.... | [
{
"answer_id": 51082,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 0,
"selected": false,
"text": "<p>From within your external script try calling <code>wp-load.php</code> - example;</p>\n\n<pre><code>require( '../y... | 2012/05/04 | [
"https://wordpress.stackexchange.com/questions/51077",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13176/"
] | **Preamble**
*I tried to make sure this question was not asked before. I'm new to using StackExchange so I may have failed in doing so. I don't mind rebukes; thick skin and I learn fast :)*
**THE PROBLEM**
I wrote a function and placed in my theme's functions.php
```
function serverConnect() {
$serverAccess = mys... | You're much better off with using a (mu-)plugin. Just add a folder named `mu-plugins` in your `wp-content` directory and place your files there. Then add a plugin header comment to it:
```
<?php
/**
* Plugin Name: Some Name
* Plugin URI: http://example.com
* Description: Loads something
* Version: 0.1
* Author: A... |
51,091 | <p>Here's a custom wordpress admin page I created:-</p>
<pre><code>// code located in my custom plugin's php file
function my_special_function(){
echo '<div> Hello World </div>';
}
function my_menu_page(){
$page_title = "Hello Page Title";
$menu_title = "Hello Menu Title";
$capability ... | [
{
"answer_id": 51082,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 0,
"selected": false,
"text": "<p>From within your external script try calling <code>wp-load.php</code> - example;</p>\n\n<pre><code>require( '../y... | 2012/05/04 | [
"https://wordpress.stackexchange.com/questions/51091",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15805/"
] | Here's a custom wordpress admin page I created:-
```
// code located in my custom plugin's php file
function my_special_function(){
echo '<div> Hello World </div>';
}
function my_menu_page(){
$page_title = "Hello Page Title";
$menu_title = "Hello Menu Title";
$capability = "administrator";
$me... | You're much better off with using a (mu-)plugin. Just add a folder named `mu-plugins` in your `wp-content` directory and place your files there. Then add a plugin header comment to it:
```
<?php
/**
* Plugin Name: Some Name
* Plugin URI: http://example.com
* Description: Loads something
* Version: 0.1
* Author: A... |
51,093 | <p>I have a feed link <a href="http://www.wdcdn.net/rss/presentation/library/client/iowa/id/128b053b916ea1f7f20233e8a26bc45d" rel="nofollow">http://www.wdcdn.net/rss/presentation/library/client/iowa/id/128b053b916ea1f7f20233e8a26bc45d</a> and I have to read all the elements of feed including credits, here is how the fe... | [
{
"answer_id": 51094,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 0,
"selected": false,
"text": "<p>anyway, if you do something like this:</p>\n\n<pre><code>$medias = $node->getElementsByTagName('media');\nfo... | 2012/05/04 | [
"https://wordpress.stackexchange.com/questions/51093",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/478/"
] | I have a feed link <http://www.wdcdn.net/rss/presentation/library/client/iowa/id/128b053b916ea1f7f20233e8a26bc45d> and I have to read all the elements of feed including credits, here is how the feed is displayed
```
<item>
<title>
<![CDATA[Dave's Lawnmower Bish Bash]]>
</title>
<link>http://cache.wdcdn.... | WordPress bundles and wraps SimplePie class for feed download, caching and processing. Retrieving namespaced data with it would be something like this:
```
$feed = fetch_feed( 'http://www.wdcdn.net/rss/presentation/library/client/iowa/id/128b053b916ea1f7f20233e8a26bc45d' );
$items = $feed->get_items();
foreach ( $it... |
51,103 | <p>I am trying to dynamically get the facebook php sdk from my current themes folder.</p>
<p>I am writing this in my functions.php, but all my attempts break the site.</p>
<p>See my attempts below...</p>
<pre><code>require template_url('/') . 'facebook-php-sdk-6c82b3f/src/facebook.php';
require get_bloginfo('templa... | [
{
"answer_id": 51104,
"author": "Pierre",
"author_id": 14490,
"author_profile": "https://wordpress.stackexchange.com/users/14490",
"pm_score": 3,
"selected": true,
"text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/get_template_directory\" rel=\"nofollow\"><code>get_... | 2012/05/04 | [
"https://wordpress.stackexchange.com/questions/51103",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11327/"
] | I am trying to dynamically get the facebook php sdk from my current themes folder.
I am writing this in my functions.php, but all my attempts break the site.
See my attempts below...
```
require template_url('/') . 'facebook-php-sdk-6c82b3f/src/facebook.php';
require get_bloginfo('template_url') . 'facebook-php-sdk... | Use [`get_template_directory()`](http://codex.wordpress.org/Function_Reference/get_template_directory) instead , require doesn't work with http:// |
51,122 | <p>I've gone through a few of the other similar topics but any of the solutions won't work for me.</p>
<p>Basically I only want to show an <li></li> if the custom field has had information added into it.</p>
<p>Here's my code, even if you don't give me an answer could you point me in the correct direction as to how t... | [
{
"answer_id": 51104,
"author": "Pierre",
"author_id": 14490,
"author_profile": "https://wordpress.stackexchange.com/users/14490",
"pm_score": 3,
"selected": true,
"text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/get_template_directory\" rel=\"nofollow\"><code>get_... | 2012/05/04 | [
"https://wordpress.stackexchange.com/questions/51122",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12578/"
] | I've gone through a few of the other similar topics but any of the solutions won't work for me.
Basically I only want to show an -
if the custom field has had information added into it.
Here's my code, even if you don't give me an answer could you point me in the correct direction as to how to do this.
```
<div cl... | Use [`get_template_directory()`](http://codex.wordpress.org/Function_Reference/get_template_directory) instead , require doesn't work with http:// |
51,134 | <p>I have a weird bug on the dashboard: the dashboard says there are a total of 3 posts, but the list is empty and says "No posts found" (see image below)</p>
<p><img src="https://i.stack.imgur.com/b6AoZ.png" alt="enter image description here"></p>
<p>It's a fresh install on a shared Windows hosting, using SQL Server... | [
{
"answer_id": 51167,
"author": "SickHippie",
"author_id": 5434,
"author_profile": "https://wordpress.stackexchange.com/users/5434",
"pm_score": 0,
"selected": false,
"text": "<p>Since you're using MSSQL, repair is a little different. <strong>Make sure you backup your database</strong> ... | 2012/05/04 | [
"https://wordpress.stackexchange.com/questions/51134",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1155/"
] | I have a weird bug on the dashboard: the dashboard says there are a total of 3 posts, but the list is empty and says "No posts found" (see image below)

It's a fresh install on a shared Windows hosting, using SQL Server as the database with the [WP D... | Try the fix posted here: <http://sourceforge.net/tracker/?func=detail&aid=3485384&group_id=315685&atid=1328061>
It worked for me.
>
> translations.php line 726
> Change this: $pattern =
> '/LIMIT\s\*(\d+)((\s\*,?\s\*)(\d+)*)(;{0,1})$/is'; to this: $pattern =
> '/LIMIT\s*(\d+)((\s\*,?\s\*)(\d+)\*);{0,1}$/is';
>
... |
51,145 | <p>This may seem like a silly question but I cannot figure this out.</p>
<p>I've created a variable in my functions.php - and I'm trying to echo it in my template files.</p>
<p>I'm guessing it's because of scope.</p>
<p>What's the simpliest what to echo a variable or create a function to allow me to output this face... | [
{
"answer_id": 51148,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 5,
"selected": true,
"text": "<p>If you don't have access to the value, it's likely a scope issue. Make sure you globalize it first:</p>\n\n<pre><code... | 2012/05/04 | [
"https://wordpress.stackexchange.com/questions/51145",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11327/"
] | This may seem like a silly question but I cannot figure this out.
I've created a variable in my functions.php - and I'm trying to echo it in my template files.
I'm guessing it's because of scope.
What's the simpliest what to echo a variable or create a function to allow me to output this facebook ID in various templ... | If you don't have access to the value, it's likely a scope issue. Make sure you globalize it first:
```
<?php
global $fb_app_id;
echo $fb_app_id;
?>
```
Alternatively
-------------
I'm not a fan of global variables, so the alternative I recommend is using WordPress' built-in filter mechanism. You add the filter in ... |
51,157 | <p>I want to add a logout button on the side admin menu (because I disable the admin bar for the users). So I thought add_menu_page() is the way to do it, but how to add the link to the regarded function?</p>
<p>Here is what i did:</p>
<pre><code>add_action( 'admin_menu', 'my_logout_menu' );
function my_logout_menu(... | [
{
"answer_id": 51160,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>Am I using the correct approach? or there are other easier ways to do it?</p>\n</blockquote>\n\n<p>If... | 2012/05/04 | [
"https://wordpress.stackexchange.com/questions/51157",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14728/"
] | I want to add a logout button on the side admin menu (because I disable the admin bar for the users). So I thought add\_menu\_page() is the way to do it, but how to add the link to the regarded function?
Here is what i did:
```
add_action( 'admin_menu', 'my_logout_menu' );
function my_logout_menu() {
add_menu_page( ... | I'm using this as a custom logout button, it also displays a random quote before logout the user. I think you can adapt it to your needs by removing what you don't need.
Instructions:
Copy the code below and save as users-logout.php
Create a folder called users-logout, upload the file and the images below to work.
An... |
51,169 | <p>I'm using the <code>trash_post</code> hook to set a flag in a custom table to indicate that this item is "deleted", but when the user chooses to restore that post, what hook can I use for that? I couldn't find anything on this page <a href="https://codex.wordpress.org/Plugin_API/Action_Reference" rel="nofollow">http... | [
{
"answer_id": 51173,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 2,
"selected": false,
"text": "<p>When a post is untrashed, WordPress calls <a href=\"http://core.trac.wordpress.org/browser/tags/3.3/wp-in... | 2012/05/04 | [
"https://wordpress.stackexchange.com/questions/51169",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14656/"
] | I'm using the `trash_post` hook to set a flag in a custom table to indicate that this item is "deleted", but when the user chooses to restore that post, what hook can I use for that? I couldn't find anything on this page <https://codex.wordpress.org/Plugin_API/Action_Reference>, but maybe there's another way to solve t... | Looking at the code for WP 3.3.2, it seems that `trash_post` is actually `wp_trash_post`. From the `wp_trash_post()` function in `/wp-includes/post.php`:
```
do_action('wp_trash_post', $post_id);
add_post_meta($post_id,'_wp_trash_meta_status', $post['post_status']);
add_post_meta($post_id,'_wp_trash_meta_time', time(... |
51,205 | <p>I'm writing a plugin and am trying to figure out how to add data to the end of a post based on some Custom Meta Information.</p>
<p>So i've done this so far:</p>
<pre><code>add_filter('the_content', 'AppendMeta');
</code></pre>
<p>And here is the "AppendMeta" function</p>
<pre><code>AppendMeta($content) {
ec... | [
{
"answer_id": 51206,
"author": "Talon",
"author_id": 10298,
"author_profile": "https://wordpress.stackexchange.com/users/10298",
"pm_score": 4,
"selected": true,
"text": "<p>Nevermind, found out I can use <code>get_the_ID();</code>.</p>\n\n<p>This function will return the post id inside... | 2012/05/05 | [
"https://wordpress.stackexchange.com/questions/51205",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10298/"
] | I'm writing a plugin and am trying to figure out how to add data to the end of a post based on some Custom Meta Information.
So i've done this so far:
```
add_filter('the_content', 'AppendMeta');
```
And here is the "AppendMeta" function
```
AppendMeta($content) {
echo $content; // Echo out post content
$P... | Nevermind, found out I can use `get_the_ID();`.
This function will return the post id inside the `the_content` filter. The function simply declares the global `$post` object and returns its ID.
```
add_filter('the_content', 'wpse51205_content')
wpse51205_content($content) {
echo $content; // Echo out post content... |
51,213 | <p>I have a wordpress site. I have a div that I only want to appear on the homepage (in the header). What type of php if statement do i need...</p>
<p>In other words:</p>
<p>only show .... in the header of the main blog index page. Problem is the header itself is loaded in every page. </p>
<p>Thanks!</p>
| [
{
"answer_id": 51214,
"author": "iambriansreed",
"author_id": 2782,
"author_profile": "https://wordpress.stackexchange.com/users/2782",
"pm_score": 3,
"selected": true,
"text": "<p>See: <a href=\"http://codex.wordpress.org/Function_Reference/is_home\" rel=\"nofollow\">http://codex.wordpr... | 2012/05/05 | [
"https://wordpress.stackexchange.com/questions/51213",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18085/"
] | I have a wordpress site. I have a div that I only want to appear on the homepage (in the header). What type of php if statement do i need...
In other words:
only show .... in the header of the main blog index page. Problem is the header itself is loaded in every page.
Thanks! | See: <http://codex.wordpress.org/Function_Reference/is_home>
```
<?php if(is_home()): ?>
<div>Your div.</div>
<?php endif; ?>
``` |
51,227 | <p>I've added a custom input field with <code>login_form</code> hook.</p>
<p>So, I need to process the post data to validate.
I've used the <code>lostpassword_post</code> for <code>lostpassword_form</code> and works great, but I cant find a hook to validate my data at login form.</p>
<p>Any Ideas?</p>
| [
{
"answer_id": 59036,
"author": "Giraldi",
"author_id": 1044,
"author_profile": "https://wordpress.stackexchange.com/users/1044",
"pm_score": 0,
"selected": false,
"text": "<p>Haven't really tested this but I'm just guessing by how I do it with the <em>registration & profile pages</e... | 2012/05/05 | [
"https://wordpress.stackexchange.com/questions/51227",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3294/"
] | I've added a custom input field with `login_form` hook.
So, I need to process the post data to validate.
I've used the `lostpassword_post` for `lostpassword_form` and works great, but I cant find a hook to validate my data at login form.
Any Ideas? | Use the action `'login_init'` to catch all calls to `wp-login.php`.
Sample code:
```
add_action( 'login_init', 'wpse_51227_validate_custom_field' );
function wpse_51227_validate_custom_field()
{
if ( ! isset ( $_POST['special_custom'] )
return;
if ( ! is_numeric( $_POST['special_custom'] )
/... |
51,230 | <p>When I try to use <code>get_page()</code> function I get the error message:</p>
<pre><code>Only variables can be passed by reference
</code></pre>
<p> </p>
<p>But what doesn't make sense is that I can use a work around that blows my mind:</p>
<h1>First test</h1>
<pre><code>$test1 = get_page(49);
</code></p... | [
{
"answer_id": 51231,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 2,
"selected": true,
"text": "<p>Correct to your first test:</p>\n\n<pre><code>$id = 49;\n$test = get_page( $id );\n</code></pre>\n"
},
{
"a... | 2012/05/05 | [
"https://wordpress.stackexchange.com/questions/51230",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15841/"
] | When I try to use `get_page()` function I get the error message:
```
Only variables can be passed by reference
```
But what doesn't make sense is that I can use a work around that blows my mind:
First test
==========
```
$test1 = get_page(49);
```
**Returns error message**
```
Only variables can be passed by re... | Correct to your first test:
```
$id = 49;
$test = get_page( $id );
``` |
51,233 | <p>Helo,</p>
<p>I would like to restyle/reorganize my Admin Menu Page (wp-admin/nav-menus.php).</p>
<p>What's the best way of doing this? Can I just edit the page directly?</p>
| [
{
"answer_id": 51241,
"author": "Pierre",
"author_id": 14490,
"author_profile": "https://wordpress.stackexchange.com/users/14490",
"pm_score": 1,
"selected": false,
"text": "<p>Editing the the file is not a good idea, it'll be replaced next time you update your wp installation, why don't... | 2012/05/05 | [
"https://wordpress.stackexchange.com/questions/51233",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12085/"
] | Helo,
I would like to restyle/reorganize my Admin Menu Page (wp-admin/nav-menus.php).
What's the best way of doing this? Can I just edit the page directly? | Editing the the file is not a good idea, it'll be replaced next time you update your wp installation, why don't you just enqueue a new css file and overwrite what you want to change, a lot can be accomplished with css without changing the markup.
```
if ( is_admin() ) {
wp_register_style( $handle, $src, $deps, $ve... |
51,234 | <p>I'm using the well-written Oenology theme by Chip Bennett as the Parent to my own Child theme.</p>
<p>In my development process, I've discovered that there are some challenges for people writing Child themes when it comes to controlling styles.</p>
<p>I've just discovered that my main style.css file gets loaded befo... | [
{
"answer_id": 51270,
"author": "Gregory",
"author_id": 15311,
"author_profile": "https://wordpress.stackexchange.com/users/15311",
"pm_score": 2,
"selected": false,
"text": "<p><strike>the only way to guarantee that my styles had final say in the cascade was to include them at the end o... | 2012/05/05 | [
"https://wordpress.stackexchange.com/questions/51234",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15311/"
] | I'm using the well-written Oenology theme by Chip Bennett as the Parent to my own Child theme.
In my development process, I've discovered that there are some challenges for people writing Child themes when it comes to controlling styles.
I've just discovered that my main style.css file gets loaded before every other ... | Just FYI, this question probably borders on **too localized**, as it is specific to the Oenology Theme.
That said, here's where I *think* you're having a problem: Oenology enqueues two style sheets:
1. `style.css`, directly in the document head (thus *before* `wp_head()` is fired)
2. `{varietal}.css`, at `wp_enqueue_... |
51,240 | <p>The theme that I'm developing is basically a portfolio, where the projects are custom post type and they are divided in categories (custom taxonomies). Here is how I'm defining both:</p>
<pre><code>$labels = array(
'name' => _x('My Portfolio', 'post type general name'),
'singular_name' => _x('Portfoli... | [
{
"answer_id": 51245,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 0,
"selected": false,
"text": "<p>The taxonomy templates support <code>taxonomy-{taxonomy}-{slug}.php</code> so have you tried:</p>\n\n<pre><code>t... | 2012/05/05 | [
"https://wordpress.stackexchange.com/questions/51240",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12512/"
] | The theme that I'm developing is basically a portfolio, where the projects are custom post type and they are divided in categories (custom taxonomies). Here is how I'm defining both:
```
$labels = array(
'name' => _x('My Portfolio', 'post type general name'),
'singular_name' => _x('Portfolio Item', 'post type ... | It seems from the OPs answer that the problem was not to do with the template, but using an incorrect url.
To get the link of a taxonomy term you can use [`get_term_link()`](http://codex.wordpress.org/Function_Reference/get_term_link):
```
<a href="<?php echo get_term_link($term,'product_category')?>"><?php echo $t... |
51,257 | <p>I am trying to protect the uploads directory with .htacess. </p>
<p>But when I browse media section in admin panel, I see user/pass popup.<br>
My guess is, WordPress use <code>fopen</code> to find if the file exists. I found mod_rewrite rule allowing <code>fopen</code> but I can't figure out how to use those rules ... | [
{
"answer_id": 51295,
"author": "user983248",
"author_id": 15704,
"author_profile": "https://wordpress.stackexchange.com/users/15704",
"pm_score": 1,
"selected": false,
"text": "<pre><code># Only allow access to this directory if they are coming from your domain; excluding you, your serv... | 2012/05/05 | [
"https://wordpress.stackexchange.com/questions/51257",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15843/"
] | I am trying to protect the uploads directory with .htacess.
But when I browse media section in admin panel, I see user/pass popup.
My guess is, WordPress use `fopen` to find if the file exists. I found mod\_rewrite rule allowing `fopen` but I can't figure out how to use those rules with basic HTTP authentication. ... | ```
# Only allow access to this directory if they are coming from your domain; excluding you, your server, Google and any other IPs
RewriteEngine On
RewriteCond %{REMOTE_ADDR} !^(xxx\.xxx\.xxx\.xxx|xxx\.xxx\xxx\.xxx|66\.249\.)
RewriteCond %{HTTP_HOST} !^(127\.0\.0\.0|localhost) [NC]
RewriteCond %{HTTP_REFERER} !^https?... |
51,263 | <p>When I first began looking into this, <a href="http://skyphe.org/code/wordpress/file-gallery/" rel="nofollow">File Gallery</a> got me much closer to solving the problem. The only issue is that the plugin only displays the generic non-image icon when I upload a file.</p>
<p>Does anyone know of a pre-existing plugin ... | [
{
"answer_id": 51266,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think you will have luck getting it to work with another gallery plugin without altering that plugins code,... | 2012/05/05 | [
"https://wordpress.stackexchange.com/questions/51263",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15299/"
] | When I first began looking into this, [File Gallery](http://skyphe.org/code/wordpress/file-gallery/) got me much closer to solving the problem. The only issue is that the plugin only displays the generic non-image icon when I upload a file.
Does anyone know of a pre-existing plugin that would either work alongside Fil... | WordPress has a native function `wp_mime_type_icon()` in `wp-includes/post.php` that you can use.
Basic example:
```
// $attachment should be a full post object
if ( wp_attachment_is_image( $attachment->ID ) )
{
echo wp_get_attachment_image(
$attachment->ID,
array( 480, 900 ),
FALSE,
... |
51,271 | <p>I'm trying to insert some CSS at the very top of the Current Theme Stylesheet via plugin. (So that the CSS is easily over-ridden by the plugin user).</p>
<p>How would you prepend CSS to the Theme Stylesheet?</p>
<p>Also i'm trying to put some Javascript just before the /body tag in the theme, how would that be ac... | [
{
"answer_id": 51272,
"author": "Pippin",
"author_id": 2418,
"author_profile": "https://wordpress.stackexchange.com/users/2418",
"pm_score": 2,
"selected": true,
"text": "<p>You should never modify the current theme's stylesheet via a plugin. What if the theme gets updated, or the user c... | 2012/05/06 | [
"https://wordpress.stackexchange.com/questions/51271",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10298/"
] | I'm trying to insert some CSS at the very top of the Current Theme Stylesheet via plugin. (So that the CSS is easily over-ridden by the plugin user).
How would you prepend CSS to the Theme Stylesheet?
Also i'm trying to put some Javascript just before the /body tag in the theme, how would that be accomplished? | You should never modify the current theme's stylesheet via a plugin. What if the theme gets updated, or the user changes themes? Not a good idea. Instead, you should have the plugin create a custom css file, which could be located anywhere you wish, even inside of the current theme's folder.
The only way to output inf... |
51,276 | <p>I'm trying to add some CSS to the head part of the CSS but I can't get it to work (I want to add it to the head before the Theme CSS so the plugin user can easily over-ride plugins default CSS without !important over-rides). Here is what I tried:</p>
<pre><code><?php
add_action('wp_head', 'addCSS');
function a... | [
{
"answer_id": 51278,
"author": "Ashfame",
"author_id": 1521,
"author_profile": "https://wordpress.stackexchange.com/users/1521",
"pm_score": 3,
"selected": true,
"text": "<p>You don't call enqueue or register functions hooking into the <code>wp_head</code> hook. At that hook its too lat... | 2012/05/06 | [
"https://wordpress.stackexchange.com/questions/51276",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10298/"
] | I'm trying to add some CSS to the head part of the CSS but I can't get it to work (I want to add it to the head before the Theme CSS so the plugin user can easily over-ride plugins default CSS without !important over-rides). Here is what I tried:
```
<?php
add_action('wp_head', 'addCSS');
function addCSS() {
wp_r... | You don't call enqueue or register functions hooking into the `wp_head` hook. At that hook its too late to add more, I guess, unless you play with priority parameter.
Use the init hook to call `wp_enqueue_*` & `wp_register_*` functions.
Do it like this:
```
<?php
add_action('wp_enqueue_scripts', 'addCSS');
function ... |
51,320 | <p>I want to list images for only user uploaded image. Here is the scenario: </p>
<ol>
<li>Using the image uploader on front end using iframe.</li>
<li>I have added <code>upload_files</code> cap to subscriber level users and want them to see only images they uploaded.</li>
<li><p>I've found this Q <a href="https://wor... | [
{
"answer_id": 51325,
"author": "user983248",
"author_id": 15704,
"author_profile": "https://wordpress.stackexchange.com/users/15704",
"pm_score": 3,
"selected": false,
"text": "<p>This works for me in order to list the items uploaded by a user on the media library.</p>\n\n<pre><code>fun... | 2012/05/06 | [
"https://wordpress.stackexchange.com/questions/51320",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3094/"
] | I want to list images for only user uploaded image. Here is the scenario:
1. Using the image uploader on front end using iframe.
2. I have added `upload_files` cap to subscriber level users and want them to see only images they uploaded.
3. I've found this Q [Restricting users to view only media library items they ha... | The media upload form that i was pulling up via thickbox was `media-upload.php`. So, i had to change the conditional to `if( 'upload.php' != $pagenow && 'media-upload.php' != $pagenow)`. I forgot to look into the obvious place :)
```
// Code originally by @t31os
add_action('pre_get_posts','users_own_attachments');
fu... |
51,330 | <p>I find myself using many of the same snippets of code for my <code>functions.php</code> file in new websites.</p>
<p>Is there a method I can use to create a few different shared <code>functions.php</code> files to use across my websites? I am not referring to a WPMU installation, but completely separate installation... | [
{
"answer_id": 51332,
"author": "Jeremy Jared",
"author_id": 5339,
"author_profile": "https://wordpress.stackexchange.com/users/5339",
"pm_score": 4,
"selected": true,
"text": "<p>If your functions can go in a single file (no images, or linked js/css files), you could add them to mu-plug... | 2012/05/07 | [
"https://wordpress.stackexchange.com/questions/51330",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14558/"
] | I find myself using many of the same snippets of code for my `functions.php` file in new websites.
Is there a method I can use to create a few different shared `functions.php` files to use across my websites? I am not referring to a WPMU installation, but completely separate installations of WordPress with separate da... | If your functions can go in a single file (no images, or linked js/css files), you could add them to mu-plugin file. See the [Must Use Plugins page on Codex](http://codex.wordpress.org/Must_Use_Plugins) for more information.
EXAMPLE:
```
<?php
/*
Plugin Name: CommonCodes
Plugin URI: http://you.com/
Description: A com... |
51,363 | <p>I have been using this site alot for solving my problems, but this time I did not succeed in finding and answer for my problem.</p>
<p>I get and infinite loop when using <code>wp_update_post</code> inside a function that is called on <code>save_post</code>. I know that this is a common issue, but I can't figure out... | [
{
"answer_id": 51364,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 6,
"selected": true,
"text": "<p>You can remove the callback from the <code>save_post</code> hook, update the post and then re-add the call... | 2012/05/07 | [
"https://wordpress.stackexchange.com/questions/51363",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15882/"
] | I have been using this site alot for solving my problems, but this time I did not succeed in finding and answer for my problem.
I get and infinite loop when using `wp_update_post` inside a function that is called on `save_post`. I know that this is a common issue, but I can't figure out how to avoid it.
I want to sav... | You can remove the callback from the `save_post` hook, update the post and then re-add the call back to the hook. The [Codex gives an example](http://codex.wordpress.org/Plugin_API/Action_Reference/save_post#Avoiding_infinite_loops).
```
add_action('save_post', 'wpse51363_save_post');
function wpse51363_save_post($p... |
51,368 | <p>I file all the galleries on my blog under the 'gallery' tag. I use the following code (<a href="https://wordpress.stackexchange.com/a/50963/10691">via</a>) to display the latest 7 gallery posts after the 8th latest post on home page:</p>
<pre><code><!-- Featured post galleries after 8th post -->
<?php
$... | [
{
"answer_id": 51372,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 2,
"selected": true,
"text": "<p>Just use the <code>$count</code> variable that you are incrementing:</p>\n\n<pre><code><?php\n $coun... | 2012/05/07 | [
"https://wordpress.stackexchange.com/questions/51368",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10691/"
] | I file all the galleries on my blog under the 'gallery' tag. I use the following code ([via](https://wordpress.stackexchange.com/a/50963/10691)) to display the latest 7 gallery posts after the 8th latest post on home page:
```
<!-- Featured post galleries after 8th post -->
<?php
$homegallery++;
if ($homegallery... | Just use the `$count` variable that you are incrementing:
```
<?php
$count = 0;
$some_featured_posts = new WP_Query(array('category_name' => 'apps', 'posts_per_page' => 5));
while ($some_featured_posts->have_posts()):
$some_featured_posts->the_post();
$count++;
if( $count <= 2 )
... |
51,386 | <p>How do I create a many-to-many relationship between two custom post types?</p>
<p>Given type A and given type B, I'd like to be able to show all Bs that relate to a given A, and all As that relate to a given B. </p>
| [
{
"answer_id": 51394,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>WordPress doesn't have a way to natively do many-to-many relationships, have a look at the <a href=\"http://wordpre... | 2012/05/07 | [
"https://wordpress.stackexchange.com/questions/51386",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15749/"
] | How do I create a many-to-many relationship between two custom post types?
Given type A and given type B, I'd like to be able to show all Bs that relate to a given A, and all As that relate to a given B. | As Milo noted, there is no built in way to do a many to many relationship between two custom post types.
That being said, these days it isn't too hard to do it yourself without a plugin if wanted.
I do many to many relationships between custom post types by using non-singular post meta.
e.g. Books and Authors
Stick... |
51,388 | <p>Others have asked how to only get <a href="https://wordpress.stackexchange.com/questions/24582/how-can-i-get-only-parent-terms">parent terms</a>, but I need to get the deepest term for the post of a specific taxonomy.</p>
<p>Is there a way I can only get terms where the number of children = 0?</p>
| [
{
"answer_id": 51392,
"author": "Mateusz Hajdziony",
"author_id": 15865,
"author_profile": "https://wordpress.stackexchange.com/users/15865",
"pm_score": 1,
"selected": true,
"text": "<p>I have written this function some time ago, it may be a bit sloppy but it does it's job:</p>\n\n<pre>... | 2012/05/07 | [
"https://wordpress.stackexchange.com/questions/51388",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10099/"
] | Others have asked how to only get [parent terms](https://wordpress.stackexchange.com/questions/24582/how-can-i-get-only-parent-terms), but I need to get the deepest term for the post of a specific taxonomy.
Is there a way I can only get terms where the number of children = 0? | I have written this function some time ago, it may be a bit sloppy but it does it's job:
```
function get_low_level_term( $taxonomy ) {
$term = null;
if( is_single() ) {
global $post;
$terms = get_the_terms( $post->ID, $taxonomy );
if( count( $terms ) == 1 ) {
foreach( $terms as $t ) {
... |
51,391 | <p>I need to register a test sidebar and have to include it on a specific page. On registering sidebar as </p>
<pre><code>register_sidebar(array('name' => 'ABC'));
</code></pre>
<p>Additional banners get displayed on all pages. Previously there are 4 dynamic sidebars registered and <strong>PHP Code</strong> is rel... | [
{
"answer_id": 51413,
"author": "Jeremy Jared",
"author_id": 5339,
"author_profile": "https://wordpress.stackexchange.com/users/5339",
"pm_score": 0,
"selected": false,
"text": "<p>A simple conditional statement will ensure it shows on a single page only. Your question is a little hard t... | 2012/05/07 | [
"https://wordpress.stackexchange.com/questions/51391",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11839/"
] | I need to register a test sidebar and have to include it on a specific page. On registering sidebar as
```
register_sidebar(array('name' => 'ABC'));
```
Additional banners get displayed on all pages. Previously there are 4 dynamic sidebars registered and **PHP Code** is related with them (banner html). Before relat... | You have three options:
1. Register a dynamic sidebar for a specific page, and then create a **page template** that calls `dynamic_sidebar()` for the registered sidebar.
2. Use an `is_page( $id )` conditional wrapper in your `page.php` template
3. Output Widget code conditionally, using `is_page( $id )`
### Custom Pa... |
51,397 | <p>I am working on my category template. Here is how I want the page to display:</p>
<ol>
<li>Category Name - <code>this is done</code></li>
<li>The latest post for each category be on top <code>(then styled which I can do)</code>. </li>
<li>The Category description - <code>this is done</code></li>
<li>List all the r... | [
{
"answer_id": 51399,
"author": "Mateusz Hajdziony",
"author_id": 15865,
"author_profile": "https://wordpress.stackexchange.com/users/15865",
"pm_score": 0,
"selected": false,
"text": "<p>Create a $counter variable (that equals 0 at the beginning) outside of the posts loop. Increment the... | 2012/05/07 | [
"https://wordpress.stackexchange.com/questions/51397",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/832/"
] | I am working on my category template. Here is how I want the page to display:
1. Category Name - `this is done`
2. The latest post for each category be on top `(then styled which I can do)`.
3. The Category description - `this is done`
4. List all the rest of the posts for the category under it - `I can list all the p... | Use WP\_Query's built in `current_post` counter in your loop:
```
while( have_posts() ):
the_post();
if( $wp_query->current_post == 0 ):
// this is the first post in the loop
else:
// this is > first post
endif;
endwhile;
```
EDIT w/html:
```
<?php
while( have_posts() ):
the_post... |
51,404 | <p>I already have a theme options page that saves to wp_options > kittens_options.</p>
<p>I'm looking for a simple way to incorporate an import/export textarea of those options on my options page.</p>
<p>I've searched Google for several hours now and haven't been able to find any useful tutorials. If anyone knows off... | [
{
"answer_id": 51406,
"author": "Tribalpixel",
"author_id": 11987,
"author_profile": "https://wordpress.stackexchange.com/users/11987",
"pm_score": 2,
"selected": false,
"text": "<p>maybe you can write 2 functions for your options </p>\n\n<ol>\n<li>one script to write a txt file to expor... | 2012/05/07 | [
"https://wordpress.stackexchange.com/questions/51404",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I already have a theme options page that saves to wp\_options > kittens\_options.
I'm looking for a simple way to incorporate an import/export textarea of those options on my options page.
I've searched Google for several hours now and haven't been able to find any useful tutorials. If anyone knows off the top of the... | maybe you can write 2 functions for your options
1. one script to write a txt file to export your options
2. one script to import in your wordpress (add upload field in your option
theme page)
all of theses functions can be in your functions.php of the theme
here is an example of function to write a ini (txt) file
... |
51,415 | <p>How can I turn a URL like:</p>
<p><code>http://site.com/?project=5</code></p>
<p>into:</p>
<p><code>http://site.com/project/5/</code></p>
<p>?</p>
<p>I was looking the rewrite doc here:
<a href="http://codex.wordpress.org/Class_Reference/WP_Rewrite#Examples" rel="nofollow">http://codex.wordpress.org/Class_Refer... | [
{
"answer_id": 51421,
"author": "Jobjörn Folkesson",
"author_id": 2334,
"author_profile": "https://wordpress.stackexchange.com/users/2334",
"pm_score": -1,
"selected": true,
"text": "<p>The PHP code is not enough, you need to edit your .htaccess file correspondingly. (You can do this wit... | 2012/05/07 | [
"https://wordpress.stackexchange.com/questions/51415",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15895/"
] | How can I turn a URL like:
`http://site.com/?project=5`
into:
`http://site.com/project/5/`
?
I was looking the rewrite doc here:
<http://codex.wordpress.org/Class_Reference/WP_Rewrite#Examples>
and came up with this
```
// Adding a new rule
function my_insert_rewrite_rules( $rules )
{
$newrules = array();
$n... | The PHP code is not enough, you need to edit your .htaccess file correspondingly. (You can do this with `$wp_rewrite->mod_rewrite_rules();` somehow, or edit it manually.) However, be aware that URL rewriting is complicated stuff - are you sure you need it? If you are using pretty permalinks for posts/pages, chances are... |
51,427 | <p>I'm using <code>wp_remote_get()</code> to download a remote file with the following URL:</p>
<pre><code>http://feeds.paidonresults.net/1.0?affiliateid=34069&feedid=M742&template=CSV&CSVSeperator=comma&field_names=ProductID,ProductName,ProductPrice,SummaryDescription,ProductDescription,AffiliateURL,I... | [
{
"answer_id": 51434,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>I am retrieving this URL ok on my test stack, which means that either:</p>\n\n<ol>\n<li>Remote server was having tem... | 2012/05/07 | [
"https://wordpress.stackexchange.com/questions/51427",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15510/"
] | I'm using `wp_remote_get()` to download a remote file with the following URL:
```
http://feeds.paidonresults.net/1.0?affiliateid=34069&feedid=M742&template=CSV&CSVSeperator=comma&field_names=ProductID,ProductName,ProductPrice,SummaryDescription,ProductDescription,AffiliateURL,ImageURL100by100,ImageURL200by200,ProductA... | I am retrieving this URL ok on my test stack, which means that either:
1. Remote server was having temporary issues.
2. Your server has configuration or other issues.
I would try to install [Core Control](http://wordpress.org/extend/plugins/core-control/) plugin, force different HTTP transports and see if that helps. |
51,441 | <p>I have a site that uses multiple query taxonomy archives.</p>
<p>i.e www.sitename.com/taxonomy1/taxonomy2/taxonomy3</p>
<p>Is there a plugin or method to create a dedicated sidebar for each queried taxonomy archive?</p>
<p>Essentially, there will be 1000 or so archives and i would like to be able to create a uniq... | [
{
"answer_id": 51454,
"author": "mrwweb",
"author_id": 9844,
"author_profile": "https://wordpress.stackexchange.com/users/9844",
"pm_score": 2,
"selected": true,
"text": "<p>I've had luck dynamically creating sidebars using a foreach loop. You'd do something like this (untested) in your ... | 2012/05/07 | [
"https://wordpress.stackexchange.com/questions/51441",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15440/"
] | I have a site that uses multiple query taxonomy archives.
i.e www.sitename.com/taxonomy1/taxonomy2/taxonomy3
Is there a plugin or method to create a dedicated sidebar for each queried taxonomy archive?
Essentially, there will be 1000 or so archives and i would like to be able to create a unique sidebar for each. Is ... | I've had luck dynamically creating sidebars using a foreach loop. You'd do something like this (untested) in your functions.php file:
```
$my_terms = get_terms( 'my_taxonomy_name' );
if( ! is_wp_error( $my_terms ) ) {
foreach( $my_terms as $term ) {
register_sidebar(
'name' => $term->name . ' A... |
51,444 | <p>How can I add extra parameters after a permalink, specifically if I'm using a custom post type?</p>
<p>For example, let's say <code>http://mysite/album/record-name</code> was the permalink. How can I make <code>http://mysite/album/record-name/related</code> not turn up a 404 or redirect?</p>
<p>WordPress doesn't s... | [
{
"answer_id": 51449,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": false,
"text": "<p>You can do this with the <a href=\"http://codex.wordpress.org/Rewrite_API\">Rewrite API</a>'s <a href=\"http://code... | 2012/05/07 | [
"https://wordpress.stackexchange.com/questions/51444",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14955/"
] | How can I add extra parameters after a permalink, specifically if I'm using a custom post type?
For example, let's say `http://mysite/album/record-name` was the permalink. How can I make `http://mysite/album/record-name/related` not turn up a 404 or redirect?
WordPress doesn't seem to call up the post template if the... | You can add an endpoint to your URIs to handle special requests.
Here is a basic example as plugin. To understand what's going on read [Christopher Davis](https://wordpress.stackexchange.com/users/6035/christopher-davis)'s fantastic tutorial [A (Mostly) Complete Guide to the WordPress Rewrite API](https://www.pmg.com/... |
51,463 | <p>I'm wondering how you go about creating an info/help message at the top of a custom post type in WP's dashboard? I often see these at the top of plugins and Id like to do the same thing for my custom post types if possible (<em>see image below for example --- Note: Screenshot has been taken from <a href="http://www.... | [
{
"answer_id": 51486,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 4,
"selected": true,
"text": "<p>The hook you are after is <a href=\"http://adambrown.info/p/wp_hooks/hook/admin_notices\" rel=\"noreferrer... | 2012/05/08 | [
"https://wordpress.stackexchange.com/questions/51463",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3567/"
] | I'm wondering how you go about creating an info/help message at the top of a custom post type in WP's dashboard? I often see these at the top of plugins and Id like to do the same thing for my custom post types if possible (*see image below for example --- Note: Screenshot has been taken from [NSP-Code's "Post-Types Or... | The hook you are after is [`admin_notices`](http://adambrown.info/p/wp_hooks/hook/admin_notices). This is fired at the top of *every* admin page.
If you wish to restrict the notice to certain pages you can use: [get\_current\_screen()](http://codex.wordpress.org/Function_Reference/get_current_screen) to get the curren... |
51,475 | <p>I am creating a post from the front end using (shortened for brevity);</p>
<pre><code>if (empty($_POST['my_title'])){
echo 'error: please insert a title';
} else {
$title = $_POST['my_title'];
}
$new_post = array(
'post_title' => $title,
'post_status' => 'publish',
'post_type' => 'p... | [
{
"answer_id": 51480,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 3,
"selected": true,
"text": "<p>Simply put the <code>wp_insert_post</code> call inside your conditional check so its only called if the post t... | 2012/05/08 | [
"https://wordpress.stackexchange.com/questions/51475",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13418/"
] | I am creating a post from the front end using (shortened for brevity);
```
if (empty($_POST['my_title'])){
echo 'error: please insert a title';
} else {
$title = $_POST['my_title'];
}
$new_post = array(
'post_title' => $title,
'post_status' => 'publish',
'post_type' => 'post'
$pid = wp_insert_... | Simply put the `wp_insert_post` call inside your conditional check so its only called if the post title is not empty, something like this:
```
if (empty($_POST['my_title'])){
echo 'error: please insert a title';
} else {
$title = $_POST['my_title'];
$new_post = array(
'post_title' => $title,
... |
51,485 | <p>I'm trying to use <code>meta_query</code> to return all users that have registered today :</p>
<pre><code>$args = array(
'meta_query' => array(
array(
'key' => 'user_registered',
'value' => date('Y-m-d'),
'compare' => '=',
'type' => 'DATE'
... | [
{
"answer_id": 51492,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 4,
"selected": false,
"text": "<p>The field <code>user_registered</code> is not a in the <code>*_usermeta</code> table, but the in <code>*_... | 2012/05/08 | [
"https://wordpress.stackexchange.com/questions/51485",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1381/"
] | I'm trying to use `meta_query` to return all users that have registered today :
```
$args = array(
'meta_query' => array(
array(
'key' => 'user_registered',
'value' => date('Y-m-d'),
'compare' => '=',
'type' => 'DATE'
)
)
);
$query = new WP_User_... | Few months ago, I updated the Codex for [`get_users()`](http://codex.wordpress.org/Class_Reference/get_users) and [`WP_User_Query`](http://codex.wordpress.org/Class_Reference/WP_User_Query), regarding the `date_query` support on the *user's registration date*, in WordPress 4.1+.
Then I also added a [simple example](ht... |
51,500 | <p>I`m trying to construct a json object but are having difficulties with the_content since it returns newlines, which causes the script to fail. The error messages received is: <strong>Uncaught SyntaxError: Unexpected token ILLEGAL</strong></p>
<p><strong>Example of the json:</strong></p>
<pre><code>[ {image : 'http... | [
{
"answer_id": 51522,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>To output JSON always the function <a href=\"http://php.net/json-encode\" rel=\"nofollow\"><code>json_encode( $string )... | 2012/05/08 | [
"https://wordpress.stackexchange.com/questions/51500",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15915/"
] | I`m trying to construct a json object but are having difficulties with the\_content since it returns newlines, which causes the script to fail. The error messages received is: **Uncaught SyntaxError: Unexpected token ILLEGAL**
**Example of the json:**
```
[ {image : 'http://localhost/wp-content/uploads/2012/04/exampl... | To output JSON always the function [`json_encode( $string )`](http://php.net/json-encode). The function is not available on all hosts. Don't worry, WordPress offers a fallback in `wp-includes/compat.php`. That's a wrapper for `class Services_JSON::encodeUnsafe()` (see `wp-includes/class-json.php`).
If you take a loo... |
51,527 | <p>I'm rewriting the question, including exemplary code, I hope it will be easier to understand now.</p>
<h2>1. My shortcode:</h2>
<pre><code> function testid_shortcode( ) {
global $post;
return $post->ID;
}
add_shortcode('testid', 'testid_shortcode');
</code></pre>
<h2>2. The i... | [
{
"answer_id": 51537,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 1,
"selected": false,
"text": "<h2><a href=\"http://codex.wordpress.org/Function_Reference/get_page\" rel=\"nofollow noreferrer\"><code>get_page</co... | 2012/05/08 | [
"https://wordpress.stackexchange.com/questions/51527",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1869/"
] | I'm rewriting the question, including exemplary code, I hope it will be easier to understand now.
1. My shortcode:
----------------
```
function testid_shortcode( ) {
global $post;
return $post->ID;
}
add_shortcode('testid', 'testid_shortcode');
```
2. The issue:
-------------
I... | The global $post object is from the current query, so what you're seeing is the expected behavior.
If you always want the shortcode to return the post\_meta from ID = 1, then you should just hardcode that into the shortcode like in @Chris\_O's answer where you just save a variable that equals 1 and pass that to `get_p... |
51,547 | <p>I am working modifying an ecommerce plugin, and it makes uses of wp_update_user() function, and everytime the function runs another table (created by the plugin), gets updated too. The problem is that the updated data on that second table is incorrect, and I am having troubles finding the part of the code that does ... | [
{
"answer_id": 51549,
"author": "SickHippie",
"author_id": 5434,
"author_profile": "https://wordpress.stackexchange.com/users/5434",
"pm_score": 2,
"selected": true,
"text": "<p><code>wp_update_user()</code> is in <code>/wp-includes/user.php</code> lines 1401-1439. It uses <code>wp_inse... | 2012/05/08 | [
"https://wordpress.stackexchange.com/questions/51547",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15930/"
] | I am working modifying an ecommerce plugin, and it makes uses of wp\_update\_user() function, and everytime the function runs another table (created by the plugin), gets updated too. The problem is that the updated data on that second table is incorrect, and I am having troubles finding the part of the code that does i... | `wp_update_user()` is in `/wp-includes/user.php` lines 1401-1439. It uses `wp_insert_user()` (same file, lines 1254-1380) to update the existing user or add a new one if the user doesn't exist. That function is where the various filters and actions affecting user account info live, and shows everything you can do to th... |
51,563 | <p>I've stuck a static width content slider on my Wordpress sites front page. I'm using the Twenty Eleven theme with a small piece of code included into index.php to display the slider. Unfortunately because of how the theme handles mobile browsers, it causes the slider to push across the screen without the rest of the... | [
{
"answer_id": 51565,
"author": "SickHippie",
"author_id": 5434,
"author_profile": "https://wordpress.stackexchange.com/users/5434",
"pm_score": 1,
"selected": false,
"text": "<p>This is more of a php question than a WP question, but there's a great function <a href=\"http://erikastokes.... | 2012/05/08 | [
"https://wordpress.stackexchange.com/questions/51563",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15936/"
] | I've stuck a static width content slider on my Wordpress sites front page. I'm using the Twenty Eleven theme with a small piece of code included into index.php to display the slider. Unfortunately because of how the theme handles mobile browsers, it causes the slider to push across the screen without the rest of the th... | This is more of a php question than a WP question, but there's a great function [here](http://erikastokes.com/php/how-to-test-if-a-browser-is-mobile.php) that does what you're looking for.
```
function is_mobile() {
// Get the user agent
$user_agent = $_SERVER['HTTP_USER_AGENT'];
// Create an array of know... |
51,567 | <p>On the Web there are many articles on how to insert external scripts into a document using the <code>wp_enqueue_script()</code> <em>method</em>.</p>
<p>Among the articles I couldn't find anything explanaining how to add inline, <code><script></code> tag enclosed scripts.</p>
<p>I use <code><script></co... | [
{
"answer_id": 51568,
"author": "mrwweb",
"author_id": 9844,
"author_profile": "https://wordpress.stackexchange.com/users/9844",
"pm_score": 2,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/wp_enqueue_script\" rel=\"nofollow noreferrer\"><code>wp_... | 2012/05/08 | [
"https://wordpress.stackexchange.com/questions/51567",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10100/"
] | On the Web there are many articles on how to insert external scripts into a document using the `wp_enqueue_script()` *method*.
Among the articles I couldn't find anything explanaining how to add inline, `<script>` tag enclosed scripts.
I use `<script>` tags in the middle of my documents though I suppose doing so is n... | You can add inline js by using the **wp\_add\_inline\_script** function.
```
function prince_scripts() {
wp_enqueue_script( 'prince-script', get_template_directory_uri(). 'main.js');
$hide_on_mobile = apply_filters( 'prince_hide_on_mobile', true );
$data = 'var hideOnMobile = ' . ( $hide_on_mobile ? 'tr... |
51,572 | <p>(By "Page Template," I mean a theme file with the <a href="http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates" rel="nofollow noreferrer">"Template Name" header</a> that can be selected in the "Template" dropdown field on the page admin.)</p>
<p>In multiple instances, I've built page templates that co... | [
{
"answer_id": 51576,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 2,
"selected": false,
"text": "<p>Pages are generally speaking rather inflexible, you would be better off using a <em>custom post type</em>. Also hoo... | 2012/05/09 | [
"https://wordpress.stackexchange.com/questions/51572",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9844/"
] | (By "Page Template," I mean a theme file with the ["Template Name" header](http://codex.wordpress.org/Pages#Creating_Your_Own_Page_Templates) that can be selected in the "Template" dropdown field on the page admin.)
In multiple instances, I've built page templates that could have been accomplished by hooking to the\_c... | I still run into the desire to do this kind of thing and have settled on the following solution which I proposed in the OP and like for a couple reasons:
1. It's very transparent and feels consistent with keeping the logic in the theme.
2. It makes it very easy to customize a template later if needed.
Custom Template... |