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 |
|---|---|---|---|---|---|---|
114,914 | <p>I have a script that pulls the facebook likes via facebook graph and writes them in my DB. However it uses file_get_contents_curl for the request and this is causing problems, so I'd like to use the wp_remote_get() command. I've tried to change it but somehow I can't do it (I don't really have PHP knowledge).</p>
<... | [
{
"answer_id": 114918,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 0,
"selected": false,
"text": "<p>Just change one function with the other. This requires also to change the way you are using <code>json_decode... | 2013/09/20 | [
"https://wordpress.stackexchange.com/questions/114914",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30939/"
] | I have a script that pulls the facebook likes via facebook graph and writes them in my DB. However it uses file\_get\_contents\_curl for the request and this is causing problems, so I'd like to use the wp\_remote\_get() command. I've tried to change it but somehow I can't do it (I don't really have PHP knowledge).
Her... | You can try this:
```
foreach( $posts as $post )
{
$url = sprintf( 'http://graph.facebook.com/?id=%s', get_permalink( $post->ID ) );
$response = wp_remote_get( $url, array( 'timeout' => 15 ) );
if( ! is_wp_error( $response )
&& isset( $response['response']['code'] )
&& 200 =... |
114,925 | <p>I try to load the main stylesheet with enqueue_style - but it isn't working.
Here is my code from functions.php:</p>
<pre><code>function my_scripts() {
wp_enqueue_style( 'main-style', get_template_directory_uri() . '/style.css', false, '1.0', 'all' );
}
add_action( 'wp_enqueue_scripts', 'my_scripts' );
... | [
{
"answer_id": 114927,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 1,
"selected": false,
"text": "<p><code>get_template_directory_uri()</code> has <strong>no</strong> trailing slash.</p>\n\n<p>From <a href=\"ht... | 2013/09/20 | [
"https://wordpress.stackexchange.com/questions/114925",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38326/"
] | I try to load the main stylesheet with enqueue\_style - but it isn't working.
Here is my code from functions.php:
```
function my_scripts() {
wp_enqueue_style( 'main-style', get_template_directory_uri() . '/style.css', false, '1.0', 'all' );
}
add_action( 'wp_enqueue_scripts', 'my_scripts' );
```
Loading... | The solution: I forgot to call wp\_head() in the header.php - added and everything works :-) |
114,941 | <p>I just spend a few hours trying to make my code look better. In the past, I did some changes using Wordpress code editor and after downloading these files yesterday, I noticed that code is totally messed up.</p>
<p>This is how code looks in the editor:
<img src="https://i.stack.imgur.com/9dOty.jpg" alt="enter image... | [
{
"answer_id": 114944,
"author": "Twifty",
"author_id": 36977,
"author_profile": "https://wordpress.stackexchange.com/users/36977",
"pm_score": 2,
"selected": false,
"text": "<p>This isn't as good as line numbers but you can add a dummy class every so often.</p>\n\n<pre><code>#_________s... | 2013/09/20 | [
"https://wordpress.stackexchange.com/questions/114941",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38330/"
] | I just spend a few hours trying to make my code look better. In the past, I did some changes using Wordpress code editor and after downloading these files yesterday, I noticed that code is totally messed up.
This is how code looks in the editor:

And... | This isn't as good as line numbers but you can add a dummy class every so often.
```
#_________section_1 {
display: none; /* Just in-case it strips the empties */
};
```
It may help you to quickly scroll to the relevant section. To be honest though, you should have a mirror of your site stored locally and only c... |
114,943 | <p>How can we add more arguments to an existing query? Suppose I have in my theme</p>
<pre><code>if (!$blog_query) $blog_query = $wp_query;
while( $blog_query->have_posts() ) : $blog_query->the_post();
</code></pre>
<p>AND I want to add two arguments to the existing query before passing, say:</p>
<pre><code>'... | [
{
"answer_id": 114944,
"author": "Twifty",
"author_id": 36977,
"author_profile": "https://wordpress.stackexchange.com/users/36977",
"pm_score": 2,
"selected": false,
"text": "<p>This isn't as good as line numbers but you can add a dummy class every so often.</p>\n\n<pre><code>#_________s... | 2013/09/20 | [
"https://wordpress.stackexchange.com/questions/114943",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38333/"
] | How can we add more arguments to an existing query? Suppose I have in my theme
```
if (!$blog_query) $blog_query = $wp_query;
while( $blog_query->have_posts() ) : $blog_query->the_post();
```
AND I want to add two arguments to the existing query before passing, say:
```
'orderby' => 'post-title',
'order' => 'ASC',... | This isn't as good as line numbers but you can add a dummy class every so often.
```
#_________section_1 {
display: none; /* Just in-case it strips the empties */
};
```
It may help you to quickly scroll to the relevant section. To be honest though, you should have a mirror of your site stored locally and only c... |
114,974 | <p>I'm trying to add a CSS hover effect to my theme's main menu and the effect is based on an attribute passed in a <code><span></code> element. The problem is that I am unable to produce this dynamically with the title of each menu item. Here is the HTML that I would like to produce:</p>
<pre><code><nav>
... | [
{
"answer_id": 114976,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 1,
"selected": true,
"text": "<p>When calling the <code>wp_nav_menu()</code> function you can pass the <code><span></code> tags in the <c... | 2013/09/20 | [
"https://wordpress.stackexchange.com/questions/114974",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38341/"
] | I'm trying to add a CSS hover effect to my theme's main menu and the effect is based on an attribute passed in a `<span>` element. The problem is that I am unable to produce this dynamically with the title of each menu item. Here is the HTML that I would like to produce:
```
<nav>
<a href="#"><span data-hover="Hom... | When calling the `wp_nav_menu()` function you can pass the `<span>` tags in the `link_before` y `link_after` arguments:
```
wp_nav_menu(array('link_before' = > '<span>', 'link_after' => '</span>'));
```
To have differents attributes in the span for each menu item you may need to use a custom nav\_walker. For example... |
114,978 | <p>I'm working with a tag plugin. Is there a WordPress way to get_posts or query all posts that have no tags?</p>
<p><strong>EDIT</strong></p>
<p>I had already queried the WP Codex, search Stackexchange and Google for a related question at the time of the question. </p>
<p>I found several results for helping findi... | [
{
"answer_id": 114983,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 4,
"selected": true,
"text": "<p>A <code>WP_Query</code> where <code>'tax_query'</code> has all tag terms and operator 'NOT IN':</p>\n\n<pre><c... | 2013/09/20 | [
"https://wordpress.stackexchange.com/questions/114978",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17467/"
] | I'm working with a tag plugin. Is there a WordPress way to get\_posts or query all posts that have no tags?
**EDIT**
I had already queried the WP Codex, search Stackexchange and Google for a related question at the time of the question.
I found several results for helping finding tags, but not the `NOT IN` operator... | A `WP_Query` where `'tax_query'` has all tag terms and operator 'NOT IN':
```
$tags = get_terms('post_tag', array('fields'=>'ids') );
$args = array(
'post_type' => 'post',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'post_tag',
'field' => 'id',
'terms' => $tags,
... |
114,984 | <p>I'm using <code>wp_insert_post</code> I loop over a text file one row at a time and for each row, I create a post. The text is set as the `post_title', for the text that is not utf8 the post inserts but with an empty title.</p>
<p>Why does that happen, if I'm able to create a post in the backend admin using non-utf8... | [
{
"answer_id": 114983,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 4,
"selected": true,
"text": "<p>A <code>WP_Query</code> where <code>'tax_query'</code> has all tag terms and operator 'NOT IN':</p>\n\n<pre><c... | 2013/09/20 | [
"https://wordpress.stackexchange.com/questions/114984",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10413/"
] | I'm using `wp_insert_post` I loop over a text file one row at a time and for each row, I create a post. The text is set as the `post\_title', for the text that is not utf8 the post inserts but with an empty title.
Why does that happen, if I'm able to create a post in the backend admin using non-utf8 chars it looks lik... | A `WP_Query` where `'tax_query'` has all tag terms and operator 'NOT IN':
```
$tags = get_terms('post_tag', array('fields'=>'ids') );
$args = array(
'post_type' => 'post',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'post_tag',
'field' => 'id',
'terms' => $tags,
... |
114,999 | <p>I am trying to translate a theme using Poedit, every thing is alright except two strings which give me errors like this:</p>
<pre><code>Error: 'msgstr' is not a valid PHP format string, unlike 'msgid'. Reason: The character that terminates the directive number 1 is not a valid conversation specifier.
</code></pre>
... | [
{
"answer_id": 114983,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 4,
"selected": true,
"text": "<p>A <code>WP_Query</code> where <code>'tax_query'</code> has all tag terms and operator 'NOT IN':</p>\n\n<pre><c... | 2013/09/20 | [
"https://wordpress.stackexchange.com/questions/114999",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37520/"
] | I am trying to translate a theme using Poedit, every thing is alright except two strings which give me errors like this:
```
Error: 'msgstr' is not a valid PHP format string, unlike 'msgid'. Reason: The character that terminates the directive number 1 is not a valid conversation specifier.
```
The string itself is t... | A `WP_Query` where `'tax_query'` has all tag terms and operator 'NOT IN':
```
$tags = get_terms('post_tag', array('fields'=>'ids') );
$args = array(
'post_type' => 'post',
'posts_per_page' => -1,
'tax_query' => array(
array(
'taxonomy' => 'post_tag',
'field' => 'id',
'terms' => $tags,
... |
115,004 | <p>I have a custom post type setup with a couple custom fields. I am creating a page where I display all of the custom post types, except I want to have multiple views. See the examples below. One is a list view, the other is a tiled project view with an image.</p>
<p>At the top there will be buttons to switch between... | [
{
"answer_id": 115030,
"author": "Eric Allen",
"author_id": 5831,
"author_profile": "https://wordpress.stackexchange.com/users/5831",
"pm_score": 0,
"selected": false,
"text": "<p>If you are just trying to avoid a page load, you could approach this from many ways. I've listed a few of th... | 2013/09/20 | [
"https://wordpress.stackexchange.com/questions/115004",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38349/"
] | I have a custom post type setup with a couple custom fields. I am creating a page where I display all of the custom post types, except I want to have multiple views. See the examples below. One is a list view, the other is a tiled project view with an image.
At the top there will be buttons to switch between templates... | My answer is something like an application of one of the **@allenericr** answer points + some cache.
I suggest to implement this only if the 3 templates are different in the *content* and not only in the *aspect*, otherwise a CSS + JS solution should be the best choice.
Create a main page template `'multi-template-p... |
115,019 | <p>I have the following custom post type that I am using on one of my sites:</p>
<pre><code>function careers_post_type() {
$labels = array(
'name' => _x( 'Careers', 'Post Type General Name', 'text_domain' ),
'singular_name' => _x( 'Career', 'Post Type Singular Name', 'te... | [
{
"answer_id": 115063,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 0,
"selected": false,
"text": "<p>You need to add the capabilites to some existing role or add you own user role.</p>\n\n<p>For example:</p>\n\... | 2013/09/20 | [
"https://wordpress.stackexchange.com/questions/115019",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31884/"
] | I have the following custom post type that I am using on one of my sites:
```
function careers_post_type() {
$labels = array(
'name' => _x( 'Careers', 'Post Type General Name', 'text_domain' ),
'singular_name' => _x( 'Career', 'Post Type Singular Name', 'text_domain' ),
... | `'capability_type'` is an argument that must be a valid **post type**.
So, or you use one of default post types (post, page) or once you have defined your own capabilities array you have to use your own post type.
So, using:
```
....
'capability_type' => 'career'
....
```
your code should work.
However, once you ... |
115,020 | <p>I have created a template named <code>product.php</code> with the following header:</p>
<pre><code><?php
/*
Template Name: Product Page
*/
</code></pre>
<p>How can I list, in a sidebar, every page that uses the "Product Page" template?</p>
<p>I have tried reading the <code>wp_list_pages()</code> function docum... | [
{
"answer_id": 115023,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": true,
"text": "<p>You can do this with a <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters\" rel=... | 2013/09/20 | [
"https://wordpress.stackexchange.com/questions/115020",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35834/"
] | I have created a template named `product.php` with the following header:
```
<?php
/*
Template Name: Product Page
*/
```
How can I list, in a sidebar, every page that uses the "Product Page" template?
I have tried reading the `wp_list_pages()` function documentation, but it only seemed possible to list filtering by... | You can do this with a [`WP_Query` `meta_query`](http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters). The page template filename is stored in post meta under the key `_wp_page_template`:
```
$args = array(
'post_type' => 'page',
'posts_per_page' => -1,
'meta_query' => array(
... |
115,029 | <p>I'm a relative newcomer to WP. I've been playing around for the past 3 months or so trying out themes, plugins etc. About a month ago I got to the point where I turned debug on and I started seeing error message and notices in my dashboard. So research suggested that at least some of these my have been the result of... | [
{
"answer_id": 115023,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": true,
"text": "<p>You can do this with a <a href=\"http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters\" rel=... | 2013/09/20 | [
"https://wordpress.stackexchange.com/questions/115029",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38361/"
] | I'm a relative newcomer to WP. I've been playing around for the past 3 months or so trying out themes, plugins etc. About a month ago I got to the point where I turned debug on and I started seeing error message and notices in my dashboard. So research suggested that at least some of these my have been the result of di... | You can do this with a [`WP_Query` `meta_query`](http://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters). The page template filename is stored in post meta under the key `_wp_page_template`:
```
$args = array(
'post_type' => 'page',
'posts_per_page' => -1,
'meta_query' => array(
... |
115,052 | <p>I have Wordpress 3.6 running on ubuntu 12.04 LTS with apache2. Wordpress is running out of the root directory on apache, ie. /var/www</p>
<p>I have an FTP server setup (VSFTPD). I have it set to chroot to the home directory of FTP users.</p>
<p>I have a single FTP user set up, with a folder in the home directory c... | [
{
"answer_id": 116574,
"author": "tanktop",
"author_id": 38946,
"author_profile": "https://wordpress.stackexchange.com/users/38946",
"pm_score": 1,
"selected": false,
"text": "<p>Okay, this may sound crazy, but have you tried absolute directory refs, i.e.\n<code>/var/www/public_html/</co... | 2013/09/21 | [
"https://wordpress.stackexchange.com/questions/115052",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38350/"
] | I have Wordpress 3.6 running on ubuntu 12.04 LTS with apache2. Wordpress is running out of the root directory on apache, ie. /var/www
I have an FTP server setup (VSFTPD). I have it set to chroot to the home directory of FTP users.
I have a single FTP user set up, with a folder in the home directory called public\_htm... | Okay, this may sound crazy, but have you tried absolute directory refs, i.e.
`/var/www/public_html/` for `FTP_BASE`?
It does say in the codex:
>
> FTP\_BASE is the full path to the "base"(ABSPATH) folder of the WordPress installation.
>
>
> |
115,073 | <p>I need to get posts done by specific users and get also comments done to these posts, so far I can get the posts and comments but can't get how to do it in loop properly, because now I get the same comments displayed for each post no matter to which posts they actually belong to...</p>
<p>So here is the code...loop... | [
{
"answer_id": 115076,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 4,
"selected": true,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/get_comments\" rel=\"noreferrer\"><code>get_comments</... | 2013/09/21 | [
"https://wordpress.stackexchange.com/questions/115073",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38065/"
] | I need to get posts done by specific users and get also comments done to these posts, so far I can get the posts and comments but can't get how to do it in loop properly, because now I get the same comments displayed for each post no matter to which posts they actually belong to...
So here is the code...loop inside an... | [`get_comments`](http://codex.wordpress.org/Function_Reference/get_comments) accepts an array of arguments, you are passing an integer.
If you want to retrieve all comments for a post use:
```
get_comments( array('post_id' => $post->ID, 'status' => 'approve') );
```
To get an already formatted comment list, is easi... |
115,085 | <p>I'm developing a site that uses a Artist custom post type and I need to query all posts of this type in a page template. I need to set the <strong>is_post_type_archive</strong> property to true too to filter this query using the <strong>posts_orderby</strong> filter. I'm using the following code, but it seems WordPr... | [
{
"answer_id": 115090,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>WP_Query retrieves posts right when it's created (in constructor). By the time you are modifying property it is alr... | 2013/09/21 | [
"https://wordpress.stackexchange.com/questions/115085",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33049/"
] | I'm developing a site that uses a Artist custom post type and I need to query all posts of this type in a page template. I need to set the **is\_post\_type\_archive** property to true too to filter this query using the **posts\_orderby** filter. I'm using the following code, but it seems WordPress is ignoring the third... | I rewrote the code and now it works
The loop:
```
$args = array('post_type' => 'artist');
$wp_query = new WP_Query( array_merge( $args, array('nopaging' => true) ) );
```
The filter:
```
function theme_posts_orderby( $orderby, $query )
{
if ($query->query_vars['post_type'] == 'artist') {
// order artis... |
115,118 | <p>I'm new to Wordpress and I've tried <code>wp_nav_menu</code> function. If i get it right it is a standard way to show you navigation menu created with help of the Menu Manager.</p>
<p>What is bothering me is the fact that it internally creates a bunch of CSS classes I probably don't need. I have control over the co... | [
{
"answer_id": 115120,
"author": "Zihad",
"author_id": 15907,
"author_profile": "https://wordpress.stackexchange.com/users/15907",
"pm_score": -1,
"selected": false,
"text": "<p>Yes it's possible. <br/>\nYou have to write your own custom nav Walker for that. Here is an one which does exa... | 2013/09/21 | [
"https://wordpress.stackexchange.com/questions/115118",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38402/"
] | I'm new to Wordpress and I've tried `wp_nav_menu` function. If i get it right it is a standard way to show you navigation menu created with help of the Menu Manager.
What is bothering me is the fact that it internally creates a bunch of CSS classes I probably don't need. I have control over the container `div`(delete ... | Using [wp\_nav\_menu()](http://codex.wordpress.org/Function_Reference/wp_nav_menu) and a Walker is a great thing and I really appreciate the other answers with this solution, but I think it's a really hard way to go for a simple menu. So I found myself quite often doing it via [wp\_get\_nav\_menu\_items()](http://codex... |
115,123 | <p>I'm trying to create a gallery type page which shows one post thumbnail from each post category. The trouble is that I want to display the page title and a link to the portfolio page in the middle of a nine square grid. I was thinking the best way to go about it would be to display four thumbnails in three columns f... | [
{
"answer_id": 115126,
"author": "Caroline",
"author_id": 20629,
"author_profile": "https://wordpress.stackexchange.com/users/20629",
"pm_score": 1,
"selected": false,
"text": "<p>Try using a loopcounter based on the post number count - provides for more flexibility</p>\n\n<pre><code><... | 2013/09/21 | [
"https://wordpress.stackexchange.com/questions/115123",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34045/"
] | I'm trying to create a gallery type page which shows one post thumbnail from each post category. The trouble is that I want to display the page title and a link to the portfolio page in the middle of a nine square grid. I was thinking the best way to go about it would be to display four thumbnails in three columns foll... | Try using a loopcounter based on the post number count - provides for more flexibility
```
<?php if (have_posts()) : ?>
<?php $count = 0; ?>
<?php while (have_posts()) : the_post(); ?>
<?php $count++; ?>
// if you are in your first post
<?php if ($count == 1) : ?>
// do whatever... |
115,146 | <p>I'm developing a new WordPress theme and I'm at the point where I'm adding theme customizer options. Most of them have been surprisingly easy to implement, but I'm stumped on a couple of important options:</p>
<ol>
<li>Switching between a light and dark theme</li>
<li>Switching between two web font choices</li>
</o... | [
{
"answer_id": 115161,
"author": "Nick Pfisterer",
"author_id": 38409,
"author_profile": "https://wordpress.stackexchange.com/users/38409",
"pm_score": 3,
"selected": true,
"text": "<p>Got it! Here's the code that worked for me.</p>\n\n<p>-- Theme Customizer settings and controls (mine a... | 2013/09/22 | [
"https://wordpress.stackexchange.com/questions/115146",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38409/"
] | I'm developing a new WordPress theme and I'm at the point where I'm adding theme customizer options. Most of them have been surprisingly easy to implement, but I'm stumped on a couple of important options:
1. Switching between a light and dark theme
2. Switching between two web font choices
I understand how to proper... | Got it! Here's the code that worked for me.
-- Theme Customizer settings and controls (mine are in a separate `customizer.php` file):
```
function themename_customize_register( $wp_customize ) {
...
$wpcustomize->add_setting( 'themename_skin', array(
'default' => 'light',
),
);
$wp_... |
115,152 | <p>I'm joining together few websites into one and I created appropriate posts and changed their post_date (publish date) to the original time of post. However (even if I list more than 1 post) the result, I get, is the last post according to quite recent 'post_modified' (last update of the post).</p>
<p>// EDIT - more... | [
{
"answer_id": 115204,
"author": "crs1138",
"author_id": 20906,
"author_profile": "https://wordpress.stackexchange.com/users/20906",
"pm_score": 4,
"selected": true,
"text": "<p>I've found what the problem was. I have a plugin, <a href=\"http://wordpress.org/plugins/intuitive-custom-post... | 2013/09/22 | [
"https://wordpress.stackexchange.com/questions/115152",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20906/"
] | I'm joining together few websites into one and I created appropriate posts and changed their post\_date (publish date) to the original time of post. However (even if I list more than 1 post) the result, I get, is the last post according to quite recent 'post\_modified' (last update of the post).
// EDIT - more detaile... | I've found what the problem was. I have a plugin, [Custom Post Order](http://wordpress.org/plugins/intuitive-custom-post-order/) running to be able to sort out my CPTs. This plugin was overriding the post order. After switching it off for posts in the CPO's settings everything behaves as it's supposed to. |
115,155 | <p>I'm writing a plugin which would print a notice, but only on the media page. I found the <code>admin_notices</code> and <code>all_admin_notices</code> actions, but these are fired on all admin pages. Is there any way to find which admin page is the hook being called on from within the callback? </p>
| [
{
"answer_id": 115157,
"author": "Sven",
"author_id": 32946,
"author_profile": "https://wordpress.stackexchange.com/users/32946",
"pm_score": 4,
"selected": true,
"text": "<p>There is a global variable called <a href=\"http://codex.wordpress.org/Global_Variables#Admin_Globals\">$pagenow<... | 2013/09/22 | [
"https://wordpress.stackexchange.com/questions/115155",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37714/"
] | I'm writing a plugin which would print a notice, but only on the media page. I found the `admin_notices` and `all_admin_notices` actions, but these are fired on all admin pages. Is there any way to find which admin page is the hook being called on from within the callback? | There is a global variable called [$pagenow](http://codex.wordpress.org/Global_Variables#Admin_Globals) for the use within WP Admin:
```
global $pagenow;
if ( $pagenow == 'upload.php' ) :
function custom_admin_notice() {
echo '<div class="updated"><p>Updated!</p></div>';
}
add_action( 'admin_notic... |
115,183 | <p>If I want to sort on 1) menu_order and if the pages weight the same I want to 2) sort them alphabetically, how? Is this the default behavior if you set menu_order?</p>
<p>Is it?:</p>
<pre><code>$args = array(
'sort_order' => 'ASC',
'sort_column' => 'menu_order, post_title'
);
$children = get_pages($a... | [
{
"answer_id": 115189,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p><code>get_pages</code> explodes <code>sort_column</code> on the comma (<code>,</code>) character. <a href=\"h... | 2013/09/22 | [
"https://wordpress.stackexchange.com/questions/115183",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12226/"
] | If I want to sort on 1) menu\_order and if the pages weight the same I want to 2) sort them alphabetically, how? Is this the default behavior if you set menu\_order?
Is it?:
```
$args = array(
'sort_order' => 'ASC',
'sort_column' => 'menu_order, post_title'
);
$children = get_pages($args);
```
Or?:
```
$ar... | `get_pages` explodes `sort_column` on the comma (`,`) character. [Just check the source:](http://core.trac.wordpress.org/browser/tags/3.6.1/wp-includes/post.php#L3722)
```
foreach ( explode( ',', $sort_column ) as $orderby ) {
```
So the correct format should be the first one you posted:
```
$args = array(
'sor... |
115,190 | <p>I am not a PHP programmer, just a simple WordPress user.</p>
<ul>
<li>How can I allow author role to allow publication of contributors posts?</li>
<li>What's the technical name for this?</li>
</ul>
| [
{
"answer_id": 115199,
"author": "Johannes Pille",
"author_id": 9745,
"author_profile": "https://wordpress.stackexchange.com/users/9745",
"pm_score": 0,
"selected": false,
"text": "<p>Obviously, a role's capabilities can be altered programmatically, but given that you are</p>\n\n<blockqu... | 2013/09/22 | [
"https://wordpress.stackexchange.com/questions/115190",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38431/"
] | I am not a PHP programmer, just a simple WordPress user.
* How can I allow author role to allow publication of contributors posts?
* What's the technical name for this? | I think that the best approach is to add the `edit_other_posts` capability to "author" role in plugin/theme activation and remove that capability on plugin/theme deactivation. With this method you only run the task once and you don't need further coding.
Using plugin activation/deactivation:
```
register_activation_h... |
115,202 | <p>How do I hide/remove the admin bar that is displayed when a user with specific role is logged in? I figured I have to do something with <code>remove_menu()</code>, but not exactly what and how.</p>
<p><a href="http://codex.wordpress.org/Class_Reference/WP_Admin_Bar" rel="noreferrer">Codex</a></p>
| [
{
"answer_id": 115203,
"author": "Christine Cooper",
"author_id": 24875,
"author_profile": "https://wordpress.stackexchange.com/users/24875",
"pm_score": 4,
"selected": true,
"text": "<p>Add the following to your <code>functions.php</code> file as detailed <a href=\"http://www.dfactory.e... | 2013/09/22 | [
"https://wordpress.stackexchange.com/questions/115202",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38405/"
] | How do I hide/remove the admin bar that is displayed when a user with specific role is logged in? I figured I have to do something with `remove_menu()`, but not exactly what and how.
[Codex](http://codex.wordpress.org/Class_Reference/WP_Admin_Bar) | Add the following to your `functions.php` file as detailed [here](http://www.dfactory.eu/wordpress-how-to/remove-disable-admin-bar/).
**Disable Admin Bar for everyone:**
```
// Disable Admin Bar for everyone
if (!function_exists('disable_admin_bar')) {
function disable_admin_bar() {
// for the admin pag... |
115,208 | <p>I am sorry for this nooby question, but I just don't get it :</p>
<p>I was working with the function reference for wp_nav_menu and this is my line of code:</p>
<pre><code><?php wp_nav_menu( array('theme_location' => 'header-menu','items_wrap' => '%3$s') ); ?>
</code></pre>
<p>But the menu is displayed... | [
{
"answer_id": 115212,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 0,
"selected": false,
"text": "<p>This is getting too long for comments. Try debugging with this in place of the code you originally p... | 2013/09/22 | [
"https://wordpress.stackexchange.com/questions/115208",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38435/"
] | I am sorry for this nooby question, but I just don't get it :
I was working with the function reference for wp\_nav\_menu and this is my line of code:
```
<?php wp_nav_menu( array('theme_location' => 'header-menu','items_wrap' => '%3$s') ); ?>
```
But the menu is displayed in `<ul><li>` anyway. (I want to remove th... | The `items_wrap` argument is in fact a `sprintf`-ed argument.
When you look into [Core source](https://github.com/WordPress/WordPress/blob/3.6.1/wp-includes/nav-menu-template.php#L151):
```
'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>'
```
...you see that you have to use the [arguments to let core do its w... |
115,217 | <p>I want to do some Scans and Stats and would like to download every plugin in the WP Plugin Directory.</p>
<p>Is there an easier way to do this, other then clicking the download button 27k times?</p>
<p>What would be my best option for doing this?</p>
| [
{
"answer_id": 115212,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 0,
"selected": false,
"text": "<p>This is getting too long for comments. Try debugging with this in place of the code you originally p... | 2013/09/22 | [
"https://wordpress.stackexchange.com/questions/115217",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26678/"
] | I want to do some Scans and Stats and would like to download every plugin in the WP Plugin Directory.
Is there an easier way to do this, other then clicking the download button 27k times?
What would be my best option for doing this? | The `items_wrap` argument is in fact a `sprintf`-ed argument.
When you look into [Core source](https://github.com/WordPress/WordPress/blob/3.6.1/wp-includes/nav-menu-template.php#L151):
```
'items_wrap' => '<ul id="%1$s" class="%2$s">%3$s</ul>'
```
...you see that you have to use the [arguments to let core do its w... |
115,233 | <p>When I set <code>WP_DEBUG</code> to <code>true</code> in <code>wp-config.php</code>, I get to see all the strict standards and deprecated messages. </p>
<p>I've set the <code>error_reporting</code> in my <code>php.ini</code>, <code>ini_set()</code> and <code>error_reporting()</code> to <code>E_ERROR | E_WARNING | E... | [
{
"answer_id": 115235,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>Just don’t set <code>WP_DEBUG</code> to <code>TRUE</code>. The error level is set in <code>wp_debug_mode()</code>, whi... | 2013/09/22 | [
"https://wordpress.stackexchange.com/questions/115233",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38405/"
] | When I set `WP_DEBUG` to `true` in `wp-config.php`, I get to see all the strict standards and deprecated messages.
I've set the `error_reporting` in my `php.ini`, `ini_set()` and `error_reporting()` to `E_ERROR | E_WARNING | E_PARSE`. But I still get to see the strict standards messages.
I know the messages can be ... | Just don’t set `WP_DEBUG` to `TRUE`. The error level is set in `wp_debug_mode()`, which is called in `wp-settings.php` before any plugins are loaded. If you leave the default values WordPress will set it to:
```
error_reporting(
E_CORE_ERROR |
E_CORE_WARNING |
E_COMPILE_ERROR |
E_ERROR |
E_WAR... |
115,251 | <p>I would like for users to be able to register using a form on the front end of the site to create them an account, after they've confirmed they will have access to a page only they can see, with their details and eventually things they've favourited.</p>
<p>I'm basically looking for a flexible way to allow member r... | [
{
"answer_id": 115255,
"author": "Eugenious",
"author_id": 37096,
"author_profile": "https://wordpress.stackexchange.com/users/37096",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think there's a simple way to do this with Wordpress out of the box. Of course you can do it withou... | 2013/09/23 | [
"https://wordpress.stackexchange.com/questions/115251",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8819/"
] | I would like for users to be able to register using a form on the front end of the site to create them an account, after they've confirmed they will have access to a page only they can see, with their details and eventually things they've favourited.
I'm basically looking for a flexible way to allow member registratio... | I would say plugins are very easy way to handle membership until unless you want it for a small scale like for few pages/posts etc.
In that case you can register the level of users as per your requirements, assign capabilities and then on each page/post you can check `if ( current_user_can() )`
This can be a solution... |
115,279 | <p>I have upgraded my Multisite setup WordPress to 3.6.1. And after that, when I do <code>Network Upgrade > Database Upgrade</code> it's showing:</p>
<blockquote>
<p>Warning! Problem updating <code>http://www.example.com/site1</code>. Your server
may not be able to connect to sites running on it. </p>
<p>E... | [
{
"answer_id": 115282,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 2,
"selected": false,
"text": "<p>That error is probably due the use of cURL in the Wordpress multisite updating proccess. By default cURL will... | 2013/09/23 | [
"https://wordpress.stackexchange.com/questions/115279",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35907/"
] | I have upgraded my Multisite setup WordPress to 3.6.1. And after that, when I do `Network Upgrade > Database Upgrade` it's showing:
>
> Warning! Problem updating `http://www.example.com/site1`. Your server
> may not be able to connect to sites running on it.
>
>
> Error message: Peer certificate cannot be authent... | If possible, you should try and fix the cause of this error - invalid SSL certificates. But there are some instances where this is not possible or desirable. One obvious one being development sites using a self-signed SSL certs.
One way around this is to set $ssl\_verify to false before line 1161 of wp-includes/class-... |
115,281 | <p>I've been using this <code>if</code> conditional statement to only show content if the current page is NOT using a certain page template;</p>
<pre><code>if (! is_page_template('template-custom.php')) {
<!-- show some content -->
}
</code></pre>
<p>which has been working fine. Only now I need to amend th... | [
{
"answer_id": 115283,
"author": "Roy van Wensen",
"author_id": 32917,
"author_profile": "https://wordpress.stackexchange.com/users/32917",
"pm_score": -1,
"selected": false,
"text": "<p>try this:</p>\n\n<pre><code>if (! is_page_template('template-custom.php') || ! is_page_template('temp... | 2013/09/23 | [
"https://wordpress.stackexchange.com/questions/115281",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33310/"
] | I've been using this `if` conditional statement to only show content if the current page is NOT using a certain page template;
```
if (! is_page_template('template-custom.php')) {
<!-- show some content -->
}
```
which has been working fine. Only now I need to amend the statement to show content if the current ... | If you want don't want to show content if the current template is `template-custom.php` or `template-custom2.php` you can use:
```
if (!is_page_template('template-custom.php') && !is_page_template('template-custom2.php')) {
<!-- show some content when you AREN NOT in template-custom.php NOR template-custom2.php --... |
115,289 | <p>I have a multisite WP and I'm now trying to update my WP to latest version. In the WP Administration Panel, there is a Network Update page at:</p>
<ul>
<li>Updates > Available Updates <em>(.../wp-admin/network/update-core.php)</em></li>
</ul>
<p>There i was able to do press the <code>[Update Now]</code> button. Th... | [
{
"answer_id": 115292,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>From quick look at the code upgrade motions are performed by <a href=\"http://core.trac.wordpress.org/browser/branc... | 2013/09/23 | [
"https://wordpress.stackexchange.com/questions/115289",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35907/"
] | I have a multisite WP and I'm now trying to update my WP to latest version. In the WP Administration Panel, there is a Network Update page at:
* Updates > Available Updates *(.../wp-admin/network/update-core.php)*
There i was able to do press the `[Update Now]` button. Then it updated the CODE BASE. So far ok.
Then ... | From quick look at the code upgrade motions are performed by [`wp_upgrade()`](http://core.trac.wordpress.org/browser/branches/3.6/wp-admin/includes/upgrade.php#L293) function. I imagine calling it in some way would get it done, but postponing it until normal upgrade process is fixed is probably more efficient.
In rece... |
115,304 | <p>I have a strange request. Is it possible to load the content of a Wordpress page in a normal PHP page?
For example I want to display the content of the wordpress page 4 in a PHP page that is on the same domain but is not a part of the wordpress installation?</p>
<p>How?</p>
<p>Thank you in advance</p>
| [
{
"answer_id": 115307,
"author": "david.binda",
"author_id": 14022,
"author_profile": "https://wordpress.stackexchange.com/users/14022",
"pm_score": 1,
"selected": false,
"text": "<p>I'd opt for a custom SQL query (if that really contains only post_content).</p>\n\n<pre><code>mysql_conne... | 2013/09/23 | [
"https://wordpress.stackexchange.com/questions/115304",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22715/"
] | I have a strange request. Is it possible to load the content of a Wordpress page in a normal PHP page?
For example I want to display the content of the wordpress page 4 in a PHP page that is on the same domain but is not a part of the wordpress installation?
How?
Thank you in advance | The alternative way. Problem with **@david.binda** solution is that:
1. you have to hardcoding a lot of things, (manually write db credientials, table prefix..)
2. You cannot use content filter (so if you have shortcode in your page, you will see some `[something]` instead of desired content..)
sure you can load word... |
115,312 | <p>I am developing a <code>custom post type</code>, which, among others includes the possibility of sending an email from within the post editor. The email body textarea is populated through a custom settings page and saved into a <code>post_meta array</code> which also includes the email and subject. Until here all fi... | [
{
"answer_id": 115314,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 1,
"selected": false,
"text": "<p>Your problem is a not-escaped regex. However you don't need <code>preg_replace</code>, just a <code>str_repla... | 2013/09/23 | [
"https://wordpress.stackexchange.com/questions/115312",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33518/"
] | I am developing a `custom post type`, which, among others includes the possibility of sending an email from within the post editor. The email body textarea is populated through a custom settings page and saved into a `post_meta array` which also includes the email and subject. Until here all fine.
The standard email c... | The final, working function:
In comparison to my initial function ended up using `str_replace` in stead of `preg_replace` as the resulting code was shorter more concise and faster. Also added two arguments to the `add_action` call removing the need to use `Global $post`; furthermore removed notices in case where `$pos... |
115,322 | <p>I am trying to upload a 762KB picture using the multi-file uploader at /wp-admin/media-new.php. This page reports that my maximum upload filesize is 2GB.</p>
<p>However, once the upload progress bar gets to 100%, the upload fails with </p>
<blockquote>
<p>The uploaded file exceeds the upload_max_filesize directi... | [
{
"answer_id": 115318,
"author": "its_me",
"author_id": 10691,
"author_profile": "https://wordpress.stackexchange.com/users/10691",
"pm_score": 1,
"selected": false,
"text": "<p>Here's what's common between CloudFlare and W3 Total Cache:</p>\n\n<ul>\n<li>Page Caching</li>\n<li>Minificati... | 2013/09/23 | [
"https://wordpress.stackexchange.com/questions/115322",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38478/"
] | I am trying to upload a 762KB picture using the multi-file uploader at /wp-admin/media-new.php. This page reports that my maximum upload filesize is 2GB.
However, once the upload progress bar gets to 100%, the upload fails with
>
> The uploaded file exceeds the upload\_max\_filesize directive in
> php.ini.
>
>
>... | W3TC is a framework. The intent is to optimize the origin (the stack the WordPress application runs on) and THEN what runs "on top" of it. A great discussion around that is available here: <http://websynthesis.com/wsa/wp-content/uploads/2013/09/The-Truth-About-WordPress-Performance.pdf?utm_content=buffere8e5b&utm_sourc... |
115,338 | <p>I am new to wordpress and i want to use a size which can be 300 x 283, i tried the <code>the_post_thumbnail(array('300,283'))</code> but it didn't work, then i went to read about <code>add_image_size</code> which i added like so <code>add_image_size( 'homepage-thumb', 220, 180, true );</code>, gave my post_thumbnail... | [
{
"answer_id": 115340,
"author": "ThatDudeLarry",
"author_id": 38483,
"author_profile": "https://wordpress.stackexchange.com/users/38483",
"pm_score": 0,
"selected": false,
"text": "<p>Check out the <a href=\"http://codex.wordpress.org/Function_Reference/add_image_size#For_Featured_Image... | 2013/09/23 | [
"https://wordpress.stackexchange.com/questions/115338",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33028/"
] | I am new to wordpress and i want to use a size which can be 300 x 283, i tried the `the_post_thumbnail(array('300,283'))` but it didn't work, then i went to read about `add_image_size` which i added like so `add_image_size( 'homepage-thumb', 220, 180, true );`, gave my post\_thumbnail same dimension but nothing happene... | By default Wordpress has three four different image sizes: full, large, medium, thumbnail. If you don't need more than three images size, you can set the with and height of the default image sizes. For example:
```
add_action( 'after_setup_theme', 'theme_setup' );
function theme_setup() {
// Be sure your theme sup... |
115,351 | <p>I am using the following code to create a dropdown on the edit post screen which will allow users to choose page templates for the post type. The code is working but when I try using it multiple times (for each post type) it no longer works. I am trying to have a dropdown for 3 post types, and each post type will ha... | [
{
"answer_id": 115340,
"author": "ThatDudeLarry",
"author_id": 38483,
"author_profile": "https://wordpress.stackexchange.com/users/38483",
"pm_score": 0,
"selected": false,
"text": "<p>Check out the <a href=\"http://codex.wordpress.org/Function_Reference/add_image_size#For_Featured_Image... | 2013/09/23 | [
"https://wordpress.stackexchange.com/questions/115351",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24067/"
] | I am using the following code to create a dropdown on the edit post screen which will allow users to choose page templates for the post type. The code is working but when I try using it multiple times (for each post type) it no longer works. I am trying to have a dropdown for 3 post types, and each post type will have ... | By default Wordpress has three four different image sizes: full, large, medium, thumbnail. If you don't need more than three images size, you can set the with and height of the default image sizes. For example:
```
add_action( 'after_setup_theme', 'theme_setup' );
function theme_setup() {
// Be sure your theme sup... |
115,368 | <p>Is there way to control the gallery default “Link to” setting? Using the <code>image_default_link_type</code> filter within a <code>functions.php</code> file works on inserting single images into posts but it doesn't seem to have any effect on galleries...</p>
| [
{
"answer_id": 115371,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 2,
"selected": true,
"text": "<p>Unfortunately there is no legal way to control it. But there is a dirty way to do it... If you select th... | 2013/09/23 | [
"https://wordpress.stackexchange.com/questions/115368",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37866/"
] | Is there way to control the gallery default “Link to” setting? Using the `image_default_link_type` filter within a `functions.php` file works on inserting single images into posts but it doesn't seem to have any effect on galleries... | Unfortunately there is no legal way to control it. But there is a dirty way to do it... If you select this route, then you will need to :
* clone the standard `gallery_shortcode` function
* add a default value for `$attr['link']` option
* hook your cloned function into `post_gallery` filter
The final result will look... |
115,369 | <p>The reason i ask is because when i create pages they don't insert the usual name of the post type like CPT's do.</p>
<p>For example if i create a page called <code>toyota</code> the URL would be <code>http://domain.com/toyota</code>, but if i created a custom post type to Enter all the makes one page with custom li... | [
{
"answer_id": 115371,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 2,
"selected": true,
"text": "<p>Unfortunately there is no legal way to control it. But there is a dirty way to do it... If you select th... | 2013/09/23 | [
"https://wordpress.stackexchange.com/questions/115369",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35567/"
] | The reason i ask is because when i create pages they don't insert the usual name of the post type like CPT's do.
For example if i create a page called `toyota` the URL would be `http://domain.com/toyota`, but if i created a custom post type to Enter all the makes one page with custom links to specific pages within my ... | Unfortunately there is no legal way to control it. But there is a dirty way to do it... If you select this route, then you will need to :
* clone the standard `gallery_shortcode` function
* add a default value for `$attr['link']` option
* hook your cloned function into `post_gallery` filter
The final result will look... |
115,373 | <p>I've gotten as far as creating custom post types, custom fields and linking those to templates on this first time WordPress project i'm working on, but i seem to have run into a problem i'm not easily able to solve (and i run into these types of problems all the time naturally:).</p>
<p>I have created a few differe... | [
{
"answer_id": 115371,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 2,
"selected": true,
"text": "<p>Unfortunately there is no legal way to control it. But there is a dirty way to do it... If you select th... | 2013/09/23 | [
"https://wordpress.stackexchange.com/questions/115373",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35567/"
] | I've gotten as far as creating custom post types, custom fields and linking those to templates on this first time WordPress project i'm working on, but i seem to have run into a problem i'm not easily able to solve (and i run into these types of problems all the time naturally:).
I have created a few different headers... | Unfortunately there is no legal way to control it. But there is a dirty way to do it... If you select this route, then you will need to :
* clone the standard `gallery_shortcode` function
* add a default value for `$attr['link']` option
* hook your cloned function into `post_gallery` filter
The final result will look... |
115,386 | <p>I've created a couple of custom post types:</p>
<pre><code>add_action( 'init', 'register_post_types' );
function register_post_types() {
register_post_type(
'jobsearch-post',
array(
'labels' => array(
'name' => __( 'Job Searches Post' ),
'singular_name' ... | [
{
"answer_id": 115371,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 2,
"selected": true,
"text": "<p>Unfortunately there is no legal way to control it. But there is a dirty way to do it... If you select th... | 2013/09/23 | [
"https://wordpress.stackexchange.com/questions/115386",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38502/"
] | I've created a couple of custom post types:
```
add_action( 'init', 'register_post_types' );
function register_post_types() {
register_post_type(
'jobsearch-post',
array(
'labels' => array(
'name' => __( 'Job Searches Post' ),
'singular_name' => __( 'Job Search P... | Unfortunately there is no legal way to control it. But there is a dirty way to do it... If you select this route, then you will need to :
* clone the standard `gallery_shortcode` function
* add a default value for `$attr['link']` option
* hook your cloned function into `post_gallery` filter
The final result will look... |
115,390 | <p>I have debug set to true and to display different banners I am using conditional tags such as:</p>
<pre><code><?php
if ( is_page( 'about' ) || '2' == $post->post_parent ) {
// the page is "About", or the parent of the page is "About"
$bannerimg = 'about.jpg';
} elseif ( is_page( 'learning' ) || ... | [
{
"answer_id": 115371,
"author": "Eugene Manuilov",
"author_id": 8170,
"author_profile": "https://wordpress.stackexchange.com/users/8170",
"pm_score": 2,
"selected": true,
"text": "<p>Unfortunately there is no legal way to control it. But there is a dirty way to do it... If you select th... | 2013/09/24 | [
"https://wordpress.stackexchange.com/questions/115390",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18389/"
] | I have debug set to true and to display different banners I am using conditional tags such as:
```
<?php
if ( is_page( 'about' ) || '2' == $post->post_parent ) {
// the page is "About", or the parent of the page is "About"
$bannerimg = 'about.jpg';
} elseif ( is_page( 'learning' ) || '56' == $post->post_... | Unfortunately there is no legal way to control it. But there is a dirty way to do it... If you select this route, then you will need to :
* clone the standard `gallery_shortcode` function
* add a default value for `$attr['link']` option
* hook your cloned function into `post_gallery` filter
The final result will look... |
115,398 | <p>Just have a query reference the <code>add_filter()</code> function.</p>
<p>Can you use this function inside a WordPress widget class.</p>
<p><strong>Example</strong></p>
<p>I have a widget with dynamic created code that I want to pass to another function created within the plugin. Can this be achieved?</p>
<pre>... | [
{
"answer_id": 115422,
"author": "Horttcore",
"author_id": 1379,
"author_profile": "https://wordpress.stackexchange.com/users/1379",
"pm_score": 2,
"selected": false,
"text": "<pre><code><?php\n/**\n * Display the actual Widget\n *\n * @param Array $args\n * @param Array $instance\n *... | 2013/09/24 | [
"https://wordpress.stackexchange.com/questions/115398",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15867/"
] | Just have a query reference the `add_filter()` function.
Can you use this function inside a WordPress widget class.
**Example**
I have a widget with dynamic created code that I want to pass to another function created within the plugin. Can this be achieved?
```
<?php
/**
* Display the actual Widget
*
* @param A... | ```
<?php
/**
* Display the actual Widget
*
* @param Array $args
* @param Array $instance
*/
public function widget($args, $instance){
…
$wcss = apply_filters( 'my-filter-name', $wcss );
…
}
?>
```
To create your own filter hook just use the function "**[apply\_filters](http://codex.wordpress.org/Fun... |
115,401 | <p>So I'm having issues regarding a Dynamic Todo List Metabox.
It should be so simple, everything else is working except for saving. I've been looking at it for 5 hours now, and could do with some fresh eyes.</p>
<pre><code> function webm_todo_box(){
global $post;
?>
<div id="meta_inner">
&... | [
{
"answer_id": 115422,
"author": "Horttcore",
"author_id": 1379,
"author_profile": "https://wordpress.stackexchange.com/users/1379",
"pm_score": 2,
"selected": false,
"text": "<pre><code><?php\n/**\n * Display the actual Widget\n *\n * @param Array $args\n * @param Array $instance\n *... | 2013/09/24 | [
"https://wordpress.stackexchange.com/questions/115401",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38508/"
] | So I'm having issues regarding a Dynamic Todo List Metabox.
It should be so simple, everything else is working except for saving. I've been looking at it for 5 hours now, and could do with some fresh eyes.
```
function webm_todo_box(){
global $post;
?>
<div id="meta_inner">
<?php
//get the sav... | ```
<?php
/**
* Display the actual Widget
*
* @param Array $args
* @param Array $instance
*/
public function widget($args, $instance){
…
$wcss = apply_filters( 'my-filter-name', $wcss );
…
}
?>
```
To create your own filter hook just use the function "**[apply\_filters](http://codex.wordpress.org/Fun... |
115,412 | <p>Wordpress (3.6) is loading two stylesheets (<code>mediaelement-css</code>, .../wp-includes/js/mediaelement/mediaelementplayer.min.css?ver=2.13.0 and <code>wp-mediaelement-css</code>, .../wp-includes/js/mediaelement/wp-mediaelement.css?ver=3.6) in wp_footer instead of wp_head. I'm getting an HTML5 error because they ... | [
{
"answer_id": 115418,
"author": "ferenyl",
"author_id": 11034,
"author_profile": "https://wordpress.stackexchange.com/users/11034",
"pm_score": 1,
"selected": false,
"text": "<p>The two stylesheets is only loaded when a video or sound was included in a post or page and that happens afte... | 2013/09/24 | [
"https://wordpress.stackexchange.com/questions/115412",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18937/"
] | Wordpress (3.6) is loading two stylesheets (`mediaelement-css`, .../wp-includes/js/mediaelement/mediaelementplayer.min.css?ver=2.13.0 and `wp-mediaelement-css`, .../wp-includes/js/mediaelement/wp-mediaelement.css?ver=3.6) in wp\_footer instead of wp\_head. I'm getting an HTML5 error because they did not add the attribu... | The two stylesheets is only loaded when a video or sound was included in a post or page and that happens after wp\_head.
But do not despair! There is a filter you can use! in the code it looks like this:
```
apply_filters( 'style_loader_tag', "<link rel='$rel' id='$handle-css' $title href='$href' type='text/css' medi... |
115,435 | <p>Is it possible to get the cart total price without any markup. So without the € symbol? Right now I'm getting the amount with: </p>
<pre><code>$totalamount = $woocommerce->cart->get_cart_total();
</code></pre>
<p>this will give €16.50</p>
<p>I tried this also:</p>
<pre><code>$totalamount = number_format(... | [
{
"answer_id": 115441,
"author": "Johannes Pille",
"author_id": 9745,
"author_profile": "https://wordpress.stackexchange.com/users/9745",
"pm_score": 4,
"selected": true,
"text": "<h2>Update 2020</h2>\n<p><strong>Answer</strong></p>\n<p>See <a href=\"https://wordpress.stackexchange.com/a... | 2013/09/24 | [
"https://wordpress.stackexchange.com/questions/115435",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37104/"
] | Is it possible to get the cart total price without any markup. So without the € symbol? Right now I'm getting the amount with:
```
$totalamount = $woocommerce->cart->get_cart_total();
```
this will give €16.50
I tried this also:
```
$totalamount = number_format($woocommerce->cart->get_cart_total(), 2, '.', '');... | Update 2020
-----------
**Answer**
See [flytech's answer](https://wordpress.stackexchange.com/a/134173/9745) for a solution using the native WooCommerce API.
**Note / Caveat**
If you're going to do proper arithmetic with monetary values, ***always* use signed integers (!) representing the smallest denomination of a... |
115,478 | <p>I have a custom loop and I'm trying to break it up into several pages but I'm not getting the next and previous links to show. Here is my code:</p>
<pre><code> <?php
if ( get_query_var( 'paged' ) )
// On a paged page.
$paged = ge... | [
{
"answer_id": 115496,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 2,
"selected": false,
"text": "<p>Page link functions depend on the value in the <code>$paged</code> global variable. So, we need to u... | 2013/09/24 | [
"https://wordpress.stackexchange.com/questions/115478",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28560/"
] | I have a custom loop and I'm trying to break it up into several pages but I'm not getting the next and previous links to show. Here is my code:
```
<?php
if ( get_query_var( 'paged' ) )
// On a paged page.
$paged = get_query_var( 'pag... | Page link functions depend on the value in the `$paged` global variable. So, we need to update that variable as well as the parameter in the custom query.
If we are on a "static" front page, the `'paged'` query variable should be undefined and the `'page'` query variable may be defined.
If neither query variable is d... |
115,491 | <p>I'm having some problems getting my JSON data that's being passed via an ajax request.</p>
<p>I'm trying to implement the media uploader into a plugins settings page. I've got it functioning properly using <strong><a href="http://mikejolley.com/2012/12/using-the-new-wordpress-3-5-media-uploader-in-plugins/" rel="no... | [
{
"answer_id": 115496,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 2,
"selected": false,
"text": "<p>Page link functions depend on the value in the <code>$paged</code> global variable. So, we need to u... | 2013/09/24 | [
"https://wordpress.stackexchange.com/questions/115491",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25124/"
] | I'm having some problems getting my JSON data that's being passed via an ajax request.
I'm trying to implement the media uploader into a plugins settings page. I've got it functioning properly using **[this method](http://mikejolley.com/2012/12/using-the-new-wordpress-3-5-media-uploader-in-plugins/)** as far as the me... | Page link functions depend on the value in the `$paged` global variable. So, we need to update that variable as well as the parameter in the custom query.
If we are on a "static" front page, the `'paged'` query variable should be undefined and the `'page'` query variable may be defined.
If neither query variable is d... |
115,498 | <p>I use form to send POST request to a page and to login user with <code>wp_signon()</code> in order to authenticate user to my wordpress installation as described in WP documentation:</p>
<pre><code>$creds = array();
$creds['user_login'] = $_POST["user-login"];
$creds['user_password'] = $_POST["user-password"];
$cre... | [
{
"answer_id": 115518,
"author": "Anjum",
"author_id": 3311,
"author_profile": "https://wordpress.stackexchange.com/users/3311",
"pm_score": 4,
"selected": true,
"text": "<p>finally this is working for me on my local WP installation after replacing - with _ from input attribute name and... | 2013/09/24 | [
"https://wordpress.stackexchange.com/questions/115498",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36504/"
] | I use form to send POST request to a page and to login user with `wp_signon()` in order to authenticate user to my wordpress installation as described in WP documentation:
```
$creds = array();
$creds['user_login'] = $_POST["user-login"];
$creds['user_password'] = $_POST["user-password"];
$creds['remember'] = true;
$... | finally this is working for me on my local WP installation after replacing - with \_ from input attribute name and using full php start tags `<?php` instead of `<?` the final code is here copy and paste into your template.
```
<?php if ( isset($_POST["user_email"]) && isset($_POST["user_password"]) ) {
$user_login ... |
115,500 | <p>So this question has been raised many times under different flags, however I'd like to present a unified thread for an ultimate solution to this issue.</p>
<p>In WordPress, by default, when switching back and forth between the HTML and Visual editors in TinyMCE, certain tags are stripped out of content, and other w... | [
{
"answer_id": 115591,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 2,
"selected": false,
"text": "<p>At first, I think this problem was solved since WP version 3.5; see <a href=\"http://core.trac.wordpress.org/tick... | 2013/09/24 | [
"https://wordpress.stackexchange.com/questions/115500",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37660/"
] | So this question has been raised many times under different flags, however I'd like to present a unified thread for an ultimate solution to this issue.
In WordPress, by default, when switching back and forth between the HTML and Visual editors in TinyMCE, certain tags are stripped out of content, and other weird funct... | Alright so I've already updated this question a ton and it's starting to get overloaded, so I figured I'd write this as an answer even though it isn't a full one.
Extrapolating from @bueltge's answer, I actually went back and found his previous post in question. In that post, there was a plugin listed that I've never ... |
115,510 | <p>I'm in the middle of building a website and one of the pages will be a glossary. The first page of the glossary will display a list of all the words, which are custom post types assigned into a custom taxonomy called "letter" which pulls the first letter of the word. </p>
<p>On top of the glossary, there is a "navi... | [
{
"answer_id": 115521,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>From quick look at source tag cloud doesn't account for current tag and is not easily tweaked to implement that in ... | 2013/09/24 | [
"https://wordpress.stackexchange.com/questions/115510",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38554/"
] | I'm in the middle of building a website and one of the pages will be a glossary. The first page of the glossary will display a list of all the words, which are custom post types assigned into a custom taxonomy called "letter" which pulls the first letter of the word.
On top of the glossary, there is a "navigation" wh... | From quick look at source tag cloud doesn't account for current tag and is not easily tweaked to implement that in code. However it does output class which includes tags ID - `class='tag-link-$tag_id'`.
What you could do is hook into `wp_head`, check if you are in tag archive and output small inline CSS block which st... |
115,526 | <p>I have this in my <code>category.php</code> to show sub-subcategories:</p>
<pre><code><?php if (is_category()) {
$this_category = get_category($cat);
if (get_category_children($this_category->cat_ID) != "") {
echo "<ul>";
wp_list_categories('orderby=id&show_count=0&title_li=
&use... | [
{
"answer_id": 115529,
"author": "tfrommen",
"author_id": 27722,
"author_profile": "https://wordpress.stackexchange.com/users/27722",
"pm_score": 4,
"selected": true,
"text": "<p>Yes, it is possible. <a href=\"http://codex.wordpress.org/Template_Tags/wp_list_categories\" rel=\"noreferrer... | 2013/09/24 | [
"https://wordpress.stackexchange.com/questions/115526",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38560/"
] | I have this in my `category.php` to show sub-subcategories:
```
<?php if (is_category()) {
$this_category = get_category($cat);
if (get_category_children($this_category->cat_ID) != "") {
echo "<ul>";
wp_list_categories('orderby=id&show_count=0&title_li=
&use_desc_for_title=1&child_of='.$this_category->cat_... | Yes, it is possible. [`wp_list_categories`](http://codex.wordpress.org/Template_Tags/wp_list_categories) accepts a (custom) walker that may handle this.
Put the following in your `functions.php` file:
```
class Custom_Walker_Category extends Walker_Category {
function start_el( &$output, $category, $depth = ... |
115,528 | <p>I am wanting to display the title, featured image, excerpt, and read more link for posts from my custom post type in a horizontal manner. Some other things I want to do here is limit the post count to 3.</p>
<p>I've looked for plug ins to do this, but all seem to fall a little short. For example, since i want to di... | [
{
"answer_id": 115551,
"author": "Thought Space Designs",
"author_id": 37660,
"author_profile": "https://wordpress.stackexchange.com/users/37660",
"pm_score": 2,
"selected": false,
"text": "<p>You'll want to first set up a new query and enter the loop. Here's how you would set up a quer... | 2013/09/24 | [
"https://wordpress.stackexchange.com/questions/115528",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37657/"
] | I am wanting to display the title, featured image, excerpt, and read more link for posts from my custom post type in a horizontal manner. Some other things I want to do here is limit the post count to 3.
I've looked for plug ins to do this, but all seem to fall a little short. For example, since i want to display thes... | You'll want to first set up a new query and enter the loop. Here's how you would set up a query to retrieve only posts from your custom post type:
```
$args = array(
"post_type"=>"your-post-type",
"posts_per_page"=>"3"
);
$query = new WP_Query($args);
```
Then, you need to enter the loop in order to retrieve... |
115,533 | <p>One custom post type that i've created has 5 custom fields that display specific content for a template that displays them in different areas on the page.</p>
<p>My question is if i would have to create another loop for each custom field i'm referencing on my template or if one would suffice?</p>
<p>Thanks.</p>
| [
{
"answer_id": 115551,
"author": "Thought Space Designs",
"author_id": 37660,
"author_profile": "https://wordpress.stackexchange.com/users/37660",
"pm_score": 2,
"selected": false,
"text": "<p>You'll want to first set up a new query and enter the loop. Here's how you would set up a quer... | 2013/09/24 | [
"https://wordpress.stackexchange.com/questions/115533",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35567/"
] | One custom post type that i've created has 5 custom fields that display specific content for a template that displays them in different areas on the page.
My question is if i would have to create another loop for each custom field i'm referencing on my template or if one would suffice?
Thanks. | You'll want to first set up a new query and enter the loop. Here's how you would set up a query to retrieve only posts from your custom post type:
```
$args = array(
"post_type"=>"your-post-type",
"posts_per_page"=>"3"
);
$query = new WP_Query($args);
```
Then, you need to enter the loop in order to retrieve... |
115,535 | <p>I have created a custom post type called "Single Neighborhood" in it i have 5 custom fields:</p>
<ol>
<li>Background Color (color picker)</li>
<li>Background Image (image upload)</li>
<li>Latest news (WYSIWYG editor to list external links to news)</li>
<li>Local Events (WYSIWYG to display other RSS feeds)</li>
<li>... | [
{
"answer_id": 115551,
"author": "Thought Space Designs",
"author_id": 37660,
"author_profile": "https://wordpress.stackexchange.com/users/37660",
"pm_score": 2,
"selected": false,
"text": "<p>You'll want to first set up a new query and enter the loop. Here's how you would set up a quer... | 2013/09/24 | [
"https://wordpress.stackexchange.com/questions/115535",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35567/"
] | I have created a custom post type called "Single Neighborhood" in it i have 5 custom fields:
1. Background Color (color picker)
2. Background Image (image upload)
3. Latest news (WYSIWYG editor to list external links to news)
4. Local Events (WYSIWYG to display other RSS feeds)
5. Listings (WYSIWYG to write out a cust... | You'll want to first set up a new query and enter the loop. Here's how you would set up a query to retrieve only posts from your custom post type:
```
$args = array(
"post_type"=>"your-post-type",
"posts_per_page"=>"3"
);
$query = new WP_Query($args);
```
Then, you need to enter the loop in order to retrieve... |
115,539 | <p>I need to change this error message from including the username to the users email address.</p>
<p>I've checked this question and answer out and it helped, but didn't go far enough for me.
<a href="https://wordpress.stackexchange.com/questions/25099/change-login-error-messages">Change login error messages</a></p>
... | [
{
"answer_id": 115564,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 3,
"selected": true,
"text": "<p>There may be an easier way to do this, but you could rewrite the <code>wp_authenticate_username_passw... | 2013/09/24 | [
"https://wordpress.stackexchange.com/questions/115539",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23020/"
] | I need to change this error message from including the username to the users email address.
I've checked this question and answer out and it helped, but didn't go far enough for me.
[Change login error messages](https://wordpress.stackexchange.com/questions/25099/change-login-error-messages)
I took this code from the... | There may be an easier way to do this, but you could rewrite the `wp_authenticate_username_password()` function in the `\wp-includes\class-wp-error.php` file.
Of course you cannot edit the function directly, but since this function is a filter function, you can remove the filter, copy it, add the copied function back ... |
115,565 | <p>How can I echo the value of the order box in posts? See photo.<img src="https://i.stack.imgur.com/VdldU.png" alt="enter image description here"></p>
| [
{
"answer_id": 115564,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 3,
"selected": true,
"text": "<p>There may be an easier way to do this, but you could rewrite the <code>wp_authenticate_username_passw... | 2013/09/25 | [
"https://wordpress.stackexchange.com/questions/115565",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38349/"
] | How can I echo the value of the order box in posts? See photo. | There may be an easier way to do this, but you could rewrite the `wp_authenticate_username_password()` function in the `\wp-includes\class-wp-error.php` file.
Of course you cannot edit the function directly, but since this function is a filter function, you can remove the filter, copy it, add the copied function back ... |
115,584 | <pre><code><div id="tab-side-container">
<ul>
<li><a href="#side-tab1">Tab 1</a></li>
<li><a href="#side-tab2">The Second Tab</a></li>
<li><a href="#side-tab3">Tab C</a></li>
</ul>
<div class="panel-container">
&l... | [
{
"answer_id": 241847,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 1,
"selected": false,
"text": "<p>user2587741 posted an answer to their question inside the question:</p>\n\n<blockquote>\n<pre><code>$tabs_d... | 2013/09/25 | [
"https://wordpress.stackexchange.com/questions/115584",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35383/"
] | ```
<div id="tab-side-container">
<ul>
<li><a href="#side-tab1">Tab 1</a></li>
<li><a href="#side-tab2">The Second Tab</a></li>
<li><a href="#side-tab3">Tab C</a></li>
</ul>
<div class="panel-container">
<div id="side-tab1">
<h2>Configurations</h2>
<p>This example has the animation disabled, so tab-swi... | user2587741 posted an answer to their question inside the question:
>
>
> ```
> $tabs_divs = '';
>
> function tabs_group($atts, $content = null ) {
> global $tabs_divs;
>
> $tabs_divs = '';
>
> $output = '<div id="tab-side-container"><ul';
> $output.='>'.do_shortcode($content).'</ul>';
> $outp... |
115,592 | <p>I have created a custom post type with parameter 'public' set to true. This is because I have to have it accessible in plugins that help you to build queries for post display, such as the Views (part of Toolset) plugin. </p>
<p>On the other hand, when I create a new post or page and use the link builder I don't wan... | [
{
"answer_id": 116027,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<h2>Versions <= 3.6.1</h2>\n\n<p>It looks like the function <code>wp_link_query()</code> is used to display th... | 2013/09/25 | [
"https://wordpress.stackexchange.com/questions/115592",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5844/"
] | I have created a custom post type with parameter 'public' set to true. This is because I have to have it accessible in plugins that help you to build queries for post display, such as the Views (part of Toolset) plugin.
On the other hand, when I create a new post or page and use the link builder I don't want entries ... | Versions <= 3.6.1
-----------------
It looks like the function `wp_link_query()` is used to display the internal posts/pages when you press the *Or link to existing content* in the "link builder":

`wp_link_query()` is defined in `/wp-includes/class-wp-editor.php`.... |
115,598 | <p>I'm getting duplicate entries with this, how can I fix it please?</p>
<pre><code><?php
echo "Month". $_POST["Month"];
global $wpdb;
$wpdb->show_errors();
$wpdb->print_error();
$wpdb->insert(
'church',
array(
'Firstname' => $_POST["Firstname"],
'Surname' => $_POST["S... | [
{
"answer_id": 115601,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 3,
"selected": true,
"text": "<p>There is nothing that prevent duplicates here.</p>\n\n<p>When you create the table <code>'church'</code> is a ... | 2013/09/25 | [
"https://wordpress.stackexchange.com/questions/115598",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38590/"
] | I'm getting duplicate entries with this, how can I fix it please?
```
<?php
echo "Month". $_POST["Month"];
global $wpdb;
$wpdb->show_errors();
$wpdb->print_error();
$wpdb->insert(
'church',
array(
'Firstname' => $_POST["Firstname"],
'Surname' => $_POST["Surname"],
'Month' => $_POST[... | There is nothing that prevent duplicates here.
When you create the table `'church'` is a good idea set a `UNIQUE` sql index for field email, in this way you can rely on email address to preventing duplicate entries.
As a generic PHP good practice, you should check the existence of a a variable before using it, using ... |
115,607 | <p>I've been brought in to help out with development on an existing plugin, and have run into a strange issue. Not sure if I'm overlooking something obvious here.</p>
<p>The situation: I'm adding a shortcode that will basically spit out a list of posts of a particular custom type, complete with title/link/thumbnail. S... | [
{
"answer_id": 177301,
"author": "Ernesto Allely",
"author_id": 67134,
"author_profile": "https://wordpress.stackexchange.com/users/67134",
"pm_score": 1,
"selected": false,
"text": "<p>I had the same problem and I could not make get_the_post_thumbnail() work. However I found a workaroun... | 2013/09/25 | [
"https://wordpress.stackexchange.com/questions/115607",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/108/"
] | I've been brought in to help out with development on an existing plugin, and have run into a strange issue. Not sure if I'm overlooking something obvious here.
The situation: I'm adding a shortcode that will basically spit out a list of posts of a particular custom type, complete with title/link/thumbnail. Standard st... | If nothing works, give this a try:
```
$img_attribs = wp_get_attachment_image_src( get_post_thumbnail_id(), 'thumbnail' ); // returns an array
if( $img_attribs ) {
?>
<img src="<?php echo $img_attribs[0]; ?>" width="<?php echo $img_attribs[1]; ?>" height="<?php echo $img_attribs[2]; ?>">
<?php } ?>
``` |
115,624 | <p>On using inspect element to check the 'href' attribute of 'Deactivate' links for the plugins listed on plugins.php page, I found that the url contains a wpnonce field with a certain value. I need to get this value. For eg,</p>
<pre><code><a href="plugins.php?action=deactivate&amp;plugin=my-custom-css%2Fmy-cu... | [
{
"answer_id": 177301,
"author": "Ernesto Allely",
"author_id": 67134,
"author_profile": "https://wordpress.stackexchange.com/users/67134",
"pm_score": 1,
"selected": false,
"text": "<p>I had the same problem and I could not make get_the_post_thumbnail() work. However I found a workaroun... | 2013/09/25 | [
"https://wordpress.stackexchange.com/questions/115624",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37341/"
] | On using inspect element to check the 'href' attribute of 'Deactivate' links for the plugins listed on plugins.php page, I found that the url contains a wpnonce field with a certain value. I need to get this value. For eg,
```
<a href="plugins.php?action=deactivate&plugin=my-custom-css%2Fmy-custom-css.php&plug... | If nothing works, give this a try:
```
$img_attribs = wp_get_attachment_image_src( get_post_thumbnail_id(), 'thumbnail' ); // returns an array
if( $img_attribs ) {
?>
<img src="<?php echo $img_attribs[0]; ?>" width="<?php echo $img_attribs[1]; ?>" height="<?php echo $img_attribs[2]; ?>">
<?php } ?>
``` |
115,637 | <p>I want to make a separate responsive.css file in my child theme but having trouble making the media queries override the styles in the child theme's default style.css.</p>
<p>I've tried putting <code><link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/responsive.css" type="text/css" ... | [
{
"answer_id": 115649,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>You can <a href=\"http://codex.wordpress.org/Function_Reference/wp_enqueue_style\" rel=\"nofollow\">enqueue your ow... | 2013/09/25 | [
"https://wordpress.stackexchange.com/questions/115637",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38171/"
] | I want to make a separate responsive.css file in my child theme but having trouble making the media queries override the styles in the child theme's default style.css.
I've tried putting `<link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri(); ?>/responsive.css" type="text/css" media="screen"/>` after ... | You can [enqueue your own stylesheet](http://codex.wordpress.org/Function_Reference/wp_enqueue_style) by adding this to your child theme's `functions.php` file:
```
function wpa_custom_css(){
wp_enqueue_style(
'wpa_custom',
get_stylesheet_directory_uri() . '/responsive.css'
);
}
add_action( 'wp... |
115,691 | <p>I have a plugin that is built with many widgets. A widget's bundle. Each widget creates it's own custom CSS code.</p>
<p>Instead of having messy source code where I display 15 different sets of inline CSS code I would like to pass the custom generated CSS code from each widget to a main custom CSS file that I creat... | [
{
"answer_id": 116028,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 2,
"selected": true,
"text": "<p>First of all I can say why your code doesn't work.</p>\n\n<p>The custom css is created inside the <code>widget... | 2013/09/25 | [
"https://wordpress.stackexchange.com/questions/115691",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15867/"
] | I have a plugin that is built with many widgets. A widget's bundle. Each widget creates it's own custom CSS code.
Instead of having messy source code where I display 15 different sets of inline CSS code I would like to pass the custom generated CSS code from each widget to a main custom CSS file that I created through... | First of all I can say why your code doesn't work.
The custom css is created inside the `widget` function that is called by WordPress in the moment that the widget is displayed.
I guess, that you on document ready send an ajax request that call `advanced_widget_pack_css()` function. But every ajax request is a comple... |
115,696 | <p>When adding custom post meta boxes, I understand that whatever <code>name</code> attribute <code>input</code> you put would be passed through the form into the server.</p>
<p>Hence, If I have</p>
<pre><code><input type="text" name="my_custom_field" id="my_custom_field" />
</code></pre>
<p>using </p>
<pre><... | [
{
"answer_id": 115700,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>Saving data from a form is not automatic as you seem to think...</p>\n\n<blockquote>\n <p>When adding custo... | 2013/09/26 | [
"https://wordpress.stackexchange.com/questions/115696",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35704/"
] | When adding custom post meta boxes, I understand that whatever `name` attribute `input` you put would be passed through the form into the server.
Hence, If I have
```
<input type="text" name="my_custom_field" id="my_custom_field" />
```
using
```
get_post_meta($post->ID, 'my_custom_field', true);
```
I am able ... | The HTML attribute `name` is what is sent to the server. There is some PHP code reading it and storing it with a specific key in the database.
The HTML name and the database key don’t have to be the same string. The PHP code can use a completely different name or split one value into multiple database values.
The tem... |
115,739 | <pre><code>define('MY_POST_TYPE', 'myslider');
define('MY_POST_SLUG', 'myslider');
function my_register_post_type () {
$args = array (
'label' => 'Gallery',
'supports' => array( 'title', 'excerpt' ),
'register_meta_box_cb' => 'my_meta_box_cb',
'show_ui' => true,
... | [
{
"answer_id": 115700,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>Saving data from a form is not automatic as you seem to think...</p>\n\n<blockquote>\n <p>When adding custo... | 2013/09/26 | [
"https://wordpress.stackexchange.com/questions/115739",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37997/"
] | ```
define('MY_POST_TYPE', 'myslider');
define('MY_POST_SLUG', 'myslider');
function my_register_post_type () {
$args = array (
'label' => 'Gallery',
'supports' => array( 'title', 'excerpt' ),
'register_meta_box_cb' => 'my_meta_box_cb',
'show_ui' => true,
'orderby' => 'm... | The HTML attribute `name` is what is sent to the server. There is some PHP code reading it and storing it with a specific key in the database.
The HTML name and the database key don’t have to be the same string. The PHP code can use a completely different name or split one value into multiple database values.
The tem... |
115,753 | <p>I created my Custom Post Type (bizdirectory), created a new post (Test Business) and created a new category (Business Directory). But if I add the Business Directory category (slug = business) to my Primary Navigation, the link shows, it registers as the category, but it says "nothing found".</p>
<p>If I search my ... | [
{
"answer_id": 115780,
"author": "Paxjah",
"author_id": 34380,
"author_profile": "https://wordpress.stackexchange.com/users/34380",
"pm_score": 1,
"selected": true,
"text": "<p>I have found the answer, I had completely misunderstood the differences between standard post types and custom ... | 2013/09/26 | [
"https://wordpress.stackexchange.com/questions/115753",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34380/"
] | I created my Custom Post Type (bizdirectory), created a new post (Test Business) and created a new category (Business Directory). But if I add the Business Directory category (slug = business) to my Primary Navigation, the link shows, it registers as the category, but it says "nothing found".
If I search my site (usin... | I have found the answer, I had completely misunderstood the differences between standard post types and custom post types, as well as their taxonomies. I found several very helpful articles and the code below is what I ended up with, as well as a few of the articles that I found helpful. I hope others find this useful.... |
115,771 | <p>I am using <a href="http://www.s5themes.com/documentation/sunrise/" rel="nofollow noreferrer">Sunrise Theme</a> from s5themes.com , and I was wondering if in the individual pages I can have a different Header Image, because from what I can tell they use the same CSS code in displaying the header image on the Home Pa... | [
{
"answer_id": 115780,
"author": "Paxjah",
"author_id": 34380,
"author_profile": "https://wordpress.stackexchange.com/users/34380",
"pm_score": 1,
"selected": true,
"text": "<p>I have found the answer, I had completely misunderstood the differences between standard post types and custom ... | 2013/09/26 | [
"https://wordpress.stackexchange.com/questions/115771",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36610/"
] | I am using [Sunrise Theme](http://www.s5themes.com/documentation/sunrise/) from s5themes.com , and I was wondering if in the individual pages I can have a different Header Image, because from what I can tell they use the same CSS code in displaying the header image on the Home Page.
Here is the screenshot of the Home ... | I have found the answer, I had completely misunderstood the differences between standard post types and custom post types, as well as their taxonomies. I found several very helpful articles and the code below is what I ended up with, as well as a few of the articles that I found helpful. I hope others find this useful.... |
115,772 | <p>My site <a href="http://remotejobs.io" rel="nofollow">http://remotejobs.io</a> currently uses a plugin to power the job board and user supplied resumes. The plugin creates users from it's own interface, so there is not typical user creation method on the site.</p>
<p>However, lately I've had an overwhelming amount ... | [
{
"answer_id": 115787,
"author": "butlerblog",
"author_id": 38603,
"author_profile": "https://wordpress.stackexchange.com/users/38603",
"pm_score": 1,
"selected": false,
"text": "<p>Depending on the flexibility of your plugin, you could add a CAPTCHA to the registration, and/or you could... | 2013/09/26 | [
"https://wordpress.stackexchange.com/questions/115772",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1171/"
] | My site <http://remotejobs.io> currently uses a plugin to power the job board and user supplied resumes. The plugin creates users from it's own interface, so there is not typical user creation method on the site.
However, lately I've had an overwhelming amount of new user creations from spam bots. I know the differenc... | This is similar to Shawn H's answer but is more effective for me.
I already had registrations disabled, but bots still show up constantly to try anyway. My goal was to completely kill all requests to the registration form to avoid the load on my server (and mess in my logs) caused by bots trying to register, so this ... |
115,778 | <p>My site has two custom types: Auction and Lot. Lots are connected to an Auction via the <strong>post_parent</strong> field. I added an Auction column to the Lots list in the admin area.</p>
<pre><code>function theme_lot_custom_columns($columns){
$new = array();
foreach($columns as $key => $value) {
... | [
{
"answer_id": 115787,
"author": "butlerblog",
"author_id": 38603,
"author_profile": "https://wordpress.stackexchange.com/users/38603",
"pm_score": 1,
"selected": false,
"text": "<p>Depending on the flexibility of your plugin, you could add a CAPTCHA to the registration, and/or you could... | 2013/09/26 | [
"https://wordpress.stackexchange.com/questions/115778",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33049/"
] | My site has two custom types: Auction and Lot. Lots are connected to an Auction via the **post\_parent** field. I added an Auction column to the Lots list in the admin area.
```
function theme_lot_custom_columns($columns){
$new = array();
foreach($columns as $key => $value) {
if ($key=='date') {
... | This is similar to Shawn H's answer but is more effective for me.
I already had registrations disabled, but bots still show up constantly to try anyway. My goal was to completely kill all requests to the registration form to avoid the load on my server (and mess in my logs) caused by bots trying to register, so this ... |
115,792 | <p>Does anyone know how I can set an image as featured image for multiple posts.</p>
<p>I have posts in a seri that I would like to use the same image as featured image.</p>
<p>bulk edit doesn't have featured image in there though.</p>
| [
{
"answer_id": 115787,
"author": "butlerblog",
"author_id": 38603,
"author_profile": "https://wordpress.stackexchange.com/users/38603",
"pm_score": 1,
"selected": false,
"text": "<p>Depending on the flexibility of your plugin, you could add a CAPTCHA to the registration, and/or you could... | 2013/09/26 | [
"https://wordpress.stackexchange.com/questions/115792",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36823/"
] | Does anyone know how I can set an image as featured image for multiple posts.
I have posts in a seri that I would like to use the same image as featured image.
bulk edit doesn't have featured image in there though. | This is similar to Shawn H's answer but is more effective for me.
I already had registrations disabled, but bots still show up constantly to try anyway. My goal was to completely kill all requests to the registration form to avoid the load on my server (and mess in my logs) caused by bots trying to register, so this ... |
115,826 | <p>When setting up meta boxes in a custom post type I've been do so using the <code>add_meta_boxes</code> hook, e.g.</p>
<pre><code>add_action('add_meta_boxes', 'meta_box_setup');
function meta_box_setup()
{
add_meta_box(
'mb_movie_review',
'Movie Review Details',
'display_movie_review_m... | [
{
"answer_id": 115906,
"author": "Paul",
"author_id": 17167,
"author_profile": "https://wordpress.stackexchange.com/users/17167",
"pm_score": 3,
"selected": true,
"text": "<p>Have a look at this list: <a href=\"http://codex.wordpress.org/Plugin_API/Action_Reference\" rel=\"nofollow\">htt... | 2013/09/26 | [
"https://wordpress.stackexchange.com/questions/115826",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12116/"
] | When setting up meta boxes in a custom post type I've been do so using the `add_meta_boxes` hook, e.g.
```
add_action('add_meta_boxes', 'meta_box_setup');
function meta_box_setup()
{
add_meta_box(
'mb_movie_review',
'Movie Review Details',
'display_movie_review_mb',
'movie-revie... | Have a look at this list: <http://codex.wordpress.org/Plugin_API/Action_Reference>
1. It doesn't matter which one you use as long as it's not too early and not too late. It's best to use intuitive and predictable hooks, so `add_meta_boxes` is preferred. Someday in the future WordPress may change something and by using... |
115,833 | <p>I have a custom post type called "on-air" that included a custom-field called "daysonair". The form for this has checkboxes for each day of the week.</p>
<p>When you add/update a post, the checked items are stored as an array in the custom-field.</p>
<p>I can't figure out how to add that custom-field to my WP_Que... | [
{
"answer_id": 115837,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 4,
"selected": true,
"text": "<p>Searching inside a serialized array is difficult and inefficient-- ie. slow. The following pure SQL will do i... | 2013/09/26 | [
"https://wordpress.stackexchange.com/questions/115833",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38672/"
] | I have a custom post type called "on-air" that included a custom-field called "daysonair". The form for this has checkboxes for each day of the week.
When you add/update a post, the checked items are stored as an array in the custom-field.
I can't figure out how to add that custom-field to my WP\_Query() search:
```... | Searching inside a serialized array is difficult and inefficient-- ie. slow. The following pure SQL will do it:
```
SELECT *
FROM `wp_postmeta`
WHERE `meta_key` LIKE 'daysonair'
AND `meta_value` LIKE '%thursday%'
LIMIT 0 , 100
```
Something like this should get `WP_Query` to do something similar:
```
$args = array(... |
115,835 | <p>I have a custom post type registered (our-team) and I have a taxonomy (team-categories) with multiple terms. Each term has multiple posts assigned to it. On my custom post type archive (archive-our-team.php) I am using the code below to separate my loop by term, which is working great, but defaults to alphabetical o... | [
{
"answer_id": 115844,
"author": "newpxsn",
"author_id": 18406,
"author_profile": "https://wordpress.stackexchange.com/users/18406",
"pm_score": 2,
"selected": true,
"text": "<p>You can use this <a href=\"http://wordpress.org/plugins/custom-taxonomy-sort/\" rel=\"nofollow\">awesome plugi... | 2013/09/26 | [
"https://wordpress.stackexchange.com/questions/115835",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27786/"
] | I have a custom post type registered (our-team) and I have a taxonomy (team-categories) with multiple terms. Each term has multiple posts assigned to it. On my custom post type archive (archive-our-team.php) I am using the code below to separate my loop by term, which is working great, but defaults to alphabetical orde... | You can use this [awesome plugin](http://wordpress.org/plugins/custom-taxonomy-sort/) to give a sort order for taxonomy. It's old but still work on WordPress 3.6 and probably the latest version too. |
115,852 | <p>I made this action hook which will send an email to the users every time a new post in the custom post type "events" is made.</p>
<pre><code>function email_members($post_id) {
global $wpdb;
$usersarray = $wpdb->get_col("SELECT user_email FROM wp_users");
$users = implode(",", $usersarray);
if( ( $_POST['post_s... | [
{
"answer_id": 115872,
"author": "ThatDudeLarry",
"author_id": 38483,
"author_profile": "https://wordpress.stackexchange.com/users/38483",
"pm_score": 0,
"selected": false,
"text": "<p>Okay, so I just tried it out on a site I'm developing and using something similar to below, I was able ... | 2013/09/27 | [
"https://wordpress.stackexchange.com/questions/115852",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36675/"
] | I made this action hook which will send an email to the users every time a new post in the custom post type "events" is made.
```
function email_members($post_id) {
global $wpdb;
$usersarray = $wpdb->get_col("SELECT user_email FROM wp_users");
$users = implode(",", $usersarray);
if( ( $_POST['post_status'] == 'publi... | `get_post_meta` as seen [here](http://core.trac.wordpress.org/browser/tags/3.6.1/wp-includes/post.php#L1724) is nothing more than a wrapper for `get_metadata`. Now when you say the meta you're getting back, if its not null but rather an empty string, it means you're hitting the end of `get_metadata` as seen [here](http... |
115,855 | <p>I have a custom loop based on these arguments (below), and for some reason when it's run, the SQL returned has this fragment:</p>
<p>... AND wp_posts.ID = -1 ...</p>
<p>And I get no results from the db. If I run the query against the db without this fragment, I get the results I need. Could someone, please, point ... | [
{
"answer_id": 115872,
"author": "ThatDudeLarry",
"author_id": 38483,
"author_profile": "https://wordpress.stackexchange.com/users/38483",
"pm_score": 0,
"selected": false,
"text": "<p>Okay, so I just tried it out on a site I'm developing and using something similar to below, I was able ... | 2013/09/27 | [
"https://wordpress.stackexchange.com/questions/115855",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38448/"
] | I have a custom loop based on these arguments (below), and for some reason when it's run, the SQL returned has this fragment:
... AND wp\_posts.ID = -1 ...
And I get no results from the db. If I run the query against the db without this fragment, I get the results I need. Could someone, please, point out what's wrong... | `get_post_meta` as seen [here](http://core.trac.wordpress.org/browser/tags/3.6.1/wp-includes/post.php#L1724) is nothing more than a wrapper for `get_metadata`. Now when you say the meta you're getting back, if its not null but rather an empty string, it means you're hitting the end of `get_metadata` as seen [here](http... |
115,896 | <p>have run my theme through the Theme checker plugin and it seems upset about use of <code>file_get_contents</code> to get a json url. I've found posts saying i should use <code>wp_remote_get</code>. I'm currently decoding the url with the following: </p>
<pre><code>$url = 'url' . $var;
$json = file_get_contents($u... | [
{
"answer_id": 115902,
"author": "Horttcore",
"author_id": 1379,
"author_profile": "https://wordpress.stackexchange.com/users/1379",
"pm_score": 3,
"selected": false,
"text": "<p>Use <a href=\"http://codex.wordpress.org/Function_Reference/wp_remote_retrieve_body\" rel=\"noreferrer\">wp_r... | 2013/09/27 | [
"https://wordpress.stackexchange.com/questions/115896",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18219/"
] | have run my theme through the Theme checker plugin and it seems upset about use of `file_get_contents` to get a json url. I've found posts saying i should use `wp_remote_get`. I'm currently decoding the url with the following:
```
$url = 'url' . $var;
$json = file_get_contents($url,0,null,null);
$output = json_deco... | If you need to send a JSON response, then there's a set of functions for that. In case you need that for an AJAX callback:
* [`wp_remote_retrieve_response_message()`](http://codex.wordpress.org/Function_Reference/wp_remote_retrieve_response_message)
* [`wp_remote_retrieve_response_code()`](http://codex.wordpress.org/F... |
115,901 | <p>My Widget Option is missing in the Dashboard area. How can i make that appear?
I have downloaded this Blank Theme from Chris Coyiers <a href="http://html5reset.org/#wordpress" rel="nofollow">site</a>. </p>
<p>sidebar.php </p>
<pre><code><?php
/**
* @package WordPress
* @subpackage HTML5-Reset-WordPress-Theme... | [
{
"answer_id": 115964,
"author": "Jeremi Liwanag",
"author_id": 36088,
"author_profile": "https://wordpress.stackexchange.com/users/36088",
"pm_score": 1,
"selected": false,
"text": "<p>I replaced this </p>\n\n<pre><code>// Widgets\nif ( !function_exists('register_sidebar' )) {\nfunction... | 2013/09/27 | [
"https://wordpress.stackexchange.com/questions/115901",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36088/"
] | My Widget Option is missing in the Dashboard area. How can i make that appear?
I have downloaded this Blank Theme from Chris Coyiers [site](http://html5reset.org/#wordpress).
sidebar.php
```
<?php
/**
* @package WordPress
* @subpackage HTML5-Reset-WordPress-Theme
* @since HTML5 Reset 2.0
*/
?>
<div class="sid... | Put this lines of code in function.php
```
if (function_exists("register_sidebar")) {
register_sidebar();
}
```
Put this to sidebar.php
```
<?php if ( !function_exists('dynamic_sidebar') || !dynamic_sidebar() ) : ?>
<?php $image = new WP_query ('showposts=1');
if(have_posts()) : while($image->have_posts()) : $image... |
115,930 | <p>Bit of a newbie here... </p>
<p>As the title states, I am trying to generate a list of 5 random users (taken from authors, editors and administrators) who have published at least 3 posts each. (Also, I would like to exclude the author whose user ID is 4.)</p>
<p>I think I have managed to do all this (hacking toget... | [
{
"answer_id": 115933,
"author": "Dave Navarro",
"author_id": 38672,
"author_profile": "https://wordpress.stackexchange.com/users/38672",
"pm_score": 0,
"selected": false,
"text": "<blockquote>\n <p>I use this feature on many pages throughout my website and am worried it might be too db... | 2013/09/27 | [
"https://wordpress.stackexchange.com/questions/115930",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10331/"
] | Bit of a newbie here...
As the title states, I am trying to generate a list of 5 random users (taken from authors, editors and administrators) who have published at least 3 posts each. (Also, I would like to exclude the author whose user ID is 4.)
I think I have managed to do all this (hacking together various solut... | You could use [`count_many_users_posts()`](http://codex.wordpress.org/Function_Reference/count_many_users_posts).
```
$args = array(
'exclude' => array( 4, ),
'fields' => 'ID',
);
$users = get_users( $args );
$user_posts = count_many_users_posts( $users );
foreach( $user_posts as $user => $posts ) {
if( $p... |
115,943 | <p>I feel like this should be an easily found answer but so far I havent found anything.</p>
<p>So the genesis loop automatically wraps the posts in a div like so:</p>
<pre><code> <div class="post-4006 post type-post status-publish
format-standard hentry category-blog tag-foia tag-nmb entry">...</div>... | [
{
"answer_id": 116375,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 0,
"selected": false,
"text": "<p>That markup is hard coded into the <code>genesis_legacy_loop()</code> Genesis function. There is no ... | 2013/09/27 | [
"https://wordpress.stackexchange.com/questions/115943",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19536/"
] | I feel like this should be an easily found answer but so far I havent found anything.
So the genesis loop automatically wraps the posts in a div like so:
```
<div class="post-4006 post type-post status-publish
format-standard hentry category-blog tag-foia tag-nmb entry">...</div>
```
Well I need to change that... | Today I had a similar issue and this worked for me:
```
/**
* Add and extra class to the entry-content div
*
*/
function vdl_entry_content_extraclass( $attributes ) {
$attributes['class'] = $attributes['class']. ' my-custom-class';
return $attributes;
}
add_filter( 'genesis_attr_entry-content', 'vdl_entry_con... |
115,945 | <p>I am using WordPress search to search a range of custom post types and allow the user to drill-down into each individual post type. </p>
<p>However I'm finding that WordPress is not returning what I'd deem to be the 'best' matches first. For example, if I search for Microsoft, pages that contain the term irregularl... | [
{
"answer_id": 115949,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": true,
"text": "<p><strong>EDIT</strong> - The current version of WordPress supports relevance, so this answer is no longer accurate.<... | 2013/09/27 | [
"https://wordpress.stackexchange.com/questions/115945",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38479/"
] | I am using WordPress search to search a range of custom post types and allow the user to drill-down into each individual post type.
However I'm finding that WordPress is not returning what I'd deem to be the 'best' matches first. For example, if I search for Microsoft, pages that contain the term irregularly are stil... | **EDIT** - The current version of WordPress supports relevance, so this answer is no longer accurate.
---
There's no concept of rank or relevance, it's just a simple LIKE query on the post title and content:
```
($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}')
`... |
115,953 | <p>I am creating a shortcode to display data based on some options.</p>
<pre><code>function dot_irt_top_posts ( $atts, $content = null ) {
// get our variable from $atts
extract(shortcode_atts(array(
'before' => '<li>',
'after' => '</li>',
'number' => '10',
... | [
{
"answer_id": 115949,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": true,
"text": "<p><strong>EDIT</strong> - The current version of WordPress supports relevance, so this answer is no longer accurate.<... | 2013/09/27 | [
"https://wordpress.stackexchange.com/questions/115953",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18389/"
] | I am creating a shortcode to display data based on some options.
```
function dot_irt_top_posts ( $atts, $content = null ) {
// get our variable from $atts
extract(shortcode_atts(array(
'before' => '<li>',
'after' => '</li>',
'number' => '10',
'post_type' => 'post',
'ye... | **EDIT** - The current version of WordPress supports relevance, so this answer is no longer accurate.
---
There's no concept of rank or relevance, it's just a simple LIKE query on the post title and content:
```
($wpdb->posts.post_title LIKE '{$n}{$term}{$n}') OR ($wpdb->posts.post_content LIKE '{$n}{$term}{$n}')
`... |
115,954 | <p>I'm adding a featured image on my page through the dashboard and I want to use it as a background image on the container div of the page.
I want to apply the background image through css, so I am thinking to put a style attribute inside my markup.
I'm thinking to make something like this: </p>
<pre><code><div id... | [
{
"answer_id": 115957,
"author": "Raank",
"author_id": 32355,
"author_profile": "https://wordpress.stackexchange.com/users/32355",
"pm_score": 5,
"selected": true,
"text": "<p>You need to <code>echo</code> the return value from <code>wp_get_attachment_image_src()</code>. It also returns ... | 2013/09/27 | [
"https://wordpress.stackexchange.com/questions/115954",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12572/"
] | I'm adding a featured image on my page through the dashboard and I want to use it as a background image on the container div of the page.
I want to apply the background image through css, so I am thinking to put a style attribute inside my markup.
I'm thinking to make something like this:
```
<div id="<?php echo $pos... | You need to `echo` the return value from `wp_get_attachment_image_src()`. It also returns an `Array()`, so you need to grab the needed part from that array. In this case it's the first/`0` value. Example:
```
<?php $thumb = wp_get_attachment_image_src( get_post_thumbnail_id($post->ID), 'full' );?>
<div id="post" class... |
115,968 | <p>I'm writing a plugin that creates a custom post type named "my_plugin_lesson":</p>
<pre><code>$args = array (
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'lessons', 'with_front' => false)
);
register_post_type ('my_plugin_lesson', $args);
</code></pre>
<p>The cu... | [
{
"answer_id": 115970,
"author": "Eyal",
"author_id": 15686,
"author_profile": "https://wordpress.stackexchange.com/users/15686",
"pm_score": 0,
"selected": false,
"text": "<p>You can use the filter <code>single_template</code>. A basic example taken <a href=\"https://codex.wordpress.org... | 2013/09/27 | [
"https://wordpress.stackexchange.com/questions/115968",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32110/"
] | I'm writing a plugin that creates a custom post type named "my\_plugin\_lesson":
```
$args = array (
'public' => true,
'has_archive' => true,
'rewrite' => array('slug' => 'lessons', 'with_front' => false)
);
register_post_type ('my_plugin_lesson', $args);
```
The custom post type has an archive, and the ... | What you need is hooking `template_include` filter and selectively load your template inside plugin.
As a good practice, if you plan to distribute your plugin, you should check if `archive-my_plugin_lesson.php` (or maybe `myplugin/archive-lesson.php`) exists in theme, if not use the plugin version.
In this way is eas... |
115,980 | <p>It appears that WPEngine does not have support for different locale strings, rendering <code>setlocale()</code> useless. </p>
<p><code>setlocale(LC_ALL, "es_ES");</code> returns <code>false</code> and immediately after that, <code>setlocale(LC_ALL, 0)</code> (as you would expect from the previous <code>false</code>... | [
{
"answer_id": 115970,
"author": "Eyal",
"author_id": 15686,
"author_profile": "https://wordpress.stackexchange.com/users/15686",
"pm_score": 0,
"selected": false,
"text": "<p>You can use the filter <code>single_template</code>. A basic example taken <a href=\"https://codex.wordpress.org... | 2013/09/27 | [
"https://wordpress.stackexchange.com/questions/115980",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37908/"
] | It appears that WPEngine does not have support for different locale strings, rendering `setlocale()` useless.
`setlocale(LC_ALL, "es_ES");` returns `false` and immediately after that, `setlocale(LC_ALL, 0)` (as you would expect from the previous `false`, returns `"en_US"`. | What you need is hooking `template_include` filter and selectively load your template inside plugin.
As a good practice, if you plan to distribute your plugin, you should check if `archive-my_plugin_lesson.php` (or maybe `myplugin/archive-lesson.php`) exists in theme, if not use the plugin version.
In this way is eas... |
116,001 | <p>I am using a plugin that allows users to upload profile graphics in place of avatars. The plugin is "<a href="http://wordpress.org/plugins/user-avatar" rel="nofollow">User Avatar</a>". </p>
<p>I am displaying user profile graphics with this code:</p>
<pre><code> echo get_avatar( get_the_author_meta('user_email... | [
{
"answer_id": 116052,
"author": "Brooke.",
"author_id": 2204,
"author_profile": "https://wordpress.stackexchange.com/users/2204",
"pm_score": 0,
"selected": false,
"text": "<p>A few months ago I wrote a discussion over at this WordPress.org thread regarding this. Check it out: <a href=\... | 2013/09/28 | [
"https://wordpress.stackexchange.com/questions/116001",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35436/"
] | I am using a plugin that allows users to upload profile graphics in place of avatars. The plugin is "[User Avatar](http://wordpress.org/plugins/user-avatar)".
I am displaying user profile graphics with this code:
```
echo get_avatar( get_the_author_meta('user_email'), $size = '60')
```
It works fine except I w... | A few months ago I wrote a discussion over at this WordPress.org thread regarding this. Check it out: <http://wordpress.org/support/topic/custom-avatar-4?replies=5>
Here is the code you'll need in the template you want your avatars:
```
<?php
$uploads = wp_upload_dir(); //WordPress upload path
$uploads_ur... |
116,012 | <p>I have created a shortcode that retrives and displays top recommended posts based on a meta_key. There are different attributes, which all work, except for once where the content of the attribute is HTML.</p>
<p>Complete code is:</p>
<pre><code>function dot_irt_top_posts ( $atts ) {
// get our variable from $atts... | [
{
"answer_id": 116014,
"author": "epilektric",
"author_id": 36634,
"author_profile": "https://wordpress.stackexchange.com/users/36634",
"pm_score": 2,
"selected": false,
"text": "<p>Try using <code>html_entity_decode()</code>.</p>\n\n<pre><code>function foo ( $atts ) {\n\n extract(sho... | 2013/09/28 | [
"https://wordpress.stackexchange.com/questions/116012",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18389/"
] | I have created a shortcode that retrives and displays top recommended posts based on a meta\_key. There are different attributes, which all work, except for once where the content of the attribute is HTML.
Complete code is:
```
function dot_irt_top_posts ( $atts ) {
// get our variable from $atts
extract(shortcode_a... | Pass just the element names and convert them to tags in your shortcode:
```
[irt_top_posts post_type='showcase' container='div' number='10']
```
In your callback:
```
$return "<$container>$return</$container>";
``` |
116,032 | <p>As i understand it, admin scripts are supposed to be registered and enqueued through the <code>admin_enqueue_scripts</code> hook and all other scripts at <code>wp_enqueue_scripts</code> so i have set up the following functions to register and enqueue all my scripts in a clear and organized way.</p>
<p>My question i... | [
{
"answer_id": 116035,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 5,
"selected": true,
"text": "<p>You can <em>register</em> the scripts earlier, for example on <code>wp_loaded</code>:</p>\n\n<pre><code>add_action( 'w... | 2013/09/28 | [
"https://wordpress.stackexchange.com/questions/116032",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33518/"
] | As i understand it, admin scripts are supposed to be registered and enqueued through the `admin_enqueue_scripts` hook and all other scripts at `wp_enqueue_scripts` so i have set up the following functions to register and enqueue all my scripts in a clear and organized way.
My question is, what if i need certain script... | You can *register* the scripts earlier, for example on `wp_loaded`:
```
add_action( 'wp_loaded', 'register_all_scripts' );
function register_all_scripts()
{
wp_register_script(...);
}
```
And then you *enqueue* the scripts whenever you need them:
```
add_action( 'wp_enqueue_scripts', 'enqueue_front_scripts' )... |
116,044 | <h2>What I want to do</h2>
<p>Sharing code in posts on WordPress is quite a pain with all the HTML escaping to take care of. So, I plan to enclose code in posts within a <a href="http://codex.wordpress.org/Shortcode_API" rel="nofollow">custom shortcode</a> called <code>[sourcecode]</code>, as shown below, and let it a... | [
{
"answer_id": 116620,
"author": "brasofilo",
"author_id": 12615,
"author_profile": "https://wordpress.stackexchange.com/users/12615",
"pm_score": 3,
"selected": true,
"text": "<p>You're asking about X, but I'll answer with <a href=\"https://meta.stackexchange.com/questions/66377/what-is... | 2013/09/28 | [
"https://wordpress.stackexchange.com/questions/116044",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10691/"
] | What I want to do
-----------------
Sharing code in posts on WordPress is quite a pain with all the HTML escaping to take care of. So, I plan to enclose code in posts within a [custom shortcode](http://codex.wordpress.org/Shortcode_API) called `[sourcecode]`, as shown below, and let it automatically escape the special... | You're asking about X, but I'll answer with [Y](https://meta.stackexchange.com/questions/66377/what-is-the-xy-problem). IMHO, there are too many exceptions to handle to grant another solution.
SyntaxHighlighter Evolved has the following [Pro Tip](http://plugins.trac.wordpress.org/browser/syntaxhighlighter/tags/3.1.7/s... |
116,081 | <p><strong>NOTE</strong>
I don't want the php code to be executed, only displayed.</p>
<p>I want to display this php code <code><?php wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); ?></code> inside a post. I cannot make it work.</p>
<p>If I go to text type of editor and type <code><pre class="l... | [
{
"answer_id": 116178,
"author": "Marco Berrocal",
"author_id": 28639,
"author_profile": "https://wordpress.stackexchange.com/users/28639",
"pm_score": 1,
"selected": false,
"text": "<p>If I were you, I would do a custom <a href=\"http://codex.wordpress.org/Shortcode_API\" rel=\"nofollow... | 2013/09/29 | [
"https://wordpress.stackexchange.com/questions/116081",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/238/"
] | **NOTE**
I don't want the php code to be executed, only displayed.
I want to display this php code `<?php wp_enqueue_script( $handle, $src, $deps, $ver, $in_footer ); ?>` inside a post. I cannot make it work.
If I go to text type of editor and type `<pre class="lang:php nums:false"> <?php wp_enqueue_script( $handle, ... | That may be a bit problematic. I use the plugin [SyntaxHighlighter Evolved](http://www.viper007bond.com/wordpress-plugins/syntaxhighlighter/), but as the plugin description says (my emphasis):
>
> TIP: **Don't use the Visual editor if you don't want your code mangled**. TinyMCE will "clean up" your HTML.
>
>
>
An... |
116,104 | <p>First of all, I am very new to wordpress and know almost nothing about it.</p>
<p>When I create the page foo using in wp-admin, I get the message that the page is created. When I click on <code>view page</code>, it 404s. I've followed the steps on <a href="http://codex.wordpress.org/Pages#Creating_Pages" rel="nofol... | [
{
"answer_id": 116105,
"author": "fisicx",
"author_id": 29414,
"author_profile": "https://wordpress.stackexchange.com/users/29414",
"pm_score": 0,
"selected": false,
"text": "<p>Wordpress categorizes posts not pages.</p>\n\n<p>In any case you are doing things the wrong way round. If you ... | 2013/09/19 | [
"https://wordpress.stackexchange.com/questions/116104",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38405/"
] | First of all, I am very new to wordpress and know almost nothing about it.
When I create the page foo using in wp-admin, I get the message that the page is created. When I click on `view page`, it 404s. I've followed the steps on <http://codex.wordpress.org/Pages#Creating_Pages>, but apparently I'm missing something.
... | Like Manish, I think the issue is with `AllowOverride`.
The following is based on a Debian server. Ubuntu, if you are not aware, is based on Debian.
In your `apache2/` directory, you should have a `sites-available/` and a `sites-enabled/` directory.
1. Disable your site with `a2dissite`
2. Edit the appropriate fil... |
116,115 | <p>I have built a custom post type called article and the information given on the admin summary screen is sparse. I was able to add the featured image post thumbnail image using the <a href="http://codex.wordpress.org/Plugin_API/Action_Reference/manage_posts_custom_column" rel="noreferrer">http://codex.wordpress.org/P... | [
{
"answer_id": 116286,
"author": "Jonathan Beech",
"author_id": 23507,
"author_profile": "https://wordpress.stackexchange.com/users/23507",
"pm_score": 3,
"selected": false,
"text": "<p>After some searching, I have found a solution using the <code>manage_edit-${post_type}_columns</code> ... | 2013/09/29 | [
"https://wordpress.stackexchange.com/questions/116115",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23507/"
] | I have built a custom post type called article and the information given on the admin summary screen is sparse. I was able to add the featured image post thumbnail image using the <http://codex.wordpress.org/Plugin_API/Action_Reference/manage_posts_custom_column> from a tutorial.
However I would like to be able to ge... | The [register\_taxonomy](https://developer.wordpress.org/reference/functions/register_taxonomy/) function has a parameter called `show_admin_column` that will handle adding a column. Have you tried that?
eg:
```php
register_taxonomy(
'my_tax,
'post_type',
array(
'label' => 'My Taxono... |
116,116 | <p>I needed to display some data in a simple html table so I started with very basics of table. As shown in the code, the data needed was a list of custom-field-values of a meta_key <em>submitdate</em>, from across all the posts, under a specific tag <strong>"female"</strong>. I wrote the following code and everything ... | [
{
"answer_id": 116119,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>Here is what is happening with your code:</p>\n\n<ol>\n<li><code>query_posts</code> uses the <code>global</co... | 2013/09/29 | [
"https://wordpress.stackexchange.com/questions/116116",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25508/"
] | I needed to display some data in a simple html table so I started with very basics of table. As shown in the code, the data needed was a list of custom-field-values of a meta\_key *submitdate*, from across all the posts, under a specific tag **"female"**. I wrote the following code and everything worked perfectly till ... | Here is what is happening with your code:
1. `query_posts` uses the `global` variable `wp_query`. It always
overwrites that variable, which is why you [**should not use
`query_posts`**](https://wordpress.stackexchange.com/questions/1753/when-should-you-use-wp-query-vs-query-posts-vs-get-posts) pretty much ever.
2. You... |
116,167 | <p>I'm dealing with a previous developer that's being difficult. He's removed the Plugin & Settings menus through the database (I'm assuming) as I can't find it anywhere in the functions.php file and can't access any plugin that might be used.</p>
<p>Can someone point me to a link on how this can be done in the da... | [
{
"answer_id": 116168,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 2,
"selected": false,
"text": "<p>I know my way around WordPress' database pretty well and I would never call editing user permissions via Php... | 2013/09/29 | [
"https://wordpress.stackexchange.com/questions/116167",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38790/"
] | I'm dealing with a previous developer that's being difficult. He's removed the Plugin & Settings menus through the database (I'm assuming) as I can't find it anywhere in the functions.php file and can't access any plugin that might be used.
Can someone point me to a link on how this can be done in the database? Is it ... | I know my way around WordPress' database pretty well and I would never call editing user permissions via PhpMyAdmin an easy thing to do. You are editing serialized strings-- very easy to get wrong, actually. So don't feel bad. There is something very wrong with that statement that "he should easily know how to ... edit... |
116,185 | <p>When I enter <code>http://example.com/wordpress/wp-admin</code> it is redirecting to <code>wp-login.php</code> page.</p>
<p>I checked the <code>index.php</code> of the wp-admin folder and checked the file, it is including <code>wp-config.php</code>, <code>wp-settings.php</code>, <code>wp-load.php</code> of the root... | [
{
"answer_id": 116189,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 3,
"selected": true,
"text": "<p>Each call to an admin page loads the <code>\\wp-admin\\admin.php</code> file.</p>\n\n<p>For example, ... | 2013/09/30 | [
"https://wordpress.stackexchange.com/questions/116185",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33649/"
] | When I enter `http://example.com/wordpress/wp-admin` it is redirecting to `wp-login.php` page.
I checked the `index.php` of the wp-admin folder and checked the file, it is including `wp-config.php`, `wp-settings.php`, `wp-load.php` of the root folder and some files in `wp-include` folder but I am unable to figure out ... | Each call to an admin page loads the `\wp-admin\admin.php` file.
For example, from the `\wp-admin\index.php` file:
```
/** Load WordPress Bootstrap */
require_once( dirname( __FILE__ ) . '/admin.php' );
```
In that file `auth_redirect()` is called.
From `\wp-admin\admin.php`:
```
require_once(ABSPATH . 'wp-admin/... |
116,190 | <p>I want to reorder the Company column to be the first column in the table, the code is working fine but it's position is the last one. How can I get it to be in the first before the username?</p>
<pre><code>function add_company_column($defaults) {
$defaults['company'] = __('Company');
return $defaults;
}
fu... | [
{
"answer_id": 116189,
"author": "Charles Clarkson",
"author_id": 31788,
"author_profile": "https://wordpress.stackexchange.com/users/31788",
"pm_score": 3,
"selected": true,
"text": "<p>Each call to an admin page loads the <code>\\wp-admin\\admin.php</code> file.</p>\n\n<p>For example, ... | 2013/09/30 | [
"https://wordpress.stackexchange.com/questions/116190",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11917/"
] | I want to reorder the Company column to be the first column in the table, the code is working fine but it's position is the last one. How can I get it to be in the first before the username?
```
function add_company_column($defaults) {
$defaults['company'] = __('Company');
return $defaults;
}
function view_co... | Each call to an admin page loads the `\wp-admin\admin.php` file.
For example, from the `\wp-admin\index.php` file:
```
/** Load WordPress Bootstrap */
require_once( dirname( __FILE__ ) . '/admin.php' );
```
In that file `auth_redirect()` is called.
From `\wp-admin\admin.php`:
```
require_once(ABSPATH . 'wp-admin/... |
116,198 | <p>What I wanted to achieve is to list some products on a custom page which belongs to two common categories. This part is working fine, except the results per page dropdown. When I change the dropdown values to 24/36/48, after page reload the number of products shown is the same as on the initial pageload.</p>
<p>I h... | [
{
"answer_id": 116206,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 2,
"selected": false,
"text": "<p>Temporarily \"cruel\" PHP workout:</p>\n\n<pre><code>if ( $_POST['woocommerce-sort-by-columns'] ) {\n $wsbc = ... | 2013/09/30 | [
"https://wordpress.stackexchange.com/questions/116198",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | What I wanted to achieve is to list some products on a custom page which belongs to two common categories. This part is working fine, except the results per page dropdown. When I change the dropdown values to 24/36/48, after page reload the number of products shown is the same as on the initial pageload.
I have the fo... | Let's imagine you got a dropdown like the following
```
// The template tag that you place in your ... template
function WPSE116198PerPageSelect()
{
$selected =
<?php
<select name="woo_per_page" id="woo_per_page" size="3">
<?php
foreach ( array( 24, 36, 48 ) as $val )
{
... |
116,221 | <p>I don't know how to force this function to run as the last function after all other save things from WP are executed.</p>
<p>This is my current code in my plugin:</p>
<pre><code>add_action( 'save_post', 'do_custom_save' );
function do_custom_save( $post_id ) {
// No auto saves
if( defined( 'DOING_AUTO... | [
{
"answer_id": 116223,
"author": "Maruti Mohanty",
"author_id": 37890,
"author_profile": "https://wordpress.stackexchange.com/users/37890",
"pm_score": 4,
"selected": true,
"text": "<p><code>add_action</code> has a <strong>priority</strong> parameter which is <strong>10</strong> by defau... | 2013/09/30 | [
"https://wordpress.stackexchange.com/questions/116221",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17368/"
] | I don't know how to force this function to run as the last function after all other save things from WP are executed.
This is my current code in my plugin:
```
add_action( 'save_post', 'do_custom_save' );
function do_custom_save( $post_id ) {
// No auto saves
if( defined( 'DOING_AUTOSAVE' ) && DOING_AUTOS... | `add_action` has a **priority** parameter which is **10** by default, you can increase that to load your function late.
Change `add_action( 'save_post', 'do_custom_save' );`
to
`add_action( 'save_post', 'do_custom_save', 100 );`
Now the priority is to set to 100 and will load quite late and will allow other functi... |
116,235 | <p>First of all I'm using twentyeleven theme, I created a custom template page to insert posts. <strong>It has 4 submit forms. it is working well, also setting feature image is ok for 3 forms except the first one it is not setting feature image for the post even it upload the image (using upload form and also using ima... | [
{
"answer_id": 116238,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 0,
"selected": false,
"text": "<p>One of your function calls is returning a <a href=\"http://codex.wordpress.org/Class_Reference/WP_Error\" re... | 2013/09/30 | [
"https://wordpress.stackexchange.com/questions/116235",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37854/"
] | First of all I'm using twentyeleven theme, I created a custom template page to insert posts. **It has 4 submit forms. it is working well, also setting feature image is ok for 3 forms except the first one it is not setting feature image for the post even it upload the image (using upload form and also using image from l... | Finally I fix the problem
I keep tracking every where in my code and start to comment my code parts step by step.
as I said in my question I have a form that do `upload the image (using upload form and also using image from link)`, and that was the main problem **a conflict between uploading using upload form and us... |
116,241 | <p>This question is related <a href="https://wordpress.stackexchange.com/questions/116090/add-quick-edit-fields-without-custom-colum">to another previously asked question</a>, which is a follow up on an answer.</p>
<h1>Task</h1>
<p>As I want to extend QuickEdit to be something really awesome (and more than just <em>q... | [
{
"answer_id": 116244,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>You can get the ID per JavaScript from the quick edit screen’s parent <code>tr</code>: that has an attribute <code>id=... | 2013/09/30 | [
"https://wordpress.stackexchange.com/questions/116241",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/385/"
] | This question is related [to another previously asked question](https://wordpress.stackexchange.com/questions/116090/add-quick-edit-fields-without-custom-colum), which is a follow up on an answer.
Task
====
As I want to extend QuickEdit to be something really awesome (and more than just *quick edit*), I need the ID o... | You can get the ID per JavaScript from the quick edit screen’s parent `tr`: that has an attribute `id="edit-418"`, where `418` is the post ID.
So extract this number, get the post data per AJAX, and insert the values you need. Not elegant.
Read `wp-admin/js/inline-edit-post.js` to see how the core does it. |
116,251 | <p>Ok, I tried to implement a fancybox lightbox in my custom theme.</p>
<p>I enqueued my scripts in functions.php:</p>
<pre><code>function ikos_add_lightbox() {
wp_enqueue_script( 'fancybox', get_template_directory_uri() . '/inc/lightbox/js/jquery.fancybox.pack.js', array( 'jquery' ), false, true );
wp_enqueue_script... | [
{
"answer_id": 116279,
"author": "P-S",
"author_id": 38771,
"author_profile": "https://wordpress.stackexchange.com/users/38771",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>oh and the images work, but they link to the image itself and that's it.</p>\n</blockquote>\n\n<p... | 2013/09/30 | [
"https://wordpress.stackexchange.com/questions/116251",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34034/"
] | Ok, I tried to implement a fancybox lightbox in my custom theme.
I enqueued my scripts in functions.php:
```
function ikos_add_lightbox() {
wp_enqueue_script( 'fancybox', get_template_directory_uri() . '/inc/lightbox/js/jquery.fancybox.pack.js', array( 'jquery' ), false, true );
wp_enqueue_script( 'lightbox', get_tem... | OMG I just got the easiest answer in this question:
[Page template that uses lightbox to display post images](https://wordpress.stackexchange.com/questions/62364/page-template-that-uses-lightbox-to-display-post-images)
I didn't know thickbox was built in :D |
116,284 | <p>Can someone tell me how to remove site name from the email subject.</p>
<p>As of now my email subject looks like this:</p>
<blockquote>
<p><strong>[sitename] - Subject goes here</strong></p>
</blockquote>
<p>I want it to look like this:</p>
<blockquote>
<p><strong>Subject goes here</strong></p>
</blockquote>... | [
{
"answer_id": 116287,
"author": "PrivateUser",
"author_id": 5074,
"author_profile": "https://wordpress.stackexchange.com/users/5074",
"pm_score": 4,
"selected": true,
"text": "<p>Finally, I wrote some code and it worked very well.</p>\n\n<p>I hope it helps.</p>\n\n<p>Put this in your <c... | 2013/09/30 | [
"https://wordpress.stackexchange.com/questions/116284",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5074/"
] | Can someone tell me how to remove site name from the email subject.
As of now my email subject looks like this:
>
> **[sitename] - Subject goes here**
>
>
>
I want it to look like this:
>
> **Subject goes here**
>
>
>
I checked the `wp_mail()` code. There is a [`wp_mail`](https://codex.wordpress.org/Plugin... | Finally, I wrote some code and it worked very well.
I hope it helps.
Put this in your `functions.php` file
```
//remove sitename from email subject
add_filter('wp_mail', 'email_subject_remove_sitename');
function email_subject_remove_sitename($email) {
$blogname = wp_specialchars_decode(get_option('blogname'), ENT... |