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 |
|---|---|---|---|---|---|---|
158,328 | <p>I'm wondering if you can help me work through an issue or provide alt ideas.</p>
<p>I have an archive displaying a list of custom tax terms in a grid view. </p>
<p>My client needs to be able to turn on/off the terms from displaying in the grid. If these were posts this would be easy because I could simply have hi... | [
{
"answer_id": 158331,
"author": "Taruc",
"author_id": 57268,
"author_profile": "https://wordpress.stackexchange.com/users/57268",
"pm_score": 2,
"selected": false,
"text": "<p>You might be able to accomplish this using Advanced Custom Fields: <a href=\"http://www.advancedcustomfields.co... | 2014/08/18 | [
"https://wordpress.stackexchange.com/questions/158328",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37657/"
] | I'm wondering if you can help me work through an issue or provide alt ideas.
I have an archive displaying a list of custom tax terms in a grid view.
My client needs to be able to turn on/off the terms from displaying in the grid. If these were posts this would be easy because I could simply have him check/uncheck a ... | I have found a solution. Thanks to @Tarukus as his answer was helpful. Again, my goal was to display terms (not posts) from my custom taxonomy via an on/off switch. To do this, I used Advanced Custom Fields and created a "Select" field with two values (on/off). Once this field was applied to my taxonomy I could select ... |
158,334 | <p>Is it possible to show all child/sub categories of all parent cats? I have the following hierarchy:</p>
<p>Parent Cat/Tax<br/>
-- Sub 1<br/>
-- Sub 2<br/>
Parent Cat/Tax 2<br/>
-- Sub 1<br/>
-- Sub 2<br/></p>
<p>I would like to be able to show all the child categories on one template without the parent showing as ... | [
{
"answer_id": 158335,
"author": "streetfire",
"author_id": 37657,
"author_profile": "https://wordpress.stackexchange.com/users/37657",
"pm_score": 0,
"selected": false,
"text": "<p>Well, I actually figured a way out. I don't have many parent categories so I added the following 'exclude'... | 2014/08/18 | [
"https://wordpress.stackexchange.com/questions/158334",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37657/"
] | Is it possible to show all child/sub categories of all parent cats? I have the following hierarchy:
Parent Cat/Tax
-- Sub 1
-- Sub 2
Parent Cat/Tax 2
-- Sub 1
-- Sub 2
I would like to be able to show all the child categories on one template without the parent showing as well. Is that possible? | To exclude parent categories from your term list, you can just pass over them after you have retrieved your term list with [`get_terms`](http://codex.wordpress.org/Function_Reference/get_terms)
Example:
```
<?php
$args = array(
'orderby' => 'name',
);
$terms = get_terms( 'mytaxname', $args );
if ( !empty( $terms... |
158,340 | <p>I have this custom post:</p>
<pre><code>add_action('init', 'eveniment_register');
function eveniment_register() {
$args = array(
'label' => __('Evenimente'),
'singular_label' => __('Eveniment'),
'public' => true,
'show_ui' => true,
'capability_type' => 'po... | [
{
"answer_id": 158335,
"author": "streetfire",
"author_id": 37657,
"author_profile": "https://wordpress.stackexchange.com/users/37657",
"pm_score": 0,
"selected": false,
"text": "<p>Well, I actually figured a way out. I don't have many parent categories so I added the following 'exclude'... | 2014/08/19 | [
"https://wordpress.stackexchange.com/questions/158340",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58117/"
] | I have this custom post:
```
add_action('init', 'eveniment_register');
function eveniment_register() {
$args = array(
'label' => __('Evenimente'),
'singular_label' => __('Eveniment'),
'public' => true,
'show_ui' => true,
'capability_type' => 'post',
'hierarchical' =... | To exclude parent categories from your term list, you can just pass over them after you have retrieved your term list with [`get_terms`](http://codex.wordpress.org/Function_Reference/get_terms)
Example:
```
<?php
$args = array(
'orderby' => 'name',
);
$terms = get_terms( 'mytaxname', $args );
if ( !empty( $terms... |
158,355 | <p>I'm trying to get a list of rows from the DB. All tables work except the one I need. No errors are thrown, don't even get a blank array. My SELECT statement works fine in phpmyadmin directly, but not through Wordpress. </p>
<p>Any ideas what might be going on? Its driving me nuts. </p>
<pre><code>$wpdb->get_res... | [
{
"answer_id": 158335,
"author": "streetfire",
"author_id": 37657,
"author_profile": "https://wordpress.stackexchange.com/users/37657",
"pm_score": 0,
"selected": false,
"text": "<p>Well, I actually figured a way out. I don't have many parent categories so I added the following 'exclude'... | 2014/08/19 | [
"https://wordpress.stackexchange.com/questions/158355",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24054/"
] | I'm trying to get a list of rows from the DB. All tables work except the one I need. No errors are thrown, don't even get a blank array. My SELECT statement works fine in phpmyadmin directly, but not through Wordpress.
Any ideas what might be going on? Its driving me nuts.
```
$wpdb->get_results("SELECT * FROM pro... | To exclude parent categories from your term list, you can just pass over them after you have retrieved your term list with [`get_terms`](http://codex.wordpress.org/Function_Reference/get_terms)
Example:
```
<?php
$args = array(
'orderby' => 'name',
);
$terms = get_terms( 'mytaxname', $args );
if ( !empty( $terms... |
158,364 | <p>In my plugin i'm using two ajax calls in back end. that worked well. but to provide the same functionality in front end i loaded the copy of these two functions with another names and my code is:</p>
<p>in my plugin main file:</p>
<pre><code>function my_action_callback(){
global $wpdb;
if (@$_POST['id']) {
... | [
{
"answer_id": 158378,
"author": "Nilambar Sharma",
"author_id": 27998,
"author_profile": "https://wordpress.stackexchange.com/users/27998",
"pm_score": 3,
"selected": true,
"text": "<p>You have to localize script by using <code>wp_localize_script</code> function. In the admin side <code... | 2014/08/19 | [
"https://wordpress.stackexchange.com/questions/158364",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40999/"
] | In my plugin i'm using two ajax calls in back end. that worked well. but to provide the same functionality in front end i loaded the copy of these two functions with another names and my code is:
in my plugin main file:
```
function my_action_callback(){
global $wpdb;
if (@$_POST['id']) {
$daty = $wpdb->get_r... | You have to localize script by using `wp_localize_script` function. In the admin side `ajaxurl` is already available. But in front end you have to localize script to define `ajaxurl`.
Example:
```
wp_enqueue_script( 'custom-ajax-request', '/path/to/settings.js', array( 'jquery' ) );
wp_localize_script( 'custom-ajax-r... |
158,398 | <p>I wanted to move jquery to the site's footer, but that doesn't work. I've tried it with the following code.</p>
<p>As you can see, I have a couple of another scripts and they load correctly on the footer. Only jquery won't work. </p>
<pre><code>//This adds our JavaScript Files
function wel_adding_scripts() {
wp_d... | [
{
"answer_id": 158400,
"author": "Tomás Cot",
"author_id": 57843,
"author_profile": "https://wordpress.stackexchange.com/users/57843",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"http://codex.wordpress.org/Function_Reference/wp_register_script#Notes\" rel=\"nofollow\">Here is... | 2014/08/19 | [
"https://wordpress.stackexchange.com/questions/158398",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/7688/"
] | I wanted to move jquery to the site's footer, but that doesn't work. I've tried it with the following code.
As you can see, I have a couple of another scripts and they load correctly on the footer. Only jquery won't work.
```
//This adds our JavaScript Files
function wel_adding_scripts() {
wp_deregister_script('jqu... | Note that if any script in the header at all needs jQuery then it will bump it to header, regardless if it's changed to be enqueued for footer.
So while changing it to be queued for footer makes sense it rarely works out when a lot of script stuff is going on. |
158,421 | <p><code>$user->user_registered</code> displays
"Registered since: 2014-08-18 07:25:22"</p>
<p>I just want to show the date, not the hour. How can I hide the hour and just show the date?</p>
<p>thank you</p>
| [
{
"answer_id": 158424,
"author": "Justin Carboneau",
"author_id": 58077,
"author_profile": "https://wordpress.stackexchange.com/users/58077",
"pm_score": 3,
"selected": true,
"text": "<p>You could just show the first 10 characters of the string, like:</p>\n\n<pre><code>echo substr($user-... | 2014/08/19 | [
"https://wordpress.stackexchange.com/questions/158421",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6927/"
] | `$user->user_registered` displays
"Registered since: 2014-08-18 07:25:22"
I just want to show the date, not the hour. How can I hide the hour and just show the date?
thank you | You could just show the first 10 characters of the string, like:
```
echo substr($user->user_registered, 0, 10);
``` |
158,443 | <p>I've been seeing a feature of one click demo content installation option on some powerful WordPress themes now a days. Mostly on Themeforest themes.</p>
<p>I'd like to know if anyone have any idea about the best way to implement this.
Or any other resources to do this.
Some hints, idea or keyword would be suffice.
... | [
{
"answer_id": 158701,
"author": "bootstrapguru",
"author_id": 57922,
"author_profile": "https://wordpress.stackexchange.com/users/57922",
"pm_score": 3,
"selected": false,
"text": "<p>if you check the Wordpress importer plugin it is easy to implement this feature. But if you want the di... | 2014/08/19 | [
"https://wordpress.stackexchange.com/questions/158443",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48345/"
] | I've been seeing a feature of one click demo content installation option on some powerful WordPress themes now a days. Mostly on Themeforest themes.
I'd like to know if anyone have any idea about the best way to implement this.
Or any other resources to do this.
Some hints, idea or keyword would be suffice.
I'm not as... | if you check the Wordpress importer plugin it is easy to implement this feature. But if you want the direct answer , here it is
First of all, we need to copy the Wordpress importer plugin files to our theme directory.
like this
```
1. themes/bootstrapguru_theme/inc/wordpress-importer.php
2. themes/bootstra... |
158,453 | <p>i need to exclude certain scripts from running on a certain page. i have tried this code but it's not working - when i inspect the page the scripts are still being loaded into the footer of my page. </p>
<p>here is my code in functions.php</p>
<pre><code>add_action( 'wp_enqueue_scripts', 'my_deregister_javascript... | [
{
"answer_id": 158458,
"author": "Steve Dimock",
"author_id": 31993,
"author_profile": "https://wordpress.stackexchange.com/users/31993",
"pm_score": 2,
"selected": false,
"text": "<p>I'd probably try only enqueueing those scripts on specific pages, rather than enqueuing and then dequeui... | 2014/08/19 | [
"https://wordpress.stackexchange.com/questions/158453",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8513/"
] | i need to exclude certain scripts from running on a certain page. i have tried this code but it's not working - when i inspect the page the scripts are still being loaded into the footer of my page.
here is my code in functions.php
```
add_action( 'wp_enqueue_scripts', 'my_deregister_javascript', 100 );
function my... | You have a basic mistake in your code. The following code
```
if ( !is_page('my-page') ) {
```
means that if you are **not** on that page, **deregister** the scripts. Have a look at the [php operators](http://www.w3schools.com/php/php_operators.asp)
>
>
> ```
> ! -> Not !$x True if $x is not true
>
> ```
>
>
... |
158,468 | <p>My site is made of "pages". Those page are static, but my team is going to modificated those pages frequently. I would like to have several authors and one editor.</p>
<p>The authors edit content, but cannot publish it.
The edito can edit content, but mainly validate and publish changes.</p>
<p>I was not able to d... | [
{
"answer_id": 158458,
"author": "Steve Dimock",
"author_id": 31993,
"author_profile": "https://wordpress.stackexchange.com/users/31993",
"pm_score": 2,
"selected": false,
"text": "<p>I'd probably try only enqueueing those scripts on specific pages, rather than enqueuing and then dequeui... | 2014/08/19 | [
"https://wordpress.stackexchange.com/questions/158468",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58010/"
] | My site is made of "pages". Those page are static, but my team is going to modificated those pages frequently. I would like to have several authors and one editor.
The authors edit content, but cannot publish it.
The edito can edit content, but mainly validate and publish changes.
I was not able to do that.
One more... | You have a basic mistake in your code. The following code
```
if ( !is_page('my-page') ) {
```
means that if you are **not** on that page, **deregister** the scripts. Have a look at the [php operators](http://www.w3schools.com/php/php_operators.asp)
>
>
> ```
> ! -> Not !$x True if $x is not true
>
> ```
>
>
... |
158,489 | <p>Let me start by saying that I have moved dozens of websites from one server to another, without issue.</p>
<p>I recently moved a website and when the URL is visited, a file named "download" with no extension and only a 1KB file size downloads automatically. I backed up all files and downloaded the databases using f... | [
{
"answer_id": 158505,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 5,
"selected": true,
"text": "<p>I guess you haven't taken a look at the file that is served for downloading, if so you would have se... | 2014/08/20 | [
"https://wordpress.stackexchange.com/questions/158489",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/14558/"
] | Let me start by saying that I have moved dozens of websites from one server to another, without issue.
I recently moved a website and when the URL is visited, a file named "download" with no extension and only a 1KB file size downloads automatically. I backed up all files and downloaded the databases using four differ... | I guess you haven't taken a look at the file that is served for downloading, if so you would have seen this:
```
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells W... |
158,510 | <p>I'm using the following code for comments pagination (based on 2014 theme)</p>
<pre><code><?php if( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : ?>
<ul class="pager">
<li class="previous">
<?php previous_comments_link( __( '&larr; Older Comments'... | [
{
"answer_id": 158505,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 5,
"selected": true,
"text": "<p>I guess you haven't taken a look at the file that is served for downloading, if so you would have se... | 2014/08/20 | [
"https://wordpress.stackexchange.com/questions/158510",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45476/"
] | I'm using the following code for comments pagination (based on 2014 theme)
```
<?php if( get_comment_pages_count() > 1 && get_option( 'page_comments' ) ) : ?>
<ul class="pager">
<li class="previous">
<?php previous_comments_link( __( '← Older Comments', '' ) ); ?>
</li>
<li class="next">
... | I guess you haven't taken a look at the file that is served for downloading, if so you would have seen this:
```
<?php
/**
* Front to the WordPress application. This file doesn't do anything, but loads
* wp-blog-header.php which does and tells WordPress to load the theme.
*
* @package WordPress
*/
/**
* Tells W... |
158,525 | <p><a href="http://html5doctor.com/block-level-links-in-html-5/" rel="nofollow noreferrer">Starting with version 5 the HTML standard allows <code><a></code> tags wrap block-level elements</a>. On a specific page I need to wrap a heading and an image with an <code><a></code> tag:</p>
<pre><code>Some intro t... | [
{
"answer_id": 158523,
"author": "Johannes Pille",
"author_id": 9745,
"author_profile": "https://wordpress.stackexchange.com/users/9745",
"pm_score": 1,
"selected": false,
"text": "<p>Your stylesheet(s) are not being loaded.</p>\n\n<ol>\n<li>Check your themes <em>header.php</em> and <em>... | 2014/08/20 | [
"https://wordpress.stackexchange.com/questions/158525",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51898/"
] | [Starting with version 5 the HTML standard allows `<a>` tags wrap block-level elements](http://html5doctor.com/block-level-links-in-html-5/). On a specific page I need to wrap a heading and an image with an `<a>` tag:
```
Some intro text.
<div>
<a href="http://somewhere/">
<h4>Some heading</h4>
<img src="ht... | Your stylesheet(s) are not being loaded.
1. Check your themes *header.php* and *functions.php* and adjust stylesheet paths
2. Do a hard refresh - Ctrl + F5 (CMD + F5 on Mac) |
158,532 | <p>I want my blog page to display 5 posts at most. But I have many custom queries (wp_query) on my site, some of them embedded together: how to make <code>Settings > Reading > Blog pages show at most</code> setting NOT affect my custom queries?</p>
| [
{
"answer_id": 158539,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 3,
"selected": true,
"text": "<p>If you're creating your own custom <code>WP_Query</code> queries, you can use the <code>posts_per_page</code> pa... | 2014/08/20 | [
"https://wordpress.stackexchange.com/questions/158532",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11634/"
] | I want my blog page to display 5 posts at most. But I have many custom queries (wp\_query) on my site, some of them embedded together: how to make `Settings > Reading > Blog pages show at most` setting NOT affect my custom queries? | If you're creating your own custom `WP_Query` queries, you can use the `posts_per_page` parameter:
```
$args = array(
// ...
'posts_per_page' => $some_number,
//...
);
$my_query = new WP_Query( $args );
```
If you want *all* the posts, use `-1` as your `$some_number`.
### Reference
* [WP\_Query » Pagi... |
158,549 | <p>I would like to create a conditional statement that checks the loop for a specific post ID, then if true, it outputs a link elsewhere.</p>
<p>This is what I have so far:</p>
<pre><code><?php query_posts('post_type=team&orderby=title&order=ASC'); ?>
<?php if ( have_posts() ) : while ( have_posts() ... | [
{
"answer_id": 158552,
"author": "Natasha Mcd",
"author_id": 57355,
"author_profile": "https://wordpress.stackexchange.com/users/57355",
"pm_score": 0,
"selected": false,
"text": "<p>@toscho was correct.</p>\n\n<p>I replaced this:</p>\n\n<pre><code><?php if ( is_singular( '2295' ) ) :... | 2014/08/20 | [
"https://wordpress.stackexchange.com/questions/158549",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57355/"
] | I would like to create a conditional statement that checks the loop for a specific post ID, then if true, it outputs a link elsewhere.
This is what I have so far:
```
<?php query_posts('post_type=team&orderby=title&order=ASC'); ?>
<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
<div class... | The reason why your check didn’t work is because `is_singular()` checks for **post types**, not for **post IDs**.
`is_singular( 'product' )` checks if the current post is of the type `product`, nothing else.
The comparison `2295 === get_the_ID()` does exactly what you need. |
158,575 | <p>I am trying to achieve pagination on a custom template I have that displays on an archive of terms. </p>
<p>It appears to be working because when I navigate to <code>mysite/taxonomy/page/2/</code> or 3,4,5 etc. the pagination works. It also shows the correct number of terms per page. However, there are not any actu... | [
{
"answer_id": 158588,
"author": "sakibmoon",
"author_id": 23214,
"author_profile": "https://wordpress.stackexchange.com/users/23214",
"pm_score": 0,
"selected": false,
"text": "<p>The problem is with <code>function_exists(\"pagination\")</code>. There is no function named pagination in ... | 2014/08/20 | [
"https://wordpress.stackexchange.com/questions/158575",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37657/"
] | I am trying to achieve pagination on a custom template I have that displays on an archive of terms.
It appears to be working because when I navigate to `mysite/taxonomy/page/2/` or 3,4,5 etc. the pagination works. It also shows the correct number of terms per page. However, there are not any actual pagination links s... | There where one or two problems with the code that I sorted out
**Big changes**
* `$number_of_terms = count( get_terms( '100list' ) );` is replaced by `$number_of_terms = wp_count_terms( '100list' );`. The reason is that [`wp_count_terms`](http://codex.wordpress.org/Function_Reference/wp_count_terms) is already there... |
158,594 | <p>I have found several tutorials how to add script to certain post type.like </p>
<pre><code>add_action( 'admin_print_scripts-post-new.php', 'banner_admin_script', 11 );
add_action( 'admin_print_scripts-post.php', 'banner_admin_script', 11 );
function banner_admin_script() {
global $post_type;
if( $post_type == 'memb... | [
{
"answer_id": 158596,
"author": "Nilambar Sharma",
"author_id": 27998,
"author_profile": "https://wordpress.stackexchange.com/users/27998",
"pm_score": 1,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code>if( in_array($post_type, array( 'members','post','testimonial' ) ) )\n w... | 2014/08/21 | [
"https://wordpress.stackexchange.com/questions/158594",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48294/"
] | I have found several tutorials how to add script to certain post type.like
```
add_action( 'admin_print_scripts-post-new.php', 'banner_admin_script', 11 );
add_action( 'admin_print_scripts-post.php', 'banner_admin_script', 11 );
function banner_admin_script() {
global $post_type;
if( $post_type == 'members' )
wp_en... | Try this:
```
if( in_array($post_type, array( 'members','post','testimonial' ) ) )
wp_enqueue_script( 'portfolio-admin-script', plugins_url( '/js/admin.js', __FILE__),'','', true);
}
```
Function `in_array` is used to check if current post type is in the array of allowed post types. |
158,622 | <p>Looking for some information as developer docs for the cherry framework seem to be non existent.</p>
<p>I am trying to add a custom post-type with the following code in my theme-init file:
(this code works fine in a standard installation used with a theme with the cherry framework it does not display i just get a 4... | [
{
"answer_id": 158596,
"author": "Nilambar Sharma",
"author_id": 27998,
"author_profile": "https://wordpress.stackexchange.com/users/27998",
"pm_score": 1,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code>if( in_array($post_type, array( 'members','post','testimonial' ) ) )\n w... | 2014/08/21 | [
"https://wordpress.stackexchange.com/questions/158622",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/13403/"
] | Looking for some information as developer docs for the cherry framework seem to be non existent.
I am trying to add a custom post-type with the following code in my theme-init file:
(this code works fine in a standard installation used with a theme with the cherry framework it does not display i just get a 404 error)
... | Try this:
```
if( in_array($post_type, array( 'members','post','testimonial' ) ) )
wp_enqueue_script( 'portfolio-admin-script', plugins_url( '/js/admin.js', __FILE__),'','', true);
}
```
Function `in_array` is used to check if current post type is in the array of allowed post types. |
158,634 | <p>I want to list all users who registered in between the $start_date and $end_date.I have written a metaquery,but it returns empty.Please help.</p>
<pre><code>$start_date = 2014-08-16 09:28:17
$end_date = 2015-08-16 09:28:17
$current_user_id = get_current_user_id();
$args = array(
'meta_query' =&... | [
{
"answer_id": 158596,
"author": "Nilambar Sharma",
"author_id": 27998,
"author_profile": "https://wordpress.stackexchange.com/users/27998",
"pm_score": 1,
"selected": false,
"text": "<p>Try this:</p>\n\n<pre><code>if( in_array($post_type, array( 'members','post','testimonial' ) ) )\n w... | 2014/08/21 | [
"https://wordpress.stackexchange.com/questions/158634",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49161/"
] | I want to list all users who registered in between the $start\_date and $end\_date.I have written a metaquery,but it returns empty.Please help.
```
$start_date = 2014-08-16 09:28:17
$end_date = 2015-08-16 09:28:17
$current_user_id = get_current_user_id();
$args = array(
'meta_query' => array(
... | Try this:
```
if( in_array($post_type, array( 'members','post','testimonial' ) ) )
wp_enqueue_script( 'portfolio-admin-script', plugins_url( '/js/admin.js', __FILE__),'','', true);
}
```
Function `in_array` is used to check if current post type is in the array of allowed post types. |
158,654 | <p>I want to get the latest titles with the_title() in an array so that I can loop through them in my javascript function. </p>
<p>How can I create this array?</p>
<p>Many thanks!</p>
| [
{
"answer_id": 158655,
"author": "Tomás Cot",
"author_id": 57843,
"author_profile": "https://wordpress.stackexchange.com/users/57843",
"pm_score": 0,
"selected": false,
"text": "<p>You could use <a href=\"http://codex.wordpress.org/Template_Tags/get_posts\" rel=\"nofollow\"><code>get_pos... | 2014/08/21 | [
"https://wordpress.stackexchange.com/questions/158654",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58117/"
] | I want to get the latest titles with the\_title() in an array so that I can loop through them in my javascript function.
How can I create this array?
Many thanks! | You can use the WordPress function **wp\_get\_recent\_posts()**, with required args.
```
$output = array();
$args = array(
'numberposts' => 10,
'offset' => 0,
'category' => 0,
'orderby' => 'post_date',
'order' => 'DESC',
'include' => ,
'exclude' => ,
'meta_key' => ,
'meta_value' =>,
'post_type' => 'post',
'post_statu... |
158,676 | <p>I'm working on a plugin which adds fields to the contact methods on the user profile page. It checks to see if the user is added to the plugin database and returns 1 if he is. This works and the plugin only shows the contact fields to the users who are added by it won't let them save changes in the contact field.</p... | [
{
"answer_id": 158655,
"author": "Tomás Cot",
"author_id": 57843,
"author_profile": "https://wordpress.stackexchange.com/users/57843",
"pm_score": 0,
"selected": false,
"text": "<p>You could use <a href=\"http://codex.wordpress.org/Template_Tags/get_posts\" rel=\"nofollow\"><code>get_pos... | 2014/08/21 | [
"https://wordpress.stackexchange.com/questions/158676",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37385/"
] | I'm working on a plugin which adds fields to the contact methods on the user profile page. It checks to see if the user is added to the plugin database and returns 1 if he is. This works and the plugin only shows the contact fields to the users who are added by it won't let them save changes in the contact field.
```
... | You can use the WordPress function **wp\_get\_recent\_posts()**, with required args.
```
$output = array();
$args = array(
'numberposts' => 10,
'offset' => 0,
'category' => 0,
'orderby' => 'post_date',
'order' => 'DESC',
'include' => ,
'exclude' => ,
'meta_key' => ,
'meta_value' =>,
'post_type' => 'post',
'post_statu... |
158,679 | <p>I want to manage my WP site in local, then sync it to my git, and then automatically deploy it.
In fact, I already have my site in production, and trying to make it work in local.
The fact is I can make it work in local, but every link send me to the distant domain : mydomain.com instead of managing localhost.</p>
... | [
{
"answer_id": 158655,
"author": "Tomás Cot",
"author_id": 57843,
"author_profile": "https://wordpress.stackexchange.com/users/57843",
"pm_score": 0,
"selected": false,
"text": "<p>You could use <a href=\"http://codex.wordpress.org/Template_Tags/get_posts\" rel=\"nofollow\"><code>get_pos... | 2014/08/21 | [
"https://wordpress.stackexchange.com/questions/158679",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58010/"
] | I want to manage my WP site in local, then sync it to my git, and then automatically deploy it.
In fact, I already have my site in production, and trying to make it work in local.
The fact is I can make it work in local, but every link send me to the distant domain : mydomain.com instead of managing localhost.
How sho... | You can use the WordPress function **wp\_get\_recent\_posts()**, with required args.
```
$output = array();
$args = array(
'numberposts' => 10,
'offset' => 0,
'category' => 0,
'orderby' => 'post_date',
'order' => 'DESC',
'include' => ,
'exclude' => ,
'meta_key' => ,
'meta_value' =>,
'post_type' => 'post',
'post_statu... |
158,689 | <p>I have a strange problem. I am dynamically populating content into Wordpress' tinyMCE editor. Part of this content is a placeholder image, that the user can then replace. The issue is when I click the 'pencil' icon to edit, I am not given the "Replace" button like I would any other images. </p>
<p>This is what I se... | [
{
"answer_id": 158780,
"author": "Alex Schmaltz",
"author_id": 58198,
"author_profile": "https://wordpress.stackexchange.com/users/58198",
"pm_score": -1,
"selected": true,
"text": "<p>This has something to do with the HTML of a media object. I copy/pasted code from another image importe... | 2014/08/21 | [
"https://wordpress.stackexchange.com/questions/158689",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58198/"
] | I have a strange problem. I am dynamically populating content into Wordpress' tinyMCE editor. Part of this content is a placeholder image, that the user can then replace. The issue is when I click the 'pencil' icon to edit, I am not given the "Replace" button like I would any other images.
This is what I see: [![ente... | This has something to do with the HTML of a media object. I copy/pasted code from another image imported from the media gallery and it worked. Use this function to insert the content:
<http://www.tinymce.com/wiki.php/API3:method.tinymce.Editor.setContent>
```
tinyMCE.activeEditor.setContent('<span>some</span> html');... |
158,700 | <p>I know this question has been asked and answered 1000 times. However, I've never truly found a solution that removes pingback link tag from "wp_head". While there are several ways to block xml-rcp/pingback/trackback from wordpress I'm trying to add to that by blocking it from the head</p>
<p>So basically I don't wa... | [
{
"answer_id": 158992,
"author": "Bryan Willis",
"author_id": 38123,
"author_profile": "https://wordpress.stackexchange.com/users/38123",
"pm_score": 3,
"selected": true,
"text": "<p>It was just a mistake I had made, the above would work like this:</p>\n\n<pre><code>$buffer = preg_replac... | 2014/08/21 | [
"https://wordpress.stackexchange.com/questions/158700",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38123/"
] | I know this question has been asked and answered 1000 times. However, I've never truly found a solution that removes pingback link tag from "wp\_head". While there are several ways to block xml-rcp/pingback/trackback from wordpress I'm trying to add to that by blocking it from the head
So basically I don't want this s... | It was just a mistake I had made, the above would work like this:
```
$buffer = preg_replace('/(<link.*?rel=("|\')pingback("|\').*?href=("|\')(.*?)("|\')(.*?)?\/?>|<link.*?href=("|\')(.*?)("|\').*?rel=("|\')pingback("|\')(.*?)?\/?>)/i', '', $buffer);
```
**HERE is the revised answer:**
```
if (!is_admin()) {
... |
158,703 | <p>When I use spl_autoload_register in my plugin, I get:</p>
<pre><code> Fatal error: Uncaught exception 'LogicException' with message
'Class wp_atom_server could not be loaded'
wp-includes\pluggable-deprecated.php on line 182
</code></pre>
<p>I did some reading and found various fixes. <a href="https://w... | [
{
"answer_id": 257461,
"author": "Meldin Xavier",
"author_id": 81076,
"author_profile": "https://wordpress.stackexchange.com/users/81076",
"pm_score": -1,
"selected": false,
"text": "<pre><code> function MyPluginClasses_autoloader( $class_name ) {\n if ( false !== strpos( $class_name... | 2014/08/21 | [
"https://wordpress.stackexchange.com/questions/158703",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49089/"
] | When I use spl\_autoload\_register in my plugin, I get:
```
Fatal error: Uncaught exception 'LogicException' with message
'Class wp_atom_server could not be loaded'
wp-includes\pluggable-deprecated.php on line 182
```
I did some reading and found various fixes. [One on SO](https://wordpress.stackexchange... | I am really not sure if it's good or bad practice to auto loading classes in WP plugin. For me, i see no side effects of using `spl_autoload_register` (not tested performance)
So to answer your question, I would like to share a class from my upcoming plugin which i am using to auto load classes from a single directory... |
158,738 | <p>Well I am lost, its late and I have been searching google all night. Heres the problem I am running into. I am trying to create a singe page website using wordpress "pages". How I have initially setup the theme is there are several page templates for ex ('page-contact.php, page-gallery.php, page-map.php etc.'). Each... | [
{
"answer_id": 158821,
"author": "Derrick Workman",
"author_id": 58563,
"author_profile": "https://wordpress.stackexchange.com/users/58563",
"pm_score": 3,
"selected": true,
"text": "<p>Well I think I seem to be doing what I was intending too. Thanks @Milo for pointing me in the right di... | 2014/08/22 | [
"https://wordpress.stackexchange.com/questions/158738",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58563/"
] | Well I am lost, its late and I have been searching google all night. Heres the problem I am running into. I am trying to create a singe page website using wordpress "pages". How I have initially setup the theme is there are several page templates for ex ('page-contact.php, page-gallery.php, page-map.php etc.'). Each of... | Well I think I seem to be doing what I was intending too. Thanks @Milo for pointing me in the right direction! As You can see below I used the get\_page\_template\_slug(); and str\_replace() to filter through the templates used per page.
Can someone Verify that this is a viable option?
```
$args = array (
'post_... |
158,759 | <p>The preview function works fine when posts are just draft. The url looks like this :
<a href="http://exemple.domain.com/blog/?p=12&preview=true" rel="nofollow">http://exemple.domain.com/blog/?p=12&preview=true</a></p>
<p>Then when I pubish my posts, let's say I want to change something and preview it, the ... | [
{
"answer_id": 158821,
"author": "Derrick Workman",
"author_id": 58563,
"author_profile": "https://wordpress.stackexchange.com/users/58563",
"pm_score": 3,
"selected": true,
"text": "<p>Well I think I seem to be doing what I was intending too. Thanks @Milo for pointing me in the right di... | 2014/08/22 | [
"https://wordpress.stackexchange.com/questions/158759",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58577/"
] | The preview function works fine when posts are just draft. The url looks like this :
<http://exemple.domain.com/blog/?p=12&preview=true>
Then when I pubish my posts, let's say I want to change something and preview it, the url looks like this : <http://exemple.domain.com/blog/my-article-title/?preview=true&preview_id... | Well I think I seem to be doing what I was intending too. Thanks @Milo for pointing me in the right direction! As You can see below I used the get\_page\_template\_slug(); and str\_replace() to filter through the templates used per page.
Can someone Verify that this is a viable option?
```
$args = array (
'post_... |
158,775 | <p>Here is my code for restrict my wordpress site:</p>
<pre><code>function restrict_access_if_logged_out(){
if (!is_user_logged_in() && !is_home()){
$redirect = home_url() . '/wp-login.php?redirect_to=' . esc_url($_SERVER["HTTP_HOST"] . urlencode($_SERVER["REQUEST_URI"]));
wp_redirect( $redirect );
... | [
{
"answer_id": 160280,
"author": "Brad Dalton",
"author_id": 9884,
"author_profile": "https://wordpress.stackexchange.com/users/9884",
"pm_score": 0,
"selected": false,
"text": "<pre><code>function restrict_access_if_logged_out(){\n if (!is_user_logged_in() || !is_home()){\n $redirec... | 2014/08/22 | [
"https://wordpress.stackexchange.com/questions/158775",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58546/"
] | Here is my code for restrict my wordpress site:
```
function restrict_access_if_logged_out(){
if (!is_user_logged_in() && !is_home()){
$redirect = home_url() . '/wp-login.php?redirect_to=' . esc_url($_SERVER["HTTP_HOST"] . urlencode($_SERVER["REQUEST_URI"]));
wp_redirect( $redirect );
exit;
}
}
add_act... | I wanted to restrict my website except a specific page. This is my solution:
```
function restrict_access_if_logged_out(){
global $wp;
if (!is_user_logged_in() && !is_home() && ($wp->query_vars['pagename'] != 'name-of-page') ){
$redirect = home_url() . '/wp-login.php?redirect_to=' . esc_url($_SERVER["HTTP_HOST... |
158,784 | <p>Is there a way, without modifying the core, to create a term for a custom taxonomy programmatically that is non deletable?</p>
<p>"Uncategorized" is an example, but in my case, it does not have to be the default term if a post is not attached a term, but yes it will be a default always existing term in that custom ... | [
{
"answer_id": 158789,
"author": "Jason",
"author_id": 47750,
"author_profile": "https://wordpress.stackexchange.com/users/47750",
"pm_score": 1,
"selected": false,
"text": "<p>I'm not sure if you can <em>stop</em> a term from being removed, but you can make sure it always exists. Just t... | 2014/08/22 | [
"https://wordpress.stackexchange.com/questions/158784",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57012/"
] | Is there a way, without modifying the core, to create a term for a custom taxonomy programmatically that is non deletable?
"Uncategorized" is an example, but in my case, it does not have to be the default term if a post is not attached a term, but yes it will be a default always existing term in that custom taxonomy.
... | **Update**
Indeed, there is a way to define one term per taxonomy as default term which makes it non-deletable from the admin GUI.
`WP_Terms_List_Table` looks for an option `get_option( 'default_' . $this->screen->taxonomy )`.
So if you have a custom Taxonomy called `genre`, you have to set an option `default_genr... |
158,800 | <p>when I upload in woocommerce image it uploads different sizes:</p>
<ol>
<li>For category</li>
<li>Single</li>
<li>Thumb</li>
</ol>
<p>and keeps original file which is big... how can I auto delete this original file ? </p>
| [
{
"answer_id": 158909,
"author": "Pat Gilmour",
"author_id": 48679,
"author_profile": "https://wordpress.stackexchange.com/users/48679",
"pm_score": 3,
"selected": true,
"text": "<p>You should be able to do this with the same filter that is talked about <a href=\"https://wordpress.stacke... | 2014/08/22 | [
"https://wordpress.stackexchange.com/questions/158800",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11896/"
] | when I upload in woocommerce image it uploads different sizes:
1. For category
2. Single
3. Thumb
and keeps original file which is big... how can I auto delete this original file ? | You should be able to do this with the same filter that is talked about [here](https://wordpress.stackexchange.com/questions/20702/delete-original-image-keep-thumbnail).
The full-size images are being kept by WordPress. It's not really a WooCommerce thing. As well as the settings for images in WooCommerce you will als... |
158,803 | <p>I want to create something similar to "<strong>youtube.com/long => youtu.be/short</strong>" for my wordpress blog/portfolio/freebie site: "<strong>magicshrooms.com/%cat-etc => mgcsr.mz/link-name</strong> ". Generally, I want to create a short link for each link and also for downloads, since my url is quite long. Of ... | [
{
"answer_id": 158909,
"author": "Pat Gilmour",
"author_id": 48679,
"author_profile": "https://wordpress.stackexchange.com/users/48679",
"pm_score": 3,
"selected": true,
"text": "<p>You should be able to do this with the same filter that is talked about <a href=\"https://wordpress.stacke... | 2014/08/22 | [
"https://wordpress.stackexchange.com/questions/158803",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57934/"
] | I want to create something similar to "**youtube.com/long => youtu.be/short**" for my wordpress blog/portfolio/freebie site: "**magicshrooms.com/%cat-etc => mgcsr.mz/link-name** ". Generally, I want to create a short link for each link and also for downloads, since my url is quite long. Of course I will buy short domai... | You should be able to do this with the same filter that is talked about [here](https://wordpress.stackexchange.com/questions/20702/delete-original-image-keep-thumbnail).
The full-size images are being kept by WordPress. It's not really a WooCommerce thing. As well as the settings for images in WooCommerce you will als... |
158,838 | <p>I have created a custom post type and a custom taxonomy. The issue is that I can not make the custom posts hierarchical with the categories it is in. I have the following code,</p>
<pre><code>function AppManager_custom_post() {
$labels = array(
'name' => _x( 'APKS', 'post type general name' )... | [
{
"answer_id": 158850,
"author": "Hassan Alvi",
"author_id": 58627,
"author_profile": "https://wordpress.stackexchange.com/users/58627",
"pm_score": 0,
"selected": false,
"text": "<p>Make the following modifications, I hope it will do the job </p>\n\n<pre><code>function AppManager_custom... | 2014/08/23 | [
"https://wordpress.stackexchange.com/questions/158838",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40779/"
] | I have created a custom post type and a custom taxonomy. The issue is that I can not make the custom posts hierarchical with the categories it is in. I have the following code,
```
function AppManager_custom_post() {
$labels = array(
'name' => _x( 'APKS', 'post type general name' ),
'singular_n... | This might not answer your question, but you have a few issues with your code
* Do not use uppercase letters in function names, taxonomy names and custom post type names. Only use lowercase letters. Separate names with a underscore (`_)`. Also, just a tip, never start these names with letters, or use a hyphen `(-)` to... |
158,853 | <p>How do I create a tag.php template that will work for every post that contain tags?</p>
<p>I created few Tags like = Food, Drink and Fruit</p>
<blockquote>
<p>post 1 have Food and Drink tags</p>
<p>post 2 have Food and Fruit tags</p>
</blockquote>
<p>How do I create a single page for those post of the tags?</p>
<p>M... | [
{
"answer_id": 158858,
"author": "Pieter Goosen",
"author_id": 31545,
"author_profile": "https://wordpress.stackexchange.com/users/31545",
"pm_score": 2,
"selected": false,
"text": "<p>Unfortunately all of your code is wrong. What you are doing is the same as <a href=\"http://codex.wordp... | 2014/08/23 | [
"https://wordpress.stackexchange.com/questions/158853",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58269/"
] | How do I create a tag.php template that will work for every post that contain tags?
I created few Tags like = Food, Drink and Fruit
>
> post 1 have Food and Drink tags
>
>
> post 2 have Food and Fruit tags
>
>
>
How do I create a single page for those post of the tags?
My code looks like this, but it didn't s... | Unfortunately all of your code is wrong. What you are doing is the same as [`query_posts`](http://codex.wordpress.org/Function_Reference/query_posts), which should never be used. Also, never swap the main query on any type of archive page or on the home page for a custom query
To create a tag page, just simply make a ... |
158,884 | <p>I am trying to add custom taxonomy (tags) to WordPress default post type. because I wanna use that taxonomy for custom post type as well.</p>
<pre><code>// Register Custom Taxonomy
function tag_synchro() {
$labels = array(
'name' => _x( 'QA Tags', 'Taxonomy General Name', ET_DOMAIN ),
... | [
{
"answer_id": 158885,
"author": "Rajeev Vyas",
"author_id": 6961,
"author_profile": "https://wordpress.stackexchange.com/users/6961",
"pm_score": 2,
"selected": true,
"text": "<p>Try this </p>\n\n<pre><code>add_action( 'init', 'tag_synchro', 10 );\n</code></pre>\n\n<p>It might be the ca... | 2014/08/23 | [
"https://wordpress.stackexchange.com/questions/158884",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31027/"
] | I am trying to add custom taxonomy (tags) to WordPress default post type. because I wanna use that taxonomy for custom post type as well.
```
// Register Custom Taxonomy
function tag_synchro() {
$labels = array(
'name' => _x( 'QA Tags', 'Taxonomy General Name', ET_DOMAIN ),
'singular_nam... | Try this
```
add_action( 'init', 'tag_synchro', 10 );
```
It might be the case that, when you set priority to 0 , your callback does not get called. |
158,894 | <p>I'm trying to modify the Genesis Tab plugin to show more than one post per tab. I've tried in vain for the past hour, but my little PHP knowledge just isn't cutting it unfortunately. Here is the current code, that should be returning 5 post titles ('posts_per_page' => 5), but is only showing one:</p>
<pre><code>// ... | [
{
"answer_id": 158903,
"author": "Pat",
"author_id": 12920,
"author_profile": "https://wordpress.stackexchange.com/users/12920",
"pm_score": 1,
"selected": false,
"text": "<p>Looks like you might be missing the <code>wp_reset_postdata()</code> in here. The WordPress codex shows you need ... | 2014/08/23 | [
"https://wordpress.stackexchange.com/questions/158894",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58640/"
] | I'm trying to modify the Genesis Tab plugin to show more than one post per tab. I've tried in vain for the past hour, but my little PHP knowledge just isn't cutting it unfortunately. Here is the current code, that should be returning 5 post titles ('posts\_per\_page' => 5), but is only showing one:
```
// Loop through... | Looks like you might be missing the `wp_reset_postdata()` in here. The WordPress codex shows you need to have a `wp_reset_postdata()` after your while loop.
Here's WordPress' example (which even has the `posts_per_page` defined):
```
<?php
// example args
$args = array( 'posts_per_page' => 3 );
// the query
$the_q... |
158,895 | <p>my current search only shows POSTS as results.</p>
<p><a href="http://newslines.org/?s=george" rel="nofollow">http://newslines.org/?s=george</a></p>
<p>My site has categories for George Clooney, George R.R. Martin etc. How do I get a list of categories that match the search term to show at the top of the results p... | [
{
"answer_id": 158899,
"author": "Will S.",
"author_id": 58221,
"author_profile": "https://wordpress.stackexchange.com/users/58221",
"pm_score": -1,
"selected": false,
"text": "<p>You can edit your search.php file to essentially run multiple search loops, like this...</p>\n\n<pre><code> ... | 2014/08/23 | [
"https://wordpress.stackexchange.com/questions/158895",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45635/"
] | my current search only shows POSTS as results.
<http://newslines.org/?s=george>
My site has categories for George Clooney, George R.R. Martin etc. How do I get a list of categories that match the search term to show at the top of the results page?
I have tried this:
```
<?php
$search_query = get_search_query();
... | Essentially what you need is show the categories the current queried posts belong.
I'll post here a function that take as argument a taaxonomy (or an array of taxonomies) and return all the terms in that (those) taxonomy(ies) that are assigned to all queried posts.
```
function queried_posts_terms( $taxonomies = 'cate... |
158,898 | <p>I have a custom meta query which is terribly slow or doesn’t even load till the end. With up to three <code>arrays</code> in <code>'meta_query'</code> the query works fine, with four and up it doesn’t work anymore.</p>
<p>When searching for a reason I found <a href="https://stackoverflow.com/questions/23331762/word... | [
{
"answer_id": 158900,
"author": "Tomás Cot",
"author_id": 57843,
"author_profile": "https://wordpress.stackexchange.com/users/57843",
"pm_score": 0,
"selected": false,
"text": "<p>ORs are really expensive.</p>\n\n<p>You have too many keys, but let's assume you can't change that now. The... | 2014/08/23 | [
"https://wordpress.stackexchange.com/questions/158898",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/21110/"
] | I have a custom meta query which is terribly slow or doesn’t even load till the end. With up to three `arrays` in `'meta_query'` the query works fine, with four and up it doesn’t work anymore.
When searching for a reason I found [this post](https://stackoverflow.com/questions/23331762/wordpress-custom-meta-query-searc... | I've come across this problem and it seems MySQL doesn't deal well with the multiple joins to the same table (wp\_postmeta) and OR-ed WHERE that WP generates here. I dealt with it by rewriting the join and where as mentioned in the post you link to - here's a version that should work in your case (**updated for WP 4.1.... |
158,901 | <p>I'm creating a theme for my portfolio site. After a some time of trial and error research and almostss, I'm stuck.</p>
<p>It's going to be very minimal site in content, therefore I decided to create a one page website. I'm using <code>get_pages($args);</code> to display each page in my front-page.php file.</p>
<p>... | [
{
"answer_id": 158902,
"author": "Will S.",
"author_id": 58221,
"author_profile": "https://wordpress.stackexchange.com/users/58221",
"pm_score": -1,
"selected": false,
"text": "<p>Without seeing your front-page.php file, here is what I'd suggest if you're using a posts page of \"Blog\". ... | 2014/08/23 | [
"https://wordpress.stackexchange.com/questions/158901",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54739/"
] | I'm creating a theme for my portfolio site. After a some time of trial and error research and almostss, I'm stuck.
It's going to be very minimal site in content, therefore I decided to create a one page website. I'm using `get_pages($args);` to display each page in my front-page.php file.
This works great. Now here's... | This doesn't work the way you think it does because get\_pages doesn't do what you think it does.
First, understand that all pages, all content, in WordPress is really a "post". A "Page" is just a special type of post.
Now, in a normal environment, you wouldn't call "get\_" anything. This is why you're confused, beca... |
158,928 | <p>I have a multi author site and I have already used some hooks to stop them from viewing other author's posts and media. Now, in the Wordpress Dashboard in the "at a glance" section it shows them the total posts and comments. They can click on them at the moment and I would like them to not be able to do this. </p>
... | [
{
"answer_id": 158939,
"author": "Waseem Abu Senjer",
"author_id": 12144,
"author_profile": "https://wordpress.stackexchange.com/users/12144",
"pm_score": 2,
"selected": false,
"text": "<p>Unfortunately, there is no 'filter' to remove or edit the <strong>previous</strong> items in the 'A... | 2014/08/24 | [
"https://wordpress.stackexchange.com/questions/158928",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48204/"
] | I have a multi author site and I have already used some hooks to stop them from viewing other author's posts and media. Now, in the Wordpress Dashboard in the "at a glance" section it shows them the total posts and comments. They can click on them at the moment and I would like them to not be able to do this.
So, I h... | The `dashboard_glance_items` filter is only useful for modifying the extra elements. The posts/comments data elements have already been displayed.
Here are three ideas:
Method #1 - Use the `dashboard_glance_items` filter:
----------------------------------------------------
You can use the following filter setup, to... |
158,929 | <p>I've been googling and attempting this for over a week now with no success. I have a few custom post types (books, films, music etc), and a custom taxonomy (location).</p>
<p>On my frontpage, I have two dropdowns that filter a search, like this:</p>
<pre><code>Look for: <custom post type> in <taxonomy>... | [
{
"answer_id": 158964,
"author": "Hassan Alvi",
"author_id": 58627,
"author_profile": "https://wordpress.stackexchange.com/users/58627",
"pm_score": 0,
"selected": false,
"text": "<p>Use jQuery action on first dropdown .. this is the code from your mentioned url .. \nYou can populate the... | 2014/08/24 | [
"https://wordpress.stackexchange.com/questions/158929",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58166/"
] | I've been googling and attempting this for over a week now with no success. I have a few custom post types (books, films, music etc), and a custom taxonomy (location).
On my frontpage, I have two dropdowns that filter a search, like this:
```
Look for: <custom post type> in <taxonomy>
```
What I am trying to do is ... | If you want an example of how to do the dropdown filtering using ajax, then if you factor out your taxonomy dropdown into your "functions.php":
```
function my_dropdown_categories( $taxonomy, $current_selected = '', $include = null ) {
// Get all terms of the chosen taxonomy
$terms = get_terms($taxonomy, array... |
158,930 | <p>I want to create a custom front page for a Wordpress site, which will have an image, some text, an embedded login form, and a <a href="http://www.metaslider.com/" rel="nofollow">metaslider</a> slider, and nothing else (no menu, no sidebar, no footer). Anyone visiting the site should be presented this page, and shoul... | [
{
"answer_id": 158942,
"author": "jdm2112",
"author_id": 45202,
"author_profile": "https://wordpress.stackexchange.com/users/45202",
"pm_score": 1,
"selected": false,
"text": "<p>It sounds as though you are confusing multiple issues. If you created front-page.php, added your content and... | 2014/08/24 | [
"https://wordpress.stackexchange.com/questions/158930",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58248/"
] | I want to create a custom front page for a Wordpress site, which will have an image, some text, an embedded login form, and a [metaslider](http://www.metaslider.com/) slider, and nothing else (no menu, no sidebar, no footer). Anyone visiting the site should be presented this page, and should be able to login with their... | It sounds as though you are confusing multiple issues. If you created front-page.php, added your content and made the settings in WP for this to display as the front page, then that part of your question is answered.
If the login form and slider are not working on that template, you have a separate challenge to overco... |
158,953 | <p>I'm trying the store multiple rows into a database. The number of fields will change. Below is the way that I use to store just one row.</p>
<pre><code> <?php
if(isset($_POST['save'])){
$wpdb->insert('wp_table_name',
array(
'field_a' => $_POST['field_a'],
'fi... | [
{
"answer_id": 158954,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 3,
"selected": false,
"text": "<p>What WP does for arrays (and objects) on some contexts (such as post fields) is using <a href=\"http://queryposts.c... | 2014/08/24 | [
"https://wordpress.stackexchange.com/questions/158953",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47687/"
] | I'm trying the store multiple rows into a database. The number of fields will change. Below is the way that I use to store just one row.
```
<?php
if(isset($_POST['save'])){
$wpdb->insert('wp_table_name',
array(
'field_a' => $_POST['field_a'],
'field_b' => $_POST['field... | What WP does for arrays (and objects) on some contexts (such as post fields) is using [`maybe_serialize()`](http://queryposts.com/function/maybe_serialize/)/[`maybe_unserialize()`](http://queryposts.com/function/maybe_unserialize/) to turn such types (and just them) to and from serialized (string-typed) representation.... |
158,956 | <p>I am building a wordpress theme from scratch on a subdomain and I want to use the same CSS files across my entire site. My problem is linking my wordpress PHP files (which are on the subdomain) to my CSS files (which are on the main domain).</p>
<p>I have tried going into theme.php and changing the ['/style.css'] t... | [
{
"answer_id": 158957,
"author": "Will S.",
"author_id": 58221,
"author_profile": "https://wordpress.stackexchange.com/users/58221",
"pm_score": 1,
"selected": true,
"text": "<p>If you're using an absolute reference like that, you'd want to include the full file path, like <a href=\"http... | 2014/08/24 | [
"https://wordpress.stackexchange.com/questions/158956",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58657/"
] | I am building a wordpress theme from scratch on a subdomain and I want to use the same CSS files across my entire site. My problem is linking my wordpress PHP files (which are on the subdomain) to my CSS files (which are on the main domain).
I have tried going into theme.php and changing the ['/style.css'] to an absol... | If you're using an absolute reference like that, you'd want to include the full file path, like <http://diginomics.com/wp-content/themes/THEMENAME/css/style.css>
I believe any time you call the functions like get\_stylesheet\_directory() or get\_stylesheet\_directory\_uri() it will return the path for the current them... |
158,967 | <p>I can make wordpress custom menu,but I got a problem with this type of menu. Can anybody give me any suggestion how to make this menu dynamic?</p>
<p>screenshot:
<a href="http://awesomescreenshot.com/0ab3d6an94" rel="nofollow">http://awesomescreenshot.com/0ab3d6an94</a></p>
<p>HTML markup</p>
<pre><code> ... | [
{
"answer_id": 158957,
"author": "Will S.",
"author_id": 58221,
"author_profile": "https://wordpress.stackexchange.com/users/58221",
"pm_score": 1,
"selected": true,
"text": "<p>If you're using an absolute reference like that, you'd want to include the full file path, like <a href=\"http... | 2014/08/24 | [
"https://wordpress.stackexchange.com/questions/158967",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58661/"
] | I can make wordpress custom menu,but I got a problem with this type of menu. Can anybody give me any suggestion how to make this menu dynamic?
screenshot:
<http://awesomescreenshot.com/0ab3d6an94>
HTML markup
```
<ul id="nav">
<li><a href="">World News <span>From Around Th... | If you're using an absolute reference like that, you'd want to include the full file path, like <http://diginomics.com/wp-content/themes/THEMENAME/css/style.css>
I believe any time you call the functions like get\_stylesheet\_directory() or get\_stylesheet\_directory\_uri() it will return the path for the current them... |
158,972 | <p>I am using the following <code>foreach</code> loop:</p>
<pre><code>$pages = get_pages(array ('post_type' => 'page','sort_column' => 'menu_order',));
foreach ($pages as $page) {
$apage = $page->post_name;
if ( $apage =='about') {
echo apply_filters('the_content', $page->post_con... | [
{
"answer_id": 158973,
"author": "Hassan Alvi",
"author_id": 58627,
"author_profile": "https://wordpress.stackexchange.com/users/58627",
"pm_score": 0,
"selected": false,
"text": "<p>Add this code into functions.php, it will add support for excerpts in Pages</p>\n\n<pre><code><?php\n ... | 2014/08/24 | [
"https://wordpress.stackexchange.com/questions/158972",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3327/"
] | I am using the following `foreach` loop:
```
$pages = get_pages(array ('post_type' => 'page','sort_column' => 'menu_order',));
foreach ($pages as $page) {
$apage = $page->post_name;
if ( $apage =='about') {
echo apply_filters('the_content', $page->post_content)
} // if about page
}... | **EDIT**
Seems that I some how misunderstood you. I do think you are missing the point of the `post_excerpt`.
When you create a new post or page (AFAIK for pages as well), you have the opportunity to create a manual excerpt in the excerpt meta box (to make it available, just enable it in screen options dropdown when ... |
158,990 | <p>I am using text widget in page, my title is too long and i want to make (Br)break in particular place, but i can not. After saving (br)break is gone, also tried (nbsp) but same result came. How to overcome?</p>
| [
{
"answer_id": 158996,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 0,
"selected": false,
"text": "<p>You can't use an HTML in the title. Leave the title empty and put the title as part of the HTML of the wi... | 2014/08/25 | [
"https://wordpress.stackexchange.com/questions/158990",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58668/"
] | I am using text widget in page, my title is too long and i want to make (Br)break in particular place, but i can not. After saving (br)break is gone, also tried (nbsp) but same result came. How to overcome? | You can work around that by passing `widget_title` through a filter :
```
function custom_widget_title( $title ) {
$title = str_replace( '__br__', '<br/>', $title );
return $title;
}
add_filter( 'widget_title', 'custom_widget_title' );
```
Now use `__br__` in your widget title instead of `<br/>` and the ... |
158,997 | <p>I've used following codes and no luck</p>
<p><strong>1</strong></p>
<pre><code>//Hide admin footer from admin
function change_footer_admin () {
return ' ';
}
add_filter('admin_footer_text', 'change_footer_admin', 9999);
function change_footer_version() {
return ' ';
}
add_filter( 'update_footer', 'change_... | [
{
"answer_id": 159013,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 4,
"selected": true,
"text": "<p>This works for me:</p>\n\n<pre><code><?php\n/** Plugin Name: Admin Footer Text Remover **/\n\nadd_filter( '... | 2014/08/25 | [
"https://wordpress.stackexchange.com/questions/158997",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43764/"
] | I've used following codes and no luck
**1**
```
//Hide admin footer from admin
function change_footer_admin () {
return ' ';
}
add_filter('admin_footer_text', 'change_footer_admin', 9999);
function change_footer_version() {
return ' ';
}
add_filter( 'update_footer', 'change_footer_version', 9999);
```
**2*... | This works for me:
```
<?php
/** Plugin Name: Admin Footer Text Remover **/
add_filter( 'admin_footer_text', '__return_empty_string', 11 );
add_filter( 'update_footer', '__return_empty_string', 11 );
```
where I use the [`__return_empty_string`](http://codex.wordpress.org/Function_Reference/_return_empty_string... |
159,014 | <p>I am trying to put a custom inline JavaScript is an options page created by a plugin.<br>
The page URL is like this <code>wp-admin/admin.php?page=psbg</code>.</p>
<p>This is the code I am using to output my script at the head.</p>
<pre><code>function add_scripts() {
$current_screen = get_current_screen();
... | [
{
"answer_id": 159021,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 2,
"selected": false,
"text": "<p>There are several ways to add scripts only to certain admin pages. The best option, from my point of view, is... | 2014/08/25 | [
"https://wordpress.stackexchange.com/questions/159014",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26991/"
] | I am trying to put a custom inline JavaScript is an options page created by a plugin.
The page URL is like this `wp-admin/admin.php?page=psbg`.
This is the code I am using to output my script at the head.
```
function add_scripts() {
$current_screen = get_current_screen();
if ( $current_screen = 'admin.ph... | There are several ways to add scripts only to certain admin pages. The best option, from my point of view, is to hook into `admin_enqueue_scripts` and use the `$hook` parameter:
```
add_action('admin_enqueue_scripts', 'cyb_admin_scripts');
function cyb_admin_scripts( $hook ) {
//You may need adjustment here to ma... |
159,016 | <p>I want to get a list of all posts that don't have an attachment and delete them.</p>
<p><a href="https://wordpress.stackexchange.com/q/144057/24579">This question</a> takes about getting all posts that <em>have</em> an attachment, but I want the reverse of it.</p>
<p>The brute force way to do it is to get all post... | [
{
"answer_id": 159021,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 2,
"selected": false,
"text": "<p>There are several ways to add scripts only to certain admin pages. The best option, from my point of view, is... | 2014/08/25 | [
"https://wordpress.stackexchange.com/questions/159016",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24579/"
] | I want to get a list of all posts that don't have an attachment and delete them.
[This question](https://wordpress.stackexchange.com/q/144057/24579) takes about getting all posts that *have* an attachment, but I want the reverse of it.
The brute force way to do it is to get all posts and then loop through them indivi... | There are several ways to add scripts only to certain admin pages. The best option, from my point of view, is to hook into `admin_enqueue_scripts` and use the `$hook` parameter:
```
add_action('admin_enqueue_scripts', 'cyb_admin_scripts');
function cyb_admin_scripts( $hook ) {
//You may need adjustment here to ma... |
159,028 | <p>I'm trying to style a single loop to look like so</p>
<pre><code>---------------------------------------------
|| | || ||
|| | ||--------------||
|| | || ||
|| | ||--------------||
|| | ... | [
{
"answer_id": 159031,
"author": "chap",
"author_id": 48204,
"author_profile": "https://wordpress.stackexchange.com/users/48204",
"pm_score": 0,
"selected": false,
"text": "<p>What I would do is use multiple loops while tracking the ID of the post recorded in the previous post and skippi... | 2014/08/25 | [
"https://wordpress.stackexchange.com/questions/159028",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I'm trying to style a single loop to look like so
```
---------------------------------------------
|| | || ||
|| | ||--------------||
|| | || ||
|| | ||--------------||
|| | || ... | instead of a counter variable, you can use the build-in loop counter;
as I don't know how you need to wrap the posts into the individual divs, here just an example structure (only to be used with 5 posts per page):
```
<div class="col-lg-12">
<div class="row">
<?php if ( have_posts() ) : ?>
... |
159,034 | <p>I've got the following code in my team-type.php file which I'm using to create a custom taxonomy for a member information: </p>
<pre><code>function create_team_taxonomies() {
$labels = array(
'name' => _x( 'Kategooriad', 'taxonomy general name' ),
'singular_name' => _x( 'K... | [
{
"answer_id": 159031,
"author": "chap",
"author_id": 48204,
"author_profile": "https://wordpress.stackexchange.com/users/48204",
"pm_score": 0,
"selected": false,
"text": "<p>What I would do is use multiple loops while tracking the ID of the post recorded in the previous post and skippi... | 2014/08/25 | [
"https://wordpress.stackexchange.com/questions/159034",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34301/"
] | I've got the following code in my team-type.php file which I'm using to create a custom taxonomy for a member information:
```
function create_team_taxonomies() {
$labels = array(
'name' => _x( 'Kategooriad', 'taxonomy general name' ),
'singular_name' => _x( 'Kategooria', 'taxonom... | instead of a counter variable, you can use the build-in loop counter;
as I don't know how you need to wrap the posts into the individual divs, here just an example structure (only to be used with 5 posts per page):
```
<div class="col-lg-12">
<div class="row">
<?php if ( have_posts() ) : ?>
... |
159,042 | <p>I am having problem on migrating my Wordpress site from the sub folder to the root directory. </p>
<p>My current website URL is not working on uploading the project on root directory. It's get redirected to the existing path </p>
<p>My current word press site is located on root directory </p>
<blockquote>
<p><a... | [
{
"answer_id": 159031,
"author": "chap",
"author_id": 48204,
"author_profile": "https://wordpress.stackexchange.com/users/48204",
"pm_score": 0,
"selected": false,
"text": "<p>What I would do is use multiple loops while tracking the ID of the post recorded in the previous post and skippi... | 2014/08/25 | [
"https://wordpress.stackexchange.com/questions/159042",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58687/"
] | I am having problem on migrating my Wordpress site from the sub folder to the root directory.
My current website URL is not working on uploading the project on root directory. It's get redirected to the existing path
My current word press site is located on root directory
>
> <http://www.macil.com.au/>
>
>
>
... | instead of a counter variable, you can use the build-in loop counter;
as I don't know how you need to wrap the posts into the individual divs, here just an example structure (only to be used with 5 posts per page):
```
<div class="col-lg-12">
<div class="row">
<?php if ( have_posts() ) : ?>
... |
159,054 | <p>I'm using a Thematic childtheme for my wordpress website, and instead of putting all my functions into the functions.php file, I thought I make it more organised by creating multiple other function files (admin_functions.php, single_functions.php ...) and included these files in my childtheme's functions.php file as... | [
{
"answer_id": 159061,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>First let's go ever when and where you can use these conditionals:</p>\n\n<ul>\n<li><a href=\"http://queryposts.com... | 2014/08/25 | [
"https://wordpress.stackexchange.com/questions/159054",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55241/"
] | I'm using a Thematic childtheme for my wordpress website, and instead of putting all my functions into the functions.php file, I thought I make it more organised by creating multiple other function files (admin\_functions.php, single\_functions.php ...) and included these files in my childtheme's functions.php file as ... | As this is an important question with no real answer, I will provide what I found after hunting a solution down, though I don't have an answer as to *why* it doesn't work like we all think it should.
You need to hook into WordPress somewhere, like this:
```
// load our posts-only PHP
add_action( "wp", "only_posts" );... |
159,058 | <p>I need to use an array of existing categories as a dropdown option value then use the selected category ID.
More exactly, I try to make a custom module to display the latest posts form selected category using Visual Composer plugin <a href="http://kb.wpbakery.com/index.php?title=Visual_Composer_tutorial" rel="nofol... | [
{
"answer_id": 159060,
"author": "Rajeev Vyas",
"author_id": 6961,
"author_profile": "https://wordpress.stackexchange.com/users/6961",
"pm_score": 4,
"selected": true,
"text": "<p>Try this,</p>\n\n<pre><code>$categories_array = array();\n$categories = get_categories();\nforeach( $categor... | 2014/08/25 | [
"https://wordpress.stackexchange.com/questions/159058",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33903/"
] | I need to use an array of existing categories as a dropdown option value then use the selected category ID.
More exactly, I try to make a custom module to display the latest posts form selected category using Visual Composer plugin [tutorial](http://kb.wpbakery.com/index.php?title=Visual_Composer_tutorial).
I tried t... | Try this,
```
$categories_array = array();
$categories = get_categories();
foreach( $categories as $category ){
$categories_array[] = $category->term_id;
}
array(
'param_name' => 'category_id',
'type' => 'dropdown',
'value' => $categories_array, // here I'm stuck
'heading' => __('C... |
159,076 | <p>I want to edit the format of how posts are display only on the homepage of a Wordpress site but I can't seem to find which template it is that is being used. I'm using the Twentytwelve theme as a base to create a custom theme.</p>
<p>Also when I say the format, I don't mean the post format (ie. bold), I mean the st... | [
{
"answer_id": 159060,
"author": "Rajeev Vyas",
"author_id": 6961,
"author_profile": "https://wordpress.stackexchange.com/users/6961",
"pm_score": 4,
"selected": true,
"text": "<p>Try this,</p>\n\n<pre><code>$categories_array = array();\n$categories = get_categories();\nforeach( $categor... | 2014/08/25 | [
"https://wordpress.stackexchange.com/questions/159076",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58706/"
] | I want to edit the format of how posts are display only on the homepage of a Wordpress site but I can't seem to find which template it is that is being used. I'm using the Twentytwelve theme as a base to create a custom theme.
Also when I say the format, I don't mean the post format (ie. bold), I mean the style so cha... | Try this,
```
$categories_array = array();
$categories = get_categories();
foreach( $categories as $category ){
$categories_array[] = $category->term_id;
}
array(
'param_name' => 'category_id',
'type' => 'dropdown',
'value' => $categories_array, // here I'm stuck
'heading' => __('C... |
159,085 | <p>I would like to deactivate a plugin for a specific user. I'm using the following code inside a the <code>wp-content/plugin-mu</code> plugin file:</p>
<pre><code>add_filter( 'option_active_plugins', 'bo_disable_apm_plugin' );
function bo_disable_apm_plugin( $plugins ) {
global $current_user;
// Not u... | [
{
"answer_id": 160802,
"author": "aifrim",
"author_id": 58040,
"author_profile": "https://wordpress.stackexchange.com/users/58040",
"pm_score": 4,
"selected": true,
"text": "<p>I think the answer to this <a href=\"https://wordpress.stackexchange.com/questions/12163/disable-plugin-plugin-... | 2014/08/25 | [
"https://wordpress.stackexchange.com/questions/159085",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9458/"
] | I would like to deactivate a plugin for a specific user. I'm using the following code inside a the `wp-content/plugin-mu` plugin file:
```
add_filter( 'option_active_plugins', 'bo_disable_apm_plugin' );
function bo_disable_apm_plugin( $plugins ) {
global $current_user;
// Not use advanced page manager f... | I think the answer to this [Disable plugin / plugin action via theme](https://wordpress.stackexchange.com/questions/12163/disable-plugin-plugin-action-via-theme) is good for base knowledge on how to disable plugins from code.
Adapting that knowledge to your needs will leave us with this:
```
add_action('admin_init', ... |
159,086 | <p>I would like to create a simple plugin to add multiple images to a custom post type. I have created a plugin to add a single image to a custom post type, but I am unable to figure out how to add multiple. <img src="https://i.stack.imgur.com/MtPox.png" alt="enter image description here">
this is where I'm at.</p>
<p... | [
{
"answer_id": 159097,
"author": "streetfire",
"author_id": 37657,
"author_profile": "https://wordpress.stackexchange.com/users/37657",
"pm_score": 3,
"selected": true,
"text": "<p>This may be an alternative for you. The <a href=\"http://www.advancedcustomfields.com/\" rel=\"nofollow\">A... | 2014/08/25 | [
"https://wordpress.stackexchange.com/questions/159086",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58541/"
] | I would like to create a simple plugin to add multiple images to a custom post type. I have created a plugin to add a single image to a custom post type, but I am unable to figure out how to add multiple. 
this is where I'm at.
js file-
```
jQuer... | This may be an alternative for you. The [Advanced Custom Fields](http://www.advancedcustomfields.com/) plug in has an Image Field, which allows images to be uploaded and selected. You can set the field to show on your Custom Post Type pages and also integrate a line of code into your template file. You can create as ma... |
159,103 | <p>Okay, so I'm well familiar with the way to properly enqueue a stylesheet or JavaScript in the WordPress header via the <code>functions.php</code> file.</p>
<p>Recently though I came across a situation that has me puzzled. I want to setup this script on my WordPress site: <a href="https://github.com/kevinburke/custo... | [
{
"answer_id": 159105,
"author": "Gazi",
"author_id": 58712,
"author_profile": "https://wordpress.stackexchange.com/users/58712",
"pm_score": 0,
"selected": false,
"text": "<pre><code>add_action( 'wp_enqueue_scripts', 'load_scripts ');\n\nfunction load_scripts() {\n\n if ( !is_admin()... | 2014/08/26 | [
"https://wordpress.stackexchange.com/questions/159103",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47430/"
] | Okay, so I'm well familiar with the way to properly enqueue a stylesheet or JavaScript in the WordPress header via the `functions.php` file.
Recently though I came across a situation that has me puzzled. I want to setup this script on my WordPress site: [customize-twitter-1.1](https://github.com/kevinburke/customize-t... | First, create a static js file with those inline codes..
```
!function(d,s,id){var js,fjs=d.getElementsByTagName(s)[0];
if(!d.getElementById(id)){js=d.createElement(s);js.id=id;
js.src="//platform.twitter.com/widgets.js";
fjs.parentNode.insertBefore(js,fjs);}
}(document,"script","twitter-wjs");
var optio... |
159,116 | <p>I was running into memory issues with this:</p>
<p><code>get_posts( array( 'posts_per_page' => '-1', 'post_type' => array( 'product', 'product_variation' ) )</code></p>
<p>(there are thousands of results) just trying to get a list of all post IDs.</p>
<p>The below code grabs 10 products at a time, to hopefu... | [
{
"answer_id": 159118,
"author": "Mayeenul Islam",
"author_id": 22728,
"author_profile": "https://wordpress.stackexchange.com/users/22728",
"pm_score": 1,
"selected": false,
"text": "<p><code>get_posts()</code> and <code>WP_Query()</code> both shares the same way of Querying the database... | 2014/08/26 | [
"https://wordpress.stackexchange.com/questions/159116",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29029/"
] | I was running into memory issues with this:
`get_posts( array( 'posts_per_page' => '-1', 'post_type' => array( 'product', 'product_variation' ) )`
(there are thousands of results) just trying to get a list of all post IDs.
The below code grabs 10 products at a time, to hopefully avoid any memory limits. It seems to ... | Use the `fields` argument to grab just the ID - will save you a ton of memory ;)
```
$product_ids = get_posts(
array(
'posts_per_page' => -1,
'post_type' => array( 'product', 'product_variation' ),
'fields' => 'ids',
)
);
``` |
159,144 | <p>I've created a post type, called Package (for news packages), and want to be able to link to specific blog posts and display them on the single-package.php page. I'm using ACF relationship fields, and using the post ID (tried with post object as well, but had the same problem)</p>
<p>The issue is that the title and... | [
{
"answer_id": 159145,
"author": "Hassan Alvi",
"author_id": 58627,
"author_profile": "https://wordpress.stackexchange.com/users/58627",
"pm_score": 2,
"selected": true,
"text": "<p>Use the old method of adding the relationship field -> Post Object</p>\n\n<pre><code><?php while (have_... | 2014/08/26 | [
"https://wordpress.stackexchange.com/questions/159144",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19608/"
] | I've created a post type, called Package (for news packages), and want to be able to link to specific blog posts and display them on the single-package.php page. I'm using ACF relationship fields, and using the post ID (tried with post object as well, but had the same problem)
The issue is that the title and permalink... | Use the old method of adding the relationship field -> Post Object
```
<?php while (have_posts()) : the_post(); ?>
<div class="entry-content">
<h1 class="content-headline">Package: <?php the_title(); ?></h1>
</div>
<div class="package-description" style="padding:15px 10px;background:white;">
<?php the_content... |
159,162 | <p>I am trying to set the Featured image as the <code>og:image</code></p>
<p>I have tried various ways and plugins (<a href="https://wordpress.org/plugins/wordpress-seo/" rel="nofollow">Yoast</a>) but finding it hard to get my head around this.</p>
<p>The issue is that it isn't picking up the feature image at all ins... | [
{
"answer_id": 159178,
"author": "mrwweb",
"author_id": 9844,
"author_profile": "https://wordpress.stackexchange.com/users/9844",
"pm_score": 4,
"selected": true,
"text": "<p>It appears that your site doesn't use the core WordPress <a href=\"http://codex.wordpress.org/Post_Thumbnails\" r... | 2014/08/26 | [
"https://wordpress.stackexchange.com/questions/159162",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58748/"
] | I am trying to set the Featured image as the `og:image`
I have tried various ways and plugins ([Yoast](https://wordpress.org/plugins/wordpress-seo/)) but finding it hard to get my head around this.
The issue is that it isn't picking up the feature image at all instead it is picking up the images in the content.
This... | It appears that your site doesn't use the core WordPress [Featured Image feature](http://codex.wordpress.org/Post_Thumbnails) but instead uses a custom image field (probably from Advanced Custom Fields). Yoast's plugin, Jetpack, and presumably many others look for the Featured Image image when setting the opengraph met... |
159,164 | <p>I see people using this to pull in page content on their home pages, remove specific categories from archives etc.. e.g.</p>
<pre><code>$post = get_post( 5 );
</code></pre>
<p>Someone suggested this was bad practice. Why is it bad and what should users do instead?</p>
| [
{
"answer_id": 159178,
"author": "mrwweb",
"author_id": 9844,
"author_profile": "https://wordpress.stackexchange.com/users/9844",
"pm_score": 4,
"selected": true,
"text": "<p>It appears that your site doesn't use the core WordPress <a href=\"http://codex.wordpress.org/Post_Thumbnails\" r... | 2014/08/26 | [
"https://wordpress.stackexchange.com/questions/159164",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/736/"
] | I see people using this to pull in page content on their home pages, remove specific categories from archives etc.. e.g.
```
$post = get_post( 5 );
```
Someone suggested this was bad practice. Why is it bad and what should users do instead? | It appears that your site doesn't use the core WordPress [Featured Image feature](http://codex.wordpress.org/Post_Thumbnails) but instead uses a custom image field (probably from Advanced Custom Fields). Yoast's plugin, Jetpack, and presumably many others look for the Featured Image image when setting the opengraph met... |
159,176 | <p>Here's my code:</p>
<pre><code><?php query_posts(array ('showposts' => '1', 'cat' => '-11'));
if (have_posts()) : while (have_posts()) : the_post();
get_template_part( 'content', 'archives' );
endwhile;
endif; ?>
<?php query_posts(array ('showposts' => '3', 'offset' => '1'));
... | [
{
"answer_id": 159178,
"author": "mrwweb",
"author_id": 9844,
"author_profile": "https://wordpress.stackexchange.com/users/9844",
"pm_score": 4,
"selected": true,
"text": "<p>It appears that your site doesn't use the core WordPress <a href=\"http://codex.wordpress.org/Post_Thumbnails\" r... | 2014/08/26 | [
"https://wordpress.stackexchange.com/questions/159176",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19608/"
] | Here's my code:
```
<?php query_posts(array ('showposts' => '1', 'cat' => '-11'));
if (have_posts()) : while (have_posts()) : the_post();
get_template_part( 'content', 'archives' );
endwhile;
endif; ?>
<?php query_posts(array ('showposts' => '3', 'offset' => '1'));
if (have_posts()) : while (have_pos... | It appears that your site doesn't use the core WordPress [Featured Image feature](http://codex.wordpress.org/Post_Thumbnails) but instead uses a custom image field (probably from Advanced Custom Fields). Yoast's plugin, Jetpack, and presumably many others look for the Featured Image image when setting the opengraph met... |
159,177 | <p>I'm creating a theme with woocommerce which has the following: </p>
<pre><code><ul>
<li>
<?php
if( is_user_logged_in() ){
?>
<a href="<?php echo get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ); ?>" title="<?php _e( 'My Account', 'woothemes' ); ?>... | [
{
"answer_id": 159179,
"author": "hereswhatidid",
"author_id": 3032,
"author_profile": "https://wordpress.stackexchange.com/users/3032",
"pm_score": 6,
"selected": true,
"text": "<p>You could check to see if the 'WooCommerce' class exists, then run the code that requires WooCommerce.</p>... | 2014/08/26 | [
"https://wordpress.stackexchange.com/questions/159177",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17073/"
] | I'm creating a theme with woocommerce which has the following:
```
<ul>
<li>
<?php
if( is_user_logged_in() ){
?>
<a href="<?php echo get_permalink( get_option( 'woocommerce_myaccount_page_id' ) ); ?>" title="<?php _e( 'My Account', 'woothemes' ); ?>"><?php _e( 'My Account', 'woothemes' ); ?></a... | You could check to see if the 'WooCommerce' class exists, then run the code that requires WooCommerce.
```
<?php
if ( class_exists( 'WooCommerce' ) ) {
// code that requires WooCommerce
} else {
// you don't appear to have WooCommerce activated
}
?>
``` |
159,206 | <p>I can't find a solution for this anywhere, so help is highly appreciated!</p>
<p>The problem is, that my Dropbox account is losing aboz 48 GB's, so I had to remove my podcast episodes from there... because there are too many posts to change now, I want to add a note in the left sidebar. This note should only be see... | [
{
"answer_id": 159179,
"author": "hereswhatidid",
"author_id": 3032,
"author_profile": "https://wordpress.stackexchange.com/users/3032",
"pm_score": 6,
"selected": true,
"text": "<p>You could check to see if the 'WooCommerce' class exists, then run the code that requires WooCommerce.</p>... | 2014/08/26 | [
"https://wordpress.stackexchange.com/questions/159206",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58764/"
] | I can't find a solution for this anywhere, so help is highly appreciated!
The problem is, that my Dropbox account is losing aboz 48 GB's, so I had to remove my podcast episodes from there... because there are too many posts to change now, I want to add a note in the left sidebar. This note should only be seen on posts... | You could check to see if the 'WooCommerce' class exists, then run the code that requires WooCommerce.
```
<?php
if ( class_exists( 'WooCommerce' ) ) {
// code that requires WooCommerce
} else {
// you don't appear to have WooCommerce activated
}
?>
``` |
159,212 | <p>I've been given a task by my teacher to do a "social network" for a game. To begin with, I want to make a custom theme where people at first have the opportunity to register and login. As I have understood, it should already be such a function, or do I have to fix it myself if I make my own theme? You do not need to... | [
{
"answer_id": 159179,
"author": "hereswhatidid",
"author_id": 3032,
"author_profile": "https://wordpress.stackexchange.com/users/3032",
"pm_score": 6,
"selected": true,
"text": "<p>You could check to see if the 'WooCommerce' class exists, then run the code that requires WooCommerce.</p>... | 2014/08/26 | [
"https://wordpress.stackexchange.com/questions/159212",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58768/"
] | I've been given a task by my teacher to do a "social network" for a game. To begin with, I want to make a custom theme where people at first have the opportunity to register and login. As I have understood, it should already be such a function, or do I have to fix it myself if I make my own theme? You do not need to gi... | You could check to see if the 'WooCommerce' class exists, then run the code that requires WooCommerce.
```
<?php
if ( class_exists( 'WooCommerce' ) ) {
// code that requires WooCommerce
} else {
// you don't appear to have WooCommerce activated
}
?>
``` |
159,215 | <p>In header.php I can do the following:</p>
<pre><code><base href="<?php echo get_bloginfo('template_url');?>/"/>
</code></pre>
<p>That way I can keep my layout images path relative.</p>
<pre><code> <img src="imgs/img.png"/>
</code></pre>
<p>Instead of </p>
<pre><code> <img src="<?php ... | [
{
"answer_id": 159253,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 0,
"selected": false,
"text": "<p>Personally I wouldn't use it - I see no real advantage over using absolute <code>href</code> and <code>src... | 2014/08/26 | [
"https://wordpress.stackexchange.com/questions/159215",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30984/"
] | In header.php I can do the following:
```
<base href="<?php echo get_bloginfo('template_url');?>/"/>
```
That way I can keep my layout images path relative.
```
<img src="imgs/img.png"/>
```
Instead of
```
<img src="<?php echo get_bloginfo('template_url');?>"/>
```
Is there any downside of settings the ... | So in general there are two opinions on absolute versus relative URLs:
* use relative URLs because easier to move around
* use absolute URLs because easier to move around
Confusing, yes. The argument boils down to that migrating things with relative URLs you don't need to change domain. The counter argument is that y... |
159,216 | <p>The "Add Media" button allows any media to be added to current editor. I need the "Uploaded to this page" from the dropdown menu to be the only option available. Some time ago I found a solution somewhere like this:</p>
<pre><code>jQuery(function($){
$(document).on("DOMNodeInserted", function(){
// Lock... | [
{
"answer_id": 159217,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 0,
"selected": false,
"text": "<p>This is what I've found which I use regularly. Really it's the same thing you're using but placing it into ... | 2014/08/26 | [
"https://wordpress.stackexchange.com/questions/159216",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57012/"
] | The "Add Media" button allows any media to be added to current editor. I need the "Uploaded to this page" from the dropdown menu to be the only option available. Some time ago I found a solution somewhere like this:
```
jQuery(function($){
$(document).on("DOMNodeInserted", function(){
// Lock uploads to "U... | Maybe I was over thinking, but the solution is easier than I thought.
I just have to limit the event handler to some element, so other unrelated ones will not trigger the handler. In this case, `.media-modal` is the overall parent of the media library element, so I am specifying this extra selector to the event, like ... |
159,247 | <p>In my all post page there is share button (via <a href="https://wordpress.org/plugins/addthis/" rel="nofollow">AddThis plugin</a>).</p>
<p>When I click to share on Facebook, it takes the URL and title, but images is showing something else. <a href="http://www.thefansworld.com/happy-new-year-trailer/" rel="nofollow"... | [
{
"answer_id": 159250,
"author": "Carlos Faria",
"author_id": 39047,
"author_profile": "https://wordpress.stackexchange.com/users/39047",
"pm_score": 0,
"selected": false,
"text": "<p>What about using the <strong>u</strong> var to share your url and let facebook get the content using Ope... | 2014/08/27 | [
"https://wordpress.stackexchange.com/questions/159247",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/49649/"
] | In my all post page there is share button (via [AddThis plugin](https://wordpress.org/plugins/addthis/)).
When I click to share on Facebook, it takes the URL and title, but images is showing something else. [For example](http://www.thefansworld.com/happy-new-year-trailer/).
I tried to make a custom share button which... | After here and there for long i find the solution for above :
Replaced above meta tag with below
```
<?php if ( have_posts() ) while ( have_posts() ) : the_post(); ?>
<?php $image = wp_get_attachment_image_src( get_post_thumbnail_id( $post->ID ), 'single-post-thumbnail' ); ?>
<?php if($image[0] != "" ){ ?>
<meta ... |
159,254 | <p>I'm building a template page for submit a profile changes. I would like to show a 'correct' message in green(example) for the user knows. </p>
<p>Here my template code:</p>
<pre><code><?php
global $avia_config;
/**
* Template Name: User Profile
*
* Allow users to update their profiles from Frontend.
*
*/
... | [
{
"answer_id": 159258,
"author": "Jasper",
"author_id": 54616,
"author_profile": "https://wordpress.stackexchange.com/users/54616",
"pm_score": -1,
"selected": false,
"text": "<p>is this page in front-end or within wp-admin? If the latter you can easily use <code>admin_notices</code> for... | 2014/08/27 | [
"https://wordpress.stackexchange.com/questions/159254",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58546/"
] | I'm building a template page for submit a profile changes. I would like to show a 'correct' message in green(example) for the user knows.
Here my template code:
```
<?php
global $avia_config;
/**
* Template Name: User Profile
*
* Allow users to update their profiles from Frontend.
*
*/
/* Get user info. */
glo... | I solved the problem. First I check if there are errors and then I add a custom redirect url like this:
```
if ( count($error) == 0 ) {
wp_redirect( get_permalink() . '?updated=true' );
}
```
And finally I added a message using 'GET' method:
```
<?php if ( $_GET['updated'] == 'true' ) : ?> <p class="form-submi... |
159,257 | <p>Eight months ago I asked nearly the same question over <a href="https://wordpress.stackexchange.com/questions/125576/ajax-request-not-coming-back-to-class">there</a>. But the Problem is still not solved so far. </p>
<p>But I have an additional ideaa why it is failing. In the meantime my code advanced. I have multip... | [
{
"answer_id": 159259,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 1,
"selected": false,
"text": "<p>Your <code>McAdmin</code> seems fine - the problem is likely one of two reasons:</p>\n\n<ol>\n<li>Another ... | 2014/08/27 | [
"https://wordpress.stackexchange.com/questions/159257",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12614/"
] | Eight months ago I asked nearly the same question over [there](https://wordpress.stackexchange.com/questions/125576/ajax-request-not-coming-back-to-class). But the Problem is still not solved so far.
But I have an additional ideaa why it is failing. In the meantime my code advanced. I have multiple classes which all ... | Your `McAdmin` seems fine - the problem is likely one of two reasons:
1. Another AJAX hook for `blubb` is terminating the script before `McAdmin::get_vehicle`
2. You need to add the same hook for `wp_ajax_nopriv_blubb` - for non-logged in AJAX requests (otherwise it fails silently).
If neither is the cause, you need ... |
159,273 | <p>I have an overlay of project's tags, and I want to display them like a list and NOT with a coma like it appears bellow, in the attachment.
Here is the code :</p>
<pre><code><p class="nom"> <?php echo strip_tags (get_the_term_list( get_the_ID(), 'project_tag', '',', ')); ?></p>
</code></pre>
<p>An... | [
{
"answer_id": 159259,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 1,
"selected": false,
"text": "<p>Your <code>McAdmin</code> seems fine - the problem is likely one of two reasons:</p>\n\n<ol>\n<li>Another ... | 2014/08/27 | [
"https://wordpress.stackexchange.com/questions/159273",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57351/"
] | I have an overlay of project's tags, and I want to display them like a list and NOT with a coma like it appears bellow, in the attachment.
Here is the code :
```
<p class="nom"> <?php echo strip_tags (get_the_term_list( get_the_ID(), 'project_tag', '',', ')); ?></p>
```
Any idea ?
I already tried to insert a
```
<... | Your `McAdmin` seems fine - the problem is likely one of two reasons:
1. Another AJAX hook for `blubb` is terminating the script before `McAdmin::get_vehicle`
2. You need to add the same hook for `wp_ajax_nopriv_blubb` - for non-logged in AJAX requests (otherwise it fails silently).
If neither is the cause, you need ... |
159,302 | <p>I am working on a product page where I show reviews from my post type 'reviews', if the product page title matches with my term from the taxonomy 'review-product'.</p>
<p><strong>Example.</strong></p>
<p>Product page title: <strong>Refrigerator</strong></p>
<p>Show (reviews) posts with: </p>
<ul>
<li>Post type: ... | [
{
"answer_id": 159309,
"author": "David",
"author_id": 31323,
"author_profile": "https://wordpress.stackexchange.com/users/31323",
"pm_score": 5,
"selected": true,
"text": "<p>You cannot use the same object of <code>WP_Query</code> twice. Therefore you need to create another one with a <... | 2014/08/27 | [
"https://wordpress.stackexchange.com/questions/159302",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25834/"
] | I am working on a product page where I show reviews from my post type 'reviews', if the product page title matches with my term from the taxonomy 'review-product'.
**Example.**
Product page title: **Refrigerator**
Show (reviews) posts with:
* Post type: 'reviews'
* Taxonomy: 'review-product'
* Term: **Refrigerator... | You cannot use the same object of `WP_Query` twice. Therefore you need to create another one with a `tax_query` parameter to fetch posts which are not assigned to any term.
```
//fetch all reviews which have no assigned term in 'review-product'
$taxonomy = 'review-product';
$post_type = 'reviews';
$args = [
'pos... |
159,303 | <p>Wordpress has placed an uncalled for character on one of our page's text. We have a few hundred pages, and this only occurs on one. In the paragraph's text, between the words 'Music' and 'Students', WordPress has placed a [X] character. It is not in the visual or text views, and only appears on the actual page. It c... | [
{
"answer_id": 159309,
"author": "David",
"author_id": 31323,
"author_profile": "https://wordpress.stackexchange.com/users/31323",
"pm_score": 5,
"selected": true,
"text": "<p>You cannot use the same object of <code>WP_Query</code> twice. Therefore you need to create another one with a <... | 2014/08/27 | [
"https://wordpress.stackexchange.com/questions/159303",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/15360/"
] | Wordpress has placed an uncalled for character on one of our page's text. We have a few hundred pages, and this only occurs on one. In the paragraph's text, between the words 'Music' and 'Students', WordPress has placed a [X] character. It is not in the visual or text views, and only appears on the actual page. It cann... | You cannot use the same object of `WP_Query` twice. Therefore you need to create another one with a `tax_query` parameter to fetch posts which are not assigned to any term.
```
//fetch all reviews which have no assigned term in 'review-product'
$taxonomy = 'review-product';
$post_type = 'reviews';
$args = [
'pos... |
159,330 | <p>I've created custom taxonomy called 'cities' where you can add cities and added custom field ( radio button ) with 2 options: 'Yes' and 'No' ( never mind what that is ).
Everythins is ok, I can get that value and other stuff.</p>
<p>Later on I came with idea to add a sortable column ( Like 'Name', 'Slug', 'Posts' e... | [
{
"answer_id": 160050,
"author": "aifrim",
"author_id": 58040,
"author_profile": "https://wordpress.stackexchange.com/users/58040",
"pm_score": 0,
"selected": false,
"text": "<p>A custom field is a custom post meta data made by the user or a theme/plugin, in this case that custom field i... | 2014/08/27 | [
"https://wordpress.stackexchange.com/questions/159330",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50511/"
] | I've created custom taxonomy called 'cities' where you can add cities and added custom field ( radio button ) with 2 options: 'Yes' and 'No' ( never mind what that is ).
Everythins is ok, I can get that value and other stuff.
Later on I came with idea to add a sortable column ( Like 'Name', 'Slug', 'Posts' etc. ).
I'v... | I had a similar problem and managed to solve it. In my case I have a custom taxonomy, `issue`, which contains a required date picker custom field using the [ACF PRO](http://advancedcustomfields.com) plugin—the field name is `issue_date`. I wanted to add the date column to my `issue` edit screen at `wp-admin/edit-tags.p... |
159,338 | <p>I've been hired to modify/update/change an existing WordPress theme. The site is already live, and I'm wondering how to work on the theme locally first.</p>
| [
{
"answer_id": 160050,
"author": "aifrim",
"author_id": 58040,
"author_profile": "https://wordpress.stackexchange.com/users/58040",
"pm_score": 0,
"selected": false,
"text": "<p>A custom field is a custom post meta data made by the user or a theme/plugin, in this case that custom field i... | 2014/08/27 | [
"https://wordpress.stackexchange.com/questions/159338",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58823/"
] | I've been hired to modify/update/change an existing WordPress theme. The site is already live, and I'm wondering how to work on the theme locally first. | I had a similar problem and managed to solve it. In my case I have a custom taxonomy, `issue`, which contains a required date picker custom field using the [ACF PRO](http://advancedcustomfields.com) plugin—the field name is `issue_date`. I wanted to add the date column to my `issue` edit screen at `wp-admin/edit-tags.p... |
159,365 | <p>I have been noticing of late, after I upload my sites to a different server, I seem to have some sort of upload problem</p>
<ol>
<li>Once I have copied and moved site using FTP to a new host I then can not upload new plugins through <code>wp-admin</code> because I get:
<blockquote>
<p>Could not create directory.... | [
{
"answer_id": 159380,
"author": "Advanced SEO",
"author_id": 25053,
"author_profile": "https://wordpress.stackexchange.com/users/25053",
"pm_score": 0,
"selected": false,
"text": "<p>This could be problem with file permissions and ownership on server. If you have SSH privilege on your s... | 2014/08/28 | [
"https://wordpress.stackexchange.com/questions/159365",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54779/"
] | I have been noticing of late, after I upload my sites to a different server, I seem to have some sort of upload problem
1. Once I have copied and moved site using FTP to a new host I then can not upload new plugins through `wp-admin` because I get:
>
> Could not create directory.),
>
>
>
2. I can't upload media o... | First issue is related with ownership of the directory.
Second issue is, you will have to make directory within directory so consider using following UNIX command:
```
sudo mkdir -p wp-content/uploads/2014/08
```
here p flag lets you create directory within directory
Third issue is related with the file permissions... |
159,376 | <p>I have a custom post type to which I'd like to programmatically import data. I have followed <a href="http://tommcfarlin.com/programmatically-create-a-post-in-wordpress/" rel="nofollow">these instructions</a> and <a href="http://codex.wordpress.org/Function_Reference/wp_insert_post" rel="nofollow">these</a>, and I ... | [
{
"answer_id": 159377,
"author": "RRikesh",
"author_id": 17305,
"author_profile": "https://wordpress.stackexchange.com/users/17305",
"pm_score": 5,
"selected": true,
"text": "<p>You should first run the <code>wp_insert_post()</code> which will return the post ID. Then use that post ID to... | 2014/08/28 | [
"https://wordpress.stackexchange.com/questions/159376",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37934/"
] | I have a custom post type to which I'd like to programmatically import data. I have followed [these instructions](http://tommcfarlin.com/programmatically-create-a-post-in-wordpress/) and [these](http://codex.wordpress.org/Function_Reference/wp_insert_post), and I can easily do it for WP typical pages and posts.
Howeve... | You should first run the `wp_insert_post()` which will return the post ID. Then use that post ID to add your custom fields. Use [`add_post_meta()`](https://codex.wordpress.org/Function_Reference/add_post_meta) to add the custom fields.
```
$post_id = wp_insert_post( $args );
add_post_meta( $post_id, 'longitude', $my_... |
159,392 | <p>In my WordPress site I have created a custom field for author website link. but I don't know how to make it hyperlink, so people can click on it to surf that website. at this moment it only shows raw text. like: <code>"www.example.com"</code></p>
<p>my code is:</p>
<pre><code><?php echo get_post_meta($post->... | [
{
"answer_id": 159394,
"author": "Robert hue",
"author_id": 22461,
"author_profile": "https://wordpress.stackexchange.com/users/22461",
"pm_score": 4,
"selected": true,
"text": "<p>Use this.</p>\n\n<pre><code>get_post_meta($post->ID, 'custom-field-name', true);\n</code></pre>\n\n<p>Wh... | 2014/08/28 | [
"https://wordpress.stackexchange.com/questions/159392",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58375/"
] | In my WordPress site I have created a custom field for author website link. but I don't know how to make it hyperlink, so people can click on it to surf that website. at this moment it only shows raw text. like: `"www.example.com"`
my code is:
```
<?php echo get_post_meta($post->ID, 'Author Website', true); ?>
``` | Use this.
```
get_post_meta($post->ID, 'custom-field-name', true);
```
Where custom-field-name is the name of the custom field. You will have to add your custom field name in place of custom-field-name.
Also to open link in new browser window/tab add `target="_blank"`. Always use `esc_url()` for URLs and `esc_html(... |
159,397 | <p>I have searched for adding featuring image to rss feed with no plug-in for WordPress. I have found some examples and applied how it was instructed. But All I have got now is nothing. Still can't reach the image.</p>
<p>The last and the best (according to me) solution (as told <a href="http://www.hughlashbrooke.com... | [
{
"answer_id": 159398,
"author": "Robert hue",
"author_id": 22461,
"author_profile": "https://wordpress.stackexchange.com/users/22461",
"pm_score": 5,
"selected": true,
"text": "<p>Here is a great <a href=\"http://www.wpcodesnippet.com/rss-feeds/display-featured-post-thumbnails-wordpress... | 2014/08/28 | [
"https://wordpress.stackexchange.com/questions/159397",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48667/"
] | I have searched for adding featuring image to rss feed with no plug-in for WordPress. I have found some examples and applied how it was instructed. But All I have got now is nothing. Still can't reach the image.
The last and the best (according to me) solution (as told [here](http://www.hughlashbrooke.com/wordpress-ad... | Here is a great [example](http://www.wpcodesnippet.com/rss-feeds/display-featured-post-thumbnails-wordpress-feeds/). How to display featured post thumbnails in WordPress feeds
paste this code snippet in your theme functions.php file
```
// display featured post thumbnails in WordPress feeds
function wcs_post_thumbnai... |
159,403 | <p>I'm using a child theme. I want to make a change to a file which currently resides in:</p>
<blockquote>
<p>mybasetheme>includes>sf-content-display>sf-post-layouts.php</p>
</blockquote>
<p>So I copied the exact same file structure into my child theme and copied the file over:</p>
<blockquote>
<p>mychildtheme>i... | [
{
"answer_id": 159404,
"author": "Shail",
"author_id": 54036,
"author_profile": "https://wordpress.stackexchange.com/users/54036",
"pm_score": 0,
"selected": false,
"text": "<p>Just change only function that you want to edit.\nSee <a href=\"http://www.venutip.com/content/right-way-overri... | 2014/08/28 | [
"https://wordpress.stackexchange.com/questions/159403",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/34215/"
] | I'm using a child theme. I want to make a change to a file which currently resides in:
>
> mybasetheme>includes>sf-content-display>sf-post-layouts.php
>
>
>
So I copied the exact same file structure into my child theme and copied the file over:
>
> mychildtheme>includes>sf-content-display>sf-post-layouts.php
> ... | When it comes to the template hierarchy, WordPress will indeed look in the child theme directory before loading from the main theme.
For all other non-specific WordPress files (like functions and 3rd party includes), it's entirely up to the main theme to decide how to load them.
Unless the theme is using `locate_temp... |
159,462 | <p>It looks like there is not an easy way to add autocomplete="off" to the password input on the WordPress login page without editing the wp-login.php page directly. </p>
<p>Is there something I'm missing? I do not want to modify core files.</p>
| [
{
"answer_id": 159464,
"author": "TheDeadMedic",
"author_id": 1685,
"author_profile": "https://wordpress.stackexchange.com/users/1685",
"pm_score": 4,
"selected": true,
"text": "<p>Your only solution (without modifying core files) is to use JavaScript.</p>\n\n<pre><code>function wpse_159... | 2014/08/28 | [
"https://wordpress.stackexchange.com/questions/159462",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58871/"
] | It looks like there is not an easy way to add autocomplete="off" to the password input on the WordPress login page without editing the wp-login.php page directly.
Is there something I'm missing? I do not want to modify core files. | Your only solution (without modifying core files) is to use JavaScript.
```
function wpse_159462_login_form() {
echo <<<html
<script>
document.getElementById( "user_pass" ).autocomplete = "off";
</script>
html;
}
add_action( 'login_form', 'wpse_159462_login_form' );
```
Having said that, if you're not the o... |
159,474 | <p>I would like to have a list of posts that is first ordered by day, and then within that day ordered user votes (stored as a meta field). </p>
<p>Would it be better to convert each timestamp to the day at the time of the query, or to create another meta field that stores the day? Or is there a better solution?</p>
| [
{
"answer_id": 159653,
"author": "Tomás Cot",
"author_id": 57843,
"author_profile": "https://wordpress.stackexchange.com/users/57843",
"pm_score": 3,
"selected": true,
"text": "<p>This is what I've found. I'm using a filter to filter the ORDER BY on the SQL query generated by WP_Query. T... | 2014/08/28 | [
"https://wordpress.stackexchange.com/questions/159474",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9862/"
] | I would like to have a list of posts that is first ordered by day, and then within that day ordered user votes (stored as a meta field).
Would it be better to convert each timestamp to the day at the time of the query, or to create another meta field that stores the day? Or is there a better solution? | This is what I've found. I'm using a filter to filter the ORDER BY on the SQL query generated by WP\_Query. The filter is this [`posts_orderby`](http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_orderby). And with it, you can write a custom ORDER BY for the query. I'm gonna show you an example.
```
add_filt... |
159,475 | <p>I am unable to add media to a page. I click the button on the page edit page and nothing happens. The web console of firefox says "TypeError: wp.Uploader is undefined". I already tried deactivating installed plug-ins and I set the default theme ("Twenty Fourteen"). I googled this problem and I only find people who a... | [
{
"answer_id": 159653,
"author": "Tomás Cot",
"author_id": 57843,
"author_profile": "https://wordpress.stackexchange.com/users/57843",
"pm_score": 3,
"selected": true,
"text": "<p>This is what I've found. I'm using a filter to filter the ORDER BY on the SQL query generated by WP_Query. T... | 2014/08/28 | [
"https://wordpress.stackexchange.com/questions/159475",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58877/"
] | I am unable to add media to a page. I click the button on the page edit page and nothing happens. The web console of firefox says "TypeError: wp.Uploader is undefined". I already tried deactivating installed plug-ins and I set the default theme ("Twenty Fourteen"). I googled this problem and I only find people who are ... | This is what I've found. I'm using a filter to filter the ORDER BY on the SQL query generated by WP\_Query. The filter is this [`posts_orderby`](http://codex.wordpress.org/Plugin_API/Filter_Reference/posts_orderby). And with it, you can write a custom ORDER BY for the query. I'm gonna show you an example.
```
add_filt... |
159,482 | <p>I'm trying to upload a custom Gravatar to Wordpress, however something is breaking the image link and I'm not sure how to fix it. </p>
<pre><code>add_filter( 'avatar_defaults', 'new_default_avatar' );
function new_default_avatar ( $avatar_defaults ) {
//Set the URL where the image file for your avatar is locat... | [
{
"answer_id": 159490,
"author": "Robert hue",
"author_id": 22461,
"author_profile": "https://wordpress.stackexchange.com/users/22461",
"pm_score": 0,
"selected": false,
"text": "<p>This is because of Photon addon you enabled in JetPack plugin. That's why your image URLs will be like...<... | 2014/08/28 | [
"https://wordpress.stackexchange.com/questions/159482",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58880/"
] | I'm trying to upload a custom Gravatar to Wordpress, however something is breaking the image link and I'm not sure how to fix it.
```
add_filter( 'avatar_defaults', 'new_default_avatar' );
function new_default_avatar ( $avatar_defaults ) {
//Set the URL where the image file for your avatar is located
$new_av... | I think the problem is simply that your *default* avatar isn't **publicly available**.
Try for example
<http://upload.wikimedia.org/wikipedia/en/b/b0/Avatar-Teaser-Poster.jpg>
instead of
```
http://loalhost:888/wordpress/wp-content/themes/blog-theme/img/icons/avatar.jpg
```
Notice that the default gravatar is se... |
159,591 | <p>I am currently studying Wordpress AJAX but keep getting error message (so the success function is not being executed)</p>
<p>Currently I have changed the header.php (of twentythirteen theme) to include JavaScript that sends AJAX Request.</p>
<pre><code><script src="<?php echo get_template_directory_uri(); ?&... | [
{
"answer_id": 159596,
"author": "stijn.aerts",
"author_id": 57077,
"author_profile": "https://wordpress.stackexchange.com/users/57077",
"pm_score": -1,
"selected": false,
"text": "<p>Try to use complete instead of succes.</p>\n\n<p>Also, including wp-load isn't the best practice, what i... | 2014/08/30 | [
"https://wordpress.stackexchange.com/questions/159591",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58665/"
] | I am currently studying Wordpress AJAX but keep getting error message (so the success function is not being executed)
Currently I have changed the header.php (of twentythirteen theme) to include JavaScript that sends AJAX Request.
```
<script src="<?php echo get_template_directory_uri(); ?>/js/html5.js"></script>
<![... | There are **tons** of questions about using Ajax, so your question could be easily marked as duplicated but I see so BIG mistakes that I can't say to you that the question is duplicated without explaining your mistakes.
1. The Ajax in Wordpress is handled in admin-ajax.php file, wehre you correctly sent the ajax reque... |
159,600 | <p>When trying to install multisite on my wordpress blog, I get a blank page on the 2nd step where I should get the options to choose from subdomain or sub directory. I've tried installing on several occasions and still the same problem persists. All plugins are deactivated. Help plsssss</p>
| [
{
"answer_id": 159596,
"author": "stijn.aerts",
"author_id": 57077,
"author_profile": "https://wordpress.stackexchange.com/users/57077",
"pm_score": -1,
"selected": false,
"text": "<p>Try to use complete instead of succes.</p>\n\n<p>Also, including wp-load isn't the best practice, what i... | 2014/08/30 | [
"https://wordpress.stackexchange.com/questions/159600",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58950/"
] | When trying to install multisite on my wordpress blog, I get a blank page on the 2nd step where I should get the options to choose from subdomain or sub directory. I've tried installing on several occasions and still the same problem persists. All plugins are deactivated. Help plsssss | There are **tons** of questions about using Ajax, so your question could be easily marked as duplicated but I see so BIG mistakes that I can't say to you that the question is duplicated without explaining your mistakes.
1. The Ajax in Wordpress is handled in admin-ajax.php file, wehre you correctly sent the ajax reque... |
159,620 | <p>In Wordpress single.php post pages are both for media attachments (e.g. <a href="http://domain.se/postname/imagename/" rel="nofollow">http://domain.se/postname/imagename/</a>) and blog post pages.</p>
<p>What conditional tag can I use to determine if a post is not a media attachment but a normal blog post?</p>
<p>... | [
{
"answer_id": 159596,
"author": "stijn.aerts",
"author_id": 57077,
"author_profile": "https://wordpress.stackexchange.com/users/57077",
"pm_score": -1,
"selected": false,
"text": "<p>Try to use complete instead of succes.</p>\n\n<p>Also, including wp-load isn't the best practice, what i... | 2014/08/30 | [
"https://wordpress.stackexchange.com/questions/159620",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58690/"
] | In Wordpress single.php post pages are both for media attachments (e.g. <http://domain.se/postname/imagename/>) and blog post pages.
What conditional tag can I use to determine if a post is not a media attachment but a normal blog post?
The reason why I want to determine this is because at the moment I have customize... | There are **tons** of questions about using Ajax, so your question could be easily marked as duplicated but I see so BIG mistakes that I can't say to you that the question is duplicated without explaining your mistakes.
1. The Ajax in Wordpress is handled in admin-ajax.php file, wehre you correctly sent the ajax reque... |
159,627 | <p>I'm displaying a simple sitemap with <em>wp_list_pages();</em></p>
<pre><code>$args = array(
'sort_column' => 'menu_order',
'title_li' => '',
'post_status' => 'publish'
);
wp_list_pages( $args );
</code></pre>
<p>The problem is that by default this also shows the published children of draft ... | [
{
"answer_id": 159640,
"author": "gmazzap",
"author_id": 35541,
"author_profile": "https://wordpress.stackexchange.com/users/35541",
"pm_score": 2,
"selected": false,
"text": "<p>Sincerly I found custom walkers annoying: sometimes what can be done with a simple filter require an entire c... | 2014/08/30 | [
"https://wordpress.stackexchange.com/questions/159627",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1381/"
] | I'm displaying a simple sitemap with *wp\_list\_pages();*
```
$args = array(
'sort_column' => 'menu_order',
'title_li' => '',
'post_status' => 'publish'
);
wp_list_pages( $args );
```
The problem is that by default this also shows the published children of draft pages, like so :
>
> Page 1 (published... | Great answers above. I took on the challenge trying to find yet another way to solve this.
The `exclude` parameter:
------------------------
We could try:
```
'exclude' => wpse_exclude_drafts_branches()
```
where:
```
function wpse_exclude_drafts_branches()
{
global $wpdb;
$exclude = array();
$result... |
159,634 | <p>I'm working on a widget that do some magic with jQuery (slide,fades elements). The problem is that the jQuery script attached to widget is not called when I delete and then replace the widget in the sidebar . </p>
<p>Even If I have in the form function something like this :</p>
<pre><code>public function form( $in... | [
{
"answer_id": 159637,
"author": "Michael Khalili",
"author_id": 27742,
"author_profile": "https://wordpress.stackexchange.com/users/27742",
"pm_score": 2,
"selected": true,
"text": "<p>You can hook into the <code>DOMNodeInserted</code> event to find out when your widget has been added t... | 2014/08/30 | [
"https://wordpress.stackexchange.com/questions/159634",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58900/"
] | I'm working on a widget that do some magic with jQuery (slide,fades elements). The problem is that the jQuery script attached to widget is not called when I delete and then replace the widget in the sidebar .
Even If I have in the form function something like this :
```
public function form( $instance ) {
wp_re... | You can hook into the `DOMNodeInserted` event to find out when your widget has been added to the side bar.
```
jQuery(document).on('DOMNodeInserted', '.widget-top', function () {
alert(jQuery('.widget-title', this).text());
});
```
The code above will alert to any newly added widget. Once you're hooked into t... |
159,638 | <p>I am trying to pass a variable value to my JS file using <code>wp_localize_script</code> and setting a function's one of the options to either <code>true</code> or <code>false</code>. Despite of all my efforts, its not working.</p>
<p>Here is what I have in head.</p>
<pre><code><script type='text/javascript'>... | [
{
"answer_id": 159645,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 2,
"selected": false,
"text": "<p><code>var CUPID = {\"button\":\"false\"};</code></p>\n\n<p>The false here should not have quotes around it.</p>\n"... | 2014/08/30 | [
"https://wordpress.stackexchange.com/questions/159638",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/26991/"
] | I am trying to pass a variable value to my JS file using `wp_localize_script` and setting a function's one of the options to either `true` or `false`. Despite of all my efforts, its not working.
Here is what I have in head.
```
<script type='text/javascript'>
/* <![CDATA[ */
var CUPID = {"button":"false"};
/* ]]> */
... | `var CUPID = {"button":"false"};`
The false here should not have quotes around it. |
159,649 | <p>So I am attempting to create a series of functions that calculate a price based on a client level I have set for each customer. Some customers may have a special deal. </p>
<p>To do this, I created a custom meta field in the user meta that allows me to assign either High, medium, or low to that client. </p>
<p>I t... | [
{
"answer_id": 159652,
"author": "Benoti",
"author_id": 58141,
"author_profile": "https://wordpress.stackexchange.com/users/58141",
"pm_score": 0,
"selected": false,
"text": "<p>You can read this: <a href=\"http://codex.wordpress.org/Function_Reference/get_userdata\" rel=\"nofollow\"><co... | 2014/08/30 | [
"https://wordpress.stackexchange.com/questions/159649",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57845/"
] | So I am attempting to create a series of functions that calculate a price based on a client level I have set for each customer. Some customers may have a special deal.
To do this, I created a custom meta field in the user meta that allows me to assign either High, medium, or low to that client.
I then created a fun... | The problem is that when you pass the `$key` argument on `get_user_meta()` function, you don't pass a valid argument. The `$key` must be a string according to the [documentation page](http://codex.wordpress.org/Function_Reference/get_user_meta). It represents the value of `meta_key` in the `wp_usermeta` table.
If wit... |
159,658 | <p>I understand how to register a custom post type, customize the slug and decide whether to add the 'front' (the WP permalink settings) or not.</p>
<p>What I'd like to do is customize the permalink by adding</p>
<pre><code>?username
</code></pre>
<p>At the end of the custom post type's url. Now I know the cleaned ... | [
{
"answer_id": 159652,
"author": "Benoti",
"author_id": 58141,
"author_profile": "https://wordpress.stackexchange.com/users/58141",
"pm_score": 0,
"selected": false,
"text": "<p>You can read this: <a href=\"http://codex.wordpress.org/Function_Reference/get_userdata\" rel=\"nofollow\"><co... | 2014/08/30 | [
"https://wordpress.stackexchange.com/questions/159658",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45248/"
] | I understand how to register a custom post type, customize the slug and decide whether to add the 'front' (the WP permalink settings) or not.
What I'd like to do is customize the permalink by adding
```
?username
```
At the end of the custom post type's url. Now I know the cleaned up Author Name can be added in the... | The problem is that when you pass the `$key` argument on `get_user_meta()` function, you don't pass a valid argument. The `$key` must be a string according to the [documentation page](http://codex.wordpress.org/Function_Reference/get_user_meta). It represents the value of `meta_key` in the `wp_usermeta` table.
If wit... |
159,684 | <p>I'm creating a search widget and for that I use a secondary loop via new WP_Query();</p>
<pre><code>$query = new WP_Query('s=searchTerm');
if ($query->have_posts()){
while ($query->have_posts()){
$query->the_post();
//echo the post
}
wp_reset_postdata();
}
else {
echo 'No re... | [
{
"answer_id": 159687,
"author": "Abhik",
"author_id": 26991,
"author_profile": "https://wordpress.stackexchange.com/users/26991",
"pm_score": 0,
"selected": false,
"text": "<p>Try adding the <code>offset</code> parameter into the arguments..</p>\n\n<pre><code>$query = new WP_Query( arra... | 2014/08/31 | [
"https://wordpress.stackexchange.com/questions/159684",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58900/"
] | I'm creating a search widget and for that I use a secondary loop via new WP\_Query();
```
$query = new WP_Query('s=searchTerm');
if ($query->have_posts()){
while ($query->have_posts()){
$query->the_post();
//echo the post
}
wp_reset_postdata();
}
else {
echo 'No results';
die();
}
... | The title of question is inaccurate. I think you don't want to escape first post, instead you want to exclude current post. You can use the `post__not_in` argument in `WP_Query`.
```
$args = array( 's' => 'searchTerm' );
//Check if we are in a post of any type
if( is_singular() ) {
$post = get_queried_object();
... |
159,697 | <p>I am working on listing all users similar to the <a href="https://wordpress.stackexchange.com/users">Users</a> page here on SE. </p>
<p>When listing each user, I want to add their 2 categories they have published most into. All categories are within <code>Posts</code>.</p>
<p>Performance is essential, therefore I'... | [
{
"answer_id": 159816,
"author": "Stubbies",
"author_id": 38933,
"author_profile": "https://wordpress.stackexchange.com/users/38933",
"pm_score": 0,
"selected": false,
"text": "<pre><code><?php \n\n $key = 'user_top_categories'; // User meta key for the top categories\n $single = fa... | 2014/08/31 | [
"https://wordpress.stackexchange.com/questions/159697",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24875/"
] | I am working on listing all users similar to the [Users](https://wordpress.stackexchange.com/users) page here on SE.
When listing each user, I want to add their 2 categories they have published most into. All categories are within `Posts`.
Performance is essential, therefore I've come up with a sufficient solution:
... | This can be done easily with `$wpdb`, here's my approach:
```
function GetTop2CategoryByUser($user_id, $taxonomy){
global $wpdb;
$results=$wpdb->get_results( $wpdb->prepare(
"
SELECT tt.term_id as category, COUNT(p.ID) as count
FROM $wpdb->posts p
JOIN $wpdb->ter... |
159,699 | <p>I have registered a custom post type <code>city</code> with 2 taxonomies <code>city_categories</code> and <code>cities</code>. But wordpress is taking archive.php instead of archive-city.php, don't understand where am I mistaking. It works only if I create a taxonomy-cities.php and then is taking taxonomies-cities.p... | [
{
"answer_id": 159816,
"author": "Stubbies",
"author_id": 38933,
"author_profile": "https://wordpress.stackexchange.com/users/38933",
"pm_score": 0,
"selected": false,
"text": "<pre><code><?php \n\n $key = 'user_top_categories'; // User meta key for the top categories\n $single = fa... | 2014/08/31 | [
"https://wordpress.stackexchange.com/questions/159699",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/133527/"
] | I have registered a custom post type `city` with 2 taxonomies `city_categories` and `cities`. But wordpress is taking archive.php instead of archive-city.php, don't understand where am I mistaking. It works only if I create a taxonomy-cities.php and then is taking taxonomies-cities.php. How can I make it take directly ... | This can be done easily with `$wpdb`, here's my approach:
```
function GetTop2CategoryByUser($user_id, $taxonomy){
global $wpdb;
$results=$wpdb->get_results( $wpdb->prepare(
"
SELECT tt.term_id as category, COUNT(p.ID) as count
FROM $wpdb->posts p
JOIN $wpdb->ter... |
159,740 | <p>I want to do a very basic AJAX call where, on click of a list item, a container div fills with associated content pulled from a Wordpress page. I'm a newb with AJAX; I've tried a few different routes today but to no avail. I got the page to load in the container but I want only the post content (as if I called the_c... | [
{
"answer_id": 159745,
"author": "Tomás Cot",
"author_id": 57843,
"author_profile": "https://wordpress.stackexchange.com/users/57843",
"pm_score": 0,
"selected": false,
"text": "<p>You are gonna need a PHP code like this, you can add it to the functions.php, or I would recommend creating... | 2014/09/01 | [
"https://wordpress.stackexchange.com/questions/159740",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55073/"
] | I want to do a very basic AJAX call where, on click of a list item, a container div fills with associated content pulled from a Wordpress page. I'm a newb with AJAX; I've tried a few different routes today but to no avail. I got the page to load in the container but I want only the post content (as if I called the\_con... | Create the [JSON endpoint](http://v2.wp-api.org/extending/adding/) that accepts a [`WP_Post`](https://codex.wordpress.org/Class_Reference/WP_Post) ID.
```
add_action( 'rest_api_init', function() {
register_rest_route( 'api/v2', '/post/(?<id>\d+)', array (
'methods' => 'GET',
'callback' => 'get_pos... |
159,756 | <p>I'm using a modified version of the Recent Posts plugin together with WP Total Cache. I'm using post__not_in as I don't want to display the current post again. It works well, but if Object Cache is activated, on some posts post__not_in does not work.</p>
<p>Here is my code:</p>
<pre><code><?php function nothing... | [
{
"answer_id": 159745,
"author": "Tomás Cot",
"author_id": 57843,
"author_profile": "https://wordpress.stackexchange.com/users/57843",
"pm_score": 0,
"selected": false,
"text": "<p>You are gonna need a PHP code like this, you can add it to the functions.php, or I would recommend creating... | 2014/09/01 | [
"https://wordpress.stackexchange.com/questions/159756",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23612/"
] | I'm using a modified version of the Recent Posts plugin together with WP Total Cache. I'm using post\_\_not\_in as I don't want to display the current post again. It works well, but if Object Cache is activated, on some posts post\_\_not\_in does not work.
Here is my code:
```
<?php function nothing_recent_posts_init... | Create the [JSON endpoint](http://v2.wp-api.org/extending/adding/) that accepts a [`WP_Post`](https://codex.wordpress.org/Class_Reference/WP_Post) ID.
```
add_action( 'rest_api_init', function() {
register_rest_route( 'api/v2', '/post/(?<id>\d+)', array (
'methods' => 'GET',
'callback' => 'get_pos... |
159,766 | <p>I can't manage to make <code>get_terms()</code> to return the empty terms and I've tried it in a number of ways.</p>
<p>Here's the code: </p>
<pre><code>$terms = get_terms('device',array('hide_empty' => 0));
foreach($terms as $term) {
if($term->parent == 0) {
if($i++ != 0) echo '</optg... | [
{
"answer_id": 159770,
"author": "Alex Dumitru",
"author_id": 5810,
"author_profile": "https://wordpress.stackexchange.com/users/5810",
"pm_score": 0,
"selected": false,
"text": "<p>I've found the problem.</p>\n\n<p>I'm using <code>get_terms()</code> twice, once for the parents and once ... | 2014/09/01 | [
"https://wordpress.stackexchange.com/questions/159766",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5810/"
] | I can't manage to make `get_terms()` to return the empty terms and I've tried it in a number of ways.
Here's the code:
```
$terms = get_terms('device',array('hide_empty' => 0));
foreach($terms as $term) {
if($term->parent == 0) {
if($i++ != 0) echo '</optgroup>'; echo '<optgroup label="'.$term->n... | You use the `hide_empty` argument for `$terms`, but not for `$this_term` inside your loop.
Also, with the way you're generating your select, it would be a lot more efficient to just query top-level terms for the main loop:
```
$terms = get_terms( 'device', array( 'hide_empty' => false, 'parent' => 0 ) );
```
And th... |
159,783 | <p>I have a problem, my custom title keeps getting added at every time I save the post..</p>
<p>First I created a Custom Post Type called 'imac' plus a front-end form for posting in this Post Type, only before saving I would like to change the ['post_title'] based on the Custom Fields people fill out on the front-end ... | [
{
"answer_id": 159791,
"author": "Silenced",
"author_id": 59029,
"author_profile": "https://wordpress.stackexchange.com/users/59029",
"pm_score": -1,
"selected": false,
"text": "<p>I can't comment yet, so I ll try to guess that the one that is getting duplicated is the post and not just ... | 2014/09/01 | [
"https://wordpress.stackexchange.com/questions/159783",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59031/"
] | I have a problem, my custom title keeps getting added at every time I save the post..
First I created a Custom Post Type called 'imac' plus a front-end form for posting in this Post Type, only before saving I would like to change the ['post\_title'] based on the Custom Fields people fill out on the front-end form aswe... | First of: Your custom title suffix getting duplicated might not be what you want to happen, but is expected behavior as per your code sample.
The [`save_post`](http://codex.wordpress.org/Plugin_API/Action_Reference/save_post) *[action hook](http://codex.wordpress.org/Plugin_API/Action_Reference/)* runs everytime a pos... |