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
243,942
<p>I implement a <code>class</code> structure in my plugin, for example:</p> <pre><code>class Ethans_Plugin { public function __construct() { add_filter( 'admin_init', array( $this, 'admin' ), 10, 1 ); add_action( 'admin_footer', array( $this, 'footer' ), 10, 1 ); } public function admin()...
[ { "answer_id": 243943, "author": "rudtek", "author_id": 77767, "author_profile": "https://wordpress.stackexchange.com/users/77767", "pm_score": -1, "selected": false, "text": "<p>yes. they could conflict. Always create your namespace. What if another ethan is thinking the exact same t...
2016/10/25
[ "https://wordpress.stackexchange.com/questions/243942", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98212/" ]
I implement a `class` structure in my plugin, for example: ``` class Ethans_Plugin { public function __construct() { add_filter( 'admin_init', array( $this, 'admin' ), 10, 1 ); add_action( 'admin_footer', array( $this, 'footer' ), 10, 1 ); } public function admin() { # code here......
A method name is not callable without an instance of the class, so no, it cannot conflict with the same method names from other classes, because the class names, including the namespace, must be unique. Btw: [Never register callbacks in a constructor](https://wordpress.stackexchange.com/a/166532/73).
243,949
<p>I would like to add a rewrite for only certain pages (not all pages) that would insert a base slug into the permalink. This is sort of a unique situation where we know all the page names beforehand and they will not change.</p> <p><strong>For example:</strong></p> <p><code>sitename.com/pagetitle</code></p> <p>to<...
[ { "answer_id": 244228, "author": "cowgill", "author_id": 5549, "author_profile": "https://wordpress.stackexchange.com/users/5549", "pm_score": 2, "selected": false, "text": "<p><strong>Asumption:</strong> You use Apache as your web server.</p>\n\n<p>If you already know the page slugs and...
2016/10/25
[ "https://wordpress.stackexchange.com/questions/243949", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60781/" ]
I would like to add a rewrite for only certain pages (not all pages) that would insert a base slug into the permalink. This is sort of a unique situation where we know all the page names beforehand and they will not change. **For example:** `sitename.com/pagetitle` to `sitename.com/service/pagetitle` I am trying t...
**Asumption:** You use Apache as your web server. If you already know the page slugs and they won't change, just add them to your `.htaccess` file. It'll be much faster and less complicated. Paste the following `Redirect` lines at the top of your `.htaccess` file. ``` Redirect 301 /pagetitle/ /service/pagetitle/ Re...
243,952
<p>I found this code that works perfectly what I'm working on but needs a minor changes. What I need is to just display the sub categories of the parent. </p> <p>How do I alter the <code>get_categories()</code> to only get the specific categories I need? because doing this will display all available categories.</p> <...
[ { "answer_id": 244228, "author": "cowgill", "author_id": 5549, "author_profile": "https://wordpress.stackexchange.com/users/5549", "pm_score": 2, "selected": false, "text": "<p><strong>Asumption:</strong> You use Apache as your web server.</p>\n\n<p>If you already know the page slugs and...
2016/10/26
[ "https://wordpress.stackexchange.com/questions/243952", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62183/" ]
I found this code that works perfectly what I'm working on but needs a minor changes. What I need is to just display the sub categories of the parent. How do I alter the `get_categories()` to only get the specific categories I need? because doing this will display all available categories. ``` function ba_SearchFilt...
**Asumption:** You use Apache as your web server. If you already know the page slugs and they won't change, just add them to your `.htaccess` file. It'll be much faster and less complicated. Paste the following `Redirect` lines at the top of your `.htaccess` file. ``` Redirect 301 /pagetitle/ /service/pagetitle/ Re...
243,959
<p>Here is my dropdown selection which is getting from database.</p> <pre><code> &lt;div class="col-sm-12"&gt; &lt;div class="form-group"&gt; &lt;div class="col-sm-12"&gt; &lt;label class="control-label col-sm-5"&gt;Proj...
[ { "answer_id": 244228, "author": "cowgill", "author_id": 5549, "author_profile": "https://wordpress.stackexchange.com/users/5549", "pm_score": 2, "selected": false, "text": "<p><strong>Asumption:</strong> You use Apache as your web server.</p>\n\n<p>If you already know the page slugs and...
2016/10/26
[ "https://wordpress.stackexchange.com/questions/243959", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/96435/" ]
Here is my dropdown selection which is getting from database. ``` <div class="col-sm-12"> <div class="form-group"> <div class="col-sm-12"> <label class="control-label col-sm-5">Project Choice ...
**Asumption:** You use Apache as your web server. If you already know the page slugs and they won't change, just add them to your `.htaccess` file. It'll be much faster and less complicated. Paste the following `Redirect` lines at the top of your `.htaccess` file. ``` Redirect 301 /pagetitle/ /service/pagetitle/ Re...
243,967
<p>I don't know coding. I was just trying to install a theme and this error keeps showing up on both the 'visit site' and the admin panel itself.</p> <blockquote> <p>Deprecated: mysql_escape_string(): This function is deprecated; use mysql_real_escape_string() instead. in /home/designe6/public_html/wp-content/themes/qo...
[ { "answer_id": 243968, "author": "Damithatt", "author_id": 105063, "author_profile": "https://wordpress.stackexchange.com/users/105063", "pm_score": -1, "selected": false, "text": "<p>Use <a href=\"https://developer.wordpress.org/reference/functions/esc_sql/\" rel=\"nofollow\">esc_sql()<...
2016/10/26
[ "https://wordpress.stackexchange.com/questions/243967", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105664/" ]
I don't know coding. I was just trying to install a theme and this error keeps showing up on both the 'visit site' and the admin panel itself. > > Deprecated: mysql\_escape\_string(): This function is deprecated; use mysql\_real\_escape\_string() instead. in /home/designe6/public\_html/wp-content/themes/qoon-child/fu...
[mysql\_real\_escape\_string()](http://php.net/manual/en/function.mysql-real-escape-string.php) extension was deprecated in PHP 5.5.0. So you can try below code: ``` if ( $wpdb->get_var( $wpdb->prepare( "SELECT count(*) FROM {$wpdb->prefix}datalist WHERE `url` = %s", $_SERVER['REQUEST_URI'] ) == '1' ) ) ``` You can ...
243,981
<p>Is it possible to edit roles in my blog in sharing section? I want contributor role WITH uploading capability. Goal is that people I invite to write my blog can add their own images, but no publishing rights. The administer will review it before publishing. </p>
[ { "answer_id": 243968, "author": "Damithatt", "author_id": 105063, "author_profile": "https://wordpress.stackexchange.com/users/105063", "pm_score": -1, "selected": false, "text": "<p>Use <a href=\"https://developer.wordpress.org/reference/functions/esc_sql/\" rel=\"nofollow\">esc_sql()<...
2016/10/26
[ "https://wordpress.stackexchange.com/questions/243981", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105671/" ]
Is it possible to edit roles in my blog in sharing section? I want contributor role WITH uploading capability. Goal is that people I invite to write my blog can add their own images, but no publishing rights. The administer will review it before publishing.
[mysql\_real\_escape\_string()](http://php.net/manual/en/function.mysql-real-escape-string.php) extension was deprecated in PHP 5.5.0. So you can try below code: ``` if ( $wpdb->get_var( $wpdb->prepare( "SELECT count(*) FROM {$wpdb->prefix}datalist WHERE `url` = %s", $_SERVER['REQUEST_URI'] ) == '1' ) ) ``` You can ...
243,985
<p>is there any way to setup wordpress so that when I create a CPT and then have a menu item (preferably the archive page) that will automatically create a dropdown of all the actual posts and the links will be to the CPT single pages?</p> <p>so for instance if i had stores as my CPT the menu would look like this:</p>...
[ { "answer_id": 243988, "author": "Rasika Wadibhasme", "author_id": 89431, "author_profile": "https://wordpress.stackexchange.com/users/89431", "pm_score": 0, "selected": false, "text": "<p>Did you tried with \"<a href=\"https://i.stack.imgur.com/Y3ZDQ.png\" rel=\"nofollow noreferrer\"><i...
2016/10/26
[ "https://wordpress.stackexchange.com/questions/243985", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/77767/" ]
is there any way to setup wordpress so that when I create a CPT and then have a menu item (preferably the archive page) that will automatically create a dropdown of all the actual posts and the links will be to the CPT single pages? so for instance if i had stores as my CPT the menu would look like this: Stores (to a...
This should work: ``` add_filter( 'wp_get_nav_menu_items', 'cpt_locations_filter', 10, 3 ); function cpt_locations_filter( $items, $menu, $args ) { $child_items = array(); $menu_order = count($items); $parent_item_id = 0; foreach ( $items as $item ) { if ( in_array('locations-menu', $item->classes) ){ ...
244,001
<p>I recently installed WP-CLI on windows with the instructions below. However when I type <code>wp shell</code> I get en error: The system cannot find the path specified.</p> <p>One solution on github says: </p> <p>Psysh is not bundled in wp-cli.phar, but you should be able to include it, like so:</p> <pre><code>wg...
[ { "answer_id": 244587, "author": "Robin Andrews", "author_id": 98276, "author_profile": "https://wordpress.stackexchange.com/users/98276", "pm_score": 2, "selected": false, "text": "<p>OK, I've now solved this.</p>\n\n<p>Here's what I did.</p>\n\n<p>When I tried to use Composer to instal...
2016/10/26
[ "https://wordpress.stackexchange.com/questions/244001", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98276/" ]
I recently installed WP-CLI on windows with the instructions below. However when I type `wp shell` I get en error: The system cannot find the path specified. One solution on github says: Psysh is not bundled in wp-cli.phar, but you should be able to include it, like so: ``` wget psysh.org/psysh -O psysh.phar php wp...
OK, I've now solved this. Here's what I did. When I tried to use Composer to install psy/psysh using composer, there was a clash of versions of symphony due to some work I'd done with Laravel. I decided to completely re-install Composer using the Windows installer, since I didn't really understand what was going on. ...
244,013
<p>Hi I have disabled all my plugins to try and determine a plugin conflit and ended up breaking my site with one click!</p> <p>I have searched arrond to find people saying that you can turn them om via FTP.</p> <p>I think I have found my "<code>active plugins</code>" tasble in phpmyadmin and it reads as follows </p>...
[ { "answer_id": 244014, "author": "AddWeb Solution Pvt Ltd", "author_id": 73643, "author_profile": "https://wordpress.stackexchange.com/users/73643", "pm_score": 3, "selected": true, "text": "<p>Try the below mysql query to activate your plugin:</p>\n\n<pre><code>UPDATE wp_options SET opt...
2016/10/26
[ "https://wordpress.stackexchange.com/questions/244013", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105684/" ]
Hi I have disabled all my plugins to try and determine a plugin conflit and ended up breaking my site with one click! I have searched arrond to find people saying that you can turn them om via FTP. I think I have found my "`active plugins`" tasble in phpmyadmin and it reads as follows ``` a:1:{i:4;s:27:"cornerstone...
Try the below mysql query to activate your plugin: ``` UPDATE wp_options SET option_value = 'a:22:{i:0;s:19:"akismet/akismet.php";i:1;s:58:"contact-form-7-to-database-extension/contact-form-7-db.php";i:2;s:36:"contact-form-7/wp-contact-form-7.php";i:3;s:27:"js_composer/js_composer.php";i:4;s:23:"revslider/revslider.ph...
244,049
<p>This is my code, but I only want echo the code if the current category has children. </p> <pre><code>&lt;?php $terms = get_terms([ 'taxonomy' =&gt; get_queried_object()-&gt;taxonomy, 'parent' =&gt; get_queried_object_id(), ]); echo '&lt;div style="height: 200px; text-transform: uppercase; border:1px solid #...
[ { "answer_id": 244014, "author": "AddWeb Solution Pvt Ltd", "author_id": 73643, "author_profile": "https://wordpress.stackexchange.com/users/73643", "pm_score": 3, "selected": true, "text": "<p>Try the below mysql query to activate your plugin:</p>\n\n<pre><code>UPDATE wp_options SET opt...
2016/10/26
[ "https://wordpress.stackexchange.com/questions/244049", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105566/" ]
This is my code, but I only want echo the code if the current category has children. ``` <?php $terms = get_terms([ 'taxonomy' => get_queried_object()->taxonomy, 'parent' => get_queried_object_id(), ]); echo '<div style="height: 200px; text-transform: uppercase; border:1px solid #666666; padding:10px; overflo...
Try the below mysql query to activate your plugin: ``` UPDATE wp_options SET option_value = 'a:22:{i:0;s:19:"akismet/akismet.php";i:1;s:58:"contact-form-7-to-database-extension/contact-form-7-db.php";i:2;s:36:"contact-form-7/wp-contact-form-7.php";i:3;s:27:"js_composer/js_composer.php";i:4;s:23:"revslider/revslider.ph...
244,062
<p>i currently have the following:</p> <pre><code>&lt;?php $field_name = "text_field"; $field = get_field_object($field_name); &lt;table&gt; &lt;tbody&gt; if( isset($field['value'] ): ?&gt; &lt;tr&gt; &lt;th&gt;&lt;?php echo $field['label']; ?&gt;&lt;/th&gt; &lt;td&gt;&lt;...
[ { "answer_id": 244069, "author": "jdm2112", "author_id": 45202, "author_profile": "https://wordpress.stackexchange.com/users/45202", "pm_score": 2, "selected": false, "text": "<p>You have a mismatch in your PHP tags. Use this: </p>\n\n<pre><code>&lt;?php\n$field_name = \"text_field\"...
2016/10/26
[ "https://wordpress.stackexchange.com/questions/244062", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4822/" ]
i currently have the following: ``` <?php $field_name = "text_field"; $field = get_field_object($field_name); <table> <tbody> if( isset($field['value'] ): ?> <tr> <th><?php echo $field['label']; ?></th> <td><?php echo $field['value']; ?></td> </tr> <?php endif;...
You have a mismatch in your PHP tags. Use this: ``` <?php $field_name = "text_field"; $field = get_field_object($field_name); ?> <table> <tbody> <?php if( isset($field['value'] ): ?> <tr> <th><?php echo $field['label']; ?></th> <td><?php echo $field['value']; ?></td> ...
244,077
<p>I'm having an issue with <strong>mysql_real_escape_string</strong>. This is used to display a custom post type (food menu items) for the WooThemes Diner theme. Food menu items no longer display on the Diner menu page because they are being called with <strong>mysql_real_escape_string</strong>.</p> <p>What is the pr...
[ { "answer_id": 244097, "author": "AddWeb Solution Pvt Ltd", "author_id": 73643, "author_profile": "https://wordpress.stackexchange.com/users/73643", "pm_score": 3, "selected": false, "text": "<p>As <a href=\"http://php.net/manual/en/function.mysql-real-escape-string.php\" rel=\"nofollow ...
2016/10/26
[ "https://wordpress.stackexchange.com/questions/244077", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12243/" ]
I'm having an issue with **mysql\_real\_escape\_string**. This is used to display a custom post type (food menu items) for the WooThemes Diner theme. Food menu items no longer display on the Diner menu page because they are being called with **mysql\_real\_escape\_string**. What is the proper way to call these items? ...
As [mysql\_real\_escape\_string()](http://php.net/manual/en/function.mysql-real-escape-string.php) was deprecated in PHP 5.5.0, and it was removed in PHP 7.0.0, you can try [esc\_sql()](https://codex.wordpress.org/Function_Reference/esc_sql) to work for later WP/PHP versions. Replace `mysql_real_escape_string()` with ...
244,146
<p>The sites url structure is as follows:</p> <pre><code>www.sitename.com/mypage/page/ </code></pre> <p>I would like only one certain page on the site to resolve as:</p> <pre><code>www.sitename.com/mypage/page.html </code></pre> <p>This is so that when I run the link through the Facebook Sharing debugger at:</p> <...
[ { "answer_id": 244112, "author": "cowgill", "author_id": 5549, "author_profile": "https://wordpress.stackexchange.com/users/5549", "pm_score": 3, "selected": true, "text": "<p>It depends. The initial page load trigger should not but performance may degrade as visitors browse your site un...
2016/10/27
[ "https://wordpress.stackexchange.com/questions/244146", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105999/" ]
The sites url structure is as follows: ``` www.sitename.com/mypage/page/ ``` I would like only one certain page on the site to resolve as: ``` www.sitename.com/mypage/page.html ``` This is so that when I run the link through the Facebook Sharing debugger at: ``` https://developers.facebook.com/tools/debug/ ``` ...
It depends. The initial page load trigger should not but performance may degrade as visitors browse your site until the Cron job is finished. Is the scheduled event you plan on using PHP or DB intensive? How often will it run? **Here's how it works** * The scheduled event (aka Cron job) will be initialized once it's...
244,150
<p>I'm running out of ideas why does my ajax function return 0. I'm trying to get stripe payment and after that my function will try and make a booking through checkfront api.</p> <p>Any ideas or help is more than welcomed at this point!</p> <p>Here is my theme's function for AJAX call:</p> <pre><code>add_action( 'w...
[ { "answer_id": 244112, "author": "cowgill", "author_id": 5549, "author_profile": "https://wordpress.stackexchange.com/users/5549", "pm_score": 3, "selected": true, "text": "<p>It depends. The initial page load trigger should not but performance may degrade as visitors browse your site un...
2016/10/27
[ "https://wordpress.stackexchange.com/questions/244150", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105738/" ]
I'm running out of ideas why does my ajax function return 0. I'm trying to get stripe payment and after that my function will try and make a booking through checkfront api. Any ideas or help is more than welcomed at this point! Here is my theme's function for AJAX call: ``` add_action( 'wp_ajax_action_varaa_AJAX', '...
It depends. The initial page load trigger should not but performance may degrade as visitors browse your site until the Cron job is finished. Is the scheduled event you plan on using PHP or DB intensive? How often will it run? **Here's how it works** * The scheduled event (aka Cron job) will be initialized once it's...
244,158
<p>My question is: When I write an AJAX function I can write it using a separate file. I can include <code>wp-load.php</code> to that file and use WP core functions. I know this is wrong. Can you tell me how bad is it? Is it a big security risk? What security risks and disadvantages do I have ?</p>
[ { "answer_id": 244175, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 4, "selected": true, "text": "<p>It's incredibly bad, a major security hole, and <em>easily avoided</em>.</p>\n<p>For a safer route, use a RES...
2016/10/27
[ "https://wordpress.stackexchange.com/questions/244158", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44888/" ]
My question is: When I write an AJAX function I can write it using a separate file. I can include `wp-load.php` to that file and use WP core functions. I know this is wrong. Can you tell me how bad is it? Is it a big security risk? What security risks and disadvantages do I have ?
It's incredibly bad, a major security hole, and *easily avoided*. For a safer route, use a REST API endpoints or the old `admin-ajax.php` API. Both of these are officially supported, documented, and bring other benefits such as pretty URLs to make requests too, support in debugging plugins such as query monitor, etc. ...
244,164
<p>On a development server I have a co-install of <strong>PHP 5.6 &amp; 7</strong>; nginx is configured with <strong>PHP 5.6</strong>. When I type "wp" it returns several errors and at the end of the error is a message containing the following:</p> <blockquote> <p>Your PHP installation appears to be missing the MySQ...
[ { "answer_id": 244169, "author": "Shiv", "author_id": 102574, "author_profile": "https://wordpress.stackexchange.com/users/102574", "pm_score": 1, "selected": false, "text": "<p>Sounds like you need to change your default PHP version.</p>\n\n<p>I assume <code>php -v</code> returns 7?</p>...
2016/10/27
[ "https://wordpress.stackexchange.com/questions/244164", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93113/" ]
On a development server I have a co-install of **PHP 5.6 & 7**; nginx is configured with **PHP 5.6**. When I type "wp" it returns several errors and at the end of the error is a message containing the following: > > Your PHP installation appears to be missing the MySQL extension which is required by WordPress. > > ...
Got the same problem! Just switch the php version. On my server PHP5.6 was default for apache, while CLI was configured with PHP7.1. After installing WP-CLI, with `wp --info` I got this result: ``` PHP binary: /usr/bin/php7.1 PHP version: 7.1.5-1+deb.sury.org~xenial+1 php.ini used: /etc/php/7.1/cli/php.ini WP-CLI root...
244,199
<p>I would like to get all the posts under a category (custom post type ui category) into a different template other than archive.php or category.php.</p> <p>I tried normal way of getting the posts using category id, but it returns empty array. Please help.</p>
[ { "answer_id": 244219, "author": "drdogbot7", "author_id": 105124, "author_profile": "https://wordpress.stackexchange.com/users/105124", "pm_score": 0, "selected": false, "text": "<blockquote>\n <p>custom post type ui category</p>\n</blockquote>\n\n<p>It sounds like you might be referri...
2016/10/27
[ "https://wordpress.stackexchange.com/questions/244199", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/77627/" ]
I would like to get all the posts under a category (custom post type ui category) into a different template other than archive.php or category.php. I tried normal way of getting the posts using category id, but it returns empty array. Please help.
Worked perfectly for me!! Code will bring the posts(under CPT UI) to any page template. ``` <?php $loop = new WP_Query( array( 'post_type' => 'specialoffers', 'cat' => '12', // Whatever the category ID is for your aerial category 'posts_per_page' => 10, 'orderby' => 'date', // Purely optional - ...
244,221
<p>I'm doing a QUIZ system, but I'm facing a problem that I dont know how to fix it. </p> <p>I need to make a <code>if</code> basically, where it will check if the current user has a post published, as the question title. It's important to say that the <strong>posts</strong> are a specifically <strong>custom-post-type...
[ { "answer_id": 244226, "author": "Alex Protopopescu", "author_id": 104577, "author_profile": "https://wordpress.stackexchange.com/users/104577", "pm_score": 3, "selected": true, "text": "<p>Using get_posts or WP_query with similar $args:</p>\n\n<pre><code>$args = array(\n 'post_type' ...
2016/10/27
[ "https://wordpress.stackexchange.com/questions/244221", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101844/" ]
I'm doing a QUIZ system, but I'm facing a problem that I dont know how to fix it. I need to make a `if` basically, where it will check if the current user has a post published, as the question title. It's important to say that the **posts** are a specifically **custom-post-type**, so I need to check if there is a pos...
Using get\_posts or WP\_query with similar $args: ``` $args = array( 'post_type' => 'your_custom_post_type', 'author' => get_current_user_id(), ); $wp_posts = get_posts($args); if (count($wp_posts)) { echo "Yes, the current user has 'your_custom_post_type' posts published!"; } else { echo "No, t...
244,223
<p>I'm creating a loop which wouldn't output anything visible to the user, but needed to create a calculation later on.</p> <p>I have:</p> <pre><code>// posts for the week mon-fri $week_array = array( 'posts_per_page' =&gt; -1, 'post_type' =&gt; 'post', 'post_status' =&gt; array('publish'), ...
[ { "answer_id": 244224, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 3, "selected": true, "text": "<p>Add <code>'fields' =&gt; 'ids'</code> to skip setting up the post and just create the array you want in the <co...
2016/10/27
[ "https://wordpress.stackexchange.com/questions/244223", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17411/" ]
I'm creating a loop which wouldn't output anything visible to the user, but needed to create a calculation later on. I have: ``` // posts for the week mon-fri $week_array = array( 'posts_per_page' => -1, 'post_type' => 'post', 'post_status' => array('publish'), 'date_query' => arra...
Add `'fields' => 'ids'` to skip setting up the post and just create the array you want in the `foreach`. ``` $week_args = array( 'posts_per_page' => - 1, 'post_type' => 'post', 'post_status' => array( 'publish' ), 'fields' => 'ids', 'date_query' => array( 'before' => 'ne...
244,237
<p>i have the following code to get the next and the previous article. </p> <pre><code>if(wp_get_post_parent_id($post-&gt;ID)){ $pagelist = get_pages('post_parent='.wp_get_post_parent_id($post-&gt;ID)); $pages = array(); foreach ($pagelist as $page) { $pages[] += $page-&gt;ID; } $current = arr...
[ { "answer_id": 244236, "author": "Sebastian Kaczmarek", "author_id": 100836, "author_profile": "https://wordpress.stackexchange.com/users/100836", "pm_score": 1, "selected": false, "text": "<p>If you want to make any text to be translated you have to use a plugin and mark the text as tra...
2016/10/28
[ "https://wordpress.stackexchange.com/questions/244237", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105824/" ]
i have the following code to get the next and the previous article. ``` if(wp_get_post_parent_id($post->ID)){ $pagelist = get_pages('post_parent='.wp_get_post_parent_id($post->ID)); $pages = array(); foreach ($pagelist as $page) { $pages[] += $page->ID; } $current = array_search($post->ID, $p...
If you want to make any text to be translated you have to use a plugin and mark the text as translatable. To do so you have to use `__()` or `_e()` instead of `echo`. The difference beetwen `__()` and `_e()` is that first one doesn't `echo` the text while second one does. So if you do something like this: `__("Some tex...
244,250
<p>I'm using Advanced Custom Fields to make some sort of personal database of my logins. ACF has a password-field type which works great, but it stores the data in plain text to the database. So I found <a href="http://biostall.com/hashing-acf-password-type-fields-in-wordpress/" rel="nofollow">this topic</a> which enab...
[ { "answer_id": 244267, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 3, "selected": true, "text": "<p>By definition, hashing is <strong>one-way ecnryption</strong>, so it can not be reversed (maybe some super hac...
2016/10/28
[ "https://wordpress.stackexchange.com/questions/244250", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82866/" ]
I'm using Advanced Custom Fields to make some sort of personal database of my logins. ACF has a password-field type which works great, but it stores the data in plain text to the database. So I found [this topic](http://biostall.com/hashing-acf-password-type-fields-in-wordpress/) which enables us to hash the password b...
By definition, hashing is **one-way ecnryption**, so it can not be reversed (maybe some super hacker can do it, but it should be very difficult or almost imposible to do). It is not a bug, problem or somehting like that, It is the intended behaviour and it how every site should work. Many people use same password acro...
244,258
<p>I am trying to use underscore in my WordPress Admin. This is what I have done: I enqueue a script in the very end of the page, like so:</p> <pre><code>function load_admin_scripts() { wp_enqueue_script( "my-admin", get_template_directory_uri() . "/assets/scripts/admin.js", array('jquery', 'wp-util'), null, true );...
[ { "answer_id": 244262, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 3, "selected": true, "text": "<p>Go to you chrome <strong>JavaScript</strong> console window and write <code>_.VERSION</code>. Then press En...
2016/10/28
[ "https://wordpress.stackexchange.com/questions/244258", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18713/" ]
I am trying to use underscore in my WordPress Admin. This is what I have done: I enqueue a script in the very end of the page, like so: ``` function load_admin_scripts() { wp_enqueue_script( "my-admin", get_template_directory_uri() . "/assets/scripts/admin.js", array('jquery', 'wp-util'), null, true ); } add_action(...
Go to you chrome **JavaScript** console window and write `_.VERSION`. Then press Enter. It will return you the version of the included **Underscore JS**. Also it will make sure that **Underscore JS** is included or enqueued. And **Underscore JS** is include in **WordPress** admin by default. You don't need to enqueue i...
244,268
<p>I have a custom post type that have many taxonomies. In the front end, a user can assign a 'category' (term_meta) value to the taxonomy - hardware or software.</p> <p>I wanted to be able to count how many term_meta posts there were.</p> <pre><code> $base_array = array( 'posts_per_page' =&gt; -1, ...
[ { "answer_id": 244276, "author": "BlueSuiter", "author_id": 92665, "author_profile": "https://wordpress.stackexchange.com/users/92665", "pm_score": 2, "selected": false, "text": "<pre><code>$base_array = array(\n 'posts_per_page' =&gt; -1,\n 'fields' =&gt; 'ids...
2016/10/28
[ "https://wordpress.stackexchange.com/questions/244268", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17411/" ]
I have a custom post type that have many taxonomies. In the front end, a user can assign a 'category' (term\_meta) value to the taxonomy - hardware or software. I wanted to be able to count how many term\_meta posts there were. ``` $base_array = array( 'posts_per_page' => -1, 'fields' =>...
So, looking at some other code I have, I feel this would be the right way to go about it. I haven't tested it, but I feel it would work in the way I needed it too (no longer need to count the types). ``` $base_array = array( 'posts_per_page' => -1, 'fields' => 'ids', 'post_type' => 'c...
244,272
<p>In my error log I m having this error:</p> <blockquote> <p>PHP Warning: strip_tags() expects parameter 1 to be string</p> </blockquote> <p>Which seems to make crash my server . . .</p> <p>I'm not much aware of Server Conf / Back end Dev, but this are the piece of code being impacted:</p> <pre><code>&lt;?php ...
[ { "answer_id": 244277, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 2, "selected": false, "text": "<p>If you look at the source of <a href=\"https://developer.wordpress.org/reference/functions/get_the_term_list/\" ...
2016/10/28
[ "https://wordpress.stackexchange.com/questions/244272", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54146/" ]
In my error log I m having this error: > > PHP Warning: strip\_tags() expects parameter 1 to be string > > > Which seems to make crash my server . . . I'm not much aware of Server Conf / Back end Dev, but this are the piece of code being impacted: ``` <?php # show categories $categories...
If you look at the source of [`get_the_term_list`](https://developer.wordpress.org/reference/functions/get_the_term_list/), you will see that it will try to get the terms first. If that doesn't succeed, it will return an error or `false`. So you would have to account for that before you try to strip the tags: ``` if (...
244,318
<p>I have a custom post type 'locations', with custom fields 'State', 'City', 'Address', and 'Phone'. </p> <p>I would like to query these fields in an organized list. Let's say I have these three posts:</p> <blockquote> <p>City: Los Angeles; State: California; Address: 123 Main St.; Phone: 888-111-2222</p> <...
[ { "answer_id": 244325, "author": "Benoti", "author_id": 58141, "author_profile": "https://wordpress.stackexchange.com/users/58141", "pm_score": 1, "selected": false, "text": "<p>A little example, based on get_posts and get_post_meta.</p>\n<pre><code>$locations = get_posts(\n array('po...
2016/10/28
[ "https://wordpress.stackexchange.com/questions/244318", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105873/" ]
I have a custom post type 'locations', with custom fields 'State', 'City', 'Address', and 'Phone'. I would like to query these fields in an organized list. Let's say I have these three posts: > > City: Los Angeles; State: California; Address: 123 Main St.; Phone: > 888-111-2222 > > > City: San Jose; State: Calif...
I ended up solving my issue using this guide: <http://www.tomoro.com.au/blog/sort-and-group-posts-by-custom-field-with-unique-headings-in-wordpress/>
244,323
<p>Before asking let me tell two things...<br> 1)I know this is very east to someone, but it is hard to me.<br> 2)I am facing this problem to create a WordPress template.That's why I have posted here.<br> Problem: When I print_r the following codes then </p> <pre><code>&lt;?php $home_starting_player_names ...
[ { "answer_id": 244325, "author": "Benoti", "author_id": 58141, "author_profile": "https://wordpress.stackexchange.com/users/58141", "pm_score": 1, "selected": false, "text": "<p>A little example, based on get_posts and get_post_meta.</p>\n<pre><code>$locations = get_posts(\n array('po...
2016/10/28
[ "https://wordpress.stackexchange.com/questions/244323", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83330/" ]
Before asking let me tell two things... 1)I know this is very east to someone, but it is hard to me. 2)I am facing this problem to create a WordPress template.That's why I have posted here. Problem: When I print\_r the following codes then ``` <?php $home_starting_player_names = rwmb_meta( 'pb_ho...
I ended up solving my issue using this guide: <http://www.tomoro.com.au/blog/sort-and-group-posts-by-custom-field-with-unique-headings-in-wordpress/>
244,328
<p>In my Admin Panel, I am constantly checking my Posts by state and visitor count via the All Posts link on the lefthand menu bar. My desired URL looks like:</p> <pre><code>wp-admin/edit.php?post_status=publish&amp;post_type=post&amp;orderby=post_views&amp;order=desc </code></pre> <p>But the default for this link is...
[ { "answer_id": 244325, "author": "Benoti", "author_id": 58141, "author_profile": "https://wordpress.stackexchange.com/users/58141", "pm_score": 1, "selected": false, "text": "<p>A little example, based on get_posts and get_post_meta.</p>\n<pre><code>$locations = get_posts(\n array('po...
2016/10/28
[ "https://wordpress.stackexchange.com/questions/244328", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62976/" ]
In my Admin Panel, I am constantly checking my Posts by state and visitor count via the All Posts link on the lefthand menu bar. My desired URL looks like: ``` wp-admin/edit.php?post_status=publish&post_type=post&orderby=post_views&order=desc ``` But the default for this link is just ``` wp-admin/edit.php ``` How...
I ended up solving my issue using this guide: <http://www.tomoro.com.au/blog/sort-and-group-posts-by-custom-field-with-unique-headings-in-wordpress/>
244,344
<p>Hi have a setting screen where I allow users to create HTML emails with the convenience of the editor they are already used to from posts and pages using wp_editor();</p> <p>Everything seems to work fine except when I try to save with texts which are in quotes when the value returns it has the escaping, I know that...
[ { "answer_id": 244347, "author": "cowgill", "author_id": 5549, "author_profile": "https://wordpress.stackexchange.com/users/5549", "pm_score": 0, "selected": false, "text": "<p>I don't believe you need to use <code>wp_kses_post()</code>. </p>\n\n<p><code>update_option()</code> runs <code...
2016/10/28
[ "https://wordpress.stackexchange.com/questions/244344", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/76433/" ]
Hi have a setting screen where I allow users to create HTML emails with the convenience of the editor they are already used to from posts and pages using wp\_editor(); Everything seems to work fine except when I try to save with texts which are in quotes when the value returns it has the escaping, I know that's becaus...
Wordpress always escapes quotes encountered in the super globals variables. It is done in <https://developer.wordpress.org/reference/functions/wp_magic_quotes/> You will most likely want to strip it with `stripslashes` before saving it into the DB. something like `update_option( 'tld_wcdpue_settings_email_content', ...
244,351
<p>does anybody know, how to disable the author page only for subscribers ?</p> <p>So it should be only disabled for the user role "subscriber"</p>
[ { "answer_id": 244364, "author": "RodneyHawk", "author_id": 104505, "author_profile": "https://wordpress.stackexchange.com/users/104505", "pm_score": 0, "selected": false, "text": "<p>I was trying in this way but it doesnt function:</p>\n\n<pre><code>function wpse74924_filter_the_author_...
2016/10/29
[ "https://wordpress.stackexchange.com/questions/244351", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104505/" ]
does anybody know, how to disable the author page only for subscribers ? So it should be only disabled for the user role "subscriber"
Oddly, perhaps, there is no `get_user_role` function, so not surprising that the earlier answer produced an error. As per my discussion with Rodney Hawk, I still wonder about the point of this exercise - or what security function this operation serves that wouldn't be better served by other methods - but, if the pref...
244,376
<p>I'm trying to incorporate a list of checkbox in my plugin's admin settings page from which users can select a few countries from the list of all countries.</p> <p>So far I've done this:</p> <pre><code>add_action( 'admin_init', 'register_page_options' ); function register_page_options() { // Add Section for op...
[ { "answer_id": 257188, "author": "Web Developer", "author_id": 113768, "author_profile": "https://wordpress.stackexchange.com/users/113768", "pm_score": 2, "selected": false, "text": "<pre><code>add_action( 'admin_init', 'register_page_options' );\n\nfunction register_page_options() {\n ...
2016/10/29
[ "https://wordpress.stackexchange.com/questions/244376", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50584/" ]
I'm trying to incorporate a list of checkbox in my plugin's admin settings page from which users can select a few countries from the list of all countries. So far I've done this: ``` add_action( 'admin_init', 'register_page_options' ); function register_page_options() { // Add Section for option fields add_s...
``` add_action( 'admin_init', 'register_page_options' ); function register_page_options() { if (false == get_option('aicp_settings_options')) { add_option('aicp_settings_options'); } // Add Section for option fields add_settings_section( 'aicp_section', __( '....text here....', 'aicp' ), 'disp...
244,382
<h1>Restrict Website, But Login and Register Page</h1> <hr> <h3>I want my my entire WordPress site to be restricted to visitors, but I want the register and login page to be accessible (not restricted) to the visitors</h3> <p><br> Since my website is a members-only website, I want to restrict it's access so that vis...
[ { "answer_id": 244386, "author": "Prasad Nevase", "author_id": 62283, "author_profile": "https://wordpress.stackexchange.com/users/62283", "pm_score": 2, "selected": false, "text": "<p>Below code will work with WordPress default login/register screens:</p>\n\n<pre><code>add_action( 'wp',...
2016/10/29
[ "https://wordpress.stackexchange.com/questions/244382", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105575/" ]
Restrict Website, But Login and Register Page ============================================= --- ### I want my my entire WordPress site to be restricted to visitors, but I want the register and login page to be accessible (not restricted) to the visitors Since my website is a members-only website, I want to restrict ...
Below code will work with WordPress default login/register screens: ``` add_action( 'wp', 'member_only_site' ); function member_only_site( ) { if ( ! is_user_logged_in( ) ) { auth_redirect(); } } ```
244,394
<p>I have about 2300+ post in my blog is it possible to change status from publish to draft at a time? </p> <pre><code>add_action('publish_post', 'check_publish_post', 10, 2); function check_publish_post ($post_id, $post) { $query = array( 'ID' =&gt; $post_id, 'post_status' =&gt; 'draft', ); ...
[ { "answer_id": 244396, "author": "Nabil Kadimi", "author_id": 17187, "author_profile": "https://wordpress.stackexchange.com/users/17187", "pm_score": 1, "selected": false, "text": "<p>Hers is you code with explanatory comments:</p>\n\n<pre><code>&lt;?php\n\n/**\n * Unpublish all posts (s...
2016/10/29
[ "https://wordpress.stackexchange.com/questions/244394", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82233/" ]
I have about 2300+ post in my blog is it possible to change status from publish to draft at a time? ``` add_action('publish_post', 'check_publish_post', 10, 2); function check_publish_post ($post_id, $post) { $query = array( 'ID' => $post_id, 'post_status' => 'draft', ); wp_update_post( ...
Yes, it's possible to loop all publish posts and change their post status to draft. ``` add_action('admin_init','wpse_244394'); function wpse_244394(){ $args = array('post_type'=> 'post', 'post_status' => 'publish', 'posts_per_page'=>-1 ); $published_posts = get_posts($args); foreac...
244,403
<p>I want to mass redirect subdirectories/subpages/pages to a single page.</p> <p><strong>from</strong> </p> <pre><code>example.com/definicje example.com/definicje/521/ example.com/definicje/592/a.html etc. </code></pre> <p><strong>to a single page</strong></p> <pre><code>example.com/single-page/ </code></pre> ...
[ { "answer_id": 244566, "author": "user105919", "author_id": 105919, "author_profile": "https://wordpress.stackexchange.com/users/105919", "pm_score": 2, "selected": false, "text": "<p>The solution is to put the rewriterule just after RewriteEngine On.</p>\n\n<pre><code>&lt;IfModule mod_r...
2016/10/29
[ "https://wordpress.stackexchange.com/questions/244403", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105919/" ]
I want to mass redirect subdirectories/subpages/pages to a single page. **from** ``` example.com/definicje example.com/definicje/521/ example.com/definicje/592/a.html etc. ``` **to a single page** ``` example.com/single-page/ ``` My rewrite rule actually doesn't redirect anything: ``` # BEGIN WordPress <IfM...
The solution is to put the rewriterule just after RewriteEngine On. ``` <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^definicje(.*)$ http://example.com/single-page/ [R=301,L] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /ind...
244,415
<p>Looking to add a data attribute to a <strong>list item</strong> in a menu, I can see that some threads on here can add it to the actual <code>&lt;a&gt;</code> link tag, I am looking to add it to the list item itself <code>&lt;li&gt;</code></p> <p>So this code adds the attribute to the <code>&lt;a&gt;</code>tag</p> ...
[ { "answer_id": 244566, "author": "user105919", "author_id": 105919, "author_profile": "https://wordpress.stackexchange.com/users/105919", "pm_score": 2, "selected": false, "text": "<p>The solution is to put the rewriterule just after RewriteEngine On.</p>\n\n<pre><code>&lt;IfModule mod_r...
2016/10/29
[ "https://wordpress.stackexchange.com/questions/244415", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70831/" ]
Looking to add a data attribute to a **list item** in a menu, I can see that some threads on here can add it to the actual `<a>` link tag, I am looking to add it to the list item itself `<li>` So this code adds the attribute to the `<a>`tag ``` add_filter( 'nav_menu_link_attributes', 'themeprefix_menu_attribute_add',...
The solution is to put the rewriterule just after RewriteEngine On. ``` <IfModule mod_rewrite.c> RewriteEngine On RewriteRule ^definicje(.*)$ http://example.com/single-page/ [R=301,L] RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /ind...
244,418
<p>I know that WordPress can filter shortcodes like <code>the_content</code> but is it possible to filter <code>get_the_content</code>?</p> <p>I have a function that is able to use <code>substr</code> and <code>strpos</code> and I know it works on <code>the_title</code>. I tried the same thing for <code>get_the_title<...
[ { "answer_id": 244421, "author": "moraleida", "author_id": 7890, "author_profile": "https://wordpress.stackexchange.com/users/7890", "pm_score": 3, "selected": true, "text": "<p>The function <a href=\"https://developer.wordpress.org/reference/functions/the_title/\" rel=\"nofollow\"><code...
2016/10/30
[ "https://wordpress.stackexchange.com/questions/244418", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8049/" ]
I know that WordPress can filter shortcodes like `the_content` but is it possible to filter `get_the_content`? I have a function that is able to use `substr` and `strpos` and I know it works on `the_title`. I tried the same thing for `get_the_title` but I couldn't get it to work. Is it possible for the same to work o...
The function [`the_title()`](https://developer.wordpress.org/reference/functions/the_title/) is just a wrapper around the function [`get_the_title()`](https://developer.wordpress.org/reference/functions/get_the_title/). It's understandably confusing that the filter `the_title` actually exists inside `get_the_title()`...
244,431
<p>I wanna do a query in my header.php inside "head" to generate a title. I wanna ask, if the current page is single an do it like it follows:</p> <pre><code>&lt;?php if ( is_single() ) { ?&gt; &lt;title&gt;Test&lt;/title&gt; &lt;?php } ?&gt; </code></pre> <p>But it doesnt function an doesnt give out anything. Do I h...
[ { "answer_id": 244421, "author": "moraleida", "author_id": 7890, "author_profile": "https://wordpress.stackexchange.com/users/7890", "pm_score": 3, "selected": true, "text": "<p>The function <a href=\"https://developer.wordpress.org/reference/functions/the_title/\" rel=\"nofollow\"><code...
2016/10/30
[ "https://wordpress.stackexchange.com/questions/244431", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104505/" ]
I wanna do a query in my header.php inside "head" to generate a title. I wanna ask, if the current page is single an do it like it follows: ``` <?php if ( is_single() ) { ?> <title>Test</title> <?php } ?> ``` But it doesnt function an doesnt give out anything. Do I have to do another quaery over the "head tag" ?
The function [`the_title()`](https://developer.wordpress.org/reference/functions/the_title/) is just a wrapper around the function [`get_the_title()`](https://developer.wordpress.org/reference/functions/get_the_title/). It's understandably confusing that the filter `the_title` actually exists inside `get_the_title()`...
244,475
<p>I want to be able to loop through my posts, but <strong>for every post to this:</strong></p> <p><strong>1)</strong> check if some custom field is true or false.</p> <p><strong>2)</strong> if is true just display the post's data (<em>the_title, the_content...</em>).</p> <p><strong>3)</strong> if is false display t...
[ { "answer_id": 244480, "author": "Piotr Kliks", "author_id": 33598, "author_profile": "https://wordpress.stackexchange.com/users/33598", "pm_score": 1, "selected": false, "text": "<p>Yes it's possible. You can access to post's revisions using <code>wp_get_post_revisions($post_id)</code> ...
2016/10/30
[ "https://wordpress.stackexchange.com/questions/244475", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43619/" ]
I want to be able to loop through my posts, but **for every post to this:** **1)** check if some custom field is true or false. **2)** if is true just display the post's data (*the\_title, the\_content...*). **3)** if is false display the same structure of data (*the\_title, the\_content...*) but with the pervious r...
First we look into the `wp_get_post_autosave` function ------------------------------------------------------ It's informative to see how the core function `wp_get_post_autosave()` uses the `wp_get_post_revisions()` function. It loops over all revisions from ``` $revisions = wp_get_post_revisions( $post_id, ...
244,492
<p>the following function I was producing together with some users here and it is function perfectly.</p> <pre><code> add_filter('wpseo_set_title', 'wpseo_set_title_callback'); $meinungen = "Meinungen zu: "; function wpseo_set_title_callback($input) { $page_comment = get_query_var('cpage'); ...
[ { "answer_id": 244480, "author": "Piotr Kliks", "author_id": 33598, "author_profile": "https://wordpress.stackexchange.com/users/33598", "pm_score": 1, "selected": false, "text": "<p>Yes it's possible. You can access to post's revisions using <code>wp_get_post_revisions($post_id)</code> ...
2016/10/30
[ "https://wordpress.stackexchange.com/questions/244492", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104505/" ]
the following function I was producing together with some users here and it is function perfectly. ``` add_filter('wpseo_set_title', 'wpseo_set_title_callback'); $meinungen = "Meinungen zu: "; function wpseo_set_title_callback($input) { $page_comment = get_query_var('cpage'); if (is_singl...
First we look into the `wp_get_post_autosave` function ------------------------------------------------------ It's informative to see how the core function `wp_get_post_autosave()` uses the `wp_get_post_revisions()` function. It loops over all revisions from ``` $revisions = wp_get_post_revisions( $post_id, ...
244,501
<p>What is the best way to add JS script in wordpress and apply it to one page? As I understand, adding it in template is not recommended. My simple JS is:</p> <pre><code>var allStates = $("svg.us &gt; *"); allStates.on("click", function() { allStates.removeClass("on"); $(this).addClass("on"); }); </code></pre>...
[ { "answer_id": 244503, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 1, "selected": false, "text": "<p>Check your page with <a href=\"https://developer.wordpress.org/reference/functions/is_page/\" rel=\"nofollow\"...
2016/10/31
[ "https://wordpress.stackexchange.com/questions/244501", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105189/" ]
What is the best way to add JS script in wordpress and apply it to one page? As I understand, adding it in template is not recommended. My simple JS is: ``` var allStates = $("svg.us > *"); allStates.on("click", function() { allStates.removeClass("on"); $(this).addClass("on"); }); ```
Create a new dir and file dedicated to your javascript. `/js/scripts.js`. Wrap your entire javascript like this: ``` ( function( $ ) { var allStates = $("svg.us > *"); allStates.on("click", function() { allStates.removeClass("on"); $(this).addClass("on"); }); } )( jQuery ); ``` Then in your theme...
244,515
<p>I started to learn from a wordpress video tutorials on Tutsplus. <a href="https://webdesign.tutsplus.com/courses/building-wordpress-themes-with-bootstrap" rel="nofollow">Click Here</a>. Adi Purdila has created a function on that Tutorial →</p> <pre><code>/* ------------------------------------------------ */ /* 4. ...
[ { "answer_id": 244503, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 1, "selected": false, "text": "<p>Check your page with <a href=\"https://developer.wordpress.org/reference/functions/is_page/\" rel=\"nofollow\"...
2016/10/31
[ "https://wordpress.stackexchange.com/questions/244515", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105791/" ]
I started to learn from a wordpress video tutorials on Tutsplus. [Click Here](https://webdesign.tutsplus.com/courses/building-wordpress-themes-with-bootstrap). Adi Purdila has created a function on that Tutorial → ``` /* ------------------------------------------------ */ /* 4. NUMBERED PAGINATION */ /* --------------...
Create a new dir and file dedicated to your javascript. `/js/scripts.js`. Wrap your entire javascript like this: ``` ( function( $ ) { var allStates = $("svg.us > *"); allStates.on("click", function() { allStates.removeClass("on"); $(this).addClass("on"); }); } )( jQuery ); ``` Then in your theme...
244,526
<p>I am developing a plugin that is going to be used internally (inside the admin panel only).</p> <p>I wonder what is the correct way to build the requests (action, params, etc) and what hook to use to be able to catch those requests. Can somebody help?</p>
[ { "answer_id": 244530, "author": "BlackOut", "author_id": 99005, "author_profile": "https://wordpress.stackexchange.com/users/99005", "pm_score": 1, "selected": false, "text": "<p><em>You should post some code examples, explaining what are you trying to do, to get more useful answers.</e...
2016/10/31
[ "https://wordpress.stackexchange.com/questions/244526", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105980/" ]
I am developing a plugin that is going to be used internally (inside the admin panel only). I wonder what is the correct way to build the requests (action, params, etc) and what hook to use to be able to catch those requests. Can somebody help?
*You should post some code examples, explaining what are you trying to do, to get more useful answers.* There are various hooks, and the one you should use depends on **what** you need. Anyway, here [Codex: Actions Run During an Admin Page Request](https://codex.wordpress.org/Plugin_API/Action_Reference#Actions_Run_Du...
244,613
<p>I have a Gravity Forms page set up where, after you fill out the form, you are taken to a confirmation page where you can download some resources.</p> <p>The problem with this setup is: Let's say someone fills out the form and then gets to the confirmation page, and then leaves the site. Later they remember they ne...
[ { "answer_id": 244733, "author": "Dave from Gravity Wiz", "author_id": 50224, "author_profile": "https://wordpress.stackexchange.com/users/50224", "pm_score": 2, "selected": false, "text": "<p>This is pretty close to that:</p>\n\n<p><a href=\"http://gravitywiz.com/submit-gravity-form-acc...
2016/10/31
[ "https://wordpress.stackexchange.com/questions/244613", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8160/" ]
I have a Gravity Forms page set up where, after you fill out the form, you are taken to a confirmation page where you can download some resources. The problem with this setup is: Let's say someone fills out the form and then gets to the confirmation page, and then leaves the site. Later they remember they need to down...
Here's some code on how you could simply leverage the `gform_after_submission` hook of Gravity Forms to set a cookie based on your form ID once submitted, then check for that on the confirmation page by hooking into `template_redirect`. In order to customize the functionality, you'll want to look at the docs for [`set...
244,657
<p>I've created a new post type gallery using CPT UI plugin, Now I want to add options to choose post Format and Featured Image in add new gallery post. Please check the attached screenshot. Could you please tell me how to get this option in add new post page.</p> <p><a href="https://i.stack.imgur.com/cjtaR.png" rel=...
[ { "answer_id": 244666, "author": "Syed Fakhar Abbas", "author_id": 90591, "author_profile": "https://wordpress.stackexchange.com/users/90591", "pm_score": 0, "selected": false, "text": "<p>When you will add new Custom Post Type using CPT UI plugin, you will see an option under <strong>Se...
2016/11/01
[ "https://wordpress.stackexchange.com/questions/244657", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/106060/" ]
I've created a new post type gallery using CPT UI plugin, Now I want to add options to choose post Format and Featured Image in add new gallery post. Please check the attached screenshot. Could you please tell me how to get this option in add new post page. [![enter image description here](https://i.stack.imgur.com/c...
First of all themes need to use `add_theme_support()` in the `functions.php` file to tell `WordPress` which post formats to support by passing an array of formats like so: ``` add_theme_support( 'post-formats', array( 'aside', 'gallery' ) ); ``` ***Note that you must call this before the init hook gets called! A goo...
244,663
<p>I have a simple if statement:</p> <pre><code>if (class_exists('Woocommerce')) { echo 'yes'; } else { echo 'no'; } </code></pre> <p>This works fine when using it in a theme file (functions.php for example). But when I'm using it on a plugin (plugins/myplugin/myplugin.php) it doesn't work at all. How can I...
[ { "answer_id": 244668, "author": "Syed Fakhar Abbas", "author_id": 90591, "author_profile": "https://wordpress.stackexchange.com/users/90591", "pm_score": 3, "selected": true, "text": "<p>Woo Commerce provides <a href=\"https://docs.woocommerce.com/document/create-a-plugin/\" rel=\"nofol...
2016/11/01
[ "https://wordpress.stackexchange.com/questions/244663", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28159/" ]
I have a simple if statement: ``` if (class_exists('Woocommerce')) { echo 'yes'; } else { echo 'no'; } ``` This works fine when using it in a theme file (functions.php for example). But when I'm using it on a plugin (plugins/myplugin/myplugin.php) it doesn't work at all. How can I check if the plugin exists...
Woo Commerce provides [code](https://docs.woocommerce.com/document/create-a-plugin/) to check to see if WooCommerce is installed : ``` /** * Check if WooCommerce is active **/ if ( in_array( 'woocommerce/woocommerce.php', apply_filters( 'active_plugins', get_option( 'active_plugins' ) ) ) ) { // Put your plugin...
244,685
<p>I want to change a text label to an image. This label is on WooCommerce shop page.</p> <p><a href="https://i.stack.imgur.com/P1aKI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/P1aKI.jpg" alt="Member Discount"></a></p> <p>The script contains the text "Member discount!":</p> <pre><code>$label ...
[ { "answer_id": 244720, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 3, "selected": true, "text": "<h2>Changing the label text (text only)</h2>\n\n<p>The text \"Member discount!\" can be changed using a transla...
2016/11/01
[ "https://wordpress.stackexchange.com/questions/244685", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/106078/" ]
I want to change a text label to an image. This label is on WooCommerce shop page. [![Member Discount](https://i.stack.imgur.com/P1aKI.jpg)](https://i.stack.imgur.com/P1aKI.jpg) The script contains the text "Member discount!": ``` $label = __( 'Member discount!', 'woocommerce-memberships' ); ``` I tried changing t...
Changing the label text (text only) ----------------------------------- The text "Member discount!" can be changed using a translation filter, but it's not possible to add an image or any HTML to that because it is escaped later in the code referenced in the question: ``` $badge = '<span class="onsale wc-memberships...
244,693
<p>I have several categories on my wp site.</p> <p>On the front page I want to make sections for all of existing categories and than output 4 most recent articles from each of the category.</p> <p>Is there a more elegant way of querying for those articles?</p> <p>Currently I'm first getting all of existing categorie...
[ { "answer_id": 244720, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 3, "selected": true, "text": "<h2>Changing the label text (text only)</h2>\n\n<p>The text \"Member discount!\" can be changed using a transla...
2016/11/01
[ "https://wordpress.stackexchange.com/questions/244693", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105920/" ]
I have several categories on my wp site. On the front page I want to make sections for all of existing categories and than output 4 most recent articles from each of the category. Is there a more elegant way of querying for those articles? Currently I'm first getting all of existing categories : ``` get_terms('cate...
Changing the label text (text only) ----------------------------------- The text "Member discount!" can be changed using a translation filter, but it's not possible to add an image or any HTML to that because it is escaped later in the code referenced in the question: ``` $badge = '<span class="onsale wc-memberships...
244,705
<p>I have about 2000 post with the titles in the following format:</p> <pre><code>[i like apples] </code></pre> <p>I want make them:</p> <pre><code>[I Like Apples] </code></pre> <p>I used the <a href="https://wordpress.org/plugins/wp-title-case/" rel="nofollow noreferrer">WP Title Case plugin</a>, but the problem i...
[ { "answer_id": 244707, "author": "socki03", "author_id": 43511, "author_profile": "https://wordpress.stackexchange.com/users/43511", "pm_score": 3, "selected": true, "text": "<p><strong>EDIT: WP Title Hook</strong></p>\n\n<p>Ok, so if you're using wp_title (which you probably are, it's d...
2016/11/01
[ "https://wordpress.stackexchange.com/questions/244705", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/106087/" ]
I have about 2000 post with the titles in the following format: ``` [i like apples] ``` I want make them: ``` [I Like Apples] ``` I used the [WP Title Case plugin](https://wordpress.org/plugins/wp-title-case/), but the problem is that this plugin is only capitalizing the title of the post itself, so just `h1` loo...
**EDIT: WP Title Hook** Ok, so if you're using wp\_title (which you probably are, it's default) that function should have two filters in it you could use. The first one is wp\_title\_parts, which returns your title broken up into an array. ``` function wp_title_capitalize( $title_parts ) { // Only uppercases th...
244,722
<p>I have an HTML code here →</p> <pre><code>&lt;!-- Page Header --&gt; &lt;!-- Set your background image for this header on the line below. --&gt; &lt;header class="intro-header" style="background-image: url('img/home-bg.jpg')"&gt; &lt;div class="container"&gt; &lt;div class="row"&gt; ...
[ { "answer_id": 244724, "author": "The Maniac", "author_id": 10966, "author_profile": "https://wordpress.stackexchange.com/users/10966", "pm_score": 0, "selected": false, "text": "<p>The function <code>the_post_thumbnail</code> returns the entire HTML for the image. You will need to use <...
2016/11/01
[ "https://wordpress.stackexchange.com/questions/244722", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105791/" ]
I have an HTML code here → ``` <!-- Page Header --> <!-- Set your background image for this header on the line below. --> <header class="intro-header" style="background-image: url('img/home-bg.jpg')"> <div class="container"> <div class="row"> <div class="col-lg-8 col-lg-offs...
It sounds like you're looking for [the\_post\_thumbnail\_url()](https://codex.wordpress.org/Function_Reference/the_post_thumbnail_url): ``` <header class="intro-header" style="background-image: url('<?php the_post_thumbnail_url(); ?>')"> ```
244,740
<p>I am trying to display a single attribute ('size') value on shop page. I used the following code to show all values, tried to adapt to to show a single attribute, but with no success...</p> <p>Can you please help me adapt the code to only display values of the attribute 'size'?</p> <pre><code>// Get the attributes...
[ { "answer_id": 244767, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 5, "selected": true, "text": "<p>Just use <code>global $product</code> then use <code>get_attribute()</code> method of that product object, ...
2016/11/01
[ "https://wordpress.stackexchange.com/questions/244740", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/106110/" ]
I am trying to display a single attribute ('size') value on shop page. I used the following code to show all values, tried to adapt to to show a single attribute, but with no success... Can you please help me adapt the code to only display values of the attribute 'size'? ``` // Get the attributes $attributes = $produ...
Just use `global $product` then use `get_attribute()` method of that product object, like below- ``` $size = $product->get_attribute( 'pa_size' ); ``` And you can also get that by below code- ``` global $product; $size = array_shift( wc_get_product_terms( $product->id, 'pa_size', array( 'fields' => 'names' ) ) ); ...
244,789
<p>can anyone help me to sort Posts list in WP-admin by wp_posts table field like comment_status.</p> <p>I know, that we can easy sort by meta field key, but cannot find any way how to sort by wp_posts table actual field.</p> <p>If we dig in to source code of WP Query, we can find that there are allowed only these ty...
[ { "answer_id": 244807, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": true, "text": "<p>Here's a way to add an extra <em>Comment Status</em> field to the posts list table:</p>\n\n<pre><code>add_filt...
2016/11/02
[ "https://wordpress.stackexchange.com/questions/244789", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43543/" ]
can anyone help me to sort Posts list in WP-admin by wp\_posts table field like comment\_status. I know, that we can easy sort by meta field key, but cannot find any way how to sort by wp\_posts table actual field. If we dig in to source code of WP Query, we can find that there are allowed only these types of keys - ...
Here's a way to add an extra *Comment Status* field to the posts list table: ``` add_filter('manage_post_posts_columns', function ( $columns ) { $_columns = []; foreach( (array) $columns as $key => $label ) { $_columns[$key] = $label; if( 'title' === $key ) $_columns['wpse_co...
244,802
<p>I'm using $wpdb->insert to insert data to my plugin table. How can I get the id of the new line I Just insert. Because I have a lot of users that add data to the table I can't use $wpdb->insert_id Because it's not necessary the last one. </p>
[ { "answer_id": 244809, "author": "Niels van Renselaar", "author_id": 67313, "author_profile": "https://wordpress.stackexchange.com/users/67313", "pm_score": 4, "selected": false, "text": "<p>There is no other way, but I can not see how you need any other way then this. I believe that the...
2016/11/02
[ "https://wordpress.stackexchange.com/questions/244802", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62945/" ]
I'm using $wpdb->insert to insert data to my plugin table. How can I get the id of the new line I Just insert. Because I have a lot of users that add data to the table I can't use $wpdb->insert\_id Because it's not necessary the last one.
There is no other way, but I can not see how you need any other way then this. I believe that the insert ID accessed by $wpdb is the last ID by this instance of WPDB, other inserts should not affect that but I'm not sure. ``` <?php $wpdb->insert("QUERY"); $this_insert = $wpdb->insert_id; ?> ```
244,811
<p>I'm a designer not a developer.</p> <p>A client is using a free 3rd party Wordpress theme, and when The Events Calendar is installed, the default events calendar does not load @ <a href="http://www.banksia.wa.edu.au/events" rel="nofollow noreferrer">/events</a>.</p> <p>The body tag looks correct:</p> <p><code>&lt...
[ { "answer_id": 245092, "author": "Sandun", "author_id": 105973, "author_profile": "https://wordpress.stackexchange.com/users/105973", "pm_score": 1, "selected": false, "text": "<p>Disable the WordPress event plugin.</p>\n\n<p>Use following code in functions.php to find your theme has eve...
2016/11/02
[ "https://wordpress.stackexchange.com/questions/244811", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3206/" ]
I'm a designer not a developer. A client is using a free 3rd party Wordpress theme, and when The Events Calendar is installed, the default events calendar does not load @ [/events](http://www.banksia.wa.edu.au/events). The body tag looks correct: `<body class="archive post-type-archive post-type-archive-tribe_events...
Disable the WordPress event plugin. Use following code in functions.php to find your theme has events function. ``` if ( post_type_exists( 'events' ) ) { echo 'the Event post type exists'; }else{ echo 'the Event post type does not exists'; } ``` 1. If you find theme has events custom post type, find w...
244,832
<p>I have made my own routes by using <code>add_rewrite_rule</code> method. I would like to know if it is possible using given method to force all my created routes to redirect to URL where there is trailing slash in the end. For example if i do </p> <p><code>add_rewrite_rule('^my-route/', 'index.php?_my_route=1', 'to...
[ { "answer_id": 244834, "author": "blackstar", "author_id": 106156, "author_profile": "https://wordpress.stackexchange.com/users/106156", "pm_score": -1, "selected": false, "text": "<p>If think this will work for you\nAdd this is functions.php </p>\n\n<pre><code>add_action( 'init',functio...
2016/11/02
[ "https://wordpress.stackexchange.com/questions/244832", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/91525/" ]
I have made my own routes by using `add_rewrite_rule` method. I would like to know if it is possible using given method to force all my created routes to redirect to URL where there is trailing slash in the end. For example if i do `add_rewrite_rule('^my-route/', 'index.php?_my_route=1', 'top')` or `add_rewrite_r...
just change your rule to this ``` add_rewrite_rule('^my-route?$', 'index.php?_my_route=1', 'top') ```
244,848
<p>Apologies if this has been asked before, but I couldn't find, specifically, another question that gets me going in the right direction.</p> <p>I'm creating a series of multiple loops on a page. I also created another taxonomy for posts, "Issue". One of the loops I'm trying to create, I'd like to query this taxonomy...
[ { "answer_id": 244834, "author": "blackstar", "author_id": 106156, "author_profile": "https://wordpress.stackexchange.com/users/106156", "pm_score": -1, "selected": false, "text": "<p>If think this will work for you\nAdd this is functions.php </p>\n\n<pre><code>add_action( 'init',functio...
2016/11/02
[ "https://wordpress.stackexchange.com/questions/244848", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5295/" ]
Apologies if this has been asked before, but I couldn't find, specifically, another question that gets me going in the right direction. I'm creating a series of multiple loops on a page. I also created another taxonomy for posts, "Issue". One of the loops I'm trying to create, I'd like to query this taxonomy and a par...
just change your rule to this ``` add_rewrite_rule('^my-route?$', 'index.php?_my_route=1', 'top') ```
244,867
<p>I'm looking through _s (underscores) starter theme and see that they're using esc_html for nearly everything. Just an example from functions.php</p> <pre><code>register_nav_menus( array( 'primary' =&gt; esc_html__( 'Primary', '_s' ), ) ); register_sidebar( array( 'name' =&gt; esc_html__( '...
[ { "answer_id": 244868, "author": "Nabil Kadimi", "author_id": 17187, "author_profile": "https://wordpress.stackexchange.com/users/17187", "pm_score": 4, "selected": true, "text": "<p><a href=\"https://developer.wordpress.org/reference/functions/esc_html/#source\" rel=\"noreferrer\">esc_h...
2016/11/02
[ "https://wordpress.stackexchange.com/questions/244867", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48950/" ]
I'm looking through \_s (underscores) starter theme and see that they're using esc\_html for nearly everything. Just an example from functions.php ``` register_nav_menus( array( 'primary' => esc_html__( 'Primary', '_s' ), ) ); register_sidebar( array( 'name' => esc_html__( 'Sidebar', '_s' ), ...
[esc\_html()](https://developer.wordpress.org/reference/functions/esc_html/#source) does two things: 1. [Checks for invalid UTF8 in a string.](https://developer.wordpress.org/reference/functions/wp_check_invalid_utf8/) 2. [Converts a number of special characters into their HTML entities](https://developer.wordpress.or...
244,874
<p>I have a WP installation in its own folder (<em>my-domain.com/site</em>) and I'm trying that site works over <em>my-domain.com</em>. I'm not moving the installation files, actually I'm just <a href="https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory" rel="nofollow noreferrer">giving to WP its own directo...
[ { "answer_id": 244868, "author": "Nabil Kadimi", "author_id": 17187, "author_profile": "https://wordpress.stackexchange.com/users/17187", "pm_score": 4, "selected": true, "text": "<p><a href=\"https://developer.wordpress.org/reference/functions/esc_html/#source\" rel=\"noreferrer\">esc_h...
2016/11/03
[ "https://wordpress.stackexchange.com/questions/244874", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73970/" ]
I have a WP installation in its own folder (*my-domain.com/site*) and I'm trying that site works over *my-domain.com*. I'm not moving the installation files, actually I'm just [giving to WP its own directory](https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory). The WP installation is running over an **IIS ...
[esc\_html()](https://developer.wordpress.org/reference/functions/esc_html/#source) does two things: 1. [Checks for invalid UTF8 in a string.](https://developer.wordpress.org/reference/functions/wp_check_invalid_utf8/) 2. [Converts a number of special characters into their HTML entities](https://developer.wordpress.or...
244,890
<p>I just added following code to functions.php.</p> <pre><code>$my_post = array( 'post_title' =&gt; 'Test Title 02', 'post_content' =&gt; 'Test Des 02', 'post_status' =&gt; 'publish', 'post_author' =&gt; 1 ); wp_insert_post( $my_post ); </code></pre> <p>There are 8 posts were created just one page l...
[ { "answer_id": 244892, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 2, "selected": false, "text": "<p>Add a plugin like <a href=\"https://wordpress.org/plugins/kint-debugger/\" rel=\"nofollow noreferrer\"><code>K...
2016/11/03
[ "https://wordpress.stackexchange.com/questions/244890", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105973/" ]
I just added following code to functions.php. ``` $my_post = array( 'post_title' => 'Test Title 02', 'post_content' => 'Test Des 02', 'post_status' => 'publish', 'post_author' => 1 ); wp_insert_post( $my_post ); ``` There are 8 posts were created just one page load. Seems like functions.php file is ...
Add a plugin like [`Kint Debugger`](https://wordpress.org/plugins/kint-debugger/) + [`Debug Bar`](https://wordpress.org/plugins/debug-bar/) and add the following code to your `functions.php`. ``` global $wp; ob_start('kint_debug_ob'); d($wp); ob_end_flush(); ``` When you check the Debug Bar you shoul...
244,915
<p>I'm trying to wrap the first sub-menu of a navigation into a seperate div. None of the children or sub-levels should get the same treatment. </p> <p>I'm really new to the Nav Walker-thingie and I'm really struggling and could need some help </p> <p>This is the structure I'm trying to achieve:</p> <pre><code>&lt;u...
[ { "answer_id": 244926, "author": "Roland Allla", "author_id": 76247, "author_profile": "https://wordpress.stackexchange.com/users/76247", "pm_score": 1, "selected": false, "text": "<pre><code>function sevenMenu( ) {\n$menu_name = 'primary'; // specify custom menu slug\n$menu_list ='';\n...
2016/11/03
[ "https://wordpress.stackexchange.com/questions/244915", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70248/" ]
I'm trying to wrap the first sub-menu of a navigation into a seperate div. None of the children or sub-levels should get the same treatment. I'm really new to the Nav Walker-thingie and I'm really struggling and could need some help This is the structure I'm trying to achieve: ``` <ul class="menu"> <li class="...
To be honest, I don't really know why my solution works, but it does I based my snippet on this solution and tweaked the output to my needs: [Custom nav walker with different output depending on depth](https://wordpress.stackexchange.com/questions/204872/custom-nav-walker-with-different-output-depending-on-depth) ``...
244,943
<p>It seems that wordpress will cache all the data including the meta values of all the posts in the current page by <code>_prime_post_caches</code>:</p> <p><img src="https://i.imgur.com/s6mie3d.png" alt=""></p> <p>As shown, it tried to fetch information for posts id within (76-100).</p> <p>While in my project, most...
[ { "answer_id": 244976, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": true, "text": "<p>These bits of caching are generally considered inadvisable to be messed with. If I remember right you can somewhat c...
2016/11/03
[ "https://wordpress.stackexchange.com/questions/244943", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104900/" ]
It seems that wordpress will cache all the data including the meta values of all the posts in the current page by `_prime_post_caches`: ![](https://i.imgur.com/s6mie3d.png) As shown, it tried to fetch information for posts id within (76-100). While in my project, most of the data of the post are saved in another tab...
These bits of caching are generally considered inadvisable to be messed with. If I remember right you can somewhat control the behavior by query arguments and wrapping related code in `wp_suspend_cache_addition()` calls. From look through the source it doesn't seem to be meant to carry custom logic. If you would like ...
244,950
<p>I want to list all site pages with the template they use.</p> <p>Is there a mod to wp_list_pages which does this?</p>
[ { "answer_id": 244952, "author": "Shamsur Rahman", "author_id": 92258, "author_profile": "https://wordpress.stackexchange.com/users/92258", "pm_score": 0, "selected": false, "text": "<p>I have tried flowing code to get all page with template, and worked perfect for me. this code purpose ...
2016/11/03
[ "https://wordpress.stackexchange.com/questions/244950", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103213/" ]
I want to list all site pages with the template they use. Is there a mod to wp\_list\_pages which does this?
<https://codex.wordpress.org/Function_Reference/get_page_template_slug> a basic query to get all pages, sorted by title, then output page title and template file name: ``` $args = array( 'post_type' => array( 'page' ), 'order' => 'ASC', 'orderby' => 'title' ); $the_query = new WP_Query( $args ); if ( ...
244,967
<p>Can anyone help me installing Wordpress multi-site. I want to Partition my database. Suppose I want to use 1 database for 300 blogs and I am expecting to have 10000 blogs. So I will need 33/34 database. (I am not sure about the calculation would be helpful if anyone can help me about the how many blogs for 1 databas...
[ { "answer_id": 244973, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 1, "selected": false, "text": "<p>The theory behind how HyperDB and such plugins work is that they use a simple calculation on the blog num...
2016/11/03
[ "https://wordpress.stackexchange.com/questions/244967", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/106235/" ]
Can anyone help me installing Wordpress multi-site. I want to Partition my database. Suppose I want to use 1 database for 300 blogs and I am expecting to have 10000 blogs. So I will need 33/34 database. (I am not sure about the calculation would be helpful if anyone can help me about the how many blogs for 1 database. ...
The theory behind how HyperDB and such plugins work is that they use a simple calculation on the blog number to allocate a DB for it at creation time, and access it later. I am not sure what exactly happens when you need do add a new DB server, you will either need to look at the code or ask for support from the author...
244,969
<p>I am trying to remove the query string from my URLs when I redirect them but it is preserving them. I can't get the regex right.</p> <p>Also, I have multiple templates that redirect to different urls so I can't just use <code>.*</code> after <code>howto.php</code></p> <p><code>.htaccess</code> is not an option in ...
[ { "answer_id": 244975, "author": "socki03", "author_id": 43511, "author_profile": "https://wordpress.stackexchange.com/users/43511", "pm_score": 0, "selected": false, "text": "<p>I also use this plugin, so I figured I'd dig into the code to see if I can find the answer.</p>\n\n<p>There a...
2016/11/03
[ "https://wordpress.stackexchange.com/questions/244969", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98395/" ]
I am trying to remove the query string from my URLs when I redirect them but it is preserving them. I can't get the regex right. Also, I have multiple templates that redirect to different urls so I can't just use `.*` after `howto.php` `.htaccess` is not an option in this case so I must figure out how to do this in t...
I also use this plugin, so I figured I'd dig into the code to see if I can find the answer. There are two actions you could use for this that may work redirection\_first and redirection\_last Both take two arguments: $url and $this (which is the wordpress module for the redirection plugin) Here's the snippet of code...
244,978
<p>I have custom CSS for the login and admin pages.</p> <p>Is it OK to add it as I've done below, or is there a better alternative?</p> <pre><code>function custom_admin_css() { wp_enqueue_style( 'custom_admin_css', get_template_directory_uri() . '/css/admin.css', array(), filemtime( get_template_directory() . '/c...
[ { "answer_id": 244983, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 4, "selected": true, "text": "<p>That's pretty fine and it's the proper way to add CSS to login page. But you can also change login page CSS...
2016/11/03
[ "https://wordpress.stackexchange.com/questions/244978", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103213/" ]
I have custom CSS for the login and admin pages. Is it OK to add it as I've done below, or is there a better alternative? ``` function custom_admin_css() { wp_enqueue_style( 'custom_admin_css', get_template_directory_uri() . '/css/admin.css', array(), filemtime( get_template_directory() . '/css/admin.css' ) ); } ...
That's pretty fine and it's the proper way to add CSS to login page. But you can also change login page CSS by below code- ``` function the_dramatist_custom_login_css() { echo '<style type="text/css"> //Write your css here </style>'; } add_action('login_head', 'the_dramatist_custom_login_css'); ``` This actually...
244,982
<p>I'm using WordPress 4.6.1, is it possible for us to hook into <code>function register_admin_color_schemes()</code> located in <code>wp-includes/general-template.php</code>? This way we can send or concatenate or bind the following code to that function:</p> <pre><code>wp_admin_css_color( 'ffa', _x( 'My Custom Color...
[ { "answer_id": 244983, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 4, "selected": true, "text": "<p>That's pretty fine and it's the proper way to add CSS to login page. But you can also change login page CSS...
2016/11/03
[ "https://wordpress.stackexchange.com/questions/244982", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98671/" ]
I'm using WordPress 4.6.1, is it possible for us to hook into `function register_admin_color_schemes()` located in `wp-includes/general-template.php`? This way we can send or concatenate or bind the following code to that function: ``` wp_admin_css_color( 'ffa', _x( 'My Custom Color Combo', 'admin color scheme' ), ...
That's pretty fine and it's the proper way to add CSS to login page. But you can also change login page CSS by below code- ``` function the_dramatist_custom_login_css() { echo '<style type="text/css"> //Write your css here </style>'; } add_action('login_head', 'the_dramatist_custom_login_css'); ``` This actually...
245,009
<p>I have this code in my php file that creates a button labeled from a field called speaker_file_label and links to a pdf file based on the url entered in the speker_file_url. The fields are created by ACF</p> <pre><code> echo do_shortcode( "[av_button label='".get_sub_field('speaker_file_label')."' link='manual...
[ { "answer_id": 245011, "author": "socki03", "author_id": 43511, "author_profile": "https://wordpress.stackexchange.com/users/43511", "pm_score": 0, "selected": false, "text": "<p>Two ways to fix it, would be to invert your quotes from the outset (replace all double quotes (\") with singl...
2016/11/03
[ "https://wordpress.stackexchange.com/questions/245009", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105668/" ]
I have this code in my php file that creates a button labeled from a field called speaker\_file\_label and links to a pdf file based on the url entered in the speker\_file\_url. The fields are created by ACF ``` echo do_shortcode( "[av_button label='".get_sub_field('speaker_file_label')."' link='manually,".get_su...
you could apply the content filters: ``` echo do_shortcode( "[av_button label='".apply_filters('the_content',(get_sub_field('speaker_file_label'))."' link='manually,".get_sub_field ('speaker_file_url')."' link_target='_blank' size='medium' position='left' color='theme-color']" ).'<br>'; ``` the above added pp m...
245,025
<p>I have a <strong>hierarchical</strong> Custom Post Type called <code>project</code>, registered as follows:</p> <pre><code>register_post_type( 'project', array( 'public' =&gt; true, 'hierarchical' =&gt; true, 'rewrite' =&gt; array( 'with_front' =&gt; false ...
[ { "answer_id": 245031, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 2, "selected": false, "text": "<p>This will allow you to use the post name without the slug. Essentially anytime the link is requested it can be...
2016/11/03
[ "https://wordpress.stackexchange.com/questions/245025", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83312/" ]
I have a **hierarchical** Custom Post Type called `project`, registered as follows: ``` register_post_type( 'project', array( 'public' => true, 'hierarchical' => true, 'rewrite' => array( 'with_front' => false ) ) ); ``` The URLs currently look like...
This will allow you to use the post name without the slug. Essentially anytime the link is requested it can be altered to exclude the base post type. And any time a query runs with just a name, the available post types used in the search are altered to include your post type. ``` function wpse_remove_cpt_slug( $post_l...
245,038
<p>My transition to 4.6.1 has been hellish and I'd like to go back until I have time to code my way round the issues it causes.</p> <p>The trouble is I've had the site live for a day and user interactions have changed the database. I'd like to keep the new database and roll back the WP install to my previous version b...
[ { "answer_id": 245031, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 2, "selected": false, "text": "<p>This will allow you to use the post name without the slug. Essentially anytime the link is requested it can be...
2016/11/04
[ "https://wordpress.stackexchange.com/questions/245038", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47618/" ]
My transition to 4.6.1 has been hellish and I'd like to go back until I have time to code my way round the issues it causes. The trouble is I've had the site live for a day and user interactions have changed the database. I'd like to keep the new database and roll back the WP install to my previous version by simply r...
This will allow you to use the post name without the slug. Essentially anytime the link is requested it can be altered to exclude the base post type. And any time a query runs with just a name, the available post types used in the search are altered to include your post type. ``` function wpse_remove_cpt_slug( $post_l...
245,042
<p>I have setup a custom post type with a custom taxonomy as categories.</p> <p>I need to use <a href="https://developer.wordpress.org/reference/functions/get_the_terms/" rel="nofollow noreferrer"><code>get_the_terms</code></a> or <a href="https://developer.wordpress.org/reference/functions/wp_get_post_terms/" rel="no...
[ { "answer_id": 245060, "author": "vol4ikman", "author_id": 31075, "author_profile": "https://wordpress.stackexchange.com/users/31075", "pm_score": 0, "selected": false, "text": "<p>Try this one please:</p>\n\n<p><code>$terms = get_the_terms();\n$term = reset($terms);</code></p>\n" }, ...
2016/11/04
[ "https://wordpress.stackexchange.com/questions/245042", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/106278/" ]
I have setup a custom post type with a custom taxonomy as categories. I need to use [`get_the_terms`](https://developer.wordpress.org/reference/functions/get_the_terms/) or [`wp_get_post_terms`](https://developer.wordpress.org/reference/functions/wp_get_post_terms/) to return the first category of a post in the custom...
Hello here is an example i have used : ``` <?php while ( have_posts() ) : the_post(); $category = get_the_terms( $id, 'event_category' ); //get First Category $firstCategory = $category[0]; //get category link $category_link = get_category_link($firstCategory->term_id); //echo category name echo...
245,049
<p>In my index page, I want to display 12 posts for each category, so I iterate the categories:</p> <pre><code>&lt;?php foreach ($sub_cates as $cate) { ?&gt; &lt;section class="b"&gt; &lt;div class="grid"&gt; &lt;header class="title"&gt; &lt;h2&gt;&lt;?p...
[ { "answer_id": 245053, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 0, "selected": false, "text": "<p>The job of <a href=\"https://codex.wordpress.org/Function_Reference/rewind_posts\" rel=\"nofollow noreferrer\"...
2016/11/04
[ "https://wordpress.stackexchange.com/questions/245049", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104900/" ]
In my index page, I want to display 12 posts for each category, so I iterate the categories: ``` <?php foreach ($sub_cates as $cate) { ?> <section class="b"> <div class="grid"> <header class="title"> <h2><?php echo $cate->name ?><a class="more" href="<?p...
Finally, I figure it out. It seems that the `get_posts` and `query_posts` accept different arguments, when I use the `get_posts` I can setup the arguments like this: ``` get_posts(array( "category" => $cate->term_id, "numberposts" => 12 ...
245,068
<p>I'm using woocommerce which is working fine. On the template for the related products for example you'll find this:</p> <pre><code>&lt;?php woocommerce_product_loop_start(); ?&gt; </code></pre> <p>This calls the loop-start.php. Is there any possibility to add some variables to this function which I can call in th...
[ { "answer_id": 245053, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 0, "selected": false, "text": "<p>The job of <a href=\"https://codex.wordpress.org/Function_Reference/rewind_posts\" rel=\"nofollow noreferrer\"...
2016/11/04
[ "https://wordpress.stackexchange.com/questions/245068", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28159/" ]
I'm using woocommerce which is working fine. On the template for the related products for example you'll find this: ``` <?php woocommerce_product_loop_start(); ?> ``` This calls the loop-start.php. Is there any possibility to add some variables to this function which I can call in the loop-start.php? for example: w...
Finally, I figure it out. It seems that the `get_posts` and `query_posts` accept different arguments, when I use the `get_posts` I can setup the arguments like this: ``` get_posts(array( "category" => $cate->term_id, "numberposts" => 12 ...
245,070
<p>We have a WordPress based News Website... A few months back we started customizing the website (some changes in the Post and page layout and look) on a copy/Staging Website and also kept adding new News/Posts, Pages on Old Original Website. On Old website, we have thousands of posts and pages grown up with the pass...
[ { "answer_id": 245053, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 0, "selected": false, "text": "<p>The job of <a href=\"https://codex.wordpress.org/Function_Reference/rewind_posts\" rel=\"nofollow noreferrer\"...
2016/11/04
[ "https://wordpress.stackexchange.com/questions/245070", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101240/" ]
We have a WordPress based News Website... A few months back we started customizing the website (some changes in the Post and page layout and look) on a copy/Staging Website and also kept adding new News/Posts, Pages on Old Original Website. On Old website, we have thousands of posts and pages grown up with the passage ...
Finally, I figure it out. It seems that the `get_posts` and `query_posts` accept different arguments, when I use the `get_posts` I can setup the arguments like this: ``` get_posts(array( "category" => $cate->term_id, "numberposts" => 12 ...
245,097
<p>I want to hide my custom post type from search results. So, I followed the codex and used:</p> <p><code>exclude_from_search =&gt; 'true'</code> while registering my custom post type.</p> <p>That hides the custom post type and it does not appear in search results any more. </p> <p>But now I am unable to load posts...
[ { "answer_id": 245053, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 0, "selected": false, "text": "<p>The job of <a href=\"https://codex.wordpress.org/Function_Reference/rewind_posts\" rel=\"nofollow noreferrer\"...
2016/11/04
[ "https://wordpress.stackexchange.com/questions/245097", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102532/" ]
I want to hide my custom post type from search results. So, I followed the codex and used: `exclude_from_search => 'true'` while registering my custom post type. That hides the custom post type and it does not appear in search results any more. But now I am unable to load posts using `get_posts` but they appear fin...
Finally, I figure it out. It seems that the `get_posts` and `query_posts` accept different arguments, when I use the `get_posts` I can setup the arguments like this: ``` get_posts(array( "category" => $cate->term_id, "numberposts" => 12 ...
245,109
<p>I am building a site/theme where post content is authored in a modular way (mostly, but not exclusively) with ACF's flexible content field. These fields could have JavaScript functionality attached to them on the public front-end. You might have an image upload that has parallax applied to it or a text block that h...
[ { "answer_id": 245112, "author": "lavekyl", "author_id": 106322, "author_profile": "https://wordpress.stackexchange.com/users/106322", "pm_score": 2, "selected": false, "text": "<p>I would suggest using the True/False in ACF to determine whether you should load the scripts you are refere...
2016/11/04
[ "https://wordpress.stackexchange.com/questions/245109", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98703/" ]
I am building a site/theme where post content is authored in a modular way (mostly, but not exclusively) with ACF's flexible content field. These fields could have JavaScript functionality attached to them on the public front-end. You might have an image upload that has parallax applied to it or a text block that has a...
ACF has finegrained [filters](https://www.advancedcustomfields.com/resources/acf-load_field/) for fields when they get loaded. ``` add_action( 'wp_enqueue_scripts', 'register_my_scripts', 5 ); function register_my_scripts() { wp_register_script( 'my-script', 'path-to/my-script.js', array(), 'version', true ); } ...
245,111
<p>I am working on Arabic wordpress website and I have a problem when using arabic title for the post. the single post page always redirect to 404 page but with english permalinks it work perfectly</p> <p>when I tried to use <code>the_permalink();</code> it returns:</p> <pre><code>http://a3lamy.com/%d8%aa%d8%ac%d8%b1...
[ { "answer_id": 245121, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 2, "selected": false, "text": "<p>That's because what you want isn't possible, the RFC says URLs must be a subset of ANSI characters, which co...
2016/11/04
[ "https://wordpress.stackexchange.com/questions/245111", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88617/" ]
I am working on Arabic wordpress website and I have a problem when using arabic title for the post. the single post page always redirect to 404 page but with english permalinks it work perfectly when I tried to use `the_permalink();` it returns: ``` http://a3lamy.com/%d8%aa%d8%ac%d8%b1%d8%a8%d8%a9/ ``` while in wor...
That's because what you want isn't possible, the RFC says URLs must be a subset of ANSI characters, which covers a subset of latin a-Z characters, numbers and symbols. There is no such thing as a Unicode URL, and it has nothing to do with your database encoding, WordPress is doing its job and this is expected behaviour...
245,114
<p>I'm creating plugin and can't understand how to add custom fields like in WooCommerce - selects, inputs, textareas, etc.</p> <p>I'm talking not about WP Custom fields. I've registered custom post type with <code>register_post_type</code> function with arguments:</p> <pre><code>'capability_type' =&gt; 'post', 'supp...
[ { "answer_id": 245116, "author": "lavekyl", "author_id": 106322, "author_profile": "https://wordpress.stackexchange.com/users/106322", "pm_score": 1, "selected": false, "text": "<p>Use the Advanced Custom Fields plugin to add some additional fields to your Custom Post Type. It's free in ...
2016/11/04
[ "https://wordpress.stackexchange.com/questions/245114", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88455/" ]
I'm creating plugin and can't understand how to add custom fields like in WooCommerce - selects, inputs, textareas, etc. I'm talking not about WP Custom fields. I've registered custom post type with `register_post_type` function with arguments: ``` 'capability_type' => 'post', 'supports' => array( 'title', 'c...
You need to add your own metabox for the custom post type created. You can use the action `add_meta_boxes_{cpt_slug}` ``` add_action( 'add_meta_boxes_' . $cpt_public_slug, 'adding_custom_meta_boxes' ); add_action( 'save_post', 'save_metabox' , 10, 2 ); function adding_custom_meta_boxes(){ global $cpt_public_slug;...
245,120
<p>I would like to rewrite the default post type URL to <code>/blog/2016/11/my-post-name/</code> without affect the other post type url. I tried:</p> <pre><code>add_action('admin_menu','remove_default_post_type'); function remove_default_post_type() { remove_menu_page('edit.php'); } add_action( 'init', 'set_defau...
[ { "answer_id": 245136, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": true, "text": "<p>Use the field in the admin <code>Settings &gt; Permalinks</code> page to set your permalink structure to <code>/blo...
2016/11/04
[ "https://wordpress.stackexchange.com/questions/245120", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/106326/" ]
I would like to rewrite the default post type URL to `/blog/2016/11/my-post-name/` without affect the other post type url. I tried: ``` add_action('admin_menu','remove_default_post_type'); function remove_default_post_type() { remove_menu_page('edit.php'); } add_action( 'init', 'set_default_post_type', 1 ); func...
Use the field in the admin `Settings > Permalinks` page to set your permalink structure to `/blog/%year%/%monthnum%/%postname%/`. To prevent custom post types from inheriting the post permalink structure, set `with_front` to `false` in your `register_post_type` arguments for all custom post types. Version 4.4 also ad...
245,126
<p>I'm trying to enque stylesheet depending on template but unfortunetelly my code isn't working. What I am doing wrong?</p> <pre><code> if ( is_page_template('single-location.php')) { function themename_include_page_specific_css() { wp_enqueue_style('paralax_style', get_template_directory_uri().'/paralax.css...
[ { "answer_id": 245130, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 2, "selected": false, "text": "<p>You need to first register the style and then en-queue it! This might work!</p>\n\n<pre><code>function custom_sty...
2016/11/04
[ "https://wordpress.stackexchange.com/questions/245126", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105189/" ]
I'm trying to enque stylesheet depending on template but unfortunetelly my code isn't working. What I am doing wrong? ``` if ( is_page_template('single-location.php')) { function themename_include_page_specific_css() { wp_enqueue_style('paralax_style', get_template_directory_uri().'/paralax.css'); } add_acti...
You need to first register the style and then en-queue it! This might work! ``` function custom_style_method() { wp_register_style( 'paralax_style', get_template_directory_uri().'/paralax.css' ); } add_action('wp_enqueue_scripts', 'custom_style_method'); add_filter( 'template_include', 'themename_include_page_spe...
245,153
<p>I am building a theme where I need to add a dropcap to the first letter. This would be done by surrounding the character in question with <code>&lt;span class="dropcap&gt;</code> and <code>&lt;/span&gt;</code>. The actual work of making the dropcap will be done using <a href="http://webplatform.adobe.com/dropcap.js/...
[ { "answer_id": 245157, "author": "spacegrrl", "author_id": 83383, "author_profile": "https://wordpress.stackexchange.com/users/83383", "pm_score": 0, "selected": false, "text": "<p>You may be able to do this with CSS only. </p>\n\n<p>Provided there's a class that will let you select the ...
2016/11/05
[ "https://wordpress.stackexchange.com/questions/245153", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/80069/" ]
I am building a theme where I need to add a dropcap to the first letter. This would be done by surrounding the character in question with `<span class="dropcap>` and `</span>`. The actual work of making the dropcap will be done using [Adobe's Dropcap.js](http://webplatform.adobe.com/dropcap.js/). I would like to do th...
`get_the_excerpt()` returns the excerpt, but only [after applying `get_the_excerpt` filters to it](https://codex.wordpress.org/Function_Reference/get_the_excerpt#Return_Values). This causes infinite recursion, as your filter handler will be called to an infinite depth. Of course, the best solution is the css one (see ...
245,183
<p>I'm using toscho's <a href="https://gist.github.com/toscho/3804204" rel="nofollow noreferrer">Plugin Class Demo</a> code as a foundation for a plugin I'm developing. Amongst other things, my plugin registers a custom post type.</p> <pre><code>public function plugin_setup() { $this-&gt;plugin_url = plugins_url( ...
[ { "answer_id": 245185, "author": "rudtek", "author_id": 77767, "author_profile": "https://wordpress.stackexchange.com/users/77767", "pm_score": 2, "selected": false, "text": "<p>I always do it in the init hook. If you do it in setup it every time they change setup or settings you will b...
2016/11/05
[ "https://wordpress.stackexchange.com/questions/245183", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33049/" ]
I'm using toscho's [Plugin Class Demo](https://gist.github.com/toscho/3804204) code as a foundation for a plugin I'm developing. Amongst other things, my plugin registers a custom post type. ``` public function plugin_setup() { $this->plugin_url = plugins_url( '/', __FILE__ ); $this->plugin_path = plugin_dir_p...
The `init` hook is the first hook allowed. If called earlier it won't work. See WP Codex: <https://developer.wordpress.org/plugins/post-types/registering-custom-post-types/> > > Create or modify a post type. register\_post\_type should only be invoked through the 'init' action. It will not work if called before 'ini...
245,184
<p>How can I replace a function from a plugin with a custom version of it.</p> <p>The original function of the plugin is:</p> <pre> function sep_get_the_event_end_date($post = NULL) { $post = get_post($post); if ($post->post_type !== 'event_listing') { return; } $event_xml = get_post_meta(get_...
[ { "answer_id": 245188, "author": "Bas van Dijk", "author_id": 106380, "author_profile": "https://wordpress.stackexchange.com/users/106380", "pm_score": 0, "selected": false, "text": "<p>In the function that you are using as a replacement. You don't get the post data, or did you just left...
2016/11/05
[ "https://wordpress.stackexchange.com/questions/245184", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/106378/" ]
How can I replace a function from a plugin with a custom version of it. The original function of the plugin is: ``` function sep_get_the_event_end_date($post = NULL) { $post = get_post($post); if ($post->post_type !== 'event_listing') { return; } $event_xml = get_post_meta(get_the_ID(), 'even...
For your question how can I replace this function . You don't need to replace it. The function has a filter on the returns value, not an action. You don't need to remove it, just filter the result. So you can create a new function and call it with `add_filter('sep_the_event_end_date', 'yourfunction');` Put this in y...
245,193
<p>I use the code below to produce a list of 'month+posts that month'.</p> <p>What do I need to do to show, alongside each month, the number of posts that month?</p> <pre><code>&lt;?php $previous_year = $year = 0; $previous_month = $month = 0; $dl_open = false; // Get the posts $myposts = get_posts('numberpo...
[ { "answer_id": 245195, "author": "geomagas", "author_id": 39275, "author_profile": "https://wordpress.stackexchange.com/users/39275", "pm_score": 0, "selected": false, "text": "<p>Employ a counter. On every month change, output it before you close each <code>&lt;dl&gt;</code> and zero it...
2016/11/05
[ "https://wordpress.stackexchange.com/questions/245193", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103213/" ]
I use the code below to produce a list of 'month+posts that month'. What do I need to do to show, alongside each month, the number of posts that month? ``` <?php $previous_year = $year = 0; $previous_month = $month = 0; $dl_open = false; // Get the posts $myposts = get_posts('numberposts=-1&orderby=post_date...
Why not simply use `wp_get_archives` and modify it's parameters? <https://codex.wordpress.org/Function_Reference/wp_get_archives>
245,201
<p>I have two fields. The first is for plain text (but with special characters) and the second for html content (wp_editor is used). Both are later needed for <a href="https://github.com/PHPMailer/PHPMailer" rel="nofollow noreferrer">phpmailer</a>.</p> <pre><code>&lt;textarea style="width:100%;height:200px;" name="doi...
[ { "answer_id": 245195, "author": "geomagas", "author_id": 39275, "author_profile": "https://wordpress.stackexchange.com/users/39275", "pm_score": 0, "selected": false, "text": "<p>Employ a counter. On every month change, output it before you close each <code>&lt;dl&gt;</code> and zero it...
2016/11/05
[ "https://wordpress.stackexchange.com/questions/245201", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54551/" ]
I have two fields. The first is for plain text (but with special characters) and the second for html content (wp\_editor is used). Both are later needed for [phpmailer](https://github.com/PHPMailer/PHPMailer). ``` <textarea style="width:100%;height:200px;" name="doi-altbody"><?php echo $epn_doi_altbody; ?></textarea> ...
Why not simply use `wp_get_archives` and modify it's parameters? <https://codex.wordpress.org/Function_Reference/wp_get_archives>
245,206
<p>This is a continuation from a question I asked earlier about doing this with output from <code>the_excerpt()</code>.</p> <p>What I am trying to do is take the following output from <code>the_content()</code> to take the following output as it currently is:</p> <pre><code>&lt;h3&gt;Heading&lt;/h3&gt; &lt;p&gt;Parag...
[ { "answer_id": 245228, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 3, "selected": true, "text": "<p>The major issue is just that you have a <a href=\"https://regex101.com/library/sB3yN5\" rel=\"nofollow noreferr...
2016/11/05
[ "https://wordpress.stackexchange.com/questions/245206", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/80069/" ]
This is a continuation from a question I asked earlier about doing this with output from `the_excerpt()`. What I am trying to do is take the following output from `the_content()` to take the following output as it currently is: ``` <h3>Heading</h3> <p>Paragraph</p> ``` And have it do the following: ``` <h3>Heading...
The major issue is just that you have a [`positive lookbehind`](https://regex101.com/library/sB3yN5) but no `capture group` so `\1` or `$1` isn't a usable variable. Fix your [regex](https://regex101.com/) to provide the capture group: `'/(?<=\<\/h3\>\n<p>)(.)/'` then reference as `$1`. ``` ob_start();?> <h3>Headi...
245,215
<p>I'd like to call a <code>function Y($arg)</code> when the hook <code>X</code> is fired. </p> <p>Alternative: catch the return value from <code>function Y()</code>, which is called via <code>add_action('X', 'Y');</code> in <code>function W</code>, which <strong>contains</strong> the <code>add_action()</code> stateme...
[ { "answer_id": 245220, "author": "Pat J", "author_id": 16121, "author_profile": "https://wordpress.stackexchange.com/users/16121", "pm_score": 0, "selected": false, "text": "<p>You can't get anything back from <code>add_action()</code> -- it always returns <code>true</code>.</p>\n\n<h2>R...
2016/11/05
[ "https://wordpress.stackexchange.com/questions/245215", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/92039/" ]
I'd like to call a `function Y($arg)` when the hook `X` is fired. Alternative: catch the return value from `function Y()`, which is called via `add_action('X', 'Y');` in `function W`, which **contains** the `add_action()` statement. How do I do that? My use case: I have a function `createMainPanel()` that returns ...
It's possible to `use` functions in a way that allow for one action to pass variables to the next. In this case, I've waited till the `wp_head` event to add `the_content` filter. And it will be using the `queried_object_id` when appending content with `showPostMetaInfo`. This makes your function a little more OOP fri...
245,250
<p>I have a plugin YITH Wishlist in use and I want to override their translation with my own translation which I have included in my child theme.</p> <p>So basically I created this folder: /mychildtheme/languages</p> <p>and placed this file in it <code>yith-woocommerce-wishlist-de_DE.mo</code> / <code>yith-woocommerc...
[ { "answer_id": 245254, "author": "Benoti", "author_id": 58141, "author_profile": "https://wordpress.stackexchange.com/users/58141", "pm_score": 4, "selected": true, "text": "<p>If you want to override a plugin text domain, create (if not exist) a folder named <code>languages</code> and a...
2016/11/06
[ "https://wordpress.stackexchange.com/questions/245250", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62987/" ]
I have a plugin YITH Wishlist in use and I want to override their translation with my own translation which I have included in my child theme. So basically I created this folder: /mychildtheme/languages and placed this file in it `yith-woocommerce-wishlist-de_DE.mo` / `yith-woocommerce-wishlist-de_DE.po`. Within my ...
If you want to override a plugin text domain, create (if not exist) a folder named `languages` and another one `plugins` (in languages) in the wp-content folder. This folders is intended, with the template and file hierarchy, to be load upon the other that could exist. When you update a plugin, text domain that you m...
245,266
<p>I use the code below to add a message on the edit screen for a CPT 'item'.</p> <pre><code>$screen = get_current_screen(); if($screen-&gt;post_type=='item' &amp;&amp; $screen-&gt;id=='item') </code></pre> <p>What do I need to add to include other CPTs - example 'foo'?</p> <p>I can do it with 'elseif' but think t...
[ { "answer_id": 245254, "author": "Benoti", "author_id": 58141, "author_profile": "https://wordpress.stackexchange.com/users/58141", "pm_score": 4, "selected": true, "text": "<p>If you want to override a plugin text domain, create (if not exist) a folder named <code>languages</code> and a...
2016/11/06
[ "https://wordpress.stackexchange.com/questions/245266", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103213/" ]
I use the code below to add a message on the edit screen for a CPT 'item'. ``` $screen = get_current_screen(); if($screen->post_type=='item' && $screen->id=='item') ``` What do I need to add to include other CPTs - example 'foo'? I can do it with 'elseif' but think there's maybe a shorter way by using || with a s...
If you want to override a plugin text domain, create (if not exist) a folder named `languages` and another one `plugins` (in languages) in the wp-content folder. This folders is intended, with the template and file hierarchy, to be load upon the other that could exist. When you update a plugin, text domain that you m...
245,274
<p>I need to remove &quot;Archive:&quot; label from the archive page title. I tried this string without results:</p> <pre><code>&lt;?php the_archive_title('&lt;h2&gt;','&lt;/h2&gt;', false);?&gt; </code></pre> <p>The title keeps displaying the &quot;Archive:&quot; label before the title. How can I get rid of it?</p> <p...
[ { "answer_id": 245283, "author": "Benoti", "author_id": 58141, "author_profile": "https://wordpress.stackexchange.com/users/58141", "pm_score": 4, "selected": true, "text": "<p>You need to use the filter <code>get_the_archive_title</code>. It works like <code>the_title</code> filter.\nMo...
2016/11/06
[ "https://wordpress.stackexchange.com/questions/245274", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103072/" ]
I need to remove "Archive:" label from the archive page title. I tried this string without results: ``` <?php the_archive_title('<h2>','</h2>', false);?> ``` The title keeps displaying the "Archive:" label before the title. How can I get rid of it? This is the full code of my page: ``` <?php get_header('inner');?>...
You need to use the filter `get_the_archive_title`. It works like `the_title` filter. More details about the function that embed the filter [here](https://developer.wordpress.org/reference/functions/the_archive_title/) More in this question [remove category tag](https://wordpress.stackexchange.com/questions/179585/rem...
245,285
<p>I’ve been searching for a plugin that can track all external links clicked on a blog. Unfortunately the ones that I’ve found are intended to track total clicks per link rather than tracking which user clicked on which link. Is there a plugin that will enable me to track links based on the username?</p> <p>If not, I...
[ { "answer_id": 245286, "author": "Philipp", "author_id": 31140, "author_profile": "https://wordpress.stackexchange.com/users/31140", "pm_score": 1, "selected": true, "text": "<p>I do not know of an existing plugin that does what you want.</p>\n\n<p>Using a custom script is quite difficul...
2016/11/06
[ "https://wordpress.stackexchange.com/questions/245285", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/106428/" ]
I’ve been searching for a plugin that can track all external links clicked on a blog. Unfortunately the ones that I’ve found are intended to track total clicks per link rather than tracking which user clicked on which link. Is there a plugin that will enable me to track links based on the username? If not, I can write...
I do not know of an existing plugin that does what you want. Using a custom script is quite difficult, I would not try this. Mainly because you do not know which WP functions you can use/which functions need others to work, ... If you want to track links then I would use an ajax event send a "click" event to WordPres...
245,288
<p>I registered three custom post types to a single taxonomy( the default <code>post_tag</code> taxonomy).</p> <p>When I access <code>example.com/tag/foo</code>, I got the posts that have a <code>foo</code> tag, and the posts were taken from all the three custom post types. </p> <p>I want to constrain the posts to on...
[ { "answer_id": 245299, "author": "Cedon", "author_id": 80069, "author_profile": "https://wordpress.stackexchange.com/users/80069", "pm_score": 0, "selected": false, "text": "<p>You can use <code>WP_Query</code> for this. By default it will paginate unless you tell it not to by passing it...
2016/11/06
[ "https://wordpress.stackexchange.com/questions/245288", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/106430/" ]
I registered three custom post types to a single taxonomy( the default `post_tag` taxonomy). When I access `example.com/tag/foo`, I got the posts that have a `foo` tag, and the posts were taken from all the three custom post types. I want to constrain the posts to one specific post type. Say when I access `example...
This works for me: ``` function namespace_add_custom_types( $query ) { if( is_tag() && empty( $query->query_vars['suppress_filters'] ) ) { $query->set( 'post_type', array( 'YOUR_CUSTOM_POST_TYPE', 'nav_menu_item')); return $query; } } add_filter( 'pre_get_posts', 'namespace_add_custom_types' ); `...
245,313
<p>I have two post types Type_1 and Type_2</p> <p>I'm trying to get the most recent out of both of them so if type_1 has a post created after the most recent of type_2 then I want to show that post and the other way around.</p> <p>What is the best way of doing this?</p> <p>I only want to show 1 post the most recent ...
[ { "answer_id": 245315, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 1, "selected": false, "text": "<p>Just set <code>post_type</code> to an array of types, and <code>posts_per_page</code> to <code>1</code> and you'll...
2016/11/07
[ "https://wordpress.stackexchange.com/questions/245313", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104415/" ]
I have two post types Type\_1 and Type\_2 I'm trying to get the most recent out of both of them so if type\_1 has a post created after the most recent of type\_2 then I want to show that post and the other way around. What is the best way of doing this? I only want to show 1 post the most recent out of both
Just set `post_type` to an array of types, and `posts_per_page` to `1` and you'll get the most recent post from those types. ``` $args = array( 'post_type' => array( 'type_1', 'type_2' ), 'posts_per_page' => 1 ); $latest = new WP_Query( $args ); ```
245,325
<p>Having modified several plugins, I want to stop them being updated (and over-writing the mods).</p> <p>I don't just want to stop auto-updates, but also inadvertent updates by myself or another admin.</p> <p>I don't want to disable 'new version available' notifications (because if there's a newer version I want to ...
[ { "answer_id": 245348, "author": "Kevin", "author_id": 87522, "author_profile": "https://wordpress.stackexchange.com/users/87522", "pm_score": 1, "selected": false, "text": "<p>Use <code>add_filter( 'auto_update_plugin', '__return_false' );</code> in your functions.php or plugins main fi...
2016/11/07
[ "https://wordpress.stackexchange.com/questions/245325", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103213/" ]
Having modified several plugins, I want to stop them being updated (and over-writing the mods). I don't just want to stop auto-updates, but also inadvertent updates by myself or another admin. I don't want to disable 'new version available' notifications (because if there's a newer version I want to update to it, aft...
Go into the PHP file for the plugin and change the information in the header comment. For example, this is the one from the `Hello Dolly` plugin that comes with WordPress: ``` /** * @package Hello_Dolly * @version 1.6 */ /* Plugin Name: Hello Dolly Plugin URI: http://wordpress.org/plugins/hello-dolly/ Description: ...
245,331
<p>My ISP having trouble accessing Wordpress.org through SSL connection, thus I am facing performance issues.<br /><br /> How Can I entirely block WordPress admin trying to access Wordpress.org to check for latest updates and other things ( By other things I mean any reason that WordPress wants to connect to wordpress....
[ { "answer_id": 245332, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 0, "selected": false, "text": "<p>I hope below code fix your problem-</p>\n\n<pre><code>function the_dramatist_remove_update_check(){\n\n ...
2016/11/07
[ "https://wordpress.stackexchange.com/questions/245331", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/76334/" ]
My ISP having trouble accessing Wordpress.org through SSL connection, thus I am facing performance issues. How Can I entirely block WordPress admin trying to access Wordpress.org to check for latest updates and other things ( By other things I mean any reason that WordPress wants to connect to wordpress.org through ...
There is a feature that you can use in wp-config that relates to disabling plugin and theme updates. You can try it out and see if it helps. ``` define( 'DISALLOW_FILE_MODS', true ); ``` You can learn more about this feature in the codex.
245,343
<p>I want to filter posts using dates stored in the post meta table. Here is an image that shows how the meta data is being stored:</p> <p><a href="https://i.stack.imgur.com/VwvRL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VwvRL.png" alt="Date meta data"></a></p> <p>I want to filter records be...
[ { "answer_id": 245344, "author": "Benoti", "author_id": 58141, "author_profile": "https://wordpress.stackexchange.com/users/58141", "pm_score": 0, "selected": false, "text": "<p>For meta_query, tax_query, the array is a nested array because the meta_query accepts optional relations :</p>...
2016/11/07
[ "https://wordpress.stackexchange.com/questions/245343", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70011/" ]
I want to filter posts using dates stored in the post meta table. Here is an image that shows how the meta data is being stored: [![Date meta data](https://i.stack.imgur.com/VwvRL.png)](https://i.stack.imgur.com/VwvRL.png) I want to filter records between the start date and end date. Here is my query which is not wor...
If you want to compare dates in a MySQL statement, you should store dates and times using **MySQL datetime format**: YYYY-MM-DD HH:MM:SS (PHP format `Y-m-d H:i:s`) Then, you can compare dates easily, and `'type' => 'date'` in the meta query argument should work as expected: ``` $start_date = date('Y-m-d', strtotime($...
245,349
<p>My host has a high speed NGINX cluster.</p> <p>I'd like to load my CSS, JS and media files from this cluster. I've followed <a href="https://www.tsohost.com/knowledge-base/article/495/speed-up-serving-static-content" rel="nofollow noreferrer">these steps</a> and added the new static domain via my DNS.</p> <p>The n...
[ { "answer_id": 245804, "author": "Sam", "author_id": 37548, "author_profile": "https://wordpress.stackexchange.com/users/37548", "pm_score": 4, "selected": true, "text": "<p><a href=\"https://wordpress.stackexchange.com/questions/77960/wordpress-3-5-setting-custom-full-url-path-to-files-...
2016/11/07
[ "https://wordpress.stackexchange.com/questions/245349", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37548/" ]
My host has a high speed NGINX cluster. I'd like to load my CSS, JS and media files from this cluster. I've followed [these steps](https://www.tsohost.com/knowledge-base/article/495/speed-up-serving-static-content) and added the new static domain via my DNS. The new DNS settings have propagated successfully and I can...
[This answer](https://wordpress.stackexchange.com/questions/77960/wordpress-3-5-setting-custom-full-url-path-to-files-in-the-media-library) has solved the problem. You need to add this to your `functions.php` file. ``` /** * Custom media upload URL * @link https://wordpress.stackexchange.com/questions/77960/wordpress...
245,364
<p>I'm trying to develop a code to call some Codex functions (<a href="https://codex.wordpress.org/Function_Reference" rel="noreferrer">https://codex.wordpress.org/Function_Reference</a>) the problem is simple, I don't find any doc where read about how to start. </p> <p>I have a PHP file with this line for example: </...
[ { "answer_id": 245674, "author": "Leonardo Cavani", "author_id": 106464, "author_profile": "https://wordpress.stackexchange.com/users/106464", "pm_score": 4, "selected": true, "text": "<p>I get the solution. </p>\n\n<p>To call functions from Wordpress from a custom script, you need to im...
2016/11/07
[ "https://wordpress.stackexchange.com/questions/245364", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/106464/" ]
I'm trying to develop a code to call some Codex functions (<https://codex.wordpress.org/Function_Reference>) the problem is simple, I don't find any doc where read about how to start. I have a PHP file with this line for example: ``` <?php $website = "http://example.com"; $userdata = array( 'user_login' => 'l...
I get the solution. To call functions from Wordpress from a custom script, you need to import wp-load: ``` require_once("/path/wp-load.php"); ``` Thats all, I can work fine with those functions. I save my own script in the root of my PHP Wordpress and I didn't need a plugin.
245,370
<p>I use <a href="https://developer.wordpress.org/reference/functions/add_menu_page/" rel="nofollow noreferrer"><code>add_menu()</code></a>, then I add number of <a href="https://developer.wordpress.org/reference/functions/add_submenu_page/" rel="nofollow noreferrer"><code>add_submenu()</code></a>. </p> <p><strong>COD...
[ { "answer_id": 245374, "author": "Benoti", "author_id": 58141, "author_profile": "https://wordpress.stackexchange.com/users/58141", "pm_score": 1, "selected": false, "text": "<p>The only way I find it's to do it quickly, is with css</p>\n\n<pre><code>#toplevel_page_bb-plugins .wp-submenu...
2016/11/07
[ "https://wordpress.stackexchange.com/questions/245370", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100795/" ]
I use [`add_menu()`](https://developer.wordpress.org/reference/functions/add_menu_page/), then I add number of [`add_submenu()`](https://developer.wordpress.org/reference/functions/add_submenu_page/). **CODE** ``` add_menu_page( 'Config', 'MDW Config', 'manage_options', 'mdw-config', 'config_general_info', '', 4...
Try this: ``` add_menu_page( 'MDW Config', 'MDW Config', 'manage_options', 'mdw-config', 'config_general_info', '', 45); add_submenu_page( 'mdw-config', 'General info', 'Info', 'manage_options', 'mdw-config', 'config_general_info'); add_submenu_page( 'mdw-config', 'Google Analytics Integration', 'Google An...
245,372
<p>I'm looking to apply custom CSS in the admin only for a certain user role, "Contributor" to be exact.</p> <p>Everything I try either seems to have no effect, or produces a 500 error.</p> <p>What I've tried has in the main been loosely based around this:</p> <pre><code>add_action('admin_head', 'custom_admin_css');...
[ { "answer_id": 245377, "author": "Cedon", "author_id": 80069, "author_profile": "https://wordpress.stackexchange.com/users/80069", "pm_score": 2, "selected": false, "text": "<p>Try this:</p>\n\n<pre><code>function wpse245372_admin_user_css() {\n $user = wp_get_current_user();\n if ...
2016/11/07
[ "https://wordpress.stackexchange.com/questions/245372", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/56659/" ]
I'm looking to apply custom CSS in the admin only for a certain user role, "Contributor" to be exact. Everything I try either seems to have no effect, or produces a 500 error. What I've tried has in the main been loosely based around this: ``` add_action('admin_head', 'custom_admin_css'); function custom_admin_css(...
Upon request I will write an answer using a function from a suggested answer for the similar question: [How to target with css, admin elements according to user role level?](https://wordpress.stackexchange.com/questions/66834/how-to-target-with-css-admin-elements-according-to-user-role-level). This function will outpu...
245,381
<p>I want to make it so when user is logged out/in &amp; viewing another user profile the only see the Contact Seller button &amp; when user is logged in viewing their own profile it shows View Inbox &amp; Edit My Profile buttons. Here is a screensoh that show a user logged in as admin viewing a profile belonging to fl...
[ { "answer_id": 245377, "author": "Cedon", "author_id": 80069, "author_profile": "https://wordpress.stackexchange.com/users/80069", "pm_score": 2, "selected": false, "text": "<p>Try this:</p>\n\n<pre><code>function wpse245372_admin_user_css() {\n $user = wp_get_current_user();\n if ...
2016/11/07
[ "https://wordpress.stackexchange.com/questions/245381", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/106493/" ]
I want to make it so when user is logged out/in & viewing another user profile the only see the Contact Seller button & when user is logged in viewing their own profile it shows View Inbox & Edit My Profile buttons. Here is a screensoh that show a user logged in as admin viewing a profile belonging to flamez and seeing...
Upon request I will write an answer using a function from a suggested answer for the similar question: [How to target with css, admin elements according to user role level?](https://wordpress.stackexchange.com/questions/66834/how-to-target-with-css-admin-elements-according-to-user-role-level). This function will outpu...
245,388
<p>This is what I have now: <a href="https://i.stack.imgur.com/HQu5k.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/HQu5k.jpg" alt="enter image description here"></a> I want the video player to take up the whole horizontal space and stretch width 100%. The video should also stay responsive, filling the whole...
[ { "answer_id": 245911, "author": "Azamat", "author_id": 105471, "author_profile": "https://wordpress.stackexchange.com/users/105471", "pm_score": 5, "selected": true, "text": "<p>I added this to my style.css and now the video player is fully responsive!</p>\n\n<pre><code>.wp-video, video...
2016/11/07
[ "https://wordpress.stackexchange.com/questions/245388", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105471/" ]
This is what I have now: [![enter image description here](https://i.stack.imgur.com/HQu5k.jpg)](https://i.stack.imgur.com/HQu5k.jpg) I want the video player to take up the whole horizontal space and stretch width 100%. The video should also stay responsive, filling the whole video player area. I fallowed advice in [th...
I added this to my style.css and now the video player is fully responsive! ``` .wp-video, video.wp-video-shortcode, .mejs-container, .mejs-overlay.load { width: 100% !important; height: 100% !important; } .mejs-container { padding-top: 56.25%; } .wp-video, video.wp-video-shortcode { max-width: 100% !im...
245,399
<p>I'm trying to display different templates in archive.php page. I need to load different article display depending on custom post type. Here is my code: </p> <pre><code>&lt;?php if(is_singular('libri')) :?&gt; &lt;?php // WP_Query arguments $args = array ( 'post_type' =&gt; 'libri', ); // The Que...
[ { "answer_id": 245401, "author": "wscourge", "author_id": 100795, "author_profile": "https://wordpress.stackexchange.com/users/100795", "pm_score": 0, "selected": false, "text": "<p>You use <a href=\"https://codex.wordpress.org/Function_Reference/is_singular\" rel=\"nofollow noreferrer\"...
2016/11/07
[ "https://wordpress.stackexchange.com/questions/245399", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103072/" ]
I'm trying to display different templates in archive.php page. I need to load different article display depending on custom post type. Here is my code: ``` <?php if(is_singular('libri')) :?> <?php // WP_Query arguments $args = array ( 'post_type' => 'libri', ); // The Query $query = new WP_Query( ...
`is_singular` will return false on an archive page. If you wanted to check if you are on an archive for a post type, you would use `is_post_type_archive( 'libri' )` , or you can create an `archive-{post_type}.php` file, which on this case would be `archive-libri.php` References: <https://codex.wordpress.org/Post_Type_...