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 |
|---|---|---|---|---|---|---|
256,669 | <p>I am registering the stylesheet and scripts but It is not working please help me. What I am doing wrong </p>
<pre><code>function theme_styles_and_scripts() {
wp_enqueue_style('bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css', array(), '3.3.6', 'all' );
}
add_action( 'wp_enqueue_scripts', '... | [
{
"answer_id": 256672,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 2,
"selected": true,
"text": "<p>There can be multiple reasons why it may not be working.</p>\n\n<p><strong>Possibility-1:</strong> You are add... | 2017/02/16 | [
"https://wordpress.stackexchange.com/questions/256669",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/108146/"
] | I am registering the stylesheet and scripts but It is not working please help me. What I am doing wrong
```
function theme_styles_and_scripts() {
wp_enqueue_style('bootstrap', get_template_directory_uri() . '/css/bootstrap.min.css', array(), '3.3.6', 'all' );
}
add_action( 'wp_enqueue_scripts', 'theme_styles_an... | There can be multiple reasons why it may not be working.
**Possibility-1:** You are adding the CSS file in a child theme. In that case, use the following CODE instead:
```
function theme_styles_and_scripts() {
wp_enqueue_style( 'bootstrap', get_stylesheet_directory_uri() . '/css/bootstrap.min.css', array(... |
256,682 | <p>I want to display dates in <strong>Hindi</strong> format like</p>
<pre><code>jan 10
</code></pre>
<p>using <code>get_the_date()</code> function. What I have tried so far:</p>
<pre><code>echo get_the_date(_e('F j'));
</code></pre>
<p>which outputs:</p>
<pre><code>F jJanuary 10, 2017.
</code></pre>
| [
{
"answer_id": 256672,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 2,
"selected": true,
"text": "<p>There can be multiple reasons why it may not be working.</p>\n\n<p><strong>Possibility-1:</strong> You are add... | 2017/02/16 | [
"https://wordpress.stackexchange.com/questions/256682",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112924/"
] | I want to display dates in **Hindi** format like
```
jan 10
```
using `get_the_date()` function. What I have tried so far:
```
echo get_the_date(_e('F j'));
```
which outputs:
```
F jJanuary 10, 2017.
``` | There can be multiple reasons why it may not be working.
**Possibility-1:** You are adding the CSS file in a child theme. In that case, use the following CODE instead:
```
function theme_styles_and_scripts() {
wp_enqueue_style( 'bootstrap', get_stylesheet_directory_uri() . '/css/bootstrap.min.css', array(... |
256,702 | <p>How can I query only those pages that <strong>DO NOT HAVE</strong> child pages?</p>
<p>E.g.:</p>
<ul>
<li>Parent page 1
<ul>
<li>Child page 1</li>
<li>Child page 2</li>
</ul></li>
<li>Parent page 2</li>
<li>Parent page 3
<ul>
<li>Child page 1</li>
<li>Child page 2</li>
</ul></li>
<li>Parent page 4</li>
</ul>
<p... | [
{
"answer_id": 256672,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 2,
"selected": true,
"text": "<p>There can be multiple reasons why it may not be working.</p>\n\n<p><strong>Possibility-1:</strong> You are add... | 2017/02/16 | [
"https://wordpress.stackexchange.com/questions/256702",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33745/"
] | How can I query only those pages that **DO NOT HAVE** child pages?
E.g.:
* Parent page 1
+ Child page 1
+ Child page 2
* Parent page 2
* Parent page 3
+ Child page 1
+ Child page 2
* Parent page 4
I would like to show
* Parent page 2
* Parent page 4
```
$newQuery = new WP_Query( array (
'posts_pe... | There can be multiple reasons why it may not be working.
**Possibility-1:** You are adding the CSS file in a child theme. In that case, use the following CODE instead:
```
function theme_styles_and_scripts() {
wp_enqueue_style( 'bootstrap', get_stylesheet_directory_uri() . '/css/bootstrap.min.css', array(... |
256,705 | <p>I am new for wordpress and i am using Ubuntu OS on my computer I want to run a downloded theme on localhost how can i do that?</p>
| [
{
"answer_id": 256672,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 2,
"selected": true,
"text": "<p>There can be multiple reasons why it may not be working.</p>\n\n<p><strong>Possibility-1:</strong> You are add... | 2017/02/16 | [
"https://wordpress.stackexchange.com/questions/256705",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113280/"
] | I am new for wordpress and i am using Ubuntu OS on my computer I want to run a downloded theme on localhost how can i do that? | There can be multiple reasons why it may not be working.
**Possibility-1:** You are adding the CSS file in a child theme. In that case, use the following CODE instead:
```
function theme_styles_and_scripts() {
wp_enqueue_style( 'bootstrap', get_stylesheet_directory_uri() . '/css/bootstrap.min.css', array(... |
256,707 | <p>I'm displaying a gallery image but I also want display the caption for image. I can get the info that we insert when us upload a image in WordPress Dashboard like "Title/Caption/ALT/Description". I want get anyone and display.</p>
<pre><code><?php
$gallery = get_post_gallery_images( $post );
foreach... | [
{
"answer_id": 256715,
"author": "Kyon147",
"author_id": 102156,
"author_profile": "https://wordpress.stackexchange.com/users/102156",
"pm_score": 2,
"selected": false,
"text": "<p>The caption for an image is actually meta_data attached to the image and the <a href=\"https://developer.wo... | 2017/02/16 | [
"https://wordpress.stackexchange.com/questions/256707",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/94215/"
] | I'm displaying a gallery image but I also want display the caption for image. I can get the info that we insert when us upload a image in WordPress Dashboard like "Title/Caption/ALT/Description". I want get anyone and display.
```
<?php
$gallery = get_post_gallery_images( $post );
foreach( $gallery as $ima... | You need to get the `metadata` of each image, add this to your `functions.php` file:
```
function get_post_gallery_images_with_info($postvar = NULL) {
if(!isset($postvar)){
global $post;
$postvar = $post;//if the param wasnt sent
}
$post_content = $postvar->post_content;
preg_match('/\... |
256,717 | <p>I'm trying to change the logo url of the site to "mywebsite.com/side2", but it is not working, can anyone tell me where is the error in the code below?</p>
<pre><code>add_filter( 'login_headerurl', 'custom_loginlogo_url' );
function custom_loginlogo_url($url) {
return home_url( 'side2' );
}
</code></pre>
| [
{
"answer_id": 256718,
"author": "Den Isahac",
"author_id": 113233,
"author_profile": "https://wordpress.stackexchange.com/users/113233",
"pm_score": -1,
"selected": false,
"text": "<p>You can use the <strong>get_page_by_path</strong> as follows:</p>\n\n<pre><code>add_filter( 'login_head... | 2017/02/16 | [
"https://wordpress.stackexchange.com/questions/256717",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113413/"
] | I'm trying to change the logo url of the site to "mywebsite.com/side2", but it is not working, can anyone tell me where is the error in the code below?
```
add_filter( 'login_headerurl', 'custom_loginlogo_url' );
function custom_loginlogo_url($url) {
return home_url( 'side2' );
}
``` | The `login_headerurl` filter is for changing the logo url of login page, according to the [Codex](https://codex.wordpress.org/Plugin_API/Filter_Reference/login_headerurl).
To change the logo URL of your homepage, you will have to look into your theme's `header.php` file. You logo and it's link are included there. Dep... |
256,724 | <p>I'm using a child theme based on 'Twenty Seventeen' and have created a custom post type ('review').</p>
<p>I want to make two Pages, one which lists 'reviews' and the other which lists a mixture of 'posts' and 'reviews' (ordered by recency).</p>
<p>For the first of those I've made a copy of Twenty Seventeen's <cod... | [
{
"answer_id": 256718,
"author": "Den Isahac",
"author_id": 113233,
"author_profile": "https://wordpress.stackexchange.com/users/113233",
"pm_score": -1,
"selected": false,
"text": "<p>You can use the <strong>get_page_by_path</strong> as follows:</p>\n\n<pre><code>add_filter( 'login_head... | 2017/02/16 | [
"https://wordpress.stackexchange.com/questions/256724",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57920/"
] | I'm using a child theme based on 'Twenty Seventeen' and have created a custom post type ('review').
I want to make two Pages, one which lists 'reviews' and the other which lists a mixture of 'posts' and 'reviews' (ordered by recency).
For the first of those I've made a copy of Twenty Seventeen's `index.php`, as `page... | The `login_headerurl` filter is for changing the logo url of login page, according to the [Codex](https://codex.wordpress.org/Plugin_API/Filter_Reference/login_headerurl).
To change the logo URL of your homepage, you will have to look into your theme's `header.php` file. You logo and it's link are included there. Dep... |
256,726 | <ol>
<li>I have Zend framework 2 application (PHP), via which I want to use WP-CLI functionality. near Zend project I have WordPress project, which I want to maintain from Zend via WP-CLI. </li>
<li>I see in the docs that WP-CLI also written on PHP. I dreamed that I install WP-CLI via composer in root of my project an... | [
{
"answer_id": 291803,
"author": "swissspidy",
"author_id": 12404,
"author_profile": "https://wordpress.stackexchange.com/users/12404",
"pm_score": 0,
"selected": false,
"text": "<p>The <code>WP_CLI</code> class has a <code>runcommand</code> method that launches a new child process to ru... | 2017/02/16 | [
"https://wordpress.stackexchange.com/questions/256726",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113499/"
] | 1. I have Zend framework 2 application (PHP), via which I want to use WP-CLI functionality. near Zend project I have WordPress project, which I want to maintain from Zend via WP-CLI.
2. I see in the docs that WP-CLI also written on PHP. I dreamed that I install WP-CLI via composer in root of my project and can use its ... | This is probably unwise. WP-CLI is developed as a command line utility and might not maintain internal structure between releases.
Since everything has to run as root in any case, there is no real difference between executing a WP-CLI command via a shell (A.K.A `exec` and its family of functions), or by calling whatev... |
256,733 | <p>Failing miserably at adding a custom column</p>
<pre><code>add_action('manage_edit-pricing_columns', 'manage_pricing_columns');
add_action('manage_pricing_posts_custom_column', 'manage_pricing_custom_columns');
function manage_pricing_columns($_columns) {
$new_columns['cb'] = '<input type="checkbox" />';
... | [
{
"answer_id": 256734,
"author": "codiiv",
"author_id": 91561,
"author_profile": "https://wordpress.stackexchange.com/users/91561",
"pm_score": 2,
"selected": true,
"text": "<pre><code>add_action('manage_edit-pricing_columns', 'manage_pricing_columns');\nadd_action('manage_pricing_posts_... | 2017/02/16 | [
"https://wordpress.stackexchange.com/questions/256733",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/84711/"
] | Failing miserably at adding a custom column
```
add_action('manage_edit-pricing_columns', 'manage_pricing_columns');
add_action('manage_pricing_posts_custom_column', 'manage_pricing_custom_columns');
function manage_pricing_columns($_columns) {
$new_columns['cb'] = '<input type="checkbox" />';
$new_columns['ti... | ```
add_action('manage_edit-pricing_columns', 'manage_pricing_columns');
add_action('manage_pricing_posts_custom_column', 'manage_pricing_custom_columns');
function manage_pricing_columns($_columns) {
$new_columns['cb'] = '<input type="checkbox" />';
$new_columns['title'] = _x('Pricing Item', 'wp');
$new_co... |
256,751 | <p>I have a custom post type <code>event</code> in WordPress, and I need to query upcoming <code>event</code> <code>posts</code> comparing <code>$current_date</code>.</p>
<p>Query conditions are :</p>
<ul>
<li><code>start_date</code> is a valid <code>date</code> always</li>
<li><code>end_date</code> can be a valid <c... | [
{
"answer_id": 256753,
"author": "TrubinE",
"author_id": 111011,
"author_profile": "https://wordpress.stackexchange.com/users/111011",
"pm_score": 0,
"selected": false,
"text": "<pre><code>// $startday, $endday - format YYYY-MM-DD and field format: YYYY-MM-DD \n $args= array... | 2017/02/16 | [
"https://wordpress.stackexchange.com/questions/256751",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/73154/"
] | I have a custom post type `event` in WordPress, and I need to query upcoming `event` `posts` comparing `$current_date`.
Query conditions are :
* `start_date` is a valid `date` always
* `end_date` can be a valid `date` or `null` or `empty` string.
* IF `end_date` is a valid `date` in db record then compare `end_date >... | There is no need to craft a custom SQL query in order to achieve this. Since version 4.1, WordPress's query classes have [supported complex/nested meta queries](https://core.trac.wordpress.org/ticket/29642). So you can craft a query like this:
```
$args['meta_query'] = array(
// Use an OR relationship betw... |
256,754 | <p>I am trying to edit theme editor to edit files on wordpress, but I get the error about, the file is not writable. So now I want to give the account write permissions on the file, but I don't know which user account wordpress runs as on the website when editing files. Does anyone know?</p>
<p>Thanks</p>
| [
{
"answer_id": 256753,
"author": "TrubinE",
"author_id": 111011,
"author_profile": "https://wordpress.stackexchange.com/users/111011",
"pm_score": 0,
"selected": false,
"text": "<pre><code>// $startday, $endday - format YYYY-MM-DD and field format: YYYY-MM-DD \n $args= array... | 2017/02/16 | [
"https://wordpress.stackexchange.com/questions/256754",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113339/"
] | I am trying to edit theme editor to edit files on wordpress, but I get the error about, the file is not writable. So now I want to give the account write permissions on the file, but I don't know which user account wordpress runs as on the website when editing files. Does anyone know?
Thanks | There is no need to craft a custom SQL query in order to achieve this. Since version 4.1, WordPress's query classes have [supported complex/nested meta queries](https://core.trac.wordpress.org/ticket/29642). So you can craft a query like this:
```
$args['meta_query'] = array(
// Use an OR relationship betw... |
256,760 | <p>I have a custom taxonomy, called albums.</p>
<p>I need to be able to text search the taxonomy term title, obviously this isn't default WP Search. Just wondering how I'd best tackle this? </p>
<p>Say there is an album called 'Football Hits',</p>
<p>I start typing foot and search that, all I need it to appear is th... | [
{
"answer_id": 256764,
"author": "nibnut",
"author_id": 111316,
"author_profile": "https://wordpress.stackexchange.com/users/111316",
"pm_score": 2,
"selected": false,
"text": "<p>So you can definitely search posts by taxonomy title - custom or otherwise. The answer will be in the \"<a h... | 2017/02/16 | [
"https://wordpress.stackexchange.com/questions/256760",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113513/"
] | I have a custom taxonomy, called albums.
I need to be able to text search the taxonomy term title, obviously this isn't default WP Search. Just wondering how I'd best tackle this?
Say there is an album called 'Football Hits',
I start typing foot and search that, all I need it to appear is the album title and the pe... | ```
// We get a list taxonomies on the search box
function get_tax_by_search($search_text){
$args = array(
'taxonomy' => array( 'my_tax' ), // taxonomy name
'orderby' => 'id',
'order' => 'ASC',
'hide_empty' => true,
'fields' => 'all',
'name__like' => $search_tex... |
256,777 | <pre><code><?php
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'meta_key' => 'views',
'orderby' => 'meta_value_num',
'order'=> 'DESC', // sort descending
);
// Custom query.
$query = new WP_Query( $args );
// Check that we have query results.
if ( $query... | [
{
"answer_id": 256764,
"author": "nibnut",
"author_id": 111316,
"author_profile": "https://wordpress.stackexchange.com/users/111316",
"pm_score": 2,
"selected": false,
"text": "<p>So you can definitely search posts by taxonomy title - custom or otherwise. The answer will be in the \"<a h... | 2017/02/16 | [
"https://wordpress.stackexchange.com/questions/256777",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113103/"
] | ```
<?php
$args = array(
'post_type' => 'product',
'post_status' => 'publish',
'meta_key' => 'views',
'orderby' => 'meta_value_num',
'order'=> 'DESC', // sort descending
);
// Custom query.
$query = new WP_Query( $args );
// Check that we have query results.
if ( $query->have_posts() ) {
//... | ```
// We get a list taxonomies on the search box
function get_tax_by_search($search_text){
$args = array(
'taxonomy' => array( 'my_tax' ), // taxonomy name
'orderby' => 'id',
'order' => 'ASC',
'hide_empty' => true,
'fields' => 'all',
'name__like' => $search_tex... |
256,804 | <p>I'm using WP API to get posts in my application and I'm trying to exclude some posts from query using <code>filter[post__not_in]</code>.
after removing <code>filter</code> in WP <strong>4.7</strong>, I'm using <code>WP REST API filter parameter</code> plugin to get it back. and it works for all parameters but for <c... | [
{
"answer_id": 256764,
"author": "nibnut",
"author_id": 111316,
"author_profile": "https://wordpress.stackexchange.com/users/111316",
"pm_score": 2,
"selected": false,
"text": "<p>So you can definitely search posts by taxonomy title - custom or otherwise. The answer will be in the \"<a h... | 2017/02/17 | [
"https://wordpress.stackexchange.com/questions/256804",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52831/"
] | I'm using WP API to get posts in my application and I'm trying to exclude some posts from query using `filter[post__not_in]`.
after removing `filter` in WP **4.7**, I'm using `WP REST API filter parameter` plugin to get it back. and it works for all parameters but for `post__not_in` it's not effecting at all, I still g... | ```
// We get a list taxonomies on the search box
function get_tax_by_search($search_text){
$args = array(
'taxonomy' => array( 'my_tax' ), // taxonomy name
'orderby' => 'id',
'order' => 'ASC',
'hide_empty' => true,
'fields' => 'all',
'name__like' => $search_tex... |
256,819 | <p>So I have a css file :<br>
<a href="https://i.stack.imgur.com/eHgBm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eHgBm.png" alt="CSS File" /></a></p>
<p>I also have enqueued it, :
<a href="https://i.stack.imgur.com/dB2fV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dB2fV.p... | [
{
"answer_id": 256820,
"author": "Pedro Coitinho",
"author_id": 111122,
"author_profile": "https://wordpress.stackexchange.com/users/111122",
"pm_score": 2,
"selected": false,
"text": "<p>it looks like your forgot a slash before <code>css/global.css</code>. The others are fine.</p>\n\n<... | 2017/02/17 | [
"https://wordpress.stackexchange.com/questions/256819",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113551/"
] | So I have a css file :
[](https://i.stack.imgur.com/eHgBm.png)
I also have enqueued it, :
[](https://i.stack.imgur.com/dB2fV.png)
When I activate the theme, and try to view my page, no css is on it, Foundation is wo... | In a quick view, the arguments you use in [`wp_enqueue_style()`](https://developer.wordpress.org/reference/functions/wp_enqueue_style/) are not correct for global.css. The third parameter is used to declare the dependencies and you have set that parameter to the string `'false'` but it should be an array. If the CSS do... |
256,830 | <p>I am trying to programmatically add multiple images to media library, I uploaded the images to <code>wp-content/uploads</code>, now I try to use <code>wp_insert_attachement</code>.</p>
<p>Here's the code, however it's not working as expected, I think metadata is not properly generated, I can see the files in media ... | [
{
"answer_id": 256834,
"author": "TrubinE",
"author_id": 111011,
"author_profile": "https://wordpress.stackexchange.com/users/111011",
"pm_score": 6,
"selected": true,
"text": "<pre><code>$image_url = 'adress img';\n\n$upload_dir = wp_upload_dir();\n\n$image_data = file_get_contents( $im... | 2017/02/17 | [
"https://wordpress.stackexchange.com/questions/256830",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113564/"
] | I am trying to programmatically add multiple images to media library, I uploaded the images to `wp-content/uploads`, now I try to use `wp_insert_attachement`.
Here's the code, however it's not working as expected, I think metadata is not properly generated, I can see the files in media library, but without a thumbnail... | ```
$image_url = 'adress img';
$upload_dir = wp_upload_dir();
$image_data = file_get_contents( $image_url );
$filename = basename( $image_url );
if ( wp_mkdir_p( $upload_dir['path'] ) ) {
$file = $upload_dir['path'] . '/' . $filename;
}
else {
$file = $upload_dir['basedir'] . '/' . $filename;
}
file_put_conten... |
256,833 | <p>What is the benefit of using (advantage/disadvantage) </p>
<pre><code>Organize my uploads into month- and year-based folders
</code></pre>
<p>option? Why would I want to organize my folder structure like this ? Is there SEO advantages ?</p>
<p>Thank you</p>
| [
{
"answer_id": 256835,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 2,
"selected": false,
"text": "<p>OMG, is there nothing else in the world except for SEO this days?</p>\n\n<p>Each OS has limitations and/o... | 2017/02/17 | [
"https://wordpress.stackexchange.com/questions/256833",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112778/"
] | What is the benefit of using (advantage/disadvantage)
```
Organize my uploads into month- and year-based folders
```
option? Why would I want to organize my folder structure like this ? Is there SEO advantages ?
Thank you | This is one of the many optional features in WordPress.There is no real benefit in using any of these 2 structures, but here is some details for you:
**Organization:**
When you are building a website which will have a lot of uploads, it is always a good option to go for the year / month structure. You might end up wi... |
256,842 | <p>I added/enqueue a style inside shortcode, it works fine but loaded in footer (before starting the .js files) rather than header. I did the same way like this solution:</p>
<p><a href="https://wordpress.stackexchange.com/questions/165754/enqueue-scripts-styles-when-shortcode-is-present">Enqueue Scripts / Styles when... | [
{
"answer_id": 256845,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 2,
"selected": false,
"text": "<h1>Why it is added in the footer:</h1>\n<p>This is the expected behaviour.</p>\n<p>Since you have enqueued the ... | 2017/02/17 | [
"https://wordpress.stackexchange.com/questions/256842",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113570/"
] | I added/enqueue a style inside shortcode, it works fine but loaded in footer (before starting the .js files) rather than header. I did the same way like this solution:
[Enqueue Scripts / Styles when shortcode is present](https://wordpress.stackexchange.com/questions/165754/enqueue-scripts-styles-when-shortcode-is-pres... | Why it is added in the footer:
==============================
This is the expected behaviour.
Since you have enqueued the style ***within your Shortcode hook function***, by the time it executes, WordPress is already done generating the `<head>` section of your page, since WordPress will only execute your shortcode f... |
256,858 | <p>I'm using the following to show a menu</p>
<pre><code>if ( has_nav_menu( 'topheader' ) ) {
// User has assigned menu to this location;
// output it
wp_nav_menu( array(
'theme_location' => 'topheader',
'menu_class' => 'topMenu', /* bootstrap ul */
'walker' => new My_Wa... | [
{
"answer_id": 256845,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 2,
"selected": false,
"text": "<h1>Why it is added in the footer:</h1>\n<p>This is the expected behaviour.</p>\n<p>Since you have enqueued the ... | 2017/02/17 | [
"https://wordpress.stackexchange.com/questions/256858",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111086/"
] | I'm using the following to show a menu
```
if ( has_nav_menu( 'topheader' ) ) {
// User has assigned menu to this location;
// output it
wp_nav_menu( array(
'theme_location' => 'topheader',
'menu_class' => 'topMenu', /* bootstrap ul */
'walker' => new My_Walker_Nav_Menu(), /* cha... | Why it is added in the footer:
==============================
This is the expected behaviour.
Since you have enqueued the style ***within your Shortcode hook function***, by the time it executes, WordPress is already done generating the `<head>` section of your page, since WordPress will only execute your shortcode f... |
256,859 | <p>I want to query/list all the terms (from all the custom taxonomies) within a custom post type with their custom post count. This is what I have so far...</p>
<pre><code>$the_query = new WP_Query( array(
'post_type' => 'teacher',
'tax_query' => array(
array(
'taxonomy' => 'ALL CU... | [
{
"answer_id": 256865,
"author": "Max Yudin",
"author_id": 11761,
"author_profile": "https://wordpress.stackexchange.com/users/11761",
"pm_score": 0,
"selected": false,
"text": "<p>There is the built-in function to count the posts – <code>wp_count_posts()</code>. You can use it to count ... | 2017/02/17 | [
"https://wordpress.stackexchange.com/questions/256859",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37346/"
] | I want to query/list all the terms (from all the custom taxonomies) within a custom post type with their custom post count. This is what I have so far...
```
$the_query = new WP_Query( array(
'post_type' => 'teacher',
'tax_query' => array(
array(
'taxonomy' => 'ALL CUSTOM TAXONOMIES',
... | If the taxonomies in question are used ONLY in the post\_type in question, then the following simple function will do what you need:
```
function
count_term_use ($post_type)
{
$args = array (
'taxonomy' => get_object_taxonomies ($post_type, 'names'),
) ;
foreach (get_terms ($args) as $term) {
... |
256,864 | <p>I'm trying to eliminate "mixed content" on my website and have done so with every area of the site except for one.</p>
<p>Any image uploaded via the Theme Customizer is not protocol relative nor https, all images uploaded via the customizer come up "http://". </p>
<p>The Customizer uses the Media Gallery uploader ... | [
{
"answer_id": 256865,
"author": "Max Yudin",
"author_id": 11761,
"author_profile": "https://wordpress.stackexchange.com/users/11761",
"pm_score": 0,
"selected": false,
"text": "<p>There is the built-in function to count the posts – <code>wp_count_posts()</code>. You can use it to count ... | 2017/02/17 | [
"https://wordpress.stackexchange.com/questions/256864",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/86752/"
] | I'm trying to eliminate "mixed content" on my website and have done so with every area of the site except for one.
Any image uploaded via the Theme Customizer is not protocol relative nor https, all images uploaded via the customizer come up "http://".
The Customizer uses the Media Gallery uploader but doesn't seem ... | If the taxonomies in question are used ONLY in the post\_type in question, then the following simple function will do what you need:
```
function
count_term_use ($post_type)
{
$args = array (
'taxonomy' => get_object_taxonomies ($post_type, 'names'),
) ;
foreach (get_terms ($args) as $term) {
... |
256,868 | <p>I'm attempting to add my logo to the middle of my navbar, and while looking at the nav walker class I couldn't figure what the best way to do this would be.</p>
<p>So my question is essentially how do I do that. the Walker_Nav_Menu() method start_el() seems to build only one li so where is it iterating over all of ... | [
{
"answer_id": 256882,
"author": "Den Isahac",
"author_id": 113233,
"author_profile": "https://wordpress.stackexchange.com/users/113233",
"pm_score": 0,
"selected": false,
"text": "<p>The best way to achieve the desired functionality, is to add a new menu item for the logo, by going to t... | 2017/02/17 | [
"https://wordpress.stackexchange.com/questions/256868",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/108441/"
] | I'm attempting to add my logo to the middle of my navbar, and while looking at the nav walker class I couldn't figure what the best way to do this would be.
So my question is essentially how do I do that. the Walker\_Nav\_Menu() method start\_el() seems to build only one li so where is it iterating over all of them an... | You need to make your own walker menu (i am guessing you already know that), and the best way i think is overriding the function that `ends` each menu item which is `end_el` :
```
class logo_in_middle_Menu_Walker extends Walker_Nav_Menu {
public $menu_location = 'primary';
function __construct($menu_location... |
256,896 | <ol>
<li>I created a php class on a separate file</li>
<li>I included the file in functions.php</li>
<li>I initialized the class</li>
</ol>
<p>The class among many other things has one functions that does this:</p>
<pre><code>$data = array(
'time' => date('Y-m-d H:i:s'),
'offset' => 0,
);
$format = arr... | [
{
"answer_id": 256903,
"author": "Nathan Johnson",
"author_id": 106269,
"author_profile": "https://wordpress.stackexchange.com/users/106269",
"pm_score": 1,
"selected": false,
"text": "<p>It's hard to say why without seeing more of your code. So if you're interested in knowing why, then ... | 2017/02/17 | [
"https://wordpress.stackexchange.com/questions/256896",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30984/"
] | 1. I created a php class on a separate file
2. I included the file in functions.php
3. I initialized the class
The class among many other things has one functions that does this:
```
$data = array(
'time' => date('Y-m-d H:i:s'),
'offset' => 0,
);
$format = array(
'%s',
'%d'
);
$wpdb->insert('my_cust... | It's hard to say why without seeing more of your code. So if you're interested in knowing why, then I'd encourage you to share more of your code.
If you're only looking for a solution, then something like the following will probably work. (I say probably because I don't know because I don't have your code.) What we wa... |
256,897 | <p>Wondering if you might have some ideas on this problem. I’m googled for days but can’t figure it out. </p>
<p>Here’s where I’m at:</p>
<p>I have a meta box for the Woocommerce post type ‘products’. Inside the meta box there’s a <code>'type' = > 'select'</code> that I want to populate with a list of all of the a... | [
{
"answer_id": 256900,
"author": "Marinus Klasen",
"author_id": 113579,
"author_profile": "https://wordpress.stackexchange.com/users/113579",
"pm_score": 0,
"selected": false,
"text": "<p>This is probably not gonna fix it, but wanted to share: I ran into the same issue today and this was... | 2017/02/17 | [
"https://wordpress.stackexchange.com/questions/256897",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113596/"
] | Wondering if you might have some ideas on this problem. I’m googled for days but can’t figure it out.
Here’s where I’m at:
I have a meta box for the Woocommerce post type ‘products’. Inside the meta box there’s a `'type' = > 'select'` that I want to populate with a list of all of the available `'taxonomy' = > 'produ... | For the life of me I really want to get this working the *right way*. For the life of me I can't figure the integration out.
Previously I had looked at [`wp_dropdown_categories()`](https://codex.wordpress.org/Function_Reference/wp_dropdown_categories) and thought it was a better (and easier) solution. I landed working... |
256,904 | <p>I migrated my wordpress, and the subscribe2 plugin
<a href="https://wordpress.org/plugins/subscribe2/installation/" rel="nofollow noreferrer">https://wordpress.org/plugins/subscribe2/installation/</a></p>
<p>looks different now. Before it has a text box with a placeholder, and then two buttons under saying subscrib... | [
{
"answer_id": 256900,
"author": "Marinus Klasen",
"author_id": 113579,
"author_profile": "https://wordpress.stackexchange.com/users/113579",
"pm_score": 0,
"selected": false,
"text": "<p>This is probably not gonna fix it, but wanted to share: I ran into the same issue today and this was... | 2017/02/17 | [
"https://wordpress.stackexchange.com/questions/256904",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113339/"
] | I migrated my wordpress, and the subscribe2 plugin
<https://wordpress.org/plugins/subscribe2/installation/>
looks different now. Before it has a text box with a placeholder, and then two buttons under saying subscribe and unsubscribe. The old plugin was version 4.16, and now the new version is 10.21. The way the new v... | For the life of me I really want to get this working the *right way*. For the life of me I can't figure the integration out.
Previously I had looked at [`wp_dropdown_categories()`](https://codex.wordpress.org/Function_Reference/wp_dropdown_categories) and thought it was a better (and easier) solution. I landed working... |
256,930 | <p>I created a page template named custpage.php
I also created a separate css file named style2.css to style the custpage which has html and php code.
The page templates loads fine it shows under the page attributes but the css stylesheet doesn't seem to work.</p>
<p>This is what I did in functions.php</p>
<pre><code... | [
{
"answer_id": 256936,
"author": "TrubinE",
"author_id": 111011,
"author_profile": "https://wordpress.stackexchange.com/users/111011",
"pm_score": 0,
"selected": false,
"text": "<p><code>'vega'</code> - must be unique name (example: 'vega-custpage-css')</p>\n\n<pre><code>wp_enqueue_style... | 2017/02/18 | [
"https://wordpress.stackexchange.com/questions/256930",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113620/"
] | I created a page template named custpage.php
I also created a separate css file named style2.css to style the custpage which has html and php code.
The page templates loads fine it shows under the page attributes but the css stylesheet doesn't seem to work.
This is what I did in functions.php
```
function register_cu... | This will work only if your template is in the root folder, if its in a subdirectory you need to supply that too:
```
if ( is_page_template( 'template_folder_name/custpage.php' ) ) {
wp_enqueue_style( 'vega', get_stylesheet_directory_uri() . '/style2.css' );
}
``` |
256,967 | <p>My website has a logo and this logo have 2 states (i.e. online and offline ). Each of them has an image that will be uploaded to the media. What I am trying to achieve is that, when hovering on, the state of the logo changes (this can be done quite easy). However, in order to easily keep track of the logo image, I a... | [
{
"answer_id": 256980,
"author": "EBennett",
"author_id": 91050,
"author_profile": "https://wordpress.stackexchange.com/users/91050",
"pm_score": 4,
"selected": true,
"text": "<p>I am assuming that by online and offline you mean active states of the logo. I think there are several option... | 2017/02/18 | [
"https://wordpress.stackexchange.com/questions/256967",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/109824/"
] | My website has a logo and this logo have 2 states (i.e. online and offline ). Each of them has an image that will be uploaded to the media. What I am trying to achieve is that, when hovering on, the state of the logo changes (this can be done quite easy). However, in order to easily keep track of the logo image, I am t... | I am assuming that by online and offline you mean active states of the logo. I think there are several options for you to use. The first two options can be used within your theme and then are simply changing the image file within the directory.
### Option One (not using WP):
You can utilise a simple use of transparan... |
256,976 | <p>I'm currently setting up a sidebar menu with multiple menus and sections. Each section with the title (the menu name) and a bunch of links underneath (the menu items) - I printed the items, but how do I print the menu name?</p>
<p>Thanks,</p>
<p>Jacob</p>
| [
{
"answer_id": 256979,
"author": "Den Isahac",
"author_id": 113233,
"author_profile": "https://wordpress.stackexchange.com/users/113233",
"pm_score": 5,
"selected": true,
"text": "<p>You can access the menu metadata using the <code>wp_get_nav_menu_object</code> function</p>\n\n<p>BY NAME... | 2017/02/18 | [
"https://wordpress.stackexchange.com/questions/256976",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/94333/"
] | I'm currently setting up a sidebar menu with multiple menus and sections. Each section with the title (the menu name) and a bunch of links underneath (the menu items) - I printed the items, but how do I print the menu name?
Thanks,
Jacob | You can access the menu metadata using the `wp_get_nav_menu_object` function
BY NAME:
```
$menu = wp_get_nav_menu_object("my mainmenu" );
```
BY SLUG:
```
$menu = wp_get_nav_menu_object("my-mainmenu" );
```
The return object as follows:
```
Object (
term_id => 4
name => My Menu Name
slug => my-menu-na... |
257,024 | <p>The following code gives all posts from the network.
What I am trying to achieve :</p>
<ul>
<li>Select which blogs to display (by ID)</li>
<li>Select how many post to display (My code selects how many post <strong>per blog</strong>)</li>
<li><p>Order by date or random</p>
<pre><code>$blogs = get_last_updated();
... | [
{
"answer_id": 267876,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 2,
"selected": true,
"text": "<p>I created a plugin which does something similar (called Multisite Post Display <a href=\"https://wordpr... | 2017/02/19 | [
"https://wordpress.stackexchange.com/questions/257024",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33719/"
] | The following code gives all posts from the network.
What I am trying to achieve :
* Select which blogs to display (by ID)
* Select how many post to display (My code selects how many post **per blog**)
* Order by date or random
```
$blogs = get_last_updated();
foreach ($blogs AS $blog) {
switch_to_blog($... | I created a plugin which does something similar (called Multisite Post Display <https://wordpress.org/plugins/multisite-post-reader/> ) . It displays posts from all multisite sub-sites.
The code in there might be helpful for what you are doing. You are welcome to dig into it and use the code to help with your project.... |
257,046 | <p>I need to set a cookie based on a GET variable so my customers can get a coupon code on our site even if they move around after selecting the coupon link. </p>
<p>I am using the code here: <a href="https://www.gravityhelp.com/forums/topic/using-cookies-to-populate-forms#post-74281" rel="noreferrer">Gravity Help</a>... | [
{
"answer_id": 257051,
"author": "majick",
"author_id": 76440,
"author_profile": "https://wordpress.stackexchange.com/users/76440",
"pm_score": 1,
"selected": false,
"text": "<p>Yes you just need to wrap in an <code>isset</code> check before setting the cookie:</p>\n\n<pre><code>$name = ... | 2017/02/19 | [
"https://wordpress.stackexchange.com/questions/257046",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70863/"
] | I need to set a cookie based on a GET variable so my customers can get a coupon code on our site even if they move around after selecting the coupon link.
I am using the code here: [Gravity Help](https://www.gravityhelp.com/forums/topic/using-cookies-to-populate-forms#post-74281) to populate the coupon field based on... | Just check if the variable is set, using the code from your link:
```
add_action( 'init', 'set_agent_cookie' );
function set_agent_cookie() {
if (isset($_GET['code'])) {
$name = 'agent';
$id = $_GET['code'];
setcookie( $name, $id, time() + 3600, "/", COOKIE_DOMAIN );
}
}
``` |
257,055 | <p>First time I faced this problem & trying to find out solution but it seems to me that it happens very few and that is why no more solution has been found like this & that is why I am here.</p>
<p>WordPress Import Message:</p>
<blockquote>
<p>File is empty. Please upload something more
substantial. This... | [
{
"answer_id": 257066,
"author": "Arsalan Mithani",
"author_id": 111402,
"author_profile": "https://wordpress.stackexchange.com/users/111402",
"pm_score": 3,
"selected": true,
"text": "<p>You need to increase the upload limit in your <code>php.ini</code>.</p>\n<p>To increase the maximum ... | 2017/02/19 | [
"https://wordpress.stackexchange.com/questions/257055",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113702/"
] | First time I faced this problem & trying to find out solution but it seems to me that it happens very few and that is why no more solution has been found like this & that is why I am here.
WordPress Import Message:
>
> File is empty. Please upload something more
> substantial. This error could also be caused by upl... | You need to increase the upload limit in your `php.ini`.
To increase the maximum upload file size, open your php.ini file in the "`xampp/php/php.ini`" directory. search for `upload_max_filesize` and increase the value like :
```
upload_max_filesize = 128M
``` |
257,071 | <p>I need to get the ID posts for which the category(taxonomy "category") is not specified.
Post include other taxonomy.</p>
<p>I get posts from code:</p>
<pre><code>$posts = $wpdb->get_results('SELECT ...', , ARRAY_A);
</code></pre>
<p>My query selects the desired type of recording</p>
<pre><code>SELECT distinc... | [
{
"answer_id": 257072,
"author": "Phoenix Online",
"author_id": 108091,
"author_profile": "https://wordpress.stackexchange.com/users/108091",
"pm_score": 0,
"selected": false,
"text": "<p>The SQL you're after is something similar to this:</p>\n\n<pre><code>SELECT *\nFROM wp_posts AS post... | 2017/02/19 | [
"https://wordpress.stackexchange.com/questions/257071",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111011/"
] | I need to get the ID posts for which the category(taxonomy "category") is not specified.
Post include other taxonomy.
I get posts from code:
```
$posts = $wpdb->get_results('SELECT ...', , ARRAY_A);
```
My query selects the desired type of recording
```
SELECT distinct posts.ID FROM wp_posts AS posts
LEFT JOIN w... | If I understand the question, you're looking for the SQL for the equivalent of
```
$args = array (
'post_type' => 'popular_music',
'post_status' => 'publish',
'tax_query' => array (
array (
'taxonomy' => 'category',
'operator' => 'NOT EXISTS',
),
),
'... |
257,073 | <p>I need to parse widget content based on it's ID.</p>
<p>But a widget works like a function that pulls data based on it's arguments, right? So when I pull the widget data, I can only get it's arguments, not the actual output.</p>
<p>How can I parse the widget content based on it's ID?</p>
<p>Example code:</p>
<pr... | [
{
"answer_id": 257072,
"author": "Phoenix Online",
"author_id": 108091,
"author_profile": "https://wordpress.stackexchange.com/users/108091",
"pm_score": 0,
"selected": false,
"text": "<p>The SQL you're after is something similar to this:</p>\n\n<pre><code>SELECT *\nFROM wp_posts AS post... | 2017/02/19 | [
"https://wordpress.stackexchange.com/questions/257073",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27278/"
] | I need to parse widget content based on it's ID.
But a widget works like a function that pulls data based on it's arguments, right? So when I pull the widget data, I can only get it's arguments, not the actual output.
How can I parse the widget content based on it's ID?
Example code:
```
// Update widget rounds aut... | If I understand the question, you're looking for the SQL for the equivalent of
```
$args = array (
'post_type' => 'popular_music',
'post_status' => 'publish',
'tax_query' => array (
array (
'taxonomy' => 'category',
'operator' => 'NOT EXISTS',
),
),
'... |
257,085 | <p>When viewing the home page of my site (<a href="http://zilredloh.com" rel="nofollow noreferrer">zilredloh.com</a>), sometimes I do not see the latest posts. A new post will have been published, but the main index page doesn't reflect this. Refreshing the browser via F5 will then show the new content.</p>
<p>I know ... | [
{
"answer_id": 257088,
"author": "Matt",
"author_id": 32255,
"author_profile": "https://wordpress.stackexchange.com/users/32255",
"pm_score": 0,
"selected": false,
"text": "<p>To narrow it down, perhaps try disabling cache in your browser. In Chrome - [Developer tools] > [Network] and ti... | 2017/02/19 | [
"https://wordpress.stackexchange.com/questions/257085",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112846/"
] | When viewing the home page of my site ([zilredloh.com](http://zilredloh.com)), sometimes I do not see the latest posts. A new post will have been published, but the main index page doesn't reflect this. Refreshing the browser via F5 will then show the new content.
I know that browsers will sometimes cache content, but... | You may need to set nocache headers in your main template header. Include this near the top of the header.php after the opening tag: `nocache_headers()`
From here: [Function Reference/nocache headers](https://codex.wordpress.org/Function_Reference/nocache_headers)
Run some tests, I believe this should only affect the... |
257,105 | <p>I have a child theme where I'm using the old @import to import in the CSS and I know this is no longer best practice. I've seen on the Wordpress codex how to do this properly, which seems straightforward enough, but I need to find the $handle used in the parent theme when it registers its stylesheet.</p>
<p>This i... | [
{
"answer_id": 257113,
"author": "David Lee",
"author_id": 111965,
"author_profile": "https://wordpress.stackexchange.com/users/111965",
"pm_score": 0,
"selected": false,
"text": "<p>That is not possible using a theme, you need to do it manually, or you will have to find a <code>plugin</... | 2017/02/20 | [
"https://wordpress.stackexchange.com/questions/257105",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/106972/"
] | I have a child theme where I'm using the old @import to import in the CSS and I know this is no longer best practice. I've seen on the Wordpress codex how to do this properly, which seems straightforward enough, but I need to find the $handle used in the parent theme when it registers its stylesheet.
This is the code ... | To clarify this, for anyone using Divi theme (but generally any WP theme), a simple inspection using Dev tools on the "head" for the stylesheet links usually gives a clue about the handle, as Den Isahac mentioned previously (it wasn't clear as he mentioned it can't be found).
**Anything before the "-css" on the ID of ... |
257,108 | <p>I want to remove the WordPress version from my Source Code. To achieve this, I have placed the following code in my functions.php file:</p>
<pre><code>function wordpress_remove_version() {
return '';
}
add_filter('the_generator', 'wordpress_remove_version');
</code></pre>
<p>This code has worked for me in the... | [
{
"answer_id": 257109,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 2,
"selected": false,
"text": "<p>Your code works for me in version 4.7.2 with 2016 theme, but a slightly simpler version is to remove the action en... | 2017/02/20 | [
"https://wordpress.stackexchange.com/questions/257108",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112472/"
] | I want to remove the WordPress version from my Source Code. To achieve this, I have placed the following code in my functions.php file:
```
function wordpress_remove_version() {
return '';
}
add_filter('the_generator', 'wordpress_remove_version');
```
This code has worked for me in the past but for some reason, ... | I have figured out the problem!
For anyone reading this, my code does work perfectly fine. The issue lied within my functions.php file.
Rather than have the following in my file:
```
function theme_name_script_enqueue() {
wp_enqueue_style( 'wpb-fa', get_template_directory_uri() . '/fonts/css/font-awesome.min.css', ... |
257,111 | <p>In response to the <a href="https://wordpress.stackexchange.com/questions/257085/help-pinpointing-source-of-caching-issue">question asked here</a> I find myself and this other user needing a solution to set a last modified header that contains the date and time of the most reicent post. Since we both in many themes ... | [
{
"answer_id": 257431,
"author": "Phoenix Online",
"author_id": 108091,
"author_profile": "https://wordpress.stackexchange.com/users/108091",
"pm_score": 0,
"selected": false,
"text": "<p>Untested, but it <em>should</em> work:</p>\n\n<pre><code>$query = \"SELECT MAX(post_modified) AS mod... | 2017/02/20 | [
"https://wordpress.stackexchange.com/questions/257111",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70863/"
] | In response to the [question asked here](https://wordpress.stackexchange.com/questions/257085/help-pinpointing-source-of-caching-issue) I find myself and this other user needing a solution to set a last modified header that contains the date and time of the most reicent post. Since we both in many themes have the home ... | Last-Modified header for visitors on the front-page
---------------------------------------------------
It's useful to see how the *Last-Modified* header is added to the feeds, in the [`wp::send_header()`](https://github.com/WordPress/WordPress/blob/55df308b4d4ea733a3738d8c210ffb0ab0d7d7bf/wp-includes/class-wp.php#L39... |
257,114 | <p>I'm trying to get a thumbnail for my post. Like if the first custom meta box doesn't have any <code>value/content</code>, should use <code>}else if ($img =get_post_custom_values('backdrop_img')) { $imgsrc = $img[0]; }</code> (which is the 2nd metabox) then 3rd, <code>else if</code> it also doesn't have any <code>co... | [
{
"answer_id": 257116,
"author": "David Lee",
"author_id": 111965,
"author_profile": "https://wordpress.stackexchange.com/users/111965",
"pm_score": 1,
"selected": false,
"text": "<p>I think you are missing the <code>$post ID</code>:</p>\n\n<pre><code> <?php\n //lets put the def... | 2017/02/20 | [
"https://wordpress.stackexchange.com/questions/257114",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110405/"
] | I'm trying to get a thumbnail for my post. Like if the first custom meta box doesn't have any `value/content`, should use `}else if ($img =get_post_custom_values('backdrop_img')) { $imgsrc = $img[0]; }` (which is the 2nd metabox) then 3rd, `else if` it also doesn't have any `content/value` just use an image from my the... | Thanks everyone for all the help! I really appreciate it. I was able to make it work by removing `[0]` in `$imgsrc = $img[0];` and using `custom_get_meta()`
like:
`$img = post_movie_get_meta('featured_img')`
and:
`$img = post_movie_get_meta('backdrop_img')` |
257,135 | <p>I am using the loop in my custom page template as you can see in my code. Only 2 posts must be shown and for the rest I should be able to have pagination.</p>
<pre><code><?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts(
array (
'posts_per_page' => ... | [
{
"answer_id": 257116,
"author": "David Lee",
"author_id": 111965,
"author_profile": "https://wordpress.stackexchange.com/users/111965",
"pm_score": 1,
"selected": false,
"text": "<p>I think you are missing the <code>$post ID</code>:</p>\n\n<pre><code> <?php\n //lets put the def... | 2017/02/20 | [
"https://wordpress.stackexchange.com/questions/257135",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/99178/"
] | I am using the loop in my custom page template as you can see in my code. Only 2 posts must be shown and for the rest I should be able to have pagination.
```
<?php
$paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
query_posts(
array (
'posts_per_page' => 2,
'post... | Thanks everyone for all the help! I really appreciate it. I was able to make it work by removing `[0]` in `$imgsrc = $img[0];` and using `custom_get_meta()`
like:
`$img = post_movie_get_meta('featured_img')`
and:
`$img = post_movie_get_meta('backdrop_img')` |
257,153 | <p>I'm at a loss.. </p>
<p>I wanna check the current users post count. If the post count is 1, the user should be redirected. I have tested the following code:</p>
<pre><code>add_action( 'template_redirect', 'redirect_to_specific_page' );
function redirect_to_specific_page() {
$current_user = wp_get_current_user();
... | [
{
"answer_id": 257116,
"author": "David Lee",
"author_id": 111965,
"author_profile": "https://wordpress.stackexchange.com/users/111965",
"pm_score": 1,
"selected": false,
"text": "<p>I think you are missing the <code>$post ID</code>:</p>\n\n<pre><code> <?php\n //lets put the def... | 2017/02/20 | [
"https://wordpress.stackexchange.com/questions/257153",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112830/"
] | I'm at a loss..
I wanna check the current users post count. If the post count is 1, the user should be redirected. I have tested the following code:
```
add_action( 'template_redirect', 'redirect_to_specific_page' );
function redirect_to_specific_page() {
$current_user = wp_get_current_user();
if (empty($the_us... | Thanks everyone for all the help! I really appreciate it. I was able to make it work by removing `[0]` in `$imgsrc = $img[0];` and using `custom_get_meta()`
like:
`$img = post_movie_get_meta('featured_img')`
and:
`$img = post_movie_get_meta('backdrop_img')` |
257,189 | <p>So right now the site automatically creates pages when a post is updated. I want this page to include an audio playlist. So what I do, is simply add the shortcode: <code>[playlist]</code>.
Then, when the audio files are attached to the page, the playlist automatically generates.</p>
<p>I can confirm that this metho... | [
{
"answer_id": 276771,
"author": "Shahzaib Khan",
"author_id": 125791,
"author_profile": "https://wordpress.stackexchange.com/users/125791",
"pm_score": 0,
"selected": false,
"text": "<p>There are multiple ways you can do this:</p>\n\n<ul>\n<li>Manual</li>\n<li>Using plugin</li>\n</ul>\n... | 2017/02/20 | [
"https://wordpress.stackexchange.com/questions/257189",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113483/"
] | So right now the site automatically creates pages when a post is updated. I want this page to include an audio playlist. So what I do, is simply add the shortcode: `[playlist]`.
Then, when the audio files are attached to the page, the playlist automatically generates.
I can confirm that this method works with specifie... | Why images don't get imported
=============================
It's the export step that causes the issue here with image attachments. WordPress’ export function doesn’t include the “attachment” post type unless you select the “All content” export option. But if you only want to import and export your posts from one site... |
257,227 | <p>I created a custom post type for WP, that should just be visitable for user that have a custom capability <code>read_cpt</code>. Within templates and <code>pre_get_posts</code> I can run checks to include or exclude the CPT by using <code>current_user_can()</code>.</p>
<p>I don't want the CPT, not even the endpoint... | [
{
"answer_id": 257250,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 2,
"selected": false,
"text": "<p>The REST API has no parameters, options to solve this - in my opinion. But you should register only if the users ... | 2017/02/20 | [
"https://wordpress.stackexchange.com/questions/257227",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45303/"
] | I created a custom post type for WP, that should just be visitable for user that have a custom capability `read_cpt`. Within templates and `pre_get_posts` I can run checks to include or exclude the CPT by using `current_user_can()`.
I don't want the CPT, not even the endpoint, to show up within the REST API, to keep i... | The REST API has no parameters, options to solve this - in my opinion. But you should register only if the users have the capability in his role, like the follow example.
```
add_action( 'rest_api_init', function() {
// Exit, if the logged in user have not enough rights.
if ( ! current_user_can( 'edit_posts' ... |
257,235 | <p>After running my Wordpress site through Page Speed Insights I'm told that I need to eliminate render blocking javascript.
So I have moved the vast majority of javascript to just before the closing body tag but the warning still appears in Page Speed Insights.</p>
<p>Can anyone suggest what I can do to resolve this... | [
{
"answer_id": 257238,
"author": "David Lee",
"author_id": 111965,
"author_profile": "https://wordpress.stackexchange.com/users/111965",
"pm_score": 2,
"selected": false,
"text": "<p>You can install a plugin to load your JavaScript asynchronously or try to do it manually adding code to y... | 2017/02/20 | [
"https://wordpress.stackexchange.com/questions/257235",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/46039/"
] | After running my Wordpress site through Page Speed Insights I'm told that I need to eliminate render blocking javascript.
So I have moved the vast majority of javascript to just before the closing body tag but the warning still appears in Page Speed Insights.
Can anyone suggest what I can do to resolve this issue ple... | You can install a plugin to load your JavaScript asynchronously or try to do it manually adding code to your `functions.php` to load your scripts asynchronously.
This can get you started,
>
> Warning
>
>
>
loading JavaScript asynchronously will cause several issues with dependencies:
```
/*function to add asyn... |
257,240 | <p>I'm loading a list of products on an archive type page and creating a custom query to do so. I want to create a 'load more' functionality so that clicking the 'load more' button at the bottom of list loads the next 10 products.</p>
<p>I thought it would be as easy as using a variable to set 'posts_per_page' and sim... | [
{
"answer_id": 257238,
"author": "David Lee",
"author_id": 111965,
"author_profile": "https://wordpress.stackexchange.com/users/111965",
"pm_score": 2,
"selected": false,
"text": "<p>You can install a plugin to load your JavaScript asynchronously or try to do it manually adding code to y... | 2017/02/20 | [
"https://wordpress.stackexchange.com/questions/257240",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113232/"
] | I'm loading a list of products on an archive type page and creating a custom query to do so. I want to create a 'load more' functionality so that clicking the 'load more' button at the bottom of list loads the next 10 products.
I thought it would be as easy as using a variable to set 'posts\_per\_page' and simply incr... | You can install a plugin to load your JavaScript asynchronously or try to do it manually adding code to your `functions.php` to load your scripts asynchronously.
This can get you started,
>
> Warning
>
>
>
loading JavaScript asynchronously will cause several issues with dependencies:
```
/*function to add asyn... |
257,253 | <p>I have problem in Wordpress after migrating my website.
In title tag (<code><title></code>) I have
<code>"&#8211;"</code>
instead of
<code>"-"</code></p>
<p>For the browser it's good, in the title it shows good.
But in html code is <code>"&#8211;"</code>....</p>
<p>Please help me <3</p>
| [
{
"answer_id": 257264,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 1,
"selected": false,
"text": "<h1>Background:</h1>\n<p>WordPress converts normal dash (-) to long dash (<code>–</code>), straight quotes to cu... | 2017/02/20 | [
"https://wordpress.stackexchange.com/questions/257253",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113800/"
] | I have problem in Wordpress after migrating my website.
In title tag (`<title>`) I have
`"–"`
instead of
`"-"`
For the browser it's good, in the title it shows good.
But in html code is `"–"`....
Please help me <3 | Background:
===========
WordPress converts normal dash (-) to long dash (`–`), straight quotes to curly quotes and some other similar symbols and punctuations to their printer friendly versions using `wptexturize`.
Generally it's recommended to leave them up to WordPress. However, occasionally, we may want to overrid... |
257,254 | <p>I want to include inline SVGs in a metabox textarea. </p>
<p>That's easy. What's killing me is how do I sanitize the textarea before saving the postmeta, and how do I escape it? </p>
<p>Halp? </p>
<p>Thanks!</p>
| [
{
"answer_id": 340313,
"author": "Marc",
"author_id": 71657,
"author_profile": "https://wordpress.stackexchange.com/users/71657",
"pm_score": 2,
"selected": false,
"text": "<p>Here is a PHP library that was created for sanitizing SVG files that may be worth looking into. <a href=\"https:... | 2017/02/20 | [
"https://wordpress.stackexchange.com/questions/257254",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93720/"
] | I want to include inline SVGs in a metabox textarea.
That's easy. What's killing me is how do I sanitize the textarea before saving the postmeta, and how do I escape it?
Halp?
Thanks! | Here is a PHP library that was created for sanitizing SVG files that may be worth looking into. <https://github.com/darylldoyle/svg-sanitizer>
Here is an example of how this could be used:
```
// Now do what you want with your clean SVG/XML data
function your_save_meta( $post_id, $post, $update ) {
// - Update ... |
257,281 | <p>I am working on a WordPress child theme where I do not have access to any markup other than the header.php. (I have access to child functions.php and the style.css)</p>
<p>The site has a body and a div#wrapper, but I would really like there to be 1 or 2 divs between those because I don't want to use body to create ... | [
{
"answer_id": 260356,
"author": "scott",
"author_id": 93587,
"author_profile": "https://wordpress.stackexchange.com/users/93587",
"pm_score": 3,
"selected": false,
"text": "<p>You say, </p>\n\n<blockquote>\n <p>I do not have access to anything other than the style-sheet and a header.ph... | 2017/02/21 | [
"https://wordpress.stackexchange.com/questions/257281",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/27168/"
] | I am working on a WordPress child theme where I do not have access to any markup other than the header.php. (I have access to child functions.php and the style.css)
The site has a body and a div#wrapper, but I would really like there to be 1 or 2 divs between those because I don't want to use body to create a column a... | >
> Can I use a similar technique to 'wrap' my everything in the body with another div?
>
>
>
Absolutely. Almost everything is possible. But you're going to have to do something a little hackish.
The `the_content` filter doesn't actually filter the content of the entire page. That particular filter is used throug... |
257,284 | <p>I'm displaying three posts (custom post types) with a foreach loop, each displaying an audio player and some metadata. The audio is played via JW Player, which I am calling using their api. There is a function in the JW Player code that allows you to stop any other players from playing if you press one player.</p>
... | [
{
"answer_id": 260356,
"author": "scott",
"author_id": 93587,
"author_profile": "https://wordpress.stackexchange.com/users/93587",
"pm_score": 3,
"selected": false,
"text": "<p>You say, </p>\n\n<blockquote>\n <p>I do not have access to anything other than the style-sheet and a header.ph... | 2017/02/21 | [
"https://wordpress.stackexchange.com/questions/257284",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/109951/"
] | I'm displaying three posts (custom post types) with a foreach loop, each displaying an audio player and some metadata. The audio is played via JW Player, which I am calling using their api. There is a function in the JW Player code that allows you to stop any other players from playing if you press one player.
Here's ... | >
> Can I use a similar technique to 'wrap' my everything in the body with another div?
>
>
>
Absolutely. Almost everything is possible. But you're going to have to do something a little hackish.
The `the_content` filter doesn't actually filter the content of the entire page. That particular filter is used throug... |
257,286 | <p>I just need to get real password (before encrypt) when user is registering. I need to save that password in another table. How I access the real password before encrypt? </p>
<p>The reason for it is, I am doing a research about passwords. </p>
| [
{
"answer_id": 260356,
"author": "scott",
"author_id": 93587,
"author_profile": "https://wordpress.stackexchange.com/users/93587",
"pm_score": 3,
"selected": false,
"text": "<p>You say, </p>\n\n<blockquote>\n <p>I do not have access to anything other than the style-sheet and a header.ph... | 2017/02/21 | [
"https://wordpress.stackexchange.com/questions/257286",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113820/"
] | I just need to get real password (before encrypt) when user is registering. I need to save that password in another table. How I access the real password before encrypt?
The reason for it is, I am doing a research about passwords. | >
> Can I use a similar technique to 'wrap' my everything in the body with another div?
>
>
>
Absolutely. Almost everything is possible. But you're going to have to do something a little hackish.
The `the_content` filter doesn't actually filter the content of the entire page. That particular filter is used throug... |
257,301 | <p>I want to use jquery in my admin side programming but it seems there's no jquery loaded in the page at all and it load only at main website! Has my wordpress any problem which can't load jquery or I should do something extra to do it. However I put this code in function.php, but it not works:</p>
<pre><code>if(is_a... | [
{
"answer_id": 257302,
"author": "David Lee",
"author_id": 111965,
"author_profile": "https://wordpress.stackexchange.com/users/111965",
"pm_score": 2,
"selected": false,
"text": "<p>If you want to load Jquery, wordpress already provides a handler for it (its also the one in <code>/wp-in... | 2017/02/21 | [
"https://wordpress.stackexchange.com/questions/257301",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112741/"
] | I want to use jquery in my admin side programming but it seems there's no jquery loaded in the page at all and it load only at main website! Has my wordpress any problem which can't load jquery or I should do something extra to do it. However I put this code in function.php, but it not works:
```
if(is_admin()){ ... | If you want to load Jquery, wordpress already provides a handler for it (its also the one in `/wp-includes/js/jquery/jquery.js`):
```
function load_admin_script(){
wp_enqueue_script('jquery');
}
add_action('admin_enqueue_scripts','load_admin_script');
```
note that the jQuery in WordPress run... |
257,317 | <p>I run WordPress version 4.7.2. and it uses jQuery version 1.12. I need to update this version to a higher one. I replaced it with a new version before, but when I upgrade WordPress core it is replaced with 1.12 again.
How can I change the version of jQuery that WordPress uses permanently?</p>
| [
{
"answer_id": 257363,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 7,
"selected": true,
"text": "<blockquote>\n <p><strong><em>Warning:</em></strong> You shouldn't replace core jQuery version, <strong>especial... | 2017/02/21 | [
"https://wordpress.stackexchange.com/questions/257317",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112741/"
] | I run WordPress version 4.7.2. and it uses jQuery version 1.12. I need to update this version to a higher one. I replaced it with a new version before, but when I upgrade WordPress core it is replaced with 1.12 again.
How can I change the version of jQuery that WordPress uses permanently? | >
> ***Warning:*** You shouldn't replace core jQuery version, **especially in the admin panel**. Since many WordPress core functionality may depend on the version. Also, other plugin may depend on the `jQuery` version added in the core.
>
>
>
If you are sure that you want to change the core `jQuery` version, in th... |
257,324 | <p>I'm using the following code to determine if a checkbox has been ticked and then display some text if it has/hasn't as a test.</p>
<p>When its checked, it works fine and the text displays. </p>
<p>When its unchecked I get the message below on the two lines I have commented in my code below.</p>
<blockquote>
<p>... | [
{
"answer_id": 257363,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 7,
"selected": true,
"text": "<blockquote>\n <p><strong><em>Warning:</em></strong> You shouldn't replace core jQuery version, <strong>especial... | 2017/02/21 | [
"https://wordpress.stackexchange.com/questions/257324",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113840/"
] | I'm using the following code to determine if a checkbox has been ticked and then display some text if it has/hasn't as a test.
When its checked, it works fine and the text displays.
When its unchecked I get the message below on the two lines I have commented in my code below.
>
> Illegal string offset 'chec\_check... | >
> ***Warning:*** You shouldn't replace core jQuery version, **especially in the admin panel**. Since many WordPress core functionality may depend on the version. Also, other plugin may depend on the `jQuery` version added in the core.
>
>
>
If you are sure that you want to change the core `jQuery` version, in th... |
257,325 | <p>Since plugin updates might bring some unexpected issues to the compatibilies. </p>
<p>Is it recommended to modify plugin version value
to fool the wordpress plugin update system if priority is to turn off plugin out-of-date warnings from wordpress backend ?</p>
| [
{
"answer_id": 257363,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 7,
"selected": true,
"text": "<blockquote>\n <p><strong><em>Warning:</em></strong> You shouldn't replace core jQuery version, <strong>especial... | 2017/02/21 | [
"https://wordpress.stackexchange.com/questions/257325",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63121/"
] | Since plugin updates might bring some unexpected issues to the compatibilies.
Is it recommended to modify plugin version value
to fool the wordpress plugin update system if priority is to turn off plugin out-of-date warnings from wordpress backend ? | >
> ***Warning:*** You shouldn't replace core jQuery version, **especially in the admin panel**. Since many WordPress core functionality may depend on the version. Also, other plugin may depend on the `jQuery` version added in the core.
>
>
>
If you are sure that you want to change the core `jQuery` version, in th... |
257,337 | <p>My local WordPress installation on XAMPP seems to have a wrong time setting. When I do</p>
<pre><code>date( 'Y-m-d H:i:s' );
</code></pre>
<p>I get <strong>2017-02-21 10:46:43</strong> as result. However my PCs time really is <strong>2017-02-21 11:46:43</strong>, so my WordPress is one hour behind.</p>
<p>Now I a... | [
{
"answer_id": 257338,
"author": "fischi",
"author_id": 15680,
"author_profile": "https://wordpress.stackexchange.com/users/15680",
"pm_score": 3,
"selected": false,
"text": "<p><code>date()</code> is a <code>PHP</code> function depending on your server settings. You can go around that b... | 2017/02/21 | [
"https://wordpress.stackexchange.com/questions/257337",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105498/"
] | My local WordPress installation on XAMPP seems to have a wrong time setting. When I do
```
date( 'Y-m-d H:i:s' );
```
I get **2017-02-21 10:46:43** as result. However my PCs time really is **2017-02-21 11:46:43**, so my WordPress is one hour behind.
Now I already did, what was recommended [here](https://stackoverfl... | `date()` is a `PHP` function depending on your server settings. You can go around that by using the WordPress function:
```
current_time( 'Y-m-d H:i:s' );
```
This function takes the settings in `wp-admin` into account. |
257,355 | <p>How to use live images on a local WP install? I want to do something like the code down here in the <code>wp-config.php</code>. Problem is that the <code>siteurl</code> must be a relative path and cant be a url. I want to set up a local environment to test some parts offline and need to show the images.</p>
<pre><c... | [
{
"answer_id": 257359,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 1,
"selected": true,
"text": "<p>Try to filter the output URLs temporarily to replace them with online images, using the following code:</p>\... | 2017/02/21 | [
"https://wordpress.stackexchange.com/questions/257355",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54693/"
] | How to use live images on a local WP install? I want to do something like the code down here in the `wp-config.php`. Problem is that the `siteurl` must be a relative path and cant be a url. I want to set up a local environment to test some parts offline and need to show the images.
```
if ($_SERVER['SERVER_ADMIN'] == ... | Try to filter the output URLs temporarily to replace them with online images, using the following code:
```
add_filter( 'wp_get_attachment_image_src', function ( $image, $attachment_id, $size ) {
// For thumbnails
if ( $size ) {
switch ( $size ) {
case 'thumbnail':
case 'medium... |
257,366 | <p>How do I create a complete organisation's database, where I can access tables and perform custom SQL requests.
I can use PHP and mySQL, I am actually working on a WordPress theme.
And I am trying to do something like this:</p>
<pre><code>+----------+ +------------+ +------------+
| Book | | Borrow ... | [
{
"answer_id": 257368,
"author": "David Lee",
"author_id": 111965,
"author_profile": "https://wordpress.stackexchange.com/users/111965",
"pm_score": 3,
"selected": true,
"text": "<p>You can do that accessing the <a href=\"https://www.phpmyadmin.net/\" rel=\"nofollow noreferrer\">phpmyadm... | 2017/02/21 | [
"https://wordpress.stackexchange.com/questions/257366",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/109858/"
] | How do I create a complete organisation's database, where I can access tables and perform custom SQL requests.
I can use PHP and mySQL, I am actually working on a WordPress theme.
And I am trying to do something like this:
```
+----------+ +------------+ +------------+
| Book | | Borrow | | Rea... | You can do that accessing the [phpmyadmin](https://www.phpmyadmin.net/) dashboard of your host, but that is no the right way to do it, i recommend you to research and learn about:
* [Custom Post Types](https://codex.wordpress.org/Post_Types)
* [Custom Taxonomies](https://codex.wordpress.org/Taxonomies) |
257,370 | <p>Here's my code:</p>
<pre><code>add_action('admin_menu', 'test_plugin_setup_menu'); /**/
function test_plugin_setup_menu(){ ... | [
{
"answer_id": 257371,
"author": "Phoenix Online",
"author_id": 108091,
"author_profile": "https://wordpress.stackexchange.com/users/108091",
"pm_score": 0,
"selected": false,
"text": "<p>It looks like you're missing the <code>checked=\"checked\"</code> value from your input...</p>\n\n<p... | 2017/02/21 | [
"https://wordpress.stackexchange.com/questions/257370",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113286/"
] | Here's my code:
```
add_action('admin_menu', 'test_plugin_setup_menu'); /**/
function test_plugin_setup_menu(){ ... | Don't comment out your validation code remember you are using it to validate the data, so its returning nothing right now, so its saving nothing, try this:
```
add_action('admin_bar_menu', 'make_parent_node', 999);
function make_parent_node($wp_admin_bar) {
$args = array(
'id' => 'test1234', // id of the ... |
257,384 | <p>I have created a custom page that I have called mypage.php.</p>
<p>It is in my template folder with al the other pages (index.php, page.php, ...)</p>
<p>I want this page to be opened when i click on the below code.</p>
<pre><code><a href="<?php site_url(); ?>/mypage.php">Go to page</a>
</code></... | [
{
"answer_id": 257385,
"author": "shishir mishra",
"author_id": 111219,
"author_profile": "https://wordpress.stackexchange.com/users/111219",
"pm_score": 1,
"selected": false,
"text": "<p>@Martina Sartor, you can use wordpress custom template process. Add a the below comment to the file ... | 2017/02/21 | [
"https://wordpress.stackexchange.com/questions/257384",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111936/"
] | I have created a custom page that I have called mypage.php.
It is in my template folder with al the other pages (index.php, page.php, ...)
I want this page to be opened when i click on the below code.
```
<a href="<?php site_url(); ?>/mypage.php">Go to page</a>
```
When I click on the link the url in my browser lo... | WordPress doesn't load templates that way.
First: give the template a name:
================================
To load a page template, first you'll have to make sure your template has a name. To do that, you'll have to have the following CODE in your template file (here `mypage.php`):
```
<?php
/**
* Template Name: ... |
257,403 | <p>I have a partial that I call around the website at various points. This partial simply displays the latest Post.</p>
<p>It looks like so:</p>
<pre><code><?php
$args = array(
'posts_per_page' => 1,
'order' => 'desc'
);
query_posts($args);
if ( have_posts() ) :
while ( have_post... | [
{
"answer_id": 257404,
"author": "David Lee",
"author_id": 111965,
"author_profile": "https://wordpress.stackexchange.com/users/111965",
"pm_score": 1,
"selected": false,
"text": "<p><strike>If you want your query to ignore if a post is sticky and dont have it at the top of your ordered ... | 2017/02/21 | [
"https://wordpress.stackexchange.com/questions/257403",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/56935/"
] | I have a partial that I call around the website at various points. This partial simply displays the latest Post.
It looks like so:
```
<?php
$args = array(
'posts_per_page' => 1,
'order' => 'desc'
);
query_posts($args);
if ( have_posts() ) :
while ( have_posts() ) : the_post();
if ... | Here's a way to force the exact `posts_per_page` value in `WP_Query`, regardless of sticky posts or custom post injects:
```
$args = [
'posts_per_page' => 1,
'_exact_posts_per_page' => true // <-- our custom input argument
];
```
by using our custom `_exact_posts_per_page` input argument.
I'm sure ... |
257,405 | <p>I am new to WordPress Plugins development, and I just started working with the widget. My question is: What are the limitations of WordPress Widget?</p>
<p>I tried to use jQuery to make the Widget Form more interactive/dynamic, but it doesn't seem to work at all. For example, I have a button that when clicked will ... | [
{
"answer_id": 257415,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 1,
"selected": false,
"text": "<p>Widget forms are tricky for JS manipulation. In general you should never use IDs to detect elements in th... | 2017/02/21 | [
"https://wordpress.stackexchange.com/questions/257405",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113869/"
] | I am new to WordPress Plugins development, and I just started working with the widget. My question is: What are the limitations of WordPress Widget?
I tried to use jQuery to make the Widget Form more interactive/dynamic, but it doesn't seem to work at all. For example, I have a button that when clicked will add a stri... | Thank you **Dave Romsey** and **Mark Kaplun** for pointing out about not using HTML ID in WordPress Widget. I finally find a solution for my need.
**Solution:**
We need to add a preset variables into all of the 3 functions (widget, form, update). In my codes, they are called "spotlight\_image\_link1, spotlight\_imag... |
257,451 | <p>I have my blogs on <code>wordpress.com</code> (e.g. <code>test.wordpress.com</code>). I want to migrate all those blogs to my self hosted WordPress website. Is this possible?</p>
<p>Is there any plugin in WordPress or do I need to develop any API?</p>
| [
{
"answer_id": 257415,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 1,
"selected": false,
"text": "<p>Widget forms are tricky for JS manipulation. In general you should never use IDs to detect elements in th... | 2017/02/22 | [
"https://wordpress.stackexchange.com/questions/257451",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113898/"
] | I have my blogs on `wordpress.com` (e.g. `test.wordpress.com`). I want to migrate all those blogs to my self hosted WordPress website. Is this possible?
Is there any plugin in WordPress or do I need to develop any API? | Thank you **Dave Romsey** and **Mark Kaplun** for pointing out about not using HTML ID in WordPress Widget. I finally find a solution for my need.
**Solution:**
We need to add a preset variables into all of the 3 functions (widget, form, update). In my codes, they are called "spotlight\_image\_link1, spotlight\_imag... |
257,478 | <p>How to get Custom Post ID by adding code to child theme's function. The following code works fine for the regular post, but can't figure out for the custom post types.</p>
<pre><code>add_filter( 'manage_posts_columns', 'revealid_add_id_column', 5 );
add_action( 'manage_posts_custom_column', 'revealid_id_column_cont... | [
{
"answer_id": 257479,
"author": "Sonali",
"author_id": 84167,
"author_profile": "https://wordpress.stackexchange.com/users/84167",
"pm_score": 1,
"selected": false,
"text": "<pre><code>add_action( 'manage_posts_custom_column', 'id_data' );\nadd_filter( 'manage_posts_columns', 'id_column... | 2017/02/22 | [
"https://wordpress.stackexchange.com/questions/257478",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93692/"
] | How to get Custom Post ID by adding code to child theme's function. The following code works fine for the regular post, but can't figure out for the custom post types.
```
add_filter( 'manage_posts_columns', 'revealid_add_id_column', 5 );
add_action( 'manage_posts_custom_column', 'revealid_id_column_content', 5, 2 );
... | ```
add_action( 'manage_posts_custom_column', 'id_data' );
add_filter( 'manage_posts_columns', 'id_column' );
function id_column( $defaults ) {
$defaults['id'] = 'ID';
return $defaults;
}
function id_data( $column_name ) {
global $post;
switch ( $column_name ) {
case 'id':
echo $post->ID;
... |
257,482 | <p>I am creating a WordPress Plugin for WordPress directory.</p>
<p>How can I get <code>the_content()</code> after applying all the shortcodes that are presents in <code>the_content</code>?</p>
<p>Let me explain:</p>
<p>My plugin will be used in multiple themes and websites; and users will add some shortcodes in the... | [
{
"answer_id": 257479,
"author": "Sonali",
"author_id": 84167,
"author_profile": "https://wordpress.stackexchange.com/users/84167",
"pm_score": 1,
"selected": false,
"text": "<pre><code>add_action( 'manage_posts_custom_column', 'id_data' );\nadd_filter( 'manage_posts_columns', 'id_column... | 2017/02/22 | [
"https://wordpress.stackexchange.com/questions/257482",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113920/"
] | I am creating a WordPress Plugin for WordPress directory.
How can I get `the_content()` after applying all the shortcodes that are presents in `the_content`?
Let me explain:
My plugin will be used in multiple themes and websites; and users will add some shortcodes in their posts or pages. I want my plugin to work af... | ```
add_action( 'manage_posts_custom_column', 'id_data' );
add_filter( 'manage_posts_columns', 'id_column' );
function id_column( $defaults ) {
$defaults['id'] = 'ID';
return $defaults;
}
function id_data( $column_name ) {
global $post;
switch ( $column_name ) {
case 'id':
echo $post->ID;
... |
257,483 | <p>Here is my script : </p>
<pre><code>$my_post = array(
'post_title' => "post test",
'post_date' => current_time('mysql'),
'post_content' => 'This is my post.',
'post_status' => 'publish',
'post_author' => 1,
... | [
{
"answer_id": 257487,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 2,
"selected": false,
"text": "<p>Remove the date param or use the right format for the time stamp, like <code>date('Y-m-d H:i:s'),</code> But it i... | 2017/02/22 | [
"https://wordpress.stackexchange.com/questions/257483",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/113921/"
] | Here is my script :
```
$my_post = array(
'post_title' => "post test",
'post_date' => current_time('mysql'),
'post_content' => 'This is my post.',
'post_status' => 'publish',
'post_author' => 1,
'post_category' => array... | Remove the date param or use the right format for the time stamp, like `date('Y-m-d H:i:s'),` But it is not necessary, WP use the current timestamp on the insert post time. |
257,489 | <p>I've been tasked to move a website into a new domain, and I've encontered this weird issue.<br>
On the homepage, I always see these:</p>
<blockquote>
<p>Notice: Constant AUTOSAVE_INTERVAL already defined in /home/gturnat/public_html/wp-config.php on line 99</p>
<p>Notice: Constant WP_POST_REVISIONS already d... | [
{
"answer_id": 257487,
"author": "bueltge",
"author_id": 170,
"author_profile": "https://wordpress.stackexchange.com/users/170",
"pm_score": 2,
"selected": false,
"text": "<p>Remove the date param or use the right format for the time stamp, like <code>date('Y-m-d H:i:s'),</code> But it i... | 2017/02/22 | [
"https://wordpress.stackexchange.com/questions/257489",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/89236/"
] | I've been tasked to move a website into a new domain, and I've encontered this weird issue.
On the homepage, I always see these:
>
> Notice: Constant AUTOSAVE\_INTERVAL already defined in /home/gturnat/public\_html/wp-config.php on line 99
>
>
> Notice: Constant WP\_POST\_REVISIONS already defined in /home/gturn... | Remove the date param or use the right format for the time stamp, like `date('Y-m-d H:i:s'),` But it is not necessary, WP use the current timestamp on the insert post time. |
257,499 | <p>I'm using a function to filter the_title, adding a string onto the end, but would also like to return the original title, unfiltered on the same page. Is there a way to get the title without it being filtered? </p>
| [
{
"answer_id": 257501,
"author": "engelen",
"author_id": 40403,
"author_profile": "https://wordpress.stackexchange.com/users/40403",
"pm_score": 3,
"selected": true,
"text": "<p>There's a few ways to do this, but I would argue that the preferred way is, in general, fetching the <code>pos... | 2017/02/22 | [
"https://wordpress.stackexchange.com/questions/257499",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/45504/"
] | I'm using a function to filter the\_title, adding a string onto the end, but would also like to return the original title, unfiltered on the same page. Is there a way to get the title without it being filtered? | There's a few ways to do this, but I would argue that the preferred way is, in general, fetching the `post_title` attribute from the post object. This does not depend on removing all filters for a certain function and adding them back later — the latter requires you to directly access the global `$wp_filter`.
[`get_po... |
257,542 | <p>All I did was adding this in my functions.php file:</p>
<pre><code>function save_nb_image()
{
global $wpdb;
$id = $_POST['id'];
$file = wp_get_attachment_url($id);
if ( !is_wp_error($id) )
{
$meta = wp_generate_attachment_metadata($id... | [
{
"answer_id": 257576,
"author": "Purple Haze Design Group",
"author_id": 113974,
"author_profile": "https://wordpress.stackexchange.com/users/113974",
"pm_score": 0,
"selected": false,
"text": "<p>I had a similar issue recently. I had moved over a theme with some plugin specific code in... | 2017/02/22 | [
"https://wordpress.stackexchange.com/questions/257542",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3216/"
] | All I did was adding this in my functions.php file:
```
function save_nb_image()
{
global $wpdb;
$id = $_POST['id'];
$file = wp_get_attachment_url($id);
if ( !is_wp_error($id) )
{
$meta = wp_generate_attachment_metadata($id, $file);
... | Problem is now solved. Thanks to user "blobfolio" [here](https://core.trac.wordpress.org/ticket/39974#comment:2):
>
> It sounds like you may have corrupted the image metadata. Have you
> tried running a plugin like
> <https://wordpress.org/plugins/force-regenerate-thumbnails/> to
> regenerate the images/meta?
>
>... |
257,571 | <p>On my single.php page I am trying to create a function to give me a custom length excerpt of a specific post by ID.</p>
<p>Below are my two functions I am running.</p>
<pre><code>/* Custom get_the_excerpt to allow getting Post excerpt by ID */
function custom_get_the_excerpt($post_id) {
global $post;
$save_pos... | [
{
"answer_id": 257572,
"author": "MaximOrlovsky",
"author_id": 15294,
"author_profile": "https://wordpress.stackexchange.com/users/15294",
"pm_score": 3,
"selected": true,
"text": "<p>Try this one</p>\n\n<pre><code>/* Change Excerpt length */\nfunction excerpt($num, $post_id) { // remove... | 2017/02/22 | [
"https://wordpress.stackexchange.com/questions/257571",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112804/"
] | On my single.php page I am trying to create a function to give me a custom length excerpt of a specific post by ID.
Below are my two functions I am running.
```
/* Custom get_the_excerpt to allow getting Post excerpt by ID */
function custom_get_the_excerpt($post_id) {
global $post;
$save_post = $post;
$post = ... | Try this one
```
/* Change Excerpt length */
function excerpt($num, $post_id) { // removed empty default value
$limit = $num+1;
$excerpt = apply_filters('the_excerpt', get_post_field('post_excerpt', $post_id));
$excerpt = explode(' ', $excerpt, $limit);
array_pop($excerpt);
$excerpt = implode(" ",$... |
257,586 | <p>I've always used @import for the css in my child-theme which i'm now told is bad practice.</p>
<p>What is the best way to set up a child theme going forward? The latest solution on the wordpress codex seems really complex / highly confusing?</p>
<p>There must be a way to do a relatively simple enqueue in my child... | [
{
"answer_id": 257588,
"author": "Den Isahac",
"author_id": 113233,
"author_profile": "https://wordpress.stackexchange.com/users/113233",
"pm_score": 2,
"selected": false,
"text": "<p>I think this is the specific code you're looking for, this can be found in the WordPress Codex <a href=\... | 2017/02/23 | [
"https://wordpress.stackexchange.com/questions/257586",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/106972/"
] | I've always used @import for the css in my child-theme which i'm now told is bad practice.
What is the best way to set up a child theme going forward? The latest solution on the wordpress codex seems really complex / highly confusing?
There must be a way to do a relatively simple enqueue in my child-theme's functions... | The code that is in [codex](https://codex.wordpress.org/Child_Themes#How_to_Create_a_Child_Theme) for queuing the style of the parent theme instead of using `@import`, is not well commented, so i will comment it more, so you have this:
```
<?php
function my_theme_enqueue_styles() {
$parent_style = 'parent-style';
... |
257,592 | <p>im trying to save different value of radio buttons on same name, it works and was able to make checked appear if the correct value is saved. </p>
<p><a href="https://i.stack.imgur.com/zz0H4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zz0H4.png" alt=""></a>
<br>As you can see on the screenshot... | [
{
"answer_id": 257608,
"author": "Jignesh Patel",
"author_id": 111556,
"author_profile": "https://wordpress.stackexchange.com/users/111556",
"pm_score": 1,
"selected": false,
"text": "<p>I think you can Also try it checked=\"checked\" some time issue with checked so just try it.</p>\n\n<... | 2017/02/23 | [
"https://wordpress.stackexchange.com/questions/257592",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110405/"
] | im trying to save different value of radio buttons on same name, it works and was able to make checked appear if the correct value is saved.
[](https://i.stack.imgur.com/zz0H4.png)
As you can see on the screenshot ABOVE (which is taken on view-source:), it the correct selected... | In the WordPress back-end you have to use `checked="checked"` (stricter XHTML), because the CSS will not be applied otherwise:
```
<input type="radio" name="colors" id="blue" checked="checked">
```
this is the CSS that applies the blue dot:
[](http... |
257,634 | <p>I am using the following code to print another image that is in my images folder in casa a post has no thumbnail but it is giving me errors on the else statement saying that there is a syntax error:</p>
<pre><code><?php if ( has_post_thumbnail() ) {
echo '<a href="<?php the_permalink(); ?>"> &... | [
{
"answer_id": 257638,
"author": "Sonali",
"author_id": 84167,
"author_profile": "https://wordpress.stackexchange.com/users/84167",
"pm_score": 2,
"selected": true,
"text": "<p>Try this inside else condition where no image assigned.</p>\n\n<pre><code> if (has_post_thumbnail()) {\n ... | 2017/02/23 | [
"https://wordpress.stackexchange.com/questions/257634",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/99178/"
] | I am using the following code to print another image that is in my images folder in casa a post has no thumbnail but it is giving me errors on the else statement saying that there is a syntax error:
```
<?php if ( has_post_thumbnail() ) {
echo '<a href="<?php the_permalink(); ?>"> <figure><?php the_post_thumbna... | Try this inside else condition where no image assigned.
```
if (has_post_thumbnail()) {
?><a href="<?php the_post_thumbnail_url(); ?>">
<?php the_post_thumbnail();?>
</a><?php
} else {
echo '<figure><a href="add_link_here"><img src="'.get_bloginfo("stylesheet_directory").'/images/stone.jpg" /></fig... |
257,645 | <p>Current structure is <code>/%year%/%monthnum%/%postname%.html</code> </p>
<p>Desired structure is <code>/%postname%/</code></p>
<p>Since we are already positioned with urls like <code>domain.com/2015/04/example-post.html</code>, we want people to be redirected to <code>domain.com/example-post/</code>.</p>
<p>I al... | [
{
"answer_id": 257647,
"author": "Mc Kernel",
"author_id": 107424,
"author_profile": "https://wordpress.stackexchange.com/users/107424",
"pm_score": 0,
"selected": false,
"text": "<p>This tool did the work for me: <a href=\"https://yoast.com/research/permalink-helper.php\" rel=\"nofollow... | 2017/02/23 | [
"https://wordpress.stackexchange.com/questions/257645",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/107424/"
] | Current structure is `/%year%/%monthnum%/%postname%.html`
Desired structure is `/%postname%/`
Since we are already positioned with urls like `domain.com/2015/04/example-post.html`, we want people to be redirected to `domain.com/example-post/`.
I already tried installing some plugins, like **Simple 301 Redirects**, ... | You don't need a plugin to achieve your goal. Use server redirect in the `.htaccess` file because it will not load the processor to interpret the WordPress PHP code and will not consume time. The redirect will be completed before the WordPress runs.
```
RewriteRule ^[0-9]+/[0-9]+/(.*)\.html$ /$1 [R=301,L]
```
Where
... |
257,662 | <p>I am working on a plugin which we need for education website. I have added 3-4 Page templates within my plugin so that we can call when plugin is activated.</p>
<p>Till WordPress <code>4.7</code>, it was working perfectly; but as I upgraded WordPress to the latest (from <code>4.6.3</code>), page templates don't eve... | [
{
"answer_id": 257666,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 0,
"selected": false,
"text": "<p>Your caching insertion code looks very weird and depending on some specific way core calculates hashes fo... | 2017/02/23 | [
"https://wordpress.stackexchange.com/questions/257662",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105597/"
] | I am working on a plugin which we need for education website. I have added 3-4 Page templates within my plugin so that we can call when plugin is activated.
Till WordPress `4.7`, it was working perfectly; but as I upgraded WordPress to the latest (from `4.6.3`), page templates don't even show in page attribute section... | The Problem:
============
As [Mark suggested already](https://wordpress.stackexchange.com/a/257666/110572), your template loading by manipulating cache is far from standard practice. With these sort of cache alteration, even if you modify your CODE to work with WordPress `4.7+`, there is no guarantee that you'll not f... |
257,667 | <p>I've been looking and looking for a solution for my problem but i have been unable to find anything. </p>
<p>I have found a plugin that allow me to restrict certain usernames, I found even a function but there is nothing that allows me to restrict partially matching usernames, there is nothing to prevent users to r... | [
{
"answer_id": 257672,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 3,
"selected": true,
"text": "<p>There's a <a href=\"https://developer.wordpress.org/reference/hooks/validate_username/\" rel=\"nofollow noreferr... | 2017/02/23 | [
"https://wordpress.stackexchange.com/questions/257667",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/80842/"
] | I've been looking and looking for a solution for my problem but i have been unable to find anything.
I have found a plugin that allow me to restrict certain usernames, I found even a function but there is nothing that allows me to restrict partially matching usernames, there is nothing to prevent users to register un... | There's a [`validate_username`](https://developer.wordpress.org/reference/hooks/validate_username/) filter hook that is used by [`validate_user()`](https://developer.wordpress.org/reference/functions/validate_username/) which is in turn used by [`register_new_user()`](https://developer.wordpress.org/reference/functions... |
257,684 | <p>Say you have 4 example domains:
1. dogsrule.com
2. dogsrule.cn
3. dogsrulecatsdrool.co.uk
4. dogsrule.au</p>
<p>Currently, each are their own WordPress sites hosted on the same server. Each are only 2 pages, the homepage which includes a form, and a thank you page.</p>
<p>Since they are such small sites and hoste... | [
{
"answer_id": 257687,
"author": "Pat J",
"author_id": 16121,
"author_profile": "https://wordpress.stackexchange.com/users/16121",
"pm_score": 1,
"selected": false,
"text": "<p>You can use WordPress Multisite version 4.5 or higher to map domains to sites: <a href=\"https://codex.wordpres... | 2017/02/23 | [
"https://wordpress.stackexchange.com/questions/257684",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/5465/"
] | Say you have 4 example domains:
1. dogsrule.com
2. dogsrule.cn
3. dogsrulecatsdrool.co.uk
4. dogsrule.au
Currently, each are their own WordPress sites hosted on the same server. Each are only 2 pages, the homepage which includes a form, and a thank you page.
Since they are such small sites and hosted on the same ser... | Why not multisite:
==================
* Multisite installations are difficult to maintain compared to single site installations.
* Many useful plugins don't work properly on multisite installations.
* There may be SEO concern for such short web sites with basically just one page (thank you page doesn't count) that loo... |
257,691 | <p>I have a situation where I have to remove a term from a taxonomy. However, there are items that are linked to that taxonomy. Sometimes, these removals are temporary (ie, we stop shipping to a country, but would like items to stay linked to those countries if ever we start shipping to that country again). </p>
<p>Is... | [
{
"answer_id": 257727,
"author": "Max Yudin",
"author_id": 11761,
"author_profile": "https://wordpress.stackexchange.com/users/11761",
"pm_score": 2,
"selected": false,
"text": "<p>You can temporarily exclude your terms from the queries. Meaning that you hide them on some listing pages, ... | 2017/02/23 | [
"https://wordpress.stackexchange.com/questions/257691",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114041/"
] | I have a situation where I have to remove a term from a taxonomy. However, there are items that are linked to that taxonomy. Sometimes, these removals are temporary (ie, we stop shipping to a country, but would like items to stay linked to those countries if ever we start shipping to that country again).
Is there any... | Not directly, but I have a need for this functionality as well, as part of a plugin I'm writing for a client and have what I think is a pretty good start on an implementation.
The approach I'm taking is to store a term meta when the term is disabled and then to hook into the `get_terms_defaults` filter to strip disabl... |
257,696 | <p>I'm trying to edit the revelar theme for my site, I've set up my child theme, created a style.css file and successfully imported all the features from the parent theme, but no matter what I try I can't seem to make any changes to my design. I've tried everything and the code I use in my child theme's style.css file ... | [
{
"answer_id": 257727,
"author": "Max Yudin",
"author_id": 11761,
"author_profile": "https://wordpress.stackexchange.com/users/11761",
"pm_score": 2,
"selected": false,
"text": "<p>You can temporarily exclude your terms from the queries. Meaning that you hide them on some listing pages, ... | 2017/02/23 | [
"https://wordpress.stackexchange.com/questions/257696",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114045/"
] | I'm trying to edit the revelar theme for my site, I've set up my child theme, created a style.css file and successfully imported all the features from the parent theme, but no matter what I try I can't seem to make any changes to my design. I've tried everything and the code I use in my child theme's style.css file sim... | Not directly, but I have a need for this functionality as well, as part of a plugin I'm writing for a client and have what I think is a pretty good start on an implementation.
The approach I'm taking is to store a term meta when the term is disabled and then to hook into the `get_terms_defaults` filter to strip disabl... |
257,702 | <p>I want my <code>single.php</code> to display posts in the same category for the previous and next posts underneath the post. The problem is that each of my posts belongs to multiple categories, and they are displayed through one of the other categories (24) versus the one I want them to display from (27). Does that ... | [
{
"answer_id": 257727,
"author": "Max Yudin",
"author_id": 11761,
"author_profile": "https://wordpress.stackexchange.com/users/11761",
"pm_score": 2,
"selected": false,
"text": "<p>You can temporarily exclude your terms from the queries. Meaning that you hide them on some listing pages, ... | 2017/02/23 | [
"https://wordpress.stackexchange.com/questions/257702",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114049/"
] | I want my `single.php` to display posts in the same category for the previous and next posts underneath the post. The problem is that each of my posts belongs to multiple categories, and they are displayed through one of the other categories (24) versus the one I want them to display from (27). Does that even make sens... | Not directly, but I have a need for this functionality as well, as part of a plugin I'm writing for a client and have what I think is a pretty good start on an implementation.
The approach I'm taking is to store a term meta when the term is disabled and then to hook into the `get_terms_defaults` filter to strip disabl... |
257,705 | <p>If you go to the ps4 page you will see that the last post is there</p>
<p><a href="http://gamersaction.com/" rel="nofollow noreferrer">My Site</a></p>
<p>Is it necessary to do something for the post to appear on the homepage or should it appear by default?</p>
| [
{
"answer_id": 257707,
"author": "Ashish Dung Dung",
"author_id": 65102,
"author_profile": "https://wordpress.stackexchange.com/users/65102",
"pm_score": 0,
"selected": false,
"text": "<p>You can set auto purge whenever you publish or update a post. \nHowever its better to purge all cach... | 2017/02/23 | [
"https://wordpress.stackexchange.com/questions/257705",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111513/"
] | If you go to the ps4 page you will see that the last post is there
[My Site](http://gamersaction.com/)
Is it necessary to do something for the post to appear on the homepage or should it appear by default? | You are most likely using browser caching ? Therefore new visitors would see the newly published post just fine, but because you've previously visited the page its cached and therefore your browser cache hasnt expired.
Generally its good practice to clear all caches upon publishing posts/pages and/or activating or de... |
257,708 | <p>My whole theme uses <code>remove_filter( 'the_content', 'wpautop' );</code> which strips the p tags and lines breaks from the output of the WYSIWYG. I have a custom post type <code>events</code> that I would like to bring back the auto p tags and br tags for, but JUST on that custom post type. Is there a way to make... | [
{
"answer_id": 257707,
"author": "Ashish Dung Dung",
"author_id": 65102,
"author_profile": "https://wordpress.stackexchange.com/users/65102",
"pm_score": 0,
"selected": false,
"text": "<p>You can set auto purge whenever you publish or update a post. \nHowever its better to purge all cach... | 2017/02/23 | [
"https://wordpress.stackexchange.com/questions/257708",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93770/"
] | My whole theme uses `remove_filter( 'the_content', 'wpautop' );` which strips the p tags and lines breaks from the output of the WYSIWYG. I have a custom post type `events` that I would like to bring back the auto p tags and br tags for, but JUST on that custom post type. Is there a way to make sure that filter doesn't... | You are most likely using browser caching ? Therefore new visitors would see the newly published post just fine, but because you've previously visited the page its cached and therefore your browser cache hasnt expired.
Generally its good practice to clear all caches upon publishing posts/pages and/or activating or de... |
257,738 | <p>I am using "ugly" permalinks and they are fine in index.php and single.php. I also have a template called sidebar.php that builds a sidebar when at the article/post level. When clicking categories and tags on the sidebar I am then returned with a 404. The actual format is: </p>
<p><a href="http://localhost/mywebsit... | [
{
"answer_id": 257910,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 1,
"selected": false,
"text": "<p>Instead of:</p>\n\n<pre><code>home_url() . \"/tag/\" . $i->slug\n</code></pre>\n\n<p>Use <a href=\"https:/... | 2017/02/23 | [
"https://wordpress.stackexchange.com/questions/257738",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29402/"
] | I am using "ugly" permalinks and they are fine in index.php and single.php. I also have a template called sidebar.php that builds a sidebar when at the article/post level. When clicking categories and tags on the sidebar I am then returned with a 404. The actual format is:
<http://localhost/mywebsite/tag/mytag>
<htt... | Following the suggestion for tags, I have gotten categories working.
I have modified the getposts function by mapping the category to the cat\_ID, rather than the slug:
```
newSuggestion($post->post_title, get_the_category($post->ID)[0]->cat_ID, get_the_category($post->ID)[0]->name, $imageUrl,
```
Then the NewSugge... |
257,739 | <p>i'm facing a problem with my custom query and need your help.</p>
<p>I want to display all posts of a specific category and I find this snippet:</p>
<pre><code>// get all the categories from the database
$cats = get_categories();
// loop through the categries
foreach ($cats as $cat) {
// setup... | [
{
"answer_id": 257910,
"author": "cybmeta",
"author_id": 37428,
"author_profile": "https://wordpress.stackexchange.com/users/37428",
"pm_score": 1,
"selected": false,
"text": "<p>Instead of:</p>\n\n<pre><code>home_url() . \"/tag/\" . $i->slug\n</code></pre>\n\n<p>Use <a href=\"https:/... | 2017/02/23 | [
"https://wordpress.stackexchange.com/questions/257739",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114076/"
] | i'm facing a problem with my custom query and need your help.
I want to display all posts of a specific category and I find this snippet:
```
// get all the categories from the database
$cats = get_categories();
// loop through the categries
foreach ($cats as $cat) {
// setup the cateogory ID
... | Following the suggestion for tags, I have gotten categories working.
I have modified the getposts function by mapping the category to the cat\_ID, rather than the slug:
```
newSuggestion($post->post_title, get_the_category($post->ID)[0]->cat_ID, get_the_category($post->ID)[0]->name, $imageUrl,
```
Then the NewSugge... |
257,749 | <p>We have a site currently with 1000s of pages with 10s of 1000s of urls linking internally to other pages. All current links use the "ugly" form of their url - ....com/?p=IDNUMBER.</p>
<p>In an SEO initiative, we're recreating the url structure. So, my question is, is it ok to leave the internal links "ugly?"</p>
<... | [
{
"answer_id": 257756,
"author": "passionsplay",
"author_id": 82414,
"author_profile": "https://wordpress.stackexchange.com/users/82414",
"pm_score": 3,
"selected": true,
"text": "<p>Changing the permalink structure is definitely a big deal for an existing site. In order to test the vari... | 2017/02/24 | [
"https://wordpress.stackexchange.com/questions/257749",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/37934/"
] | We have a site currently with 1000s of pages with 10s of 1000s of urls linking internally to other pages. All current links use the "ugly" form of their url - ....com/?p=IDNUMBER.
In an SEO initiative, we're recreating the url structure. So, my question is, is it ok to leave the internal links "ugly?"
In Wordpress, w... | Changing the permalink structure is definitely a big deal for an existing site. In order to test the various ways in which changing the permalink structure could break the site, I definitely recommend setting up a test environment.
>
> So, my question is, is it ok to leave the internal links "ugly?"
>
>
>
I'm not... |
257,757 | <p>I'm creating an advertising portal for a small network using a custom post type. In order to prevent WordPress database corruption or unauthorized access to user information, I need to keep data separated from the advertising app by duplicating custom post type data to an external database when creating and updating... | [
{
"answer_id": 257763,
"author": "TMA",
"author_id": 91044,
"author_profile": "https://wordpress.stackexchange.com/users/91044",
"pm_score": -1,
"selected": false,
"text": "<p>For this you need to modify the core wordpress file, in which the function code is written. </p>\n\n<p>You can g... | 2017/02/24 | [
"https://wordpress.stackexchange.com/questions/257757",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114085/"
] | I'm creating an advertising portal for a small network using a custom post type. In order to prevent WordPress database corruption or unauthorized access to user information, I need to keep data separated from the advertising app by duplicating custom post type data to an external database when creating and updating an... | I have been searching for an answer to this question for over a month now - i do not think wordpress is very good for any site that has a secure external DB or for anyone who does not want to store customer data in the main wordpress database, which is strange as that seems like a highly valued function.
At any rate i... |
257,804 | <p>I'm creating for the first time a theme <strong>from scratch</strong>.</p>
<blockquote>
<p>It's not a child theme</p>
</blockquote>
<p>In theme's <code>function.php</code> file I'm doing</p>
<pre><code>add_action( 'wp_enqueue_scripts', function() {
wp_enqueue_style( 'style', get_stylesheet_uri());
});
</cod... | [
{
"answer_id": 257805,
"author": "David Klhufek",
"author_id": 113922,
"author_profile": "https://wordpress.stackexchange.com/users/113922",
"pm_score": -1,
"selected": false,
"text": "<p>let's try this way:</p>\n\n<pre><code><?php\n//\n// Recommended way to include parent theme style... | 2017/02/24 | [
"https://wordpress.stackexchange.com/questions/257804",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/94289/"
] | I'm creating for the first time a theme **from scratch**.
>
> It's not a child theme
>
>
>
In theme's `function.php` file I'm doing
```
add_action( 'wp_enqueue_scripts', function() {
wp_enqueue_style( 'style', get_stylesheet_uri());
});
```
But the `style.css` file is not included in the served html.
Is t... | Found:
As stated here: <https://codex.wordpress.org/Function_Reference/wp_head>.
>
> Put this template tag immediately before tag in a theme template (ex. header.php, index.php).
>
>
>
So I added
```
<?php wp_head() ?>
```
just before `</HEAD` and now it works. |
257,841 | <p>The idea here is the following (I've now uploaded a picture to make it clearer what I need): </p>
<ol>
<li>Create a new page that contains a nicely formatted CSS table.</li>
<li>Each row would refer to a specific post from a specific category.</li>
<li>Each column would refer to specific information about that post... | [
{
"answer_id": 257849,
"author": "Anwer AR",
"author_id": 83820,
"author_profile": "https://wordpress.stackexchange.com/users/83820",
"pm_score": 2,
"selected": true,
"text": "<p>1: You can use <a href=\"https://developer.wordpress.org/themes/template-files-section/page-templates/\" rel=... | 2017/02/24 | [
"https://wordpress.stackexchange.com/questions/257841",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114130/"
] | The idea here is the following (I've now uploaded a picture to make it clearer what I need):
1. Create a new page that contains a nicely formatted CSS table.
2. Each row would refer to a specific post from a specific category.
3. Each column would refer to specific information about that post (linked title, post date... | 1: You can use [`Page template`](https://developer.wordpress.org/themes/template-files-section/page-templates/) and custom [`WP_Query`](https://codex.wordpress.org/Class_Reference/WP_Query) to show posts from a specific category into a page.
2: you can also achive same thing with [`shortcode`](https://codex.wordpress... |
257,854 | <p>I see that in other sites that use wordpress this does not happen, so I would like to know how to space without creating a blank paragraph or a &nbsp ?</p>
<p>As you can see in the image, in each space a blank paragraph is created</p>
<p><a href="https://i.stack.imgur.com/RZXjV.png" rel="nofollow noreferrer"><... | [
{
"answer_id": 257861,
"author": "Morshed Maruf",
"author_id": 114147,
"author_profile": "https://wordpress.stackexchange.com/users/114147",
"pm_score": 1,
"selected": false,
"text": "<pre><code><?php\nfunction add_necessary_functions() {\n\n function read_more($limit){\n $p... | 2017/02/24 | [
"https://wordpress.stackexchange.com/questions/257854",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/111513/"
] | I see that in other sites that use wordpress this does not happen, so I would like to know how to space without creating a blank paragraph or a   ?
As you can see in the image, in each space a blank paragraph is created
[](https://i.stack.imgur.c... | Judging from your site's content and the comments, you may try using the following CODE in your theme's `functions.php` file. It'll remove empty `<p> </p>` tags from post content:
```
add_filter( 'the_content', 'wpse_257854_remove_empty_p', PHP_INT_MAX );
add_filter( 'the_excerpt', 'wpse_257854_remove_empty_p', P... |
257,880 | <p>I've created a new widget based on one of my parent theme's custom widgets. In the parent theme the widget files are in the <code>/inc</code> and <code>template-parts</code> folders. I created these same folders in my child theme but can't get the widget to show up on the widgets page. However, it works if I add the... | [
{
"answer_id": 257861,
"author": "Morshed Maruf",
"author_id": 114147,
"author_profile": "https://wordpress.stackexchange.com/users/114147",
"pm_score": 1,
"selected": false,
"text": "<pre><code><?php\nfunction add_necessary_functions() {\n\n function read_more($limit){\n $p... | 2017/02/25 | [
"https://wordpress.stackexchange.com/questions/257880",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68414/"
] | I've created a new widget based on one of my parent theme's custom widgets. In the parent theme the widget files are in the `/inc` and `template-parts` folders. I created these same folders in my child theme but can't get the widget to show up on the widgets page. However, it works if I add the widget code to the `func... | Judging from your site's content and the comments, you may try using the following CODE in your theme's `functions.php` file. It'll remove empty `<p> </p>` tags from post content:
```
add_filter( 'the_content', 'wpse_257854_remove_empty_p', PHP_INT_MAX );
add_filter( 'the_excerpt', 'wpse_257854_remove_empty_p', P... |
257,892 | <p>I am trying to get post title by sql. My sql code is </p>
<pre><code>$query ="SELECT wp_posts.post_title AS title ,
wp_posts.post_content AS content,
wp_posts.post_date AS blogdate
FROM wp_posts
WHERE wp_posts.post_status = 'publish'
ORDER BY wp_... | [
{
"answer_id": 257894,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 3,
"selected": true,
"text": "<p>I am not sure why you are using a custom query and not <code>get_posts()</code> or <code>WP_Query</code> as you should... | 2017/02/25 | [
"https://wordpress.stackexchange.com/questions/257892",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101459/"
] | I am trying to get post title by sql. My sql code is
```
$query ="SELECT wp_posts.post_title AS title ,
wp_posts.post_content AS content,
wp_posts.post_date AS blogdate
FROM wp_posts
WHERE wp_posts.post_status = 'publish'
ORDER BY wp_posts.post_dat... | I am not sure why you are using a custom query and not `get_posts()` or `WP_Query` as you should.
Anyway, you need to get the post ID …
```
$query ="SELECT wp_posts.post_title AS title ,
wp_posts.post_content AS content,
wp_posts.post_date AS blogdate ,
... |
257,899 | <p>I have a page called <code>mypage</code> and a custom query var called <code>mycustomvar</code>, I am trying to rewrite the following url:</p>
<pre><code>http://example.com/index.php?name=mypage&mycustomvar=someword
</code></pre>
<p>to</p>
<pre><code>http://example.com/mypage/someword
</code></pre>
<p>using<... | [
{
"answer_id": 257970,
"author": "Stephen",
"author_id": 11023,
"author_profile": "https://wordpress.stackexchange.com/users/11023",
"pm_score": 0,
"selected": false,
"text": "<p>UGH I (maybe) just figured it out. I didn't need my variable to have a name, just a location.</p>\n\n<p>So ch... | 2017/02/25 | [
"https://wordpress.stackexchange.com/questions/257899",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11023/"
] | I have a page called `mypage` and a custom query var called `mycustomvar`, I am trying to rewrite the following url:
```
http://example.com/index.php?name=mypage&mycustomvar=someword
```
to
```
http://example.com/mypage/someword
```
using
```
add_rewrite_rule( '^mypage/([^/]+)/?', 'index.php?name=mypage&mycustom... | OK, let's first get some definitive clarification on the proper query vars.
Refer to [Post and Page parameters](https://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters) on the `WP_Query` codex page.
>
> name (string) - use post slug.
>
>
> pagename (string) - use page slug.
>
>
>
We can c... |
257,907 | <p>I've a script that I run on each page on my WordPress blog, but it has different input each time.</p>
<p>I have for a example a hint button: The hint button needs to be different on each page.</p>
<pre><code>function answerbutton() {
document.getElementById("answer").innerHTML = 'Readers will see this text as ... | [
{
"answer_id": 257970,
"author": "Stephen",
"author_id": 11023,
"author_profile": "https://wordpress.stackexchange.com/users/11023",
"pm_score": 0,
"selected": false,
"text": "<p>UGH I (maybe) just figured it out. I didn't need my variable to have a name, just a location.</p>\n\n<p>So ch... | 2017/02/25 | [
"https://wordpress.stackexchange.com/questions/257907",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114176/"
] | I've a script that I run on each page on my WordPress blog, but it has different input each time.
I have for a example a hint button: The hint button needs to be different on each page.
```
function answerbutton() {
document.getElementById("answer").innerHTML = 'Readers will see this text as a hint';
}
```
What... | OK, let's first get some definitive clarification on the proper query vars.
Refer to [Post and Page parameters](https://codex.wordpress.org/Class_Reference/WP_Query#Post_.26_Page_Parameters) on the `WP_Query` codex page.
>
> name (string) - use post slug.
>
>
> pagename (string) - use page slug.
>
>
>
We can c... |
257,925 | <p>I found that Woocommerce is disabling autosave, maybe for good reason, but I'd like to have it turned on and see if it presents an issue. This is what I found in the __construct in their post type class, from wp-content/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php....</p>
<pre><code>// Disable A... | [
{
"answer_id": 257949,
"author": "superwinner",
"author_id": 113690,
"author_profile": "https://wordpress.stackexchange.com/users/113690",
"pm_score": 0,
"selected": false,
"text": "<p>I kinda managed to fix it, don't know if it's the proper way, this is in case of sortable fields, using... | 2017/02/25 | [
"https://wordpress.stackexchange.com/questions/257925",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/83280/"
] | I found that Woocommerce is disabling autosave, maybe for good reason, but I'd like to have it turned on and see if it presents an issue. This is what I found in the \_\_construct in their post type class, from wp-content/plugins/woocommerce/includes/admin/class-wc-admin-post-types.php....
```
// Disable Auto Save
add... | The reason for this is that the widget will run its update logic on `keydown` *and* also on `change` for a given `input` element. See <https://github.com/WordPress/wordpress-develop/blob/4.7.2/src/wp-admin/js/customize-widgets.js#L891-L907>
There are some tradeoffs made when widgets were added to the customizer to bri... |
257,942 | <p>I've Developed Plugin for using all WordPress Themes. Now depending on Themes requirements I need to change some files on some files. But I don't wants to touch my Plugin.
I've used <pre>add_theme_support('jeweltheme-core');</pre>
I've copied Plugins files and Folders the same way on Plugin. I need to Edit "Widget" ... | [
{
"answer_id": 258098,
"author": "Doug Belchamber",
"author_id": 39013,
"author_profile": "https://wordpress.stackexchange.com/users/39013",
"pm_score": 2,
"selected": false,
"text": "<p>If you've written the plugin, then I'd suggest you add something like this:</p>\n\n<pre><code> // ... | 2017/02/25 | [
"https://wordpress.stackexchange.com/questions/257942",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85724/"
] | I've Developed Plugin for using all WordPress Themes. Now depending on Themes requirements I need to change some files on some files. But I don't wants to touch my Plugin.
I've used
```
add_theme_support('jeweltheme-core');
```
I've copied Plugins files and Folders the same way on Plugin. I need to Edit "Widget" file... | I've made my solution like this:
```
function jeweltheme_core_get_template_path($template){
$located = '';
$template_slug = rtrim( $template, '.php' );
$template = $template_slug . '.php';
$this_plugin_dir = WP_PLUGIN_DIR.'/'.str_replace( basename( __FILE__), "", plugin_basename... |
257,955 | <p>I'm using <code>Wordpress Settings API</code>. Everything works as it should except this <code>select</code> dropdown. When I select an option, the value echoed is correct but in the dropdown it displays the default first value i.e <code>6</code> and not the selected one. Where am I going wrong?</p>
<pre><code> pub... | [
{
"answer_id": 257959,
"author": "Roel Magdaleno",
"author_id": 99204,
"author_profile": "https://wordpress.stackexchange.com/users/99204",
"pm_score": 0,
"selected": false,
"text": "<p>I went through this, and I could tell that there's a WP function called <code>selected</code>, which y... | 2017/02/25 | [
"https://wordpress.stackexchange.com/questions/257955",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/447/"
] | I'm using `Wordpress Settings API`. Everything works as it should except this `select` dropdown. When I select an option, the value echoed is correct but in the dropdown it displays the default first value i.e `6` and not the selected one. Where am I going wrong?
```
public function someplugin_select() {
... | The reason your `$item == $option` condition is always failing is because of the way PHP compares floats!
Try the following instead:
```
echo "<option value='$item'" . selected (abs ($item - $options) <= 0.01, true, false) . ">$item</option>" ;
```
See [Comparing floats](http://php.net/manual/en/language.types.floa... |
257,957 | <p>When I change the redirect https in my .htaccess the site returns the message "Too many redirects" loop. </p>
<p>This is the modified .htaccess</p>
<pre><code>RewriteCond %{HTTPS} off
RewriteRule (.*)$ https://www.mywebsite.it/$1 [L,R=301]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteB... | [
{
"answer_id": 257960,
"author": "Poofy",
"author_id": 114069,
"author_profile": "https://wordpress.stackexchange.com/users/114069",
"pm_score": -1,
"selected": false,
"text": "<p><p>\ndo you want to push all the traffic to https?<p>\ni have ssl installed on my site, and i use this code ... | 2017/02/25 | [
"https://wordpress.stackexchange.com/questions/257957",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/54283/"
] | When I change the redirect https in my .htaccess the site returns the message "Too many redirects" loop.
This is the modified .htaccess
```
RewriteCond %{HTTPS} off
RewriteRule (.*)$ https://www.mywebsite.it/$1 [L,R=301]
# BEGIN WordPress
<IfModule mod_rewrite.c>
RewriteEngine On
RewriteBase /
RewriteRule ^index\.p... | Adding redirect to htaccess in the way that you have done will not work without adjudicating the site url to be https as well. If it is http, you will get endless redirect due to wordpress detecting that you are trying to access a non canonical URL (the https), and will try to redirect you to the canonical one, which i... |
257,978 | <p>I have created a page template and custom post type 'pa' that I want to display on the page template. I have the template created, also made <code>archive-pa.php</code>, <code>single-pa.php</code><br>
My template: <code>page-pa.php</code> contains this: </p>
<pre><code><?php
/*
Template Name: Personal Assistan... | [
{
"answer_id": 257960,
"author": "Poofy",
"author_id": 114069,
"author_profile": "https://wordpress.stackexchange.com/users/114069",
"pm_score": -1,
"selected": false,
"text": "<p><p>\ndo you want to push all the traffic to https?<p>\ni have ssl installed on my site, and i use this code ... | 2017/02/26 | [
"https://wordpress.stackexchange.com/questions/257978",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114208/"
] | I have created a page template and custom post type 'pa' that I want to display on the page template. I have the template created, also made `archive-pa.php`, `single-pa.php`
My template: `page-pa.php` contains this:
```
<?php
/*
Template Name: Personal Assistants
*/
get_header(); ?>
<div id="primary" class="co... | Adding redirect to htaccess in the way that you have done will not work without adjudicating the site url to be https as well. If it is http, you will get endless redirect due to wordpress detecting that you are trying to access a non canonical URL (the https), and will try to redirect you to the canonical one, which i... |
258,007 | <p>Adding alt tag information to every product photo is a lot of work. We always just copy and paste our product title into the image alt tags.</p>
<p>I figured since all the information is there; there must be a way to do this automatically.</p>
<p><strong>Question:</strong> How do you apply a woocommerce product's ... | [
{
"answer_id": 258009,
"author": "Richard Webster",
"author_id": 101457,
"author_profile": "https://wordpress.stackexchange.com/users/101457",
"pm_score": 4,
"selected": true,
"text": "<p>This is what you need, taken from - <a href=\"https://stackoverflow.com/questions/27087772/how-can-i... | 2017/02/26 | [
"https://wordpress.stackexchange.com/questions/258007",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110570/"
] | Adding alt tag information to every product photo is a lot of work. We always just copy and paste our product title into the image alt tags.
I figured since all the information is there; there must be a way to do this automatically.
**Question:** How do you apply a woocommerce product's TITLE as all the ALT TAGS for ... | This is what you need, taken from - <https://stackoverflow.com/questions/27087772/how-can-i-change-meta-alt-and-title-in-catalog-thumbnail-product-thumbnail>
```
add_filter('wp_get_attachment_image_attributes', 'change_attachement_image_attributes', 20, 2);
function change_attachement_image_attributes( $attr, $attach... |
258,013 | <p>I'm trying to echo <strong>all</strong> of my custom taxonomies, but this only prints out the first one:</p>
<pre><code>$skill_list = wp_get_post_terms($post->ID, 'skill', array('fields' => 'names'));
echo 'skill-' . $term->slug;
</code></pre>
<p>Does anyone have an idea of what I've done wrong?</p>
| [
{
"answer_id": 258009,
"author": "Richard Webster",
"author_id": 101457,
"author_profile": "https://wordpress.stackexchange.com/users/101457",
"pm_score": 4,
"selected": true,
"text": "<p>This is what you need, taken from - <a href=\"https://stackoverflow.com/questions/27087772/how-can-i... | 2017/02/26 | [
"https://wordpress.stackexchange.com/questions/258013",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91093/"
] | I'm trying to echo **all** of my custom taxonomies, but this only prints out the first one:
```
$skill_list = wp_get_post_terms($post->ID, 'skill', array('fields' => 'names'));
echo 'skill-' . $term->slug;
```
Does anyone have an idea of what I've done wrong? | This is what you need, taken from - <https://stackoverflow.com/questions/27087772/how-can-i-change-meta-alt-and-title-in-catalog-thumbnail-product-thumbnail>
```
add_filter('wp_get_attachment_image_attributes', 'change_attachement_image_attributes', 20, 2);
function change_attachement_image_attributes( $attr, $attach... |
258,026 | <p>I am trying to build a plugin that will replace one file from the theme. It will be plugin for certain theme that has a file placed in includes folder to the path would be: </p>
<p>wp-content/theme/includes/example-file.php</p>
<p>This example-file.php is loaded in header and footer also via <code>include</code></... | [
{
"answer_id": 258032,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 4,
"selected": true,
"text": "<h1>WordPress way (recommended):</h1>\n\n<p>In your plugin, use the WordPress <code>theme_file_path</code> filter... | 2017/02/26 | [
"https://wordpress.stackexchange.com/questions/258026",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/81451/"
] | I am trying to build a plugin that will replace one file from the theme. It will be plugin for certain theme that has a file placed in includes folder to the path would be:
wp-content/theme/includes/example-file.php
This example-file.php is loaded in header and footer also via `include`
I want to make a plugin that... | WordPress way (recommended):
============================
In your plugin, use the WordPress `theme_file_path` filter hook to change the file from the plugin. Use the following CODE in your plugin:
```
add_filter( 'theme_file_path', 'wpse_258026_modify_theme_include_file', 20, 2 );
function wpse_258026_modify_theme_in... |
258,048 | <p>I am working with twenty fourteen theme.
I want to customize the full-width template for my needs, to make it wider on specific pages.
so I copied it into a sub folder in my child theme.</p>
<p>how do I embed styling that will affect this template ONLY?</p>
<p>tried this, but it doesnt work: <a href="http://www.tr... | [
{
"answer_id": 258032,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 4,
"selected": true,
"text": "<h1>WordPress way (recommended):</h1>\n\n<p>In your plugin, use the WordPress <code>theme_file_path</code> filter... | 2017/02/26 | [
"https://wordpress.stackexchange.com/questions/258048",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114256/"
] | I am working with twenty fourteen theme.
I want to customize the full-width template for my needs, to make it wider on specific pages.
so I copied it into a sub folder in my child theme.
how do I embed styling that will affect this template ONLY?
tried this, but it doesnt work: <http://www.transformationpowertools.co... | WordPress way (recommended):
============================
In your plugin, use the WordPress `theme_file_path` filter hook to change the file from the plugin. Use the following CODE in your plugin:
```
add_filter( 'theme_file_path', 'wpse_258026_modify_theme_include_file', 20, 2 );
function wpse_258026_modify_theme_in... |