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 |
|---|---|---|---|---|---|---|
77,797 | <p>I have a page template where I first am getting the contents of the page, as input in the admin tool, then a loop of posts of a custom post type.</p>
<p>I need to split this loop up into the 2 newest posts ("featured") and then a second loop of all the remaining posts. I am trying to use code from the WP Codex, <a ... | [
{
"answer_id": 77796,
"author": "Melanie Sumner",
"author_id": 25415,
"author_profile": "https://wordpress.stackexchange.com/users/25415",
"pm_score": 2,
"selected": false,
"text": "<p>Gravity Forms + Custom Post Types: Allows a simple way to map a Gravity Form post entry to a custom pos... | 2012/12/31 | [
"https://wordpress.stackexchange.com/questions/77797",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23610/"
] | I have a page template where I first am getting the contents of the page, as input in the admin tool, then a loop of posts of a custom post type.
I need to split this loop up into the 2 newest posts ("featured") and then a second loop of all the remaining posts. I am trying to use code from the WP Codex, [from this pa... | Gravity Forms + Custom Post Types: Allows a simple way to map a Gravity Form post entry to a custom post type. Also include custom taxonomies.
I think this might be what you are looking for. In my WP plugin list I see Gravity Form and Gravity Forms + Custom Post Types as two separate plugins. |
77,804 | <p>I have a shortcode called update which is used as follows</p>
<pre><code>[update title='' date=''] this is some update, etc. etc. 2 paragraphs or more [/update]
</code></pre>
<p>This outputs some html that wrap the title, date and content in some html.</p>
<p>Along wit this, I would like spit out a single line at... | [
{
"answer_id": 77807,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>A cleaner way than my first suggestion would be this:</p>\n\n<ul>\n<li>Run the shortcode handler two times: 1. before t... | 2012/12/31 | [
"https://wordpress.stackexchange.com/questions/77804",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25328/"
] | I have a shortcode called update which is used as follows
```
[update title='' date=''] this is some update, etc. etc. 2 paragraphs or more [/update]
```
This outputs some html that wrap the title, date and content in some html.
Along wit this, I would like spit out a single line at the top of the content that outp... | A cleaner way than my first suggestion would be this:
* Run the shortcode handler two times: 1. before the content is parsed, 2. during the regular content parsing.
* Store the data you want to prepend in a variable.
It is important to use `'the_post'` as first entry. Otherwise you can get strange side effect in case... |
77,811 | <p>I'm looking for a way to have the screen split with side-by-side blog posts that are tied together. My client has her Grandather's travel dairies and wants to posts the entries. The originals are in German but she also has English translations. So what I'd like is column A has an English post and column B has the ... | [
{
"answer_id": 77814,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>A very simple solution: Add <a href=\"https://wordpress.stackexchange.com/a/77323/73\">a second editor field</a> to th... | 2012/12/31 | [
"https://wordpress.stackexchange.com/questions/77811",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11543/"
] | I'm looking for a way to have the screen split with side-by-side blog posts that are tied together. My client has her Grandather's travel dairies and wants to posts the entries. The originals are in German but she also has English translations. So what I'd like is column A has an English post and column B has the Germa... | A very simple solution: Add [a second editor field](https://wordpress.stackexchange.com/a/77323/73) to the post editor, and use the meta field content in a filter on `the_content`.
```
add_filter( 'the_content', 'wpse_77811_extra_content' );
function wpse_77811_extra_content( $content )
{
return $content . get_po... |
77,818 | <p>I have installed Wordpress using multisite + path (as opposed to subdomain).<br>
Seems to work, except JS/CSS files are not loaded.
my conf:</p>
<pre><code><Directory "/var/www/pages">
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
</code></pre>
<p>My htaccess</p>
... | [
{
"answer_id": 78002,
"author": "Itay Moav -Malimovka",
"author_id": 25418,
"author_profile": "https://wordpress.stackexchange.com/users/25418",
"pm_score": 2,
"selected": false,
"text": "<p>The problem was in the .htaccess file the installation script generated. Specificaly, those two l... | 2012/12/31 | [
"https://wordpress.stackexchange.com/questions/77818",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25418/"
] | I have installed Wordpress using multisite + path (as opposed to subdomain).
Seems to work, except JS/CSS files are not loaded.
my conf:
```
<Directory "/var/www/pages">
Options All
AllowOverride All
Order allow,deny
Allow from all
</Directory>
```
My htaccess
```
RewriteEngine On
RewriteBase /pages/
Re... | The problem was in the .htaccess file the installation script generated. Specificaly, those two lines:
```
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) home/itaymoav/dev/lmspages/$2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ home/itaymoav/dev/lmspages/$2 [L]
```
The path in there is the actual p... |
77,841 | <p>I have a WPMU install with a couple of sites on it. I'd like to add some subdirectories that are not wordpress blog pages but do contain working PHP code. They do not use any of wordpress's libraries and are not plugins. </p>
<p>The catch is that I'd like these subdirectories to only show up on a particular site... | [
{
"answer_id": 78002,
"author": "Itay Moav -Malimovka",
"author_id": 25418,
"author_profile": "https://wordpress.stackexchange.com/users/25418",
"pm_score": 2,
"selected": false,
"text": "<p>The problem was in the .htaccess file the installation script generated. Specificaly, those two l... | 2012/12/31 | [
"https://wordpress.stackexchange.com/questions/77841",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8901/"
] | I have a WPMU install with a couple of sites on it. I'd like to add some subdirectories that are not wordpress blog pages but do contain working PHP code. They do not use any of wordpress's libraries and are not plugins.
The catch is that I'd like these subdirectories to only show up on a particular site. For instanc... | The problem was in the .htaccess file the installation script generated. Specificaly, those two lines:
```
RewriteRule ^([_0-9a-zA-Z-]+/)?(wp-(content|admin|includes).*) home/itaymoav/dev/lmspages/$2 [L]
RewriteRule ^([_0-9a-zA-Z-]+/)?(.*\.php)$ home/itaymoav/dev/lmspages/$2 [L]
```
The path in there is the actual p... |
77,846 | <p>I am trying to display some posts in ascending order beginning with the first created and ending with the most recently created post. Any help is appreciated. Here is my code:</p>
<pre><code><?php
$numofmebers = '-1';
if ( empty($_GET['page_id_all']) ) $_GET['page_id_all'] = 1;
$count_post = 0;
query_... | [
{
"answer_id": 77847,
"author": "Ed Burns",
"author_id": 25356,
"author_profile": "https://wordpress.stackexchange.com/users/25356",
"pm_score": 2,
"selected": true,
"text": "<p>Keep in mind that query_posts is best avoided as it has negative effects on the main loop. A better approach ... | 2013/01/01 | [
"https://wordpress.stackexchange.com/questions/77846",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25424/"
] | I am trying to display some posts in ascending order beginning with the first created and ending with the most recently created post. Any help is appreciated. Here is my code:
```
<?php
$numofmebers = '-1';
if ( empty($_GET['page_id_all']) ) $_GET['page_id_all'] = 1;
$count_post = 0;
query_posts( array( 'p... | Keep in mind that query\_posts is best avoided as it has negative effects on the main loop. A better approach would be a new instance of WP\_Query or changing the query arguments for the main loop.
To get the order you want, try adding the following to your args:
```
array( 'posts_per_page' => '-1', 'post_type' => '... |
77,848 | <p>I have created an Image Upload field for a User Photo in the User Profile section in the wp-admin using Advanced Custom Fields. I realized ACF could do this per this post: <a href="https://wordpress.stackexchange.com/questions/43997/photo-gallery-on-profile-page">Photo gallery on profile page?</a></p>
<p>How would ... | [
{
"answer_id": 77850,
"author": "Anagio",
"author_id": 10413,
"author_profile": "https://wordpress.stackexchange.com/users/10413",
"pm_score": 0,
"selected": false,
"text": "<p>Because it's not reading your variable $publisher_photo. Try <code><?php echo '<img class=\"publisher-pic... | 2013/01/01 | [
"https://wordpress.stackexchange.com/questions/77848",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17193/"
] | I have created an Image Upload field for a User Photo in the User Profile section in the wp-admin using Advanced Custom Fields. I realized ACF could do this per this post: [Photo gallery on profile page?](https://wordpress.stackexchange.com/questions/43997/photo-gallery-on-profile-page)
How would I go about capturing ... | Got it working! Here's what solved my problem:
```
<?php
$publisher_photo = get_the_author_meta('user_photo');
$image_src = wp_get_attachment_image_src($publisher_photo);
echo '<img class="publisher-picture" src="'. $image_src[0] .'" />';
?>
``` |
77,856 | <p>I have a question here and hope you guys can help me with that. Couldn't find the exact answer from search and I am not a coder myself. I was given the instruction (to change plugin name) by my previous coder before he handed the plugin to me. He said if I want to change the plugin name, all I need to to is go to po... | [
{
"answer_id": 77860,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 1,
"selected": false,
"text": "<p>This error comes when the plugin header is corrupt. <code>Plugin Name: xxx</code> should <em>not</em> be the firs... | 2013/01/01 | [
"https://wordpress.stackexchange.com/questions/77856",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25426/"
] | I have a question here and hope you guys can help me with that. Couldn't find the exact answer from search and I am not a coder myself. I was given the instruction (to change plugin name) by my previous coder before he handed the plugin to me. He said if I want to change the plugin name, all I need to to is go to popup... | The top of your Plugin's main PHP file must contain a **standard Plugin information header**. This header lets WordPress recognize that your Plugin exists, add it to the Plugin management screen so it can be activated, load it, and run its functions; without the header, your Plugin will never be activated and will neve... |
77,874 | <p>Can anybody fix this incorrect related posts codes snippet?</p>
<pre><code>function related_posts() {
if (is_single()) {
global $post;
$current_post = $post->ID;
$categories = get_the_category();
foreach ($categories as $category) :
?>
<div class="my-related-posts"><h4>Related Post... | [
{
"answer_id": 77905,
"author": "Ralf912",
"author_id": 16589,
"author_profile": "https://wordpress.stackexchange.com/users/16589",
"pm_score": 2,
"selected": true,
"text": "<p>Your first problem:</p>\n\n<p>Try to write down what you want to do: You do not want to print posts that are al... | 2013/01/01 | [
"https://wordpress.stackexchange.com/questions/77874",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19942/"
] | Can anybody fix this incorrect related posts codes snippet?
```
function related_posts() {
if (is_single()) {
global $post;
$current_post = $post->ID;
$categories = get_the_category();
foreach ($categories as $category) :
?>
<div class="my-related-posts"><h4>Related Posts</h4><ul>
<?php
$posts ... | Your first problem:
Try to write down what you want to do: You do not want to print posts that are already printed.
So you have to remember what posts are already printed. In PHP normally an array is a good solution to remember things that are already done. Let's add an array:
```
$printed_posts = array( $current_po... |
77,876 | <p>I want to show user registration date like </p>
<blockquote>
<p>Member since: 15,dec 2012.</p>
</blockquote>
<p>I have a code </p>
<pre><code><?php echo date("M Y", strtotime(get_userdata(get_current_user_id( ))->user_registered)); ?>
</code></pre>
<p>but it show same date in all users profiles. Can s... | [
{
"answer_id": 77878,
"author": "Ralf912",
"author_id": 16589,
"author_profile": "https://wordpress.stackexchange.com/users/16589",
"pm_score": 5,
"selected": true,
"text": "<p><code>get_current_user_id()</code> give you the user id of the <strong>logged in</strong> user. And that is: yo... | 2013/01/01 | [
"https://wordpress.stackexchange.com/questions/77876",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24762/"
] | I want to show user registration date like
>
> Member since: 15,dec 2012.
>
>
>
I have a code
```
<?php echo date("M Y", strtotime(get_userdata(get_current_user_id( ))->user_registered)); ?>
```
but it show same date in all users profiles. Can some one please tell me how I fix that. | `get_current_user_id()` give you the user id of the **logged in** user. And that is: you.
You have to get all users:
```
<?php
$users = get_users();
foreach( $users as $user ) {
$udata = get_userdata( $user->ID );
$registered = $udata->user_registered;
printf( '... |
77,881 | <p>I'm customizing a WooCommerce theme and am going to be moving the title. There is an action in <code>content-single-product.php</code> called:</p>
<pre><code>do_action( 'woocommerce_single_product_summary' );
</code></pre>
<p>in the <code>woocommerce_hooks.php</code> file the title action is: </p>
<pre><code>add_... | [
{
"answer_id": 77885,
"author": "jochem",
"author_id": 24417,
"author_profile": "https://wordpress.stackexchange.com/users/24417",
"pm_score": 4,
"selected": true,
"text": "<p>That would be:</p>\n\n<pre><code>remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_sing... | 2013/01/01 | [
"https://wordpress.stackexchange.com/questions/77881",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10413/"
] | I'm customizing a WooCommerce theme and am going to be moving the title. There is an action in `content-single-product.php` called:
```
do_action( 'woocommerce_single_product_summary' );
```
in the `woocommerce_hooks.php` file the title action is:
```
add_action( 'woocommerce_single_product_summary', 'woocommerce_... | That would be:
```
remove_action( 'woocommerce_single_product_summary', 'woocommerce_template_single_title', 5 );
```
You can read about it here: [`remove_action` Codex](http://codex.wordpress.org/Function_Reference/remove_action) |
77,882 | <p>I want to create a custom page that will display let's say 20 latest galleries / page - but only the first image from the gallery, not all of them. something like this: <a href="http://www.autoblog.it/gallerie/" rel="nofollow">http://www.autoblog.it/gallerie/</a></p>
<p>I've done this:</p>
<pre><code><?php
$arg... | [
{
"answer_id": 77888,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Getting the latest posts with a gallery is simple: search for posts with the string <code>'[gallery'</code>.</p>\n\n<p... | 2013/01/01 | [
"https://wordpress.stackexchange.com/questions/77882",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25431/"
] | I want to create a custom page that will display let's say 20 latest galleries / page - but only the first image from the gallery, not all of them. something like this: <http://www.autoblog.it/gallerie/>
I've done this:
```
<?php
$args = array(
'post_type' => 'attachment',
'posts_per_page' => 10,
'post_parent' => $po... | Getting the latest posts with a gallery is simple: search for posts with the string `'[gallery'`.
```
$posts = get_posts(
array (
's' => '[gallery'
)
);
```
Getting the first image from each gallery is harder, because you have to render the `gallery` shortcode. I would not use the default h... |
77,908 | <p>I can't find a more or less clear example on how to create additional fields, so may be someone can help me here? Here is my code:</p>
<pre><code>function __construct(){
add_action('admin_init', array($this, 'plugin_admin_init'));
}
public function create_fields(){
register_setting('dleToWp_options', 'data... | [
{
"answer_id": 77914,
"author": "Ed Burns",
"author_id": 25356,
"author_profile": "https://wordpress.stackexchange.com/users/25356",
"pm_score": 0,
"selected": false,
"text": "<p>Pretty close - but in your settings_page function, you have to add the html form elements for each field afte... | 2013/01/01 | [
"https://wordpress.stackexchange.com/questions/77908",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22622/"
] | I can't find a more or less clear example on how to create additional fields, so may be someone can help me here? Here is my code:
```
function __construct(){
add_action('admin_init', array($this, 'plugin_admin_init'));
}
public function create_fields(){
register_setting('dleToWp_options', 'database_name');
... | There are a lot of things which you have to understand about [Settings API](http://codex.wordpress.org/Settings_API). Instead of duplicating information, I would strongly recommend you to read through bunch of articles called [The Complete Guide To The WordPress Settings API](http://wp.tutsplus.com/tutorials/the-comple... |
77,931 | <p>I need the Wordpress menu to include the 'current-menu-ancestor' class to reflect that site is currently in the recipe section. Supposing I have a recipe custom post type. I have the following code in my functions.php but it's not working:</p>
<pre><code>function add_active_item_classes($classes = array(), $menu_it... | [
{
"answer_id": 78302,
"author": "Emerson Maningo",
"author_id": 20972,
"author_profile": "https://wordpress.stackexchange.com/users/20972",
"pm_score": 2,
"selected": true,
"text": "<p>This is the final working code:</p>\n\n<pre><code><?php\nfunction additional_active_item_classes($cl... | 2013/01/02 | [
"https://wordpress.stackexchange.com/questions/77931",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20972/"
] | I need the Wordpress menu to include the 'current-menu-ancestor' class to reflect that site is currently in the recipe section. Supposing I have a recipe custom post type. I have the following code in my functions.php but it's not working:
```
function add_active_item_classes($classes = array(), $menu_item = false){
... | This is the final working code:
```
<?php
function additional_active_item_classes($classes = array(), $menu_item = false){
global $wp_query;
if(in_array('current-menu-item', $menu_item->classes)){
$classes[] = 'current-menu-item';
}
if ( $menu_item->post_name == 'product' && is_post_type_archive('product') ) {
... |
77,937 | <p>I am trying to create an unsubscribe page for my members, but in order to see the unsubscribe form, they have to be logged out, so the first link is: </p>
<pre><code>/wp-login.php?action=logout&_wpnonce=ba51bbcdc3.
</code></pre>
<p>Once they are logged out, I need them redirected to the unsubscribe form, but ... | [
{
"answer_id": 77938,
"author": "Naveen Chand K",
"author_id": 24328,
"author_profile": "https://wordpress.stackexchange.com/users/24328",
"pm_score": 0,
"selected": false,
"text": "<p>WordPress includes a template tag which you can use: <a href=\"http://codex.wordpress.org/Function_Refe... | 2013/01/02 | [
"https://wordpress.stackexchange.com/questions/77937",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25334/"
] | I am trying to create an unsubscribe page for my members, but in order to see the unsubscribe form, they have to be logged out, so the first link is:
```
/wp-login.php?action=logout&_wpnonce=ba51bbcdc3.
```
Once they are logged out, I need them redirected to the unsubscribe form, but I can't just set up a forward,... | You can use the [`wp_logout_url()`](http://codex.wordpress.org/Function_Reference/wp_logout_url) template tag to generate a logout link. You can specify the URL that the user will be redirected to as the first pramiter:
```
wp_logout_url( 'http://example.com' );
```
The above code will generate a URL that looks a bi... |
77,941 | <p>My WP theme got these notice on description menu function</p>
<p>my code :</p>
<p><a href="http://www49.zippyshare.com/v/89513423/file.html" rel="nofollow">http://www49.zippyshare.com/v/89513423/file.html</a></p>
<pre><code>/* Discription Navigation Menu, Credit to Christian Kriesi */
class description_walker e... | [
{
"answer_id": 77950,
"author": "Mridul Aggarwal",
"author_id": 22495,
"author_profile": "https://wordpress.stackexchange.com/users/22495",
"pm_score": 1,
"selected": true,
"text": "<p>It looks like the <code>$args</code> passed to the function is not an object for some reason. I can't s... | 2013/01/02 | [
"https://wordpress.stackexchange.com/questions/77941",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25452/"
] | My WP theme got these notice on description menu function
my code :
<http://www49.zippyshare.com/v/89513423/file.html>
```
/* Discription Navigation Menu, Credit to Christian Kriesi */
class description_walker extends Walker_Nav_Menu
{
function start_el(&$output, $item, $depth, $args)
{
gl... | It looks like the `$args` passed to the function is not an object for some reason. I can't see the origin of this problem but for a quick solution, you can add `$args = (object) $args;` before the first time you use `$args`, here on line 44
Also, as commented by toscho, `dropdown_menu()` is not a valid function in wor... |
77,943 | <p>My theme shows full posts on the main page and I want it to show only the summary, I tried searching for the_content tag in my theme's index.php file but it is not even there!<br>
I don't have a home.php or category.php. I tried searching my whole wordpress installation for the_content and the only places i could fi... | [
{
"answer_id": 77945,
"author": "jhoffmcd",
"author_id": 24654,
"author_profile": "https://wordpress.stackexchange.com/users/24654",
"pm_score": 0,
"selected": false,
"text": "<p>What theme are you working with?</p>\n\n<p>This bit of code here:</p>\n\n<pre><code><?php get_template_par... | 2013/01/02 | [
"https://wordpress.stackexchange.com/questions/77943",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25453/"
] | My theme shows full posts on the main page and I want it to show only the summary, I tried searching for the\_content tag in my theme's index.php file but it is not even there!
I don't have a home.php or category.php. I tried searching my whole wordpress installation for the\_content and the only places i could find... | Decide about `the_excerpt()` or `the_content()` with a conditional: `is_singular()`.
You can use a [plugin](https://gist.github.com/2973189) and filter `the_content` depending on the current page’s type: archive or singular. But you can use it in your theme too.
```
add_filter( 'the_content', 't5_replace_content_with... |
77,960 | <p>As the recent changes in WordPress 3.5 removed the "full URL path to files" option from media library I am wondering how to set this option to a custom path now?</p>
<p>I need to set my "full URL path to files" for my media files to a custom subdomain. Can you guys help me out with finding a solution for this probl... | [
{
"answer_id": 77961,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 5,
"selected": true,
"text": "<p>The option name is <code>upload_url_path</code>, and you can still filter it:</p>\n\n<pre><code>add_filter( 'pre_option... | 2013/01/02 | [
"https://wordpress.stackexchange.com/questions/77960",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20605/"
] | As the recent changes in WordPress 3.5 removed the "full URL path to files" option from media library I am wondering how to set this option to a custom path now?
I need to set my "full URL path to files" for my media files to a custom subdomain. Can you guys help me out with finding a solution for this problem?
Regar... | The option name is `upload_url_path`, and you can still filter it:
```
add_filter( 'pre_option_upload_url_path', 'wpse_77960_upload_url' );
function wpse_77960_upload_url()
{
return 'http://subdomain.example.com/files';
}
``` |
77,962 | <p>I currently have configured Wordpress so that a post can be copied to other sites within a Wordpress network. However, a post may be broadcast more than once, and I want to check if the image is already published into that site's <code>wp_posts</code> table.</p>
<p>As an example, let's say an image has the image pa... | [
{
"answer_id": 77971,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>The easiest way <em>should</em> be to use <a href=\"http://queryposts.com/function/wp_attachment_is_image/\" rel=\"... | 2013/01/02 | [
"https://wordpress.stackexchange.com/questions/77962",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13882/"
] | I currently have configured Wordpress so that a post can be copied to other sites within a Wordpress network. However, a post may be broadcast more than once, and I want to check if the image is already published into that site's `wp_posts` table.
As an example, let's say an image has the image path:
```
/wp-content/... | Yes, a database query is possible with WordPress:
```
function is_image_in_network( $image_name )
{
global $wpdb;
$image = "uploads/2012/01/{$image_name}";
$value = '%'.like_escape( $image ).'%';
$blog_id = get_current_blog_id();
$wpdb->set_blog_id( $blog_id );
$image = $wpdb->get_var(
... |
77,963 | <p>I have this array for checkbox:</p>
<pre><code>array(
'name' => __('Latest Product',''),
'desc' => __('Select if you want to display latest product',''),
'id' => $prefix . 'checkbox',
'type' => 'checkbox',
'std' => ''
)
</code></pre>
<p>I want to add an at... | [
{
"answer_id": 77965,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>Store the ID in a variable, and access that variable using JavaScript:</p>\n\n<pre><code><script>\ndocument.getE... | 2013/01/02 | [
"https://wordpress.stackexchange.com/questions/77963",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25464/"
] | I have this array for checkbox:
```
array(
'name' => __('Latest Product',''),
'desc' => __('Select if you want to display latest product',''),
'id' => $prefix . 'checkbox',
'type' => 'checkbox',
'std' => ''
)
```
I want to add an attribute for `onclick="chk(electronics, th... | Store the ID in a variable, and access that variable using JavaScript:
```
<script>
document.getElementById("<?php echo $checkbox_id; ?>").onclick = function() {
chk(electronics, this.checked);
}
</script>
```
You can also collect multiple IDs in an array and run through that array later in your script. But avoi... |
77,966 | <p>I want to display all posts from specific categories on a single page.
Therefore I edited the page.php file in my theme folder.
I added an 'if-clause' to check which page currently being displayed and load all posts from the following categories.</p>
<pre><code><?php get_header(); ?>
<div id="primary">... | [
{
"answer_id": 77967,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>This happens because you are still using <code>query_posts()</code>. <a href=\"https://wordpress.stackexchange.com/que... | 2013/01/02 | [
"https://wordpress.stackexchange.com/questions/77966",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12614/"
] | I want to display all posts from specific categories on a single page.
Therefore I edited the page.php file in my theme folder.
I added an 'if-clause' to check which page currently being displayed and load all posts from the following categories.
```
<?php get_header(); ?>
<div id="primary">
<div id="content" rol... | I'd Advise adding the arg of the category in an array. And don't use `query_posts`.
Also `showposts` is deprecated use `posts_per_page` instead.
```
$args = array (
'cat' => array(2,6,9,13),
'posts_per_page' => -1, //showposts is deprecated
'orderby' => 'date' //You can specify more filters to get the data... |
77,973 | <p>I have to change my wordpress look. The sidebar should be placed on the left side. I was already looking for solutions, but the piece of codes I found didn't fit into mine. I dont know where I have to change it. I know I can change it in the Options, but I need to change it IN the CSS Stylesheet. Thanks for your hel... | [
{
"answer_id": 77967,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>This happens because you are still using <code>query_posts()</code>. <a href=\"https://wordpress.stackexchange.com/que... | 2013/01/02 | [
"https://wordpress.stackexchange.com/questions/77973",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25467/"
] | I have to change my wordpress look. The sidebar should be placed on the left side. I was already looking for solutions, but the piece of codes I found didn't fit into mine. I dont know where I have to change it. I know I can change it in the Options, but I need to change it IN the CSS Stylesheet. Thanks for your help !... | I'd Advise adding the arg of the category in an array. And don't use `query_posts`.
Also `showposts` is deprecated use `posts_per_page` instead.
```
$args = array (
'cat' => array(2,6,9,13),
'posts_per_page' => -1, //showposts is deprecated
'orderby' => 'date' //You can specify more filters to get the data... |
77,986 | <p>Hi need to remove the title of a specific page, this <a href="http://staging.geekwire.com/calendar/" rel="nofollow">one</a>. I could do</p>
<pre><code>add_filter( 'the_title', ai1ec_remove_title );
function ai1ec_remove_title( $title ) {
if( 'Calendar' === $title ) {
return '';
} else {
ret... | [
{
"answer_id": 77988,
"author": "Naveen Chand K",
"author_id": 24328,
"author_profile": "https://wordpress.stackexchange.com/users/24328",
"pm_score": 0,
"selected": false,
"text": "<p>Well, why do you need a function to remove the title. Simply delete the title in the Editor, and moreov... | 2013/01/02 | [
"https://wordpress.stackexchange.com/questions/77986",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13205/"
] | Hi need to remove the title of a specific page, this [one](http://staging.geekwire.com/calendar/). I could do
```
add_filter( 'the_title', ai1ec_remove_title );
function ai1ec_remove_title( $title ) {
if( 'Calendar' === $title ) {
return '';
} else {
return $title;
}
}
```
but this would... | You could target the ID of the page in the database. It is also passed as a 2nd parameter to the function. Assuming your ID to be "1234", the code becomes
```
add_filter( 'the_title', ai1ec_remove_title, 10, 2 );
function ai1ec_remove_title( $title, $id ) {
if( 1234 == $id ) {
return '';
} else {
... |
77,999 | <p>I am trying to block the visualization of a custom post, of type 'product', if it is assigned to certain values of the taxonomy 'product_cat'. </p>
<p>Strictly speaking, I would like to block the visualization of a product if it falls under certain categories.</p>
<p>I can not make this work, even by hardcoding a ... | [
{
"answer_id": 77993,
"author": "woony",
"author_id": 17541,
"author_profile": "https://wordpress.stackexchange.com/users/17541",
"pm_score": 0,
"selected": false,
"text": "<p>That's an acceptable way to do it, if it works it works right :).</p>\n\n<p>But if you want things not to be 'te... | 2013/01/02 | [
"https://wordpress.stackexchange.com/questions/77999",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I am trying to block the visualization of a custom post, of type 'product', if it is assigned to certain values of the taxonomy 'product\_cat'.
Strictly speaking, I would like to block the visualization of a product if it falls under certain categories.
I can not make this work, even by hardcoding a forbidden name f... | As has been mentioned, your way works, but there are some ways you can decouple the form from the template, allowing more flexibility.
The [Shortcode API](http://codex.wordpress.org/Shortcode_API) allows you to create a shortcode for your form, so you can simply enter something like `[my_form]` in the page's content, ... |
78,001 | <p>I am working on a Wordpress website and I am using a loop to get all the posts that have title and body contain an image.</p>
<p>But the problem is that it returns me all the titles but not all the images. I don't understand why.</p>
<p>Here is the code:</p>
<pre><code><?php query_posts('cat=17&order=ASC'... | [
{
"answer_id": 78043,
"author": "Rob Vermeer",
"author_id": 11135,
"author_profile": "https://wordpress.stackexchange.com/users/11135",
"pm_score": 1,
"selected": false,
"text": "<p>You are trying to get the ID via <code>$post->ID</code>, but that will only return the post ID of the f... | 2012/12/28 | [
"https://wordpress.stackexchange.com/questions/78001",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26956/"
] | I am working on a Wordpress website and I am using a loop to get all the posts that have title and body contain an image.
But the problem is that it returns me all the titles but not all the images. I don't understand why.
Here is the code:
```
<?php query_posts('cat=17&order=ASC');
remove_filter('the_content', 'wp... | You are trying to get the ID via `$post->ID`, but that will only return the post ID of the first post. You can use `global $post;` before the args array, or much simpler replace $post->ID by the function `get_the_ID()`.
```
$args = array('post_type' => 'attachment', 'numberposts' => 34, 'post_status' => null, 'post_pa... |
78,009 | <p>I couldn't find anything pertaining to my question.</p>
<p>How difficult would it be to display the category of search results, without a plugin - if possible.</p>
<p>So it would be something like this:</p>
<blockquote>
<p>Category One</p>
<p>Search results from category one</p>
<p>Category Two</p>
<p>Search results... | [
{
"answer_id": 78043,
"author": "Rob Vermeer",
"author_id": 11135,
"author_profile": "https://wordpress.stackexchange.com/users/11135",
"pm_score": 1,
"selected": false,
"text": "<p>You are trying to get the ID via <code>$post->ID</code>, but that will only return the post ID of the f... | 2013/01/02 | [
"https://wordpress.stackexchange.com/questions/78009",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25475/"
] | I couldn't find anything pertaining to my question.
How difficult would it be to display the category of search results, without a plugin - if possible.
So it would be something like this:
>
> Category One
>
>
> Search results from category one
>
>
> Category Two
>
>
> Search results from category two
>
>
>... | You are trying to get the ID via `$post->ID`, but that will only return the post ID of the first post. You can use `global $post;` before the args array, or much simpler replace $post->ID by the function `get_the_ID()`.
```
$args = array('post_type' => 'attachment', 'numberposts' => 34, 'post_status' => null, 'post_pa... |
78,014 | <p>I am writing a plugin which will enable to write posts from front-end. Those posts have to be checked by admin before published. Now if admin edits the post or publishes the post, the post author is changed from the original author to admin. How can I prevent that?</p>
| [
{
"answer_id": 78142,
"author": "Ed Burns",
"author_id": 25356,
"author_profile": "https://wordpress.stackexchange.com/users/25356",
"pm_score": -1,
"selected": false,
"text": "<p>That seems like a very strange issue. The status of a post should not affect the user setting.</p>\n\n<p>Ha... | 2013/01/02 | [
"https://wordpress.stackexchange.com/questions/78014",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25348/"
] | I am writing a plugin which will enable to write posts from front-end. Those posts have to be checked by admin before published. Now if admin edits the post or publishes the post, the post author is changed from the original author to admin. How can I prevent that? | The administrative editors could [fix the author manually](https://wordpress.stackexchange.com/questions/44023/is-there-a-way-to-prevent-author-change-when-editor-administrator-edits-a-post).
Alternatively, you could add custom post meta-data to designate the original author. Then, hooking into the [`publish_post` or ... |
78,035 | <p>How can i retrieve a picture, let say ( No picture ) when i don't add a picture in my custom field </p>
<p>I use this code to retrive the field...</p>
<pre><code><img class="film"
src="/scripts/timthumb.php?src=<?php the_field('img_actor'); ?>&h=251&w=175&zc=1"
alt="<?php the_tit... | [
{
"answer_id": 78142,
"author": "Ed Burns",
"author_id": 25356,
"author_profile": "https://wordpress.stackexchange.com/users/25356",
"pm_score": -1,
"selected": false,
"text": "<p>That seems like a very strange issue. The status of a post should not affect the user setting.</p>\n\n<p>Ha... | 2013/01/02 | [
"https://wordpress.stackexchange.com/questions/78035",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25478/"
] | How can i retrieve a picture, let say ( No picture ) when i don't add a picture in my custom field
I use this code to retrive the field...
```
<img class="film"
src="/scripts/timthumb.php?src=<?php the_field('img_actor'); ?>&h=251&w=175&zc=1"
alt="<?php the_title(); ?>"
title="<?php the_title(); ?>... | The administrative editors could [fix the author manually](https://wordpress.stackexchange.com/questions/44023/is-there-a-way-to-prevent-author-change-when-editor-administrator-edits-a-post).
Alternatively, you could add custom post meta-data to designate the original author. Then, hooking into the [`publish_post` or ... |
78,070 | <p>Since the new version of Wordpress (3.5), it seems to be an incompatibility between the image manager and the custom image sizes.</p>
<p>Previously I used in my functions.php :</p>
<pre><code>add_action( 'after_setup_theme', 'addemo_setup' );
function addemo_setup() {
add_theme_support( 'post-thumbnails' ); ... | [
{
"answer_id": 80032,
"author": "aguidis",
"author_id": 23524,
"author_profile": "https://wordpress.stackexchange.com/users/23524",
"pm_score": 1,
"selected": true,
"text": "<p>Instead of using the functions.php to add my custom image size, I installed the plugin <a href=\"http://wordpre... | 2012/12/23 | [
"https://wordpress.stackexchange.com/questions/78070",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23524/"
] | Since the new version of Wordpress (3.5), it seems to be an incompatibility between the image manager and the custom image sizes.
Previously I used in my functions.php :
```
add_action( 'after_setup_theme', 'addemo_setup' );
function addemo_setup() {
add_theme_support( 'post-thumbnails' );
add_image_size... | Instead of using the functions.php to add my custom image size, I installed the plugin [Simple Image Size](http://wordpress.org/extend/plugins/simple-image-sizes/). This plugin does perfectly the job. |
78,084 | <p>Hi I have this code in my functions.php and its working well when the editor is viewing the Media library: <a href="http://example.com/wp-admin/upload.php" rel="nofollow">http://example.com/wp-admin/upload.php</a></p>
<pre><code>add_action('pre_get_posts','users_own_attachments');
function users_own_attachments( $... | [
{
"answer_id": 78301,
"author": "Emerson Maningo",
"author_id": 20972,
"author_profile": "https://wordpress.stackexchange.com/users/20972",
"pm_score": 0,
"selected": false,
"text": "<p>The feasible solution would be to run a conditional tag to determine if the user is viewing the add me... | 2013/01/03 | [
"https://wordpress.stackexchange.com/questions/78084",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20972/"
] | Hi I have this code in my functions.php and its working well when the editor is viewing the Media library: <http://example.com/wp-admin/upload.php>
```
add_action('pre_get_posts','users_own_attachments');
function users_own_attachments( $wp_query_obj ) {
global $current_user, $pagenow;
if( !is_a( $current_user, 'WP... | If I correctly understand your question, you may try this
```
function wpse78084_show_media_by_current_author_only($query) {
global $pagenow, $user_ID;
if( 'upload.php' == $pagenow && !current_user_can('manage_options') )
$query->set('author', $user_ID);
return $query;
}
if ( is_admin() )
add_filter('pre_... |
78,086 | <p>I'm trying to customize the Categories meta-box when adding a post.</p>
<p><img src="https://i.stack.imgur.com/UkmL4.jpg" alt="screenshot"></p>
<p>I have added a custom post and I need the administrator to post a new post without the ability to use the top level categories and also, he can just choose only one cat... | [
{
"answer_id": 87120,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": false,
"text": "<p>Freed from comment; the asker really did not want to write an answer. :/</p>\n\n<pre><code>function convert_root_cats_... | 2013/01/03 | [
"https://wordpress.stackexchange.com/questions/78086",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24490/"
] | I'm trying to customize the Categories meta-box when adding a post.

I have added a custom post and I need the administrator to post a new post without the ability to use the top level categories and also, he can just choose only one category, no more than one categor... | Freed from comment; the asker really did not want to write an answer. :/
```
function convert_root_cats_to_radio()
{
global $post_type;
?>
<script type="text/javascript">
jQuery("#activitycategorychecklist>li>label input").each(function(){
this.disabled = "disabled";
});
jQuery("#activitycategorychec... |
78,113 | <p>I have added a content rating system to my platform where the authors can select which audience their post is appropriate for. Currently, these options are available:</p>
<blockquote>
<p>Unrated </p>
<p>G</p>
<p>PG</p>
<p>R</p>
</blockquote>
<p>The code that I use to display the rating options on ... | [
{
"answer_id": 78114,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 1,
"selected": false,
"text": "<p>You are already doing what you need to do, but in another context.</p>\n\n<pre><code>$value = get_post_meta($... | 2013/01/03 | [
"https://wordpress.stackexchange.com/questions/78113",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24875/"
] | I have added a content rating system to my platform where the authors can select which audience their post is appropriate for. Currently, these options are available:
>
> Unrated
>
>
> G
>
>
> PG
>
>
> R
>
>
>
The code that I use to display the rating options on the post edit page is:
```
// Article Conte... | You are already doing what you need to do, but in another context.
```
$value = get_post_meta($post->ID, 'rating', true);
```
Take that value and format it for display.
**Edit:** I installed your whole block of code. You are storing you key, not your ratings value. You need to access that `$ratings` array again to... |
78,117 | <p>We are introducing a "featured author" area on our site and would like to display the most recent articles by a select group of authors. However, we only want a maximum of one post per author to display. So an author could potentially have posted 5 times since another author had posted, but regardless only one of th... | [
{
"answer_id": 78126,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": false,
"text": "<p>You need to <code>GROUP BY</code> the author ID, which is going to require a filter on <a href=\"http://codex... | 2013/01/03 | [
"https://wordpress.stackexchange.com/questions/78117",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25522/"
] | We are introducing a "featured author" area on our site and would like to display the most recent articles by a select group of authors. However, we only want a maximum of one post per author to display. So an author could potentially have posted 5 times since another author had posted, but regardless only one of their... | You need to `GROUP BY` the author ID, which is going to require a filter on [`posts_groupby`](http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_groupby). The Codex page for that filter is non-existent but it works like [`posts_join`](http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_join). Somethi... |
78,121 | <p>Is there a way I can wrap a div around wp_nav_menu's ul.sub-menu </p>
<p>So for example the markup would go from</p>
<pre><code><ul class="menu">
<li><a href="/">Item 1</a></li>
<li>
<a href="/">Item 2</a>
<ul class="sub-menu">
... | [
{
"answer_id": 78125,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 6,
"selected": true,
"text": "<p><a href=\"https://wordpress.stackexchange.com/a/78065/73\">Use a custom walker</a>, extend the methods <code>start_lvl(... | 2013/01/03 | [
"https://wordpress.stackexchange.com/questions/78121",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18547/"
] | Is there a way I can wrap a div around wp\_nav\_menu's ul.sub-menu
So for example the markup would go from
```
<ul class="menu">
<li><a href="/">Item 1</a></li>
<li>
<a href="/">Item 2</a>
<ul class="sub-menu">
<li><a href="/">Item 1</a></li>
<li><a href="/">Item 1<... | [Use a custom walker](https://wordpress.stackexchange.com/a/78065/73), extend the methods `start_lvl()` and `end_lvl`.
Sample code, not tested:
```
class WPSE_78121_Sublevel_Walker extends Walker_Nav_Menu
{
function start_lvl( &$output, $depth = 0, $args = array() ) {
$indent = str_repeat("\t", $depth);
... |
78,140 | <p>If I embed a YouTube video into a post, how do I put a play button over the featured image so that the video can be played without having to open the whole post?</p>
<p>I.e Flipboard the iOS app has a function which allows you to watch videos from the featured image stage. </p>
| [
{
"answer_id": 78175,
"author": "Wyck",
"author_id": 1509,
"author_profile": "https://wordpress.stackexchange.com/users/1509",
"pm_score": 2,
"selected": false,
"text": "<p>You can't just put a play button over an image and expect it to play a video without some serious magic.</p>\n\n<p>... | 2013/01/03 | [
"https://wordpress.stackexchange.com/questions/78140",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25534/"
] | If I embed a YouTube video into a post, how do I put a play button over the featured image so that the video can be played without having to open the whole post?
I.e Flipboard the iOS app has a function which allows you to watch videos from the featured image stage. | It happens that I answered a [similar Question](https://wordpress.stackexchange.com/a/74026/12615).
And adapting it a little bit, some serious magic can happen ;)
**Notes**:
* the CSS is being printed inline. It should go with the theme's `style.css` and be adapted accordingly.
* each Featured Image is encapsulat... |
78,144 | <p>I have a script that enables a logged in user (role Author) to delete their own posts using <code>get_delete_post_link()</code>. However, I also want to be able to restrict the author's access to the dashboard. Any attempt to do so using a plugin (Theme my Login, for example) or a simple script like those linked bel... | [
{
"answer_id": 78163,
"author": "bosco",
"author_id": 25324,
"author_profile": "https://wordpress.stackexchange.com/users/25324",
"pm_score": 0,
"selected": false,
"text": "<p>How about a targeted redirect when an Author attempts to view the dashboard?</p>\n\n<pre><code>function restrict... | 2013/01/03 | [
"https://wordpress.stackexchange.com/questions/78144",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23364/"
] | I have a script that enables a logged in user (role Author) to delete their own posts using `get_delete_post_link()`. However, I also want to be able to restrict the author's access to the dashboard. Any attempt to do so using a plugin (Theme my Login, for example) or a simple script like those linked below disables my... | This is how I ended up solving this issue. Originally I used this code for the link to delete an individual post:
```
<?php if( !(get_post_status() == 'trash') ) : ?>
<a class="delete-post" onclick="return confirm('Are you sure you wish to delete post: <?php echo get_the_title() ?>?')"href="<?php echo get_delete_post_... |
78,179 | <p>Hi I am trying to add post from a certain taxonomy term to a cpt loop. The code below is the code I am using.</p>
<pre><code> <?php // Create empty array to store post ids in
$excludes = array();
$args=array(
'post_type' => array ('gallery','videos'),
'taxonomy'=>... | [
{
"answer_id": 78185,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 2,
"selected": false,
"text": "<p>As Toscho mentionned <a href=\"https://wordpress.stackexchange.com/questions/78179/how-do-i-use-multiple-loops... | 2013/01/04 | [
"https://wordpress.stackexchange.com/questions/78179",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20145/"
] | Hi I am trying to add post from a certain taxonomy term to a cpt loop. The code below is the code I am using.
```
<?php // Create empty array to store post ids in
$excludes = array();
$args=array(
'post_type' => array ('gallery','videos'),
'taxonomy'=>'series',
'term' ... | As Toscho mentionned [above](https://wordpress.stackexchange.com/questions/78179/how-do-i-use-multiple-loops-with-wp-query#comment106673_78179), you didn't close your `if` and `while`. When in doubt, indent your codes to avoid confusion.
```
$my_query = new WP_Query( $args );
if ($my_query->have_posts()) :
while($my... |
78,211 | <p>Is it possible to remove the quick edit function for a custom post type?</p>
<p>I have 14 custom taxonomy with hundreds of terms in each and it takes too much time and resource to load all of them into the source-code of the page.</p>
<p>I tried to find a solution using google but most of them just hides the quick... | [
{
"answer_id": 78222,
"author": "Eric Holmes",
"author_id": 23454,
"author_profile": "https://wordpress.stackexchange.com/users/23454",
"pm_score": 4,
"selected": true,
"text": "<p>Check out the <a href=\"http://codex.wordpress.org/Plugin_API/Filter_Reference/bulk_actions\" rel=\"nofollo... | 2013/01/04 | [
"https://wordpress.stackexchange.com/questions/78211",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8038/"
] | Is it possible to remove the quick edit function for a custom post type?
I have 14 custom taxonomy with hundreds of terms in each and it takes too much time and resource to load all of them into the source-code of the page.
I tried to find a solution using google but most of them just hides the quick edit button, but... | Check out the [Bulk Actions page](http://codex.wordpress.org/Plugin_API/Filter_Reference/bulk_actions) in the codex. I believe the proper action to unset is inline. This will remove the "Edit" bulk action, which is actually quick edit.
```
<?php
function remove_bulk_actions( $actions ){
unset( $actions['in... |
78,218 | <p>I have a blog and on the main page are 3 blocks of posts. So, I get these posts with "get_post" and I have 3 similar codes on page:</p>
<pre><code>global $post;
$args = array( ... );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
.......
<?php endforeach; ?>
</code... | [
{
"answer_id": 78222,
"author": "Eric Holmes",
"author_id": 23454,
"author_profile": "https://wordpress.stackexchange.com/users/23454",
"pm_score": 4,
"selected": true,
"text": "<p>Check out the <a href=\"http://codex.wordpress.org/Plugin_API/Filter_Reference/bulk_actions\" rel=\"nofollo... | 2013/01/04 | [
"https://wordpress.stackexchange.com/questions/78218",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25561/"
] | I have a blog and on the main page are 3 blocks of posts. So, I get these posts with "get\_post" and I have 3 similar codes on page:
```
global $post;
$args = array( ... );
$myposts = get_posts( $args );
foreach( $myposts as $post ) : setup_postdata($post); ?>
.......
<?php endforeach; ?>
```
I have a hight load of... | Check out the [Bulk Actions page](http://codex.wordpress.org/Plugin_API/Filter_Reference/bulk_actions) in the codex. I believe the proper action to unset is inline. This will remove the "Edit" bulk action, which is actually quick edit.
```
<?php
function remove_bulk_actions( $actions ){
unset( $actions['in... |
78,230 | <p>I'm trying to figure out how it's possible to 'refresh' the media library in the new media dialogue in 3.5. I'm adding images from an external image library to the WordPress library (via a tab/iFrame combo in the media dialogue) which works ok, but I have to close and reopen the dialogue in order to show the newly a... | [
{
"answer_id": 88455,
"author": "Rajeev Vyas",
"author_id": 6961,
"author_profile": "https://wordpress.stackexchange.com/users/6961",
"pm_score": -1,
"selected": false,
"text": "<p>is it what you are looking for</p>\n\n<pre><code>wp.media.editor.remove('content');\nwp.media.editor.add('c... | 2013/01/04 | [
"https://wordpress.stackexchange.com/questions/78230",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9069/"
] | I'm trying to figure out how it's possible to 'refresh' the media library in the new media dialogue in 3.5. I'm adding images from an external image library to the WordPress library (via a tab/iFrame combo in the media dialogue) which works ok, but I have to close and reopen the dialogue in order to show the newly adde... | The correct way of refreshing the content of the frame, as found in the WP core, is as below:
```
if(wp.media.frame.content.get()!==null){
wp.media.frame.content.get().collection.props.set({ignore: (+ new Date())});
wp.media.frame.content.get().options.selection.reset();
}else{
wp.media.frame.library.props.se... |
78,243 | <p>I have a custom login form working properly on my home view. Nice. But what I want is when user try to view some page, be redirected to my home view instead of wp-login. Im trying to do this way:</p>
<pre><code>add_action('template_redirect', 'redirect_to_login');
function redirect_to_login(){
if(!is_user_logged_... | [
{
"answer_id": 78244,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": false,
"text": "<p>Add another condition:</p>\n\n<pre><code>if( ! is_user_logged_in() and ! is_home() ) {\n # redirect …\n}\n</code></... | 2013/01/04 | [
"https://wordpress.stackexchange.com/questions/78243",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21018/"
] | I have a custom login form working properly on my home view. Nice. But what I want is when user try to view some page, be redirected to my home view instead of wp-login. Im trying to do this way:
```
add_action('template_redirect', 'redirect_to_login');
function redirect_to_login(){
if(!is_user_logged_in()){
wp_r... | `template_redirect` is called on every page load including the home page so your code will redirect the user to the homepage even when user is visiting the homepage
You could add another condition there, `is_home()` or `is_front_page()`, depending on the setting in admin, but i recommend a longer approach for better c... |
78,260 | <p>WordPress has a file called <code>pluggable.php</code> which contains a list of functions you can override in your plugin. </p>
<p>The problem I am facing (I am overriding <code>wp_authenticate</code>) is for each blog in my network I try to activate this plugin, I get:</p>
<blockquote>
<p>failure, can't re-decl... | [
{
"answer_id": 78265,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": true,
"text": "<p>Wrap your function in <code>if( ! function_exists( 'wp_authenticate' ) )</code> to get rid of the error and successf... | 2013/01/04 | [
"https://wordpress.stackexchange.com/questions/78260",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25418/"
] | WordPress has a file called `pluggable.php` which contains a list of functions you can override in your plugin.
The problem I am facing (I am overriding `wp_authenticate`) is for each blog in my network I try to activate this plugin, I get:
>
> failure, can't re-declare wp\_authenticate which was previously declare... | Wrap your function in `if( ! function_exists( 'wp_authenticate' ) )` to get rid of the error and successfully activate your plugin:
```
if( ! function_exists( 'wp_authenticate' ) ){
function wp_authenticate(){}
}
```
This is necessary because in the context of activating a plugin, the function *does* already exi... |
78,322 | <p>I am trying to remove the action hooks added by SEO ultimate plugin for some pages. The way it is added in the plugin's class is</p>
<pre><code> //Hook to output all <head> code i changed the priority to 2
add_action('wp_head', array(&$this, 'template_head'), 2);
</code></pre>
<p>The SEO plugin cr... | [
{
"answer_id": 78327,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": true,
"text": "<p>You have to use the same priority, and you need access to the global variable:</p>\n\n<pre><code>function remove_seo_he... | 2013/01/05 | [
"https://wordpress.stackexchange.com/questions/78322",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12673/"
] | I am trying to remove the action hooks added by SEO ultimate plugin for some pages. The way it is added in the plugin's class is
```
//Hook to output all <head> code i changed the priority to 2
add_action('wp_head', array(&$this, 'template_head'), 2);
```
The SEO plugin creates a global variable like this
`... | You have to use the same priority, and you need access to the global variable:
```
function remove_seo_header() {
remove_action(
'wp_head',
array( $GLOBALS['seo_ultimate'], 'template_head' ), 2
);
}
``` |
78,333 | <p>What I am looking to do is check if a page is private, give the users the option to register and see the page. Here is what I have now:</p>
<pre><code><?php
if (have_posts()) :
/* Print the most as normal */
else :
if ($post->post_status = 'private')
{
/* Print login/register box */
}
el... | [
{
"answer_id": 78341,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 4,
"selected": true,
"text": "<p>When a POST is set to private, non-logged in users will receive a 404 message. If you dump the global variable <co... | 2013/01/05 | [
"https://wordpress.stackexchange.com/questions/78333",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25598/"
] | What I am looking to do is check if a page is private, give the users the option to register and see the page. Here is what I have now:
```
<?php
if (have_posts()) :
/* Print the most as normal */
else :
if ($post->post_status = 'private')
{
/* Print login/register box */
}
else
{
/* Pri... | When a POST is set to private, non-logged in users will receive a 404 message. If you dump the global variable `$wp_query`,
```
var_dump($wp_query);
```
..you will notice that no `post_status` is present in the parameters returned therefore using the slug (or `name` parameter of `query_vars` array for example) we ca... |
78,334 | <p>I would like to use underscore in my permalinks instead of hyphen.</p>
<p>Current permalink:</p>
<pre><code>www.example.com/2013/01/hello-this-is-a-test-post/
</code></pre>
<p>Desired permalink</p>
<pre><code>www.example.com/2013/01/hello_this_is_a_test_post/
</code></pre>
<p>I have tried <a href="https://wordp... | [
{
"answer_id": 78348,
"author": "PrivateUser",
"author_id": 5074,
"author_profile": "https://wordpress.stackexchange.com/users/5074",
"pm_score": 1,
"selected": true,
"text": "<p><a href=\"https://wordpress.stackexchange.com/users/73/toscho\">Toscho</a> advised me like this.</p>\n\n<bloc... | 2013/01/05 | [
"https://wordpress.stackexchange.com/questions/78334",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5074/"
] | I would like to use underscore in my permalinks instead of hyphen.
Current permalink:
```
www.example.com/2013/01/hello-this-is-a-test-post/
```
Desired permalink
```
www.example.com/2013/01/hello_this_is_a_test_post/
```
I have tried [some solutions](https://wordpress.stackexchange.com/a/17460/5074) mentioned h... | [Toscho](https://wordpress.stackexchange.com/users/73/toscho) advised me like this.
>
> Google treats - as word separator, but not \_. You will hurt yourself.
> :)
>
>
>
He was 100% true. Here is [an article](http://www.ecreativeim.com/blog/2011/03/seo-basics-hyphen-or-underscore-for-seo-urls/) that explains it.... |
78,335 | <p>I have 3 custom searches created using different templates.</p>
<p>The search results page loads different results depending on the referrer:</p>
<pre><code><?
/* Template Name: Search Results */
$search_refer = $_GET["post_type"];
if ($search_refer == 'post') {
load_template(TEMPLATEPATH . '/search/filme... | [
{
"answer_id": 78401,
"author": "liying",
"author_id": 24490,
"author_profile": "https://wordpress.stackexchange.com/users/24490",
"pm_score": 0,
"selected": false,
"text": "<p>first of all ,see this url <a href=\"http://codex.wordpress.org/Using_Permalinks\" rel=\"nofollow\">http://code... | 2013/01/05 | [
"https://wordpress.stackexchange.com/questions/78335",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17885/"
] | I have 3 custom searches created using different templates.
The search results page loads different results depending on the referrer:
```
<?
/* Template Name: Search Results */
$search_refer = $_GET["post_type"];
if ($search_refer == 'post') {
load_template(TEMPLATEPATH . '/search/filme.php');
}
elseif ($sear... | This snippet should solve your problem. Just put it into your functions.php file.
```
function my_insert_rewrite_rules( $rules ) {
$newrules = array();
$newrules['search/([^/]+)/post_type/([^/]+)/?$'] = 'index.php?s=$matches[1]&post_type=$matches[2]';
return $newrules + $rules;
}
add_filter( 'rewrite_rules... |
78,339 | <p>I'm creating a madlib style checkout form using WooTheme's <em><a href="http://wcdocs.woothemes.com/snippets/tutorial-customising-checkout-fields-using-actions-and-filters/">Customizing checkout fields using actions and filters</a></em>. </p>
<p>Billing fields in the checkout template <code>form-billing.php</code>a... | [
{
"answer_id": 78377,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 2,
"selected": false,
"text": "<p>You can make a copy into your theme and edit the template that renders the checkout form.</p>\n\n<p>Adapted ... | 2013/01/05 | [
"https://wordpress.stackexchange.com/questions/78339",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1057/"
] | I'm creating a madlib style checkout form using WooTheme's *[Customizing checkout fields using actions and filters](http://wcdocs.woothemes.com/snippets/tutorial-customising-checkout-fields-using-actions-and-filters/)*.
Billing fields in the checkout template `form-billing.php`are displayed with this call:
```
<?php... | Thanks to Dbranes for the answer.
Replace:
```
<?php foreach ($checkout->checkout_fields['billing'] as $key => $field) : ?>
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
<?php endforeach; ?>
```
With:
```
<?php
// order the keys for your custom ordering or delete the ones you don'... |
78,345 | <p>I want to filter the blog's name for Google's user agents.</p>
<p>I have tried <code>the_title</code>, <code>the_content</code>, <code>comment_text</code>, <code>single_post_title</code>, <code>wp_title</code>, <code>category_description</code>, <code>bloginfo</code> hooks, but none of them worked!</p>
<p>Can anyb... | [
{
"answer_id": 78377,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 2,
"selected": false,
"text": "<p>You can make a copy into your theme and edit the template that renders the checkout form.</p>\n\n<p>Adapted ... | 2013/01/05 | [
"https://wordpress.stackexchange.com/questions/78345",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10968/"
] | I want to filter the blog's name for Google's user agents.
I have tried `the_title`, `the_content`, `comment_text`, `single_post_title`, `wp_title`, `category_description`, `bloginfo` hooks, but none of them worked!
Can anybody help me? | Thanks to Dbranes for the answer.
Replace:
```
<?php foreach ($checkout->checkout_fields['billing'] as $key => $field) : ?>
<?php woocommerce_form_field( $key, $field, $checkout->get_value( $key ) ); ?>
<?php endforeach; ?>
```
With:
```
<?php
// order the keys for your custom ordering or delete the ones you don'... |
78,358 | <p>I have a function that I thought should find the first article with a featured image in it, and then return that image. Not sure if this is the best way to go about it, as it's giving me a 502 Bad Gateway...</p>
<pre><code>function get_category_post($cat_id){
$finished = false;
$postcount = 0;
... | [
{
"answer_id": 78363,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>The ID of the featured image is stored under the meta key <code>_thumbnail_id</code>, so we can do a query for a sin... | 2013/01/05 | [
"https://wordpress.stackexchange.com/questions/78358",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25283/"
] | I have a function that I thought should find the first article with a featured image in it, and then return that image. Not sure if this is the best way to go about it, as it's giving me a 502 Bad Gateway...
```
function get_category_post($cat_id){
$finished = false;
$postcount = 0;
$post_args ... | The ID of the featured image is stored under the meta key `_thumbnail_id`, so we can do a query for a single post that has this key:
```
$args = array(
'posts_per_page' => 1,
'meta_key' => '_thumbnail_id',
'cat' => $cat_id
);
$latest_thumb = new WP_Query( $args );
if( $latest_thumb->have_posts() )
ret... |
78,359 | <p>I am encountering a strange problem which I couldn't solve so far.</p>
<p>I'm calling a .php script via cronjob (Debian/GNU Linux).
To use wordpress functionailty I added:</p>
<pre><code>define('WP_USE_THEMES', false);
require( '/full/path/to/wp-blog-header.php' );
</code></pre>
<p>Now database queries and defaul... | [
{
"answer_id": 78363,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>The ID of the featured image is stored under the meta key <code>_thumbnail_id</code>, so we can do a query for a sin... | 2013/01/05 | [
"https://wordpress.stackexchange.com/questions/78359",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25607/"
] | I am encountering a strange problem which I couldn't solve so far.
I'm calling a .php script via cronjob (Debian/GNU Linux).
To use wordpress functionailty I added:
```
define('WP_USE_THEMES', false);
require( '/full/path/to/wp-blog-header.php' );
```
Now database queries and default wordpress functionality all wor... | The ID of the featured image is stored under the meta key `_thumbnail_id`, so we can do a query for a single post that has this key:
```
$args = array(
'posts_per_page' => 1,
'meta_key' => '_thumbnail_id',
'cat' => $cat_id
);
$latest_thumb = new WP_Query( $args );
if( $latest_thumb->have_posts() )
ret... |
78,372 | <p>I am working on creating custom meta boxes for the back-end of WordPress.</p>
<p>I would like to add a metabox with several fields, in my case an image upload and a text input, but with a button that can duplicate both fields.</p>
<p>I've been following <a href="http://wp.tutsplus.com/tutorials/reusable-custom-met... | [
{
"answer_id": 78586,
"author": "Oterox",
"author_id": 1484,
"author_profile": "https://wordpress.stackexchange.com/users/1484",
"pm_score": 0,
"selected": false,
"text": "<p>To add repeatable fields you have to create an array with, for example, text inputs:</p>\n\n<pre><code>array( // ... | 2013/01/05 | [
"https://wordpress.stackexchange.com/questions/78372",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25573/"
] | I am working on creating custom meta boxes for the back-end of WordPress.
I would like to add a metabox with several fields, in my case an image upload and a text input, but with a button that can duplicate both fields.
I've been following [this tutorial](http://wp.tutsplus.com/tutorials/reusable-custom-meta-boxes-pa... | I created and managed my own custom meta fields for years and I can tell you it was always a headache. I frequently came up against stumbling blocks like yours and ended up banging my fist against the wall. I've also worked on quite a few sites which had been flooded with plugins, sometimes so many that it soured me on... |
78,404 | <p>I followed <a href="http://coolestguyplanettech.com/downtown/install-and-configure-apache-mysql-php-and-phpmyadmin-osx-108-mountain-lion" rel="nofollow">this tutorial</a> on setting up a local web development setup without mamp. Now my problem is when I go to upload a image in WordPress I get the following error:</p... | [
{
"answer_id": 78405,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 2,
"selected": false,
"text": "<p>You need to change the <a href=\"http://codex.wordpress.org/Changing_FIle_Permissions\" rel=\"nofollow\">file per... | 2013/01/06 | [
"https://wordpress.stackexchange.com/questions/78404",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7653/"
] | I followed [this tutorial](http://coolestguyplanettech.com/downtown/install-and-configure-apache-mysql-php-and-phpmyadmin-osx-108-mountain-lion) on setting up a local web development setup without mamp. Now my problem is when I go to upload a image in WordPress I get the following error:
>
> “Screen Shot 2013-01-05 a... | You need to change the [file permissions](http://codex.wordpress.org/Changing_FIle_Permissions) on your `wp-content` folder (and containing folders) to `755`. On your setup you can do this with:
```
find . -type d -exec sudo chmod 755 {} \;
```
Please note that using `chmod -R 755` will mark both directories **and f... |
78,406 | <p>My site is basically a Pinterest style product catalogue with atleast one image per post. </p>
<p>I upload large images, thumbnails of which are automatically generated by wordpress BUT the website has been loading really slow because <code>the_content</code> tag by default uses the largest thumbnail image that I c... | [
{
"answer_id": 78414,
"author": "varun1505",
"author_id": 25456,
"author_profile": "https://wordpress.stackexchange.com/users/25456",
"pm_score": 0,
"selected": false,
"text": "<p>I think <a href=\"http://codex.wordpress.org/Function_Reference/the_post_thumbnail#Post_Thumbnail_Linking_to... | 2013/01/06 | [
"https://wordpress.stackexchange.com/questions/78406",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16113/"
] | My site is basically a Pinterest style product catalogue with atleast one image per post.
I upload large images, thumbnails of which are automatically generated by wordpress BUT the website has been loading really slow because `the_content` tag by default uses the largest thumbnail image that I choose from the "media... | I suspect you may be unclear about the code and features you are referring to and therefore about what you are asking. If you are trying to change the size of the thumbnail for an image you are inserting in the content area then you would change this in the Settings under Media as **marikamitsos** mentioned.
Insert th... |
78,422 | <p>I'm building a site that doesn't want any styling applied to the entry-content, because it should keep the formatting of the text.</p>
<p>Bizarly, it works on old entries, but new entries via the front-end system fail:
<code>http://madebylars.nl/music/?page_id=373</code></p>
<h3>Example:</h3>
<p>This one works:</p>
... | [
{
"answer_id": 78439,
"author": "adrian7",
"author_id": 7171,
"author_profile": "https://wordpress.stackexchange.com/users/7171",
"pm_score": 0,
"selected": false,
"text": "<p>There could be a number of reasons why it does not work: invalid markup, stripping content also removes <code>&l... | 2013/01/06 | [
"https://wordpress.stackexchange.com/questions/78422",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23478/"
] | I'm building a site that doesn't want any styling applied to the entry-content, because it should keep the formatting of the text.
Bizarly, it works on old entries, but new entries via the front-end system fail:
`http://madebylars.nl/music/?page_id=373`
### Example:
This one works:
```
http://madebylars.nl/music/?t... | The pages you are linking use two different characters, one is the `&mdash` and the other I don't know the name, it does not translates into an Html entity...
Original:
`2——-2——-7——-7——-|` <-- Mixed characters
Using the character that works:
`2---2---7---7---|` <-- This one is not `&mdash`.
You may consider using ... |
78,428 | <p>I'm creating custom wordpress theme. How can I enable "Description" metabox for menu items (on nav-menu page) by default programmatically?</p>
| [
{
"answer_id": 78432,
"author": "nonsensecreativity",
"author_id": 10997,
"author_profile": "https://wordpress.stackexchange.com/users/10997",
"pm_score": 0,
"selected": false,
"text": "<p>If you're looking to output the menu description here is a useful tutorial using WordPress Walker M... | 2013/01/06 | [
"https://wordpress.stackexchange.com/questions/78428",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24891/"
] | I'm creating custom wordpress theme. How can I enable "Description" metabox for menu items (on nav-menu page) by default programmatically? | Remove the `description` from the user meta value `managenav-menuscolumnshidden`:
```
add_filter( 'manage_nav-menus_columns', 'enable_nav_menu_description_by_default' );
function enable_nav_menu_description_by_default( $columns )
{
$desc_key = 'managenav-menuscolumnshidden';
$hidden = get_user_option( $desc... |
78,441 | <p>I have the following code in my functions.php file to display post shortlink in my posts (I prefer not to edit theme files if possible)...</p>
<pre><code>function add_post_content($content) {
if ( is_single() ) {
$content .= '<p>Shortlink: ' .wp_get_shortlink(); '</p>';
} elseif ( 'port... | [
{
"answer_id": 78442,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 1,
"selected": true,
"text": "<p>Reorder the logic, and fix the minor syntax error in your appended string:</p>\n\n<pre><code>function add_post_content(... | 2013/01/06 | [
"https://wordpress.stackexchange.com/questions/78441",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25636/"
] | I have the following code in my functions.php file to display post shortlink in my posts (I prefer not to edit theme files if possible)...
```
function add_post_content($content) {
if ( is_single() ) {
$content .= '<p>Shortlink: ' .wp_get_shortlink(); '</p>';
} elseif ( 'portfolio' == get_post_type() ... | Reorder the logic, and fix the minor syntax error in your appended string:
```
function add_post_content($content) {
if ( 'portfolio' == get_post_type() )
return $content;
if ( is_single() )
return $content . '<p>Shortlink: ' . wp_get_shortlink() . '</p>';
return $content;
}
``` |
78,483 | <p>Where you can add your menu in under appearance > menus, I have descriptions in. In my page, I want to be able to echo out that description. Not in the menu, but in my page. How can I access this information?</p>
<p>EDIT: </p>
<p>@toscho</p>
<p>How do I edit my custom walker? Does the object $item have acces... | [
{
"answer_id": 78485,
"author": "Claire",
"author_id": 14739,
"author_profile": "https://wordpress.stackexchange.com/users/14739",
"pm_score": 0,
"selected": false,
"text": "<p>Found the answer on a google cached website.</p>\n\n<p>So to access the current page's navigation item descript... | 2013/01/06 | [
"https://wordpress.stackexchange.com/questions/78483",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14739/"
] | Where you can add your menu in under appearance > menus, I have descriptions in. In my page, I want to be able to echo out that description. Not in the menu, but in my page. How can I access this information?
EDIT:
@toscho
How do I edit my custom walker? Does the object $item have access to the page excerpt?
```
c... | I don’t like the idea to parse the menu items again. As an alternative solution I suggest to store the description during the first run:
```
add_filter( 'walker_nav_menu_start_el', 'wpse_78483_get_current_items_description', 10, 2 );
/**
* Get nav items description.
*
* @wp-hook walker_nav_menu_start_el
* @param ... |
78,490 | <p>I need a way to get just the comments that aren't top level i.e. where parent is not 0.</p>
<p>I've tried:</p>
<pre><code>$args = array(
'parent' => -0
);
$comments = get_comments($args);
</code></pre>
<p>I know the parent comment id's (44 and 48) of all the comments I require, so I tried:</p>
<pre><code>$... | [
{
"answer_id": 78491,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 4,
"selected": true,
"text": "<p>You cannot do that with a parameter for <code>get_comments()</code>, but filtering <code>'comments_clauses'</code> shou... | 2013/01/06 | [
"https://wordpress.stackexchange.com/questions/78490",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25430/"
] | I need a way to get just the comments that aren't top level i.e. where parent is not 0.
I've tried:
```
$args = array(
'parent' => -0
);
$comments = get_comments($args);
```
I know the parent comment id's (44 and 48) of all the comments I require, so I tried:
```
$args = array(
'parent' => array(44,48)
);
$... | You cannot do that with a parameter for `get_comments()`, but filtering `'comments_clauses'` should do it.
Sample code, not tested:
```
add_filter( 'comments_clauses', 'wpse_78490_child_comments_only' );
function wpse_78490_child_comments_only( $clauses )
{
$clauses['where'] .= ' AND comment_parent != 0';
re... |
78,499 | <p>I am using the wordpress <a href="http://www.advancedcustomfields.com/docs/field-types/select/" rel="noreferrer">Advanced Custom Fields plugin</a>.</p>
<p>This question is about the <a href="http://www.advancedcustomfields.com/docs/field-types/select/" rel="noreferrer">select field</a>, and in the documentation onl... | [
{
"answer_id": 140825,
"author": "Fredy31",
"author_id": 8895,
"author_profile": "https://wordpress.stackexchange.com/users/8895",
"pm_score": 3,
"selected": false,
"text": "<p>Throwing the solution here for better reading.</p>\n\n<pre><code>$field = get_field_object('field_name');\n$val... | 2013/01/07 | [
"https://wordpress.stackexchange.com/questions/78499",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11327/"
] | I am using the wordpress [Advanced Custom Fields plugin](http://www.advancedcustomfields.com/docs/field-types/select/).
This question is about the [select field](http://www.advancedcustomfields.com/docs/field-types/select/), and in the documentation only tells me how to output the value, not the label/name.
I can't s... | The get\_field\_object() function requires the field KEY not the field NAME. See docs: <http://www.advancedcustomfields.com/resources/functions/get_field_object/>
So it should looks something like this...
```
$field = get_field_object('field_53d27f5599979');
$value = get_field('field_myfield');
$label = $field['choic... |
78,511 | <p>I'm building a website that uses Wordpress as the CMS and is built with Yii framework. All the business logic works fine. Most visible pages are filled with content from Wordpress admin and only the user profile section is built with Yii. </p>
<p>My problem is that I would like to reuse the layout of the wordpress ... | [
{
"answer_id": 78515,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>In your <code>header.php</code> you are probably using <code>wp_title()</code>. This one requires at least two global ... | 2013/01/07 | [
"https://wordpress.stackexchange.com/questions/78511",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25659/"
] | I'm building a website that uses Wordpress as the CMS and is built with Yii framework. All the business logic works fine. Most visible pages are filled with content from Wordpress admin and only the user profile section is built with Yii.
My problem is that I would like to reuse the layout of the wordpress pages in t... | In your `header.php` you are probably using `wp_title()`. This one requires at least two global variables: `$wpdb` (the `get_query_var()` call) and `$wp_locale`, on singular views a global `$post` object too.
So you have to create these variables, or set `wp_title()` in a conditional, like this:
```
if ( ! empty ( $G... |
78,536 | <p>I've wrote some basic custom PHP code for my Wordpress site. The code basically access a MySQL database (a different database from the wordpress database) and displays the information. In addition to running it on the main page, I also need it to run on the sidebar. The code functions perfectly in the main page <em>... | [
{
"answer_id": 78539,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 1,
"selected": false,
"text": "<p>First of all dont use Exec-PHP plugin, instead of it write your own. Second use $wpdb object (instance o... | 2013/01/07 | [
"https://wordpress.stackexchange.com/questions/78536",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25670/"
] | I've wrote some basic custom PHP code for my Wordpress site. The code basically access a MySQL database (a different database from the wordpress database) and displays the information. In addition to running it on the main page, I also need it to run on the sidebar. The code functions perfectly in the main page *or* it... | First of all dont use Exec-PHP plugin, instead of it write your own. Second use $wpdb object (instance of WPDB class) to make all calls to database.
* <http://codex.wordpress.org/Writing_a_Plugin>
* <http://codex.wordpress.org/Class_Reference/wpdb> |
78,543 | <p>I have a litlle problem. I have a custom taxonomy 'rodzaj' with value i.ex. obrazek. I use this code to add post:</p>
<pre><code>$postArray = array(
'post_status' => 'publish',
'post_author'=> get_current_user_id(),
'post_category'=>array($catId),
... | [
{
"answer_id": 78549,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p>Have you tried:</p>\n\n<pre><code>wp_set_object_terms( $postId, array( 'obrazek'), 'rodzaj' );\n</code></pre>... | 2013/01/07 | [
"https://wordpress.stackexchange.com/questions/78543",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25675/"
] | I have a litlle problem. I have a custom taxonomy 'rodzaj' with value i.ex. obrazek. I use this code to add post:
```
$postArray = array(
'post_status' => 'publish',
'post_author'=> get_current_user_id(),
'post_category'=>array($catId),
'post_title' => $_... | Have you tried:
```
wp_set_object_terms( $postId, array( 'obrazek'), 'rodzaj' );
```
`wp_set_object_terms` and `wp_set_post_terms` take the same arguments. `wp_set_post_terms` even uses wp\_set\_object\_terms internally. The main difference being that you used an array in the one that worked, and you didn't use an a... |
78,547 | <p>I have little problem with Media Uploader in new WordPress 3.5. I created own plugin which is upload the picture. I'm using this code JS:</p>
<pre><code><script type="text/javascript">
var file_frame;
jQuery('.button-secondary').live('click', function( event ){
event.preventDefault();
... | [
{
"answer_id": 81482,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 3,
"selected": false,
"text": "<p><strong>Only Uploader</strong></p>\n\n<p>below a example code, works only on post edit page. If you will use also ... | 2013/01/07 | [
"https://wordpress.stackexchange.com/questions/78547",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25677/"
] | I have little problem with Media Uploader in new WordPress 3.5. I created own plugin which is upload the picture. I'm using this code JS:
```
<script type="text/javascript">
var file_frame;
jQuery('.button-secondary').live('click', function( event ){
event.preventDefault();
if ( file_frame )... | **Only Uploader**
below a example code, works only on post edit page. If you will use also on other page, then include the function `wp_enqueue_media()`, see the next headline.
```
jQuery(document).ready(function($) {
var _custom_media = true,
_orig_send_attachment = wp.media.editor.send.attachment;
$('.s... |
78,569 | <p>Just wondering if there's anything particularly wrong with putting theme elements like navigation menus, or even footer content or anything else that is going to be the same on every page inside the posts loop. (<code><?php while ( have_posts() ) : the_post() ?>
</code>)</p>
<p>Obviously for most themes, it m... | [
{
"answer_id": 81482,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 3,
"selected": false,
"text": "<p><strong>Only Uploader</strong></p>\n\n<p>below a example code, works only on post edit page. If you will use also ... | 2013/01/07 | [
"https://wordpress.stackexchange.com/questions/78569",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25146/"
] | Just wondering if there's anything particularly wrong with putting theme elements like navigation menus, or even footer content or anything else that is going to be the same on every page inside the posts loop. (`<?php while ( have_posts() ) : the_post() ?>`)
Obviously for most themes, it makes sense for the posts to ... | **Only Uploader**
below a example code, works only on post edit page. If you will use also on other page, then include the function `wp_enqueue_media()`, see the next headline.
```
jQuery(document).ready(function($) {
var _custom_media = true,
_orig_send_attachment = wp.media.editor.send.attachment;
$('.s... |
78,573 | <p>I'm trying to delete all comments from posts in a certain category in a Wordpress database.</p>
<p>The Wordpress database is rather complicated so this must be probably some join of <code>wp_posts</code>, <code>wp_comments</code> and <code>wp_term_relationships</code> as the categories are not stored with neither p... | [
{
"answer_id": 78574,
"author": "user1636130",
"author_id": 44317,
"author_profile": "https://wordpress.stackexchange.com/users/44317",
"pm_score": 1,
"selected": true,
"text": "<p>The wordpress database seems fairly straight forward and is extremely well documented:</p>\n\n<p><a href=\"... | 2013/01/06 | [
"https://wordpress.stackexchange.com/questions/78573",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115390/"
] | I'm trying to delete all comments from posts in a certain category in a Wordpress database.
The Wordpress database is rather complicated so this must be probably some join of `wp_posts`, `wp_comments` and `wp_term_relationships` as the categories are not stored with neither posts nor comments.
How can I do this? I'm ... | The wordpress database seems fairly straight forward and is extremely well documented:
<http://codex.wordpress.org/Database_Description>
It seems to me that all the category information is stored in the table **wp\_term\_relationships**. So you should select from the comments table, join it with the posts table and t... |
78,580 | <p>In previous installations of WordPress it was possible to number images in <code>attachment.php</code> using the code below, which was originally provided <a href="https://wordpress.stackexchange.com/questions/36279/gallery-image-numbers">here</a>. However, I'm finding that this code no longer works as the image nu... | [
{
"answer_id": 78582,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": true,
"text": "<p>There is no complete solution possible. And that is not new.</p>\n\n<p>Any image can be a part of a gallery in a post t... | 2013/01/07 | [
"https://wordpress.stackexchange.com/questions/78580",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5205/"
] | In previous installations of WordPress it was possible to number images in `attachment.php` using the code below, which was originally provided [here](https://wordpress.stackexchange.com/questions/36279/gallery-image-numbers). However, I'm finding that this code no longer works as the image numbers are inaccurate.
Is ... | There is no complete solution possible. And that is not new.
Any image can be a part of a gallery in a post that is not that image’s parent. So the post parent is not a useful parameter. The new interface makes such galleries easier to create, but they were possible in earlier versions too.
Even *if* the attachment’s... |
78,595 | <p>How do I remove Editor in custom post type keeping the Add media button. When I used as following in custom post type declaration, it removes the Add Media button and I don't need editor in my post type.</p>
<pre><code>'supports' => array( 'title', 'thumbnail' ),
</code></pre>
<p>Thanks</p>
| [
{
"answer_id": 78730,
"author": "Pontus Abrahamsson",
"author_id": 16722,
"author_profile": "https://wordpress.stackexchange.com/users/16722",
"pm_score": 1,
"selected": false,
"text": "<p>WordPress uses the function <a href=\"http://codex.wordpress.org/Function_Reference/wp_editor\" rel... | 2013/01/07 | [
"https://wordpress.stackexchange.com/questions/78595",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16286/"
] | How do I remove Editor in custom post type keeping the Add media button. When I used as following in custom post type declaration, it removes the Add Media button and I don't need editor in my post type.
```
'supports' => array( 'title', 'thumbnail' ),
```
Thanks | WordPress uses the function [wp\_editor()](http://codex.wordpress.org/Function_Reference/wp_editor) and there are no parameter that will disable the textarea (what i can see). So i think that you can just hide it with some css.
```
function wpse_78595_hide_editor() {
global $current_screen;
if( $current_scree... |
78,596 | <p>There is a plugin that's conflicting with mine when the user loads the admin pages of my plugin, therefore I want to deregister and remove the conflicting script on these pages.</p>
<p>Here is the code for the conflicting script:-</p>
<pre><code>add_action( 'admin_head', 'function_name' );
function function_name(... | [
{
"answer_id": 78597,
"author": "akTed",
"author_id": 25472,
"author_profile": "https://wordpress.stackexchange.com/users/25472",
"pm_score": 0,
"selected": false,
"text": "<p>See <a href=\"http://codex.wordpress.org/Function_Reference/wp_dequeue_script\" rel=\"nofollow\">wp_dequeue_scri... | 2013/01/07 | [
"https://wordpress.stackexchange.com/questions/78596",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25695/"
] | There is a plugin that's conflicting with mine when the user loads the admin pages of my plugin, therefore I want to deregister and remove the conflicting script on these pages.
Here is the code for the conflicting script:-
```
add_action( 'admin_head', 'function_name' );
function function_name() {
if ( is_admin() )... | Yep, it's possible, but you want to use [`wp_dequeue_script`](http://codex.wordpress.org/Function_Reference/wp_dequeue_script).
Try this:
```
<?php
function admin_hc_deregister_conflicts()
{
wp_dequeue_script('script_name');
}
``` |
78,599 | <p>I have been wrestling with this for some time. I've read the documentation about creating a separate home page and posts page, and so on, and I have managed to create a landing page, and a blog. </p>
<p>But I'd like to have the landing/home page be a dedicated music page with a player, and I can't seem to get rid ... | [
{
"answer_id": 78615,
"author": "bosco",
"author_id": 25324,
"author_profile": "https://wordpress.stackexchange.com/users/25324",
"pm_score": 2,
"selected": false,
"text": "<p>On the most basic level, you could prevent all posts from being displayed by simply ripping the Loop out of the ... | 2013/01/07 | [
"https://wordpress.stackexchange.com/questions/78599",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25696/"
] | I have been wrestling with this for some time. I've read the documentation about creating a separate home page and posts page, and so on, and I have managed to create a landing page, and a blog.
But I'd like to have the landing/home page be a dedicated music page with a player, and I can't seem to get rid of the blog... | On the most basic level, you could prevent all posts from being displayed by simply ripping the Loop out of the template that is displaying your "landing page." If you only wish to ***modify*** the posts being displayed on your "landing page," (say for instance should you be using Wordpress post object as songs and att... |
78,601 | <p>I just wondered what this row in the Wordpress Database refers to?</p>
<pre><code>32 gzipcompression 0
</code></pre>
<p>I stumbled upon it in the WP options table. What if I set the value to <code>1</code>. </p>
<p>I do already have gzipcompression enabled via htaccess, so I simply wondered what this is?</p>
<p... | [
{
"answer_id": 78604,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 3,
"selected": true,
"text": "<p>It's set in <code>schema.php</code>, <a href=\"https://github.com/WordPress/WordPress/blob/3.5/wp-admin/includes/sch... | 2013/01/07 | [
"https://wordpress.stackexchange.com/questions/78601",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3529/"
] | I just wondered what this row in the Wordpress Database refers to?
```
32 gzipcompression 0
```
I stumbled upon it in the WP options table. What if I set the value to `1`.
I do already have gzipcompression enabled via htaccess, so I simply wondered what this is?
Thank you for your answer. | It's set in `schema.php`, [the WordPress Administration Scheme API](https://github.com/WordPress/WordPress/blob/3.5/wp-admin/includes/schema.php#L393). You can also find it in [the Codex](http://codex.wordpress.org/Option_Reference#Reading).
As you can see from a search through core, there's (as far as my search went)... |
78,627 | <p>Can the wp-plugins (Must Use Plugins) URL be targeted for use in functions.php? I have a mu-functions.php file in the mu-plugins folder. One function calls a javascript file (<code>alerts.js</code>) located in <code>example.com/wp-content/mu-plugins/js/</code>. How can I target the mu-plugins folder in my function?<... | [
{
"answer_id": 78633,
"author": "bosco",
"author_id": 25324,
"author_profile": "https://wordpress.stackexchange.com/users/25324",
"pm_score": 3,
"selected": true,
"text": "<p><strong>EDIT: this solution is not a best-practice. Please use the solution submitted by Nathan below!</strong></... | 2013/01/07 | [
"https://wordpress.stackexchange.com/questions/78627",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14558/"
] | Can the wp-plugins (Must Use Plugins) URL be targeted for use in functions.php? I have a mu-functions.php file in the mu-plugins folder. One function calls a javascript file (`alerts.js`) located in `example.com/wp-content/mu-plugins/js/`. How can I target the mu-plugins folder in my function?
Currently, I am using `g... | **EDIT: this solution is not a best-practice. Please use the solution submitted by Nathan below!**
Use [the `WPMU_PLUGIN_DIR` and `WPMU_PLUGIN_URL` constants](http://codex.wordpress.org/Must_Use_Plugins) :)
```
function load_my_alerts(){
wp_register_script(
'my_alerts',
WPMU_PLUGIN_URL . '/js/al... |
78,628 | <p>I selected only 2 levels of comment for my wordpress site.
How can I display the number of comment of the first level ? (Depth-1)</p>
| [
{
"answer_id": 78656,
"author": "akTed",
"author_id": 25472,
"author_profile": "https://wordpress.stackexchange.com/users/25472",
"pm_score": 2,
"selected": false,
"text": "<p>In the wp_comments table, if <code>comment_parent</code> equals 0, it's a first-level comment.</p>\n\n<pre><code... | 2013/01/07 | [
"https://wordpress.stackexchange.com/questions/78628",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25707/"
] | I selected only 2 levels of comment for my wordpress site.
How can I display the number of comment of the first level ? (Depth-1) | In the wp\_comments table, if `comment_parent` equals 0, it's a first-level comment.
```
function get_num_toplevel_comments() {
global $wpdb;
return $wpdb->get_var("
SELECT COUNT(*)
FROM $wpdb->comments
WHERE comment_parent = 0
");
}
``` |
78,629 | <p>I am creating a plugin. In this plugin I have shortcodes that provide some logic and content for pages. This way I have created 'Page A' and 'Page B'. Both of the pages will redirect user to external page. The external page is not written by me and will not process any of my $_GET or $_POST values. Then this extern... | [
{
"answer_id": 78656,
"author": "akTed",
"author_id": 25472,
"author_profile": "https://wordpress.stackexchange.com/users/25472",
"pm_score": 2,
"selected": false,
"text": "<p>In the wp_comments table, if <code>comment_parent</code> equals 0, it's a first-level comment.</p>\n\n<pre><code... | 2013/01/07 | [
"https://wordpress.stackexchange.com/questions/78629",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25348/"
] | I am creating a plugin. In this plugin I have shortcodes that provide some logic and content for pages. This way I have created 'Page A' and 'Page B'. Both of the pages will redirect user to external page. The external page is not written by me and will not process any of my $\_GET or $\_POST values. Then this external... | In the wp\_comments table, if `comment_parent` equals 0, it's a first-level comment.
```
function get_num_toplevel_comments() {
global $wpdb;
return $wpdb->get_var("
SELECT COUNT(*)
FROM $wpdb->comments
WHERE comment_parent = 0
");
}
``` |
78,630 | <p>Does anyone know how to get ID's of images from wordpress gallery in post? I have search entire internet and there is nothing to this subject.</p>
| [
{
"answer_id": 78636,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 2,
"selected": false,
"text": "<p>You can find out the IDs of which images are included in a gallery by switching to the <strong>Text</strong> edit... | 2013/01/07 | [
"https://wordpress.stackexchange.com/questions/78630",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13746/"
] | Does anyone know how to get ID's of images from wordpress gallery in post? I have search entire internet and there is nothing to this subject. | You can find out the IDs of which images are included in a gallery by switching to the **Text** editor tab and look for a piece of code like this:
```
[gallery columns="3" link="file" ids="615,619,618,617,616"]
```
The comma-separated list of image IDs are enclosed in the `ids` attribute
---
If you're looking to f... |
78,637 | <p>I wanna make a simple shortcode that returns the youtube link in a specified size and use the content. Something like:</p>
<pre><code>[yt]http://youtu.be/Nl29v5pfxTw[/yt]
</code></pre>
<p>I have this code, but I want to simplify it:</p>
<pre><code> function youtube($atts) {
extract(shortcode_atts(array... | [
{
"answer_id": 78641,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 2,
"selected": false,
"text": "<p>Shortcode functions accept a <a href=\"http://codex.wordpress.org/Shortcode_API#Overview\" rel=\"nofollow\">secon... | 2013/01/08 | [
"https://wordpress.stackexchange.com/questions/78637",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20530/"
] | I wanna make a simple shortcode that returns the youtube link in a specified size and use the content. Something like:
```
[yt]http://youtu.be/Nl29v5pfxTw[/yt]
```
I have this code, but I want to simplify it:
```
function youtube($atts) {
extract(shortcode_atts(array(
"value" => 'http://... | Shortcode functions accept a [second parameter](http://codex.wordpress.org/Shortcode_API#Overview) which contains the value in between the shortcode opening and closing tags:
```
function youtube( $atts, $value = 'http://' ) {
extract( shortcode_atts( array(
"width" => '620',
"height" => '350',
... |
78,649 | <p>Trying to build a search that not only searches the defaults (title, content etc) but also a specific custom field.</p>
<p>My current query:</p>
<pre><code>$args = array(
'post_type' => 'post',
's' => $query,
'meta_query' => array(
array(
'key' => 'speel',
'value' => $query,... | [
{
"answer_id": 78671,
"author": "M-R",
"author_id": 17061,
"author_profile": "https://wordpress.stackexchange.com/users/17061",
"pm_score": 2,
"selected": false,
"text": "<p>Well its kind of a hack but it works. You need to add posts_clauses filter. This filter function check for the any... | 2013/01/08 | [
"https://wordpress.stackexchange.com/questions/78649",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25713/"
] | Trying to build a search that not only searches the defaults (title, content etc) but also a specific custom field.
My current query:
```
$args = array(
'post_type' => 'post',
's' => $query,
'meta_query' => array(
array(
'key' => 'speel',
'value' => $query,
'compare' => 'LIKE'
)
... | As per [Nick Perkins'](https://wordpress.stackexchange.com/a/78655/25713) suggestion, I had to merge two queries like so:
```
$q1 = get_posts(array(
'fields' => 'ids',
'post_type' => 'post',
's' => $query
));
$q2 = get_posts(array(
'fields' => 'ids',
'post_type' => 'post',
... |
78,666 | <p>I am trying to determine if an item has a sub-item with depth 1 or higher. I cannot find anywhere if there is some function/query I can write that grabs the current item looks in the database if it has any sub-pages and returns <code>true</code>. </p>
<p>What I aim to do with this is give the <code><li></code... | [
{
"answer_id": 78672,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>You can filter <code>wp_nav_menu_objects</code> and add the classes in one rush. You don’t even need a custom walker fo... | 2013/01/08 | [
"https://wordpress.stackexchange.com/questions/78666",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25722/"
] | I am trying to determine if an item has a sub-item with depth 1 or higher. I cannot find anywhere if there is some function/query I can write that grabs the current item looks in the database if it has any sub-pages and returns `true`.
What I aim to do with this is give the `<li>` class a different class depending on... | You can filter `wp_nav_menu_objects` and add the classes in one rush. You don’t even need a custom walker for that.
```
add_filter( 'wp_nav_menu_objects', 'add_has_children_to_nav_items' );
function add_has_children_to_nav_items( $items )
{
$parents = wp_list_pluck( $items, 'menu_item_parent');
foreach ( $it... |
78,667 | <p>Due to some changes in the DB, I need to alter a table to add one column to it, but even though the function is running, the table isn't altered.
Here's the ALTER TABLE code that I've written</p>
<pre><code>$sql = "ALTER TABLE " . $packagetable . " ADD COLUMN price decimal(14,2) NOT NULL AFTER description;";
dbDelt... | [
{
"answer_id": 78670,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 4,
"selected": false,
"text": "<p>You've used the <code>dbDelta</code> function incorrectly.</p>\n<p>The whole point of that function is you pa... | 2013/01/08 | [
"https://wordpress.stackexchange.com/questions/78667",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16933/"
] | Due to some changes in the DB, I need to alter a table to add one column to it, but even though the function is running, the table isn't altered.
Here's the ALTER TABLE code that I've written
```
$sql = "ALTER TABLE " . $packagetable . " ADD COLUMN price decimal(14,2) NOT NULL AFTER description;";
dbDelta($sql);
```
... | You've used the `dbDelta` function incorrectly.
The whole point of that function is you pass in a table creation SQL command.
If the table doesn't exist, it creates it.
**If the table exists but doesn't match**, it's modified until it matches. This includes adding and updating columns, indexes, and other aspects.
S... |
78,673 | <p>i have created custom post type 'event' to display in single page named single-event.php file but it provides me 404 error. how i can solve this problem even i used </p>
<blockquote>
<p>flush_rewrite_rules();</p>
</blockquote>
<p>please provide some idea.......</p>
<pre><code>function custom_event() {
$labels =... | [
{
"answer_id": 78675,
"author": "M-R",
"author_id": 17061,
"author_profile": "https://wordpress.stackexchange.com/users/17061",
"pm_score": 0,
"selected": false,
"text": "<p>Place flush_rewrite_rules(); after the register call.\nAlso, Try flushing your rewrite rules through WP Admin, by ... | 2013/01/08 | [
"https://wordpress.stackexchange.com/questions/78673",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23681/"
] | i have created custom post type 'event' to display in single page named single-event.php file but it provides me 404 error. how i can solve this problem even i used
>
> flush\_rewrite\_rules();
>
>
>
please provide some idea.......
```
function custom_event() {
$labels = array(
'name' => _x('Event', 'post t... | Follow [this](http://justintadlock.com/archives/2010/04/29/custom-post-types-in-wordpress) tutorial for creating the custom post type.
Here is the working code as per your requirement:
```
function create_post_type_event() {
//Create custom post type for event
$labels = array(
'name' => _x('Even... |
78,690 | <p><a href="https://wordpress.stackexchange.com/questions/59770/only-allow-new-subpages-to-be-created">Here</a> is an amazing solution to restrict the creation of new parent pages, and I would want to use it, but the newly created sub-pages are saved only as drafts and this was not solved (see last comments at mentione... | [
{
"answer_id": 80182,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 4,
"selected": true,
"text": "<p>you actually don't need any ajax or server side action, simple see if the user has selected a parent page:</p>... | 2013/01/08 | [
"https://wordpress.stackexchange.com/questions/78690",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25187/"
] | [Here](https://wordpress.stackexchange.com/questions/59770/only-allow-new-subpages-to-be-created) is an amazing solution to restrict the creation of new parent pages, and I would want to use it, but the newly created sub-pages are saved only as drafts and this was not solved (see last comments at mentioned link).
The... | you actually don't need any ajax or server side action, simple see if the user has selected a parent page:
```
add_action( 'admin_head-post-new.php', 'publish_admin_hook_wpse_78690' );
add_action( 'admin_head-post.php', 'publish_admin_hook_wpse_78690' );
function publish_admin_hook_wpse_78690()
{
global $current_... |
78,718 | <p>Below is a snippet of code that appears on one of my pages called: Featured. I created a template and then respectively created a page and activated the template in the wp-admin. However when I click the button to paginate to page 2, which looks something like: <a href="http://example.com/featured/page/2" rel="nofol... | [
{
"answer_id": 78720,
"author": "molokom",
"author_id": 14047,
"author_profile": "https://wordpress.stackexchange.com/users/14047",
"pm_score": 1,
"selected": false,
"text": "<p>your code was a bit messy but working for me.</p>\n\n<p>I cleaned a bit and it works fine for me. I used on a ... | 2013/01/08 | [
"https://wordpress.stackexchange.com/questions/78718",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17193/"
] | Below is a snippet of code that appears on one of my pages called: Featured. I created a template and then respectively created a page and activated the template in the wp-admin. However when I click the button to paginate to page 2, which looks something like: <http://example.com/featured/page/2> the next page shows u... | In functions.php
```
function my_theme_navigation()
{
global $shortname;
if( get_option( $shortname . '_next_prev_or_paginate' ) == 'Next' ) :
// the block for next-prev navigation
echo '<div style="float:left">';
next_posts_link('Older');
echo '</div>';
echo '<div s... |
78,740 | <p>CSS-Tricks suggests <a href="http://css-tricks.com/snippets/wordpress/include-jquery-in-wordpress-theme/" rel="nofollow">this code</a> to load jQuery.</p>
<p>However, I'm curious if anybody has done the same thing in functions.php with <strong>two fallbacks: the Microsoft hosted jQuery being the first option and lo... | [
{
"answer_id": 78747,
"author": "Simon Hayter",
"author_id": 24663,
"author_profile": "https://wordpress.stackexchange.com/users/24663",
"pm_score": -1,
"selected": false,
"text": "<p>As far as I can tell there is no fall back within their functions.php, what that functions.php is doing ... | 2013/01/08 | [
"https://wordpress.stackexchange.com/questions/78740",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5205/"
] | CSS-Tricks suggests [this code](http://css-tricks.com/snippets/wordpress/include-jquery-in-wordpress-theme/) to load jQuery.
However, I'm curious if anybody has done the same thing in functions.php with **two fallbacks: the Microsoft hosted jQuery being the first option and locally hosted jQuery being the second**, th... | I use a similar pattern to enqueue jQuery from the Google CDN (as the CSS Tricks example). However in my footer (typically `footer.php`) I'll usually hard code the following fallback.
```
<script type="text/javascript">
if (typeof jQuery === 'undefined') {
document.write('<script src="<?php echo get_styles... |
78,744 | <p>I'm trying to figure out how to count and display the number of images in a gallery with WP 3.5. I was following an old post on <a href="http://ottopress.com/2011/photo-gallery-primer/">Ottopress</a>, querying the DB for attachments but it seems the galleries are now contained in shortcodes.</p>
<p>Is it possible t... | [
{
"answer_id": 82627,
"author": "justmattb",
"author_id": 26347,
"author_profile": "https://wordpress.stackexchange.com/users/26347",
"pm_score": 2,
"selected": false,
"text": "<p>This works:</p>\n\n<pre><code>$images = get_children( array(\n 'post_parent' => $post->ID,\n 'po... | 2013/01/08 | [
"https://wordpress.stackexchange.com/questions/78744",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12870/"
] | I'm trying to figure out how to count and display the number of images in a gallery with WP 3.5. I was following an old post on [Ottopress](http://ottopress.com/2011/photo-gallery-primer/), querying the DB for attachments but it seems the galleries are now contained in shortcodes.
Is it possible to extract the shortco... | This works:
```
$images = get_children( array(
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'orderby' => 'menu_order',
'order' => 'ASC',
'numberposts' => 999
));
if ( $images ) {
$total_images = count( $images );
}
```
The variable $total\_images w... |
78,752 | <p>I'm working with Wordpress 3.3.1 on a local installation. I've uploaded an image file and it doesn't show up.</p>
<p>The base directory is a symbolic link <code>/var/www/wordpress/</code> that leads to <code>/usr/share/wordpress/</code></p>
<p>The file exists here:
<code>/srv/www/wp-uploads/localhost/2013/01/Logo.... | [
{
"answer_id": 82627,
"author": "justmattb",
"author_id": 26347,
"author_profile": "https://wordpress.stackexchange.com/users/26347",
"pm_score": 2,
"selected": false,
"text": "<p>This works:</p>\n\n<pre><code>$images = get_children( array(\n 'post_parent' => $post->ID,\n 'po... | 2013/01/08 | [
"https://wordpress.stackexchange.com/questions/78752",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25752/"
] | I'm working with Wordpress 3.3.1 on a local installation. I've uploaded an image file and it doesn't show up.
The base directory is a symbolic link `/var/www/wordpress/` that leads to `/usr/share/wordpress/`
The file exists here:
`/srv/www/wp-uploads/localhost/2013/01/Logo.png`
Wordpress thinks the file is here:
`ht... | This works:
```
$images = get_children( array(
'post_parent' => $post->ID,
'post_type' => 'attachment',
'post_mime_type' => 'image',
'orderby' => 'menu_order',
'order' => 'ASC',
'numberposts' => 999
));
if ( $images ) {
$total_images = count( $images );
}
```
The variable $total\_images w... |
78,754 | <p><strong>BACKGROUND:</strong></p>
<p>Running everything up on Linode. Having followed the "Getting Started," "Securing Your Server," "LEMP Server on Ubuntu 12.04," and the "Manage Web Content with WordPress" guides I was able to successfully get my first Wordpress site running. Now I want to know what I should do ... | [
{
"answer_id": 78790,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 0,
"selected": false,
"text": "<p>I really know nothing about Nginx, but here are some maybe useful sources. Not everthing is in English, but Google ... | 2013/01/08 | [
"https://wordpress.stackexchange.com/questions/78754",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25624/"
] | **BACKGROUND:**
Running everything up on Linode. Having followed the "Getting Started," "Securing Your Server," "LEMP Server on Ubuntu 12.04," and the "Manage Web Content with WordPress" guides I was able to successfully get my first Wordpress site running. Now I want to know what I should do (or at least get some exp... | >
> What permissions should I set on each of wp folders? Users will need
> to upload various assets (images, pdfs, office docs, audio, video). I
> found this article here that seems helpful, but would like to get some
> input from folks having done this?
>
>
>
This will be the same as any other web server. What... |
78,765 | <p>At the moment i am working on database conversation script from other cms to Wordpress and faced one problem: I have a list of images, so i need to upload it to Wordpress, after it receive new link, change it with the old one in the post and insert this post. So i wondering if is possiple after <code>wp_insert_post<... | [
{
"answer_id": 78766,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 0,
"selected": false,
"text": "<p>See the <a href=\"http://codex.wordpress.org/Function_Reference/media_handle_upload\" rel=\"nofollow\"><code>media_... | 2013/01/08 | [
"https://wordpress.stackexchange.com/questions/78765",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22622/"
] | At the moment i am working on database conversation script from other cms to Wordpress and faced one problem: I have a list of images, so i need to upload it to Wordpress, after it receive new link, change it with the old one in the post and insert this post. So i wondering if is possiple after `wp_insert_post` somehow... | Wordpress attachments are saved in the `wp_posts` table with the `post_type` field set to `'attachment'`. The post id for the post that the attachment is 'linked' to is in the `post_parent` field. Keep in mind that an attachment being 'linked to a post is not really a solid connection. It is very possible to have an at... |
78,779 | <p>I've created a new custom post type (lets call it "Reviews") on the backend of my Wordpress. It works fine for the most part but the Categories I create within that Custom Post Type are not displaying on the meta box.</p>
<p>For example, in a normal post, it should say "In Category X". In the custom post type, that... | [
{
"answer_id": 81624,
"author": "Bainternet",
"author_id": 2487,
"author_profile": "https://wordpress.stackexchange.com/users/2487",
"pm_score": 3,
"selected": false,
"text": "<p>Simply use <a href=\"http://codex.wordpress.org/Function_Reference/get_the_term_list\"><strong><code>get_the_... | 2013/01/08 | [
"https://wordpress.stackexchange.com/questions/78779",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22961/"
] | I've created a new custom post type (lets call it "Reviews") on the backend of my Wordpress. It works fine for the most part but the Categories I create within that Custom Post Type are not displaying on the meta box.
For example, in a normal post, it should say "In Category X". In the custom post type, that field is ... | Simply use [**`get_the_term_list`**](http://codex.wordpress.org/Function_Reference/get_the_term_list)
ex:
```
echo get_the_term_list( $post->ID, Taxonomy_NAME, '<span class="the-category">', ', ', '</span>' );
```
just change Taxonomy\_NAME to your category taxonomy name, if its the default category taxonomy then c... |
78,787 | <p>The option to change the upload folder for images is gone on version 3.5, any way to make it visible again or a workaround ?</p>
<p>From this <a href="http://core.trac.wordpress.org/ticket/21720" rel="nofollow">core ticket</a>:</p>
<blockquote>
<p>Changing the <code>upload_path</code> and <code>upload_url_path</... | [
{
"answer_id": 78794,
"author": "Joseph Leedy",
"author_id": 8554,
"author_profile": "https://wordpress.stackexchange.com/users/8554",
"pm_score": 2,
"selected": false,
"text": "<p>You can find it at <code>/wp-admin/options.php</code>, which lists all options alphabetically. It'll be nea... | 2013/01/08 | [
"https://wordpress.stackexchange.com/questions/78787",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15704/"
] | The option to change the upload folder for images is gone on version 3.5, any way to make it visible again or a workaround ?
From this [core ticket](http://core.trac.wordpress.org/ticket/21720):
>
> Changing the `upload_path` and `upload_url_path` options are pretty dangerous. They have the potential to break quite ... | In addition to what Joseph suggested, you can also define the upload path in the `wp-config.php` file like this:
```
define( 'UPLOADS', 'wp-content/'.'files' );
```
If you'd like it outside the `wp-content` folder, specify path like this:
```
define( 'UPLOADS', ''.'uploads' );
```
For uploading to a folder like `... |
78,819 | <p>I have created a plugin that will submit a form via ajax. Below is the php function.</p>
<pre><code>add_action('wp_ajax_nopriv_audience_intel', 'audience_intel_ajax');
add_action('wp_ajax_audience_intel', 'audience_intel_ajax');
function audience_intel_ajax() {
$likeit = $_POST['likeit'];
$response = $_POST... | [
{
"answer_id": 78860,
"author": "Morne Zeelie",
"author_id": 12625,
"author_profile": "https://wordpress.stackexchange.com/users/12625",
"pm_score": 0,
"selected": false,
"text": "<p>You will be better off using the $.post for ajax. Have a look here <a href=\"http://codex.wordpress.org/A... | 2013/01/09 | [
"https://wordpress.stackexchange.com/questions/78819",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25778/"
] | I have created a plugin that will submit a form via ajax. Below is the php function.
```
add_action('wp_ajax_nopriv_audience_intel', 'audience_intel_ajax');
add_action('wp_ajax_audience_intel', 'audience_intel_ajax');
function audience_intel_ajax() {
$likeit = $_POST['likeit'];
$response = $_POST['response'];
... | This is the final code I am using. Thanks to webaware for pointing out that I was not using the correct datatype.
```
jQuery(document).ready(function($) {
$('.audience_intel_container .close').click(function(){
$('.audience_intel_container').fadeOut('fast', function(){
});
});
$('.audienc... |
78,820 | <p>I am trying to get author information in my <code>header.php</code>.</p>
<p>This is what I use to display the name and it works like a charm:</p>
<pre><code><?php $author_id=$post->post_author; ?><?php echo the_author_meta( 'display_name' , $author_id ); ?>
</code></pre>
<p>I also wanted to get the... | [
{
"answer_id": 78822,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 0,
"selected": false,
"text": "<p><code>the_author_meta( 'user_url' )</code> will retrieve the website URL as set in the author's profile. You need... | 2013/01/09 | [
"https://wordpress.stackexchange.com/questions/78820",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22975/"
] | I am trying to get author information in my `header.php`.
This is what I use to display the name and it works like a charm:
```
<?php $author_id=$post->post_author; ?><?php echo the_author_meta( 'display_name' , $author_id ); ?>
```
I also wanted to get the author's URL so I changed the code to
```
<?php $author_... | I just put a piece of code from [`author.php`](http://themes.trac.wordpress.org/browser/twentytwelve/1.1.1/author.php#L1) file of `TwentyTwelve` theme:
```
<?php
/* Queue the first post, that way we know
* what author we're dealing with (if that is the case).
*
* We reset this later so we can run th... |
78,826 | <p>I'm trying to feed checkbox values from a Gravity Forms form (which creates a new post) into an Advanced Custom Fields field. I've had a read around and found some info in a post (at the bottom of the question).</p>
<p>Is this the correct way to do it? It's not inserting the multiple GF checkboxes into the ACF text... | [
{
"answer_id": 79941,
"author": "webaware",
"author_id": 24260,
"author_profile": "https://wordpress.stackexchange.com/users/24260",
"pm_score": 2,
"selected": false,
"text": "<p>I had a look at this again this morning, and I reckon your problem and solution are both very simple.</p>\n\n... | 2013/01/09 | [
"https://wordpress.stackexchange.com/questions/78826",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4588/"
] | I'm trying to feed checkbox values from a Gravity Forms form (which creates a new post) into an Advanced Custom Fields field. I've had a read around and found some info in a post (at the bottom of the question).
Is this the correct way to do it? It's not inserting the multiple GF checkboxes into the ACF textbox. Shoul... | My situation to tackle this problem was a bit problematic because I wanted to use the GF Update Post plugin to let my users edit their post right after they submitted the content. With the above solution ACF does not write to the db and correct ACF fields (at least not for me).
My solution:
1. Create a ACF custom fie... |
78,829 | <p>When I wish my filter or action hook to override all others, I will assign it a priority of <code>999</code>. However, lately I have been seeing some people use extreme values for the priority, such as <code>20000</code>, and even <code>99999</code></p>
<p>Besides the fact that using priorities this high is ridicul... | [
{
"answer_id": 78832,
"author": "webaware",
"author_id": 24260,
"author_profile": "https://wordpress.stackexchange.com/users/24260",
"pm_score": 3,
"selected": false,
"text": "<p>It's an integer, so on a 32-bit PHP system it will be limited to -2147483648 to 2147483647, and on 64-bit PHP... | 2013/01/09 | [
"https://wordpress.stackexchange.com/questions/78829",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19726/"
] | When I wish my filter or action hook to override all others, I will assign it a priority of `999`. However, lately I have been seeing some people use extreme values for the priority, such as `20000`, and even `99999`
Besides the fact that using priorities this high is ridiculous, will they actually work? Is there a li... | There are no limits and no performance penalties. To understand why, you need to understand how all hooks are stored in the WP ecosystem.
First of all you need to understand where all hooks are stored and how they do it. All hooks for filters and actions are stored in global variable called `wp_filter`, yes yes actio... |
78,833 | <p>Is there a way to know the total number of posts before the loop starts? I'm thinking in use two loops. The first will do the counting, while the second one will handle the content. However, I don't think this approach is 'elegant'. Any other solutions?</p>
| [
{
"answer_id": 78834,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 4,
"selected": true,
"text": "<p>functions.php:</p>\n\n<pre><code>function wpse8170_get_posts_count() {\n global $wp_query;\n return... | 2013/01/09 | [
"https://wordpress.stackexchange.com/questions/78833",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9060/"
] | Is there a way to know the total number of posts before the loop starts? I'm thinking in use two loops. The first will do the counting, while the second one will handle the content. However, I don't think this approach is 'elegant'. Any other solutions? | functions.php:
```
function wpse8170_get_posts_count() {
global $wp_query;
return $wp_query->post_count;
}
```
index.php:
```
if (have_posts()) :
echo '<h1>' . wpse8170_get_posts_count() . ' Posts Found</h1>';
while ( have_posts() ) :
the_post();
//...
endwhile;
endif;
``` |
78,836 | <p>I created this theme and it worked on my site without any problem. When I moved it to another server, I get <code>wp_register_script was called incorrectly.</code> error.</p>
<p>I scanned my source code and I didn't use any wp_register_script ... however I am suspecting that it is reacting to this ...</p>
<pre><co... | [
{
"answer_id": 78855,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 1,
"selected": false,
"text": "<p>You need to hook your function into either <code>wp_enqueue_scripts</code>, <code>admin_enqueue_scripts</code>, o... | 2013/01/09 | [
"https://wordpress.stackexchange.com/questions/78836",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17199/"
] | I created this theme and it worked on my site without any problem. When I moved it to another server, I get `wp_register_script was called incorrectly.` error.
I scanned my source code and I didn't use any wp\_register\_script ... however I am suspecting that it is reacting to this ...
```
function add_script_code() ... | You need to hook your function into either `wp_enqueue_scripts`, `admin_enqueue_scripts`, or `init`. `wp_footer` is too late to enqueue scripts; they need to be enqueued before the `wp_head()` function is called.
The fifth argument of the [`wp_enqueue_scripts()`](http://codex.wordpress.org/Function_Reference/wp_enqueu... |
78,847 | <p>I am trying to return all posts that meet the following conditions:</p>
<p>The category must be 63</p>
<p>OR</p>
<p>the post must have a value associated with the meta key named 'android_link'</p>
<p>My current argument array currently does not work because it is asking for both of these conditions to be met. Is... | [
{
"answer_id": 78855,
"author": "shea",
"author_id": 19726,
"author_profile": "https://wordpress.stackexchange.com/users/19726",
"pm_score": 1,
"selected": false,
"text": "<p>You need to hook your function into either <code>wp_enqueue_scripts</code>, <code>admin_enqueue_scripts</code>, o... | 2013/01/09 | [
"https://wordpress.stackexchange.com/questions/78847",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25786/"
] | I am trying to return all posts that meet the following conditions:
The category must be 63
OR
the post must have a value associated with the meta key named 'android\_link'
My current argument array currently does not work because it is asking for both of these conditions to be met. Is it possible to change it so t... | You need to hook your function into either `wp_enqueue_scripts`, `admin_enqueue_scripts`, or `init`. `wp_footer` is too late to enqueue scripts; they need to be enqueued before the `wp_head()` function is called.
The fifth argument of the [`wp_enqueue_scripts()`](http://codex.wordpress.org/Function_Reference/wp_enqueu... |
78,874 | <p>I'm trying to upload images in WP 3.5 to set featured images for posts. Unfortunately I get the following error message:</p>
<blockquote>
<p>An error occurred in the upload. Please try again later.</p>
</blockquote>
<p>The installed theme is Minimatica. I've tried Googling the issue, but couldn't find any soluti... | [
{
"answer_id": 78878,
"author": "molokom",
"author_id": 14047,
"author_profile": "https://wordpress.stackexchange.com/users/14047",
"pm_score": 0,
"selected": false,
"text": "<p>I had this problem too.</p>\n\n<p>Try to add this code to your wp-config.php file, just before the require_onc... | 2013/01/09 | [
"https://wordpress.stackexchange.com/questions/78874",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25791/"
] | I'm trying to upload images in WP 3.5 to set featured images for posts. Unfortunately I get the following error message:
>
> An error occurred in the upload. Please try again later.
>
>
>
The installed theme is Minimatica. I've tried Googling the issue, but couldn't find any solution except downgrade to WP 3.4.2. | This was addressed on the Minimatica website:
<http://www.onedesigns.com/support/topic/how-to-fix-issues-with-media-uploader-with-minimatica-in-wordpress-3-5>
You will need to update your functions.php file as follows:
In functions.php find this line (line 225 if you haven’t altered the file):
```
add_action('init'... |
78,881 | <p>In my plugin, I would like to add two buttons to Media Manager (to the left of "Insert Into Post" in "media-toolbar-primary" section), and connect a jQuery action to it.</p>
<ol>
<li>First one - The "Select All" button shoud allow to select all availabe images (only images), depending on option value selected (eg. ... | [
{
"answer_id": 80400,
"author": "Elliott",
"author_id": 6824,
"author_profile": "https://wordpress.stackexchange.com/users/6824",
"pm_score": 2,
"selected": false,
"text": "<p>Thomas Griffin created a plugin example, <a href=\"https://github.com/thomasgriffin/New-Media-Image-Uploader\" r... | 2013/01/09 | [
"https://wordpress.stackexchange.com/questions/78881",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25644/"
] | In my plugin, I would like to add two buttons to Media Manager (to the left of "Insert Into Post" in "media-toolbar-primary" section), and connect a jQuery action to it.
1. First one - The "Select All" button shoud allow to select all availabe images (only images), depending on option value selected (eg. All Media Ite... | This block of code will add a button right next to the "Insert into post" one. When clicked, it will send selected images to WP editor, each wrapped inside your template HTML:
```
var wpMediaFramePost = wp.media.view.MediaFrame.Post;
wp.media.view.MediaFrame.Post = wpMediaFramePost.extend(
{
mainInsertToolbar: fun... |
79,891 | <p>I want to make a link that goes to wp-login.php for whatever domain I'm at now. Something like:</p>
<pre><code><a href="http://<script>document.write(document.domain);</script>/wp-login.php">Login</a>
</code></pre>
<p>But I don't know how to write / format that properly.</p>
| [
{
"answer_id": 80400,
"author": "Elliott",
"author_id": 6824,
"author_profile": "https://wordpress.stackexchange.com/users/6824",
"pm_score": 2,
"selected": false,
"text": "<p>Thomas Griffin created a plugin example, <a href=\"https://github.com/thomasgriffin/New-Media-Image-Uploader\" r... | 2013/01/09 | [
"https://wordpress.stackexchange.com/questions/79891",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24421/"
] | I want to make a link that goes to wp-login.php for whatever domain I'm at now. Something like:
```
<a href="http://<script>document.write(document.domain);</script>/wp-login.php">Login</a>
```
But I don't know how to write / format that properly. | This block of code will add a button right next to the "Insert into post" one. When clicked, it will send selected images to WP editor, each wrapped inside your template HTML:
```
var wpMediaFramePost = wp.media.view.MediaFrame.Post;
wp.media.view.MediaFrame.Post = wpMediaFramePost.extend(
{
mainInsertToolbar: fun... |
79,905 | <p>I am somewhat familiar with the concept of packages in Java, but I'm new to Wordpress and PHP. </p>
<p>In a template file such as <code>header.php</code>, what is happening when you include the <code>@package</code> notation?</p>
<pre><code><?php
/*
* @package MyTheme
*/
</code></pre>
| [
{
"answer_id": 79908,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>Nothing will happen. This <a href=\"http://manual.phpdoc.org/HTMLSmartyConverter/HandS/phpDocumentor/tutorial_tags.pac... | 2013/01/09 | [
"https://wordpress.stackexchange.com/questions/79905",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25803/"
] | I am somewhat familiar with the concept of packages in Java, but I'm new to Wordpress and PHP.
In a template file such as `header.php`, what is happening when you include the `@package` notation?
```
<?php
/*
* @package MyTheme
*/
``` | [Those are PHPDoc tags](http://codex.wordpress.org/Inline_Documentation). They are entirely for code documentation purposes. |
79,914 | <p>I have three custom post type: </p>
<ul>
<li>books</li>
<li>magazine</li>
<li>videos</li>
</ul>
<p>Now i want to limit the number of post for custom post type, for example:</p>
<ul>
<li>books => 3 post</li>
<li>magazine => 2 post</li>
<li>videos => 1 post</li>
</ul>
<p>I used a query post like this:</p>
<pre><c... | [
{
"answer_id": 79960,
"author": "luke",
"author_id": 25713,
"author_profile": "https://wordpress.stackexchange.com/users/25713",
"pm_score": 1,
"selected": false,
"text": "<p>You can do this by merging queries:</p>\n\n<pre><code>$q1 = get_posts(array(\n 'post_type' => 'books',\n ... | 2013/01/09 | [
"https://wordpress.stackexchange.com/questions/79914",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19878/"
] | I have three custom post type:
* books
* magazine
* videos
Now i want to limit the number of post for custom post type, for example:
* books => 3 post
* magazine => 2 post
* videos => 1 post
I used a query post like this:
```
query_posts( array(
'post_type' => array(
'books',
'magazine',
'videos'
... | I hate writing "you can't do that" answers, but you can't. That is the strict answer to your question about whether you can do this with a single `WP_Query`. You can't limit post type counts individually in the same query using [`WP_Query`](http://codex.wordpress.org/Class_Reference/WP_Query) (You are actually using [`... |