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 |
|---|---|---|---|---|---|---|
261,307 | <p>I'm going to be setting up a custom post type on a site (for job vacancies) and I'm going to create a separate menu item on the site's main nav using categories, and i'll use a 'jobs' category to effectively have the jobs menu item running as a second blog.</p>
<p>What i would like is to have it so when the client ... | [
{
"answer_id": 261308,
"author": "Charles",
"author_id": 15605,
"author_profile": "https://wordpress.stackexchange.com/users/15605",
"pm_score": 2,
"selected": false,
"text": "<p>To answer the first question (pre-populate a CPT with a Cat) you could add following function to functions.ph... | 2017/03/25 | [
"https://wordpress.stackexchange.com/questions/261307",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/106972/"
] | I'm going to be setting up a custom post type on a site (for job vacancies) and I'm going to create a separate menu item on the site's main nav using categories, and i'll use a 'jobs' category to effectively have the jobs menu item running as a second blog.
What i would like is to have it so when the client adds a job... | To answer the first question (pre-populate a CPT with a Cat) you could add following function to functions.php .*(make backup first svp)*
In the code below *movies* is the Custom Post Type and *horror* is the Category.
Please change to own preferences.
```
/**
* Set a Category on Custom Post Type
*
* Read more... |
261,313 | <p>I have installed wordpress in the sub-directory /www/html/wordpress/ (and not at /www/html/) and the solution given here <a href="https://wordpress.stackexchange.com/questions/261080/how-to-get-rid-of-index-php/261089#261089">How to get rid of index.php</a> didn't work on this server.</p>
<p>The solution suggests a... | [
{
"answer_id": 261308,
"author": "Charles",
"author_id": 15605,
"author_profile": "https://wordpress.stackexchange.com/users/15605",
"pm_score": 2,
"selected": false,
"text": "<p>To answer the first question (pre-populate a CPT with a Cat) you could add following function to functions.ph... | 2017/03/25 | [
"https://wordpress.stackexchange.com/questions/261313",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116068/"
] | I have installed wordpress in the sub-directory /www/html/wordpress/ (and not at /www/html/) and the solution given here [How to get rid of index.php](https://wordpress.stackexchange.com/questions/261080/how-to-get-rid-of-index-php/261089#261089) didn't work on this server.
The solution suggests adding the following t... | To answer the first question (pre-populate a CPT with a Cat) you could add following function to functions.php .*(make backup first svp)*
In the code below *movies* is the Custom Post Type and *horror* is the Category.
Please change to own preferences.
```
/**
* Set a Category on Custom Post Type
*
* Read more... |
261,319 | <p>I want to display the list of posts from my wordpress blog on someother site along with the author name, title, date and description. Hence, I decided to use WP REST API V2. As per WP REST API Documentation I retrived the data in JSON format by following example URL <code>http://example.com/wp-json/wp/v2/posts?_embe... | [
{
"answer_id": 263326,
"author": "erwstout",
"author_id": 73064,
"author_profile": "https://wordpress.stackexchange.com/users/73064",
"pm_score": 4,
"selected": true,
"text": "<p>Wordfence blocks the User endpoint from the public. In settings there is a checkbox you can unselect to make ... | 2017/03/25 | [
"https://wordpress.stackexchange.com/questions/261319",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/91491/"
] | I want to display the list of posts from my wordpress blog on someother site along with the author name, title, date and description. Hence, I decided to use WP REST API V2. As per WP REST API Documentation I retrived the data in JSON format by following example URL `http://example.com/wp-json/wp/v2/posts?_embed`. I ge... | Wordfence blocks the User endpoint from the public. In settings there is a checkbox you can unselect to make it visible in the WP Rest API again. |
261,340 | <p>I'm trying to "POST" data from my Form through ajax to a mysql database.
This code is hooked to the "after_setup_theme" action:</p>
<pre><code>add_action("wp_ajax_ajax_anmeldung", "ajax_anmeldung");
add_action("wp_ajax_nopriv_ajax_anmeldung", "ajax_anmeldung");
function ajax_anmeldung() {
echo "<script>... | [
{
"answer_id": 261362,
"author": "Abdul Awal Uzzal",
"author_id": 31449,
"author_profile": "https://wordpress.stackexchange.com/users/31449",
"pm_score": 1,
"selected": false,
"text": "<p>Please try this:</p>\n\n<p>Add the following in your theme's functions.php</p>\n\n<pre><code>add_act... | 2017/03/25 | [
"https://wordpress.stackexchange.com/questions/261340",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116001/"
] | I'm trying to "POST" data from my Form through ajax to a mysql database.
This code is hooked to the "after\_setup\_theme" action:
```
add_action("wp_ajax_ajax_anmeldung", "ajax_anmeldung");
add_action("wp_ajax_nopriv_ajax_anmeldung", "ajax_anmeldung");
function ajax_anmeldung() {
echo "<script>
alert('he... | Please try this:
Add the following in your theme's functions.php
```
add_action( 'init', 'tnc_aj_scripts' );
function tnc_aj_scripts() {
wp_register_script( "ajax_anmeldung_script", get_template_directory_uri(). '/my-ajax.js', array('jquery'), '1.0', true);
wp_localize_script( 'ajax_anmeldung_script', 'mYAjax... |
261,359 | <p>I made a custom theme named <code>testTheme</code> having these files:</p>
<p><a href="https://i.stack.imgur.com/YJ2x9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/YJ2x9.png" alt="The files of my theme" /></a></p>
<p>And I wanted to put some translation on it therefore I created the required .p... | [
{
"answer_id": 261392,
"author": "jardindeden",
"author_id": 116160,
"author_profile": "https://wordpress.stackexchange.com/users/116160",
"pm_score": 2,
"selected": false,
"text": "<p>If you have a child theme, in your function.php you have to change <code>get_template_directory()</code... | 2017/03/25 | [
"https://wordpress.stackexchange.com/questions/261359",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116178/"
] | I made a custom theme named `testTheme` having these files:
[](https://i.stack.imgur.com/YJ2x9.png)
And I wanted to put some translation on it therefore I created the required .po and .mo files for greek language via poedit as seen in the following image:
... | 1. Change your translate file name to `el_GR.po` and `el_GR.mo`:
```
el_GR.po in: testTheme\languages\el.po
el_GR.mo in: testTheme\languages\el.mo
```
2. In 404.php file for print text you should write code like this (add textdomain):
```
<?php _e('The requested page does not exist.', 'testTheme'); ?>
```
Second p... |
261,379 | <p>Im working on a plugin. I placed like button under each post so users can like the post. When user click the button it updates 'likes_count' post_meta field which i created. Now here is my question. I created an admin page and i want to list all the tags order by 'likes_count' post_meta field. Is it possible? Thanks... | [
{
"answer_id": 261422,
"author": "Faysal Mahamud",
"author_id": 83752,
"author_profile": "https://wordpress.stackexchange.com/users/83752",
"pm_score": 3,
"selected": true,
"text": "<pre><code>$querystr = \"\n SELECT DISTINCT\n -- post_meta.meta_value,\n key2.name as tag_name,ke... | 2017/03/26 | [
"https://wordpress.stackexchange.com/questions/261379",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114388/"
] | Im working on a plugin. I placed like button under each post so users can like the post. When user click the button it updates 'likes\_count' post\_meta field which i created. Now here is my question. I created an admin page and i want to list all the tags order by 'likes\_count' post\_meta field. Is it possible? Thank... | ```
$querystr = "
SELECT DISTINCT
-- post_meta.meta_value,
key2.name as tag_name,key2.slug as tag_slug FROM $wpdb->posts key1
LEFT JOIN $wpdb->term_relationships ON (key1.ID = $wpdb->term_relationships.object_id)
LEFT JOIN $wpdb->postmeta post_meta ON (key1.ID = post_meta.post_id)
LEFT JOIN $wpdb->terms... |
261,387 | <p>is it possible to add first name & last name to the default registration form of wordpress?</p>
| [
{
"answer_id": 261389,
"author": "Faysal Mahamud",
"author_id": 83752,
"author_profile": "https://wordpress.stackexchange.com/users/83752",
"pm_score": 4,
"selected": true,
"text": "<p>Add this code in functions.php</p>\n<pre><code>add_action( 'register_form', 'myplugin_register_form' );... | 2017/03/26 | [
"https://wordpress.stackexchange.com/questions/261387",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110405/"
] | is it possible to add first name & last name to the default registration form of wordpress? | Add this code in functions.php
```
add_action( 'register_form', 'myplugin_register_form' );
function myplugin_register_form() {
$first_name = ( ! empty( $_POST['first_name'] ) ) ? trim( $_POST['first_name'] ) : '';
$last_name = ( ! empty( $_POST['last_name'] ) ) ? trim( $_POST['last_name'] ) : '';
?>... |
261,409 | <p>I'm using ajax in a plugin for a front-end form.
But it only works if I place the <code>add_action("wp_ajax_..."</code> in the plugin loader.
I would like to register the call in another file. </p>
<p>I have tried: </p>
<pre><code>function my_plugin_init() {
if ( ! is_admin() ) {
require( dirname( _... | [
{
"answer_id": 261413,
"author": "Sam",
"author_id": 115586,
"author_profile": "https://wordpress.stackexchange.com/users/115586",
"pm_score": 0,
"selected": false,
"text": "<p>Have you enqueued your script and then added wp_localize_script in the file you wish to use ajax?</p>\n\n<pre><... | 2017/03/26 | [
"https://wordpress.stackexchange.com/questions/261409",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16575/"
] | I'm using ajax in a plugin for a front-end form.
But it only works if I place the `add_action("wp_ajax_..."` in the plugin loader.
I would like to register the call in another file.
I have tried:
```
function my_plugin_init() {
if ( ! is_admin() ) {
require( dirname( __FILE__ ) . '/inc/my-plugin-func... | *Any* action that fires before the AJAX call is made will work. Generally speaking, `init` is good choice.
You mention that the ajax call is made from a "front-end form". If that form is available to end-users who are **not** logged in, then you need to use:
```
add_action ('wp_ajax_nopriv_my_plugin_etc', 'my_plugin_... |
261,410 | <p>I am using the WP-CLI to manage my sites. I can run the following command</p>
<pre><code>wp post list --fields=ID,mycustomfield
ID | mycustomfield
-----------------------
1 | active
2 | active
3 | disabled
4 | active
</code></pre>
<p>I am trying to narrow this list down by only returning ... | [
{
"answer_id": 261420,
"author": "fightstarr20",
"author_id": 10247,
"author_profile": "https://wordpress.stackexchange.com/users/10247",
"pm_score": 2,
"selected": false,
"text": "<p>Managed to figure this out, you can pass <strong>--meta_key</strong> and <strong>--meta_compare</strong>... | 2017/03/26 | [
"https://wordpress.stackexchange.com/questions/261410",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/10247/"
] | I am using the WP-CLI to manage my sites. I can run the following command
```
wp post list --fields=ID,mycustomfield
ID | mycustomfield
-----------------------
1 | active
2 | active
3 | disabled
4 | active
```
I am trying to narrow this list down by only returning those which has **mycustomf... | Managed to figure this out, you can pass **--meta\_key** and **--meta\_compare** arguments like this...
```
wp post list --fields=ID,mycustomfield --meta_key=mycustomfield '--meta_compare=active'
ID | mycustomfield
-----------------------
1 | active
2 | active
4 | active
``` |
261,414 | <p>I'm trying to update a custom field by hooking into the <code>save-post</code> action, but for reasons I can't figure out, it's not working.</p>
<p>The following function is placed in the theme's <code>functions.php</code>:</p>
<pre><code>function save_address_meta() {
$meta = get_post_meta( get_the_ID() );... | [
{
"answer_id": 261416,
"author": "Abdul Awal Uzzal",
"author_id": 31449,
"author_profile": "https://wordpress.stackexchange.com/users/31449",
"pm_score": 3,
"selected": true,
"text": "<p>Try changing <code>update_post_meta(get_the_ID(), $address, 'test');</code> to <code>update_post_meta... | 2017/03/26 | [
"https://wordpress.stackexchange.com/questions/261414",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/108005/"
] | I'm trying to update a custom field by hooking into the `save-post` action, but for reasons I can't figure out, it's not working.
The following function is placed in the theme's `functions.php`:
```
function save_address_meta() {
$meta = get_post_meta( get_the_ID() );
$address = $meta['address'];
... | Try changing `update_post_meta(get_the_ID(), $address, 'test');` to `update_post_meta(get_the_ID(), 'address', 'test');` |
261,425 | <p>I just create a site on my Multisite domain (example.com), for instance site1.example.com</p>
<p>After this, I try to enter on <a href="https://site1.example.com/wp-admin" rel="nofollow noreferrer">https://site1.example.com/wp-admin</a>, but I'm redirected to <a href="https://www.example.com/wp-signup.php?new=examp... | [
{
"answer_id": 262093,
"author": "Nikolay",
"author_id": 100555,
"author_profile": "https://wordpress.stackexchange.com/users/100555",
"pm_score": 0,
"selected": false,
"text": "<p>This .htaccess file looks like it is for a network that uses sub-folders but the URL address that you say y... | 2017/03/26 | [
"https://wordpress.stackexchange.com/questions/261425",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116259/"
] | I just create a site on my Multisite domain (example.com), for instance site1.example.com
After this, I try to enter on <https://site1.example.com/wp-admin>, but I'm redirected to <https://www.example.com/wp-signup.php?new=example.com>
My .htaccess containt this lines:
```
RewriteEngine On
RewriteBase /
RewriteRule ... | This .htaccess file looks like it is for a network that uses sub-folders but the URL address that you say you are trying is for a network that uses sub-domains. Which type are you using? Have you followed the steps in the /wp-admin/network/setup.php page correctly?
Another idea is that you have added SSL but the site ... |
261,436 | <p>This is similar to, but more specific than, the <a href="https://wordpress.stackexchange.com/questions/30970/using-get-posts-with-arguments-found-in-meta-keys">question found here</a>. That question suggests the Wordpress <a href="https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters" rel="nof... | [
{
"answer_id": 262093,
"author": "Nikolay",
"author_id": 100555,
"author_profile": "https://wordpress.stackexchange.com/users/100555",
"pm_score": 0,
"selected": false,
"text": "<p>This .htaccess file looks like it is for a network that uses sub-folders but the URL address that you say y... | 2017/03/26 | [
"https://wordpress.stackexchange.com/questions/261436",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16142/"
] | This is similar to, but more specific than, the [question found here](https://wordpress.stackexchange.com/questions/30970/using-get-posts-with-arguments-found-in-meta-keys). That question suggests the Wordpress [WP\_Query example](https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters), which are ... | This .htaccess file looks like it is for a network that uses sub-folders but the URL address that you say you are trying is for a network that uses sub-domains. Which type are you using? Have you followed the steps in the /wp-admin/network/setup.php page correctly?
Another idea is that you have added SSL but the site ... |
261,440 | <p>I'm am currently trialling the new (as of 2017) core API built into Wordpress. My setup is reasonably simple:</p>
<pre><code> +---------+ +------+ +---------+
|Wordpress|<-->|Guzzle|<-->| App |
|(API) | +------+ |(PHPSlim)|
+---------+ +---------+
</code></pre>
<p>G... | [
{
"answer_id": 261673,
"author": "Celso Bessa",
"author_id": 22694,
"author_profile": "https://wordpress.stackexchange.com/users/22694",
"pm_score": 1,
"selected": false,
"text": "<p>There is a cache plugin for WP Rest API with the name... <a href=\"https://wordpress.org/plugins/wp-rest-... | 2017/03/27 | [
"https://wordpress.stackexchange.com/questions/261440",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/82167/"
] | I'm am currently trialling the new (as of 2017) core API built into Wordpress. My setup is reasonably simple:
```
+---------+ +------+ +---------+
|Wordpress|<-->|Guzzle|<-->| App |
|(API) | +------+ |(PHPSlim)|
+---------+ +---------+
```
Guzzle will be operating through a loca... | There is a cache plugin for WP Rest API with the name... [WP Rest API Cache](https://wordpress.org/plugins/wp-rest-api-cache/):
I've used it for small projects and helped me a lot. |
261,443 | <p>I created a shortcode for visual composer to get terms of a custom taxonomy. But when I get them (for a category dropdown on visual composer's backend editor) it's not working.<br><br>
<a href="https://i.stack.imgur.com/IO1P8.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IO1P8.jpg" alt="enter im... | [
{
"answer_id": 261673,
"author": "Celso Bessa",
"author_id": 22694,
"author_profile": "https://wordpress.stackexchange.com/users/22694",
"pm_score": 1,
"selected": false,
"text": "<p>There is a cache plugin for WP Rest API with the name... <a href=\"https://wordpress.org/plugins/wp-rest-... | 2017/03/27 | [
"https://wordpress.stackexchange.com/questions/261443",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116280/"
] | I created a shortcode for visual composer to get terms of a custom taxonomy. But when I get them (for a category dropdown on visual composer's backend editor) it's not working.
[](https://i.stack.imgur.com/IO1P8.jpg)
My code:
```
$args1= array(
... | There is a cache plugin for WP Rest API with the name... [WP Rest API Cache](https://wordpress.org/plugins/wp-rest-api-cache/):
I've used it for small projects and helped me a lot. |
261,449 | <p>i want to change the output of a method inside the class of a plugin from the child function.php without changing the plugin's file. The output i want to change is that instead of a common a href, it uses the template button array. The thing is that the output of the method you get is a shortcode (this shortcode bel... | [
{
"answer_id": 261460,
"author": "ferdouswp",
"author_id": 114362,
"author_profile": "https://wordpress.stackexchange.com/users/114362",
"pm_score": 0,
"selected": false,
"text": "<p>You can use in your child theme directory plugin name and plugin file overwrite. Example child-theme-name... | 2017/03/27 | [
"https://wordpress.stackexchange.com/questions/261449",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116284/"
] | i want to change the output of a method inside the class of a plugin from the child function.php without changing the plugin's file. The output i want to change is that instead of a common a href, it uses the template button array. The thing is that the output of the method you get is a shortcode (this shortcode below ... | In you case i am considering this is direct function attached to shortcode. You can create your own shortcode and use it to display what you want. You can try this hack hope it will help you,
```
add_shortcode( 'custom-bewpi-download-invoice', 'print_invoice_func');
function print_invoice_func( $atts ) {
if ( ! isset... |
261,459 | <p>I have to change a few things in a page that I have not created. I have to insert some text inside a contact form. When I go to edit that page all I see is some shortcode. It's a custom shortcode that looks like [companyName_apply_form]. I have no idea where it comes from. It's not coming from the contact form plugi... | [
{
"answer_id": 261464,
"author": "jardindeden",
"author_id": 116160,
"author_profile": "https://wordpress.stackexchange.com/users/116160",
"pm_score": 2,
"selected": true,
"text": "<p>Just use the Windows search bar in <code>wp-content</code> directory and search for <code>companyName_ap... | 2017/03/27 | [
"https://wordpress.stackexchange.com/questions/261459",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115742/"
] | I have to change a few things in a page that I have not created. I have to insert some text inside a contact form. When I go to edit that page all I see is some shortcode. It's a custom shortcode that looks like [companyName\_apply\_form]. I have no idea where it comes from. It's not coming from the contact form plugin... | Just use the Windows search bar in `wp-content` directory and search for `companyName_apply_form`. You should find the file where the shortcode is created.
To add a shortcode in Wordpress you normally use this syntax:
```
'add_shortcode("shortcode_name", "function_name")'
``` |
261,477 | <p>I need to change a text content inside a contact form using jQuery, I know that the custom.js file that I'm using is connected as when I do a console.log I can see what I write. </p>
<p>When I select the paragraph that I need and change it's html content nothing happens, is it possible for the content to be overwri... | [
{
"answer_id": 261487,
"author": "Fabrizio Mele",
"author_id": 40463,
"author_profile": "https://wordpress.stackexchange.com/users/40463",
"pm_score": 1,
"selected": false,
"text": "<p>Have you tried to wrap it into the <code>jQuery()</code> function?</p>\n\n<pre><code>jQuery(function(){... | 2017/03/27 | [
"https://wordpress.stackexchange.com/questions/261477",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115742/"
] | I need to change a text content inside a contact form using jQuery, I know that the custom.js file that I'm using is connected as when I do a console.log I can see what I write.
When I select the paragraph that I need and change it's html content nothing happens, is it possible for the content to be overwritten by so... | In some instances, I'll run a *delayed init* function in a setTimeout like this:
```
var delay = setTimeout(function() {
jQuery("p.help-block.small").html("<p> ... </p>");
}, 100);
```
In the event that something is overwriting the html of that paragraph block on page load, this function will run 100 millisecond... |
261,478 | <p>From <a href="https://wordpress.stackexchange.com/a/261087/3206">this answer</a>, a MU site has the following in <code>wp-config.php</code>:</p>
<pre><code>define('WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'www.example.com');
define('PAT... | [
{
"answer_id": 262475,
"author": "mmm",
"author_id": 74311,
"author_profile": "https://wordpress.stackexchange.com/users/74311",
"pm_score": 0,
"selected": false,
"text": "<p>the first error come from additionnal code which would probably not be usefull with the actual WordPress version ... | 2017/03/27 | [
"https://wordpress.stackexchange.com/questions/261478",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3206/"
] | From [this answer](https://wordpress.stackexchange.com/a/261087/3206), a MU site has the following in `wp-config.php`:
```
define('WP_ALLOW_MULTISITE', true );
define('MULTISITE', true);
define('SUBDOMAIN_INSTALL', true);
define('DOMAIN_CURRENT_SITE', 'www.example.com');
define('PATH_CURRENT_SITE', '/');
define('SITE_... | Strangely it worked for me (on more than one multisites) to set SUBDOMAIN\_INSTALL to false. To be honest, I hadn't had time to investigate further why ...
`define('SUBDOMAIN_INSTALL', false);` |
261,482 | <p>I want to show posts using WP_Query functions. Also I want to add random order.</p>
<p>So I try</p>
<pre><code><?php
$temp = $wp_query;
$wp_query= null;
$args = array(
'orderby' => 'rand',
);
$wp_query = new WP_Query($args);
$wp_query->query('showposts=8' . '&paged='.$paged );
... | [
{
"answer_id": 261483,
"author": "Svartbaard",
"author_id": 112928,
"author_profile": "https://wordpress.stackexchange.com/users/112928",
"pm_score": 1,
"selected": false,
"text": "<p>Take a look at the WP_Query class reference and work yourself up from there. Try the basic examples, pla... | 2017/03/27 | [
"https://wordpress.stackexchange.com/questions/261482",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116307/"
] | I want to show posts using WP\_Query functions. Also I want to add random order.
So I try
```
<?php
$temp = $wp_query;
$wp_query= null;
$args = array(
'orderby' => 'rand',
);
$wp_query = new WP_Query($args);
$wp_query->query('showposts=8' . '&paged='.$paged );
while ($wp_query->have_posts()) :... | It's quite some time since I worked with WordPress, but it seems to me that:
You're executing the query twice.
=================================
* First when you pass `$args` to the constructor during instantiation.
* Second when you call `query()`.
**With this, you're essentially overwriting the first query (the on... |
261,516 | <p>Can anybody help me with a function to delete posts older than one year with postmeta, attachements and files?</p>
<p>Tnx</p>
| [
{
"answer_id": 289692,
"author": "Md. Mrinal Haque",
"author_id": 111354,
"author_profile": "https://wordpress.stackexchange.com/users/111354",
"pm_score": -1,
"selected": false,
"text": "<p>I find-out an way, when working on a <code>cron</code> related project.<br/>\n1. Install and acti... | 2017/03/27 | [
"https://wordpress.stackexchange.com/questions/261516",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/90139/"
] | Can anybody help me with a function to delete posts older than one year with postmeta, attachements and files?
Tnx | I've already answered that type of question [here](https://wordpress.stackexchange.com/questions/289103/automatically-delete-attachments-and-posts/289243#289243) but you want to delete `post_meta` too. Here is your code. Please test this on `localhost` first.
```php
<?php
// Please use this function carefully.
// Cha... |
261,527 | <p>I inherited a site with a custom php file for a custom sidebar. The sidebar is pulled in to action on pages using the "About" template. The sidebar is supposed to be displaying the image of the person whose profile it is on the top of the sidebar. Only one of the 4 profiles is pulling the correct image (the other 3 ... | [
{
"answer_id": 289692,
"author": "Md. Mrinal Haque",
"author_id": 111354,
"author_profile": "https://wordpress.stackexchange.com/users/111354",
"pm_score": -1,
"selected": false,
"text": "<p>I find-out an way, when working on a <code>cron</code> related project.<br/>\n1. Install and acti... | 2017/03/27 | [
"https://wordpress.stackexchange.com/questions/261527",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116340/"
] | I inherited a site with a custom php file for a custom sidebar. The sidebar is pulled in to action on pages using the "About" template. The sidebar is supposed to be displaying the image of the person whose profile it is on the top of the sidebar. Only one of the 4 profiles is pulling the correct image (the other 3 are... | I've already answered that type of question [here](https://wordpress.stackexchange.com/questions/289103/automatically-delete-attachments-and-posts/289243#289243) but you want to delete `post_meta` too. Here is your code. Please test this on `localhost` first.
```php
<?php
// Please use this function carefully.
// Cha... |
261,560 | <p>I am creating a plugin settings page using the register_settings() api. </p>
<p>How can i create a html editor (wordpress default editor would be splendid) instead of just a text area.</p>
<p>This is an example of the code I am using:</p>
<pre><code>add_action( 'admin_menu', 'pw_add_admin_menu' );
add_action( 'ad... | [
{
"answer_id": 261585,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 2,
"selected": false,
"text": "<p>always always always escape output (ok, some rare cases you should not, but the rule of thumb is to escap... | 2017/03/27 | [
"https://wordpress.stackexchange.com/questions/261560",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105668/"
] | I am creating a plugin settings page using the register\_settings() api.
How can i create a html editor (wordpress default editor would be splendid) instead of just a text area.
This is an example of the code I am using:
```
add_action( 'admin_menu', 'pw_add_admin_menu' );
add_action( 'admin_init', 'pw_settings_ini... | Here's an updated version of your original code, which solves the saving issue.
The reason that the content inside of the WP Editor was not saving was due to the value of the `textarea_name` parameter passed to `wp_editor()`.
This is wrong:
```
'textarea_name' => 'pw_intro',
```
It should look like this:
```
't... |
261,562 | <p>I want to remove the home page header image from all other pages. When you click an individual article, the feature image and header image blend into each other in an unflattering way.There needs to be separation between the images or have the header image remain on the home page only.</p>
<p>www.mybesthelperblog.w... | [
{
"answer_id": 261585,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 2,
"selected": false,
"text": "<p>always always always escape output (ok, some rare cases you should not, but the rule of thumb is to escap... | 2017/03/27 | [
"https://wordpress.stackexchange.com/questions/261562",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116359/"
] | I want to remove the home page header image from all other pages. When you click an individual article, the feature image and header image blend into each other in an unflattering way.There needs to be separation between the images or have the header image remain on the home page only.
www.mybesthelperblog.wordpress.c... | Here's an updated version of your original code, which solves the saving issue.
The reason that the content inside of the WP Editor was not saving was due to the value of the `textarea_name` parameter passed to `wp_editor()`.
This is wrong:
```
'textarea_name' => 'pw_intro',
```
It should look like this:
```
't... |
261,603 | <p>I have a sample:</p>
<p><strong>CODE PHP:</strong></p>
<pre><code> <ul class="categories-list">
<?php wp_list_categories('title_li='); ?>
</ul>
</code></pre>
<p>This code displays the category list sorted by name.</p>
<p>What I want to do is to have a custom order ... not by name not b... | [
{
"answer_id": 261609,
"author": "Nehal Shah",
"author_id": 114177,
"author_profile": "https://wordpress.stackexchange.com/users/114177",
"pm_score": 1,
"selected": false,
"text": "<p>You can use the shuffle() function to get the categories in random order.\nLike this, </p>\n\n<pre><code... | 2017/03/28 | [
"https://wordpress.stackexchange.com/questions/261603",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116384/"
] | I have a sample:
**CODE PHP:**
```
<ul class="categories-list">
<?php wp_list_categories('title_li='); ?>
</ul>
```
This code displays the category list sorted by name.
What I want to do is to have a custom order ... not by name not by id.
For example, this order:
```
1. Category with ID 5:
2. C... | You will need to [add term meta](https://developer.wordpress.org/reference/functions/add_term_meta/) to your categories. In this metafield you will store the string or number that you want to use as a base for your custom order ([tutorial](http://themehybrid.com/weblog/introduction-to-wordpress-term-meta)). Let's say y... |
261,628 | <p>I have a WordPress.org site. I am planning to use a new theme for the site. I have Installed the template and it is currently under the Themes folder. </p>
<p>The old theme is currently active. I would like to work on the new template and keep the old template active.</p>
<p>Once I finish working on the new theme,... | [
{
"answer_id": 261609,
"author": "Nehal Shah",
"author_id": 114177,
"author_profile": "https://wordpress.stackexchange.com/users/114177",
"pm_score": 1,
"selected": false,
"text": "<p>You can use the shuffle() function to get the categories in random order.\nLike this, </p>\n\n<pre><code... | 2017/03/28 | [
"https://wordpress.stackexchange.com/questions/261628",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/92500/"
] | I have a WordPress.org site. I am planning to use a new theme for the site. I have Installed the template and it is currently under the Themes folder.
The old theme is currently active. I would like to work on the new template and keep the old template active.
Once I finish working on the new theme, I would then lik... | You will need to [add term meta](https://developer.wordpress.org/reference/functions/add_term_meta/) to your categories. In this metafield you will store the string or number that you want to use as a base for your custom order ([tutorial](http://themehybrid.com/weblog/introduction-to-wordpress-term-meta)). Let's say y... |
261,633 | <p>I know this is normally an obvious question with a lot of answers (like <a href="https://wordpress.stackexchange.com/questions/120759/show-post-titles-only-on-the-homepage">here</a>), but I'd like to show only the beginning of the posts with a "read more" button. I don't use excerpts, so I'd like Wordpress to automa... | [
{
"answer_id": 261609,
"author": "Nehal Shah",
"author_id": 114177,
"author_profile": "https://wordpress.stackexchange.com/users/114177",
"pm_score": 1,
"selected": false,
"text": "<p>You can use the shuffle() function to get the categories in random order.\nLike this, </p>\n\n<pre><code... | 2017/03/28 | [
"https://wordpress.stackexchange.com/questions/261633",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116402/"
] | I know this is normally an obvious question with a lot of answers (like [here](https://wordpress.stackexchange.com/questions/120759/show-post-titles-only-on-the-homepage)), but I'd like to show only the beginning of the posts with a "read more" button. I don't use excerpts, so I'd like Wordpress to automaticly grab the... | You will need to [add term meta](https://developer.wordpress.org/reference/functions/add_term_meta/) to your categories. In this metafield you will store the string or number that you want to use as a base for your custom order ([tutorial](http://themehybrid.com/weblog/introduction-to-wordpress-term-meta)). Let's say y... |
261,641 | <p>I am having an issue with my WordPress load times. Site loads very slowly, and trying to pin this to the correct issue whether it be the template/code or server related.</p>
<pre><code>http://03e4976.netsolhost.com/site2016/
</code></pre>
<p><strong>First Issue -</strong>
I am wondering why my wordpress site is l... | [
{
"answer_id": 261609,
"author": "Nehal Shah",
"author_id": 114177,
"author_profile": "https://wordpress.stackexchange.com/users/114177",
"pm_score": 1,
"selected": false,
"text": "<p>You can use the shuffle() function to get the categories in random order.\nLike this, </p>\n\n<pre><code... | 2017/03/28 | [
"https://wordpress.stackexchange.com/questions/261641",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116407/"
] | I am having an issue with my WordPress load times. Site loads very slowly, and trying to pin this to the correct issue whether it be the template/code or server related.
```
http://03e4976.netsolhost.com/site2016/
```
**First Issue -**
I am wondering why my wordpress site is looking for a parallax-slider css file th... | You will need to [add term meta](https://developer.wordpress.org/reference/functions/add_term_meta/) to your categories. In this metafield you will store the string or number that you want to use as a base for your custom order ([tutorial](http://themehybrid.com/weblog/introduction-to-wordpress-term-meta)). Let's say y... |
261,645 | <p>I'm struggling to see if this is natively supported, or if it's not the best place to implement this functionality - in my app (Laravel) or the same side as the API (WordPress).</p>
<p>Retrieving a single page (/about-us) via the slug is easy:</p>
<pre><code>/wp-json/wp/v2/pages?slug=about-us
</code></pre>
<p>But... | [
{
"answer_id": 390444,
"author": "bosco",
"author_id": 25324,
"author_profile": "https://wordpress.stackexchange.com/users/25324",
"pm_score": 2,
"selected": false,
"text": "<p>Unfortunately, this functionality is not natively supported out of the box. In detail, the problem is that most... | 2017/03/28 | [
"https://wordpress.stackexchange.com/questions/261645",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/1062/"
] | I'm struggling to see if this is natively supported, or if it's not the best place to implement this functionality - in my app (Laravel) or the same side as the API (WordPress).
Retrieving a single page (/about-us) via the slug is easy:
```
/wp-json/wp/v2/pages?slug=about-us
```
But the issue comes with retrieving ... | Unfortunately, this functionality is not natively supported out of the box. In detail, the problem is that most post types including `page` use the base `WP_REST_Posts_Controller` which maps the `slug` parameter to the `post_name__in` `WP_Query` argument, which does not facilitate resolving hierarchical slugs. The `pag... |
261,686 | <p>Server upgrading Friday, which will kill my existing WP 3.1 blog. So I’m installing 4.7.3 fresh in new subdirectory of existing WP 3.1 domain/site AND using the same database. Domain is a subweb. Server is running PHP 5.3. (New one will run 5.6) Once working, I’ll point the domain at the new directory. (Not sure whe... | [
{
"answer_id": 261687,
"author": "rudtek",
"author_id": 77767,
"author_profile": "https://wordpress.stackexchange.com/users/77767",
"pm_score": 1,
"selected": false,
"text": "<p>It could be 2 things</p>\n\n<p>Most like it's your file permissions. It is probably that your apache isn't ab... | 2017/03/28 | [
"https://wordpress.stackexchange.com/questions/261686",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116436/"
] | Server upgrading Friday, which will kill my existing WP 3.1 blog. So I’m installing 4.7.3 fresh in new subdirectory of existing WP 3.1 domain/site AND using the same database. Domain is a subweb. Server is running PHP 5.3. (New one will run 5.6) Once working, I’ll point the domain at the new directory. (Not sure whethe... | It could be 2 things
Most like it's your file permissions. It is probably that your apache isn't able to open the files set files to 0644 and directories 0755.
The other problem could be your php version. Since you are upgrading to a new server, why not get the php in version 7? php 5.6 hit end of life 2 months ago. |
261,712 | <p>Lest say i have
Category 1
Category 2
Category 3</p>
<p>Inside a post which is located in category 1, I would like to show list of posts which are in category 2 and 3. If it is only in category 2 or only in category 3 it shouldn't be shown.</p>
<p>I was that there are </p>
<p><a href="https://codex.wordpress.org/... | [
{
"answer_id": 261687,
"author": "rudtek",
"author_id": 77767,
"author_profile": "https://wordpress.stackexchange.com/users/77767",
"pm_score": 1,
"selected": false,
"text": "<p>It could be 2 things</p>\n\n<p>Most like it's your file permissions. It is probably that your apache isn't ab... | 2017/03/29 | [
"https://wordpress.stackexchange.com/questions/261712",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/100468/"
] | Lest say i have
Category 1
Category 2
Category 3
Inside a post which is located in category 1, I would like to show list of posts which are in category 2 and 3. If it is only in category 2 or only in category 3 it shouldn't be shown.
I was that there are
[Multiple Taxonomy Handling:](https://codex.wordpress.org/Cla... | It could be 2 things
Most like it's your file permissions. It is probably that your apache isn't able to open the files set files to 0644 and directories 0755.
The other problem could be your php version. Since you are upgrading to a new server, why not get the php in version 7? php 5.6 hit end of life 2 months ago. |
261,756 | <p>I've set up a subfolder multisite.
Main site: <a href="https://cs-amx.org/" rel="nofollow noreferrer">https://cs-amx.org/</a>
Subdomain site: <a href="https://cs-amx.org/chypre" rel="nofollow noreferrer">https://cs-amx.org/chypre</a></p>
<p>You see the maintenance screen is well displayed on the main site, but not ... | [
{
"answer_id": 261687,
"author": "rudtek",
"author_id": 77767,
"author_profile": "https://wordpress.stackexchange.com/users/77767",
"pm_score": 1,
"selected": false,
"text": "<p>It could be 2 things</p>\n\n<p>Most like it's your file permissions. It is probably that your apache isn't ab... | 2017/03/29 | [
"https://wordpress.stackexchange.com/questions/261756",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63073/"
] | I've set up a subfolder multisite.
Main site: <https://cs-amx.org/>
Subdomain site: <https://cs-amx.org/chypre>
You see the maintenance screen is well displayed on the main site, but not on the subdomain site.
All the themes and plugin files lead to a 404.
For example, cs-amx.org/chypre/wp-content/plugins/maintenanc... | It could be 2 things
Most like it's your file permissions. It is probably that your apache isn't able to open the files set files to 0644 and directories 0755.
The other problem could be your php version. Since you are upgrading to a new server, why not get the php in version 7? php 5.6 hit end of life 2 months ago. |
261,764 | <p><a href="https://i.stack.imgur.com/8AKxq.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8AKxq.jpg" alt="enter image description here"></a> I have added custom menu just as in image above . But i am unable to open the pages. They are showing 404 page not found. </p>
| [
{
"answer_id": 261765,
"author": "Dean Jansen",
"author_id": 114897,
"author_profile": "https://wordpress.stackexchange.com/users/114897",
"pm_score": 2,
"selected": false,
"text": "<p>You can use the following to create a sub menu under woocommerce.\nPlease use the following for referen... | 2017/03/29 | [
"https://wordpress.stackexchange.com/questions/261764",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116488/"
] | [](https://i.stack.imgur.com/8AKxq.jpg) I have added custom menu just as in image above . But i am unable to open the pages. They are showing 404 page not found. | You can use the following to create a sub menu under woocommerce.
Please use the following for reference.
<https://developer.wordpress.org/reference/functions/add_submenu_page/>
```
add_action('admin_menu', 'testing_submenu_page');
function testing_submenu_page() {
add_submenu_page( 'woocommerce', 'sub menu', 's... |
261,777 | <p>Can <code>wp_script_is</code> used in <code>pluginA</code> check if a script is being enqueued/registered from <code>pluginB</code>? </p>
<p>I have two plugins both of which use Angular. One plugin (pluginA) has <code>angular.min.js</code> being loaded across all pages. The other (pluginB) has <code>angular.min.js<... | [
{
"answer_id": 261845,
"author": "Jigar Patel",
"author_id": 116524,
"author_profile": "https://wordpress.stackexchange.com/users/116524",
"pm_score": 0,
"selected": false,
"text": "<p>You are on the right path. There is no better way to determine script is enqueued or not. This is effic... | 2017/03/29 | [
"https://wordpress.stackexchange.com/questions/261777",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110157/"
] | Can `wp_script_is` used in `pluginA` check if a script is being enqueued/registered from `pluginB`?
I have two plugins both of which use Angular. One plugin (pluginA) has `angular.min.js` being loaded across all pages. The other (pluginB) has `angular.min.js` being loaded on only one. I would like to check if `plugin... | Now that I see you were hooking into `plugins_loaded`, this makes sense because it is fired much earlier than `wp_enqueue_scripts`. It is expected that your function would return 0 at this point.
See [here](https://codex.wordpress.org/Plugin_API/Action_Reference#Actions_Run_During_a_Typical_Request) and [here](https:/... |
261,785 | <p>So I am trying to display just the notes and the audio which are showing up with "AUDIO" and "TRANSCRIPT" as the output with a link to download them. </p>
<p>The issue I am having is that this also out put the featured image and the names of the uploaded PDF and MP3 show like this:</p>
<p>newyear2 (name of the fea... | [
{
"answer_id": 261845,
"author": "Jigar Patel",
"author_id": 116524,
"author_profile": "https://wordpress.stackexchange.com/users/116524",
"pm_score": 0,
"selected": false,
"text": "<p>You are on the right path. There is no better way to determine script is enqueued or not. This is effic... | 2017/03/29 | [
"https://wordpress.stackexchange.com/questions/261785",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116501/"
] | So I am trying to display just the notes and the audio which are showing up with "AUDIO" and "TRANSCRIPT" as the output with a link to download them.
The issue I am having is that this also out put the featured image and the names of the uploaded PDF and MP3 show like this:
newyear2 (name of the featured image)
h... | Now that I see you were hooking into `plugins_loaded`, this makes sense because it is fired much earlier than `wp_enqueue_scripts`. It is expected that your function would return 0 at this point.
See [here](https://codex.wordpress.org/Plugin_API/Action_Reference#Actions_Run_During_a_Typical_Request) and [here](https:/... |
261,789 | <p>I am trying to build a function, which gives out different image-urls, according to the last digit of <code>bbp_get_topic_id()</code>.<br>
This is, what i've got so far: </p>
<pre><code>function bg_image_topic_titlearea() {
$letztezifferimgs = substr("'.bbp_get_topic_id().'", -1);
switch ($letztezifferimgs) {
... | [
{
"answer_id": 261845,
"author": "Jigar Patel",
"author_id": 116524,
"author_profile": "https://wordpress.stackexchange.com/users/116524",
"pm_score": 0,
"selected": false,
"text": "<p>You are on the right path. There is no better way to determine script is enqueued or not. This is effic... | 2017/03/29 | [
"https://wordpress.stackexchange.com/questions/261789",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116503/"
] | I am trying to build a function, which gives out different image-urls, according to the last digit of `bbp_get_topic_id()`.
This is, what i've got so far:
```
function bg_image_topic_titlearea() {
$letztezifferimgs = substr("'.bbp_get_topic_id().'", -1);
switch ($letztezifferimgs) {
case "0":
echo ... | Now that I see you were hooking into `plugins_loaded`, this makes sense because it is fired much earlier than `wp_enqueue_scripts`. It is expected that your function would return 0 at this point.
See [here](https://codex.wordpress.org/Plugin_API/Action_Reference#Actions_Run_During_a_Typical_Request) and [here](https:/... |
261,829 | <p>I am setting the featured image as a background for the top part of the page. The images are quite large and I'd like to be able to set smaller image sizes for smaller screen sizes. Since the images are added inline, I don't think I can use the external styles.css file to set different images.</p>
<p>Here's an exam... | [
{
"answer_id": 261847,
"author": "ferdouswp",
"author_id": 114362,
"author_profile": "https://wordpress.stackexchange.com/users/114362",
"pm_score": -1,
"selected": false,
"text": "<pre>\n\n<b>You can simply use CSS media query for different device one example </b>\n\n@media only screen... | 2017/03/29 | [
"https://wordpress.stackexchange.com/questions/261829",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38890/"
] | I am setting the featured image as a background for the top part of the page. The images are quite large and I'd like to be able to set smaller image sizes for smaller screen sizes. Since the images are added inline, I don't think I can use the external styles.css file to set different images.
Here's an example of wha... | If you use Adaptive Images plugin for WordPress, you would just make one inline css for all viewport widths using the biggest image and then it does all the work on the server. You do nothing to your markup but in the Adaptive Images plugin settings you enter your breakpoints, so it will serve small images to small dev... |
261,832 | <p>I've been using shortcodes for cutting down on the amount of html I have in my visual editor.</p>
<p>I have a shortcode [person] with features name, age, location, phone, and description. I want to list my 50 friends on a page. Each feature of the person needs to be styled in html and the same on all. Each person r... | [
{
"answer_id": 261847,
"author": "ferdouswp",
"author_id": 114362,
"author_profile": "https://wordpress.stackexchange.com/users/114362",
"pm_score": -1,
"selected": false,
"text": "<pre>\n\n<b>You can simply use CSS media query for different device one example </b>\n\n@media only screen... | 2017/03/29 | [
"https://wordpress.stackexchange.com/questions/261832",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/104376/"
] | I've been using shortcodes for cutting down on the amount of html I have in my visual editor.
I have a shortcode [person] with features name, age, location, phone, and description. I want to list my 50 friends on a page. Each feature of the person needs to be styled in html and the same on all. Each person returns the... | If you use Adaptive Images plugin for WordPress, you would just make one inline css for all viewport widths using the biggest image and then it does all the work on the server. You do nothing to your markup but in the Adaptive Images plugin settings you enter your breakpoints, so it will serve small images to small dev... |
261,833 | <p>I am trying to output some calendar events from a custom table which are also tied to a custom post type. I have this working except that in my foreach loop, the last date is repeated in each row. I need some help using the right method of getting the $eventDate correctly. Here is my code:</p>
<pre><code><?ph... | [
{
"answer_id": 261843,
"author": "Jigar Patel",
"author_id": 116524,
"author_profile": "https://wordpress.stackexchange.com/users/116524",
"pm_score": 0,
"selected": false,
"text": "<p>You need to go for the <strong>nested loop</strong>. Try this</p>\n\n<pre><code><?php\n $today = ... | 2017/03/29 | [
"https://wordpress.stackexchange.com/questions/261833",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/40891/"
] | I am trying to output some calendar events from a custom table which are also tied to a custom post type. I have this working except that in my foreach loop, the last date is repeated in each row. I need some help using the right method of getting the $eventDate correctly. Here is my code:
```
<?php
$today = date('Y-m... | As discussed in the comments, instead of using the `ID` query argument to get each `'calp_event'`-type post individually, you can pass an array of IDs to `post__in` in order to grab them all at once, thus reducing the number of database transactions in your code to 2.
By creating an array mapping post IDs to event sta... |
261,838 | <p>I need to add a div before the first paragraph.</p>
<p>Example:</p>
<pre><code><div class="ads-site">ADS </div>
<p>First Paragraph</p>
<p>Second Paragraph</p>
</code></pre>
<p>My Function:</p>
<pre><code>global $post; function my_content_div( $content ) { $content = '<div... | [
{
"answer_id": 261840,
"author": "Yogensia",
"author_id": 97143,
"author_profile": "https://wordpress.stackexchange.com/users/97143",
"pm_score": 0,
"selected": false,
"text": "<p>You can use <a href=\"https://codex.wordpress.org/Plugin_API/Filter_Reference/the_content\" rel=\"nofollow n... | 2017/03/30 | [
"https://wordpress.stackexchange.com/questions/261838",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I need to add a div before the first paragraph.
Example:
```
<div class="ads-site">ADS </div>
<p>First Paragraph</p>
<p>Second Paragraph</p>
```
My Function:
```
global $post; function my_content_div( $content ) { $content = '<div>My div</div>' . $content; return $content; } add_filter('the_content', 'my_content... | Yogenisia's is right that you should use `the_content` filter.
If you want to insert something before the first paragraph, locate the first `<p>` in `$content`, then insert your `div` with `substr_replace`.
```
add_filter( 'the_content', 'namespace_insert_before_first_paragraph' );
function namespace_insert_before_f... |
261,855 | <p>I have a custom post type, named 'products', it has a custom taxonomy that is called 'collections'.<br>
This is how I have registered the taxonomy.</p>
<pre><code>$productTaxonomyArgs = [
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'show... | [
{
"answer_id": 261864,
"author": "Harry",
"author_id": 100916,
"author_profile": "https://wordpress.stackexchange.com/users/100916",
"pm_score": -1,
"selected": false,
"text": "<p>Try this code, its working for me ..</p>\n\n<pre><code> function add_collection_taxonomies() {\n $pro... | 2017/03/30 | [
"https://wordpress.stackexchange.com/questions/261855",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/106941/"
] | I have a custom post type, named 'products', it has a custom taxonomy that is called 'collections'.
This is how I have registered the taxonomy.
```
$productTaxonomyArgs = [
'public' => true,
'publicly_queryable' => true,
'show_ui' => true,
'show_in_menu' => true,
'show_admin_column' => true,
... | I just found out what I was doing wrong. Apparently you have to place archive pages in the root folder of your theme.
I placed them in a subfolder called templates. This works for page templates with a template name, but not for `taxonomy.php`, `archive.php`, `single.php` etc. |
261,868 | <p>Im using a charts plugin an i need to force some array elements to be strings.</p>
<pre><code>$values_x = array();
for ($i = 0; $i < count( $series[0]['data'] ); $i++ ) {
$values_x[] = $series[0]['data'][$i][0];
}
$values_y = array();
for ($i = 0; ... | [
{
"answer_id": 261910,
"author": "xvilo",
"author_id": 104427,
"author_profile": "https://wordpress.stackexchange.com/users/104427",
"pm_score": 0,
"selected": false,
"text": "<p>I am not sure how your code works. \nBut if <code>$series[0]['data'][$i][0]</code> generates <code>2010</code... | 2017/03/30 | [
"https://wordpress.stackexchange.com/questions/261868",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116556/"
] | Im using a charts plugin an i need to force some array elements to be strings.
```
$values_x = array();
for ($i = 0; $i < count( $series[0]['data'] ); $i++ ) {
$values_x[] = $series[0]['data'][$i][0];
}
$values_y = array();
for ($i = 0; $i < count( $seri... | There are a few ways you can make an integer a string. Here are 2 main ways to make that happen
1. **Type Cast** - `$values_x[] = (string) $series[0]['data'][$i][0]`
2. **Double Quote** - `$values_x[] "{$series[0]['data'][$i][0]}"`
Also, you might want to check for null first and assign a default
```
$values_x = !em... |
261,870 | <p>I want to add a third column consisting of an input textfield using the Settings API. Is this possible?</p>
<pre><code>function print_custom_field()
{
$value = get_option( 'my_first_field', '' );
$value_second = get_option( 'my_second_field', '' );
echo '<input type="text" id="my_first_field" name="my... | [
{
"answer_id": 261910,
"author": "xvilo",
"author_id": 104427,
"author_profile": "https://wordpress.stackexchange.com/users/104427",
"pm_score": 0,
"selected": false,
"text": "<p>I am not sure how your code works. \nBut if <code>$series[0]['data'][$i][0]</code> generates <code>2010</code... | 2017/03/30 | [
"https://wordpress.stackexchange.com/questions/261870",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/447/"
] | I want to add a third column consisting of an input textfield using the Settings API. Is this possible?
```
function print_custom_field()
{
$value = get_option( 'my_first_field', '' );
$value_second = get_option( 'my_second_field', '' );
echo '<input type="text" id="my_first_field" name="my_first_field" val... | There are a few ways you can make an integer a string. Here are 2 main ways to make that happen
1. **Type Cast** - `$values_x[] = (string) $series[0]['data'][$i][0]`
2. **Double Quote** - `$values_x[] "{$series[0]['data'][$i][0]}"`
Also, you might want to check for null first and assign a default
```
$values_x = !em... |
261,872 | <p>Custom post type created with this arg</p>
<pre><code>'labels' => $labels,
'hierarchical' => false,
'description' => 'Custom post type for question and answer',
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail' ),
'public' => false,
'show_ui' => true,
'show_in_menu' => false,
'menu... | [
{
"answer_id": 261885,
"author": "dipen patel",
"author_id": 116371,
"author_profile": "https://wordpress.stackexchange.com/users/116371",
"pm_score": 1,
"selected": false,
"text": "<p>I think this issue is connected to has_archive set to false in your code. So you need to set ‘has_archi... | 2017/03/30 | [
"https://wordpress.stackexchange.com/questions/261872",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116559/"
] | Custom post type created with this arg
```
'labels' => $labels,
'hierarchical' => false,
'description' => 'Custom post type for question and answer',
'supports' => array( 'title', 'editor', 'excerpt', 'thumbnail' ),
'public' => false,
'show_ui' => true,
'show_in_menu' => false,
'menu_position' => 24,
'menu_icon' => 'd... | will as i had answerd dipen under here this a wordpress Super mega SEO bug ... try any page created in wordpress and add link /page/3/ to /page/100000000/ it will have the same content which my own Competitors sent to index and really harm my serp resluts.
[Wordpress Infinity loop](https://perishablepress.com/wordpre... |
261,889 | <p>I have a simple "favorite post" button that works with AJAX. I understand that using a WordPress nonce improves security, but am not quite sure why or how it does this. This also makes me unable to check if I've implemented the nonce correctly and securely.</p>
<p><strong>jQuery Script</strong></p>
<pre><code>func... | [
{
"answer_id": 261885,
"author": "dipen patel",
"author_id": 116371,
"author_profile": "https://wordpress.stackexchange.com/users/116371",
"pm_score": 1,
"selected": false,
"text": "<p>I think this issue is connected to has_archive set to false in your code. So you need to set ‘has_archi... | 2017/03/30 | [
"https://wordpress.stackexchange.com/questions/261889",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22588/"
] | I have a simple "favorite post" button that works with AJAX. I understand that using a WordPress nonce improves security, but am not quite sure why or how it does this. This also makes me unable to check if I've implemented the nonce correctly and securely.
**jQuery Script**
```
function favorites_javascript() { ... | will as i had answerd dipen under here this a wordpress Super mega SEO bug ... try any page created in wordpress and add link /page/3/ to /page/100000000/ it will have the same content which my own Competitors sent to index and really harm my serp resluts.
[Wordpress Infinity loop](https://perishablepress.com/wordpre... |
261,932 | <p>I was trying to dig into this deeper, but I couldn't find any useful ways/hooks to add a little disclaimer above the Additional CSS code editor in the Wordpress Customizer. If anyone has a starting point of how i can add something simple like that, it would be greatly appreciated. </p>
<p>The section I am talking a... | [
{
"answer_id": 261939,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 0,
"selected": false,
"text": "<p>You will need the <a href=\"https://codex.wordpress.org/Class_Reference/WP_Customize_Manager/get_section\" rel=\... | 2017/03/30 | [
"https://wordpress.stackexchange.com/questions/261932",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38146/"
] | I was trying to dig into this deeper, but I couldn't find any useful ways/hooks to add a little disclaimer above the Additional CSS code editor in the Wordpress Customizer. If anyone has a starting point of how i can add something simple like that, it would be greatly appreciated.
The section I am talking about is `w... | Yep. I was able to show it by default using:
```
<?php
add_action('customize_controls_print_styles', function() {
?>
<style id="custom-css">
#sub-accordion-section-custom_css .description {
display: block !important;
}
</style>
<?php
});
```
Thanks for your help! |
261,935 | <p>I am developing a simple ranking plugin. Every post has it's own like count, and these counts are saved as custom-fields. </p>
<p>The problem is, no matter how much i research, i still couldn't find the proper way to manipulate theme's design in order to display post meta as i like. I've found some methods about ch... | [
{
"answer_id": 261939,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 0,
"selected": false,
"text": "<p>You will need the <a href=\"https://codex.wordpress.org/Class_Reference/WP_Customize_Manager/get_section\" rel=\... | 2017/03/30 | [
"https://wordpress.stackexchange.com/questions/261935",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116595/"
] | I am developing a simple ranking plugin. Every post has it's own like count, and these counts are saved as custom-fields.
The problem is, no matter how much i research, i still couldn't find the proper way to manipulate theme's design in order to display post meta as i like. I've found some methods about changing the... | Yep. I was able to show it by default using:
```
<?php
add_action('customize_controls_print_styles', function() {
?>
<style id="custom-css">
#sub-accordion-section-custom_css .description {
display: block !important;
}
</style>
<?php
});
```
Thanks for your help! |
261,940 | <p>I am trying to show 5 posts from a category in my home footer. I have placed this code</p>
<pre><code><?php query_posts( 'category_name=entertainment&posts_per_page=5' ); ?>
</code></pre>
<p>right in my <code>home.php</code> file and everything works fine except more than 5 posts are showing. In fact it... | [
{
"answer_id": 261941,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 1,
"selected": false,
"text": "<p>First: <a href=\"https://wordpress.stackexchange.com/questions/1753/when-should-you-use-wp-query-vs-query-posts-... | 2017/03/30 | [
"https://wordpress.stackexchange.com/questions/261940",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115764/"
] | I am trying to show 5 posts from a category in my home footer. I have placed this code
```
<?php query_posts( 'category_name=entertainment&posts_per_page=5' ); ?>
```
right in my `home.php` file and everything works fine except more than 5 posts are showing. In fact it is showing all the posts from that category. I ... | First: [don't use `query_posts`](https://wordpress.stackexchange.com/questions/1753/when-should-you-use-wp-query-vs-query-posts-vs-get-posts). Second: use [`$wp_query`](https://codex.wordpress.org/Function_Reference/WP_Query) instead:
```
$args = array (
'category_name' => 'entertainment',
'posts_per_page'=> 5
)... |
261,944 | <p>I'm developing a theme which will grab and upload an image when a post is published, using the following function:</p>
<pre><code>media_sideload_img( $url, $id, $description, 'src' );
</code></pre>
<p>The problem is, I often update my posts and this ends up with dozens of copies of the same image, which was upload... | [
{
"answer_id": 262125,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>I wonder if you're looking for the core <a href=\"https://developer.wordpress.org/reference/functions/attachme... | 2017/03/30 | [
"https://wordpress.stackexchange.com/questions/261944",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/94498/"
] | I'm developing a theme which will grab and upload an image when a post is published, using the following function:
```
media_sideload_img( $url, $id, $description, 'src' );
```
The problem is, I often update my posts and this ends up with dozens of copies of the same image, which was uploaded several times with ever... | I wonder if you're looking for the core [`attachment_url_to_postid()`](https://developer.wordpress.org/reference/functions/attachment_url_to_postid/) function that uses:
```
$sql = $wpdb->prepare(
"SELECT post_id FROM $wpdb->postmeta
WHERE meta_key = '_wp_attached_file' AND meta_value = %s",
$path
);... |
261,951 | <p>I'm a beginner plugin developer. I need my plugin to save and edit multiple indexed sets of key/value pairs on my custom settings page and retrieve later them by their index on the Appearance>>Widgets page.</p>
<p>Is it best to create a custom table in the database for this or does the Settings API have dimensiona... | [
{
"answer_id": 262125,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>I wonder if you're looking for the core <a href=\"https://developer.wordpress.org/reference/functions/attachme... | 2017/03/30 | [
"https://wordpress.stackexchange.com/questions/261951",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116579/"
] | I'm a beginner plugin developer. I need my plugin to save and edit multiple indexed sets of key/value pairs on my custom settings page and retrieve later them by their index on the Appearance>>Widgets page.
Is it best to create a custom table in the database for this or does the Settings API have dimensional accommoda... | I wonder if you're looking for the core [`attachment_url_to_postid()`](https://developer.wordpress.org/reference/functions/attachment_url_to_postid/) function that uses:
```
$sql = $wpdb->prepare(
"SELECT post_id FROM $wpdb->postmeta
WHERE meta_key = '_wp_attached_file' AND meta_value = %s",
$path
);... |
261,968 | <p>Is there a possibility to disable the email field on WooCommerce customer account details? Or Is there a hook or action available to do such thing? I'm just using a pre-made themes and not that much into PHP. Have tried this plugin called "Prevent Email Change" by Happy Plugins, but it didn't worked. </p>
<p>Would ... | [
{
"answer_id": 262044,
"author": "KAGG Design",
"author_id": 108721,
"author_profile": "https://wordpress.stackexchange.com/users/108721",
"pm_score": 3,
"selected": true,
"text": "<p>You can do it by adding this code to <code>functions.php</code>:</p>\n\n<pre><code>function custom_overr... | 2017/03/31 | [
"https://wordpress.stackexchange.com/questions/261968",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/104391/"
] | Is there a possibility to disable the email field on WooCommerce customer account details? Or Is there a hook or action available to do such thing? I'm just using a pre-made themes and not that much into PHP. Have tried this plugin called "Prevent Email Change" by Happy Plugins, but it didn't worked.
Would really app... | You can do it by adding this code to `functions.php`:
```
function custom_override_checkout_fields( $fields ) {
unset($fields['billing']['billing_email']);
return $fields;
}
add_filter( 'woocommerce_checkout_fields' , 'custom_override_checkout_fields', 1000, 1 );
```
But it is wrong approach, since WooCo... |
261,969 | <p>I'm trying to rename and rearange the <strong>Widgets</strong> panel in WP Customizer area (apperance > customizer). So far I've only tried to rename the section, I would also like to move it to the bottom.</p>
<p>I'm using this code:</p>
<pre><code> $wp_customize->get_section('widgets')->title = __( 'Si... | [
{
"answer_id": 261984,
"author": "Jignesh Patel",
"author_id": 111556,
"author_profile": "https://wordpress.stackexchange.com/users/111556",
"pm_score": 2,
"selected": false,
"text": "<p>Rename and Re-arrange the Widgets panel in WP customizer area in \nappearance > customizer.</p>\n\n<p... | 2017/03/31 | [
"https://wordpress.stackexchange.com/questions/261969",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101618/"
] | I'm trying to rename and rearange the **Widgets** panel in WP Customizer area (apperance > customizer). So far I've only tried to rename the section, I would also like to move it to the bottom.
I'm using this code:
```
$wp_customize->get_section('widgets')->title = __( 'Sidebar & Footer widgets' );
```
Here's t... | Figured it out. Use "get\_panel" not "get\_section"
```
$wp_customize->get_panel('widgets')->title = __( 'Sidebar & Footer widgets' );
``` |
261,972 | <p>Here's my code in the functions.php file:</p>
<pre><code><?php
// Excerpt Length Control
function set_excerpt_length(){
return 85;
}
// Theme stream_support
function wpb_theme_setup(){
add_theme_support( 'post-thumbnails' );
}
add_filter('excerpt_length', 'set_excerpt_l... | [
{
"answer_id": 261984,
"author": "Jignesh Patel",
"author_id": 111556,
"author_profile": "https://wordpress.stackexchange.com/users/111556",
"pm_score": 2,
"selected": false,
"text": "<p>Rename and Re-arrange the Widgets panel in WP customizer area in \nappearance > customizer.</p>\n\n<p... | 2017/03/31 | [
"https://wordpress.stackexchange.com/questions/261972",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93691/"
] | Here's my code in the functions.php file:
```
<?php
// Excerpt Length Control
function set_excerpt_length(){
return 85;
}
// Theme stream_support
function wpb_theme_setup(){
add_theme_support( 'post-thumbnails' );
}
add_filter('excerpt_length', 'set_excerpt_length');
```
An... | Figured it out. Use "get\_panel" not "get\_section"
```
$wp_customize->get_panel('widgets')->title = __( 'Sidebar & Footer widgets' );
``` |
261,986 | <p>I'm new to developing a custom template in Wordpress but I fail to see how I can style a menu item seperately.</p>
<p>With <code>posts</code> I can loop through them and place them in custom html elements. With <code>wp_page_menu()</code> I can only output the whole list. How can I loop through each item and place ... | [
{
"answer_id": 261995,
"author": "Philipp Zedler",
"author_id": 44375,
"author_profile": "https://wordpress.stackexchange.com/users/44375",
"pm_score": 1,
"selected": false,
"text": "<p>Following the code of the <code>wp_page_menu</code> directs me to the function <a href=\"https://codex... | 2017/03/31 | [
"https://wordpress.stackexchange.com/questions/261986",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116634/"
] | I'm new to developing a custom template in Wordpress but I fail to see how I can style a menu item seperately.
With `posts` I can loop through them and place them in custom html elements. With `wp_page_menu()` I can only output the whole list. How can I loop through each item and place them in my custom template?
**H... | Please find below the function for showing navigation menu.
Here, `$menu` is equivalent to ***Menu name, ID, or slug***
```
<?php
function showMyMenu($menu)
{
$navData = wp_get_nav_menu_items($menu);
?>
<ul class="nav navbar-nav navbar-right is-hidden">
<?php
foreach($navData as $k => $v)
{
... |
261,996 | <p>Have a CPT with custom field "size" valued "big" or "small" and Author with custom radio field "gender". Author can be "Man" or "Woman".
Need query posts if, for example, author is "man" and filed "size" is "big".
Try something like this:</p>
<pre><code>$args = array(
'post_type' => 'custom_post_type',
'met... | [
{
"answer_id": 262381,
"author": "BillyHoyle",
"author_id": 116633,
"author_profile": "https://wordpress.stackexchange.com/users/116633",
"pm_score": 2,
"selected": true,
"text": "<p>In case this helps anyone in the future:</p>\n\n<p>The problem was not a WordPress issue, it was a server... | 2017/03/31 | [
"https://wordpress.stackexchange.com/questions/261996",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64530/"
] | Have a CPT with custom field "size" valued "big" or "small" and Author with custom radio field "gender". Author can be "Man" or "Woman".
Need query posts if, for example, author is "man" and filed "size" is "big".
Try something like this:
```
$args = array(
'post_type' => 'custom_post_type',
'meta_query' => array... | In case this helps anyone in the future:
The problem was not a WordPress issue, it was a server configuration issue.
Useful explanation on checking which stream wrappers are enabled on your server (used this to make sure https was enabled on my server) [Enable Stream Wrappers](https://stackoverflow.com/questions/2305... |
262,005 | <p>I already have found <a href="https://wordpress.stackexchange.com/a/59957/25187">a working solution</a> for my question, but <strong>the problem is that it neutralizes</strong> <a href="https://wordpress.stackexchange.com/a/94820/25187">another function</a> that adds the category base into the custom post type perma... | [
{
"answer_id": 262023,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 3,
"selected": true,
"text": "<p>Lets take these functions and paraphrase them into english, then put them in the order they're ran. I'm going... | 2017/03/31 | [
"https://wordpress.stackexchange.com/questions/262005",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25187/"
] | I already have found [a working solution](https://wordpress.stackexchange.com/a/59957/25187) for my question, but **the problem is that it neutralizes** [another function](https://wordpress.stackexchange.com/a/94820/25187) that adds the category base into the custom post type permalinks, and I need boths, so **I must t... | Lets take these functions and paraphrase them into english, then put them in the order they're ran. I'm going to deliberately avoid using PHP in this answer, but a basic understanding of PHP will be necessary:
```
When the `post_type_link` filter runs: // the add_action calls
run: `wpa_course_post_link` as it has ... |
262,026 | <p>I have a Wordpress menu that are both being used as a normal menu with page name that links to the page. I want to echo the same registered menu, but without the page name. To be clear, I still want the anchorlink, but I do not want any text contained within the anchorlink.</p>
<pre><code><li><a href="the-... | [
{
"answer_id": 262023,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 3,
"selected": true,
"text": "<p>Lets take these functions and paraphrase them into english, then put them in the order they're ran. I'm going... | 2017/03/31 | [
"https://wordpress.stackexchange.com/questions/262026",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/92908/"
] | I have a Wordpress menu that are both being used as a normal menu with page name that links to the page. I want to echo the same registered menu, but without the page name. To be clear, I still want the anchorlink, but I do not want any text contained within the anchorlink.
```
<li><a href="the-page-link"></a></li>
`... | Lets take these functions and paraphrase them into english, then put them in the order they're ran. I'm going to deliberately avoid using PHP in this answer, but a basic understanding of PHP will be necessary:
```
When the `post_type_link` filter runs: // the add_action calls
run: `wpa_course_post_link` as it has ... |
262,042 | <p>I have a plugin, which creates a panel on following page:</p>
<pre><code>mysite.com/wp-content/plugins/myplugin/includes/mypanel.php
</code></pre>
<p>I want to use this panel on following page </p>
<pre><code>mysite.com/mypanel
</code></pre>
<p>Solution that I tried was to using <code>mypanel.php</code> as page ... | [
{
"answer_id": 262190,
"author": "Nathan Johnson",
"author_id": 106269,
"author_profile": "https://wordpress.stackexchange.com/users/106269",
"pm_score": 1,
"selected": false,
"text": "<p>If you already have, or are planning to have, a page called 'mypanel', then you can use the <code>pa... | 2017/03/31 | [
"https://wordpress.stackexchange.com/questions/262042",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/112778/"
] | I have a plugin, which creates a panel on following page:
```
mysite.com/wp-content/plugins/myplugin/includes/mypanel.php
```
I want to use this panel on following page
```
mysite.com/mypanel
```
Solution that I tried was to using `mypanel.php` as page template as below:
```
add_filter( 'page_template', 'wpa339... | Your CODE is fine, the reason you are getting 403 error is because `$_SERVER['DOCUMENT_ROOT']` returns absolute PATH to your web root, not URL.
JavaScript needs to be added as URL. So, you may use `Load_Template_Scripts_wpa83855` function in your plugin and then use:
```
wp_enqueue_script( 'wtd', plugins_url( '/js/wt... |
262,079 | <p>Users to the site can register and log in and access a special page <code>members.php</code>, which is the home page of their account.</p>
<p>But if they leave the site and come back (provided they are still logged in) they need to be landing on <code>members.php</code> and not my regular home page.</p>
<p>Now eve... | [
{
"answer_id": 262190,
"author": "Nathan Johnson",
"author_id": 106269,
"author_profile": "https://wordpress.stackexchange.com/users/106269",
"pm_score": 1,
"selected": false,
"text": "<p>If you already have, or are planning to have, a page called 'mypanel', then you can use the <code>pa... | 2017/04/01 | [
"https://wordpress.stackexchange.com/questions/262079",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78121/"
] | Users to the site can register and log in and access a special page `members.php`, which is the home page of their account.
But if they leave the site and come back (provided they are still logged in) they need to be landing on `members.php` and not my regular home page.
Now everyone, logged in as well as logged out,... | Your CODE is fine, the reason you are getting 403 error is because `$_SERVER['DOCUMENT_ROOT']` returns absolute PATH to your web root, not URL.
JavaScript needs to be added as URL. So, you may use `Load_Template_Scripts_wpa83855` function in your plugin and then use:
```
wp_enqueue_script( 'wtd', plugins_url( '/js/wt... |
262,100 | <p>I have 10 thousand of users about 98% of these users never published a post (i mean post not comments). </p>
<p>I need a way to mass delete users with 0 posts.</p>
<p>The method must count all posts included custom post types and has to use proper WordPress function to delete a user as if they were manually delete... | [
{
"answer_id": 262105,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 4,
"selected": true,
"text": "<p>If you have a large number of users to delete, you might consder using the <a href=\"https://wp-cli.org/comman... | 2017/04/01 | [
"https://wordpress.stackexchange.com/questions/262100",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77283/"
] | I have 10 thousand of users about 98% of these users never published a post (i mean post not comments).
I need a way to mass delete users with 0 posts.
The method must count all posts included custom post types and has to use proper WordPress function to delete a user as if they were manually deleted in the dashboar... | If you have a large number of users to delete, you might consder using the [wp user delete](https://wp-cli.org/commands/user/delete/) **wp-cli** command to avoid script timeouts.
[Here's](https://stackoverflow.com/a/8155865/2078474) an example of a SQL query to delete all users **without posts of any type and status**... |
262,109 | <p>I'm new to WP and I am not quite sure how to approach my goal - I'd like to make featured images in blog posts 1920px wide x 350px high that will become full width banner images at the top of the page.</p>
<p>How do I go about that?</p>
<p>Currently I am using pretty simple .css rules that simply position a backgr... | [
{
"answer_id": 262105,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 4,
"selected": true,
"text": "<p>If you have a large number of users to delete, you might consder using the <a href=\"https://wp-cli.org/comman... | 2017/04/01 | [
"https://wordpress.stackexchange.com/questions/262109",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93691/"
] | I'm new to WP and I am not quite sure how to approach my goal - I'd like to make featured images in blog posts 1920px wide x 350px high that will become full width banner images at the top of the page.
How do I go about that?
Currently I am using pretty simple .css rules that simply position a background image at the... | If you have a large number of users to delete, you might consder using the [wp user delete](https://wp-cli.org/commands/user/delete/) **wp-cli** command to avoid script timeouts.
[Here's](https://stackoverflow.com/a/8155865/2078474) an example of a SQL query to delete all users **without posts of any type and status**... |
262,116 | <p>I have a code, i used to call a particular category in my post page footer and i have specified the number of posts to display but its showing all the posts from that category.</p>
<p>here are the codes</p>
<pre><code><?php query_posts('category_name=tech&order=dsc&showposts=12'); ?>
</code></pre>
<... | [
{
"answer_id": 262131,
"author": "Nikolay",
"author_id": 100555,
"author_profile": "https://wordpress.stackexchange.com/users/100555",
"pm_score": 0,
"selected": false,
"text": "<p>It says <a href=\"https://developer.wordpress.org/reference/classes/wp_query/#pagination-parameters\" rel=\... | 2017/04/01 | [
"https://wordpress.stackexchange.com/questions/262116",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115764/"
] | I have a code, i used to call a particular category in my post page footer and i have specified the number of posts to display but its showing all the posts from that category.
here are the codes
```
<?php query_posts('category_name=tech&order=dsc&showposts=12'); ?>
```
and `<?php query_posts('cat=438'.'&showposts=... | If you need the number of posts in the query args then use posts\_per\_page, since posts\_per\_page has a default value of 10, it will always display 10 posts, if you wish to see all the posts, as in, there should not be any limit then choose its value to be -1 and use it like this
```
$args=array(
'post_type'=>'... |
262,153 | <p>I have a subdomain </p>
<blockquote>
<p><code>http://blog.example.com</code></p>
</blockquote>
<p>I would like to redirect it to subdirectory as </p>
<blockquote>
<p><code>https://www.example.com/blog</code></p>
</blockquote>
<p>But not admin(<strong>/wp-admin</strong>). Admin area should be as it is </p>
<... | [
{
"answer_id": 262214,
"author": "Greeso",
"author_id": 34253,
"author_profile": "https://wordpress.stackexchange.com/users/34253",
"pm_score": 0,
"selected": false,
"text": "<p>Have you tried the following?</p>\n\n<pre><code><html>\n <head>\n <meta http-equiv=\"... | 2017/04/02 | [
"https://wordpress.stackexchange.com/questions/262153",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63027/"
] | I have a subdomain
>
> `http://blog.example.com`
>
>
>
I would like to redirect it to subdirectory as
>
> `https://www.example.com/blog`
>
>
>
But not admin(**/wp-admin**). Admin area should be as it is
>
> `http://blog.example.com/wp-admin`
>
>
>
currently I have this in my htaccess
```
<IfModule... | Use below rule,
```
RewriteEngine On
# excluding www
RewriteCond %{HTTP_HOST} !^www
RewriteCond %{HTTP_HOST} ^blog
# excluding wp-admin
RewriteCond %{REQUEST_URI} !^wp-admin
RewriteRule ^ https://www.example.com/%1
``` |
262,155 | <p>I have following code, which is generating the the text on the website. code resides in front-page.php file in the theme folder.</p>
<pre><code><p class="excerpt">
<?php
$theExcerpt = get_the_excerpt();
$tags = array("<p>", "</p>");
... | [
{
"answer_id": 262164,
"author": "Bob",
"author_id": 116319,
"author_profile": "https://wordpress.stackexchange.com/users/116319",
"pm_score": 3,
"selected": true,
"text": "<p>One thing you can try is going into the page's Edit mode, by pressing \"Edit\" on that page, and then checking w... | 2017/04/02 | [
"https://wordpress.stackexchange.com/questions/262155",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116754/"
] | I have following code, which is generating the the text on the website. code resides in front-page.php file in the theme folder.
```
<p class="excerpt">
<?php
$theExcerpt = get_the_excerpt();
$tags = array("<p>", "</p>");
$theExcerpt = s... | One thing you can try is going into the page's Edit mode, by pressing "Edit" on that page, and then checking whether that text is by any chance the actual excerpt. If you can't see an "excerpt" section on that page you can go to the top of that page, click "Screen Options" on the top right, and tick the option "Excerpt... |
262,160 | <p>I'm using <strong>woocommerce multi vendor plugin</strong>, this is my current URL </p>
<pre><code>http://localhost/cloudstock4/vendor/vender-two/
</code></pre>
<p>I want to get this last couple of word. i think this page use the WP archive.php </p>
| [
{
"answer_id": 262163,
"author": "Benoti",
"author_id": 58141,
"author_profile": "https://wordpress.stackexchange.com/users/58141",
"pm_score": 1,
"selected": false,
"text": "<p>You can use <a href=\"https://codex.wordpress.org/Function_Reference/get_query_var\" rel=\"nofollow noreferrer... | 2017/04/02 | [
"https://wordpress.stackexchange.com/questions/262160",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116757/"
] | I'm using **woocommerce multi vendor plugin**, this is my current URL
```
http://localhost/cloudstock4/vendor/vender-two/
```
I want to get this last couple of word. i think this page use the WP archive.php | You can use [`get_query_var()`](https://codex.wordpress.org/Function_Reference/get_query_var) to get what you want in the query made with the request.
```
$vendor = get_query_var('vendor');
```
If the vendor var is set, $vendor will be 'vender-two'.
Hope it helps |
262,178 | <p>I have a super simple requirement here. I have added a meta field to all posts that will allow a url to be used to redirect the post (i have reasons for doing it this way). I am trying to trigger this on the action "the_post", but for some reason it doesnt seem to fire. Here is what ive added </p>
<pre><code>functi... | [
{
"answer_id": 262175,
"author": "Kevin Mamaqi",
"author_id": 60103,
"author_profile": "https://wordpress.stackexchange.com/users/60103",
"pm_score": 2,
"selected": false,
"text": "<p>You need to use <a href=\"https://codex.wordpress.org/Function_Reference/wp_script_is\" rel=\"nofollow n... | 2017/04/02 | [
"https://wordpress.stackexchange.com/questions/262178",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/190834/"
] | I have a super simple requirement here. I have added a meta field to all posts that will allow a url to be used to redirect the post (i have reasons for doing it this way). I am trying to trigger this on the action "the\_post", but for some reason it doesnt seem to fire. Here is what ive added
```
function nb_checkre... | You need to use [wp\_script\_is](https://codex.wordpress.org/Function_Reference/wp_script_is) in order to check if the library you are willing to use has already been included by another plugin. As you can see the handle is important, if you change it to whatEverIWant.js, it will not recognize the library. |
262,196 | <p>I'm using WP 4.7.3 and a custom template set (mh-magazine).</p>
<p>By default, WP sets a title tag like "Page title" - "Blog title".</p>
<p>Now all I want to achieve is to replace "-" into a pipe symbol for layout reasons. So the processed HTMl should look like:</p>
<p>My page title | My blog title</p>
<p>I thou... | [
{
"answer_id": 262197,
"author": "Paul 'Sparrow Hawk' Biron",
"author_id": 113496,
"author_profile": "https://wordpress.stackexchange.com/users/113496",
"pm_score": 3,
"selected": true,
"text": "<p>It all depends on how your theme's <code>header.php</code> is structured, but the most lik... | 2017/04/02 | [
"https://wordpress.stackexchange.com/questions/262196",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116780/"
] | I'm using WP 4.7.3 and a custom template set (mh-magazine).
By default, WP sets a title tag like "Page title" - "Blog title".
Now all I want to achieve is to replace "-" into a pipe symbol for layout reasons. So the processed HTMl should look like:
My page title | My blog title
I thought that this is easy to achiev... | It all depends on how your theme's `header.php` is structured, but the most likely way is via the [document\_title\_separator](https://developer.wordpress.org/reference/hooks/document_title_separator/) filter, as in
```
add_filter ('document_title_separator', 'wpse_set_document_title_separator') ;
function
wpse_set_d... |
262,220 | <p>I wanted to display ads on in post in a particular category. I also want to display ads in another category not only one but every time I insert the code again and change the category id, it causes a "white screen" error. Can you tell me how can I extend that function, that I will be able to display different ads i... | [
{
"answer_id": 262197,
"author": "Paul 'Sparrow Hawk' Biron",
"author_id": 113496,
"author_profile": "https://wordpress.stackexchange.com/users/113496",
"pm_score": 3,
"selected": true,
"text": "<p>It all depends on how your theme's <code>header.php</code> is structured, but the most lik... | 2017/04/03 | [
"https://wordpress.stackexchange.com/questions/262220",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115069/"
] | I wanted to display ads on in post in a particular category. I also want to display ads in another category not only one but every time I insert the code again and change the category id, it causes a "white screen" error. Can you tell me how can I extend that function, that I will be able to display different ads in di... | It all depends on how your theme's `header.php` is structured, but the most likely way is via the [document\_title\_separator](https://developer.wordpress.org/reference/hooks/document_title_separator/) filter, as in
```
add_filter ('document_title_separator', 'wpse_set_document_title_separator') ;
function
wpse_set_d... |
262,225 | <p>I want to change the size of the featued image for one custom post type only. This is what I currently have:</p>
<pre><code>function custom_admin_thumb_size($thumb_size){
global $post_type;
if( 'slider' == $post_type ){
return array(1000,400);
}else{
return array(266,266);
}
}
a... | [
{
"answer_id": 262228,
"author": "Jebble",
"author_id": 81939,
"author_profile": "https://wordpress.stackexchange.com/users/81939",
"pm_score": 1,
"selected": false,
"text": "<p>There is no filter to do this for just a certain post_type but you can use <code>get_post_type( esc_attr( $_GE... | 2017/04/03 | [
"https://wordpress.stackexchange.com/questions/262225",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102737/"
] | I want to change the size of the featued image for one custom post type only. This is what I currently have:
```
function custom_admin_thumb_size($thumb_size){
global $post_type;
if( 'slider' == $post_type ){
return array(1000,400);
}else{
return array(266,266);
}
}
add_filter( 'ad... | [`admin_post_thumbnail_size`](https://developer.wordpress.org/reference/hooks/admin_post_thumbnail_size/) takes three parameters:
1. $thumb\_size: selected Thumb Size if you do nothing in the filter.
2. $thumbnail\_id: Thumbnail attachment ID.
3. $post: associated WP\_Post instance
So you may make use of these parame... |
262,227 | <p>I am trying to retrieve all the post associated with my custom taxonomy term. My custom taxonomy is "Stores". I am using the following code.</p>
<pre><code>$posts = get_posts(array(
'post_type' => 'coupon',
'numberposts' => -1,
'post_status' => array('p... | [
{
"answer_id": 262228,
"author": "Jebble",
"author_id": 81939,
"author_profile": "https://wordpress.stackexchange.com/users/81939",
"pm_score": 1,
"selected": false,
"text": "<p>There is no filter to do this for just a certain post_type but you can use <code>get_post_type( esc_attr( $_GE... | 2017/04/03 | [
"https://wordpress.stackexchange.com/questions/262227",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110516/"
] | I am trying to retrieve all the post associated with my custom taxonomy term. My custom taxonomy is "Stores". I am using the following code.
```
$posts = get_posts(array(
'post_type' => 'coupon',
'numberposts' => -1,
'post_status' => array('publish', 'unreliable', ... | [`admin_post_thumbnail_size`](https://developer.wordpress.org/reference/hooks/admin_post_thumbnail_size/) takes three parameters:
1. $thumb\_size: selected Thumb Size if you do nothing in the filter.
2. $thumbnail\_id: Thumbnail attachment ID.
3. $post: associated WP\_Post instance
So you may make use of these parame... |
262,275 | <p>I want to conditionally add a body class depending on what template is being used.</p>
<p>I can't figure out why the following code is not working...</p>
<pre><code>function damsonhomes_body_classes( $classes ) {
if (is_page_template('single.php')) {
$classes[] = 'sans-hero';
}
return $classes;
}
a... | [
{
"answer_id": 262278,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 3,
"selected": true,
"text": "<p>The <a href=\"https://developer.wordpress.org/reference/functions/is_page_template/\" rel=\"nofollow norefer... | 2017/04/03 | [
"https://wordpress.stackexchange.com/questions/262275",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/57057/"
] | I want to conditionally add a body class depending on what template is being used.
I can't figure out why the following code is not working...
```
function damsonhomes_body_classes( $classes ) {
if (is_page_template('single.php')) {
$classes[] = 'sans-hero';
}
return $classes;
}
add_filter( 'body_clas... | The [`is_page_template()`](https://developer.wordpress.org/reference/functions/is_page_template/) function is the incorrect function to use in this case as it checks against [Page Templates](https://codex.wordpress.org/Pages#Page_Templates) and `single.php` is just a normal template, not a page specific one, usually me... |
262,286 | <p>I'm trying to load the 3 latests posts on my homepage. I'm an utter novice but I <em>seem</em> to be making progress.</p>
<p>This is my code (below). At the minute each post has a title of "Home", I understand that is because the homepage is the main query?</p>
<pre><code><?php
$latest_blog_posts = new WP_Q... | [
{
"answer_id": 262287,
"author": "rudtek",
"author_id": 77767,
"author_profile": "https://wordpress.stackexchange.com/users/77767",
"pm_score": 3,
"selected": true,
"text": "<p>This is how you would do it. You're loop is based on being in an archive or index page. (or home)</p>\n\n<pre>... | 2017/04/03 | [
"https://wordpress.stackexchange.com/questions/262286",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116827/"
] | I'm trying to load the 3 latests posts on my homepage. I'm an utter novice but I *seem* to be making progress.
This is my code (below). At the minute each post has a title of "Home", I understand that is because the homepage is the main query?
```
<?php
$latest_blog_posts = new WP_Query( array( 'posts_per_page' =... | This is how you would do it. You're loop is based on being in an archive or index page. (or home)
```
$args = array(
'posts_per_page' => 3,
'post_type' => 'post', //choose post type here
'order' => 'DESC',
);
// query
$the_query = new WP_Query( $args );
if( $the_query->have_posts() ):
while( $... |
262,299 | <p>Is there anyway to load a custom style in specific taxonomy pages?
for example these two pages: </p>
<pre><code>wp-admin/edit-tags.php?taxonomy=news-category&post_type=news
wp-admin/term.php?taxonomy=news-category&..
</code></pre>
<p>I added a style to admin but other pager got edited too, how can we load ... | [
{
"answer_id": 262302,
"author": "Paul 'Sparrow Hawk' Biron",
"author_id": 113496,
"author_profile": "https://wordpress.stackexchange.com/users/113496",
"pm_score": 4,
"selected": true,
"text": "<p>You can do it like this:</p>\n\n<pre><code>add_action ('admin_enqueue_scripts', 'wpse_styl... | 2017/04/03 | [
"https://wordpress.stackexchange.com/questions/262299",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116836/"
] | Is there anyway to load a custom style in specific taxonomy pages?
for example these two pages:
```
wp-admin/edit-tags.php?taxonomy=news-category&post_type=news
wp-admin/term.php?taxonomy=news-category&..
```
I added a style to admin but other pager got edited too, how can we load the style when in these two pages ... | You can do it like this:
```
add_action ('admin_enqueue_scripts', 'wpse_style_tax') ;
function
wpse_style_tax ()
{
// these 3 globals are set during execution of {edit-tags,term}.php
global $pagenow, $typenow, $taxnow ;
if (!in_array ($pagenow, array ('edit-tags.php', 'term.php')) {
return ;
... |
262,300 | <p>I'm saving my CPT in <a href="https://github.com/nanodesigns/nanosupport/blob/v0.3.3/includes/ns-set-environment.php#L355-L377" rel="nofollow noreferrer"><code>private</code> status</a>. So the transition would be from <code>pending</code> to <code>private</code>. Thing is, when the post was first submitted and is p... | [
{
"answer_id": 262306,
"author": "Paul 'Sparrow Hawk' Biron",
"author_id": 113496,
"author_profile": "https://wordpress.stackexchange.com/users/113496",
"pm_score": 3,
"selected": true,
"text": "<p>@Howdy_McGee is on the right track in his comment: by the time <a href=\"https://developer... | 2017/04/03 | [
"https://wordpress.stackexchange.com/questions/262300",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/22728/"
] | I'm saving my CPT in [`private` status](https://github.com/nanodesigns/nanosupport/blob/v0.3.3/includes/ns-set-environment.php#L355-L377). So the transition would be from `pending` to `private`. Thing is, when the post was first submitted and is pending there's a date of that submission on the `post_date` field in db. ... | @Howdy\_McGee is on the right track in his comment: by the time [transition\_post\_status](https://developer.wordpress.org/reference/hooks/transition_post_status) is fired, the post has already been updated (i.e., written to the db).
What you need to do is hook into [wp\_insert\_post\_data](https://developer.wordpress... |
262,301 | <p>I am trying to get rig of the <code>Disqus</code> script on my front page, but unfortunately I cannot manage how to do this.</p>
<p>Here is a little story of the steps I've done.</p>
<ol>
<li><p>Find the script name in the source code files of the plugin</p>
<p>wp_register_script( 'dsq_count_script', plugins_url(... | [
{
"answer_id": 262305,
"author": "Nathan Johnson",
"author_id": 106269,
"author_profile": "https://wordpress.stackexchange.com/users/106269",
"pm_score": 5,
"selected": true,
"text": "<p>When attempting to dequeue a script, we need to hook in after the script is enqueued, but before it's... | 2017/04/03 | [
"https://wordpress.stackexchange.com/questions/262301",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/93387/"
] | I am trying to get rig of the `Disqus` script on my front page, but unfortunately I cannot manage how to do this.
Here is a little story of the steps I've done.
1. Find the script name in the source code files of the plugin
wp\_register\_script( 'dsq\_count\_script', plugins\_url( '/media/js/count.js', **FILE** ) );... | When attempting to dequeue a script, we need to hook in after the script is enqueued, but before it's printed. In this case, the Disqus plugin is using the `wp_footer` hook at a priority of 10 to enqueue the scripts. The footer scripts get printed during `wp_footer` at a priority of 20. So we should be able to hook int... |
262,310 | <p>One of the pages on my company's website, the hero is displaying incorrectly. It seems that the news page is missing an "h3". Where is the document where i can edit this. an example of the difference is below.</p>
<p>So the careers page has it set up like so:</p>
<pre><code><div class="hero__content">
&l... | [
{
"answer_id": 262311,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 1,
"selected": false,
"text": "<p>It depends on your theme. To find out exactly which file to edit, add the following code to your <code>he... | 2017/04/03 | [
"https://wordpress.stackexchange.com/questions/262310",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116845/"
] | One of the pages on my company's website, the hero is displaying incorrectly. It seems that the news page is missing an "h3". Where is the document where i can edit this. an example of the difference is below.
So the careers page has it set up like so:
```
<div class="hero__content">
<div class="hero__content-wra... | It depends on your theme. To find out exactly which file to edit, add the following code to your `header.php` file inside `/wp-content/themes/nameofyourtheme`:
```
<!-- <?php global $template; print_r($template); ?> -->
```
You can then view the page in question's source and see a comment that tells you the name of ... |
262,319 | <p>I am trying to add a style to the header, using this method the style only loads on single posts but if I use a shortcode to load the post content that style does not load in the header: </p>
<pre><code>add_action( 'wp_head', 'output_styles')
function output_styles($base_ID){
$global post;
echo '<style t... | [
{
"answer_id": 262324,
"author": "Paul 'Sparrow Hawk' Biron",
"author_id": 113496,
"author_profile": "https://wordpress.stackexchange.com/users/113496",
"pm_score": 1,
"selected": false,
"text": "<p>In this case, <a href=\"https://developer.wordpress.org/reference/functions/has_shortcode... | 2017/04/03 | [
"https://wordpress.stackexchange.com/questions/262319",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116836/"
] | I am trying to add a style to the header, using this method the style only loads on single posts but if I use a shortcode to load the post content that style does not load in the header:
```
add_action( 'wp_head', 'output_styles')
function output_styles($base_ID){
$global post;
echo '<style type="text/css">'.... | In this case, [has\_shortcode()](https://developer.wordpress.org/reference/functions/has_shortcode/) is your friend.
First, we hook into [wp\_print\_styles](https://developer.wordpress.org/reference/hooks/wp_print_styles/), instead of `wp_head`. In the func we hook
we check if the post contains our shortcode. If it do... |
262,326 | <p>I have a "utility navigation" on the top of my website that currently has two links - one to our blog and the other to the weekly newsletter. We also do a radio show everyday at 5pm, as well as a rerun on Saturday at 7am and 7pm. During this time, I would like a third menu item to appear with a link to the podcast t... | [
{
"answer_id": 262440,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 1,
"selected": true,
"text": "<p>Since you need to edit theme files, you'll first want to determine whether you're using a custom-built the... | 2017/04/03 | [
"https://wordpress.stackexchange.com/questions/262326",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116850/"
] | I have a "utility navigation" on the top of my website that currently has two links - one to our blog and the other to the weekly newsletter. We also do a radio show everyday at 5pm, as well as a rerun on Saturday at 7am and 7pm. During this time, I would like a third menu item to appear with a link to the podcast to l... | Since you need to edit theme files, you'll first want to determine whether you're using a custom-built theme or something that was downloaded from somewhere. If it was downloaded from somewhere, you'll need to create a [child theme](https://codex.wordpress.org/Child_Themes) (basically, you just create a new `style.css`... |
262,339 | <p>I'm using Advanced Custom Fields and Genesis and trying to modify a template to reflect a relationship between two custom post types (using their associated custom fields.) In this case, I have custom post types for "Staff" and "Reports", and for staff, I have the custom fields "first_name" and "last_name"; and asso... | [
{
"answer_id": 262345,
"author": "rudtek",
"author_id": 77767,
"author_profile": "https://wordpress.stackexchange.com/users/77767",
"pm_score": 3,
"selected": true,
"text": "<p>I haven't tested this but it SHOULD work. You'll want to put it in the single-staff.php. You'll have to add t... | 2017/04/04 | [
"https://wordpress.stackexchange.com/questions/262339",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/89753/"
] | I'm using Advanced Custom Fields and Genesis and trying to modify a template to reflect a relationship between two custom post types (using their associated custom fields.) In this case, I have custom post types for "Staff" and "Reports", and for staff, I have the custom fields "first\_name" and "last\_name"; and assoc... | I haven't tested this but it SHOULD work. You'll want to put it in the single-staff.php. You'll have to add the details (actual query, post types, etc).
```
$reports = get_posts(array(
'post_type' => 'reports', //use actual post type
'meta_query' => array(
... |
262,340 | <p>I'm developing a single page application (SAP) based theme, where I've <strong>Portfolio</strong> CPT to show portfolio items in loop other than blog posts.</p>
<p>I've built 2 separate posts load more function which triggers on click. SO the blog posts are working fine, but on click on load more button on <strong>... | [
{
"answer_id": 262345,
"author": "rudtek",
"author_id": 77767,
"author_profile": "https://wordpress.stackexchange.com/users/77767",
"pm_score": 3,
"selected": true,
"text": "<p>I haven't tested this but it SHOULD work. You'll want to put it in the single-staff.php. You'll have to add t... | 2017/04/04 | [
"https://wordpress.stackexchange.com/questions/262340",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/78274/"
] | I'm developing a single page application (SAP) based theme, where I've **Portfolio** CPT to show portfolio items in loop other than blog posts.
I've built 2 separate posts load more function which triggers on click. SO the blog posts are working fine, but on click on load more button on **Portfolio** section it append... | I haven't tested this but it SHOULD work. You'll want to put it in the single-staff.php. You'll have to add the details (actual query, post types, etc).
```
$reports = get_posts(array(
'post_type' => 'reports', //use actual post type
'meta_query' => array(
... |
262,371 | <p>How i can add custom text to menu?
I want such structure in output:</p>
<pre><code><ul>
<li>home</li>
<li>services
<ul>
<p>services</p>
<li><a href="#">service1</a></li>
<li><a href="#"&... | [
{
"answer_id": 262379,
"author": "Abhishek Pandey",
"author_id": 114826,
"author_profile": "https://wordpress.stackexchange.com/users/114826",
"pm_score": -1,
"selected": false,
"text": "<p>You can add it by back end appearance > menu and create menu and > sub menu by dragging page or po... | 2017/04/04 | [
"https://wordpress.stackexchange.com/questions/262371",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116880/"
] | How i can add custom text to menu?
I want such structure in output:
```
<ul>
<li>home</li>
<li>services
<ul>
<p>services</p>
<li><a href="#">service1</a></li>
<li><a href="#">service2</a></li>
<li><a href="#">service3</a>
<ul>
... | There is another alt way to do this with CSS3. You would add a link to the WP Menu as normal but make the Location either `javascript:void(0);` or `#` so it doesn't go anywhere (I would say the `javascript...` is the better way to prevent anchor link from firing).
Then in your style.css or CSS doc you can get target t... |
262,393 | <p>Is is possible to remove all the categories from a product in WooCommerce?</p>
<p>I have written a script which is run every time when a product is added/updated via WP-All-Import, but there are some wrong categories on the products, which I want to clean, deleting all the categories or products is not an option, s... | [
{
"answer_id": 262402,
"author": "NVO",
"author_id": 116406,
"author_profile": "https://wordpress.stackexchange.com/users/116406",
"pm_score": 2,
"selected": true,
"text": "<p>I have found the solution, actually it is very simple:</p>\n\n<pre><code>$terms = get_the_terms($product_id, 'pr... | 2017/04/04 | [
"https://wordpress.stackexchange.com/questions/262393",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116406/"
] | Is is possible to remove all the categories from a product in WooCommerce?
I have written a script which is run every time when a product is added/updated via WP-All-Import, but there are some wrong categories on the products, which I want to clean, deleting all the categories or products is not an option, so I want c... | I have found the solution, actually it is very simple:
```
$terms = get_the_terms($product_id, 'product_cat');
foreach($terms as $term){
wp_remove_object_terms($product_id, $term->term_id, 'product_cat');
}
```
This code get all the therms with the 'product\_cat' taxonomy, with a foreach loop I remove all the it... |
262,423 | <p>When adding a new user role with <a href="https://developer.wordpress.org/reference/functions/add_role/" rel="nofollow noreferrer"><code>add_role()</code></a>, are there any capabilities attributed to the role (or allowed by the role) by default?</p>
<p>It is possible to create a role without defining any capabilit... | [
{
"answer_id": 262461,
"author": "mmm",
"author_id": 74311,
"author_profile": "https://wordpress.stackexchange.com/users/74311",
"pm_score": 1,
"selected": false,
"text": "<p>With the default value (empty array), there is no capabilities added to the role (not even <code>read</code>) and... | 2017/04/04 | [
"https://wordpress.stackexchange.com/questions/262423",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/33393/"
] | When adding a new user role with [`add_role()`](https://developer.wordpress.org/reference/functions/add_role/), are there any capabilities attributed to the role (or allowed by the role) by default?
It is possible to create a role without defining any capabilities. There will simply be no capabilities set for this rol... | I've found that the WordPress `has_cap()` function, which is relied on by functions like `user_can()` and `current_user_can`, explicitly returns false for empty capabilities.
Example: If a capability is passed as an argument using [`current_user_can()`](https://developer.wordpress.org/reference/functions/current_user_... |
262,427 | <p>I'm looking to pull all of the metadata (e.g. alt, width, height) from the theme logo, which is uploaded through Appearance -> Customization into my theme template file. This is what I currently have, but it's not working:</p>
<pre><code>$custom_logo_id = get_theme_mod('custom_logo');
if ($custom_logo_id) {
$im... | [
{
"answer_id": 262445,
"author": "brandozz",
"author_id": 64789,
"author_profile": "https://wordpress.stackexchange.com/users/64789",
"pm_score": 1,
"selected": false,
"text": "<p>Ends up that \"alt\" is not stored in wp_get_attachment_metadata so I pulled it from the post meta:</p>\n\n<... | 2017/04/04 | [
"https://wordpress.stackexchange.com/questions/262427",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64789/"
] | I'm looking to pull all of the metadata (e.g. alt, width, height) from the theme logo, which is uploaded through Appearance -> Customization into my theme template file. This is what I currently have, but it's not working:
```
$custom_logo_id = get_theme_mod('custom_logo');
if ($custom_logo_id) {
$image = wp_get_a... | Ends up that "alt" is not stored in wp\_get\_attachment\_metadata so I pulled it from the post meta:
```
$custom_logo_id = get_theme_mod('custom_logo');
if ($custom_logo_id) {
$image = wp_get_attachment_image_src($custom_logo_id, 'full');
$meta = wp_get_attachment_metadata($custom_logo_id);
**$alt_text = g... |
262,438 | <p>I have the code below to list the recent posts on my site. It's working fine.</p>
<p>I need to style differently the first post (bigger image and bigger title).</p>
<p>Any idea how ?</p>
<pre><code><?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array( 'post_type' => 'post', 'p... | [
{
"answer_id": 262439,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 1,
"selected": false,
"text": "<p>You will have to need to redirect all your traffics from HTTP to HTTPS. A rewrite rule can do this for you.... | 2017/04/04 | [
"https://wordpress.stackexchange.com/questions/262438",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/92431/"
] | I have the code below to list the recent posts on my site. It's working fine.
I need to style differently the first post (bigger image and bigger title).
Any idea how ?
```
<?php $paged = (get_query_var('paged')) ? get_query_var('paged') : 1;
$args = array( 'post_type' => 'post', 'posts_per_page' => 10, 'paged' => $... | This is happening because WordPress saves URLs in content absolutely by default (meaning that it's actually got your urls saved as <http://example.com> in the database). So to fix this you'll want to run a search and replace in your database to fix those errors.
I like to use the plugin [Better Search Replace](https:/... |
262,478 | <p>So I have followed the tutorial below to reset my own passwords when I get forget my password for WordPress Admin login</p>
<p><a href="https://crybit.com/reset-wordpress-users-password/" rel="nofollow noreferrer">https://crybit.com/reset-wordpress-users-password/</a></p>
<p>but it does not seem to work for this o... | [
{
"answer_id": 262485,
"author": "Charles",
"author_id": 15605,
"author_profile": "https://wordpress.stackexchange.com/users/15605",
"pm_score": 1,
"selected": false,
"text": "<p>Maybe this is not the answer you look for but giving one of below a try could maybe help you out?!<br /></p>\... | 2017/04/04 | [
"https://wordpress.stackexchange.com/questions/262478",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/109760/"
] | So I have followed the tutorial below to reset my own passwords when I get forget my password for WordPress Admin login
<https://crybit.com/reset-wordpress-users-password/>
but it does not seem to work for this other site I am working on. I am not sure why. I have heard colleagues talk about the PHP Portable password... | you all have been wonderful resources. Now for the answer. It was a plugin called Wordfence that refused to recognize any user I created via wp\_users table. If the person with admin privileges did not create my user, there was no way I was going to get in. The users I created it says Existing User No, but when a colle... |
262,484 | <p>I added some shortcode after the content using filter, like this:</p>
<pre><code>add_filter( 'the_content', 'image_posts' );
</code></pre>
<p>but now that I run <code>has_shortcode</code> in another function, this returns false even though the shortcode is there (which was added using the above filter. </p>
<pre>... | [
{
"answer_id": 262487,
"author": "Ian",
"author_id": 11583,
"author_profile": "https://wordpress.stackexchange.com/users/11583",
"pm_score": 1,
"selected": false,
"text": "<p>For this, you'll actually want to utilize the <code>wp_enqueue_scripts</code> action instead of <code>wp_head</co... | 2017/04/05 | [
"https://wordpress.stackexchange.com/questions/262484",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116939/"
] | I added some shortcode after the content using filter, like this:
```
add_filter( 'the_content', 'image_posts' );
```
but now that I run `has_shortcode` in another function, this returns false even though the shortcode is there (which was added using the above filter.
```
add_action( 'wp_head', 'gallery_style');
f... | For this, you'll actually want to utilize the `wp_enqueue_scripts` action instead of `wp_head`.
`wp_enqueue_scripts` is technically the proper way to add scripts and styles to your site. This action allows us to both register scripts and styles for later use (which is what we want here) and allows us to output scripts... |
262,491 | <p>I am making a theme that will be updateable via github.
<a href="https://github.com/pallazzio/skeleton" rel="nofollow noreferrer">https://github.com/pallazzio/skeleton</a></p>
<p>I am trying to use the plugin updater tutorial from smashing magazine, modified for updating a theme instead.
<a href="https://www.smashi... | [
{
"answer_id": 262487,
"author": "Ian",
"author_id": 11583,
"author_profile": "https://wordpress.stackexchange.com/users/11583",
"pm_score": 1,
"selected": false,
"text": "<p>For this, you'll actually want to utilize the <code>wp_enqueue_scripts</code> action instead of <code>wp_head</co... | 2017/04/05 | [
"https://wordpress.stackexchange.com/questions/262491",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115138/"
] | I am making a theme that will be updateable via github.
<https://github.com/pallazzio/skeleton>
I am trying to use the plugin updater tutorial from smashing magazine, modified for updating a theme instead.
<https://www.smashingmagazine.com/2015/08/deploy-wordpress-plugins-with-github-using-transients/>
I got it almos... | For this, you'll actually want to utilize the `wp_enqueue_scripts` action instead of `wp_head`.
`wp_enqueue_scripts` is technically the proper way to add scripts and styles to your site. This action allows us to both register scripts and styles for later use (which is what we want here) and allows us to output scripts... |
262,506 | <p>I would like to show comment count IN the post (not in post meta), is there a snippet how to do this or a wordpress internal shortcode? </p>
| [
{
"answer_id": 262487,
"author": "Ian",
"author_id": 11583,
"author_profile": "https://wordpress.stackexchange.com/users/11583",
"pm_score": 1,
"selected": false,
"text": "<p>For this, you'll actually want to utilize the <code>wp_enqueue_scripts</code> action instead of <code>wp_head</co... | 2017/04/05 | [
"https://wordpress.stackexchange.com/questions/262506",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102691/"
] | I would like to show comment count IN the post (not in post meta), is there a snippet how to do this or a wordpress internal shortcode? | For this, you'll actually want to utilize the `wp_enqueue_scripts` action instead of `wp_head`.
`wp_enqueue_scripts` is technically the proper way to add scripts and styles to your site. This action allows us to both register scripts and styles for later use (which is what we want here) and allows us to output scripts... |
262,527 | <p>On one particular site, when I do a search, not all relevant results are returned.</p>
<p>Example:</p>
<p>Post Title: This is xxx</p>
<p>Post Content: Hello World, this is xxx.</p>
<p>When searching for 'xxx', the post isn't returned in the search results.</p>
<p>Is this expected behaviour, and how do I fix thi... | [
{
"answer_id": 262524,
"author": "Shivanand Sharma",
"author_id": 116231,
"author_profile": "https://wordpress.stackexchange.com/users/116231",
"pm_score": 0,
"selected": false,
"text": "<p>The function <code>wp_send_new_user_notifications</code> automatically sends the registration info... | 2017/04/05 | [
"https://wordpress.stackexchange.com/questions/262527",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50432/"
] | On one particular site, when I do a search, not all relevant results are returned.
Example:
Post Title: This is xxx
Post Content: Hello World, this is xxx.
When searching for 'xxx', the post isn't returned in the search results.
Is this expected behaviour, and how do I fix this?
This is the code for the search te... | You can get the last inserted id at the time of registration and with this id get the user meta by meta keys you assign and send mail with details. |
262,534 | <pre><code> register_setting('Y-sidebar-options','picture');
</code></pre>
<p>where do the option group name stored in database . </p>
| [
{
"answer_id": 262524,
"author": "Shivanand Sharma",
"author_id": 116231,
"author_profile": "https://wordpress.stackexchange.com/users/116231",
"pm_score": 0,
"selected": false,
"text": "<p>The function <code>wp_send_new_user_notifications</code> automatically sends the registration info... | 2017/04/05 | [
"https://wordpress.stackexchange.com/questions/262534",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116882/"
] | ```
register_setting('Y-sidebar-options','picture');
```
where do the option group name stored in database . | You can get the last inserted id at the time of registration and with this id get the user meta by meta keys you assign and send mail with details. |
262,569 | <p>Any reason this code does not work in the admin section (specifically when ajaxing but the issue persists on other pages) of WordPress but works just fine</p>
<pre><code>ob_start();
dynamic_sidebar('frontpage_widgets');
$content = ob_get_clean();
print_r($content); // nothing
</code></pre>
<p>the sidebars ar... | [
{
"answer_id": 262990,
"author": "Atul Jindal",
"author_id": 58957,
"author_profile": "https://wordpress.stackexchange.com/users/58957",
"pm_score": -1,
"selected": false,
"text": "<p>Try to logout the admin, and then see the code behavior. Sometimes, due to login session this behavior i... | 2017/04/05 | [
"https://wordpress.stackexchange.com/questions/262569",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19536/"
] | Any reason this code does not work in the admin section (specifically when ajaxing but the issue persists on other pages) of WordPress but works just fine
```
ob_start();
dynamic_sidebar('frontpage_widgets');
$content = ob_get_clean();
print_r($content); // nothing
```
the sidebars are set from what I see (bec... | Yes, you have to make sure to hook this function at some point after the sidebars are registered. It's not quite explained, but implied in the codex that this function [`dynamic_sidebar( $index )`](https://codex.wordpress.org/Function_Reference/dynamic_sidebar) expects them to be registered and loaded as registered by ... |
262,579 | <p>I'm trying to create a code that will show the a photo if there is featured image otherwise it will just show the page title. This code is in my header as it's near the logo.</p>
<p>When I use this code on a page without a featured image:</p>
<pre><code><?php
if ( get_post_thumbnail_id() =='' ) {
echo 'no ... | [
{
"answer_id": 262990,
"author": "Atul Jindal",
"author_id": 58957,
"author_profile": "https://wordpress.stackexchange.com/users/58957",
"pm_score": -1,
"selected": false,
"text": "<p>Try to logout the admin, and then see the code behavior. Sometimes, due to login session this behavior i... | 2017/04/05 | [
"https://wordpress.stackexchange.com/questions/262579",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/105668/"
] | I'm trying to create a code that will show the a photo if there is featured image otherwise it will just show the page title. This code is in my header as it's near the logo.
When I use this code on a page without a featured image:
```
<?php
if ( get_post_thumbnail_id() =='' ) {
echo 'no picture';
echo 'its i... | Yes, you have to make sure to hook this function at some point after the sidebars are registered. It's not quite explained, but implied in the codex that this function [`dynamic_sidebar( $index )`](https://codex.wordpress.org/Function_Reference/dynamic_sidebar) expects them to be registered and loaded as registered by ... |
262,582 | <p>I want to add a custom image size to my child theme.</p>
<p>The base is the Penscratch theme, and it has it own image sizes defined:</p>
<pre><code>function penscratch_setup() {
/* ... */
add_theme_support( 'post-thumbnails' );
add_image_size( 'penscratch-featured', '400', '200', true );
/* .... | [
{
"answer_id": 262583,
"author": "Shivanand Sharma",
"author_id": 116231,
"author_profile": "https://wordpress.stackexchange.com/users/116231",
"pm_score": 3,
"selected": true,
"text": "<p>After you add a new image size, you have to regenerate the images for that size. The <a href=\"http... | 2017/04/05 | [
"https://wordpress.stackexchange.com/questions/262582",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/116999/"
] | I want to add a custom image size to my child theme.
The base is the Penscratch theme, and it has it own image sizes defined:
```
function penscratch_setup() {
/* ... */
add_theme_support( 'post-thumbnails' );
add_image_size( 'penscratch-featured', '400', '200', true );
/* ... */
}
```
And if... | After you add a new image size, you have to regenerate the images for that size. The [Regenerate Thumbnails](https://wordpress.org/plugins/regenerate-thumbnails/) plugin comes in handy for this purpose. |
262,593 | <p>I'm working on a WordPress website and I'd like to modify the password reset screen <code>/wp-login.php?action=rp</code>. Currently, the password reset screen generates a new password for the user and I want to add a <code>Confirm Password</code> field and make it a required field.</p>
<p>I think I've found the rel... | [
{
"answer_id": 262607,
"author": "birgire",
"author_id": 26350,
"author_profile": "https://wordpress.stackexchange.com/users/26350",
"pm_score": 3,
"selected": true,
"text": "<p>It's tempting to unhide the <code>pass2</code> input but that's not enough. </p>\n\n<p>In the file <code>/wp-a... | 2017/04/05 | [
"https://wordpress.stackexchange.com/questions/262593",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/114722/"
] | I'm working on a WordPress website and I'd like to modify the password reset screen `/wp-login.php?action=rp`. Currently, the password reset screen generates a new password for the user and I want to add a `Confirm Password` field and make it a required field.
I think I've found the relevant code in the `wp-login.php`... | It's tempting to unhide the `pass2` input but that's not enough.
In the file `/wp-admin/js/user-profile.js` the `bindPass1()` binds it to `pass1` that makes writing to it not possible. The `pass2` input is then hidden in `bindPasswordForm()` with `$('.user-pass2-wrap').hide();`
We can instead add our own input field... |
262,634 | <p>I am trying to cleanup unnecessary code in a wordpress site. I see, in html source code of the website, there is a javascript. it is adroll script, check below...</p>
<pre><code><script type="text/javascript">
adroll_adv_id = "4XJPGN2DSVEYBBDED4DKXK";
adroll_pix_id = "SEEYI5KV2BA53OK5YIG7IP";
(function () {
v... | [
{
"answer_id": 262665,
"author": "Barry Kooij",
"author_id": 16655,
"author_profile": "https://wordpress.stackexchange.com/users/16655",
"pm_score": 3,
"selected": true,
"text": "<p>I would download all files via FTP and search in the folder for <code>adroll_adv_id</code>. If there's no ... | 2017/04/06 | [
"https://wordpress.stackexchange.com/questions/262634",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102538/"
] | I am trying to cleanup unnecessary code in a wordpress site. I see, in html source code of the website, there is a javascript. it is adroll script, check below...
```
<script type="text/javascript">
adroll_adv_id = "4XJPGN2DSVEYBBDED4DKXK";
adroll_pix_id = "SEEYI5KV2BA53OK5YIG7IP";
(function () {
var oldonload = windo... | I would download all files via FTP and search in the folder for `adroll_adv_id`. If there's no result then it's either in the database or obfuscated. |
262,644 | <p>For our WordPress-website, I wanted to create a test instance - to test WordPress-updates/plugin updates and new developments on the theme and so on ...</p>
<p>so i wrote a script to copy the database and the files:</p>
<pre><code>sourcedir="/srv/www/htdocs/www.example.de"
testdir="/srv/www/htdocs/test.example.de"... | [
{
"answer_id": 262646,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 2,
"selected": true,
"text": "<p>In general test enviroments better use the same domain name as the live site. Since it doesn't seem like y... | 2017/04/06 | [
"https://wordpress.stackexchange.com/questions/262644",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/117033/"
] | For our WordPress-website, I wanted to create a test instance - to test WordPress-updates/plugin updates and new developments on the theme and so on ...
so i wrote a script to copy the database and the files:
```
sourcedir="/srv/www/htdocs/www.example.de"
testdir="/srv/www/htdocs/test.example.de"
workdir="/data/examp... | In general test enviroments better use the same domain name as the live site. Since it doesn't seem like you follow such pattern (and yes, it is harder to follow), you need to make sure you convert all the URLs in the DB properly, and the way you do it will fail with any data which is serialized. Use wp-cli to change U... |
262,654 | <p>I managed to make my code working via codepen as you can see if you visit the link <a href="http://codepen.io/Sidney-Dev/pen/gmyoWM?editors=1111" rel="nofollow noreferrer">here</a></p>
<p>Now trying to implement on a WordPress test site it looks like my javascript is not working as well as the fontawesome is not be... | [
{
"answer_id": 262646,
"author": "Mark Kaplun",
"author_id": 23970,
"author_profile": "https://wordpress.stackexchange.com/users/23970",
"pm_score": 2,
"selected": true,
"text": "<p>In general test enviroments better use the same domain name as the live site. Since it doesn't seem like y... | 2017/04/06 | [
"https://wordpress.stackexchange.com/questions/262654",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/99178/"
] | I managed to make my code working via codepen as you can see if you visit the link [here](http://codepen.io/Sidney-Dev/pen/gmyoWM?editors=1111)
Now trying to implement on a WordPress test site it looks like my javascript is not working as well as the fontawesome is not being loaded properly.
[Here is the link for the ... | In general test enviroments better use the same domain name as the live site. Since it doesn't seem like you follow such pattern (and yes, it is harder to follow), you need to make sure you convert all the URLs in the DB properly, and the way you do it will fail with any data which is serialized. Use wp-cli to change U... |
262,677 | <p>I have defined the following custom post type + taxonomy </p>
<pre><code>$productTaxonomyLabels = [
'name' => __('Product Categories', 'byronposttypes'),
'singular_name' => __('Product Category', 'byronposttypes'),
];
$productTaxonomyArgs = [
'labels' => $productTaxonomyLab... | [
{
"answer_id": 262661,
"author": "Abdul Awal Uzzal",
"author_id": 31449,
"author_profile": "https://wordpress.stackexchange.com/users/31449",
"pm_score": 3,
"selected": true,
"text": "<p>File name should be <code>admin-ajax.php</code></p>\n\n<p>This file handles all the ajax requests. So... | 2017/04/06 | [
"https://wordpress.stackexchange.com/questions/262677",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/106941/"
] | I have defined the following custom post type + taxonomy
```
$productTaxonomyLabels = [
'name' => __('Product Categories', 'byronposttypes'),
'singular_name' => __('Product Category', 'byronposttypes'),
];
$productTaxonomyArgs = [
'labels' => $productTaxonomyLabels,
'public' =>... | File name should be `admin-ajax.php`
This file handles all the ajax requests. So, you should never remove this file.
Many features will stop working like autosave and many other that uses ajax if you remove this file. |
262,712 | <p>I am using <a href="http://underscores.me/" rel="nofollow noreferrer">Underscores</a> starter theme and I've created a custom post type <code>video</code>.</p>
<pre><code>$args = array(
'label' => __( 'Video', 'text_domain' ),
'description' => __( 'Videos', 'text_domain' ),
... | [
{
"answer_id": 262714,
"author": "rudtek",
"author_id": 77767,
"author_profile": "https://wordpress.stackexchange.com/users/77767",
"pm_score": 4,
"selected": true,
"text": "<p>In your dashboard go to settings/permalinks. Hit save. You should be able to see your cpts now.</p>\n"
},
... | 2017/04/06 | [
"https://wordpress.stackexchange.com/questions/262712",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/50147/"
] | I am using [Underscores](http://underscores.me/) starter theme and I've created a custom post type `video`.
```
$args = array(
'label' => __( 'Video', 'text_domain' ),
'description' => __( 'Videos', 'text_domain' ),
'labels' => $labels,
'supports' =... | In your dashboard go to settings/permalinks. Hit save. You should be able to see your cpts now. |
262,725 | <p>I made a mistake and changed the URL under settings -> General. After this Wordpress locked me out. I first added in the wp-congif.php file: </p>
<pre><code>define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
</code></pre>
<p>This appeared to have fixed the issue but only if I was lo... | [
{
"answer_id": 262728,
"author": "Jonny Perl",
"author_id": 40765,
"author_profile": "https://wordpress.stackexchange.com/users/40765",
"pm_score": 0,
"selected": false,
"text": "<p>Take a look in the wp_options table and check the values for <code>siteurl</code> and <code>home</code> - ... | 2017/04/06 | [
"https://wordpress.stackexchange.com/questions/262725",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115742/"
] | I made a mistake and changed the URL under settings -> General. After this Wordpress locked me out. I first added in the wp-congif.php file:
```
define('WP_HOME','http://example.com');
define('WP_SITEURL','http://example.com');
```
This appeared to have fixed the issue but only if I was logged into Wordpress. Users... | Fixed by adding a htaccess file to the root directory with this information:
```
<IfModule mod_rewrite.c>
RewriteEngine on
RewriteCond %{HTTP_HOST} ^(www.)?example.com$
RewriteCond %{REQUEST_URI} !^/my_subdir/
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ /my_subdir/$1
Rewr... |