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 |
|---|---|---|---|---|---|---|
306,726 | <p>I apologize in advance if this is wrong place to ask my question (mods: please move it to appropriate place)</p>
<hr>
<p>I'm seeing following message in my wordpress logs:</p>
<blockquote>
<p>PHP Warning: include(): Unable to allocate memory for pool.</p>
</blockquote>
<p>and/or</p>
<blockquote>
<p>PHP War... | [
{
"answer_id": 306735,
"author": "Edward Caissie",
"author_id": 1952,
"author_profile": "https://wordpress.stackexchange.com/users/1952",
"pm_score": 1,
"selected": false,
"text": "<p>Does this topic help (it appears to be referencing the items you are looking at currently) <a href=\"htt... | 2018/06/22 | [
"https://wordpress.stackexchange.com/questions/306726",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/3255/"
] | I apologize in advance if this is wrong place to ask my question (mods: please move it to appropriate place)
---
I'm seeing following message in my wordpress logs:
>
> PHP Warning: include(): Unable to allocate memory for pool.
>
>
>
and/or
>
> PHP Warning: Unknown: Unable to allocate memory for pool. in Unkn... | Does this topic help (it appears to be referencing the items you are looking at currently) <https://stackoverflow.com/questions/3723316/what-is-causing-unable-to-allocate-memory-for-pool-in-php> ? |
306,752 | <p>I'm hoping someone who knows more than me about PHP and WordPress can help me out with this issue. I have a custom post type with posts I am displaying using the following code:</p>
<pre><code><?php $args = array( 'post_type' => 'upcoming_event', 'posts_per_page' => 3 );
$loop = new WP_Query( $args );
w... | [
{
"answer_id": 306735,
"author": "Edward Caissie",
"author_id": 1952,
"author_profile": "https://wordpress.stackexchange.com/users/1952",
"pm_score": 1,
"selected": false,
"text": "<p>Does this topic help (it appears to be referencing the items you are looking at currently) <a href=\"htt... | 2018/06/22 | [
"https://wordpress.stackexchange.com/questions/306752",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/145742/"
] | I'm hoping someone who knows more than me about PHP and WordPress can help me out with this issue. I have a custom post type with posts I am displaying using the following code:
```
<?php $args = array( 'post_type' => 'upcoming_event', 'posts_per_page' => 3 );
$loop = new WP_Query( $args );
while ( $loop->have_post... | Does this topic help (it appears to be referencing the items you are looking at currently) <https://stackoverflow.com/questions/3723316/what-is-causing-unable-to-allocate-memory-for-pool-in-php> ? |
306,756 | <p>I noticed recently that when uploading files larger than 7mb to a Wordpress site that I developed, I get an HTTP Error. I've checked some of my PHP variables, and have verified that <code>memory_limit</code> is set to 256M and both <code>post_max_size</code> and <code>upload_max_filesize</code> are set to 128M. Afte... | [
{
"answer_id": 306761,
"author": "Andy Macaulay-Brook",
"author_id": 94267,
"author_profile": "https://wordpress.stackexchange.com/users/94267",
"pm_score": 2,
"selected": false,
"text": "<p>I sometimes get this exact same issue and set of symptoms.</p>\n\n<p>It's caused by the image bei... | 2018/06/22 | [
"https://wordpress.stackexchange.com/questions/306756",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/47939/"
] | I noticed recently that when uploading files larger than 7mb to a Wordpress site that I developed, I get an HTTP Error. I've checked some of my PHP variables, and have verified that `memory_limit` is set to 256M and both `post_max_size` and `upload_max_filesize` are set to 128M. After reading [this thread](https://word... | I sometimes get this exact same issue and set of symptoms.
It's caused by the image being too large for the memory available. Not the file size as that has compressed data, but the actual width x height x colourdepth.
You can see the full size image because it uploaded fine. You have trouble in the media browser beca... |
306,784 | <p><a href="https://developer.wordpress.org/themes/advanced-topics/child-themes/#3-enqueue-stylesheet" rel="nofollow noreferrer">WordPress documentation</a> says to enqueue parent stylesheet in child theme:</p>
<pre><code>add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles()... | [
{
"answer_id": 306761,
"author": "Andy Macaulay-Brook",
"author_id": 94267,
"author_profile": "https://wordpress.stackexchange.com/users/94267",
"pm_score": 2,
"selected": false,
"text": "<p>I sometimes get this exact same issue and set of symptoms.</p>\n\n<p>It's caused by the image bei... | 2018/06/23 | [
"https://wordpress.stackexchange.com/questions/306784",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/2426/"
] | [WordPress documentation](https://developer.wordpress.org/themes/advanced-topics/child-themes/#3-enqueue-stylesheet) says to enqueue parent stylesheet in child theme:
```
add_action( 'wp_enqueue_scripts', 'my_theme_enqueue_styles' );
function my_theme_enqueue_styles() {
$parent_style = 'parent-style';
// Why... | I sometimes get this exact same issue and set of symptoms.
It's caused by the image being too large for the memory available. Not the file size as that has compressed data, but the actual width x height x colourdepth.
You can see the full size image because it uploaded fine. You have trouble in the media browser beca... |
306,816 | <p>I'm using Contact Form 7 and Flamingo to create a consultant registration form on my Wordpress site. By my client request, every submission need to have a registration code (reg_code) which is a combination of submission date and a random number to make it unique.</p>
<p>So I added an hidden input field to my CF7 c... | [
{
"answer_id": 306819,
"author": "Andy Macaulay-Brook",
"author_id": 94267,
"author_profile": "https://wordpress.stackexchange.com/users/94267",
"pm_score": 3,
"selected": true,
"text": "<p>You could save your AJAX pain and go about this in a different way by placing a hidden field withi... | 2018/06/23 | [
"https://wordpress.stackexchange.com/questions/306816",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/70137/"
] | I'm using Contact Form 7 and Flamingo to create a consultant registration form on my Wordpress site. By my client request, every submission need to have a registration code (reg\_code) which is a combination of submission date and a random number to make it unique.
So I added an hidden input field to my CF7 code with ... | You could save your AJAX pain and go about this in a different way by placing a hidden field within your form in PHP.
Method 1, with the aid of a plugin
==================================
I generally use the Contact Form 7 Dynamic Text Extension plugin as an easy route to creating custom CF7 tags, which still needs a... |
306,859 | <p>I want my WordPress homepage to display post by popularity. Like it automatically bring the post to top which have been visited by most visitors and same in ascending order.
Any help will be appreciated.</p>
| [
{
"answer_id": 306819,
"author": "Andy Macaulay-Brook",
"author_id": 94267,
"author_profile": "https://wordpress.stackexchange.com/users/94267",
"pm_score": 3,
"selected": true,
"text": "<p>You could save your AJAX pain and go about this in a different way by placing a hidden field withi... | 2018/06/24 | [
"https://wordpress.stackexchange.com/questions/306859",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/145800/"
] | I want my WordPress homepage to display post by popularity. Like it automatically bring the post to top which have been visited by most visitors and same in ascending order.
Any help will be appreciated. | You could save your AJAX pain and go about this in a different way by placing a hidden field within your form in PHP.
Method 1, with the aid of a plugin
==================================
I generally use the Contact Form 7 Dynamic Text Extension plugin as an easy route to creating custom CF7 tags, which still needs a... |
306,868 | <p>I'm new to wordpress and am trying to develop my first own theme. The thing is: the front page must be static, with no display of posts. But I need a blog section and am trying to do it by creating a custom page template that calls the last 10 posts.</p>
<p>How would I do that using the loop? Please, help me! Thank... | [
{
"answer_id": 306879,
"author": "Andy Macaulay-Brook",
"author_id": 94267,
"author_profile": "https://wordpress.stackexchange.com/users/94267",
"pm_score": 0,
"selected": false,
"text": "<p>If you create a page template with your own query, you are throwing away all the work WordPress d... | 2018/06/25 | [
"https://wordpress.stackexchange.com/questions/306868",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/145809/"
] | I'm new to wordpress and am trying to develop my first own theme. The thing is: the front page must be static, with no display of posts. But I need a blog section and am trying to do it by creating a custom page template that calls the last 10 posts.
How would I do that using the loop? Please, help me! Thank you all i... | By default WordPress displays your content in a blog format on the homepage.
Using Default Static and Blog Page Settings in WordPress.
WordPress comes with built-in support for creating a custom home page (static front page), and a separate page for blog posts. To use this method, you need to create two new WordPress... |
306,873 | <p>I'm trying to upload files with dwg extension to media but when I do that I get an error telling me that uploading files with this extension is not allowed. I tried to upload them via ftp but I cannot see them in my panel afterwards. I've looked for a solution online and tried adding this to my <code>functions.php</... | [
{
"answer_id": 306874,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 3,
"selected": true,
"text": "<p>Your code should work just fine. The only problem in there is that you’ve set incorrect mime type, I g... | 2018/06/25 | [
"https://wordpress.stackexchange.com/questions/306873",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/145150/"
] | I'm trying to upload files with dwg extension to media but when I do that I get an error telling me that uploading files with this extension is not allowed. I tried to upload them via ftp but I cannot see them in my panel afterwards. I've looked for a solution online and tried adding this to my `functions.php`:
```
fu... | Your code should work just fine. The only problem in there is that you’ve set incorrect mime type, I guess...
It should be `image/vnd.dwg`.
So this one should work:
```
function custom_upload_mimes ( $existing_mimes=array() ) {
$existing_mimes['dwg'] = 'image/vnd.dwg';
return $existing_mimes;
}
add_filter('u... |
306,887 | <p>I am trying to create custom post & post tags with following code</p>
<pre><code>function cptportfolioPost_init() {
register_post_type( 'portfolio',
array(
'labels' => array(
'name' => __( 'Portfolio' ),
'singular_name' => __( 'Portfolio' )
),
'public' => true... | [
{
"answer_id": 306874,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 3,
"selected": true,
"text": "<p>Your code should work just fine. The only problem in there is that you’ve set incorrect mime type, I g... | 2018/06/25 | [
"https://wordpress.stackexchange.com/questions/306887",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/102143/"
] | I am trying to create custom post & post tags with following code
```
function cptportfolioPost_init() {
register_post_type( 'portfolio',
array(
'labels' => array(
'name' => __( 'Portfolio' ),
'singular_name' => __( 'Portfolio' )
),
'public' => true,
'has_archive' => true,... | Your code should work just fine. The only problem in there is that you’ve set incorrect mime type, I guess...
It should be `image/vnd.dwg`.
So this one should work:
```
function custom_upload_mimes ( $existing_mimes=array() ) {
$existing_mimes['dwg'] = 'image/vnd.dwg';
return $existing_mimes;
}
add_filter('u... |
306,904 | <p>I occasionally want to reset my WordPress installation back to default--both the database and files. What is the most efficient way to do so? </p>
<p>I know there are viable plugins to reset the database. But are there automated methods to reset the files to default as well? Or do I need to simply delete everythin... | [
{
"answer_id": 306922,
"author": "Benjamin Atkin",
"author_id": 8567,
"author_profile": "https://wordpress.stackexchange.com/users/8567",
"pm_score": 0,
"selected": false,
"text": "<p>You can use git and a script:</p>\n\n<pre><code>#!/bin/bash\n# check out a revision\ngit checkout master... | 2018/06/25 | [
"https://wordpress.stackexchange.com/questions/306904",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/51204/"
] | I occasionally want to reset my WordPress installation back to default--both the database and files. What is the most efficient way to do so?
I know there are viable plugins to reset the database. But are there automated methods to reset the files to default as well? Or do I need to simply delete everything and re-up... | If you only want to *empty* the site of its *content* (*posts*, *comments*, *terms*, and *meta*) then there's a [wp-cli](https://developer.wordpress.org/cli/commands/site/empty/) command for that:
```
$ wp site empty
```
Use the the `--uploads` parameter to delete all files in the uploads folder and `--yes` to skip ... |
306,990 | <p>I just want to setup SMTP for a specific instance of <code>wp_mail()</code>. </p>
<p>I have tested plugins like "Easy WP SMTP" and also checked how to set up SMTP manually but all <strong>these apply to the entire site</strong> and then every email from the site is sent through the SMTP account.</p>
<p>I don't wan... | [
{
"answer_id": 318826,
"author": "butlerblog",
"author_id": 38603,
"author_profile": "https://wordpress.stackexchange.com/users/38603",
"pm_score": 2,
"selected": false,
"text": "<p>The following is a way to handle your question. It is in two parts. First, you would create your connect... | 2018/06/26 | [
"https://wordpress.stackexchange.com/questions/306990",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/101689/"
] | I just want to setup SMTP for a specific instance of `wp_mail()`.
I have tested plugins like "Easy WP SMTP" and also checked how to set up SMTP manually but all **these apply to the entire site** and then every email from the site is sent through the SMTP account.
I don't want to send any other emails like newslette... | The following is a way to handle your question. It is in two parts. First, you would create your connection as constants to be used later. The best way to do this is in wp-config.php. (You mentioned that you're doing this in a custom plugin. If that's something that is to be portable, then you may want to change this t... |
307,003 | <p>I need to put link with image at the end of post page.
What I am looking for is that at the end of each new post, I need to have small image with link that opens in a new window. How to do that?
Thanks.</p>
| [
{
"answer_id": 318826,
"author": "butlerblog",
"author_id": 38603,
"author_profile": "https://wordpress.stackexchange.com/users/38603",
"pm_score": 2,
"selected": false,
"text": "<p>The following is a way to handle your question. It is in two parts. First, you would create your connect... | 2018/06/26 | [
"https://wordpress.stackexchange.com/questions/307003",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/145893/"
] | I need to put link with image at the end of post page.
What I am looking for is that at the end of each new post, I need to have small image with link that opens in a new window. How to do that?
Thanks. | The following is a way to handle your question. It is in two parts. First, you would create your connection as constants to be used later. The best way to do this is in wp-config.php. (You mentioned that you're doing this in a custom plugin. If that's something that is to be portable, then you may want to change this t... |
307,018 | <p>I am a newbe in wordpress theme development. Can anyone tell me where I should implement the code for any ajax functionalities(say a voting system for posts)? should I write it on a separate plugin or as a custom code in functions.php please do explain your reason, thanks.</p>
| [
{
"answer_id": 307022,
"author": "Tom J Nowell",
"author_id": 736,
"author_profile": "https://wordpress.stackexchange.com/users/736",
"pm_score": 1,
"selected": false,
"text": "<p>Use REST API endpoint instead!</p>\n\n<p>Lets register an endpoint at <code>/wp-json/tomjn/v1/test</code>, t... | 2018/06/26 | [
"https://wordpress.stackexchange.com/questions/307018",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/145902/"
] | I am a newbe in wordpress theme development. Can anyone tell me where I should implement the code for any ajax functionalities(say a voting system for posts)? should I write it on a separate plugin or as a custom code in functions.php please do explain your reason, thanks. | Use REST API endpoint instead!
Lets register an endpoint at `/wp-json/tomjn/v1/test`, that calls `tomjn_rest_test()` when you hit it:
```
add_action( 'rest_api_init', function () {
register_rest_route( 'tomjn/v1', '/test/', array(
'methods' => 'GET',
'callback' => 'tomjn_rest_t... |
307,040 | <p>Is it possible / how can I get all posts from all sites on a multisite installation using the REST API? On the front page of the primary site, I want to display recent posts from <em>all</em> the sites; e.g., mysite.com shows recent posts from mysite.com/site1, myite.com/site2, etc., merged together (possibly with s... | [
{
"answer_id": 307045,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 1,
"selected": false,
"text": "<p>Yes, there is a way to do that. It's a bit complex for here; you have to loop through all sites (after... | 2018/06/26 | [
"https://wordpress.stackexchange.com/questions/307040",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124357/"
] | Is it possible / how can I get all posts from all sites on a multisite installation using the REST API? On the front page of the primary site, I want to display recent posts from *all* the sites; e.g., mysite.com shows recent posts from mysite.com/site1, myite.com/site2, etc., merged together (possibly with some filter... | Here's a REST API recipe for **latest post per site on a multi-site**, for relatively few sites:
* Use `get_sites()`,
* loop over sites and switch to each site,
* query latest post on each site,
* collect data,
* order data by *utime*,
* serve data
**Example REST Routes**
```
https://example.com/wp-json/wpse/v1/late... |
307,088 | <p>Im trying to get this simple condition tag to work . Im having no luck</p>
<pre><code>// If we are logged in, and NOT an admin and NOT on specific page...
if ( is_user_logged_in() & !is_admin() ) & !is_page('account') ) {
</code></pre>
| [
{
"answer_id": 307089,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 2,
"selected": false,
"text": "<p>Count the brackets, you've got an extra one:</p>\n\n<pre><code>// ↓... | 2018/06/27 | [
"https://wordpress.stackexchange.com/questions/307088",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/108508/"
] | Im trying to get this simple condition tag to work . Im having no luck
```
// If we are logged in, and NOT an admin and NOT on specific page...
if ( is_user_logged_in() & !is_admin() ) & !is_page('account') ) {
``` | ```
if(strpos($_SERVER['REQUEST_URI'], '/account/') === FALSE AND strpos($_SERVER['REQUEST_URI'], '/wp-admin/') === FALSE AND ! is_user_logged_in() === FALSE) {
``` |
307,105 | <p>I have the following website: <a href="https://www.bibaboegifts.be" rel="nofollow noreferrer">www.bibaboegifts.be</a>.</p>
<ul>
<li>When giving in the URL <a href="https://www.bibaboegifts.be" rel="nofollow noreferrer">https://www.bibaboegifts.be</a>, the CSS is loaded. </li>
<li>However, when giving in the URL <a ... | [
{
"answer_id": 307089,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 2,
"selected": false,
"text": "<p>Count the brackets, you've got an extra one:</p>\n\n<pre><code>// ↓... | 2018/06/27 | [
"https://wordpress.stackexchange.com/questions/307105",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/129008/"
] | I have the following website: [www.bibaboegifts.be](https://www.bibaboegifts.be).
* When giving in the URL <https://www.bibaboegifts.be>, the CSS is loaded.
* However, when giving in the URL <https://bibaboegifts.be> (**without the www. part**), the CSS is not loaded. Only the content is displayed, but my lay-out is n... | ```
if(strpos($_SERVER['REQUEST_URI'], '/account/') === FALSE AND strpos($_SERVER['REQUEST_URI'], '/wp-admin/') === FALSE AND ! is_user_logged_in() === FALSE) {
``` |
307,109 | <p>I have a custom page template defined and working properly.
On this specific page, I want to list a lot of links, and paginate them, to display 100 links per page.</p>
<p>Here is the code in my template file, working exactly like I want</p>
<pre><code><div class="container">
<ul class="row listing-items"&... | [
{
"answer_id": 307182,
"author": "yofisim",
"author_id": 98907,
"author_profile": "https://wordpress.stackexchange.com/users/98907",
"pm_score": 3,
"selected": true,
"text": "<p>After a huge night overthinking this, and thanks to Joost de Valk (Yoast SEO plugin author), I found the solut... | 2018/06/27 | [
"https://wordpress.stackexchange.com/questions/307109",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/98907/"
] | I have a custom page template defined and working properly.
On this specific page, I want to list a lot of links, and paginate them, to display 100 links per page.
Here is the code in my template file, working exactly like I want
```
<div class="container">
<ul class="row listing-items">
<?php
$paged = ( ... | After a huge night overthinking this, and thanks to Joost de Valk (Yoast SEO plugin author), I found the solution.
As per this thread: <https://github.com/Yoast/wordpress-seo/issues/437> , what I want to achieve the way I do, **is undoable, or at least, a very bad practice.**
If you want your custom query to have th... |
307,113 | <p>I have disabled the author pages on my WordPress blog using the Yoast SEO plugin, but I saw that when I click the author name, it just redirects me to the homepage. Can I change the URL myblog.com/author/me directly to myblog.com, without a 301 redirect? Thanks!</p>
| [
{
"answer_id": 307114,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 2,
"selected": false,
"text": "<p>Disabling the author pages is a 'good thing'. A 'bad actor' can enumerate your users, or even get your... | 2018/06/27 | [
"https://wordpress.stackexchange.com/questions/307113",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/145970/"
] | I have disabled the author pages on my WordPress blog using the Yoast SEO plugin, but I saw that when I click the author name, it just redirects me to the homepage. Can I change the URL myblog.com/author/me directly to myblog.com, without a 301 redirect? Thanks! | Disabling the author pages is a 'good thing'. A 'bad actor' can enumerate your users, or even get your admin user (which is user id 1) with a simple query on any page. So redirecting author requests is a good idea - and a good security measure. (As is never having a user called 'admin', especially if it has admin privi... |
307,155 | <p>I could use another set of eyes on this one...its been a little bit of time since I last created a Wordpress theme. I can't figure out what I'm doing wrong here.</p>
<p>I created a custom post type (journal) and set up a loop on a custom template, which I set on the homepage.<br>
I then have single-journal.php tem... | [
{
"answer_id": 307157,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>The Main Query already contains the correct post, but you are creating a new query and asking for a single post or... | 2018/06/28 | [
"https://wordpress.stackexchange.com/questions/307155",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64900/"
] | I could use another set of eyes on this one...its been a little bit of time since I last created a Wordpress theme. I can't figure out what I'm doing wrong here.
I created a custom post type (journal) and set up a loop on a custom template, which I set on the homepage.
I then have single-journal.php template for th... | You shouldn't be using custom queries in these templates. The main query (using `have_posts();`, `the_post();` etc. without `$loop`) is already set up with the correct posts for these templates.
Look at the custom query you're using on the single template:
```
$args = array('post_type' => 'journal',
'showpos... |
307,159 | <p>I am setting up non-for-profit domestic violence support website and struggle to find a way to create active category parent and it children links in pages sidebar.</p>
<p>What is the ideal solution to dynamically display category parent and it's children?</p>
| [
{
"answer_id": 307157,
"author": "Milo",
"author_id": 4771,
"author_profile": "https://wordpress.stackexchange.com/users/4771",
"pm_score": 1,
"selected": false,
"text": "<p>The Main Query already contains the correct post, but you are creating a new query and asking for a single post or... | 2018/06/28 | [
"https://wordpress.stackexchange.com/questions/307159",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/145989/"
] | I am setting up non-for-profit domestic violence support website and struggle to find a way to create active category parent and it children links in pages sidebar.
What is the ideal solution to dynamically display category parent and it's children? | You shouldn't be using custom queries in these templates. The main query (using `have_posts();`, `the_post();` etc. without `$loop`) is already set up with the correct posts for these templates.
Look at the custom query you're using on the single template:
```
$args = array('post_type' => 'journal',
'showpos... |
307,209 | <p>First of all, I tried searching and working on this, but couldn't create the logic or method to do this.</p>
<p>I'm trying to display <code>users</code> and <code>custom post type</code> content together into a single <code>loop</code>. I can get the value of <code>custom post type</code> using <code>WP_Query</code... | [
{
"answer_id": 307518,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 3,
"selected": true,
"text": "<p>You can not merge two different queries when the returned type is an object, because they have different met... | 2018/06/28 | [
"https://wordpress.stackexchange.com/questions/307209",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/110899/"
] | First of all, I tried searching and working on this, but couldn't create the logic or method to do this.
I'm trying to display `users` and `custom post type` content together into a single `loop`. I can get the value of `custom post type` using `WP_Query` and `users` using `WP_USER_Query`. and I can display them simul... | You can not merge two different queries when the returned type is an object, because they have different methods and properties. Instead, you can get them as an array. Then you can merge them and compare the dates. For this, I'm going to use `get_posts()` over `WP_Query()`, and `get_users()` over `WP_User_Query()` to a... |
307,239 | <p>Just starting to play with Gutenberg block development, and I am building a very simple button (yes I know buttons are already included, but this block will have lots of settings and classes not included in the core block).</p>
<p>Seem's pretty strait forward, but when I save the block and reload, I get a validatio... | [
{
"answer_id": 307518,
"author": "Johansson",
"author_id": 94498,
"author_profile": "https://wordpress.stackexchange.com/users/94498",
"pm_score": 3,
"selected": true,
"text": "<p>You can not merge two different queries when the returned type is an object, because they have different met... | 2018/06/28 | [
"https://wordpress.stackexchange.com/questions/307239",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/19536/"
] | Just starting to play with Gutenberg block development, and I am building a very simple button (yes I know buttons are already included, but this block will have lots of settings and classes not included in the core block).
Seem's pretty strait forward, but when I save the block and reload, I get a validation error an... | You can not merge two different queries when the returned type is an object, because they have different methods and properties. Instead, you can get them as an array. Then you can merge them and compare the dates. For this, I'm going to use `get_posts()` over `WP_Query()`, and `get_users()` over `WP_User_Query()` to a... |
307,259 | <p>I've just checked a double click on my form that inserts new user meta, which actually inserted it twice! The problem is, I actually need the values to be non-unique so I can insert multiple times. </p>
<p>My aim is simple, to capture post the data from the form into the <code>user_meta</code>table only once from t... | [
{
"answer_id": 307264,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 2,
"selected": false,
"text": "<p>Dunno if you looked at add_user_meta, but it takes an optional fourth parameter.</p>\n\n<pre><code>function add_us... | 2018/06/28 | [
"https://wordpress.stackexchange.com/questions/307259",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146035/"
] | I've just checked a double click on my form that inserts new user meta, which actually inserted it twice! The problem is, I actually need the values to be non-unique so I can insert multiple times.
My aim is simple, to capture post the data from the form into the `user_meta`table only once from the form, but it seems... | Dunno if you looked at add\_user\_meta, but it takes an optional fourth parameter.
```
function add_user_meta( $user_id, $meta_key, $meta_value, $unique = false )
```
Send "true" to the $unique value and it won't insert it twice.
<https://developer.wordpress.org/reference/functions/add_user_meta/> |
307,307 | <ul>
<li>I'm using Advanced Custom Fields.</li>
<li>I have a registered <code>bookitall_roomstype</code> custom post type. </li>
<li>I have a registered <code>bookitall_bookings</code> as another custom post type.</li>
<li>In the bookitall_bookings there is a field called
<code>bookitall_roomstype</code> that is stored... | [
{
"answer_id": 307319,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 1,
"selected": false,
"text": "<p>You shouldn't need to get all <code>bookitall_roomstype</code> in lines 2-9 of your code. You really only... | 2018/06/29 | [
"https://wordpress.stackexchange.com/questions/307307",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/38848/"
] | * I'm using Advanced Custom Fields.
* I have a registered `bookitall_roomstype` custom post type.
* I have a registered `bookitall_bookings` as another custom post type.
* In the bookitall\_bookings there is a field called
`bookitall_roomstype` that is stored as a `pagelink` (acf "type"). (This
looks like a permalink ... | [The page link field](https://www.advancedcustomfields.com/resources/page-link/) actually stores the post ID, which gets formatted internally by the `get_field` function on output. The 3rd argument for `get_field` lets you disable that output formatting so you just get the ID back, which you can then use to get title a... |
307,310 | <p>We recently implemented a stock quote system, where a user can enter a stock symbol and it will return all sorts of financial values.</p>
<p>I have a template made up that displays the financial widgets, and when a user enters a ticker symbol it runs some JS with the callback url being my template. In this example,... | [
{
"answer_id": 307319,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 1,
"selected": false,
"text": "<p>You shouldn't need to get all <code>bookitall_roomstype</code> in lines 2-9 of your code. You really only... | 2018/06/29 | [
"https://wordpress.stackexchange.com/questions/307310",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146068/"
] | We recently implemented a stock quote system, where a user can enter a stock symbol and it will return all sorts of financial values.
I have a template made up that displays the financial widgets, and when a user enters a ticker symbol it runs some JS with the callback url being my template. In this example, it is som... | [The page link field](https://www.advancedcustomfields.com/resources/page-link/) actually stores the post ID, which gets formatted internally by the `get_field` function on output. The 3rd argument for `get_field` lets you disable that output formatting so you just get the ID back, which you can then use to get title a... |
307,345 | <p>The following <em>works</em> but isn't up to snuff with <a href="https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards" rel="nofollow noreferrer">PHP Code Sniffer WordPress coding standards</a> </p>
<pre><code><?php esc_html_e( ADDRESS, 'wprig' ); ?>
</code></pre>
<p>Linter yells at me wit... | [
{
"answer_id": 307349,
"author": "Otto",
"author_id": 2232,
"author_profile": "https://wordpress.stackexchange.com/users/2232",
"pm_score": 5,
"selected": true,
"text": "<p>You cannot use constants or anything other than actual strings with translation functions.</p>\n\n<p>This is becaus... | 2018/06/29 | [
"https://wordpress.stackexchange.com/questions/307345",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/132362/"
] | The following *works* but isn't up to snuff with [PHP Code Sniffer WordPress coding standards](https://github.com/WordPress-Coding-Standards/WordPress-Coding-Standards)
```
<?php esc_html_e( ADDRESS, 'wprig' ); ?>
```
Linter yells at me with:
>
> [WordPress.WP.I18n.NonSingularStringLiteralText] The $text arg must... | You cannot use constants or anything other than actual strings with translation functions.
This is because the code that reads your code, and produces the translatable strings does not actually *run* your code, it is *reading* your code.
Here is a more detailed post on the topic:
<http://ottopress.com/2012/internati... |
307,362 | <p>You know how all these websites send out links to their new users for them to verify their Email address? I'm trying to set up something like this but after some research I still haven't found a good explanation on how to implement this.</p>
<p>I'm open for plugin recommendations, however most of the plugins I foun... | [
{
"answer_id": 307367,
"author": "Akshat",
"author_id": 114978,
"author_profile": "https://wordpress.stackexchange.com/users/114978",
"pm_score": 5,
"selected": true,
"text": "<p>You can use <code>user_register</code> hook</p>\n\n<pre><code>add_action( 'user_register', 'my_registration',... | 2018/06/30 | [
"https://wordpress.stackexchange.com/questions/307362",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/145115/"
] | You know how all these websites send out links to their new users for them to verify their Email address? I'm trying to set up something like this but after some research I still haven't found a good explanation on how to implement this.
I'm open for plugin recommendations, however most of the plugins I found have a t... | You can use `user_register` hook
```
add_action( 'user_register', 'my_registration', 10, 2 );
function my_registration( $user_id ) {
// get user data
$user_info = get_userdata($user_id);
// create md5 code to verify later
$code = md5(time());
// make it into a code to send it to user via email
... |
307,416 | <p>How can I enable shortcodes on a custom post type that doesn't use <code>the_content()</code> or <code>get_the_content()</code>?
In the template file it uses</p>
<pre><code><?php echo nl2br( $post->post_content ); ?>
</code></pre>
<p>to get the content from the backend like any other post or page would.
I... | [
{
"answer_id": 307446,
"author": "Mammaltron",
"author_id": 88160,
"author_profile": "https://wordpress.stackexchange.com/users/88160",
"pm_score": -1,
"selected": false,
"text": "<p>Use <code>apply_filters()</code> to let WordPress process the shortcodes in your content. </p>\n\n<p><cod... | 2018/07/01 | [
"https://wordpress.stackexchange.com/questions/307416",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/86094/"
] | How can I enable shortcodes on a custom post type that doesn't use `the_content()` or `get_the_content()`?
In the template file it uses
```
<?php echo nl2br( $post->post_content ); ?>
```
to get the content from the backend like any other post or page would.
I have tried using
```
<?php echo do_shortcode(get_post_f... | For my particular situation the answer was to replace `<?php echo nl2br( $post->post_content ); ?>` with `<?php echo $content; ?>` which allowed all shortcodes to work as expected. |
307,484 | <p>I am trying to build a plugin, in the plugin I want the admin to be able to send data to database and let the user view the data in the front end, but I am still having problems with sending data to database</p>
<p>I am trying to validate this code to keep it safe from injection
This is my code </p>
<pre><code>&l... | [
{
"answer_id": 307487,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 2,
"selected": false,
"text": "<pre><code>$table = wp_save;\n</code></pre>\n\n<p>This is setting <code>$table</code> to a PHP <a href=\"h... | 2018/07/02 | [
"https://wordpress.stackexchange.com/questions/307484",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146214/"
] | I am trying to build a plugin, in the plugin I want the admin to be able to send data to database and let the user view the data in the front end, but I am still having problems with sending data to database
I am trying to validate this code to keep it safe from injection
This is my code
```
<?php
if (!empty($_... | ```
$table = wp_save;
```
This is setting `$table` to a PHP [constant](http://php.net/manual/en/language.constants.php) `wp_save`. If I had to guess I'd say you don't actually have a constant by that name, and just meant to set the table name to `wp_save`. To do that you need to put the table name between quotes, so ... |
307,521 | <p>I have registered a widget in order to allow users to filter posts by category or write something in the search box, the problem is that my 'blog' page is 'home.php' because it is a single-page-site (in index.php I am loading all the content), when I pick up a category or click on search button it redirects to index... | [
{
"answer_id": 307487,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 2,
"selected": false,
"text": "<pre><code>$table = wp_save;\n</code></pre>\n\n<p>This is setting <code>$table</code> to a PHP <a href=\"h... | 2018/07/02 | [
"https://wordpress.stackexchange.com/questions/307521",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/137882/"
] | I have registered a widget in order to allow users to filter posts by category or write something in the search box, the problem is that my 'blog' page is 'home.php' because it is a single-page-site (in index.php I am loading all the content), when I pick up a category or click on search button it redirects to index.ph... | ```
$table = wp_save;
```
This is setting `$table` to a PHP [constant](http://php.net/manual/en/language.constants.php) `wp_save`. If I had to guess I'd say you don't actually have a constant by that name, and just meant to set the table name to `wp_save`. To do that you need to put the table name between quotes, so ... |
307,539 | <p>Is is safe to edit language files from wp-content/languages/plugins/woocommerce-ro_RO.mo(.po) ? I'm asking this because I don't want them to be overriden on plugin update. Sorry if dumb question.</p>
| [
{
"answer_id": 307487,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 2,
"selected": false,
"text": "<pre><code>$table = wp_save;\n</code></pre>\n\n<p>This is setting <code>$table</code> to a PHP <a href=\"h... | 2018/07/02 | [
"https://wordpress.stackexchange.com/questions/307539",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115614/"
] | Is is safe to edit language files from wp-content/languages/plugins/woocommerce-ro\_RO.mo(.po) ? I'm asking this because I don't want them to be overriden on plugin update. Sorry if dumb question. | ```
$table = wp_save;
```
This is setting `$table` to a PHP [constant](http://php.net/manual/en/language.constants.php) `wp_save`. If I had to guess I'd say you don't actually have a constant by that name, and just meant to set the table name to `wp_save`. To do that you need to put the table name between quotes, so ... |
307,542 | <p>It can be sometimes bothersome when, in the Discussion (Comments) dashboard, where the admin can see a list of comments, moving the mouse over a link will cause a preview of that link. Sometimes the preview gets in the way of looking at the comment. This is especially true with spam comments.</p>
<p>And I am also c... | [
{
"answer_id": 338830,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": 0,
"selected": false,
"text": "<p>This is still happening in WP5.2.1. You can verify it by looking at your spam messages (via the Admin,... | 2018/07/02 | [
"https://wordpress.stackexchange.com/questions/307542",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/29416/"
] | It can be sometimes bothersome when, in the Discussion (Comments) dashboard, where the admin can see a list of comments, moving the mouse over a link will cause a preview of that link. Sometimes the preview gets in the way of looking at the comment. This is especially true with spam comments.
And I am also concerned t... | [Since version 4.1.6](https://wordpress.org/support/topic/how-to-disable-mshots-service/#post-12939728), Akismet has a filter which [allows you to disable these "mShots"](https://wordpress.org/support/topic/how-to-disable-mshots-service/#post-12944077) (the site preview popups):
```
<?php
function disable_akismet_msho... |
307,580 | <p>I'm working on a Plugin for the WordPress Customizer and need to call a function when the previewer has loaded. Is there an event or an other method that tells me the preview is loaded?</p>
<p>If have tried:</p>
<pre><code>jQuery(window).load (function() { // Customizer loaded...
wp.customize.previewer.bind( 'r... | [
{
"answer_id": 307901,
"author": "Milli",
"author_id": 146281,
"author_profile": "https://wordpress.stackexchange.com/users/146281",
"pm_score": 0,
"selected": false,
"text": "<p>I haven't found an Customizer API event for when the preview has loaded. Here is a solution with the on load ... | 2018/07/03 | [
"https://wordpress.stackexchange.com/questions/307580",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146281/"
] | I'm working on a Plugin for the WordPress Customizer and need to call a function when the previewer has loaded. Is there an event or an other method that tells me the preview is loaded?
If have tried:
```
jQuery(window).load (function() { // Customizer loaded...
wp.customize.previewer.bind( 'refresh', function() {... | Yes, this is the way to detect when the preview has loaded:
```
wp.customize.bind( 'ready', function() {
wp.customize.previewer.bind( 'ready', function( message ) {
console.info( 'Preview is loaded' );
} );
} );
```
This JS code should be enqueued at the `customize_controls_enqueue_scripts` action with `cus... |
307,591 | <p>I want to use a fallback image if no featured image is set. I'm using the following code, but the image is not shown...</p>
<pre><code><?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>
<?php the_post_thumbnail( array(334, 259) ); // Declare pixel size you need inside the array ?>
&l... | [
{
"answer_id": 307621,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 1,
"selected": false,
"text": "<p>Your code looks OK and it should work just fine. But there are some things you can (and you should) f... | 2018/07/03 | [
"https://wordpress.stackexchange.com/questions/307591",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/82174/"
] | I want to use a fallback image if no featured image is set. I'm using the following code, but the image is not shown...
```
<?php if ( has_post_thumbnail()) : // Check if thumbnail exists ?>
<?php the_post_thumbnail( array(334, 259) ); // Declare pixel size you need inside the array ?>
<?php else : // No thumbnail... | Your code looks OK and it should work just fine. But there are some things you can (and you should) fix.
1. You don't use absolute URL for your fallback image
-----------------------------------------------------
You pass `/wp/wp-content/themes/klicknet-theme/images/testbild.png` as src of your image. It would be muc... |
307,636 | <p>When i try to install a website that i got as an duplicator archive i get the following error at the very last step of the installation:</p>
<p><a href="https://i.stack.imgur.com/oIbB7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oIbB7.jpg" alt="enter image description here"></a>
I am using th... | [
{
"answer_id": 307605,
"author": "WebElaine",
"author_id": 102815,
"author_profile": "https://wordpress.stackexchange.com/users/102815",
"pm_score": 2,
"selected": false,
"text": "<p>You can't add additional \"folders\" in the post editing screen. You would need to change your permalink ... | 2018/07/04 | [
"https://wordpress.stackexchange.com/questions/307636",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/122013/"
] | When i try to install a website that i got as an duplicator archive i get the following error at the very last step of the installation:
[](https://i.stack.imgur.com/oIbB7.jpg)
I am using the latest version of xampp on my local machine which has 16GB ... | You can't add additional "folders" in the post editing screen. You would need to change your permalink structure, so that Posts include the Category in the URL. In Settings > Permalinks, choose "Custom Structure" and paste
`/%category%/%postname%/`
Keep in mind this will change all your Post URLs, so you'll need to a... |
307,640 | <p>Created my first custom theme from scratch and I'm trying to do a listing of all posts with the same tag.</p>
<p>In <code>tag.php</code> I display all posts with that specific tag via a <code>WP_Query</code> and I'm trying to implement the pagination for that listing (using <code>paginate_links()</code>). Page links... | [
{
"answer_id": 307663,
"author": "Fayaz",
"author_id": 110572,
"author_profile": "https://wordpress.stackexchange.com/users/110572",
"pm_score": 2,
"selected": true,
"text": "<h2>Overall CODE issues:</h2>\n\n<p>Your CODE is so wrong in so many ways that I shouldn't even attempt to addres... | 2018/07/04 | [
"https://wordpress.stackexchange.com/questions/307640",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/133712/"
] | Created my first custom theme from scratch and I'm trying to do a listing of all posts with the same tag.
In `tag.php` I display all posts with that specific tag via a `WP_Query` and I'm trying to implement the pagination for that listing (using `paginate_links()`). Page links seem to be outputted correctly. Also the ... | Overall CODE issues:
--------------------
Your CODE is so wrong in so many ways that I shouldn't even attempt to address them here. I suggest you study [Official WordPress Theme Handbook](https://developer.wordpress.org/themes/) properly before doing these sort of customizations.
For the sake of the context, I'm igno... |
307,650 | <p>The default menu classes in WordPress are pretty useful. But one problem that i stumble over from time to time is with categories as subitems in menus. For example the following menu structure:</p>
<ul>
<li>Page 1</li>
<li>Page 2
<ul>
<li>Category 1</li>
</ul></li>
<li>Page 3</li>
</ul>
<p>So when <code>Category ... | [
{
"answer_id": 307656,
"author": "mcgoo",
"author_id": 146340,
"author_profile": "https://wordpress.stackexchange.com/users/146340",
"pm_score": 0,
"selected": false,
"text": "<p>You could use <a href=\"https://codex.wordpress.org/Class_Reference/Walker\" rel=\"nofollow noreferrer\">http... | 2018/07/04 | [
"https://wordpress.stackexchange.com/questions/307650",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/52227/"
] | The default menu classes in WordPress are pretty useful. But one problem that i stumble over from time to time is with categories as subitems in menus. For example the following menu structure:
* Page 1
* Page 2
+ Category 1
* Page 3
So when `Category 1` is active `Page 2` gets `.current-menu-ancestor` which is fine... | This is probably what you are looking for ..
```
add_filter( 'wp_nav_menu_objects', 'add_menu_parent_class' );
function add_menu_parent_class( $items ) {
$parents = array();
foreach ( $items as $item ) {
if ( in_array('current-post-ancestor', $item->classes) ) {
$parents[] = $item->menu_i... |
307,699 | <p>I've been trying to solve this myself for hours but I can't figure out where I am going wrong.</p>
<p>I have a custom registration form on my website and I would like to add a checkbox for users to sign up for the newsletter.</p>
<p>I went through the <a href="https://beta.docs.mailpoet.com/article/195-add-subscri... | [
{
"answer_id": 307656,
"author": "mcgoo",
"author_id": 146340,
"author_profile": "https://wordpress.stackexchange.com/users/146340",
"pm_score": 0,
"selected": false,
"text": "<p>You could use <a href=\"https://codex.wordpress.org/Class_Reference/Walker\" rel=\"nofollow noreferrer\">http... | 2018/07/04 | [
"https://wordpress.stackexchange.com/questions/307699",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/145115/"
] | I've been trying to solve this myself for hours but I can't figure out where I am going wrong.
I have a custom registration form on my website and I would like to add a checkbox for users to sign up for the newsletter.
I went through the [Mailpoet Docs](https://beta.docs.mailpoet.com/article/195-add-subscribers-throu... | This is probably what you are looking for ..
```
add_filter( 'wp_nav_menu_objects', 'add_menu_parent_class' );
function add_menu_parent_class( $items ) {
$parents = array();
foreach ( $items as $item ) {
if ( in_array('current-post-ancestor', $item->classes) ) {
$parents[] = $item->menu_i... |
307,713 | <p>I have a custom post type <code>mycpt</code> and I'm trying to allow for a variable to be appended onto the end of the URL right after the post name slug, like this:</p>
<pre><code>www.site.com/mycpt/the-name-of-my-post/var-value-here/
</code></pre>
<p>I've been searching around, and the only examples I can find d... | [
{
"answer_id": 307715,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 1,
"selected": false,
"text": "<p>As a temporary solution you can try using free plugin : <a href=\"https://wordpress.org/plugins/custom-post-type-... | 2018/07/04 | [
"https://wordpress.stackexchange.com/questions/307713",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/63238/"
] | I have a custom post type `mycpt` and I'm trying to allow for a variable to be appended onto the end of the URL right after the post name slug, like this:
```
www.site.com/mycpt/the-name-of-my-post/var-value-here/
```
I've been searching around, and the only examples I can find don't use the post name/slug in the UR... | Here's a complete working example that adds a post type, with extra rule to capture an additional parameter:
```
function wpd_post_type_and_rule() {
register_post_type( 'mycpt',
array(
'labels' => array(
'name' => __( 'mycpt' ),
),
'public' => true,
... |
307,783 | <p>I built a page with Elementor, and I want to use it as my home page. When I use a static home page with my theme, it still gets wrapped with the header, footer, and content container, which I don't want in this case.</p>
<p>I've built a simple <code>front-page.php</code> template to try to just output the contents ... | [
{
"answer_id": 370754,
"author": "Maduka Jayalath",
"author_id": 110601,
"author_profile": "https://wordpress.stackexchange.com/users/110601",
"pm_score": 3,
"selected": false,
"text": "<p>Here is the way,</p>\n<pre><code>$contentElementor = "";\n\nif (class_exists("\\\\El... | 2018/07/05 | [
"https://wordpress.stackexchange.com/questions/307783",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/31649/"
] | I built a page with Elementor, and I want to use it as my home page. When I use a static home page with my theme, it still gets wrapped with the header, footer, and content container, which I don't want in this case.
I've built a simple `front-page.php` template to try to just output the contents of this page.
```
<!... | Here is the way,
```
$contentElementor = "";
if (class_exists("\\Elementor\\Plugin")) {
$post_ID = 124;
$pluginElementor = \Elementor\Plugin::instance();
$contentElementor = $pluginElementor->frontend->get_builder_content($post_ID);
}
echo $contentElementor;
``` |
307,794 | <p>I have the following problem when I am validating a field with the Advanced Custom Fields plugin in wordpress. What happens is that the field is validated correctly but the error appears on a new page instead of going out on the same page above the field to which I am validating. The code to validate is the followin... | [
{
"answer_id": 319945,
"author": "Kostiantyn Petlia",
"author_id": 104932,
"author_profile": "https://wordpress.stackexchange.com/users/104932",
"pm_score": 3,
"selected": true,
"text": "<p>I did have the same issue. And I wasted enough time for the answer.</p>\n\n<p>At first be sure tha... | 2018/07/05 | [
"https://wordpress.stackexchange.com/questions/307794",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/144662/"
] | I have the following problem when I am validating a field with the Advanced Custom Fields plugin in wordpress. What happens is that the field is validated correctly but the error appears on a new page instead of going out on the same page above the field to which I am validating. The code to validate is the following:
... | I did have the same issue. And I wasted enough time for the answer.
At first be sure that:
The ajax request isn't failed and happens. So, check:
1. Is acf\_form\_head() before get\_header() and run before any html is output?
2. Does your theme contain call to wp\_head()?
3. Does your theme contain call to wp\_foot()... |
307,795 | <p>I’m looking to add Instagram to my follow buttons, and on the settings pages it tells me:</p>
<p>You can setup Instagram, YouTube, Snapchat, and other buttons in an AddToAny Follow widget.</p>
<p>Add the “AddToAny Follow” widget in Customize or Widgets.</p>
<p>But in the AddToAny Follow Widget i’ve got linkedin, ... | [
{
"answer_id": 319945,
"author": "Kostiantyn Petlia",
"author_id": 104932,
"author_profile": "https://wordpress.stackexchange.com/users/104932",
"pm_score": 3,
"selected": true,
"text": "<p>I did have the same issue. And I wasted enough time for the answer.</p>\n\n<p>At first be sure tha... | 2018/07/05 | [
"https://wordpress.stackexchange.com/questions/307795",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/8895/"
] | I’m looking to add Instagram to my follow buttons, and on the settings pages it tells me:
You can setup Instagram, YouTube, Snapchat, and other buttons in an AddToAny Follow widget.
Add the “AddToAny Follow” widget in Customize or Widgets.
But in the AddToAny Follow Widget i’ve got linkedin, twitter and facebook. No... | I did have the same issue. And I wasted enough time for the answer.
At first be sure that:
The ajax request isn't failed and happens. So, check:
1. Is acf\_form\_head() before get\_header() and run before any html is output?
2. Does your theme contain call to wp\_head()?
3. Does your theme contain call to wp\_foot()... |
307,916 | <p>I've just installed a fresh install of WordPress and before doing anything else I've tried to setup a multisite, which I would like to do with subdirectories. </p>
<p>But when I click on Network Setup I get the notification: </p>
<blockquote>
<p>Because your installation is not new, the sites in your WordPress
... | [
{
"answer_id": 307955,
"author": "Robert Gres",
"author_id": 146551,
"author_profile": "https://wordpress.stackexchange.com/users/146551",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"https://premium.wpmudev.org/forums/topic/enabling-network-because-your-install-is-not-new-the... | 2018/07/07 | [
"https://wordpress.stackexchange.com/questions/307916",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/59568/"
] | I've just installed a fresh install of WordPress and before doing anything else I've tried to setup a multisite, which I would like to do with subdirectories.
But when I click on Network Setup I get the notification:
>
> Because your installation is not new, the sites in your WordPress
> network must use sub-doma... | You don't need to do anything just past this code in your activated theme's `functions.php`
```
add_filter( 'allow_subdirectory_install', '__return_true' );
``` |
307,920 | <p>I want to remove tag, category classes from Post Titles of my WordPress blog. On the frontend, Wordpress generates extra classes for every single article title.</p>
<p>For Example, <a href="https://examsmate.in/indian-army-preparation-tips/" rel="nofollow noreferrer">this article</a>, has these article title classe... | [
{
"answer_id": 307955,
"author": "Robert Gres",
"author_id": 146551,
"author_profile": "https://wordpress.stackexchange.com/users/146551",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"https://premium.wpmudev.org/forums/topic/enabling-network-because-your-install-is-not-new-the... | 2018/07/07 | [
"https://wordpress.stackexchange.com/questions/307920",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146528/"
] | I want to remove tag, category classes from Post Titles of my WordPress blog. On the frontend, Wordpress generates extra classes for every single article title.
For Example, [this article](https://examsmate.in/indian-army-preparation-tips/), has these article title classes "category-tips-guides" "tag-indian-army" as d... | You don't need to do anything just past this code in your activated theme's `functions.php`
```
add_filter( 'allow_subdirectory_install', '__return_true' );
``` |
307,930 | <p>Problem:</p>
<ul>
<li>I need to associate to every PostType a Company(done with Taxonomy, taxonomy is a huge list of Companies)</li>
<li>A company can be a Producer or a Developer</li>
<li>I need to Select a Producer on the PostType</li>
<li>I need to Select a Developer on the PostType</li>
</ul>
<p>As you underst... | [
{
"answer_id": 307955,
"author": "Robert Gres",
"author_id": 146551,
"author_profile": "https://wordpress.stackexchange.com/users/146551",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"https://premium.wpmudev.org/forums/topic/enabling-network-because-your-install-is-not-new-the... | 2018/07/07 | [
"https://wordpress.stackexchange.com/questions/307930",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146538/"
] | Problem:
* I need to associate to every PostType a Company(done with Taxonomy, taxonomy is a huge list of Companies)
* A company can be a Producer or a Developer
* I need to Select a Producer on the PostType
* I need to Select a Developer on the PostType
As you understand you can have the same Company as Developer an... | You don't need to do anything just past this code in your activated theme's `functions.php`
```
add_filter( 'allow_subdirectory_install', '__return_true' );
``` |
307,970 | <p>I am making my theme.
I am using wp_editor in front-end to submit post. </p>
<p>I submit through wp_editor in the specific page, and this being displayed in single.php.
At single.php I am using </p>
<pre><code><?php the_content(); ?>
</code></pre>
<p>The problem is when I put enter-key (like br tag) in a ... | [
{
"answer_id": 307955,
"author": "Robert Gres",
"author_id": 146551,
"author_profile": "https://wordpress.stackexchange.com/users/146551",
"pm_score": 1,
"selected": false,
"text": "<p><a href=\"https://premium.wpmudev.org/forums/topic/enabling-network-because-your-install-is-not-new-the... | 2018/07/08 | [
"https://wordpress.stackexchange.com/questions/307970",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/133185/"
] | I am making my theme.
I am using wp\_editor in front-end to submit post.
I submit through wp\_editor in the specific page, and this being displayed in single.php.
At single.php I am using
```
<?php the_content(); ?>
```
The problem is when I put enter-key (like br tag) in a post that is several blank row, these... | You don't need to do anything just past this code in your activated theme's `functions.php`
```
add_filter( 'allow_subdirectory_install', '__return_true' );
``` |
308,021 | <p>I'm trying to add a class to list blocks (<code>core/list</code>) in Gutenberg. Unfortunately, it looks like because some blocks like lists and paragraphs don't have the standard default class name of <code>wp-block-{name}</code> they can't be renamed using the <a href="https://wordpress.org/gutenberg/handbook/exten... | [
{
"answer_id": 308044,
"author": "Shibi",
"author_id": 62500,
"author_profile": "https://wordpress.stackexchange.com/users/62500",
"pm_score": 4,
"selected": false,
"text": "<p>You have second and third arguments with this hook you can use the second to get the block type.</p>\n\n<p><a h... | 2018/07/09 | [
"https://wordpress.stackexchange.com/questions/308021",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/17461/"
] | I'm trying to add a class to list blocks (`core/list`) in Gutenberg. Unfortunately, it looks like because some blocks like lists and paragraphs don't have the standard default class name of `wp-block-{name}` they can't be renamed using the [`blocks.getBlockDefaultClassName`](https://wordpress.org/gutenberg/handbook/ext... | There are issues in the answer marked as correct. It will break the alignment class functionality, and is not actually adding to the classList, instead it is overriding it. And you will only be able to use that one solution for your whole theme.
Instead you can use "registerBlockStyle()" to add a style variation to th... |
308,029 | <p>I want my user pay before every post publishing. I searched for some hooks that triggers before a post publishes, but all these hooks run after a post is successfully published and i don't want this.
pre_post_update, publish_post, save_post and wp_insert_post are the available hooks.
If there is not an action that ... | [
{
"answer_id": 308044,
"author": "Shibi",
"author_id": 62500,
"author_profile": "https://wordpress.stackexchange.com/users/62500",
"pm_score": 4,
"selected": false,
"text": "<p>You have second and third arguments with this hook you can use the second to get the block type.</p>\n\n<p><a h... | 2018/07/09 | [
"https://wordpress.stackexchange.com/questions/308029",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/136480/"
] | I want my user pay before every post publishing. I searched for some hooks that triggers before a post publishes, but all these hooks run after a post is successfully published and i don't want this.
pre\_post\_update, publish\_post, save\_post and wp\_insert\_post are the available hooks.
If there is not an action th... | There are issues in the answer marked as correct. It will break the alignment class functionality, and is not actually adding to the classList, instead it is overriding it. And you will only be able to use that one solution for your whole theme.
Instead you can use "registerBlockStyle()" to add a style variation to th... |
308,126 | <p>I am wondering whether it is possible to automatically add a class to a series of links based on the link text.</p>
<p>The scenario is as follows:</p>
<p>I am displaying a list of links on a page in Wordpress that link to other posts - in this case a custom post type for a schedule. The posts all have time based n... | [
{
"answer_id": 308128,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 1,
"selected": false,
"text": "<p>If you just want to do this for styling reasons it's not necessary to add a class, you can style based ... | 2018/07/10 | [
"https://wordpress.stackexchange.com/questions/308126",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146666/"
] | I am wondering whether it is possible to automatically add a class to a series of links based on the link text.
The scenario is as follows:
I am displaying a list of links on a page in Wordpress that link to other posts - in this case a custom post type for a schedule. The posts all have time based names, i.e. '12:23... | If I understand it correctly you want a visual indicator for departures relevant on the current time.
One solution will be using Javascript and provide a way for the element to be identified as passed or active schedule time.
**HTML**
```
<div id="myElement">
<a href="https://myawesomenewsite.com/departuretime/125... |
308,150 | <p>I want to create an Autocomplete function in WordPress. I want a search field from where <strong>username</strong> can be searched. I am using following JQuery UI. </p>
<pre><code><label>Users</label>
<input type="text" name="user_name" id="user-name" />
<?php
$get_arr_user = array('John', '... | [
{
"answer_id": 308153,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 2,
"selected": false,
"text": "<p>The <a href=\"https://codex.wordpress.org/Function_Reference/get_users\" rel=\"nofollow noreferrer\"><code>get_u... | 2018/07/10 | [
"https://wordpress.stackexchange.com/questions/308150",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124069/"
] | I want to create an Autocomplete function in WordPress. I want a search field from where **username** can be searched. I am using following JQuery UI.
```
<label>Users</label>
<input type="text" name="user_name" id="user-name" />
<?php
$get_arr_user = array('John', 'Rogers', 'Paul', 'Amanda', 'Peter');
?>
<scrip... | The other answers are correct, but it's possible to achive the same thing with less code using [`wp_list_pluck()`](https://codex.wordpress.org/Function_Reference/wp_list_pluck):
```
$users = get_users();
$user_names = wp_list_pluck( $users, 'display_name' );
```
`wp_list_pluck()` used that way will get the `display_... |
308,162 | <p>I am using bootstrap to layout a simple webpage. I have also add some css (<code>@media (min-width: 1920px) {..}</code>) media queries which I use for different resolutions</p>
<p>Now I hope WP has a hook which checks the media resolution so I can trim with more characters/words.</p>
<pre><code><?php echo wp_tr... | [
{
"answer_id": 308165,
"author": "Howdy_McGee",
"author_id": 7355,
"author_profile": "https://wordpress.stackexchange.com/users/7355",
"pm_score": 0,
"selected": false,
"text": "<p>One way to find out if a specific function has hooks is to look it up on the <a href=\"https://developer.wo... | 2018/07/10 | [
"https://wordpress.stackexchange.com/questions/308162",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/9936/"
] | I am using bootstrap to layout a simple webpage. I have also add some css (`@media (min-width: 1920px) {..}`) media queries which I use for different resolutions
Now I hope WP has a hook which checks the media resolution so I can trim with more characters/words.
```
<?php echo wp_trim_words(get_the_content(), 40, '..... | Browser resolution is set on the user end. Actually, the window may even be resized after the page has been loaded. Css media queries will deal with that on the user end.
So, when the page is generated on the server side, the user window size is unknown and you cannot determine how many words to serve at that point. I... |
308,164 | <p>How to remove elementor from wordpress admin menu. I have tried below option but it didnt work.</p>
<pre><code>add_action( 'admin_menu', 'my_remove_menu_pages' );
function my_remove_menu_pages() {
remove_menu_page( 'edit.php?post_type=elementor_library' );
//Elementor
};
</code></pre>
| [
{
"answer_id": 308176,
"author": "Amit Jugran",
"author_id": 135161,
"author_profile": "https://wordpress.stackexchange.com/users/135161",
"pm_score": 0,
"selected": false,
"text": "<p>I have been able to do it using <code>'admin_init'</code> action. The correct code is below</p>\n\n<pre... | 2018/07/10 | [
"https://wordpress.stackexchange.com/questions/308164",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/135161/"
] | How to remove elementor from wordpress admin menu. I have tried below option but it didnt work.
```
add_action( 'admin_menu', 'my_remove_menu_pages' );
function my_remove_menu_pages() {
remove_menu_page( 'edit.php?post_type=elementor_library' );
//Elementor
};
``` | This would work for editors. You can swap the role in and out depending on which role you are trying to target (e.g., `editor`, `subscriber`, etc.). This would go in `functions.php` of your child theme.
```
function remove_menus(){
// get current login user's role
$roles = wp_get_current_user()->roles;
// test role
i... |
308,236 | <p>Is there any way to change the order of filters for e.g. the_content before they are applied? What I currently have is the following ideas:</p>
<pre><code>/**
* Print all filters for some hook.
*/
function print_filters_for( $hook = '' ) {
global $wp_filter;
if( empty( $hook ) || !isset( $wp_filter[$hook]... | [
{
"answer_id": 308242,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 3,
"selected": true,
"text": "<p>If you know the existing callback and priority you can just remove the filters and then add again at a d... | 2018/07/11 | [
"https://wordpress.stackexchange.com/questions/308236",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/12035/"
] | Is there any way to change the order of filters for e.g. the\_content before they are applied? What I currently have is the following ideas:
```
/**
* Print all filters for some hook.
*/
function print_filters_for( $hook = '' ) {
global $wp_filter;
if( empty( $hook ) || !isset( $wp_filter[$hook] ) )
... | If you know the existing callback and priority you can just remove the filters and then add again at a different priority:
```
remove_filter( 'the_content', 'convert_smilies', 20 );
add_filter( 'the_content', 'convert_smilies', 30 );
remove_filter( 'the_content', 'capital_P_dangit', 11 );
add_filter( 'the_content', '... |
308,271 | <p>There is a site with WordPress installed and a theme selected. I have created an HTML page for the site, but it wasn't looking well with the theme. So, I want to put the page on the site without any theme, and just the way I wrote the code, without disabling the theme from any other pages.</p>
<p>Is there an easy w... | [
{
"answer_id": 308272,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": 4,
"selected": true,
"text": "<p>There is, in fact, a way to do it without messing with the theme, let's say your WordPress is on <code>pub... | 2018/07/11 | [
"https://wordpress.stackexchange.com/questions/308271",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146759/"
] | There is a site with WordPress installed and a theme selected. I have created an HTML page for the site, but it wasn't looking well with the theme. So, I want to put the page on the site without any theme, and just the way I wrote the code, without disabling the theme from any other pages.
Is there an easy way to do i... | There is, in fact, a way to do it without messing with the theme, let's say your WordPress is on `public_html/your_site`, now you want to create an HTML page that is on `your_site.com/mypage`, so instead of creating a page or post called `mypage` on your WordPress dashboard you are going to create a **mypage.html** and... |
308,291 | <p>I discovered after much painful debugging that requests to the the WP HTTP API (in this case, though <code>wp_remote_request()</code>) always ended up as <code>GET</code> method after being redirected, even if the method was something else in the initial request (in my case <code>PURGE</code> as used by the <a href=... | [
{
"answer_id": 308292,
"author": "jerclarke",
"author_id": 175,
"author_profile": "https://wordpress.stackexchange.com/users/175",
"pm_score": 1,
"selected": true,
"text": "<p>It turns out that as part of <code>class-request->parse_response()</code>, where redirections are handled for... | 2018/07/11 | [
"https://wordpress.stackexchange.com/questions/308291",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/175/"
] | I discovered after much painful debugging that requests to the the WP HTTP API (in this case, though `wp_remote_request()`) always ended up as `GET` method after being redirected, even if the method was something else in the initial request (in my case `PURGE` as used by the [Varnish HTTP Purge plugin](https://wordpres... | It turns out that as part of `class-request->parse_response()`, where redirections are handled for the various higher-level request functions (this is where it does the recursive requests for each subsequent hop) there's a weird hook thing that ends up running `WP_Http->browser_redirect_compatibility()` on the redirect... |
308,301 | <p>I am creating a plugin that generates a theme, and so I want to have a checkbox at the end of the theme generation process that gives the possibility to activate the freshly created theme without having to do it manually.
Is there any function that can do that?</p>
| [
{
"answer_id": 308302,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": 1,
"selected": false,
"text": "<p>The only thing that comes to my mind is to do it from the database, so basically after you check the chec... | 2018/07/11 | [
"https://wordpress.stackexchange.com/questions/308301",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146776/"
] | I am creating a plugin that generates a theme, and so I want to have a checkbox at the end of the theme generation process that gives the possibility to activate the freshly created theme without having to do it manually.
Is there any function that can do that? | Of course there’s a function for that ([Codex](https://codex.wordpress.org/Function_Reference/switch_theme)):
```
switch_theme( $stylesheet )
```
It:
>
> Switches current theme to new template and stylesheet names. Accepts
> one argument: $stylesheet of the theme. ($stylesheet is the name of
> your folder slug. ... |
308,361 | <p>I have a running site (Site A).</p>
<p>I want to re-write the site fully to improve everything but, when I'm finished, I don't want to have to get everyone to sign up to the new site.</p>
<p>I wondered if I could create an entirely new site on a different domain (Site B) with a clean install of Wordpress - and the... | [
{
"answer_id": 308302,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": 1,
"selected": false,
"text": "<p>The only thing that comes to my mind is to do it from the database, so basically after you check the chec... | 2018/07/12 | [
"https://wordpress.stackexchange.com/questions/308361",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/39292/"
] | I have a running site (Site A).
I want to re-write the site fully to improve everything but, when I'm finished, I don't want to have to get everyone to sign up to the new site.
I wondered if I could create an entirely new site on a different domain (Site B) with a clean install of Wordpress - and then when I'm finish... | Of course there’s a function for that ([Codex](https://codex.wordpress.org/Function_Reference/switch_theme)):
```
switch_theme( $stylesheet )
```
It:
>
> Switches current theme to new template and stylesheet names. Accepts
> one argument: $stylesheet of the theme. ($stylesheet is the name of
> your folder slug. ... |
308,433 | <p>I am creating a comparison table and the issue is in while loop i am not able to put the <code>"tr"</code> in proper place. I need layout like this</p>
<pre><code><table>
<tr>
<td>post title 1</td>
<td>post title 2</td>
<td>post title 3</td>
</tr>
<tr>
&l... | [
{
"answer_id": 308434,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 2,
"selected": false,
"text": "<p>You need 3 separate loops. One for each row, with each post creating a new column:</p>\n\n<pre><code>&l... | 2018/07/13 | [
"https://wordpress.stackexchange.com/questions/308433",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/128610/"
] | I am creating a comparison table and the issue is in while loop i am not able to put the `"tr"` in proper place. I need layout like this
```
<table>
<tr>
<td>post title 1</td>
<td>post title 2</td>
<td>post title 3</td>
</tr>
<tr>
<td>post content 1</td>
<td>post content 2</td>
<td>post content 3</td>
</tr>
<tr>
<td>p... | ```
<div class="acadp">
<?php
$compare =[];
while( $acadp_query->have_posts() ) {
$acadp_query->the_post(); $post_meta = get_post_meta( $post->ID );
$category = wp_get_object_terms( $post->ID, 'acadp_categories' );
$compare['Title'][] = get_the_title();
$compare['Manufacturer'][] = $category[0]->nam... |
308,439 | <p>My version variable doesn't seem to be being applied within my enqueue functions (snippet below).</p>
<pre><code>//version number
$version = '1.0.0';
function frontend_styles($version) {
wp_enqueue_style(
'frontend_styles', //reference
get_stylesheet_directory_uri() . '/assets/css/app.min.css',... | [
{
"answer_id": 308440,
"author": "Florian",
"author_id": 52583,
"author_profile": "https://wordpress.stackexchange.com/users/52583",
"pm_score": 1,
"selected": false,
"text": "<p>Try this</p>\n\n<pre><code>// global theme version\n$version = '1.0.0';\n\nfunction frontend_styles() {\n\n ... | 2018/07/13 | [
"https://wordpress.stackexchange.com/questions/308439",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/141411/"
] | My version variable doesn't seem to be being applied within my enqueue functions (snippet below).
```
//version number
$version = '1.0.0';
function frontend_styles($version) {
wp_enqueue_style(
'frontend_styles', //reference
get_stylesheet_directory_uri() . '/assets/css/app.min.css', //source
... | Try this
```
// global theme version
$version = '1.0.0';
function frontend_styles() {
global $version;
wp_enqueue_style(
'frontend_styles', //reference
get_stylesheet_directory_uri() . '/assets/css/app.min.css', //source
array(), //dependenices
$version, //version number
... |
308,444 | <p>I have been searching for theme developing info but all that are related to this subject are talking about a custom page at <code>page.php</code>.</p>
<p>What I am trying to achieve is different. The scenario is that I have to create a page where the content is hard-coded, so I can have more creative freedom on the... | [
{
"answer_id": 308440,
"author": "Florian",
"author_id": 52583,
"author_profile": "https://wordpress.stackexchange.com/users/52583",
"pm_score": 1,
"selected": false,
"text": "<p>Try this</p>\n\n<pre><code>// global theme version\n$version = '1.0.0';\n\nfunction frontend_styles() {\n\n ... | 2018/07/13 | [
"https://wordpress.stackexchange.com/questions/308444",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146878/"
] | I have been searching for theme developing info but all that are related to this subject are talking about a custom page at `page.php`.
What I am trying to achieve is different. The scenario is that I have to create a page where the content is hard-coded, so I can have more creative freedom on the design. That is to s... | Try this
```
// global theme version
$version = '1.0.0';
function frontend_styles() {
global $version;
wp_enqueue_style(
'frontend_styles', //reference
get_stylesheet_directory_uri() . '/assets/css/app.min.css', //source
array(), //dependenices
$version, //version number
... |
308,457 | <p>I am currently using Wordpress and I have a problem. I'm trying to develop a code that shows an image or another image based on the value of the custom field</p>
<p>In each product, for example, I have a variable called store_1 or store_2 apart from the main stock of the product.</p>
<p>What I want to do is a cust... | [
{
"answer_id": 308440,
"author": "Florian",
"author_id": 52583,
"author_profile": "https://wordpress.stackexchange.com/users/52583",
"pm_score": 1,
"selected": false,
"text": "<p>Try this</p>\n\n<pre><code>// global theme version\n$version = '1.0.0';\n\nfunction frontend_styles() {\n\n ... | 2018/07/13 | [
"https://wordpress.stackexchange.com/questions/308457",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146891/"
] | I am currently using Wordpress and I have a problem. I'm trying to develop a code that shows an image or another image based on the value of the custom field
In each product, for example, I have a variable called store\_1 or store\_2 apart from the main stock of the product.
What I want to do is a custom function for... | Try this
```
// global theme version
$version = '1.0.0';
function frontend_styles() {
global $version;
wp_enqueue_style(
'frontend_styles', //reference
get_stylesheet_directory_uri() . '/assets/css/app.min.css', //source
array(), //dependenices
$version, //version number
... |
308,466 | <p>I'm seeing a weird problem where if someone searches "Test Search" it's returning fine, but if someone searches "Test Search " it's returning some weird posts that don't seem relevant.</p>
<p>How do I go about trimming white space from beginning and end of a search term?</p>
| [
{
"answer_id": 308474,
"author": "cjbj",
"author_id": 75495,
"author_profile": "https://wordpress.stackexchange.com/users/75495",
"pm_score": 0,
"selected": false,
"text": "<p>In WordPress search terms are <a href=\"https://codex.wordpress.org/Class_Reference/WP_Query#Search_Parameter\" ... | 2018/07/13 | [
"https://wordpress.stackexchange.com/questions/308466",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/75134/"
] | I'm seeing a weird problem where if someone searches "Test Search" it's returning fine, but if someone searches "Test Search " it's returning some weird posts that don't seem relevant.
How do I go about trimming white space from beginning and end of a search term? | I came across the same problem.
In my opinion, this should be the default search behavior in WP.
The solution is to filter the array of parsed query variables.
See the documentation [here](https://developer.wordpress.org/reference/hooks/request/).
Add this to the `functions.php` file in your theme directory.
`... |
308,470 | <p>I'm fairly new to wordpress and the content management system. I've been following a couple of tutorials to get started. I've been searching for specifically how to include a date picker in the add new custom post type. </p>
<p><a href="https://i.stack.imgur.com/sCISj.png" rel="nofollow noreferrer"><img src="https:... | [
{
"answer_id": 308475,
"author": "sunil",
"author_id": 56910,
"author_profile": "https://wordpress.stackexchange.com/users/56910",
"pm_score": 1,
"selected": false,
"text": "<p>@vemuez</p>\n\n<p>you need to enqueue js and css files to admin_print_script and admin_print_style</p>\n\n<p>he... | 2018/07/13 | [
"https://wordpress.stackexchange.com/questions/308470",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146895/"
] | I'm fairly new to wordpress and the content management system. I've been following a couple of tutorials to get started. I've been searching for specifically how to include a date picker in the add new custom post type.
[](https://i.stack.imgur.com/sCI... | With the help of sunil's answer I figured out exactly what I needed to do.
I went and downloaded the free version of Metabox at <https://wordpress.org/plugins/meta-box/>
Once I downloaded it, I've placed it in `child-theme/external/meta-box`and referenced it from `child-theme/inc/events-custom-post-type.php`.
`even... |
308,497 | <p>How can I copy the default styling for the admin and tell wordpress to use custom style instead of the default? Basically I want to change the colour and font without having to use !important syntax to force Wordpress to use it. </p>
| [
{
"answer_id": 308567,
"author": "dhirenpatel22",
"author_id": 124380,
"author_profile": "https://wordpress.stackexchange.com/users/124380",
"pm_score": 1,
"selected": false,
"text": "<p>Enqueue custom admin CSS file (custom-admin.css) in your WordPress backend using below function:</p>\... | 2018/07/13 | [
"https://wordpress.stackexchange.com/questions/308497",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146914/"
] | How can I copy the default styling for the admin and tell wordpress to use custom style instead of the default? Basically I want to change the colour and font without having to use !important syntax to force Wordpress to use it. | As noted by @Fusion, this has changed beginning with version 5. In order to override admin styles for 5.\*, you need a hook in `functions.php`, something like this:
```php
function custom_admin() {
$url = get_settings('siteurl');
$url = $url . '/wp-content/themes/my-theme/wp-admin.css';
echo '<link rel="st... |
308,505 | <p>What is the best approach to changing admin menu labels? As part of my first step in modifying the admin area, I would like to know how I can change <strong>WooCommerce</strong> label to <strong>Shop</strong>? </p>
| [
{
"answer_id": 308506,
"author": "Castiblanco",
"author_id": 44370,
"author_profile": "https://wordpress.stackexchange.com/users/44370",
"pm_score": 3,
"selected": true,
"text": "<p>In order to change the menu labels you will have to go to add this code into your <code>functions.php</cod... | 2018/07/14 | [
"https://wordpress.stackexchange.com/questions/308505",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146914/"
] | What is the best approach to changing admin menu labels? As part of my first step in modifying the admin area, I would like to know how I can change **WooCommerce** label to **Shop**? | In order to change the menu labels you will have to go to add this code into your `functions.php`:
```
add_filter( 'gettext', 'change_woocommerce_text' );
function change_woocommerce_text( $translated )
{
$translated = str_replace( 'WooCommerce', 'Store', $translated );
return $translated;
}
```
Tested. |
308,509 | <p>In the <code>register_post_status</code>, I've already disabled
<code>show_in_admin_all_list</code> & <code>show_in_admin_status_list</code> for my custom status <code>my_hidden_status</code></p>
<p>However, from the query log the post_status <code>my_hidden_status</code> is still not being filtered out (when lo... | [
{
"answer_id": 308731,
"author": "SeventhSteel",
"author_id": 17276,
"author_profile": "https://wordpress.stackexchange.com/users/17276",
"pm_score": 1,
"selected": false,
"text": "<p>Is it a bug? It's doing a little more work than it has to, but it's not resulting in any unexpected outp... | 2018/07/14 | [
"https://wordpress.stackexchange.com/questions/308509",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/16037/"
] | In the `register_post_status`, I've already disabled
`show_in_admin_all_list` & `show_in_admin_status_list` for my custom status `my_hidden_status`
However, from the query log the post\_status `my_hidden_status` is still not being filtered out (when loading edit.php)
e.g.
```
SELECT post_status, COUNT( * ) AS num_po... | >
> ***TL;DR:*** It's not a bug (*as we generally understand it*), rather it's a feature that was **never fully implemented** in WordPress.
>
>
>
---
Status of `register_post_status()`
----------------------------------
`register_post_status()` function was never fully implemented in WordPress. If you check Word... |
308,517 | <p>I have following foreach loop code...</p>
<pre><code><?php
$usernames = $wpdb->get_results( "SELECT user_name FROM wpxa_project_members WHERE project_id = 698" );
foreach ( $usernames as $username )
{
echo $username->user_name;
}
?>
</code></pre>
<p>When I use <code>echo $username->user_name... | [
{
"answer_id": 308519,
"author": "Andrea Somovigo",
"author_id": 64435,
"author_profile": "https://wordpress.stackexchange.com/users/64435",
"pm_score": 1,
"selected": false,
"text": "<pre><code>$usernames = $wpdb->get_results( \"SELECT user_name FROM wpxa_project_members WHERE projec... | 2018/07/14 | [
"https://wordpress.stackexchange.com/questions/308517",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124069/"
] | I have following foreach loop code...
```
<?php
$usernames = $wpdb->get_results( "SELECT user_name FROM wpxa_project_members WHERE project_id = 698" );
foreach ( $usernames as $username )
{
echo $username->user_name;
}
?>
```
When I use `echo $username->user_name;` it displays all the usernames from the `use... | I have found the solution... Here it is...
```
<?php
$usernames = $wpdb->get_results( "SELECT user_name FROM wpxa_project_members WHERE project_id = 698" );
foreach ( $usernames as $username )
{
$member_username[] = $username->user_name;
}
echo $member_username[0];
?>
```
Hope it may help other users. |
308,520 | <p>I want to hide the navigation menu on a particular page. I know how to find the page id, but I am clueless about how to find the rest of the stuff, it would be great if someone could look into my blog's css from the link - idkwhereto.com</p>
<p>Thanks.</p>
| [
{
"answer_id": 308519,
"author": "Andrea Somovigo",
"author_id": 64435,
"author_profile": "https://wordpress.stackexchange.com/users/64435",
"pm_score": 1,
"selected": false,
"text": "<pre><code>$usernames = $wpdb->get_results( \"SELECT user_name FROM wpxa_project_members WHERE projec... | 2018/07/14 | [
"https://wordpress.stackexchange.com/questions/308520",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146922/"
] | I want to hide the navigation menu on a particular page. I know how to find the page id, but I am clueless about how to find the rest of the stuff, it would be great if someone could look into my blog's css from the link - idkwhereto.com
Thanks. | I have found the solution... Here it is...
```
<?php
$usernames = $wpdb->get_results( "SELECT user_name FROM wpxa_project_members WHERE project_id = 698" );
foreach ( $usernames as $username )
{
$member_username[] = $username->user_name;
}
echo $member_username[0];
?>
```
Hope it may help other users. |
308,532 | <p>For some reason, I have to unpublish certain posts every time wordpress loads.
This is my code: </p>
<pre><code>function af_change_post_status() {
$notpayed_posts = new WP_Query( array(
'meta_key' => '_payment',
'meta_value' => '0'
) );
foreach (... | [
{
"answer_id": 308533,
"author": "Krzysiek Dróżdż",
"author_id": 34172,
"author_profile": "https://wordpress.stackexchange.com/users/34172",
"pm_score": 1,
"selected": false,
"text": "<p>It's pretty simple error. You use <code>WP_Query</code> to get posts, but then you try to use that <c... | 2018/07/14 | [
"https://wordpress.stackexchange.com/questions/308532",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/136480/"
] | For some reason, I have to unpublish certain posts every time wordpress loads.
This is my code:
```
function af_change_post_status() {
$notpayed_posts = new WP_Query( array(
'meta_key' => '_payment',
'meta_value' => '0'
) );
foreach ($notpayed_posts as $... | >
> This function contains do\_action() calls for post status transition
> action hooks. The order of the words in the function name might be
> confusing – **it does not change the status of posts, it only calls
> actions that can be hooked into by plugin developers.**
>
>
>
<https://codex.wordpress.org/Functio... |
308,542 | <p>Hi i'm just begining with wordpress so any help would be appreciated. I trying to get this working but the response data is undefined because of the 400 error. I've tried everything. Here's my code.</p>
<pre><code>function simokydesigns_translate_scripts() {
wp_enqueue_script('customjquery', get_template_direct... | [
{
"answer_id": 308544,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 0,
"selected": false,
"text": "<p>This line break here:</p>\n\n<pre><code>wp_localize_script( 'customjquery', 'ajaxurl', admin_url( 'admi... | 2018/07/14 | [
"https://wordpress.stackexchange.com/questions/308542",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146939/"
] | Hi i'm just begining with wordpress so any help would be appreciated. I trying to get this working but the response data is undefined because of the 400 error. I've tried everything. Here's my code.
```
function simokydesigns_translate_scripts() {
wp_enqueue_script('customjquery', get_template_directory_uri()
... | You have two problems
in PHP you need change this
is bad:
```
wp_localize_script( 'customjquery', 'ajaxurl', admin_url( 'admin-
ajax.php' ) );
```
change to:
```
wp_localize_script( 'customjquery', 'my_custom_vars', ['ajax_url' => admin_url('admin-ajax.php')] );
```
and your javascript need this changes
is... |
308,552 | <p>I am trying to get product attribute slug. I have used below code but it display name. </p>
<pre><code>echo $_product->get_attribute( 'pa_color' );
</code></pre>
<p>I am working on woocommerce/cart/cart.php file in theme folder.</p>
<p>Also I checked this is coming in anchor url of product image in cart page b... | [
{
"answer_id": 308556,
"author": "Andrea Somovigo",
"author_id": 64435,
"author_profile": "https://wordpress.stackexchange.com/users/64435",
"pm_score": 2,
"selected": false,
"text": "<pre><code>$att=$_product->get_attribute('pa_color');\n\n$values = wc_get_product_terms( $product->... | 2018/07/14 | [
"https://wordpress.stackexchange.com/questions/308552",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/145656/"
] | I am trying to get product attribute slug. I have used below code but it display name.
```
echo $_product->get_attribute( 'pa_color' );
```
I am working on woocommerce/cart/cart.php file in theme folder.
Also I checked this is coming in anchor url of product image in cart page but not getting it
**anchor url**: <... | I got this....
To get slug use:
```
$attributes = $_product->get_attributes();
$pa_color = $attributes["pa_color"];
```
Thanks to all for helping me. |
308,580 | <p>I want to know how to change the login label such as Username or Email Address to Username within the wp-login.php?</p>
| [
{
"answer_id": 308583,
"author": "Rick Hellewell",
"author_id": 29416,
"author_profile": "https://wordpress.stackexchange.com/users/29416",
"pm_score": -1,
"selected": false,
"text": "<p>@William : although your solution may work, it's not the proper way (which is why you got a downvote)... | 2018/07/14 | [
"https://wordpress.stackexchange.com/questions/308580",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146914/"
] | I want to know how to change the login label such as Username or Email Address to Username within the wp-login.php? | All of these strings/labels are passed through translation functions, so you can use [`gettext`](https://codex.wordpress.org/Plugin_API/Filter_Reference/gettext) filter to modify them.
```
function change_labels( $translated_text, $text, $domain ) {
if ( 'Username' === $text ) {
$translated_text = 'Usernam... |
308,591 | <p>I have added custom field in woocommerce Products>General Tab. But I am not getting those custom fields value in response using following link:- <a href="http://yoursite.com/wp-json/wc/v2/products/" rel="nofollow noreferrer">http://yoursite.com/wp-json/wc/v2/products/</a></p>
<p>My Code:-</p>
<pre><code>//Display ... | [
{
"answer_id": 308608,
"author": "Andrea Somovigo",
"author_id": 64435,
"author_profile": "https://wordpress.stackexchange.com/users/64435",
"pm_score": 2,
"selected": false,
"text": "<p>You should ad the custom field to product API response, try this\n (untested)</p>\n\n<pre><code>add_f... | 2018/07/15 | [
"https://wordpress.stackexchange.com/questions/308591",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146897/"
] | I have added custom field in woocommerce Products>General Tab. But I am not getting those custom fields value in response using following link:- <http://yoursite.com/wp-json/wc/v2/products/>
My Code:-
```
//Display Fields
add_action( 'woocommerce_product_options_general_product_data', 'woo_add_custom_general_fiel... | You should ad the custom field to product API response, try this
(untested)
```
add_filter( 'woocommerce_rest_prepare_product', 'custom_products_api_data', 90, 2 );
function custom_products_api_data( $response, $post ) {
// retrieve a custom field and add it to API response
$response->data['purchasing_cost'] = get_p... |
308,611 | <p>I am using <code>save_post</code> for a function to send an email when a post is updated by a user. This is firing twice and I am aware this is due to the post revisions and autosaves. </p>
<p>I have tried to prevent this from happening by wrapping my <code>wp_mail</code> within a conditional statement but this sti... | [
{
"answer_id": 308612,
"author": "Atlas_Gondal",
"author_id": 132879,
"author_profile": "https://wordpress.stackexchange.com/users/132879",
"pm_score": 0,
"selected": false,
"text": "<p>Try this piece of code inside your function:</p>\n\n<pre><code>if ( defined( 'DOING_AUTOSAVE' ) &&... | 2018/07/15 | [
"https://wordpress.stackexchange.com/questions/308611",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/64567/"
] | I am using `save_post` for a function to send an email when a post is updated by a user. This is firing twice and I am aware this is due to the post revisions and autosaves.
I have tried to prevent this from happening by wrapping my `wp_mail` within a conditional statement but this still fires twice. What adjustments... | First, you can use this hook to target only one custom type:
<https://developer.wordpress.org/reference/hooks/save_post_post-post_type/>
This hook (and `save_post`) is called the first time when you click on "new ..." and then the hook is called with `$update = FALSE`.
Then to send e-mail only when the object is ... |
308,656 | <p>I am using WP_Query to loop a Custom Field, Custom Post Type that shows 6 Menu Icons across 6 horizontal fields. The icons do not show on the page. </p>
<p>My query code is:</p>
<pre><code><?php $loop = new WP_Query( array( 'post_type' => 'course_feature', 'orderby', => 'post_id', 'order' => 'ASC')); ... | [
{
"answer_id": 308657,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 2,
"selected": false,
"text": "<p>There's a missing opening quote and closing bracket on this line:</p>\n\n<pre><code><i class=<?ph... | 2018/07/16 | [
"https://wordpress.stackexchange.com/questions/308656",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146589/"
] | I am using WP\_Query to loop a Custom Field, Custom Post Type that shows 6 Menu Icons across 6 horizontal fields. The icons do not show on the page.
My query code is:
```
<?php $loop = new WP_Query( array( 'post_type' => 'course_feature', 'orderby', => 'post_id', 'order' => 'ASC')); ?>
```
code to show loop:
```
... | There's a missing opening quote and closing bracket on this line:
```
<i class=<?php the_field('course_feature_icon'); ?>"</i>
```
Needs to be:
```
<i class="<?php the_field('course_feature_icon'); ?>"></i>
```
That's all that's wrong with your code. It should then work assuming:
1. You have a custom field, `cou... |
308,661 | <p>How can I change the menu icon (coming from external plugins, like WooCommerce) in wp-admin area with custom icon? (The menu-item is actually <code>post-type</code>, so there should be some <code>register_post_type</code> command i think).</p>
| [
{
"answer_id": 308665,
"author": "mmm",
"author_id": 74311,
"author_profile": "https://wordpress.stackexchange.com/users/74311",
"pm_score": 0,
"selected": false,
"text": "<p>to add a custom image, you can use this code. the original image is set with CSS then you have to add custom CSS ... | 2018/07/16 | [
"https://wordpress.stackexchange.com/questions/308661",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146914/"
] | How can I change the menu icon (coming from external plugins, like WooCommerce) in wp-admin area with custom icon? (The menu-item is actually `post-type`, so there should be some `register_post_type` command i think). | WooCommerce styles the icon via this CSS file: `woocommerce/assets/css/menu.css`, and here's the corresponding code (*pretty-printed* or actually, I copied it from [`woocommerce/assets/css/menu.scss`](https://plugins.trac.wordpress.org/browser/woocommerce/tags/3.4.3/assets/css/menu.scss#L17)):
```
#adminmenu #toplevel... |
308,695 | <p>I have Used the function <code>dynamic_sidebar('sidebarId')</code> in the <code>sidebar.php</code> file.</p>
<p>and all the functionality of the sidebar is Working succsessfully </p>
<p>My Question is How To Change the Html of the sidebar widgets and add some classes in widget items To fit My Design ?</p>
<p><a h... | [
{
"answer_id": 308665,
"author": "mmm",
"author_id": 74311,
"author_profile": "https://wordpress.stackexchange.com/users/74311",
"pm_score": 0,
"selected": false,
"text": "<p>to add a custom image, you can use this code. the original image is set with CSS then you have to add custom CSS ... | 2018/07/16 | [
"https://wordpress.stackexchange.com/questions/308695",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/142085/"
] | I have Used the function `dynamic_sidebar('sidebarId')` in the `sidebar.php` file.
and all the functionality of the sidebar is Working succsessfully
My Question is How To Change the Html of the sidebar widgets and add some classes in widget items To fit My Design ?
[):
```
#adminmenu #toplevel... |
308,700 | <p>My parent theme calls a function:</p>
<pre><code>function get_nav_markup() {
ob_start();
?>
<nav class="navbar navbar-toggleable-md navbar-inverse site-navbar" role="navigation">
<div class="container">
<?php if ( is_home() ): ?>
<h1 class="navbar-bran... | [
{
"answer_id": 308702,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 2,
"selected": false,
"text": "<p>No, it doesn't appear to be possible. At least not directly. You can replace functions in parent themes... | 2018/07/16 | [
"https://wordpress.stackexchange.com/questions/308700",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/146418/"
] | My parent theme calls a function:
```
function get_nav_markup() {
ob_start();
?>
<nav class="navbar navbar-toggleable-md navbar-inverse site-navbar" role="navigation">
<div class="container">
<?php if ( is_home() ): ?>
<h1 class="navbar-brand mb-0">
<?php echo ge... | Ok so here is what I have decided given the situation.
1. I have copied the header.php file into my child theme.
2. I have changed the line in the header file from get\_header\_markup(); to get\_header\_markup\_updated();
3. I have then created a new function in my child themes function.php file called get\_header\_m... |
308,730 | <p>I'm trying to build functionality (using the Advanced Custom Fields plugin) to list information in a page template for all custom post types ('Product') that have specified taxonomies.</p>
<p>This is my current stable code, which queries the Products, but only based on the taxonomy terms I hard-code:</p>
<pre><cod... | [
{
"answer_id": 308738,
"author": "Paul Elrich",
"author_id": 146435,
"author_profile": "https://wordpress.stackexchange.com/users/146435",
"pm_score": -1,
"selected": false,
"text": "<p>If conditions don't run inside of arrays, so you will need to write separate arrays for each condition... | 2018/07/16 | [
"https://wordpress.stackexchange.com/questions/308730",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/115332/"
] | I'm trying to build functionality (using the Advanced Custom Fields plugin) to list information in a page template for all custom post types ('Product') that have specified taxonomies.
This is my current stable code, which queries the Products, but only based on the taxonomy terms I hard-code:
```
$posts = get_posts(... | OK, I have no idea how and why your code should work... It has nothing in common with correct PHP syntax... But it's pretty good pseudo-code, so I think I can guess, what you wanted to achieve...
```
$tax_query = array();
if ( have_rows('category_taxonomies') ) {
while ( have_rows('category_taxonomies') ) {
... |
308,759 | <p>I wanted to combine multiple categories in one Menu item</p>
<p>I checked this dicussion, someone said:</p>
<blockquote>
<p>You'd have to make a custom link for that.</p>
<p>Make your URL <a href="http://www.example.com/?cat=(id-white),(id-rabbit)" rel="nofollow noreferrer">http://www.example.com/?cat=(id-w... | [
{
"answer_id": 308770,
"author": "kero",
"author_id": 108180,
"author_profile": "https://wordpress.stackexchange.com/users/108180",
"pm_score": 2,
"selected": false,
"text": "<p>You misunderstood the quote, the URL needs to be</p>\n\n<pre><code>http://example.com/?cat=32,33\n</code></pre... | 2018/07/17 | [
"https://wordpress.stackexchange.com/questions/308759",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/135792/"
] | I wanted to combine multiple categories in one Menu item
I checked this dicussion, someone said:
>
> You'd have to make a custom link for that.
>
>
> Make your URL <http://www.example.com/?cat=(id-white),(id-rabbit)>
>
>
>
Below is my link but can't show the correct categories. ID is correct.
<http://example.... | You misunderstood the quote, the URL needs to be
```
http://example.com/?cat=32,33
```
I just tested it and it seems to work. However, the title was only one of the categories' name, there might be other problems with this solution. |
308,837 | <p>I want the custom fields for PDF file upload on admin side for the post where i can select any PDF file for the any posts using custom code or any type of plugins.</p>
<p>can you recommend me please by which my problem can be solved ?</p>
<pre><code><?php
$array=array('posts_per_page'=>2, 'post_type'=>'p... | [
{
"answer_id": 308839,
"author": "dhirenpatel22",
"author_id": 124380,
"author_profile": "https://wordpress.stackexchange.com/users/124380",
"pm_score": 3,
"selected": true,
"text": "<p>Follow below steps to create custom PDF upload field in custom post type:</p>\n\n<ol>\n<li>Install <a ... | 2018/07/17 | [
"https://wordpress.stackexchange.com/questions/308837",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/144155/"
] | I want the custom fields for PDF file upload on admin side for the post where i can select any PDF file for the any posts using custom code or any type of plugins.
can you recommend me please by which my problem can be solved ?
```
<?php
$array=array('posts_per_page'=>2, 'post_type'=>'post');
$mypost=get_posts($arra... | Follow below steps to create custom PDF upload field in custom post type:
1. Install [Advance Custom Field](https://wordpress.org/plugins/advanced-custom-fields/) from wordpress.org
2. Go to **Custom Fields** and click on **Add New** button.
3. Follow instructions in below screenshot to add the custom field to upload ... |
308,854 | <p>To start I've been searching through several questions and documentation pieces but it seems with WordPress' <code>v2</code> many of the old questions are no longer valid. What I am trying to do is get all posts or a singular post from a category in Postman instead of the common returned 10 posts without having to m... | [
{
"answer_id": 308869,
"author": "Jacob Peattie",
"author_id": 39152,
"author_profile": "https://wordpress.stackexchange.com/users/39152",
"pm_score": 2,
"selected": false,
"text": "<p>Pretty much all the URLs you are using are invalid in some way:</p>\n\n<pre><code>http://foobar.com/wp-... | 2018/07/17 | [
"https://wordpress.stackexchange.com/questions/308854",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/25271/"
] | To start I've been searching through several questions and documentation pieces but it seems with WordPress' `v2` many of the old questions are no longer valid. What I am trying to do is get all posts or a singular post from a category in Postman instead of the common returned 10 posts without having to modify the API ... | After a few hours trying different permutations of how to get a return on categories I found my answer. To establish the listing of categories associated with `post` use:
```
/wp-json/wp/v2/categories/
```
I needed a particular category and the `id` of that category was `4` and the slug was called `foobar`.
To get ... |
308,876 | <p>My wordpress site dj.pyromusic.cn is based in China, on a chinese server. Somewhere in the theme, or the site, it is making a request to youtube which is obviously blocked here, causing the load time to be over 300 seconds before it times out.</p>
<p>Here is a screenshot of the inspection:</p>
<p><a href="https://... | [
{
"answer_id": 308877,
"author": "HU is Sebastian",
"author_id": 56587,
"author_profile": "https://wordpress.stackexchange.com/users/56587",
"pm_score": 1,
"selected": false,
"text": "<p>The Youtube is called by a script named \"jquery.st.youtube.js\" which is located in your themes fold... | 2018/07/18 | [
"https://wordpress.stackexchange.com/questions/308876",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147123/"
] | My wordpress site dj.pyromusic.cn is based in China, on a chinese server. Somewhere in the theme, or the site, it is making a request to youtube which is obviously blocked here, causing the load time to be over 300 seconds before it times out.
Here is a screenshot of the inspection:
[ You can edit the themes files directly, search for the enqueuing of the script jquery.st.youtube.js (most likely... |
308,909 | <p>I have access to a single Linux/Apache server where I'm trying to deploy WordPress. For purposes of this error, I've tested it with the default twentyseventeen theme and all plugins disabled.</p>
<p>When I go to any wp-admin page, logged in as an administrator, most of the icons from the left navigation are missing... | [
{
"answer_id": 308916,
"author": "HU is Sebastian",
"author_id": 56587,
"author_profile": "https://wordpress.stackexchange.com/users/56587",
"pm_score": 1,
"selected": false,
"text": "<p>Do you load own javascripts into the admin? If i recall correctly, if SCRIPT_DEBUG is set to true, th... | 2018/07/18 | [
"https://wordpress.stackexchange.com/questions/308909",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/41356/"
] | I have access to a single Linux/Apache server where I'm trying to deploy WordPress. For purposes of this error, I've tested it with the default twentyseventeen theme and all plugins disabled.
When I go to any wp-admin page, logged in as an administrator, most of the icons from the left navigation are missing, checked ... | Do you load own javascripts into the admin? If i recall correctly, if SCRIPT\_DEBUG is set to true, the javascripts are not concenated, but loaded seperately. So if a custom javascript doesn't play well being concenated, this can lead to the whole concenated javascript being corrupt and not being run correctly.
Try r... |
308,933 | <p>I try this:</p>
<pre><code><?php
function get_ct($id){
$ct = apply_filters('the_content', get_post_field('post_content', $id));
return $ct;
}
$arr = array('post_content' => get_ct(126));
echo json_encode($arr);
?>
</code></pre>
<p>but the post_content 's values ist null a... | [
{
"answer_id": 308916,
"author": "HU is Sebastian",
"author_id": 56587,
"author_profile": "https://wordpress.stackexchange.com/users/56587",
"pm_score": 1,
"selected": false,
"text": "<p>Do you load own javascripts into the admin? If i recall correctly, if SCRIPT_DEBUG is set to true, th... | 2018/07/18 | [
"https://wordpress.stackexchange.com/questions/308933",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147160/"
] | I try this:
```
<?php
function get_ct($id){
$ct = apply_filters('the_content', get_post_field('post_content', $id));
return $ct;
}
$arr = array('post_content' => get_ct(126));
echo json_encode($arr);
?>
```
but the post\_content 's values ist null any suggestion? thanks | Do you load own javascripts into the admin? If i recall correctly, if SCRIPT\_DEBUG is set to true, the javascripts are not concenated, but loaded seperately. So if a custom javascript doesn't play well being concenated, this can lead to the whole concenated javascript being corrupt and not being run correctly.
Try r... |
308,941 | <p>In August, GDPR requires all websites to have a cookie notification on every page. I am creating a custom post type plugin - but I'm having one problem. The content from the custom post type page isn't being pulled in - it's pulling in the content from the page it is on. If I click on the permalink of the notice pag... | [
{
"answer_id": 308916,
"author": "HU is Sebastian",
"author_id": 56587,
"author_profile": "https://wordpress.stackexchange.com/users/56587",
"pm_score": 1,
"selected": false,
"text": "<p>Do you load own javascripts into the admin? If i recall correctly, if SCRIPT_DEBUG is set to true, th... | 2018/07/18 | [
"https://wordpress.stackexchange.com/questions/308941",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/145059/"
] | In August, GDPR requires all websites to have a cookie notification on every page. I am creating a custom post type plugin - but I'm having one problem. The content from the custom post type page isn't being pulled in - it's pulling in the content from the page it is on. If I click on the permalink of the notice page -... | Do you load own javascripts into the admin? If i recall correctly, if SCRIPT\_DEBUG is set to true, the javascripts are not concenated, but loaded seperately. So if a custom javascript doesn't play well being concenated, this can lead to the whole concenated javascript being corrupt and not being run correctly.
Try r... |
308,950 | <p>I have a question about <a href="https://codex.wordpress.org/Post_Types#Custom_Post_Types" rel="nofollow noreferrer">this</a> documentation.</p>
<p>Why would I register a Custom Post Type in the init function as the docs suggest? Is this only if I am not using a plugin?</p>
<p>As I understand it, <a href="https://... | [
{
"answer_id": 308951,
"author": "Frank P. Walentynowicz",
"author_id": 32851,
"author_profile": "https://wordpress.stackexchange.com/users/32851",
"pm_score": 3,
"selected": true,
"text": "<p><code>register_post_type</code> function should be executed every time a WP request is made. De... | 2018/07/18 | [
"https://wordpress.stackexchange.com/questions/308950",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/77764/"
] | I have a question about [this](https://codex.wordpress.org/Post_Types#Custom_Post_Types) documentation.
Why would I register a Custom Post Type in the init function as the docs suggest? Is this only if I am not using a plugin?
As I understand it, [init runs every-time WordPress runs/is-loaded](https://codex.wordpress... | `register_post_type` function should be executed every time a WP request is made. Default post types don't have this requirement. You can use your code as is, in MU plugin. Just create a `.PHP` file with this code, and place it in `mu-plugins` sub-folder of `wp-content`. You don't need to provide any standard plugin he... |
308,953 | <p>I am converting a static website made with Bootstrap in WordPress.
Here is my bootstrap multilevel navigation menu code: </p>
<pre><code><section class="menuBar">
<nav class="navbar navbar-expand-lg navbar-light" data-toggle="sticky-onscroll">
<div class="container">
<b... | [
{
"answer_id": 308957,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 3,
"selected": true,
"text": "<p>Here some thing interesting for you</p>\n\n<p><strong>STEP 1</strong>\nadd a script to header like below ( it's al... | 2018/07/18 | [
"https://wordpress.stackexchange.com/questions/308953",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/137372/"
] | I am converting a static website made with Bootstrap in WordPress.
Here is my bootstrap multilevel navigation menu code:
```
<section class="menuBar">
<nav class="navbar navbar-expand-lg navbar-light" data-toggle="sticky-onscroll">
<div class="container">
<button class="navbar-toggler collaps... | Here some thing interesting for you
**STEP 1**
add a script to header like below ( it's always better go for the enqueue method . i need some one to help me with properly adding the below script in WordPress way .jquery should run before the second script>
```
<script src="http://ajax.googleapis.com/ajax/libs/jquery... |
308,959 | <p>I have a blog. My computer crashed months ago, my username is <code>admin</code> I have tried to recover my password but as it is lost create a new one, they sent a huge long address password will not let me copy and I just do not know what to do. I have recently paid for hosting the site again and can't use my dash... | [
{
"answer_id": 308957,
"author": "Community",
"author_id": -1,
"author_profile": "https://wordpress.stackexchange.com/users/-1",
"pm_score": 3,
"selected": true,
"text": "<p>Here some thing interesting for you</p>\n\n<p><strong>STEP 1</strong>\nadd a script to header like below ( it's al... | 2018/07/19 | [
"https://wordpress.stackexchange.com/questions/308959",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147180/"
] | I have a blog. My computer crashed months ago, my username is `admin` I have tried to recover my password but as it is lost create a new one, they sent a huge long address password will not let me copy and I just do not know what to do. I have recently paid for hosting the site again and can't use my dashboard. | Here some thing interesting for you
**STEP 1**
add a script to header like below ( it's always better go for the enqueue method . i need some one to help me with properly adding the below script in WordPress way .jquery should run before the second script>
```
<script src="http://ajax.googleapis.com/ajax/libs/jquery... |
308,970 | <p>I have a widget located at <code>/child-theme/includes/custom-widget.php</code>.</p>
<p>How do I call <code>register_widget</code> and reference that widget?</p>
<p>I've tried something like the following inside <code>functions.php</code>:</p>
<pre><code>function SER_register_widgets() {
register_widget( 'incl... | [
{
"answer_id": 308972,
"author": "maverick",
"author_id": 132953,
"author_profile": "https://wordpress.stackexchange.com/users/132953",
"pm_score": 3,
"selected": true,
"text": "<p>include that file in your functions.php file like </p>\n\n<p><code>require_once('includes/custom-widgets.ph... | 2018/07/19 | [
"https://wordpress.stackexchange.com/questions/308970",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147186/"
] | I have a widget located at `/child-theme/includes/custom-widget.php`.
How do I call `register_widget` and reference that widget?
I've tried something like the following inside `functions.php`:
```
function SER_register_widgets() {
register_widget( 'includes/custom-widget.php' );
}
add_action( 'widgets_init', 'SER... | include that file in your functions.php file like
`require_once('includes/custom-widgets.php');`
then you can call `add_action()` hook, in your case
`add_action('widgets_init', 'SER_register_widgets'); .`
the idea is to make that function ( ser\_register\_widgets ) visible in current php file ( functions.php file... |
308,994 | <p>I need to show the post featured image at the desired position on my theme template. At the same time, I need its width to be 300px and the height- adaptive.</p>
<p>What code should I add to my template?</p>
| [
{
"answer_id": 308995,
"author": "Guillermo Carone",
"author_id": 76897,
"author_profile": "https://wordpress.stackexchange.com/users/76897",
"pm_score": 0,
"selected": false,
"text": "<p>f you want the width of the image to be fixed and the height to change you should look into creating... | 2018/07/19 | [
"https://wordpress.stackexchange.com/questions/308994",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/145504/"
] | I need to show the post featured image at the desired position on my theme template. At the same time, I need its width to be 300px and the height- adaptive.
What code should I add to my template? | You can create custom size image with [`add_image_size()`](https://developer.wordpress.org/reference/functions/add_image_size/) in the functions.php
```
function add_custom_size_images() {
// Add image size width 300 with unlimited height.
add_image_size( 'featured-image-300', 300 );
}
add_action( 'after_setup... |
309,007 | <p>I have set up a custom post type, which user can edit from the frontend. I'm using <code>wp_delete_post()</code> to allow users to delete a post they created. It works, but the posts get deleted instead of being moved to trash.<p>I have tried moving a post to the bin via the backend and it works like you would expec... | [
{
"answer_id": 309013,
"author": "Hồ Trọng Linh Ân",
"author_id": 141631,
"author_profile": "https://wordpress.stackexchange.com/users/141631",
"pm_score": 4,
"selected": true,
"text": "<p>Following the line of code</p>\n\n<p><a href=\"https://core.trac.wordpress.org/browser/tags/4.9/src... | 2018/07/19 | [
"https://wordpress.stackexchange.com/questions/309007",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/136877/"
] | I have set up a custom post type, which user can edit from the frontend. I'm using `wp_delete_post()` to allow users to delete a post they created. It works, but the posts get deleted instead of being moved to trash.I have tried moving a post to the bin via the backend and it works like you would expect it, the post is... | Following the line of code
<https://core.trac.wordpress.org/browser/tags/4.9/src/wp-includes/post.php#L2467>
```
if ( ! $force_delete && ( 'post' === $post->post_type || 'page' === $post->post_type ) && 'trash' !== get_post_status( $postid ) && EMPTY_TRASH_DAYS ) {
return wp_trash_post( $postid );
}
```
the $fo... |
309,008 | <p>I would like to do the following:</p>
<p>Registered users in my wordpress application can receive messages. They can choose to receive messages in the following ways:</p>
<ul>
<li>The Wordpress application (Inbox system)</li>
<li>SMS message</li>
<li>Email</li>
</ul>
<p>I would like to use the <a href="https://nl... | [
{
"answer_id": 309383,
"author": "Deleyna",
"author_id": 147443,
"author_profile": "https://wordpress.stackexchange.com/users/147443",
"pm_score": 0,
"selected": false,
"text": "<p>Disclaimer: I'm a relatively new developer and don't know those plugins so my suggestions are general.</p>\... | 2018/07/19 | [
"https://wordpress.stackexchange.com/questions/309008",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/65180/"
] | I would like to do the following:
Registered users in my wordpress application can receive messages. They can choose to receive messages in the following ways:
* The Wordpress application (Inbox system)
* SMS message
* Email
I would like to use the [Front End PM plugin](https://nl.wordpress.org/plugins/front-end-pm/... | Levi Dulstein has a lot of righ, but in my opinion Front-end-pm uses two hooks to send messages:
* fep\_save\_message (from back-end)
* fep\_action\_message\_after\_send (from front-end)
Before sending a email few things are checked, like publishig or sending status (includes/class-fep-emails.php):
```
function save... |
309,043 | <p>I have all terms in English and I am creating/duplicating the same ones for German language by using foreach on english terms and this way i create all terms for German language. </p>
<p>The problem is when i need to assign an German term to its English version.</p>
<p>I tried the trick with TRID like this: </p>
... | [
{
"answer_id": 309046,
"author": "Agon Xheladini",
"author_id": 86433,
"author_profile": "https://wordpress.stackexchange.com/users/86433",
"pm_score": 1,
"selected": false,
"text": "<p>Ok I found the solution. </p>\n\n<p>Actually taxonomy name on icl_translation table is stored with pre... | 2018/07/19 | [
"https://wordpress.stackexchange.com/questions/309043",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/86433/"
] | I have all terms in English and I am creating/duplicating the same ones for German language by using foreach on english terms and this way i create all terms for German language.
The problem is when i need to assign an German term to its English version.
I tried the trick with TRID like this:
```
$trid = $sitepres... | Ok I found the solution.
Actually taxonomy name on icl\_translation table is stored with prefix called "tax\_" which means taxonomy. The above code would work like this:
```
$trid = $sitepress->get_element_trid($englist_term_id, "tax_taxonomy_name");
$sitepress->set_element_language_details($new_term_id, "tax_taxon... |
309,065 | <p><strong>Background</strong></p>
<p>I am using the theme Rookie from Sportpress.</p>
<p>I created a child theme.</p>
<p>Translation files are existing, especially german in my case.</p>
<p>Wordpress is set to german language.</p>
<p><strong>The Problem</strong></p>
<p>Translation is working fine everywhere exce... | [
{
"answer_id": 309077,
"author": "mmm",
"author_id": 74311,
"author_profile": "https://wordpress.stackexchange.com/users/74311",
"pm_score": -1,
"selected": false,
"text": "<p>Putting files in <code>wp-content/languages/themes/</code> is not a good idea because on the next update, the fi... | 2018/07/20 | [
"https://wordpress.stackexchange.com/questions/309065",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/136930/"
] | **Background**
I am using the theme Rookie from Sportpress.
I created a child theme.
Translation files are existing, especially german in my case.
Wordpress is set to german language.
**The Problem**
Translation is working fine everywhere except on themes provided templates like the search results page content or... | I downloaded the free Rookie parent theme and have no problem displaying translations of "Search Results for: %s" on a successful search results screen.
This works in the WordPress languages folder at `wp-content/languages/themes/rookie-de_DE.mo` as well as Loco Translate's custom directory. It works there if the file... |
309,106 | <p>I have following piece of code, which inserts usernames and other details of users in the database. After inserting the usernames I want to email them using <code>wp_mail();</code>. I am unable to do so. How can I do this?</p>
<pre><code>$member_details->user_login = array_map( 'sanitize_text_field', $_POST['use... | [
{
"answer_id": 309144,
"author": "LearntoExcel",
"author_id": 97108,
"author_profile": "https://wordpress.stackexchange.com/users/97108",
"pm_score": -1,
"selected": false,
"text": "<p>Let us see what code you are trying. Assuming that the hook you have bound that function to is firing,... | 2018/07/20 | [
"https://wordpress.stackexchange.com/questions/309106",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/124069/"
] | I have following piece of code, which inserts usernames and other details of users in the database. After inserting the usernames I want to email them using `wp_mail();`. I am unable to do so. How can I do this?
```
$member_details->user_login = array_map( 'sanitize_text_field', $_POST['user_login'] );
$member_details... | Assuming that `$member_details->user_login` is already a user in the `wp_users` table, then you could use the following to get their email address:
`$user = get_user_by( $member_details->user_login, 'login' );`
From there, you have the user's email address and can use `wp_mail()` to email them:
```
$subject = "My em... |
309,151 | <p>I use the following code to change the title of WordPress <strong>posts</strong> and <strong>pages</strong>. But it changes nav menu item titles too, which I want to avoid.</p>
<p>I want to change the title of posts and pages in: <strong>home page</strong>, all <strong>archive pages</strong> and all <strong>widgets... | [
{
"answer_id": 309154,
"author": "anmari",
"author_id": 3569,
"author_profile": "https://wordpress.stackexchange.com/users/3569",
"pm_score": -1,
"selected": false,
"text": "<p>If you have the post object (get_the_ID(); or $post->ID; are essentially the same) See <a href=\"https://stac... | 2018/07/21 | [
"https://wordpress.stackexchange.com/questions/309151",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/106350/"
] | I use the following code to change the title of WordPress **posts** and **pages**. But it changes nav menu item titles too, which I want to avoid.
I want to change the title of posts and pages in: **home page**, all **archive pages** and all **widgets** (recent posts widget, random post widget, etc.)
There are simil... | Problem Description:
--------------------
Let me rephrase the question first. You want to:
1. Set new title to all `post` and `page` type from a meta field.
2. You want this to happen everywhere (home page, single page, widgets etc.)
3. However, you don't want this title change to happen if the title is on the Naviga... |
309,177 | <p>I have a query as shown below:</p>
<pre><code><?php
$query = new WP_Query( $wpplnum );
while( $query->have_posts() ): $query->the_post();
?>
<div class="carousel-item col-md-4 active">
<div class="card">
<img class="card-img-top img-fluid" src="http://placehold.it/800x600/... | [
{
"answer_id": 309180,
"author": "user141080",
"author_id": 141080,
"author_profile": "https://wordpress.stackexchange.com/users/141080",
"pm_score": 0,
"selected": false,
"text": "<p>Do you mean something like the following?</p>\n\n<pre><code>$query = new WP_Query($wpplnum);\n\n$first =... | 2018/07/21 | [
"https://wordpress.stackexchange.com/questions/309177",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/-1/"
] | I have a query as shown below:
```
<?php
$query = new WP_Query( $wpplnum );
while( $query->have_posts() ): $query->the_post();
?>
<div class="carousel-item col-md-4 active">
<div class="card">
<img class="card-img-top img-fluid" src="http://placehold.it/800x600/f44242/fff" alt="Card image cap">
<di... | **I'd use the `current_post` property of the `WP_Query` class instance**, which in your case is the `$query`. So here I check if `$query->current_post` is greater than or equals to `1`:
```
<div class="carousel-item col-md-4 <?php echo $query->current_post >= 1 ? '' : 'active'; ?>">
```
Resource: <https://codex.word... |
309,185 | <p>so I am still quite new to wordpress development so don't rage and I am sorry if I did something really stupid.</p>
<p>So I am having trouble with my CSS, for some reason it's not affecting the widget content output, which can be seen in the movieposterdisplay-class file. What I am trying to do is make the outputte... | [
{
"answer_id": 309189,
"author": "Shubham Vijay",
"author_id": 28586,
"author_profile": "https://wordpress.stackexchange.com/users/28586",
"pm_score": -1,
"selected": false,
"text": "<p>Fortunately, it’s fairly easy to find and diagnose the problem. Go to any page on your site and, in Ch... | 2018/07/21 | [
"https://wordpress.stackexchange.com/questions/309185",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147303/"
] | so I am still quite new to wordpress development so don't rage and I am sorry if I did something really stupid.
So I am having trouble with my CSS, for some reason it's not affecting the widget content output, which can be seen in the movieposterdisplay-class file. What I am trying to do is make the outputted youtube ... | The problem was due to an incorrect file path in the movieposterdisplay-scripts file. Whilst the file loaded correctly in the main php file
`require_once(plugin_dir_path(__FILE__).'/includes/movieposterdisplay- class.php');`
as it already assigned the correct plugin folder name. It did not enqueue correctly as the co... |
309,190 | <p>Wordpress Category Archive permalinks set up with %category% include the full category tree. I want to see only the leaf category in the URL, not the full tree.</p>
<p>Example:</p>
<pre><code>Wordpress Category: recipes > baking > bread
current permalink for archive: domain.com/recipes/baking/bread
desired p... | [
{
"answer_id": 309189,
"author": "Shubham Vijay",
"author_id": 28586,
"author_profile": "https://wordpress.stackexchange.com/users/28586",
"pm_score": -1,
"selected": false,
"text": "<p>Fortunately, it’s fairly easy to find and diagnose the problem. Go to any page on your site and, in Ch... | 2018/07/21 | [
"https://wordpress.stackexchange.com/questions/309190",
"https://wordpress.stackexchange.com",
"https://wordpress.stackexchange.com/users/147308/"
] | Wordpress Category Archive permalinks set up with %category% include the full category tree. I want to see only the leaf category in the URL, not the full tree.
Example:
```
Wordpress Category: recipes > baking > bread
current permalink for archive: domain.com/recipes/baking/bread
desired permalink: domain.com/bread
... | The problem was due to an incorrect file path in the movieposterdisplay-scripts file. Whilst the file loaded correctly in the main php file
`require_once(plugin_dir_path(__FILE__).'/includes/movieposterdisplay- class.php');`
as it already assigned the correct plugin folder name. It did not enqueue correctly as the co... |