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 |
|---|---|---|---|---|---|---|
51,578 | <p>how to get values from a form(form is in admin panel page) and put that values in separate variables</p>
<pre><code><?php
/*
Plugin Name: calc plugin
*/
add_action('admin_menu', 'my_plugin_menu');
function my_plugin_menu() {
add_options_page('My Plugin Options', 'My Plugin', 8,... | [
{
"answer_id": 51579,
"author": "Rutwick Gangurde",
"author_id": 4740,
"author_profile": "https://wordpress.stackexchange.com/users/4740",
"pm_score": 0,
"selected": false,
"text": "<p>Use the <code>init</code> action to handle the posted form. See the <a href=\"http://codex.wordpress.or... | 2012/05/09 | [
"https://wordpress.stackexchange.com/questions/51578",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15941/"
] | how to get values from a form(form is in admin panel page) and put that values in separate variables
```
<?php
/*
Plugin Name: calc plugin
*/
add_action('admin_menu', 'my_plugin_menu');
function my_plugin_menu() {
add_options_page('My Plugin Options', 'My Plugin', 8, 'your-unique-ide... | If you want to add an settings page, (or add options to and existing settings page) please use the [**settings api**](http://codex.wordpress.org/Settings_API):
* [`register_setting`](http://codex.wordpress.org/Function_Reference/register_setting)
* [`add_settings_section`](http://codex.wordpress.org/Function_Reference... |
51,581 | <p>I'm updating my self-built theme to HTML5, and easily made a number of changes already.</p>
<p>My theme's sole stylesheet is added to the page head via <code>wp_enqueue_style</code> in the <code>functions.php</code> file, as follows:</p>
<pre><code>function gridded_enqueue_styles() {
wp_enqueue_style('style', ... | [
{
"answer_id": 51582,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 3,
"selected": true,
"text": "<p>For modify this output you can use that filter:</p>\n\n<pre><code>function wpse51581_hide_type($src) {\n return ... | 2012/05/09 | [
"https://wordpress.stackexchange.com/questions/51581",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/99/"
] | I'm updating my self-built theme to HTML5, and easily made a number of changes already.
My theme's sole stylesheet is added to the page head via `wp_enqueue_style` in the `functions.php` file, as follows:
```
function gridded_enqueue_styles() {
wp_enqueue_style('style', get_template_directory_uri() . '/style.css'... | For modify this output you can use that filter:
```
function wpse51581_hide_type($src) {
return str_replace("type='text/css'", '', $src);
}
add_filter('style_loader_tag', 'wpse51581_hide_type');
```
You can see this hook into `wp-includes/class.wp-styles.php` |
51,613 | <p>I use the <a href="https://wordpress.stackexchange.com/a/43562/10691"><strong><code>post_gallery</code> filter</strong></a> in functions.php to replace the core gallery code, with the gallery code I've modified to suit my needs, like this:</p>
<pre><code>function aahan_post_gallery($output, $attr) {
global $pos... | [
{
"answer_id": 51620,
"author": "its_me",
"author_id": 10691,
"author_profile": "https://wordpress.stackexchange.com/users/10691",
"pm_score": 1,
"selected": false,
"text": "<p>Replace this line in your filtered gallery code:</p>\n\n<pre><code>$link = isset($attr['link']) && 'fil... | 2012/05/09 | [
"https://wordpress.stackexchange.com/questions/51613",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10691/"
] | I use the [**`post_gallery` filter**](https://wordpress.stackexchange.com/a/43562/10691) in functions.php to replace the core gallery code, with the gallery code I've modified to suit my needs, like this:
```
function aahan_post_gallery($output, $attr) {
global $post;
static $instance = 0;
$instance++;
... | Instead of using 2 separate functions to grab the attachment you can use the same function, and then add the URL in separately using `wp_get_attachment_url`, making the logic much clearer, and reducing the amount of work needed:
e.g.
```
$image = wp_get_attachment_image( $id, $size, false );
// if it's set to not sh... |
51,636 | <p>I've had a look around for this but nothing has came up (perhaps am not searching good enough?) but I'm trying to set a parent on a taxonomy which is loaded from another taxonomy.</p>
<p>For example I have Car Makes and Car Models, when adding a new model I would like to select its parent (Car Make) not another par... | [
{
"answer_id": 51789,
"author": "Petr Sláma",
"author_id": 16018,
"author_profile": "https://wordpress.stackexchange.com/users/16018",
"pm_score": 2,
"selected": false,
"text": "<p>I am not sure, but look at <a href=\"http://codex.wordpress.org/Function_Reference/register_taxonomy_for_ob... | 2012/05/09 | [
"https://wordpress.stackexchange.com/questions/51636",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6824/"
] | I've had a look around for this but nothing has came up (perhaps am not searching good enough?) but I'm trying to set a parent on a taxonomy which is loaded from another taxonomy.
For example I have Car Makes and Car Models, when adding a new model I would like to select its parent (Car Make) not another parent within... | I am not sure, but look at [`register_taxonomy_for_object_type`](http://codex.wordpress.org/Function_Reference/register_taxonomy_for_object_type) - it connect even taxonomies.
If it will not help, your only one solution is combination of custom-taxonomy and [custom post type](http://codex.wordpress.org/Function_Refere... |
51,646 | <p>I'm using following install function with dbDelta as referring to the codex, articles on SO I watched out for the typical problems with e.g. one space instead of two spaced at the PRIMARY KEY ...</p>
<pre><code>function myplugin_install(){
global $wpdb;
$table_name = $wpdb->prefix . "vehicles";
... | [
{
"answer_id": 51789,
"author": "Petr Sláma",
"author_id": 16018,
"author_profile": "https://wordpress.stackexchange.com/users/16018",
"pm_score": 2,
"selected": false,
"text": "<p>I am not sure, but look at <a href=\"http://codex.wordpress.org/Function_Reference/register_taxonomy_for_ob... | 2012/05/09 | [
"https://wordpress.stackexchange.com/questions/51646",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12614/"
] | I'm using following install function with dbDelta as referring to the codex, articles on SO I watched out for the typical problems with e.g. one space instead of two spaced at the PRIMARY KEY ...
```
function myplugin_install(){
global $wpdb;
$table_name = $wpdb->prefix . "vehicles";
$sql = "CREATE... | I am not sure, but look at [`register_taxonomy_for_object_type`](http://codex.wordpress.org/Function_Reference/register_taxonomy_for_object_type) - it connect even taxonomies.
If it will not help, your only one solution is combination of custom-taxonomy and [custom post type](http://codex.wordpress.org/Function_Refere... |
51,661 | <p>I need a way to create a menu page with a list of all users for administrative purposes. The list will be used by users that don't have permission or acceses to the "Users" menu page. The page need to have the User ID, Name, Registration Date, Nickname, User Level and User Role for each user</p>
<p>Any idea how to ... | [
{
"answer_id": 51662,
"author": "user983248",
"author_id": 15704,
"author_profile": "https://wordpress.stackexchange.com/users/15704",
"pm_score": 2,
"selected": true,
"text": "<p>As a plugin all that I can give to you is this.</p>\n\n<pre><code><?php\n/*\nPlugin Name: Users Table\nPl... | 2012/05/09 | [
"https://wordpress.stackexchange.com/questions/51661",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15974/"
] | I need a way to create a menu page with a list of all users for administrative purposes. The list will be used by users that don't have permission or acceses to the "Users" menu page. The page need to have the User ID, Name, Registration Date, Nickname, User Level and User Role for each user
Any idea how to achieve th... | As a plugin all that I can give to you is this.
```
<?php
/*
Plugin Name: Users Table
Plugin URI: http://www.exe.ie
Description: A list of all available users with their ID, Name, Registration Date, Nickname, User Level and User Role
Version: 1.0
Author: Daniel Conde
Author URI: http://www.exe.ie
License: GPL
*/
add_... |
51,672 | <p>I have added a custom meta box for advanced information for a specific post category, to my create new post page. </p>
<p>Now I recognize, that if I save the post, it writes 2 entries in the db with 2 post_ids.</p>
<pre><code>add_action( 'add_meta_boxes', 'my-plugin_add_custom_box' );
add_action( 'save_post', 'my-... | [
{
"answer_id": 51716,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 1,
"selected": false,
"text": "<p>An <a href=\"https://github.com/bueltge/Add-Language-Box/blob/master/fb-add-language-box.php\" rel=\"nofollow\">Ex... | 2012/05/09 | [
"https://wordpress.stackexchange.com/questions/51672",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12614/"
] | I have added a custom meta box for advanced information for a specific post category, to my create new post page.
Now I recognize, that if I save the post, it writes 2 entries in the db with 2 post\_ids.
```
add_action( 'add_meta_boxes', 'my-plugin_add_custom_box' );
add_action( 'save_post', 'my-plugin_save_postdata... | One of the two IDs might be a post revision. To prevent this behaviour, I always have this checks in my save\_postdata function:
```
// Autosave, do nothing
if ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE )
return;
// AJAX? Not used here
if ( defined( 'DOING_AJAX' ) && DOING_AJAX )
return;
// Chec... |
51,678 | <p>After searching for a couple of days and reading 2 year old threads I'm having difficulty finding a solution to the problem of having users login by email only.</p>
<p>At first I was delighted to see WP_Email_Login only to find out you can still use your username to login. I'm not sure how to go about writing this ... | [
{
"answer_id": 51714,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 3,
"selected": false,
"text": "<p>It's possible, you must change the default validation via the action filter.</p>\n<pre><code>// Remove the default... | 2012/05/09 | [
"https://wordpress.stackexchange.com/questions/51678",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15873/"
] | After searching for a couple of days and reading 2 year old threads I'm having difficulty finding a solution to the problem of having users login by email only.
At first I was delighted to see WP\_Email\_Login only to find out you can still use your username to login. I'm not sure how to go about writing this as a plu... | **Update:**
I have created a plugin for login, registration and retrieve password with email. <https://wordpress.org/plugins/smart-wp-login/>
Answer in short, you can configure WordPress to login with email.
Three Steps:
* Remove default authentication function
* Add custom authentication function
* Change text "Use... |
51,687 | <p>I'm trying to dynamically generate a <code><a name=""></code> link reference inside of a Wordpress plugin. The plugin will output this link reference inside of the posts it generates. The categories of posts that this plugin generates will always be changing, so when we link to those posts from a separate pa... | [
{
"answer_id": 51717,
"author": "jbeldock",
"author_id": 15985,
"author_profile": "https://wordpress.stackexchange.com/users/15985",
"pm_score": 0,
"selected": false,
"text": "<p>The issue is the syntax of your string literal and the inner < ? php tag pair. You can simply use double ... | 2012/05/10 | [
"https://wordpress.stackexchange.com/questions/51687",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15578/"
] | I'm trying to dynamically generate a `<a name="">` link reference inside of a Wordpress plugin. The plugin will output this link reference inside of the posts it generates. The categories of posts that this plugin generates will always be changing, so when we link to those posts from a separate page, we still need to b... | I am not entirely sure what you are asking, but if you need a unique identifier based on posts created in WordPress, then use the post ID. Every post type is saved into the same table in the database so posts, pages, and custom post types will never have conflicting IDs. |
51,692 | <p>Within the <code>WP_Dependencies</code> class exists a method named <code>add_data</code>. This function adds data to scripts/styles that have been enqueued during the WordPress load. A commonly cited use for this function is to add a conditional when adding stylesheets that are targeted at different versions of IE.... | [
{
"answer_id": 52428,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>This function adds data to scripts/styles that have been enqueued during the WordPress load.</p>\n<... | 2012/05/10 | [
"https://wordpress.stackexchange.com/questions/51692",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4850/"
] | Within the `WP_Dependencies` class exists a method named `add_data`. This function adds data to scripts/styles that have been enqueued during the WordPress load. A commonly cited use for this function is to add a conditional when adding stylesheets that are targeted at different versions of IE. For example, to target I... | >
> This function adds data to scripts/styles that have been enqueued during the WordPress load.
>
>
>
Not really. It adds data to scripts/styles that've been `registered`.
>
> The data key that is set by `wp_localize_script` is ultimately overwritten by the call to `$wp_scripts->add_data`, whereas if you call `... |
51,699 | <p>Is there a way to compare the_excerpt() to the_content() to know if the_excerpt() is actually showing the entire post content? for instance, if a post were particularly short.</p>
<p>ultimately i'd like to have a "Read more" link at the end of excerpts. but i want it to say 1 thing for posts and another for posts... | [
{
"answer_id": 51705,
"author": "mrwweb",
"author_id": 9844,
"author_profile": "https://wordpress.stackexchange.com/users/9844",
"pm_score": 4,
"selected": true,
"text": "<p>What you're trying to do with the video is exactly what <a href=\"http://codex.wordpress.org/Post_Formats\">Post F... | 2012/05/10 | [
"https://wordpress.stackexchange.com/questions/51699",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6477/"
] | Is there a way to compare the\_excerpt() to the\_content() to know if the\_excerpt() is actually showing the entire post content? for instance, if a post were particularly short.
ultimately i'd like to have a "Read more" link at the end of excerpts. but i want it to say 1 thing for posts and another for posts of the v... | What you're trying to do with the video is exactly what [Post Formats](http://codex.wordpress.org/Post_Formats) were created to handle.
Add this to functions:
```
add_theme_support( 'post-formats', array( 'video' ) );
```
And then this to handle your Read More link:
```
if( !has_post_format( 'video' ) ) {
echo... |
51,732 | <p>How does WordPress convert raw data from the database to a readable format in the_content function?</p>
<p>I've noticed that it applies the_content filter, but what does the_content filter do?</p>
| [
{
"answer_id": 51749,
"author": "Michael",
"author_id": 4884,
"author_profile": "https://wordpress.stackexchange.com/users/4884",
"pm_score": 4,
"selected": true,
"text": "<p>the default filters are set in /wp-includes/default-filters.php;</p>\n\n<p>for 'the_content' this is from line 13... | 2012/05/10 | [
"https://wordpress.stackexchange.com/questions/51732",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8979/"
] | How does WordPress convert raw data from the database to a readable format in the\_content function?
I've noticed that it applies the\_content filter, but what does the\_content filter do? | the default filters are set in /wp-includes/default-filters.php;
for 'the\_content' this is from line 135:
```
add_filter( 'the_content', 'wptexturize' );
add_filter( 'the_content', 'convert_smilies' );
add_filter( 'the_content', 'convert_chars' );
add_filter( 'the_content', 'wpautop' );
add... |
51,741 | <p>Is there a way to get the content from another outside the loop? The ID is 302 and I need to display the content of that on another page.</p>
| [
{
"answer_id": 51747,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 7,
"selected": true,
"text": "<h3>You can use <a href=\"http://codex.wordpress.org/Function_Reference/get_page\" rel=\"noreferrer\"><code>get_page()... | 2012/05/10 | [
"https://wordpress.stackexchange.com/questions/51741",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4588/"
] | Is there a way to get the content from another outside the loop? The ID is 302 and I need to display the content of that on another page. | ### You can use [`get_page()`](http://codex.wordpress.org/Function_Reference/get_page) to return the `$post` object of a static page:
```
$page_id = 302;
$page_object = get_page( $page_id );
echo $page_object->post_content;
```
### Edit
Similarly, you can use [`get_post()`](http://codex.wordpress.org/Function_Refer... |
51,776 | <p>I have a theme that is custom developed and really complex. One of the things that I have is multiple content areas where users can specify content for specific tabs. I load multiple instances of the WordPress editor through the <code>wp_editor()</code> function. It works perfectly. (This is all on the admin sid... | [
{
"answer_id": 52724,
"author": "Steven",
"author_id": 13118,
"author_profile": "https://wordpress.stackexchange.com/users/13118",
"pm_score": 2,
"selected": false,
"text": "<p>You need to call the editor init again once you add your ajax textarea, I did it like this:</p>\n\n<pre><code>$... | 2012/05/10 | [
"https://wordpress.stackexchange.com/questions/51776",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15568/"
] | I have a theme that is custom developed and really complex. One of the things that I have is multiple content areas where users can specify content for specific tabs. I load multiple instances of the WordPress editor through the `wp_editor()` function. It works perfectly. (This is all on the admin side, in the "Page" p... | To get the quicktags to show up, you need to re instantiate them within your ajax oncomplete handler.
```
quicktags({id : 'editorcontentid'});
```
My ajax success handler looks like this;
```
success: function(data, textStatus, XMLHttpRequest){
//append editor to dom
$('#container').append($... |
51,790 | <p>I'm using custom post types to display properties and have a custom price field assigned to each post. On the property page I want to display a list of four similarly priced properties, two less than or equal to the price of the current property and two greater than the current price. Ordering properties numerically... | [
{
"answer_id": 51791,
"author": "Alex Lane",
"author_id": 16016,
"author_profile": "https://wordpress.stackexchange.com/users/16016",
"pm_score": -1,
"selected": false,
"text": "<h1>Edit</h1>\n\n<p>Thanks for calling me out, it's the only way to get better.</p>\n\n<p>The updated query wo... | 2012/05/10 | [
"https://wordpress.stackexchange.com/questions/51790",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6800/"
] | I'm using custom post types to display properties and have a custom price field assigned to each post. On the property page I want to display a list of four similarly priced properties, two less than or equal to the price of the current property and two greater than the current price. Ordering properties numerically by... | One possibility is a direct SQL query similar to the one [given here](https://stackoverflow.com/questions/9320485/how-can-i-search-for-rows-around-a-given-string-value).
But I'm not convinced that it would be much more efficient than 2 queries, all handled by WordPress:
*The is untested*
```
$price =0; //Price of cu... |
51,800 | <p>This question has changed significantly. </p>
<p>I have the latest version of Wordpress and am hosting it on an Apache server.
Link to Blog: <a href="http://blogs.bzaeds.org/test/2012/05/11/video-test/" rel="nofollow">http://blogs.bzaeds.org/test/2012/05/11/video-test/</a></p>
<p>Now, here's the thing. </p>
<p>Wh... | [
{
"answer_id": 51821,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 0,
"selected": false,
"text": "<p>There's a <a href=\"http://www.longtailvideo.com/support/forums/jw-player/bug-reports/15740/not-working-on-i... | 2012/05/10 | [
"https://wordpress.stackexchange.com/questions/51800",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16022/"
] | This question has changed significantly.
I have the latest version of Wordpress and am hosting it on an Apache server.
Link to Blog: <http://blogs.bzaeds.org/test/2012/05/11/video-test/>
Now, here's the thing.
When I upload a video to Wordpress it will play on a Mac in Firefox with the Wordpress URL the item is gi... | After 6 days of pure sadness, this ended up being the fix: <http://www.technowut.com/2012/05/14/how-to-stream-videos-to-ios-devices-with-multisite-wordpress/>
Here’s how to get it working on CentOS 6 with the packaged Apache httpd:
Nils Maier wrote the module for Apache httpd. Download the source and take some time t... |
51,806 | <p>Back in my naive days of theming, I had to make it so the link inserted by <code><!--more--></code> wouldn't dump the viewer at the anchor it produces. </p>
<p>I made a dinky plugin that consisted of:</p>
<pre><code>function No_More_Link($buffer) {
$inHTML[0] = '/#more-\d+/';
$outHTML[0] = '';
return p... | [
{
"answer_id": 51821,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 0,
"selected": false,
"text": "<p>There's a <a href=\"http://www.longtailvideo.com/support/forums/jw-player/bug-reports/15740/not-working-on-i... | 2012/05/10 | [
"https://wordpress.stackexchange.com/questions/51806",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8966/"
] | Back in my naive days of theming, I had to make it so the link inserted by `<!--more-->` wouldn't dump the viewer at the anchor it produces.
I made a dinky plugin that consisted of:
```
function No_More_Link($buffer) {
$inHTML[0] = '/#more-\d+/';
$outHTML[0] = '';
return preg_replace($inHTML, $outHTML, $buffer... | After 6 days of pure sadness, this ended up being the fix: <http://www.technowut.com/2012/05/14/how-to-stream-videos-to-ios-devices-with-multisite-wordpress/>
Here’s how to get it working on CentOS 6 with the packaged Apache httpd:
Nils Maier wrote the module for Apache httpd. Download the source and take some time t... |
51,810 | <p>I have a standard HTML form that the visitor will fill out. It consists of mostly checkboxes. What I would like, is after the form is submitted, a page is then presented to the user showing what they checked. For example, if the visitor checked off Checkbox A, B, and D (but not C), then upon submission they would... | [
{
"answer_id": 51896,
"author": "jroakes",
"author_id": 2743,
"author_profile": "https://wordpress.stackexchange.com/users/2743",
"pm_score": 2,
"selected": false,
"text": "<p>Take a look at <a href=\"http://premium.wpmudev.org/\" rel=\"nofollow\">http://premium.wpmudev.org/</a>. There ... | 2012/05/10 | [
"https://wordpress.stackexchange.com/questions/51810",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9636/"
] | I have a standard HTML form that the visitor will fill out. It consists of mostly checkboxes. What I would like, is after the form is submitted, a page is then presented to the user showing what they checked. For example, if the visitor checked off Checkbox A, B, and D (but not C), then upon submission they would see t... | I believe that [ThreeWP Broadcast](http://wordpress.org/extend/plugins/threewp-broadcast/) is the plugin you should use. I've been using this plugin in WPMS to share (and link) content between blogs, and it works well.
Basically, this plugin allows you to:
* duplicate a post from a blog to other blogs in the network
... |
51,838 | <p>On localhost (WAMP server) I have installed wordpress in the root directory (examplesite.com). I have an application that needs to run outside of Wordpress, so I would like it in the folder /application (examplesite.com/application). I created the folder “application” in the root, but when I go to the url example... | [
{
"answer_id": 51855,
"author": "Jacek Kaniuk",
"author_id": 16025,
"author_profile": "https://wordpress.stackexchange.com/users/16025",
"pm_score": 0,
"selected": false,
"text": "<p>Try it like that:</p>\n\n<pre><code><IfModule mod_rewrite.c>\nRewriteEngine On\nRewriteBase /\nRewr... | 2012/05/11 | [
"https://wordpress.stackexchange.com/questions/51838",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16029/"
] | On localhost (WAMP server) I have installed wordpress in the root directory (examplesite.com). I have an application that needs to run outside of Wordpress, so I would like it in the folder /application (examplesite.com/application). I created the folder “application” in the root, but when I go to the url examplesite.c... | You can revert to the default WordPress rewrite rules. This line already handles checking for existing physical directories:
```
RewriteCond %{REQUEST_FILENAME} !-d
```
Your problem does not lie with WordPress, but with some other problem with your server/htaccess files. You have not provided enough information to s... |
51,844 | <p>I am using a <a href="http://wordpress.org/extend/plugins/posttabs/" rel="nofollow">postTabs plugin</a> and <a href="http://wordpress.org/extend/plugins/comprehensive-google-map-plugin/" rel="nofollow">Comprehensive Google Map Plugin</a>, my problem was when I have my Google map on the second tab, the map is not loa... | [
{
"answer_id": 51855,
"author": "Jacek Kaniuk",
"author_id": 16025,
"author_profile": "https://wordpress.stackexchange.com/users/16025",
"pm_score": 0,
"selected": false,
"text": "<p>Try it like that:</p>\n\n<pre><code><IfModule mod_rewrite.c>\nRewriteEngine On\nRewriteBase /\nRewr... | 2012/05/11 | [
"https://wordpress.stackexchange.com/questions/51844",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9583/"
] | I am using a [postTabs plugin](http://wordpress.org/extend/plugins/posttabs/) and [Comprehensive Google Map Plugin](http://wordpress.org/extend/plugins/comprehensive-google-map-plugin/), my problem was when I have my Google map on the second tab, the map is not loading as expected. But if I move it on the 1st tab it wo... | You can revert to the default WordPress rewrite rules. This line already handles checking for existing physical directories:
```
RewriteCond %{REQUEST_FILENAME} !-d
```
Your problem does not lie with WordPress, but with some other problem with your server/htaccess files. You have not provided enough information to s... |
51,897 | <p>I have thumbnail support added with the following in my functions.php</p>
<pre><code>// Add Thumbnail Support
add_theme_support('post-thumbnails');
set_post_thumbnail_size( 140, 140, true );
</code></pre>
<p>And I create the custom post type with</p>
<pre><code>// Create Custom Post Type for Work
add_action( 'ini... | [
{
"answer_id": 51898,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 7,
"selected": true,
"text": "<p>try the <a href=\"http://codex.wordpress.org/Function_Reference/register_post_type#Parameters\"><code>register_post_... | 2012/05/11 | [
"https://wordpress.stackexchange.com/questions/51897",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9636/"
] | I have thumbnail support added with the following in my functions.php
```
// Add Thumbnail Support
add_theme_support('post-thumbnails');
set_post_thumbnail_size( 140, 140, true );
```
And I create the custom post type with
```
// Create Custom Post Type for Work
add_action( 'init', 'create_post_type' );
function cr... | try the [`register_post_type`](http://codex.wordpress.org/Function_Reference/register_post_type#Parameters) `supports` parameter:
```
'supports' => array( 'thumbnail' )
``` |
51,906 | <p>So I'm doing a query like this:</p>
<pre><code> $the_query = new WP_Query( array( 'meta_key' => 'homepage', 'meta_value' => 'yes',
'post_type' => 'page', 'orderby' => 'modified', 'posts_per_page' => 1 ) );
</code></pre>
<p>To get a single page with a specific key value, how do I get the page tem... | [
{
"answer_id": 51907,
"author": "SickHippie",
"author_id": 5434,
"author_profile": "https://wordpress.stackexchange.com/users/5434",
"pm_score": 3,
"selected": true,
"text": "<p>This should do the trick for you. This shows what template file is stored in <code>post_meta</code>, if one h... | 2012/05/11 | [
"https://wordpress.stackexchange.com/questions/51906",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8957/"
] | So I'm doing a query like this:
```
$the_query = new WP_Query( array( 'meta_key' => 'homepage', 'meta_value' => 'yes',
'post_type' => 'page', 'orderby' => 'modified', 'posts_per_page' => 1 ) );
```
To get a single page with a specific key value, how do I get the page template from a query like this, if it has o... | This should do the trick for you. This shows what template file is stored in `post_meta`, if one has been selected in the admin panel:
`$template_name = get_post_meta( $the_query->post->ID, '_wp_page_template', true );`
If you want to see if the page is the homepage, use `is_home()` or `is_front_page()`.
If you want... |
51,920 | <p>Is there any filter available to set the naming convention of those auto generated thumbnails? </p>
<p>Something like this:</p>
<ul>
<li>thumbnail_150x150.jpg -> thumbnail-s.jpg</li>
<li>thumbnail_300x300.jpg -> thumbnail-m.jpg</li>
<li>thumbnail_600x600.jpg -> thumbnail-l.jpg</li>
</ul>
| [
{
"answer_id": 51983,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 3,
"selected": true,
"text": "<p><em>Seems</em> that the answer is <strong>no</strong>...</p>\n<p>I've followed the core functions and found a... | 2012/05/11 | [
"https://wordpress.stackexchange.com/questions/51920",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6851/"
] | Is there any filter available to set the naming convention of those auto generated thumbnails?
Something like this:
* thumbnail\_150x150.jpg -> thumbnail-s.jpg
* thumbnail\_300x300.jpg -> thumbnail-m.jpg
* thumbnail\_600x600.jpg -> thumbnail-l.jpg | *Seems* that the answer is **no**...
I've followed the core functions and found a dead-end. And found this post ( [How can I make add\_image\_size() crop from the top?](https://wordpress.stackexchange.com/q/20923/12615) ) where [Rarst](https://wordpress.stackexchange.com/users/847/rarst) says:
>
> Intermediate image... |
51,971 | <p>I need a way to disable the save process completely using an <code>action/filter</code>. Something that works (for e.g.:) in the <code>query</code>, <code>posts_clauses</code> or <code>wp_insert_post/save_post/update_post</code> hooks.</p>
<p>So far I only tried to <code>return '';</code>, which gives me tons of er... | [
{
"answer_id": 51980,
"author": "Rob Vermeer",
"author_id": 11135,
"author_profile": "https://wordpress.stackexchange.com/users/11135",
"pm_score": 4,
"selected": true,
"text": "<pre><code>function disable_save( $maybe_empty, $postarr ) {\n $maybe_empty = true;\n\n return $maybe_em... | 2012/05/12 | [
"https://wordpress.stackexchange.com/questions/51971",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/385/"
] | I need a way to disable the save process completely using an `action/filter`. Something that works (for e.g.:) in the `query`, `posts_clauses` or `wp_insert_post/save_post/update_post` hooks.
So far I only tried to `return '';`, which gives me tons of errors for missing values for post object parts in the admin UI.
T... | ```
function disable_save( $maybe_empty, $postarr ) {
$maybe_empty = true;
return $maybe_empty;
}
add_filter( 'wp_insert_post_empty_content', 'disable_save', 999999, 2 );
```
Because `wp_insert_post_empty_content` is set to true, WordPress thinks there is no title and no content and stops updating the post.
... |
51,984 | <p>I want to retrieve data from custom table, that I've made inside the wordpress database and display it in a wordpress page , like posts</p>
<p>Thanks in advance</p>
| [
{
"answer_id": 51985,
"author": "mor7ifer",
"author_id": 11740,
"author_profile": "https://wordpress.stackexchange.com/users/11740",
"pm_score": 0,
"selected": false,
"text": "<p>Sounds like you're looking for <code>$wpdb</code>. You'll need to write all your own functions and such. I st... | 2012/05/12 | [
"https://wordpress.stackexchange.com/questions/51984",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16059/"
] | I want to retrieve data from custom table, that I've made inside the wordpress database and display it in a wordpress page , like posts
Thanks in advance | Here is an example code that will get the data and then display it:
```
global $wpdb;
// this adds the prefix which is set by the user upon instillation of wordpress
$table_name = $wpdb->prefix . "your_table_name";
// this will get the data from your table
$retrieve_data = $wpdb->get_results( "SELE... |
51,989 | <p>I am wondering how you would implement the following hook.</p>
<pre><code>do_action( 'woocommerce_process_product_meta_' . $product_type, $post_id );
</code></pre>
<p>What is the correct way to call a call the action from a plugin file.
Bellow is the code that I am currently using but its not working.</p>
<pre><c... | [
{
"answer_id": 51994,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 0,
"selected": false,
"text": "<p>For example you have two product types: product1 and product2. Then you will have two action calls: <cod... | 2012/05/13 | [
"https://wordpress.stackexchange.com/questions/51989",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15855/"
] | I am wondering how you would implement the following hook.
```
do_action( 'woocommerce_process_product_meta_' . $product_type, $post_id );
```
What is the correct way to call a call the action from a plugin file.
Bellow is the code that I am currently using but its not working.
```
global $post, $thepostid, $woocom... | If you don't intend your meta field to be specific to a particular product type you can do the following ( which is what I do in my own WooCommerce extension ).
```
function new_post_meta () {
if (isset($_POST['location']))
update_post_meta( $post_id, 'location', json_encode($_POST['location']) );
... |
51,992 | <p>I have a custom hierarchical taxonomy called "places" set up with categories like so: Services > Financial Services > Financial Advisors.</p>
<p>The permalink for this category listing page is currently mysite.com/places/services/financial-services/financial-advisors.</p>
<p>Does anyone know how I can remove the p... | [
{
"answer_id": 51993,
"author": "Libin",
"author_id": 12611,
"author_profile": "https://wordpress.stackexchange.com/users/12611",
"pm_score": 0,
"selected": false,
"text": "<p>Check this plugin <a href=\"http://wordpress.org/extend/plugins/taxonomic-seo-permalinks/\" rel=\"nofollow noref... | 2012/05/13 | [
"https://wordpress.stackexchange.com/questions/51992",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16078/"
] | I have a custom hierarchical taxonomy called "places" set up with categories like so: Services > Financial Services > Financial Advisors.
The permalink for this category listing page is currently mysite.com/places/services/financial-services/financial-advisors.
Does anyone know how I can remove the parents from my pe... | Simply set to false 'hierarchical'=>true from rewrite parameter in your register\_taxonomy.
It should looks like this:
```
register_taxonomy('places', 'post', array(
// Hierarchical taxonomy
'hierarchical' => true,
'labels' => array(
//here your labels
),
// Control the slugs used for this ... |
51,998 | <p>I am working with a client who has a directory site that allows users to create accounts, then lists of items from the directory. Right now, whenever a user creates an account, she gets a profile URL like:</p>
<pre><code>domain.com/member/%author%
</code></pre>
<p>Which is accomplished with a simple:</p>
<pre><co... | [
{
"answer_id": 55303,
"author": "AriePutranto",
"author_id": 17138,
"author_profile": "https://wordpress.stackexchange.com/users/17138",
"pm_score": 0,
"selected": false,
"text": "<p>add_rewrite_rule() should be the answer\n<a href=\"http://codex.wordpress.org/Rewrite_API/add_rewrite_rul... | 2012/05/13 | [
"https://wordpress.stackexchange.com/questions/51998",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16080/"
] | I am working with a client who has a directory site that allows users to create accounts, then lists of items from the directory. Right now, whenever a user creates an account, she gets a profile URL like:
```
domain.com/member/%author%
```
Which is accomplished with a simple:
```
$wp_rewrite->author_base = 'member... | **Option 1**
I assume custom post type generate a URL something like this
*domain.com/%custom-post-type%/%list%*
So you could write it so it looks as... since the main URL doesn't have author before custom type you would have to do this via a function since authors are dynamic
```
RewriteRule ^members/%author%/(.*)... |
52,001 | <p>I try to assign custom taxonomies to a <strong><em>page</em></strong> when newly added by the "publish" button.</p>
<p>This is the function:</p>
<pre><code>function set_default_object_terms( $id, $post ) {
if ( 'publish' === $post->post_status ) {
log_me ('From inside function: '.__FUNCTION__.', while I pr... | [
{
"answer_id": 52010,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 3,
"selected": true,
"text": "<p>You are using <code>wp_set_object_terms</code> wrong, the second parameter should be the term slug or id and t... | 2012/05/13 | [
"https://wordpress.stackexchange.com/questions/52001",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12812/"
] | I try to assign custom taxonomies to a ***page*** when newly added by the "publish" button.
This is the function:
```
function set_default_object_terms( $id, $post ) {
if ( 'publish' === $post->post_status ) {
log_me ('From inside function: '.__FUNCTION__.', while I pressed the "publish" button. Post-ID: '.$id);... | You are using `wp_set_object_terms` wrong, the second parameter should be the term slug or id and the 3 parameter should be the taxonomy name, so try:
```
function set_default_object_terms( $id, $post ) {
if ( 'publish' === $post->post_status ) {
log_me ('be in function while "publish" i pressed with this... |
52,002 | <p>The code below is from Wordpress SEO plugin by Yoast. I am trying to add the page number to the Meta description on paginated posts (to avoid duplication issues with Google).</p>
<pre><code>function metadesc( $echo = true ) {
if ( get_query_var('paged') && get_query_var('paged') > 1 )
... | [
{
"answer_id": 52110,
"author": "A.M.M",
"author_id": 16083,
"author_profile": "https://wordpress.stackexchange.com/users/16083",
"pm_score": 0,
"selected": false,
"text": "<p>Just fixed this. I have posted the solution in WordPress forum where I had initially asked.\n<a href=\"http://wo... | 2012/05/13 | [
"https://wordpress.stackexchange.com/questions/52002",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16083/"
] | The code below is from Wordpress SEO plugin by Yoast. I am trying to add the page number to the Meta description on paginated posts (to avoid duplication issues with Google).
```
function metadesc( $echo = true ) {
if ( get_query_var('paged') && get_query_var('paged') > 1 )
return;
global ... | To add a page number *regardless* to any plugin … use filters. Do not change the plugin file. You cannot run updates other wise.
Example:
```
<?php # -*- coding: utf-8 -*-
/**
* Plugin Name: T5 Add page number to title
* Description: Adds <code> | Page $number</code> to the page title.
* License: MIT
* Licens... |
52,009 | <p>I have gravity forms set up on my site and I am wanting to hide/show a form based on whether or not the user has posted an entry into the form/database.
If they have made an entry, then I want to hide it and display some simple text.</p>
<p>I see that gravity forms allow you to limit number of entries but this is n... | [
{
"answer_id": 52011,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 2,
"selected": false,
"text": "<p>Try this;</p>\n\n<pre><code><?php \n\n $user = wp_get_current_user();\n\n if ( count_user_posts( $user-&... | 2012/05/13 | [
"https://wordpress.stackexchange.com/questions/52009",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11827/"
] | I have gravity forms set up on my site and I am wanting to hide/show a form based on whether or not the user has posted an entry into the form/database.
If they have made an entry, then I want to hide it and display some simple text.
I see that gravity forms allow you to limit number of entries but this is not quite w... | Try this;
```
<?php
$user = wp_get_current_user();
if ( count_user_posts( $user->ID ) >= 1 ) {
// echo your text snippet
} else {
// echo your form
}
?>
```
1) `wp_get_current_user()` returns the `WP_User` object which includes many properties for that user.
2) Since we only ... |
52,019 | <p>Is there a way I could install some plugin or have syntax highlighting for my wordpress.com blog or do I need to install WP on my own server to be able to install a plugin to do that?</p>
| [
{
"answer_id": 52021,
"author": "pixelngrain",
"author_id": 9821,
"author_profile": "https://wordpress.stackexchange.com/users/9821",
"pm_score": -1,
"selected": false,
"text": "<p>There is a plugin call \"SyntaxHighlighter\" really nice and easy. I am using on my blog. here is the link ... | 2012/05/13 | [
"https://wordpress.stackexchange.com/questions/52019",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16093/"
] | Is there a way I could install some plugin or have syntax highlighting for my wordpress.com blog or do I need to install WP on my own server to be able to install a plugin to do that? | WordPress.com uses [Alex Gorbatchev’s SyntaxHighlighter](http://alexgorbatchev.com/SyntaxHighlighter) so all you need to do is use the right shortcode ex:
```
[code language="css"]
#button {
font-weight: bold;
border: 2px solid #fff;
}
[/code]
```
which gives you something like this:
![enter image description here]... |
52,023 | <p>Currently I'm trying to get the post type labels plural. In detail: </p>
<pre><code>$GLOBALS['wp_post_types'][ get_current_screen()->post_type ]->labels->name
</code></pre>
<p>This is how I'm trying to retrieve it - in the admin UI - using the public wp API functions:</p>
<pre><code>$post_type_name = get... | [
{
"answer_id": 52027,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 3,
"selected": false,
"text": "<p>This works...</p>\n\n<pre><code>$object = get_post_type_object( 'post' );\n\necho $object->labels->name;\ne... | 2012/05/13 | [
"https://wordpress.stackexchange.com/questions/52023",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/385/"
] | Currently I'm trying to get the post type labels plural. In detail:
```
$GLOBALS['wp_post_types'][ get_current_screen()->post_type ]->labels->name
```
This is how I'm trying to retrieve it - in the admin UI - using the public wp API functions:
```
$post_type_name = get_current_screen()->post_type;
$post_type_obj =... | ### Edit:
get\_post\_type\_labels was never intended to be a public function. It is only used internally when registering a post type. See these trac tickets:
* [get\_taxonomy\_labels() and \_get\_custom\_object\_labels() fail if $object->taxonomy is not array](http://core.trac.wordpress.org/ticket/16310)
* [Fatal er... |
52,030 | <p>I am currently using this code in my theme right before showing the content of the custom post type my_post_type:</p>
<pre><code>$title = $post->post_title;
query_posts( array (
'post_type' => 'page',
'posts_per_page' => -1,
'my_taxonomy' => $title
));
</code></pre>
<p>This means that ... | [
{
"answer_id": 52027,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 3,
"selected": false,
"text": "<p>This works...</p>\n\n<pre><code>$object = get_post_type_object( 'post' );\n\necho $object->labels->name;\ne... | 2012/05/13 | [
"https://wordpress.stackexchange.com/questions/52030",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15882/"
] | I am currently using this code in my theme right before showing the content of the custom post type my\_post\_type:
```
$title = $post->post_title;
query_posts( array (
'post_type' => 'page',
'posts_per_page' => -1,
'my_taxonomy' => $title
));
```
This means that when I go to .../my\_post\_type/some... | ### Edit:
get\_post\_type\_labels was never intended to be a public function. It is only used internally when registering a post type. See these trac tickets:
* [get\_taxonomy\_labels() and \_get\_custom\_object\_labels() fail if $object->taxonomy is not array](http://core.trac.wordpress.org/ticket/16310)
* [Fatal er... |
52,070 | <p>Is it a way to get posts published between a date and today with <code>query_posts()</code> ?</p>
<p>Example : All posts published since <strong>2012-04-01</strong></p>
<p>Thanks</p>
<p>EDIT : </p>
<p>How to add the filter date on this Query Posts ?</p>
<pre><code>query_posts( array(
array('post'),
't... | [
{
"answer_id": 52072,
"author": "moraleida",
"author_id": 7890,
"author_profile": "https://wordpress.stackexchange.com/users/7890",
"pm_score": 6,
"selected": true,
"text": "<p><strong>UPDATE December 23 2014</strong></p>\n\n<p>There is a better method using <code>date_query</code> prope... | 2012/05/14 | [
"https://wordpress.stackexchange.com/questions/52070",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2000/"
] | Is it a way to get posts published between a date and today with `query_posts()` ?
Example : All posts published since **2012-04-01**
Thanks
EDIT :
How to add the filter date on this Query Posts ?
```
query_posts( array(
array('post'),
'tax_query' => array(
array(
'taxonomy' => 'post... | **UPDATE December 23 2014**
There is a better method using `date_query` property of `WP_Query` class:
```
$args = array(
'post_type' => 'post',
'tax_query' => array(
array(
'taxonomy' => 'post_format',
'field' => 'slug',
'terms' => array( 'post-format-ima... |
52,071 | <p>I have a client that used to have a static website and a blog powered from WordPress under the <code>/blog</code> subdirectory. Now he decided to move everything into WordPress so that he can also create and edit pages easily. However because the website is getting a lot of traffic and he already has likes, tweets a... | [
{
"answer_id": 52077,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": false,
"text": "<p>Extend the <code>'rewrite'</code> argument to suppress the first URL part:</p>\n\n<pre><code> 'rewrite' => a... | 2012/05/14 | [
"https://wordpress.stackexchange.com/questions/52071",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13469/"
] | I have a client that used to have a static website and a blog powered from WordPress under the `/blog` subdirectory. Now he decided to move everything into WordPress so that he can also create and edit pages easily. However because the website is getting a lot of traffic and he already has likes, tweets and +1 in every... | Extend the `'rewrite'` argument to suppress the first URL part:
```
'rewrite' => array(
'with_front' => false,
'slug' => 'product'
)
```
But using just `%postname%` for different post types is really tricky and error prone. Avoid it. |
52,084 | <p>I created a new custom post type 'Projects' and want the archive of all posts of this type to be available at mysite.com/projects. At the moment all project single posts are shown with a slug as follows mysite.com/projects/project-title, but when I go to mysite.com/projects I get a 404. </p>
<p>Here is how I built ... | [
{
"answer_id": 52086,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 3,
"selected": true,
"text": "<p>Nothing appears to be incorrect - (and I assumed you've gone to saved your permalink structure to flush th... | 2012/05/14 | [
"https://wordpress.stackexchange.com/questions/52084",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5844/"
] | I created a new custom post type 'Projects' and want the archive of all posts of this type to be available at mysite.com/projects. At the moment all project single posts are shown with a slug as follows mysite.com/projects/project-title, but when I go to mysite.com/projects I get a 404.
Here is how I built the custom... | Nothing appears to be incorrect - (and I assumed you've gone to saved your permalink structure to flush the rewrite rules as the comments suggest? :) ).
I would recommend using this plug-in to determine problems with your url-redirection: <http://wordpress.org/extend/plugins/monkeyman-rewrite-analyzer/> - update your ... |
52,087 | <p>I am building a wordpress website with dynamic wordpress menu + one level drop down menu (sub menu). since my drop down is a bit tricky and required special CSS I tried to remove the styling that wordpress automatically gives to menus by using this code:</p>
<pre><code>function wp_nav_menu_remove_attributes( $menu ... | [
{
"answer_id": 52089,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 0,
"selected": false,
"text": "<p>Create a custom <a href=\"http://codex.wordpress.org/Function_Reference/Walker_Class\" rel=\"nofollow\">Walker</a> ... | 2012/05/14 | [
"https://wordpress.stackexchange.com/questions/52087",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7730/"
] | I am building a wordpress website with dynamic wordpress menu + one level drop down menu (sub menu). since my drop down is a bit tricky and required special CSS I tried to remove the styling that wordpress automatically gives to menus by using this code:
```
function wp_nav_menu_remove_attributes( $menu ){
return ... | For anybody interested in the code to remove any class you want. I Just worked with the Roots theme and they did the replacement like below. You can just add the class you want to replace in the list.
```
/**
* Replace various active menu class names with "active" or nothing
*
*/
function roots_wp_nav_menu($text) ... |
52,097 | <p>I have a bunch of articles imported via a very old Joomla 1.0 installation. The content of these posts have a lot of unwanted inline html. I was able to clean all with something like this (I made a template with this inside, then I opened it):</p>
<pre><code><?php
$tochange = get_posts('post_type=post&numbe... | [
{
"answer_id": 53104,
"author": "Joshua",
"author_id": 10119,
"author_profile": "https://wordpress.stackexchange.com/users/10119",
"pm_score": 1,
"selected": false,
"text": "<p>To change every post, you need to loop through every post. Assuming your code checks out, which it seems it wil... | 2012/05/14 | [
"https://wordpress.stackexchange.com/questions/52097",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6099/"
] | I have a bunch of articles imported via a very old Joomla 1.0 installation. The content of these posts have a lot of unwanted inline html. I was able to clean all with something like this (I made a template with this inside, then I opened it):
```
<?php
$tochange = get_posts('post_type=post&numberposts=-1');
fore... | If you just need to change the post content, you can avoid the overhead of get\_posts/WP\_Query by directly querying the database:
```
global $wpdb;
$results = $wpdb->get_results("SELECT ID, post_content FROM {$wpdb->posts}");
$total = count($results);
$changed = 0;
foreach($results as $entry){
$new_content = s... |
52,099 | <p>I need to customize the admin panel for my user. So how do I remove the entire admin menu? Not remove the menu item, I mean entirely remove the left vertical menu bar, include the design of the menu (eg, css, background..etc). I want it become blank. </p>
<p>I can do it by css hack. But I prefer to use hook to do... | [
{
"answer_id": 52109,
"author": "mrwweb",
"author_id": 9844,
"author_profile": "https://wordpress.stackexchange.com/users/9844",
"pm_score": 2,
"selected": false,
"text": "<p>The only hook-friendly way I know is to use <a href=\"http://codex.wordpress.org/Function_Reference/remove_menu_p... | 2012/05/14 | [
"https://wordpress.stackexchange.com/questions/52099",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14728/"
] | I need to customize the admin panel for my user. So how do I remove the entire admin menu? Not remove the menu item, I mean entirely remove the left vertical menu bar, include the design of the menu (eg, css, background..etc). I want it become blank.
I can do it by css hack. But I prefer to use hook to do it. Any ide... | The correct hook to use is `admin_menu` and then create a function to remove the menus you want to remove. The following 2 functions remove all the menus.
```
add_action( 'admin_menu', 'remove_admin_menus' );
add_action( 'admin_menu', 'remove_admin_submenus' );
//Remove top level admin menus
function remove_admin_me... |
52,114 | <p>Is it possible to redirect users to an admin page if they access another admin page?</p>
<p>For example if they a user ever hits "all pages" <code>/wp-admin/edit.php?post_type=page</code></p>
<p>they would get redirected to "add New page" <code>/wp-admin/post-new.php?post_type=page</code></p>
| [
{
"answer_id": 52164,
"author": "ampt",
"author_id": 580,
"author_profile": "https://wordpress.stackexchange.com/users/580",
"pm_score": 0,
"selected": false,
"text": "<p>Yes this is possible by adding an <a href=\"http://codex.wordpress.org/Function_Reference/add_action\" rel=\"nofollow... | 2012/05/14 | [
"https://wordpress.stackexchange.com/questions/52114",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3246/"
] | Is it possible to redirect users to an admin page if they access another admin page?
For example if they a user ever hits "all pages" `/wp-admin/edit.php?post_type=page`
they would get redirected to "add New page" `/wp-admin/post-new.php?post_type=page` | ```
/**
* Redirect admin pages.
*
* Redirect specific admin page to another specific admin page.
*
* @return void
* @author Michael Ecklund
*
*/
function disallowed_admin_pages() {
global $pagenow;
# Check current admin page.
if ( $pagenow == 'edit.php' && isset( $_GET['post_type'] ) && $_GET['pos... |
52,121 | <p>I have a plugin that inserts a tinymce like shown below. Something causes the second toolbar, the <code>theme_advanced_buttons2</code> to have <code>display:none</code> attached to their style attribute, effectively hiding them.</p>
<p>I don't manage to find the code responsible for this.</p>
<pre><code>$tinymce =... | [
{
"answer_id": 52132,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 3,
"selected": true,
"text": "<h1>Show the Kitchen Sink by Default</h1>\n<p><sup>Copying <a href=\"https://wordpress.stackexchange.com/users/16124/nus\... | 2012/05/14 | [
"https://wordpress.stackexchange.com/questions/52121",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I have a plugin that inserts a tinymce like shown below. Something causes the second toolbar, the `theme_advanced_buttons2` to have `display:none` attached to their style attribute, effectively hiding them.
I don't manage to find the code responsible for this.
```
$tinymce =
array
(
'theme_advanced_buttons1'... | Show the Kitchen Sink by Default
================================
Copying [@nus'](https://wordpress.stackexchange.com/users/16124/nus) answer as an answer to help newcomers.
If you would like to show that second row of options by default, there’s an easy way. Simply put the following into your theme’s `functions.php`... |
52,122 | <p>Is there any way to add class to edited posts in order to style them differently?
If there is a way to do that without adding a class, this option would be much better.</p>
<p>EDITED - IGNORE THE ABOVE QUESTION - SEE BELOW</p>
<p>Is there a way to add a check box (meta box) in the area that a user writes an articl... | [
{
"answer_id": 52130,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Basically what you want to do is write either a function, or a small plugin (not so challenging if you know php).<... | 2012/05/14 | [
"https://wordpress.stackexchange.com/questions/52122",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15801/"
] | Is there any way to add class to edited posts in order to style them differently?
If there is a way to do that without adding a class, this option would be much better.
EDITED - IGNORE THE ABOVE QUESTION - SEE BELOW
Is there a way to add a check box (meta box) in the area that a user writes an article/post so when th... | This is very similar to @mrwweb's answer, but a little bit more fleshed out. We're also not going to overload taxonomies in order to get our post class, but do what you wanted initially: use a custom meta box.
There is a built in template tag called [`post_class`](http://codex.wordpress.org/Function_Reference/post_cla... |
52,125 | <p>I've been trying to utilize the PHP excerpt function to call from her recent blog post to post on a <a href="http://www.chazsouthard.com/art/" rel="nofollow">main landing page</a> without avail. Any thoughts?</p>
<pre><code><div id="home_news" class="prefix_9 grid_3">
<div id="newsbox" style="display: ... | [
{
"answer_id": 52128,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 2,
"selected": false,
"text": "<p><code>the_excerpt()</code> won't work on a landing page. It must be used inside the post <a href=\"http://codex.word... | 2012/05/14 | [
"https://wordpress.stackexchange.com/questions/52125",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16126/"
] | I've been trying to utilize the PHP excerpt function to call from her recent blog post to post on a [main landing page](http://www.chazsouthard.com/art/) without avail. Any thoughts?
```
<div id="home_news" class="prefix_9 grid_3">
<div id="newsbox" style="display: block;">
<div id="news">
<h2>... | While this was far from clear in the OP at first, I think this might be a good solution. Just make a shortcode to place the excerpt in the body. (This is a bad idea if you want this on *every page*. This is a good idea if you want it once in a while on some pages in the body.)
Here's code to put in your functions.php:... |
52,143 | <p>I try to get the collapsible-widget-area plugin so that every widget it creates inside the collapsible area has a unique id <code><div></code> after its title.</p>
<pre><code>function get_args() {
$this->args = apply_filters( 'collapsible-widget-area-args', array(
'name' => __( 'Col... | [
{
"answer_id": 52165,
"author": "mrwweb",
"author_id": 9844,
"author_profile": "https://wordpress.stackexchange.com/users/9844",
"pm_score": 3,
"selected": true,
"text": "<p>Looking at <a href=\"http://core.trac.wordpress.org/browser/trunk/wp-includes/widgets.php\" rel=\"nofollow\">widge... | 2012/05/15 | [
"https://wordpress.stackexchange.com/questions/52143",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15642/"
] | I try to get the collapsible-widget-area plugin so that every widget it creates inside the collapsible area has a unique id `<div>` after its title.
```
function get_args() {
$this->args = apply_filters( 'collapsible-widget-area-args', array(
'name' => __( 'Collapsible Widget Area', 'collapsible-w... | Looking at [widget.php in trac](http://core.trac.wordpress.org/browser/trunk/wp-includes/widgets.php) `sprintf()` *only* runs on `before_widget` (Line 884):
```
$params[0]['before_widget'] = sprintf($params[0]['before_widget'], $id, $classname_);
```
Hence, it won't work for any of the other arguments.
I wondered w... |
52,148 | <p>Hello have been looking at this for quite a while and cant seem to resolve it was hoping someone more familiar with the wordpress core and php could share some idea.</p>
<p>What I want to accomplish essentially is to Hide a div that permits buddypress users (the subscrivers) from adding new topics to a group forum.... | [
{
"answer_id": 52146,
"author": "onetrickpony",
"author_id": 1986,
"author_profile": "https://wordpress.stackexchange.com/users/1986",
"pm_score": 4,
"selected": true,
"text": "<p><a href=\"http://queryposts.com/function/wp_get_active_and_valid_plugins/\"><code>wp_get_active_and_valid_pl... | 2012/05/15 | [
"https://wordpress.stackexchange.com/questions/52148",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | Hello have been looking at this for quite a while and cant seem to resolve it was hoping someone more familiar with the wordpress core and php could share some idea.
What I want to accomplish essentially is to Hide a div that permits buddypress users (the subscrivers) from adding new topics to a group forum. But I don... | [`wp_get_active_and_valid_plugins()`](http://queryposts.com/function/wp_get_active_and_valid_plugins/)
[`get_plugins()`](http://codex.wordpress.org/Function_Reference/get_plugins)
and `get_option('active_plugins')` |
52,152 | <p>I have a site that is performance critical. Doing shortcodes I thought about the time the server needs to parse and return the content, instead to allow some HTML (<code><div class="redletter"></code>) to go through the TinyMCE editor. In the meantime, my code for that is:</p>
<pre><code>// [redletter]Content... | [
{
"answer_id": 52504,
"author": "DarkGhostHunter",
"author_id": 16135,
"author_profile": "https://wordpress.stackexchange.com/users/16135",
"pm_score": 1,
"selected": false,
"text": "<p>Well, in terms of performance, I think is always better to avoid any \"postmanipulation\" to the post_... | 2012/05/15 | [
"https://wordpress.stackexchange.com/questions/52152",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16135/"
] | I have a site that is performance critical. Doing shortcodes I thought about the time the server needs to parse and return the content, instead to allow some HTML (`<div class="redletter">`) to go through the TinyMCE editor. In the meantime, my code for that is:
```
// [redletter]Content[/redletter]
add_shortcode('red... | I'd say make the button--but not for performance reasons.
I think if you benchmark it, you'll find that any performance overhead added by running a simple function like this (one that does some simple string concat) is quite minimal. Or, at least, down to *fractions of fractions* of a second on a decent server.
If yo... |
52,178 | <p>I want to highlight the parent of a child page in the menu when the child page itself is not in the menu.</p>
<p>I know this would work if you add the child as a sub page but that isn't the case.</p>
<p>Any ideas?</p>
| [
{
"answer_id": 52179,
"author": "janw",
"author_id": 10911,
"author_profile": "https://wordpress.stackexchange.com/users/10911",
"pm_score": 3,
"selected": true,
"text": "<p>Alrdy got it:</p>\n\n<pre><code><?php //in functions.php\nadd_filter('nav_menu_css_class', 'highlight_portfolio... | 2012/05/15 | [
"https://wordpress.stackexchange.com/questions/52178",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10911/"
] | I want to highlight the parent of a child page in the menu when the child page itself is not in the menu.
I know this would work if you add the child as a sub page but that isn't the case.
Any ideas? | Alrdy got it:
```
<?php //in functions.php
add_filter('nav_menu_css_class', 'highlight_portfolio', 12, 2);
function highlight_portfolio($classes, $item) {
$parent = get_post_ancestors();
$parent_ID = $parent[0];
if ($parent_ID == $item->object_id) {
array_push($classes, 'current-menu-ancestor');
... |
52,186 | <p>When there is no value for parameter "s" , it redirects automatically to homepage.
Instead of this , I want to show all the information from my custom sql query.
how can i do this??</p>
| [
{
"answer_id": 52179,
"author": "janw",
"author_id": 10911,
"author_profile": "https://wordpress.stackexchange.com/users/10911",
"pm_score": 3,
"selected": true,
"text": "<p>Alrdy got it:</p>\n\n<pre><code><?php //in functions.php\nadd_filter('nav_menu_css_class', 'highlight_portfolio... | 2012/05/15 | [
"https://wordpress.stackexchange.com/questions/52186",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11668/"
] | When there is no value for parameter "s" , it redirects automatically to homepage.
Instead of this , I want to show all the information from my custom sql query.
how can i do this?? | Alrdy got it:
```
<?php //in functions.php
add_filter('nav_menu_css_class', 'highlight_portfolio', 12, 2);
function highlight_portfolio($classes, $item) {
$parent = get_post_ancestors();
$parent_ID = $parent[0];
if ($parent_ID == $item->object_id) {
array_push($classes, 'current-menu-ancestor');
... |
52,194 | <p>If I use <code>get_posts()</code> like so I get a number of results with the value 1 for the <code>my_key</code> meta_key:</p>
<pre><code>$posts = get_posts(
array(
'post_type' => 'attachment',
'meta_key' => 'my_key',
'meta_value' => '1'
)
);
//this has a bunch of ... | [
{
"answer_id": 52204,
"author": "mrwweb",
"author_id": 9844,
"author_profile": "https://wordpress.stackexchange.com/users/9844",
"pm_score": 0,
"selected": false,
"text": "<p>I believe your problem is that you're trying to use <code>WP_Query</code> like <code>get_posts()</code>. It seems... | 2012/05/15 | [
"https://wordpress.stackexchange.com/questions/52194",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6811/"
] | If I use `get_posts()` like so I get a number of results with the value 1 for the `my_key` meta\_key:
```
$posts = get_posts(
array(
'post_type' => 'attachment',
'meta_key' => 'my_key',
'meta_value' => '1'
)
);
//this has a bunch of results as expected
print_r($posts);
```
H... | First, just pass your arguments to the constructor of `WP_Query` as this is both cleaner, and the way you're supposed to do it according to the [Codex documentation of the class](http://codex.wordpress.org/Class_Reference/WP_Query).
You should be constructing things like this:
```
$my_key_query_args = array(
'post... |
52,211 | <p>I am adding fields to a custom post type. How can I have editing options in my meta data just as they are in the editor box?</p>
<pre><code> add_action('add_meta_boxes', 'add_property');
function add_property(){
add_meta_box("description-meta", "Property Description", "desc_options", "property", "normal");
}
... | [
{
"answer_id": 52224,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 2,
"selected": true,
"text": "<p>Unfortunately you can't yet...</p>\n\n<p>see this trac ticket: <a href=\"http://core.trac.wordpress.org/ti... | 2012/05/15 | [
"https://wordpress.stackexchange.com/questions/52211",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5416/"
] | I am adding fields to a custom post type. How can I have editing options in my meta data just as they are in the editor box?
```
add_action('add_meta_boxes', 'add_property');
function add_property(){
add_meta_box("description-meta", "Property Description", "desc_options", "property", "normal");
}
function de... | Unfortunately you can't yet...
see this trac ticket: <http://core.trac.wordpress.org/ticket/19173>
In particular it seems that:
>
> The problem is that TinyMCE, once initialized cannot be moved in the DOM, or rather the browsers cannot handle it being moved. That's why the errors are so inconsistent in different br... |
52,235 | <p>I plan on skipping the Posts post type once and for all. This is a brand new portal. It will have 100s of thousands of content in the form of articles, multimedia, and links. Instead of Posts, I will be using a custom post type called "Articles." Similarly, for my video, audio, and picture posts, I will be using ano... | [
{
"answer_id": 52238,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 4,
"selected": true,
"text": "<blockquote>\n <p><strong>1. how do you get rid of the post menu on the admin ui?</strong></p>\n</blockquote>\n\n<p>Simp... | 2012/05/15 | [
"https://wordpress.stackexchange.com/questions/52235",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14967/"
] | I plan on skipping the Posts post type once and for all. This is a brand new portal. It will have 100s of thousands of content in the form of articles, multimedia, and links. Instead of Posts, I will be using a custom post type called "Articles." Similarly, for my video, audio, and picture posts, I will be using anothe... | >
> **1. how do you get rid of the post menu on the admin ui?**
>
>
>
Simple, just un-register the `post` post type. There isn't a default function to do this, but one of the core developers ([Nacin](http://core.trac.wordpress.org/ticket/14761)) posted some sample code on a WP Trac ticket showing how it can be don... |
52,246 | <p>I'm trying to figure out why WP doesn't seem to recognize functions like get_the_post_thumbnail() inside a shortcode loop.</p>
<p>For example, tried adding it to a fresh theme / plugin-less installation. Here's my functions.php:</p>
<pre><code><?php
add_theme_support( 'post-thumbnails' );
function scRecentPho... | [
{
"answer_id": 52266,
"author": "mrwweb",
"author_id": 9844,
"author_profile": "https://wordpress.stackexchange.com/users/9844",
"pm_score": 0,
"selected": false,
"text": "<p>I see the problem now. The first argument is <a href=\"http://codex.wordpress.org/Function_Reference/get_the_post... | 2012/05/15 | [
"https://wordpress.stackexchange.com/questions/52246",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10774/"
] | I'm trying to figure out why WP doesn't seem to recognize functions like get\_the\_post\_thumbnail() inside a shortcode loop.
For example, tried adding it to a fresh theme / plugin-less installation. Here's my functions.php:
```
<?php
add_theme_support( 'post-thumbnails' );
function scRecentPhoto() {
global $post;
... | Found a solution, just had to copy and paste the original functions from the WP core and rename them for functions.php.
Not sure why this workaround worked in this instance for theme options, but it did.
Thanks for all the help everyone. |
52,275 | <p>I have a type of attachments that need full screen display. So, I need to put the comments form somewhere else. How can I tell WP those comments belongs to a post?</p>
| [
{
"answer_id": 57006,
"author": "Diana",
"author_id": 17048,
"author_profile": "https://wordpress.stackexchange.com/users/17048",
"pm_score": -1,
"selected": false,
"text": "<p>What about a tabbed post page, just like reuters.com. You can use pure css or ajax and separate the post conten... | 2012/05/16 | [
"https://wordpress.stackexchange.com/questions/52275",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5210/"
] | I have a type of attachments that need full screen display. So, I need to put the comments form somewhere else. How can I tell WP those comments belongs to a post? | Most starter themes now, like [Twenty Eleven](http://wordpress.org/extend/themes/twentyeleven), come with separate files for each template — for example, `single.php` and `content-single.php` represent the *Single* (Post) template in Twenty Eleven.
The starter theme I use, [Reddle](http://theme.wordpress.com/themes/re... |
52,285 | <p><img src="https://i.stack.imgur.com/ZTsvh.png" alt="enter image description here"></p>
<p><sup>Hierarchical structure of custom post type "Book" (for example).</sup></p>
<p>When we are on <code>Post 2-95</code>, I want to know:</p>
<ul>
<li>Does the post has this post ancestor(<code>Post 1-31</code>)? </li>
<li>D... | [
{
"answer_id": 52290,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 2,
"selected": true,
"text": "<p>Given a post represented by a post object <code>$p</code>, you can find out if post 31 is the parent via:</p>\... | 2012/05/16 | [
"https://wordpress.stackexchange.com/questions/52285",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9934/"
] | 
Hierarchical structure of custom post type "Book" (for example).
When we are on `Post 2-95`, I want to know:
* Does the post has this post ancestor(`Post 1-31`)?
* Does it have child posts(`Post 3-19`, `Post 3-10`)?
Then, if it has:
* an ancestor... | Given a post represented by a post object `$p`, you can find out if post 31 is the parent via:
```
if($p->post_parent == 31){
// it is!
} else {
// it isn't
}
```
To figure out the children, something like:
```
$posts = get_posts(array(
'post_parent' => $p->ID,
'post_type' => $p->post_type
));
// ... |
52,298 | <p>I recently setup a WordPress multisite install using subdomains and the WordPress MU domain mapping plugin.</p>
<p>When I initially setup the domain mapping plugin, I set the root (http://domain.com) and <a href="http://www.domain.com" rel="nofollow">http://www.domain.com</a> to redirect to blog ID 2 (ie. www.domai... | [
{
"answer_id": 52994,
"author": "chrisguitarguy",
"author_id": 6035,
"author_profile": "https://wordpress.stackexchange.com/users/6035",
"pm_score": 2,
"selected": true,
"text": "<p>I was in a similar situation recently. I ended up putting the root site on a random subdomain (eg <code>ms... | 2012/05/16 | [
"https://wordpress.stackexchange.com/questions/52298",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/578/"
] | I recently setup a WordPress multisite install using subdomains and the WordPress MU domain mapping plugin.
When I initially setup the domain mapping plugin, I set the root (http://domain.com) and <http://www.domain.com> to redirect to blog ID 2 (ie. www.domain.com). However, when I do this the redirect on the root pr... | I was in a similar situation recently. I ended up putting the root site on a random subdomain (eg `ms.domain.com`) With the intention of never using the root site.
With that done, I created a plugin to activate only on the main (root) site.
The plugin hooks into a action that fires only on the front end (`template_re... |
52,300 | <p>I have the following code in my plugin main file :</p>
<pre><code>function my_function() {
?>
<script type="text/javascript">
jQuery(function () {
alert('jQuery');
});
</script>
<?php
}
add_action("wp_footer", "my_function");
</code></pre>
<p>My website does have jQuery loade... | [
{
"answer_id": 52304,
"author": "onetrickpony",
"author_id": 1986,
"author_profile": "https://wordpress.stackexchange.com/users/1986",
"pm_score": 1,
"selected": false,
"text": "<p>Because you just defined a function there. You didn't execute it or attached it to some event, to be execut... | 2012/05/16 | [
"https://wordpress.stackexchange.com/questions/52300",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11634/"
] | I have the following code in my plugin main file :
```
function my_function() {
?>
<script type="text/javascript">
jQuery(function () {
alert('jQuery');
});
</script>
<?php
}
add_action("wp_footer", "my_function");
```
My website does have jQuery loaded and operational (lots of features on my pa... | That snippet 'works' for me.
Is the script being printed at the bottom of the page? More specifically, does your theme call [`wp_footer`](http://codex.wordpress.org/Function_Reference/wp_footer). All themes should, but not all themes do call `wp_footer` which breaks plugins which rely on it.
For the record - you shou... |
52,302 | <p>Is it possible to remove the username field from the registration page?</p>
<p>I want the users to enter only their email and password.<br />
A new user should be created based on these two parameters only.</p>
<p>Is that possible and if so, how?</p>
| [
{
"answer_id": 102695,
"author": "Matt Keys",
"author_id": 32799,
"author_profile": "https://wordpress.stackexchange.com/users/32799",
"pm_score": 1,
"selected": false,
"text": "<p>I think any solution to this request is going to be a 'hack' as wordpress requires that there be a username... | 2012/05/16 | [
"https://wordpress.stackexchange.com/questions/52302",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9432/"
] | Is it possible to remove the username field from the registration page?
I want the users to enter only their email and password.
A new user should be created based on these two parameters only.
Is that possible and if so, how? | **Absolutely *YES***, you can achieve this.
**Rule 1:** WordPress requires a username. We must provide a username.
**Rule 2:** Don't edit WordPress core code.
We can achieve this by hiding username field, get email and store it as username.
**Step-1: Remove Username textfield**
```
add_action('login_head', functi... |
52,315 | <p>I'm making a widget that shows a set of images from recent custom posts. I want to run the following query:</p>
<pre><code>SELECT p.*
FROM wp_posts p
WHERE post_type='attachment'
AND post_mime_type LIKE 'image%'
AND post_parent IN (
SELECT ID
FROM wp_posts
WHERE post_type ='my_custom_post_type'
)
ORDER BY po... | [
{
"answer_id": 52325,
"author": "mrwweb",
"author_id": 9844,
"author_profile": "https://wordpress.stackexchange.com/users/9844",
"pm_score": 2,
"selected": false,
"text": "<p>What I recommend is one instance of <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query\" rel=\"nofollo... | 2012/05/16 | [
"https://wordpress.stackexchange.com/questions/52315",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3644/"
] | I'm making a widget that shows a set of images from recent custom posts. I want to run the following query:
```
SELECT p.*
FROM wp_posts p
WHERE post_type='attachment'
AND post_mime_type LIKE 'image%'
AND post_parent IN (
SELECT ID
FROM wp_posts
WHERE post_type ='my_custom_post_type'
)
ORDER BY post_date DESC
L... | It seems like a bit of a waste to run through two loops just to use some built in API functions that weren't designed for a use case like this.
I think you're better off to use your SQL combined with the [wpdb](http://codex.wordpress.org/Class_Reference/wpdb) class -- faster and cleaner.
Example (with modified SQL):
... |
52,323 | <p>We are using a jQuery UI accordian to render a menu in the sidebar. We've already written the markup and javascript and I am just trying to get the wp_nav_menu to output the same markup we've already written. I am creating a custom Walker Class extending Walker_Nav_Menu.</p>
<p>Here is the markup we are going for</... | [
{
"answer_id": 52329,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 4,
"selected": true,
"text": "<p>The easiest way is to extend the <code>Walker_Nav_Menu</code> class rather than the <code>Walker_Class</co... | 2012/05/16 | [
"https://wordpress.stackexchange.com/questions/52323",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/496/"
] | We are using a jQuery UI accordian to render a menu in the sidebar. We've already written the markup and javascript and I am just trying to get the wp\_nav\_menu to output the same markup we've already written. I am creating a custom Walker Class extending Walker\_Nav\_Menu.
Here is the markup we are going for
```
<h... | The easiest way is to extend the `Walker_Nav_Menu` class rather than the `Walker_Class`, (as the parent / ID fields are set and often you want to maintain some of the mark-up etc).
The main methods are:
* `start_el` / `end_el` - responsible for displaying an element in a list
* `start_lvl` / `end_lvl` - responsible ... |
52,339 | <p>I'm customizing a theme for a client and I want to leverage post formats.</p>
<p>On the quote post format I would like</p>
<pre><code>the_content();
</code></pre>
<p>to be wrapped in a two spans that contains quotation marks that I could style and position. Is this possible?</p>
<p>Thanks.</p>
| [
{
"answer_id": 52341,
"author": "Sisir",
"author_id": 3094,
"author_profile": "https://wordpress.stackexchange.com/users/3094",
"pm_score": 2,
"selected": true,
"text": "<p><strong>Try</strong> </p>\n\n<pre><code>$content = get_the_content();\n$content = '<span>\"</span>'.$co... | 2012/05/16 | [
"https://wordpress.stackexchange.com/questions/52339",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8678/"
] | I'm customizing a theme for a client and I want to leverage post formats.
On the quote post format I would like
```
the_content();
```
to be wrapped in a two spans that contains quotation marks that I could style and position. Is this possible?
Thanks. | **Try**
```
$content = get_the_content();
$content = '<span>"</span>'.$content.'<span>"</span>';
echo apply_filters('the_content', $content);
```
**CSS Solution:**
```
<blockquote>
<?php the_content(); ?>
</blockquote>
blockquote:before{
content: '"';
}
blockquote:after{
content: '"';
}
``` |
52,352 | <p>I have my awesome <a href="http://thestuffedpepper.ca/wp/" rel="nofollow">wordpress website here</a> that I have been working on for weeks now and all is great with it except for one thing! For some reason when you try to look at the <a href="http://thestuffedpepper.ca/wp/2012/03" rel="nofollow">archives pages</a> t... | [
{
"answer_id": 52341,
"author": "Sisir",
"author_id": 3094,
"author_profile": "https://wordpress.stackexchange.com/users/3094",
"pm_score": 2,
"selected": true,
"text": "<p><strong>Try</strong> </p>\n\n<pre><code>$content = get_the_content();\n$content = '<span>\"</span>'.$co... | 2012/05/16 | [
"https://wordpress.stackexchange.com/questions/52352",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25108/"
] | I have my awesome [wordpress website here](http://thestuffedpepper.ca/wp/) that I have been working on for weeks now and all is great with it except for one thing! For some reason when you try to look at the [archives pages](http://thestuffedpepper.ca/wp/2012/03) the whole page's font gets smaller. I mean, any navigati... | **Try**
```
$content = get_the_content();
$content = '<span>"</span>'.$content.'<span>"</span>';
echo apply_filters('the_content', $content);
```
**CSS Solution:**
```
<blockquote>
<?php the_content(); ?>
</blockquote>
blockquote:before{
content: '"';
}
blockquote:after{
content: '"';
}
``` |
52,356 | <p>I am trying to add a filter on my custom theme based on post month, similar with the archives but with some differences.</p>
<p>What is the best way to get a list of months in witch we have posts?</p>
<p>Thanks,
Alex</p>
<p>I used the following query:</p>
<pre><code> $wpdb->get_results("SELECT DISTINCT YEAR(p... | [
{
"answer_id": 52438,
"author": "Michael Ecklund",
"author_id": 9579,
"author_profile": "https://wordpress.stackexchange.com/users/9579",
"pm_score": 1,
"selected": false,
"text": "<p>Try <a href=\"http://codex.wordpress.org/Function_Reference/wp_get_archives\" rel=\"nofollow\">wp_get_ar... | 2012/05/16 | [
"https://wordpress.stackexchange.com/questions/52356",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13375/"
] | I am trying to add a filter on my custom theme based on post month, similar with the archives but with some differences.
What is the best way to get a list of months in witch we have posts?
Thanks,
Alex
I used the following query:
```
$wpdb->get_results("SELECT DISTINCT YEAR(post_date) AS `year`, MONTH(post_date) ... | Core can't help you here. You'll have to do a…
Custom Query
------------
Here's a save query, that I use on admin UI screens to get the total amounts of month with posts to use them in the custom pagination. Pay attention that I query not only for the published posts, but take into consideration that there might be s... |
52,402 | <p>I've set some meta variables on my WP posts. I want to be able to sort by these variables, and everything is working great except when I sort by either "views" or "likes". When I sort by either of those two fields, WP doesn't generate my nav (wp_nav_menu).</p>
<p>I've tried "resetting" the $wp_query variable surrou... | [
{
"answer_id": 52408,
"author": "helenhousandi",
"author_id": 2226,
"author_profile": "https://wordpress.stackexchange.com/users/2226",
"pm_score": 5,
"selected": true,
"text": "<p>Nav menus are also generated by a WP_Query, so in your <code>pre_get_posts</code> callback function you nee... | 2012/05/17 | [
"https://wordpress.stackexchange.com/questions/52402",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16201/"
] | I've set some meta variables on my WP posts. I want to be able to sort by these variables, and everything is working great except when I sort by either "views" or "likes". When I sort by either of those two fields, WP doesn't generate my nav (wp\_nav\_menu).
I've tried "resetting" the $wp\_query variable surrounding m... | Nav menus are also generated by a WP\_Query, so in your `pre_get_posts` callback function you need to check if the `$query` you're altering is the main query. The easiest way to do this would probably be to do this right at the beginning of the function:
```
if ( ! $query->is_main_query() )
return $query;
```
Al... |
52,405 | <p>This is really weird. In attempting to solve <a href="https://wordpress.stackexchange.com/q/52340/7890">this problem</a> i ended up with an almost perfect use of paginate_links() instead of a custom pagination function:</p>
<pre><code>$myquery = new WP_Query($args);
$paged = get_query_var('page');
($paged == 0 ? $... | [
{
"answer_id": 52443,
"author": "jmdodd",
"author_id": 11521,
"author_profile": "https://wordpress.stackexchange.com/users/11521",
"pm_score": 3,
"selected": true,
"text": "<p>Have you tried specifying the <code>base</code> and <code>format</code> arguments for <code>paginate_links()</co... | 2012/05/17 | [
"https://wordpress.stackexchange.com/questions/52405",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7890/"
] | This is really weird. In attempting to solve [this problem](https://wordpress.stackexchange.com/q/52340/7890) i ended up with an almost perfect use of paginate\_links() instead of a custom pagination function:
```
$myquery = new WP_Query($args);
$paged = get_query_var('page');
($paged == 0 ? $paged = 1 : $paged = $pa... | Have you tried specifying the `base` and `format` arguments for `paginate_links()`? It assumes the default values of:
```
'base' => '%_%',
'format' => '?page=%#%',
```
Your `base` should be something like `/parent-page/child-page/%_%`; then the first page link will be to `/parent-page/child-page/`, and ... |
52,412 | <p>What plugin you would recommend that would give powerful Admin UI options such as change Add Posts menu item to Add Articles, remove Add Media option for certain user roles and not allowing certain user roles to create Tags etc.</p>
<p>I'm not talking about those plugins that lets you do client logo instead of Word... | [
{
"answer_id": 52443,
"author": "jmdodd",
"author_id": 11521,
"author_profile": "https://wordpress.stackexchange.com/users/11521",
"pm_score": 3,
"selected": true,
"text": "<p>Have you tried specifying the <code>base</code> and <code>format</code> arguments for <code>paginate_links()</co... | 2012/05/17 | [
"https://wordpress.stackexchange.com/questions/52412",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14967/"
] | What plugin you would recommend that would give powerful Admin UI options such as change Add Posts menu item to Add Articles, remove Add Media option for certain user roles and not allowing certain user roles to create Tags etc.
I'm not talking about those plugins that lets you do client logo instead of Wordpress logo... | Have you tried specifying the `base` and `format` arguments for `paginate_links()`? It assumes the default values of:
```
'base' => '%_%',
'format' => '?page=%#%',
```
Your `base` should be something like `/parent-page/child-page/%_%`; then the first page link will be to `/parent-page/child-page/`, and ... |
52,447 | <pre><code>function hotlinkers_wp_query($query) {
if ( !$query->is_admin && $query->is_search) {
$search_query = str_replace('-',' ', $query->query_vars['s']);
$query->set('s', $search_query);
}
return $query;
}
add_action('pre_get_posts', 'hotlinkers_wp_quer... | [
{
"answer_id": 52443,
"author": "jmdodd",
"author_id": 11521,
"author_profile": "https://wordpress.stackexchange.com/users/11521",
"pm_score": 3,
"selected": true,
"text": "<p>Have you tried specifying the <code>base</code> and <code>format</code> arguments for <code>paginate_links()</co... | 2012/05/17 | [
"https://wordpress.stackexchange.com/questions/52447",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70/"
] | ```
function hotlinkers_wp_query($query) {
if ( !$query->is_admin && $query->is_search) {
$search_query = str_replace('-',' ', $query->query_vars['s']);
$query->set('s', $search_query);
}
return $query;
}
add_action('pre_get_posts', 'hotlinkers_wp_query');
```
this is for the ... | Have you tried specifying the `base` and `format` arguments for `paginate_links()`? It assumes the default values of:
```
'base' => '%_%',
'format' => '?page=%#%',
```
Your `base` should be something like `/parent-page/child-page/%_%`; then the first page link will be to `/parent-page/child-page/`, and ... |
52,451 | <p>I am creating a widget plugin that a user could potentially use multiple iterations of the widget multiple times on a single widget-area / multiple widget-areas on a single page. Because of its functionality there will be differing widget-level variables that I will need to individually pass from PHP to JavaScript t... | [
{
"answer_id": 52454,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 0,
"selected": false,
"text": "<p><code>wp_enqueue_scripts</code> has already happened. enqueue the script directly in your widget function and outpu... | 2012/05/17 | [
"https://wordpress.stackexchange.com/questions/52451",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8756/"
] | I am creating a widget plugin that a user could potentially use multiple iterations of the widget multiple times on a single widget-area / multiple widget-areas on a single page. Because of its functionality there will be differing widget-level variables that I will need to individually pass from PHP to JavaScript to t... | **It's not true that you have to use `wp_localize_script` before the wp\_head**.
Since 3.3 you can use `wp_enqueue_script` in the body of the document (i.e. in a widget or shortcode callback) and the script is loaded in the *footer*.
Here's a skeleton class I've used for adding variables for each instance of a widget... |
52,452 | <p>I'm getting nags on google speed test regarding the querystrings in my scripts. So, I'm trying to remove them by passing false as the argument for that parameter. However, it does not seem to have effect:</p>
<pre><code>wp_register_script('myscript', get_bloginfo('template_directory').'/scripts.myversionnumber.js',... | [
{
"answer_id": 52457,
"author": "SickHippie",
"author_id": 5434,
"author_profile": "https://wordpress.stackexchange.com/users/5434",
"pm_score": 5,
"selected": true,
"text": "<p>I think you have to pass NULL as the 4th parameter.</p>\n\n<pre><code>wp_register_script(\n 'myscript',\n ... | 2012/05/17 | [
"https://wordpress.stackexchange.com/questions/52452",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/366/"
] | I'm getting nags on google speed test regarding the querystrings in my scripts. So, I'm trying to remove them by passing false as the argument for that parameter. However, it does not seem to have effect:
```
wp_register_script('myscript', get_bloginfo('template_directory').'/scripts.myversionnumber.js',false,false,tr... | I think you have to pass NULL as the 4th parameter.
```
wp_register_script(
'myscript',
get_bloginfo('template_directory').'/scripts.myversionnumber.js',
false,
NULL,
true);
wp_enqueue_script('myscript');
``` |
52,455 | <p>I've got a front end post editing page located at mysite/post_id/edit and am trying to redirect users that are not the author back to the post. Here's the code I'm working with:</p>
<pre><code> <?php
global $current_user; get_currentuserinfo();
if($post->post_author != $current_user->ID):
wp... | [
{
"answer_id": 52462,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 5,
"selected": true,
"text": "<p>Once you're in the template it's too late, as headers have already been sent. You have to hook earlier in the reques... | 2012/05/17 | [
"https://wordpress.stackexchange.com/questions/52455",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5019/"
] | I've got a front end post editing page located at mysite/post\_id/edit and am trying to redirect users that are not the author back to the post. Here's the code I'm working with:
```
<?php
global $current_user; get_currentuserinfo();
if($post->post_author != $current_user->ID):
wp_redirect( the_permali... | Once you're in the template it's too late, as headers have already been sent. You have to hook earlier in the request to check, like the template redirect hook:
```
add_action( 'template_redirect', 'wpse52455_redirect' );
function wpse52455_redirect(){
// do your check and call wp_redirect here
}
```
Note that ... |
52,456 | <p>How can I count words in a post? Something like the one displayed just below the post?</p>
<p>Can someone please show me the code for getting this. I have been searching everywhere.</p>
| [
{
"answer_id": 52459,
"author": "SickHippie",
"author_id": 5434,
"author_profile": "https://wordpress.stackexchange.com/users/5434",
"pm_score": 4,
"selected": true,
"text": "<p>How hard did you search? I searched Google for \"wordpress count words in post\" and found a function for it ... | 2012/05/17 | [
"https://wordpress.stackexchange.com/questions/52456",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12918/"
] | How can I count words in a post? Something like the one displayed just below the post?
Can someone please show me the code for getting this. I have been searching everywhere. | How hard did you search? I searched Google for "wordpress count words in post" and found a function for it in the first result!
Put this in `functions.php`:
```
function prefix_wcount(){
ob_start();
the_content();
$content = ob_get_clean();
return sizeof(explode(" ", $content));
}
```
Then call it i... |
52,464 | <p>Since I won't be using the built-in links feature of wordpress, I see no reason in keeping its related menu items on the admin ui causing nothing but clutter. </p>
<p>How do I do that?</p>
| [
{
"answer_id": 52459,
"author": "SickHippie",
"author_id": 5434,
"author_profile": "https://wordpress.stackexchange.com/users/5434",
"pm_score": 4,
"selected": true,
"text": "<p>How hard did you search? I searched Google for \"wordpress count words in post\" and found a function for it ... | 2012/05/17 | [
"https://wordpress.stackexchange.com/questions/52464",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14967/"
] | Since I won't be using the built-in links feature of wordpress, I see no reason in keeping its related menu items on the admin ui causing nothing but clutter.
How do I do that? | How hard did you search? I searched Google for "wordpress count words in post" and found a function for it in the first result!
Put this in `functions.php`:
```
function prefix_wcount(){
ob_start();
the_content();
$content = ob_get_clean();
return sizeof(explode(" ", $content));
}
```
Then call it i... |
52,471 | <p>I want all my posts to have /ARTICLES/%post-name% structure. </p>
<p>But as soon as I modify the custom structure to that, for a reason that beats me, wordpress adds the <code>articles</code> prefix across the board. </p>
<p>So I end up with urls like this for my category pages with something like the following</p... | [
{
"answer_id": 52474,
"author": "Michael Ecklund",
"author_id": 9579,
"author_profile": "https://wordpress.stackexchange.com/users/9579",
"pm_score": 1,
"selected": false,
"text": "<p>The <a href=\"http://yoast.com/wordpress/seo/\" rel=\"nofollow\">WordPress SEO Plugin by Yoast</a> has a... | 2012/05/17 | [
"https://wordpress.stackexchange.com/questions/52471",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14967/"
] | I want all my posts to have /ARTICLES/%post-name% structure.
But as soon as I modify the custom structure to that, for a reason that beats me, wordpress adds the `articles` prefix across the board.
So I end up with urls like this for my category pages with something like the following
`mysite.com/articles/category... | 1) Add this rewrite at the end of you `function.php`
```
function add_rewrite_rules( $wp_rewrite )
{
$new_rules = array(
'YOUR_PREFIX/(.+?)/?$' => 'index.php?post_type=post&name='. $wp_rewrite->preg_index(1),
);
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
add_action('generate_rewrite_... |
52,475 | <p>My theme is currently activated and showing only the background image and the "home" link. I believe the issue lies within header.php, but I can't quite figure out what. Any ideas? (Also, is there a php validator I could run my code through, or would a WP theme's code be too WP specific?)</p>
<pre><code><!DOCTYP... | [
{
"answer_id": 52474,
"author": "Michael Ecklund",
"author_id": 9579,
"author_profile": "https://wordpress.stackexchange.com/users/9579",
"pm_score": 1,
"selected": false,
"text": "<p>The <a href=\"http://yoast.com/wordpress/seo/\" rel=\"nofollow\">WordPress SEO Plugin by Yoast</a> has a... | 2012/05/17 | [
"https://wordpress.stackexchange.com/questions/52475",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14606/"
] | My theme is currently activated and showing only the background image and the "home" link. I believe the issue lies within header.php, but I can't quite figure out what. Any ideas? (Also, is there a php validator I could run my code through, or would a WP theme's code be too WP specific?)
```
<!DOCTYPE html>
<html>
<... | 1) Add this rewrite at the end of you `function.php`
```
function add_rewrite_rules( $wp_rewrite )
{
$new_rules = array(
'YOUR_PREFIX/(.+?)/?$' => 'index.php?post_type=post&name='. $wp_rewrite->preg_index(1),
);
$wp_rewrite->rules = $new_rules + $wp_rewrite->rules;
}
add_action('generate_rewrite_... |
52,480 | <p>I was reading <a href="https://wordpress.stackexchange.com/users/9364/stephen-harris">Stephen Harris</a>'s excellent answer to <a href="https://wordpress.stackexchange.com/questions/50761/when-to-use-wp-query-query-posts-and-pre-get-posts?newsletter=1&nlcode=66447%7C9502">this question</a> regarding the use of <... | [
{
"answer_id": 52482,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 6,
"selected": true,
"text": "<p>The simplest way is to add the action right before the query and <a href=\"http://codex.wordpress.org/Function_Refer... | 2012/05/17 | [
"https://wordpress.stackexchange.com/questions/52480",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14170/"
] | I was reading [Stephen Harris](https://wordpress.stackexchange.com/users/9364/stephen-harris)'s excellent answer to [this question](https://wordpress.stackexchange.com/questions/50761/when-to-use-wp-query-query-posts-and-pre-get-posts?newsletter=1&nlcode=66447%7C9502) regarding the use of `WP_query()`, `query_posts()` ... | The simplest way is to add the action right before the query and [remove it](http://codex.wordpress.org/Function_Reference/remove_action) immediately after.
```
add_action('pre_get_posts', 'some_function_in_functionsphp');
$my_secondary_loop = new WP_Query(...);
remove_action('pre_get_posts', 'some_function_in_functio... |
52,486 | <p>There have been some recent additions to the WordPress.org plugin repository. Most notably the changes to the plugin page and the author profile page which now shows an <a href="http://profiles.wordpress.org/c3mdigital" rel="nofollow">authors favorite plugins</a>.</p>
<p>I want to create a sidebar widget plugin th... | [
{
"answer_id": 52482,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 6,
"selected": true,
"text": "<p>The simplest way is to add the action right before the query and <a href=\"http://codex.wordpress.org/Function_Refer... | 2012/05/17 | [
"https://wordpress.stackexchange.com/questions/52486",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/251/"
] | There have been some recent additions to the WordPress.org plugin repository. Most notably the changes to the plugin page and the author profile page which now shows an [authors favorite plugins](http://profiles.wordpress.org/c3mdigital).
I want to create a sidebar widget plugin that shows a plugin authors favorites. ... | The simplest way is to add the action right before the query and [remove it](http://codex.wordpress.org/Function_Reference/remove_action) immediately after.
```
add_action('pre_get_posts', 'some_function_in_functionsphp');
$my_secondary_loop = new WP_Query(...);
remove_action('pre_get_posts', 'some_function_in_functio... |
52,489 | <p>I am using wordpress 3.2 and I did a query post like this:</p>
<pre><code><?php query_posts("posts_per_page=1post=type&page=post_parent=10");?>
</code></pre>
<p>Then I try to echo out the date of this post I queried like this.</p>
<pre><code><?php echo the_date(); ?>
</code></pre>
<p>It gives me ... | [
{
"answer_id": 52490,
"author": "Kristian",
"author_id": 8639,
"author_profile": "https://wordpress.stackexchange.com/users/8639",
"pm_score": 0,
"selected": false,
"text": "<p>I think that is meant to be run within the <code>while( have_posts() )</code> conditional:</p>\n\n<pre><code>wh... | 2012/05/17 | [
"https://wordpress.stackexchange.com/questions/52489",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16225/"
] | I am using wordpress 3.2 and I did a query post like this:
```
<?php query_posts("posts_per_page=1post=type&page=post_parent=10");?>
```
Then I try to echo out the date of this post I queried like this.
```
<?php echo the_date(); ?>
```
It gives me the title of the post and the excerpt and the permalink but no da... | See this [special note about using the `the\_date'](http://codex.wordpress.org/Function_Reference/the_date)
>
> SPECIAL NOTE: When there are multiple posts on a page published under
> the SAME DAY, the\_date() only displays the date for the first post
> (that is, the first instance of the\_date()). To repeat the da... |
52,555 | <p>I have a custom notification function for our comments editor, who prefers to have all comments from one article threaded together in her email client. To achieve this, I'm creating a custom message-ID for the first comment on an article, then setting that as the In-Reply-To for future comment notifications. </p>
<... | [
{
"answer_id": 52566,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": false,
"text": "<p>You can filter the <code>$phpmailer</code> object. Something like this should do the trick (not tested):</p>\n\n<pre><... | 2012/05/18 | [
"https://wordpress.stackexchange.com/questions/52555",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5907/"
] | I have a custom notification function for our comments editor, who prefers to have all comments from one article threaded together in her email client. To achieve this, I'm creating a custom message-ID for the first comment on an article, then setting that as the In-Reply-To for future comment notifications.
This is ... | You can filter the `$phpmailer` object. Something like this should do the trick (not tested):
```
add_action( 'phpmailer_init', 'wpse_52555_msg_id' );
function wpse_52555_msg_id( &$phpmailer )
{
$msg_id = get_post_meta( get_the_ID(), 'messageID', TRUE );
'' !== $msg_id and $phpmailer->MessageID = $msg_id . '@... |
52,565 | <p>My theme currently has a single menu on the left hand sidebar of WP admin. I want to include submenus on that menu. </p>
<p>How can I add, for example, a single submenu item to the "Theme Options" menu below?</p>
<pre><code>add_menu_page(
"My Theme Options",
"Theme Options",
'edit_themes',
basen... | [
{
"answer_id": 52566,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": false,
"text": "<p>You can filter the <code>$phpmailer</code> object. Something like this should do the trick (not tested):</p>\n\n<pre><... | 2012/05/18 | [
"https://wordpress.stackexchange.com/questions/52565",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6620/"
] | My theme currently has a single menu on the left hand sidebar of WP admin. I want to include submenus on that menu.
How can I add, for example, a single submenu item to the "Theme Options" menu below?
```
add_menu_page(
"My Theme Options",
"Theme Options",
'edit_themes',
basename(__FILE__),
'... | You can filter the `$phpmailer` object. Something like this should do the trick (not tested):
```
add_action( 'phpmailer_init', 'wpse_52555_msg_id' );
function wpse_52555_msg_id( &$phpmailer )
{
$msg_id = get_post_meta( get_the_ID(), 'messageID', TRUE );
'' !== $msg_id and $phpmailer->MessageID = $msg_id . '@... |
52,578 | <p>I've got two taxonomies: "type of guide", and "tools".</p>
<p>They look something like this: </p>
<p><strong>Type of guide</strong></p>
<pre><code>- Article
- Video
- Cheat sheet
</code></pre>
<p><strong>Tool</strong></p>
<p>— Learning Management System</p>
<ul>
<li><p>Quiz Tool</p>
<pre><code>- Hide a grade... | [
{
"answer_id": 52584,
"author": "Michael Ecklund",
"author_id": 9579,
"author_profile": "https://wordpress.stackexchange.com/users/9579",
"pm_score": 0,
"selected": false,
"text": "<p>This should get all post data for the taxonomy \"Tool\" with term \"Quiz Tool\".</p>\n\n<pre><code>$post... | 2012/05/18 | [
"https://wordpress.stackexchange.com/questions/52578",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3877/"
] | I've got two taxonomies: "type of guide", and "tools".
They look something like this:
**Type of guide**
```
- Article
- Video
- Cheat sheet
```
**Tool**
— Learning Management System
* Quiz Tool
```
- Hide a grades column (article)
- Creating a Gradebook (article)
- Long Answer Question Steps (article)
- Matchi... | This helper function will return the ID of the term you are currently viewing (from *any* taxonomy - you can limit just to a specific taxonomy, or the built-in tag and category taxonomies).
It will return false if you are not on a taxonomy term archive page.
```
function wpse52578_get_current_term_id(){
if( !is_t... |
52,580 | <p>I have a problem.</p>
<p>I'm using a custom shortcode to try to get the url. If the shortcode is inside a post then it gets the post url. When I open the post on a category list, this post shortcode works correctly.</p>
<pre><code>extract(shortcode_atts(array(
'gurl' => get_permalink(),
), $atts));
</code>... | [
{
"answer_id": 52584,
"author": "Michael Ecklund",
"author_id": 9579,
"author_profile": "https://wordpress.stackexchange.com/users/9579",
"pm_score": 0,
"selected": false,
"text": "<p>This should get all post data for the taxonomy \"Tool\" with term \"Quiz Tool\".</p>\n\n<pre><code>$post... | 2012/05/18 | [
"https://wordpress.stackexchange.com/questions/52580",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16173/"
] | I have a problem.
I'm using a custom shortcode to try to get the url. If the shortcode is inside a post then it gets the post url. When I open the post on a category list, this post shortcode works correctly.
```
extract(shortcode_atts(array(
'gurl' => get_permalink(),
), $atts));
```
But when i try to add thi... | This helper function will return the ID of the term you are currently viewing (from *any* taxonomy - you can limit just to a specific taxonomy, or the built-in tag and category taxonomies).
It will return false if you are not on a taxonomy term archive page.
```
function wpse52578_get_current_term_id(){
if( !is_t... |
52,582 | <p>I am posting Word generated HTML to WordPress via XMLRPC. Before I go to post.php, the format is correctly preserved in the database. TinyMCE performs its magic and I lose quite a few formatting details.<br>
The main issue i am seeing is that <code><span></code> tag with style information surrounding other e... | [
{
"answer_id": 52988,
"author": "SickHippie",
"author_id": 5434,
"author_profile": "https://wordpress.stackexchange.com/users/5434",
"pm_score": 2,
"selected": false,
"text": "<p>I almost always use the <a href=\"http://wordpress.org/extend/plugins/tinymce-advanced\" rel=\"nofollow\">Tin... | 2012/05/18 | [
"https://wordpress.stackexchange.com/questions/52582",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12388/"
] | I am posting Word generated HTML to WordPress via XMLRPC. Before I go to post.php, the format is correctly preserved in the database. TinyMCE performs its magic and I lose quite a few formatting details.
The main issue i am seeing is that `<span>` tag with style information surrounding other elements are stripped ou... | I couldn't find the `extended_valid_elements` option in the settings panel for TinyMCE advanced, but adding the following to my `functions.php` solved it:
```
function override_mce_options($initArray) {
$opts = '*[*]';
$initArray['valid_elements'] = $opts;
$initArray['extended_valid_elements'] = $opts;
... |
52,585 | <p>I have created some custom fields with Advanced Custom Fields and set them to appear in my custom post type named X (post type is equal to X). </p>
<p>But I only need them to display on a particular single page from this custom post type, not on all of them.</p>
<p>How would I do that?</p>
| [
{
"answer_id": 52615,
"author": "ltfishie",
"author_id": 12388,
"author_profile": "https://wordpress.stackexchange.com/users/12388",
"pm_score": 3,
"selected": true,
"text": "<p>Couldn't you do this through ACF settings page? You can select Post and set it equal to the title.</p>\n\n<p>... | 2012/05/18 | [
"https://wordpress.stackexchange.com/questions/52585",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9718/"
] | I have created some custom fields with Advanced Custom Fields and set them to appear in my custom post type named X (post type is equal to X).
But I only need them to display on a particular single page from this custom post type, not on all of them.
How would I do that? | Couldn't you do this through ACF settings page? You can select Post and set it equal to the title.
**Edit**
Updated image for clarification

**Edit 2**
It turns out ACF does not query for custom type when display the title drop down. To include al... |
52,586 | <p>Could someone tell me how i could make this work? i have a loop, and i would like to create another loop to find the other posts from the same category : but this does not work :</p>
<pre><code><?php while ( have_posts() ) : the_post(); ?>
<?php /* How to display all other posts. */ ?>
... | [
{
"answer_id": 52587,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://queryposts.com/function/the_id/\" rel=\"nofollow\"><code>the_ID()</code></a> prints the ... | 2012/05/18 | [
"https://wordpress.stackexchange.com/questions/52586",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8432/"
] | Could someone tell me how i could make this work? i have a loop, and i would like to create another loop to find the other posts from the same category : but this does not work :
```
<?php while ( have_posts() ) : the_post(); ?>
<?php /* How to display all other posts. */ ?>
<?php
... | Okay, it works like that :
```
<?php while ( have_posts() ) : the_post(); ?>
<?php
$cats = get_the_category();
$cat_obj = array_shift($cats);
var_dump($cat_obj);
$cat_id = (int) $cat_obj->cat_ID;
$qq... |
52,590 | <p>Well, I think the question might be a bit confusing. But well, I want to get the recent 4 posts, ignoring the first five recent posts. So in short the sixth, seventh, eighth and ninth - most recent posts.</p>
| [
{
"answer_id": 52587,
"author": "Stephen Harris",
"author_id": 9364,
"author_profile": "https://wordpress.stackexchange.com/users/9364",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://queryposts.com/function/the_id/\" rel=\"nofollow\"><code>the_ID()</code></a> prints the ... | 2012/05/18 | [
"https://wordpress.stackexchange.com/questions/52590",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11764/"
] | Well, I think the question might be a bit confusing. But well, I want to get the recent 4 posts, ignoring the first five recent posts. So in short the sixth, seventh, eighth and ninth - most recent posts. | Okay, it works like that :
```
<?php while ( have_posts() ) : the_post(); ?>
<?php
$cats = get_the_category();
$cat_obj = array_shift($cats);
var_dump($cat_obj);
$cat_id = (int) $cat_obj->cat_ID;
$qq... |
52,592 | <p>I want to use the following code</p>
<pre><code>the_time('d. F Y', '<p class="article-date">', '</p>');
</code></pre>
<p>to show the date of an article (post) wrapped within <code><p></p></code>. I also tried</p>
<pre><code> echo '<p class="article-date">' . the_time('d. F Y') . '&l... | [
{
"answer_id": 52595,
"author": "mor7ifer",
"author_id": 11740,
"author_profile": "https://wordpress.stackexchange.com/users/11740",
"pm_score": 4,
"selected": true,
"text": "<pre><code><p>\n <?php the_time() ?>\n</p>\n</code></pre>\n\n<p>It helps with separation of ... | 2012/05/18 | [
"https://wordpress.stackexchange.com/questions/52592",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13921/"
] | I want to use the following code
```
the_time('d. F Y', '<p class="article-date">', '</p>');
```
to show the date of an article (post) wrapped within `<p></p>`. I also tried
```
echo '<p class="article-date">' . the_time('d. F Y') . '</p>';
```
but again the date isn't placed in those tags. What I'm doing wrong... | ```
<p>
<?php the_time() ?>
</p>
```
It helps with separation of concerns and increases readability of code as well as being consistent with WordPress coding standards and the default coding style.
The first method you attempted is completely invalid, `the_time()` only accepts 1 parameter, the date format. The s... |
52,611 | <p>I have created a theme that uses a featured image on every page.</p>
<p>In settings, I have setup my "Posts Page" to be "news"...how do I get the featured image from "news" to display?</p>
<p>The following will display the id of my posts page:</p>
<pre><code><?php
$page_for_posts = get_option( 'page_for_po... | [
{
"answer_id": 52625,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 0,
"selected": false,
"text": "<p>You could always do this instead;</p>\n\n<pre><code>$id = get_the_ID();\necho get_the_post_thumbnail($id, 'large'... | 2012/05/18 | [
"https://wordpress.stackexchange.com/questions/52611",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9820/"
] | I have created a theme that uses a featured image on every page.
In settings, I have setup my "Posts Page" to be "news"...how do I get the featured image from "news" to display?
The following will display the id of my posts page:
```
<?php
$page_for_posts = get_option( 'page_for_posts' );
echo $page_for_post... | I feel like such an idiot!! I was trouble-shooting this last night and I guess I removed the featured image for the news page...so, of course, the image wasn't showing up!
I added the featured image and the following code:
```
<?php if(is_home()) { ?>
<?php
$page_for_posts = get_option( 'page_for_posts' )... |
52,638 | <p>I am using the following code for my pagination.</p>
<pre><code>// Pagination
function my_paginate_links() {
global $wp_rewrite, $wp_query;
$wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;
$pagination = array(
'base' => @add_query_arg('pa... | [
{
"answer_id": 52641,
"author": "Geert",
"author_id": 4936,
"author_profile": "https://wordpress.stackexchange.com/users/4936",
"pm_score": 2,
"selected": false,
"text": "<p>Looking at the source of <code>paginate_links()</code> it seems there is no option available to always include a p... | 2012/05/19 | [
"https://wordpress.stackexchange.com/questions/52638",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7877/"
] | I am using the following code for my pagination.
```
// Pagination
function my_paginate_links() {
global $wp_rewrite, $wp_query;
$wp_query->query_vars['paged'] > 1 ? $current = $wp_query->query_vars['paged'] : $current = 1;
$pagination = array(
'base' => @add_query_arg('page','%#%'),
'forma... | Looking at the source of `paginate_links()` it seems there is no option available to always include a previous or next link. The function simply compares the current page number with the total page number to determine whether these links need to be added.
Working around this problem is possible, though. This should ge... |
52,655 | <p>I'm wondering if is possible to change the text "Enter title here" based on the post format that you selected? For example: If you select the post format <strong>Quote</strong> than your text will be "Enter author's quote". Is that possible?</p>
| [
{
"answer_id": 52656,
"author": "Rutwick Gangurde",
"author_id": 4740,
"author_profile": "https://wordpress.stackexchange.com/users/4740",
"pm_score": 0,
"selected": false,
"text": "<p>Go for jQuery! You can do this via php, but only when you are editing a post, for which you've already ... | 2012/05/19 | [
"https://wordpress.stackexchange.com/questions/52655",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9060/"
] | I'm wondering if is possible to change the text "Enter title here" based on the post format that you selected? For example: If you select the post format **Quote** than your text will be "Enter author's quote". Is that possible? | You need to do the following;
```
jQuery(document).ready(function( $ ) {
$('input.post-format').click(function(){
$('#title-prompt-text').val( $(this).next('label').text());
})
});
```
This will replace the title with whichever post format you select.
Save the above into a file called **`custom-post... |
52,662 | <p>I would like to add some code in functions.php that does this:</p>
<ul>
<li><p>If the first paragraph contains an image, show my custom code right AFTER it. For example:</p>
<pre><code><div class="entry-content">
<p><img src="http://example.com/example.jpg" alt="Image in 1st para" /></p>... | [
{
"answer_id": 52667,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>To catch the first paragraph (<code><p></code>) you can use a regex. That's <a href=\"https://stackoverflow.com/... | 2012/05/19 | [
"https://wordpress.stackexchange.com/questions/52662",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10691/"
] | I would like to add some code in functions.php that does this:
* If the first paragraph contains an image, show my custom code right AFTER it. For example:
```
<div class="entry-content">
<p><img src="http://example.com/example.jpg" alt="Image in 1st para" /></p>
<div>MY CUSTOM CODE</div>
</div>
```
* But if... | How about a few simple lines With jQuery?
```
jQuery(document).ready( function ($) {
if ($(".entry-content:first-child").has('img').length) //this check for the img tag
$(".entry-content:first-child").after("<div>MY CUSTOM CODE</div>");
else
$(".entry-content:first-child").before("<div>MY CUSTO... |
52,663 | <p>I have over 6 image sizes, Therefore WP cannot satisfy every size with proper cropping as some images get their head cut off and some don't.</p>
<p>Is there a plugin that lets me choose the cropping area of each size (including custom sizes)?</p>
<p>To further explain this, I imagine it'd just let me move the crop... | [
{
"answer_id": 52666,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 3,
"selected": false,
"text": "<p>You can customize or change WordPress image sizes using this function: <a href=\"http://codex.wordpress.org/Functio... | 2012/05/19 | [
"https://wordpress.stackexchange.com/questions/52663",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15913/"
] | I have over 6 image sizes, Therefore WP cannot satisfy every size with proper cropping as some images get their head cut off and some don't.
Is there a plugin that lets me choose the cropping area of each size (including custom sizes)?
To further explain this, I imagine it'd just let me move the crop selection for ev... | You can customize or change WordPress image sizes using this function: <http://codex.wordpress.org/Function_Reference/add_image_size>
```
<?php add_image_size( $name, $width, $height, $crop ); ?>
```
The `$crop` parameter can be set to `false` for proportional or `true` for hard crop (it will hard crop from the cent... |
52,665 | <p>I am tired of WordPress's horrible HTML editor and have decided to write all my html in Notepad++ and then just copy it over. However, simple line breaks <code>"\n"</code> that would be normally ignored in html are converted to <code><br /></code> tags. I have disabled the visual editor, so everything I save s... | [
{
"answer_id": 52671,
"author": "jlengstorf",
"author_id": 11567,
"author_profile": "https://wordpress.stackexchange.com/users/11567",
"pm_score": 4,
"selected": false,
"text": "<p>That's handled by a <a href=\"http://codex.wordpress.org/Plugin_API/Filter_Reference\" rel=\"noreferrer\">f... | 2012/05/19 | [
"https://wordpress.stackexchange.com/questions/52665",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16272/"
] | I am tired of WordPress's horrible HTML editor and have decided to write all my html in Notepad++ and then just copy it over. However, simple line breaks `"\n"` that would be normally ignored in html are converted to `<br />` tags. I have disabled the visual editor, so everything I save should be the exact html that is... | That's handled by a [filter](http://codex.wordpress.org/Plugin_API/Filter_Reference) called `wpautop` (declared in `wp-includes/formatting.php`, line 189).
You can remove it with this:
```
remove_filter('the_content', 'wpautop');
``` |
52,675 | <p>In the theme admin menu below, the "MyTheme Menu Label" is being duplicated twice on the sidebar menu, once for the main menu link and again for the first submenu link.</p>
<p>How can I remove the 2nd instance of the link</p>
<pre><code>add_menu_page(
"MyTheme",
"MyTheme Menu Label", //THIS IS REPEATED TW... | [
{
"answer_id": 52695,
"author": "mor7ifer",
"author_id": 11740,
"author_profile": "https://wordpress.stackexchange.com/users/11740",
"pm_score": 3,
"selected": false,
"text": "<p>From <a href=\"http://codex.wordpress.org/Adding_Administration_Menus#Sub-Level_Menus\" rel=\"noreferrer\">th... | 2012/05/20 | [
"https://wordpress.stackexchange.com/questions/52675",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/366/"
] | In the theme admin menu below, the "MyTheme Menu Label" is being duplicated twice on the sidebar menu, once for the main menu link and again for the first submenu link.
How can I remove the 2nd instance of the link
```
add_menu_page(
"MyTheme",
"MyTheme Menu Label", //THIS IS REPEATED TWICE IN THE MENU
"... | There is a workaround to hide this automatically created submenu. In the past I've used it quite often, but lately I have returned to leaving it as is (or renaming it, as m0r7if3r suggested).
Also note, that aside your main question, you have switched the positions of the *menu\_slug* and *function* arguments in `add_... |
52,682 | <p>Is there a best practice for including your <code>wp-config.php</code> file in your version control repository?</p>
<p>I'm considering creating a new site with this type of configuration, (similar to <a href="http://alexking.org/blog/2012/02/14/svn-to-git-migration">Alex King</a> and <a href="http://markjaquith.wor... | [
{
"answer_id": 52954,
"author": "EAMann",
"author_id": 46,
"author_profile": "https://wordpress.stackexchange.com/users/46",
"pm_score": 3,
"selected": false,
"text": "<blockquote>\n <p>How can I do this without exposing my passwords to git, in case this repository ever becomes public?<... | 2012/05/20 | [
"https://wordpress.stackexchange.com/questions/52682",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/300/"
] | Is there a best practice for including your `wp-config.php` file in your version control repository?
I'm considering creating a new site with this type of configuration, (similar to [Alex King](http://alexking.org/blog/2012/02/14/svn-to-git-migration) and [Mark Jaquith](http://markjaquith.wordpress.com/2011/06/24/word... | Here is how I do it and I haven't come across anything better than this. I keep a different version of wp-config.php file under version control and then keep a file one directory above which holds all the database credentials and salts/keys. Also this way, I am able to distinguish between the type of setup I am running... |
52,688 | <p>I use a standard loop in my index.php and that shows all the posts beeing posted. What i'm looking for is a code that only shows the posts that have image(s) in it. </p>
<p>With other words: i only want to show posts that have images in content in my loop.</p>
| [
{
"answer_id": 52706,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 0,
"selected": false,
"text": "<p>I would suggest, that the easiest way to go about this is to create a special category called for example, <stron... | 2012/05/20 | [
"https://wordpress.stackexchange.com/questions/52688",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12727/"
] | I use a standard loop in my index.php and that shows all the posts beeing posted. What i'm looking for is a code that only shows the posts that have image(s) in it.
With other words: i only want to show posts that have images in content in my loop. | I found and modified a chunk of code found here: <http://www.wprecipes.com/wordpress-tip-detect-if-a-post-has-at-least-one-image>.
```
<?php
while ( have_posts() ) : the_post();
$content = $post->post_content;
$searchimages = '~<img [^>]* />~';
preg_match_all( $searchimages, $content, $pics );
$iNumbe... |
52,711 | <p>I'm not able to use array for the terms in the following query, only a single term:</p>
<pre><code> $args=array(
'facts' => 'information', //taxonomy:facts and term:information
'post_type' => 'book',
'post_status' => 'publish',
'posts_per_page' => -1,
'caller_get_posts'=> 1
... | [
{
"answer_id": 52710,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 1,
"selected": false,
"text": "<p>I recommend (and use myself) XAMPP located here <a href=\"http://www.apachefriends.org/en/xampp-windows.html\" re... | 2012/05/20 | [
"https://wordpress.stackexchange.com/questions/52711",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6768/"
] | I'm not able to use array for the terms in the following query, only a single term:
```
$args=array(
'facts' => 'information', //taxonomy:facts and term:information
'post_type' => 'book',
'post_status' => 'publish',
'posts_per_page' => -1,
'caller_get_posts'=> 1
);
$my_query = null;
... | I recommend (and use myself) XAMPP located here [LINK](http://www.apachefriends.org/en/xampp-windows.html), which will allow you to run a web-server on a machine of choice.
Once you setup XAMPP, you would install WordPress or WordPress with Multisite (enabled) just like you would any other WordPress installation on a... |
52,716 | <p>I need to paginate some custom posts...I can’t see why but I’m getting 404’s when going to the next page. Here’s my code:</p>
<pre><code>$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts( array( 'post_type' => 's_stories', 'posts_per_page' => 4 , 'paged'=>$paged) );
if (have_pos... | [
{
"answer_id": 52717,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p><code>query_posts()</code> should not be used in general and especially if you are trying to mess with pagination.</... | 2012/05/20 | [
"https://wordpress.stackexchange.com/questions/52716",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12350/"
] | I need to paginate some custom posts...I can’t see why but I’m getting 404’s when going to the next page. Here’s my code:
```
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts( array( 'post_type' => 's_stories', 'posts_per_page' => 4 , 'paged'=>$paged) );
if (have_posts()){
while (have_po... | [Don't use `query_posts`](https://wordpress.stackexchange.com/a/50762/9364). This is a classic example of what happens when you do :)
Basically, when WordPress receives an url, it interprets this as a query - it then queries the database to find the results (if any) and serves up an appropriate template (such as 404.p... |
52,727 | <p>I'm trying to use the_author_meta to retrieve some links which users can set in their profile.</p>
<p>I set up extra profile fields and they are saving to the database.</p>
<p>On my author.php I have the following code.</p>
<pre><code><div class="user_social_icons"><a href="<?php the_author_meta('face... | [
{
"answer_id": 52741,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 3,
"selected": false,
"text": "<p>It's entirely possible that you are calling <code>the_author_meta()</code> from outside of your post loop in the ... | 2012/05/20 | [
"https://wordpress.stackexchange.com/questions/52727",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16290/"
] | I'm trying to use the\_author\_meta to retrieve some links which users can set in their profile.
I set up extra profile fields and they are saving to the database.
On my author.php I have the following code.
```
<div class="user_social_icons"><a href="<?php the_author_meta('facebook'); ?>" class="facebook" title="Fa... | It's entirely possible that you are calling `the_author_meta()` from outside of your post loop in the `author.php` template in which case the above will not work.
Instead, you can use
* `get_the_author_meta('facebook')` or...
* `get_the_author_meta('facebook', $user_id)` where `$user_id` is the ID# of the current use... |
52,737 | <p>When I click on Reply, the reply form appears at the bottom of the page (under the last comment). How can I add the Reply Form inside the comment to which I am going to add the reply?</p>
| [
{
"answer_id": 52738,
"author": "Karina",
"author_id": 16295,
"author_profile": "https://wordpress.stackexchange.com/users/16295",
"pm_score": 0,
"selected": false,
"text": "<p>You can create a <code><div class=\"quick-holder\"></div></code> container in the end of each one c... | 2012/05/20 | [
"https://wordpress.stackexchange.com/questions/52737",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15801/"
] | When I click on Reply, the reply form appears at the bottom of the page (under the last comment). How can I add the Reply Form inside the comment to which I am going to add the reply? | 1. Ensure that you have **Threaded Comments** enabled: go to `Dashboard -> Settings -> Discussion` and enable the option to thread comments
2. Ensure that your Theme **enqueues the `comment-reply` script**. Look for the following, usually in `header.php`, `functions.php`, etc.:
```
<?php wp_enqueue_script( 'comment-re... |
52,750 | <p>I'm sure there's some very easy explaination for this, but I'm stuck. I am just trying to put a nice, simple recent posts element on the front-page of a site and for some reason when I try to use:</p>
<pre><code>$args = array(
'post_type' => array('post','recipes'),
'posts_per_page' => 4
);
query_po... | [
{
"answer_id": 52758,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 2,
"selected": false,
"text": "<ol>\n<li>Don't use query_posts for secondary loops.<br>\nThis is just a general \"best practices\" recommendation an... | 2012/05/21 | [
"https://wordpress.stackexchange.com/questions/52750",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16305/"
] | I'm sure there's some very easy explaination for this, but I'm stuck. I am just trying to put a nice, simple recent posts element on the front-page of a site and for some reason when I try to use:
```
$args = array(
'post_type' => array('post','recipes'),
'posts_per_page' => 4
);
query_posts( $args );
if ( h... | 1. Don't use query\_posts for secondary loops.
This is just a general "best practices" recommendation and not the cause of your problem.
2. When you register the post type make sure `'public' => true`
3. Put the following in a template somewhere and report back the output. It will return the object of each registere... |