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 |
|---|---|---|---|---|---|---|
83,005 | <p>When I do this:</p>
<pre><code>$transients = $wpdb->get_col(
"
SELECT option_name
FROM $wpdb->options
WHERE option_name
LIKE '_transient_wb_tt_%'
"
);
</code></pre>
<p>It works fine, but when I use prepare like so:</p>
<pre><code>$transients = $wpdb->get_col( ... | [
{
"answer_id": 83010,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": true,
"text": "<p>I agree with @bainternet. You don't need <code>$wpdb->prepare</code>. There isn't any user supplied content... | 2013/01/24 | [
"https://wordpress.stackexchange.com/questions/83005",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26499/"
] | When I do this:
```
$transients = $wpdb->get_col(
"
SELECT option_name
FROM $wpdb->options
WHERE option_name
LIKE '_transient_wb_tt_%'
"
);
```
It works fine, but when I use prepare like so:
```
$transients = $wpdb->get_col( $wpdb->prepare(
"
SELECT option_na... | I agree with @bainternet. You don't need `$wpdb->prepare`. There isn't any user supplied content.
The answer to the question is that to get a wildcard `%` to pass through `prepare` you need to double it in your code.
```
LIKE '_transient_wb_tt_%%'
```
Try that or this if you want a good look at the generated que... |
83,033 | <p>I am developing a wordpress site and I would like to be able to log and handle mysql errors from wordpress core.</p>
<p>My site has a mix of wordpress pages and posts + a few php pages that run under the wordpress engine. I configured the php.ini to prepend a php file to all php scripts with the error handling func... | [
{
"answer_id": 83037,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": false,
"text": "<p>You should be using the <a href=\"http://codex.wordpress.org/Class_Reference/wpdb\"><code>wpdb</code> class</a> for... | 2013/01/25 | [
"https://wordpress.stackexchange.com/questions/83033",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26514/"
] | I am developing a wordpress site and I would like to be able to log and handle mysql errors from wordpress core.
My site has a mix of wordpress pages and posts + a few php pages that run under the wordpress engine. I configured the php.ini to prepend a php file to all php scripts with the error handling functions. The... | You should be using the [`wpdb` class](http://codex.wordpress.org/Class_Reference/wpdb) for all your own queries. All core queries also use `wpdb`. See [`wpdb` Show and Hide SQL Errors](http://codex.wordpress.org/Class_Reference/wpdb#Show_and_Hide_SQL_Errors)
```
<?php $wpdb->show_errors(); ?>
<?php $wpdb->hide_error... |
83,046 | <p>I'm currently developing my WordPress locally, committing my code to GitHub with Git and then SSHing into my server and doing a "git pull" to update my code. Is this a good option for code deployment onto a WordPress site (I obviously have root level access to my server in this case.) I know of things like Capistran... | [
{
"answer_id": 83218,
"author": "James Hebden",
"author_id": 25611,
"author_profile": "https://wordpress.stackexchange.com/users/25611",
"pm_score": 7,
"selected": true,
"text": "<p>I use git for this and find it works really well. A few suggestions:</p>\n\n<ul>\n<li>Add your uploads dir... | 2013/01/25 | [
"https://wordpress.stackexchange.com/questions/83046",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17193/"
] | I'm currently developing my WordPress locally, committing my code to GitHub with Git and then SSHing into my server and doing a "git pull" to update my code. Is this a good option for code deployment onto a WordPress site (I obviously have root level access to my server in this case.) I know of things like Capistrano, ... | I use git for this and find it works really well. A few suggestions:
* Add your uploads directory (wp-content/uploads) directory to your `.gitignore` file.
* Run a web server and database server on your development system so you can test changes locally before pushing them to production.
* Keep your database connectio... |
83,054 | <p>Trying to remove the WYSIWYG Editor on all post types except the default pages and posts.</p>
<p>Shouldn't this work</p>
<pre><code>// Remove WYSIWYG Editor
function remove_wysiwyg( $hook ) {
if ( $hook != 'post-new.php' || $hook != 'post.php' )
add_filter('user_can_richedit', '__return_false');
}
add_acti... | [
{
"answer_id": 83055,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>A bit involved, but this should work:</p>\n\n<pre><code>function remove_wysiwyg() {\n global $pagenow;\n if (... | 2013/01/25 | [
"https://wordpress.stackexchange.com/questions/83054",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18241/"
] | Trying to remove the WYSIWYG Editor on all post types except the default pages and posts.
Shouldn't this work
```
// Remove WYSIWYG Editor
function remove_wysiwyg( $hook ) {
if ( $hook != 'post-new.php' || $hook != 'post.php' )
add_filter('user_can_richedit', '__return_false');
}
add_action( 'init', 'remove_w... | A bit involved, but this should work:
```
function remove_wysiwyg() {
global $pagenow;
if ( 'post.php' == $pagenow ) {
$type = get_post_type( $_GET['post'] );
if( 'post' != $type || 'page' != $type )
add_filter('user_can_richedit', '__return_false');
} elseif ( 'post-new.php' ==... |
83,061 | <p>Is there any way to prevent double execution of do_action statements? For example, I have the following lines:</p>
<pre><code>do_action('myhook1', 'myfunction1');
do_action('myhook2', 'myfunction2');
do_action('myhook3', 'myfunction3');
</code></pre>
<p>There are also other plugins that "might" be executing them.<... | [
{
"answer_id": 83055,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>A bit involved, but this should work:</p>\n\n<pre><code>function remove_wysiwyg() {\n global $pagenow;\n if (... | 2013/01/25 | [
"https://wordpress.stackexchange.com/questions/83061",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20972/"
] | Is there any way to prevent double execution of do\_action statements? For example, I have the following lines:
```
do_action('myhook1', 'myfunction1');
do_action('myhook2', 'myfunction2');
do_action('myhook3', 'myfunction3');
```
There are also other plugins that "might" be executing them.
Is there a built-in Word... | A bit involved, but this should work:
```
function remove_wysiwyg() {
global $pagenow;
if ( 'post.php' == $pagenow ) {
$type = get_post_type( $_GET['post'] );
if( 'post' != $type || 'page' != $type )
add_filter('user_can_richedit', '__return_false');
} elseif ( 'post-new.php' ==... |
83,065 | <p>I installed <a href="http://jetpack.me" rel="nofollow">jetpack</a> to my wordpress blog site. How can I hide <code>jetpack</code> to contributors, and show it only to administrators?</p>
<p>Thanks</p>
| [
{
"answer_id": 83055,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>A bit involved, but this should work:</p>\n\n<pre><code>function remove_wysiwyg() {\n global $pagenow;\n if (... | 2013/01/25 | [
"https://wordpress.stackexchange.com/questions/83065",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26267/"
] | I installed [jetpack](http://jetpack.me) to my wordpress blog site. How can I hide `jetpack` to contributors, and show it only to administrators?
Thanks | A bit involved, but this should work:
```
function remove_wysiwyg() {
global $pagenow;
if ( 'post.php' == $pagenow ) {
$type = get_post_type( $_GET['post'] );
if( 'post' != $type || 'page' != $type )
add_filter('user_can_richedit', '__return_false');
} elseif ( 'post-new.php' ==... |
83,088 | <p>I'm getting an "file.png exceeds the maximum upload size for this site" error. It's saying the upload limit is 1MB when trying to upload an image that is 2.5M on WP 3.5. It is setup in multi-blog mode (if that matters).</p>
<p>I have set my php.ini file to 64M for post_max_size and upload_max_size, and it's working... | [
{
"answer_id": 83095,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 4,
"selected": true,
"text": "<blockquote>\n <p>It is setup in multi-blog mode (if that matters)</p>\n</blockquote>\n\n<p>That will matter ... | 2013/01/25 | [
"https://wordpress.stackexchange.com/questions/83088",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24283/"
] | I'm getting an "file.png exceeds the maximum upload size for this site" error. It's saying the upload limit is 1MB when trying to upload an image that is 2.5M on WP 3.5. It is setup in multi-blog mode (if that matters).
I have set my php.ini file to 64M for post\_max\_size and upload\_max\_size, and it's working for o... | >
> It is setup in multi-blog mode (if that matters)
>
>
>
That will matter a lot. you probably need to ask the super admin to change the upload setting for your site <https://codex.wordpress.org/Network_Admin_Settings_Screen#Upload_Settings> |
83,102 | <p>To change the upload directory I have to do this:</p>
<pre><code>define ( "upload", "<new upload location>" );
</code></pre>
<p>How can you change the themes location? I like to create a folder themes in the root directory.</p>
| [
{
"answer_id": 83103,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>You have to change the <strong>path</strong> and the <strong>URL</strong> to make sure themes work. I am using the fol... | 2013/01/25 | [
"https://wordpress.stackexchange.com/questions/83102",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8757/"
] | To change the upload directory I have to do this:
```
define ( "upload", "<new upload location>" );
```
How can you change the themes location? I like to create a folder themes in the root directory. | You can register *additional* directory or directories with themes by using [`register_theme_directory()`](http://queryposts.com/function/register_theme_directory/) function, that accepts filesystem path to folder.
Note that this isn't typical and even while core handles it mostly fine, third party code in themes and ... |
83,141 | <p>I have the following code in functions.php</p>
<pre><code><script type="text/javascript">
var post_id = "1055"; // hardcoded post id for testing purposes
var type = "some_type";
var data = {action: "get_variations", parent_id: post_id, item_type: type};
jQuery.post("/wp-admin/admin-ajax.php", data, function(r... | [
{
"answer_id": 83143,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 0,
"selected": false,
"text": "<p>Your ajax callback has no arguments,</p>\n\n<p>this should work:</p>\n\n<pre><code>function get_variations(){... | 2013/01/25 | [
"https://wordpress.stackexchange.com/questions/83141",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13974/"
] | I have the following code in functions.php
```
<script type="text/javascript">
var post_id = "1055"; // hardcoded post id for testing purposes
var type = "some_type";
var data = {action: "get_variations", parent_id: post_id, item_type: type};
jQuery.post("/wp-admin/admin-ajax.php", data, function(response){
alert(... | Ajax-calls use the `$_POST`-variable to submit their arguments to the function. As `$_POST['action']` is always used by Wordpress Ajax calls (contains the name of the action, obviously ;) ), PHP only complains over missing argument no. 2.
You can either use the solution provided by Bainternet. If you want to use your ... |
83,160 | <p>I want to remove the "Continue Reading" link from the teaser excerpt only and not from the automatic excerpt, which filter is easily available.</p>
<p>This is the original code; it's from the Showcase Template Page Template:</p>
<pre><code> <?php while ( have_posts() ) : the_post(); ?>
<?php
if ( ... | [
{
"answer_id": 83163,
"author": "Rafael Marques",
"author_id": 25562,
"author_profile": "https://wordpress.stackexchange.com/users/25562",
"pm_score": 2,
"selected": false,
"text": "<p>Change standard text for all excerpts:</p>\n\n<pre><code>function custom_excerpt_more($more) {\n glob... | 2013/01/25 | [
"https://wordpress.stackexchange.com/questions/83160",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26554/"
] | I want to remove the "Continue Reading" link from the teaser excerpt only and not from the automatic excerpt, which filter is easily available.
This is the original code; it's from the Showcase Template Page Template:
```
<?php while ( have_posts() ) : the_post(); ?>
<?php
if ( '' != get_the_content() )
... | Change standard text for all excerpts:
```
function custom_excerpt_more($more) {
global $post;
$more_text = '...';
return '… <a href="'. get_permalink($post->ID) . '">' . $more_text . '</a>';
}
add_filter('excerpt_more', 'custom_excerpt_more');
```
Create your own excerpt function:
```
// Rafael Marques Ex... |
83,180 | <p>I have this issue where I need to get all page templates. I know there are ways to get them based on their name. I know that I can include a page template but I am trying to include them in the loop on the index page. I just installed the 2012 theme, modified the header to include my scripts. I used a function that ... | [
{
"answer_id": 83183,
"author": "Jamie",
"author_id": 14761,
"author_profile": "https://wordpress.stackexchange.com/users/14761",
"pm_score": 0,
"selected": false,
"text": "<p>I figured it out. This was my solution. Do you have a better one? after the endwhile, I did this ( all my templa... | 2013/01/26 | [
"https://wordpress.stackexchange.com/questions/83180",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14761/"
] | I have this issue where I need to get all page templates. I know there are ways to get them based on their name. I know that I can include a page template but I am trying to include them in the loop on the index page. I just installed the 2012 theme, modified the header to include my scripts. I used a function that Mil... | Checking for `get_page_templates()` in the [core](http://core.trac.wordpress.org/browser/tags/3.5/wp-admin/includes/theme.php#L83), I found a workaround that doesn't break the theme like:
>
> Fatal error: Call to undefined function get\_page\_templates()
>
>
>
I'm using this just after `<body>` and works ok:
```... |
83,190 | <p>I was looking for a quick and dirty method to output a breadcrumb navigation on a WP site, without requiring the installation of a plugin and also leveraging the built-in WP menu.</p>
<p>Here's what I came up with. I'm curious to know if there is a better solution I am missing, and/or if there is anything obviously... | [
{
"answer_id": 83198,
"author": "user1924165",
"author_id": 26565,
"author_profile": "https://wordpress.stackexchange.com/users/26565",
"pm_score": 0,
"selected": false,
"text": "<p>Why not do something similar to this;</p>\n\n<pre><code>function the_breadcrumb() {\nif (!is_home()) {\n ... | 2013/01/26 | [
"https://wordpress.stackexchange.com/questions/83190",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26561/"
] | I was looking for a quick and dirty method to output a breadcrumb navigation on a WP site, without requiring the installation of a plugin and also leveraging the built-in WP menu.
Here's what I came up with. I'm curious to know if there is a better solution I am missing, and/or if there is anything obviously wrong wit... | I couldn't believe there is not a single FREE plugin available that does this. So I wrote my own function. Here you go. Just copy this to your functions.php:
```
function my_breadcrumb($theme_location = 'main', $separator = ' > ') {
$theme_locations = get_nav_menu_locations();
if( ! isset( $theme_location... |
83,201 | <p>Please help me I am new baby in wordpress, how can i hide that 'course or call' category from the page..</p>
<p>i have var dump the variable which is passing as parameter to query_post </p>
<pre><code> $args = jr_filter_form();
var_dump($args);
query_posts($args);
</code></pre>
<p><img src=... | [
{
"answer_id": 83208,
"author": "Christian Rios",
"author_id": 26364,
"author_profile": "https://wordpress.stackexchange.com/users/26364",
"pm_score": 1,
"selected": false,
"text": "<p>You essentially want to add the following to <code>$args</code>:</p>\n\n<p><code>'cat' => -65</code>... | 2013/01/26 | [
"https://wordpress.stackexchange.com/questions/83201",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26566/"
] | Please help me I am new baby in wordpress, how can i hide that 'course or call' category from the page..
i have var dump the variable which is passing as parameter to query\_post
```
$args = jr_filter_form();
var_dump($args);
query_posts($args);
```
,
$args
);
query_posts($args);
``` |
83,212 | <p>Sometimes I want to access one particular CPT to extract something from it, for example a custom field value:</p>
<pre><code>$group = new WP_Query( array(
'post_type' => 'group',
'p' => $group_id
) );
while ( $group->have_posts() ) : $group->the_post();
$group_type = get_post_meta($post->... | [
{
"answer_id": 83215,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Your <code>WP_Query</code> object holds an array of posts. Just take first entry:</p>\n\n<pre><code>get_post_meta( $gr... | 2013/01/26 | [
"https://wordpress.stackexchange.com/questions/83212",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11634/"
] | Sometimes I want to access one particular CPT to extract something from it, for example a custom field value:
```
$group = new WP_Query( array(
'post_type' => 'group',
'p' => $group_id
) );
while ( $group->have_posts() ) : $group->the_post();
$group_type = get_post_meta($post->ID, "group_type", $single = ... | how about [get\_post](http://codex.wordpress.org/Function_Reference/get_post)?
```
$post = get_post( $p );
$group_type = get_post_meta( $post->ID, 'group_type', true );
``` |
83,217 | <p>Firstly, I know that XML-RPC is designed to send out the raw post data, but I need it to expand shortcodes out. I don't use it for posting so it won't be an issue there, but there are services that are grabbing posts from it and they're getting the shortcodes [] instead of the expanded shortcodes. I'd switch to RSS ... | [
{
"answer_id": 83221,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<h2>Explanation of the behavior</h2>\n\n<p>A shortcode is meant to be processed during runtime (when rendering & d... | 2013/01/26 | [
"https://wordpress.stackexchange.com/questions/83217",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26571/"
] | Firstly, I know that XML-RPC is designed to send out the raw post data, but I need it to expand shortcodes out. I don't use it for posting so it won't be an issue there, but there are services that are grabbing posts from it and they're getting the shortcodes [] instead of the expanded shortcodes. I'd switch to RSS but... | Explanation of the behavior
---------------------------
A shortcode is meant to be processed during runtime (when rendering & displaying a post on the public facing view). It is absolutely not meant to be a pre-processor during saving the post. The receiver simply doesn't have your parser (which is the function proces... |
83,224 | <p>When adding category to Menu, I need it to list all the item that belong to that category in separate <code>UL</code> automatically. like this <br />
<a href="https://i.stack.imgur.com/ulOOS.jpg" rel="nofollow noreferrer">http://i.stack.imgur.com/ulOOS.jpg</a><br />
Of course I can do that manually, but I'm look for... | [
{
"answer_id": 83221,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 1,
"selected": false,
"text": "<h2>Explanation of the behavior</h2>\n\n<p>A shortcode is meant to be processed during runtime (when rendering & d... | 2013/01/26 | [
"https://wordpress.stackexchange.com/questions/83224",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17264/"
] | When adding category to Menu, I need it to list all the item that belong to that category in separate `UL` automatically. like this
[http://i.stack.imgur.com/ulOOS.jpg](https://i.stack.imgur.com/ulOOS.jpg)
Of course I can do that manually, but I'm look for a way to add a filter, maybe, to the `wp page menu` func... | Explanation of the behavior
---------------------------
A shortcode is meant to be processed during runtime (when rendering & displaying a post on the public facing view). It is absolutely not meant to be a pre-processor during saving the post. The receiver simply doesn't have your parser (which is the function proces... |
83,228 | <p>I got this function and i want to make the contents divs of "foreach" as return. How can i do that?</p>
<pre><code><?php
$args = array( 'numberposts' => 6, 'post_status'=>"publish",'post_type'=>"post",'orderby'=>"post_date");
$postslist = get_posts( $args );
foreach ($postslist as $post... | [
{
"answer_id": 83233,
"author": "webaware",
"author_id": 24260,
"author_profile": "https://wordpress.stackexchange.com/users/24260",
"pm_score": 0,
"selected": false,
"text": "<p>Use <a href=\"http://php.net/manual/en/function.ob-get-clean.php\" rel=\"nofollow\">output buffering</a> to g... | 2013/01/26 | [
"https://wordpress.stackexchange.com/questions/83228",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25881/"
] | I got this function and i want to make the contents divs of "foreach" as return. How can i do that?
```
<?php
$args = array( 'numberposts' => 6, 'post_status'=>"publish",'post_type'=>"post",'orderby'=>"post_date");
$postslist = get_posts( $args );
foreach ($postslist as $post) : setup_postdata($post); ?>... | Build a string instead of directly outputting the contents.
```
$str = '';
foreach ($postslist as $post) : setup_postdata($post);
$str .= '<div class="events">';
$str .= '<p><strong>'.get_the_date().'</strong></p>';
$str .= '<p><a href="'.get_permalink().'" title="'.esc_attr(get_the_title()).'">'.get_the_ti... |
83,230 | <p>I add a custom post type with custom taxonomy and i wish to get all postings into this by a template, but the result is 0</p>
<pre><code>$args=array(
'post_type' => 'contents',
'post_status' => 'publish',
'tax_query' => array(
'taxonomy' => 'content-category',
'field' => 'id',
... | [
{
"answer_id": 83231,
"author": "varun1505",
"author_id": 25456,
"author_profile": "https://wordpress.stackexchange.com/users/25456",
"pm_score": -1,
"selected": false,
"text": "<p>Are you sure you want to pass so many arguments?\nThe following should be sufficient to just display the po... | 2013/01/26 | [
"https://wordpress.stackexchange.com/questions/83230",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16431/"
] | I add a custom post type with custom taxonomy and i wish to get all postings into this by a template, but the result is 0
```
$args=array(
'post_type' => 'contents',
'post_status' => 'publish',
'tax_query' => array(
'taxonomy' => 'content-category',
'field' => 'id',
'terms' => array(5,26,28)
... | The `taxonomy`, `field` and `terms` in `tax_query` should be two array-level deep instead of one. Quoted from the [WP\_Query page](http://codex.wordpress.org/Class_Reference/WP_Query):
>
> Important Note: tax\_query takes an array of tax query arguments arrays
> (it takes an array of arrays) - you can see this in th... |
83,244 | <p>I've had this problem for a while now; I hoped that it would go away when I moved to my new host but it hasn't. Whenever I try to install or update a plugin or theme, or even update Wordpress, the page will simply say <code>downloading install package ...</code> but that is the only line that ever appears. If I leav... | [
{
"answer_id": 83231,
"author": "varun1505",
"author_id": 25456,
"author_profile": "https://wordpress.stackexchange.com/users/25456",
"pm_score": -1,
"selected": false,
"text": "<p>Are you sure you want to pass so many arguments?\nThe following should be sufficient to just display the po... | 2013/01/26 | [
"https://wordpress.stackexchange.com/questions/83244",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14001/"
] | I've had this problem for a while now; I hoped that it would go away when I moved to my new host but it hasn't. Whenever I try to install or update a plugin or theme, or even update Wordpress, the page will simply say `downloading install package ...` but that is the only line that ever appears. If I leave it for a suf... | The `taxonomy`, `field` and `terms` in `tax_query` should be two array-level deep instead of one. Quoted from the [WP\_Query page](http://codex.wordpress.org/Class_Reference/WP_Query):
>
> Important Note: tax\_query takes an array of tax query arguments arrays
> (it takes an array of arrays) - you can see this in th... |
83,313 | <p>I'm developing my own theme on a website where I use the polldaddy polls & ratings plugin. I've set the ratings to show up on the homepage and that's working with e.g. the twentytwelve theme. However with my own theme, I do see the polldaddy div, but there's nothing in it:</p>
<pre><code><div class="pd-ratin... | [
{
"answer_id": 83320,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 2,
"selected": true,
"text": "<p>The <code>wp_footer()</code> function has to be called in <code>footer.php</code>, just before closing the page wit... | 2013/01/27 | [
"https://wordpress.stackexchange.com/questions/83313",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I'm developing my own theme on a website where I use the polldaddy polls & ratings plugin. I've set the ratings to show up on the homepage and that's working with e.g. the twentytwelve theme. However with my own theme, I do see the polldaddy div, but there's nothing in it:
```
<div class="pd-rating" id="pd_rating_hold... | The `wp_footer()` function has to be called in `footer.php`, just before closing the page with `</body>`. |
83,322 | <p>I want to use the datepicker that gets bundled with WordPress on the front end of a website. I enqueued <code>jquery-ui-datepicker</code> but the datepicker isn't styled(no js error in console). Is there a corresponding <code>wp_enqueue_style</code> for that?</p>
<p>I used this code in <code>functions.php</code></p... | [
{
"answer_id": 83327,
"author": "david.binda",
"author_id": 14022,
"author_profile": "https://wordpress.stackexchange.com/users/14022",
"pm_score": 6,
"selected": true,
"text": "<p>As far as I know, there is not style for datepicker. You have to register your own. The code then will be:<... | 2013/01/27 | [
"https://wordpress.stackexchange.com/questions/83322",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17305/"
] | I want to use the datepicker that gets bundled with WordPress on the front end of a website. I enqueued `jquery-ui-datepicker` but the datepicker isn't styled(no js error in console). Is there a corresponding `wp_enqueue_style` for that?
I used this code in `functions.php`
```
function rr_scripts() {
wp_enqueue_scr... | As far as I know, there is not style for datepicker. You have to register your own. The code then will be:
```
function rr_scripts() {
wp_enqueue_script( 'jquery' );
wp_enqueue_script( 'jquery-ui-datepicker', array( 'jquery' ) );
wp_register_style( 'bootstrap_css', get_template_directory_uri() . '/assets/css/bo... |
83,328 | <p>I'm developing my own theme and added this in a function which is called with the hook <code>after_setup_theme</code> to support infinite scroll:</p>
<pre><code>add_theme_support( 'infinite-scroll', array(
'container' => 'content',
'footer' => false,
'wrapper' => false
) );
</code></pre>
<p>I... | [
{
"answer_id": 83708,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 2,
"selected": false,
"text": "<p>Most likely, your theme is missing either the <code>wp_head()</code> call in the header.php (add it right before th... | 2013/01/27 | [
"https://wordpress.stackexchange.com/questions/83328",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I'm developing my own theme and added this in a function which is called with the hook `after_setup_theme` to support infinite scroll:
```
add_theme_support( 'infinite-scroll', array(
'container' => 'content',
'footer' => false,
'wrapper' => false
) );
```
I got this from <http://jetpack.me/support/infi... | You need either a `content.php` or `content-<post format>.php` OR use a render:
```
add_theme_support( 'infinite-scroll', array(
'container' => 'content',
'footer' => false,
'render' => 'render_function',
'wrapper' => false
) );
function render_function() {
get_template_part('loop');
}
```
This... |
83,329 | <p>I want to remove the short link header tag from a specific page. Please suggest me a filter guys. I want to remove the entire </p>
<pre><code><link rel='shortlink'...
</code></pre>
<p>section from a specific page. Adding a filter to the wp_shortlink_wp_head will work fine? I am not sure whether i can add filte... | [
{
"answer_id": 83333,
"author": "david.binda",
"author_id": 14022,
"author_profile": "https://wordpress.stackexchange.com/users/14022",
"pm_score": 2,
"selected": false,
"text": "<p>Replace 2 for ID of your page. Insert into your functions.php</p>\n\n<pre><code>if ( is_page(2) ){\n rem... | 2013/01/27 | [
"https://wordpress.stackexchange.com/questions/83329",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26615/"
] | I want to remove the short link header tag from a specific page. Please suggest me a filter guys. I want to remove the entire
```
<link rel='shortlink'...
```
section from a specific page. Adding a filter to the wp\_shortlink\_wp\_head will work fine? I am not sure whether i can add filter to the function just lik... | Replace 2 for ID of your page. Insert into your functions.php
```
if ( is_page(2) ){
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );
}
``` |
83,332 | <p>I <a href="https://wordpress.stackexchange.com/questions/6549/any-examples-of-adding-custom-fields-to-the-category-editor?answertab=active#tab-top">found</a> this code for custom field add category editor.</p>
<p>I added custom field to the Category. </p>
<p>e.g. My field name is Hastag and i have a Sport category... | [
{
"answer_id": 83333,
"author": "david.binda",
"author_id": 14022,
"author_profile": "https://wordpress.stackexchange.com/users/14022",
"pm_score": 2,
"selected": false,
"text": "<p>Replace 2 for ID of your page. Insert into your functions.php</p>\n\n<pre><code>if ( is_page(2) ){\n rem... | 2013/01/27 | [
"https://wordpress.stackexchange.com/questions/83332",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25951/"
] | I [found](https://wordpress.stackexchange.com/questions/6549/any-examples-of-adding-custom-fields-to-the-category-editor?answertab=active#tab-top) this code for custom field add category editor.
I added custom field to the Category.
e.g. My field name is Hastag and i have a Sport category. And i want to call display... | Replace 2 for ID of your page. Insert into your functions.php
```
if ( is_page(2) ){
remove_action( 'wp_head', 'wp_shortlink_wp_head', 10, 0 );
}
``` |
83,357 | <p>I have been reading through Codex and other SO and SE posts regarding this. But I am confused.</p>
<p>I used home_url() and site_url() to linking the site's home and it gave same results.</p>
<p>As I was using qTranslate for bilingual implementation. And had its language switcher.</p>
<p>Found later, when clicked... | [
{
"answer_id": 83359,
"author": "david.binda",
"author_id": 14022,
"author_profile": "https://wordpress.stackexchange.com/users/14022",
"pm_score": 3,
"selected": true,
"text": "<p>The difference in your case is in filters being applied to output of these functions.</p>\n\n<p>While blogi... | 2013/01/27 | [
"https://wordpress.stackexchange.com/questions/83357",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23316/"
] | I have been reading through Codex and other SO and SE posts regarding this. But I am confused.
I used home\_url() and site\_url() to linking the site's home and it gave same results.
As I was using qTranslate for bilingual implementation. And had its language switcher.
Found later, when clicked on the home logo (use... | The difference in your case is in filters being applied to output of these functions.
While bloginfo applies one of these filters:
```
if ( 'display' == $filter ) {
if ( $url )
$output = apply_filters('bloginfo_url', $output, $show);
else
$output = apply_filters('bloginfo', $ou... |
83,361 | <p>Can some one let me know how I can create custom Category and Post type including the items in side the red box (Please take a look at following image link) and add them to WordPress dashboard?</p>
<p><a href="https://i.stack.imgur.com/06WvE.png" rel="nofollow noreferrer">There is an image a this link</a>, sorry I ... | [
{
"answer_id": 83359,
"author": "david.binda",
"author_id": 14022,
"author_profile": "https://wordpress.stackexchange.com/users/14022",
"pm_score": 3,
"selected": true,
"text": "<p>The difference in your case is in filters being applied to output of these functions.</p>\n\n<p>While blogi... | 2013/01/27 | [
"https://wordpress.stackexchange.com/questions/83361",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26628/"
] | Can some one let me know how I can create custom Category and Post type including the items in side the red box (Please take a look at following image link) and add them to WordPress dashboard?
[There is an image a this link](https://i.stack.imgur.com/06WvE.png), sorry I wasn't allowed to attach image on the post
Tha... | The difference in your case is in filters being applied to output of these functions.
While bloginfo applies one of these filters:
```
if ( 'display' == $filter ) {
if ( $url )
$output = apply_filters('bloginfo_url', $output, $show);
else
$output = apply_filters('bloginfo', $ou... |
83,363 | <p>Is there a way to insert wp gallery shortcode into custom metabox textarea ?
I would like to have something like this:</p>
<p>New metabox in post/page with textarea and below textarea there are a button to open wp browse media gallery lightbox. then when we have done to select few images as gallery, click the "inse... | [
{
"answer_id": 83359,
"author": "david.binda",
"author_id": 14022,
"author_profile": "https://wordpress.stackexchange.com/users/14022",
"pm_score": 3,
"selected": true,
"text": "<p>The difference in your case is in filters being applied to output of these functions.</p>\n\n<p>While blogi... | 2013/01/27 | [
"https://wordpress.stackexchange.com/questions/83363",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26624/"
] | Is there a way to insert wp gallery shortcode into custom metabox textarea ?
I would like to have something like this:
New metabox in post/page with textarea and below textarea there are a button to open wp browse media gallery lightbox. then when we have done to select few images as gallery, click the "insert gallery... | The difference in your case is in filters being applied to output of these functions.
While bloginfo applies one of these filters:
```
if ( 'display' == $filter ) {
if ( $url )
$output = apply_filters('bloginfo_url', $output, $show);
else
$output = apply_filters('bloginfo', $ou... |
83,367 | <p>I am trying to edit the price value for a single product.</p>
<p>In <code>single-product/price.php</code> there is a template call to <code>$product->get_price_html</code>. How can I edit that function/method to change the way the HTML is presented?</p>
<p>At the moment even if I delete all the contents of the ... | [
{
"answer_id": 83376,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 6,
"selected": true,
"text": "<p>Core and plugin files should never be edited directly, as any updates could overwrite your changes. If you look in W... | 2013/01/27 | [
"https://wordpress.stackexchange.com/questions/83367",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22656/"
] | I am trying to edit the price value for a single product.
In `single-product/price.php` there is a template call to `$product->get_price_html`. How can I edit that function/method to change the way the HTML is presented?
At the moment even if I delete all the contents of the function located in `class-wc-product` it ... | Core and plugin files should never be edited directly, as any updates could overwrite your changes. If you look in WooCommerce source at the `get_price_html` method, there are a number of [filters](http://codex.wordpress.org/Plugin_API/Filter_Reference) available to modify the output of the function.
See [`add_filter`... |
83,388 | <p>I've been messing around / searching for hours and still can't get this to work, so i'm finally giving in and asking for some help.</p>
<p>I'm trying to write a custom walker that shows only the current pages children, or if there are no children display the pages siblings. </p>
<p>For example, take the following ... | [
{
"answer_id": 87776,
"author": "Steve Fischer",
"author_id": 2774,
"author_profile": "https://wordpress.stackexchange.com/users/2774",
"pm_score": 0,
"selected": false,
"text": "<p>I had a similar experience. You may want to think about moving the pages logic out of the walker. Basica... | 2013/01/27 | [
"https://wordpress.stackexchange.com/questions/83388",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26636/"
] | I've been messing around / searching for hours and still can't get this to work, so i'm finally giving in and asking for some help.
I'm trying to write a custom walker that shows only the current pages children, or if there are no children display the pages siblings.
For example, take the following menu tree:
* 1.0... | This is the walker I used to display only children of the current menu item. Or the menu items siblings if it doesn't have any children of its own.
There are comments throughout the class explaining each section
```
<?php
class SH_Child_Only_Walker extends Walker_Nav_Menu {
private $ID;
private $depth;
private $cla... |
83,403 | <p>I am trying to use <code>auth_redirect</code> to automatically redirected not logged-in visitors when then visit a specific page.
Here is the code I use:</p>
<pre><code>add_action('template_redirect','wpse16975_check_if_logged_in');
function wpse16975_check_if_logged_in(){
$pageid = 29;
if(is_page($pageid))... | [
{
"answer_id": 108402,
"author": "Fabien Quatravaux",
"author_id": 16975,
"author_profile": "https://wordpress.stackexchange.com/users/16975",
"pm_score": 3,
"selected": true,
"text": "<p>The problem is that this function is normally used in the backend. To use it in the frontend, you ne... | 2013/01/28 | [
"https://wordpress.stackexchange.com/questions/83403",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16975/"
] | I am trying to use `auth_redirect` to automatically redirected not logged-in visitors when then visit a specific page.
Here is the code I use:
```
add_action('template_redirect','wpse16975_check_if_logged_in');
function wpse16975_check_if_logged_in(){
$pageid = 29;
if(is_page($pageid)) auth_redirect();
}
```
... | The problem is that this function is normally used in the backend. To use it in the frontend, you need to add the following filter:
```
add_filter( 'auth_redirect_scheme', 'wpse16975_check_loggedin' );
function wpse16975_check_loggedin(){
return 'logged_in';
}
```
Then `auth_redirect()` will work as expected : r... |
83,415 | <p>I have installed wordpress Muilit Site (NETWORK) </p>
<p>I need to Remove / Rename <strong><code>Uncategorized</code></strong> Category In Wordpress. </p>
<p>How is this possible?</p>
| [
{
"answer_id": 83419,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 1,
"selected": false,
"text": "<p>In <code>wp-admin</code>, you can rename the <code>Uncategorized</code> category any time. Just go to <... | 2013/01/28 | [
"https://wordpress.stackexchange.com/questions/83415",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18746/"
] | I have installed wordpress Muilit Site (NETWORK)
I need to Remove / Rename **`Uncategorized`** Category In Wordpress.
How is this possible? | To change the default "Uncategorized" using code you can do the following:
```
// Uncategorized ID is always 1
wp_update_term(1, 'category', array(
'name' => 'hello',
'slug' => 'hello',
'description' => 'hi'
));
```
Read this: <http://codex.wordpress.org/Function_Reference/wp_update_term> |
83,434 | <p>With the new Gallery editor in Wordpress I am able to set up my galleries and to drag the Thumbnails to re-arrange the image order. On the backend that seems to work fine. But I ran into an issue when I try to display the gallery on the front end using the 'orderby' => 'menu_order' attribute. The display was not usi... | [
{
"answer_id": 83440,
"author": "david.binda",
"author_id": 14022,
"author_profile": "https://wordpress.stackexchange.com/users/14022",
"pm_score": 2,
"selected": false,
"text": "<p>it seems to me, after going through the source codes (both PHP and JS), that gallery and it's order is not... | 2013/01/28 | [
"https://wordpress.stackexchange.com/questions/83434",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15743/"
] | With the new Gallery editor in Wordpress I am able to set up my galleries and to drag the Thumbnails to re-arrange the image order. On the backend that seems to work fine. But I ran into an issue when I try to display the gallery on the front end using the 'orderby' => 'menu\_order' attribute. The display was not using... | it seems to me, after going through the source codes (both PHP and JS), that gallery and it's order is not saved to database at all. Gallery exists only in JS when you are creating that and even does not persist when you leave a post editing page.
Gallery gets saved only by inserting gallery shortcode with exact order... |
83,449 | <p>I had a custom post type with slug as (<strong>sometext</strong>) which I changed to (<strong>someothertext</strong>)
And it works great</p>
<p>So for example :</p>
<p>my posts with urls like </p>
<pre><code>http://localhost/sometext/innerposts
</code></pre>
<p>gets redirected to </p>
<pre><code>http://localhos... | [
{
"answer_id": 83450,
"author": "Mike Madern",
"author_id": 24806,
"author_profile": "https://wordpress.stackexchange.com/users/24806",
"pm_score": 2,
"selected": false,
"text": "<p>The link to the archive page is saved into WordPress rewrite rules. These rules are used to locate several... | 2013/01/28 | [
"https://wordpress.stackexchange.com/questions/83449",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20241/"
] | I had a custom post type with slug as (**sometext**) which I changed to (**someothertext**)
And it works great
So for example :
my posts with urls like
```
http://localhost/sometext/innerposts
```
gets redirected to
```
http://localhost/someothertext/innerposts
```
but not my archive page
basically I would ... | The link to the archive page is saved into WordPress rewrite rules. These rules are used to locate several locations on the front end of your WordPress system. When you change the `slug` of a Custom Post Type, the normal pages will redirect directly to the new location, but the archive page won't, this because the rewr... |
83,463 | <p>I'm trying to add languages to my wordpress driven website and i installed xili-languages plugin. Unfortunately it uses lang param to differentiate between languages and i rather have seen something like <a href="http://domain.com/cn/article-in-chinese/" rel="nofollow">http://domain.com/cn/article-in-chinese/</a> ra... | [
{
"answer_id": 109538,
"author": "RChanaud",
"author_id": 35810,
"author_profile": "https://wordpress.stackexchange.com/users/35810",
"pm_score": 0,
"selected": false,
"text": "<p>You would like to write:\n<code>http://domain.com/cn/article-in-chinese/</code>\nso that wordpress understan... | 2013/01/28 | [
"https://wordpress.stackexchange.com/questions/83463",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20565/"
] | I'm trying to add languages to my wordpress driven website and i installed xili-languages plugin. Unfortunately it uses lang param to differentiate between languages and i rather have seen something like <http://domain.com/cn/article-in-chinese/> rather than <http://domain.com/article-in-chinese/?lang=cn> | Set permalink to (Post Name)
or
```
http://www.example.com/[blog_name]`/%post_id%/%postname%/`
```
Add following code to `functions.php` of your theme:
```
add_filter ( 'alias_rule', 'xili_language_trans_slug_qv' ) ;
function xl_permalinks_init () {
global $XL_Permalinks_rules;
if (class_exists('XL_Perma... |
83,478 | <p>I am working on a custom theme, basically migrating a current sites look and feel into WordPress. Most of everything is based on Pages, and all of these pages should have a left sidebar. Of those pages, they are one of the 3 below:</p>
<ol>
<li>Page is part of a section, so shows a list of all parts of the section ... | [
{
"answer_id": 83486,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 1,
"selected": false,
"text": "<p>I not 100% clear what your question is so hopefully this can point you in the right direction for conditional widge... | 2013/01/28 | [
"https://wordpress.stackexchange.com/questions/83478",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17423/"
] | I am working on a custom theme, basically migrating a current sites look and feel into WordPress. Most of everything is based on Pages, and all of these pages should have a left sidebar. Of those pages, they are one of the 3 below:
1. Page is part of a section, so shows a list of all parts of the section in a widget
2... | I not 100% clear what your question is so hopefully this can point you in the right direction for conditional widgets. I will give you 3 options.
`1.` `is_active_widget` checks if widgets are active based in the widget ID.
* <http://codex.wordpress.org/Function_Reference/is_active_widget>
`2.` Using `is_active_sideb... |
83,480 | <p>Is there a way I can return the shortcode text instead of the output.</p>
<p>My code function is hooked into 'the_content' and I know if my function contain shortcode it will automatically generate the output. I just want to output shortcode text e.g [gallery]</p>
<pre><code>add_filter( 'the_content', 'show_on_fro... | [
{
"answer_id": 83482,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>If you want to literally echo \"this is example of shortcode : [gallery]\" with no shortcode processing then ... | 2013/01/28 | [
"https://wordpress.stackexchange.com/questions/83480",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26624/"
] | Is there a way I can return the shortcode text instead of the output.
My code function is hooked into 'the\_content' and I know if my function contain shortcode it will automatically generate the output. I just want to output shortcode text e.g [gallery]
```
add_filter( 'the_content', 'show_on_front', 10 );
function ... | Another way is to use a shortcode to display shortcodes :)
```
add_shortcode('SH','shortcode_display_handler');
function shortcode_display_handler($atts = array(),$content=null){
$content = str_replace("[","[",$content);
$content = str_replace("]","]",$content);
return $content;
}
```
Usage:
```... |
83,481 | <p>I modified my index.php to check if the search query is an author and if yes, display articles of that author.
That is working fine but as soon as you go to page 2 of the results, wordpress triggers a 404 error. So I guess Wordpress is not calling the index.php on <a href="http://www.test.com/page/2/?s=my+search+qu... | [
{
"answer_id": 83487,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": -1,
"selected": true,
"text": "<p><code>index.php</code> is the default template, the fallback.</p>\n\n<p>If we look here:</p>\n\n<p><a href=\"... | 2013/01/28 | [
"https://wordpress.stackexchange.com/questions/83481",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23974/"
] | I modified my index.php to check if the search query is an author and if yes, display articles of that author.
That is working fine but as soon as you go to page 2 of the results, wordpress triggers a 404 error. So I guess Wordpress is not calling the index.php on <http://www.test.com/page/2/?s=my+search+query> and I ... | `index.php` is the default template, the fallback.
If we look here:
<http://codex.wordpress.org/Template_Hierarchy>
And at the diagram:

We can see here that search.php is the appropriate template.
Have you considered using author.php and the aut... |
83,491 | <p>I am using the folowing to get child title and content. Each child has a gallery and a short code in the content editor in the content, but I only get the gallery and not shortcode. It isn't something to do with the short code but rather on the content as I tried to add some paragraph to the content after the galler... | [
{
"answer_id": 83495,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 2,
"selected": false,
"text": "<p>I would like to suggest you to use <code>WP_Query</code> to fetch pages from db:</p>\n\n<pre><code>$the_... | 2013/01/28 | [
"https://wordpress.stackexchange.com/questions/83491",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26593/"
] | I am using the folowing to get child title and content. Each child has a gallery and a short code in the content editor in the content, but I only get the gallery and not shortcode. It isn't something to do with the short code but rather on the content as I tried to add some paragraph to the content after the gallery a... | This is how i resolved it:
```
<?php
/*
Template Name: home
*/
get_header(); ?>
<?php $counter = 1 ?>
<div class="row-fluid">
<?php
$args = array(
'child_of' => 4,
'parent' => 0,
'post_type' => 'page',
'post_status' => 'publish'
);
$childrens = query_posts('showposts=3&post_parent=4&post_type=page... |
83,498 | <p>I'm looking for a custom permalink plugin that is able to interact with menu classes.</p>
<p>For instance, I have a menu that includes the parent <code>website.com/shop</code> as one of its list items. If a page, say <code>website.com/shop/product</code>, includes that menu, the list item for <code>website.com/shop... | [
{
"answer_id": 83495,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 2,
"selected": false,
"text": "<p>I would like to suggest you to use <code>WP_Query</code> to fetch pages from db:</p>\n\n<pre><code>$the_... | 2013/01/28 | [
"https://wordpress.stackexchange.com/questions/83498",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26675/"
] | I'm looking for a custom permalink plugin that is able to interact with menu classes.
For instance, I have a menu that includes the parent `website.com/shop` as one of its list items. If a page, say `website.com/shop/product`, includes that menu, the list item for `website.com/shop` will get a class, something like `c... | This is how i resolved it:
```
<?php
/*
Template Name: home
*/
get_header(); ?>
<?php $counter = 1 ?>
<div class="row-fluid">
<?php
$args = array(
'child_of' => 4,
'parent' => 0,
'post_type' => 'page',
'post_status' => 'publish'
);
$childrens = query_posts('showposts=3&post_parent=4&post_type=page... |
83,506 | <p>I have a question regarding <a href="http://www.gravityhelp.com/documentation/page/Gform_pre_render" rel="noreferrer">gform_pre_render</a>?</p>
<p>I have dealer form. Which basically you choose your county, and then your dealer.</p>
<p><strong>Dropdown A = Dealer Country<br />
Dropdown B = Dealer Name</strong></p>... | [
{
"answer_id": 83556,
"author": "webaware",
"author_id": 24260,
"author_profile": "https://wordpress.stackexchange.com/users/24260",
"pm_score": 1,
"selected": false,
"text": "<p>The easy way, and one that should with or without AJAX or JavaScript, is to have the dealer county drop-down ... | 2013/01/28 | [
"https://wordpress.stackexchange.com/questions/83506",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11327/"
] | I have a question regarding [gform\_pre\_render](http://www.gravityhelp.com/documentation/page/Gform_pre_render)?
I have dealer form. Which basically you choose your county, and then your dealer.
**Dropdown A = Dealer Country
Dropdown B = Dealer Name**
I have about 15 countries, and I am using get\_terms in the g... | Eventually the solution I used was this. Upon change of Dropdown A I have an ajax function request tha re-populated Downdown B with the filtered options based on the selection in Dropdown A.
See the ajax jquery script...
```
countryFilter = function () {
var countryClass = '.dealer-country select',
deal... |
83,508 | <p>I want to have a picture or multiple pictures on each page in wordpress.</p>
<p>AFAIK there are two standart ways of doing this</p>
<ol>
<li><p>in WYSIWYG editor, attach file etc</p></li>
<li><p>widgets.</p></li>
</ol>
<p>Problem is, those wont do for my clients.</p>
<p>So how can I make a custom field on each p... | [
{
"answer_id": 83556,
"author": "webaware",
"author_id": 24260,
"author_profile": "https://wordpress.stackexchange.com/users/24260",
"pm_score": 1,
"selected": false,
"text": "<p>The easy way, and one that should with or without AJAX or JavaScript, is to have the dealer county drop-down ... | 2013/01/28 | [
"https://wordpress.stackexchange.com/questions/83508",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26678/"
] | I want to have a picture or multiple pictures on each page in wordpress.
AFAIK there are two standart ways of doing this
1. in WYSIWYG editor, attach file etc
2. widgets.
Problem is, those wont do for my clients.
So how can I make a custom field on each page, where the user selects a pic if he wants.
I know there ... | Eventually the solution I used was this. Upon change of Dropdown A I have an ajax function request tha re-populated Downdown B with the filtered options based on the selection in Dropdown A.
See the ajax jquery script...
```
countryFilter = function () {
var countryClass = '.dealer-country select',
deal... |
83,514 | <p>Hey I get this error messages on my localhost setup, but only with the Genesis Framework enabled; WordPress Twenty Eleven works fine. This happens when I want to create a new post. If I refresh the page the error will repeat, but the post itself gets created and everything seems to go fine.</p>
<p>Does anyone know ... | [
{
"answer_id": 84205,
"author": "Chris_O",
"author_id": 251,
"author_profile": "https://wordpress.stackexchange.com/users/251",
"pm_score": 5,
"selected": true,
"text": "<h1>You have found a bug in Genesis.</h1>\n<p>Your Xdebug stack trace fingers the culprit as the <code>genesis_save_cu... | 2013/01/28 | [
"https://wordpress.stackexchange.com/questions/83514",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25537/"
] | Hey I get this error messages on my localhost setup, but only with the Genesis Framework enabled; WordPress Twenty Eleven works fine. This happens when I want to create a new post. If I refresh the page the error will repeat, but the post itself gets created and everything seems to go fine.
Does anyone know what cause... | You have found a bug in Genesis.
================================
Your Xdebug stack trace fingers the culprit as the `genesis_save_custom_fields()` function which calls [`current_user_can()`](http://codex.wordpress.org/Function_Reference/current_user_can) with a singular capability (edit\_post and edit\_page) which al... |
83,525 | <p>I'm developing a plugin that doesn't use a custom post type, but separate database tables.
It's a plugin that displays a list of courses with links that lead to the different course detail pages, where the user then can subscribe for a course.</p>
<p>In the current state, I'm using a shortcode to get the plugins dat... | [
{
"answer_id": 83632,
"author": "theMojoWill",
"author_id": 20503,
"author_profile": "https://wordpress.stackexchange.com/users/20503",
"pm_score": 0,
"selected": false,
"text": "<p>Try using <a href=\"http://codex.wordpress.org/Conditional_Tags\" rel=\"nofollow\">conditional tags</a> to... | 2013/01/28 | [
"https://wordpress.stackexchange.com/questions/83525",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22506/"
] | I'm developing a plugin that doesn't use a custom post type, but separate database tables.
It's a plugin that displays a list of courses with links that lead to the different course detail pages, where the user then can subscribe for a course.
In the current state, I'm using a shortcode to get the plugins data into a ... | I would use the [**`is_page_template()`**](http://codex.wordpress.org/Function_Reference/is_page_template) conditional:
```
if ( is_page_template( 'page-courses.php' ) ) {
// The current page uses your
// custom page template;
// do something
}
```
Edit
----
You would use this conditional *inside* your ... |
83,531 | <p>I created a custom post type, of which the (simplified) arguments are:</p>
<pre><code>register_post_type(
'Event',
'public' => true,
'rewrite' => array( 'slug' => 'eventy'),
'has_archive' => false,
'hierarchical' => false
)
</code></pre>
<p>It works fine in general. However if I ... | [
{
"answer_id": 83668,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": true,
"text": "<p>Step 1, add the rewrite tags for custom event year and month query vars, then register the event post type with thos... | 2013/01/28 | [
"https://wordpress.stackexchange.com/questions/83531",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26682/"
] | I created a custom post type, of which the (simplified) arguments are:
```
register_post_type(
'Event',
'public' => true,
'rewrite' => array( 'slug' => 'eventy'),
'has_archive' => false,
'hierarchical' => false
)
```
It works fine in general. However if I try to rewrite the URLs in `functions.php... | Step 1, add the rewrite tags for custom event year and month query vars, then register the event post type with those tags in the slug argument of the rewrite argument:
```
function wpa83531_register_event_post_type(){
add_rewrite_tag('%event_year%','(\d+)');
add_rewrite_tag('%event_month%','(.+)');
regi... |
83,547 | <p>I'm transitioning all my query_posts queries to get_posts after a lot of research about how bad it is for performance. My solution is get_posts but working with it is confusing me.
Here is what I have:</p>
<pre><code> $posts = get_posts('showposts=-1&offest=10&post_type=any');
foreach ($posts... | [
{
"answer_id": 83552,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": true,
"text": "<blockquote>\n <p>How do I get dynamic parameters into the array,...</p>\n</blockquote>\n\n<p><a href=\"http://c... | 2013/01/29 | [
"https://wordpress.stackexchange.com/questions/83547",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18726/"
] | I'm transitioning all my query\_posts queries to get\_posts after a lot of research about how bad it is for performance. My solution is get\_posts but working with it is confusing me.
Here is what I have:
```
$posts = get_posts('showposts=-1&offest=10&post_type=any');
foreach ($posts as $post) :
... | >
> How do I get dynamic parameters into the array,...
>
>
>
[This example from the Codex](http://codex.wordpress.org/Class_Reference/WP_Query#Sticky_Post_Parameters) demonstrates that:
```
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$sticky = get_option( 'sticky_posts' );
$args = array(
... |
83,555 | <p>I have one weird thing happening with lightbox on my website. If I add a lightbox image or gallery and then click on the image, the first time it will navigate directly to the image file. If you then click the back button and click the image again, lightbox loads up normally. </p>
<p>Any thoughts on why reloading t... | [
{
"answer_id": 83552,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": true,
"text": "<blockquote>\n <p>How do I get dynamic parameters into the array,...</p>\n</blockquote>\n\n<p><a href=\"http://c... | 2013/01/29 | [
"https://wordpress.stackexchange.com/questions/83555",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26548/"
] | I have one weird thing happening with lightbox on my website. If I add a lightbox image or gallery and then click on the image, the first time it will navigate directly to the image file. If you then click the back button and click the image again, lightbox loads up normally.
Any thoughts on why reloading the page af... | >
> How do I get dynamic parameters into the array,...
>
>
>
[This example from the Codex](http://codex.wordpress.org/Class_Reference/WP_Query#Sticky_Post_Parameters) demonstrates that:
```
$paged = get_query_var( 'paged' ) ? get_query_var( 'paged' ) : 1;
$sticky = get_option( 'sticky_posts' );
$args = array(
... |
83,563 | <p>I've seen a couple of discussions about getting Wordpress to regenerate a unique nonce for subsequent Ajax requests, but for the life of me I can't actually get Wordpress to do it-- every time I request what I think should be a new nonce, I get the same nonce back from Wordpress. I understand the concept of WP's non... | [
{
"answer_id": 84120,
"author": "Tim",
"author_id": 26696,
"author_profile": "https://wordpress.stackexchange.com/users/26696",
"pm_score": 4,
"selected": true,
"text": "<p>Here's a very lengthy answer of my own question that goes beyond just addressing the question of generating unique ... | 2013/01/29 | [
"https://wordpress.stackexchange.com/questions/83563",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26696/"
] | I've seen a couple of discussions about getting Wordpress to regenerate a unique nonce for subsequent Ajax requests, but for the life of me I can't actually get Wordpress to do it-- every time I request what I think should be a new nonce, I get the same nonce back from Wordpress. I understand the concept of WP's nonce\... | Here's a very lengthy answer of my own question that goes beyond just addressing the question of generating unique nonces for subsequent Ajax requests. This is an "add to favorites" feature that was made generic for the purposes of the answer (my feature lets users add the post IDs of photo attachments to a list of fav... |
83,568 | <p>After researching a lot I found that there are quite a few very common issues with the "Yoast SEO plugin" that haven't been resolved yet.
I also ran into those issues (which is why I was researching) and strangely enough there are no solutions for many of those issues yet, although they are so common.</p>
<p>Many u... | [
{
"answer_id": 83793,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": true,
"text": "<p>You have two titles because Yoast adds an og:title tag, and then you add another one with your own code, what's unex... | 2013/01/29 | [
"https://wordpress.stackexchange.com/questions/83568",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6903/"
] | After researching a lot I found that there are quite a few very common issues with the "Yoast SEO plugin" that haven't been resolved yet.
I also ran into those issues (which is why I was researching) and strangely enough there are no solutions for many of those issues yet, although they are so common.
Many users of th... | You have two titles because Yoast adds an og:title tag, and then you add another one with your own code, what's unexpected about this result? so remove the one you add with your code, problem solved.
[Facebook's Debugger](http://zoomingjapan.com/travel/hiraizumi-motsuji-temple/) doesn't like your page because you have... |
83,578 | <p>I'm looking to set a default value to a specific custom field, in case the client doesn't add into the custom field it already has a specific number associated with it. </p>
<p>one step deeper, I'd like it so if cat =22 is selected this custom field is automatically added into the post with a default that hopefully... | [
{
"answer_id": 83583,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 1,
"selected": false,
"text": "<p>You would not do this via a global, you simply use the default functionality of <code>add_post_meta</code>.</p>\n\n... | 2013/01/29 | [
"https://wordpress.stackexchange.com/questions/83578",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26705/"
] | I'm looking to set a default value to a specific custom field, in case the client doesn't add into the custom field it already has a specific number associated with it.
one step deeper, I'd like it so if cat =22 is selected this custom field is automatically added into the post with a default that hopefully the clien... | You can check it by adding a hook to `save_post` action. In this way all your posts will have default value for a custom field.
```
add_action( 'save_post', 'wpse8170_save_post', 10, 2 );
function wpse8170_save_post( $post_id, WP_Post $post ) {
if ( ( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOSAVE ) || !current_use... |
83,587 | <p>I want to display list of all posts under a couple of categories and some individual posts. If I use the following code, it does not return anything, as it looks for those individual posts in the categories.</p>
<pre><code>query_posts( array ( 'category__in' => array( 28, 34 ), 'post__in' => array( 8200, 3581... | [
{
"answer_id": 83591,
"author": "Simon",
"author_id": 10889,
"author_profile": "https://wordpress.stackexchange.com/users/10889",
"pm_score": 1,
"selected": false,
"text": "<p>The problem here is that <code>WP_Query</code> requires the posts returned to be both in your lists of post IDs ... | 2013/01/29 | [
"https://wordpress.stackexchange.com/questions/83587",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17234/"
] | I want to display list of all posts under a couple of categories and some individual posts. If I use the following code, it does not return anything, as it looks for those individual posts in the categories.
```
query_posts( array ( 'category__in' => array( 28, 34 ), 'post__in' => array( 8200, 3581, 38, 1562, 7613 )) ... | The problem here is that `WP_Query` requires the posts returned to be both in your lists of post IDs *and* in one of your categories. The SQL query generated by your code looks something like this:
```
SELECT SQL_CALC_FOUND_ROWS wp_posts.ID FROM wp_posts INNER JOIN wp_term_relationships ON (wp_posts.ID = wp_term_relat... |
83,594 | <p>I have a <code>new WP_Query</code> that I use to generate a custom loop and display a set of posts. One of the things the query does is provide pagination.</p>
<p>Before I display the queried posts though, I'd like to get a list of all the tags for the posts found. I know I can do this by looping through each of th... | [
{
"answer_id": 83600,
"author": "Simon",
"author_id": 10889,
"author_profile": "https://wordpress.stackexchange.com/users/10889",
"pm_score": 2,
"selected": true,
"text": "<p>I don't think that is possible. The SQL query performed by <code>WP_Query</code> returns only the post objects (a... | 2013/01/29 | [
"https://wordpress.stackexchange.com/questions/83594",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26709/"
] | I have a `new WP_Query` that I use to generate a custom loop and display a set of posts. One of the things the query does is provide pagination.
Before I display the queried posts though, I'd like to get a list of all the tags for the posts found. I know I can do this by looping through each of the posts and then remo... | I don't think that is possible. The SQL query performed by `WP_Query` returns only the post objects (and perhaps some metadata), while the tags resides in a different table. When looping through the returned posts in templates you usually put `the_tags();` or something similar in your templates, which in turns runs a n... |
83,602 | <p>I running WordPress on <code>IIS & SQL server</code>. As some of the plugins do not work correctly with <strong>DB ABSTRACTION</strong> I am using a lot of <code>functions.php</code> filters as so on.</p>
<p>To make my search results <strong>include tags</strong> I have added the following code to my <code>func... | [
{
"answer_id": 83600,
"author": "Simon",
"author_id": 10889,
"author_profile": "https://wordpress.stackexchange.com/users/10889",
"pm_score": 2,
"selected": true,
"text": "<p>I don't think that is possible. The SQL query performed by <code>WP_Query</code> returns only the post objects (a... | 2013/01/29 | [
"https://wordpress.stackexchange.com/questions/83602",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17269/"
] | I running WordPress on `IIS & SQL server`. As some of the plugins do not work correctly with **DB ABSTRACTION** I am using a lot of `functions.php` filters as so on.
To make my search results **include tags** I have added the following code to my `functions.php` - <http://pastebin.com/BZG20McY>
My search results now ... | I don't think that is possible. The SQL query performed by `WP_Query` returns only the post objects (and perhaps some metadata), while the tags resides in a different table. When looping through the returned posts in templates you usually put `the_tags();` or something similar in your templates, which in turns runs a n... |
83,643 | <blockquote>
<p><strong>Possible Duplicate:</strong><br>
<a href="https://wordpress.stackexchange.com/questions/4696/pagination-not-working-with-custom-loop">Pagination not working with custom loop</a> </p>
</blockquote>
<p>So I have a post type called portfolio, but I can't get it to paginate.
I'd also like it... | [
{
"answer_id": 83622,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 3,
"selected": true,
"text": "<p>If it's a new domain, it's pretty simple:</p>\n\n<ol>\n<li>Install WordPress on the NEW domain</li>\n<li>Cop... | 2013/01/29 | [
"https://wordpress.stackexchange.com/questions/83643",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22450/"
] | >
> **Possible Duplicate:**
>
> [Pagination not working with custom loop](https://wordpress.stackexchange.com/questions/4696/pagination-not-working-with-custom-loop)
>
>
>
So I have a post type called portfolio, but I can't get it to paginate.
I'd also like it to paginate on single pages so each item has a pre... | If it's a new domain, it's pretty simple:
1. Install WordPress on the NEW domain
2. Copy `wp-content/themes` and `wp-content/plugin` from the OLD domain to the NEW domain (using FTP)
3. Activate the Theme on the NEW domain
4. Activate Plugins on the NEW domain
5. Delete generic content (hello world post, about page, e... |
83,647 | <p>the template function as a callback argument of <code>wp_list_comments</code> function, and the template function takes three args:<code>$comment, $args, $depth</code>, like the template function that defined in the theme <code>twentyeleven</code>'s functions.php,</p>
<pre><code>function twentyeleven_comment( $comm... | [
{
"answer_id": 83657,
"author": "david.binda",
"author_id": 14022,
"author_profile": "https://wordpress.stackexchange.com/users/14022",
"pm_score": 1,
"selected": false,
"text": "<p>Just go ahead and call it in the same way the tventyeleven does:</p>\n\n<pre><code><?php\n ... | 2013/01/29 | [
"https://wordpress.stackexchange.com/questions/83647",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26723/"
] | the template function as a callback argument of `wp_list_comments` function, and the template function takes three args:`$comment, $args, $depth`, like the template function that defined in the theme `twentyeleven`'s functions.php,
```
function twentyeleven_comment( $comment, $args, $depth ) {
$GLOBALS['comment'] = $c... | Well, I have the solution.
first, use the global variable $comment\_depth, pass it to `twentyeleven_comment()` function, and in the `twentyeleven_comment()` function, define a new variable named `$defaults` like this:
```
function twentyeleven_comment( $comment, $args, $depth ) {
$defaults = array('walker' => nul... |
83,649 | <p>can anyone help me split this custom post type into two lists? i'm a novice PHPr but have been left with this code by someone who said it was too complicated...</p>
<pre><code>function listforcontinent($name, $top = false){
// top=true - show name, no columns
// top=false - dont show name, columns
$slu... | [
{
"answer_id": 83657,
"author": "david.binda",
"author_id": 14022,
"author_profile": "https://wordpress.stackexchange.com/users/14022",
"pm_score": 1,
"selected": false,
"text": "<p>Just go ahead and call it in the same way the tventyeleven does:</p>\n\n<pre><code><?php\n ... | 2013/01/29 | [
"https://wordpress.stackexchange.com/questions/83649",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26724/"
] | can anyone help me split this custom post type into two lists? i'm a novice PHPr but have been left with this code by someone who said it was too complicated...
```
function listforcontinent($name, $top = false){
// top=true - show name, no columns
// top=false - dont show name, columns
$slugname = saniti... | Well, I have the solution.
first, use the global variable $comment\_depth, pass it to `twentyeleven_comment()` function, and in the `twentyeleven_comment()` function, define a new variable named `$defaults` like this:
```
function twentyeleven_comment( $comment, $args, $depth ) {
$defaults = array('walker' => nul... |
83,650 | <p>I love admin-ajax.php. But I hate having to localize in order to point frontend scripts to it, and I wish there was an equivalent, easy-to-find file for themes. (It also just bothers me to see frontend requests go through "/wp-admin/". No practical reason, just looks ugly IMO.)</p>
<p>So I've simply copied admin-aj... | [
{
"answer_id": 83652,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 5,
"selected": true,
"text": "<p>You could just use a RewriteRule to your .htaccess above the regular permalink rewrite rules:</p>\n\n<pre><code>Rewrite... | 2013/01/29 | [
"https://wordpress.stackexchange.com/questions/83650",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1537/"
] | I love admin-ajax.php. But I hate having to localize in order to point frontend scripts to it, and I wish there was an equivalent, easy-to-find file for themes. (It also just bothers me to see frontend requests go through "/wp-admin/". No practical reason, just looks ugly IMO.)
So I've simply copied admin-ajax.php to ... | You could just use a RewriteRule to your .htaccess above the regular permalink rewrite rules:
```
RewriteRule ^ajax$ /wp-admin/admin-ajax.php [L]
```
Now send your AJAX requests to `example.com/ajax`, and never miss core changes to that file after upgrades. |
83,660 | <p>I have made a page where you people can find al the teasers (teaser made with the read more tag) from my posts.( By clicking one of them you "open" the whole article, including photo's, ... . This is working well.
On my homepage I want a short welcome text and in a sidebar my 3 recent posts.
I'm first trying to get... | [
{
"answer_id": 83661,
"author": "AndyWarren",
"author_id": 23672,
"author_profile": "https://wordpress.stackexchange.com/users/23672",
"pm_score": 0,
"selected": false,
"text": "<p>Add <code><?php global $more; $more = 0; ?></code> right after/below <code>while ($rPosts->have_po... | 2013/01/29 | [
"https://wordpress.stackexchange.com/questions/83660",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26465/"
] | I have made a page where you people can find al the teasers (teaser made with the read more tag) from my posts.( By clicking one of them you "open" the whole article, including photo's, ... . This is working well.
On my homepage I want a short welcome text and in a sidebar my 3 recent posts.
I'm first trying to get th... | First, ensure that your template file is named `home.php`.
Second, there's no need to use a custom query loop in this context. If you only want to display 3 posts on the blog posts index (i.e. the "homepage"), then filter the main loop query via `pre_get_posts`:
```
function wpse83660_filter_pre_get_posts( $query ) {... |
83,675 | <p>A rare event - I want to do something in WordPress but have no idea how to go about it and searching turns up literally nothing.</p>
<p>When you're inserting an image into a post, you get alignment options: 'none', 'left', 'right', 'center'. These result in the image being inserted with a CSS class related to align... | [
{
"answer_id": 83677,
"author": "Pavlos Bizimis",
"author_id": 18619,
"author_profile": "https://wordpress.stackexchange.com/users/18619",
"pm_score": 0,
"selected": false,
"text": "<p>Maybe you should create a shortcode for inserting the image with class attributes. I´ve seen this in a ... | 2013/01/29 | [
"https://wordpress.stackexchange.com/questions/83675",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4702/"
] | A rare event - I want to do something in WordPress but have no idea how to go about it and searching turns up literally nothing.
When you're inserting an image into a post, you get alignment options: 'none', 'left', 'right', 'center'. These result in the image being inserted with a CSS class related to alignment, like... | I agree with [david-binda](https://wordpress.stackexchange.com/users/14022/david-binda) - great question! I've run in to this problem on a number of occasions and come up with a solution that works pretty well. While I do like the idea of adding a shortcode to insert the image with classes as suggested by [pavlos-bizim... |
83,679 | <p>I would like to require a featured image on a site I am developing.</p>
<p>I tried the code here: <a href="https://wordpress.stackexchange.com/questions/74464/make-featured-image-required">Make featured image required</a> and nothing happened - the JS showed up in the site header, but I could still save the post wi... | [
{
"answer_id": 84574,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 2,
"selected": false,
"text": "<p>I would do this by hooking into the <code>save_post</code> action, not by javascript.</p>\n\n<p>The main idea i... | 2013/01/29 | [
"https://wordpress.stackexchange.com/questions/83679",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16808/"
] | I would like to require a featured image on a site I am developing.
I tried the code here: [Make featured image required](https://wordpress.stackexchange.com/questions/74464/make-featured-image-required) and nothing happened - the JS showed up in the site header, but I could still save the post without a featured imag... | Here's what I ended up doing:
```
jQuery('#post').submit(function() {
if (jQuery('.force').is(':checked')) {
if (jQuery("#set-post-thumbnail").find('img').size() > 0) {
jQuery('#ajax-loading').hide();
jQuery('#publish').removeClass('button-primary-disable... |
83,685 | <p>OK I'm doing a a menu (sidebar menu) that will display this all child pages of parent page (currently open)<br/>
Parent <br/>
|-Child 1<br/>
|-Child 2<br/>
|<em>Child 3<br/>
<br/>
but in same time when someone is in bolded page (child) will see the same thing<br/>
Parent <br/>
|-Child 1<br/>
_</em> _|-Child 1<br/>
_... | [
{
"answer_id": 84574,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 2,
"selected": false,
"text": "<p>I would do this by hooking into the <code>save_post</code> action, not by javascript.</p>\n\n<p>The main idea i... | 2013/01/29 | [
"https://wordpress.stackexchange.com/questions/83685",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26737/"
] | OK I'm doing a a menu (sidebar menu) that will display this all child pages of parent page (currently open)
Parent
|-Child 1
|-Child 2
|*Child 3
but in same time when someone is in bolded page (child) will see the same thing
Parent
|-Child 1
\_* \_|-Child 1
\_ \_|**-Child 2**
\_ \_|- Ch... | Here's what I ended up doing:
```
jQuery('#post').submit(function() {
if (jQuery('.force').is(':checked')) {
if (jQuery("#set-post-thumbnail").find('img').size() > 0) {
jQuery('#ajax-loading').hide();
jQuery('#publish').removeClass('button-primary-disable... |
83,687 | <p>I want to change the login URL per a client request.</p>
<p>so, instead of mysite.com/wp-login.php</p>
<p>or mysite.com/wp-admin</p>
<p>it is this: mysite.com/someotherpagename.php<br>
or mysite.com/someotherpagename</p>
<p>I do not want to use /login. It's too obvious, per the client.</p>
<p>Thanks in advance.... | [
{
"answer_id": 83714,
"author": "Rafael Marques",
"author_id": 25562,
"author_profile": "https://wordpress.stackexchange.com/users/25562",
"pm_score": 1,
"selected": false,
"text": "<p>Open your .htaccess file and add Rewrite Rules:</p>\n\n<pre><code>RewriteRule ^myregister/?$ /wp-login.... | 2013/01/29 | [
"https://wordpress.stackexchange.com/questions/83687",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26739/"
] | I want to change the login URL per a client request.
so, instead of mysite.com/wp-login.php
or mysite.com/wp-admin
it is this: mysite.com/someotherpagename.php
or mysite.com/someotherpagename
I do not want to use /login. It's too obvious, per the client.
Thanks in advance. | Open your .htaccess file and add Rewrite Rules:
```
RewriteRule ^myregister/?$ /wp-login.php?action=register [QSA,L]
RewriteRule ^mylogin/?$ /wp-login.php [QSA,L]
```
If your wordpress installed in a subdirectory:
```
RewriteRule ^myregister/?$ /subdirectory/wp-login.php?action=register [QSA,L]
RewriteRule ^mylogin... |
83,688 | <p>I'm trying to use get_template_part to retrieve a template file based on the current post type (slug) the user is in. The template file just includes an image that is used specific to specific post types.</p>
<pre><code><?php get_template_part('parts/get_post_type( $post )') ?><p id="t3-splash-title">&l... | [
{
"answer_id": 83714,
"author": "Rafael Marques",
"author_id": 25562,
"author_profile": "https://wordpress.stackexchange.com/users/25562",
"pm_score": 1,
"selected": false,
"text": "<p>Open your .htaccess file and add Rewrite Rules:</p>\n\n<pre><code>RewriteRule ^myregister/?$ /wp-login.... | 2013/01/29 | [
"https://wordpress.stackexchange.com/questions/83688",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20910/"
] | I'm trying to use get\_template\_part to retrieve a template file based on the current post type (slug) the user is in. The template file just includes an image that is used specific to specific post types.
```
<?php get_template_part('parts/get_post_type( $post )') ?><p id="t3-splash-title"><?php $post_type = get_pos... | Open your .htaccess file and add Rewrite Rules:
```
RewriteRule ^myregister/?$ /wp-login.php?action=register [QSA,L]
RewriteRule ^mylogin/?$ /wp-login.php [QSA,L]
```
If your wordpress installed in a subdirectory:
```
RewriteRule ^myregister/?$ /subdirectory/wp-login.php?action=register [QSA,L]
RewriteRule ^mylogin... |
83,689 | <p>I'm trying to get allow only lowercase usernames are valid usernames in my wordpress blog.
I managed to write a function but it does not seem to work. </p>
<pre><code>add_filter('validate_username' , 'simple_user', 1, 2);
function simple_user($valid, $username ) {
if (preg_match("/[a-z0-9]+/", $user... | [
{
"answer_id": 83726,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>The filter <code>validate_username</code> sends and expects a <em>boolean</em> value, not a string.</p>\n\n<p>Hook into... | 2013/01/29 | [
"https://wordpress.stackexchange.com/questions/83689",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25563/"
] | I'm trying to get allow only lowercase usernames are valid usernames in my wordpress blog.
I managed to write a function but it does not seem to work.
```
add_filter('validate_username' , 'simple_user', 1, 2);
function simple_user($valid, $username ) {
if (preg_match("/[a-z0-9]+/", $username)) {
... | The filter `validate_username` sends and expects a *boolean* value, not a string.
Hook into `sanitize_user` and use `mb_strtolower()`.
Sample code, not tested:
```
add_filter( 'sanitize_user', 'wpse_83689_lower_case_user_name' );
function wpse_83689_lower_case_user_name( $name )
{
// might be turned off
if ... |
83,698 | <p>I've been banging my head against a wall on this one for a while but I'm not quite sure from all the tutorials I read how to see why this isn't doing what I expect.</p>
<p>I have a page called <code>shop-guide/shop-page?id=412</code> (for example)</p>
<p>and I want to change it so it it's <code>shop-guide/shop-pag... | [
{
"answer_id": 83699,
"author": "WP Themes",
"author_id": 25649,
"author_profile": "https://wordpress.stackexchange.com/users/25649",
"pm_score": 0,
"selected": false,
"text": "<p>I believe you first need to register your custom querystring variable. You could use <code>add_rewrite_tag</... | 2013/01/29 | [
"https://wordpress.stackexchange.com/questions/83698",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26743/"
] | I've been banging my head against a wall on this one for a while but I'm not quite sure from all the tutorials I read how to see why this isn't doing what I expect.
I have a page called `shop-guide/shop-page?id=412` (for example)
and I want to change it so it it's `shop-guide/shop-page/id/412/`
As far as I can tell ... | Two issues -
your rewrite rule isn't formatted correctly, this:
```
'shop-guide/shop-page/id/([^/]*)/'
```
should be:
```
'shop-guide/shop-page/id/([^/]*)/?$'
```
and if `shop-guide` and `shop-page` are parent / child pages, this:
```
'index.php?p=143&id=$matches[1]'
```
should be:
```
'index.php?pagename=sh... |
83,700 | <p>I am try to insert link to my thumbnail images, the link is hyperlink with post. When i put this code inside the loop then instead of showing the first image, first show the second image (template_url) </p>
<pre><code><a href="<?php the_permalink() ?>" class="alignnone" title="<?php the_title(); ?>"&... | [
{
"answer_id": 83699,
"author": "WP Themes",
"author_id": 25649,
"author_profile": "https://wordpress.stackexchange.com/users/25649",
"pm_score": 0,
"selected": false,
"text": "<p>I believe you first need to register your custom querystring variable. You could use <code>add_rewrite_tag</... | 2013/01/30 | [
"https://wordpress.stackexchange.com/questions/83700",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I am try to insert link to my thumbnail images, the link is hyperlink with post. When i put this code inside the loop then instead of showing the first image, first show the second image (template\_url)
```
<a href="<?php the_permalink() ?>" class="alignnone" title="<?php the_title(); ?>">
<?php if (has_post_thumbnai... | Two issues -
your rewrite rule isn't formatted correctly, this:
```
'shop-guide/shop-page/id/([^/]*)/'
```
should be:
```
'shop-guide/shop-page/id/([^/]*)/?$'
```
and if `shop-guide` and `shop-page` are parent / child pages, this:
```
'index.php?p=143&id=$matches[1]'
```
should be:
```
'index.php?pagename=sh... |
83,704 | <p>I have two kind of post types in my WordPress website:</p>
<ol>
<li>"Articles" which is the classic post type</li>
<li>"Breves" which is a custom post type</li>
</ol>
<p>I want them to share the same standard categories and post tags so this is how I created the "Breve" custom post type as a plugin:</p>
<pre><cod... | [
{
"answer_id": 83709,
"author": "liying",
"author_id": 24490,
"author_profile": "https://wordpress.stackexchange.com/users/24490",
"pm_score": 0,
"selected": false,
"text": "<p>why not try this plugin: <a href=\"http://webdevstudios.com/plugin/custom-post-type-ui/\" rel=\"nofollow\">Cust... | 2013/01/30 | [
"https://wordpress.stackexchange.com/questions/83704",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22755/"
] | I have two kind of post types in my WordPress website:
1. "Articles" which is the classic post type
2. "Breves" which is a custom post type
I want them to share the same standard categories and post tags so this is how I created the "Breve" custom post type as a plugin:
```
function breve_register() {
$labels =... | The admin menu is kind of a pain to work with, it's not very flexible and is in need of an overhaul. See [this ongoing ticket](http://core.trac.wordpress.org/ticket/12718) on the subject.
What you can do is use the [`remove_submenu_page`](http://codex.wordpress.org/Function_Reference/remove_submenu_page) function to r... |
83,712 | <p>I want to add a menu that belongs to parent multisite blog to all child-blogs. I need the menu displayed in all child-blogs, I mean the same menu on all multisites blogs. How I can do that?</p>
| [
{
"answer_id": 83722,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 0,
"selected": false,
"text": "<p>Use a plugin header to force network activation:</p>\n\n<pre><code>Network: true\n</code></pre>\n\n<p>Register the men... | 2013/01/30 | [
"https://wordpress.stackexchange.com/questions/83712",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22663/"
] | I want to add a menu that belongs to parent multisite blog to all child-blogs. I need the menu displayed in all child-blogs, I mean the same menu on all multisites blogs. How I can do that? | Well, thanks to **@toscho** ... For your help I found a way to achieve show the primary nav that belongs to parent blog to all child blogs:
```
/**
* Plugin Name: Network Primary Nav
* Network: true
*/
add_filter( 'wp_nav_menu_objects', 'network_primary_nav', 100, 2 );
function network_primary_nav( $menu_items, $... |
83,739 | <p>I wish to style the active link (ie. when home page is selected that the home page link be a different colour)</p>
<pre><code>.current-menu-item a { color: #36c; }
</code></pre>
<p>My test site is : www.milknhny.co.uk/ShopTest</p>
<p>I placed this in the CSS as i believe this was the class that i wished to change... | [
{
"answer_id": 83722,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 0,
"selected": false,
"text": "<p>Use a plugin header to force network activation:</p>\n\n<pre><code>Network: true\n</code></pre>\n\n<p>Register the men... | 2013/01/30 | [
"https://wordpress.stackexchange.com/questions/83739",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23874/"
] | I wish to style the active link (ie. when home page is selected that the home page link be a different colour)
```
.current-menu-item a { color: #36c; }
```
My test site is : www.milknhny.co.uk/ShopTest
I placed this in the CSS as i believe this was the class that i wished to change, however it does not appear to h... | Well, thanks to **@toscho** ... For your help I found a way to achieve show the primary nav that belongs to parent blog to all child blogs:
```
/**
* Plugin Name: Network Primary Nav
* Network: true
*/
add_filter( 'wp_nav_menu_objects', 'network_primary_nav', 100, 2 );
function network_primary_nav( $menu_items, $... |
83,768 | <p>I use this function and hook:</p>
<pre><code>function mysite_admin_menu()
{
add_menu_page( 'Categories', 'Catégories', 'administrator', 'categories', 'a_function' );
add_submenu_page( 'categories', 'Manage', 'Manage', 'administrator', 'xxx', 'a_function' );
remove_submenu_page('categories','categories');
}
a... | [
{
"answer_id": 83775,
"author": "Oleg Butuzov",
"author_id": 14536,
"author_profile": "https://wordpress.stackexchange.com/users/14536",
"pm_score": 2,
"selected": false,
"text": "<p>I don't recommend you do that.</p>\n\n<p>Let's assume your prefix for <code>admin.php</code> is <code>_tr... | 2013/01/30 | [
"https://wordpress.stackexchange.com/questions/83768",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22755/"
] | I use this function and hook:
```
function mysite_admin_menu()
{
add_menu_page( 'Categories', 'Catégories', 'administrator', 'categories', 'a_function' );
add_submenu_page( 'categories', 'Manage', 'Manage', 'administrator', 'xxx', 'a_function' );
remove_submenu_page('categories','categories');
}
add_action( 'ad... | This is an old post but can't you just use wordpress `$menu` and/or `$submenu` globals like Oleg suggested in number 2.
When in doubt copy **WordPress**:
[wordpress/wp-admin/menu.php](https://github.com/WordPress/WordPress/blob/d23cd0aa5002e0749555ae355a04fa17e87db5e4/wp-admin/menu.php#L90)
For example to add link t... |
83,769 | <p>At the moment I'm doing</p>
<pre><code>add_filter("manage_edit-comments_columns", function($columns) {
unset($columns["author"]);
$columns_one = array_slice($columns,0,1);
$columns_two = array_slice($columns,1);
$columns_one["user"] = "User";
$columns = $columns_one + $column... | [
{
"answer_id": 83770,
"author": "Oleg Butuzov",
"author_id": 14536,
"author_profile": "https://wordpress.stackexchange.com/users/14536",
"pm_score": 3,
"selected": true,
"text": "<p>There is no filter for this column. So answer is 'No'.</p>\n\n<p>WP_List_Table search for method column_{s... | 2013/01/30 | [
"https://wordpress.stackexchange.com/questions/83769",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26766/"
] | At the moment I'm doing
```
add_filter("manage_edit-comments_columns", function($columns) {
unset($columns["author"]);
$columns_one = array_slice($columns,0,1);
$columns_two = array_slice($columns,1);
$columns_one["user"] = "User";
$columns = $columns_one + $columns_two;
... | There is no filter for this column. So answer is 'No'.
WP\_List\_Table search for method column\_{something} inside class of Lister. Comments List class has column\_author. So kill this column, and create filter as you do now. |
83,774 | <p>I'm using the following code to display posts with todays date or in the future... except the future part isn't working. If I take out the if statement then it shows all posts - in the past, present and future.</p>
<pre><code>$today = date( 'd M' );
$pages = get_children( array(
'post_status' => 'future,pub... | [
{
"answer_id": 83777,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 0,
"selected": false,
"text": "<p>Hook <code>posts_where</code> filter and add your condition to the sql query:</p>\n\n<pre><code>function... | 2013/01/30 | [
"https://wordpress.stackexchange.com/questions/83774",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4588/"
] | I'm using the following code to display posts with todays date or in the future... except the future part isn't working. If I take out the if statement then it shows all posts - in the past, present and future.
```
$today = date( 'd M' );
$pages = get_children( array(
'post_status' => 'future,publish',
'post_... | Use [get\_posts function](https://codex.wordpress.org/Template_Tags/get_posts) with [WP\_Query params](https://codex.wordpress.org/Class_Reference/WP_Query) instead of get\_children. The code will than look like this:
```
$today = getdate();
$pages = get_posts( array(
'post_status' => array( 'publish', 'future' )... |
83,779 | <p>For the sake of this discussion, here's a version of my query within category.php:</p>
<pre><code>wp_reset_query();
$category_id = get_cat_ID(single_cat_title('', false));
$my_query = new WP_Query(array(
'posts_per_page' => SOME_DEFINED_VALUE,
'cat' => $category_id,
'paged' => ( get_query_var('paged') ? g... | [
{
"answer_id": 83780,
"author": "Chip Bennett",
"author_id": 3966,
"author_profile": "https://wordpress.stackexchange.com/users/3966",
"pm_score": 2,
"selected": false,
"text": "<p>Where/how are you defining <code>$category_id</code>?</p>\n\n<p>Reference <a href=\"http://codex.wordpress.... | 2013/01/30 | [
"https://wordpress.stackexchange.com/questions/83779",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18343/"
] | For the sake of this discussion, here's a version of my query within category.php:
```
wp_reset_query();
$category_id = get_cat_ID(single_cat_title('', false));
$my_query = new WP_Query(array(
'posts_per_page' => SOME_DEFINED_VALUE,
'cat' => $category_id,
'paged' => ( get_query_var('paged') ? get_query_var('paged') :... | Where/how are you defining `$category_id`?
Reference [the Codex entry for `WP_Query()` category parameters](http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters). `WP_Query()` expects category IDs to be passed as **integers**, not as **strings**:
* If `$category_id` is an *integer*, pass it to `'ca... |
83,806 | <p>For some context, we're building an activation system for new users of an app using WordPress as a framework. We've got a plugin driving most of our interactions, where all of this code resides.</p>
<p>When a new user signs up, they are sent an activate link via email, which when clicked, sends them to an activate ... | [
{
"answer_id": 83810,
"author": "Manny Fleurmond",
"author_id": 2234,
"author_profile": "https://wordpress.stackexchange.com/users/2234",
"pm_score": 2,
"selected": false,
"text": "<p><code>__CLASS__</code> should be <code>$this</code> in your <code>add_action</code> call. I think <code>... | 2013/01/30 | [
"https://wordpress.stackexchange.com/questions/83806",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1765/"
] | For some context, we're building an activation system for new users of an app using WordPress as a framework. We've got a plugin driving most of our interactions, where all of this code resides.
When a new user signs up, they are sent an activate link via email, which when clicked, sends them to an activate page. When... | Have you tried
```
add_action( 'init', array( $this, 'auto_sign_in') );
```
`__CLASS__` returns the class name, not the class instance, so it only works for static functions. |
83,820 | <p>Converting my HTML template to WP Theme I am confused how to linkto the pages in WP?
For Example I have an Item div which I would like to link to my store page when user click on that but I dont know how to get the correct URL for my store page?!
This is also happening when I would like to link from another site to ... | [
{
"answer_id": 83810,
"author": "Manny Fleurmond",
"author_id": 2234,
"author_profile": "https://wordpress.stackexchange.com/users/2234",
"pm_score": 2,
"selected": false,
"text": "<p><code>__CLASS__</code> should be <code>$this</code> in your <code>add_action</code> call. I think <code>... | 2013/01/30 | [
"https://wordpress.stackexchange.com/questions/83820",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26628/"
] | Converting my HTML template to WP Theme I am confused how to linkto the pages in WP?
For Example I have an Item div which I would like to link to my store page when user click on that but I dont know how to get the correct URL for my store page?!
This is also happening when I would like to link from another site to my ... | Have you tried
```
add_action( 'init', array( $this, 'auto_sign_in') );
```
`__CLASS__` returns the class name, not the class instance, so it only works for static functions. |
83,852 | <p>I am looking for a way to write a condition for a subpage...in other words</p>
<p><code>if</code> we're on the subpage "duck" then do something...<code>if</code> not do something else.</p>
<p>I found some code I thought would work, but it shows up on all of the pages under a given parent page, not just on its indi... | [
{
"answer_id": 83837,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 1,
"selected": true,
"text": "<p>You can hook on <code>save_post</code> or <code>publish_post</code> hook in each post and publish in other blogs. Y... | 2013/01/30 | [
"https://wordpress.stackexchange.com/questions/83852",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9820/"
] | I am looking for a way to write a condition for a subpage...in other words
`if` we're on the subpage "duck" then do something...`if` not do something else.
I found some code I thought would work, but it shows up on all of the pages under a given parent page, not just on its individual page...I'm only trying to target... | You can hook on `save_post` or `publish_post` hook in each post and publish in other blogs. You must use the function [`switch_to_blog()`](http://codex.wordpress.org/WPMU_Functions/switch_to_blog) to switch in other blog and then use `[wp_insert_post()][2]` to save a post inside this blog; do this for each blog.
Alte... |
83,855 | <p>I have a custom page template where I would like to load some javascript. I suppose I could always include the javascript in the actual file, but that seems ugly. Is there any way to identify if WordPress is loading my custom-page.php file so I can enqueue the script only on that page?</p>
<p>It should work dynamica... | [
{
"answer_id": 83860,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 6,
"selected": true,
"text": "<p>You can use <a href=\"http://codex.wordpress.org/Function_Reference/is_page_template\" rel=\"noreferrer\"><str... | 2013/01/30 | [
"https://wordpress.stackexchange.com/questions/83855",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20279/"
] | I have a custom page template where I would like to load some javascript. I suppose I could always include the javascript in the actual file, but that seems ugly. Is there any way to identify if WordPress is loading my custom-page.php file so I can enqueue the script only on that page?
It should work dynamically, so c... | You can use [**`is_page_template`**](http://codex.wordpress.org/Function_Reference/is_page_template) to check if you template is being used and load your scripts based on that ex:
Add this code to your functions.php:
```
add_action('wp_enqueue_scripts','Load_Template_Scripts_wpa83855');
function Load_Template_Scripts... |
83,861 | <p>I have a WPMU instance that works less like a network of blogs and more like a holistic application. I'm needing to do a check and see if 3 pages with the slugs 'home', 'login', and 'password' exist. If not, I need the system to generate them automatically. If it does, I need the system to ignore.</p>
<p>Right now ... | [
{
"answer_id": 83863,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": true,
"text": "<p>I think you want:</p>\n\n<pre><code>if( get_page_by_title( 'home' ) == NULL )\n create_pages_fly( 'home' );\n</co... | 2013/01/30 | [
"https://wordpress.stackexchange.com/questions/83861",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25283/"
] | I have a WPMU instance that works less like a network of blogs and more like a holistic application. I'm needing to do a check and see if 3 pages with the slugs 'home', 'login', and 'password' exist. If not, I need the system to generate them automatically. If it does, I need the system to ignore.
Right now I have the... | I think you want:
```
if( get_page_by_title( 'home' ) == NULL )
create_pages_fly( 'home' );
```
Your original `if` condition said if the page exists (does not equal NULL), then create the page. Also, the 2nd argument should be a string, though it doesn't really matter in this case since it'll just default to `'p... |
83,866 | <p>I want to limit registration based on the domain associated with their email address. I was looking at the <code>user_register</code> action hook, but it fires <em>after</em> the user is already inserted, which, although it could be hacked into working, is less than ideal. I want to preempt rather than retroactively... | [
{
"answer_id": 83869,
"author": "WP Themes",
"author_id": 25649,
"author_profile": "https://wordpress.stackexchange.com/users/25649",
"pm_score": 1,
"selected": false,
"text": "<p>This depends if you are building your own custom registration form where you implement the actual user regis... | 2013/01/31 | [
"https://wordpress.stackexchange.com/questions/83866",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15299/"
] | I want to limit registration based on the domain associated with their email address. I was looking at the `user_register` action hook, but it fires *after* the user is already inserted, which, although it could be hacked into working, is less than ideal. I want to preempt rather than retroactively remove invalid users... | You're looking in the wrong place.
When a user first attempts to register, their username and email is processed and sanitized inside the `register_new_user()` function in `wp-login.php`. This is where you want to do your filtering.
Before the user is created, WordPress will pass the sanitized user login, email addre... |
83,873 | <p>Hi I want all my uploads to be uploaded to a subdomain on my site instead of 'wp-content/uploads' </p>
<p>I created a subdomain <code>cdn.mysite.com</code> and i want all the uploads to go there instead. </p>
<p>I want my uploads to be <code>cdn.mysite.com/uploads/year/month/mediafile</code></p>
<p>Just as the up... | [
{
"answer_id": 83876,
"author": "Matt Shelton",
"author_id": 26794,
"author_profile": "https://wordpress.stackexchange.com/users/26794",
"pm_score": 0,
"selected": false,
"text": "<p>Are the sites hosted in such a way that you could create symbolic link within your primary site's directo... | 2013/01/31 | [
"https://wordpress.stackexchange.com/questions/83873",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20145/"
] | Hi I want all my uploads to be uploaded to a subdomain on my site instead of 'wp-content/uploads'
I created a subdomain `cdn.mysite.com` and i want all the uploads to go there instead.
I want my uploads to be `cdn.mysite.com/uploads/year/month/mediafile`
Just as the uploads automatically create a folder for the up... | Add the following to your theme's functions.php file, making sure you replace the example CDN URL with your own:
```
function my_cdn_upload_url() {
return 'http://mk124.yourcdn.com/yoursite/wp-content/uploads';
}
add_filter( 'pre_option_upload_url_path', 'my_cdn_upload_url' );
``` |
83,887 | <p>Is there a function that simply returns the current "page type" instead of using is_page(), is_preview(), is_single(), is_archive(), etc?</p>
<p>For example: I can find the current "post type" but I can't find it's corresponding "page type".</p>
| [
{
"answer_id": 83888,
"author": "Oleg Butuzov",
"author_id": 14536,
"author_profile": "https://wordpress.stackexchange.com/users/14536",
"pm_score": 1,
"selected": false,
"text": "<pre><code><?php\nvar_dump(get_query_var('post_type'));\n</code></pre>\n\n<p>but even than that page can ... | 2013/01/31 | [
"https://wordpress.stackexchange.com/questions/83887",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3545/"
] | Is there a function that simply returns the current "page type" instead of using is\_page(), is\_preview(), is\_single(), is\_archive(), etc?
For example: I can find the current "post type" but I can't find it's corresponding "page type". | You need your own helper function which will return you what you need. It could be like this one:
```
function wpse8170_loop() {
global $wp_query;
$loop = 'notfound';
if ( $wp_query->is_page ) {
$loop = is_front_page() ? 'front' : 'page';
} elseif ( $wp_query->is_home ) {
$loop = 'home... |
83,897 | <p>For a long time I served my blog from <a href="http://www.murrayc.com/blog/" rel="noreferrer">http://www.murrayc.com/blog/</a>, with the wordpress installation in /home/murrayc/murrayc.com/blog/. Now I've moved it to <a href="http://www.murrayc.com/" rel="noreferrer">http://www.murrayc.com/</a>, without moving the w... | [
{
"answer_id": 83901,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 1,
"selected": false,
"text": "<p>When it happens to me it usually turns out that I'm editing the wrong file. Are you sure the active theme ... | 2013/01/31 | [
"https://wordpress.stackexchange.com/questions/83897",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26807/"
] | For a long time I served my blog from <http://www.murrayc.com/blog/>, with the wordpress installation in /home/murrayc/murrayc.com/blog/. Now I've moved it to <http://www.murrayc.com/>, without moving the wordpress installation on the filesystem.
I did that by:
* Changing the "Site Address (URL)", in Settings->Genera... | When it happens to me it usually turns out that I'm editing the wrong file. Are you sure the active theme is the one you are editing? You should go to your admin and check. If you really deleted the right CSS file your theme should become inactive and listed as a broken theme |
83,920 | <p>Using WordPress 3.5.</p>
<p>I'm trying to put a <code><form></code> into a Page of a WP-based site. Unfortunately, WP is "helpfully" screwing up the formatting of the form by inserting <code><br></code> and <code><p></code> tags in inappropriate places next to the form controls.</p>
<p>I don't w... | [
{
"answer_id": 83923,
"author": "david.binda",
"author_id": 14022,
"author_profile": "https://wordpress.stackexchange.com/users/14022",
"pm_score": 0,
"selected": false,
"text": "<p>Try to modify your shortcode function to output your form - I mean insert your form html to $output varibl... | 2013/01/31 | [
"https://wordpress.stackexchange.com/questions/83920",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26815/"
] | Using WordPress 3.5.
I'm trying to put a `<form>` into a Page of a WP-based site. Unfortunately, WP is "helpfully" screwing up the formatting of the form by inserting `<br>` and `<p>` tags in inappropriate places next to the form controls.
I don't want to disable `wpautop` globally, as it's still helpful for blog pos... | Late to the party, but this plugin, [Toggle wpautop](https://wordpress.org/plugins/toggle-wpautop/), lets you selectively disable whether you want WP to butcher your content on pages or posts, and works on WP 4.9 (current version as of this answer). |
83,933 | <p>I need to filter uploads to a specific folder for a custom-post type called "document" only for PDFs.</p>
<p>So far, I have: </p>
<pre><code>function custom_upload_directory( $args ) {
$base_directory = '/home/xxx/my_uploadfolder';
$base_url = 'http://xxxx/wp-content/uploads/my_uploadfolder';
$id = $_REQUEST['pos... | [
{
"answer_id": 84898,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": false,
"text": "<p>you might consider using</p>\n\n<pre><code>if(get_post_mime_type($id) == 'application/pdf'){\n ...\n}\n</cod... | 2013/01/31 | [
"https://wordpress.stackexchange.com/questions/83933",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26820/"
] | I need to filter uploads to a specific folder for a custom-post type called "document" only for PDFs.
So far, I have:
```
function custom_upload_directory( $args ) {
$base_directory = '/home/xxx/my_uploadfolder';
$base_url = 'http://xxxx/wp-content/uploads/my_uploadfolder';
$id = $_REQUEST['post_id'];
$parent = get... | you might consider using
```
if(get_post_mime_type($id) == 'application/pdf'){
...
}
```
to check for pdf files.
<http://codex.wordpress.org/Function_Reference/get_post_mime_type>
You might also take a look at the code behind the **wp\_delete\_attachment()** function and you can hook into it with the **delete a... |
83,947 | <p>I have been using shortcodes in my templates successfully, apart from when a closing tag is required to wrap some other code or content. </p>
<p>The problem is that the closing tag, eg [/shortcode], doesn't get processed, and is simply printed to screen as plain text.</p>
<p>Am I missing something obvious?</p>
<... | [
{
"answer_id": 89226,
"author": "Matt Lawhead",
"author_id": 28328,
"author_profile": "https://wordpress.stackexchange.com/users/28328",
"pm_score": 1,
"selected": false,
"text": "<p>Hey i found a workaround that I think works:</p>\n\n<p>What I was doing before was probably like you guys... | 2013/01/31 | [
"https://wordpress.stackexchange.com/questions/83947",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15426/"
] | I have been using shortcodes in my templates successfully, apart from when a closing tag is required to wrap some other code or content.
The problem is that the closing tag, eg [/shortcode], doesn't get processed, and is simply printed to screen as plain text.
Am I missing something obvious?
Thanks!
Austen | The reason
```
echo do_shortcode("[/expand]");
```
is not working is because [/expand] is not a valid shortcode on it's own. The combination of [expand] and [/expand] is valid so
```
echo do_shortcode("[expand] some content [/expand]");
```
should work as intended.
If you want to use this way of seting things up... |
83,956 | <p>Given a site with 100 posts, where an unspecified number of posts are manually written, and the rest are created using the WordPress importer, how would I programmatically identify the posts imported without having access to remote sites or the original import file?</p>
<p>E.g. was this post created by the Importer... | [
{
"answer_id": 83957,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 1,
"selected": false,
"text": "<p>While I am not aware of import doing anything explicit to mark the posts, the possible indicators are:</p>\n\n<ul>\n... | 2013/01/31 | [
"https://wordpress.stackexchange.com/questions/83956",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/736/"
] | Given a site with 100 posts, where an unspecified number of posts are manually written, and the rest are created using the WordPress importer, how would I programmatically identify the posts imported without having access to remote sites or the original import file?
E.g. was this post created by the Importer tool? | Two things I could imagine:
* Check the `post_modified` value. Maybe import creates a definitive timestamp that you could use. You'll still have to save the import date somewhere so you can check against it.
* I do some post importing via a stream/HTTP response (this is not the native importer). During the import, I m... |
83,958 | <p>I have a problem with displaying some content on my homepage. First i'm going to explain my problem. I have a page with all my blog posts on it (use of excerpt function). When you click on a read more link on the blog posts page, you get the whole article. </p>
<p>On my homepage I want to show the 3 latest posts. I... | [
{
"answer_id": 83960,
"author": "Blowsie",
"author_id": 6074,
"author_profile": "https://wordpress.stackexchange.com/users/6074",
"pm_score": 0,
"selected": false,
"text": "<p>I think what your trying to ask is.</p>\n\n<blockquote>\n <p><strong>How can i have multiple excerpt lengths?</... | 2013/01/31 | [
"https://wordpress.stackexchange.com/questions/83958",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26465/"
] | I have a problem with displaying some content on my homepage. First i'm going to explain my problem. I have a page with all my blog posts on it (use of excerpt function). When you click on a read more link on the blog posts page, you get the whole article.
On my homepage I want to show the 3 latest posts. I already h... | Custom Fields are perfect for this when you want not different excerpt lenght, but also different excerpt content.
Following code will add additional TinyMCE editor to the Edit Post admin page so you can write formatted excerpt specially for your front page. Excerpt will be stored in `_wpse83958_front_page_excerpt` cu... |
83,984 | <p>The index page of any wordpress blog has a same size of font in their heading. Can't we tailor size of headings by ourselves for each post? </p>
<p>If we change it by CSS, every heading will be changed. Or may be we can create a shortcode for it? Any clues to get started?</p>
| [
{
"answer_id": 83986,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>If you theme is using <a href=\"http://codex.wordpress.org/Function_Reference/body_class\" rel=\"nofollow\"><... | 2013/01/31 | [
"https://wordpress.stackexchange.com/questions/83984",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25007/"
] | The index page of any wordpress blog has a same size of font in their heading. Can't we tailor size of headings by ourselves for each post?
If we change it by CSS, every heading will be changed. Or may be we can create a shortcode for it? Any clues to get started? | If you theme is using [`body_class`](http://codex.wordpress.org/Function_Reference/body_class) as it should be you can target just about any page you want with your CSS. For example, to target all `h1` tags on `author` pages.
```
.author h1 {
color:red;
}
```
Or all `h2` on an archive page of any kind:
```
.archi... |
83,985 | <p>I have a simple auto log in hook that looks like the following:</p>
<pre><code>function auto_login() {
if (!is_user_logged_in()) {
//Removed some code for brevity.
$user = get_userdatabylogin($domainName);
if ($user != null) {
//Set the auth cookie.
wp_set_auth_... | [
{
"answer_id": 83989,
"author": "david.binda",
"author_id": 14022,
"author_profile": "https://wordpress.stackexchange.com/users/14022",
"pm_score": 3,
"selected": true,
"text": "<p>Maybe it is too late to hook on init. Try set_current_user or some earlier hook. List is here: <a href=\"ht... | 2013/01/31 | [
"https://wordpress.stackexchange.com/questions/83985",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24277/"
] | I have a simple auto log in hook that looks like the following:
```
function auto_login() {
if (!is_user_logged_in()) {
//Removed some code for brevity.
$user = get_userdatabylogin($domainName);
if ($user != null) {
//Set the auth cookie.
wp_set_auth_cookie($user->... | Maybe it is too late to hook on init. Try set\_current\_user or some earlier hook. List is here: <https://codex.wordpress.org/Plugin_API/Action_Reference> |
83,990 | <p>I have code which takes some $_POST data and loops through it. In the loop, I store the $_POST data in variables and create a new post using those variables. The loop ends when I run out of $_POST data.</p>
<p>All of this works. I even output the variables during the loop so I know the loop works and I see the crea... | [
{
"answer_id": 83992,
"author": "david.binda",
"author_id": 14022,
"author_profile": "https://wordpress.stackexchange.com/users/14022",
"pm_score": 1,
"selected": false,
"text": "<p>The code does not adds posts twice - checked in my local installation. </p>\n\n<p>You have got errors in i... | 2013/01/31 | [
"https://wordpress.stackexchange.com/questions/83990",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10507/"
] | I have code which takes some $\_POST data and loops through it. In the loop, I store the $\_POST data in variables and create a new post using those variables. The loop ends when I run out of $\_POST data.
All of this works. I even output the variables during the loop so I know the loop works and I see the created pos... | Found a solution. By wrapping my code inside
```
if ( true !== DOING_CRON && true !== DOING_AJAX ) {
}
```
The posts now only post once, as they should. |
83,993 | <p>I would like the thumbnails underneath the main image on the single product page to replace the main image when they are either clicked or on hover, I prefer hover. Right now the thumbnails just open in their own fancybox. This is a very common feature on most big ecommerce sites and it's weird that it's not an opti... | [
{
"answer_id": 94880,
"author": "Sam",
"author_id": 26836,
"author_profile": "https://wordpress.stackexchange.com/users/26836",
"pm_score": 0,
"selected": false,
"text": "<p>I found this <a href=\"http://www.magictoolbox.com/magiczoomplus/\" rel=\"nofollow\">http://www.magictoolbox.com/m... | 2013/01/31 | [
"https://wordpress.stackexchange.com/questions/83993",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26836/"
] | I would like the thumbnails underneath the main image on the single product page to replace the main image when they are either clicked or on hover, I prefer hover. Right now the thumbnails just open in their own fancybox. This is a very common feature on most big ecommerce sites and it's weird that it's not an option ... | I have just achieved the effect by my own. I will post it here in case others find this thread:
```
jQuery(document).on('click','.thumbnails .zoom', function(){
var photo_fullsize = jQuery(this).find('img').attr('src').replace('-100x132','');
jQuery('.woocommerce-main-image img').attr('src', photo_ful... |
83,997 | <p>Going crazy with this. Can't figure out if this is normal behavior. </p>
<p>I have added a filter to rewrite image inserts to use <code><figure></code> and <code><figcaption></code>. Works well. </p>
<p>However, when I insert an image in the Visual view and press return, I want it to start a new paragr... | [
{
"answer_id": 87952,
"author": "Ryan Gannon",
"author_id": 18912,
"author_profile": "https://wordpress.stackexchange.com/users/18912",
"pm_score": 2,
"selected": false,
"text": "<p>I'm currently having the same problem. Here's my work-around.</p>\n\n<pre><code>add_filter( 'tiny_mce_befo... | 2013/01/31 | [
"https://wordpress.stackexchange.com/questions/83997",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26839/"
] | Going crazy with this. Can't figure out if this is normal behavior.
I have added a filter to rewrite image inserts to use `<figure>` and `<figcaption>`. Works well.
However, when I insert an image in the Visual view and press return, I want it to start a new paragraph.
Instead it creates another `<figure>` elemen... | I'm currently having the same problem. Here's my work-around.
```
add_filter( 'tiny_mce_before_init', 'workaround' );
public function workaround( $in ) {
$in['force_br_newlines'] = true;
$in['force_p_newlines'] = false;
$in['forced_root_block'] = '';
return $in;
}
```
tiny\_mce\_before\_init gives yo... |
83,999 | <p>Is there a WP function to automatically get the correct URL of the current page?
Meaning if I just opened a single post, the function returns the same as <code>get_permalink()</code>, but if I'm on a paginated instance of a page (when paginating through the comments), the function returns the same as <code>get_pagen... | [
{
"answer_id": 84047,
"author": "vaibhav",
"author_id": 22975,
"author_profile": "https://wordpress.stackexchange.com/users/22975",
"pm_score": -1,
"selected": false,
"text": "<p>I dont now of pagination \nbut\nYou can use this function to get url within the loop </p>\n\n<pre><code><... | 2013/01/31 | [
"https://wordpress.stackexchange.com/questions/83999",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18118/"
] | Is there a WP function to automatically get the correct URL of the current page?
Meaning if I just opened a single post, the function returns the same as `get_permalink()`, but if I'm on a paginated instance of a page (when paginating through the comments), the function returns the same as `get_pagenum_link(get_query_v... | In addition to Rajeev Vyas's answer, you don't need to pass any non-empty parameters to `add_query_arg()`. The following has always worked well for me:
```
// relative current URI:
$current_rel_uri = add_query_arg( NULL, NULL );
// absolute current URI (on single site):
$current_uri = home_url( add_query_arg( NULL, ... |
84,003 | <p>I am working on a function set that will add a piece to each custom post type on a site. Since I won't know what CPTs are registered, I wrote a function to get them all (simple). However, I now need to create a function for each value in an array (a small settings page) to properly finish this off.</p>
<p>here's my... | [
{
"answer_id": 84047,
"author": "vaibhav",
"author_id": 22975,
"author_profile": "https://wordpress.stackexchange.com/users/22975",
"pm_score": -1,
"selected": false,
"text": "<p>I dont now of pagination \nbut\nYou can use this function to get url within the loop </p>\n\n<pre><code><... | 2013/01/31 | [
"https://wordpress.stackexchange.com/questions/84003",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/403/"
] | I am working on a function set that will add a piece to each custom post type on a site. Since I won't know what CPTs are registered, I wrote a function to get them all (simple). However, I now need to create a function for each value in an array (a small settings page) to properly finish this off.
here's my array exa... | In addition to Rajeev Vyas's answer, you don't need to pass any non-empty parameters to `add_query_arg()`. The following has always worked well for me:
```
// relative current URI:
$current_rel_uri = add_query_arg( NULL, NULL );
// absolute current URI (on single site):
$current_uri = home_url( add_query_arg( NULL, ... |
84,023 | <p>I have the following template page. I am attempting to output all of the articles from the category 4. However I am only getting some of the posts, about 20% of them. Not sure what would be causing this. Also is there a way to use the category name in the query_posts instead of the category number?</p>
<pre><code>&... | [
{
"answer_id": 84028,
"author": "Bart Karp",
"author_id": 26850,
"author_profile": "https://wordpress.stackexchange.com/users/26850",
"pm_score": 0,
"selected": false,
"text": "<p>Avoid query_posts at all costs, even the Codex itself says its <em>the easiest, but not preferred way to alt... | 2013/02/01 | [
"https://wordpress.stackexchange.com/questions/84023",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7653/"
] | I have the following template page. I am attempting to output all of the articles from the category 4. However I am only getting some of the posts, about 20% of them. Not sure what would be causing this. Also is there a way to use the category name in the query\_posts instead of the category number?
```
<?php
/*
Templ... | For your issue regarding only returning 20% of your posts, try the following
`<?php query_posts('cat=4&posts_per_page=-1'); ?>`
Note: By default, 10 posts are returned. `-1` will return all posts in the resulting set.
<http://codex.wordpress.org/Function_Reference/query_posts#All_Posts_in_a_Category>
--
For your q... |
84,030 | <p>I've migrated hosts for a WordPress site, and a lot of my images have the same title.</p>
<p>I am trying to pinpoint one media file by the file name, but file name is not a column listed in Media Library.</p>
<p>I don't want to have to wade through dozens of images with the same title trying to find the problem fi... | [
{
"answer_id": 84039,
"author": "Bart Karp",
"author_id": 26850,
"author_profile": "https://wordpress.stackexchange.com/users/26850",
"pm_score": 4,
"selected": true,
"text": "<p>Here you go, this code not only lists all filenames in Library but also allows you to sort them by name:</p>\... | 2013/02/01 | [
"https://wordpress.stackexchange.com/questions/84030",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3206/"
] | I've migrated hosts for a WordPress site, and a lot of my images have the same title.
I am trying to pinpoint one media file by the file name, but file name is not a column listed in Media Library.
I don't want to have to wade through dozens of images with the same title trying to find the problem file name, so I can... | Here you go, this code not only lists all filenames in Library but also allows you to sort them by name:
```
// Add the column
function filename_column( $cols ) {
$cols["filename"] = "Filename";
return $cols;
}
// Display filenames
function filename_value( $column_name, $id ) {
$meta = wp_get_attachment_m... |
84,064 | <p>WordPress has minimum theme template files as </p>
<ul>
<li>style.css </li>
<li>index.php</li>
</ul>
<p>and also some other files as listed <a href="http://codex.wordpress.org/Theme_Development#Template_Files" rel="noreferrer">here</a>.</p>
<p>If the theme developer wants to build theme with less bells and whistl... | [
{
"answer_id": 84065,
"author": "Oleg Butuzov",
"author_id": 14536,
"author_profile": "https://wordpress.stackexchange.com/users/14536",
"pm_score": 3,
"selected": false,
"text": "<p>Two - <code>styles.css</code> and <code>index.php</code>.\nIf you're gonna add additional functionality (... | 2013/02/01 | [
"https://wordpress.stackexchange.com/questions/84064",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26860/"
] | WordPress has minimum theme template files as
* style.css
* index.php
and also some other files as listed [here](http://codex.wordpress.org/Theme_Development#Template_Files).
If the theme developer wants to build theme with less bells and whistles, what are some of the template files which should be included at min... | To have the theme listed:
* `style.css`
With at minimum this:
```
/*
Theme Name: Minimum Theme
Description: Test
Author: Test
Version: 1.0
*/
```
For the theme to be functional:
* `index.php`
`index.php` must have a post loop, so this would be the bare minimum functional `index.php`
```
<html>
<head><?php wp... |
84,072 | <p>I've a buddypress website and what I want is to show in the frontend the notification that buddybar have in the backend, but only the notification not all the buddybar.</p>
<p>basically set the notification like facebook....</p>
<p>how can I do that?</p>
| [
{
"answer_id": 84103,
"author": "user2011524",
"author_id": 26789,
"author_profile": "https://wordpress.stackexchange.com/users/26789",
"pm_score": 2,
"selected": false,
"text": "<p>Put the following code in your functions.php. If you want a demo i can show you.</p>\n\n<pre><code>// my c... | 2013/02/01 | [
"https://wordpress.stackexchange.com/questions/84072",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26865/"
] | I've a buddypress website and what I want is to show in the frontend the notification that buddybar have in the backend, but only the notification not all the buddybar.
basically set the notification like facebook....
how can I do that? | Put the following code in your functions.php. If you want a demo i can show you.
```
// my custom notification menu www.cityflavourmagazine.com
function my_bp_adminbar_notifications_menu() {
global $bp;
if ( !is_user_logged_in() )
return false;
echo '<li id="top-notification">';
_e( 'Alerts', 'buddypress' );
i... |
84,082 | <p>I noticed that when I hook into 'wp' it seems to be firing twice -- for example</p>
<pre><code>add_action('wp', 'just_testing');
function just_testing(){
global $post;
error_log($post->ID);
}
</code></pre>
<p>returns into my error_log the following two entries:</p>
<pre><code>[01-Feb-2013 13:06:58 UTC]... | [
{
"answer_id": 84127,
"author": "akTed",
"author_id": 25472,
"author_profile": "https://wordpress.stackexchange.com/users/25472",
"pm_score": 1,
"selected": false,
"text": "<p>Search for <code>'wp'</code>, and <code>\"wp\"</code> (quotes included) in the files of your plugins directory a... | 2013/02/01 | [
"https://wordpress.stackexchange.com/questions/84082",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23591/"
] | I noticed that when I hook into 'wp' it seems to be firing twice -- for example
```
add_action('wp', 'just_testing');
function just_testing(){
global $post;
error_log($post->ID);
}
```
returns into my error\_log the following two entries:
```
[01-Feb-2013 13:06:58 UTC] 1120
[01-Feb-2013 13:06:58 UTC]
```
... | It can happen if one of the files you include in the theme is returning **404 Not Found** error. Like, if you're linking to a .js or .css or an image which does not exist on that location. Use the Inspector in your browser to see if you get any 404 errors, anywhere.
Fix them and try again. |
84,086 | <p>I would like to add a <strong>separator</strong> to the <strong>admin submenu</strong> section, <strong>NOT in the top level section</strong>.</p>
<p><img src="https://i.stack.imgur.com/0OL8S.jpg" alt="enter image description here"></p>
<p>I'm thinking of using javascript and styling to do the job, but I was wonde... | [
{
"answer_id": 84101,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 3,
"selected": false,
"text": "<h2>Add an admin menu separator</h2>\n\n<p>Separators, if this question targets this, are the dividers of the admin me... | 2013/02/01 | [
"https://wordpress.stackexchange.com/questions/84086",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1044/"
] | I would like to add a **separator** to the **admin submenu** section, **NOT in the top level section**.

I'm thinking of using javascript and styling to do the job, but I was wondering if there's a more straightforward method such as that when adding... | Admin menu & *submenu* separators
=================================
After going over it and extending the core API to allow main menu separators in custom positions, I did a quick run through core menu files, dumped the hell out of everything's that in there and found a solution that allows to use the core API also fo... |
84,087 | <p>Essentially, I build web sites with galleries, for photographers.
Up until now, gallery images have all been attached to posts and I've just pulled from the category taxonomy. This is messy if it's also to be used as a regular blog. </p>
<p>So I've been poking around and I discovered things like if an attachment it... | [
{
"answer_id": 84101,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 3,
"selected": false,
"text": "<h2>Add an admin menu separator</h2>\n\n<p>Separators, if this question targets this, are the dividers of the admin me... | 2013/02/01 | [
"https://wordpress.stackexchange.com/questions/84087",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26869/"
] | Essentially, I build web sites with galleries, for photographers.
Up until now, gallery images have all been attached to posts and I've just pulled from the category taxonomy. This is messy if it's also to be used as a regular blog.
So I've been poking around and I discovered things like if an attachment item isn't a... | Admin menu & *submenu* separators
=================================
After going over it and extending the core API to allow main menu separators in custom positions, I did a quick run through core menu files, dumped the hell out of everything's that in there and found a solution that allows to use the core API also fo... |