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 |
|---|---|---|---|---|---|---|
237,305 | <p><a href="https://i.stack.imgur.com/dWB4c.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dWB4c.jpg" alt="enter image description here"></a></p>
<p>I have been adding a post type to my theme, how do I hide/disable the Move to trash button?
Here is my code so far:</p>
<pre><code>$labels = array(
... | [
{
"answer_id": 237306,
"author": "Bhagchandani",
"author_id": 101627,
"author_profile": "https://wordpress.stackexchange.com/users/101627",
"pm_score": 3,
"selected": true,
"text": "<p>You can hide move to trash button via adding css in the admin area. Try following code in <code>functio... | 2016/08/27 | [
"https://wordpress.stackexchange.com/questions/237305",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/73800/"
] | [](https://i.stack.imgur.com/dWB4c.jpg)
I have been adding a post type to my theme, how do I hide/disable the Move to trash button?
Here is my code so far:
```
$labels = array(
'name' => _x( 'Inhoud', 'taxonomy general n... | You can hide move to trash button via adding css in the admin area. Try following code in `functions.php` file:
```
function my_custom_admin_styles() {
?>
<style type="text/css">
.post-type-inhoud form #delete-action{
display:none;
}
</style>
<?php
}
add_action('admin_head', 'my_custom... |
237,327 | <p>I want to create shortcode like [genre] for WordPress. </p>
<pre><code>add_action( 'init', 'cptui_register_my_cpts_movie' );
function cptui_register_my_cpts_movie() {
$labels = array(
"name" => __( 'MOVIE', '' ),
"singular_name" => __( 'Movie', '' ),
"menu_name" => __( 'MOVIES L... | [
{
"answer_id": 237333,
"author": "wpclevel",
"author_id": 92212,
"author_profile": "https://wordpress.stackexchange.com/users/92212",
"pm_score": 1,
"selected": false,
"text": "<p>You can use <code>page</code> post type.</p>\n\n<ul>\n<li>Simple to use.</li>\n<li>Easy to edit with page-bu... | 2016/08/28 | [
"https://wordpress.stackexchange.com/questions/237327",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101774/"
] | I want to create shortcode like [genre] for WordPress.
```
add_action( 'init', 'cptui_register_my_cpts_movie' );
function cptui_register_my_cpts_movie() {
$labels = array(
"name" => __( 'MOVIE', '' ),
"singular_name" => __( 'Movie', '' ),
"menu_name" => __( 'MOVIES LIBRARY', '' ),
... | I would not use WordPress pages nor articles for this.
Simply, create a new custom post type called "Projects", with a plugin like Types, then create a new custom taxonomy "Partners" and associate it with that custom post type.
Clean and easy structure. |
237,352 | <p>I want to make custom button for some products in place of add to cart button on shop page and set dynamic relinking to some other page. So I made a checkbox at the product page and if that checkbox is enabled then the custom button with different link will be visible to that product. here is the code for checkbox:<... | [
{
"answer_id": 237370,
"author": "Ashish Pariyani",
"author_id": 101657,
"author_profile": "https://wordpress.stackexchange.com/users/101657",
"pm_score": -1,
"selected": false,
"text": "<p>Got it to work with just changing \"add_to_cart_url()\" to \"get_permalink()\" inside if statement... | 2016/08/28 | [
"https://wordpress.stackexchange.com/questions/237352",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101657/"
] | I want to make custom button for some products in place of add to cart button on shop page and set dynamic relinking to some other page. So I made a checkbox at the product page and if that checkbox is enabled then the custom button with different link will be visible to that product. here is the code for checkbox:
``... | Per [Ashish's](https://wordpress.stackexchange.com/users/101657/ashish-pariyani) answer that's been posted, below is the update code for clarification with the correct answer by switching `add_to_cart_url()` to `get_permalink()`:
```
global $product, $post;
$hasCustomization = get_post_meta( $post -> ID, '_wcm_custom... |
237,365 | <p>I want to add an <code>id="myid"</code> to shortcode embedded iframe:-</p>
<pre><code>$video_url = get_post_meta($post_id, 'video_url',true);
//or
$video_url .= 'video url';
$check_embeds=$GLOBALS['wp_embed']->run_shortcode( '[embed]'. $video_url .'[/embed]' );
echo $check_embeds;
</code></pre>
<p>This code hel... | [
{
"answer_id": 237370,
"author": "Ashish Pariyani",
"author_id": 101657,
"author_profile": "https://wordpress.stackexchange.com/users/101657",
"pm_score": -1,
"selected": false,
"text": "<p>Got it to work with just changing \"add_to_cart_url()\" to \"get_permalink()\" inside if statement... | 2016/08/28 | [
"https://wordpress.stackexchange.com/questions/237365",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101698/"
] | I want to add an `id="myid"` to shortcode embedded iframe:-
```
$video_url = get_post_meta($post_id, 'video_url',true);
//or
$video_url .= 'video url';
$check_embeds=$GLOBALS['wp_embed']->run_shortcode( '[embed]'. $video_url .'[/embed]' );
echo $check_embeds;
```
This code helps me to display video through custom me... | Per [Ashish's](https://wordpress.stackexchange.com/users/101657/ashish-pariyani) answer that's been posted, below is the update code for clarification with the correct answer by switching `add_to_cart_url()` to `get_permalink()`:
```
global $product, $post;
$hasCustomization = get_post_meta( $post -> ID, '_wcm_custom... |
237,368 | <p><a href="https://danscartoons.com" rel="nofollow noreferrer"><strong>My index page</strong></a> has three button on top upper right corner. They are Facebook, Twitter and RSS.</p>
<p>I have accessed my <code>header.php</code> to add the appropriate URL's for both Facebook & Twitter (I did not add RSS feed as of... | [
{
"answer_id": 237370,
"author": "Ashish Pariyani",
"author_id": 101657,
"author_profile": "https://wordpress.stackexchange.com/users/101657",
"pm_score": -1,
"selected": false,
"text": "<p>Got it to work with just changing \"add_to_cart_url()\" to \"get_permalink()\" inside if statement... | 2016/08/28 | [
"https://wordpress.stackexchange.com/questions/237368",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/99226/"
] | [**My index page**](https://danscartoons.com) has three button on top upper right corner. They are Facebook, Twitter and RSS.
I have accessed my `header.php` to add the appropriate URL's for both Facebook & Twitter (I did not add RSS feed as of yet) below is a screenshot of what I have so far:
[ answer that's been posted, below is the update code for clarification with the correct answer by switching `add_to_cart_url()` to `get_permalink()`:
```
global $product, $post;
$hasCustomization = get_post_meta( $post -> ID, '_wcm_custom... |
237,374 | <p>Is there any neat way of disabling the figures/images in a certain post category until a user logs in. I want the entire post content to be visible except for the images.</p>
<p>I'm not a programmer and I have not found any useful plugin.</p>
| [
{
"answer_id": 237370,
"author": "Ashish Pariyani",
"author_id": 101657,
"author_profile": "https://wordpress.stackexchange.com/users/101657",
"pm_score": -1,
"selected": false,
"text": "<p>Got it to work with just changing \"add_to_cart_url()\" to \"get_permalink()\" inside if statement... | 2016/08/28 | [
"https://wordpress.stackexchange.com/questions/237374",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101304/"
] | Is there any neat way of disabling the figures/images in a certain post category until a user logs in. I want the entire post content to be visible except for the images.
I'm not a programmer and I have not found any useful plugin. | Per [Ashish's](https://wordpress.stackexchange.com/users/101657/ashish-pariyani) answer that's been posted, below is the update code for clarification with the correct answer by switching `add_to_cart_url()` to `get_permalink()`:
```
global $product, $post;
$hasCustomization = get_post_meta( $post -> ID, '_wcm_custom... |
237,381 | <p>Suppose we registered the <code>composers</code> and the <code>interprets</code> custom taxonomies.</p>
<p>The <code>composers</code> taxonomy could have the following terms:</p>
<ul>
<li>Wolfgang Amadeus Mozart</li>
<li>Ludwig van Beethoven</li>
<li>Richard Wagner</li>
</ul>
<p>The <code>interprets</code> taxono... | [
{
"answer_id": 237379,
"author": "markratledge",
"author_id": 268,
"author_profile": "https://wordpress.stackexchange.com/users/268",
"pm_score": 3,
"selected": true,
"text": "<p>PHP errors are the cause of whitescreens. You will have error logs in your Cpanel at Hostgator, but it's much... | 2016/08/28 | [
"https://wordpress.stackexchange.com/questions/237381",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/88041/"
] | Suppose we registered the `composers` and the `interprets` custom taxonomies.
The `composers` taxonomy could have the following terms:
* Wolfgang Amadeus Mozart
* Ludwig van Beethoven
* Richard Wagner
The `interprets` taxonomy could have the following terms:
* Glenn Gould
* Daniel Barenboim
* Vienna State Opera
I ... | PHP errors are the cause of whitescreens. You will have error logs in your Cpanel at Hostgator, but it's much easier to use the debug logs that are available in WordPress. *(For debugging outside of the WordPress environment, see <http://php.net/manual/en/debugger-about.php> about PHP's own debugger and third-party deb... |
237,385 | <p>so i wrote a simple script and enqueued it properly.</p>
<p><strong>my-jquery-script.js:</strong></p>
<pre><code>jQuery(document).ready(function($) {
$('#some_id').on('click','.clone',function(e){
alert('clicked');
/*.....*/
e.preventDefault();
});
});
</code></pre>
<p><strong>functions.php:</strong></p>
<pre><c... | [
{
"answer_id": 237387,
"author": "fuxia",
"author_id": 73,
"author_profile": "https://wordpress.stackexchange.com/users/73",
"pm_score": 2,
"selected": false,
"text": "<p>If your script depends on jQuery, you have to declare that dependency to make sure WordPress will enqueue it earlier ... | 2016/08/28 | [
"https://wordpress.stackexchange.com/questions/237385",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101800/"
] | so i wrote a simple script and enqueued it properly.
**my-jquery-script.js:**
```
jQuery(document).ready(function($) {
$('#some_id').on('click','.clone',function(e){
alert('clicked');
/*.....*/
e.preventDefault();
});
});
```
**functions.php:**
```
add_action( 'wp_enqueue_scripts', 'my_function' );
function my_fu... | If your script depends on jQuery, you have to declare that dependency to make sure WordPress will enqueue it earlier than yours.
```
wp_enqueue_script(
'my-jquery-script',
get_stylesheet_directory_uri() . '/js/my-jquery-script.js',
[ 'jquery' ] /* declare the dependency */
);
``` |
237,395 | <p>I've been using site/page builders for so long in WP that I'm OOTL with the current setup of templates, stylesheets and functions in the newer WP builds.</p>
<p>I've got an older theme that I need to make a unique page for and am struggling to understand how to use a specific stylesheet for this page template.
If t... | [
{
"answer_id": 237398,
"author": "CodeMascot",
"author_id": 44192,
"author_profile": "https://wordpress.stackexchange.com/users/44192",
"pm_score": 1,
"selected": false,
"text": "<p>If you don't need to use often some scripts or styles, it's better to register them before <code>enqueue</... | 2016/08/29 | [
"https://wordpress.stackexchange.com/questions/237395",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/30889/"
] | I've been using site/page builders for so long in WP that I'm OOTL with the current setup of templates, stylesheets and functions in the newer WP builds.
I've got an older theme that I need to make a unique page for and am struggling to understand how to use a specific stylesheet for this page template.
If the page te... | The preferred way is to use `add_action( 'wp_enqueue_scripts', 'themeslug_enqueue_style' );` within your child theme `functions.php` file or directly in your `referral.php` template page. Either way, it's by using `add_action` and not by echoing into the `<link>` tag.
Registering your style is also a recommended pract... |
237,410 | <p>I'm new to WordPress, and I'm having an issue with "The Loop."
I have 2 custom post type named 'book' and 'author'
.in author post type I have custom filed checkbox which can choose between author and translator.
also in book post type I have 2 metaboxs which user must choose the name of author and translator from t... | [
{
"answer_id": 237414,
"author": "bynicolas",
"author_id": 99217,
"author_profile": "https://wordpress.stackexchange.com/users/99217",
"pm_score": 2,
"selected": true,
"text": "<p>I believe your issue is with <code>$vals=get_post_meta($post_id, $key2, true);</code></p>\n\n<p>If you check... | 2016/08/29 | [
"https://wordpress.stackexchange.com/questions/237410",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101035/"
] | I'm new to WordPress, and I'm having an issue with "The Loop."
I have 2 custom post type named 'book' and 'author'
.in author post type I have custom filed checkbox which can choose between author and translator.
also in book post type I have 2 metaboxs which user must choose the name of author and translator from thos... | I believe your issue is with `$vals=get_post_meta($post_id, $key2, true);`
If you check the codex, the last parameter for [get\_post\_meta](https://developer.wordpress.org/reference/functions/get_post_meta/) is whether to return a single value or array of values. You have set it to `true` which means return only one v... |
237,427 | <p>After getting so close to nailing my theme I've hit the last hurdle. Essentially I have three different areas on my homepage:</p>
<ol>
<li>The latest post appears in the header and styled as a featured post</li>
<li>Two posts below that styled as recent posts</li>
<li>The rest of the posts (10) in date order below ... | [
{
"answer_id": 237444,
"author": "The J",
"author_id": 98010,
"author_profile": "https://wordpress.stackexchange.com/users/98010",
"pm_score": 0,
"selected": false,
"text": "<p>I would probably try without the <code>&& !$query->is_paged()</code> (you already have 2 conditions... | 2016/08/29 | [
"https://wordpress.stackexchange.com/questions/237427",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/99335/"
] | After getting so close to nailing my theme I've hit the last hurdle. Essentially I have three different areas on my homepage:
1. The latest post appears in the header and styled as a featured post
2. Two posts below that styled as recent posts
3. The rest of the posts (10) in date order below those
Latest post (1) an... | Here's a suggestion for a general way to support **different** number of posts on the *home page* than on the *other paginated pages*. We should use the *main query* instead of *sub-queries*, if possible.
**Formula**
It seems to make sense to take the *offset* for paginated pages as:
```
offset_op = ( paged - 1 ) * ... |
237,436 | <p>Can anyone tell me how to create a function out of the following code? It's for displaying page navigation links in a custom category template. As you can see, it's quite a large block of code and I would like to wrap it in a function so I can generate the links with just a single line of code in my template.</p>
<... | [
{
"answer_id": 237444,
"author": "The J",
"author_id": 98010,
"author_profile": "https://wordpress.stackexchange.com/users/98010",
"pm_score": 0,
"selected": false,
"text": "<p>I would probably try without the <code>&& !$query->is_paged()</code> (you already have 2 conditions... | 2016/08/29 | [
"https://wordpress.stackexchange.com/questions/237436",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68414/"
] | Can anyone tell me how to create a function out of the following code? It's for displaying page navigation links in a custom category template. As you can see, it's quite a large block of code and I would like to wrap it in a function so I can generate the links with just a single line of code in my template.
Here it ... | Here's a suggestion for a general way to support **different** number of posts on the *home page* than on the *other paginated pages*. We should use the *main query* instead of *sub-queries*, if possible.
**Formula**
It seems to make sense to take the *offset* for paginated pages as:
```
offset_op = ( paged - 1 ) * ... |
237,438 | <p>I'm trying to give custom color to each <strong>category item</strong>, But it gives only one style to all items.</p>
<p>I use this plugin for the colors:
'<a href="https://wordpress.org/plugins/category-color/" rel="nofollow">Category Color</a>'</p>
<p>My code as below,</p>
<pre><code><?php
$category = get_t... | [
{
"answer_id": 237439,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "<p>Why you don't use \"Term meta\"?</p>\n\n<p><a href=\"https://www.smashingmagazine.com/2015/12/how-to-use-term-met... | 2016/08/29 | [
"https://wordpress.stackexchange.com/questions/237438",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101827/"
] | I'm trying to give custom color to each **category item**, But it gives only one style to all items.
I use this plugin for the colors:
'[Category Color](https://wordpress.org/plugins/category-color/)'
My code as below,
```
<?php
$category = get_the_category();
$the_category_id = $category[0]->cat_ID;
if(function_e... | You are getting the color for one category (*term* is more appropriate though)
```
$the_category_id = $category[0]->cat_ID;
```
instead of checking the ID and Color for each term, that's why it's applying the same to all.
Try this (untested):
```
<?php
$categories = get_the_category();
$sep = '';
fore... |
237,442 | <p>I need to get a post thumbnail to show up in an email, but this doesnt work with just <code>mailto</code>: as i've tried it.</p>
<pre><code><a href="mailto:?subject=Anbefalt innlegg - <?php the_title(); ?>&body=Hei, jeg fant et innlegg som jeg tror du vil like. <img src='<?php echo wp_get_attachm... | [
{
"answer_id": 237445,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 2,
"selected": true,
"text": "<p>The <code>mailto</code> protocol is fairly limited and does not support html in the body. Notably iOS supports so... | 2016/08/29 | [
"https://wordpress.stackexchange.com/questions/237442",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/100922/"
] | I need to get a post thumbnail to show up in an email, but this doesnt work with just `mailto`: as i've tried it.
```
<a href="mailto:?subject=Anbefalt innlegg - <?php the_title(); ?>&body=Hei, jeg fant et innlegg som jeg tror du vil like. <img src='<?php echo wp_get_attachment_url( get_post_thumbnail_id($post->ID) );... | The `mailto` protocol is fairly limited and does not support html in the body. Notably iOS supports some tags, but you cannot rely on that. The point is that `mailto` parses information from the browser to the user's email program. The more tags are allowed, the higher the security risk becomes. So, if you insist on se... |
237,458 | <p>I have a custom post type <code>Portfolio</code> and each portfolio is a questionnaire. If I email the link of a portfolio to a client via email. </p>
<p>How can I expire link after 10 minutes, So if client has came after 10 minutes to visit the link Then there should be message that link has expired Please try aga... | [
{
"answer_id": 237472,
"author": "C C",
"author_id": 83299,
"author_profile": "https://wordpress.stackexchange.com/users/83299",
"pm_score": 0,
"selected": false,
"text": "<p>Here's one idea: Hook to the <code>template_redirect</code> action:</p>\n\n<p><a href=\"https://codex.wordpress.... | 2016/08/29 | [
"https://wordpress.stackexchange.com/questions/237458",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101087/"
] | I have a custom post type `Portfolio` and each portfolio is a questionnaire. If I email the link of a portfolio to a client via email.
How can I expire link after 10 minutes, So if client has came after 10 minutes to visit the link Then there should be message that link has expired Please try again.
How can I do tha... | Ok I came up with this
```
add_action( 'wp_loaded', 'my_create_questionnaire_link');
function my_create_questionnaire_link(){
// this check is for demo, if you go to http://yoursite.demo/?create-my-link, you will get your unique url added to your content
if( isset( $_GET['create-my-link'] ) ){
// This filter... |
237,461 | <p>Hello every one i am facing one issue in adding logo option in my theme panel of wordpress i am using this code</p>
<pre><code>function logo_display()
{
?>
<input type="file" name="logo" />
<?php echo get_option('logo'); ?>
<?php
}
function handle_logo_upload()
{
if(!em... | [
{
"answer_id": 237714,
"author": "shamim khan",
"author_id": 98304,
"author_profile": "https://wordpress.stackexchange.com/users/98304",
"pm_score": 2,
"selected": true,
"text": "<p>if you use wordpress customizer then try this code</p>\n\n<pre><code>public static function register ( $wp... | 2016/08/29 | [
"https://wordpress.stackexchange.com/questions/237461",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/98358/"
] | Hello every one i am facing one issue in adding logo option in my theme panel of wordpress i am using this code
```
function logo_display()
{
?>
<input type="file" name="logo" />
<?php echo get_option('logo'); ?>
<?php
}
function handle_logo_upload()
{
if(!empty($_FILES["demo-file"]["tmp_na... | if you use wordpress customizer then try this code
```
public static function register ( $wp_customize ) {
// Logo upload
$wp_customize->add_section( 'bia_logo_section' , array(
'title' => __( 'Site Logo', 'bia' ),
'priority' => 30,
'description' => 'Upload a logo to replace th... |
237,488 | <p>I'm making my first wordpress site. When I publish a post I see it in my home page but despite I add an image I can't see it above the post title in my home page. <a href="https://i.stack.imgur.com/EnztZ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EnztZ.jpg" alt="enter image description here">... | [
{
"answer_id": 237714,
"author": "shamim khan",
"author_id": 98304,
"author_profile": "https://wordpress.stackexchange.com/users/98304",
"pm_score": 2,
"selected": true,
"text": "<p>if you use wordpress customizer then try this code</p>\n\n<pre><code>public static function register ( $wp... | 2016/08/29 | [
"https://wordpress.stackexchange.com/questions/237488",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101850/"
] | I'm making my first wordpress site. When I publish a post I see it in my home page but despite I add an image I can't see it above the post title in my home page. [](https://i.stack.imgur.com/EnztZ.jpg)
Thank you in advice. | if you use wordpress customizer then try this code
```
public static function register ( $wp_customize ) {
// Logo upload
$wp_customize->add_section( 'bia_logo_section' , array(
'title' => __( 'Site Logo', 'bia' ),
'priority' => 30,
'description' => 'Upload a logo to replace th... |
237,558 | <h2>Introduction</h2>
<p>When uploading a file (<code>stackexchange.jpg</code>) to the media library in a WordPress site, there are two relevant links.</p>
<ol>
<li><p><strong>Direct link to file</strong><br><code>http://example.com/wp-content/uploads/stackexchange.jpg</code></p></li>
<li><p><strong>Attachment page</... | [
{
"answer_id": 238205,
"author": "KenB",
"author_id": 27576,
"author_profile": "https://wordpress.stackexchange.com/users/27576",
"pm_score": 2,
"selected": true,
"text": "<p>Great question! I've been thinking about this myself and your question prompted me to dig into it.</p>\n\n<p>Ther... | 2016/08/30 | [
"https://wordpress.stackexchange.com/questions/237558",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/88601/"
] | Introduction
------------
When uploading a file (`stackexchange.jpg`) to the media library in a WordPress site, there are two relevant links.
1. **Direct link to file**
`http://example.com/wp-content/uploads/stackexchange.jpg`
2. **Attachment page**
`http://example.com/stackexchange/`
My question deals with the ... | Great question! I've been thinking about this myself and your question prompted me to dig into it.
There is a filter `wp_insert_attachment_data` than can be used to fix the slug name for uploaded files. It is called for attachments shortly before the attachment is inserted into the database in `post.php`.
The followi... |
237,573 | <p>I'm trying to add a CSS class to every image in a custom post type. </p>
<p>I've found <a href="https://wordpress.stackexchange.com/questions/108831/add-css-class-to-every-image">this answer</a>, to add a class to every image in general: </p>
<pre><code>function add_image_class($class){
$class .= ' additional-... | [
{
"answer_id": 237575,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 2,
"selected": false,
"text": "<p>The function <a href=\"https://developer.wordpress.org/reference/functions/get_post_type/\" rel=\"nofollow\"><co... | 2016/08/30 | [
"https://wordpress.stackexchange.com/questions/237573",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/92868/"
] | I'm trying to add a CSS class to every image in a custom post type.
I've found [this answer](https://wordpress.stackexchange.com/questions/108831/add-css-class-to-every-image), to add a class to every image in general:
```
function add_image_class($class){
$class .= ' additional-class';
return $class;
}
add... | Combining the answer here by @cjcj with the code in [this answer](https://wordpress.stackexchange.com/a/22166/92868), the code that works for me outside the loop, in functions.php is:
```
// Add ability to check for custom post type outside the loop.
function is_post_type($type){
global $wp_query;
if($type ==... |
237,599 | <p>Depending on the product category, I have different data to display on category page. I'm getting my category <code>ID</code> this way:</p>
<pre><code><?php global $post;
$terms = get_the_terms( $post->ID, 'product_cat' );
foreach ($terms as $term) {
$product_cat_id = $term->term_id;
break;
}
if (... | [
{
"answer_id": 237603,
"author": "Ethan O'Sullivan",
"author_id": 98212,
"author_profile": "https://wordpress.stackexchange.com/users/98212",
"pm_score": 0,
"selected": false,
"text": "<p>Your <code>$product_cat_id</code> is an <code>array()</code> of all of your categories and it looks ... | 2016/08/30 | [
"https://wordpress.stackexchange.com/questions/237599",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101907/"
] | Depending on the product category, I have different data to display on category page. I'm getting my category `ID` this way:
```
<?php global $post;
$terms = get_the_terms( $post->ID, 'product_cat' );
foreach ($terms as $term) {
$product_cat_id = $term->term_id;
break;
}
if ($product_cat_id == "6") {
echo "aa... | >
> Try This Code
>
>
>
```
<?php global $post;
$terms = get_the_terms( $post->ID, 'product_cat' );
foreach ($terms as $term) {
$product_cat_id = $term->term_id;
break;
}
if ($product_cat_id == "6" && $product_cat_id == "7" ) {
echo "aaabbb";
}
else if ($product_ca... |
237,601 | <p>I am currently making an e-shop on woocommerce. On my homepage there is products slider with the add-to-cart button under each product. If I click on the button, product is added to cart successfully, but without any message.</p>
<p>While surfing the Internet, I've found out, that messages can be added on shop page... | [
{
"answer_id": 237602,
"author": "Faisal Ramzan",
"author_id": 85487,
"author_profile": "https://wordpress.stackexchange.com/users/85487",
"pm_score": 2,
"selected": false,
"text": "<p>This article will help you in this issue\n<a href=\"https://docs.woocommerce.com/document/woocommerce-c... | 2016/08/30 | [
"https://wordpress.stackexchange.com/questions/237601",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/80324/"
] | I am currently making an e-shop on woocommerce. On my homepage there is products slider with the add-to-cart button under each product. If I click on the button, product is added to cart successfully, but without any message.
While surfing the Internet, I've found out, that messages can be added on shop page, product ... | Solution was as simple as it should be: I've just added this piece of code into my main page .php file:
```
do_action( 'woocommerce_before_single_product' );
``` |
237,610 | <p>Here is my query args :</p>
<pre><code> $query_args = array(
'post_type' => 'rented_properties',
'post_status' => 'publish',
'order' => 'DESC',
// 'fields' => 'SUM(amount_to_paid)',
);
$my_querys = null;
$my_querys = new WP_Query(... | [
{
"answer_id": 237711,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 2,
"selected": true,
"text": "<p><code>WP_Query</code> gets posts from the database, but it's not a generic SQL query class, it should really ... | 2016/08/30 | [
"https://wordpress.stackexchange.com/questions/237610",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/99113/"
] | Here is my query args :
```
$query_args = array(
'post_type' => 'rented_properties',
'post_status' => 'publish',
'order' => 'DESC',
// 'fields' => 'SUM(amount_to_paid)',
);
$my_querys = null;
$my_querys = new WP_Query($query_args);
```
My meta... | `WP_Query` gets posts from the database, but it's not a generic SQL query class, it should really be called `WP_Post_Query`, as `WP_Query` implies it can do any SQL.
As a result, you need to do several things:
1. Grab the posts you need
2. Get their meta values for `amount_to_paid` using `get_post_meta`
3. Add those ... |
237,613 | <p>I'm using WP version 4.4.4. I have some posts where it has a continue reading button and link to the actual excerpt. My problem is the excerpt also has a continue reading button. Here is my code at the end of <code>functions.php</code>.</p>
<pre><code>function new_excerpt_more($more) {
global $post;
return '... <... | [
{
"answer_id": 237711,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 2,
"selected": true,
"text": "<p><code>WP_Query</code> gets posts from the database, but it's not a generic SQL query class, it should really ... | 2016/08/30 | [
"https://wordpress.stackexchange.com/questions/237613",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91536/"
] | I'm using WP version 4.4.4. I have some posts where it has a continue reading button and link to the actual excerpt. My problem is the excerpt also has a continue reading button. Here is my code at the end of `functions.php`.
```
function new_excerpt_more($more) {
global $post;
return '... <a class="moretag" href="'. ... | `WP_Query` gets posts from the database, but it's not a generic SQL query class, it should really be called `WP_Post_Query`, as `WP_Query` implies it can do any SQL.
As a result, you need to do several things:
1. Grab the posts you need
2. Get their meta values for `amount_to_paid` using `get_post_meta`
3. Add those ... |
237,620 | <p>I am developing a wordpress theme. In <code>single.php</code> page I want to loop similar to this,</p>
<pre><code><?php while ( have_posts() ) : the_post(); ?>
<?php if ( is_single() ) : ?>
<div class="post-heading-info">
<!--Post heading info like title, category goe... | [
{
"answer_id": 237621,
"author": "Ethan O'Sullivan",
"author_id": 98212,
"author_profile": "https://wordpress.stackexchange.com/users/98212",
"pm_score": 1,
"selected": false,
"text": "<p>As many people would agree, editing WordPress' core is not recommended because any updates that are ... | 2016/08/30 | [
"https://wordpress.stackexchange.com/questions/237620",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/89234/"
] | I am developing a wordpress theme. In `single.php` page I want to loop similar to this,
```
<?php while ( have_posts() ) : the_post(); ?>
<?php if ( is_single() ) : ?>
<div class="post-heading-info">
<!--Post heading info like title, category goes here -->
</div>
<?php endif; ?>... | As many people would agree, editing WordPress' core is not recommended because any updates that are made from the official developer (ex: 4.6 to 4.6.1) will override your changes. Plus, editing the core could potentially break your website or any other theme/plugin if it's not properly edited.
This is where plugins co... |
237,629 | <p>I can think of a number of ways to go about doing this. I'm looking for the most efficient way. Menu looks like this:</p>
<p>catArchive1 [num_new_posts] catArchive2 [num_new_posts] catArchive3 [num_new_posts]</p>
<p>^^[num_new_posts] being the number of new posts</p>
<p>Assuming we have a cookie value set for th... | [
{
"answer_id": 237621,
"author": "Ethan O'Sullivan",
"author_id": 98212,
"author_profile": "https://wordpress.stackexchange.com/users/98212",
"pm_score": 1,
"selected": false,
"text": "<p>As many people would agree, editing WordPress' core is not recommended because any updates that are ... | 2016/08/30 | [
"https://wordpress.stackexchange.com/questions/237629",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/11857/"
] | I can think of a number of ways to go about doing this. I'm looking for the most efficient way. Menu looks like this:
catArchive1 [num\_new\_posts] catArchive2 [num\_new\_posts] catArchive3 [num\_new\_posts]
^^[num\_new\_posts] being the number of new posts
Assuming we have a cookie value set for the users last visi... | As many people would agree, editing WordPress' core is not recommended because any updates that are made from the official developer (ex: 4.6 to 4.6.1) will override your changes. Plus, editing the core could potentially break your website or any other theme/plugin if it's not properly edited.
This is where plugins co... |
237,671 | <p>I have website in WordPress and I updated my <code>.htaccess</code> file with following rule. </p>
<pre><code><IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 yea... | [
{
"answer_id": 237621,
"author": "Ethan O'Sullivan",
"author_id": 98212,
"author_profile": "https://wordpress.stackexchange.com/users/98212",
"pm_score": 1,
"selected": false,
"text": "<p>As many people would agree, editing WordPress' core is not recommended because any updates that are ... | 2016/08/31 | [
"https://wordpress.stackexchange.com/questions/237671",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101535/"
] | I have website in WordPress and I updated my `.htaccess` file with following rule.
```
<IfModule mod_expires.c>
ExpiresActive On
ExpiresByType image/jpg "access 1 year"
ExpiresByType image/jpeg "access 1 year"
ExpiresByType image/gif "access 1 year"
ExpiresByType image/png "access 1 year"
ExpiresByType text/css "acce... | As many people would agree, editing WordPress' core is not recommended because any updates that are made from the official developer (ex: 4.6 to 4.6.1) will override your changes. Plus, editing the core could potentially break your website or any other theme/plugin if it's not properly edited.
This is where plugins co... |
237,741 | <p>I need to protect some hooks which only can be hooked by functions/callbacks within my theme/plugin.</p>
<p>For example:</p>
<pre><code>if ( is_protected_hook('hook_name') ) {
throw new \Exception('You cannot hook to a protected hook.');
} else {
do_action('hook_name');
}
</code></pre>
<p>Is there a way to de... | [
{
"answer_id": 237748,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 3,
"selected": true,
"text": "<p>As noted in my answer to <a href=\"https://wordpress.stackexchange.com/questions/237717/how-to-check-if-a-hook-is... | 2016/08/31 | [
"https://wordpress.stackexchange.com/questions/237741",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/92212/"
] | I need to protect some hooks which only can be hooked by functions/callbacks within my theme/plugin.
For example:
```
if ( is_protected_hook('hook_name') ) {
throw new \Exception('You cannot hook to a protected hook.');
} else {
do_action('hook_name');
}
```
Is there a way to define the `is_protected_hook()` fu... | As noted in my answer to [your related question](https://wordpress.stackexchange.com/questions/237717/how-to-check-if-a-hook-is-hooked-or-not) there is a datastructre `$wp_filter` that stores all information on hooks and filters. You may want to try a `var_dump` on it just to see what it looks like. There is no built i... |
237,757 | <p>I have the following code (below) in my theme. I am using redux framework for my theme options. My codes in a part looking like this. And I am really not sure about the security issue of this chunk of codes. Please any expert help me indicating any security problem in here. Your few minutes from your life would be r... | [
{
"answer_id": 237759,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 3,
"selected": true,
"text": "<p>Security issues arise when you write code that open up possibilities for outsiders to access your database or oth... | 2016/08/31 | [
"https://wordpress.stackexchange.com/questions/237757",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/89234/"
] | I have the following code (below) in my theme. I am using redux framework for my theme options. My codes in a part looking like this. And I am really not sure about the security issue of this chunk of codes. Please any expert help me indicating any security problem in here. Your few minutes from your life would be real... | Security issues arise when you write code that open up possibilities for outsiders to access your database or otherwise compromise your installation.
The above code just reads options and content from the database and translates this into static html that will be send to the browser of the page's visitor. There's no c... |
237,762 | <p>I would like to disable all attachment pages completely. I Googled it, but there's just information on <a href="https://stackoverflow.com/questions/28885293/how-disable-image-attachment-pages-in-wordpress">how to redirect to parent post or homepage</a>. That's not what I would call an elegant solution. Why introduce... | [
{
"answer_id": 271089,
"author": "Ihor Vorotnov",
"author_id": 47359,
"author_profile": "https://wordpress.stackexchange.com/users/47359",
"pm_score": 4,
"selected": false,
"text": "<p>You can filter default rewrite rules and remove those for attachments:</p>\n\n<pre><code>function clean... | 2016/08/31 | [
"https://wordpress.stackexchange.com/questions/237762",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/88787/"
] | I would like to disable all attachment pages completely. I Googled it, but there's just information on [how to redirect to parent post or homepage](https://stackoverflow.com/questions/28885293/how-disable-image-attachment-pages-in-wordpress). That's not what I would call an elegant solution. Why introduce unnecessary p... | You can filter default rewrite rules and remove those for attachments:
```
function cleanup_default_rewrite_rules( $rules ) {
foreach ( $rules as $regex => $query ) {
if ( strpos( $regex, 'attachment' ) || strpos( $query, 'attachment' ) ) {
unset( $rules[ $regex ] );
}
}
return... |
237,816 | <p>I have build a custom post_type with "Resellers" in order to enter my personal reseller items. The "Resellers" post have taxonomies like "Countries" and "Departmens".</p>
<p>I am running into a problem:</p>
<p>The first time that the page is displayed, nothing gets fetched from my custom post type taxonomies. If I... | [
{
"answer_id": 271089,
"author": "Ihor Vorotnov",
"author_id": 47359,
"author_profile": "https://wordpress.stackexchange.com/users/47359",
"pm_score": 4,
"selected": false,
"text": "<p>You can filter default rewrite rules and remove those for attachments:</p>\n\n<pre><code>function clean... | 2016/09/01 | [
"https://wordpress.stackexchange.com/questions/237816",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101256/"
] | I have build a custom post\_type with "Resellers" in order to enter my personal reseller items. The "Resellers" post have taxonomies like "Countries" and "Departmens".
I am running into a problem:
The first time that the page is displayed, nothing gets fetched from my custom post type taxonomies. If I click on one of... | You can filter default rewrite rules and remove those for attachments:
```
function cleanup_default_rewrite_rules( $rules ) {
foreach ( $rules as $regex => $query ) {
if ( strpos( $regex, 'attachment' ) || strpos( $query, 'attachment' ) ) {
unset( $rules[ $regex ] );
}
}
return... |
237,820 | <p>I retrieve information from database postmeta table.
I have 2 custom post type 'book' and 'author' I using metabox to connect them together. when user go to book custom post and adding new book. he must use check box metabox to determined which author write this book.</p>
<p>I have another page in my website which ... | [
{
"answer_id": 237821,
"author": "WordPress Mechanic",
"author_id": 33660,
"author_profile": "https://wordpress.stackexchange.com/users/33660",
"pm_score": 1,
"selected": false,
"text": "<p>Have a look here:</p>\n\n<p><a href=\"https://codex.wordpress.org/Function_Reference/get_post_thum... | 2016/09/01 | [
"https://wordpress.stackexchange.com/questions/237820",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101035/"
] | I retrieve information from database postmeta table.
I have 2 custom post type 'book' and 'author' I using metabox to connect them together. when user go to book custom post and adding new book. he must use check box metabox to determined which author write this book.
I have another page in my website which show autho... | You use the function `get_the_post_thumbnail()` which returns a `string`. So you need to print that string with `echo` or use `the_post_thumbnail()` which echos itself. |
237,827 | <p>How we can get the complete cart details from the order id in woocommerce including the totals and subtotals etc.</p>
| [
{
"answer_id": 237831,
"author": "Annapurna",
"author_id": 98322,
"author_profile": "https://wordpress.stackexchange.com/users/98322",
"pm_score": 2,
"selected": true,
"text": "<p>Try this:</p>\n\n<pre><code><?php\n global $woocommerce;\n $items = $woocommerce->cart->get_c... | 2016/09/01 | [
"https://wordpress.stackexchange.com/questions/237827",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/83446/"
] | How we can get the complete cart details from the order id in woocommerce including the totals and subtotals etc. | Try this:
```
<?php
global $woocommerce;
$items = $woocommerce->cart->get_cart();
?>
``` |
237,833 | <p>I've got a partial called within <code>single.php</code> that looks like this:</p>
<pre><code><?php $userdata = get_userdata($post->post_author) ; ?>
<div class="entry-meta">
<span class="byline author vcard"><?= __('By', 'sage'); ?>
<a href="<?= get_author_posts_url(g... | [
{
"answer_id": 237843,
"author": "WordPress Mechanic",
"author_id": 33660,
"author_profile": "https://wordpress.stackexchange.com/users/33660",
"pm_score": 0,
"selected": false,
"text": "<p><strong>There are two solutions:</strong></p>\n\n<p><strong>1)</strong> Use a variable like this\n... | 2016/09/01 | [
"https://wordpress.stackexchange.com/questions/237833",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51378/"
] | I've got a partial called within `single.php` that looks like this:
```
<?php $userdata = get_userdata($post->post_author) ; ?>
<div class="entry-meta">
<span class="byline author vcard"><?= __('By', 'sage'); ?>
<a href="<?= get_author_posts_url(get_the_author_meta('ID')); ?>" rel="author" class="fn">
... | WordPress caches the user information. There's really no problem just to call `get_userdata` every time you need it. The only thing you are doing by transfering it to a variable `$userdata` is have WP fetch it from another place in the memory.
Note: read [this post](https://wordpress.stackexchange.com/questions/176804... |
237,834 | <p>I set post per page from setting>maximum post per page to 20. I have 2 different custom post types 'book' and 'author' for archives of each of them. I want to load different number of post in page. I want to load 20 book per page in book archive and 5 post in author archive in each page. I also use WP-PageNavi plugi... | [
{
"answer_id": 237847,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 0,
"selected": false,
"text": "<p>You will have to make the query arguments dependend on the type of archive you are generating (which WP already ... | 2016/09/01 | [
"https://wordpress.stackexchange.com/questions/237834",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101035/"
] | I set post per page from setting>maximum post per page to 20. I have 2 different custom post types 'book' and 'author' for archives of each of them. I want to load different number of post in page. I want to load 20 book per page in book archive and 5 post in author archive in each page. I also use WP-PageNavi plugin.
... | add below code in functions.php file , here "event" is custom post type (change it as per your post type) , so here it will display 6 post on events list page , also you need to copy default archive.php file and copy and create new archive-event.php (replace event with your post type).
```
function custom_type_archiv... |
237,854 | <p>I have problem with <code>wp_localize_script</code>, That I cannot get <strong>boolean</strong> and <strong>int</strong> as variable</p>
<pre><code>wp_enqueue_script( 'helloworld' , 'helloworld.js', false, '1.0.0', true);
$site_config = array();
$site_config['boo'] = (bool)true;
$site_config['number'] = (int)1;
... | [
{
"answer_id": 237856,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 2,
"selected": false,
"text": "<h2><em>Why</em> part:</h2>\n\n<p>The <em>Why</em> part can be found within the <code>WP_Scripts::localize()</co... | 2016/09/01 | [
"https://wordpress.stackexchange.com/questions/237854",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6332/"
] | I have problem with `wp_localize_script`, That I cannot get **boolean** and **int** as variable
```
wp_enqueue_script( 'helloworld' , 'helloworld.js', false, '1.0.0', true);
$site_config = array();
$site_config['boo'] = (bool)true;
$site_config['number'] = (int)1;
wp_localize_script( 'helloworld' , 'site_config' , ... | **I just do something like this so long :**
```
wp_add_inline_script('helloworld','var site_config ='.json_encode($site_config));
``` |
237,878 | <p>Sometimes I want to change a post a little bit, but the post was already published on my blog. The change concerns adding/removing tags or rewriting the title of the post (just to correct a misspelled word). All the things can be done using the admin panel by pressing "quick edit".</p>
<p>Unfortunately, the action... | [
{
"answer_id": 237889,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 0,
"selected": false,
"text": "<p>It sounds like you're only displaying this information on the single post view and not making any searches fo... | 2016/09/01 | [
"https://wordpress.stackexchange.com/questions/237878",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70882/"
] | Sometimes I want to change a post a little bit, but the post was already published on my blog. The change concerns adding/removing tags or rewriting the title of the post (just to correct a misspelled word). All the things can be done using the admin panel by pressing "quick edit".
Unfortunately, the action updates th... | The question of how to customize which post data gets updated has been answered [elsewhere on StackExchange](https://wordpress.stackexchange.com/questions/35931/how-can-i-edit-post-data-before-it-is-saved).
Here is a specific example of how to stop the modified date from being updated:
```
function stop_modified_date... |
237,879 | <p>Is it possible to override Javascript in a plugin with a child theme?</p>
<p>Specifically I'm trying to override a portion of a WooCommerce product page - I would like to get rid of the tabbed content areas, and instead have all of the content visible with the "tabs" then being anchor links down the page.</p>
<p>I... | [
{
"answer_id": 237881,
"author": "mmm",
"author_id": 74311,
"author_profile": "https://wordpress.stackexchange.com/users/74311",
"pm_score": 1,
"selected": false,
"text": "<p>You can disable this portion of JavaScript code with this code : </p>\n\n<pre><code>$( 'body' ).off( 'click', '.w... | 2016/09/01 | [
"https://wordpress.stackexchange.com/questions/237879",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85805/"
] | Is it possible to override Javascript in a plugin with a child theme?
Specifically I'm trying to override a portion of a WooCommerce product page - I would like to get rid of the tabbed content areas, and instead have all of the content visible with the "tabs" then being anchor links down the page.
I've figured out h... | You can disable this portion of JavaScript code with this code :
```
$( 'body' ).off( 'click', '.wc-tabs li a, ul.tabs li a');
```
`.off(` detach the listeners : <http://api.jquery.com/off/> |
237,882 | <p>I'm getting a feed error of 'XML parsing error: :[line number]:0: junk after document element'.</p>
<p>Although such errors often seem to be from unwanted code injections, mine is showing 'Cannot modify header information - headers already sent by'... which I've previously had with unwanted white space.</p>
<p>'Wa... | [
{
"answer_id": 237881,
"author": "mmm",
"author_id": 74311,
"author_profile": "https://wordpress.stackexchange.com/users/74311",
"pm_score": 1,
"selected": false,
"text": "<p>You can disable this portion of JavaScript code with this code : </p>\n\n<pre><code>$( 'body' ).off( 'click', '.w... | 2016/09/01 | [
"https://wordpress.stackexchange.com/questions/237882",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63350/"
] | I'm getting a feed error of 'XML parsing error: :[line number]:0: junk after document element'.
Although such errors often seem to be from unwanted code injections, mine is showing 'Cannot modify header information - headers already sent by'... which I've previously had with unwanted white space.
'Warning: Cannot mod... | You can disable this portion of JavaScript code with this code :
```
$( 'body' ).off( 'click', '.wc-tabs li a, ul.tabs li a');
```
`.off(` detach the listeners : <http://api.jquery.com/off/> |
237,886 | <p><strong>I know it's not supposed to work like this and that InstantWP is made for testing and not for an actual website</strong>, but I didn't know it when I started out and after two months of work I just can't throw it all away and start over.</p>
<p><em>Is there any way to transfer what I made on a ftp server ?<... | [
{
"answer_id": 237881,
"author": "mmm",
"author_id": 74311,
"author_profile": "https://wordpress.stackexchange.com/users/74311",
"pm_score": 1,
"selected": false,
"text": "<p>You can disable this portion of JavaScript code with this code : </p>\n\n<pre><code>$( 'body' ).off( 'click', '.w... | 2016/09/01 | [
"https://wordpress.stackexchange.com/questions/237886",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102015/"
] | **I know it's not supposed to work like this and that InstantWP is made for testing and not for an actual website**, but I didn't know it when I started out and after two months of work I just can't throw it all away and start over.
*Is there any way to transfer what I made on a ftp server ?*
I'm a newbie, so please ... | You can disable this portion of JavaScript code with this code :
```
$( 'body' ).off( 'click', '.wc-tabs li a, ul.tabs li a');
```
`.off(` detach the listeners : <http://api.jquery.com/off/> |
237,903 | <p>I've got a Layer 7 Load Balancer setup using HAProxy for WordPress Multisite.</p>
<p>I'm looking to have anything related to the WordPress backend to be served from a specific group of servers (A/K/A anything in <code>/wp-admin/</code>) while serving the frontend of the WordPress websites from another group of serv... | [
{
"answer_id": 238745,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 1,
"selected": false,
"text": "<p>Most of your question seem to be server related and would be off topic here, but here's my five cents on the Wor... | 2016/09/01 | [
"https://wordpress.stackexchange.com/questions/237903",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9579/"
] | I've got a Layer 7 Load Balancer setup using HAProxy for WordPress Multisite.
I'm looking to have anything related to the WordPress backend to be served from a specific group of servers (A/K/A anything in `/wp-admin/`) while serving the frontend of the WordPress websites from another group of servers.
Do I need to ad... | **The problem #1 & #2**:
Don't know why you need to add and validate extra cookies, but for me, it's simple and quite straight forward:
This is what I have tried on vagrant boxes and with default WordPress structure:
**1**. Prepare 6 separate servers
* `111.111.1.10` - MySQL server
* `111.111.1.11` - HAProxy server... |
237,913 | <p>I need to override the 404 code for a very specific scenario and it's not yet fully working.</p>
<p>I am linking day archives with <code>rel=prev/next</code>, and the chain is supposed to be intact start-to-end. For this reason, at least one post needs to be published everyday, best right at midnight. This should n... | [
{
"answer_id": 238745,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 1,
"selected": false,
"text": "<p>Most of your question seem to be server related and would be off topic here, but here's my five cents on the Wor... | 2016/09/01 | [
"https://wordpress.stackexchange.com/questions/237913",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70333/"
] | I need to override the 404 code for a very specific scenario and it's not yet fully working.
I am linking day archives with `rel=prev/next`, and the chain is supposed to be intact start-to-end. For this reason, at least one post needs to be published everyday, best right at midnight. This should not be a problem edito... | **The problem #1 & #2**:
Don't know why you need to add and validate extra cookies, but for me, it's simple and quite straight forward:
This is what I have tried on vagrant boxes and with default WordPress structure:
**1**. Prepare 6 separate servers
* `111.111.1.10` - MySQL server
* `111.111.1.11` - HAProxy server... |
237,947 | <p>My organization has a website powered by wordpress. We are using pagebuilder to design pages. We also have some assets (pdf files, ppts) etc. Currently everyone can access these files. </p>
<p>I need to modify them so that there is some access control. So the first suggestion to provide the access control was “regi... | [
{
"answer_id": 238745,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 1,
"selected": false,
"text": "<p>Most of your question seem to be server related and would be off topic here, but here's my five cents on the Wor... | 2016/09/02 | [
"https://wordpress.stackexchange.com/questions/237947",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102068/"
] | My organization has a website powered by wordpress. We are using pagebuilder to design pages. We also have some assets (pdf files, ppts) etc. Currently everyone can access these files.
I need to modify them so that there is some access control. So the first suggestion to provide the access control was “register” each... | **The problem #1 & #2**:
Don't know why you need to add and validate extra cookies, but for me, it's simple and quite straight forward:
This is what I have tried on vagrant boxes and with default WordPress structure:
**1**. Prepare 6 separate servers
* `111.111.1.10` - MySQL server
* `111.111.1.11` - HAProxy server... |
237,957 | <p>I am trying to fetch a post based on the following meta keys.</p>
<ul>
<li><code>post_code</code> with <code>432C</code></li>
<li><code>location</code> with <code>XYZ</code>
Both belong to a CPT. I'm trying to fetch the Post with both these meta_values. </li>
</ul>
<p>I Don't Want an OR relation, I want a AND rela... | [
{
"answer_id": 237958,
"author": "Manthan Dave",
"author_id": 83209,
"author_profile": "https://wordpress.stackexchange.com/users/83209",
"pm_score": -1,
"selected": false,
"text": "<p>Tried below object parametes</p>\n\n<pre><code>array(\n 'key' => 'post_code',\n ... | 2016/09/02 | [
"https://wordpress.stackexchange.com/questions/237957",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/89206/"
] | I am trying to fetch a post based on the following meta keys.
* `post_code` with `432C`
* `location` with `XYZ`
Both belong to a CPT. I'm trying to fetch the Post with both these meta\_values.
I Don't Want an OR relation, I want a AND relation, I have tried several `WP_Query` objects and still haven't found a solutio... | **SOLUTION**
The Solution Accepted below worked, however, I wanted to know how is it working?
This is how it's working
```
SELECT * FROM wp_posts p, wp_postmeta m1, wp_postmeta m2
WHERE p.ID = m1.post_id and p.ID = m2.post_id
AND m1.meta_key = 'key1' AND m1.meta_value = 'value1'
AND m2.meta_key = 'key2' ... |
237,986 | <p>I have three files: <code>submit.php</code> (a page), <code>validation.php</code>, <code>script.php</code></p>
<p>I am trying to use the fields as a front end submission area via the <code>wp_insert_post()</code> function.</p>
<p>However, I don't know exactly where to put the function, as where I try either is bef... | [
{
"answer_id": 237958,
"author": "Manthan Dave",
"author_id": 83209,
"author_profile": "https://wordpress.stackexchange.com/users/83209",
"pm_score": -1,
"selected": false,
"text": "<p>Tried below object parametes</p>\n\n<pre><code>array(\n 'key' => 'post_code',\n ... | 2016/09/02 | [
"https://wordpress.stackexchange.com/questions/237986",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17411/"
] | I have three files: `submit.php` (a page), `validation.php`, `script.php`
I am trying to use the fields as a front end submission area via the `wp_insert_post()` function.
However, I don't know exactly where to put the function, as where I try either is before the `validation.php` file or if I put it in that file it ... | **SOLUTION**
The Solution Accepted below worked, however, I wanted to know how is it working?
This is how it's working
```
SELECT * FROM wp_posts p, wp_postmeta m1, wp_postmeta m2
WHERE p.ID = m1.post_id and p.ID = m2.post_id
AND m1.meta_key = 'key1' AND m1.meta_value = 'value1'
AND m2.meta_key = 'key2' ... |
238,005 | <p>I've been using an added function to load a modified rss template.
Works fine, but now I need to add a custom template for a CPT.</p>
<p>I have code for each,which works ok, but can't be used together because one over-rides the other.</p>
<p>I don't know enough php to modify.</p>
<p>Here's the code I'm using...</... | [
{
"answer_id": 238022,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>Just combine the logic for the two together. :)</p>\n\n<p>Use a single callback and depending on current context ov... | 2016/09/02 | [
"https://wordpress.stackexchange.com/questions/238005",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63350/"
] | I've been using an added function to load a modified rss template.
Works fine, but now I need to add a custom template for a CPT.
I have code for each,which works ok, but can't be used together because one over-rides the other.
I don't know enough php to modify.
Here's the code I'm using...
```
remove_all_actions( ... | Answering my own question, I’ll add this in case it’s of use to someone.
It seems to work ok with…
```
// This delivers valid feeds, with the correct templates.
remove_all_actions( 'do_feed_rss2' );
add_action( 'do_feed_rss2', function() {
$rss_template = get_template_directory() . '/feeds/item-feed.php';
$rss_templa... |
238,006 | <p>just wondering if anyone came across this: I have a front page featuring artists in a square grid, now the client asks for a switch button to reorder the artist from A-Z (based on artist name) to the conventional newest post first - but this shall happen without reloading the page.</p>
<p>I found a solution with gi... | [
{
"answer_id": 238009,
"author": "EBennett",
"author_id": 91050,
"author_profile": "https://wordpress.stackexchange.com/users/91050",
"pm_score": 1,
"selected": false,
"text": "<p>With WordPress you can utilise a function called <a href=\"https://codex.wordpress.org/Function_Reference/wp... | 2016/09/02 | [
"https://wordpress.stackexchange.com/questions/238006",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/83211/"
] | just wondering if anyone came across this: I have a front page featuring artists in a square grid, now the client asks for a switch button to reorder the artist from A-Z (based on artist name) to the conventional newest post first - but this shall happen without reloading the page.
I found a solution with giving a par... | With WordPress you can utilise a function called [wp\_localize\_script()](https://codex.wordpress.org/Function_Reference/wp_localize_script) which allows you to pass in a script, and a variable you would like that script to have access too.
Perhaps by assigning the new query to a variable, and then accessing it withi... |
238,010 | <p>I've added additional tabs to my product pages within my functions.php file and now need to wrap that in an if statement so the additional tabs only show on products within the category of "Models." I've tried every way of doing it that I can find, and none of them work. They all get rid of the additional tabs on ev... | [
{
"answer_id": 238009,
"author": "EBennett",
"author_id": 91050,
"author_profile": "https://wordpress.stackexchange.com/users/91050",
"pm_score": 1,
"selected": false,
"text": "<p>With WordPress you can utilise a function called <a href=\"https://codex.wordpress.org/Function_Reference/wp... | 2016/09/02 | [
"https://wordpress.stackexchange.com/questions/238010",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85805/"
] | I've added additional tabs to my product pages within my functions.php file and now need to wrap that in an if statement so the additional tabs only show on products within the category of "Models." I've tried every way of doing it that I can find, and none of them work. They all get rid of the additional tabs on every... | With WordPress you can utilise a function called [wp\_localize\_script()](https://codex.wordpress.org/Function_Reference/wp_localize_script) which allows you to pass in a script, and a variable you would like that script to have access too.
Perhaps by assigning the new query to a variable, and then accessing it withi... |
238,011 | <p>I had been assuming that <code>ID</code> in <code>wp_posts</code> is the primary key and that <code>post_id</code> in <code>wp_postmeta</code> is the foreign key but there is no relationship between them.</p>
<p>How does these two tables relate each other? There is a <code>meta_key</code> and <code>meta_value</code... | [
{
"answer_id": 238020,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 2,
"selected": false,
"text": "<p>The <code>post_id</code> column in the <code>wp_postmeta</code> table <em>is</em> a reference to the <code>... | 2016/09/02 | [
"https://wordpress.stackexchange.com/questions/238011",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102107/"
] | I had been assuming that `ID` in `wp_posts` is the primary key and that `post_id` in `wp_postmeta` is the foreign key but there is no relationship between them.
How does these two tables relate each other? There is a `meta_key` and `meta_value` column where `meta_key` data are `_sku`, `_price`, and `_stock`. How can I... | The `post_id` column in the `wp_postmeta` table *is* a reference to the `ID` column in the `wp_posts` table.
I'd suggest using the native [update\_post\_meta()](https://codex.wordpress.org/Function_Reference/update_post_meta) function in WordPress to update the meta data.
E.g. (Post ID is 123 in this example, and we'... |
238,038 | <p>I have recently add this function found in <a href="https://wordpress.stackexchange.com/questions/89767/how-to-increase-the-character-limit-for-post-name-of-200">this post</a> to increase my posts title limit of charcters from 200 to custom length, the problem now is that when I click publish, the posts are saved as... | [
{
"answer_id": 238042,
"author": "iyrin",
"author_id": 33393,
"author_profile": "https://wordpress.stackexchange.com/users/33393",
"pm_score": 1,
"selected": false,
"text": "<p>You simply need to copy the current function <code>sanitize_title_with_dashes</code> from <a href=\"https://cor... | 2016/09/02 | [
"https://wordpress.stackexchange.com/questions/238038",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/98757/"
] | I have recently add this function found in [this post](https://wordpress.stackexchange.com/questions/89767/how-to-increase-the-character-limit-for-post-name-of-200) to increase my posts title limit of charcters from 200 to custom length, the problem now is that when I click publish, the posts are saved as drafts and I ... | You simply need to copy the current function `sanitize_title_with_dashes` from <https://core.trac.wordpress.org/browser/tags/4.6/src/wp-includes/formatting.php#L1948> and change the following line:
```
$title = utf8_uri_encode($title, 200);
```
To this:
```
$title = utf8_uri_encode($title, 1000);
```
**Minor ed... |
238,039 | <p>I'm wondering how to change the admin theme based on a user's role. Currently I can change the admin theme using a plugin (ex: <a href="https://wordpress.org/plugins/blue-admin/" rel="nofollow">Blue Admin</a>) - but I'm not sure how to make those changes based on a role (subscriber etc).</p>
<p>Would also like to ... | [
{
"answer_id": 238041,
"author": "Jeremy Ross",
"author_id": 102007,
"author_profile": "https://wordpress.stackexchange.com/users/102007",
"pm_score": 0,
"selected": false,
"text": "<p>The admin color scheme is stored in <code>user_meta</code> as <code>admin_color</code> (default is '<em... | 2016/09/02 | [
"https://wordpress.stackexchange.com/questions/238039",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41269/"
] | I'm wondering how to change the admin theme based on a user's role. Currently I can change the admin theme using a plugin (ex: [Blue Admin](https://wordpress.org/plugins/blue-admin/)) - but I'm not sure how to make those changes based on a role (subscriber etc).
Would also like to have specific menu items / etc shown ... | You can ~~set~~ force a specific Admin Color Scheme pro user role through a function.
*Personally I would first take away the option to select the scheme from profile.php (Back-end Users/Your Profile)*
Below is just an example function which does set a specific color scheme for specific user roles.
*Please mak... |
238,057 | <pre><code>function dwwp_admin_enqueue_scripts_mlm() {
wp_enqueue_style( 'dwwp-admin-css', plugins_url( 'css/admin-users.css', __FILE__ ) );
wp_enqueue_script( 'admin-users', plugins_url( 'js/admin-users.js', __FILE__ ) );
wp_enqueue_script( 'jquery', 'http://code.jquery.com/jquery-1.10.2.js' );
... | [
{
"answer_id": 238068,
"author": "theodorhanu",
"author_id": 36255,
"author_profile": "https://wordpress.stackexchange.com/users/36255",
"pm_score": 1,
"selected": true,
"text": "<p>No. As wordpress codex states, you should use jquery and other javascript files provided by them. As for c... | 2016/09/03 | [
"https://wordpress.stackexchange.com/questions/238057",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101387/"
] | ```
function dwwp_admin_enqueue_scripts_mlm() {
wp_enqueue_style( 'dwwp-admin-css', plugins_url( 'css/admin-users.css', __FILE__ ) );
wp_enqueue_script( 'admin-users', plugins_url( 'js/admin-users.js', __FILE__ ) );
wp_enqueue_script( 'jquery', 'http://code.jquery.com/jquery-1.10.2.js' );
wp_enq... | No. As wordpress codex states, you should use jquery and other javascript files provided by them. As for css files I think you can use yours.
Please check [this link](https://developer.wordpress.org/reference/functions/wp_enqueue_script/)( scroll down) for a list of already defined javascript files.
Also, you have to... |
238,107 | <p>I am using WordPress Media Library in my plugin in the backend. How to change the upload path for it dynamically? Can it be done during the enqueue, or when creating it in JavaScript?</p>
<p>I am using <code>wp_enqueue_media()</code> in <code>admin_enqueue_scripts</code> action, and later creating the media frame i... | [
{
"answer_id": 238979,
"author": "Aniruddha Gawade",
"author_id": 101818,
"author_profile": "https://wordpress.stackexchange.com/users/101818",
"pm_score": 1,
"selected": false,
"text": "<p>Might wanna look at</p>\n\n<p><a href=\"https://developer.wordpress.org/reference/functions/wp_upl... | 2016/09/03 | [
"https://wordpress.stackexchange.com/questions/238107",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75841/"
] | I am using WordPress Media Library in my plugin in the backend. How to change the upload path for it dynamically? Can it be done during the enqueue, or when creating it in JavaScript?
I am using `wp_enqueue_media()` in `admin_enqueue_scripts` action, and later creating the media frame in Javascript using `wp.media`.
... | Might wanna look at
<https://developer.wordpress.org/reference/functions/wp_upload_dir/>
In definition there is a hook `upload_dir`, you can use that to change `path`.
Haven't tried or tested it, but you can give it a try. |
238,129 | <p>I am trying to access post meta for custom post type and taxonomy using WP_Query and then query the posts with that specific post meta.
<br />
So far I have tied the following code:</p>
<pre><code>$hot_args = array(
'post_type' => 'video',
'posts_per_page' ... | [
{
"answer_id": 238115,
"author": "rayrutjes",
"author_id": 99248,
"author_profile": "https://wordpress.stackexchange.com/users/99248",
"pm_score": 2,
"selected": false,
"text": "<p>Moving a WordPress website is fairly easy, here are the steps:</p>\n\n<ul>\n<li>Backup your mysql database ... | 2016/09/04 | [
"https://wordpress.stackexchange.com/questions/238129",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/76334/"
] | I am trying to access post meta for custom post type and taxonomy using WP\_Query and then query the posts with that specific post meta.
So far I have tied the following code:
```
$hot_args = array(
'post_type' => 'video',
'posts_per_page' => '6',
... | Moving a WordPress website is fairly easy, here are the steps:
* Backup your mysql database and re-import it in the new environment,
* Move all the files to the new environment,
* Update the `wp-config.php` file to reflect the new database connection information,
* (\*)Replace all occurrences of your domain name with ... |
238,141 | <p>I am Creating a Multi row , 2 Columns blog Post like this </p>
<pre><code>Post #1 | Post #4
Post #2 | Post #5
Post #3 | Post #6
</code></pre>
<p>I have found some post useful</p>
<p><a href="https://digwp.com/2010/03/wordpress-post-content-multiple-columns/" rel="nofollow noreferrer">https://digwp.co... | [
{
"answer_id": 238115,
"author": "rayrutjes",
"author_id": 99248,
"author_profile": "https://wordpress.stackexchange.com/users/99248",
"pm_score": 2,
"selected": false,
"text": "<p>Moving a WordPress website is fairly easy, here are the steps:</p>\n\n<ul>\n<li>Backup your mysql database ... | 2016/09/04 | [
"https://wordpress.stackexchange.com/questions/238141",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102175/"
] | I am Creating a Multi row , 2 Columns blog Post like this
```
Post #1 | Post #4
Post #2 | Post #5
Post #3 | Post #6
```
I have found some post useful
<https://digwp.com/2010/03/wordpress-post-content-multiple-columns/>
Based on the post I have Created Code as follows
```
<?php
// Some sample styles ... | Moving a WordPress website is fairly easy, here are the steps:
* Backup your mysql database and re-import it in the new environment,
* Move all the files to the new environment,
* Update the `wp-config.php` file to reflect the new database connection information,
* (\*)Replace all occurrences of your domain name with ... |
238,146 | <p>I have 2 taxonomy sets <strong><code>product_cat</code></strong> and <strong><code>tvshows_cat</code></strong>.</p>
<p>There are 12 terms for each of them. A product may get 1 or 12 terms applied.</p>
<p>I use this code to show the term list in the product page:</p>
<pre>
$cats = get_the_term_list($post->ID, 'pro... | [
{
"answer_id": 238149,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 0,
"selected": false,
"text": "<p>We can limit the number of displayed terms with</p>\n\n<pre><code>// Add filter\nadd_filter( 'get_the_terms',... | 2016/09/04 | [
"https://wordpress.stackexchange.com/questions/238146",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101903/"
] | I have 2 taxonomy sets **`product_cat`** and **`tvshows_cat`**.
There are 12 terms for each of them. A product may get 1 or 12 terms applied.
I use this code to show the term list in the product page:
```
$cats = get_the_term_list($post->ID, 'product_cat', '', ' ', '');
$tvcats = get_the_term_list($post->ID, 'tvs... | >
> **Instead using `get_the_term_list()` function, you should use `get_the_terms()` which will give you directly an array of terms** *(as `get_the_term_list()` is using `get_the_terms()` herself if you look to the source code of the function)*.
>
>
>
Then that you can build a **custom function** to get what you ... |
238,170 | <p>So i'm working on a plugin where I assign a default avatar to anyone that comments. The line i'm stuck on contains a theme directory reference but I want to reference the image in the plugin directory instead. Thanks in advance!</p>
<pre><code>$new_avatar_url = get_bloginfo( 'plugin_directory' ) . '/avatar-1.jpg';
... | [
{
"answer_id": 238172,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 3,
"selected": true,
"text": "<p>Try <a href=\"https://codex.wordpress.org/Function_Reference/plugin_dir_url\" rel=\"nofollow\"><code>plugin_... | 2016/09/04 | [
"https://wordpress.stackexchange.com/questions/238170",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102192/"
] | So i'm working on a plugin where I assign a default avatar to anyone that comments. The line i'm stuck on contains a theme directory reference but I want to reference the image in the plugin directory instead. Thanks in advance!
```
$new_avatar_url = get_bloginfo( 'plugin_directory' ) . '/avatar-1.jpg';
``` | Try [`plugin_dir_url()`](https://codex.wordpress.org/Function_Reference/plugin_dir_url):
```
$new_avatar_url = plugin_dir_url( __FILE__ ) . '/avatar-1.jpg';
``` |
238,191 | <p>We have a section on the homepage where we'd like to show a different (random) post every 3 days.</p>
<p>I'm trying to figure out a way to do it. This would give us a weekly post, but I don't know how to get a post every 3 days...:</p>
<pre><code><?php
global $post;
$args = array(
... | [
{
"answer_id": 238188,
"author": "Ethan O'Sullivan",
"author_id": 98212,
"author_profile": "https://wordpress.stackexchange.com/users/98212",
"pm_score": 3,
"selected": true,
"text": "<p>No script of function necessary. It's actually built into WordPress. Simply go to your page to edit a... | 2016/09/04 | [
"https://wordpress.stackexchange.com/questions/238191",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/23411/"
] | We have a section on the homepage where we'd like to show a different (random) post every 3 days.
I'm trying to figure out a way to do it. This would give us a weekly post, but I don't know how to get a post every 3 days...:
```
<?php
global $post;
$args = array(
'post_type' =>... | No script of function necessary. It's actually built into WordPress. Simply go to your page to edit and on the right hand side you should see a widget labeled *Publish*.
On the third line down, you will see an *Edit* button and you can set the date and time on when you want the page to be shown:
) {\n\n$thiscat = get_category( get_... | 2016/09/05 | [
"https://wordpress.stackexchange.com/questions/238210",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/68414/"
] | I'm trying to display a list of categories in a PHP enabled text widget. On child category pages I need to get the id of the current category's parent category and then use that to return a list of all that category's child categories except the current category.
I tried the following code but it's not working:
```
<... | I now realize there's an easier way to do this:
```
<?php if (is_category( )) {
$thiscat = get_category( get_query_var( 'cat' ) );
$catid = $thiscat->cat_ID;
$parent = $thiscat->category_parent;
if (!empty ($parent) ) {
//child category pages
$catlist = get_categori... |
238,235 | <p>I'm trying to change the stylesheet for specific page/post while viewing in frontend, but I can't find the hook or filter for doing that ..</p>
<p>I've tried many hooks and pages and it doesn't work</p>
<p>Should I use <code>page_css_class</code> ?</p>
<pre><code>apply_filters( 'page_css_class', array $css_class,... | [
{
"answer_id": 238236,
"author": "Nathan Powell",
"author_id": 27196,
"author_profile": "https://wordpress.stackexchange.com/users/27196",
"pm_score": 0,
"selected": false,
"text": "<p>Look around for \"child theme\" of the theme you are using. Create something new. The basics for child ... | 2016/09/05 | [
"https://wordpress.stackexchange.com/questions/238235",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102188/"
] | I'm trying to change the stylesheet for specific page/post while viewing in frontend, but I can't find the hook or filter for doing that ..
I've tried many hooks and pages and it doesn't work
Should I use `page_css_class` ?
```
apply_filters( 'page_css_class', array $css_class, WP_Post $page, int $depth, array $args... | The filter [`page_css_class`](https://developer.wordpress.org/reference/hooks/page_css_class/) allows you to change the classes on all pages, when they are listed. This is not what you are looking for.
In stead, you'll want to enqueue different style sheets for different posts/pages. This you can do using conditionals... |
238,271 | <p>I have a custom post type of people with some custom taxonomy boxes, i want to hide these when on child pages. I have found remove_meta_box works fine but i just can't access the $post object within the action.</p>
<p>Currently i have</p>
<pre><code>function remove_post_custom_fields($post) {
global $post;
if(... | [
{
"answer_id": 238255,
"author": "montrealist",
"author_id": 8105,
"author_profile": "https://wordpress.stackexchange.com/users/8105",
"pm_score": 3,
"selected": true,
"text": "<p>Newer hosting providers that cater specifically to WordPress usually have tools in place to ease this pain. ... | 2016/09/05 | [
"https://wordpress.stackexchange.com/questions/238271",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/6123/"
] | I have a custom post type of people with some custom taxonomy boxes, i want to hide these when on child pages. I have found remove\_meta\_box works fine but i just can't access the $post object within the action.
Currently i have
```
function remove_post_custom_fields($post) {
global $post;
if( count($post->ances... | Newer hosting providers that cater specifically to WordPress usually have tools in place to ease this pain. I put my clients on Pantheon which has this [neat Git-enabled workflow](https://pantheon.io/docs/pantheon-workflow/), where code only moves up (from dev to staging to production) and DB stuff only moves down (vic... |
238,293 | <p>Similar to generating an array of the admin menu/submenu:</p>
<pre><code>global $menu;
foreach ( $menu as $group => $item ) {
echo '<pre>'; print_r( $item ); echo '</pre>';
}
</code></pre>
<p>How can I get an array of all of the available menu items in the toolbar? I tried using the <code>global $... | [
{
"answer_id": 238295,
"author": "Syed Fakhar Abbas",
"author_id": 90591,
"author_profile": "https://wordpress.stackexchange.com/users/90591",
"pm_score": 2,
"selected": false,
"text": "<p>There is an action hook <a href=\"https://developer.wordpress.org/?s=admin_bar_menu\" rel=\"nofollo... | 2016/09/05 | [
"https://wordpress.stackexchange.com/questions/238293",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/98212/"
] | Similar to generating an array of the admin menu/submenu:
```
global $menu;
foreach ( $menu as $group => $item ) {
echo '<pre>'; print_r( $item ); echo '</pre>';
}
```
How can I get an array of all of the available menu items in the toolbar? I tried using the `global $wp_admin_bar` variable, but that seems to no... | There is an action hook [admin\_bar\_menu](https://developer.wordpress.org/?s=admin_bar_menu) which will provide you an array of admin bar menu items.
```
add_action('admin_bar_menu', 'get_admin_bar_header_array');
public function get_admin_bar_header_array($admin_bar){
print_r($admin_bar);
}
... |
238,314 | <p>I want to include a json manifest file in wordpress plugin but don't know how,
this is the file that i want to include in my plugin with <code>rel=manifest</code> and <code>href=manifest.json</code></p>
<p><code><link rel="manifest" href="/manifest.json"></code></p>
<p>How to do this in plugin ?</p>
| [
{
"answer_id": 238319,
"author": "user3114253",
"author_id": 76325,
"author_profile": "https://wordpress.stackexchange.com/users/76325",
"pm_score": 2,
"selected": false,
"text": "<p>Include this in you plugin</p>\n\n<pre><code>add_action( 'wp_head', 'inc_manifest_link' );\n\n// Creates ... | 2016/09/06 | [
"https://wordpress.stackexchange.com/questions/238314",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102268/"
] | I want to include a json manifest file in wordpress plugin but don't know how,
this is the file that i want to include in my plugin with `rel=manifest` and `href=manifest.json`
`<link rel="manifest" href="/manifest.json">`
How to do this in plugin ? | Include this in you plugin
```
add_action( 'wp_head', 'inc_manifest_link' );
// Creates the link tag
function inc_manifest_link() {
echo '<link rel="manifest" href="/manifest.json">';
}
```
what we are doing here is adding a hook to wp\_head action. |
238,330 | <p>I tried the example in this link <a href="https://codex.wordpress.org/Function_Reference/wp_embed_register_handler" rel="nofollow">https://codex.wordpress.org/Function_Reference/wp_embed_register_handler</a> but it didn't work. This is my whole code:</p>
<pre><code>add_action('init', function() {
wp_embed_regis... | [
{
"answer_id": 238351,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>I modified the example you posted from the Codex:</p>\n\n<pre><code>/**\n * Embed support for Forbes videos\n ... | 2016/09/06 | [
"https://wordpress.stackexchange.com/questions/238330",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102275/"
] | I tried the example in this link <https://codex.wordpress.org/Function_Reference/wp_embed_register_handler> but it didn't work. This is my whole code:
```
add_action('init', function() {
wp_embed_register_handler( 'forbes', '#http://(?:www|video)\.forbes\.com/(?:video/embed/embed\.html|embedvideo/)\?show=([\d]+)&f... | I modified the example you posted from the Codex:
```
/**
* Embed support for Forbes videos
*
* Usage Example:
*
* http://www.forbes.com/video/5049647995001/
*/
add_action( 'init', function()
{
wp_embed_register_handler(
'forbes',
'#http://www\.forbes\.com/video/([\d]+)/?#i',
'... |
238,347 | <p>I have many duplicated post and I wanted remove them but Google already indexed them. So the idea is redirect all post with pattern [-number] in the end of the url to the same URL without number</p>
<p><code>www.domain.com/category/post-title[-number]</code> to <code>www.domain.com/category/post-title</code></p>
<... | [
{
"answer_id": 238354,
"author": "mmm",
"author_id": 74311,
"author_profile": "https://wordpress.stackexchange.com/users/74311",
"pm_score": 0,
"selected": false,
"text": "<p>you can test this in the 404 template and do a redirection </p>\n\n<p>try this : </p>\n\n<pre><code>add_filter(\"... | 2016/09/06 | [
"https://wordpress.stackexchange.com/questions/238347",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65640/"
] | I have many duplicated post and I wanted remove them but Google already indexed them. So the idea is redirect all post with pattern [-number] in the end of the url to the same URL without number
`www.domain.com/category/post-title[-number]` to `www.domain.com/category/post-title`
Example:
```
www.domain.com/category... | You're close. Add the following to your `.htaccess` file in between the `<IfModule mod_rewrite.c>` tags that were created by WordPress:
```
RewriteCond %{HTTP_HOST}
RewriteRule ^(.+)-[0-9]+/$ /$1 [R=301]
```
Your `.htaccess` should looks like the following if it hasn't been modified by another plugin:
```
# BEGIN W... |
238,359 | <p>I tried to figure out how to separate the custom post type taxonomies.</p>
<pre><code>$terms = get_the_terms( $post->ID , array( 'commitments', 'type' ) );
foreach ( $terms as $term ) {
$term_link = get_term_link( $term, array( 'commitments', 'type' ) );
if( is_wp_error( $term_link ) )
contin... | [
{
"answer_id": 238362,
"author": "Dexter0015",
"author_id": 62134,
"author_profile": "https://wordpress.stackexchange.com/users/62134",
"pm_score": 4,
"selected": true,
"text": "<p>You can use a counter to determine if you need to add a comma or not :</p>\n\n<pre><code>$terms = get_the_t... | 2016/09/06 | [
"https://wordpress.stackexchange.com/questions/238359",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35253/"
] | I tried to figure out how to separate the custom post type taxonomies.
```
$terms = get_the_terms( $post->ID , array( 'commitments', 'type' ) );
foreach ( $terms as $term ) {
$term_link = get_term_link( $term, array( 'commitments', 'type' ) );
if( is_wp_error( $term_link ) )
continue;
echo ... | You can use a counter to determine if you need to add a comma or not :
```
$terms = get_the_terms( $post->ID , array( 'commitments', 'type' ) );
// init counter
$i = 1;
foreach ( $terms as $term ) {
$term_link = get_term_link( $term, array( 'commitments', 'type' ) );
if( is_wp_error( $term_link ) )
... |
238,383 | <p>My feed uses the excerpt, and I want to remove a line of code containing an image.</p>
<p>Example format is...</p>
<pre><code><img class="pagehead" src="/graphics/magazine/307/1.jpg" alt="" />
</code></pre>
| [
{
"answer_id": 238384,
"author": "Dexter0015",
"author_id": 62134,
"author_profile": "https://wordpress.stackexchange.com/users/62134",
"pm_score": 1,
"selected": false,
"text": "<p>You can <a href=\"https://codex.wordpress.org/Customizing_Feeds\" rel=\"nofollow\">customize your feed lik... | 2016/09/06 | [
"https://wordpress.stackexchange.com/questions/238383",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63350/"
] | My feed uses the excerpt, and I want to remove a line of code containing an image.
Example format is...
```
<img class="pagehead" src="/graphics/magazine/307/1.jpg" alt="" />
``` | UPDATE...
Answering my own question, I'll add this in the hope it'll be useful to someone...
Whilst waiting for answers, I found a solution which seems to work fine.
```
function remove_images( $the_excerpt_rss ) {
$postOutput = preg_replace('/<img[^>]+./','', $the_excerpt_rss);
return $postOutput;}
add_filter( 'the... |
238,386 | <p>I downgraded to MAMP after trying MAMP pro, everything is fine except some of the links don’t have localhost port; eg…localhost/about, when it should be localhost:8888/about. Some of the links include the port, and some don’t, but I’m not sure why? Any ideas would be greatly appreciated. Thanks!</p>
| [
{
"answer_id": 238384,
"author": "Dexter0015",
"author_id": 62134,
"author_profile": "https://wordpress.stackexchange.com/users/62134",
"pm_score": 1,
"selected": false,
"text": "<p>You can <a href=\"https://codex.wordpress.org/Customizing_Feeds\" rel=\"nofollow\">customize your feed lik... | 2016/09/06 | [
"https://wordpress.stackexchange.com/questions/238386",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102305/"
] | I downgraded to MAMP after trying MAMP pro, everything is fine except some of the links don’t have localhost port; eg…localhost/about, when it should be localhost:8888/about. Some of the links include the port, and some don’t, but I’m not sure why? Any ideas would be greatly appreciated. Thanks! | UPDATE...
Answering my own question, I'll add this in the hope it'll be useful to someone...
Whilst waiting for answers, I found a solution which seems to work fine.
```
function remove_images( $the_excerpt_rss ) {
$postOutput = preg_replace('/<img[^>]+./','', $the_excerpt_rss);
return $postOutput;}
add_filter( 'the... |
238,395 | <p>I'm converting an existing website to a WordPress theme. One of the pages is a gallery that uses JS <code>history.pushState</code> to create unique URLs for loading certain images. </p>
<p>E.g. page URL (non WP website): <code>http://www.good-deeds-day.org/gallery/</code></p>
<p>URL for a certain image: <code>http... | [
{
"answer_id": 238399,
"author": "Rarst",
"author_id": 847,
"author_profile": "https://wordpress.stackexchange.com/users/847",
"pm_score": 0,
"selected": false,
"text": "<p>But from your description it's <em>not</em> an URL to a gallery, but individual image of one. I would guess it shou... | 2016/09/06 | [
"https://wordpress.stackexchange.com/questions/238395",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102311/"
] | I'm converting an existing website to a WordPress theme. One of the pages is a gallery that uses JS `history.pushState` to create unique URLs for loading certain images.
E.g. page URL (non WP website): `http://www.good-deeds-day.org/gallery/`
URL for a certain image: `http://www.good-deeds-day.org/gallery/img-35`
I... | I ended up using add\_rewrite\_rule:
```
function bones_rewrite_rules() {
$gallery_page_id = 395;
add_rewrite_rule('^gallery/img-.*', 'index.php?page_id=' . $gallery_page_id, 'top');
}
add_action('init', 'bones_rewrite_rules');
``` |
238,403 | <p>Creating first wp plugin.</p>
<p>Using add action init with filter for the_content</p>
<p>I noticed that whenever I echo anything it appears twice in the header, and finally once in the body.</p>
<p>Why?</p>
<p>Or How can I avoid this?</p>
<p>kthxbai</p>
<p><strong>EDIT</strong> </p>
<pre><code>function my_mo... | [
{
"answer_id": 238438,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 2,
"selected": true,
"text": "<p>I do not believe that the root issue exists within the code provided. I tested an even further reduced test ... | 2016/09/06 | [
"https://wordpress.stackexchange.com/questions/238403",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/87622/"
] | Creating first wp plugin.
Using add action init with filter for the\_content
I noticed that whenever I echo anything it appears twice in the header, and finally once in the body.
Why?
Or How can I avoid this?
kthxbai
**EDIT**
```
function my_module_init() {
//Filter this content
add_filter('the_content', 'm... | I do not believe that the root issue exists within the code provided. I tested an even further reduced test case which I've pasted below, and I do not get duplicated content:
```
function my_module_init() {
add_filter('the_content', 'my_content_ctrlr');
}
add_action('init', 'my_module_init');
function my_content_ct... |
238,422 | <p>As a plugin developer, I want to ensure that my plugin doesn't leave any custom settings left behind from my plugin when upgrading from <code>v1.0</code> to <code>v2.0</code>.</p>
<p>Whenever a user uninstalls my plugin, I've created an <a href="https://developer.wordpress.org/plugins/the-basics/uninstall-methods/"... | [
{
"answer_id": 238438,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 2,
"selected": true,
"text": "<p>I do not believe that the root issue exists within the code provided. I tested an even further reduced test ... | 2016/09/06 | [
"https://wordpress.stackexchange.com/questions/238422",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/98212/"
] | As a plugin developer, I want to ensure that my plugin doesn't leave any custom settings left behind from my plugin when upgrading from `v1.0` to `v2.0`.
Whenever a user uninstalls my plugin, I've created an [`uninstall.php`](https://developer.wordpress.org/plugins/the-basics/uninstall-methods/) file (standard practic... | I do not believe that the root issue exists within the code provided. I tested an even further reduced test case which I've pasted below, and I do not get duplicated content:
```
function my_module_init() {
add_filter('the_content', 'my_content_ctrlr');
}
add_action('init', 'my_module_init');
function my_content_ct... |
238,461 | <p>I'm using the Toolset Types plugin to create various custom posts and custom taxonomies. </p>
<p>I have 2 custom post types (Schools, and Productions) that share a common taxonomy (School Subjects). However, on the Schools edit page, I want the title of that taxonomy meta box to say "Subject Wishlist", while leavin... | [
{
"answer_id": 238560,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 2,
"selected": true,
"text": "<p>There is a filter called <code>register_taxonomy_args</code> in WP v4.4 that's a big help here. This tested ... | 2016/09/07 | [
"https://wordpress.stackexchange.com/questions/238461",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1118/"
] | I'm using the Toolset Types plugin to create various custom posts and custom taxonomies.
I have 2 custom post types (Schools, and Productions) that share a common taxonomy (School Subjects). However, on the Schools edit page, I want the title of that taxonomy meta box to say "Subject Wishlist", while leaving the defa... | There is a filter called `register_taxonomy_args` in WP v4.4 that's a big help here. This tested and working example assumes that the post types `schools` and `productions` have already been created.
```
/**
* Filter the arguments for registering a taxonomy.
*
* @since 4.4.0
*
* @param array $args Array o... |
238,477 | <p>I know we have the following command available in <code>WP-CLI</code> to remove transients</p>
<pre><code># Delete all transients
$ wp transient delete-all
</code></pre>
<p>However, my question is does it remove transients on all sites over multi sites? If not how can we remove transients on all sites?</p>
| [
{
"answer_id": 238560,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 2,
"selected": true,
"text": "<p>There is a filter called <code>register_taxonomy_args</code> in WP v4.4 that's a big help here. This tested ... | 2016/09/07 | [
"https://wordpress.stackexchange.com/questions/238477",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101396/"
] | I know we have the following command available in `WP-CLI` to remove transients
```
# Delete all transients
$ wp transient delete-all
```
However, my question is does it remove transients on all sites over multi sites? If not how can we remove transients on all sites? | There is a filter called `register_taxonomy_args` in WP v4.4 that's a big help here. This tested and working example assumes that the post types `schools` and `productions` have already been created.
```
/**
* Filter the arguments for registering a taxonomy.
*
* @since 4.4.0
*
* @param array $args Array o... |
238,530 | <p>I have a custom <code>WP_Users_Query</code> that I have been using on a site.</p>
<p>It has worked fine for a while. I went to add some pagination to the query using the <code>number</code> parameter <a href="https://codex.wordpress.org/Class_Reference/WP_User_Query#Pagination_Parameters" rel="nofollow">as per the ... | [
{
"answer_id": 238504,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 3,
"selected": true,
"text": "<p><code>$_SERVER['REQUEST_URI']</code> is your only option. wordpress failed parsing the url so not much yo... | 2016/09/07 | [
"https://wordpress.stackexchange.com/questions/238530",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102389/"
] | I have a custom `WP_Users_Query` that I have been using on a site.
It has worked fine for a while. I went to add some pagination to the query using the `number` parameter [as per the docs here](https://codex.wordpress.org/Class_Reference/WP_User_Query#Pagination_Parameters). But for some reason, when I add that parame... | `$_SERVER['REQUEST_URI']` is your only option. wordpress failed parsing the url so not much you can get from the API |
238,535 | <p>I'm using the <a href="https://wordpress.org/plugins/cpt-onomies/" rel="nofollow">CPT-onomies plugin</a> to make a CPT into a taxonomy. I have a hero image CPT (created with <em>CPT-onomies</em>) and the hero images post type is attached to the page post type. This allows me to select a hero image post that will be ... | [
{
"answer_id": 238543,
"author": "Jeremy Ross",
"author_id": 102007,
"author_profile": "https://wordpress.stackexchange.com/users/102007",
"pm_score": 0,
"selected": false,
"text": "<p>I think the problem lies with this line:</p>\n\n<p><code>$hero_image_id = isset( $post_parent ) &&a... | 2016/09/07 | [
"https://wordpress.stackexchange.com/questions/238535",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/83438/"
] | I'm using the [CPT-onomies plugin](https://wordpress.org/plugins/cpt-onomies/) to make a CPT into a taxonomy. I have a hero image CPT (created with *CPT-onomies*) and the hero images post type is attached to the page post type. This allows me to select a hero image post that will be a term of a page post. All of this i... | I ended up using the `wp_get_object_terms()` function instead of `get_the_terms()`. The `get_the_terms()` function attempts to cache the terms where `wp_get_object_terms()` does not.
The fixed code to get the hero images CPT's ID is:
```
$hero_image_id = ( $assigned_hero_images = wp_get_object_terms( $post_parent, '... |
238,547 | <p>I want to dequeue a script ('enterprise-responsive-menu'), but the function I have in my template does not do that. Does anything look wrong? </p>
<p>Here is the enqueue in functions.php-</p>
<pre><code>//* Enqueue Scripts
add_action( 'wp_enqueue_scripts', 'enterprise_load_scripts' );
function enterprise_load_scr... | [
{
"answer_id": 238549,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 3,
"selected": true,
"text": "<p>Move your <code>project_dequeue_unnecessary_scripts()</code> function to your <code>functions.php</code> fil... | 2016/09/07 | [
"https://wordpress.stackexchange.com/questions/238547",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102397/"
] | I want to dequeue a script ('enterprise-responsive-menu'), but the function I have in my template does not do that. Does anything look wrong?
Here is the enqueue in functions.php-
```
//* Enqueue Scripts
add_action( 'wp_enqueue_scripts', 'enterprise_load_scripts' );
function enterprise_load_scripts() {
wp_enqueue_... | Move your `project_dequeue_unnecessary_scripts()` function to your `functions.php` file and add a conditional statement to determine if the appropriate template is being loaded. E.g.:
```
// Remove Mobile Header
function project_dequeue_unnecessary_scripts() {
if ( is_page_template( 'name-of-template.php' ) ) {
... |
238,555 | <p>I set up and configured a WordPress site using WooCommerce. When I was developing, I imported the dummy data for testing.</p>
<p>How can I remove the dummy data to delivery?</p>
| [
{
"answer_id": 238549,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 3,
"selected": true,
"text": "<p>Move your <code>project_dequeue_unnecessary_scripts()</code> function to your <code>functions.php</code> fil... | 2016/09/08 | [
"https://wordpress.stackexchange.com/questions/238555",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/83673/"
] | I set up and configured a WordPress site using WooCommerce. When I was developing, I imported the dummy data for testing.
How can I remove the dummy data to delivery? | Move your `project_dequeue_unnecessary_scripts()` function to your `functions.php` file and add a conditional statement to determine if the appropriate template is being loaded. E.g.:
```
// Remove Mobile Header
function project_dequeue_unnecessary_scripts() {
if ( is_page_template( 'name-of-template.php' ) ) {
... |
238,587 | <p>I am configuring Git along with my WP development environment, and I was wondering what should be tracked and what should be ignored. If it makes sense to track plugins and for WP core. Create one repo for both theme & plugins?</p>
<p>Common sense would suggest that tracking WP as a whole, is overkill and unuse... | [
{
"answer_id": 238592,
"author": "Kenya Sullivan",
"author_id": 92563,
"author_profile": "https://wordpress.stackexchange.com/users/92563",
"pm_score": 2,
"selected": false,
"text": "<p>This is subjective and depends on what you are trying to achieve. A theme developer may have a differe... | 2016/09/08 | [
"https://wordpress.stackexchange.com/questions/238587",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1210/"
] | I am configuring Git along with my WP development environment, and I was wondering what should be tracked and what should be ignored. If it makes sense to track plugins and for WP core. Create one repo for both theme & plugins?
Common sense would suggest that tracking WP as a whole, is overkill and unuseful, as I am n... | Basically ignore everything except your theme folder and custom plugins. sample .gitignore:
```
wp-admin/
wp-includes/
.htaccess
index.php
license.txt
liesmich.html
readme.html
wp-activate.php
wp-blog-header.php
wp-comments-post.php
wp-config.php
wp-config-sample.php
wp-config-stage.php
wp-config-live.php
wp-config-d... |
238,589 | <p>I have several categories post:</p>
<pre><code>General
News
Comedy
Competitions
Culture
Gaming
Food
etc
</code></pre>
<p>The posts url are in the following format:</p>
<pre><code>www.mydomain.com/category-name/post-title
</code></pre>
<p>Example:</p>
<pre><code>www.mydomain.com/food/how-to-make-paella
www.mydom... | [
{
"answer_id": 238592,
"author": "Kenya Sullivan",
"author_id": 92563,
"author_profile": "https://wordpress.stackexchange.com/users/92563",
"pm_score": 2,
"selected": false,
"text": "<p>This is subjective and depends on what you are trying to achieve. A theme developer may have a differe... | 2016/09/08 | [
"https://wordpress.stackexchange.com/questions/238589",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65640/"
] | I have several categories post:
```
General
News
Comedy
Competitions
Culture
Gaming
Food
etc
```
The posts url are in the following format:
```
www.mydomain.com/category-name/post-title
```
Example:
```
www.mydomain.com/food/how-to-make-paella
www.mydomain.com/gaming/game-of-theday
```
But I would like to hide... | Basically ignore everything except your theme folder and custom plugins. sample .gitignore:
```
wp-admin/
wp-includes/
.htaccess
index.php
license.txt
liesmich.html
readme.html
wp-activate.php
wp-blog-header.php
wp-comments-post.php
wp-config.php
wp-config-sample.php
wp-config-stage.php
wp-config-live.php
wp-config-d... |
238,600 | <p>I have comments enabled on my site but the form isn't appearing. It worked at one point as there are comments on some of my posts with links to them but they don't appear on the page.</p>
<p>Take this post: <a href="https://arcath.net/2016/03/react/" rel="noreferrer">https://arcath.net/2016/03/react/</a> The theme ... | [
{
"answer_id": 238602,
"author": "Dexter0015",
"author_id": 62134,
"author_profile": "https://wordpress.stackexchange.com/users/62134",
"pm_score": 4,
"selected": true,
"text": "<p><strong>Stupid question :</strong> \nIs it possible that your theme doesn't include the comments on display... | 2016/09/08 | [
"https://wordpress.stackexchange.com/questions/238600",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85357/"
] | I have comments enabled on my site but the form isn't appearing. It worked at one point as there are comments on some of my posts with links to them but they don't appear on the page.
Take this post: <https://arcath.net/2016/03/react/> The theme is clearly showing 1 comment at the top of the page.
Comments are enable... | **Stupid question :**
Is it possible that your theme doesn't include the comments on display?
In addition to settings, your theme must display comments.
The default function provided by WP is [comments\_template](https://developer.wordpress.org/reference/functions/comments_template/) (to use on single.php and/or pag... |
238,606 | <p>I created a custom table 'products' with the following field:title,description,url.The items stored into the table are imported.</p>
<p>I would like to extends the wordpress search to this table.
Is it possible to do this?</p>
| [
{
"answer_id": 238602,
"author": "Dexter0015",
"author_id": 62134,
"author_profile": "https://wordpress.stackexchange.com/users/62134",
"pm_score": 4,
"selected": true,
"text": "<p><strong>Stupid question :</strong> \nIs it possible that your theme doesn't include the comments on display... | 2016/09/08 | [
"https://wordpress.stackexchange.com/questions/238606",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102441/"
] | I created a custom table 'products' with the following field:title,description,url.The items stored into the table are imported.
I would like to extends the wordpress search to this table.
Is it possible to do this? | **Stupid question :**
Is it possible that your theme doesn't include the comments on display?
In addition to settings, your theme must display comments.
The default function provided by WP is [comments\_template](https://developer.wordpress.org/reference/functions/comments_template/) (to use on single.php and/or pag... |
238,640 | <p>Looking through the <a href="https://developer.wordpress.org/reference/functions/is_page_template/" rel="noreferrer">Wordpress documentation</a>, it says that <code>is_page_template()</code> compares against a "template name", if one is provided.</p>
<p>I have a template stored in <code>page-homepage.php</code> cal... | [
{
"answer_id": 238642,
"author": "jdm2112",
"author_id": 45202,
"author_profile": "https://wordpress.stackexchange.com/users/45202",
"pm_score": 5,
"selected": true,
"text": "<p>Your condition should be written like this:</p>\n<pre><code>if (is_page_template('path/file.php')) { \n // ... | 2016/09/08 | [
"https://wordpress.stackexchange.com/questions/238640",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4109/"
] | Looking through the [Wordpress documentation](https://developer.wordpress.org/reference/functions/is_page_template/), it says that `is_page_template()` compares against a "template name", if one is provided.
I have a template stored in `page-homepage.php` called `Homepage`:
```
/*
* Template Name: Homepage
* Descri... | Your condition should be written like this:
```
if (is_page_template('path/file.php')) {
// Do stuff
}
```
I believe the confusion is a result of two things:
1. The docs refer to "name" ambiguously. Specifying "file name" would make the documentation much more clear.
2. The code behind `is_page_template()` sho... |
238,645 | <p>I'm using the catch-base theme as a parent theme and have the following code in functions.php </p>
<pre><code><?php
function my_theme_enqueue_styles() {
$parent_style = 'catch-base';
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-theme',
get_styleshe... | [
{
"answer_id": 238649,
"author": "Brandon",
"author_id": 102030,
"author_profile": "https://wordpress.stackexchange.com/users/102030",
"pm_score": 2,
"selected": false,
"text": "<p>The catch-base theme wraps every function in an if statement to make it easy to modify if necessary.</p>\n\... | 2016/09/08 | [
"https://wordpress.stackexchange.com/questions/238645",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102030/"
] | I'm using the catch-base theme as a parent theme and have the following code in functions.php
```
<?php
function my_theme_enqueue_styles() {
$parent_style = 'catch-base';
wp_enqueue_style( $parent_style, get_template_directory_uri() . '/style.css' );
wp_enqueue_style( 'child-theme',
get_stylesheet_directory_uri(... | The catch-base theme wraps every function in an if statement to make it easy to modify if necessary.
Example....
```
if (! function_exists('function_name')) {
/* some code */
}
```
So what I ended up doing was adding this to my functions.php file in the child theme and it overwrote the function and the extra d... |
238,647 | <p>I have an anchor link on my product pages to a div further down the page. The div only shows if there is content in it.</p>
<p>Is it possible to write an if statement for the link based on the div ID? If #ID exists? </p>
<p>This is the div:</p>
<pre><code><div class="upsells products" id="tab-accessories">
... | [
{
"answer_id": 238694,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 0,
"selected": false,
"text": "<p>You're approach this the wrong way, I think. Even before you are outputting the link and the div in your templat... | 2016/09/08 | [
"https://wordpress.stackexchange.com/questions/238647",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85805/"
] | I have an anchor link on my product pages to a div further down the page. The div only shows if there is content in it.
Is it possible to write an if statement for the link based on the div ID? If #ID exists?
This is the div:
```
<div class="upsells products" id="tab-accessories">
<!--Change related pro... | This can be done but we need to see the if statement that is around your div. Right now you that code above will still present the div, just not the content IN the div. You need to wrap that link code in the same if statement that your div is in.
example: if your div if statement is:
```
if ( has_term( 'Accessories',... |
238,672 | <p>I've noticed plugins using a singleton pattern that will use WordPress's <code>_doing_it_wrong()</code> function in their <code>clone()</code> methods, like so:</p>
<pre><code><?php
public function __clone() {
_doing_it_wrong( __FUNCTION__, __( 'Cheatin&#8217; huh?', 'divlibrary' ), $this->version );
... | [
{
"answer_id": 263996,
"author": "Nathan Johnson",
"author_id": 106269,
"author_profile": "https://wordpress.stackexchange.com/users/106269",
"pm_score": 3,
"selected": true,
"text": "<blockquote>\n <p>What is an alternative method to the WordPress private _doing_it_wrong() function?</p... | 2016/09/09 | [
"https://wordpress.stackexchange.com/questions/238672",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12691/"
] | I've noticed plugins using a singleton pattern that will use WordPress's `_doing_it_wrong()` function in their `clone()` methods, like so:
```
<?php
public function __clone() {
_doing_it_wrong( __FUNCTION__, __( 'Cheatin’ huh?', 'divlibrary' ), $this->version );
}
?>
```
But I also noticed this warning/not... | >
> What is an alternative method to the WordPress private \_doing\_it\_wrong() function?
>
>
>
There's no way that WordPress is ever going to get rid of the `_doing_it_wrong()` function, so it's perfectly safe to use it. But if for some reason you don't want to use it because it's marked private, then you could c... |
238,679 | <p>I've been working with the <code>wp_list_categories( $args );</code> to display categories from a taxonomy and I feel that this might be the wrong method to use. Now I'm wondering if it is possible to instead of having the categories outputted into an unordered list, they are outputted as individual div elements for... | [
{
"answer_id": 263996,
"author": "Nathan Johnson",
"author_id": 106269,
"author_profile": "https://wordpress.stackexchange.com/users/106269",
"pm_score": 3,
"selected": true,
"text": "<blockquote>\n <p>What is an alternative method to the WordPress private _doing_it_wrong() function?</p... | 2016/09/09 | [
"https://wordpress.stackexchange.com/questions/238679",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93077/"
] | I've been working with the `wp_list_categories( $args );` to display categories from a taxonomy and I feel that this might be the wrong method to use. Now I'm wondering if it is possible to instead of having the categories outputted into an unordered list, they are outputted as individual div elements for each category... | >
> What is an alternative method to the WordPress private \_doing\_it\_wrong() function?
>
>
>
There's no way that WordPress is ever going to get rid of the `_doing_it_wrong()` function, so it's perfectly safe to use it. But if for some reason you don't want to use it because it's marked private, then you could c... |
238,680 | <p>I am using following codes to show title of a post in another post.But it shows only post id.How to solve this?</p>
<pre><code><?php $home_team_name = rwmb_meta( 'pb_select_home_team', 'type=select_advanced', get_the_ID() ); ?>
<?php echo esc_html( $home_team_name ); ?>
</code></pre>
<p>Thanks<... | [
{
"answer_id": 238681,
"author": "user3114253",
"author_id": 76325,
"author_profile": "https://wordpress.stackexchange.com/users/76325",
"pm_score": 0,
"selected": false,
"text": "<p>Generally we use <code>the_title()</code> or <code>echo get_the_title()</code> to print title</p>\n\n<p>t... | 2016/09/09 | [
"https://wordpress.stackexchange.com/questions/238680",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/83330/"
] | I am using following codes to show title of a post in another post.But it shows only post id.How to solve this?
```
<?php $home_team_name = rwmb_meta( 'pb_select_home_team', 'type=select_advanced', get_the_ID() ); ?>
<?php echo esc_html( $home_team_name ); ?>
```
Thanks | Because you're outside the loop, you'll need to either know the post id of the title you want and specify it in the function parameter, or call the global $post variable if you're on the page (just not in the loop yet).
```
global $post
echo get_the_title($post->ID);
or
echo get_the_title(2);
``` |
238,693 | <p>I want to display the content of all pages on a single page, with links to each page.</p>
<p>This might sound like a daft request, but it's useful for quickly reviewing what's available on a smallish site.</p>
<p>Using the code below, I can get most of the info I want, but don't know how to add the permalink.</p>
... | [
{
"answer_id": 238698,
"author": "Malisa",
"author_id": 71627,
"author_profile": "https://wordpress.stackexchange.com/users/71627",
"pm_score": -1,
"selected": false,
"text": "<p>There is probably better ways to achieve what you are wanting, but to answer your question with what you have... | 2016/09/09 | [
"https://wordpress.stackexchange.com/questions/238693",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63350/"
] | I want to display the content of all pages on a single page, with links to each page.
This might sound like a daft request, but it's useful for quickly reviewing what's available on a smallish site.
Using the code below, I can get most of the info I want, but don't know how to add the permalink.
```
<?php $pages = g... | Try this code to show list of page content. Page title will be the link of that page.
```
$args = array(
'post_type' => 'page', //specifying post type
'posts_per_page' => 10, //No. of Pages to show
);
$loop = new WP_Query( $args );
while ( $loop->have_posts() ) : $loop->the_post();?>
<h3><a href="<?php t... |
238,697 | <p>I have a standard WordPress page category with tag_ID=92 which I want to noindex all posts in this category entirely. Is there a way to do it with actions/hooks in functions.php?</p>
| [
{
"answer_id": 238699,
"author": "Malisa",
"author_id": 71627,
"author_profile": "https://wordpress.stackexchange.com/users/71627",
"pm_score": 2,
"selected": false,
"text": "<p>By noindex, I'm assuming you mean meta robots noindex, if so you could manually do this by utilizing the <a h... | 2016/09/09 | [
"https://wordpress.stackexchange.com/questions/238697",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101087/"
] | I have a standard WordPress page category with tag\_ID=92 which I want to noindex all posts in this category entirely. Is there a way to do it with actions/hooks in functions.php? | As the previous code I posted didnt work for the OP, clutching at straws, we can try to obtain the same outcome using [`get_the_category`](https://developer.wordpress.org/reference/functions/get_the_category/)
As the OP stated he was using YOAST, i'll wrap this function into the YOAST hook for robots.
```
add_filter('... |
238,709 | <p>I've been away from Wordpress for a few months, and now I'm struggling to remember how to create a Page of Posts. It's most infuriating!</p>
<p><strong>The Current Site</strong></p>
<p>I have <code>home.php</code> set up to display the latest Posts of a Custom Post Type as the main page. It works fine. A simple <c... | [
{
"answer_id": 238712,
"author": "Harshita",
"author_id": 102498,
"author_profile": "https://wordpress.stackexchange.com/users/102498",
"pm_score": 1,
"selected": false,
"text": "<p><strong>Changing the post type on the home page</strong></p>\n\n<p>By default, WordPress shows the post po... | 2016/09/09 | [
"https://wordpress.stackexchange.com/questions/238709",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/4109/"
] | I've been away from Wordpress for a few months, and now I'm struggling to remember how to create a Page of Posts. It's most infuriating!
**The Current Site**
I have `home.php` set up to display the latest Posts of a Custom Post Type as the main page. It works fine. A simple `pre_get_posts` function in `functions.php`... | Try this code in your `page-blog.php` to display list of posts
```
$paged = get_query_var('paged') ? get_query_var('paged') : 1;
$args = array(
'post_type' => 'post', //Change this with your post type
'posts_per_page' => 10, //No. of Pages to show
'offset' => 0, //excluding t... |
238,741 | <p>I have custom post type name "resources" and taxonomy called "type" with lot of terms in it. I do not want to create custom template for each term like taxonomy-type-{term}.php every time I add new term.</p>
<p>What I am trying to achieve here is a single page where it handle to check each terms. If the current ter... | [
{
"answer_id": 238771,
"author": "Malisa",
"author_id": 71627,
"author_profile": "https://wordpress.stackexchange.com/users/71627",
"pm_score": 0,
"selected": false,
"text": "<p>Well, you could try the following code: </p>\n\n<pre><code>// get all terms used by current post for specific... | 2016/09/09 | [
"https://wordpress.stackexchange.com/questions/238741",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/35253/"
] | I have custom post type name "resources" and taxonomy called "type" with lot of terms in it. I do not want to create custom template for each term like taxonomy-type-{term}.php every time I add new term.
What I am trying to achieve here is a single page where it handle to check each terms. If the current term is "2462... | Thank you for your time answering my unclear question. The code I found is the one that Im looking for. Thank you again :)
```
<?php
//http://codex.wordpress.org/Function_Reference/WP_Query#Taxonomy_Parameters
$term_slug = get_queried_object()->slug;
if ( !$term_slug )
return;
else
$args = arr... |
238,749 | <p>Trying to conditionally hide the "private" prefix in front of the page title on one specific page named 'members' only.</p>
<p>I used this code in functions.php to hide the prefix on all pages.</p>
<pre><code>function title_format($content) {
return '%s';
}
add_filter('private_title_format', 'title_format');
add_... | [
{
"answer_id": 238771,
"author": "Malisa",
"author_id": 71627,
"author_profile": "https://wordpress.stackexchange.com/users/71627",
"pm_score": 0,
"selected": false,
"text": "<p>Well, you could try the following code: </p>\n\n<pre><code>// get all terms used by current post for specific... | 2016/09/09 | [
"https://wordpress.stackexchange.com/questions/238749",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/94259/"
] | Trying to conditionally hide the "private" prefix in front of the page title on one specific page named 'members' only.
I used this code in functions.php to hide the prefix on all pages.
```
function title_format($content) {
return '%s';
}
add_filter('private_title_format', 'title_format');
add_filter('protected_tit... | Thank you for your time answering my unclear question. The code I found is the one that Im looking for. Thank you again :)
```
<?php
//http://codex.wordpress.org/Function_Reference/WP_Query#Taxonomy_Parameters
$term_slug = get_queried_object()->slug;
if ( !$term_slug )
return;
else
$args = arr... |
238,807 | <p>I have used a theme that includes the word "courses" throughout the theme by default as it is an online education platform. I am however creating a website with a similar design, but for projects so i would like to replace the word "courses" throughout the theme with the word "projects"
I have minimum experience w... | [
{
"answer_id": 238810,
"author": "Zeeshan",
"author_id": 102553,
"author_profile": "https://wordpress.stackexchange.com/users/102553",
"pm_score": -1,
"selected": false,
"text": "<p>The simplest thing you can do is export the database and find/replace <code>courses</code> with <code>proj... | 2016/09/10 | [
"https://wordpress.stackexchange.com/questions/238807",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102552/"
] | I have used a theme that includes the word "courses" throughout the theme by default as it is an online education platform. I am however creating a website with a similar design, but for projects so i would like to replace the word "courses" throughout the theme with the word "projects"
I have minimum experience with ... | I see some great answers for how to do a search and replace on a given string found in the database. However as I understand the OP's question, they are looking to replace text found in the theme files, as the question says "I have used a theme that includes the word "courses" throughout the theme by default...".
If t... |
238,850 | <p>I don't know why <code>get_term()</code> works on other pages but won't work in <code>functions.php</code>. Using <code>get_term()</code> in <code>functions.php</code> causes WordPress to report the error <em>Invalid taxonomy</em>.</p>
<p>my <code>function.php</code> which is ajax handler and already registered for... | [
{
"answer_id": 238851,
"author": "bbruman",
"author_id": 102212,
"author_profile": "https://wordpress.stackexchange.com/users/102212",
"pm_score": 0,
"selected": false,
"text": "<p><a href=\"https://codex.wordpress.org/Function_Reference/get_term\" rel=\"nofollow\">https://codex.wordpres... | 2016/09/11 | [
"https://wordpress.stackexchange.com/questions/238850",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/66294/"
] | I don't know why `get_term()` works on other pages but won't work in `functions.php`. Using `get_term()` in `functions.php` causes WordPress to report the error *Invalid taxonomy*.
my `function.php` which is ajax handler and already registered for ajax
```
public function load_destination()
{
global $wpd... | It sounds like you are are using `get_term()` for a custom taxonomy. If you're using `get_term()` inside `functions.php` and outside of a hooked function, that code is going to be run immediately when `functions.php` is loaded. Your custom taxonomy will not have been registered at this point, because that happens on th... |
238,863 | <p>I am beginner of wordpress. </p>
<pre><code> <?php if( have_posts() ):
while( have_posts() ): the_post(); ?>
<p><?php the_title(); ?></p>
<p><?php the_category(); ?></p>
... | [
{
"answer_id": 238879,
"author": "Sami",
"author_id": 102593,
"author_profile": "https://wordpress.stackexchange.com/users/102593",
"pm_score": 2,
"selected": true,
"text": "<p>Go to admin (Wordpress Portal) > Settings > Reading, look to \"Front page displays\" and make sure \"Your lates... | 2016/09/11 | [
"https://wordpress.stackexchange.com/questions/238863",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/96869/"
] | I am beginner of wordpress.
```
<?php if( have_posts() ):
while( have_posts() ): the_post(); ?>
<p><?php the_title(); ?></p>
<p><?php the_category(); ?></p>
<p><?php the_content(); ?></p>
<?... | Go to admin (Wordpress Portal) > Settings > Reading, look to "Front page displays" and make sure "Your latest posts" is checked
<https://codex.wordpress.org/Settings_Reading_Screen> |
238,882 | <p>I'm not experienced with the WordPress. My goal is to display all the posts on the page.</p>
<p>I was trying to display posts on a page like so:</p>
<pre><code><?php if (have_posts()) : while (have_posts()) : the_post(); ?>
...
<?php endwhile; else: ?>
<p><?php _e( 'Sorry, no pages found.' )... | [
{
"answer_id": 238893,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 1,
"selected": false,
"text": "<p>The number of posts displayed in any loop by default is controlled by <em>Settings > Blog pages show at mos... | 2016/09/11 | [
"https://wordpress.stackexchange.com/questions/238882",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/82592/"
] | I'm not experienced with the WordPress. My goal is to display all the posts on the page.
I was trying to display posts on a page like so:
```
<?php if (have_posts()) : while (have_posts()) : the_post(); ?>
...
<?php endwhile; else: ?>
<p><?php _e( 'Sorry, no pages found.' ); ?></p>
<?php endif; ?>
```
I've faced ... | The number of posts displayed in any loop by default is controlled by *Settings > Blog pages show at most*. To show all posts, you can enter a huge number, but `-1` (which is the value to use for the `posts_per_page` paramerter in `WP_Query`) does not work here.
It is possible to show all posts on the category and aut... |
238,889 | <p>I'm trying to make a social links menu for the footer in my theme. I want a menu to be customisable in Dashboard, I want the links to be relative to what's put in there.</p>
<p>Originally to get that, I did this: </p>
<pre><code><a href="http://www.facebook.com/" target="_blank"><i class="fa fa-facebook c... | [
{
"answer_id": 238902,
"author": "C C",
"author_id": 83299,
"author_profile": "https://wordpress.stackexchange.com/users/83299",
"pm_score": 2,
"selected": true,
"text": "<p>This is a tough one. Normally I'd say use <code>text-indent:-99999px;</code> as part of the markup for <code><... | 2016/09/11 | [
"https://wordpress.stackexchange.com/questions/238889",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102600/"
] | I'm trying to make a social links menu for the footer in my theme. I want a menu to be customisable in Dashboard, I want the links to be relative to what's put in there.
Originally to get that, I did this:
```
<a href="http://www.facebook.com/" target="_blank"><i class="fa fa-facebook circle"></i></a>
<a href="http:... | This is a tough one. Normally I'd say use `text-indent:-99999px;` as part of the markup for `<a>` -- to get that link text off the screen. But you have that `fa` italic tag which is really text as well - so it gets shifted off the screen, too.
This solution is pretty ugly but you can probably tweak it for your use.
W... |
238,905 | <p>I need to add revision support to WooCommerce Products (at least for the main content). The developers are unwilling to do this until there is some support on Wordpress for the extra product fields: <a href="https://github.com/woothemes/woocommerce/issues/2178" rel="nofollow">https://github.com/woothemes/woocommerce... | [
{
"answer_id": 238906,
"author": "Roy Ho",
"author_id": 67572,
"author_profile": "https://wordpress.stackexchange.com/users/67572",
"pm_score": 5,
"selected": true,
"text": "<p>As you pointed out already there is a filter.</p>\n\n<pre><code>add_filter( 'woocommerce_register_post_type_pro... | 2016/09/11 | [
"https://wordpress.stackexchange.com/questions/238905",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102609/"
] | I need to add revision support to WooCommerce Products (at least for the main content). The developers are unwilling to do this until there is some support on Wordpress for the extra product fields: <https://github.com/woothemes/woocommerce/issues/2178>
As I prefer partial revision support than nothing, I took a look ... | As you pointed out already there is a filter.
```
add_filter( 'woocommerce_register_post_type_product', 'wpse_modify_product_post_type' );
function wpse_modify_product_post_type( $args ) {
$args['supports'][] = 'revisions';
return $args;
}
```
Put that in your child theme's functions.php file. |
238,911 | <p>I have this code I want to implement onto my website. I have successfully set up a child theme. This code is suppose to change the background every day of the week. I am not all too familiar with Wordpress, and I am wondering where I should place it and how. Can someone please give me step by step instruction what I... | [
{
"answer_id": 238916,
"author": "Dave Romsey",
"author_id": 2807,
"author_profile": "https://wordpress.stackexchange.com/users/2807",
"pm_score": 1,
"selected": false,
"text": "<p>The code you've posted is JavaScript, and it should be placed within a JavaScript file inside of your child... | 2016/09/12 | [
"https://wordpress.stackexchange.com/questions/238911",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102602/"
] | I have this code I want to implement onto my website. I have successfully set up a child theme. This code is suppose to change the background every day of the week. I am not all too familiar with Wordpress, and I am wondering where I should place it and how. Can someone please give me step by step instruction what I ne... | In this scenario, the tag that you want to call to execute your function is the [`wp_head()`](https://codex.wordpress.org/Plugin_API/Action_Reference/wp_head).
Looking at the code you provides, you have the idea down, but I decided to rewrite it differently. In your child theme's [`functions.php`](https://codex.wordpr... |
238,915 | <p>How can a <strong>category</strong> be assigned to a <em>new front-end post</em> submission?<br><br>
<em>Posting works</em>, Category is not assigned.
Would like to be able to add more than one, if possible.<br>
Both are CPT and custom taxonomies.<br><br></p>
<pre><code>if ( isset( $_POST['submitted'] ) && ... | [
{
"answer_id": 238923,
"author": "Navin Bhudiya",
"author_id": 98536,
"author_profile": "https://wordpress.stackexchange.com/users/98536",
"pm_score": -1,
"selected": false,
"text": "<p>By using <strong>wp_set_object_terms</strong> you can set post category , for more details please foll... | 2016/09/12 | [
"https://wordpress.stackexchange.com/questions/238915",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101510/"
] | How can a **category** be assigned to a *new front-end post* submission?
*Posting works*, Category is not assigned.
Would like to be able to add more than one, if possible.
Both are CPT and custom taxonomies.
```
if ( isset( $_POST['submitted'] ) && isset( $_POST['new_post_nonce_field'] ) && wp_verify_nonce( $... | I checked and it works with this:
```
$new_post = array(
'post_content' => $_POST['post-content'],
'post_title' => wp_strip_all_tags( $_POST['post-title'] ),
'post_type' => 'custom_pt'
);
```
*note: I used a text input for the single category*
```
<input id="input-name-value" name="input-nam... |
238,941 | <p>I'm trying to add some javascript to my theme customizer. My JS file is loaded no problem and my document ready event works but <code>wp.customize.bind()</code> isn't calling my callback.</p>
<pre><code>jQuery(document).on('ready', function(){
console.log('binding')
wp.customize.bind('ready', function(){
co... | [
{
"answer_id": 284297,
"author": "Digvijayad",
"author_id": 118765,
"author_profile": "https://wordpress.stackexchange.com/users/118765",
"pm_score": 0,
"selected": false,
"text": "<p>I had same problem. \nThe reason it was not binding for me was because I had this error <code>\"Uncaught... | 2016/09/12 | [
"https://wordpress.stackexchange.com/questions/238941",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/85357/"
] | I'm trying to add some javascript to my theme customizer. My JS file is loaded no problem and my document ready event works but `wp.customize.bind()` isn't calling my callback.
```
jQuery(document).on('ready', function(){
console.log('binding')
wp.customize.bind('ready', function(){
console.log('ready')
})
}... | Do not put the Customizer `ready` event handler inside of the jQuery `event` handler. The Customizer `ready` will trigger at jQuery `ready`, so you are adding the event handler too late. Just do:
```
wp.customize.bind('ready', function(){
console.log('ready');
});
```
Your JS needs to be enqueued with `customize... |