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 |
|---|---|---|---|---|---|---|
166,471 | <p>I want to add a new field to the user registration. I'm using this <a href="http://www.paulund.co.uk/add-custom-user-profile-fields" rel="nofollow">tutorial by Paul Underwood</a>.</p>
<p>The tutorial works but I want to switch the input text to a textarea which I do know how to do. The problem is making sure WordPr... | [
{
"answer_id": 166472,
"author": "Bordoni",
"author_id": 12166,
"author_profile": "https://wordpress.stackexchange.com/users/12166",
"pm_score": 1,
"selected": false,
"text": "<p>There is a couple solution to your problem, some of them will give you more flexibility others will make the ... | 2014/10/26 | [
"https://wordpress.stackexchange.com/questions/166471",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37786/"
] | I want to add a new field to the user registration. I'm using this [tutorial by Paul Underwood](http://www.paulund.co.uk/add-custom-user-profile-fields).
The tutorial works but I want to switch the input text to a textarea which I do know how to do. The problem is making sure WordPress saves this information correctly... | [wp\_kses\_post](https://codex.wordpress.org/Function_Reference/wp_kses_post) if you want to allow certain HTML in your textarea/wp editor (safest, as @Bordoni said).
[esc\_textarea](https://codex.wordpress.org/Function_Reference/esc_textarea) is what you might looking for. |
166,478 | <p>I want to add author name and date on category pages under Title. Here is the <a href="http://www.3danimationindia.com/category/animation-outsourcing/" rel="nofollow">page</a> </p>
<p>But i don't how i can edit it ? where i have to go to find category template file.</p>
<p>By Googling i found it is written in the ... | [
{
"answer_id": 166480,
"author": "Bordoni",
"author_id": 12166,
"author_profile": "https://wordpress.stackexchange.com/users/12166",
"pm_score": 0,
"selected": false,
"text": "<p>So @Sharma,</p>\n\n<p>The file you are looking for is the <code>archive.php</code>, but if you cannot change ... | 2014/10/26 | [
"https://wordpress.stackexchange.com/questions/166478",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56543/"
] | I want to add author name and date on category pages under Title. Here is the [page](http://www.3danimationindia.com/category/animation-outsourcing/)
But i don't how i can edit it ? where i have to go to find category template file.
By Googling i found it is written in the Single.php. but i put changes in it but not... | This is how its done in Twenty Fourteen which uses a template tag:
**Note:** The conditionals `if ( is_sticky() && is_home() && ! is_paged() ) {` will need to be changed or removed
```
if ( ! function_exists( 'twentyfourteen_posted_on' ) ) :
/**
* Print HTML with meta information for the current post-date/time and a... |
166,492 | <p>I'm using the following query to fetch posts in a category (10). I would like to change this code to use the category slug or name instead of the id number as this often changes when I move sites about.??</p>
<pre><code><?php $custom_query = new WP_Query(array ('cat' => 10, 'showposts' => 1));
query_posts(... | [
{
"answer_id": 166493,
"author": "Bordoni",
"author_id": 12166,
"author_profile": "https://wordpress.stackexchange.com/users/12166",
"pm_score": 2,
"selected": false,
"text": "<p>Lets start by removing the <code>query_posts()</code> from your code since you already have it's better broth... | 2014/10/26 | [
"https://wordpress.stackexchange.com/questions/166492",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22537/"
] | I'm using the following query to fetch posts in a category (10). I would like to change this code to use the category slug or name instead of the id number as this often changes when I move sites about.??
```
<?php $custom_query = new WP_Query(array ('cat' => 10, 'showposts' => 1));
query_posts($custom_query);
while($... | Lets start by removing the `query_posts()` from your code since you already have it's better brother `new WP_Query`.
Then what you will need is to use the `category_name` param on your `WP_Query`.
You should always search on the [WP\_Query page](http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters)... |
166,504 | <p>I've tried to update post meta by link in loop. Here is code</p>
<pre><code>function make_sticky($post_id) {
// Update, add, or delete field ----------------------------------
if ( get_post_meta($post_id, 'sticky', FALSE ) ) {
if ( get_post_meta($post_id, 'sticky', '1' ) ) {
update_post_... | [
{
"answer_id": 166493,
"author": "Bordoni",
"author_id": 12166,
"author_profile": "https://wordpress.stackexchange.com/users/12166",
"pm_score": 2,
"selected": false,
"text": "<p>Lets start by removing the <code>query_posts()</code> from your code since you already have it's better broth... | 2014/10/26 | [
"https://wordpress.stackexchange.com/questions/166504",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40659/"
] | I've tried to update post meta by link in loop. Here is code
```
function make_sticky($post_id) {
// Update, add, or delete field ----------------------------------
if ( get_post_meta($post_id, 'sticky', FALSE ) ) {
if ( get_post_meta($post_id, 'sticky', '1' ) ) {
update_post_meta($post_id,... | Lets start by removing the `query_posts()` from your code since you already have it's better brother `new WP_Query`.
Then what you will need is to use the `category_name` param on your `WP_Query`.
You should always search on the [WP\_Query page](http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters)... |
166,522 | <p>I have a custom post type in my plugin named <code>members</code>, along with two custom fields; <code>first_name</code> and <code>last_name</code>. I am trying to order my listing my the last name, then the first name. The only solution I have found is one that utilizes a function to pull in the first two query met... | [
{
"answer_id": 166493,
"author": "Bordoni",
"author_id": 12166,
"author_profile": "https://wordpress.stackexchange.com/users/12166",
"pm_score": 2,
"selected": false,
"text": "<p>Lets start by removing the <code>query_posts()</code> from your code since you already have it's better broth... | 2014/10/26 | [
"https://wordpress.stackexchange.com/questions/166522",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62609/"
] | I have a custom post type in my plugin named `members`, along with two custom fields; `first_name` and `last_name`. I am trying to order my listing my the last name, then the first name. The only solution I have found is one that utilizes a function to pull in the first two query meta fields and replaces them (I follow... | Lets start by removing the `query_posts()` from your code since you already have it's better brother `new WP_Query`.
Then what you will need is to use the `category_name` param on your `WP_Query`.
You should always search on the [WP\_Query page](http://codex.wordpress.org/Class_Reference/WP_Query#Category_Parameters)... |
166,533 | <p>I'm trying to embed a YouTube video in a Text Widget and Wordpress 4.0 is stripping out the embed when rendering. For example, if I put this in the body of the widget:</p>
<pre><code>Before
[embed]http://youtu.be/JQ_2De2cnzI&rel=0&showinfo=0&w=120[/embed]
After
</code></pre>
<p>then when I inspect the... | [
{
"answer_id": 166536,
"author": "Gabriel",
"author_id": 54569,
"author_profile": "https://wordpress.stackexchange.com/users/54569",
"pm_score": 3,
"selected": true,
"text": "<p>Shortcodes are not supported in the Text Widget by default. Add the following to your functions.php:</p>\n\n<p... | 2014/10/26 | [
"https://wordpress.stackexchange.com/questions/166533",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48996/"
] | I'm trying to embed a YouTube video in a Text Widget and Wordpress 4.0 is stripping out the embed when rendering. For example, if I put this in the body of the widget:
```
Before
[embed]http://youtu.be/JQ_2De2cnzI&rel=0&showinfo=0&w=120[/embed]
After
```
then when I inspect the div in the browser I end up with this:... | Shortcodes are not supported in the Text Widget by default. Add the following to your functions.php:
```
// Enable shortcodes in WP Text Widget
add_filter( 'widget_text', 'shortcode_unautop');
add_filter( 'widget_text', 'do_shortcode', 11);
```
Instead of wrapping the video URL in the [embed] shortcode, use the foll... |
166,541 | <p>I have a custom post type called "patients". I was using only the post title, but now I need to make a relationship with users.</p>
<p>I made this by creating a custom post field (created by ACF), a relational field showing a type of user. It works nice for the admin, but I also need to insert some posts dynamicall... | [
{
"answer_id": 166551,
"author": "Manny Fleurmond",
"author_id": 2234,
"author_profile": "https://wordpress.stackexchange.com/users/2234",
"pm_score": 0,
"selected": false,
"text": "<p>As suggested in the comments by @Nilambar, <code>wp_insert_post</code> returns the <code>ID</code> of t... | 2014/10/27 | [
"https://wordpress.stackexchange.com/questions/166541",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9832/"
] | I have a custom post type called "patients". I was using only the post title, but now I need to make a relationship with users.
I made this by creating a custom post field (created by ACF), a relational field showing a type of user. It works nice for the admin, but I also need to insert some posts dynamically. How can... | I'm not sur but I think you had (will probalby help other people as the guy who I was 1hour ago)/have same problem that I just resolve.
You have a custom field and you want to manage an User type field in it ?!
Well, everyone know UPDATE\_FIELD, but what I didn't know that if you want to add a user, u just have to ... |
166,547 | <p>Can I create a login page, which could be entered all registered visitors, but were not allowed entrance to the administrator, even if he has entered the correct username and password? For admin I want to have a different login page with a secret address.
I have a shop at the base of the plugin Woocommerce. Its logi... | [
{
"answer_id": 166551,
"author": "Manny Fleurmond",
"author_id": 2234,
"author_profile": "https://wordpress.stackexchange.com/users/2234",
"pm_score": 0,
"selected": false,
"text": "<p>As suggested in the comments by @Nilambar, <code>wp_insert_post</code> returns the <code>ID</code> of t... | 2014/10/27 | [
"https://wordpress.stackexchange.com/questions/166547",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62604/"
] | Can I create a login page, which could be entered all registered visitors, but were not allowed entrance to the administrator, even if he has entered the correct username and password? For admin I want to have a different login page with a secret address.
I have a shop at the base of the plugin Woocommerce. Its login p... | I'm not sur but I think you had (will probalby help other people as the guy who I was 1hour ago)/have same problem that I just resolve.
You have a custom field and you want to manage an User type field in it ?!
Well, everyone know UPDATE\_FIELD, but what I didn't know that if you want to add a user, u just have to ... |
166,586 | <p><a href="https://make.wordpress.org/core/handbook/coding-standards/php/#naming-conventions">WP Core Handbook > PHP Coding Standards > Naming Conventions</a> suggests the following for naming files with classes:</p>
<blockquote>
<p>Class file names should be based on the class name with <code>class-</code>
prepe... | [
{
"answer_id": 166589,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": false,
"text": "<p>First, ignore the <code>class-</code> prefix. This comes from WordPress’ pure procedural code approach, classes are u... | 2014/10/27 | [
"https://wordpress.stackexchange.com/questions/166586",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/847/"
] | [WP Core Handbook > PHP Coding Standards > Naming Conventions](https://make.wordpress.org/core/handbook/coding-standards/php/#naming-conventions) suggests the following for naming files with classes:
>
> Class file names should be based on the class name with `class-`
> prepended and the underscores in the class nam... | First, ignore the `class-` prefix. This comes from WordPress’ pure procedural code approach, classes are used as containers for procedural code, not for real objects, and most files do not contain classes at all or classes and other code together. It doesn’t make sense when all of your files contain just one class and ... |
166,628 | <p>I am trying to add pagination to the archiveof my custom post type. Right now it is structured by year & month and I want to add pagination and I fail miserably.</p>
<p>So its like this:</p>
<pre><code><!-- Request: cpt/2014/pagina/2 -->
<!-- Matched Rewrite Rule: cpt/([0-9]{4})/pagina/?([0-9]{1,})/?$... | [
{
"answer_id": 166981,
"author": "mrwweb",
"author_id": 9844,
"author_profile": "https://wordpress.stackexchange.com/users/9844",
"pm_score": 1,
"selected": false,
"text": "<p>Take a look at the <a href=\"http://codex.wordpress.org/Template_Hierarchy\" rel=\"nofollow noreferrer\">\"Templ... | 2014/10/27 | [
"https://wordpress.stackexchange.com/questions/166628",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58040/"
] | I am trying to add pagination to the archiveof my custom post type. Right now it is structured by year & month and I want to add pagination and I fail miserably.
So its like this:
```
<!-- Request: cpt/2014/pagina/2 -->
<!-- Matched Rewrite Rule: cpt/([0-9]{4})/pagina/?([0-9]{1,})/?$ -->
<!-- Matched Rewrite Query: p... | Because WordPress redirected to `index.php` when it should have loaded `archive.php` or `archive-cpt.php` I made a workaround like so:
```
add_rewrite_rule(
$cpt_name . '/page/?([0-9]{1,})?$',
'index.php?post_type=' . $cpt_slug . '&qpaged=$matches[1]',
'top'
);
```
`qpaged` instead of `paged`. |
166,630 | <p>I need some help with the code to put inside the <code><title></code> to generate the following:</p>
<ul>
<li><strong>Static front page:</strong> Should just be the <code>bloginfo('name')</code></li>
<li><strong>All other pages:</strong> Should be <code>wp_title()</code> | <code>bloginfo('name')</code></li>
<... | [
{
"answer_id": 166632,
"author": "DanBeckett",
"author_id": 62651,
"author_profile": "https://wordpress.stackexchange.com/users/62651",
"pm_score": 1,
"selected": false,
"text": "<p>The conditional tag <code>is_front_page()</code> is used to specifically check for a static front page, so... | 2014/10/27 | [
"https://wordpress.stackexchange.com/questions/166630",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54162/"
] | I need some help with the code to put inside the `<title>` to generate the following:
* **Static front page:** Should just be the `bloginfo('name')`
* **All other pages:** Should be `wp_title()` | `bloginfo('name')`
**EDIT**
I have tried the following but it doesn't work:
```
<title><?php if(is_front_page() ) { blog... | The conditional tag `is_front_page()` is used to specifically check for a static front page, so you should be able to use that to switch between your title formats
```
<title>
<?php if(is_front_page()) {
bloginfo('name');
} else {
wp_title( '|', true, 'right' );
}; ?>
</title>
``` |
166,668 | <p>A client of mine wants the ability to create small blocks of content (call them "pods") and (re)use them in various pages across the site. So far, this is achieved by creating a custom post type [fig. 1] and calling pages generated therein via shortcode [fig. 2] into the "container" page [fig. 3]. </p>
<p>The probl... | [
{
"answer_id": 166748,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": true,
"text": "<p>There is a little underknown field in posts database called <code>post_content_filtered</code>. It isn't used by cor... | 2014/10/28 | [
"https://wordpress.stackexchange.com/questions/166668",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62670/"
] | A client of mine wants the ability to create small blocks of content (call them "pods") and (re)use them in various pages across the site. So far, this is achieved by creating a custom post type [fig. 1] and calling pages generated therein via shortcode [fig. 2] into the "container" page [fig. 3].
The problem is that... | There is a little underknown field in posts database called `post_content_filtered`. It isn't used by core (as far as I remember) and sometimes plugins use it to store alternate representation of content (which is more or less what it is intended for).
So in for your use case my idea would be to store content with sho... |
166,676 | <p>This is my code in <code>functions.php</code> file.</p>
<pre><code>function getcity(){
global $wpdb;
if($_POST['state']) {
$id=$_POST['state'];
$postid=$_POST['post_id'];
$district = esc_html(get_post_meta($postid , 'district ', true));
$result=$wpdb->get_results("SELECT *... | [
{
"answer_id": 166748,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": true,
"text": "<p>There is a little underknown field in posts database called <code>post_content_filtered</code>. It isn't used by cor... | 2014/10/28 | [
"https://wordpress.stackexchange.com/questions/166676",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58671/"
] | This is my code in `functions.php` file.
```
function getcity(){
global $wpdb;
if($_POST['state']) {
$id=$_POST['state'];
$postid=$_POST['post_id'];
$district = esc_html(get_post_meta($postid , 'district ', true));
$result=$wpdb->get_results("SELECT * FROM districts WHERE state_... | There is a little underknown field in posts database called `post_content_filtered`. It isn't used by core (as far as I remember) and sometimes plugins use it to store alternate representation of content (which is more or less what it is intended for).
So in for your use case my idea would be to store content with sho... |
166,727 | <p>We have many WP sites with a proxy in between the servers that they sit on and the internet.</p>
<p>Some things in WP simply don't work:</p>
<ul>
<li>RSS feeds on dashboard</li>
<li>looking up themes</li>
<li>looking up plugins</li>
<li>core updates</li>
</ul>
<p>We do everything manually and there are really no ... | [
{
"answer_id": 167014,
"author": "kaiser",
"author_id": 385,
"author_profile": "https://wordpress.stackexchange.com/users/385",
"pm_score": 4,
"selected": false,
"text": "<h1>jQuery / JavaScript in the footer</h1>\n\n<p>One thing you can do is to <a href=\"http://unserkaiser.com/blog/201... | 2014/10/28 | [
"https://wordpress.stackexchange.com/questions/166727",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/32393/"
] | We have many WP sites with a proxy in between the servers that they sit on and the internet.
Some things in WP simply don't work:
* RSS feeds on dashboard
* looking up themes
* looking up plugins
* core updates
We do everything manually and there are really no issues except for SLOWNESS on page loads. It seems that ... | jQuery / JavaScript in the footer
=================================
One thing you can do is to [move jQuery to the footer blog post](http://unserkaiser.com/blog/2013/10/08/how-to-move-wordpress-core-javascript-to-the-footer/). It's per default not needed in the header. You will have check if everything still works tou... |
166,751 | <p>I have custom post type "press." and made a page template the queries posts of that type. The posts are supposed to show their published date, but if there are more than one posts with the same date, only the first post shows the date and the others don't. Is there a way to show the date of every post?</p>
<p><img ... | [
{
"answer_id": 166753,
"author": "gdaniel",
"author_id": 30984,
"author_profile": "https://wordpress.stackexchange.com/users/30984",
"pm_score": 3,
"selected": false,
"text": "<p>Don't use <code>the_date()</code>, instead use <code>the_time()</code>.</p>\n\n<p>the_date returns the date o... | 2014/10/28 | [
"https://wordpress.stackexchange.com/questions/166751",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/74495/"
] | I have custom post type "press." and made a page template the queries posts of that type. The posts are supposed to show their published date, but if there are more than one posts with the same date, only the first post shows the date and the others don't. Is there a way to show the date of every post?
![enter image d... | I faced similar issue in past because I modified my date function.
And then posts were displaying date if only each post has different date otherwise it returned blank.
Try adding `<?php echo get_the_date(); ?>` instead. |
166,761 | <p>I have a query that pulls fields from the 3 most recent posts for a carousel:</p>
<pre><code>get_posts('posts_per_page=3')
</code></pre>
<p>I need to re-order the results so that instead of it being </p>
<blockquote>
<p>1, 2, 3 </p>
</blockquote>
<p>it is </p>
<blockquote>
<p>3, 1, 2. </p>
</blockquote>
<p... | [
{
"answer_id": 166763,
"author": "Robert hue",
"author_id": 22461,
"author_profile": "https://wordpress.stackexchange.com/users/22461",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think WordPress offers any way to order posts as you like. It has <code>ASC</code> and <code>DESC<... | 2014/10/28 | [
"https://wordpress.stackexchange.com/questions/166761",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62706/"
] | I have a query that pulls fields from the 3 most recent posts for a carousel:
```
get_posts('posts_per_page=3')
```
I need to re-order the results so that instead of it being
>
> 1, 2, 3
>
>
>
it is
>
> 3, 1, 2.
>
>
>
Any ideas on how to do this? | Reordering the way you want is really pretty trivial. Proof of concept:
```
$p = array(1,2,3);
var_dump($p);
array_push($p,array_shift($p));
var_dump($p);
```
With the WordPress code:
```
$p = get_posts('posts_per_page=3');
array_push($p,array_shift($p));
var_dump($p);
```
To make it more interesting, you can do... |
166,794 | <p>I got white blank page after copying the functions.php to my child theme.</p>
<p>How can I change "like_escape"? What file can I find that?</p>
<p>And I see this notice:</p>
<pre><code>Notice: like_escape is deprecated since version 4.0! Use wpdb::esc_like() instead. in /home7/homecre1/public_html/betasite/wp-inc... | [
{
"answer_id": 166763,
"author": "Robert hue",
"author_id": 22461,
"author_profile": "https://wordpress.stackexchange.com/users/22461",
"pm_score": 0,
"selected": false,
"text": "<p>I don't think WordPress offers any way to order posts as you like. It has <code>ASC</code> and <code>DESC<... | 2014/10/29 | [
"https://wordpress.stackexchange.com/questions/166794",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62725/"
] | I got white blank page after copying the functions.php to my child theme.
How can I change "like\_escape"? What file can I find that?
And I see this notice:
```
Notice: like_escape is deprecated since version 4.0! Use wpdb::esc_like() instead. in /home7/homecre1/public_html/betasite/wp-includes/functions.php on line... | Reordering the way you want is really pretty trivial. Proof of concept:
```
$p = array(1,2,3);
var_dump($p);
array_push($p,array_shift($p));
var_dump($p);
```
With the WordPress code:
```
$p = get_posts('posts_per_page=3');
array_push($p,array_shift($p));
var_dump($p);
```
To make it more interesting, you can do... |
166,862 | <p>I am using custom post types to add certain sections to my website. These post types are not meant to be treated like a blog, it's basically just an easy way for me to give the client access to managing certain sections, such as "reviews." Today I noticed that Google is indexing these custom post types and I was won... | [
{
"answer_id": 166870,
"author": "Yatix",
"author_id": 8441,
"author_profile": "https://wordpress.stackexchange.com/users/8441",
"pm_score": 5,
"selected": true,
"text": "<p>If you write code for registering custom post-type try adding these attributes</p>\n<pre><code>public => false,... | 2014/10/29 | [
"https://wordpress.stackexchange.com/questions/166862",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13286/"
] | I am using custom post types to add certain sections to my website. These post types are not meant to be treated like a blog, it's basically just an easy way for me to give the client access to managing certain sections, such as "reviews." Today I noticed that Google is indexing these custom post types and I was wonder... | If you write code for registering custom post-type try adding these attributes
```
public => false, has_archive => false, publicly_queryable => false, query_var => false
```
Otherwise, set these options to false in plugin that you might be using. |
166,907 | <p>I'm using <code>WP_User_Query</code> to bring back a list of users. I'm passing a list of specific users to be included in results. For example:</p>
<pre><code> $user_ids = array( 1, 5, 9, 61, 24, 12 );
$args = array(
'include' => $user_ids,
'count_total' => true,
'search' =>... | [
{
"answer_id": 166910,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 2,
"selected": true,
"text": "<p>I think that instead of dealing with complex SQL queries and ways to make WordPress use them, a simple <a href... | 2014/10/30 | [
"https://wordpress.stackexchange.com/questions/166907",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22599/"
] | I'm using `WP_User_Query` to bring back a list of users. I'm passing a list of specific users to be included in results. For example:
```
$user_ids = array( 1, 5, 9, 61, 24, 12 );
$args = array(
'include' => $user_ids,
'count_total' => true,
'search' => sanitize_text_field( $_GET['phra... | I think that instead of dealing with complex SQL queries and ways to make WordPress use them, a simple [`uasort`](http://php.net/manual/en/function.usort.php) can do the trick:
```
$uids = array( 1 );
$user_query = new WP_User_Query( array( 'include' => $uids ) );
$users = (array) $user_query->results;
usort( $user... |
166,941 | <p>I'm trying to pass a variable into the add_shortcode function to be used as the shortcode name but it does not seem to be working. Is there a way that I can pass a variable similar to this? </p>
<pre><code>foreach ($files1 as $value) {
$new_value = substr($value, 0, -4);
add_shortcode($new_value, function(... | [
{
"answer_id": 166944,
"author": "taido",
"author_id": 60658,
"author_profile": "https://wordpress.stackexchange.com/users/60658",
"pm_score": -1,
"selected": false,
"text": "<p>I am not sure your mind but I think parameter $new_value you are using in function add_shortcode is undefined.... | 2014/10/30 | [
"https://wordpress.stackexchange.com/questions/166941",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62791/"
] | I'm trying to pass a variable into the add\_shortcode function to be used as the shortcode name but it does not seem to be working. Is there a way that I can pass a variable similar to this?
```
foreach ($files1 as $value) {
$new_value = substr($value, 0, -4);
add_shortcode($new_value, function() {
r... | There are two solutions:
1. Use the [third argument for the shortcode](https://wordpress.stackexchange.com/questions/42882/current-shortcode-detect-currently-used-shortcode).
2. Use the `use` keyword.
Examples
1. The third parameter for each shortcode callback is the name of the shortcode:
```php
foreach ($files1 a... |
166,945 | <p>I want to display the titles of the last N posts in a specific category. I am using the following code: </p>
<pre><code> <?php
$cat_id=get_cat_ID('category1');
$posts = get_posts ("cat=$cat_id&posts_per_page=3");
if ($posts)
{
foreach ($posts as $post)... | [
{
"answer_id": 166946,
"author": "Robert hue",
"author_id": 22461,
"author_profile": "https://wordpress.stackexchange.com/users/22461",
"pm_score": 3,
"selected": true,
"text": "<p>First, there is no parameter named <code>cat</code> in <code>get_posts</code>. Use <code>category</code> in... | 2014/10/30 | [
"https://wordpress.stackexchange.com/questions/166945",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62333/"
] | I want to display the titles of the last N posts in a specific category. I am using the following code:
```
<?php
$cat_id=get_cat_ID('category1');
$posts = get_posts ("cat=$cat_id&posts_per_page=3");
if ($posts)
{
foreach ($posts as $post):
setup_po... | First, there is no parameter named `cat` in `get_posts`. Use `category` instead to input comma separated category IDs or `category_name` to directly inserting category name.
Second, in your code you have commented out the title of the post.
Try this code.
```
<?php
$cat_id = get_cat_ID('category1');
$posts = ... |
166,949 | <p>I´m a PHP noop and I want to get the post from a post_type with a specifically ID(for example 64), and than only this.. For Example if there are 3 posts in my post_type (ID 63, ID 64, ID 65) than please show me in frontend the post with ID 64..
Can you help me?
I try this >>></p>
<pre><code>$args = array( 'post_typ... | [
{
"answer_id": 166950,
"author": "Robert hue",
"author_id": 22461,
"author_profile": "https://wordpress.stackexchange.com/users/22461",
"pm_score": 0,
"selected": false,
"text": "<p>You can specify post id in <code>WP_Query</code> with <code>p=</code>\nHere is your code.</p>\n\n<pre><cod... | 2014/10/30 | [
"https://wordpress.stackexchange.com/questions/166949",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62792/"
] | I´m a PHP noop and I want to get the post from a post\_type with a specifically ID(for example 64), and than only this.. For Example if there are 3 posts in my post\_type (ID 63, ID 64, ID 65) than please show me in frontend the post with ID 64..
Can you help me?
I try this >>>
```
$args = array( 'post_type' => 'my_pt... | You query is completely wrong and mingled. You are using `WP_Query` and `get_post` together and intermingled in one query, which will never work
To retrieve just **one** single post, make use of [`get_post`](http://codex.wordpress.org/Function_Reference/get_post). You can delete your complete query in your question. R... |
166,972 | <p>I want to only get posts with current or future dates, to show upcoming events. </p>
<p>Current arguments:</p>
<pre><code>$args = array(
'post_type' => 'event',
'meta_key' => 'event_start_date',
'orderby' => 'meta_value',
'order' => 'ASC'
);
</code></pre>
<p>This returns all t... | [
{
"answer_id": 166992,
"author": "Chrizlee",
"author_id": 62806,
"author_profile": "https://wordpress.stackexchange.com/users/62806",
"pm_score": 2,
"selected": false,
"text": "<p>adding the following arguments did the trick</p>\n\n<pre><code>'meta_value' => date('Y-m-d h:i'),\n ... | 2014/10/30 | [
"https://wordpress.stackexchange.com/questions/166972",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62806/"
] | I want to only get posts with current or future dates, to show upcoming events.
Current arguments:
```
$args = array(
'post_type' => 'event',
'meta_key' => 'event_start_date',
'orderby' => 'meta_value',
'order' => 'ASC'
);
```
This returns all the posts, including past events.
I read abo... | adding the following arguments did the trick
```
'meta_value' => date('Y-m-d h:i'),
'meta_compare' => '>',
``` |
166,994 | <p>I'm trying to add links "Previous Post" and "Next Post" in my single.php file without success because previous_posts_link and next_posts_link dont return anything.</p>
<p>Honestly I do not know where in the loop put these buttons.</p>
<p>Thanks.</p>
<p></p>
<pre><code><?php if ( have_posts() ) : while ( have_... | [
{
"answer_id": 166998,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p><code>next_posts_link</code> and <code>previous_posts_link</code> (plural) are for archive pagination. For single p... | 2014/10/30 | [
"https://wordpress.stackexchange.com/questions/166994",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48707/"
] | I'm trying to add links "Previous Post" and "Next Post" in my single.php file without success because previous\_posts\_link and next\_posts\_link dont return anything.
Honestly I do not know where in the loop put these buttons.
Thanks.
```
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div cla... | `next_posts_link` and `previous_posts_link` (plural) are for archive pagination. For single posts you want [`next_post_link`](http://codex.wordpress.org/Function_Reference/next_post_link) and [`previous_post_link`](http://codex.wordpress.org/Function_Reference/previous_post_link) (singular). |
167,003 | <p>I'm building a site for a research and my participants will be all logged in to use the site. I would like to make these participants able to see only their own comments, so other users' comments will be hidden.</p>
<p>I'm using the comments.php file with, among other things, this simple code and a callback to form... | [
{
"answer_id": 167005,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 2,
"selected": true,
"text": "<p>What you need to do to achieve this is to provide the second parameter of <a href=\"http://codex.wor... | 2014/10/30 | [
"https://wordpress.stackexchange.com/questions/167003",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62810/"
] | I'm building a site for a research and my participants will be all logged in to use the site. I would like to make these participants able to see only their own comments, so other users' comments will be hidden.
I'm using the comments.php file with, among other things, this simple code and a callback to format the com... | What you need to do to achieve this is to provide the second parameter of [`wp_list_comments()`](http://codex.wordpress.org/Function_Reference/wp_list_comments), which would be `$comments` and is described like this:
>
> (array) (optional) Array obtained by [get\_comments](http://codex.wordpress.org/Function_Referenc... |
167,019 | <p>This is trivial, but I can't really find an answer, I've seen some hints like search in database etc., but this is madness.</p>
<p>Basically, I have a metabox with upload button that allows you to upload or pick existing image from Media Library, that's how I get the URL of this image:</p>
<pre><code>$my_image = g... | [
{
"answer_id": 183744,
"author": "Tomas Ramirez Sarduy",
"author_id": 2899,
"author_profile": "https://wordpress.stackexchange.com/users/2899",
"pm_score": 1,
"selected": false,
"text": "<p>I had the same problem while I was using CMB plugin, I solved adding a custom function to <code>fu... | 2014/10/31 | [
"https://wordpress.stackexchange.com/questions/167019",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1869/"
] | This is trivial, but I can't really find an answer, I've seen some hints like search in database etc., but this is madness.
Basically, I have a metabox with upload button that allows you to upload or pick existing image from Media Library, that's how I get the URL of this image:
```
$my_image = get_post_meta($post->I... | Ok, all those hipercomplex functions can be reduced to one simple command: `attachment_url_to_postid`
You only need to parse the image url to retrieve the attachment id:
```
<?php
$attachment_id = attachment_url_to_postid( $image_url );
echo $attachment_id;
?>
```
That's all you need. |
167,060 | <p>I have the posts which have many custom defined meta fields.
On posts I am calling them on requirement using <code>get_post_meta</code>. Means for 10 meta fields I am using it 10 times. </p>
<p>Am I doing it right? Means, is there any performance issue with the above method and if yes then how to reduce the number ... | [
{
"answer_id": 167061,
"author": "Nilambar Sharma",
"author_id": 27998,
"author_profile": "https://wordpress.stackexchange.com/users/27998",
"pm_score": 1,
"selected": false,
"text": "<p>You can use <code>get_post_meta</code> to fetch all meta field values at once.</p>\n\n<pre><code>$met... | 2014/10/31 | [
"https://wordpress.stackexchange.com/questions/167060",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31989/"
] | I have the posts which have many custom defined meta fields.
On posts I am calling them on requirement using `get_post_meta`. Means for 10 meta fields I am using it 10 times.
Am I doing it right? Means, is there any performance issue with the above method and if yes then how to reduce the number of calls.
I am aware... | To answer this, I have gone and done some tests on this, and the results was actually mind blowing.
Here is my test
===============
*To this yourself, set yourself up with a test page. Just simply copy page.php, rename it and delete the loop. Now just create a new page in the back end. Before you start, first test yo... |
167,068 | <p>I have a main website with 2 sub domains.</p>
<p>www.example.com</p>
<p>www.space.example.com</p>
<p>www.products.example.com</p>
<p>I want to publish articles on my main website using categories to sort them.</p>
<p>for example, an article using "space" category, and an article using "products" category.</p>
... | [
{
"answer_id": 167065,
"author": "maiorano84",
"author_id": 15492,
"author_profile": "https://wordpress.stackexchange.com/users/15492",
"pm_score": 3,
"selected": true,
"text": "<p><code>@import</code> is a convenient CSS shortcut for loading a particular stylesheet (often parent themes ... | 2014/10/31 | [
"https://wordpress.stackexchange.com/questions/167068",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40572/"
] | I have a main website with 2 sub domains.
www.example.com
www.space.example.com
www.products.example.com
I want to publish articles on my main website using categories to sort them.
for example, an article using "space" category, and an article using "products" category.
Using wp-query and custom post type, I wan... | `@import` is a convenient CSS shortcut for loading a particular stylesheet (often parent themes or other dependencies), but part of the reason why it's generally discouraged is due to - as you had mentioned - a small performance hit (stylesheets loaded with `@import` are not loaded in parallel).
Another reason is that... |
167,071 | <p>How to remove ul-class in wp_nav_menu?</p>
<pre><code>'items_wrap' => '%3$s',
'container' => false
</code></pre>
<p>Adding above does not work.</p>
| [
{
"answer_id": 167072,
"author": "Robert hue",
"author_id": 22461,
"author_profile": "https://wordpress.stackexchange.com/users/22461",
"pm_score": 2,
"selected": false,
"text": "<p>To remove ul class from wp_nav_menu, you will have to define <code>menu_class</code> to false. Default wp... | 2014/10/31 | [
"https://wordpress.stackexchange.com/questions/167071",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62857/"
] | How to remove ul-class in wp\_nav\_menu?
```
'items_wrap' => '%3$s',
'container' => false
```
Adding above does not work. | To remove ul class from wp\_nav\_menu, you will have to define `menu_class` to false. Default wp\_nav\_menu ul menu class is `menu`.
```
<?php wp_nav_menu( array( 'container' => false, 'items_wrap' => '<ul>%3$s</ul>', 'theme_location' => 'mainmenu' ) ); ?>
```
I added `mainmenu` as `theme_location`. You should chang... |
167,091 | <p>I'm using <code>WP_User_Query</code> to get a list of users from my database. I'm showing specific users only via use of the <code>include</code> parameter. For example:</p>
<pre><code>$args = array(
'include' => array( 1, 3, 5, 99, 61, 24, 12 ),
'count_total' => true,
'search' => sanitize_text... | [
{
"answer_id": 167095,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 4,
"selected": true,
"text": "<p><em>Updated:</em></p>\n\n<p>The <code>WP_User_Query</code> class, in WordPress 4.1+, supports it with : </p>\n... | 2014/10/31 | [
"https://wordpress.stackexchange.com/questions/167091",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22599/"
] | I'm using `WP_User_Query` to get a list of users from my database. I'm showing specific users only via use of the `include` parameter. For example:
```
$args = array(
'include' => array( 1, 3, 5, 99, 61, 24, 12 ),
'count_total' => true,
'search' => sanitize_text_field( $_GET['phrase'] )
);
$query = new WP... | *Updated:*
The `WP_User_Query` class, in WordPress 4.1+, supports it with :
```
'orderby' => 'include'
```
Since WordPress 4.7 there's also support for:
```
'orderby' => 'login__in'
```
and
```
'orderby' => 'nicename__in'
```
So we no longer need to implement it through a filter, like we did here below.
Pre... |
167,099 | <p>I've created a simple text custom meta field for pages. I can successfully enter plain text which prints on the frontend of the site with no problem.</p>
<p>I want to add shortcodes also. If I add a shortcode to the field, the shortcode prints to the front end as plain text.</p>
<p>The code I'm using:</p>
<pre><c... | [
{
"answer_id": 167123,
"author": "Welcher",
"author_id": 27210,
"author_profile": "https://wordpress.stackexchange.com/users/27210",
"pm_score": 1,
"selected": false,
"text": "<p>It looks like you have all the pieces you need to make this work - you just need to connect them. Try the sni... | 2014/10/31 | [
"https://wordpress.stackexchange.com/questions/167099",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37243/"
] | I've created a simple text custom meta field for pages. I can successfully enter plain text which prints on the frontend of the site with no problem.
I want to add shortcodes also. If I add a shortcode to the field, the shortcode prints to the front end as plain text.
The code I'm using:
```
<?php $meta = get_post_m... | You can do this by using 'the\_content' filter. That way, Wordpress will treat the content as it was came from the editor field and execute all the shortcodes:
```
<?php $meta = get_post_meta($post->ID, 'intSlider', true); ?>
<div id="sliderWrap">
<div id="slider" class="floatLeft">
<? echo apply_filters('... |
167,109 | <p>I have an existing WP Multisite network. I want to simplify the maintenance of the themes. I'd like all subsites to have the same parent and child theme applied across the network.I saw several posts on WP_DEFAULT_THEME in the wp-config.php file but am unclear what the code would look like when applying both the par... | [
{
"answer_id": 167110,
"author": "Bordoni",
"author_id": 12166,
"author_profile": "https://wordpress.stackexchange.com/users/12166",
"pm_score": 0,
"selected": false,
"text": "<p>The configuration of what is the father theme on WordPress lies on the Child Theme you just need to setup <co... | 2014/10/31 | [
"https://wordpress.stackexchange.com/questions/167109",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62862/"
] | I have an existing WP Multisite network. I want to simplify the maintenance of the themes. I'd like all subsites to have the same parent and child theme applied across the network.I saw several posts on WP\_DEFAULT\_THEME in the wp-config.php file but am unclear what the code would look like when applying both the pare... | The `WP_DEFAULT_THEME` constant actually just overrides what WordPress sets as default theme (which per default is the latest of the bundled themes). It does not really help you to define your parent theme. In fact you just have to "Network enable" your parent and [child themes](http://codex.wordpress.org/Child_Themes)... |
167,116 | <p>We've got a WordPress Multisite install.</p>
<p>Can you mix sites that use subdomains with sites that use paths?</p>
<p>And, if so, are there any guides to this?</p>
| [
{
"answer_id": 167110,
"author": "Bordoni",
"author_id": 12166,
"author_profile": "https://wordpress.stackexchange.com/users/12166",
"pm_score": 0,
"selected": false,
"text": "<p>The configuration of what is the father theme on WordPress lies on the Child Theme you just need to setup <co... | 2014/10/31 | [
"https://wordpress.stackexchange.com/questions/167116",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48904/"
] | We've got a WordPress Multisite install.
Can you mix sites that use subdomains with sites that use paths?
And, if so, are there any guides to this? | The `WP_DEFAULT_THEME` constant actually just overrides what WordPress sets as default theme (which per default is the latest of the bundled themes). It does not really help you to define your parent theme. In fact you just have to "Network enable" your parent and [child themes](http://codex.wordpress.org/Child_Themes)... |
167,128 | <p>My site sits on a server that uses Varnish as a (powerful) caching engine.
Unfortunately, it seems wordpress is busting the Varnish cache by sending a cache-control http header. If I <code>curl -I domain.com</code> I get:</p>
<pre><code>HTTP/1.1 200 OK
Server: Apache/2.4.10
X-Powered-By: PHP/5.4.4-14+deb7u14
Expire... | [
{
"answer_id": 167130,
"author": "chrisguitarguy",
"author_id": 6035,
"author_profile": "https://wordpress.stackexchange.com/users/6035",
"pm_score": 2,
"selected": false,
"text": "<p>You can hook into <code>wp_headers</code> and remove the cache control headers. WordPress generally does... | 2014/10/31 | [
"https://wordpress.stackexchange.com/questions/167128",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/82/"
] | My site sits on a server that uses Varnish as a (powerful) caching engine.
Unfortunately, it seems wordpress is busting the Varnish cache by sending a cache-control http header. If I `curl -I domain.com` I get:
```
HTTP/1.1 200 OK
Server: Apache/2.4.10
X-Powered-By: PHP/5.4.4-14+deb7u14
Expires: Thu, 19 Nov 1981 08:52... | Thanks to @chrisguitarguy's answer, you can control the http headers sent by Wordpress via the "send\_headers" hook. Here is the function I added to my theme's functions.php file, and that solved the issue with the Varnish server.
```
function varnish_safe_http_headers() {
header( 'X-UA-Compatible: IE=edge,chrome=... |
167,132 | <p>I have created a custom page template and want to hide page title from the page.</p>
<p>How do I do this? I know I can just leave page title blank or do it in CSS and that works but isn't that bad for SEO etc? How do I write the conditional statement and where do I put it?</p>
<p>Here is my template:</p>
<pre><co... | [
{
"answer_id": 167135,
"author": "eelias",
"author_id": 62880,
"author_profile": "https://wordpress.stackexchange.com/users/62880",
"pm_score": -1,
"selected": false,
"text": "<p>Page title can be used in the following code:</p>\n\n<pre><code><?php the_title( '<h1 class=\"title-hea... | 2014/11/01 | [
"https://wordpress.stackexchange.com/questions/167132",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62879/"
] | I have created a custom page template and want to hide page title from the page.
How do I do this? I know I can just leave page title blank or do it in CSS and that works but isn't that bad for SEO etc? How do I write the conditional statement and where do I put it?
Here is my template:
```
<?php
/*
Template Name: N... | It's simple:
Don't forget to move `add_filter` to functions.php file :)
```
<?php
/*
Template Name: No Title Page
*/
add_filter( 'the_title', function ($title) { return "";});
?>
<?php get_header(); ?>
<div class="wrapper">
<?php while ( have_posts() ) : the_post(); ?>
<?php get_template_part( 'content', 'p... |
167,136 | <p>In the admin panel's "Edit Comment" page, for some reason after I click "Update" the Edit page goes into infinite loop/loading (the spinner icon in the Google Chrome tab never stops spinning). My computer goes into "deep think" for 10-20 minutes, even after I close WordPress, the web browser, and my IDE (I'm working... | [
{
"answer_id": 167139,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p><code>wp_update_comment</code> triggers the <code>edit_comment</code> action (<a href=\"https://core.trac.wordpress... | 2014/11/01 | [
"https://wordpress.stackexchange.com/questions/167136",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62878/"
] | In the admin panel's "Edit Comment" page, for some reason after I click "Update" the Edit page goes into infinite loop/loading (the spinner icon in the Google Chrome tab never stops spinning). My computer goes into "deep think" for 10-20 minutes, even after I close WordPress, the web browser, and my IDE (I'm working lo... | `wp_update_comment` triggers the `edit_comment` action ([source](https://core.trac.wordpress.org/browser/tags/4.0/src/wp-includes/comment.php#L1911)), you're creating an infinite loop. |
167,156 | <p>I have created the following custom post types:</p>
<ul>
<li>Artists
<ul>
<li>Albums
<ul>
<li>Songs</li>
</ul></li>
</ul></li>
</ul>
<p>Songs are children of Albums, Albums are children of Artists.</p>
<p>I am trying to set up a navigation structure that shows this relationship, in the following format: <code>htt... | [
{
"answer_id": 167293,
"author": "Rachel Carden",
"author_id": 14003,
"author_profile": "https://wordpress.stackexchange.com/users/14003",
"pm_score": 3,
"selected": true,
"text": "<p>In order to rewrite a custom post type's URL, or permalink, you'll need to filter the 'post_type_link', ... | 2014/11/01 | [
"https://wordpress.stackexchange.com/questions/167156",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62852/"
] | I have created the following custom post types:
* Artists
+ Albums
- Songs
Songs are children of Albums, Albums are children of Artists.
I am trying to set up a navigation structure that shows this relationship, in the following format: `http://www.example.com/artists/alicia-keys/discography/girl-on-fire/brand-ne... | In order to rewrite a custom post type's URL, or permalink, you'll need to filter the 'post\_type\_link', which is run whenever get\_permalink() is called, allowing you to change a post's permalink. I've include some guide code below.
It seems like you have a handle on the rewrite rules but let me know if you need mor... |
167,184 | <p>I have a site with 70K spam subscribers, and I don't need any of them. So I need to delete all subscribers from wp_users and each user's associated meta from wp_usermeta using a query in adminer and/or phpmyadmin.</p>
<p>But to keep from crashing the server, so how can I delete a few thousand at a time?</p>
<p>Thi... | [
{
"answer_id": 167215,
"author": "Fatih SARI",
"author_id": 62927,
"author_profile": "https://wordpress.stackexchange.com/users/62927",
"pm_score": 2,
"selected": false,
"text": "<p>You can use Wp function for this. wp_delete_user(); this function work with user id. you can get all subsc... | 2014/11/02 | [
"https://wordpress.stackexchange.com/questions/167184",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/268/"
] | I have a site with 70K spam subscribers, and I don't need any of them. So I need to delete all subscribers from wp\_users and each user's associated meta from wp\_usermeta using a query in adminer and/or phpmyadmin.
But to keep from crashing the server, so how can I delete a few thousand at a time?
This seems to be t... | My favorite way to do something like this is not via database hacking (which I am always concerned will have side effects), but via a command line tool.
For example, giving a functioning [WP CLI install](http://wp-cli.org "WP CLI"), you can simply do this:
`wp user delete $(wp user list --role=subscriber --field=ID -... |
167,186 | <p>I want to know if it's possible to get the ID of a page with a specific template. Is this possible to get the ID of a page that assigned to "page-special.php"?</p>
| [
{
"answer_id": 167187,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 7,
"selected": true,
"text": "<p>When a page is created, the assigned template to that page is saved as custom post meta in the same way ... | 2014/11/02 | [
"https://wordpress.stackexchange.com/questions/167186",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62911/"
] | I want to know if it's possible to get the ID of a page with a specific template. Is this possible to get the ID of a page that assigned to "page-special.php"? | When a page is created, the assigned template to that page is saved as custom post meta in the same way as custom fields. The `meta_key` is `_wp_page_template` and the `meta_value` will be the page template
You can simply make use of [`get_pages`](http://codex.wordpress.org/Function_Reference/get_pages) to retrieve al... |
167,203 | <p>I would like to create a website for a scholarship. For that, I want to create three pages for seeing all members of the scholarship:</p>
<ul>
<li>one for members of the board of trustees (people who created it)</li>
<li>one for current scholars</li>
<li>one for former scholars</li>
</ul>
<p>I am new to Wordpress ... | [
{
"answer_id": 167187,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 7,
"selected": true,
"text": "<p>When a page is created, the assigned template to that page is saved as custom post meta in the same way ... | 2014/11/02 | [
"https://wordpress.stackexchange.com/questions/167203",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I would like to create a website for a scholarship. For that, I want to create three pages for seeing all members of the scholarship:
* one for members of the board of trustees (people who created it)
* one for current scholars
* one for former scholars
I am new to Wordpress and this is my first serious project with ... | When a page is created, the assigned template to that page is saved as custom post meta in the same way as custom fields. The `meta_key` is `_wp_page_template` and the `meta_value` will be the page template
You can simply make use of [`get_pages`](http://codex.wordpress.org/Function_Reference/get_pages) to retrieve al... |
167,205 | <p>I've got a site with products... and some of those products are in categories (collections). For those products I want to show a button 'view the collection,' and have that link to the category.</p>
<p>So, I did this:</p>
<pre><code><?php if(in_category): ?>
<a class="btn-light" href="http://dev.andrianna... | [
{
"answer_id": 167214,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 1,
"selected": false,
"text": "<p><strong>EDIT</strong></p>\n<p>From your comments, you are using <a href=\"http://codex.wordpress.org/Fu... | 2014/11/02 | [
"https://wordpress.stackexchange.com/questions/167205",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62925/"
] | I've got a site with products... and some of those products are in categories (collections). For those products I want to show a button 'view the collection,' and have that link to the category.
So, I did this:
```
<?php if(in_category): ?>
<a class="btn-light" href="http://dev.andriannashamarisinc.com/product-catego... | **EDIT**
From your comments, you are using [`get_cat_ID()`](http://codex.wordpress.org/Function_Reference/get_cat_ID) totally wrong. You can only feed one category to it. Please follow all links given and check the examples in the codex. Also, as stated, enable debugging, because that is all problems you should have p... |
167,238 | <p>I have WordPress Multisite with several sites. I set up <code>DISABLE_WP_CRON</code> to <code>true</code> in my <code>wp-config.php</code>.</p>
<p>If we set up cron task with wget or curl we have 30 sec rule to execute PHP script. It's so small to send tons of email notifications and do other stuff (maybe remote SM... | [
{
"answer_id": 176272,
"author": "DiverseAndRemote.com",
"author_id": 23690,
"author_profile": "https://wordpress.stackexchange.com/users/23690",
"pm_score": 4,
"selected": false,
"text": "<p>I think the best way is to use WP-CLI but you'd need to write a bash script to do this. Here is ... | 2014/11/03 | [
"https://wordpress.stackexchange.com/questions/167238",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/46077/"
] | I have WordPress Multisite with several sites. I set up `DISABLE_WP_CRON` to `true` in my `wp-config.php`.
If we set up cron task with wget or curl we have 30 sec rule to execute PHP script. It's so small to send tons of email notifications and do other stuff (maybe remote SMTP server connection is slow, maybe it's re... | I think the best way is to use WP-CLI but you'd need to write a bash script to do this. Here is one that should do it for you:
```
WP_PATH="/path/to/wp"
for SITE_URL in = $(wp site list --fields=domain,path,archived,deleted --format=csv --path="$WP_PATH" | grep ",0,0$" | awk -F ',' '{print $1 $2}')
do
for EVENT_HO... |
167,290 | <p>I have to test the function where it calls <code>wp_get_attachment_image_src</code>. How do I add an image for testing, because right now if I call this method it returns false. </p>
| [
{
"answer_id": 167409,
"author": "J.D.",
"author_id": 27757,
"author_profile": "https://wordpress.stackexchange.com/users/27757",
"pm_score": 4,
"selected": true,
"text": "<p>I'd take a look at how WordPress has constructed their attachment tests. You'll find that <code>tests/phpunit/tes... | 2014/11/03 | [
"https://wordpress.stackexchange.com/questions/167290",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62360/"
] | I have to test the function where it calls `wp_get_attachment_image_src`. How do I add an image for testing, because right now if I call this method it returns false. | I'd take a look at how WordPress has constructed their attachment tests. You'll find that `tests/phpunit/tests/post/attachments.php` they use [this method](https://core.trac.wordpress.org/browser/branches/4.5/tests/phpunit/includes/testcase.php#L722):
```
function _make_attachment( $upload, $parent_post_id = 0 ) {
... |
167,294 | <p>I am attempting to create a multisite as a subdirectory and I have followed the network instructions to the 'T'. The multisite seems to be set up correctly, the .htaccess and wp-config.php files seem correct and I was able to do a network setup, however when I go to my multisite page it comes up with a 404 error - N... | [
{
"answer_id": 179083,
"author": "sladda",
"author_id": 68016,
"author_profile": "https://wordpress.stackexchange.com/users/68016",
"pm_score": 4,
"selected": true,
"text": "<p>I had the axact same problem.</p>\n\n<p><strong>My solution</strong>: edited/etc/apache2/sites-enabled/000-defa... | 2014/11/03 | [
"https://wordpress.stackexchange.com/questions/167294",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62968/"
] | I am attempting to create a multisite as a subdirectory and I have followed the network instructions to the 'T'. The multisite seems to be set up correctly, the .htaccess and wp-config.php files seem correct and I was able to do a network setup, however when I go to my multisite page it comes up with a 404 error - Not ... | I had the axact same problem.
**My solution**: edited/etc/apache2/sites-enabled/000-default.conf. It needs to look like:
```
<VirtualHost *:80>
ServerAdmin webmaster@localhost
DocumentRoot /var/www/html
<Directory />
Options FollowSymLinks
AllowOverride all
... |
167,303 | <p>I want to move away from using MD5 for hashing passwords in the database. The plan is to declare a custom global <code>$wp_hasher</code> as hinted at in the <a href="http://codex.wordpress.org/Function_Reference/wp_hash_password" rel="nofollow">docs</a> for <code>wp hash password()</code>:</p>
<blockquote>
<p>Unl... | [
{
"answer_id": 167317,
"author": "s_ha_dum",
"author_id": 21376,
"author_profile": "https://wordpress.stackexchange.com/users/21376",
"pm_score": 3,
"selected": true,
"text": "<p>What I would do is this: Since <code>wp_hash_password()</code> is a \"pluggable\" function, create a simple p... | 2014/11/03 | [
"https://wordpress.stackexchange.com/questions/167303",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62975/"
] | I want to move away from using MD5 for hashing passwords in the database. The plan is to declare a custom global `$wp_hasher` as hinted at in the [docs](http://codex.wordpress.org/Function_Reference/wp_hash_password) for `wp hash password()`:
>
> Unless the global $wp\_hasher is set, the default implementation uses P... | What I would do is this: Since `wp_hash_password()` is a "pluggable" function, create a simple plugin or MU-Plugin and define a function called `wp_hash_password()` in that plugin/mu-plugin. Wordpress will use your function instead of the core function.
Just copy the original code into your plugin/mu-plugin and chang... |
167,308 | <p>I am currently using the following code to get the URL of the featured image of a wordpress post:</p>
<pre><code>URL="<?php if (function_exists('wp_get_attachment_thumb_url')) {echo wp_get_attachment_thumb_url(get_post_thumbnail_id($post->ID), 'big-size'); }?>"
</code></pre>
<p>But the code only returns t... | [
{
"answer_id": 167309,
"author": "SLH",
"author_id": 45476,
"author_profile": "https://wordpress.stackexchange.com/users/45476",
"pm_score": 6,
"selected": true,
"text": "<p>There are four valid sizes built in to the WordPress core.</p>\n\n<pre><code>the_post_thumbnail('thumbnail'); /... | 2014/11/03 | [
"https://wordpress.stackexchange.com/questions/167308",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30729/"
] | I am currently using the following code to get the URL of the featured image of a wordpress post:
```
URL="<?php if (function_exists('wp_get_attachment_thumb_url')) {echo wp_get_attachment_thumb_url(get_post_thumbnail_id($post->ID), 'big-size'); }?>"
```
But the code only returns the smaller (150x150px) thumbnail. T... | There are four valid sizes built in to the WordPress core.
```
the_post_thumbnail('thumbnail'); // Thumbnail (default 150px x 150px max)
the_post_thumbnail('medium'); // Medium resolution (default 300px x 300px max)
the_post_thumbnail('medium_large'); // Medium Large resolution (default 768px x 0(means automa... |
167,310 | <p>My custom Meta Box has a drop down field, but how do I set the default Option Value to be blank? It is currently populating via the CPT's meta_value, but I'd like that to change.</p>
<p>Here's a screenshot of the issue: <img src="https://i.stack.imgur.com/91b6c.png" alt="enter image description here"> </p>
<p>I wa... | [
{
"answer_id": 167311,
"author": "SLH",
"author_id": 45476,
"author_profile": "https://wordpress.stackexchange.com/users/45476",
"pm_score": 3,
"selected": true,
"text": "<p>Before the foreach loop:</p>\n\n<p><code>foreach($authors as $author) {</code></p>\n\n<p>Add this empty option ele... | 2014/11/03 | [
"https://wordpress.stackexchange.com/questions/167310",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54745/"
] | My custom Meta Box has a drop down field, but how do I set the default Option Value to be blank? It is currently populating via the CPT's meta\_value, but I'd like that to change.
Here's a screenshot of the issue: 
I want the first option for the Se... | Before the foreach loop:
`foreach($authors as $author) {`
Add this empty option element:
`echo '<option value="0"></option>';`
Hope it works! :) |
167,332 | <p>I don't want to add the category support for the posts of a certain custom post type but to categorize the post types itself. How is that possible?</p>
<h3>Story behind:</h3>
<p>In my theme I handle different post types differently. But certain post types are being processed in the same way, so a categorisation of t... | [
{
"answer_id": 167336,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 1,
"selected": false,
"text": "<p>I'm assuming you're not using a plugin to register your post types and doing them yourself. WordPress doesn... | 2014/11/03 | [
"https://wordpress.stackexchange.com/questions/167332",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34790/"
] | I don't want to add the category support for the posts of a certain custom post type but to categorize the post types itself. How is that possible?
### Story behind:
In my theme I handle different post types differently. But certain post types are being processed in the same way, so a categorisation of the post types... | Thanks guys, I found a solution:
It's as easy as adding the `post_type_category` element to the arguments object within register\_post\_type():
```
$args = array(
'label' => 'sausages',
'description' => 'Sausages',
'labels' => $labels,
'post_type_category' => 'food'... |
167,381 | <p>I've been having looot of troubles with this function, I don't know what to do, because I tried everything.</p>
<p>I have a custom post type, let's call it study. The url structure for it is </p>
<pre><code>http://example.com/study/studyname
</code></pre>
<p>They have different sections, I want to have the new st... | [
{
"answer_id": 167336,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 1,
"selected": false,
"text": "<p>I'm assuming you're not using a plugin to register your post types and doing them yourself. WordPress doesn... | 2014/11/04 | [
"https://wordpress.stackexchange.com/questions/167381",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63023/"
] | I've been having looot of troubles with this function, I don't know what to do, because I tried everything.
I have a custom post type, let's call it study. The url structure for it is
```
http://example.com/study/studyname
```
They have different sections, I want to have the new structure like this:
```
http://ex... | Thanks guys, I found a solution:
It's as easy as adding the `post_type_category` element to the arguments object within register\_post\_type():
```
$args = array(
'label' => 'sausages',
'description' => 'Sausages',
'labels' => $labels,
'post_type_category' => 'food'... |
167,389 | <p>By mistake I just ran this query: (note the extra <code>;</code>)</p>
<pre><code>DELETE FROM wp_users; WHERE ID = 321;
</code></pre>
<p>How can I add a user through SQL?</p>
<p>I searched around but couldn't find a proper answer to this fairly simple question.</p>
<p>More info about the situation I was in when ... | [
{
"answer_id": 167390,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 2,
"selected": false,
"text": "<p>Generally, WordPress has functions to handle what you want, it is much preferable to use them. For ... | 2014/11/04 | [
"https://wordpress.stackexchange.com/questions/167389",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44793/"
] | By mistake I just ran this query: (note the extra `;`)
```
DELETE FROM wp_users; WHERE ID = 321;
```
How can I add a user through SQL?
I searched around but couldn't find a proper answer to this fairly simple question.
More info about the situation I was in when I asked this:
* Can't use `wp-cli` on this shared h... | This will create a new admin user called username with password: password in a database called DATABASE with table prefix wp\_
Change the two accordingly to your own database name and table prefix.
Try this:
First create a row in `wp_users`. Replace DATABASE with your database name, username with your choosen userna... |
167,401 | <p>I've this error "Call to a member function get_results() on a non-object in"
from this code:</p>
<pre><code>require_once($_SERVER['DOCUMENT_ROOT'] . $folder . '/wp-config.php');
require_once($_SERVER['DOCUMENT_ROOT'] . $folder . '/wp-load.php');
if (!$wpdb) {
$wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOS... | [
{
"answer_id": 167403,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 4,
"selected": true,
"text": "<p>This is a <a href=\"http://php.net/manual/en/language.variables.scope.php\" rel=\"noreferrer\">PHP variable scope</... | 2014/11/04 | [
"https://wordpress.stackexchange.com/questions/167401",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62228/"
] | I've this error "Call to a member function get\_results() on a non-object in"
from this code:
```
require_once($_SERVER['DOCUMENT_ROOT'] . $folder . '/wp-config.php');
require_once($_SERVER['DOCUMENT_ROOT'] . $folder . '/wp-load.php');
if (!$wpdb) {
$wpdb = new wpdb( DB_USER, DB_PASSWORD, DB_NAME, DB_HOST);
} else {
... | This is a [PHP variable scope](http://php.net/manual/en/language.variables.scope.php) issue, there is no `$wpdb` defined in your function.
Add
```
global $wpdb;
```
before trying to use the `$wpdb` object. |
167,402 | <p>I want to disable <strong>all</strong> TinyMCE 4 keyboard shortcuts. I have looked around for a workable solution but only realised how poor the TinyMCE documentation is. </p>
<p>I did find one <a href="https://wordpress.stackexchange.com/a/38313/24875">answer here</a> but either I do not know how to apply it or it... | [
{
"answer_id": 168044,
"author": "bonger",
"author_id": 57034,
"author_profile": "https://wordpress.stackexchange.com/users/57034",
"pm_score": 2,
"selected": false,
"text": "<p><strong>Re <a href=\"https://wordpress.stackexchange.com/a/38313\">answer</a> cited by the OP:</strong></p>\n\... | 2014/11/04 | [
"https://wordpress.stackexchange.com/questions/167402",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63034/"
] | I want to disable **all** TinyMCE 4 keyboard shortcuts. I have looked around for a workable solution but only realised how poor the TinyMCE documentation is.
I did find one [answer here](https://wordpress.stackexchange.com/a/38313/24875) but either I do not know how to apply it or it doesn't work with TinyMCE 4 (that... | **Re [answer](https://wordpress.stackexchange.com/a/38313) cited by the OP:**
**Edited to add meta and access and other.**
The `custom_shortcuts` flags mentioned was in tinymce 3.x (see [here](http://www.tinymce.com/wiki.php/Configuration3x:custom_shortcuts)) but was removed from 4.x, and on scanning the source nothi... |
167,407 | <p>I'm new to wordpress. I'm writing my first plugin. I don't understand how to have my function run only after submitting the login form while not running every time I refresh the login page. I tried with authenticate filter. But my function runs every time I refresh the login page. </p>
<p>I don't understand why aut... | [
{
"answer_id": 167429,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>The filter runs on every page load, but the first argument will be a <code>WP_User</code> object only on successfu... | 2014/11/04 | [
"https://wordpress.stackexchange.com/questions/167407",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63037/"
] | I'm new to wordpress. I'm writing my first plugin. I don't understand how to have my function run only after submitting the login form while not running every time I refresh the login page. I tried with authenticate filter. But my function runs every time I refresh the login page.
I don't understand why authenticatio... | The filter runs on every page load, but the first argument will be a `WP_User` object only on successful submission. It will be `null` if nothing was submitted, but most likely it will be a [`WP_Error`](http://codex.wordpress.org/Class_Reference/WP_Error) object, which [you can check for](http://codex.wordpress.org/Fun... |
167,430 | <p>I have a class for handling customizer code, where I am adding a lot of color options. I have trimmed a bunch of repetitive parts out so it is not too long ;) My issue is I cannot figure out why the default settings do not appear to be being set, but only on front end. If I open in the customizer view, the live prev... | [
{
"answer_id": 167434,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 3,
"selected": false,
"text": "<p>There are two different defaults, and you're only using one of them.</p>\n\n<p>The default value that you set in t... | 2014/11/04 | [
"https://wordpress.stackexchange.com/questions/167430",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/20977/"
] | I have a class for handling customizer code, where I am adding a lot of color options. I have trimmed a bunch of repetitive parts out so it is not too long ;) My issue is I cannot figure out why the default settings do not appear to be being set, but only on front end. If I open in the customizer view, the live preview... | There are two different defaults, and you're only using one of them.
The default value that you set in the call to $wp\_customize->add\_setting is the default *for the customizer*. It does not apply outside of the customizer. The default here is what will be used if no setting exists in the database.
The second defau... |
167,441 | <p>I'm trying to sort a custom post type in ascending order (instead of the default descending). Registering the post type like so:</p>
<pre><code>function codex_custom_init() {
register_post_type(
'calendar', array(
'labels' => array('name' => __( 'Calendar' ), 'singular_name' => __( 'Calendar' ... | [
{
"answer_id": 167444,
"author": "Steven Jones",
"author_id": 24124,
"author_profile": "https://wordpress.stackexchange.com/users/24124",
"pm_score": 4,
"selected": true,
"text": "<p>You don't declare the order of the results when you register the post type. </p>\n\n<p>Instead, you do at... | 2014/11/04 | [
"https://wordpress.stackexchange.com/questions/167441",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28065/"
] | I'm trying to sort a custom post type in ascending order (instead of the default descending). Registering the post type like so:
```
function codex_custom_init() {
register_post_type(
'calendar', array(
'labels' => array('name' => __( 'Calendar' ), 'singular_name' => __( 'Calendar' ) ),
'public' => ... | You don't declare the order of the results when you register the post type.
Instead, you do at the time the results are requested. If you're using WP\_Query to get the results then you add your orderby and order arguments to the request.
<http://codex.wordpress.org/Class_Reference/WP_Query>
If you want to change th... |
167,449 | <p>I've just recently setup a new Wordpress site on a Debian based VPS. I've managed to get everything working fine except for the permalinks. None of the options work except for the default one.</p>
<p>My .htaccess file currently looks like this -</p>
<pre><code># BEGIN WordPress
<IfModule mod_rewrite.c>
Rewri... | [
{
"answer_id": 167462,
"author": "Omnikrys",
"author_id": 22666,
"author_profile": "https://wordpress.stackexchange.com/users/22666",
"pm_score": 2,
"selected": false,
"text": "<p>Have you tried something simple to ensure it is actually rewriting? Something like...</p>\n\n<pre><code>Rewr... | 2014/11/04 | [
"https://wordpress.stackexchange.com/questions/167449",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63049/"
] | I've just recently setup a new Wordpress site on a Debian based VPS. I've managed to get everything working fine except for the permalinks. None of the options work except for the default one.
My .htaccess file currently looks like this -
```
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
R... | Have you tried something simple to ensure it is actually rewriting? Something like...
```
RewriteEngine On
RewriteRule ^.*$ verified.php
```
Then create a verified.php page...
```
<?php
print 'mod_rewrite works!';
?>
```
Now you should hit that page no matter where you try to go on the site. If you don't mod\_rew... |
167,461 | <p>How can i get a list of all custom post types registered and show them on any template page.</p>
<p>I have code like this.</p>
<pre><code><?php
/**
* Template Name: Custom Post Types List
*/
get_header();
$args=array(
'public' => true,
'exclude_from_sea... | [
{
"answer_id": 225960,
"author": "Kamal Ahmed",
"author_id": 93685,
"author_profile": "https://wordpress.stackexchange.com/users/93685",
"pm_score": 4,
"selected": false,
"text": "<p>Your code looks good. However, you can try the followoing codes to get all custom posts \n \n\n<pre><c... | 2014/11/05 | [
"https://wordpress.stackexchange.com/questions/167461",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63060/"
] | How can i get a list of all custom post types registered and show them on any template page.
I have code like this.
```
<?php
/**
* Template Name: Custom Post Types List
*/
get_header();
$args=array(
'public' => true,
'exclude_from_search' => false,
'_... | Your code looks good. However, you can try the followoing codes to get all custom posts
```
$args = array(
'public' => true,
'_builtin' => false,
);
$output = 'names'; // names or objects, note names is the default
$operator = 'and'; // 'and' or 'or'
$post_types = get_post_types(... |
167,485 | <p>I have this simple code, but can't get the_content and the ACF-code to work together.</p>
<p>If I include the_content() it blocks out the ACF-code, but if I remove the_content() the ACF-code works fine. I suspect there's a very simple solution to this.</p>
<p>I've simplified and removed unnecessary elements from t... | [
{
"answer_id": 167490,
"author": "Ashok Kumar Nath",
"author_id": 43284,
"author_profile": "https://wordpress.stackexchange.com/users/43284",
"pm_score": 0,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code><?php\n $acf = false;\n while ( have_posts() ) : the_post();\n\... | 2014/11/05 | [
"https://wordpress.stackexchange.com/questions/167485",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59140/"
] | I have this simple code, but can't get the\_content and the ACF-code to work together.
If I include the\_content() it blocks out the ACF-code, but if I remove the\_content() the ACF-code works fine. I suspect there's a very simple solution to this.
I've simplified and removed unnecessary elements from the code below:... | Just for information, this is a bug in WP and autop. You can view the ticket [here](https://core.trac.wordpress.org/ticket/2691) and it does not look like it will be fixed any time soon. The work around is to start your multiline comment with `<!--` and end it with `<!-- -->` |
167,513 | <p>I want to change the default <strong>placeholder text</strong> in my Custom Post Type title field. This isn't possible while registering a new post type.</p>
<p>The following screenshot describes it.</p>
<p><img src="https://i.stack.imgur.com/CRsVm.png" alt="Screen from WP Admin"></p>
| [
{
"answer_id": 167514,
"author": "SLH",
"author_id": 45476,
"author_profile": "https://wordpress.stackexchange.com/users/45476",
"pm_score": -1,
"selected": false,
"text": "<pre><code>function change_default_title( $title ) {\n $screen = get_current_screen();\n\n // you can copy/pa... | 2014/11/05 | [
"https://wordpress.stackexchange.com/questions/167513",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45476/"
] | I want to change the default **placeholder text** in my Custom Post Type title field. This isn't possible while registering a new post type.
The following screenshot describes it.
 | I use a code which differs from yours a little bit. There is no need to get the current screen using the `enter_title_here`-filter because you have already a post-object:
```
/**
* Filter: Modifies the standard placeholder text
* @param string $title
* @param WP_Post $post
* @return string
*/
function my_enter_ti... |
167,534 | <p>I'm creating a theme based on the <a href="https://github.com/tlovett1/_s_backbone" rel="nofollow noreferrer">underscore theme with Backbone.js integration</a>. I am struggling to find any clear examples/documentation on the WP-API plugin's capabilities, and starting to find it fairly frustrating.</p>
<p>I am pullin... | [
{
"answer_id": 167526,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 2,
"selected": false,
"text": "<blockquote>\n <p>Grid of customer logos that link to their respective websites/success case posts. The site ... | 2014/11/05 | [
"https://wordpress.stackexchange.com/questions/167534",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23454/"
] | I'm creating a theme based on the [underscore theme with Backbone.js integration](https://github.com/tlovett1/_s_backbone). I am struggling to find any clear examples/documentation on the WP-API plugin's capabilities, and starting to find it fairly frustrating.
I am pulling in a basic list of posts using the following... | >
> Grid of customer logos that link to their respective websites/success case posts. The site owner should be able to add or remove these at ease.
>
>
>
Well I think the easiest way would to create a [Custom Post Type](http://codex.wordpress.org/Post_Types) called "Customer Logos". After that you could handle con... |
167,554 | <p>I need to auto-generate usernames upon WordPress registration. I have a custom registration form set up and would like to create the username in functions.php.</p>
<p>Can someone tell me why this isn't working? It seems like it should work after reading the <a href="http://codex.wordpress.org/Customizing_the_Regist... | [
{
"answer_id": 167555,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>You can alter user login via the <code>pre_user_login</code> filter. Note that this runs when the user is created ... | 2014/11/05 | [
"https://wordpress.stackexchange.com/questions/167554",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1462/"
] | I need to auto-generate usernames upon WordPress registration. I have a custom registration form set up and would like to create the username in functions.php.
Can someone tell me why this isn't working? It seems like it should work after reading the [WordPress Codex on customized registration forms](http://codex.word... | One alternative is to modify the `$_POST['user_login']` input value when submitting new registration form, that is before WP process the registration form. A good hook to achieve this is `login_form_register` that fires before processing and rendering registration form. `login_init` also works but need more work to mak... |
167,599 | <p>I want to retrieve the featured image of a post as an object (<code>array</code>) in order to have all image sizes available.</p>
<p>The <code>get_the_post_thumbnail()</code> function doesn't do this, any ideas?</p>
| [
{
"answer_id": 167600,
"author": "passatgt",
"author_id": 8038,
"author_profile": "https://wordpress.stackexchange.com/users/8038",
"pm_score": 4,
"selected": true,
"text": "<p>First get the registered image sizes and the featured image attachment id:</p>\n\n<pre><code>$sizes = get_inter... | 2014/11/06 | [
"https://wordpress.stackexchange.com/questions/167599",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3390/"
] | I want to retrieve the featured image of a post as an object (`array`) in order to have all image sizes available.
The `get_the_post_thumbnail()` function doesn't do this, any ideas? | First get the registered image sizes and the featured image attachment id:
```
$sizes = get_intermediate_image_sizes();
$post_thumbnail_id = get_post_thumbnail_id();
```
Loop through the registered sizes and create an array:
```
$images = array();
foreach ( $sizes as $size ) {
$images[] = wp_get_attachment_imag... |
167,610 | <p>I have this code to enqueue a script file when the page is not <code>single.php</code> (neither admin page):</p>
<pre><code>//functions.php
/********************** Add JS file **************************/
function my_own_scripts() {
if (! is_admin() && ! is_single()) {
wp_register_script( 'my_jav... | [
{
"answer_id": 167611,
"author": "Robert hue",
"author_id": 22461,
"author_profile": "https://wordpress.stackexchange.com/users/22461",
"pm_score": 0,
"selected": false,
"text": "<p>To exclude both of these pages/sections you will have to check if the conditions are met for individual se... | 2014/11/06 | [
"https://wordpress.stackexchange.com/questions/167610",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/36778/"
] | I have this code to enqueue a script file when the page is not `single.php` (neither admin page):
```
//functions.php
/********************** Add JS file **************************/
function my_own_scripts() {
if (! is_admin() && ! is_single()) {
wp_register_script( 'my_javascript_file',get_bloginfo('style... | With a couple minor modifications, I was able to run your function with your desired outcome (sitewide except on single post/cpt pages & in admin area).
The current preferred method of returning the stylesheet uri is with the `get_stylesheet_directory_uri()`, *not* by using `get_bloginfo('stylesheet_directory')`:
>
... |
167,620 | <p>I'm trying to learn if this is possible, and how I might go about implementing it. Our site is a scientific journal, and our published articles follow this permalink structure:</p>
<pre><code>http://ehponline.org/<article-slug>
i.e. http://ehponline.org/1306796
</code></pre>
<p>Every article that we publish ... | [
{
"answer_id": 167634,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>This seems like a suitable use case for <a href=\"http://codex.wordpress.org/Rewrite_API/add_rewrite_endpoint\" rel... | 2014/11/06 | [
"https://wordpress.stackexchange.com/questions/167620",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54061/"
] | I'm trying to learn if this is possible, and how I might go about implementing it. Our site is a scientific journal, and our published articles follow this permalink structure:
```
http://ehponline.org/<article-slug>
i.e. http://ehponline.org/1306796
```
Every article that we publish has a corresponding `PDF` that i... | Using [`add_rewrite_endpoint`](https://codex.wordpress.org/Rewrite_API/add_rewrite_endpoint)
```
<?php
if ( ! class_exists( 'PDFRewriteEndpoint' ) ):
class PDFRewriteEndpoint {
/**
* Add actions and filters in constructor.
*/
public function __construct() {
add_acti... |
167,635 | <p>I wish <code>pre_get_posts</code> to filter posts that appear in the <code>archive-events.php</code> and <code>taxonomy-eventcat.php</code> templates.</p>
<p>I have a <code>post_meta</code> in use named <code>o_event_start</code> that stores a value in <a href="http://dev.mysql.com/doc/refman/5.0/en/datetime.html" ... | [
{
"answer_id": 167636,
"author": "Marcin",
"author_id": 3768,
"author_profile": "https://wordpress.stackexchange.com/users/3768",
"pm_score": 1,
"selected": false,
"text": "<p>If you have store date different then timestamp it will be VERY hard to do this.</p>\n\n<p>To get this if is tim... | 2014/11/06 | [
"https://wordpress.stackexchange.com/questions/167635",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58040/"
] | I wish `pre_get_posts` to filter posts that appear in the `archive-events.php` and `taxonomy-eventcat.php` templates.
I have a `post_meta` in use named `o_event_start` that stores a value in [**DATETIME**](http://dev.mysql.com/doc/refman/5.0/en/datetime.html) (2014-12-31 21:30:00) *format* and I wish to show all event... | If you have store date different then timestamp it will be VERY hard to do this.
To get this if is timestamp stored, you need add "meta\_query" like this:
```
add_action('pre_get_posts', 'my_pre_get_posts');
function my_pre_get_posts($query)
{
$offest = 0;// you must count this to avoid today and tomorrow
$qu... |
167,653 | <p>I created a custom post type called "portfolio" for posts. When navigating to a post the URL shows as <code>www.mysite/?portfolio=some-post-title</code></p>
<p>In footer.php I want to display something only if the post has the post type "portfolio". How is this possible?</p>
<p>I also tried different options from ... | [
{
"answer_id": 167658,
"author": "at least three characters",
"author_id": 1613,
"author_profile": "https://wordpress.stackexchange.com/users/1613",
"pm_score": 2,
"selected": false,
"text": "<p>I found a good way to check using <code>is_singular( 'portfolio' )</code></p>\n"
},
{
... | 2014/11/06 | [
"https://wordpress.stackexchange.com/questions/167653",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1613/"
] | I created a custom post type called "portfolio" for posts. When navigating to a post the URL shows as `www.mysite/?portfolio=some-post-title`
In footer.php I want to display something only if the post has the post type "portfolio". How is this possible?
I also tried different options from <http://codex.wordpress.org/... | First, check your syntax and ensure any comparison operators, escapes, and quotes are correct, and the statements are written properly based on [the examples](http://codex.wordpress.org/Conditional_Tags#Working_Examples) given in the codex. [w3schools' PHP Tutorial](http://www.w3schools.com/php/php_syntax.asp) is a gre... |
167,667 | <p>I have specified a loop to show featured images for my custom post type and wish to add a img-responsive class from bootstrap to my featured image. </p>
<p>How can I do this?</p>
<p>Thanks!</p>
<p>Code:</p>
<pre><code><div class="home-featured-img">
<?php
if ( has_post_thumbnail() ) { // check... | [
{
"answer_id": 167669,
"author": "Eric Holmes",
"author_id": 23454,
"author_profile": "https://wordpress.stackexchange.com/users/23454",
"pm_score": 1,
"selected": false,
"text": "<p>The second argument of <a href=\"http://codex.wordpress.org/Function_Reference/the_post_thumbnail\" rel=\... | 2014/11/06 | [
"https://wordpress.stackexchange.com/questions/167667",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63089/"
] | I have specified a loop to show featured images for my custom post type and wish to add a img-responsive class from bootstrap to my featured image.
How can I do this?
Thanks!
Code:
```
<div class="home-featured-img">
<?php
if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to... | You can add custom class to post thumbnails. [the\_post\_thumbnail](http://codex.wordpress.org/Function_Reference/the_post_thumbnail) accepts array of attribute `$attr` where you can specify image class.
So your code will be.
```
<div class="home-featured-img">
<?php
if ( has_post_thumbnail() ) { // check... |
167,689 | <p>As a wordpress newbie I am having problems in adding custom meta box in my "slider" custom post type which I used in some old wp theme.</p>
<p>I'm getting a warning:</p>
<pre><code>Warning: call_user_func() expects parameter 1 to be a valid callback, function 'new_meta_box' not found or invalid function name in...... | [
{
"answer_id": 167692,
"author": "Jagankumar",
"author_id": 57118,
"author_profile": "https://wordpress.stackexchange.com/users/57118",
"pm_score": 0,
"selected": false,
"text": "<p>follow the stackexchange they will explained how you are going to create a meta boxes.</p>\n\n<p><a href=... | 2014/11/07 | [
"https://wordpress.stackexchange.com/questions/167689",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63089/"
] | As a wordpress newbie I am having problems in adding custom meta box in my "slider" custom post type which I used in some old wp theme.
I'm getting a warning:
```
Warning: call_user_func() expects parameter 1 to be a valid callback, function 'new_meta_box' not found or invalid function name in...
```
Here is my cod... | Hey Change Callback function to like this and add\_meta\_box to add\_meta\_boxes hook
```
function create_meta_box_slider() {
add_meta_box( 'new-meta-boxes-slider', __('slider Settings'), 'new_meta_box', 'slider', 'normal', 'high' );
}
add_action('add_meta_boxes', 'create_meta_box_slider');
function new_meta... |
167,695 | <p>I'm trying to modify a function in a plugin so that it only returns the custom post type (venues) of the user that’s logged in (by default it displays all venues). This is my first time customizing a function, so any help would be greatly appreciated!</p>
<p>This is what I've put into my functions.php file:</p>
<pre... | [
{
"answer_id": 167700,
"author": "dMcClintock",
"author_id": 47707,
"author_profile": "https://wordpress.stackexchange.com/users/47707",
"pm_score": 0,
"selected": false,
"text": "<p>Use <code>get_currentuserinfo();</code> to pull the current user's ID, then check it against <code>$post-... | 2014/11/07 | [
"https://wordpress.stackexchange.com/questions/167695",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54133/"
] | I'm trying to modify a function in a plugin so that it only returns the custom post type (venues) of the user that’s logged in (by default it displays all venues). This is my first time customizing a function, so any help would be greatly appreciated!
This is what I've put into my functions.php file:
```
global $curr... | See below for my version of what you are trying to do. However keep in mind that adding this function to your functions.php, and changing the plugin to point to this function, will produce an error that the function does not exist. This is because plugins are included before functions.php, so when the plugin loads your... |
167,704 | <p>I currently run on a VPS that is running the latest version of Ubuntu, PHP 5.5.9, and WP 4.0, and have been running my plugin upgrades through <code>libssh2</code> via a configuration in <code>wp-config.php</code> ever since I started working on this VPS, as WordPress is unable to open a connection automatically.</p... | [
{
"answer_id": 167700,
"author": "dMcClintock",
"author_id": 47707,
"author_profile": "https://wordpress.stackexchange.com/users/47707",
"pm_score": 0,
"selected": false,
"text": "<p>Use <code>get_currentuserinfo();</code> to pull the current user's ID, then check it against <code>$post-... | 2014/11/07 | [
"https://wordpress.stackexchange.com/questions/167704",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44216/"
] | I currently run on a VPS that is running the latest version of Ubuntu, PHP 5.5.9, and WP 4.0, and have been running my plugin upgrades through `libssh2` via a configuration in `wp-config.php` ever since I started working on this VPS, as WordPress is unable to open a connection automatically.
However, within the past w... | See below for my version of what you are trying to do. However keep in mind that adding this function to your functions.php, and changing the plugin to point to this function, will produce an error that the function does not exist. This is because plugins are included before functions.php, so when the plugin loads your... |
167,720 | <p>I am using thesis in wordpress 4.1 i am trying to display related post by category with bellow function
but when i go to the post detail page it throws internal server error.i have used same code in another website and the code is working good on that site and each word of code is same on both site i am stucked her... | [
{
"answer_id": 167961,
"author": "H. Guerrero cruzgloriosa.org",
"author_id": 63271,
"author_profile": "https://wordpress.stackexchange.com/users/63271",
"pm_score": -1,
"selected": false,
"text": "<p>Check <a href=\"http://www.wpthesisskins.com/free-thesis-related-post-box-for-thesis-th... | 2014/11/07 | [
"https://wordpress.stackexchange.com/questions/167720",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39122/"
] | I am using thesis in wordpress 4.1 i am trying to display related post by category with bellow function
but when i go to the post detail page it throws internal server error.i have used same code in another website and the code is working good on that site and each word of code is same on both site i am stucked here i... | I have sorted this issue i was tested this code on our test server and
i saw error on post detail page the error was `Fatal error: Call to undefined function short_title()`
after seen this i have remove the function code `short_title();` from my `custom.php` and replace with `the_title();` to display tittle.And i h... |
167,736 | <p>I want to delete old favicon and replace new favicon in my wordpress website.</p>
<p>Please suggest, which file name and where code that I need to add new favicon.ico in my wordpress website?</p>
| [
{
"answer_id": 167738,
"author": "Jbbhatti",
"author_id": 63179,
"author_profile": "https://wordpress.stackexchange.com/users/63179",
"pm_score": 2,
"selected": false,
"text": "<p>Here are <a href=\"http://codex.wordpress.org/Creating_a_Favicon#Installing_a_Favicon_in_WordPress\" rel=\"n... | 2014/11/07 | [
"https://wordpress.stackexchange.com/questions/167736",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63178/"
] | I want to delete old favicon and replace new favicon in my wordpress website.
Please suggest, which file name and where code that I need to add new favicon.ico in my wordpress website? | Here are [the instructions from the WordPress Codex](http://codex.wordpress.org/Creating_a_Favicon#Installing_a_Favicon_in_WordPress):
1. Go to your WordPress Administration Panel.
2. Click on Appearance.
3. Click on Theme Editor.
4. Select the file called Header or header.php to edit the file.
5. Search for the line ... |
167,740 | <p>Can anyone spot anything wrong with this code(see below). No content is showing up on my page. Many thanks in advance.</p>
<pre><code><?php
$args = array(
'posts_per_page' => 3,
'orderby' => 'rand',
'category_name' => 'testimonials'
);
$query = new WP_Query( $args );
//... | [
{
"answer_id": 167747,
"author": "dswebsme",
"author_id": 62906,
"author_profile": "https://wordpress.stackexchange.com/users/62906",
"pm_score": 2,
"selected": true,
"text": "<p>There aren't any errors in your code. I'm able to copy / paste it into functions.php and return 3 posts categ... | 2014/11/07 | [
"https://wordpress.stackexchange.com/questions/167740",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52272/"
] | Can anyone spot anything wrong with this code(see below). No content is showing up on my page. Many thanks in advance.
```
<?php
$args = array(
'posts_per_page' => 3,
'orderby' => 'rand',
'category_name' => 'testimonials'
);
$query = new WP_Query( $args );
// The Loop
if ( $qu... | There aren't any errors in your code. I'm able to copy / paste it into functions.php and return 3 posts categorized under "testimonials" without issue.
By default this WP\_Query will retrieve only 'post' matches so if you are using pages or a custom post type you'll need to specify that in your query args as:
`$args[... |
167,742 | <p>I made a Template page <code>galerie.php</code> and I wanted to show posts there.</p>
<p>Why isn't this working? It seems that posts only appear at <code>home page</code> for some reason.</p>
<p>The code is:</p>
<pre><code><?php while(have_posts()) : the_post() ?>
<div id="owl-images" class="owl-ca... | [
{
"answer_id": 167747,
"author": "dswebsme",
"author_id": 62906,
"author_profile": "https://wordpress.stackexchange.com/users/62906",
"pm_score": 2,
"selected": true,
"text": "<p>There aren't any errors in your code. I'm able to copy / paste it into functions.php and return 3 posts categ... | 2014/11/07 | [
"https://wordpress.stackexchange.com/questions/167742",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63177/"
] | I made a Template page `galerie.php` and I wanted to show posts there.
Why isn't this working? It seems that posts only appear at `home page` for some reason.
The code is:
```
<?php while(have_posts()) : the_post() ?>
<div id="owl-images" class="owl-carousel">
<a href="<?php the_post_thumbnail() ?>" da... | There aren't any errors in your code. I'm able to copy / paste it into functions.php and return 3 posts categorized under "testimonials" without issue.
By default this WP\_Query will retrieve only 'post' matches so if you are using pages or a custom post type you'll need to specify that in your query args as:
`$args[... |
167,753 | <p>I want to retrieve the content of posts within a foreach loop.</p>
<pre><code> $recent_posts = wp_get_recent_posts();
$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
$content = apply_filters( 'the_content', get_the_content() );
$content = str_replace( ']]>', ']... | [
{
"answer_id": 167747,
"author": "dswebsme",
"author_id": 62906,
"author_profile": "https://wordpress.stackexchange.com/users/62906",
"pm_score": 2,
"selected": true,
"text": "<p>There aren't any errors in your code. I'm able to copy / paste it into functions.php and return 3 posts categ... | 2014/11/07 | [
"https://wordpress.stackexchange.com/questions/167753",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49869/"
] | I want to retrieve the content of posts within a foreach loop.
```
$recent_posts = wp_get_recent_posts();
$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
$content = apply_filters( 'the_content', get_the_content() );
$content = str_replace( ']]>', ']]>', $content );
... | There aren't any errors in your code. I'm able to copy / paste it into functions.php and return 3 posts categorized under "testimonials" without issue.
By default this WP\_Query will retrieve only 'post' matches so if you are using pages or a custom post type you'll need to specify that in your query args as:
`$args[... |
167,780 | <p>I have a weird issue: I changed my timezone, hit "Save," and was immediately logged out of the admin panel. Now every time I try to access the dashboard after logging in I'm immediately logged out.</p>
<p>My editor has not been effected by this—apparently it's only my account.</p>
<p>I've searched Google, the Word... | [
{
"answer_id": 167783,
"author": "Jimtrim",
"author_id": 59213,
"author_profile": "https://wordpress.stackexchange.com/users/59213",
"pm_score": 1,
"selected": false,
"text": "<p>This may be because of the way Wordpress handles logins with cookies. Have you tried deleting your cookies an... | 2014/11/07 | [
"https://wordpress.stackexchange.com/questions/167780",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43552/"
] | I have a weird issue: I changed my timezone, hit "Save," and was immediately logged out of the admin panel. Now every time I try to access the dashboard after logging in I'm immediately logged out.
My editor has not been effected by this—apparently it's only my account.
I've searched Google, the WordPress.org support... | I've found the problem. It's a plugin called [iThemes Security](https://ithemes.com/purchase/ithemes-security-pro/).
Here's what I did to figure it out:
1. I renamed my `plugins` folder `plugins_old`—and the website started working.
2. I created a new, empty `plugins` folder.
3. I moved each plugin back into the `plu... |
167,801 | <p>I am trying to set up a login system and Contact form for Fornt End Users of my Custom WP Theme. I need to create some Ajax Post method and Send the input values to server like Captcha and User Inputs values like captcha, name, phone, email, ... Now my question is, do I have to create PHP Session to secure unwanted ... | [
{
"answer_id": 167812,
"author": "Hybrid Web Dev",
"author_id": 36506,
"author_profile": "https://wordpress.stackexchange.com/users/36506",
"pm_score": 2,
"selected": false,
"text": "<p>Sessions are basically useful for having data persist between pages. </p>\n\n<p>If you're using ajax c... | 2014/11/07 | [
"https://wordpress.stackexchange.com/questions/167801",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26628/"
] | I am trying to set up a login system and Contact form for Fornt End Users of my Custom WP Theme. I need to create some Ajax Post method and Send the input values to server like Captcha and User Inputs values like captcha, name, phone, email, ... Now my question is, do I have to create PHP Session to secure unwanted for... | Yes, you can but you will get errors about the header already being sent unless you hook into init or admin\_init (or elsewhere prior to the headers being sent). I haven't tested it, but you may be able to hook your session function into the `send_headers` action[1](http://codex.wordpress.org/Plugin_API/Action_Referenc... |
167,820 | <p>I created my first plugin last week that makes a custom post type. As this worked, I copy pasted the code I already had and modified it to be a different post type. For whatever reason however, the callback I have set for add_meta_box is not being called. Can anyone tell me why this is, where I have looked it over r... | [
{
"answer_id": 167825,
"author": "Matt Keys",
"author_id": 32799,
"author_profile": "https://wordpress.stackexchange.com/users/32799",
"pm_score": 3,
"selected": true,
"text": "<p>Looks like we both missed the error because I didn't see it at first either.</p>\n\n<p>In your call to add_m... | 2014/11/08 | [
"https://wordpress.stackexchange.com/questions/167820",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40950/"
] | I created my first plugin last week that makes a custom post type. As this worked, I copy pasted the code I already had and modified it to be a different post type. For whatever reason however, the callback I have set for add\_meta\_box is not being called. Can anyone tell me why this is, where I have looked it over re... | Looks like we both missed the error because I didn't see it at first either.
In your call to add\_meta\_box you skipped the argument for context and went straight to priority. "high" is not an available string for the context argument, and this apparently causes the function to silently fail.
Adding in the string for... |
167,837 | <p>I'm looking for a way to list all the terms from a custom taxonomy. Only the terms that have posts attached to it should have links to the archive page. If there are no posts attached it should only show the names.</p>
<p>Any ideas? Thanks!</p>
<pre><code><?php
$taxonomy = 'cat';
$queried_term = get_term_by( 's... | [
{
"answer_id": 167839,
"author": "SLH",
"author_id": 45476,
"author_profile": "https://wordpress.stackexchange.com/users/45476",
"pm_score": 3,
"selected": false,
"text": "<p>I didn't understood your question well, but try this. Explanation is in the comments.</p>\n\n<pre><code>// your t... | 2014/11/08 | [
"https://wordpress.stackexchange.com/questions/167837",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63214/"
] | I'm looking for a way to list all the terms from a custom taxonomy. Only the terms that have posts attached to it should have links to the archive page. If there are no posts attached it should only show the names.
Any ideas? Thanks!
```
<?php
$taxonomy = 'cat';
$queried_term = get_term_by( 'slug', get_query_var($tax... | I didn't understood your question well, but try this. Explanation is in the comments.
```
// your taxonomy name
$tax = 'post_tag';
// get the terms of taxonomy
$terms = get_terms( $tax, [
'hide_empty' => false, // do not hide empty terms
]);
// loop through all terms
foreach( $terms as $term ) {
// if no entrie... |
167,847 | <p>I have a default theme. When i add media to wordpress site. By default it use simple "a href" tag I want to add attribute "rel=nofollow" to it. Can anybody please point me in right direction?.</p>
| [
{
"answer_id": 167873,
"author": "josh",
"author_id": 24323,
"author_profile": "https://wordpress.stackexchange.com/users/24323",
"pm_score": 2,
"selected": true,
"text": "<p>You need to hook into the <a href=\"https://developer.wordpress.org/reference/hooks/image_send_to_editor/\" rel=\... | 2014/11/08 | [
"https://wordpress.stackexchange.com/questions/167847",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63218/"
] | I have a default theme. When i add media to wordpress site. By default it use simple "a href" tag I want to add attribute "rel=nofollow" to it. Can anybody please point me in right direction?. | You need to hook into the [image\_send\_to\_editor](https://developer.wordpress.org/reference/hooks/image_send_to_editor/) filter. This allows you to modify the markup used when inserting an image into the content editor.
Something like this should work:
```
add_filter('image_send_to_editor', 'my_add_rel_nofollow', 1... |
167,849 | <p>I am trying to get a simple php function working with cron (based on a tutorial). I have the following:</p>
<pre><code><?php if (!wp_next_scheduled('please_just_work')) {
wp_schedule_event( time(), 'daily', 'please_just_work' );
}
add_action ( 'please_just_work', 'my_task_function' );
function my_task_function(... | [
{
"answer_id": 167853,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>The <code>print()</code> output string into current page view. But in the case of the WP cron you <em>never see</em... | 2014/11/08 | [
"https://wordpress.stackexchange.com/questions/167849",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58166/"
] | I am trying to get a simple php function working with cron (based on a tutorial). I have the following:
```
<?php if (!wp_next_scheduled('please_just_work')) {
wp_schedule_event( time(), 'daily', 'please_just_work' );
}
add_action ( 'please_just_work', 'my_task_function' );
function my_task_function() {
$test_score ... | Looking at your function:
```
function my_task_function() {
$test_score
update_field('score', $test_score );
}
```
$test\_score is not defined here, it should be $test\_score = 'something'; Left the way you have it now will generate php warnings.
Also the update\_field function used in this context (in a c... |
167,866 | <p>I have added custom WordPress admin menu and pages, however, I would like for it to appear in the "Appearance > Menus" section so that the user can add it in the menu structure of their website.</p>
<p>Please let me know how to achieve this.</p>
<p>Here are the sample custom menu I added on the admin page:
<img sr... | [
{
"answer_id": 167853,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>The <code>print()</code> output string into current page view. But in the case of the WP cron you <em>never see</em... | 2014/11/08 | [
"https://wordpress.stackexchange.com/questions/167866",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62215/"
] | I have added custom WordPress admin menu and pages, however, I would like for it to appear in the "Appearance > Menus" section so that the user can add it in the menu structure of their website.
Please let me know how to achieve this.
Here are the sample custom menu I added on the admin page:
![enter image descriptio... | Looking at your function:
```
function my_task_function() {
$test_score
update_field('score', $test_score );
}
```
$test\_score is not defined here, it should be $test\_score = 'something'; Left the way you have it now will generate php warnings.
Also the update\_field function used in this context (in a c... |
167,898 | <p>I normally use this argument to prevent errors with <a href="http://codex.wordpress.org/Function_Reference/wp_remote_get" rel="noreferrer"><code>wp_remote_get</code></a> and <a href="http://codex.wordpress.org/Function_Reference/wp_remote_post" rel="noreferrer"><code>wp_remote_post</code></a></p>
<pre><code>array(
... | [
{
"answer_id": 167906,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>WordPress can rely on underlying server software (typically cURL) to perform network request. In a nutshell because... | 2014/11/09 | [
"https://wordpress.stackexchange.com/questions/167898",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/18981/"
] | I normally use this argument to prevent errors with [`wp_remote_get`](http://codex.wordpress.org/Function_Reference/wp_remote_get) and [`wp_remote_post`](http://codex.wordpress.org/Function_Reference/wp_remote_post)
```
array(
'sslverify' => false
)
```
For security reasons I would like to set it to `true` (or r... | TL;DR: Yes, remove that setting as of WordPress 3.7 or later.
In the past, many people added the sslverify=false parameter specifically because their installation of PHP was unable to properly verify the certificate.
Typically, this was because the PHP install had not been updated with the latest copy of the CA Root... |
167,944 | <p>I have a function set up to show 'Similar Products', i.e. showing products that share the same <code>products-category</code> taxonomy term. This works great but I want to narrow the function even further and make it more specific. Thus I want it to look at 2 taxonomies (<code>product-category</code> and <code>space... | [
{
"answer_id": 167949,
"author": "SLH",
"author_id": 45476,
"author_profile": "https://wordpress.stackexchange.com/users/45476",
"pm_score": 5,
"selected": true,
"text": "<p>First of all, get all term slugs from the custom taxonomy <code>space</code> by current post ID.</p>\n\n<pre><code... | 2014/11/09 | [
"https://wordpress.stackexchange.com/questions/167944",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28065/"
] | I have a function set up to show 'Similar Products', i.e. showing products that share the same `products-category` taxonomy term. This works great but I want to narrow the function even further and make it more specific. Thus I want it to look at 2 taxonomies (`product-category` and `space`) to find similar products. T... | First of all, get all term slugs from the custom taxonomy `space` by current post ID.
```
$space_terms = wp_get_post_terms( $post->ID, 'space' );
if( $space_terms ) {
$space_terms = array();
foreach( $space_terms as $term ) {
$space_terms[] = $term->slug;
}
}
```
You should specify the logical relationship ... |
167,948 | <p>I'm rather new to Wordpress and I've been looking around for an hour and a bit but cannot find what I'm looking for.</p>
<p>I want to add an "edit profile" button to the author page so the user can edit their personal information and I want to add a "blog post" button where the user can write their blog post, both ... | [
{
"answer_id": 167949,
"author": "SLH",
"author_id": 45476,
"author_profile": "https://wordpress.stackexchange.com/users/45476",
"pm_score": 5,
"selected": true,
"text": "<p>First of all, get all term slugs from the custom taxonomy <code>space</code> by current post ID.</p>\n\n<pre><code... | 2014/11/09 | [
"https://wordpress.stackexchange.com/questions/167948",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63265/"
] | I'm rather new to Wordpress and I've been looking around for an hour and a bit but cannot find what I'm looking for.
I want to add an "edit profile" button to the author page so the user can edit their personal information and I want to add a "blog post" button where the user can write their blog post, both through th... | First of all, get all term slugs from the custom taxonomy `space` by current post ID.
```
$space_terms = wp_get_post_terms( $post->ID, 'space' );
if( $space_terms ) {
$space_terms = array();
foreach( $space_terms as $term ) {
$space_terms[] = $term->slug;
}
}
```
You should specify the logical relationship ... |
167,978 | <p>I use <a href="https://wordpress.stackexchange.com/a/133527/25187">a function</a> in my theme that prevents upload of big size image files (thanks to @fischi), but I want to apply it <strong>strictly</strong> to .jpg/.jpeg files only, because it prevents to upload .pdf files too. How to adapt this function?</p>
<pr... | [
{
"answer_id": 167995,
"author": "Nikhil sHETH",
"author_id": 63288,
"author_profile": "https://wordpress.stackexchange.com/users/63288",
"pm_score": -1,
"selected": false,
"text": "<p>lurie add below condition...</p>\n\n<pre><code>if ( $type == $imagetype ) {\n// write code for reduce .... | 2014/11/10 | [
"https://wordpress.stackexchange.com/questions/167978",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25187/"
] | I use [a function](https://wordpress.stackexchange.com/a/133527/25187) in my theme that prevents upload of big size image files (thanks to @fischi), but I want to apply it **strictly** to .jpg/.jpeg files only, because it prevents to upload .pdf files too. How to adapt this function?
```
add_filter('wp_handle_upload_p... | I like to use the following:
First I initiate an array of supported mime types:
`$supportedTypes = array( 'application/pdf' );`
Next I get my actual uploaded file type:
`$fileType = $_FILES['type'][0]`
Then I use [`wp_check_filetype()`](http://codex.wordpress.org/Function_Reference/wp_check_filetype) to get the ex... |
167,982 | <p>I have a problem with making something like taxonomy filter.
My code is similar to this:</p>
<pre><code>$args = array(
'post_type' => 'post',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'movie_genre',
'field' => 'slug',
'terms' => array( 'a... | [
{
"answer_id": 167985,
"author": "Domain",
"author_id": 26523,
"author_profile": "https://wordpress.stackexchange.com/users/26523",
"pm_score": 1,
"selected": false,
"text": "<p>You would have to add the tax_query parameters depending on if the value is there in the GET parameters.</p>\n... | 2014/11/10 | [
"https://wordpress.stackexchange.com/questions/167982",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/62891/"
] | I have a problem with making something like taxonomy filter.
My code is similar to this:
```
$args = array(
'post_type' => 'post',
'tax_query' => array(
'relation' => 'AND',
array(
'taxonomy' => 'movie_genre',
'field' => 'slug',
'terms' => array( 'action', 'comedy' ),
),
a... | You would have to add the tax\_query parameters depending on if the value is there in the GET parameters.
So it would be something like this,
```
$args = array(
'post_type' => 'post',
'tax_query' => array( 'relation' => 'AND', ) );
$car = $_GET["car"];
if(!empty($car)){
array_push(
... |
167,988 | <pre><code><?php
// Silence is golden.
</code></pre>
<p>The folder is <code>../wp-content/index.php</code></p>
<p>Why have this file. What's the purpose?</p>
<p>I suppose it's in order to avoid invalid visit.</p>
<p>But why?</p>
| [
{
"answer_id": 167996,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 6,
"selected": true,
"text": "<p>Try to visit through the folder structure of your site from the browser:</p>\n\n<pre><code>http://examp... | 2014/11/10 | [
"https://wordpress.stackexchange.com/questions/167988",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63273/"
] | ```
<?php
// Silence is golden.
```
The folder is `../wp-content/index.php`
Why have this file. What's the purpose?
I suppose it's in order to avoid invalid visit.
But why? | Try to visit through the folder structure of your site from the browser:
```
http://example.com/wp-content/
```
You will see a blank page. That's actually is the `index.php`, and its content is very simple - a commented out PHP comment:
```
<?php
// Silence is golden.
```
Remove the file and visit the URL again. ... |
167,997 | <p>I'm using custom post types and custom fields plugins for my custom post types. </p>
<p>I have all other paginations working smoothly on my website except for my single.php. I have a custom post type of "Products" with dozens of products assigned to a custom taxonomy of "Types" and so far I've gotten all of the pag... | [
{
"answer_id": 168000,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 3,
"selected": true,
"text": "<p>You will need to add <code>%link</code> to the first parameter (<code>$format</code>) of <a href=\"http:... | 2014/11/10 | [
"https://wordpress.stackexchange.com/questions/167997",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63171/"
] | I'm using custom post types and custom fields plugins for my custom post types.
I have all other paginations working smoothly on my website except for my single.php. I have a custom post type of "Products" with dozens of products assigned to a custom taxonomy of "Types" and so far I've gotten all of the pagination on... | You will need to add `%link` to the first parameter (`$format`) of [`next_post_link`](http://codex.wordpress.org/Function_Reference/next_post_link) and [`previous_post_link`](http://codex.wordpress.org/Function_Reference/previous_post_link)
This will generate the html links to the respective posts
**EDIT 1**
Just on... |
168,022 | <p>I have a function set up that prints the taxonomy term name and slug for every <code>products-category</code> taxonomy term present. This works great, but it's just displaying them alphabetically like so (regardless of if they are a parent / child taxonomy term):</p>
<pre><code>Parent Category 2
Parent Category 1
C... | [
{
"answer_id": 168024,
"author": "SLH",
"author_id": 45476,
"author_profile": "https://wordpress.stackexchange.com/users/45476",
"pm_score": 4,
"selected": true,
"text": "<p>You should have two foreach loops. One for getting parent taxonomy terms, and second for getting child taxonomy te... | 2014/11/10 | [
"https://wordpress.stackexchange.com/questions/168022",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28065/"
] | I have a function set up that prints the taxonomy term name and slug for every `products-category` taxonomy term present. This works great, but it's just displaying them alphabetically like so (regardless of if they are a parent / child taxonomy term):
```
Parent Category 2
Parent Category 1
Child Category 3
Parent Ca... | You should have two foreach loops. One for getting parent taxonomy terms, and second for getting child taxonomy terms.
In the second foreach you need to specify the parent taxonomy term ID which is `$parent_term->term_id` from the first foreach loop.
```
foreach( get_terms( 'products-category', array( 'hide_empty' =>... |
168,023 | <p>I'm having a terrible time trying to figure this out.</p>
<p>I've registered a custom taxonomy (clinical-programs) and like to list all the PAGES that are assigned to particular page(s).</p>
<p><img src="https://i.stack.imgur.com/U1Zos.jpg" alt="enter image description here"></p>
| [
{
"answer_id": 168027,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>list all the PAGES that are assigned to particular page(s).</p>\n</blockquote>\n\n<p>I'm as... | 2014/11/10 | [
"https://wordpress.stackexchange.com/questions/168023",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40723/"
] | I'm having a terrible time trying to figure this out.
I've registered a custom taxonomy (clinical-programs) and like to list all the PAGES that are assigned to particular page(s).
 | Thank you for answering!. I was looking for a more complete solution. I figured it out.
```
echo '<div class="row profiles">';
$terms = get_terms("clinical-programs");
if ( !empty( $terms ) && !is_wp_error( $terms ) ){
foreach ( $terms as $term ) {
//View faculty member by clinic... |
168,059 | <p>I am developing my first WP theme and would like to know how to display page name for every page/post instead of just "mysiteaddress.com"</p>
<p>How can I set that all my posts and pages show the tittle by default?</p>
| [
{
"answer_id": 168027,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>list all the PAGES that are assigned to particular page(s).</p>\n</blockquote>\n\n<p>I'm as... | 2014/11/10 | [
"https://wordpress.stackexchange.com/questions/168059",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63089/"
] | I am developing my first WP theme and would like to know how to display page name for every page/post instead of just "mysiteaddress.com"
How can I set that all my posts and pages show the tittle by default? | Thank you for answering!. I was looking for a more complete solution. I figured it out.
```
echo '<div class="row profiles">';
$terms = get_terms("clinical-programs");
if ( !empty( $terms ) && !is_wp_error( $terms ) ){
foreach ( $terms as $term ) {
//View faculty member by clinic... |
168,081 | <p>I have moved my wordpress site from Amazon AWS to bluehost with same domain.</p>
<ol>
<li>Setup and Map domain to bluehost.</li>
<li>Install wordpress</li>
<li>Copy plugin, uploads, and themes folder to new server</li>
<li>Dump db and import db</li>
</ol>
<p>After I load the site, everything is working fine but al... | [
{
"answer_id": 168027,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 1,
"selected": false,
"text": "<blockquote>\n <p>list all the PAGES that are assigned to particular page(s).</p>\n</blockquote>\n\n<p>I'm as... | 2014/11/11 | [
"https://wordpress.stackexchange.com/questions/168081",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29009/"
] | I have moved my wordpress site from Amazon AWS to bluehost with same domain.
1. Setup and Map domain to bluehost.
2. Install wordpress
3. Copy plugin, uploads, and themes folder to new server
4. Dump db and import db
After I load the site, everything is working fine but all featured image of the post are gone even I ... | Thank you for answering!. I was looking for a more complete solution. I figured it out.
```
echo '<div class="row profiles">';
$terms = get_terms("clinical-programs");
if ( !empty( $terms ) && !is_wp_error( $terms ) ){
foreach ( $terms as $term ) {
//View faculty member by clinic... |
168,087 | <p>I'm creating a plugin widget that does a different search from the normal default search widget. I copied the code from the default widget:</p>
<pre><code>class new_search extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'widget_search', 'descript... | [
{
"answer_id": 168172,
"author": "skim-",
"author_id": 25265,
"author_profile": "https://wordpress.stackexchange.com/users/25265",
"pm_score": 3,
"selected": false,
"text": "<p>You can hook into the 'get_search_form' action hook ( check out the \"last option\" part of the link below ). ... | 2014/11/11 | [
"https://wordpress.stackexchange.com/questions/168087",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63319/"
] | I'm creating a plugin widget that does a different search from the normal default search widget. I copied the code from the default widget:
```
class new_search extends WP_Widget {
function __construct() {
$widget_ops = array('classname' => 'widget_search', 'description' => __( "A sea... | You can hook into the 'get\_search\_form' action hook ( check out the "last option" part of the link below ). Set the priority high enough to override anything created in a theme.
A plugin could look like ( from the link below ):
```
function my_search_form( $form ) {
$form = '<form role="search" method="get" id=... |
168,114 | <p>Ok so I have a custom post type of "Products" and a custom taxonomy of "Types". Now in the types taxonomy I have dozens of categories and sub categories assigned to custom post types.</p>
<p>Custom Post Type Item: Blue Car</p>
<p>Categories assigned to car: Honda > Accord > LX</p>
<p>So what I am trying to achiev... | [
{
"answer_id": 168119,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>The functions you have tried are for terms <em>by themselves</em>, just existing in site.</p>\n\n<p>What you are lo... | 2014/11/11 | [
"https://wordpress.stackexchange.com/questions/168114",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63171/"
] | Ok so I have a custom post type of "Products" and a custom taxonomy of "Types". Now in the types taxonomy I have dozens of categories and sub categories assigned to custom post types.
Custom Post Type Item: Blue Car
Categories assigned to car: Honda > Accord > LX
So what I am trying to achieve is when I go to a spec... | *SIDENOTE: This function can be used even if have posts belongs to one taxonomy only. You don't need to have a post that belongs to two or more taxonomies within the same hierarchy. I have made this function very flexible*
It is always a problem for me to display a category list or term list for a post if the followin... |
168,131 | <p>I am using the plugin PHP Browser Detection and I want to achieve different menus for different devices. I have set them up called primary and mobile.</p>
<p>Now, I want to switch those on used device. Something like this I have done and it is working fine:</p>
<pre><code> if ( is_tablet() ) {
wp_nav_menu( ar... | [
{
"answer_id": 168119,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>The functions you have tried are for terms <em>by themselves</em>, just existing in site.</p>\n\n<p>What you are lo... | 2014/11/11 | [
"https://wordpress.stackexchange.com/questions/168131",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50311/"
] | I am using the plugin PHP Browser Detection and I want to achieve different menus for different devices. I have set them up called primary and mobile.
Now, I want to switch those on used device. Something like this I have done and it is working fine:
```
if ( is_tablet() ) {
wp_nav_menu( array('menu' => 'primar... | *SIDENOTE: This function can be used even if have posts belongs to one taxonomy only. You don't need to have a post that belongs to two or more taxonomies within the same hierarchy. I have made this function very flexible*
It is always a problem for me to display a category list or term list for a post if the followin... |
168,141 | <p>I am using the following code to create a Custom Post Type and a Custom Taxonomy:</p>
<pre><code>// Register Post Type
add_action( 'init', 'cptui_register_my_cpt_resource' );
function cptui_register_my_cpt_resource() {
register_post_type( 'resource', array(
'label' => 'Resources',
'descriptio... | [
{
"answer_id": 168119,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>The functions you have tried are for terms <em>by themselves</em>, just existing in site.</p>\n\n<p>What you are lo... | 2014/11/11 | [
"https://wordpress.stackexchange.com/questions/168141",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57258/"
] | I am using the following code to create a Custom Post Type and a Custom Taxonomy:
```
// Register Post Type
add_action( 'init', 'cptui_register_my_cpt_resource' );
function cptui_register_my_cpt_resource() {
register_post_type( 'resource', array(
'label' => 'Resources',
'description' => '',
... | *SIDENOTE: This function can be used even if have posts belongs to one taxonomy only. You don't need to have a post that belongs to two or more taxonomies within the same hierarchy. I have made this function very flexible*
It is always a problem for me to display a category list or term list for a post if the followin... |
168,146 | <p>Basically I want to be able to see the names of files on the front-end - not just templates e.g. category/page templates, but the actual theme files like header.php/sidebar.php/footer.php and so on. </p>
<p>So I think the problem is what I've found so far doesn't have the depth I need and only goes as far as tellin... | [
{
"answer_id": 168152,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p><code>get_header</code>, <code>get_footer</code>, and <code>get_sidebar</code> all have corresponding actions that... | 2014/11/11 | [
"https://wordpress.stackexchange.com/questions/168146",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/42783/"
] | Basically I want to be able to see the names of files on the front-end - not just templates e.g. category/page templates, but the actual theme files like header.php/sidebar.php/footer.php and so on.
So I think the problem is what I've found so far doesn't have the depth I need and only goes as far as telling me what ... | PHP has a function, [`get_included_files()`](http://php.net/manual/en/function.get-included-files.php), that returns all the files that have been included during a request.
However, if you use that function you obtain **all** the files required: WordPress core files, plugin files...
You need a way to:
* Filter out f... |
168,161 | <p>I'm trying to intercept an image upload, resize it and then just let the upload continue.</p>
<p>I'm using the filter wp_handle_upload_prefilter that passes as an argument a single file $FILES array. </p>
<p>I load the image editor with wp_get_image_editor($file['tmp_name']), resize it and save it with a new name.... | [
{
"answer_id": 168164,
"author": "skim-",
"author_id": 25265,
"author_profile": "https://wordpress.stackexchange.com/users/25265",
"pm_score": 0,
"selected": false,
"text": "<p>This seems overly complex, when Wordpress offers a native function to add image sizes. I know that this adds a... | 2014/11/11 | [
"https://wordpress.stackexchange.com/questions/168161",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63355/"
] | I'm trying to intercept an image upload, resize it and then just let the upload continue.
I'm using the filter wp\_handle\_upload\_prefilter that passes as an argument a single file $FILES array.
I load the image editor with wp\_get\_image\_editor($file['tmp\_name']), resize it and save it with a new name. This all ... | I decided to approach it differently. Instead of hooking into 'wp\_handle\_upload\_prefilter' and tampering with the $file variable I decided to do the resize after the file is uploaded and after I get the attachment id like this:
```
public function resize_attachment($attachment_id, $width, $height) {
// Get fil... |
168,169 | <p>I'm using a custom Google search engine to display results on my site, rather than WordPress's built-in search functionality. I've done this by modifying our theme's search.php template to replace the standard loop with the code from Google. Everything is working swimmingly.</p>
<p>However, WordPress is still was... | [
{
"answer_id": 168170,
"author": "rfair404",
"author_id": 291,
"author_profile": "https://wordpress.stackexchange.com/users/291",
"pm_score": 0,
"selected": false,
"text": "<p>Many tutorials exist for disabling the search - see <a href=\"http://wpzine.com/disable-wordpress-search/\" rel=... | 2014/11/11 | [
"https://wordpress.stackexchange.com/questions/168169",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16666/"
] | I'm using a custom Google search engine to display results on my site, rather than WordPress's built-in search functionality. I've done this by modifying our theme's search.php template to replace the standard loop with the code from Google. Everything is working swimmingly.
However, WordPress is still wasting time/en... | Same issue with you and just found it out on stackexchange.
Put codes below in the function.php in your theme.
```
function _cancel_query( $query ) {
if ( !is_admin() && !is_feed() && is_search() ) {
$query = false;
}
return $query;
}
add_action( 'posts_request', '_cancel_query' );
```
Here's the... |