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 |
|---|---|---|---|---|---|---|
221,264 | <p>I have a post type which I want to add some taxonomy values (tags)</p>
<p>Example Post Type One</p>
<ol>
<li><strong>City</strong>: London, Paris</li>
<li><strong>Color</strong>: Red, Yellow</li>
<li><strong>Language</strong>: </li>
</ol>
<p>In the example above, Language doesn't have any value, therefore, I want... | [
{
"answer_id": 221266,
"author": "Jubayer Shamshed",
"author_id": 90791,
"author_profile": "https://wordpress.stackexchange.com/users/90791",
"pm_score": 1,
"selected": false,
"text": "<p>In wordpress <a href=\"https://developer.wordpress.org/reference/functions/get_terms/\" rel=\"nofoll... | 2016/03/21 | [
"https://wordpress.stackexchange.com/questions/221264",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55160/"
] | I have a post type which I want to add some taxonomy values (tags)
Example Post Type One
1. **City**: London, Paris
2. **Color**: Red, Yellow
3. **Language**:
In the example above, Language doesn't have any value, therefore, I want to hide it.
I have this code:
```
<?php
$lang= get_terms( 'lang' );
if ( !empty( $l... | [`get_terms()`](https://developer.wordpress.org/reference/functions/get_terms/) return all the terms in the taxonomy regardless of the current post.
So if current post does not have **lang** terms still this condition `if ( !empty( $lang))` will be `true` thus it will display the text **Language**.
Use [`get_the_term_... |
221,287 | <p>I'm converting html into Wordpress theme. In the header I have a tel number and a button. Both are links, but styled differently.</p>
<p>Do you think it would be better to make them a sidebar (widget area) or as settings in customizer? What should be the principle choosing between customiser or widget area.</p>
| [
{
"answer_id": 221266,
"author": "Jubayer Shamshed",
"author_id": 90791,
"author_profile": "https://wordpress.stackexchange.com/users/90791",
"pm_score": 1,
"selected": false,
"text": "<p>In wordpress <a href=\"https://developer.wordpress.org/reference/functions/get_terms/\" rel=\"nofoll... | 2016/03/21 | [
"https://wordpress.stackexchange.com/questions/221287",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/87738/"
] | I'm converting html into Wordpress theme. In the header I have a tel number and a button. Both are links, but styled differently.
Do you think it would be better to make them a sidebar (widget area) or as settings in customizer? What should be the principle choosing between customiser or widget area. | [`get_terms()`](https://developer.wordpress.org/reference/functions/get_terms/) return all the terms in the taxonomy regardless of the current post.
So if current post does not have **lang** terms still this condition `if ( !empty( $lang))` will be `true` thus it will display the text **Language**.
Use [`get_the_term_... |
221,323 | <p>I am writing a plugin for adding a custom field to the image attachment dialogue box, the plugin works for storing valid input data. I have a problem for showing the error message "This is not a valid URL".</p>
<p>I think that I followed the <a href="https://codex.wordpress.org/Plugin_API/Filter_Reference/attachmen... | [
{
"answer_id": 221321,
"author": "sankorati",
"author_id": 90630,
"author_profile": "https://wordpress.stackexchange.com/users/90630",
"pm_score": 0,
"selected": false,
"text": "<p>Gzip compression is defined at server level, not in wp</p>\n"
},
{
"answer_id": 221330,
"author... | 2016/03/21 | [
"https://wordpress.stackexchange.com/questions/221323",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91017/"
] | I am writing a plugin for adding a custom field to the image attachment dialogue box, the plugin works for storing valid input data. I have a problem for showing the error message "This is not a valid URL".
I think that I followed the [documentation](https://codex.wordpress.org/Plugin_API/Filter_Reference/attachment_f... | The `enfoce_gzip` constant, and the other in the same group in your config, actually refer to how wordpress should serve admin side related JS and CSS, and it seems like you are interested in the front end.
Setting gzip compression is something that you should do in your server configuration level (several options dep... |
221,333 | <p>I am working on a wordpress site that has this short code, </p>
<pre><code>[vc_single_image image="7004" css_animation="right-to-left" border_color="grey" img_link_target="_self" img_size="300px"]
</code></pre>
<p>I need to replicate that short code a few times but I can not figure out where the four digit number ... | [
{
"answer_id": 221336,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>It's not easy to trace trough the code behind <code>[vc_single_image]</code>, because for start it uses the <... | 2016/03/21 | [
"https://wordpress.stackexchange.com/questions/221333",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/88534/"
] | I am working on a wordpress site that has this short code,
```
[vc_single_image image="7004" css_animation="right-to-left" border_color="grey" img_link_target="_self" img_size="300px"]
```
I need to replicate that short code a few times but I can not figure out where the four digit number referencing the image come... | It's not easy to trace trough the code behind `[vc_single_image]`, because for start it uses the [`extract`](http://php.net/manual/en/function.extract.php), that's not recommended in WordPress or PHP in general.
The `image` attribute value is stripped for non-integers into the `$img_id` variable.
With your setup, the... |
221,337 | <p>I've blocked access to xmlrcp, and removed most everything that is generated in <code>wp_head</code>. However, I'm still getting notifications in the admin about comments being posted on posts even when there is no form on that page. How is this possible?</p>
<p><strong>I'm thinking that this below would work:</str... | [
{
"answer_id": 221342,
"author": "Henry Ibinson",
"author_id": 91023,
"author_profile": "https://wordpress.stackexchange.com/users/91023",
"pm_score": 0,
"selected": false,
"text": "<p>A small trick is checking your current theme and creating a new file comments.php (if you don't have). ... | 2016/03/21 | [
"https://wordpress.stackexchange.com/questions/221337",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38123/"
] | I've blocked access to xmlrcp, and removed most everything that is generated in `wp_head`. However, I'm still getting notifications in the admin about comments being posted on posts even when there is no form on that page. How is this possible?
**I'm thinking that this below would work:**
```
// Remove comment suppor... | The visual representation of a comment form (or lack of it) do not have any impact on the ability to receive comments, and spammers usually don't care at all what is in your form. Wordpress have a well publicized end point to which all comments are being sent (and while I don't remember the detail off the top of my hea... |
221,396 | <p>I'm creating my own theme and I'm looking to add a featured image option by adding:</p>
<pre><code>add_theme_support( $feature, $arguments );
</code></pre>
<p>Into the <code>functions.php</code> file. When I do this I get this error:</p>
<pre><code>add_theme_support( 'post-thumbnails' ); Warning: Cannot modify he... | [
{
"answer_id": 221397,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 1,
"selected": false,
"text": "<p>As user <a href=\"https://wordpress.stackexchange.com/users/76440/majick\">/u/majick</a> suggests in the co... | 2016/03/22 | [
"https://wordpress.stackexchange.com/questions/221396",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91011/"
] | I'm creating my own theme and I'm looking to add a featured image option by adding:
```
add_theme_support( $feature, $arguments );
```
Into the `functions.php` file. When I do this I get this error:
```
add_theme_support( 'post-thumbnails' ); Warning: Cannot modify header information - headers already sent by (outp... | As user [/u/majick](https://wordpress.stackexchange.com/users/76440/majick) suggests in the comments below: the better option may be [`after_setup_theme`](https://codex.wordpress.org/Plugin_API/Action_Reference/after_setup_theme) which looks like this:
```
function theme_setup() {
add_theme_support( 'post-thumbnai... |
221,401 | <p>I have created the code to loop through the product list and display the price</p>
<pre><code> $args = array( 'post_type' => 'product', 'posts_per_page' => 100, 'product_cat' => 'hot-deals');
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
glob... | [
{
"answer_id": 221409,
"author": "Nicolai Grossherr",
"author_id": 22534,
"author_profile": "https://wordpress.stackexchange.com/users/22534",
"pm_score": 2,
"selected": false,
"text": "<p>I'm pretty sure that the problem is, that the <code>WP_Query</code> returns <em>post objects</em>, ... | 2016/03/22 | [
"https://wordpress.stackexchange.com/questions/221401",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50421/"
] | I have created the code to loop through the product list and display the price
```
$args = array( 'post_type' => 'product', 'posts_per_page' => 100, 'product_cat' => 'hot-deals');
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
global $product;
$xml .= '<Orig... | I'm pretty sure that the problem is, that the `WP_Query` returns *post objects*, which are not identical to Woocommerces *product objects*. While you are trying to get the product data by getting the according global, that won't work, especially because the query you are performing does nothing to that global. Now what... |
221,419 | <p>I'm trying to implement a custom RSS feed that is formatted for podcasting and pulls in the audio file from an Advanced Custom Field. Basically I've been working off of the example provided here: <a href="https://css-tricks.com/roll-simple-wordpress-podcast-plugin/" rel="nofollow">https://css-tricks.com/roll-simple-... | [
{
"answer_id": 224174,
"author": "eteubert",
"author_id": 743,
"author_profile": "https://wordpress.stackexchange.com/users/743",
"pm_score": 2,
"selected": true,
"text": "<p>You need to explicitly set the Content Type, otherwise WordPress defaults to octet-stream for unknown feeds.</p>\... | 2016/03/22 | [
"https://wordpress.stackexchange.com/questions/221419",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91064/"
] | I'm trying to implement a custom RSS feed that is formatted for podcasting and pulls in the audio file from an Advanced Custom Field. Basically I've been working off of the example provided here: <https://css-tricks.com/roll-simple-wordpress-podcast-plugin/>
My plugin looks like this:
```
// add a custom RSS feed
fun... | You need to explicitly set the Content Type, otherwise WordPress defaults to octet-stream for unknown feeds.
```
function run_podcast_rss(){
header( 'Content-Type: application/rss+xml; charset=' . get_option( 'blog_charset' ), true );
require_once( dirname( __FILE__ ) . '/feed-template.php' );
}
``` |
221,423 | <p>I made my first WP plugin, it is a contact form - here is the code:</p>
<pre><code><?php
/*
Plugin Name: Example Contact Form Plugin
Plugin URI: http://example.com
Description: Simple non-bloated WordPress Contact Form
Version: 1.0
Author: Agbonghama Collins
Author URI: http://w3guy.com
*/
function html_form_co... | [
{
"answer_id": 224174,
"author": "eteubert",
"author_id": 743,
"author_profile": "https://wordpress.stackexchange.com/users/743",
"pm_score": 2,
"selected": true,
"text": "<p>You need to explicitly set the Content Type, otherwise WordPress defaults to octet-stream for unknown feeds.</p>\... | 2016/03/22 | [
"https://wordpress.stackexchange.com/questions/221423",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/55063/"
] | I made my first WP plugin, it is a contact form - here is the code:
```
<?php
/*
Plugin Name: Example Contact Form Plugin
Plugin URI: http://example.com
Description: Simple non-bloated WordPress Contact Form
Version: 1.0
Author: Agbonghama Collins
Author URI: http://w3guy.com
*/
function html_form_code() {
echo '... | You need to explicitly set the Content Type, otherwise WordPress defaults to octet-stream for unknown feeds.
```
function run_podcast_rss(){
header( 'Content-Type: application/rss+xml; charset=' . get_option( 'blog_charset' ), true );
require_once( dirname( __FILE__ ) . '/feed-template.php' );
}
``` |
221,433 | <p>I've built a custom query for geolocation searches. I'm saving lat and lng within each custom post type as a meta value. My query extension returns results successfully when lat and lng are the only search variables.</p>
<p>Problem: I would like to also add tax_queries to my query to further select posts</p>
<p><s... | [
{
"answer_id": 224174,
"author": "eteubert",
"author_id": 743,
"author_profile": "https://wordpress.stackexchange.com/users/743",
"pm_score": 2,
"selected": true,
"text": "<p>You need to explicitly set the Content Type, otherwise WordPress defaults to octet-stream for unknown feeds.</p>\... | 2016/03/22 | [
"https://wordpress.stackexchange.com/questions/221433",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50043/"
] | I've built a custom query for geolocation searches. I'm saving lat and lng within each custom post type as a meta value. My query extension returns results successfully when lat and lng are the only search variables.
Problem: I would like to also add tax\_queries to my query to further select posts
**Class to extend ... | You need to explicitly set the Content Type, otherwise WordPress defaults to octet-stream for unknown feeds.
```
function run_podcast_rss(){
header( 'Content-Type: application/rss+xml; charset=' . get_option( 'blog_charset' ), true );
require_once( dirname( __FILE__ ) . '/feed-template.php' );
}
``` |
221,466 | <p>I wish to change/remove parts of the automatic post class function that's built in to wordpress, lets say when i make a post, the html code generated looks like this:</p>
<pre><code><div id="post-106" class="contentmain fullwidth post-106 post type-post status-publish format-standard has-post-thumbnail hentry ca... | [
{
"answer_id": 224174,
"author": "eteubert",
"author_id": 743,
"author_profile": "https://wordpress.stackexchange.com/users/743",
"pm_score": 2,
"selected": true,
"text": "<p>You need to explicitly set the Content Type, otherwise WordPress defaults to octet-stream for unknown feeds.</p>\... | 2016/03/23 | [
"https://wordpress.stackexchange.com/questions/221466",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/86334/"
] | I wish to change/remove parts of the automatic post class function that's built in to wordpress, lets say when i make a post, the html code generated looks like this:
```
<div id="post-106" class="contentmain fullwidth post-106 post type-post status-publish format-standard has-post-thumbnail hentry category-test categ... | You need to explicitly set the Content Type, otherwise WordPress defaults to octet-stream for unknown feeds.
```
function run_podcast_rss(){
header( 'Content-Type: application/rss+xml; charset=' . get_option( 'blog_charset' ), true );
require_once( dirname( __FILE__ ) . '/feed-template.php' );
}
``` |
221,481 | <p>So inside this theme I'm making for a client there is a section inside the customizer that allows them to change a header on each individual page, my question is how do I fetch the alt tag of that Image?</p>
<p>The Images are uploaded through the Media Library so the alt text has been set after the Image was upload... | [
{
"answer_id": 221517,
"author": "majick",
"author_id": 76440,
"author_profile": "https://wordpress.stackexchange.com/users/76440",
"pm_score": 0,
"selected": false,
"text": "<p>I believe the problem may be with not providing arguments to the customizer <code>add_setting</code> call, esp... | 2016/03/23 | [
"https://wordpress.stackexchange.com/questions/221481",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85776/"
] | So inside this theme I'm making for a client there is a section inside the customizer that allows them to change a header on each individual page, my question is how do I fetch the alt tag of that Image?
The Images are uploaded through the Media Library so the alt text has been set after the Image was uploaded.
Below... | Ok I found the answer that no one has on the net I been looking for days now.
Here is how I was able to do it. Hope this helps someone out there
```
// This is getting the image / url
$feature1 = get_theme_mod('feature_image_1');
// This is getting the post id
$feature1_id = attachment_url_to_postid($feature1);
// ... |
221,485 | <p>In some cases it might be useful to use multiple post & page parameters in your <code>WP_Query</code> object. In my case, I would like to display children of a parent page including the parent page itself.</p>
<p>Visualization of what I want to achieve. Imagine the following pages hierarchically sorted as follo... | [
{
"answer_id": 221490,
"author": "Lalji Nakum",
"author_id": 91099,
"author_profile": "https://wordpress.stackexchange.com/users/91099",
"pm_score": -1,
"selected": false,
"text": "<p>You can use <code>get_pages()</code> with <code>child_of</code> parameter like below : </p>\n\n<pre><cod... | 2016/03/23 | [
"https://wordpress.stackexchange.com/questions/221485",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44637/"
] | In some cases it might be useful to use multiple post & page parameters in your `WP_Query` object. In my case, I would like to display children of a parent page including the parent page itself.
Visualization of what I want to achieve. Imagine the following pages hierarchically sorted as following:
* page A
* **page ... | We can filter the `posts_where` clause of the generated SQL to also return the parent post/page and not just the parent's children. Here we will set our own custom argument called `wpse_include_parent`, which, when set to `true`, will alter the generated SQL accordingly.
All we need to do inside our `posts_where` filt... |
221,522 | <p>I am facing some UI issues with my wordpress website. The newly added "Author" role is not able to see the formatting toolbar while writing the post. After debugging, I found a javascript error which I suppose is due to the update of version 4.4.2.</p>
<p>The error (below snip) is this:</p>
<pre><code>Refused to e... | [
{
"answer_id": 221877,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 2,
"selected": false,
"text": "<p>The error is most likely correct (and is most likely related to browser upgrade than any WP version chang... | 2016/03/23 | [
"https://wordpress.stackexchange.com/questions/221522",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56575/"
] | I am facing some UI issues with my wordpress website. The newly added "Author" role is not able to see the formatting toolbar while writing the post. After debugging, I found a javascript error which I suppose is due to the update of version 4.4.2.
The error (below snip) is this:
```
Refused to execute script from 'h... | The error is most likely correct (and is most likely related to browser upgrade than any WP version change) and your theme/plugin does fishy things. The ajax enedpoint should be uses to return data - html/json/xml.
Wordpress will use the text/html mime type for all responses from the ajax endpoint without any simple ... |
221,552 | <p>I'm fairly new to WP development, however as far as I can see I've followed the correct procedure in my custom archive page (below). If I remove the check for <code>is_main_query()</code> it wipes the menus out and likely a lot of other data is lost due to the filter being applied. </p>
<p>Adding debug code shows t... | [
{
"answer_id": 221556,
"author": "darrinb",
"author_id": 6304,
"author_profile": "https://wordpress.stackexchange.com/users/6304",
"pm_score": 1,
"selected": false,
"text": "<p>The action hook <code>pre_get_posts</code> is called well before the page template is rendered. Move <code>add... | 2016/03/23 | [
"https://wordpress.stackexchange.com/questions/221552",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91132/"
] | I'm fairly new to WP development, however as far as I can see I've followed the correct procedure in my custom archive page (below). If I remove the check for `is_main_query()` it wipes the menus out and likely a lot of other data is lost due to the filter being applied.
Adding debug code shows that `is_main_query()`... | Thanks for all your help.
The key issues where that i needed to post the code in the functions.php file and needed to amend the if statement to read:
```
$query->is_main_query() && is_post_type_archive( 'festival' )
```
So that it would only effect my custom post type.
Thanks! |
221,553 | <p>I have very little space to host my WordPress website. That is why I want all my media files are stored in the cloud like dropbox, google drive etc.</p>
<p>For example, if a user wants to upload an image from the front-end using the common upload file button, then the image file is automatically stored directly to ... | [
{
"answer_id": 221556,
"author": "darrinb",
"author_id": 6304,
"author_profile": "https://wordpress.stackexchange.com/users/6304",
"pm_score": 1,
"selected": false,
"text": "<p>The action hook <code>pre_get_posts</code> is called well before the page template is rendered. Move <code>add... | 2016/03/23 | [
"https://wordpress.stackexchange.com/questions/221553",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/89982/"
] | I have very little space to host my WordPress website. That is why I want all my media files are stored in the cloud like dropbox, google drive etc.
For example, if a user wants to upload an image from the front-end using the common upload file button, then the image file is automatically stored directly to the cloud.... | Thanks for all your help.
The key issues where that i needed to post the code in the functions.php file and needed to amend the if statement to read:
```
$query->is_main_query() && is_post_type_archive( 'festival' )
```
So that it would only effect my custom post type.
Thanks! |
221,585 | <p>I have a text widget, in it i just place there an iframe.</p>
<p>A few days ago i wanted to override this widget on mobile browsers and add a background of an image on mobile browsers, luckily i used <a href="https://woorkup.com/hide-wordpress-widgets-mobile-devices/" rel="nofollow">How to hide widget on mobile</a>... | [
{
"answer_id": 221556,
"author": "darrinb",
"author_id": 6304,
"author_profile": "https://wordpress.stackexchange.com/users/6304",
"pm_score": 1,
"selected": false,
"text": "<p>The action hook <code>pre_get_posts</code> is called well before the page template is rendered. Move <code>add... | 2016/03/24 | [
"https://wordpress.stackexchange.com/questions/221585",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91150/"
] | I have a text widget, in it i just place there an iframe.
A few days ago i wanted to override this widget on mobile browsers and add a background of an image on mobile browsers, luckily i used [How to hide widget on mobile](https://woorkup.com/hide-wordpress-widgets-mobile-devices/) , i changed the code from that link... | Thanks for all your help.
The key issues where that i needed to post the code in the functions.php file and needed to amend the if statement to read:
```
$query->is_main_query() && is_post_type_archive( 'festival' )
```
So that it would only effect my custom post type.
Thanks! |
221,618 | <p>I have a custom post type that looks like:</p>
<pre><code>register_post_type( 'letters', array(
'labels' => array(
'all_items' => __( 'All Letters', 'text_domain' ),
'name' => __( 'Letters' ),
'search_items' => __('Search Letters'),
'singular_name' => __( 'Letter' ... | [
{
"answer_id": 221556,
"author": "darrinb",
"author_id": 6304,
"author_profile": "https://wordpress.stackexchange.com/users/6304",
"pm_score": 1,
"selected": false,
"text": "<p>The action hook <code>pre_get_posts</code> is called well before the page template is rendered. Move <code>add... | 2016/03/24 | [
"https://wordpress.stackexchange.com/questions/221618",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9820/"
] | I have a custom post type that looks like:
```
register_post_type( 'letters', array(
'labels' => array(
'all_items' => __( 'All Letters', 'text_domain' ),
'name' => __( 'Letters' ),
'search_items' => __('Search Letters'),
'singular_name' => __( 'Letter' ),
),
'has_ar... | Thanks for all your help.
The key issues where that i needed to post the code in the functions.php file and needed to amend the if statement to read:
```
$query->is_main_query() && is_post_type_archive( 'festival' )
```
So that it would only effect my custom post type.
Thanks! |
221,640 | <p>I would like to add "back buttons" to every page in my Wordpress site..and I'd like it to appear at the top of each page. How do I code that and where is it placed on the page code? thank you, Lori</p>
| [
{
"answer_id": 221644,
"author": "Prasad Nevase",
"author_id": 62283,
"author_profile": "https://wordpress.stackexchange.com/users/62283",
"pm_score": 2,
"selected": false,
"text": "<p>You can use following code. I trust you can style the link to look like button :)</p>\n\n<pre><code>if(... | 2016/03/24 | [
"https://wordpress.stackexchange.com/questions/221640",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91185/"
] | I would like to add "back buttons" to every page in my Wordpress site..and I'd like it to appear at the top of each page. How do I code that and where is it placed on the page code? thank you, Lori | You can use following code. I trust you can style the link to look like button :)
```
if( wp_get_referer() )
echo '<a href="'<?php wp_get_referer() ?> '" >BACK</a>';
``` |
221,667 | <p>I'm using isotope to filter a custom post type. But I only want the child taxonomies of 2 particular parents. I have it working nicely for one parent, but I'm not sure how to modify the array to allow for 2 parents.</p>
<pre><code>$terms = get_terms('speight_plans', array('parent' => 16)); // you can use any ta... | [
{
"answer_id": 221688,
"author": "Tung Du",
"author_id": 83304,
"author_profile": "https://wordpress.stackexchange.com/users/83304",
"pm_score": 0,
"selected": false,
"text": "<p>I can think about the <code>get_term_children()</code> function. You can use that function two times to retri... | 2016/03/24 | [
"https://wordpress.stackexchange.com/questions/221667",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/88351/"
] | I'm using isotope to filter a custom post type. But I only want the child taxonomies of 2 particular parents. I have it working nicely for one parent, but I'm not sure how to modify the array to allow for 2 parents.
```
$terms = get_terms('speight_plans', array('parent' => 16)); // you can use any taxonomy, instead of... | We can filter the generated SQL query through the [`terms_clauses` filter](https://developer.wordpress.org/reference/hooks/terms_clauses/) before the SQL query is executed. What we will be doing is to introduce a new parameter called `wpse_parents` which will accept an array of parent term ID's to get children from. No... |
221,672 | <p>I have a custom post type that im trying to limit results in search. </p>
<p>The CPT is a deal/coupon, with a start and end date for each of the deals. </p>
<p>What I'm trying to do is only show these posts in search:</p>
<ol>
<li>For non-recurring events....Show posts where the end date is today or after todays ... | [
{
"answer_id": 221688,
"author": "Tung Du",
"author_id": 83304,
"author_profile": "https://wordpress.stackexchange.com/users/83304",
"pm_score": 0,
"selected": false,
"text": "<p>I can think about the <code>get_term_children()</code> function. You can use that function two times to retri... | 2016/03/24 | [
"https://wordpress.stackexchange.com/questions/221672",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77113/"
] | I have a custom post type that im trying to limit results in search.
The CPT is a deal/coupon, with a start and end date for each of the deals.
What I'm trying to do is only show these posts in search:
1. For non-recurring events....Show posts where the end date is today or after todays today.
**OR**
2. For recu... | We can filter the generated SQL query through the [`terms_clauses` filter](https://developer.wordpress.org/reference/hooks/terms_clauses/) before the SQL query is executed. What we will be doing is to introduce a new parameter called `wpse_parents` which will accept an array of parent term ID's to get children from. No... |
221,700 | <p>I have tried so many solutions for this but I can't figure it out. Here is a simplified version of the plugin code:</p>
<pre><code>class YITH_Vendors_Frontend_Premium extends YITH_Vendors_Frontend {
public function __construct() {
add_action( 'woocommerce_register_form', array( $this, 'register_form' ) );
... | [
{
"answer_id": 221688,
"author": "Tung Du",
"author_id": 83304,
"author_profile": "https://wordpress.stackexchange.com/users/83304",
"pm_score": 0,
"selected": false,
"text": "<p>I can think about the <code>get_term_children()</code> function. You can use that function two times to retri... | 2016/03/25 | [
"https://wordpress.stackexchange.com/questions/221700",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56526/"
] | I have tried so many solutions for this but I can't figure it out. Here is a simplified version of the plugin code:
```
class YITH_Vendors_Frontend_Premium extends YITH_Vendors_Frontend {
public function __construct() {
add_action( 'woocommerce_register_form', array( $this, 'register_form' ) );
}
```
So I w... | We can filter the generated SQL query through the [`terms_clauses` filter](https://developer.wordpress.org/reference/hooks/terms_clauses/) before the SQL query is executed. What we will be doing is to introduce a new parameter called `wpse_parents` which will accept an array of parent term ID's to get children from. No... |
221,704 | <p>I have a single page for my products where all products get listed. This is how i've archieved it:</p>
<pre><code><ul class="produkte">
<?php $args = array( 'post_type' => 'produkte', 'posts_per_page' => 30 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->th... | [
{
"answer_id": 221706,
"author": "Tung Du",
"author_id": 83304,
"author_profile": "https://wordpress.stackexchange.com/users/83304",
"pm_score": 4,
"selected": true,
"text": "<p>The problem here is <code>the_post_thumbnail()</code> doesn't return image url but the img tag.</p>\n\n<p>You ... | 2016/03/25 | [
"https://wordpress.stackexchange.com/questions/221704",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/79865/"
] | I have a single page for my products where all products get listed. This is how i've archieved it:
```
<ul class="produkte">
<?php $args = array( 'post_type' => 'produkte', 'posts_per_page' => 30 );
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();
echo '<li class="... | The problem here is `the_post_thumbnail()` doesn't return image url but the img tag.
You can use this code
```
$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
echo '<li class="produkt" style="background: url('. $url.')">';
``` |
221,716 | <p>I want to organize data on my website the following way. I am not sure how it can be done. Do it need to make a custom post type or taxonomy to organize data like this. </p>
<p>Help and guidance will be appreciated. </p>
<pre><code>home
- incubators
- incubators name
- incubated startup
- incub... | [
{
"answer_id": 221706,
"author": "Tung Du",
"author_id": 83304,
"author_profile": "https://wordpress.stackexchange.com/users/83304",
"pm_score": 4,
"selected": true,
"text": "<p>The problem here is <code>the_post_thumbnail()</code> doesn't return image url but the img tag.</p>\n\n<p>You ... | 2016/03/25 | [
"https://wordpress.stackexchange.com/questions/221716",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/24020/"
] | I want to organize data on my website the following way. I am not sure how it can be done. Do it need to make a custom post type or taxonomy to organize data like this.
Help and guidance will be appreciated.
```
home
- incubators
- incubators name
- incubated startup
- incubated startup
... | The problem here is `the_post_thumbnail()` doesn't return image url but the img tag.
You can use this code
```
$url = wp_get_attachment_url( get_post_thumbnail_id($post->ID) );
echo '<li class="produkt" style="background: url('. $url.')">';
``` |
221,727 | <p>I want to add an additional header to outgoing emails on my sites, so I can easily determine which site sent a given email. (I put a standard functionality plugin on all of my sites, so this is easy enough to do, and configuring my email client to filter and otherwise act on this header would be an amazing time-save... | [
{
"answer_id": 221728,
"author": "Sumit",
"author_id": 32475,
"author_profile": "https://wordpress.stackexchange.com/users/32475",
"pm_score": 2,
"selected": false,
"text": "<p>PHP <code>headers</code> are strings. You can not parse them as array. You need to add you additional header as... | 2016/03/25 | [
"https://wordpress.stackexchange.com/questions/221727",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67104/"
] | I want to add an additional header to outgoing emails on my sites, so I can easily determine which site sent a given email. (I put a standard functionality plugin on all of my sites, so this is easy enough to do, and configuring my email client to filter and otherwise act on this header would be an amazing time-saver.)... | Thanks to the above, I've realized my central mistake -- I didn't quite realize that the arguments being passed in were a multi-dimensional array.
For now, I've re-implemented the function thus:
```
function ws_add_site_header($email) {
$email['headers'][] = 'X-WU-Site: ' . parse_url(get_site_url(), PHP_URL_HOST)... |
221,730 | <p>I need to get attachment images with horizontal orientation. I tried to use <code>Meta_Query</code> but I don't know how to compare two values (<strong>width</strong> and <strong>height</strong>) from one associative array that is in <code>wp_postmeta</code> table. I don't have any specific values of width and heigh... | [
{
"answer_id": 221728,
"author": "Sumit",
"author_id": 32475,
"author_profile": "https://wordpress.stackexchange.com/users/32475",
"pm_score": 2,
"selected": false,
"text": "<p>PHP <code>headers</code> are strings. You can not parse them as array. You need to add you additional header as... | 2016/03/25 | [
"https://wordpress.stackexchange.com/questions/221730",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91227/"
] | I need to get attachment images with horizontal orientation. I tried to use `Meta_Query` but I don't know how to compare two values (**width** and **height**) from one associative array that is in `wp_postmeta` table. I don't have any specific values of width and height, I only need to compare this values which is in a... | Thanks to the above, I've realized my central mistake -- I didn't quite realize that the arguments being passed in were a multi-dimensional array.
For now, I've re-implemented the function thus:
```
function ws_add_site_header($email) {
$email['headers'][] = 'X-WU-Site: ' . parse_url(get_site_url(), PHP_URL_HOST)... |
221,751 | <p>Similar to the question over at <a href="https://wordpress.stackexchange.com/questions/72547/get-wp-logout-url-function-to-work-on-external-non-wordpress-page">Get wp_logout_url function to work on external (non-Wordpress) page</a></p>
<p>The problem I am facing is the fact the subdomain is on a different server so... | [
{
"answer_id": 253805,
"author": "Satbir Kira",
"author_id": 80800,
"author_profile": "https://wordpress.stackexchange.com/users/80800",
"pm_score": 2,
"selected": true,
"text": "<p>You can create a file called custom_logout.php and place it in the root wordpress directory. This contains... | 2016/03/25 | [
"https://wordpress.stackexchange.com/questions/221751",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91245/"
] | Similar to the question over at [Get wp\_logout\_url function to work on external (non-Wordpress) page](https://wordpress.stackexchange.com/questions/72547/get-wp-logout-url-function-to-work-on-external-non-wordpress-page)
The problem I am facing is the fact the subdomain is on a different server so I am unable to inc... | You can create a file called custom\_logout.php and place it in the root wordpress directory. This contains
```
<?php
require_once("wp-load.php"); //load wordpress
wp_logout(); //logout
exit(); //end page
?>
```
Then in your subdomain site open the url with an anchor tag
```
<a href="http://youweb... |
221,760 | <p>I have a function that stores the "like" status for a post as post meta. I want to associate that "like" with the user that liked it, so I setup a custom field called "like_status_{user_id}" (where {user_id} is the id of the currently logged in user) which I store as a 0 or 1. So for a post with several "likes" ther... | [
{
"answer_id": 221763,
"author": "LonnyLot",
"author_id": 20697,
"author_profile": "https://wordpress.stackexchange.com/users/20697",
"pm_score": -1,
"selected": false,
"text": "<p>Per the <a href=\"https://codex.wordpress.org/Class_Reference/WP_Meta_Query#Accepted_Arguments\" rel=\"nofo... | 2016/03/26 | [
"https://wordpress.stackexchange.com/questions/221760",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17864/"
] | I have a function that stores the "like" status for a post as post meta. I want to associate that "like" with the user that liked it, so I setup a custom field called "like\_status\_{user\_id}" (where {user\_id} is the id of the currently logged in user) which I store as a 0 or 1. So for a post with several "likes" the... | Unfortunately you cannot perform a `meta_query` using a `LIKE` comparison on the `meta_key` value when using `WP_Query`. I've been down this road...
Instead you have a couple other options if you want to maintain like status relationships as post meta and not user meta and or meta in a custom table.
Option 1
--------... |
221,769 | <p>I want to set a number of plugin options set to blank if they are not defined so I can avoid the PHP notices.</p>
<p>What is a better way of writing this code?</p>
<pre><code>$options = get_option('plugin_options');
// Add new plugin options defaults here
if( !isset( $options['plugin_option_1'] ) ) $options['pl... | [
{
"answer_id": 221771,
"author": "Adam",
"author_id": 13418,
"author_profile": "https://wordpress.stackexchange.com/users/13418",
"pm_score": 1,
"selected": false,
"text": "<p>Example:</p>\n\n<pre><code>/**\n* assume $options only has three keys defined\n* \n* array(\n* 'plugin_o... | 2016/03/26 | [
"https://wordpress.stackexchange.com/questions/221769",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70831/"
] | I want to set a number of plugin options set to blank if they are not defined so I can avoid the PHP notices.
What is a better way of writing this code?
```
$options = get_option('plugin_options');
// Add new plugin options defaults here
if( !isset( $options['plugin_option_1'] ) ) $options['plugin_option_1'] = '';... | WordPress provides a default method, [`wp_parse_args`](http://php.net/manual/en/function.array-merge.php), to combine a set of default options and a user-defined set of options. This method uses PHP's native [`array_merge`](http://php.net/manual/en/function.array-merge.php) for arrays, but also works when either of the... |
221,773 | <p>I'm not sure why this is not working as its a very simple query. It works when i pull all posts including pending, but not when i want to get posts that are only published.</p>
<p>I have a function to get posts. I pass in a bool variable. If its true, i want to pull all posts from a custom post type called books, i... | [
{
"answer_id": 221775,
"author": "engelen",
"author_id": 40403,
"author_profile": "https://wordpress.stackexchange.com/users/40403",
"pm_score": 3,
"selected": true,
"text": "<p>First off, you probably shouldn't be using <code>query_posts</code>, which modifies WordPress' main loop and i... | 2016/03/26 | [
"https://wordpress.stackexchange.com/questions/221773",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/190834/"
] | I'm not sure why this is not working as its a very simple query. It works when i pull all posts including pending, but not when i want to get posts that are only published.
I have a function to get posts. I pass in a bool variable. If its true, i want to pull all posts from a custom post type called books, including o... | First off, you probably shouldn't be using `query_posts`, which modifies WordPress' main loop and is unsuited for pretty much any purpose (read [When should you use WP\_Query vs query\_posts() vs get\_posts()?](https://wordpress.stackexchange.com/questions/1753/when-should-you-use-wp-query-vs-query-posts-vs-get-posts) ... |
221,791 | <p>I have problem displaying child page content on parent page (both static).
I can display other page content but only if on same level. It dosent work in relation parent - child. </p>
<pre><code><?php
$investor_content_query = new WP_Query( array(
'pagename' => 'current',
'post_parent' ... | [
{
"answer_id": 221792,
"author": "frogg3862",
"author_id": 83367,
"author_profile": "https://wordpress.stackexchange.com/users/83367",
"pm_score": 1,
"selected": false,
"text": "<p>You were being too specific/not passing the correct parameters into your <code>wp_query</code>.\nThis shoul... | 2016/03/26 | [
"https://wordpress.stackexchange.com/questions/221791",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/89711/"
] | I have problem displaying child page content on parent page (both static).
I can display other page content but only if on same level. It dosent work in relation parent - child.
```
<?php
$investor_content_query = new WP_Query( array(
'pagename' => 'current',
'post_parent' => 'investor-relatio... | Ok, i found solution. What I really needed was parent page slug in "pagename" argument.
```
'pagename'=> 'investor-relations/current'
```
*And working solution:*
```
<?php
$investor_content_query = new WP_Query( array(
'pagename'=> 'investor-relations/current'
) );
if ( $investor_content_query-... |
221,800 | <p>I want to display image title and caption inside a <code><p></code> tag in single post in <code>the_content()</code> function for every image that has one. So for example if I add gallery, and define title for every image, I want to have above every image it's title displayed, and below every image it's captio... | [
{
"answer_id": 221807,
"author": "SBP",
"author_id": 91269,
"author_profile": "https://wordpress.stackexchange.com/users/91269",
"pm_score": -1,
"selected": false,
"text": "<p><a href=\"https://wordpress.stackexchange.com/questions/74515/add-filter-and-changing-output-captions-of-image-g... | 2016/03/26 | [
"https://wordpress.stackexchange.com/questions/221800",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70495/"
] | I want to display image title and caption inside a `<p>` tag in single post in `the_content()` function for every image that has one. So for example if I add gallery, and define title for every image, I want to have above every image it's title displayed, and below every image it's caption displayed, and also for all s... | I got a few minutes and made the custom code for you.
Copy and paste this in your themes functions.php
```
remove_shortcode('gallery', 'gallery_shortcode');
add_shortcode('gallery', 'gallery_shortcode_custom');
function gallery_shortcode_custom( $attr ) {
$post = get_post();
static $instance = 0;
$instanc... |
221,808 | <p>I have created custom tables for performance reasons for products, carts, and notifications. I want to make these tables and their data available for normal CRUD via the WP REST API v2. How would I add custom tables (and their columns) to the API so that I could get/update those records?</p>
| [
{
"answer_id": 253047,
"author": "Kosso",
"author_id": 111022,
"author_profile": "https://wordpress.stackexchange.com/users/111022",
"pm_score": 1,
"selected": false,
"text": "<p>Rather than create custom database tables, you would be better off creating your own custom post types (withi... | 2016/03/26 | [
"https://wordpress.stackexchange.com/questions/221808",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17864/"
] | I have created custom tables for performance reasons for products, carts, and notifications. I want to make these tables and their data available for normal CRUD via the WP REST API v2. How would I add custom tables (and their columns) to the API so that I could get/update those records? | I eventualy worked out a solution for my `restaurants` table, which sits alongside the `wp_*` tables in my WP database. Hope this helps
```
add_action( 'rest_api_init', function () {
register_rest_route( 'restos/v1', '/all', array(
'methods' => 'GET',
'callback' => 'handle_get_all',
'permission_callback'... |
221,811 | <p>I want to use a function like this to allow access to the feeds from a variety of services but my knowledge of the security implications is limited. I think I'm being safe by limiting the access to feeds. </p>
<p>What are the dangers (if any) I'm creating if I do this?</p>
<pre><code>add_action( 'pre_get_posts', '... | [
{
"answer_id": 221926,
"author": "Tom Woodward",
"author_id": 82797,
"author_profile": "https://wordpress.stackexchange.com/users/82797",
"pm_score": 0,
"selected": false,
"text": "<p>I read <a href=\"https://stackoverflow.com/questions/15853633/is-there-any-secure-way-to-allow-cross-sit... | 2016/03/26 | [
"https://wordpress.stackexchange.com/questions/221811",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/82797/"
] | I want to use a function like this to allow access to the feeds from a variety of services but my knowledge of the security implications is limited. I think I'm being safe by limiting the access to feeds.
What are the dangers (if any) I'm creating if I do this?
```
add_action( 'pre_get_posts', 'add_header_origin' );... | You need to have a super great reason to disable CORS, as no real reason was given here the answer should be "do not do it, it is not secure".
You assume that no one can craft a feed link which will give him a write access. This might be true, but you should not open holes in your security based on "assuming".
In the... |
221,850 | <p>Just today I synchronized a development website database with a production website database. </p>
<p>Now, my development website gives a "404 Not Found" error. The URL starts with HTTPS, and there is a red slash through the HTTPS text. The 404 page says "The server can not find the requested page: dev.greenbee-w... | [
{
"answer_id": 221970,
"author": "Elektra",
"author_id": 91391,
"author_profile": "https://wordpress.stackexchange.com/users/91391",
"pm_score": 3,
"selected": false,
"text": "<p>There are 2 things you must do.</p>\n\n<p>If you are using Apache server go to .htaccess and change the Rewri... | 2016/03/27 | [
"https://wordpress.stackexchange.com/questions/221850",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75669/"
] | Just today I synchronized a development website database with a production website database.
Now, my development website gives a "404 Not Found" error. The URL starts with HTTPS, and there is a red slash through the HTTPS text. The 404 page says "The server can not find the requested page: dev.greenbee-web.com/ilaimh... | There are 2 things you must do.
If you are using Apache server go to .htaccess and change the Rewrite and RewriteBase engine to
```
RewriteEngine On
RewriteCond %{SERVER_PORT} ^443$
RewriteRule ^(.*)$ http://%{HTTP_HOST}/$1 [R=301,L]
RewriteBase /
RewriteRule ^index.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
R... |
221,858 | <p>In wordpress, to use $ instead of jQuery prefix, i added the following code around all js code:</p>
<pre><code>jQuery(function($) {
...
});
</code></pre>
<p>It works well, but i cannot call an object from another javascript file, the following problem persists:</p>
<pre><code>Slider is not defined
</code></pr... | [
{
"answer_id": 221863,
"author": "Adam",
"author_id": 66648,
"author_profile": "https://wordpress.stackexchange.com/users/66648",
"pm_score": 3,
"selected": true,
"text": "<p>The issue you have is that <code>Slider</code> is not accessible outside of its scope as that's defined by the <c... | 2016/03/27 | [
"https://wordpress.stackexchange.com/questions/221858",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85161/"
] | In wordpress, to use $ instead of jQuery prefix, i added the following code around all js code:
```
jQuery(function($) {
...
});
```
It works well, but i cannot call an object from another javascript file, the following problem persists:
```
Slider is not defined
```
This is my code:
**file1.js**
```
jQuery... | The issue you have is that `Slider` is not accessible outside of its scope as that's defined by the `.ready()` though you've used shorthand for that. The function needs to be available in the global scope:
file1.js
```
function Slider() {
this.nb_ele = 10;
}
jQuery(function($) {
// ...
});
```
file2.js
```
j... |
221,867 | <p>I am literally pulling my hair out trying to figure this out. I have been at it for almost 12 hours now.</p>
<p>Being new to PHP and theme development I am having a hard time understanding how to get <code>theme_options('value');</code> to display when putting in a PHP stylesheet.</p>
<p>I have taken an example of... | [
{
"answer_id": 221868,
"author": "Jevuska",
"author_id": 18731,
"author_profile": "https://wordpress.stackexchange.com/users/18731",
"pm_score": 0,
"selected": false,
"text": "<h2>CSS customizable by manipulate parse_query</h2>\n<p><em>@Scott Reinmuth</em>, I think you misdirection about... | 2016/03/28 | [
"https://wordpress.stackexchange.com/questions/221867",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91310/"
] | I am literally pulling my hair out trying to figure this out. I have been at it for almost 12 hours now.
Being new to PHP and theme development I am having a hard time understanding how to get `theme_options('value');` to display when putting in a PHP stylesheet.
I have taken an example off a blog post I read [here](... | Although @Jevuska did solve my issue, I have found a much easier solution to adding dynamic CSS from my theme options page. Here we go!
Add this to **functions.php**
```
add_action('wp_head', 'my_custom_css');
function my_custom_css(){
require_once( get_template_directory() . '/css/theme-styles.php' );
}
```
Now yo... |
221,880 | <p>I am trying to create a part on my wordpress theme that will only display one featured post. I have installed this plugin - <a href="https://wordpress.org/plugins/featured-post/" rel="nofollow">https://wordpress.org/plugins/featured-post/</a> . </p>
<p>I know I am supposed to integrate <code><?php query_posts($q... | [
{
"answer_id": 221882,
"author": "Mehul Gohil",
"author_id": 37768,
"author_profile": "https://wordpress.stackexchange.com/users/37768",
"pm_score": 0,
"selected": false,
"text": "<p>I have just simplified my code. Add a custom field with name \"_featured\" with Yes and No Radio Button a... | 2016/03/28 | [
"https://wordpress.stackexchange.com/questions/221880",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91325/"
] | I am trying to create a part on my wordpress theme that will only display one featured post. I have installed this plugin - <https://wordpress.org/plugins/featured-post/> .
I know I am supposed to integrate `<?php query_posts($query_string."&featured=yes");` somewhere into the loop to output the featured post. I trie... | `query_posts()` can alter the WP query even when it is executed and it should be placed at least before you start the loop i.e. `have_posts()`. Currently you are placing it after setting up post data i.e. `the_post()`. Which is resulting in unexpected behavior.
**Example:**
```
global $query_string; //Get current que... |
221,896 | <p>I'm trying to set up a form for people to fill in, however I want to split it up into sections so as to not create a long list of different details on just one page.</p>
<p>For example:</p>
<p>PAGE ONE Includes</p>
<ul>
<li>First Name:</li>
<li>Last Name:</li>
<li>Phone:</li>
<li>Email:</li>
<li>Start Date:</li>
... | [
{
"answer_id": 221882,
"author": "Mehul Gohil",
"author_id": 37768,
"author_profile": "https://wordpress.stackexchange.com/users/37768",
"pm_score": 0,
"selected": false,
"text": "<p>I have just simplified my code. Add a custom field with name \"_featured\" with Yes and No Radio Button a... | 2016/03/28 | [
"https://wordpress.stackexchange.com/questions/221896",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91338/"
] | I'm trying to set up a form for people to fill in, however I want to split it up into sections so as to not create a long list of different details on just one page.
For example:
PAGE ONE Includes
* First Name:
* Last Name:
* Phone:
* Email:
* Start Date:
* Start Time:
* End Date:
* End Time:
* Address:
(Multiple ad... | `query_posts()` can alter the WP query even when it is executed and it should be placed at least before you start the loop i.e. `have_posts()`. Currently you are placing it after setting up post data i.e. `the_post()`. Which is resulting in unexpected behavior.
**Example:**
```
global $query_string; //Get current que... |
221,923 | <p>On a page in Wordpress, If I enter the following code:</p>
<pre><code>var r='<li><a href="#"><img src="' + slide.src + '" width="50" height="50" /></a></li>';
</code></pre>
<p>it is rendered in the browser as</p>
<pre><code> var r='
<li><a href="#"><img src="' + slide... | [
{
"answer_id": 221951,
"author": "markratledge",
"author_id": 268,
"author_profile": "https://wordpress.stackexchange.com/users/268",
"pm_score": 1,
"selected": false,
"text": "<p>You have to bracket the function in <code><script></code> tags and then either</p>\n\n<p>1) take all t... | 2016/03/28 | [
"https://wordpress.stackexchange.com/questions/221923",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51358/"
] | On a page in Wordpress, If I enter the following code:
```
var r='<li><a href="#"><img src="' + slide.src + '" width="50" height="50" /></a></li>';
```
it is rendered in the browser as
```
var r='
<li><a href="#"><img src="' + slide.src + '" width="50" height="50" /></a></li>
';
```
and it gives me this error ... | In the new WordPress (WP 5+) Editor - Gutenberg, you can use a "Custom HTML" block to prevent the automatic line breaks and paragraphs:
on Visual Editor click + > Formatting > Custom HTML - and put your JavaScript in there
on Code Editor enclose your JavaScript with `<!-- wp:html --> <!-- /wp:html -->` |
221,930 | <p>I'm trying to modify a theme to make it work with my custom fields (I'm using ACF for most of the data I put on pages) for a site with song lyrics on it.
The original code was this:</p>
<pre><code>$metro_creativex_posttitle = get_the_title();
$metro_creativex_feat_image = wp_get_attachment_image_src(
... | [
{
"answer_id": 221951,
"author": "markratledge",
"author_id": 268,
"author_profile": "https://wordpress.stackexchange.com/users/268",
"pm_score": 1,
"selected": false,
"text": "<p>You have to bracket the function in <code><script></code> tags and then either</p>\n\n<p>1) take all t... | 2016/03/28 | [
"https://wordpress.stackexchange.com/questions/221930",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91366/"
] | I'm trying to modify a theme to make it work with my custom fields (I'm using ACF for most of the data I put on pages) for a site with song lyrics on it.
The original code was this:
```
$metro_creativex_posttitle = get_the_title();
$metro_creativex_feat_image = wp_get_attachment_image_src(
get_post_thumb... | In the new WordPress (WP 5+) Editor - Gutenberg, you can use a "Custom HTML" block to prevent the automatic line breaks and paragraphs:
on Visual Editor click + > Formatting > Custom HTML - and put your JavaScript in there
on Code Editor enclose your JavaScript with `<!-- wp:html --> <!-- /wp:html -->` |
221,941 | <p>I have added the following code in my <code>functions.php</code> </p>
<pre><code>add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 150, 150);
</code></pre>
<p>My posts display with a thumbnail with the 150x150 dimensions. However, I'd like to change the size. When I change the 150 by 150 in the <c... | [
{
"answer_id": 221954,
"author": "Nathan Powell",
"author_id": 27196,
"author_profile": "https://wordpress.stackexchange.com/users/27196",
"pm_score": 1,
"selected": false,
"text": "<p>The code you are using is correct. The problem is that you are looking at <code>thumbnail</code>s that ... | 2016/03/28 | [
"https://wordpress.stackexchange.com/questions/221941",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91325/"
] | I have added the following code in my `functions.php`
```
add_theme_support( 'post-thumbnails' );
set_post_thumbnail_size( 150, 150);
```
My posts display with a thumbnail with the 150x150 dimensions. However, I'd like to change the size. When I change the 150 by 150 in the `set_post_thumbnail_size` to 200 or any... | The code you are using is correct. The problem is that you are looking at `thumbnail`s that have already been created. As @Loius mentioned you will need to use [Regenerate Thumbnails](https://wordpress.org/plugins/regenerate-thumbnails/) to see the effect. Why core has not implemented this is beyond me. |
221,989 | <p>I work on a theme that displays <strong>3 columns</strong> with images, so the size for thumbnails on large displays will be 360x240px.</p>
<p>When resized, on some <strong>mobile</strong> devices, like iPhone, there will be just <strong>1 column</strong> with images, which may result that the <strong>featured imag... | [
{
"answer_id": 221999,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 1,
"selected": false,
"text": "<p>Your problem comes from not doing responsive design. Responsive design should leave everything to be deci... | 2016/03/29 | [
"https://wordpress.stackexchange.com/questions/221989",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9162/"
] | I work on a theme that displays **3 columns** with images, so the size for thumbnails on large displays will be 360x240px.
When resized, on some **mobile** devices, like iPhone, there will be just **1 column** with images, which may result that the **featured image will be larger** than 360px in width.
Now, in order ... | The answer is to use WP's responsive images, customising the sizes attribute to suit your use case.
Reading between the lines, I'm assuming here that you are using a responsive design approach to show the different layouts at different widths.
The easiest way is to start by making yourself a replacement template tag ... |
222,012 | <p>Several years ago, not really having a handle on the best practice for running a MultiSite network, I often network activated plugins. Later I realized this was a mistake because not all the sites used some of the plugins. So I have unnecessary scripts and stylesheets on several sites. </p>
<p>What I've started doi... | [
{
"answer_id": 222015,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>Your issue is timing. If you check out <a href=\"https://wordpress.stackexchange.com/a/21579/847\">this answer for ... | 2016/03/29 | [
"https://wordpress.stackexchange.com/questions/222012",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/44017/"
] | Several years ago, not really having a handle on the best practice for running a MultiSite network, I often network activated plugins. Later I realized this was a mistake because not all the sites used some of the plugins. So I have unnecessary scripts and stylesheets on several sites.
What I've started doing for tho... | Going off of the plugins source code I simply copied then changed the `add_action();` to `remove_action();` in my child-themes function.php
```
add_action('wp_print_styles', 'add_advanced_recent_posts_widget_stylesheet');
```
Replace `add` with `remove`.
```
remove_action('wp_print_styles','add_advanced_recent_post... |
222,038 | <p>I have a PHP script running in WordPress, that uses a <code>WP_Query</code> to get the posts from one of my subdomains and return it as a JSON string. The script only receives the post data if I call it using the correct subdomain.</p>
<p>For example, if I go to <code>news.example.com/api/news.php</code>, the JSON ... | [
{
"answer_id": 222015,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>Your issue is timing. If you check out <a href=\"https://wordpress.stackexchange.com/a/21579/847\">this answer for ... | 2016/03/29 | [
"https://wordpress.stackexchange.com/questions/222038",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91436/"
] | I have a PHP script running in WordPress, that uses a `WP_Query` to get the posts from one of my subdomains and return it as a JSON string. The script only receives the post data if I call it using the correct subdomain.
For example, if I go to `news.example.com/api/news.php`, the JSON prints correctly, but if I go to... | Going off of the plugins source code I simply copied then changed the `add_action();` to `remove_action();` in my child-themes function.php
```
add_action('wp_print_styles', 'add_advanced_recent_posts_widget_stylesheet');
```
Replace `add` with `remove`.
```
remove_action('wp_print_styles','add_advanced_recent_post... |
222,090 | <p><code>get_theme_mod</code> is returning cached content:
this code:</p>
<pre><code>$parallax_one_logos = get_theme_mod('parallax_one_logos_content',
json_encode(
array(
array("image_url" => parallax_get_file('/images/companies/1.png') ,"link" => "#" ),
array("image_url" =>... | [
{
"answer_id": 222094,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 1,
"selected": true,
"text": "<p>If the theme mod option has a value in database, your code is working just fine as it should return the value ... | 2016/03/30 | [
"https://wordpress.stackexchange.com/questions/222090",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91460/"
] | `get_theme_mod` is returning cached content:
this code:
```
$parallax_one_logos = get_theme_mod('parallax_one_logos_content',
json_encode(
array(
array("image_url" => parallax_get_file('/images/companies/1.png') ,"link" => "#" ),
array("image_url" => parallax_get_file('/images/compa... | If the theme mod option has a value in database, your code is working just fine as it should return the value in database and ignore the second parameter. The second parameter is the default value to be used if there is no value is set. And the value is stored in database.
The problem is that you are wrong considering... |
222,100 | <p>Just like in topic I try to order posts from category by date and comment_count but code below doesn't work:</p>
<pre><code><?php
//get post from current category
$category = get_the_category();
$category_ID = $category[0]->term_id;
$args = array(
'cat' => $category_ID,
//li... | [
{
"answer_id": 222104,
"author": "engelen",
"author_id": 40403,
"author_profile": "https://wordpress.stackexchange.com/users/40403",
"pm_score": 2,
"selected": true,
"text": "<p>The query you currently have will order the posts by their <code>post_date</code> property, which is an SQL co... | 2016/03/30 | [
"https://wordpress.stackexchange.com/questions/222100",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47607/"
] | Just like in topic I try to order posts from category by date and comment\_count but code below doesn't work:
```
<?php
//get post from current category
$category = get_the_category();
$category_ID = $category[0]->term_id;
$args = array(
'cat' => $category_ID,
//limit posts to 3
'po... | The query you currently have will order the posts by their `post_date` property, which is an SQL column of the type `datetime`. This type stores the date, but also the time (hours, minutes and seconds). The second sorting option, `comment_count`, is only applied to posts with the same timestamp, i.e. that were posted a... |
222,112 | <p>I want to add custom classes to my menu items. For every subpage I show its siblings as a navigation:</p>
<pre><code> global $post;
if ( is_page() && $post->post_parent ) {
$args = array(
'sort_column' => 'menu_order',
'title_li' => '... | [
{
"answer_id": 222126,
"author": "engelen",
"author_id": 40403,
"author_profile": "https://wordpress.stackexchange.com/users/40403",
"pm_score": 2,
"selected": false,
"text": "<p>There is no good filter to add the CSS classes to the anchor (<code><a></code>) elements, but as you ne... | 2016/03/30 | [
"https://wordpress.stackexchange.com/questions/222112",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11687/"
] | I want to add custom classes to my menu items. For every subpage I show its siblings as a navigation:
```
global $post;
if ( is_page() && $post->post_parent ) {
$args = array(
'sort_column' => 'menu_order',
'title_li' => '',
'child_of'=> ... | One of the ways is to extend `Walker_Page` class. See comment in the code to know where changes go.
```
class My_Siblings_CSS_Walker_Page extends Walker_Page {
public function start_el( &$output, $page, $depth = 0, $args = array(), $current_page = 0 ) {
if ( $depth ) {
$indent = str_repeat( "\t... |
222,121 | <p>I want to get all the posts that do not contain the tag 'index'. How can it be done?</p>
<p>I mean in the reverse of</p>
<pre><code>get_posts(array('tag' => 'index'))
</code></pre>
<p>Thank you</p>
| [
{
"answer_id": 222123,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>You could try the <code>tax_query</code> with the <code>'NOT IN'</code> operator (untested)</p>\n\n<pre><code>... | 2016/03/30 | [
"https://wordpress.stackexchange.com/questions/222121",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91474/"
] | I want to get all the posts that do not contain the tag 'index'. How can it be done?
I mean in the reverse of
```
get_posts(array('tag' => 'index'))
```
Thank you | You could try the `tax_query` with the `'NOT IN'` operator (untested)
```
$myposts = get_posts(
[
'tax_query' => [
[
'taxonomy' => 'post_tag',
'terms' => [ 'index' ],
'field' => 'slug',
'operator' => 'NOT IN',
]... |
222,136 | <p>Any idea how to check if the website is hidden from search engines? The reason is I want to show a big red banner at the top of the homepage when this option is checked because I always forget that this option is checked.</p>
| [
{
"answer_id": 222138,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 3,
"selected": true,
"text": "<p>The setting is stored in the option <code>blog_public</code>.</p>\n\n<pre><code>if( 0 == get_option( 'blog_public' ... | 2016/03/30 | [
"https://wordpress.stackexchange.com/questions/222136",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67792/"
] | Any idea how to check if the website is hidden from search engines? The reason is I want to show a big red banner at the top of the homepage when this option is checked because I always forget that this option is checked. | The setting is stored in the option `blog_public`.
```
if( 0 == get_option( 'blog_public' ) ){
echo 'search engines discouraged';
}
``` |
222,148 | <p>Basically on my site I have a bunch of song lyrics and in a static page I want to show them listed by album <a href="http://www.thenewblackgold.netsons.org/wp/indexes/by-album/" rel="nofollow">Link to my website</a> and album position of the song and I have two custom fields with that data, <code>sd_album_title</cod... | [
{
"answer_id": 222153,
"author": "Sumit",
"author_id": 32475,
"author_profile": "https://wordpress.stackexchange.com/users/32475",
"pm_score": 2,
"selected": true,
"text": "<p>Why you are using <code>pre_get_posts</code> when using your own <code>get_posts()</code> ? You can just pass th... | 2016/03/30 | [
"https://wordpress.stackexchange.com/questions/222148",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91366/"
] | Basically on my site I have a bunch of song lyrics and in a static page I want to show them listed by album [Link to my website](http://www.thenewblackgold.netsons.org/wp/indexes/by-album/) and album position of the song and I have two custom fields with that data, `sd_album_title` and `sd\_album\_track\_n.
Plus som... | Why you are using `pre_get_posts` when using your own `get_posts()` ? You can just pass the argument list directly to `get_posts()`.
`orderby` can accept array of arguments and can order by multiple values.
First name the indexes of meta queries array. This can be anything to use in orderby parameter. e.g.
```
'meta_... |
222,172 | <p>I have a daily wp schedule event. </p>
<p>I know that it happens when a user visits the site and if a schedule time passes. </p>
<p>If I started it on today 12 a.m. and if tomorrow first visitor comes tomorrow 1:20 a.m. that event happen tomorrow 1:20 a.m.. </p>
<p>Day after day, it happens after 1.20 a.m. or aft... | [
{
"answer_id": 222250,
"author": "David E. Smith",
"author_id": 67104,
"author_profile": "https://wordpress.stackexchange.com/users/67104",
"pm_score": 3,
"selected": true,
"text": "<p><em>wp-cron</em> is often called a pseudo-cron, because it doesn't run on a strict schedule. If nobody ... | 2016/03/31 | [
"https://wordpress.stackexchange.com/questions/222172",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91136/"
] | I have a daily wp schedule event.
I know that it happens when a user visits the site and if a schedule time passes.
If I started it on today 12 a.m. and if tomorrow first visitor comes tomorrow 1:20 a.m. that event happen tomorrow 1:20 a.m..
Day after day, it happens after 1.20 a.m. or after 12 a.m.? | *wp-cron* is often called a pseudo-cron, because it doesn't run on a strict schedule. If nobody visits the site, it doesn't run. If you schedule a wp-cron event to run, say, every 12 hours, it will run *at most* every 12 hours. But, if your site has very little traffic, there could be far more than 12 hours between run... |
222,200 | <p>I need to get the subscription key of a particular subscription to pass into a custom function. I have referenced the documentation where it shows how to get the key, but I have failed to integrate this into my code. So what my code does is, when a renewal is triggered, I hook into processed_subscription_payment wit... | [
{
"answer_id": 222240,
"author": "nerdalert",
"author_id": 91410,
"author_profile": "https://wordpress.stackexchange.com/users/91410",
"pm_score": 3,
"selected": true,
"text": "<p>I figured out the answer, so I thought I'd post it. My code looks like this now and it works:</p>\n\n<pre><c... | 2016/03/31 | [
"https://wordpress.stackexchange.com/questions/222200",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91410/"
] | I need to get the subscription key of a particular subscription to pass into a custom function. I have referenced the documentation where it shows how to get the key, but I have failed to integrate this into my code. So what my code does is, when a renewal is triggered, I hook into processed\_subscription\_payment with... | I figured out the answer, so I thought I'd post it. My code looks like this now and it works:
```
add_action( 'processed_subscription_payment', 'updatedays', 10, 2 );
function updatedays($user_id, $subscription_key)
{
//do what I need to the sub key
}
```
There really needs to be more examples on the Wootheme... |
222,203 | <p>I'm working on a page template and I need <code>the_title</code> to be separate from the page text. I'm not sure how to load <code>the_content</code> without it having the title.
Can anyone help?</p>
| [
{
"answer_id": 222204,
"author": "Marta",
"author_id": 18097,
"author_profile": "https://wordpress.stackexchange.com/users/18097",
"pm_score": 0,
"selected": false,
"text": "<p>It's very possible that you have a function or a plugin that is inserting into your content the title.</p>\n\n<... | 2016/03/31 | [
"https://wordpress.stackexchange.com/questions/222203",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85626/"
] | I'm working on a page template and I need `the_title` to be separate from the page text. I'm not sure how to load `the_content` without it having the title.
Can anyone help? | ```
<?php if ( have_posts() ) : while ( have_posts() ) : the_post();
the_title( '<h3>', '</h3>' );// puts the title in h3 tags
the_content(); // adds the content
endwhile; else: ?>
<p>Sorry, no posts matched your criteria.</p>
<?php endif; ?>
```
Notice that you can use the title fu... |
222,205 | <p>I am pretty new to WordPress API, loving it btw, I have a small project, adding a like button to the end of every post, pressing it makes user like the post, button changes to dislike, pressing again makes user dislike the post.</p>
<p>Without the knowledge of WordPress API, I planned to create a table for my plugi... | [
{
"answer_id": 222210,
"author": "Luis Alberto Gonzalez Noguera",
"author_id": 91533,
"author_profile": "https://wordpress.stackexchange.com/users/91533",
"pm_score": 0,
"selected": false,
"text": "<p>The post meta (also known as custom fields) helps us to associate more content with a p... | 2016/03/31 | [
"https://wordpress.stackexchange.com/questions/222205",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91527/"
] | I am pretty new to WordPress API, loving it btw, I have a small project, adding a like button to the end of every post, pressing it makes user like the post, button changes to dislike, pressing again makes user dislike the post.
Without the knowledge of WordPress API, I planned to create a table for my plugin in wpdb ... | Yes, we can use existing tables in WordPress for storing the values.
Post meta fields are stored in the `{$wpdb->prefix}_postmeta` table (depending on the table prefix; `wp_postmeta` by default). If the meta key `"like_count"` is already present in the table along with the post ID then `update_post_meta()` will upda... |
222,219 | <p>I want to display the post archives like seen in this picture. Shown by year and on click it should open up the months. I am not sure how to approach this, would you customize the standard WordPress Archives Widget?</p>
<p><a href="https://i.stack.imgur.com/2bJDl.png" rel="nofollow noreferrer"><img src="https://i.s... | [
{
"answer_id": 222235,
"author": "Isaac Lubow",
"author_id": 2150,
"author_profile": "https://wordpress.stackexchange.com/users/2150",
"pm_score": -1,
"selected": false,
"text": "<p>The \"Archives\" Widget makes use of <a href=\"https://developer.wordpress.org/reference/functions/wp_get_... | 2016/03/31 | [
"https://wordpress.stackexchange.com/questions/222219",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/67074/"
] | I want to display the post archives like seen in this picture. Shown by year and on click it should open up the months. I am not sure how to approach this, would you customize the standard WordPress Archives Widget?
[](https://i.stack.imgur.com/2bJDl.... | I did this for a client and it looked like this:
The PHP code:
```
<dl class="tree-accordion">
<?php
$currentyear = date("Y");
$years = range($currentyear, 1950);
foreach($years as $year) { ?>
<dt><a href=""><i class="fa fa-fw fa-plus-square-o" aria-hidden="true"></i> <?php echo $year; ?></a><... |
222,231 | <p>I have this 'primary' menu with a few items in the CMS, which I can list nicely with this <strong>PHP code:</strong></p>
<pre><code>$args = array(
'theme_location' => 'primary'
);
wp_nav_menu( $args );
</code></pre>
<p>The PHP outputs the menu with the <code><ul></code> tag. but, I want to use <stro... | [
{
"answer_id": 222232,
"author": "Marttin Notta",
"author_id": 91525,
"author_profile": "https://wordpress.stackexchange.com/users/91525",
"pm_score": 0,
"selected": false,
"text": "<p>From your question i'm guessing you don't want wrapping divs around your tags. To remove them just add... | 2016/03/31 | [
"https://wordpress.stackexchange.com/questions/222231",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91540/"
] | I have this 'primary' menu with a few items in the CMS, which I can list nicely with this **PHP code:**
```
$args = array(
'theme_location' => 'primary'
);
wp_nav_menu( $args );
```
The PHP outputs the menu with the `<ul>` tag. but, I want to use **HTML** that looks like this:
```
<ul class="nav navbar-nav"> ... | You can change the classes of the `<ul>` by adding `'menu_class'=>'nav navbar-nav'` to your `$args` array. *Remember, this parameter overwrites all the classes, so add "menu" as well if you want many themes and plugins to work!*
If you don't want the outer `<div>`, you can "unwrap" the `<ul>` by adding `'container'=>f... |
222,238 | <p>I have two loops in home page (index.php)</p>
<pre><code><?php
$args = array(
'post_type' => 'post',
'posts_per_page' => 3,
);
$another_query = new WP_Query($args);
if( $another_query->have_posts() ) {
$i = 0;
while ($another_query->have_posts()) : $anoth... | [
{
"answer_id": 222247,
"author": "nicogaldo",
"author_id": 87880,
"author_profile": "https://wordpress.stackexchange.com/users/87880",
"pm_score": 0,
"selected": false,
"text": "<p>I have not tried it, but I think it should be like this:</p>\n\n<pre><code>$paged = get_query_var( 'paged' ... | 2016/03/31 | [
"https://wordpress.stackexchange.com/questions/222238",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I have two loops in home page (index.php)
```
<?php
$args = array(
'post_type' => 'post',
'posts_per_page' => 3,
);
$another_query = new WP_Query($args);
if( $another_query->have_posts() ) {
$i = 0;
while ($another_query->have_posts()) : $another_query->the_post(); ?>
... | You do need to run a custom query for your second loop. You can simply adjust the main query to your needs. It is always never a good idea to run custom queries in place of the main query. One big issue is always pagination, WordPress disregards all other queries, and only focus on the main query when it comes to page ... |
222,244 | <p>Im trying to override the admin email template text "New customer order" to "New order" in function.php, but i can not finde any info on google.
Can somebody please give me a hint! :)</p>
| [
{
"answer_id": 222247,
"author": "nicogaldo",
"author_id": 87880,
"author_profile": "https://wordpress.stackexchange.com/users/87880",
"pm_score": 0,
"selected": false,
"text": "<p>I have not tried it, but I think it should be like this:</p>\n\n<pre><code>$paged = get_query_var( 'paged' ... | 2016/03/31 | [
"https://wordpress.stackexchange.com/questions/222244",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91547/"
] | Im trying to override the admin email template text "New customer order" to "New order" in function.php, but i can not finde any info on google.
Can somebody please give me a hint! :) | You do need to run a custom query for your second loop. You can simply adjust the main query to your needs. It is always never a good idea to run custom queries in place of the main query. One big issue is always pagination, WordPress disregards all other queries, and only focus on the main query when it comes to page ... |
222,268 | <p>I have an admin form for a plugin I am making. However, there are a couple of fields I need to add where the admin need to upload a document or image. When these files are uploaded, I do not want them to be added to the media library of WordPress as these files won't be used on any web pages. All I need is just the ... | [
{
"answer_id": 222270,
"author": "dg4220",
"author_id": 91201,
"author_profile": "https://wordpress.stackexchange.com/users/91201",
"pm_score": 0,
"selected": false,
"text": "<p>I think it depends on how you're handling the file input field in your form. I've used <a href=\"https://codex... | 2016/03/31 | [
"https://wordpress.stackexchange.com/questions/222268",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/86404/"
] | I have an admin form for a plugin I am making. However, there are a couple of fields I need to add where the admin need to upload a document or image. When these files are uploaded, I do not want them to be added to the media library of WordPress as these files won't be used on any web pages. All I need is just the URL... | HTML
====
Okay, you'll of course want to set up an HTML file. I would use this code or something like it:
```
<form action="upload.php" method="post" enctype="multipart/form-data">
Select image to upload:
<input type="file" name="fileToUpload" id="fileToUpload">
<input type="submit" value="Upload Image" n... |
222,335 | <p>I have stuck in serious problem. I want to create a document and upload a word doc from front end after user login. Logged in user is admin. The plugin bp-doc uses WordPress default media uploader to upload file. </p>
<p>The plugin hits <code>.../wp-admin/async-upload.php</code>, but this throws an error <code>An e... | [
{
"answer_id": 223002,
"author": "Agustin Prosperi",
"author_id": 91219,
"author_profile": "https://wordpress.stackexchange.com/users/91219",
"pm_score": 1,
"selected": false,
"text": "<p>Maybe your switching from https to http after login, you can try this plugin <a href=\"https://wordp... | 2016/04/01 | [
"https://wordpress.stackexchange.com/questions/222335",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/53934/"
] | I have stuck in serious problem. I want to create a document and upload a word doc from front end after user login. Logged in user is admin. The plugin bp-doc uses WordPress default media uploader to upload file.
The plugin hits `.../wp-admin/async-upload.php`, but this throws an error `An error occurred in the uploa... | have you tried by setting the second argument of `wp_signon()` to `true` or blank?
set false will prevent `wp_signon()` from setting secure cookie which is essential for accessing `wp-admin` if your using ssl.
i have tested and `$user = wp_signon( $user_data, true );` works as expected. |
222,347 | <p>I would like to version control my WP sites with git. A big struggle I have with this is: how do you version control options/plugin settings in the database.</p>
<p>I would like to don't touch the dashboard in the live site. Only the users should need to login in to write posts - but I as a developer would like to ... | [
{
"answer_id": 222358,
"author": "Sumeet Shroff",
"author_id": 85982,
"author_profile": "https://wordpress.stackexchange.com/users/85982",
"pm_score": 0,
"selected": false,
"text": "<p>Not sure of what u need but....</p>\n\n<ol>\n<li><p>Maybe your can track the activities by using a Acti... | 2016/04/01 | [
"https://wordpress.stackexchange.com/questions/222347",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/83359/"
] | I would like to version control my WP sites with git. A big struggle I have with this is: how do you version control options/plugin settings in the database.
I would like to don't touch the dashboard in the live site. Only the users should need to login in to write posts - but I as a developer would like to log in onl... | [WP-CFM](https://wordpress.org/plugins/wp-cfm/) is probably the closest to what you're looking for. Actually, it has been inspired by Drupal's Features module.
From the plugin page:
>
> WP-CFM lets you copy database configuration to / from the filesystem. Easily deploy configuration changes without needing to copy t... |
222,348 | <p>I wish to create different template pages for all Parent Categories and Subcategories. I was hoping to do it using the hierarchy (eg. something like <code>category-parent.php</code> and <code>category-sub.php</code>), but looking at the flow diagram I found, I don't think there's an option:</p>
<p><a href="https://... | [
{
"answer_id": 222355,
"author": "Sumeet Shroff",
"author_id": 85982,
"author_profile": "https://wordpress.stackexchange.com/users/85982",
"pm_score": 0,
"selected": false,
"text": "<p>There is another way if you code the same in the <code>category.php</code> file.\nCheck if the category... | 2016/04/01 | [
"https://wordpress.stackexchange.com/questions/222348",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4109/"
] | I wish to create different template pages for all Parent Categories and Subcategories. I was hoping to do it using the hierarchy (eg. something like `category-parent.php` and `category-sub.php`), but looking at the flow diagram I found, I don't think there's an option:
[ filter.
`category-parent.php` and `category-sub.php` both are not required. One can be `category.php` for parent categories and for child categories, you can use `custom-category-chil... |
222,352 | <p>I'm getting quite frustrated setting up the correct URL structure for a Cutom Post Type with a Custom taxonomy. </p>
<p>I have a Custom Post Type called <code>courses</code> with a Custom Taxonomy called <code>course-type</code>. </p>
<ol>
<li><strong>The URL structure should be:</strong>
<code>site.com/courses/co... | [
{
"answer_id": 222372,
"author": "Michael Ecklund",
"author_id": 9579,
"author_profile": "https://wordpress.stackexchange.com/users/9579",
"pm_score": 0,
"selected": false,
"text": "<p>With your desired permalink URL structure ... WordPress is automatically handling the creation of rewri... | 2016/04/01 | [
"https://wordpress.stackexchange.com/questions/222352",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/28103/"
] | I'm getting quite frustrated setting up the correct URL structure for a Cutom Post Type with a Custom taxonomy.
I have a Custom Post Type called `courses` with a Custom Taxonomy called `course-type`.
1. **The URL structure should be:**
`site.com/courses/course-type/course-single-post/`.
2. **For example:** `site.co... | Setting `has_archive` to `true` causes WordPress to generate a rewrite rule for the archive using the rewrite slug, which is not what you want in your case. Instead, explicitly specify the archive slug as a string and the correct rules will be generated:
```
$args = array(
'has_archive' => 'courses',
'rewrit... |
222,452 | <p>Till today I never used <code>header.php</code> and <code>footer.php</code> because my theme has multiple templates and I do not know how or where to place the CSS and JS files. Could someone please explain how to have a <code>header.php</code> and use <code>get_header();</code> but also include new CSS files depend... | [
{
"answer_id": 222456,
"author": "Max Yudin",
"author_id": 11761,
"author_profile": "https://wordpress.stackexchange.com/users/11761",
"pm_score": 2,
"selected": false,
"text": "<p>Don't include CSS and JavaScript manually, there are special functions for this purpose. Modify this code t... | 2016/04/02 | [
"https://wordpress.stackexchange.com/questions/222452",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/87656/"
] | Till today I never used `header.php` and `footer.php` because my theme has multiple templates and I do not know how or where to place the CSS and JS files. Could someone please explain how to have a `header.php` and use `get_header();` but also include new CSS files depending on the template?
**Normal Code** *And how ... | Include CSS and JavaScipt in the `functions.php`.
Create an empty PHP file, call it `header.php`, and yes `wp_head()` goes just before `</head>` not before `<body>` tag.
```
<!DOCTYPE html>
<html>
<head>
<title>Website</title>
<link href="style.css" rel="stylesheet" type="text/css" />
<?php wp_head(); ?>
</... |
222,498 | <p>I have a custom post type called <code>shows</code> and taxonomy called <code>podcast</code>. Using <code>taxonomy-podcast.php</code>, I having hard time finding a function that will generate next/previous Term URL Archive.</p>
<h2>For Example:</h2>
<p>URL: url.com/podcast/example-term-2</p>
<blockquote>
<p><st... | [
{
"answer_id": 222504,
"author": "majick",
"author_id": 76440,
"author_profile": "https://wordpress.stackexchange.com/users/76440",
"pm_score": 1,
"selected": false,
"text": "<p>Something like this will do it, if you have a lot of terms it could be a rather expensive query though as it r... | 2016/04/03 | [
"https://wordpress.stackexchange.com/questions/222498",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/48726/"
] | I have a custom post type called `shows` and taxonomy called `podcast`. Using `taxonomy-podcast.php`, I having hard time finding a function that will generate next/previous Term URL Archive.
For Example:
------------
URL: url.com/podcast/example-term-2
>
> **Example Term 2**
>
>
> post 1,post 2,post 3
>
>
>
D... | It is quite possible to achieve this. What we need to do is
* Get all the terms sorted by slug (*or any other field desired*) associated with our taxonomy
* Get the current term object
* Determine where in the array our current term is
* Get the two adjacent terms (*if any*)
* Build the links to those term pages
THE ... |
222,501 | <p>How can I apply this function to a single page ID:</p>
<pre><code>function exclude_jobs_locations($args){
$exclude = "40";
$args["exclude"] = $exclude;
return $args;
}
add_filter("sjb_job_location_filter_args","exclude_jobs_locations");
</code></pre>
<p>Can I also exclude child categories when parent c... | [
{
"answer_id": 222504,
"author": "majick",
"author_id": 76440,
"author_profile": "https://wordpress.stackexchange.com/users/76440",
"pm_score": 1,
"selected": false,
"text": "<p>Something like this will do it, if you have a lot of terms it could be a rather expensive query though as it r... | 2016/04/03 | [
"https://wordpress.stackexchange.com/questions/222501",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/90898/"
] | How can I apply this function to a single page ID:
```
function exclude_jobs_locations($args){
$exclude = "40";
$args["exclude"] = $exclude;
return $args;
}
add_filter("sjb_job_location_filter_args","exclude_jobs_locations");
```
Can I also exclude child categories when parent category is excluded?
I've... | It is quite possible to achieve this. What we need to do is
* Get all the terms sorted by slug (*or any other field desired*) associated with our taxonomy
* Get the current term object
* Determine where in the array our current term is
* Get the two adjacent terms (*if any*)
* Build the links to those term pages
THE ... |
222,526 | <p>I need to move my simple <code>Wordpres</code> site from <code>www.mysite.oldplace.com</code> to <code>www.oldplace.com</code> in most as possible simple and native way. My simple site specification:
WP 4.4.2
Twenty Twelve 1.9 theme
Polylang plugin 1.8.4 </p>
<p>I know that I can install some plugins that might do ... | [
{
"answer_id": 222527,
"author": "kovshenin",
"author_id": 1316,
"author_profile": "https://wordpress.stackexchange.com/users/1316",
"pm_score": 1,
"selected": false,
"text": "<p>Unfortunately there's nothing native in WordPress to handle searching and replacing your domain name across a... | 2016/04/03 | [
"https://wordpress.stackexchange.com/questions/222526",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/74608/"
] | I need to move my simple `Wordpres` site from `www.mysite.oldplace.com` to `www.oldplace.com` in most as possible simple and native way. My simple site specification:
WP 4.4.2
Twenty Twelve 1.9 theme
Polylang plugin 1.8.4
I know that I can install some plugins that might do this job, but I'm not sure they really does... | Unfortunately there's nothing native in WordPress to handle searching and replacing your domain name across all your posts, options, etc.
The closest you can get is WP-CLI's [search-replace](http://wp-cli.org/commands/search-replace/) command. It's not an official WordPress project, but it has quite a high adoption ra... |
222,535 | <p>I am trying to build a simple Wordpress favourite post plugin that is scalable and could handle 1000s or 10000s of users or more.</p>
<p>There are several different approaches that I have seen in other plugins and I would like to know which would be best practice from a scalability point of view, which means that s... | [
{
"answer_id": 222536,
"author": "Marttin Notta",
"author_id": 91525,
"author_profile": "https://wordpress.stackexchange.com/users/91525",
"pm_score": 0,
"selected": false,
"text": "<p><b>Option</b> 1 is not the best choice because serializing data means you must parse your SQL result t... | 2016/04/03 | [
"https://wordpress.stackexchange.com/questions/222535",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/58447/"
] | I am trying to build a simple Wordpress favourite post plugin that is scalable and could handle 1000s or 10000s of users or more.
There are several different approaches that I have seen in other plugins and I would like to know which would be best practice from a scalability point of view, which means that size of the... | You forgot option 3 - Add a special table in which the pair (user,post id) will be the index. Ok I am not a MySQL person so maybe it is too extreme, but maybe having two tables one with users as index and one with posts will be even better.
The thing about performance is that there are rarely absolute solutions for ev... |
222,540 | <p>On a fresh install, I want to move the upload folder to a subdomain (supposed to speed up download). My subdomain links to a folder called static. So I have: </p>
<ul>
<li>Home
<ul>
<li>wp
<ul>
<li>wp-admin</li>
<li>wp-content</li>
<li>wp-include</li>
</ul></li>
<li>static</li>
</ul></li>
</ul>
<p>Now I need to ... | [
{
"answer_id": 222542,
"author": "kovshenin",
"author_id": 1316,
"author_profile": "https://wordpress.stackexchange.com/users/1316",
"pm_score": 4,
"selected": true,
"text": "<blockquote>\n <p>I went to the wp-admin/options.php page and set ... But is that how it's supposed to be done?<... | 2016/04/03 | [
"https://wordpress.stackexchange.com/questions/222540",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/88773/"
] | On a fresh install, I want to move the upload folder to a subdomain (supposed to speed up download). My subdomain links to a folder called static. So I have:
* Home
+ wp
- wp-admin
- wp-content
- wp-include
+ static
Now I need to tell WordPress where the upload folder is and define its URL. The [codex](http:... | >
> I went to the wp-admin/options.php page and set ... But is that how it's supposed to be done?
>
>
>
Nope. You should never change anything in the WordPress core files because all your changes will be lost during the next update. You should use actions and filters instead:
```
add_filter( 'pre_option_upload_pa... |
222,552 | <p>I want to get all categories (custom taxonomy) in array from a specific post type. The taxonomy (category) registered for a specific post type only. And I want to retrieve all categories in an array.
Be like -</p>
<pre><code>array(
'Category Name 1' => 'slug-name-1',
'Category Name 2' => 'slug-name-2',
... | [
{
"answer_id": 222604,
"author": "Luis Sanz",
"author_id": 81084,
"author_profile": "https://wordpress.stackexchange.com/users/81084",
"pm_score": 1,
"selected": false,
"text": "<p>You can use <a href=\"https://developer.wordpress.org/reference/functions/get_terms/\" rel=\"nofollow\"><co... | 2016/04/03 | [
"https://wordpress.stackexchange.com/questions/222552",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/81042/"
] | I want to get all categories (custom taxonomy) in array from a specific post type. The taxonomy (category) registered for a specific post type only. And I want to retrieve all categories in an array.
Be like -
```
array(
'Category Name 1' => 'slug-name-1',
'Category Name 2' => 'slug-name-2',
'Category Name 3' =>... | You can use [`get_terms()`](https://developer.wordpress.org/reference/functions/get_terms/) to retrieve the custom taxonomy terms and then build up a custom array to match the structure you want.
Try this:
```
//Get the custom taxonomy terms
$taxonomies = array(
'name' => 'your_custom_taxonomy' //Edit to match yo... |
222,565 | <p>I have two different files for the header in my theme. These are <code>header.php</code> and <code>header-full.php</code>. </p>
<p>How can I load different CSS in different headers?</p>
<p>I enqueue my CSS files in <code>function.php</code> like this:</p>
<p><a href="https://i.stack.imgur.com/HE8U6.jpg" rel="nofo... | [
{
"answer_id": 222575,
"author": "Max Yudin",
"author_id": 11761,
"author_profile": "https://wordpress.stackexchange.com/users/11761",
"pm_score": 1,
"selected": true,
"text": "<p>Enqueue style depending on a template filename:</p>\n\n<pre><code>if('header.php' == basename( get_page_temp... | 2016/04/04 | [
"https://wordpress.stackexchange.com/questions/222565",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91204/"
] | I have two different files for the header in my theme. These are `header.php` and `header-full.php`.
How can I load different CSS in different headers?
I enqueue my CSS files in `function.php` like this:
[](https://i.stack.imgur.com/HE8U6.jpg) | Enqueue style depending on a template filename:
```
if('header.php' == basename( get_page_template() ) { // check the template file name
// enqueue header.php style here
}
if('header-full.php' == basename( get_page_template() ) { // check the template file name
// enqueue header-full.php style here
}
```
`w... |
222,580 | <p>i want to remove those <code><p></code> and <code><br/></code> tags from my contactform7 forms. now they have this wpcf7_autop which can be set to false when inserting:</p>
<pre><code>define('WPCF7_AUTOP', false);
</code></pre>
<p>to wp-config.php</p>
<p><strong>The problem is:</strong>
I need this se... | [
{
"answer_id": 222707,
"author": "Aishan",
"author_id": 89530,
"author_profile": "https://wordpress.stackexchange.com/users/89530",
"pm_score": 2,
"selected": true,
"text": "<ul>\n<li><p>You can try minify html from the contact form 7 </p></li>\n<li><p>To completely disable the wpautop f... | 2016/04/04 | [
"https://wordpress.stackexchange.com/questions/222580",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/43619/"
] | i want to remove those `<p>` and `<br/>` tags from my contactform7 forms. now they have this wpcf7\_autop which can be set to false when inserting:
```
define('WPCF7_AUTOP', false);
```
to wp-config.php
**The problem is:**
I need this setting to be attached with my theme, so is it possible to some how do it through... | * You can try minify html from the contact form 7
* To completely disable the wpautop filter, you can use:
```
remove_filter('the_content', 'wpautop');
``` |
222,608 | <p>I wrote my first Plugin and have one issue, the content of my Plugin is shown on every page. So if I want to open my gallery it shows my plugin content.</p>
<p><strong>myplugin.php</strong></p>
<pre><code><?php
/*
* Plugin Name: Gw2 Event Timer
* Plugin URI: http://localhost/wordpress
* Description: T1Ein G... | [
{
"answer_id": 222610,
"author": "Bruno Cantuaria",
"author_id": 65717,
"author_profile": "https://wordpress.stackexchange.com/users/65717",
"pm_score": 1,
"selected": true,
"text": "<p>It's a common mistake about the difference of WordPress' Actions and Filters.</p>\n\n<ol>\n<li>Action ... | 2016/04/04 | [
"https://wordpress.stackexchange.com/questions/222608",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91744/"
] | I wrote my first Plugin and have one issue, the content of my Plugin is shown on every page. So if I want to open my gallery it shows my plugin content.
**myplugin.php**
```
<?php
/*
* Plugin Name: Gw2 Event Timer
* Plugin URI: http://localhost/wordpress
* Description: T1Ein Guild Wars 2 Timer - beinhaltet alle W... | It's a common mistake about the difference of WordPress' Actions and Filters.
1. Action is when you want something to happens besides the default.
2. Filter is when you want something to happens instead the default.
Knowing that, when you use an action, your output will be inserted in that action content. But when yo... |
222,660 | <p>all - </p>
<p>I do not have the greatest CSS skills in the world, but I can normally figure things out. Right now I'm trying to implement a fairly simple media query in the child theme of my Wordpress site. I don't know if I typed something wrong or made another mistake, but the media query rules don't even show up... | [
{
"answer_id": 222668,
"author": "Emanuel Rocha Costa",
"author_id": 75873,
"author_profile": "https://wordpress.stackexchange.com/users/75873",
"pm_score": 0,
"selected": false,
"text": "<p>The problem is due you having the styles associated to the element style property: </p>\n\n<pre><... | 2016/04/04 | [
"https://wordpress.stackexchange.com/questions/222660",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91768/"
] | all -
I do not have the greatest CSS skills in the world, but I can normally figure things out. Right now I'm trying to implement a fairly simple media query in the child theme of my Wordpress site. I don't know if I typed something wrong or made another mistake, but the media query rules don't even show up when I in... | I think I may have the solution below :)
Try adding this to your CSS file:
```
@media screen and (max-width: 479px) {
.sow-slider-base ul.sow-slider-images li.sow-slider-image.sow-slider-image-cover {
background-image: url('http://www.thousandgirlsinitiative.org/wp-content/uploads/2016/04/Wendy-mobile.jpg... |
222,664 | <p>I want to include the comments form on a page generated by my plugin. I got the post id I want to attach the comments to, but I can't get any of the Wordpress comments functions to work. </p>
<p>Tried to create a Wordpress loop within my plugin page like this, but the comments form won´t show up: </p>
<pre><code>... | [
{
"answer_id": 222690,
"author": "Ray Flores",
"author_id": 29355,
"author_profile": "https://wordpress.stackexchange.com/users/29355",
"pm_score": 2,
"selected": true,
"text": "<p>Just as @Jevuska mentioned, you can use the $post_id as an argument here, in fact, you can also use a ton o... | 2016/04/04 | [
"https://wordpress.stackexchange.com/questions/222664",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/83020/"
] | I want to include the comments form on a page generated by my plugin. I got the post id I want to attach the comments to, but I can't get any of the Wordpress comments functions to work.
Tried to create a Wordpress loop within my plugin page like this, but the comments form won´t show up:
```
$args = array ('post_... | Just as @Jevuska mentioned, you can use the $post\_id as an argument here, in fact, you can also use a ton of optional $args as well `<?php comment_form( $args, $post_id ); ?>`
You can find the information in the Codex here: <https://codex.wordpress.org/Function_Reference/comment_form> |
222,712 | <p>My template works fine, however, its using my main header file, even though I have changed it to point to <code>sub-header.php</code> </p>
<pre><code><?php /* Template Name: Sub Page */
get_header('sub-header'); ?>
</code></pre>
| [
{
"answer_id": 222713,
"author": "Mehul Gohil",
"author_id": 37768,
"author_profile": "https://wordpress.stackexchange.com/users/37768",
"pm_score": 1,
"selected": true,
"text": "<p>You are following a wrong format to call sub header file.</p>\n\n<p><strong>Here is how we have to call su... | 2016/04/05 | [
"https://wordpress.stackexchange.com/questions/222712",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91799/"
] | My template works fine, however, its using my main header file, even though I have changed it to point to `sub-header.php`
```
<?php /* Template Name: Sub Page */
get_header('sub-header'); ?>
``` | You are following a wrong format to call sub header file.
**Here is how we have to call sub header files:**
```
<?php get_header('subexample'); ?>
```
**Here is how you have to name the sub header file:**
`header-subexample.php`
Hope this helps! |
222,730 | <p>I'm having an issue with the order WordPress is loading page templates and <code>functions.php</code>.</p>
<p>I have <code>front-page.php</code> which has <code>$_POST['sort-by']</code> allowing users to sort posts using a drop-down menu.</p>
<p>It's simple enough and works just fine. Now comes the part where I ha... | [
{
"answer_id": 222713,
"author": "Mehul Gohil",
"author_id": 37768,
"author_profile": "https://wordpress.stackexchange.com/users/37768",
"pm_score": 1,
"selected": true,
"text": "<p>You are following a wrong format to call sub header file.</p>\n\n<p><strong>Here is how we have to call su... | 2016/04/05 | [
"https://wordpress.stackexchange.com/questions/222730",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91806/"
] | I'm having an issue with the order WordPress is loading page templates and `functions.php`.
I have `front-page.php` which has `$_POST['sort-by']` allowing users to sort posts using a drop-down menu.
It's simple enough and works just fine. Now comes the part where I have the ability to "Load more posts" which uses `wp... | You are following a wrong format to call sub header file.
**Here is how we have to call sub header files:**
```
<?php get_header('subexample'); ?>
```
**Here is how you have to name the sub header file:**
`header-subexample.php`
Hope this helps! |
222,742 | <p>I am setting up an events page for my website. This page is using a loop to display a list of acts performing at different venues month-by-month. When a viewer comes to the page, they use a simple form to select the month, and when submitted this return the relevant data. At the moment the data fields I am displayin... | [
{
"answer_id": 222750,
"author": "Charles Jaimet",
"author_id": 43741,
"author_profile": "https://wordpress.stackexchange.com/users/43741",
"pm_score": 1,
"selected": false,
"text": "<p>Your best bet is not to run a bunch of queries but to loop through your data once to organize it then ... | 2016/04/05 | [
"https://wordpress.stackexchange.com/questions/222742",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91798/"
] | I am setting up an events page for my website. This page is using a loop to display a list of acts performing at different venues month-by-month. When a viewer comes to the page, they use a simple form to select the month, and when submitted this return the relevant data. At the moment the data fields I am displaying f... | Your best bet is not to run a bunch of queries but to loop through your data once to organize it then a second time to display it. Below is the logic you need. The exact code will depend on your data set.
```
$events = array();
$posts = WP_Query( $args );
foreach ( $posts as $post ) {
$venue = $post->venue;
$day_... |
222,763 | <p>Are there any disadvantages to using the following code to setup WP_HOME and WP_SITEURL in wp.config for both singlesite installs and multisite installs:</p>
<pre><code>/**
* Site Host URLs
*/
$hostname = $_SERVER['HTTP_HOST'];
if(isset($_SERVER['HTTP_X_FORWARDED_HOST']) && !empty($_SERVER['HTTP_X_FORWARDE... | [
{
"answer_id": 222766,
"author": "Marttin Notta",
"author_id": 91525,
"author_profile": "https://wordpress.stackexchange.com/users/91525",
"pm_score": 0,
"selected": false,
"text": "<p>As far as i can see (2 years wordpress/woocommerce) i have always used WP_HOME and WP_SITEURL. Makes it... | 2016/04/05 | [
"https://wordpress.stackexchange.com/questions/222763",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91822/"
] | Are there any disadvantages to using the following code to setup WP\_HOME and WP\_SITEURL in wp.config for both singlesite installs and multisite installs:
```
/**
* Site Host URLs
*/
$hostname = $_SERVER['HTTP_HOST'];
if(isset($_SERVER['HTTP_X_FORWARDED_HOST']) && !empty($_SERVER['HTTP_X_FORWARDED_HOST'])) {
$ho... | The obvious problem is that you are trusting user input (http headers) which makes your code suspicious from security POV.
Other then that, no real problems with it, but my experience is that such hacks have a tendency to just move whatever problem you are trying to solve this way to another place. |
222,797 | <p>Good evening everyone.</p>
<p>I have three Custom Post Types and i want to remove the parent slugs from them.</p>
<pre><code>$args = array(
'rewrite' => array('slug' => '/','with_front' => true),
);
</code></pre>
<p><code>functions.php</code></p>
<pre><code>function wpse_101072_flatten_hierarchies( $pos... | [
{
"answer_id": 222766,
"author": "Marttin Notta",
"author_id": 91525,
"author_profile": "https://wordpress.stackexchange.com/users/91525",
"pm_score": 0,
"selected": false,
"text": "<p>As far as i can see (2 years wordpress/woocommerce) i have always used WP_HOME and WP_SITEURL. Makes it... | 2016/04/05 | [
"https://wordpress.stackexchange.com/questions/222797",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | Good evening everyone.
I have three Custom Post Types and i want to remove the parent slugs from them.
```
$args = array(
'rewrite' => array('slug' => '/','with_front' => true),
);
```
`functions.php`
```
function wpse_101072_flatten_hierarchies( $post_link, $post ) {
if ( 'CPT1' != $post->post_type ... | The obvious problem is that you are trusting user input (http headers) which makes your code suspicious from security POV.
Other then that, no real problems with it, but my experience is that such hacks have a tendency to just move whatever problem you are trying to solve this way to another place. |
222,799 | <p>I have built a site using WooCommerce Bookings with an AJAX request that processes the payment, creates and order and lastly creates a booking with the order ID. However, when I send the newly created order ID via the WooCommerce Bookings create method the order doesn't appear in the Booking and I have to manually ... | [
{
"answer_id": 222766,
"author": "Marttin Notta",
"author_id": 91525,
"author_profile": "https://wordpress.stackexchange.com/users/91525",
"pm_score": 0,
"selected": false,
"text": "<p>As far as i can see (2 years wordpress/woocommerce) i have always used WP_HOME and WP_SITEURL. Makes it... | 2016/04/05 | [
"https://wordpress.stackexchange.com/questions/222799",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16020/"
] | I have built a site using WooCommerce Bookings with an AJAX request that processes the payment, creates and order and lastly creates a booking with the order ID. However, when I send the newly created order ID via the WooCommerce Bookings create method the order doesn't appear in the Booking and I have to manually conn... | The obvious problem is that you are trusting user input (http headers) which makes your code suspicious from security POV.
Other then that, no real problems with it, but my experience is that such hacks have a tendency to just move whatever problem you are trying to solve this way to another place. |
222,857 | <p>In a question that is related to, but not the same as, <a href="https://wordpress.stackexchange.com/questions/5144/how-to-link-to-images-in-my-plugin-regardless-of-the-plugin-folders-name/">How to link to images in my plugin regardless of the plugin folder's name</a></p>
<ul>
<li><code>plugin-folder/plugin-main... | [
{
"answer_id": 222859,
"author": "Elektra",
"author_id": 91391,
"author_profile": "https://wordpress.stackexchange.com/users/91391",
"pm_score": 0,
"selected": false,
"text": "<p><strong>Edit</strong></p>\n\n<p>My bad, in that case I can think of this. </p>\n\n<pre><code>$x = WP_PLUGIN_U... | 2016/04/06 | [
"https://wordpress.stackexchange.com/questions/222857",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19707/"
] | In a question that is related to, but not the same as, [How to link to images in my plugin regardless of the plugin folder's name](https://wordpress.stackexchange.com/questions/5144/how-to-link-to-images-in-my-plugin-regardless-of-the-plugin-folders-name/)
* `plugin-folder/plugin-main-file.php`
* `plugin-folder/images... | I think you are looking for [plugin\_dir\_url](https://codex.wordpress.org/Function_Reference/plugin_dir_url):
```
$url = plugin_dir_url(__FILE__);
$imageurl = $url.'images/someimage.png';
```
**EDIT**: Sorry I misread the question... that is only an answer to the linked question. You could check the parent directo... |
222,887 | <p>Is there a way to get products in the order of the IDs in the shortcode parameter:</p>
<p>e.g <code>[products ids="53,68,1"]</code></p>
<p>Display block with 3 product, where 53 on first place, 68 on second...?</p>
<p>Now I get products sorted by sku, name etc. Depending on order-by parameter, but I need specifi... | [
{
"answer_id": 222859,
"author": "Elektra",
"author_id": 91391,
"author_profile": "https://wordpress.stackexchange.com/users/91391",
"pm_score": 0,
"selected": false,
"text": "<p><strong>Edit</strong></p>\n\n<p>My bad, in that case I can think of this. </p>\n\n<pre><code>$x = WP_PLUGIN_U... | 2016/04/06 | [
"https://wordpress.stackexchange.com/questions/222887",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91898/"
] | Is there a way to get products in the order of the IDs in the shortcode parameter:
e.g `[products ids="53,68,1"]`
Display block with 3 product, where 53 on first place, 68 on second...?
Now I get products sorted by sku, name etc. Depending on order-by parameter, but I need specific order. | I think you are looking for [plugin\_dir\_url](https://codex.wordpress.org/Function_Reference/plugin_dir_url):
```
$url = plugin_dir_url(__FILE__);
$imageurl = $url.'images/someimage.png';
```
**EDIT**: Sorry I misread the question... that is only an answer to the linked question. You could check the parent directo... |
222,888 | <p>I want to show a select box for user roles in the registration form. I am using this model:</p>
<pre><code>/* ROLES IN LIST REGISTRATION */
// 1. Add a new form element...
add_action( 'register_form', 'odin_register_form' );
function odin_register_form() {
global $wp_roles;
echo '<select name="role" cl... | [
{
"answer_id": 222859,
"author": "Elektra",
"author_id": 91391,
"author_profile": "https://wordpress.stackexchange.com/users/91391",
"pm_score": 0,
"selected": false,
"text": "<p><strong>Edit</strong></p>\n\n<p>My bad, in that case I can think of this. </p>\n\n<pre><code>$x = WP_PLUGIN_U... | 2016/04/06 | [
"https://wordpress.stackexchange.com/questions/222888",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/71254/"
] | I want to show a select box for user roles in the registration form. I am using this model:
```
/* ROLES IN LIST REGISTRATION */
// 1. Add a new form element...
add_action( 'register_form', 'odin_register_form' );
function odin_register_form() {
global $wp_roles;
echo '<select name="role" class="input">';
... | I think you are looking for [plugin\_dir\_url](https://codex.wordpress.org/Function_Reference/plugin_dir_url):
```
$url = plugin_dir_url(__FILE__);
$imageurl = $url.'images/someimage.png';
```
**EDIT**: Sorry I misread the question... that is only an answer to the linked question. You could check the parent directo... |
222,891 | <p>I have to load multiple posts on a single page. The situation is different. The client ask to reorder the posts, that the current post of the category becomes first and all the rest are next. Then on scroll I load the next posts <em>(infinite scroll effect)</em>. So what I do is, I query the database, get the posts,... | [
{
"answer_id": 222893,
"author": "majick",
"author_id": 76440,
"author_profile": "https://wordpress.stackexchange.com/users/76440",
"pm_score": 3,
"selected": true,
"text": "<p>You can use <em>output buffering</em> to achieve this effect:</p>\n\n<pre><code>function get_comments_form() {\... | 2016/04/06 | [
"https://wordpress.stackexchange.com/questions/222891",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/81454/"
] | I have to load multiple posts on a single page. The situation is different. The client ask to reorder the posts, that the current post of the category becomes first and all the rest are next. Then on scroll I load the next posts *(infinite scroll effect)*. So what I do is, I query the database, get the posts, find my c... | You can use *output buffering* to achieve this effect:
```
function get_comments_form() {
ob_start();
comments_form();
$commentsform = ob_get_contents();
ob_end_clean();
return $commentsform;
}
$commentsform = get_comments_form();
``` |
222,896 | <p>Is there an image bug in WP 4.4.2? I have tried the forums but no-one replies there. </p>
<p>When I upload an image, it is crunched according to my media settings. But when I go to 'Add media' and select 'Large' from the dropdown, it shows and inserts an image with width=640px, though it uses the crunched image tha... | [
{
"answer_id": 222893,
"author": "majick",
"author_id": 76440,
"author_profile": "https://wordpress.stackexchange.com/users/76440",
"pm_score": 3,
"selected": true,
"text": "<p>You can use <em>output buffering</em> to achieve this effect:</p>\n\n<pre><code>function get_comments_form() {\... | 2016/04/06 | [
"https://wordpress.stackexchange.com/questions/222896",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/90448/"
] | Is there an image bug in WP 4.4.2? I have tried the forums but no-one replies there.
When I upload an image, it is crunched according to my media settings. But when I go to 'Add media' and select 'Large' from the dropdown, it shows and inserts an image with width=640px, though it uses the crunched image that is 1140p... | You can use *output buffering* to achieve this effect:
```
function get_comments_form() {
ob_start();
comments_form();
$commentsform = ob_get_contents();
ob_end_clean();
return $commentsform;
}
$commentsform = get_comments_form();
``` |
222,899 | <p>Here's the scenario - I want to select fontawesome icons from the dropdown list but it's not working. For some reason the class inside <code>span</code> is not adding up (I have tried <code>jQuery().append()</code>, CSS) but so far no luck. ANY help would be appreciated.</p>
<p><strong>Code in <code>Page.php</code>... | [
{
"answer_id": 222893,
"author": "majick",
"author_id": 76440,
"author_profile": "https://wordpress.stackexchange.com/users/76440",
"pm_score": 3,
"selected": true,
"text": "<p>You can use <em>output buffering</em> to achieve this effect:</p>\n\n<pre><code>function get_comments_form() {\... | 2016/04/06 | [
"https://wordpress.stackexchange.com/questions/222899",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78505/"
] | Here's the scenario - I want to select fontawesome icons from the dropdown list but it's not working. For some reason the class inside `span` is not adding up (I have tried `jQuery().append()`, CSS) but so far no luck. ANY help would be appreciated.
**Code in `Page.php` file**
```
<div class="features-block-one">
<... | You can use *output buffering* to achieve this effect:
```
function get_comments_form() {
ob_start();
comments_form();
$commentsform = ob_get_contents();
ob_end_clean();
return $commentsform;
}
$commentsform = get_comments_form();
``` |
222,921 | <p>I have a php file located at:</p>
<pre><code>.../wp-content/themes/kallyas-child/pagebuilder/elements/TH_TeamBox/TH_TeamBox.php
</code></pre>
<p>I'm trying to use the above file to overwrite the parent's <em>TH_TeamBox.php</em> file which is found here:</p>
<pre><code>.../wp-content/themes/kallyas/pagebuilder/ele... | [
{
"answer_id": 222923,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 5,
"selected": true,
"text": "<p>Child themes are allowed to override <em>templates</em>, not simply arbitrary PHP files.</p>\n\n<p>In WordPress, a ... | 2016/04/06 | [
"https://wordpress.stackexchange.com/questions/222921",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91918/"
] | I have a php file located at:
```
.../wp-content/themes/kallyas-child/pagebuilder/elements/TH_TeamBox/TH_TeamBox.php
```
I'm trying to use the above file to overwrite the parent's *TH\_TeamBox.php* file which is found here:
```
.../wp-content/themes/kallyas/pagebuilder/elements/TH_TeamBox/TH_TeamBox.php
```
My ch... | Child themes are allowed to override *templates*, not simply arbitrary PHP files.
In WordPress, a theme consists of a bunch of PHP files which are used as Templates. You can find a list of those files in the [Template Hierarchy](https://developer.wordpress.org/themes/basics/template-hierarchy/).
Those specific templ... |
222,960 | <p>I want to make custom post types in my WordPress site. For that I used the <code>register_post_type</code> method in my <code>functions.php</code>, but why is only one custom post type showing in my admin page?</p>
<p>The code is shown below:</p>
<pre><code>function create_my_custom_posts() {
register_post_typ... | [
{
"answer_id": 222961,
"author": "Marttin Notta",
"author_id": 91525,
"author_profile": "https://wordpress.stackexchange.com/users/91525",
"pm_score": 3,
"selected": true,
"text": "<p>In the documentation it is written that post type must be max. 20 characters, cannot contain capital let... | 2016/04/07 | [
"https://wordpress.stackexchange.com/questions/222960",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/89018/"
] | I want to make custom post types in my WordPress site. For that I used the `register_post_type` method in my `functions.php`, but why is only one custom post type showing in my admin page?
The code is shown below:
```
function create_my_custom_posts() {
register_post_type( 'career_post', array(
'labels' =... | In the documentation it is written that post type must be max. 20 characters, cannot contain capital letters or spaces. |
222,986 | <p><a href="https://i.stack.imgur.com/F1yy5.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F1yy5.jpg" alt="An image illustration on how a drop down for news archive should be after php is added"></a>Am trying to get wp posts between two specific calendar month. The problem is, it is a annual year. S... | [
{
"answer_id": 222961,
"author": "Marttin Notta",
"author_id": 91525,
"author_profile": "https://wordpress.stackexchange.com/users/91525",
"pm_score": 3,
"selected": true,
"text": "<p>In the documentation it is written that post type must be max. 20 characters, cannot contain capital let... | 2016/04/07 | [
"https://wordpress.stackexchange.com/questions/222986",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91953/"
] | [](https://i.stack.imgur.com/F1yy5.jpg)Am trying to get wp posts between two specific calendar month. The problem is, it is a annual year. So month starts from May and ends in Next year April. S... | In the documentation it is written that post type must be max. 20 characters, cannot contain capital letters or spaces. |
223,009 | <p>I am trying to develop a plugin to extend WooCommerce and I would like to do something with the product id when I land on a single product page (e.g. store it in the database or store it in a session variable).</p>
<p>However whatever hook I try to use, two results are given. So for example I might use the hook woo... | [
{
"answer_id": 223005,
"author": "Owais Alam",
"author_id": 91939,
"author_profile": "https://wordpress.stackexchange.com/users/91939",
"pm_score": 1,
"selected": false,
"text": "<p>Perhaps your question no so much clear regarding your issue.I give the solution which i have understand th... | 2016/04/07 | [
"https://wordpress.stackexchange.com/questions/223009",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91964/"
] | I am trying to develop a plugin to extend WooCommerce and I would like to do something with the product id when I land on a single product page (e.g. store it in the database or store it in a session variable).
However whatever hook I try to use, two results are given. So for example I might use the hook woocommerce\_... | If your attachment is handled via the WP media library, each one has unique ID, just like Posts. When your users download the attachment by clicking the button, store a reference to that attachment ID in a `user_meta` setting and then update the button accordingly.
Another option: <https://easydigitaldownloads.com/> |
223,012 | <p>Two post types blog and events. I want to list in the same query but order events by their event date and blogs by their published date:</p>
<pre><code> $args = array(
'post_type' => array( 'post', 'event' ),
'posts_per_page' => '-1',
... | [
{
"answer_id": 223005,
"author": "Owais Alam",
"author_id": 91939,
"author_profile": "https://wordpress.stackexchange.com/users/91939",
"pm_score": 1,
"selected": false,
"text": "<p>Perhaps your question no so much clear regarding your issue.I give the solution which i have understand th... | 2016/04/07 | [
"https://wordpress.stackexchange.com/questions/223012",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/83064/"
] | Two post types blog and events. I want to list in the same query but order events by their event date and blogs by their published date:
```
$args = array(
'post_type' => array( 'post', 'event' ),
'posts_per_page' => '-1',
'meta_query'... | If your attachment is handled via the WP media library, each one has unique ID, just like Posts. When your users download the attachment by clicking the button, store a reference to that attachment ID in a `user_meta` setting and then update the button accordingly.
Another option: <https://easydigitaldownloads.com/> |
223,073 | <p>How can I create a type of loop in WordPress where an image moves left or right for each post? I.e. first post image will be left, second post image will go right, third post image will go left, and so on...</p>
<p><a href="https://i.stack.imgur.com/tohVE.png" rel="nofollow noreferrer"><img src="https://i.stack.img... | [
{
"answer_id": 223074,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>The PHP modulus operator gives you the remainder from dividing 2 numbers. The remainder from the division of any n... | 2016/04/08 | [
"https://wordpress.stackexchange.com/questions/223073",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91995/"
] | How can I create a type of loop in WordPress where an image moves left or right for each post? I.e. first post image will be left, second post image will go right, third post image will go left, and so on...
[](https://i.stack.imgur.com/tohVE.png) | The PHP modulus operator gives you the remainder from dividing 2 numbers. The remainder from the division of any number by two is either 0 or 1, so we can use that to provide an "alternator". We use the `current_post` var as a counter, which is available in any `WP_Query` object:
```
while( have_posts() ){
the_pos... |
223,117 | <p>I currently have simple pagination set up showing the text older and newer. If one of the text isn't needed it display an 'inactive' version of it so that the text doesn't disappear.</p>
<pre><code><?php if( get_next_posts_link() ) :?>
<div id="next-post-link" class="post-pag flL"><?p... | [
{
"answer_id": 223119,
"author": "Greg McMullen",
"author_id": 36028,
"author_profile": "https://wordpress.stackexchange.com/users/36028",
"pm_score": 1,
"selected": true,
"text": "<p>You can find more information in the <a href=\"https://codex.wordpress.org/Widgets_API\" rel=\"nofollow\... | 2016/04/08 | [
"https://wordpress.stackexchange.com/questions/223117",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51147/"
] | I currently have simple pagination set up showing the text older and newer. If one of the text isn't needed it display an 'inactive' version of it so that the text doesn't disappear.
```
<?php if( get_next_posts_link() ) :?>
<div id="next-post-link" class="post-pag flL"><?php next_posts_link( '<i class... | You can find more information in the [Widgets API](https://codex.wordpress.org/Widgets_API) |
223,135 | <p>I'm implementing a Kiosk webapp based off WordPress and I have some conditionals which are key, they work based on whether user is logged in or not.</p>
<p>I'm aware that after user clicks "remember me" it will keep them logged in for 14 days.</p>
<p>However, I want to keep users logged in for as long as possible... | [
{
"answer_id": 223136,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>What you found is actually perfectly accurate. With WP's commitment to backwards compatibility it's not that common... | 2016/04/08 | [
"https://wordpress.stackexchange.com/questions/223135",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76433/"
] | I'm implementing a Kiosk webapp based off WordPress and I have some conditionals which are key, they work based on whether user is logged in or not.
I'm aware that after user clicks "remember me" it will keep them logged in for 14 days.
However, I want to keep users logged in for as long as possible once they log in ... | What you found is actually perfectly accurate. With WP's commitment to backwards compatibility it's not that common for thing to stop working.
This filter is used in [`wp_set_auth_cookie()`](https://codex.wordpress.org/Function_Reference/wp_set_auth_cookie) to calculate the duration. Resulting value is used in PHP's [... |
223,141 | <p>I am working with wp-rest api and i have this json structure to work with:</p>
<pre><code>[
{
"id": 11,
"title": {
"rendered": "Test-Font"
},
"acf": {
"schrift": [
{
"zeichen": "A",
"anzahl": "23"
},
{
"zeichen": "B",
"anz... | [
{
"answer_id": 223136,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 2,
"selected": false,
"text": "<p>What you found is actually perfectly accurate. With WP's commitment to backwards compatibility it's not that common... | 2016/04/08 | [
"https://wordpress.stackexchange.com/questions/223141",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/86584/"
] | I am working with wp-rest api and i have this json structure to work with:
```
[
{
"id": 11,
"title": {
"rendered": "Test-Font"
},
"acf": {
"schrift": [
{
"zeichen": "A",
"anzahl": "23"
},
{
"zeichen": "B",
"anzahl": "46"
... | What you found is actually perfectly accurate. With WP's commitment to backwards compatibility it's not that common for thing to stop working.
This filter is used in [`wp_set_auth_cookie()`](https://codex.wordpress.org/Function_Reference/wp_set_auth_cookie) to calculate the duration. Resulting value is used in PHP's [... |
223,153 | <p>I have a WP site with multiple post types. Posts, products w/taxonomies.</p>
<p>I have my WP Default posts_per_page setting at 10 in the admin. I want to keep this setting as the blog would be best at 10 per page.</p>
<p>However on a page/template like taxonomyNAme-archive.php I want to get many more than 10. B... | [
{
"answer_id": 223156,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>Use the <a href=\"https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts\" rel=\"nofollow\"><code>p... | 2016/04/08 | [
"https://wordpress.stackexchange.com/questions/223153",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5181/"
] | I have a WP site with multiple post types. Posts, products w/taxonomies.
I have my WP Default posts\_per\_page setting at 10 in the admin. I want to keep this setting as the blog would be best at 10 per page.
However on a page/template like taxonomyNAme-archive.php I want to get many more than 10. But I don't need a ... | Use the [`pre_get_posts`](https://codex.wordpress.org/Plugin_API/Action_Reference/pre_get_posts) action to modify query parameters before the queries are run. You can use many of the [Conditional Tags](https://codex.wordpress.org/Conditional_Tags) to target specific types of pages.
```
function wpd_alter_posts_per_pag... |
223,169 | <p>It seems that some of the css on the table that shows the list of all the pages adversely reacts with one of my plugins, which adds a bunch of columns to the table. I'm pretty sure this is edit.php. At least, that's what's in the URL.</p>
<p>Using the developer tools in Chrome I noticed that the table contains a cl... | [
{
"answer_id": 223172,
"author": "ashraf",
"author_id": 30937,
"author_profile": "https://wordpress.stackexchange.com/users/30937",
"pm_score": 1,
"selected": false,
"text": "<p>I guess you are in edit.php so you can add style only for this admin page. </p>\n\n<pre><code>function enqueue... | 2016/04/09 | [
"https://wordpress.stackexchange.com/questions/223169",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38365/"
] | It seems that some of the css on the table that shows the list of all the pages adversely reacts with one of my plugins, which adds a bunch of columns to the table. I'm pretty sure this is edit.php. At least, that's what's in the URL.
Using the developer tools in Chrome I noticed that the table contains a class called... | A bit of a hack fix, I installed Tampermonkey for Chrome (a userscript manager) and created the following userscript:
```
// ==UserScript==
// @name Fix edit.php!
// @author You
// @match http://www.example.com/wp-admin/edit.php*
// @grant none
// ==/UserScript==
(function() {
'use str... |
223,216 | <p>The situation is this: I have created a custom post type which works perfectly, now I want to create a specific archive page template for the taxonomies of this post type.</p>
<p>I duplicated the <code>archive.php</code> page of my theme (schema by MTS) but it doesn't work in this case. </p>
<p>Here the code:
... | [
{
"answer_id": 223237,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 0,
"selected": false,
"text": "<p>What is wrong here is your assumptions that the values should be the same. I don't know of the top of my ... | 2016/04/09 | [
"https://wordpress.stackexchange.com/questions/223216",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/92109/"
] | The situation is this: I have created a custom post type which works perfectly, now I want to create a specific archive page template for the taxonomies of this post type.
I duplicated the `archive.php` page of my theme (schema by MTS) but it doesn't work in this case.
Here the code:
```
<?php
$term = get_term_by(... | I had same problem.
According to [documentation](https://developer.wordpress.org/themes/template-files-section/taxonomy-templates/):
```
The hierarchy for a custom taxonomy is listed below:
taxonomy-{taxonomy}-{term}.php
taxonomy-{taxonomy}.php
taxonomy.php
archive.php
index.php
```
So, it doesn't matter witch tem... |