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 |
|---|---|---|---|---|---|---|
89,191 | <p>Inside of my loop in single.php, I used a custom query using <code>get_posts</code> to return posts belonging to a certain category.</p>
<pre><code><?php global $post;
$paged = get_query_var( 'paged' ) ? ge... | [
{
"answer_id": 89194,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": true,
"text": "<p>You need to call <a href=\"http://codex.wordpress.org/Function_Reference/wp_reset_postdata\"><code>wp_reset_postdata... | 2013/03/03 | [
"https://wordpress.stackexchange.com/questions/89191",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16048/"
] | Inside of my loop in single.php, I used a custom query using `get_posts` to return posts belonging to a certain category.
```
<?php global $post;
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
... | You need to call [`wp_reset_postdata()`](http://codex.wordpress.org/Function_Reference/wp_reset_postdata) after your query to restore the global `$post` variable that the navigation link functions use to determine the next/previous posts. |
89,199 | <p>I'm using advanced custom fields and set an image upload field in user profiles. I'm using this image a few places on the website and need to set a custom size for it on some pages.</p>
<p>If I set <code>add_image_size( 'homepage-thumb', 190, 259, true );</code> in my functions file how can I use this image size wi... | [
{
"answer_id": 89248,
"author": "Kim",
"author_id": 28312,
"author_profile": "https://wordpress.stackexchange.com/users/28312",
"pm_score": 0,
"selected": false,
"text": "<p>This might work if it is the full size image url you are storing in your custom field. Try to place this function ... | 2013/03/03 | [
"https://wordpress.stackexchange.com/questions/89199",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10413/"
] | I'm using advanced custom fields and set an image upload field in user profiles. I'm using this image a few places on the website and need to set a custom size for it on some pages.
If I set `add_image_size( 'homepage-thumb', 190, 259, true );` in my functions file how can I use this image size with the uploaded image... | Your first problem is that custom field is saved as url, and not as id. So you need to retrieve the attachment id from the url. First tentation is to use the 'guid' field.
Resist the temptation and find another way: for robust wordpress code you have to think 'guid' not exists, so repeat with me: "guid does not exist"... |
89,202 | <p>I want to query 6 posts, but only those which have a featured image attached. I am using <code>meta_key</code> method for this with <code>WP_Query</code> as such:</p>
<pre><code>$args = array(
'post_type' => 'post',
'meta_key' => '_thumbnail_id',
'post_count' => 6 );
$query = new WP_Query($arg... | [
{
"answer_id": 89204,
"author": "helgatheviking",
"author_id": 6477,
"author_profile": "https://wordpress.stackexchange.com/users/6477",
"pm_score": 5,
"selected": false,
"text": "<p>As of WordPress 3.5, the <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Param... | 2013/03/03 | [
"https://wordpress.stackexchange.com/questions/89202",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23620/"
] | I want to query 6 posts, but only those which have a featured image attached. I am using `meta_key` method for this with `WP_Query` as such:
```
$args = array(
'post_type' => 'post',
'meta_key' => '_thumbnail_id',
'post_count' => 6 );
$query = new WP_Query($args);
```
Followed by
```
<?php while($query... | When running the importer, you must check the checkbox to download and import all media/attachments, and the original server must be reachable from the server conducting the import.
If you fail to do this, the posts will have no valid featured image, and fail to show in your loop, and any attempt to call `the_post_thu... |
89,213 | <p>We currently have a setup where anyone can register as a user and their own 'page' gets created manually by admin. We need a menu option to be something like 'View Your Page' and direct a user to their own page. I can't get my head around it as there is no current link between the user and the page that's created ... | [
{
"answer_id": 89217,
"author": "chifliiiii",
"author_id": 4130,
"author_profile": "https://wordpress.stackexchange.com/users/4130",
"pm_score": 1,
"selected": false,
"text": "<p>IF you name the pages with the username for example www.site.com/author-page/jhon_doe you can try something ... | 2013/03/03 | [
"https://wordpress.stackexchange.com/questions/89213",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | We currently have a setup where anyone can register as a user and their own 'page' gets created manually by admin. We need a menu option to be something like 'View Your Page' and direct a user to their own page. I can't get my head around it as there is no current link between the user and the page that's created manua... | I've answered a [similar Question](https://wordpress.stackexchange.com/q/89134/12615) and the same code can be adapted for this case. This creates a Meta Box where you can assign a user to a specific post/page, and the information is stored as a Custom Field. The following can be put in `functions.php` or in a function... |
89,221 | <p>Inline width and height attributes were never a huge problem with images in WordPress, since these were easily overwritten with CSS.</p>
<p>The problem I'm having is that any images with captions are being wrapped in a ID 'attachment_('attachmentnumber') and a class of 'wp-caption' AND they're given inline CSS widt... | [
{
"answer_id": 89231,
"author": "Kim",
"author_id": 28312,
"author_profile": "https://wordpress.stackexchange.com/users/28312",
"pm_score": 2,
"selected": false,
"text": "<p>You can override inline styles with \"!important\" like this:</p>\n\n<pre><code>width: 100px !important;\n</code><... | 2013/03/03 | [
"https://wordpress.stackexchange.com/questions/89221",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22450/"
] | Inline width and height attributes were never a huge problem with images in WordPress, since these were easily overwritten with CSS.
The problem I'm having is that any images with captions are being wrapped in a ID 'attachment\_('attachmentnumber') and a class of 'wp-caption' AND they're given inline CSS width and hei... | To remove the inline width in a clean PHP-way could be done with a filter, as described in the source code: <https://core.trac.wordpress.org/browser/trunk/src/wp-includes/media.php#L1587>
Returning a zero (or false) will remove it:
```
add_filter( 'img_caption_shortcode_width', '__return_false' );
``` |
89,227 | <p>OK so I'm about 90% done, the only part that keeps breaking is when I try to exclude a specific taxonomy term.</p>
<p>Break down:</p>
<p>Sorting: ('v_sort' => 'views') This is being done via the popular WP-Postviews plugin.</p>
<p>Post Types: post, videos, music, albums.</p>
<p>Date: The last 30 days.</p>
<p><s... | [
{
"answer_id": 89235,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 1,
"selected": false,
"text": "<p>You can try:</p>\n\n<pre><code>$the_query = new WP_Query( array(\n 'posts_per_page' => '5',\n 'v_sort... | 2013/03/03 | [
"https://wordpress.stackexchange.com/questions/89227",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35798/"
] | OK so I'm about 90% done, the only part that keeps breaking is when I try to exclude a specific taxonomy term.
Break down:
Sorting: ('v\_sort' => 'views') This is being done via the popular WP-Postviews plugin.
Post Types: post, videos, music, albums.
Date: The last 30 days.
**Excluded Taxonomy Term:** Taxonomy = ... | You can try:
```
$the_query = new WP_Query( array(
'posts_per_page' => '5',
'v_sortby' => 'views',
'post_type' => array( 'post', 'music', 'videos', 'albums' ),
'tax_query' => array(
array(
'taxonomy' => 'content',
'field' => 'slug',
'terms' => array( 'indy' ... |
89,236 | <p>We're using the disqus plugin on our wordpress site, so anyone commenting should have a login through disqus.
Yet, I'm still seeing spammers trying to post through the regular comments API.
They're not getting through to the post, but they're clogging my inbox as admin.</p>
<p>How do I disable this API - I only wan... | [
{
"answer_id": 89238,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": false,
"text": "<p>You can try to stop it in the <code>pre_comment_on_post</code> hook</p>\n\n<pre><code>add_action('pre_comment_... | 2013/03/04 | [
"https://wordpress.stackexchange.com/questions/89236",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28595/"
] | We're using the disqus plugin on our wordpress site, so anyone commenting should have a login through disqus.
Yet, I'm still seeing spammers trying to post through the regular comments API.
They're not getting through to the post, but they're clogging my inbox as admin.
How do I disable this API - I only want to accep... | There is much easier way to close standard WordPress comments. Just add
```
add_filter( 'comments_open', '__return_false' );
```
to your `functions.php` file and comments will be closed. |
89,241 | <p>I'm looking to count how many post live within the custom post type called "videos", but only the ones from the category called "work".</p>
<pre><code><?php $count_posts = wp_count_posts('videos'); echo $count_posts->publish; // ?>
</code></pre>
<p>How can I adjust the above code to accomplish this?</p>
... | [
{
"answer_id": 89247,
"author": "Red",
"author_id": 2289,
"author_profile": "https://wordpress.stackexchange.com/users/2289",
"pm_score": 2,
"selected": false,
"text": "<p>Found a solution.</p>\n\n<pre><code><?php $posts = get_posts('post_type=videos&category=4'); \n$count = count... | 2013/03/04 | [
"https://wordpress.stackexchange.com/questions/89241",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2289/"
] | I'm looking to count how many post live within the custom post type called "videos", but only the ones from the category called "work".
```
<?php $count_posts = wp_count_posts('videos'); echo $count_posts->publish; // ?>
```
How can I adjust the above code to accomplish this?
Thanks! | An alternative solution using [WP\_Query](http://codex.wordpress.org/Class_Reference/WP_Query) would be:
```
$args = array(
'cat' => 4,
'post_type' => 'videos'
);
$the_query = new WP_Query( $args );
echo $the_query->found_posts;
``` |
89,250 | <p>For a single custom post type, I'm using previous_post_link and next_post_link with simple arrows. (Although text arrows are shown here, in the actual I'm using graphics with the text hidden via CSS.) Code:</p>
<pre><code><nav class="arrowNav">
<div class="nav-previous">
<?php previous_pos... | [
{
"answer_id": 89247,
"author": "Red",
"author_id": 2289,
"author_profile": "https://wordpress.stackexchange.com/users/2289",
"pm_score": 2,
"selected": false,
"text": "<p>Found a solution.</p>\n\n<pre><code><?php $posts = get_posts('post_type=videos&category=4'); \n$count = count... | 2013/03/04 | [
"https://wordpress.stackexchange.com/questions/89250",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14751/"
] | For a single custom post type, I'm using previous\_post\_link and next\_post\_link with simple arrows. (Although text arrows are shown here, in the actual I'm using graphics with the text hidden via CSS.) Code:
```
<nav class="arrowNav">
<div class="nav-previous">
<?php previous_post_link('%link', '«'); ?>
... | An alternative solution using [WP\_Query](http://codex.wordpress.org/Class_Reference/WP_Query) would be:
```
$args = array(
'cat' => 4,
'post_type' => 'videos'
);
$the_query = new WP_Query( $args );
echo $the_query->found_posts;
``` |
89,251 | <p>I am using the Settings API for a plugin's settings page. One of the settings allows the user to change the cron job interval for the cron job created by this plugin.</p>
<p>Therefore I'd like to run a function on saving of the settings page, which checks the value in the database and compares it to the value the e... | [
{
"answer_id": 89274,
"author": "Jesse",
"author_id": 9145,
"author_profile": "https://wordpress.stackexchange.com/users/9145",
"pm_score": 2,
"selected": true,
"text": "<p>I'm not familiar with wordpress settings api but I know those options generated by settings api are handled/saved i... | 2013/03/04 | [
"https://wordpress.stackexchange.com/questions/89251",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5844/"
] | I am using the Settings API for a plugin's settings page. One of the settings allows the user to change the cron job interval for the cron job created by this plugin.
Therefore I'd like to run a function on saving of the settings page, which checks the value in the database and compares it to the value the existing cr... | I'm not familiar with wordpress settings api but I know those options generated by settings api are handled/saved in wp-admin/options.php
Unfortunately,
```
if ( isset( $_POST[ $option ] ) ) {
$value = $_POST[ $option ];
if ( ! is_array( $value ) )
$value = trim( $value );
$value = stripslas... |
89,257 | <p>I'm not sure how to use <a href="http://adambrown.info/p/wp_hooks/hook/comments_number?version=3.5&file=wp-includes/comment-template.php" rel="nofollow">this filter</a>. Could someone show me an example? I'm trying to change <code>('0', '1', '%')</code> to <code>('0 Comments', '1 Comment', '% Comments')</code>.<... | [
{
"answer_id": 89274,
"author": "Jesse",
"author_id": 9145,
"author_profile": "https://wordpress.stackexchange.com/users/9145",
"pm_score": 2,
"selected": true,
"text": "<p>I'm not familiar with wordpress settings api but I know those options generated by settings api are handled/saved i... | 2013/03/04 | [
"https://wordpress.stackexchange.com/questions/89257",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14008/"
] | I'm not sure how to use [this filter](http://adambrown.info/p/wp_hooks/hook/comments_number?version=3.5&file=wp-includes/comment-template.php). Could someone show me an example? I'm trying to change `('0', '1', '%')` to `('0 Comments', '1 Comment', '% Comments')`.
I'm using this function to get the comments number.
`... | I'm not familiar with wordpress settings api but I know those options generated by settings api are handled/saved in wp-admin/options.php
Unfortunately,
```
if ( isset( $_POST[ $option ] ) ) {
$value = $_POST[ $option ];
if ( ! is_array( $value ) )
$value = trim( $value );
$value = stripslas... |
89,259 | <p>My theme already has a specific body class filter for the colorscheme it uses. How can I also add a body class filter for the page name? Basically I want to combine these statements:</p>
<pre><code><body <?php body_class(); ?>>
<body class="<?php echo get_stencil(); ?>">
</code></pre>
<p>I'... | [
{
"answer_id": 89261,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 2,
"selected": false,
"text": "<p>Add following filter code in functions.php to add any custom class to body.</p>\n\n<pre><code>// Add speci... | 2013/03/04 | [
"https://wordpress.stackexchange.com/questions/89259",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23384/"
] | My theme already has a specific body class filter for the colorscheme it uses. How can I also add a body class filter for the page name? Basically I want to combine these statements:
```
<body <?php body_class(); ?>>
<body class="<?php echo get_stencil(); ?>">
```
I've been trying but I just keep getting error messa... | directly in the body tag line:
```
<body <?php body_class( get_stencil() ); ?>>
```
<http://codex.wordpress.org/Function_Reference/body_class#Adding_More_Classes> |
89,263 | <p><strong>UPDATE:</strong> My original question has been solved, but this is turning into a valid discussion about why not to use global variables, so I am updating the question to reflect that. The solution was <code><?php global $category_link_prop; echo esc_url( $category_link_prop ); ?></code> as @TomJNowell... | [
{
"answer_id": 89271,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 5,
"selected": false,
"text": "<p><strong>Don't use global variables</strong>, as simple as that.</p>\n<p><strong>Why not to use globals</st... | 2013/03/04 | [
"https://wordpress.stackexchange.com/questions/89263",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25300/"
] | **UPDATE:** My original question has been solved, but this is turning into a valid discussion about why not to use global variables, so I am updating the question to reflect that. The solution was `<?php global $category_link_prop; echo esc_url( $category_link_prop ); ?>` as @TomJNowell suggested.
**UPDATE 2:** I now ... | While I strongly advise against this, and it will **not** speed things up, your usage is incorrect.
**WordPress already caches these things in the object cache/memory so it doesn't have to fetch it multiple times in the same request, you don't need to store the result and reuse, WP does that already out of the box**.
... |
89,265 | <p><strong>The main problem here is about too large file size of image not image re-sizing</strong></p>
<p>My wordpress website is like a web gallery which contains many images.</p>
<p>Initially, I just uploaded hundreds of images via wordpress media uploader without caring of its file size at all. </p>
<p>However,... | [
{
"answer_id": 89271,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 5,
"selected": false,
"text": "<p><strong>Don't use global variables</strong>, as simple as that.</p>\n<p><strong>Why not to use globals</st... | 2013/03/04 | [
"https://wordpress.stackexchange.com/questions/89265",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28340/"
] | **The main problem here is about too large file size of image not image re-sizing**
My wordpress website is like a web gallery which contains many images.
Initially, I just uploaded hundreds of images via wordpress media uploader without caring of its file size at all.
However, when i browse my website, it's too sl... | While I strongly advise against this, and it will **not** speed things up, your usage is incorrect.
**WordPress already caches these things in the object cache/memory so it doesn't have to fetch it multiple times in the same request, you don't need to store the result and reuse, WP does that already out of the box**.
... |
89,292 | <p>Hi~ I'm back again and I'm trying to add another function to the script I was working on <a href="https://wordpress.stackexchange.com/questions/89045/writing-a-plugin-that-notify-my-friends-of-new-post-that-mentions-them">a plugin that notify my friends of new post that mentions(@) them</a>. Now I want to change th... | [
{
"answer_id": 89301,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 3,
"selected": true,
"text": "<p>You generally use <code>add_filter</code> before displaying information. For your case you can use <code>add_ac... | 2013/03/04 | [
"https://wordpress.stackexchange.com/questions/89292",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28255/"
] | Hi~ I'm back again and I'm trying to add another function to the script I was working on [a plugin that notify my friends of new post that mentions(@) them](https://wordpress.stackexchange.com/questions/89045/writing-a-plugin-that-notify-my-friends-of-new-post-that-mentions-them). Now I want to change the plain text of... | You generally use `add_filter` before displaying information. For your case you can use `add_action('publish_post', 'your_function')` and then you intercept `$_POST` values. The content of the WYSIWYG editor is available through `$_POST['content']`.
The hook is of type [`publish_{post_type}`](http://adambrown.info/p/w... |
89,299 | <p>I have a category on my website called 'profiles' I am in the process of moving this category to a custom post type called 'profiles'.</p>
<p>My problem is I cannot get the archive page to show for this custom post type. When I go to the url <code>mywebsite.com/profiles</code> it takes me to a single post page for ... | [
{
"answer_id": 89439,
"author": "stemie",
"author_id": 22502,
"author_profile": "https://wordpress.stackexchange.com/users/22502",
"pm_score": 2,
"selected": false,
"text": "<p>Re saving the permalink structure seemed to fix the issue.\nThanks for the tip Mike and Vinod.</p>\n"
},
{
... | 2013/03/04 | [
"https://wordpress.stackexchange.com/questions/89299",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22502/"
] | I have a category on my website called 'profiles' I am in the process of moving this category to a custom post type called 'profiles'.
My problem is I cannot get the archive page to show for this custom post type. When I go to the url `mywebsite.com/profiles` it takes me to a single post page for a post in the profile... | 1. Navigate to Settings -> permalinks
2. Change the permalink structure to *Default*
3. Save settings
4. Change to custom structure or post name (or any other structure)
5. Save Settings
This will re-write the htaccess file and then the re-write should work.
---
If the above solution doesn't work - it should be rela... |
89,311 | <p>I want to increase the maximum upload file (media default:32mb). Before posting i search, but i didn't have the result that i want.
My host didn't support .htaccess.
I create my own <code>php.ini</code> with these:</p>
<pre><code>memory_limit = 32M
upload_max_filesize = 120M
upload_max_filesize = 120M
post_max_size... | [
{
"answer_id": 89439,
"author": "stemie",
"author_id": 22502,
"author_profile": "https://wordpress.stackexchange.com/users/22502",
"pm_score": 2,
"selected": false,
"text": "<p>Re saving the permalink structure seemed to fix the issue.\nThanks for the tip Mike and Vinod.</p>\n"
},
{
... | 2013/03/04 | [
"https://wordpress.stackexchange.com/questions/89311",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I want to increase the maximum upload file (media default:32mb). Before posting i search, but i didn't have the result that i want.
My host didn't support .htaccess.
I create my own `php.ini` with these:
```
memory_limit = 32M
upload_max_filesize = 120M
upload_max_filesize = 120M
post_max_size = 100M
file_uploads = On... | 1. Navigate to Settings -> permalinks
2. Change the permalink structure to *Default*
3. Save settings
4. Change to custom structure or post name (or any other structure)
5. Save Settings
This will re-write the htaccess file and then the re-write should work.
---
If the above solution doesn't work - it should be rela... |
89,322 | <p>I am using the latest WordPress version and when I use <code><?php the_excerpt(); ?></code> on the index page it doesn't show the post excerpt.</p>
<p>I tried putting in the_content() instead and it worked, so I'm assuming there is something wrong.</p>
<p>My code:</p>
<pre><code><?php get_header(); ?>... | [
{
"answer_id": 89323,
"author": "C. E.",
"author_id": 161159,
"author_profile": "https://wordpress.stackexchange.com/users/161159",
"pm_score": 0,
"selected": false,
"text": "<p>The function that gets the excerpt, and <code>the_excerpt</code> itself, can be located in <code>wp-includes/p... | 2013/03/02 | [
"https://wordpress.stackexchange.com/questions/89322",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28462/"
] | I am using the latest WordPress version and when I use `<?php the_excerpt(); ?>` on the index page it doesn't show the post excerpt.
I tried putting in the\_content() instead and it worked, so I'm assuming there is something wrong.
My code:
```
<?php get_header(); ?>
<?php if (have_posts()) : ?>
<div id="post-area"... | I actually solved it myself, it turns out there was this piece of code which I removed that solved my problem:
```
function custom_excerpt_length( $length ) {
return 0;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
```
Not sure what it does though, but it doesn't seem like I nee... |
89,334 | <p>I am having issues with the get_the_terms php that is pulling in my current posts categories (custom taxonomy portfolio_category). I can successfully pull in the last category. </p>
<p>If you look at this page you'll see links along the top: <a href="http://www.slarc.com/portfolio-view/central-control-building-eas... | [
{
"answer_id": 89323,
"author": "C. E.",
"author_id": 161159,
"author_profile": "https://wordpress.stackexchange.com/users/161159",
"pm_score": 0,
"selected": false,
"text": "<p>The function that gets the excerpt, and <code>the_excerpt</code> itself, can be located in <code>wp-includes/p... | 2013/03/04 | [
"https://wordpress.stackexchange.com/questions/89334",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28079/"
] | I am having issues with the get\_the\_terms php that is pulling in my current posts categories (custom taxonomy portfolio\_category). I can successfully pull in the last category.
If you look at this page you'll see links along the top: <http://www.slarc.com/portfolio-view/central-control-building-east-texas/> those ... | I actually solved it myself, it turns out there was this piece of code which I removed that solved my problem:
```
function custom_excerpt_length( $length ) {
return 0;
}
add_filter( 'excerpt_length', 'custom_excerpt_length', 999 );
```
Not sure what it does though, but it doesn't seem like I nee... |
89,336 | <p>I have <a href="http://jsfiddle.net/UqY2C/" rel="nofollow">this js function</a> (the <code>textualizer.js</code> is external) but I can't make it works on WordPress. Any help? </p>
<p>I already added</p>
<pre><code>wp_register_script( 'textualizer', WP_THEME_URL . '/assets/js/textualizer.js');
wp_enqueue_script( '... | [
{
"answer_id": 89374,
"author": "Marc Wiest",
"author_id": 14008,
"author_profile": "https://wordpress.stackexchange.com/users/14008",
"pm_score": 1,
"selected": false,
"text": "<p>Not quite sure where WP_THEME_URL links to, but here is an idea. Depending on whether you're calling the fi... | 2013/03/04 | [
"https://wordpress.stackexchange.com/questions/89336",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27686/"
] | I have [this js function](http://jsfiddle.net/UqY2C/) (the `textualizer.js` is external) but I can't make it works on WordPress. Any help?
I already added
```
wp_register_script( 'textualizer', WP_THEME_URL . '/assets/js/textualizer.js');
wp_enqueue_script( 'textualizer' );
```
to theme functions.
What am I doing... | Using Google with the error message you posted in your comment, Google show me this: The [Deferred](http://api.jquery.com/category/deferred-object/) object, introduced in jQuery **1.5**
Your source code says, that you use jQuery **1.4.4**.
jQuery is bundled with WordPress and it's version is **1.8.3**. Please use th... |
89,341 | <p>I've successfully used the code from the post:
Restrict ADMIN menu items based on username, replace username with an actual user's name.</p>
<p>The problem is the theme still shows on the main dashboard and by clicking on the theme name the admin is taken to the appearance menu which had been hidden by using the co... | [
{
"answer_id": 89374,
"author": "Marc Wiest",
"author_id": 14008,
"author_profile": "https://wordpress.stackexchange.com/users/14008",
"pm_score": 1,
"selected": false,
"text": "<p>Not quite sure where WP_THEME_URL links to, but here is an idea. Depending on whether you're calling the fi... | 2013/03/04 | [
"https://wordpress.stackexchange.com/questions/89341",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28365/"
] | I've successfully used the code from the post:
Restrict ADMIN menu items based on username, replace username with an actual user's name.
The problem is the theme still shows on the main dashboard and by clicking on the theme name the admin is taken to the appearance menu which had been hidden by using the code.
Any ... | Using Google with the error message you posted in your comment, Google show me this: The [Deferred](http://api.jquery.com/category/deferred-object/) object, introduced in jQuery **1.5**
Your source code says, that you use jQuery **1.4.4**.
jQuery is bundled with WordPress and it's version is **1.8.3**. Please use th... |
89,351 | <p>I have a custom post type <code>recipes</code>. I am using a cron script to automatically aggregate news into the database.</p>
<p>It is currently being imported and saved as 'Pending Review'. Is it possible to create another post status called <code>Aggregated</code> which will list all of the aggregated news to b... | [
{
"answer_id": 89388,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 3,
"selected": false,
"text": "<p>Your code should be sound, and should add the desired status to the $wp_post_statuses global array.</p>\n\n<p... | 2013/03/04 | [
"https://wordpress.stackexchange.com/questions/89351",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26762/"
] | I have a custom post type `recipes`. I am using a cron script to automatically aggregate news into the database.
It is currently being imported and saved as 'Pending Review'. Is it possible to create another post status called `Aggregated` which will list all of the aggregated news to be published?
I tried using the ... | There is a great Step by Step description on how to do that here <https://www.jclabs.co.uk/create-custom-post-status-in-wordpress-using-register_post_status/>
To add your custom post status to the drop-down menue, just add the following to your themes function script:
```
add_action('admin_footer-post.php', 'jc_appen... |
89,382 | <p>I've written a simple multi-language system, whereby clicking on a flag icon sets a one year cookie containing a two letter language code (e.g. nl, de, etc).</p>
<p>I hook into the <code>wp</code> action to read the cookie value, then use the <code>the_title</code> and <code>the_content</code> filters to show the c... | [
{
"answer_id": 89453,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 1,
"selected": false,
"text": "<p>Your question is complicated enough to answer by myself, but I would suggest you to install <a href=\"ht... | 2013/03/04 | [
"https://wordpress.stackexchange.com/questions/89382",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2877/"
] | I've written a simple multi-language system, whereby clicking on a flag icon sets a one year cookie containing a two letter language code (e.g. nl, de, etc).
I hook into the `wp` action to read the cookie value, then use the `the_title` and `the_content` filters to show the correct language (the different languages ar... | Your question is complicated enough to answer by myself, but I would suggest you to install [`qTranslate`](http://wordpress.org/extend/plugins/qtranslate/) plugin. As the plugin's description says:
>
> Choose one of 3 Modes to make your URLs pretty and SEO-friendly. - The
> everywhere compatible ?lang=en, simple and... |
89,384 | <p>I have a shortcode for a blockquote <code>[blockquote]this is the quote[/blockquote]</code> ... this is the code.</p>
<pre><code>function shortcode_shortcodetest( $atts, $content = null ) {
$return = '<div class="blockquotewrapper"><blockquote>';
$return .= do_shortcode( $content );
$return ... | [
{
"answer_id": 89385,
"author": "byronyasgur",
"author_id": 6169,
"author_profile": "https://wordpress.stackexchange.com/users/6169",
"pm_score": 3,
"selected": true,
"text": "<p>By chance I just happened to discover what it was, so I think I'll leave this here as it might help someone i... | 2013/03/04 | [
"https://wordpress.stackexchange.com/questions/89384",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6169/"
] | I have a shortcode for a blockquote `[blockquote]this is the quote[/blockquote]` ... this is the code.
```
function shortcode_shortcodetest( $atts, $content = null ) {
$return = '<div class="blockquotewrapper"><blockquote>';
$return .= do_shortcode( $content );
$return .= '</blockquote>';
$return .= '<... | By chance I just happened to discover what it was, so I think I'll leave this here as it might help someone in the future.
Some web pages, including an answer to [this question](https://wordpress.stackexchange.com/questions/20453/how-can-i-remove-the-paragraph-from-shortcodes-content) suggest using the following code ... |
89,386 | <p>I am trying to understand how can create custom rewrites for pages/categories. Ex i have <code>example.com/?page_id=178</code> and for this page have a contact form and i want this: <code>%slug%.php</code></p>
<pre><code>example.com/contact.php
</code></pre>
<p>In the permalinks i have two choices.
1) Is the <stro... | [
{
"answer_id": 89385,
"author": "byronyasgur",
"author_id": 6169,
"author_profile": "https://wordpress.stackexchange.com/users/6169",
"pm_score": 3,
"selected": true,
"text": "<p>By chance I just happened to discover what it was, so I think I'll leave this here as it might help someone i... | 2013/03/05 | [
"https://wordpress.stackexchange.com/questions/89386",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I am trying to understand how can create custom rewrites for pages/categories. Ex i have `example.com/?page_id=178` and for this page have a contact form and i want this: `%slug%.php`
```
example.com/contact.php
```
In the permalinks i have two choices.
1) Is the **Post name** and the 2) is the **Custom Structure** ... | By chance I just happened to discover what it was, so I think I'll leave this here as it might help someone in the future.
Some web pages, including an answer to [this question](https://wordpress.stackexchange.com/questions/20453/how-can-i-remove-the-paragraph-from-shortcodes-content) suggest using the following code ... |
89,392 | <p>I have a blog Post home page with the following code in <code>home.php</code>:</p>
<pre><code><div id="primary">
<div id="content" role="main">
<h2 class="page-title">Featured Products</h2>
<?php
$paged = (get_query_var('paged')) ? get_query_var('pa... | [
{
"answer_id": 89399,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 0,
"selected": false,
"text": "<p>Change the line in which you set the variable $paged as follows:</p>\n\n<p><code>$paged = (get_query_var('pag... | 2013/03/05 | [
"https://wordpress.stackexchange.com/questions/89392",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28153/"
] | I have a blog Post home page with the following code in `home.php`:
```
<div id="primary">
<div id="content" role="main">
<h2 class="page-title">Featured Products</h2>
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
wp_reset_query();
mp_display_products('&post_type=product&paged=' . $paged, $dis... | To understand why 404 erros occur with pagination, you have to first understand the process WordPress follows when a page is requested.
The query is parsed and the results are queried from the database *before* the template is loaded. When you create a new query in the template, these results are unrelated to the orig... |
89,393 | <p>I have a new, custom theme that I've uploaded on a pre-existing site/blog. Everything seems to be working ok, with the exception of the older blog posts not showing up. Any ideas what I can do to fix?</p>
<pre><code><?php get_header();?>
<div id="blog-container">
<?php get_sidebar( 'blog');?>... | [
{
"answer_id": 89399,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 0,
"selected": false,
"text": "<p>Change the line in which you set the variable $paged as follows:</p>\n\n<p><code>$paged = (get_query_var('pag... | 2013/03/05 | [
"https://wordpress.stackexchange.com/questions/89393",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14606/"
] | I have a new, custom theme that I've uploaded on a pre-existing site/blog. Everything seems to be working ok, with the exception of the older blog posts not showing up. Any ideas what I can do to fix?
```
<?php get_header();?>
<div id="blog-container">
<?php get_sidebar( 'blog');?>
<div class="content">
<... | To understand why 404 erros occur with pagination, you have to first understand the process WordPress follows when a page is requested.
The query is parsed and the results are queried from the database *before* the template is loaded. When you create a new query in the template, these results are unrelated to the orig... |
89,395 | <p>I've been googling this for a while, and came across this link here: <a href="https://wordpress.stackexchange.com/questions/29286/can-i-limit-this-meta-box-to-a-particular-page">Can I limit this meta box to a particular page?</a></p>
<p>What I am trying to achieve is adding a custom Meta Boxe I created onto a CPT P... | [
{
"answer_id": 89400,
"author": "Gary Smirny",
"author_id": 28390,
"author_profile": "https://wordpress.stackexchange.com/users/28390",
"pm_score": 1,
"selected": true,
"text": "<p>From your comment, it sounds like you don't want a metabox. A metabox is used to add metadata to a particul... | 2013/03/05 | [
"https://wordpress.stackexchange.com/questions/89395",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28389/"
] | I've been googling this for a while, and came across this link here: [Can I limit this meta box to a particular page?](https://wordpress.stackexchange.com/questions/29286/can-i-limit-this-meta-box-to-a-particular-page)
What I am trying to achieve is adding a custom Meta Boxe I created onto a CPT Posts Screen (`edit.ph... | From your comment, it sounds like you don't want a metabox. A metabox is used to add metadata to a particular post, not create a new post from scratch. What it sounds like you want to do is create a widget to do what you want and then invoke it through an action or filter at the top/bottom of the page. You can use the ... |
89,413 | <p>I'm using the query below in the index.php file as the main query, whenever I try to go to the 2nd page I get a 404 error, I tried using posts_per_page but to no avail.</p>
<pre><code><?php
$args = array(
'post_type' => array( 'post', 'videos', 'music' ),
'tax_query' => array(
array(
't... | [
{
"answer_id": 89416,
"author": "chrisguitarguy",
"author_id": 6035,
"author_profile": "https://wordpress.stackexchange.com/users/6035",
"pm_score": 3,
"selected": true,
"text": "<p>Pagination in URLs only works for the \"main\" query. What you've created is a secondary query, so WordPre... | 2013/03/05 | [
"https://wordpress.stackexchange.com/questions/89413",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35798/"
] | I'm using the query below in the index.php file as the main query, whenever I try to go to the 2nd page I get a 404 error, I tried using posts\_per\_page but to no avail.
```
<?php
$args = array(
'post_type' => array( 'post', 'videos', 'music' ),
'tax_query' => array(
array(
'taxonomy' => 'content'... | Pagination in URLs only works for the "main" query. What you've created is a secondary query, so WordPress doesn't "know" about it in such a way that the application would be able to create pagination. If you use a secondary query (like your example) it's up to you to do the pagination stuff manually.
Rather than crea... |
89,425 | <p>I am using meteor-slides plugin to make header as a slideshow. I am using twenty-eleven theme. Now i need to make this slideshow for my homepage only and featured images of other pages as headers for the respective pages. Can anyone help me with this?</p>
| [
{
"answer_id": 89416,
"author": "chrisguitarguy",
"author_id": 6035,
"author_profile": "https://wordpress.stackexchange.com/users/6035",
"pm_score": 3,
"selected": true,
"text": "<p>Pagination in URLs only works for the \"main\" query. What you've created is a secondary query, so WordPre... | 2013/03/05 | [
"https://wordpress.stackexchange.com/questions/89425",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28044/"
] | I am using meteor-slides plugin to make header as a slideshow. I am using twenty-eleven theme. Now i need to make this slideshow for my homepage only and featured images of other pages as headers for the respective pages. Can anyone help me with this? | Pagination in URLs only works for the "main" query. What you've created is a secondary query, so WordPress doesn't "know" about it in such a way that the application would be able to create pagination. If you use a secondary query (like your example) it's up to you to do the pagination stuff manually.
Rather than crea... |
89,434 | <p>I am using the default Twenty Twelve Wordpress theme with my site, and I am trying to customize the sidebar. The CSS I am using is:</p>
<pre><code>.widget-area, #secondary{
float: right;
width: 210px;
font-family: Georgia, "Times New Roman", Times, serif;
padding: 0 15px 0 15px;
border-bottom: 1px solid #cacaca; ... | [
{
"answer_id": 89437,
"author": "Ronald",
"author_id": 27469,
"author_profile": "https://wordpress.stackexchange.com/users/27469",
"pm_score": -1,
"selected": false,
"text": "<p>are you using reset.css ? \nif not you can download here\n<a href=\"http://www.cssreset.com/scripts/html5-doct... | 2013/03/05 | [
"https://wordpress.stackexchange.com/questions/89434",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28396/"
] | I am using the default Twenty Twelve Wordpress theme with my site, and I am trying to customize the sidebar. The CSS I am using is:
```
.widget-area, #secondary{
float: right;
width: 210px;
font-family: Georgia, "Times New Roman", Times, serif;
padding: 0 15px 0 15px;
border-bottom: 1px solid #cacaca;
borde... | You have added this CSS in below css3 media query and this css3 media rule does not support IE8 and below browsers so it is not applying css contained in its block.
```
/* Minimum width of 600 pixels. */
@media screen and (min-width: 800px) {
.widget-area, #secondary{
float: right;
width: 210px;
font-family: Georgia... |
89,454 | <p>I have a class with this function to provide a user language based on $user_id</p>
<pre><code>function provide_user_language($user_id) {
return apply_filters('get_user_language',$user_id);
}
</code></pre>
<p>So in my script, I can simply get the user language by doing this:</p>
<pre><code>$user_language=$this-&... | [
{
"answer_id": 89464,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 3,
"selected": false,
"text": "<p>The trick Toscho used was to get around the problem using Objects.</p>\n\n<p>So lets say we have a filter nam... | 2013/03/05 | [
"https://wordpress.stackexchange.com/questions/89454",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20972/"
] | I have a class with this function to provide a user language based on $user\_id
```
function provide_user_language($user_id) {
return apply_filters('get_user_language',$user_id);
}
```
So in my script, I can simply get the user language by doing this:
```
$user_language=$this->provide_user_language($user_id);
``... | Thanks Tom,
Unfortunately Toscho concept didn't work for me, so I dig deeper in the add filter documentation here: <http://codex.wordpress.org/Function_Reference/add_filter> and they allow anonymous functions as callback.
This method finally solved my problem. This is how I resolve this one for other users that are e... |
89,456 | <p>I am seeing many plugins use the following format for defining their constant:</p>
<pre><code>/* Set the constant path to the plugin's javascript directory. */
if( !defined( 'MY_ETS_JS' ) )
define( 'MY_ETS_JS', MY_ETS_URI . trailingslashit( 'js' ), true );
</code></pre>
<p>So basically there is a check bef... | [
{
"answer_id": 89459,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 0,
"selected": false,
"text": "<p>You cannot re-define defines. They're called <em>constants</em>. So this is more a check to not produce an er... | 2013/03/05 | [
"https://wordpress.stackexchange.com/questions/89456",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5844/"
] | I am seeing many plugins use the following format for defining their constant:
```
/* Set the constant path to the plugin's javascript directory. */
if( !defined( 'MY_ETS_JS' ) )
define( 'MY_ETS_JS', MY_ETS_URI . trailingslashit( 'js' ), true );
```
So basically there is a check before we define the constant... | These are not [PHP global variables](http://php.net/manual/en/reserved.variables.globals.php), they are constants that cannot be modified(hence the name).
Trying to redefine them, using a [`define()`](http://www.php.net/manual/en/function.define.php) will trigger a notice since they are already defined(and consequentl... |
89,463 | <p>I am trying to piece together a Metabox with 3 text editor fields for a custom post type.</p>
<p>The box is showing up and appears to be saving on the custom post type entries but I can't get the data to display on the single-[custom-post-type].php page.</p>
<p>Most recently I have tried the following to get the m... | [
{
"answer_id": 89465,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 3,
"selected": false,
"text": "<p>To show post type meta data on a single page template, I assume that you're in the Loop.</p>\n\n<pre><code>// Use g... | 2013/03/05 | [
"https://wordpress.stackexchange.com/questions/89463",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12238/"
] | I am trying to piece together a Metabox with 3 text editor fields for a custom post type.
The box is showing up and appears to be saving on the custom post type entries but I can't get the data to display on the single-[custom-post-type].php page.
Most recently I have tried the following to get the meta box data to d... | To show post type meta data on a single page template, I assume that you're in the Loop.
```
// Use get_the_ID() to get the ID via the API function
echo get_post_meta( get_the_ID(), 'my-info', true );
// You can also call it from the global, as the query refers to the current single page
echo get_post_meta( $GLOBALS['... |
89,468 | <p>Is there any way out to create additional thumbnails of custom size in nextgen gallery while uploading images?
For example I would like to create 3 thumbnails of size 25*30, 100*50, and 400*350 to display them in certain custom pages.Or can i add custom code to resize when image upload is triggered and if so where?<... | [
{
"answer_id": 89465,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 3,
"selected": false,
"text": "<p>To show post type meta data on a single page template, I assume that you're in the Loop.</p>\n\n<pre><code>// Use g... | 2013/03/05 | [
"https://wordpress.stackexchange.com/questions/89468",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27422/"
] | Is there any way out to create additional thumbnails of custom size in nextgen gallery while uploading images?
For example I would like to create 3 thumbnails of size 25\*30, 100\*50, and 400\*350 to display them in certain custom pages.Or can i add custom code to resize when image upload is triggered and if so where? | To show post type meta data on a single page template, I assume that you're in the Loop.
```
// Use get_the_ID() to get the ID via the API function
echo get_post_meta( get_the_ID(), 'my-info', true );
// You can also call it from the global, as the query refers to the current single page
echo get_post_meta( $GLOBALS['... |
89,470 | <p>I'm using custom (commercial) fonts in my project. Everything works well in the frontend.</p>
<p>I noticed however that, when trying to add this font to the TinyMCE iframe, I get a 403 for the webfonts. The problem seems to be, that requests from the iframe do not have a referrer. And fonts.com needs a referrer to ... | [
{
"answer_id": 89472,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 1,
"selected": false,
"text": "<p>If you want add your custom styles to TinyMCE editor in WordPress, you need to create a css file, for in... | 2013/03/05 | [
"https://wordpress.stackexchange.com/questions/89470",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6406/"
] | I'm using custom (commercial) fonts in my project. Everything works well in the frontend.
I noticed however that, when trying to add this font to the TinyMCE iframe, I get a 403 for the webfonts. The problem seems to be, that requests from the iframe do not have a referrer. And fonts.com needs a referrer to validate t... | I ran into this issue with Typekit, here's my solution:
<http://www.tomjn.com/150/typekit-wp-editor-styles/>
```
add_filter("mce_external_plugins", "tomjn_mce_external_plugins");
function tomjn_mce_external_plugins($plugin_array){
$plugin_array['typekit'] = get_template_directory_uri().'/typekit.tinymce.js';
... |
89,473 | <p>I am trying to create a shortcode with an array as input like so</p>
<pre><code>function product_gallery_shortcode($atts) {
extract(shortcode_atts(array(
'product_id' => '31',
'prodvid' => false,
'youtubeids'=>'',//['lbRqMddP2jo','eFAxx817rC0'],
'thumbnr' =&... | [
{
"answer_id": 89479,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 0,
"selected": false,
"text": "<p>Could you not just do:</p>\n\n<pre><code>extract(shortcode_atts(array(\n 'product_id' => '31',\... | 2013/03/05 | [
"https://wordpress.stackexchange.com/questions/89473",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9936/"
] | I am trying to create a shortcode with an array as input like so
```
function product_gallery_shortcode($atts) {
extract(shortcode_atts(array(
'product_id' => '31',
'prodvid' => false,
'youtubeids'=>'',//['lbRqMddP2jo','eFAxx817rC0'],
'thumbnr' =>2
), $a... | Ok found a solution
```
function product_gallery_shortcode($atts) {
extract(shortcode_atts(array(
'product_id' => '31',
'prodvid' => false,
'youtubeids'=> '',
'thumbnr' =>2
), $atts));
etc
```
and i had to turn youtubeids into an array again
```
$yout... |
89,494 | <p>I'm developing a theme. I added the codes (below) into the <code>header.php</code>. But I posted it into the WP theme repository, and it's under review, and the reviewer informed me to enqueue the style with <code>wp_enqueue_style()</code>/ <code>wp_enqueue_script()</code>. But can't understand how to implement it w... | [
{
"answer_id": 89495,
"author": "Mike Madern",
"author_id": 24806,
"author_profile": "https://wordpress.stackexchange.com/users/24806",
"pm_score": 5,
"selected": true,
"text": "<p>This is what you could do:</p>\n\n<p>1 - Put the CSS in a separate file and save it in your theme directory... | 2013/03/05 | [
"https://wordpress.stackexchange.com/questions/89494",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22728/"
] | I'm developing a theme. I added the codes (below) into the `header.php`. But I posted it into the WP theme repository, and it's under review, and the reviewer informed me to enqueue the style with `wp_enqueue_style()`/ `wp_enqueue_script()`. But can't understand how to implement it with the function. I've seen the dire... | This is what you could do:
1 - Put the CSS in a separate file and save it in your theme directory.
2 - Add the following code in your `functions php`:
```
function wpse_89494_enqueue_scripts() {
if ( has_nav_menu( 'secondary' ) ) {
wp_enqueue_style(
'wpse_89494_style_1',
get_template_directory_... |
89,512 | <p>Is there a function in WordPress that will check if the page you are on is a sub-category archive page?</p>
<p>Like the way is_category checks if it's a category page?</p>
| [
{
"answer_id": 89513,
"author": "Kirill Fuchs",
"author_id": 16500,
"author_profile": "https://wordpress.stackexchange.com/users/16500",
"pm_score": 4,
"selected": true,
"text": "<p>Sub-categories use the regular category archive page by default. There is no function such as is_subcatego... | 2013/03/05 | [
"https://wordpress.stackexchange.com/questions/89512",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16500/"
] | Is there a function in WordPress that will check if the page you are on is a sub-category archive page?
Like the way is\_category checks if it's a category page? | Sub-categories use the regular category archive page by default. There is no function such as is\_subcategory. But you can write your own.
Here is an example:
This will check if the current page is a sub-category. Or if you pass an ID it will check if the ID is a subcategory.
```
function is_subcategory( $cat_id = NU... |
89,521 | <p>We're working on a database with personal data from different sportsmen such as name, height, weight, etc.</p>
<p>We've managed to build a detailed filter through <code>query_posts</code>.</p>
<p>Every filter field is working as expected except for the text input field that we use to filter the sportsman by name. ... | [
{
"answer_id": 89525,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 0,
"selected": false,
"text": "<p>First, use <code>WP_query</code> instead of <code>query_posts</code>.</p>\n\n<pre><code>$my_query = new WP_qu... | 2013/03/05 | [
"https://wordpress.stackexchange.com/questions/89521",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28421/"
] | We're working on a database with personal data from different sportsmen such as name, height, weight, etc.
We've managed to build a detailed filter through `query_posts`.
Every filter field is working as expected except for the text input field that we use to filter the sportsman by name. The problem is that when we ... | Use search parameter 's' instead of 'name'
```
query_posts( array(
's' => $sportsman_name,
'post_type' => 'db',
'posts_per_page' => 100,
'paged' => $paged,
'category_name' => $sport,
'meta_query' => array(
$height,
$weight,
$tshirt_size,
$foot_size,
)));
``` |
89,535 | <p>I'm trying to adapt some code on <a href="http://www.ringabell.org/en/appeller-un-fichier-de-template-custom-avec-une-rewrite-rule-dans-wordpress/" rel="nofollow noreferrer">calling a custom template via rewrite rule</a>.</p>
<p>I have a custom taxonomy called "state". I want to create an archive for the taxonomy,... | [
{
"answer_id": 89525,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 0,
"selected": false,
"text": "<p>First, use <code>WP_query</code> instead of <code>query_posts</code>.</p>\n\n<pre><code>$my_query = new WP_qu... | 2013/03/05 | [
"https://wordpress.stackexchange.com/questions/89535",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6477/"
] | I'm trying to adapt some code on [calling a custom template via rewrite rule](http://www.ringabell.org/en/appeller-un-fichier-de-template-custom-avec-une-rewrite-rule-dans-wordpress/).
I have a custom taxonomy called "state". I want to create an archive for the taxonomy, that lists all the *terms* in that taxonomy.
`... | Use search parameter 's' instead of 'name'
```
query_posts( array(
's' => $sportsman_name,
'post_type' => 'db',
'posts_per_page' => 100,
'paged' => $paged,
'category_name' => $sport,
'meta_query' => array(
$height,
$weight,
$tshirt_size,
$foot_size,
)));
``` |
89,543 | <p>I want to build a list of partners. At the moment, I have tried with the "links" function, the problem is that I can't use html tags on the description field. Therefore I'm looking for another solution. Anyone has a suggestion? </p>
| [
{
"answer_id": 89556,
"author": "chifliiiii",
"author_id": 4130,
"author_profile": "https://wordpress.stackexchange.com/users/4130",
"pm_score": 1,
"selected": false,
"text": "<p>As NW Tech commented you should use a custom post type for it. Check codex for <a href=\"http://codex.wordpre... | 2013/03/05 | [
"https://wordpress.stackexchange.com/questions/89543",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28435/"
] | I want to build a list of partners. At the moment, I have tried with the "links" function, the problem is that I can't use html tags on the description field. Therefore I'm looking for another solution. Anyone has a suggestion? | As NW Tech commented you should use a custom post type for it. Check codex for [register\_post\_type](http://codex.wordpress.org/Function_Reference/register_post_type).
You could try something like this:
```
function partners_custom_init() {
$labels = array(
'name' => 'Partners',
'singular_name' => 'Partner... |
89,581 | <p>I want to restrict access to my WordPress site to allow registered users only. I have tried the following plugins:</p>
<ul>
<li>Require-login</li>
<li>Authenticator</li>
<li>WP-lock</li>
</ul>
<p>All of them have the same problem: After seeing the login page, you can easily retype the URL in the browser address ba... | [
{
"answer_id": 89585,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": true,
"text": "<p>It seems to me that all you should need is this:</p>\n\n<pre><code>function force_login_wpse_89581() {\n if (... | 2013/03/06 | [
"https://wordpress.stackexchange.com/questions/89581",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28447/"
] | I want to restrict access to my WordPress site to allow registered users only. I have tried the following plugins:
* Require-login
* Authenticator
* WP-lock
All of them have the same problem: After seeing the login page, you can easily retype the URL in the browser address bar to bypass the login screen and access th... | It seems to me that all you should need is this:
```
function force_login_wpse_89581() {
if (!is_user_logged_in()) wp_safe_redirect(wp_login_url());
}
add_action('template_redirect','force_login_wpse_89581');
```
That should force users to the login page except for users who have already logged in.
I don't know ... |
89,590 | <p>I've got my user registration to automatically create a post with the user_register hook however the title shows up as (no title) can someone help me with what I'm doing wrong here?</p>
<pre><code>add_action('user_register','create_new_user_post');
$userinfo = get_userdata($user_id);
$disname = $userinfo->displ... | [
{
"answer_id": 89591,
"author": "Josh",
"author_id": 23126,
"author_profile": "https://wordpress.stackexchange.com/users/23126",
"pm_score": 2,
"selected": true,
"text": "<p>Your function <code>create_new_user_post()</code> can't see:</p>\n\n<pre><code>$userinfo = get_userdata($user_id);... | 2013/03/06 | [
"https://wordpress.stackexchange.com/questions/89590",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18726/"
] | I've got my user registration to automatically create a post with the user\_register hook however the title shows up as (no title) can someone help me with what I'm doing wrong here?
```
add_action('user_register','create_new_user_post');
$userinfo = get_userdata($user_id);
$disname = $userinfo->display_name;
functi... | Your function `create_new_user_post()` can't see:
```
$userinfo = get_userdata($user_id);
$disname = $userinfo->display_name;
```
Place those within the function so that the function has access to those variables. |
89,600 | <p>I'm trying to convert a json string back into an array in wordpress. Here is the json string that I'm getting back from the database:</p>
<pre><code>[
{
"item_title": "Kindle Fire HD 7\", Dolby Audio, Dual-Band Wi-Fi, 16 GB - Includes Special Offers",
"item_url": "http://my.dev/tester/wordpress/... | [
{
"answer_id": 89604,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 3,
"selected": true,
"text": "<p>I tried to parse your JSON into <a href=\"http://json.parser.online.fr/\" rel=\"nofollow noreferrer\">this</a> ... | 2013/03/06 | [
"https://wordpress.stackexchange.com/questions/89600",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27291/"
] | I'm trying to convert a json string back into an array in wordpress. Here is the json string that I'm getting back from the database:
```
[
{
"item_title": "Kindle Fire HD 7\", Dolby Audio, Dual-Band Wi-Fi, 16 GB - Includes Special Offers",
"item_url": "http://my.dev/tester/wordpress/wp-content/eco... | I tried to parse your JSON into [this](http://json.parser.online.fr/) and got an error that you have bad escaped characters (backslash must be escaped).
Taking into account [Vinod Dalvi's comment](https://wordpress.stackexchange.com/questions/89600/json-decode-does-not-work-on-wordpress#comment121102_89600), the defin... |
89,603 | <p>I would like to add one line to a wp core file. Basically on the 'edit.php' page, just right above </p>
<pre><code><?php
include('./admin-footer.php');
</code></pre>
<p>I would like to add an php include statement... </p>
<pre><code>include('./custom-file.php');
</code></pre>
<p>The custom-file is located ins... | [
{
"answer_id": 89604,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 3,
"selected": true,
"text": "<p>I tried to parse your JSON into <a href=\"http://json.parser.online.fr/\" rel=\"nofollow noreferrer\">this</a> ... | 2013/03/06 | [
"https://wordpress.stackexchange.com/questions/89603",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28389/"
] | I would like to add one line to a wp core file. Basically on the 'edit.php' page, just right above
```
<?php
include('./admin-footer.php');
```
I would like to add an php include statement...
```
include('./custom-file.php');
```
The custom-file is located inside a plugin, not a theme... so if I write it inside... | I tried to parse your JSON into [this](http://json.parser.online.fr/) and got an error that you have bad escaped characters (backslash must be escaped).
Taking into account [Vinod Dalvi's comment](https://wordpress.stackexchange.com/questions/89600/json-decode-does-not-work-on-wordpress#comment121102_89600), the defin... |
89,612 | <p>What I am trying to accomplish is placing custom widget on an admin page (edit.php). I tried using these two functions: </p>
<p>Places custom html right below < body > (above all page content)</p>
<pre><code>add_action( 'load-edit.php', 'your_function' );
function your_function() {
include( plugin_dir_path(... | [
{
"answer_id": 89604,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 3,
"selected": true,
"text": "<p>I tried to parse your JSON into <a href=\"http://json.parser.online.fr/\" rel=\"nofollow noreferrer\">this</a> ... | 2013/03/06 | [
"https://wordpress.stackexchange.com/questions/89612",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28389/"
] | What I am trying to accomplish is placing custom widget on an admin page (edit.php). I tried using these two functions:
Places custom html right below < body > (above all page content)
```
add_action( 'load-edit.php', 'your_function' );
function your_function() {
include( plugin_dir_path( __FILE__ ) . 'quickpost... | I tried to parse your JSON into [this](http://json.parser.online.fr/) and got an error that you have bad escaped characters (backslash must be escaped).
Taking into account [Vinod Dalvi's comment](https://wordpress.stackexchange.com/questions/89600/json-decode-does-not-work-on-wordpress#comment121102_89600), the defin... |
89,632 | <p>I want to reset admin's meta value after login. It can be changed after login by admin via control panel, but I want to reset it after every login.</p>
<p>I used this code but it's not working:</p>
<pre><code>function reset_dismiss_message(){
update_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice', f... | [
{
"answer_id": 89634,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 2,
"selected": true,
"text": "<p><code>wp_login</code> action <a href=\"http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/user... | 2013/03/06 | [
"https://wordpress.stackexchange.com/questions/89632",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10316/"
] | I want to reset admin's meta value after login. It can be changed after login by admin via control panel, but I want to reset it after every login.
I used this code but it's not working:
```
function reset_dismiss_message(){
update_user_meta( get_current_user_id(), 'tgmpa_dismissed_notice', false );
}
add_action(... | `wp_login` action [passes](http://core.trac.wordpress.org/browser/tags/3.5.1/wp-includes/user.php#L64) 2 arguments `$user_login` and `$user`. The second argument is the object of `WP_User` class, which you can use to get user id from:
```
function reset_dismiss_message( $user_login, $user ) {
update_user_meta( $us... |
89,651 | <p>I'm working on a plugin in which I do the following for autoloading classes:</p>
<pre><code>function TFSLAutoload($class) {
$classfile = dirname(__FILE__).'/includes/'.strtolower($class).'.php';
include $classfile;
} // function TFSLAutoload
spl_autoload_register('TFSLAutoload');
</code></pre>
<p>In the pl... | [
{
"answer_id": 89655,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>There is no built-in autoloader in WordPress. But other plugins or a theme might have registered an autoloader, and dep... | 2013/03/06 | [
"https://wordpress.stackexchange.com/questions/89651",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27722/"
] | I'm working on a plugin in which I do the following for autoloading classes:
```
function TFSLAutoload($class) {
$classfile = dirname(__FILE__).'/includes/'.strtolower($class).'.php';
include $classfile;
} // function TFSLAutoload
spl_autoload_register('TFSLAutoload');
```
In the plugin (classes) I can insta... | There is no built-in autoloader in WordPress. But other plugins or a theme might have registered an autoloader, and depending on the order of execution these are called earlier or later than yours.
---
**Update 21. 08. 2014** This answer is no longer what I would recommend. Do use an autoloader if you need one.
---
... |
89,667 | <p>Been hunting for a while and I can't figure out how to use <code>get_custom_header</code> to get the alt text associated with the media file, so that I can add photo credits to the headers on my site. Am I missing something?</p>
<p>Code to add header image is:</p>
<pre><code><img src="<?php header_image(); ?... | [
{
"answer_id": 89690,
"author": "jfacemyer",
"author_id": 12660,
"author_profile": "https://wordpress.stackexchange.com/users/12660",
"pm_score": -1,
"selected": false,
"text": "<p>Try:</p>\n\n<pre><code>get_custom_header()->description\n</code></pre>\n"
},
{
"answer_id": 1000... | 2013/03/06 | [
"https://wordpress.stackexchange.com/questions/89667",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1340/"
] | Been hunting for a while and I can't figure out how to use `get_custom_header` to get the alt text associated with the media file, so that I can add photo credits to the headers on my site. Am I missing something?
Code to add header image is:
```
<img src="<?php header_image(); ?>" height="<?php echo get_custom_heade... | Use this for the `alt=""` attribute on the custom header `<img>` tag …
```
alt="<?php
$attachment_id = get_custom_header()->attachment_id;
$alt = get_post_meta( $attachment_id, '_wp_attachment_image_alt', true );
if ( count( $alt ) ) echo $alt;
?>" />
```
… and then just edit the media attachment and add the alt ... |
89,687 | <p>I am using plugin like to read <a href="http://wordpress.org/extend/plugins/like-to-keep-reading/" rel="nofollow">http://wordpress.org/extend/plugins/like-to-keep-reading/</a>
problem is its using opening and closing shortcodes,when I embed them to my site <a href="http://vijaykudal.info" rel="nofollow">http://vijay... | [
{
"answer_id": 89689,
"author": "Eric Holmes",
"author_id": 23454,
"author_profile": "https://wordpress.stackexchange.com/users/23454",
"pm_score": 2,
"selected": true,
"text": "<p>To put shortcode within a PHP template, use <a href=\"http://codex.wordpress.org/Function_Reference/do_shor... | 2013/03/06 | [
"https://wordpress.stackexchange.com/questions/89687",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22582/"
] | I am using plugin like to read <http://wordpress.org/extend/plugins/like-to-keep-reading/>
problem is its using opening and closing shortcodes,when I embed them to my site <http://vijaykudal.info> only opening short codes displayed,can you please help me?
PS:-tried with different themes as well | To put shortcode within a PHP template, use [do\_shortcode();](http://codex.wordpress.org/Function_Reference/do_shortcode)
```
<?php
echo do_shortcode( '[like_to_read]The text that is hidden from the user.[/like_to_read]' );
?>
```
Edit:
```
<?php
echo do_shortcode( '[like_to_read]' . get_the_content() . '[/li... |
89,702 | <p>I have one problem I use this function for truncate posts</p>
<pre><code>function truncate_post($amount,$quote_after=false) {
$truncate = get_the_content();
$truncate = apply_filters('the_content', $truncate);
$truncate = preg_replace('@<script[^>]*?>.*?</script>@si', '', $truncate);
$truncate = preg... | [
{
"answer_id": 89713,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/strip_shortcodes\" rel=\"nofollow\"><code>strip_s... | 2013/03/06 | [
"https://wordpress.stackexchange.com/questions/89702",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13668/"
] | I have one problem I use this function for truncate posts
```
function truncate_post($amount,$quote_after=false) {
$truncate = get_the_content();
$truncate = apply_filters('the_content', $truncate);
$truncate = preg_replace('@<script[^>]*?>.*?</script>@si', '', $truncate);
$truncate = preg_replace('@<style[^>]*?>.*?</... | Use [`strip_shortcodes`](http://codex.wordpress.org/Function_Reference/strip_shortcodes) as well. That should remove the shortcodes from the content.
A couple of notes: Your code seems to be doing some things that I don't understand. For example, you run the `the_content` filter on your content which adds markup, only... |
89,719 | <p>my Media -->Library content disappeared from the dashboard, but I still can see it inside my actual site folder.</p>
<p>Could anyone instruct me how to fix it?</p>
<p>Thank You</p>
| [
{
"answer_id": 90073,
"author": "krembo99",
"author_id": 13256,
"author_profile": "https://wordpress.stackexchange.com/users/13256",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n<p><strong>premise</strong> :</p>\n<p>I am not so sure as to the exact reason of your problem, but... | 2013/03/06 | [
"https://wordpress.stackexchange.com/questions/89719",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27531/"
] | my Media -->Library content disappeared from the dashboard, but I still can see it inside my actual site folder.
Could anyone instruct me how to fix it?
Thank You | >
> **premise** :
>
>
> I am not so sure as to the exact reason of your problem, but after the
> comments, and considering a normal "user" level of coding expertise, I
> post this answer describing not the ultimate solution, but the steps
> that I myself would have considered when facing a similar problem.
> There m... |
89,723 | <p>When using w3.org's validation tool Unicorn I get the following error/warning:</p>
<p>URI: <a href="http://energyshop.se/hem/feed/" rel="nofollow">http://energyshop.se/hem/feed/</a>
This feed does not validate.</p>
<p>After looking into my source its there crystal clear in the <code><head>:
<link rel="al... | [
{
"answer_id": 89732,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>If we look at the file </p>\n\n<pre><code>/wp-includes/default-filters.php\n</code></pre>\n\n<p>we can find the... | 2013/03/07 | [
"https://wordpress.stackexchange.com/questions/89723",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24909/"
] | When using w3.org's validation tool Unicorn I get the following error/warning:
URI: <http://energyshop.se/hem/feed/>
This feed does not validate.
After looking into my source its there crystal clear in the `<head>:
<link rel="alternate" type="application/rss+xml" title="energyshop.se » Hem kommentarsflöde" hre... | If we look at the file
```
/wp-includes/default-filters.php
```
we can find these two lines in there
```
add_action( 'wp_head', 'feed_links', 2 );
add_action( 'wp_head', 'feed_links_extra', 3 );
```
so if we want to remove these actions, we can ... |
89,727 | <p>Looking for a way to include custom fields in the output of WP_Query. I am managing a site where nearly every post type has a lot of custom fields defined and it would be much nicer not to have to run get_post_custom in almost every loop.</p>
| [
{
"answer_id": 89736,
"author": "David Chase",
"author_id": 28116,
"author_profile": "https://wordpress.stackexchange.com/users/28116",
"pm_score": 0,
"selected": false,
"text": "<p><code>WP_Query</code> let you query posts based on key or values from the custom fields if you would like ... | 2013/03/07 | [
"https://wordpress.stackexchange.com/questions/89727",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26561/"
] | Looking for a way to include custom fields in the output of WP\_Query. I am managing a site where nearly every post type has a lot of custom fields defined and it would be much nicer not to have to run get\_post\_custom in almost every loop. | You may want to hook somewhere in the gazillion hooks available in [**`wp-includes/query.php`**](http://core.trac.wordpress.org/browser/trunk/wp-includes/query.php).
I would suggest something like this:
```
function my_always_get_post_custom( $posts ) {
for ( $i = 0; $i < count($posts); $i++ ) {
$custom... |
89,781 | <p>I found an interesting concepts of adding an additional option to the "General Options" in Wordpress.</p>
<pre><code>/**
* Custom Theme Settings
* see http://digwp.com/2009/09/global-custom-fields-take-two/
*/
add_action('admin_menu', 'add_gcf_interface');
function add_gcf_interface() {
add_options_page('O... | [
{
"answer_id": 89783,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 1,
"selected": false,
"text": "<p>I would like to strongly recommend you to read these articles:</p>\n\n<ul>\n<li><a href=\"http://wp.tuts... | 2013/03/07 | [
"https://wordpress.stackexchange.com/questions/89781",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3529/"
] | I found an interesting concepts of adding an additional option to the "General Options" in Wordpress.
```
/**
* Custom Theme Settings
* see http://digwp.com/2009/09/global-custom-fields-take-two/
*/
add_action('admin_menu', 'add_gcf_interface');
function add_gcf_interface() {
add_options_page('Other', 'Other'... | You can create a custom filter using [filter functions](http://codex.wordpress.org/Plugin_API) of Plugin API.
I have changed you code as following to create and use custom filter.
```
function add_gcf_interface() {
add_options_page('Other', 'Other', '8', 'functions', 'otherGlobalOptions');
}
function otherGlobalOptio... |
89,782 | <p>The WordPress SEO plugin by Yoast allows users to add SEO titles and meta descriptions to taxonomy term archive pages. These are then used in the head of the document. </p>
<p>I´m trying to display the SEO title of taxonomy terms as an H1 in my taxonomy archive template.</p>
<p>To do this in a post, post type or ... | [
{
"answer_id": 89784,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 3,
"selected": false,
"text": "<p>On archive page in post loop add following line of code to make it work</p>\n\n<pre><code>echo get_post_me... | 2013/03/07 | [
"https://wordpress.stackexchange.com/questions/89782",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7584/"
] | The WordPress SEO plugin by Yoast allows users to add SEO titles and meta descriptions to taxonomy term archive pages. These are then used in the head of the document.
I´m trying to display the SEO title of taxonomy terms as an H1 in my taxonomy archive template.
To do this in a post, post type or page is easy:
``... | Get Archive SEO titles
----------------------
If you defined a Custom Post Type archive title you can get that by:
```
$titles = get_option( 'wpseo_titles' );
$title = $titles['title-ptarchive-POST_TYPE'];
echo apply_filters( 'the_title', $title );
```
Remember to replace `POST_TYPE` by your own Custom Post Type.... |
89,791 | <p>I need to include the path to my theme file within a javascript file. How would I go about this? I have already tried: </p>
<pre><code>var templateUrl = "<?php get_stylesheet_directory_uri(); ?>";
function LightboxOptions() {
this.fileLoadingImage = "'"+templateUrl+"/img/loading.gif'";
this.fileCloseImag... | [
{
"answer_id": 89793,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 3,
"selected": false,
"text": "<p><strong>These are the following two ways to add theme path in javascript file.</strong></p>\n\n<p><strong>... | 2013/03/07 | [
"https://wordpress.stackexchange.com/questions/89791",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18937/"
] | I need to include the path to my theme file within a javascript file. How would I go about this? I have already tried:
```
var templateUrl = "<?php get_stylesheet_directory_uri(); ?>";
function LightboxOptions() {
this.fileLoadingImage = "'"+templateUrl+"/img/loading.gif'";
this.fileCloseImage = "'"+templateUrl+... | What you're looking for is [wp\_localize\_script function](https://codex.wordpress.org/Function_Reference/wp_localize_script).
You use it like this when enqueing script
```
wp_register_script( 'my-script', 'myscript_url' );
wp_enqueue_script( 'my-script' );
$translation_array = array( 'templateUrl' => get_stylesheet_... |
89,812 | <p>nginx 1.2.7 + WP 3.5.1 + W3TC 0.9.2.8.</p>
<p>Rewrite rules generated by the plugin simply don't work, server returns 404 after including them in nginx server config. Or maybe I'm doing something wrong?</p>
<p>Here is my <strong>nginx.conf</strong>:</p>
<pre><code>user www-data;
worker_processes 2;
pid /var/run/n... | [
{
"answer_id": 89842,
"author": "Paramdeo Singh",
"author_id": 28516,
"author_profile": "https://wordpress.stackexchange.com/users/28516",
"pm_score": -1,
"selected": false,
"text": "<p>W3 Total Cache and Quick Cache and the like work very well with Apache. As Wordpress wasn't made out o... | 2013/03/07 | [
"https://wordpress.stackexchange.com/questions/89812",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28540/"
] | nginx 1.2.7 + WP 3.5.1 + W3TC 0.9.2.8.
Rewrite rules generated by the plugin simply don't work, server returns 404 after including them in nginx server config. Or maybe I'm doing something wrong?
Here is my **nginx.conf**:
```
user www-data;
worker_processes 2;
pid /var/run/nginx.pid;
events {
worker_connection... | **Solved.**
Instead of
```
if (-f "$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index.html$w3tc_enc") {
set $w3tc_rewrite 0;
}
```
should be
```
if (!-f "$document_root/wp-content/cache/page_enhanced/$http_host/$request_uri/_index.html$w3tc_enc") {
set $w3tc_rewrite 0;
}
```
in **W3... |
89,819 | <p>I'm a newbie at modifying wooCommerce.
I hope someone can help me with a problem i'm having while trying to make a minor change to the plugin to fit with a request from my client.</p>
<p>I'm trying to modify WooCommerce to display the category name for each product. <strong>I want the category name to be shown abo... | [
{
"answer_id": 90200,
"author": "Ewout",
"author_id": 26106,
"author_profile": "https://wordpress.stackexchange.com/users/26106",
"pm_score": 2,
"selected": false,
"text": "<p>you need the get_categories function, which takes the following arguments:</p>\n\n<p><code>get_categories( $sepa... | 2013/03/07 | [
"https://wordpress.stackexchange.com/questions/89819",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28546/"
] | I'm a newbie at modifying wooCommerce.
I hope someone can help me with a problem i'm having while trying to make a minor change to the plugin to fit with a request from my client.
I'm trying to modify WooCommerce to display the category name for each product. **I want the category name to be shown above the product i... | The product title is added to the `woocommerce_single_product_summary` hook at priority 5, so you'll want to add to the same hook with a lower (earlier) priority. You'd add this to your theme's functions.php file. I presume when you say "category" you mean the WooCommerce product category, so this should return the fir... |
89,831 | <p>I'm not sure whether this question belongs here but I don't know where else to ask it : do WordPress designers/developers usually create a dashboard theme thumbnail when they completed the WP theme for their client? If so, do they put their own logo on it or a screenshot of the home page?</p>
| [
{
"answer_id": 90200,
"author": "Ewout",
"author_id": 26106,
"author_profile": "https://wordpress.stackexchange.com/users/26106",
"pm_score": 2,
"selected": false,
"text": "<p>you need the get_categories function, which takes the following arguments:</p>\n\n<p><code>get_categories( $sepa... | 2013/03/07 | [
"https://wordpress.stackexchange.com/questions/89831",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11634/"
] | I'm not sure whether this question belongs here but I don't know where else to ask it : do WordPress designers/developers usually create a dashboard theme thumbnail when they completed the WP theme for their client? If so, do they put their own logo on it or a screenshot of the home page? | The product title is added to the `woocommerce_single_product_summary` hook at priority 5, so you'll want to add to the same hook with a lower (earlier) priority. You'd add this to your theme's functions.php file. I presume when you say "category" you mean the WooCommerce product category, so this should return the fir... |
89,833 | <p>I am looking to use the <a href="http://www.gravityhelp.com/documentation/page/Gform_column_input_content" rel="nofollow">gform_column_input_content</a> filter to make a repeatable file upload element. The filter modifies the HTML content of the list field column input tag.</p>
<p>The following code provided from t... | [
{
"answer_id": 89839,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 2,
"selected": true,
"text": "<p>The following provides you with a file upload:</p>\n\n<pre><code>add_filter(\"gform_column_input_content_21_9_... | 2013/03/07 | [
"https://wordpress.stackexchange.com/questions/89833",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19497/"
] | I am looking to use the [gform\_column\_input\_content](http://www.gravityhelp.com/documentation/page/Gform_column_input_content) filter to make a repeatable file upload element. The filter modifies the HTML content of the list field column input tag.
The following code provided from the docs shows how to replace the ... | The following provides you with a file upload:
```
add_filter("gform_column_input_content_21_9_3", "change_column3_content", 10, 6);
function change_column3_content($input, $input_info, $field, $text, $value, $form_id) {
$input_field_name = 'input_' . $field["id"] . '[]';
$tabindex = GFCommon::get_tabindex();
... |
89,856 | <p>I'm using the below function for wp_link_pages. <a href="http://themeforward.com/demo2/2012/10/10/this-post-has-a-longer-title-designers-find-this-useful-to-see/" rel="nofollow">It can be viewed in use here.</a></p>
<p>I would like to add a class to the previous link and a class to the next link so they can be sty... | [
{
"answer_id": 89864,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 0,
"selected": false,
"text": "<p>You can do that either by means of JavaScript/jQuery, or you could use CSS selectors.</p>\n\n<p>The trick is ... | 2013/03/07 | [
"https://wordpress.stackexchange.com/questions/89856",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5205/"
] | I'm using the below function for wp\_link\_pages. [It can be viewed in use here.](http://themeforward.com/demo2/2012/10/10/this-post-has-a-longer-title-designers-find-this-useful-to-see/)
I would like to add a class to the previous link and a class to the next link so they can be styled individually. I'm not a pro at ... | First, I would add a string formatting placeholder to 'link\_before', like so...
```
$args['link_before'] = '<span class="classlinks %s">';
```
Next, I would use [sprintf()](http://php.net/manual/en/function.sprintf.php) to insert an appropriate class for the appropriate link (let's assume the classes will be 'link-... |
89,874 | <p>In the dashboard, I'm using a textarea to get user input. I'd like them to be able to use shortcodes anywhere in that textarea.</p>
<p>Here's my current function:</p>
<pre><code>function slp_getwelcome() {
$slp_welcome = get_option('slp_welcome');
$slp_welcome_sc = do_shortcode( $slp_we... | [
{
"answer_id": 89955,
"author": "user28589",
"author_id": 28589,
"author_profile": "https://wordpress.stackexchange.com/users/28589",
"pm_score": 1,
"selected": false,
"text": "<p>Check the Apache processes. I had this same sort of issue a while back and essentially what was happening wa... | 2013/03/07 | [
"https://wordpress.stackexchange.com/questions/89874",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5295/"
] | In the dashboard, I'm using a textarea to get user input. I'd like them to be able to use shortcodes anywhere in that textarea.
Here's my current function:
```
function slp_getwelcome() {
$slp_welcome = get_option('slp_welcome');
$slp_welcome_sc = do_shortcode( $slp_welcome );
return ... | Check the Apache processes. I had this same sort of issue a while back and essentially what was happening was that the requests were being made faster than the server could handle it and at that point every slowed to a crawl. This was leaving hundreds of Apache processes running and waiting for the next thing that neve... |
89,880 | <p>Im using following code for getting most populer post with thumbnail.I have a custom post type taxonomy (Talks). Custom post types(video) have 6 category.</p>
<p>But my code not working. It just getting 1 post.But i have 10 post. How can i fix it?</p>
<pre><code> <?php
$args = array(
'post_type' => '... | [
{
"answer_id": 89888,
"author": "Brian",
"author_id": 17924,
"author_profile": "https://wordpress.stackexchange.com/users/17924",
"pm_score": 1,
"selected": false,
"text": "<p>If you can't use an existing plugin, then you could do something like this: <a href=\"http://wp-snippets.com/pos... | 2013/03/07 | [
"https://wordpress.stackexchange.com/questions/89880",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25951/"
] | Im using following code for getting most populer post with thumbnail.I have a custom post type taxonomy (Talks). Custom post types(video) have 6 category.
But my code not working. It just getting 1 post.But i have 10 post. How can i fix it?
```
<?php
$args = array(
'post_type' => 'video',
'showposts' => ... | Brain helped me..
I have installed already [WP-PostViews](http://wordpress.org/support/plugin/wp-postviews) Plugin
I just changed following line on my code and it worked.
Thanks for all answers and suggestion.
`'meta_key' => 'views'` |
89,886 | <p>I have a search field for the blog posts, but I need an other for a custom post type. How can I create this <em>custom search form</em> with a <strong><em>different</strong> search result layout</em>?</p>
| [
{
"answer_id": 89945,
"author": "Ronald",
"author_id": 27469,
"author_profile": "https://wordpress.stackexchange.com/users/27469",
"pm_score": 6,
"selected": false,
"text": "<p>Here is what I've tried and got a solution with 3 steps. Let's say your custom post type is "<strong>produ... | 2013/03/07 | [
"https://wordpress.stackexchange.com/questions/89886",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27891/"
] | I have a search field for the blog posts, but I need an other for a custom post type. How can I create this *custom search form* with a ***different*** search result layout? | Here is what I've tried and got a solution with 3 steps. Let's say your custom post type is "**products**"
1 . **Add Function Code** here you can specify the *archive-search.php*
```
function template_chooser($template)
{
global $wp_query;
$post_type = get_query_var('post_type');
if( $wp_query->is_... |
89,889 | <p>I am building a site for a friend, the site has launched, now he tells me he wants his site name to appear green everywhere it appears on the website. </p>
<p>Immediately, I thought of the plugin <a href="http://wordpress.org/extend/plugins/seo-automatic-links" rel="nofollow">SEO Smart Links</a>, which automaticall... | [
{
"answer_id": 89892,
"author": "hereswhatidid",
"author_id": 3032,
"author_profile": "https://wordpress.stackexchange.com/users/3032",
"pm_score": 3,
"selected": true,
"text": "<p>If it's purely for setting the style of the text you may want to use JavaScript/jQuery instead. Here's a q... | 2013/03/07 | [
"https://wordpress.stackexchange.com/questions/89889",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14558/"
] | I am building a site for a friend, the site has launched, now he tells me he wants his site name to appear green everywhere it appears on the website.
Immediately, I thought of the plugin [SEO Smart Links](http://wordpress.org/extend/plugins/seo-automatic-links), which automatically links a string of text. Is there a... | If it's purely for setting the style of the text you may want to use JavaScript/jQuery instead. Here's a quick sample that would replace all instances of "ipsum" with
```
<span class="red">ipsum</span>
```
And the full code:
```
// Find text in descendents of an element, in reverse document order
// pattern must be... |
89,919 | <p>This may sound like a stupid question, but...</p>
<p>What are the main parts of a Wordpress template, and which parts are mandatory and which parts are optional? </p>
<p>So far I am aware of:</p>
<ul>
<li>Posts (mandatory)</li>
<li>Pages (mandatory)</li>
<li>Page Templates (optional)</li>
<li>Tags (optional)</li>... | [
{
"answer_id": 89921,
"author": "Androliyah",
"author_id": 17636,
"author_profile": "https://wordpress.stackexchange.com/users/17636",
"pm_score": 3,
"selected": true,
"text": "<p>Indeed, it is as toscho has said. index.php and style.css are the bare minumum.</p>\n\n<p>Developers like to... | 2013/03/08 | [
"https://wordpress.stackexchange.com/questions/89919",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/304/"
] | This may sound like a stupid question, but...
What are the main parts of a Wordpress template, and which parts are mandatory and which parts are optional?
So far I am aware of:
* Posts (mandatory)
* Pages (mandatory)
* Page Templates (optional)
* Tags (optional)
* Categories (optional)
* Search / Search Results (ma... | Indeed, it is as toscho has said. index.php and style.css are the bare minumum.
Developers like to separate things, though, so instead of having one index.php file to rule all, you'll find parts like:
```
header.php
footer.php
sidebar.php
index.php
style.css
functions.php
```
and additional templates like ones you ... |
89,926 | <p>I am creating a plugin which will also have a few addons. I am adding settings tabs for the addons, but I want to make a conditional check in the main plugin to prevent those tabs from showing if the addon plugin is not active. </p>
<p>There is the function is_plugin_active() which can be used easily for this check... | [
{
"answer_id": 89928,
"author": "chrisguitarguy",
"author_id": 6035,
"author_profile": "https://wordpress.stackexchange.com/users/6035",
"pm_score": 4,
"selected": true,
"text": "<blockquote>\n <p>There is the function is_plugin_active() which can be used easily for this check, but what... | 2013/03/08 | [
"https://wordpress.stackexchange.com/questions/89926",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5844/"
] | I am creating a plugin which will also have a few addons. I am adding settings tabs for the addons, but I want to make a conditional check in the main plugin to prevent those tabs from showing if the addon plugin is not active.
There is the function is\_plugin\_active() which can be used easily for this check, but wh... | >
> There is the function is\_plugin\_active() which can be used easily for this check, but what if the user decides to change the folder name of the plugin?
>
>
>
Simply put, you're doing it wrong.
If you're making extensions for a plugin, then you should provide hooks in the "parent" plugin for those addons to ... |
89,946 | <p>How can I get the current url in a wordpress page? I have enabled clean urls, but I want the url without the clean urls. For example </p>
<pre><code>http://example.com/?page_id=1
</code></pre>
<p>instead of </p>
<pre><code>http://example.com/my-page
</code></pre>
| [
{
"answer_id": 89960,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 1,
"selected": false,
"text": "<p>Add the following custom function in functions.php file of your theme to get the <strong>page url without ... | 2013/03/08 | [
"https://wordpress.stackexchange.com/questions/89946",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27422/"
] | How can I get the current url in a wordpress page? I have enabled clean urls, but I want the url without the clean urls. For example
```
http://example.com/?page_id=1
```
instead of
```
http://example.com/my-page
``` | Add the following custom function in functions.php file of your theme to get the **page url without the clean urls**
```
function get_page_custom_link() {
global $post;
$link = '';
if ( 'page' == get_option( 'show_on_front' ) && $post->ID == get_option( 'page_on_front' ) )
$link = home_url('... |
89,947 | <p>I'd like to ONLY show the authors website link if it exists, but I can't work out the exact syntax for it.</p>
<p>I have this</p>
<pre><code> if ( get_the_author_meta('user_url') ) : // If a user has filled out their decscription show a bio on their entries
echo the_author_meta('user_url');
... | [
{
"answer_id": 89950,
"author": "Vinod Dalvi",
"author_id": 14347,
"author_profile": "https://wordpress.stackexchange.com/users/14347",
"pm_score": 2,
"selected": true,
"text": "<p>Try passing $user_ID global variable to function as following. it is working for me.</p>\n\n<pre><code><... | 2013/03/08 | [
"https://wordpress.stackexchange.com/questions/89947",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22450/"
] | I'd like to ONLY show the authors website link if it exists, but I can't work out the exact syntax for it.
I have this
```
if ( get_the_author_meta('user_url') ) : // If a user has filled out their decscription show a bio on their entries
echo the_author_meta('user_url');
endif;
```
But ... | Try passing $user\_ID global variable to function as following. it is working for me.
```
<?php
global $user_ID;
if ( get_the_author_meta('user_url',$user_ID) ) : // If a user has filled out their decscription show a bio on their entries
?>
<a class="meta-website" href="<?php the_author_meta('user_url',$user_I... |
89,959 | <p>I am trying to make a custom sidebar for my posts in certain categories. It will look something like this.</p>
<p><img src="https://i.stack.imgur.com/Jn9wS.png" alt="enter image description here"></p>
<p>My category structure looks like this:</p>
<ul>
<li>Parent 1
<ul>
<li>Child 1
<ul>
<li>Sub Child 1</li>
<li>... | [
{
"answer_id": 89961,
"author": "Mike Madern",
"author_id": 24806,
"author_profile": "https://wordpress.stackexchange.com/users/24806",
"pm_score": 3,
"selected": true,
"text": "<p>I guess you could take a big step using <a href=\"http://codex.wordpress.org/wp_list_categories\" rel=\"nof... | 2013/03/08 | [
"https://wordpress.stackexchange.com/questions/89959",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41170/"
] | I am trying to make a custom sidebar for my posts in certain categories. It will look something like this.

My category structure looks like this:
* Parent 1
+ Child 1
- Sub Child 1
- Sub Child 2
+ Child 1
- Sub Child 1
- Sub Child 2
* Par... | I guess you could take a big step using [`wp_list_categories()`](http://codex.wordpress.org/wp_list_categories) with a `walker` to add a additional Unordered List to every item.
**The code**:
```
$cat_id = get_query_var( 'cat' );
$subcats = get_categories( 'child_of=' . $cat_id ); // child categories
class Cat_Walke... |
89,972 | <p>I know that it's possible to switch the WP locale by using URL paramaters, <a href="https://wordpress.stackexchange.com/questions/59517/multilingual-theme-changing-locale-based-on-url">as described here</a>, but I'm trying to build a method that would entirely rely on a custom "Language" taxonomy.</p>
<p>What I cur... | [
{
"answer_id": 89977,
"author": "david.binda",
"author_id": 14022,
"author_profile": "https://wordpress.stackexchange.com/users/14022",
"pm_score": 2,
"selected": true,
"text": "<p>You might be interested in <a href=\"http://codex.wordpress.org/Function_Reference/url_to_postid\" rel=\"no... | 2013/03/08 | [
"https://wordpress.stackexchange.com/questions/89972",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22963/"
] | I know that it's possible to switch the WP locale by using URL paramaters, [as described here](https://wordpress.stackexchange.com/questions/59517/multilingual-theme-changing-locale-based-on-url), but I'm trying to build a method that would entirely rely on a custom "Language" taxonomy.
What I currently have is a simp... | You might be interested in [url\_to\_postid](http://codex.wordpress.org/Function_Reference/url_to_postid) function
Used as follows from your wpsx\_redefine\_locale function:
```
$url = $_SERVER['REQUEST_URI'];
$postid = url_to_postid( $url );
```
Note that this does not return the post id for custom post types but ... |
89,979 | <p>How i can link all different images size upload in wordpress?
I've definited different size image with the plugin <a href="http://wordpress.org/extend/plugins/simple-image-sizes/" rel="nofollow">simple image size</a>
so i'ld like show in single post, links to all new images
example here: <a href="http://topwalls.net... | [
{
"answer_id": 89985,
"author": "david.binda",
"author_id": 14022,
"author_profile": "https://wordpress.stackexchange.com/users/14022",
"pm_score": 1,
"selected": false,
"text": "<p>I guess you're lookin for <a href=\"https://codex.wordpress.org/Function_Reference/get_intermediate_image_... | 2013/03/08 | [
"https://wordpress.stackexchange.com/questions/89979",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28605/"
] | How i can link all different images size upload in wordpress?
I've definited different size image with the plugin [simple image size](http://wordpress.org/extend/plugins/simple-image-sizes/)
so i'ld like show in single post, links to all new images
example here: <http://topwalls.net/brink-6/>
hi this is my image.php
... | You can do this by adding this function to your `funcitons.php` file.
```
function my_get_image_size_links() {
/* If not viewing an image attachment page, return. */
if ( !wp_attachment_is_image( get_the_ID() ) )
return;
/* Set up an empty array for the links. */
$links = array();
/* Get the intermediate image ... |
89,981 | <p>I want to create a form that I can use a shortcode to insert into my site.</p>
<p>It would be really nice if I could create the HTML part in a seperate file and then insert it with a PHP shortcode (to seperate the logic of the page from the mechanics of making it into a shortcode).</p>
<p>How could I do this?</p>
<h... | [
{
"answer_id": 89983,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 2,
"selected": false,
"text": "<p>Add the following to your <strong>functions.php</strong>:</p>\n\n<pre><code>function my_form_shortcode() {\n ... | 2013/03/08 | [
"https://wordpress.stackexchange.com/questions/89981",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24655/"
] | I want to create a form that I can use a shortcode to insert into my site.
It would be really nice if I could create the HTML part in a seperate file and then insert it with a PHP shortcode (to seperate the logic of the page from the mechanics of making it into a shortcode).
How could I do this?
-- Update --
-------... | Something I forgot in my previous comment was that shortcodes *return* content, both the suggested `include` and my alternative [`get_template_part`](http://codex.wordpress.org/Function_Reference/get_template_part) will directly output the content (which is what you are seeing with the content appearing at the top of y... |
89,990 | <p>How can i retrieve the author id if i have its name.</p>
<p>I have fornt end form any user can enter the author name to filter the posts by author name so after that how can i get author id. Or there is any other way to write the query so that it return the posts which is posted by specific authors. Thanks</p>
| [
{
"answer_id": 89994,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/get_user_by\" rel=\"noreferrer\"><code>get_user_by</c... | 2013/03/08 | [
"https://wordpress.stackexchange.com/questions/89990",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27912/"
] | How can i retrieve the author id if i have its name.
I have fornt end form any user can enter the author name to filter the posts by author name so after that how can i get author id. Or there is any other way to write the query so that it return the posts which is posted by specific authors. Thanks | [`get_user_by`](http://codex.wordpress.org/Function_Reference/get_user_by) will get you the user data by 'id', 'slug', 'email', or 'login'.
'slug' is the user\_nicename.
```
$user = get_user_by('slug','nicename');
```
However, I am not sure what you mean by 'name'. There are other plausible 'name' fields, not all... |
89,996 | <p>I'm writing my first twenty twelve child theme and came across (what I think) is a strange quirk.</p>
<p>I modified front-page.php to have a slider using sliderjs, afterwards I decided I did not want to use this as a front page template, so I'd much prefer to call it something else for a different page.</p>
<p>To ... | [
{
"answer_id": 89999,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p><code>front-page.php</code> is a reserved template in <em>WordPress</em>, not just Twenty Twelve. The templat... | 2013/03/08 | [
"https://wordpress.stackexchange.com/questions/89996",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28610/"
] | I'm writing my first twenty twelve child theme and came across (what I think) is a strange quirk.
I modified front-page.php to have a slider using sliderjs, afterwards I decided I did not want to use this as a front page template, so I'd much prefer to call it something else for a different page.
To my surprise, the ... | I had the exact same problem and finally figured it out. You have to go into `functions.php` line 390 -
```
if ( is_page_template( 'page-templates/front-page.php' ) ) {
```
copy and paste this section of code and rename it to the file name you have chosen for your template.
Then you have to alter all the CSS that ... |
90,001 | <p>I have been trying to figure out how to escape quotes (single and double) from shortcode attributes.</p>
<p>Basically the content is written by the user and therefore can potentially include " and ' quotes. Problem being, with " quotes it is stopping the shortcode attribute from functioning eg:</p>
<p>attibute="so... | [
{
"answer_id": 90006,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 3,
"selected": true,
"text": "<p>It seems you are working on the wrong end.</p>\n\n<p>Try sanitizing the user input, for instance by means of <... | 2013/03/08 | [
"https://wordpress.stackexchange.com/questions/90001",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28602/"
] | I have been trying to figure out how to escape quotes (single and double) from shortcode attributes.
Basically the content is written by the user and therefore can potentially include " and ' quotes. Problem being, with " quotes it is stopping the shortcode attribute from functioning eg:
attibute="some text here with... | It seems you are working on the wrong end.
Try sanitizing the user input, for instance by means of [`sanitize_text_field`](http://codex.wordpress.org/Function_Reference/sanitize_text_field), not the shortcode output. |
90,056 | <p>I have a front-end form where people can submit their website URL.</p>
<p>I'm actually verifying URLs in Wordpress with a PHP function and I would like to know if there is a built-in function that allows me to do this ?</p>
<p>This is the function that I am actually using :</p>
<pre><code>function validateURL($UR... | [
{
"answer_id": 90057,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>There isn't a function that validates a URL, just one that sanitizes a string for use within a URL (<a href=\"http:... | 2013/03/09 | [
"https://wordpress.stackexchange.com/questions/90056",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25458/"
] | I have a front-end form where people can submit their website URL.
I'm actually verifying URLs in Wordpress with a PHP function and I would like to know if there is a built-in function that allows me to do this ?
This is the function that I am actually using :
```
function validateURL($URL) {
$v = "/^(http|https... | Use `esc_url( $url )` for URLs that should be displayed and `esc_url_raw( $url )` if the URL should be sent to the database.
* The first will replace bare ampersands `&` with `&`.
* The second is a wrapper for the first; it will just suppress the escaping of ampersands.
* Both functions will check the protocol. S... |
90,065 | <p>I frequently post pages with code examples. However, Wordpress strips out whitespace, thus ruining the indentation and formatting of my code. So this:</p>
<pre><code><pre>
selector {
property: value;
property: value;
}
</pre>
</code></pre>
<p>becomes this:</p>
<pre>selector {prop... | [
{
"answer_id": 90981,
"author": "revo",
"author_id": 26909,
"author_profile": "https://wordpress.stackexchange.com/users/26909",
"pm_score": 1,
"selected": false,
"text": "<p>Don't use the visual editor. Copy the code into your 'HTML' view and it will preserve indentation. Copy it into '... | 2013/03/09 | [
"https://wordpress.stackexchange.com/questions/90065",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26368/"
] | I frequently post pages with code examples. However, Wordpress strips out whitespace, thus ruining the indentation and formatting of my code. So this:
```
<pre>
selector {
property: value;
property: value;
}
</pre>
```
becomes this:
```
selector {property: value;property: value;}
```
I found ... | You are not wrapping the code inside `<code>` tags.
```
<pre>
<code>
selector {
property: value;
property: value;
}
</code>
</pre>
```
Furthermore, most syntax highlighting plugins also use this format (both `<pre>` and `<code>`) to render code.
Here you have more about this.
<https... |
90,091 | <p>I'm using <code>Post templates</code> plugin. But its very outdated.</p>
<p>I'm getting <code>Warning: Illegal offset type</code> at this line </p>
<pre><code>$templates = $themes[$theme]['Template Files'];
</code></pre>
<p>Here is my full function code.</p>
<pre><code>function get_post_templates() {
$theme... | [
{
"answer_id": 90094,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 2,
"selected": true,
"text": "<p>The Line</p>\n\n<pre><code>$theme = wp_get_theme();\n</code></pre>\n\n<p>returns a <code>WP_Theme</code> Object,... | 2013/03/09 | [
"https://wordpress.stackexchange.com/questions/90091",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5074/"
] | I'm using `Post templates` plugin. But its very outdated.
I'm getting `Warning: Illegal offset type` at this line
```
$templates = $themes[$theme]['Template Files'];
```
Here is my full function code.
```
function get_post_templates() {
$themes = wp_get_themes();
$theme = wp_get_theme();
$templates = ... | The Line
```
$theme = wp_get_theme();
```
returns a `WP_Theme` Object, and you cannot use an Object in an `Array` like this.
Use
```
$templates = $themes[$theme->template]['Template Files'];
```
To get the `Array` of your template Files. In Order to get this function running again, you also have to change `Singl... |
90,114 | <p>I would like to enhance the Media Editor, after WordPress 3.5, on the gallery view.<br>
I want to add a new select field on the right side and send the selected values to the gallery shortcode.</p>
<p><img src="https://i.stack.imgur.com/brx7x.png" alt="enter image description here"></p>
<p>I think, the function <c... | [
{
"answer_id": 90443,
"author": "onetrickpony",
"author_id": 1986,
"author_profile": "https://wordpress.stackexchange.com/users/1986",
"pm_score": 4,
"selected": false,
"text": "<p>If you really want to use Backbone templates, then your hook is correct.</p>\n\n<p>I would use jQuery to in... | 2013/03/09 | [
"https://wordpress.stackexchange.com/questions/90114",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/170/"
] | I would like to enhance the Media Editor, after WordPress 3.5, on the gallery view.
I want to add a new select field on the right side and send the selected values to the gallery shortcode.

I think, the function `wp.media.gallery` in `wp-includes... | A small source, perhaps for a plugin to create the solution. At first the php part, there include the javascript for the button inside the Media Manager. Is more usable answer, but the answer of @One Trick Pony was create and the right direction and JS solution.
See the result on the image:
![enter image description h... |
90,135 | <p>I'm customizing a wordpress theme called <a href="http://accordium.parkerandkent.com/accordium/" rel="nofollow">Accordium</a>, and I have decided to add infinite scroll to it using a wordpress plugin called <a href="http://www.problogdesign.com/wordpress/load-next-wordpress-posts-with-ajax/" rel="nofollow">pbd-ajax-... | [
{
"answer_id": 90137,
"author": "Ralf912",
"author_id": 16589,
"author_profile": "https://wordpress.stackexchange.com/users/16589",
"pm_score": 1,
"selected": false,
"text": "<p>If I click on the large button on the bottom of your page (the one in your first screenshot), then your page i... | 2013/03/09 | [
"https://wordpress.stackexchange.com/questions/90135",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28470/"
] | I'm customizing a wordpress theme called [Accordium](http://accordium.parkerandkent.com/accordium/), and I have decided to add infinite scroll to it using a wordpress plugin called [pbd-ajax-load-posts](http://www.problogdesign.com/wordpress/load-next-wordpress-posts-with-ajax/). In the theme, when you click on a post ... | If I click on the large button on the bottom of your page (the one in your first screenshot), then your page is called with the parameter `?paged=2`. If I call your page directly with this parameter, I got the following JS error `TypeError: $ is not a function`
From the source of your page:
```
<!-- Clickable Nav Scr... |
90,140 | <p>I've created a menu page using the following function:</p>
<pre><code>add_menu_page(
'Nonpareil options',
'Nonpareil options',
'administrator',
'nonpareil_theme_options',
'nonpareil_theme_display'
);
</code></pre>
<p>Now I want to load a js file only on this page. I'm trying to do so properly by enque... | [
{
"answer_id": 90144,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>You could try replacing </p>\n\n<pre><code>if( 'nonpareil_theme_options' != $hook )\n</code></pre>\n\n<p>with <... | 2013/03/09 | [
"https://wordpress.stackexchange.com/questions/90140",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10036/"
] | I've created a menu page using the following function:
```
add_menu_page(
'Nonpareil options',
'Nonpareil options',
'administrator',
'nonpareil_theme_options',
'nonpareil_theme_display'
);
```
Now I want to load a js file only on this page. I'm trying to do so properly by enqueueing it only on my new pa... | You could try replacing
```
if( 'nonpareil_theme_options' != $hook )
```
with
```
if( 'toplevel_page_nonpareil_theme_options' != $hook )
```
if you have the custom menu added like this:
```
add_action('admin_menu', 'register_custom_menu_page');
function register_custom_menu_page() {
add_menu_page('Nonparei... |
90,147 | <p>How can I take my table I created like this:</p>
<pre><code>global $wpdb; //Get all the wordpress database stuff
$table_prefix = $wpdb->base_prefix; //Get the global prefix for all sites (on a multisite installation)
$table_name = $table_prefix.'wpaa';//Add wpaa behind the prefix
$sql = "CREATE TABLE IF NO... | [
{
"answer_id": 90151,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p><code>$wpdb->get_results();</code> has a second parameter for the return format:</p>\n\n<pre><code>/**\n * Retrieve ... | 2013/03/09 | [
"https://wordpress.stackexchange.com/questions/90147",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28674/"
] | How can I take my table I created like this:
```
global $wpdb; //Get all the wordpress database stuff
$table_prefix = $wpdb->base_prefix; //Get the global prefix for all sites (on a multisite installation)
$table_name = $table_prefix.'wpaa';//Add wpaa behind the prefix
$sql = "CREATE TABLE IF NOT EXISTS `".$tabl... | `$wpdb->get_results();` has a second parameter for the return format:
```
/**
* Retrieve an entire SQL result set from the database (i.e., many rows)
*
* Executes a SQL query and returns the entire SQL result.
*
* @since 0.71
*
* @param string $query SQL query.
* @param string $output Optional.
* Any of ARRA... |
90,150 | <p>Ok so here is the <a href="http://www.backslash.gr/demos/contenthover-jquery-plugin/" rel="nofollow">plugin in question </a> I'm trying to integrate it on the homepage of my <a href="http://www.docs.purethemes.net/incredible/" rel="nofollow">wordpress theme (incredible bought from themeforest)</a></p>
<p>After read... | [
{
"answer_id": 90579,
"author": "Tom",
"author_id": 28824,
"author_profile": "https://wordpress.stackexchange.com/users/28824",
"pm_score": 0,
"selected": false,
"text": "<p>try adding in the following format. Could also add all your javascript to one plugins file to cut down on requests... | 2013/03/09 | [
"https://wordpress.stackexchange.com/questions/90150",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | Ok so here is the [plugin in question](http://www.backslash.gr/demos/contenthover-jquery-plugin/) I'm trying to integrate it on the homepage of my [wordpress theme (incredible bought from themeforest)](http://www.docs.purethemes.net/incredible/)
After reading up on wordpress enqueue script and all that stuff i want t... | You can load the scripts like this:
```
function wpa_90150_scripts() {
wp_enqueue_script(
'contenthover',
get_template_directory_uri() . '/js/jquery.contenthover.js',
array('jquery'),
'',
true
);
wp_enqueue_script(
'custom',
get_template_directo... |
90,157 | <p>I'm trying to make Cloudflare's Rocket Loader work on my WP site. Everything works fine except for the WP Visual Editor. I followed the advice here but it doesn't work:</p>
<p><a href="https://wordpress.stackexchange.com/questions/50457/how-do-i-add-custom-attributes-to-javascript-tags-in-wordpress/90156#90156">How... | [
{
"answer_id": 93860,
"author": "nanastopoulos",
"author_id": 30687,
"author_profile": "https://wordpress.stackexchange.com/users/30687",
"pm_score": 2,
"selected": false,
"text": "<p>Notice in the example that the tag does not have the <code>type='text/javascript'</code> attribute. For... | 2013/03/10 | [
"https://wordpress.stackexchange.com/questions/90157",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28679/"
] | I'm trying to make Cloudflare's Rocket Loader work on my WP site. Everything works fine except for the WP Visual Editor. I followed the advice here but it doesn't work:
[How do I add custom attributes to javascript tags in Wordpress?](https://wordpress.stackexchange.com/questions/50457/how-do-i-add-custom-attributes-t... | Notice in the example that the tag does not have the `type='text/javascript'` attribute. For some reason Rocket Loader requires `data-cfasync='false'` to be used without the `type='text/javascript'`... a bug?
Your code does add the `data-cfasync='false'` attribute, but does not override the WordPress behaviour of addi... |
90,160 | <p>I don't quite get why this isn't working. I'm trying to use the following to only show posts from the current year on the front page:</p>
<pre><code><?php query_posts( "&year=$current_year&order=DESC"); ?>
</code></pre>
<p>Yet it still shows posts from 2012 (they weren't actually made in 2012, but I ... | [
{
"answer_id": 90162,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p><strong>Don't use <code>query_posts</code> to modify your queries.</strong> It's a waste of resources and it produc... | 2013/03/10 | [
"https://wordpress.stackexchange.com/questions/90160",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18441/"
] | I don't quite get why this isn't working. I'm trying to use the following to only show posts from the current year on the front page:
```
<?php query_posts( "&year=$current_year&order=DESC"); ?>
```
Yet it still shows posts from 2012 (they weren't actually made in 2012, but I set the publish date to one of the posts... | You just need get current date and add it on data\_query in wp\_query, Look this:
```
<?php
$getdate = getdate();
$args = array(
'date_query' => array(
array(
'year' => $getdate["year"]
),
),
);
$query = new WP_Query( $args );
?>
```
and then use loop:
```
<?php
if ( $query... |
90,174 | <p>I'm using TinyMCE Advanced and SyntaxHighliter plugins on my WordPress install. </p>
<p>Why does the editor change my inserted code, from:</p>
<pre><code>[php]
<?php
/**
echo('code');
/**/
[/php]
</code></pre>
<p>to:</p>
<pre><code>[php]
<!--?php <br ?-->/**
echo('code');
/**/
[/php]
</code></pre>
| [
{
"answer_id": 90986,
"author": "revo",
"author_id": 26909,
"author_profile": "https://wordpress.stackexchange.com/users/26909",
"pm_score": 2,
"selected": true,
"text": "<p>I suggest you to use <code>htmlspecialchars()</code> before sending content and<code>htmlspecialchars_decode()</co... | 2013/03/10 | [
"https://wordpress.stackexchange.com/questions/90174",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5844/"
] | I'm using TinyMCE Advanced and SyntaxHighliter plugins on my WordPress install.
Why does the editor change my inserted code, from:
```
[php]
<?php
/**
echo('code');
/**/
[/php]
```
to:
```
[php]
<!--?php <br ?-->/**
echo('code');
/**/
[/php]
``` | I suggest you to use `htmlspecialchars()` before sending content and`htmlspecialchars_decode()` before showing content on page, here is functions that you need to copy/paste to your functions.php :
```
function wp_po9568($content)
{
return htmlspecialchars($content);
}
add_filter('content_save_pre','wp_po9568');
... |
90,188 | <p>How could I add a description to <code>$wp_customize->add_control</code>? I've found I really need to include a short description on some of the controls but it doesn't look like it's possible. </p>
<p>I noticed you can add a description to <code>$wp_customize->add_section</code> but that's only a tooltip.</p... | [
{
"answer_id": 90211,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 4,
"selected": true,
"text": "<p>Here is one way to do it by extending the control you want to use.</p>\n\n<p>Below is an example where we exten... | 2013/03/10 | [
"https://wordpress.stackexchange.com/questions/90188",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4999/"
] | How could I add a description to `$wp_customize->add_control`? I've found I really need to include a short description on some of the controls but it doesn't look like it's possible.
I noticed you can add a description to `$wp_customize->add_section` but that's only a tooltip.
This is ideally what I'd like to do, bu... | Here is one way to do it by extending the control you want to use.
Below is an example where we extend the text control and add an extra description like the one seen here on the screenshot:

```
function mytheme_customizer( $wp_customize ) {
cl... |
90,215 | <p>i'm working on the new site with custom menu and extended Walker_Nav_Menu class to add custom content to the wp nav menu.</p>
<p>i have registered a custom select box (key: my_custom_menu) in menu from wordpress admin, have a look at the following image:</p>
<p><img src="https://i.stack.imgur.com/ssMxi.jpg" alt="h... | [
{
"answer_id": 90294,
"author": "Lê Phan Đức Trọng",
"author_id": 28722,
"author_profile": "https://wordpress.stackexchange.com/users/28722",
"pm_score": 1,
"selected": false,
"text": "<p>Filter 'wp_nav_menu_objects' would help:</p>\n\n<pre><code>add_filter( 'wp_nav_menu_objects', 'remov... | 2013/03/10 | [
"https://wordpress.stackexchange.com/questions/90215",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28693/"
] | i'm working on the new site with custom menu and extended Walker\_Nav\_Menu class to add custom content to the wp nav menu.
i have registered a custom select box (key: my\_custom\_menu) in menu from wordpress admin, have a look at the following image:
;
function remove_sub_items( $items,$args ) {
$new_items = array();
for ($i=1;$i<count($items)+1;$i++){
//is lvl0
if(empty($items[$i]->menu_item_parent)){
$new_items= array_... |
90,220 | <h2>What I am trying to do?</h2>
<p>My blog uses a custom taxonomy called <code>edition</code> with terms like <code>us-canada</code> (6), <code>eu</code> (7) and <code>india</code> (8) -- term slug (ID).</p>
<p>I want to make sure that posts <strong>not assigned to any specific 'edition'</strong> be shown under all ... | [
{
"answer_id": 90573,
"author": "vancoder",
"author_id": 26778,
"author_profile": "https://wordpress.stackexchange.com/users/26778",
"pm_score": 5,
"selected": true,
"text": "<p>I'll take another shot.</p>\n\n<p>The following should modify the main query, such that it will include in its... | 2013/03/10 | [
"https://wordpress.stackexchange.com/questions/90220",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10691/"
] | What I am trying to do?
-----------------------
My blog uses a custom taxonomy called `edition` with terms like `us-canada` (6), `eu` (7) and `india` (8) -- term slug (ID).
I want to make sure that posts **not assigned to any specific 'edition'** be shown under all the terms (i.e. if a post is not assigned to usa, eu... | I'll take another shot.
The following should modify the main query, such that it will include in its loop any posts that belong to *no term of the Edition custom taxonomy*.
```
add_filter('pre_get_posts','better_editions_archive');
function better_editions_archive( $query ) {
if ( $query->is_tax( 'edition' ) &&... |
90,225 | <p>I'd like to include a functionality in a theme that will overwrite styles from previously included CSS files. For this purpose, I need to be able to display a <code><style></code> in the header after ALL stylesheets have been displayed.</p>
<p>Is there a hook to do this?</p>
| [
{
"answer_id": 90226,
"author": "Dzhuneyt",
"author_id": 18207,
"author_profile": "https://wordpress.stackexchange.com/users/18207",
"pm_score": 0,
"selected": false,
"text": "<p>Although it is generally not recommended, we can hook to the <code>[wp_print_styles][1]</code> action, which ... | 2013/03/10 | [
"https://wordpress.stackexchange.com/questions/90225",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18207/"
] | I'd like to include a functionality in a theme that will overwrite styles from previously included CSS files. For this purpose, I need to be able to display a `<style>` in the header after ALL stylesheets have been displayed.
Is there a hook to do this? | Hook to `wp_enqueue_scripts` with a high priority number. For example:
```
function load_my_style_wpse_90225() {
wp_register_style( 'mystyle', get_template_directory_uri() .'/path/to/stylesheet.css');
wp_enqueue_style( 'mystyle' );
}
add_action('wp_enqueue_scripts','load_my_style_wpse_90225',1000);
```
That shou... |
90,230 | <p>I'm using category intersection pages for users to be able to filter posts by categories.</p>
<p>E.g. <a href="http://freemapsalgarve.com/category/destinations/alvor+bars-pubs/" rel="nofollow">http://freemapsalgarve.com/category/destinations/alvor+bars-pubs/</a></p>
<p>Here the user is filtering on the "alvor" AND... | [
{
"answer_id": 90226,
"author": "Dzhuneyt",
"author_id": 18207,
"author_profile": "https://wordpress.stackexchange.com/users/18207",
"pm_score": 0,
"selected": false,
"text": "<p>Although it is generally not recommended, we can hook to the <code>[wp_print_styles][1]</code> action, which ... | 2013/03/10 | [
"https://wordpress.stackexchange.com/questions/90230",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28699/"
] | I'm using category intersection pages for users to be able to filter posts by categories.
E.g. <http://freemapsalgarve.com/category/destinations/alvor+bars-pubs/>
Here the user is filtering on the "alvor" AND "bars-pubs" child categories of "destinations".
I want to be able to get the id's of the categories that are... | Hook to `wp_enqueue_scripts` with a high priority number. For example:
```
function load_my_style_wpse_90225() {
wp_register_style( 'mystyle', get_template_directory_uri() .'/path/to/stylesheet.css');
wp_enqueue_style( 'mystyle' );
}
add_action('wp_enqueue_scripts','load_my_style_wpse_90225',1000);
```
That shou... |
90,231 | <p>I am new to Wordpress but forced to create a website as a Wordpress template for my current employee (I am a front end developer, mostly build new systems/apps etc from scratch). Creating the template is no issue, but how do I go about making everything fully editable? For example the footer: it contains contact inf... | [
{
"answer_id": 90226,
"author": "Dzhuneyt",
"author_id": 18207,
"author_profile": "https://wordpress.stackexchange.com/users/18207",
"pm_score": 0,
"selected": false,
"text": "<p>Although it is generally not recommended, we can hook to the <code>[wp_print_styles][1]</code> action, which ... | 2013/03/10 | [
"https://wordpress.stackexchange.com/questions/90231",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28700/"
] | I am new to Wordpress but forced to create a website as a Wordpress template for my current employee (I am a front end developer, mostly build new systems/apps etc from scratch). Creating the template is no issue, but how do I go about making everything fully editable? For example the footer: it contains contact inform... | Hook to `wp_enqueue_scripts` with a high priority number. For example:
```
function load_my_style_wpse_90225() {
wp_register_style( 'mystyle', get_template_directory_uri() .'/path/to/stylesheet.css');
wp_enqueue_style( 'mystyle' );
}
add_action('wp_enqueue_scripts','load_my_style_wpse_90225',1000);
```
That shou... |
90,235 | <p>I programmed a theme post (edit: probably that's the <code>single.php</code> template) which uses the function <code>get_userdata( $_GET['p'] )</code>. But the main admin reformatted urls to this: <code>~/author/gamelaster</code> (default is <code>?author=1</code>) and now this is not working correctly.</p>
<block... | [
{
"answer_id": 90248,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": true,
"text": "<p>If you are on an \"Author\" page, and since you mentioned <code>author.php</code> it seems that you are, <a hr... | 2013/03/10 | [
"https://wordpress.stackexchange.com/questions/90235",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28663/"
] | I programmed a theme post (edit: probably that's the `single.php` template) which uses the function `get_userdata( $_GET['p'] )`. But the main admin reformatted urls to this: `~/author/gamelaster` (default is `?author=1`) and now this is not working correctly.
>
> How do I get the id of Author in this URL format?
> ... | If you are on an "Author" page, and since you mentioned `author.php` it seems that you are, [`get_queried_object()`](http://codex.wordpress.org/Function_Reference/get_queried_object) will give you the author data, which it seems is what you want.
Try:
```
var_dump(get_queried_object());
```
I believe that is all t... |
90,253 | <p>I have a number of custom templates which are assigned to different pages in my admin.</p>
<p>Is it possible to hide/lock the templates dropdown for certain pages? For instance, I have an <code>Events Calendar</code> template which will only ever be assigned to the Events Calendar page and so there is no need for t... | [
{
"answer_id": 90248,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": true,
"text": "<p>If you are on an \"Author\" page, and since you mentioned <code>author.php</code> it seems that you are, <a hr... | 2013/03/10 | [
"https://wordpress.stackexchange.com/questions/90253",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26762/"
] | I have a number of custom templates which are assigned to different pages in my admin.
Is it possible to hide/lock the templates dropdown for certain pages? For instance, I have an `Events Calendar` template which will only ever be assigned to the Events Calendar page and so there is no need for the client to see this... | If you are on an "Author" page, and since you mentioned `author.php` it seems that you are, [`get_queried_object()`](http://codex.wordpress.org/Function_Reference/get_queried_object) will give you the author data, which it seems is what you want.
Try:
```
var_dump(get_queried_object());
```
I believe that is all t... |
90,265 | <p>I'd like to show my users some features I offer if they register in a special nav bar. I've created this for a logged in version and a logged out version:</p>
<pre class="lang-php prettyprint-override"><code>if ( is_user_logged_in() ) {
$menu = wp_nav_menu( array(
'theme_location' => 'logged-in-menu'... | [
{
"answer_id": 90268,
"author": "MaxxDinh",
"author_id": 28693,
"author_profile": "https://wordpress.stackexchange.com/users/28693",
"pm_score": 0,
"selected": false,
"text": "<p>Because the menu item is not button so you can't use .button(disable); function, combine this code with your ... | 2013/03/11 | [
"https://wordpress.stackexchange.com/questions/90265",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18726/"
] | I'd like to show my users some features I offer if they register in a special nav bar. I've created this for a logged in version and a logged out version:
```php
if ( is_user_logged_in() ) {
$menu = wp_nav_menu( array(
'theme_location' => 'logged-in-menu',
'container' => '0',
'fallback... | When you look [at the possible arguments](http://codex.wordpress.org/Function_Reference/wp_nav_menu), then you'll see that there's as well the option to add a custom nav menu `walker` class.
```
$defaults = array(
'theme_location' => '',
'menu' => '',
'container' => 'div',
'container_... |
90,287 | <p>I am using an <code>onclick</code> function to redirect the user if they are not login.</p>
<p>I am calling a php function in achor tag like this</p>
<pre><code><a href="#" class="fright hrtacnhor" onclick="<?php checkstatus(); ?>">save to my favorite</a>
</code></pre>
<p>and the function I am u... | [
{
"answer_id": 90292,
"author": "Mike Madern",
"author_id": 24806,
"author_profile": "https://wordpress.stackexchange.com/users/24806",
"pm_score": 0,
"selected": false,
"text": "<p>You can't use PHP this way. </p>\n\n<p>PHP is static and will is parsed when the output is generated. Whe... | 2013/03/11 | [
"https://wordpress.stackexchange.com/questions/90287",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27912/"
] | I am using an `onclick` function to redirect the user if they are not login.
I am calling a php function in achor tag like this
```
<a href="#" class="fright hrtacnhor" onclick="<?php checkstatus(); ?>">save to my favorite</a>
```
and the function I am using is
```
<?php
function checkstatus(){
wp_redirect( g... | You could do the redirect by means of JavaScript:
```
<a href="#" class="fright hrtacnhor" onclick="window.location='<?php echo get_permalink( 8 ) ?>'">save to my favorite</a>
```
But why yould you want to do it that way and not just use the link directly? |
90,300 | <p>I'm building a hotel search engine and I've first created a custom content type "hotel" with Types & Views Toolset. I'm using "Search everything" plugin to query custom fields and custom taxonomy from this custom content and I've excluded the other content types from functions.php.</p>
<p>For now, I have these ... | [
{
"answer_id": 94921,
"author": "user1606423",
"author_id": 19511,
"author_profile": "https://wordpress.stackexchange.com/users/19511",
"pm_score": 0,
"selected": false,
"text": "<p>If you like to query directly in $wpdb you could do it like this in search.php:</p>\n\n<pre><code>global $... | 2013/03/11 | [
"https://wordpress.stackexchange.com/questions/90300",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28727/"
] | I'm building a hotel search engine and I've first created a custom content type "hotel" with Types & Views Toolset. I'm using "Search everything" plugin to query custom fields and custom taxonomy from this custom content and I've excluded the other content types from functions.php.
For now, I have these custom fields ... | If I understand you correctly, you need to have post metas in your query. This is where the `meta_query` parameter of the [WP\_Query](http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters) class comes to help.
The `meta_query` is an array of arrays.
Example from the codex:
```
$args = array(
... |