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
286,423
<p>I wanted some information about on how to achieve the below senario. Can anyone help me out please.</p> <p>Ok so here is what i have got so far.</p> <p>I have two custom post types. And i am pulling &amp; merging those to load randomly. They load randomly and with post types alternatively.</p> <p>Ex: post type 1,...
[ { "answer_id": 286424, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 1, "selected": false, "text": "<p>If that <code>col-4</code> class does what your example suggests it does, then just wrapping each post ...
2017/11/20
[ "https://wordpress.stackexchange.com/questions/286423", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/124296/" ]
I wanted some information about on how to achieve the below senario. Can anyone help me out please. Ok so here is what i have got so far. I have two custom post types. And i am pulling & merging those to load randomly. They load randomly and with post types alternatively. Ex: post type 1, post type 2, post type 1, p...
If that `col-4` class does what your example suggests it does, then just wrapping each post in `col-4` would achieve the same effect: ``` <div class="col-4"> Post 1 </div> <div class="col-4"> Post 2 </div> <div class="col-4"> Post 3 </div> <div class="col-4"> Post 4 </div> <div class="col-4"> Post 5 </div> <div class=...
286,440
<p>I know how to find the post_excerpt using the post ID, but is it possible to find a post ID using an excerpt? Every time I search for this, all that comes up is how to find the post_excerpt from the ID. Thanks for any help.</p>
[ { "answer_id": 286442, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 0, "selected": false, "text": "<p><strong>Via the APIs? No</strong>, the excerpt is not an option in <code>WP_Query</code> which is what power...
2017/11/20
[ "https://wordpress.stackexchange.com/questions/286440", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/123624/" ]
I know how to find the post\_excerpt using the post ID, but is it possible to find a post ID using an excerpt? Every time I search for this, all that comes up is how to find the post\_excerpt from the ID. Thanks for any help.
You can get the post ID from the excerpt, but as far as I can tell, `WP_Query` doesn't support this (very well), so you need to write a custom WPDB query. ``` function get_post_id_by_excerpt($excerpt) { global $wpdb; $result = $wpdb->get_row( $wpdb->prepare("SELECT ID FROM {$wpdb->prefix}posts WHERE p...
286,464
<h1>**EDIT: I finally figured this out. Scroll down for my self-answered self-accepted answer (green check mark) **</h1> <p>I'm currently using <code>functions.php</code> to redirect <code>https</code> urls to <code>http</code> for a site which currently has no SSL certificate:</p> <pre><code>function shapeSpace_check_...
[ { "answer_id": 286474, "author": "Drupalizeme", "author_id": 115005, "author_profile": "https://wordpress.stackexchange.com/users/115005", "pm_score": 2, "selected": false, "text": "<p>Taken from your code I would refactor it like this:</p>\n\n<pre><code>function bhww_ssl_template_redire...
2017/11/20
[ "https://wordpress.stackexchange.com/questions/286464", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/112507/" ]
\*\*EDIT: I finally figured this out. Scroll down for my self-answered self-accepted answer (green check mark) \*\* =================================================================================================================== I'm currently using `functions.php` to redirect `https` urls to `http` for a site which...
Thanks to everyone for your help. But the following code is what finally worked for me to 301 redirect `https` to `http` and `www` to non-www. I placed the following code block inside of `functions.php`: ``` //check if https being used regardless of certificate function shapeSpace_check_https() { if ((!empty($_SE...
286,467
<p>I want to hook into the subscriber role index.php page (wp-admin/index.php) to add some custom content outside of the widgets.</p> <p>This admin_init works for all admin pages:</p> <pre><code>add_action( 'init', 'test_init'); function test_init(){ add_action( 'admin_init', 'test_admin_init'); } function test_...
[ { "answer_id": 286474, "author": "Drupalizeme", "author_id": 115005, "author_profile": "https://wordpress.stackexchange.com/users/115005", "pm_score": 2, "selected": false, "text": "<p>Taken from your code I would refactor it like this:</p>\n\n<pre><code>function bhww_ssl_template_redire...
2017/11/20
[ "https://wordpress.stackexchange.com/questions/286467", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101490/" ]
I want to hook into the subscriber role index.php page (wp-admin/index.php) to add some custom content outside of the widgets. This admin\_init works for all admin pages: ``` add_action( 'init', 'test_init'); function test_init(){ add_action( 'admin_init', 'test_admin_init'); } function test_admin_init() { e...
Thanks to everyone for your help. But the following code is what finally worked for me to 301 redirect `https` to `http` and `www` to non-www. I placed the following code block inside of `functions.php`: ``` //check if https being used regardless of certificate function shapeSpace_check_https() { if ((!empty($_SE...
286,512
<p>I had a website built on Woocommerce for me, but no longer have access to the Developer. I'm not a programmer so anything beyond CSS changes gives me quite a bit of problems. There is a piece of code that was working fine, but I have added an additional item to the site and now it only will fetch the most recent ite...
[ { "answer_id": 286474, "author": "Drupalizeme", "author_id": 115005, "author_profile": "https://wordpress.stackexchange.com/users/115005", "pm_score": 2, "selected": false, "text": "<p>Taken from your code I would refactor it like this:</p>\n\n<pre><code>function bhww_ssl_template_redire...
2017/11/21
[ "https://wordpress.stackexchange.com/questions/286512", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/112509/" ]
I had a website built on Woocommerce for me, but no longer have access to the Developer. I'm not a programmer so anything beyond CSS changes gives me quite a bit of problems. There is a piece of code that was working fine, but I have added an additional item to the site and now it only will fetch the most recent item a...
Thanks to everyone for your help. But the following code is what finally worked for me to 301 redirect `https` to `http` and `www` to non-www. I placed the following code block inside of `functions.php`: ``` //check if https being used regardless of certificate function shapeSpace_check_https() { if ((!empty($_SE...
286,516
<p>I want to set a custom permalink for a specific wordpress page/post.</p> <p>My expectation: <br> 1) Go to specific wordpress page/post edit view.<br> 2) Click edit permalink.<br> 3) Type in new permalink for the specific page/post and click save.<br></p> <p>I have found a plugin name <a href="https://wordpress.org...
[ { "answer_id": 286474, "author": "Drupalizeme", "author_id": 115005, "author_profile": "https://wordpress.stackexchange.com/users/115005", "pm_score": 2, "selected": false, "text": "<p>Taken from your code I would refactor it like this:</p>\n\n<pre><code>function bhww_ssl_template_redire...
2017/11/21
[ "https://wordpress.stackexchange.com/questions/286516", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/131671/" ]
I want to set a custom permalink for a specific wordpress page/post. My expectation: 1) Go to specific wordpress page/post edit view. 2) Click edit permalink. 3) Type in new permalink for the specific page/post and click save. I have found a plugin name [Custom Permalinks](https://wordpress.org/plugins/cu...
Thanks to everyone for your help. But the following code is what finally worked for me to 301 redirect `https` to `http` and `www` to non-www. I placed the following code block inside of `functions.php`: ``` //check if https being used regardless of certificate function shapeSpace_check_https() { if ((!empty($_SE...
286,530
<p>You can use <code>wp_editor</code> to display the wordpress rich editor. How can I display the shorter version (Please see the screenshot, I need that) of <code>wp_editor</code>? </p> <p><a href="https://i.stack.imgur.com/53ubM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/53ubM.png" alt="enter...
[ { "answer_id": 286565, "author": "Cedon", "author_id": 80069, "author_profile": "https://wordpress.stackexchange.com/users/80069", "pm_score": 2, "selected": false, "text": "<p>You will want to pass some parameters into your <code>$settings</code> array for <code>wp_editor()</code> that ...
2017/11/21
[ "https://wordpress.stackexchange.com/questions/286530", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/123092/" ]
You can use `wp_editor` to display the wordpress rich editor. How can I display the shorter version (Please see the screenshot, I need that) of `wp_editor`? [![enter image description here](https://i.stack.imgur.com/53ubM.png)](https://i.stack.imgur.com/53ubM.png)
You will want to pass some parameters into your `$settings` array for `wp_editor()` that only tells it to display the quicktags for `strong`,`em`,`ul`,`ol`, and `link` per your screenshot. I didn't have time to test it, but this code should give you want you want: ``` $settings = array( // Any previous settings yo...
286,534
<p>I'm looking for how hide or remove Link Relationship (XFN) from Menus tab (In red on the picture below)</p> <p><a href="https://i.stack.imgur.com/ReqAc.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ReqAc.jpg" alt="enter image description here"></a></p>
[ { "answer_id": 286565, "author": "Cedon", "author_id": 80069, "author_profile": "https://wordpress.stackexchange.com/users/80069", "pm_score": 2, "selected": false, "text": "<p>You will want to pass some parameters into your <code>$settings</code> array for <code>wp_editor()</code> that ...
2017/11/21
[ "https://wordpress.stackexchange.com/questions/286534", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119785/" ]
I'm looking for how hide or remove Link Relationship (XFN) from Menus tab (In red on the picture below) [![enter image description here](https://i.stack.imgur.com/ReqAc.jpg)](https://i.stack.imgur.com/ReqAc.jpg)
You will want to pass some parameters into your `$settings` array for `wp_editor()` that only tells it to display the quicktags for `strong`,`em`,`ul`,`ol`, and `link` per your screenshot. I didn't have time to test it, but this code should give you want you want: ``` $settings = array( // Any previous settings yo...
286,547
<p>Is there a way to bulk add one word at the end of each URL for posts? I have around 3500 posts and it would be time consuming to add to each one.</p> <p>For example URL's are </p> <pre><code>www.example.com/my-post/ www.examle.com/new-post/ </code></pre> <p>And I want to add one word to end of URL</p> <pre><code...
[ { "answer_id": 286549, "author": "Sid", "author_id": 110516, "author_profile": "https://wordpress.stackexchange.com/users/110516", "pm_score": 2, "selected": true, "text": "<p>Here is your code:</p>\n\n<pre><code>if ( isset($_GET['slug-update']) ) {\n\n $posts = get_posts();\n\n fo...
2017/11/21
[ "https://wordpress.stackexchange.com/questions/286547", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74294/" ]
Is there a way to bulk add one word at the end of each URL for posts? I have around 3500 posts and it would be time consuming to add to each one. For example URL's are ``` www.example.com/my-post/ www.examle.com/new-post/ ``` And I want to add one word to end of URL ``` www.example.com/my-post-word/ www.examle.co...
Here is your code: ``` if ( isset($_GET['slug-update']) ) { $posts = get_posts(); foreach($posts as $singlepost) { if($singlepost->post_status === 'publish'){ $post_id = $singlepost->ID; $current_slug = $singlepost->post_name; $updated_slug = $current_slug . '-word...
286,551
<p>I have added a custom url to the widget image in the new WP 4.9. Now I want to add an onclick event to the link.</p> <p>The a tag looks like this</p> <pre><code>&lt;a href="http://domain.com/this-is-a-page" class="" rel="" target=""&gt;&lt;/a&gt; </code></pre> <p>And I want to have it like this</p> <pre><code>&l...
[ { "answer_id": 286553, "author": "Drupalizeme", "author_id": 115005, "author_profile": "https://wordpress.stackexchange.com/users/115005", "pm_score": 2, "selected": true, "text": "<p>I would use the <a href=\"https://support.google.com/tagmanager/answer/6106961?hl=en\" rel=\"nofollow no...
2017/11/21
[ "https://wordpress.stackexchange.com/questions/286551", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/39284/" ]
I have added a custom url to the widget image in the new WP 4.9. Now I want to add an onclick event to the link. The a tag looks like this ``` <a href="http://domain.com/this-is-a-page" class="" rel="" target=""></a> ``` And I want to have it like this ``` <a href="http://domain.com/this-is-a-page" onclick="ga('se...
I would use the [Google Tag Manager firing options](https://support.google.com/tagmanager/answer/6106961?hl=en): Or Old school jQuery solution: ``` function($){ $('.widget_class').click(function() { ga('send', 'event', 'Sidebar Image', 'Promo Image', 'Clicked'); }); })(jQuery); ``` Now y...
286,599
<p>I created a new tab called "Videos" inside of the BuddyPress Profile page. This tab contains all video posts added by that user. The problem is that it only shows the first 12 posts and the pagination does not show up. I did try to include the pagination code provided by the theme but to no avail.</p> <p>Notes:</p>...
[ { "answer_id": 286554, "author": "Welcher", "author_id": 27210, "author_profile": "https://wordpress.stackexchange.com/users/27210", "pm_score": 1, "selected": false, "text": "<p>Depending on your setup, there may be caching in place that would not be accounted for when accessing the dat...
2017/11/21
[ "https://wordpress.stackexchange.com/questions/286599", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/131892/" ]
I created a new tab called "Videos" inside of the BuddyPress Profile page. This tab contains all video posts added by that user. The problem is that it only shows the first 12 posts and the pagination does not show up. I did try to include the pagination code provided by the theme but to no avail. Notes: * I am using...
The data is serialized. In order to edit it, you need to unserialize it, edit, then serialize again, and save. You can do that with PHP. Check [serialize](http://php.net/manual/en/function.serialize.php) and [unserialize](http://php.net/manual/en/function.unserialize.php). You can check this tool as well: [serializ...
286,618
<p>I have a wordpress setup which has more than 300 categories.</p> <p>Now I have requirement to give some flexibility to choose the categories. In that case I initially pre-ticked all the categories, if someone need to exclude a category they can deselect it. </p> <p>Now the problem I am facing is how to give accura...
[ { "answer_id": 286717, "author": "grazdev", "author_id": 129417, "author_profile": "https://wordpress.stackexchange.com/users/129417", "pm_score": 2, "selected": false, "text": "<p>Why are you pre-ticking all the categories? Isn't it easier to display all the results and at the same time...
2017/11/22
[ "https://wordpress.stackexchange.com/questions/286618", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68403/" ]
I have a wordpress setup which has more than 300 categories. Now I have requirement to give some flexibility to choose the categories. In that case I initially pre-ticked all the categories, if someone need to exclude a category they can deselect it. Now the problem I am facing is how to give accurate results accord...
As you probably know it, categories are taxonomies. When you use the arguments such as `category__in`, it will add a tax query to your `WP_Query()`. So, your situation would be something like this: ``` $args = array( 'post_type' => 'post', 'tax_query' => array( 'relation' => 'AND', array( ...
286,632
<pre><code>$args = array( 'post_type' =&gt; 'listing', 'order' =&gt; 'ASC', 'hide_empty' =&gt; false, 'parent' =&gt; 0, ); $listCatTerms = get_terms( 'listing-category',$args); if ( ! empty( $listCatTerms ) &amp;&amp; ! is_wp_error( $listCatTerms ) ){ foreach ( $listCatTerms as $term ) { ...
[ { "answer_id": 286641, "author": "Sid", "author_id": 110516, "author_profile": "https://wordpress.stackexchange.com/users/110516", "pm_score": 1, "selected": false, "text": "<p>Here you go:</p>\n\n<pre><code>$args = array(\n 'post_type' =&gt; 'listing',\n 'order' =&gt; 'ASC...
2017/11/22
[ "https://wordpress.stackexchange.com/questions/286632", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102970/" ]
``` $args = array( 'post_type' => 'listing', 'order' => 'ASC', 'hide_empty' => false, 'parent' => 0, ); $listCatTerms = get_terms( 'listing-category',$args); if ( ! empty( $listCatTerms ) && ! is_wp_error( $listCatTerms ) ){ foreach ( $listCatTerms as $term ) { echo '<li class="...
Here you go: ``` $args = array( 'post_type' => 'listing', 'order' => 'ASC', 'hide_empty' => false, 'parent' => 0, ); $listCatTerms = get_terms( 'listing-category',$args); if ( ! empty( $listCatTerms ) && ! is_wp_error( $listCatTerms ) ){ echo "<ul>"; for...
286,660
<p>I crated a footer.php and a corresponding customFooter.php. It looked great until I added header.php and customHeader.css. Now the 2 custom css files are overlaping. For example: some of the <code>&lt;img&gt;</code> are not aligned properly, due to the alignment of the pther css file. Is it possible to restrict cer...
[ { "answer_id": 286641, "author": "Sid", "author_id": 110516, "author_profile": "https://wordpress.stackexchange.com/users/110516", "pm_score": 1, "selected": false, "text": "<p>Here you go:</p>\n\n<pre><code>$args = array(\n 'post_type' =&gt; 'listing',\n 'order' =&gt; 'ASC...
2017/11/22
[ "https://wordpress.stackexchange.com/questions/286660", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/128998/" ]
I crated a footer.php and a corresponding customFooter.php. It looked great until I added header.php and customHeader.css. Now the 2 custom css files are overlaping. For example: some of the `<img>` are not aligned properly, due to the alignment of the pther css file. Is it possible to restrict certain css file only t...
Here you go: ``` $args = array( 'post_type' => 'listing', 'order' => 'ASC', 'hide_empty' => false, 'parent' => 0, ); $listCatTerms = get_terms( 'listing-category',$args); if ( ! empty( $listCatTerms ) && ! is_wp_error( $listCatTerms ) ){ echo "<ul>"; for...
286,706
<p>I have spent the last hour googling and trying different methods but nothing works the way I want it to.</p> <p>Within the loop of the posts, I need to get the permalink of the main page. </p> <h2>Example</h2> <p>You have a portfolio custom post type and then a page where you show all of your work <code>archive-p...
[ { "answer_id": 286641, "author": "Sid", "author_id": 110516, "author_profile": "https://wordpress.stackexchange.com/users/110516", "pm_score": 1, "selected": false, "text": "<p>Here you go:</p>\n\n<pre><code>$args = array(\n 'post_type' =&gt; 'listing',\n 'order' =&gt; 'ASC...
2017/11/22
[ "https://wordpress.stackexchange.com/questions/286706", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/130535/" ]
I have spent the last hour googling and trying different methods but nothing works the way I want it to. Within the loop of the posts, I need to get the permalink of the main page. Example ------- You have a portfolio custom post type and then a page where you show all of your work `archive-portfolio.php`, I need t...
Here you go: ``` $args = array( 'post_type' => 'listing', 'order' => 'ASC', 'hide_empty' => false, 'parent' => 0, ); $listCatTerms = get_terms( 'listing-category',$args); if ( ! empty( $listCatTerms ) && ! is_wp_error( $listCatTerms ) ){ echo "<ul>"; for...
286,726
<p>I have set the "shop" page as my front page and I want to remove the default woocommerce title from the home page of the site. I have emptied the title but I still get an empty tag like this on the home page:</p> <pre><code>&lt;h1 class="woocommerce-products-header__title page-title"&gt;&lt;/h1&gt; </code></pre> <...
[ { "answer_id": 286728, "author": "meDeepakJain", "author_id": 85593, "author_profile": "https://wordpress.stackexchange.com/users/85593", "pm_score": 1, "selected": false, "text": "<p>Few alternate ways to do so:</p>\n\n<ol>\n<li>Remove title code from your theme's home.php</li>\n<li>Cre...
2017/11/23
[ "https://wordpress.stackexchange.com/questions/286726", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/125637/" ]
I have set the "shop" page as my front page and I want to remove the default woocommerce title from the home page of the site. I have emptied the title but I still get an empty tag like this on the home page: ``` <h1 class="woocommerce-products-header__title page-title"></h1> ``` This creates an empty area above the...
you can overwrite woocommerce template of **"archive-product.php"** into your current theme and replace with this code. ``` <?php if ( apply_filters( 'woocommerce_show_page_title', true ) ) : ?> <?php if(!is_shop()) { ?> <h1 class="page-title"><?php woocommerce_page_title(); ?></h1> ...
286,746
<p>I have about 100 blog posts and I've been successfully creating 'Page Templates' with ease - and when I create a page I can select the Page Template from the 'Page Attributes' which is all very nice and easy.</p> <p>I thought the same would be possible for posts...</p> <p>So I created a post template and saved it ...
[ { "answer_id": 286747, "author": "grazdev", "author_id": 129417, "author_profile": "https://wordpress.stackexchange.com/users/129417", "pm_score": 3, "selected": false, "text": "<p>You have to add the following lines at the top of your post template file: </p>\n\n<pre><code>&lt;?php\n/*\...
2017/11/23
[ "https://wordpress.stackexchange.com/questions/286746", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93691/" ]
I have about 100 blog posts and I've been successfully creating 'Page Templates' with ease - and when I create a page I can select the Page Template from the 'Page Attributes' which is all very nice and easy. I thought the same would be possible for posts... So I created a post template and saved it as 'single-templa...
You have to add the following lines at the top of your post template file: ``` <?php /* * Template Name: Featured Article * Template Post Type: post, page, product */ get_header(); ?> ``` Of course replace "Featured Article" with your desired template name and the list of post types with the post types you wa...
286,748
<p>Is it possible that Tag Cloud Widget will show only tags by category?</p> <p>If a single post is from <code>sports</code> category, then the Tag Cloud Widget will only show tags about sports.</p>
[ { "answer_id": 286747, "author": "grazdev", "author_id": 129417, "author_profile": "https://wordpress.stackexchange.com/users/129417", "pm_score": 3, "selected": false, "text": "<p>You have to add the following lines at the top of your post template file: </p>\n\n<pre><code>&lt;?php\n/*\...
2017/11/23
[ "https://wordpress.stackexchange.com/questions/286748", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/128147/" ]
Is it possible that Tag Cloud Widget will show only tags by category? If a single post is from `sports` category, then the Tag Cloud Widget will only show tags about sports.
You have to add the following lines at the top of your post template file: ``` <?php /* * Template Name: Featured Article * Template Post Type: post, page, product */ get_header(); ?> ``` Of course replace "Featured Article" with your desired template name and the list of post types with the post types you wa...
286,759
<p>I'd like to query the database directly, and determine which plugins are enabled.</p> <p>How can I do this?</p>
[ { "answer_id": 286760, "author": "Piyush Rawat", "author_id": 73600, "author_profile": "https://wordpress.stackexchange.com/users/73600", "pm_score": 1, "selected": false, "text": "<p>You can use <code>get_options('active_plugins')</code> to retrieve all active plugins.</p>\n\n<p>For che...
2017/11/23
[ "https://wordpress.stackexchange.com/questions/286759", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65429/" ]
I'd like to query the database directly, and determine which plugins are enabled. How can I do this?
You can do it like this: SQL --- ``` SELECT * FROM wp_options WHERE option_name = 'active_plugins'; ``` But for better approach will be the WordPress way: Wordpress --------- ``` if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $active_plugins = get_option(...
286,764
<p>I use WooCommerce REST API for updating/creating/deleting products. When I try to delete a product using <code>$woocommerce-&gt;post('products/batch')</code>, an image connected with a product is not deleting from the DB and filesystem. It takes up unnecessary space on the server. </p> <p>What is the best way to re...
[ { "answer_id": 286760, "author": "Piyush Rawat", "author_id": 73600, "author_profile": "https://wordpress.stackexchange.com/users/73600", "pm_score": 1, "selected": false, "text": "<p>You can use <code>get_options('active_plugins')</code> to retrieve all active plugins.</p>\n\n<p>For che...
2017/11/23
[ "https://wordpress.stackexchange.com/questions/286764", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/131997/" ]
I use WooCommerce REST API for updating/creating/deleting products. When I try to delete a product using `$woocommerce->post('products/batch')`, an image connected with a product is not deleting from the DB and filesystem. It takes up unnecessary space on the server. What is the best way to resolve this problem?
You can do it like this: SQL --- ``` SELECT * FROM wp_options WHERE option_name = 'active_plugins'; ``` But for better approach will be the WordPress way: Wordpress --------- ``` if ( ! function_exists( 'get_plugins' ) ) { require_once ABSPATH . 'wp-admin/includes/plugin.php'; } $active_plugins = get_option(...
286,788
<p>Is there a way to update plugins, themes, and core, all in one row, instead 3 rows, in WPCLI?</p> <p>This is the current code I use in the <code>crontab</code> and that I'd like to improve:</p> <pre><code>0 0 * * * for dir in /var/www/html/*/; do cd "$dir" &amp;&amp; /usr/local/bin/wp plugin update --all --allow-r...
[ { "answer_id": 286790, "author": "Pat J", "author_id": 16121, "author_profile": "https://wordpress.stackexchange.com/users/16121", "pm_score": 1, "selected": false, "text": "<p>I'd do something like this:</p>\n\n<pre><code>0 0 * * * for dir in /var/www/html/*/; do cd \"$dir\" &amp;&amp; ...
2017/11/23
[ "https://wordpress.stackexchange.com/questions/286788", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/131001/" ]
Is there a way to update plugins, themes, and core, all in one row, instead 3 rows, in WPCLI? This is the current code I use in the `crontab` and that I'd like to improve: ``` 0 0 * * * for dir in /var/www/html/*/; do cd "$dir" && /usr/local/bin/wp plugin update --all --allow-root; done 0 0 * * * for dir in /var/www/...
Run a script instead: ``` 0 0 * * * for dir in /var/www/html/*/; do cd "$dir" && ./updatewp.sh; done ``` In `updatewp.sh`: ``` wp core update --all --allow-root wp plugin update --all --allow-root wp theme update --all --allow-root ```
286,805
<p>I've created a product with variations but they are not linked at the back end and won't show up on the product page unless i manually set them<a href="https://i.stack.imgur.com/Q5If8.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Q5If8.jpg" alt="enter image description here"></a></p> <pre><code...
[ { "answer_id": 322000, "author": "Ramuchit Kumar", "author_id": 156014, "author_profile": "https://wordpress.stackexchange.com/users/156014", "pm_score": 1, "selected": false, "text": "<p>you have to create another request for variation.</p>\n\n<pre><code>$variation_data = [\n 'regula...
2017/11/23
[ "https://wordpress.stackexchange.com/questions/286805", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119733/" ]
I've created a product with variations but they are not linked at the back end and won't show up on the product page unless i manually set them[![enter image description here](https://i.stack.imgur.com/Q5If8.jpg)](https://i.stack.imgur.com/Q5If8.jpg) ``` $data = [ 'title'=> 'ship your idea5', 'type' => 'variable', 'd...
you have to create another request for variation. ``` $variation_data = [ 'regular_price' => '15.00', 'image' => [ 'src' => 'https://shop.local/path/to/image_size_l.jpg', ], 'attributes' => [ [ 'id' => 5, 'option' => 'L', ], ], ]; $thi...
286,823
<p>//The textarea is displayed when the if clause evaluates to false. // What do I need to change?</p> <pre><code>&lt;?php if ( 1==2) ?&gt; &lt;textarea&gt; "Add multiple lines of text here and watch the scrollbars grow."&gt; &lt;/textarea&gt; </code></pre>
[ { "answer_id": 286825, "author": "rudtek", "author_id": 77767, "author_profile": "https://wordpress.stackexchange.com/users/77767", "pm_score": 0, "selected": false, "text": "<p>You don't have a complete code there:</p>\n\n<pre><code>&lt;?php \nif ( 1==2): ?&gt;\n&lt;textarea&gt;\n\"Add...
2017/11/24
[ "https://wordpress.stackexchange.com/questions/286823", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/129686/" ]
//The textarea is displayed when the if clause evaluates to false. // What do I need to change? ``` <?php if ( 1==2) ?> <textarea> "Add multiple lines of text here and watch the scrollbars grow."> </textarea> ```
You may do it this way using open/close bracket **{}** ``` <?php if ( 1==2) { ?> <textarea> "Add multiple lines of text here and watch the scrollbars grow."> </textarea> <?php } ?> ``` In general rules you need to enclose all the `if else` statement using php tag and the html outside it. You may also use echo. --...
286,879
<p>Is it possible to pass variable to <code>get_search_form()</code>? </p> <p>I'm using it in two places: one in header and on the search page in the content. The latter must have additional class, e.g. <code>search--full</code>. I've tried to use <code>is_search()</code> but while it works well on other pages, on sea...
[ { "answer_id": 286825, "author": "rudtek", "author_id": 77767, "author_profile": "https://wordpress.stackexchange.com/users/77767", "pm_score": 0, "selected": false, "text": "<p>You don't have a complete code there:</p>\n\n<pre><code>&lt;?php \nif ( 1==2): ?&gt;\n&lt;textarea&gt;\n\"Add...
2017/11/24
[ "https://wordpress.stackexchange.com/questions/286879", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/121208/" ]
Is it possible to pass variable to `get_search_form()`? I'm using it in two places: one in header and on the search page in the content. The latter must have additional class, e.g. `search--full`. I've tried to use `is_search()` but while it works well on other pages, on search page both forms have `search--full` cla...
You may do it this way using open/close bracket **{}** ``` <?php if ( 1==2) { ?> <textarea> "Add multiple lines of text here and watch the scrollbars grow."> </textarea> <?php } ?> ``` In general rules you need to enclose all the `if else` statement using php tag and the html outside it. You may also use echo. --...
286,890
<p>I'm trying to see if I am on a single page, this page is defined by:</p> <ol> <li>Is not the homepage for sure.</li> <li>Doesn't have any posts for sure.</li> </ol> <p>Here's my code:</p> <pre><code>&lt;?php if ( !is_home() &amp;&amp; !have_posts() ) : ?&gt; &lt;div class="single-page"&gt; &lt;?php endif; ?&g...
[ { "answer_id": 286825, "author": "rudtek", "author_id": 77767, "author_profile": "https://wordpress.stackexchange.com/users/77767", "pm_score": 0, "selected": false, "text": "<p>You don't have a complete code there:</p>\n\n<pre><code>&lt;?php \nif ( 1==2): ?&gt;\n&lt;textarea&gt;\n\"Add...
2017/11/24
[ "https://wordpress.stackexchange.com/questions/286890", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/130044/" ]
I'm trying to see if I am on a single page, this page is defined by: 1. Is not the homepage for sure. 2. Doesn't have any posts for sure. Here's my code: ``` <?php if ( !is_home() && !have_posts() ) : ?> <div class="single-page"> <?php endif; ?> ``` Added to `page.php`, but it doesn't seem to do anything. I kn...
You may do it this way using open/close bracket **{}** ``` <?php if ( 1==2) { ?> <textarea> "Add multiple lines of text here and watch the scrollbars grow."> </textarea> <?php } ?> ``` In general rules you need to enclose all the `if else` statement using php tag and the html outside it. You may also use echo. --...
286,947
<p>I am building an application using WordPress Rest API.</p> <p>I want to make simple calls to the API, such as just <strong><code>/wp-json/wp/v2/posts</code></strong> and let the backend have a systematic way how to handle this and serve <code>/wp-json/wp/v2/posts?per_page=7</code> under the hood instead.</p> <p>Ba...
[ { "answer_id": 286975, "author": "mmm", "author_id": 74311, "author_profile": "https://wordpress.stackexchange.com/users/74311", "pm_score": 0, "selected": false, "text": "<p>To define default values, you can use the filter <code>rest_{$post_type}_collection_params</code> like that : </p...
2017/11/26
[ "https://wordpress.stackexchange.com/questions/286947", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/77764/" ]
I am building an application using WordPress Rest API. I want to make simple calls to the API, such as just **`/wp-json/wp/v2/posts`** and let the backend have a systematic way how to handle this and serve `/wp-json/wp/v2/posts?per_page=7` under the hood instead. Basically, how can I override the defaults for the Res...
I think I found answer to your question, it is: `rest_{$this->post_type}_query` filter hook. With this hook you are able to directly edit internal WP\_Query parameter. For example, if you'd like to internally sort Posts by `post_title` by default, then you'd have to write something like this: ``` function order_rest...
286,955
<p>I have been working on a website using WordPress <a href="http://1stgoringheath.org.uk/" rel="nofollow noreferrer">http://1stgoringheath.org.uk/</a>, there are some pages that I didn't want to have the sidebar on, so I made a template and removed get_sidebar</p> <p>Now I have just a blank area where the sidebar wa...
[ { "answer_id": 286958, "author": "Kins Okafor", "author_id": 131906, "author_profile": "https://wordpress.stackexchange.com/users/131906", "pm_score": -1, "selected": false, "text": "<p>You can only remove the blank space by editing the custom css. First you need to be working on a Child...
2017/11/26
[ "https://wordpress.stackexchange.com/questions/286955", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132124/" ]
I have been working on a website using WordPress <http://1stgoringheath.org.uk/>, there are some pages that I didn't want to have the sidebar on, so I made a template and removed get\_sidebar Now I have just a blank area where the sidebar was, which I want to remove and allow the main content div fill the space. The ...
You may add this code to your custom CSS : ``` .page-template-pageWithOutSidebar .entry-header, .page-template-pageWithOutSidebar .entry-content { padding-right: 0; } ```
286,960
<p>I've been banging my head against the wall for last couple of days trying to exclude a category from an archive of easy digital downloads, which i am displaying in a custom widget, however i cannot hide a category called 'custom-project' no matter what i try.</p> <p>This is the code i am trying to use, based on ins...
[ { "answer_id": 286961, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 4, "selected": true, "text": "<h2>Issue 1</h2>\n\n<p>In your tax query, you should use <code>NOT IN</code> instead of <code>NOT_IN</code>. Th...
2017/11/26
[ "https://wordpress.stackexchange.com/questions/286960", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64807/" ]
I've been banging my head against the wall for last couple of days trying to exclude a category from an archive of easy digital downloads, which i am displaying in a custom widget, however i cannot hide a category called 'custom-project' no matter what i try. This is the code i am trying to use, based on instructions ...
Issue 1 ------- In your tax query, you should use `NOT IN` instead of `NOT_IN`. That's preventing your tax query from working ( Assuming that the other fields are correct ). Issue 2 ------- In your arguments for `WP_Query()`, you should use `category__not_in` instead of `cat`. So, change your code to: ``` $argsQuer...
286,996
<p>I want to do some changes on WP for a friend but I don't want to do it live. So I was thinking of cloning the current WP to another directory on the same server and then do work on that version (www.myfriendswp.com -> www.myfriendswp.com/testing) and, when done, clone the changes back to main directory.</p> <p>Is t...
[ { "answer_id": 286961, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 4, "selected": true, "text": "<h2>Issue 1</h2>\n\n<p>In your tax query, you should use <code>NOT IN</code> instead of <code>NOT_IN</code>. Th...
2017/11/27
[ "https://wordpress.stackexchange.com/questions/286996", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105635/" ]
I want to do some changes on WP for a friend but I don't want to do it live. So I was thinking of cloning the current WP to another directory on the same server and then do work on that version (www.myfriendswp.com -> www.myfriendswp.com/testing) and, when done, clone the changes back to main directory. Is this possib...
Issue 1 ------- In your tax query, you should use `NOT IN` instead of `NOT_IN`. That's preventing your tax query from working ( Assuming that the other fields are correct ). Issue 2 ------- In your arguments for `WP_Query()`, you should use `category__not_in` instead of `cat`. So, change your code to: ``` $argsQuer...
287,015
<p>So far I've got the code below which achieves the effect I'm after, but it appends the title of only the current page to every page title on a page (including Next / Previous links which obviously have different titles), so I obviously need to retrieve the custom field value from these posts, but I'm struggling to a...
[ { "answer_id": 287017, "author": "Marcelo Henriques Cortez", "author_id": 44437, "author_profile": "https://wordpress.stackexchange.com/users/44437", "pm_score": 0, "selected": false, "text": "<p>If you need to append something to EVERY post_title you have, you should:</p>\n\n<p>Make you...
2017/11/27
[ "https://wordpress.stackexchange.com/questions/287015", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132164/" ]
So far I've got the code below which achieves the effect I'm after, but it appends the title of only the current page to every page title on a page (including Next / Previous links which obviously have different titles), so I obviously need to retrieve the custom field value from these posts, but I'm struggling to achi...
If you need to append something to EVERY post\_title you have, you should: Make your loop with `WP Query`, [check Codex](https://codex.wordpress.org/Class_Reference/WP_Query) Then, use `get_the_ID`, to get the specific post ID, [check Codex](https://developer.wordpress.org/reference/functions/get_the_ID/) Then, use ...
287,033
<p>I want to make a rewrite-rule for latest posts <code>example.com/latest</code> via <code>rewrite_rules_array</code>-filterhook and display the posts with <code>archive.php</code>. </p> <p>Usually this is what <code>example.com/index.php</code> does, I guess? But I use my themes <code>index.php</code> for a custom i...
[ { "answer_id": 287017, "author": "Marcelo Henriques Cortez", "author_id": 44437, "author_profile": "https://wordpress.stackexchange.com/users/44437", "pm_score": 0, "selected": false, "text": "<p>If you need to append something to EVERY post_title you have, you should:</p>\n\n<p>Make you...
2017/11/27
[ "https://wordpress.stackexchange.com/questions/287033", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102487/" ]
I want to make a rewrite-rule for latest posts `example.com/latest` via `rewrite_rules_array`-filterhook and display the posts with `archive.php`. Usually this is what `example.com/index.php` does, I guess? But I use my themes `index.php` for a custom index page. `index.php?category_name=technik` successfully gets o...
If you need to append something to EVERY post\_title you have, you should: Make your loop with `WP Query`, [check Codex](https://codex.wordpress.org/Class_Reference/WP_Query) Then, use `get_the_ID`, to get the specific post ID, [check Codex](https://developer.wordpress.org/reference/functions/get_the_ID/) Then, use ...
287,051
<p>i am new to plugin development in wordpress and i have have this simple test plugin that i am working on. The problem i am having is that the uninstall.php file does not appear to get trigger and as such the database entried i wish to remove remain after the plugin in uninstalled from the WordPress admin.</p> <p><s...
[ { "answer_id": 287044, "author": "grazdev", "author_id": 129417, "author_profile": "https://wordpress.stackexchange.com/users/129417", "pm_score": 0, "selected": false, "text": "<p>This should work: </p>\n\n<pre><code>&lt;img src=\"&lt;?php echo do_shortcode('[my_shortcode]'); ?&gt;\" /&...
2017/11/27
[ "https://wordpress.stackexchange.com/questions/287051", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/71390/" ]
i am new to plugin development in wordpress and i have have this simple test plugin that i am working on. The problem i am having is that the uninstall.php file does not appear to get trigger and as such the database entried i wish to remove remain after the plugin in uninstalled from the WordPress admin. **Plugin cod...
You cannot use Shortcodes in attributes since 4.2.3, for security reasons. See the [announcement](https://make.wordpress.org/core/2015/07/23/changes-to-the-shortcode-api/) (emphasis mine): > > Earlier today, we released WordPress 4.2.3, which includes a > **relatively large security fix that affects the Shortcode AP...
287,057
<p>I'm trying to adjust a function that checks if the site visitor is on a post type archive and returns a certain layout. I need it to also check to see if it is in certain categories (using regular WP categories - not custom taxonomies).</p> <p>This is the original code that works.</p> <pre><code>// ADD ARCHIVE LAY...
[ { "answer_id": 287044, "author": "grazdev", "author_id": 129417, "author_profile": "https://wordpress.stackexchange.com/users/129417", "pm_score": 0, "selected": false, "text": "<p>This should work: </p>\n\n<pre><code>&lt;img src=\"&lt;?php echo do_shortcode('[my_shortcode]'); ?&gt;\" /&...
2017/11/27
[ "https://wordpress.stackexchange.com/questions/287057", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132201/" ]
I'm trying to adjust a function that checks if the site visitor is on a post type archive and returns a certain layout. I need it to also check to see if it is in certain categories (using regular WP categories - not custom taxonomies). This is the original code that works. ``` // ADD ARCHIVE LAYOUT FOR POSITION VIDE...
You cannot use Shortcodes in attributes since 4.2.3, for security reasons. See the [announcement](https://make.wordpress.org/core/2015/07/23/changes-to-the-shortcode-api/) (emphasis mine): > > Earlier today, we released WordPress 4.2.3, which includes a > **relatively large security fix that affects the Shortcode AP...
287,062
<p>I'm working on a new site that includes memberships, and I'd like the Page Title to be a different color on the membership page without changing on any of the other pages. I've seen code that helps change the home page title color (using .home) but none that use a different page. The page title is "A Voice That Care...
[ { "answer_id": 287071, "author": "Patrice Poliquin", "author_id": 32365, "author_profile": "https://wordpress.stackexchange.com/users/32365", "pm_score": 0, "selected": false, "text": "<p>Firstly, I would recommend you to create a custom template page (<a href=\"https://developer.wordpre...
2017/11/27
[ "https://wordpress.stackexchange.com/questions/287062", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132204/" ]
I'm working on a new site that includes memberships, and I'd like the Page Title to be a different color on the membership page without changing on any of the other pages. I've seen code that helps change the home page title color (using .home) but none that use a different page. The page title is "A Voice That Cares" ...
If you're using `body_class` and `post_class` correctly, you should have CSS classes you can match against that take the form `postid-0001` etc Next you need the CSS to change the `h1` colour Find the ID of your membership page, and use the CSS class in your CSS selector so it only matches on that page. e.g. `.posti...
287,078
<pre><code>Array ( [0] =&gt; Array ( [week-day] =&gt; tuesday [day-date] =&gt; 1511841600 [events_ids] =&gt; Array ( [0] =&gt; 83417 ) ) [1] =&gt; Array ( [week-day] =&gt; wednesday [day-date] =&gt; 1511913600 [events_ids] =&gt; Array ( [0] =&gt; 83417 ) ) [2] =&gt; Array ( [week-day] =&gt; thrusday [day...
[ { "answer_id": 287080, "author": "Andrew Herder", "author_id": 81637, "author_profile": "https://wordpress.stackexchange.com/users/81637", "pm_score": 2, "selected": true, "text": "<p>This should get the desired result:</p>\n\n<pre><code>//Initial Array\n$events = array\n(\n array\n ...
2017/11/27
[ "https://wordpress.stackexchange.com/questions/287078", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/130304/" ]
``` Array ( [0] => Array ( [week-day] => tuesday [day-date] => 1511841600 [events_ids] => Array ( [0] => 83417 ) ) [1] => Array ( [week-day] => wednesday [day-date] => 1511913600 [events_ids] => Array ( [0] => 83417 ) ) [2] => Array ( [week-day] => thrusday [day-date] => 1512000000 [events_ids] => Array ...
This should get the desired result: ``` //Initial Array $events = array ( array ( 'week-day' => 'tuesday', 'day-date' => 1511841600, 'events_ids' => array( 83417 ) ), array ( 'week-day' => 'wednesday', 'day-date' => 1511913600, 'events_ids' => array( ...
287,104
<p>This is the main requirements of my project.</p> <p>After a user login, logout should be done only if user click logout button or if user delete browser history.</p> <p>When browser closing, then machine restarting, changing IP address <strong>should NOT logout the User</strong>.</p> <p>Is this possible with Word...
[ { "answer_id": 287108, "author": "Aniruddha Gawade", "author_id": 101818, "author_profile": "https://wordpress.stackexchange.com/users/101818", "pm_score": -1, "selected": false, "text": "<p>You can try setting cookies when a user logs in using <code>wp_set_auth_cookie</code>.</p>\n\n<p>...
2017/11/28
[ "https://wordpress.stackexchange.com/questions/287104", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/123092/" ]
This is the main requirements of my project. After a user login, logout should be done only if user click logout button or if user delete browser history. When browser closing, then machine restarting, changing IP address **should NOT logout the User**. Is this possible with WordPress? Is there any filter, action ho...
You can use the `auth_cookie_expiration` filter to change the expiration time of the cookie WordPress sets to remember you. The user won't be logged out unless they change browser or clear their cookies (normally part of clearing history). The problem is that you can't set a cookie to never expire, so you have to set ...
287,203
<p>I created the rewrite rule</p> <pre><code>add_rewrite_rule("^user/(\d+)/(myaccount)/?", 'index.php?pagename=$matches[2]&amp;user_id=$matches[1]','top'); </code></pre> <p>So when a user visits example.com/user/123/myaccount/ it should use the wordpress page with slug 'myaccount' and pass '123' as the user_id.</p> ...
[ { "answer_id": 287219, "author": "hashtagerrors", "author_id": 102412, "author_profile": "https://wordpress.stackexchange.com/users/102412", "pm_score": -1, "selected": false, "text": "<p>Your rewrite rule <code>user/(\\d+)/(myaccount)/</code> had an error because of forward slashes. In ...
2017/11/29
[ "https://wordpress.stackexchange.com/questions/287203", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74060/" ]
I created the rewrite rule ``` add_rewrite_rule("^user/(\d+)/(myaccount)/?", 'index.php?pagename=$matches[2]&user_id=$matches[1]','top'); ``` So when a user visits example.com/user/123/myaccount/ it should use the wordpress page with slug 'myaccount' and pass '123' as the user\_id. I have flushed my rewrite rules, ...
I tested the suggestion from my comment and it worked. Remove the brackets from `(myaccount)` and change `$matches[2]` in the URL to `myaccount`: ``` function wpse_287203_rewrite_rule() { add_rewrite_rule( '^user/(\d+)/myaccount/?', 'index.php?pagename=myaccount&user_id=$matches[1]', 'top' ); } add_action( 'init...
287,216
<p>The description for <code>register_uninstall_hook</code>'s <code>$callback</code> parameter states:</p> <blockquote> <p>Must be a static method or function.<sup><a href="https://github.com/WordPress/WordPress/blob/05d60f74edf749467e8441c31c33c7fdbbd41e1d/wp-includes/plugin.php#L805-L806" rel="noreferrer">1</a></s...
[ { "answer_id": 340234, "author": "Lucas Vendramini", "author_id": 168637, "author_profile": "https://wordpress.stackexchange.com/users/168637", "pm_score": 2, "selected": false, "text": "<p>Depends the way you want to implement it. The static is used because you don't have to instantiate...
2017/11/29
[ "https://wordpress.stackexchange.com/questions/287216", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59643/" ]
The description for `register_uninstall_hook`'s `$callback` parameter states: > > Must be a static method or function.[1](https://github.com/WordPress/WordPress/blob/05d60f74edf749467e8441c31c33c7fdbbd41e1d/wp-includes/plugin.php#L805-L806) > > > There is no such comment for `register_activation_hook` or `registe...
Depends the way you want to implement it. The static is used because you don't have to instantiate the class to use the functions of the class. It's up to you. I generally would do: ``` <?php /*it's good practice that every class has its own file. So put it in for example 'classes/class-hooks.php' and require it prop...
287,255
<p>How do I display a rating at all times, even if it is empty? This is for woocommerce, meant for product boxes like popular products and new products, doesn't have to show up on single product pages.</p>
[ { "answer_id": 320620, "author": "Fatema Tuz Zuhora", "author_id": 155001, "author_profile": "https://wordpress.stackexchange.com/users/155001", "pm_score": 1, "selected": false, "text": "<p>Add the following code to your functions.php</p>\n\n<pre><code>add_action('woocommerce_after_shop...
2017/11/29
[ "https://wordpress.stackexchange.com/questions/287255", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132231/" ]
How do I display a rating at all times, even if it is empty? This is for woocommerce, meant for product boxes like popular products and new products, doesn't have to show up on single product pages.
Add the following code to your functions.php ``` add_action('woocommerce_after_shop_loop_item_title','change_loop_ratings_location', 2 ); function change_loop_ratings_location(){ remove_action('woocommerce_after_shop_loop_item_title','woocommerce_template_loop_rating', 5 ); add_action('woocommerce_after_shop_loop_item...
287,281
<p>I have worked four hours on this but with no result. There is a custom taxonomy and I need to display the image of the child category but displays the image of parent category.</p> <p>My code is:</p> <pre><code>&lt;?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $queried...
[ { "answer_id": 287286, "author": "Narek Zakarian", "author_id": 92573, "author_profile": "https://wordpress.stackexchange.com/users/92573", "pm_score": -1, "selected": false, "text": "<p>Instead of <code>$term_id</code>, you have to use <code>$termchildren</code> id and put it in foreach...
2017/11/29
[ "https://wordpress.stackexchange.com/questions/287281", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132336/" ]
I have worked four hours on this but with no result. There is a custom taxonomy and I need to display the image of the child category but displays the image of parent category. My code is: ``` <?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $queried_object = get_queried_ob...
Haven't tested it, but this should do it. ``` <?php $term = get_term_by( 'slug', get_query_var( 'term' ), get_query_var( 'taxonomy' ) ); $queried_object = get_queried_object(); $term_id = get_queried_object() -> term_id; $taxonomyName = "product-categories"; $termchildren = get_term_children( $term_id, $taxonomyN...
287,284
<p>Is there a way to make it so Everyone can see comments, But only the post author or those belonging to the Premium role can post a comment? </p> <p>Could I do something like </p> <pre><code> global $current_user; get_currentuserinfo(); if (is_user_logged_in() &amp;&amp; $current_user-&gt;ID...
[ { "answer_id": 287287, "author": "Daniel Fonda", "author_id": 132335, "author_profile": "https://wordpress.stackexchange.com/users/132335", "pm_score": 1, "selected": false, "text": "<p>Good news, bad news..</p>\n\n<p><strong>Good news</strong>\nThe logic behind it is really simple. You ...
2017/11/29
[ "https://wordpress.stackexchange.com/questions/287284", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/129681/" ]
Is there a way to make it so Everyone can see comments, But only the post author or those belonging to the Premium role can post a comment? Could I do something like ``` global $current_user; get_currentuserinfo(); if (is_user_logged_in() && $current_user->ID == $post->post_author) { comm...
Good news, bad news.. **Good news** The logic behind it is really simple. You basically wrap the form inside of a simple if statement. ``` if(condition){ /*Your form here*/ } else {echo '<h4>You need to be a premium account to post comments</h4>';} ``` **Bad News** You'll need to code in another...
287,292
<p>I'm currently working on an Estate Agency website. Built the custom post type and some custom taxonomies.</p> <p>I need to build a custom search where a user can select options from the custom taxonomies to display the search results.</p> <p>Example: Search by location &amp; min-max price &amp; number of bedrooms....
[ { "answer_id": 287287, "author": "Daniel Fonda", "author_id": 132335, "author_profile": "https://wordpress.stackexchange.com/users/132335", "pm_score": 1, "selected": false, "text": "<p>Good news, bad news..</p>\n\n<p><strong>Good news</strong>\nThe logic behind it is really simple. You ...
2017/11/29
[ "https://wordpress.stackexchange.com/questions/287292", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82343/" ]
I'm currently working on an Estate Agency website. Built the custom post type and some custom taxonomies. I need to build a custom search where a user can select options from the custom taxonomies to display the search results. Example: Search by location & min-max price & number of bedrooms. I tried a couple of plu...
Good news, bad news.. **Good news** The logic behind it is really simple. You basically wrap the form inside of a simple if statement. ``` if(condition){ /*Your form here*/ } else {echo '<h4>You need to be a premium account to post comments</h4>';} ``` **Bad News** You'll need to code in another...
287,306
<p>This is probably an easy question but I'm having so much trouble figuring it out on my own.</p> <p>I installed Storefront (the official Woocommerce theme) on a test server and I like it a lot, but the default front page (called Welcome) does not have a sidebar, which is a deal-breaker for me. I've been trying to ad...
[ { "answer_id": 287313, "author": "Daniel Fonda", "author_id": 132335, "author_profile": "https://wordpress.stackexchange.com/users/132335", "pm_score": 1, "selected": false, "text": "<p>I think there's an option to include it via the customizer (appearance->themes->customize)</p>\n\n<p>I...
2017/11/29
[ "https://wordpress.stackexchange.com/questions/287306", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132349/" ]
This is probably an easy question but I'm having so much trouble figuring it out on my own. I installed Storefront (the official Woocommerce theme) on a test server and I like it a lot, but the default front page (called Welcome) does not have a sidebar, which is a deal-breaker for me. I've been trying to add one with...
I think there's an option to include it via the customizer (appearance->themes->customize) If not, then you might need to open up content-homepage.php and put ``` <?php get_sidebar(); ?> ``` Where you want to display the sidebar.
287,320
<p>I have an ACF custom field that depends on the value I need to change the page title, however, I cannot affect the page title, it appears my code is running after the page title is generated.</p> <p>To explain my requirements. This is a real estate site where some listings are confidential, they flag it as such in ...
[ { "answer_id": 287329, "author": "Elyes At.", "author_id": 117786, "author_profile": "https://wordpress.stackexchange.com/users/117786", "pm_score": 1, "selected": false, "text": "<p>In order to change the title, you need to use <code>the_title</code> filter, also if you want to determin...
2017/11/29
[ "https://wordpress.stackexchange.com/questions/287320", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/91132/" ]
I have an ACF custom field that depends on the value I need to change the page title, however, I cannot affect the page title, it appears my code is running after the page title is generated. To explain my requirements. This is a real estate site where some listings are confidential, they flag it as such in the admin,...
If you refer to the post title you need to hook your function to the\_title filter like explained in the [codex](https://codex.wordpress.org/Plugin_API/Filter_Reference/the_title). ``` add_filter('the_title', 'my_custom_title', 10, 2); ``` If you refer to the HTML meta in your page then you need to hook your functio...
287,347
<p>I'm having some trouble creating a shortcode that queries some posts. This is the basics of my code:</p> <pre><code>function shortcode_equipment($atts, $content = null) { $equipment = get_page_by_title($content, OBJECT, 'equipment'); $loop = new WP_Query( array( 'posts_per_page' =&gt; 1, 'post_type...
[ { "answer_id": 287350, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 1, "selected": false, "text": "<p>There's most likely an escaping issue happening there. Try to escape the title before passing it to your sh...
2017/11/30
[ "https://wordpress.stackexchange.com/questions/287347", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132377/" ]
I'm having some trouble creating a shortcode that queries some posts. This is the basics of my code: ``` function shortcode_equipment($atts, $content = null) { $equipment = get_page_by_title($content, OBJECT, 'equipment'); $loop = new WP_Query( array( 'posts_per_page' => 1, 'post_type' => 'equ...
Title `Hello world!@#$%^*(),.;:\` will work but any title you enter containing `' " < > &` characters won't work because in `$content` variable you have escaped [HTML entities](http://php.net/manual/pl/function.htmlentities.php) so Mal's Post becomes `Mal&#8217;s Post`. To bypass it you can use [`sanitize_title`](http...
287,363
<p>Currently I am using a very standard loop, and wondering how can I make it to display something like this "<strong>Latest Posts (4 today)</strong>" which will update with the amount of posts from that specific category which are published per day.</p> <pre><code>&lt;ul&gt; &lt;?php if ( have_posts() ) : while ( hav...
[ { "answer_id": 287364, "author": "dipak_pusti", "author_id": 44528, "author_profile": "https://wordpress.stackexchange.com/users/44528", "pm_score": -1, "selected": false, "text": "<p>You can use <code>date_query</code> to get your posts from today,</p>\n\n<ol>\n<li><p><code>pre_get_post...
2017/11/30
[ "https://wordpress.stackexchange.com/questions/287363", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/124290/" ]
Currently I am using a very standard loop, and wondering how can I make it to display something like this "**Latest Posts (4 today)**" which will update with the amount of posts from that specific category which are published per day. ``` <ul> <?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?> <li> <a...
I think I have figured out the most efficient way to do this. The tricky part is that you need the query for posts within the date range to: A. Match the current query. If you're looking at a category or tag, you want to get the posts from that day in that category or tag. B. Not be limited by the current posts-per-p...
287,372
<p>I have a wordpress website, where i am providing customers with user name and password to access my shop.</p> <p>When a customer logs in, he can see the top wordpress admin bar as well. I dont want users added as "customers" through users>add new to see that bar. </p> <p>How should i disable this? </p>
[ { "answer_id": 287364, "author": "dipak_pusti", "author_id": 44528, "author_profile": "https://wordpress.stackexchange.com/users/44528", "pm_score": -1, "selected": false, "text": "<p>You can use <code>date_query</code> to get your posts from today,</p>\n\n<ol>\n<li><p><code>pre_get_post...
2017/11/30
[ "https://wordpress.stackexchange.com/questions/287372", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132310/" ]
I have a wordpress website, where i am providing customers with user name and password to access my shop. When a customer logs in, he can see the top wordpress admin bar as well. I dont want users added as "customers" through users>add new to see that bar. How should i disable this?
I think I have figured out the most efficient way to do this. The tricky part is that you need the query for posts within the date range to: A. Match the current query. If you're looking at a category or tag, you want to get the posts from that day in that category or tag. B. Not be limited by the current posts-per-p...
287,377
<p>I would like to create a blogroll page with a table where the links would be in the left table division and the description in the right division. So far, everything works... </p> <p>Where it becomes tricky is that I would like a table for each link category. Unfortunately, the sql table links doesn't have a column...
[ { "answer_id": 287567, "author": "Chris", "author_id": 132409, "author_profile": "https://wordpress.stackexchange.com/users/132409", "pm_score": 0, "selected": false, "text": "<p>I've found a way to output the blogroll links in a table with the categories as title, without using a custom...
2017/11/30
[ "https://wordpress.stackexchange.com/questions/287377", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132409/" ]
I would like to create a blogroll page with a table where the links would be in the left table division and the description in the right division. So far, everything works... Where it becomes tricky is that I would like a table for each link category. Unfortunately, the sql table links doesn't have a column link\_cat...
As suggested, here is the "arrayed" version: ``` $args = array( 'categorize' => 1, 'category_before' => '', 'category_after' => '</table>', 'title_before' => '<h3>', 'title_after' => '</h3><table><tr><th>Link</th><th>Description</th><tr>', 'orderby' => 'name', 'order' => 'ASC', ...
287,422
<p>I have installed <a href="https://www.advancedcustomfields.com/" rel="nofollow noreferrer">Advanced Custom Fielts</a>, and I have created custom fields such as email, phone etc. I put those in my footer.php, and the data is displayed only on the homepage. Can I use ACF to create global variables? My rule for that cu...
[ { "answer_id": 287426, "author": "Narek Zakarian", "author_id": 92573, "author_profile": "https://wordpress.stackexchange.com/users/92573", "pm_score": 3, "selected": true, "text": "<p>You Need to use <a href=\"https://wordpress.org/plugins/acf-option-pages/\" rel=\"nofollow noreferrer\"...
2017/11/30
[ "https://wordpress.stackexchange.com/questions/287422", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/131267/" ]
I have installed [Advanced Custom Fielts](https://www.advancedcustomfields.com/), and I have created custom fields such as email, phone etc. I put those in my footer.php, and the data is displayed only on the homepage. Can I use ACF to create global variables? My rule for that custom field is `'If Post Type is equal to...
You Need to use [ACF Options Page](https://wordpress.org/plugins/acf-option-pages/) plugin as well. ***This Plugin has been deleted from the repository. Now you can use the function without the plugin.*** The options page feature provides a set of functions to add extra admin pages and all data saved on an options pa...
287,451
<p>I'm working on my first WooCommerce site for an e-commerce shop I'll be launching hopefully in January (I should say that I've been working with Wordpress since the very beginning, so I'm not new to WP or PHP development) but I'm struggling with how to setup a good development/production environment.</p> <p>I've be...
[ { "answer_id": 287426, "author": "Narek Zakarian", "author_id": 92573, "author_profile": "https://wordpress.stackexchange.com/users/92573", "pm_score": 3, "selected": true, "text": "<p>You Need to use <a href=\"https://wordpress.org/plugins/acf-option-pages/\" rel=\"nofollow noreferrer\"...
2017/11/30
[ "https://wordpress.stackexchange.com/questions/287451", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6751/" ]
I'm working on my first WooCommerce site for an e-commerce shop I'll be launching hopefully in January (I should say that I've been working with Wordpress since the very beginning, so I'm not new to WP or PHP development) but I'm struggling with how to setup a good development/production environment. I've been searchi...
You Need to use [ACF Options Page](https://wordpress.org/plugins/acf-option-pages/) plugin as well. ***This Plugin has been deleted from the repository. Now you can use the function without the plugin.*** The options page feature provides a set of functions to add extra admin pages and all data saved on an options pa...
287,476
<p>I created a new page for the homepage settings of my theme using <code>add_pages_page()</code>. On that page I want to use <a href="https://codex.wordpress.org/Javascript_Reference/wp.media" rel="nofollow noreferrer">wp.media</a> to let the user select one or several images from the library (or upload new ones). I t...
[ { "answer_id": 287426, "author": "Narek Zakarian", "author_id": 92573, "author_profile": "https://wordpress.stackexchange.com/users/92573", "pm_score": 3, "selected": true, "text": "<p>You Need to use <a href=\"https://wordpress.org/plugins/acf-option-pages/\" rel=\"nofollow noreferrer\"...
2017/12/01
[ "https://wordpress.stackexchange.com/questions/287476", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60539/" ]
I created a new page for the homepage settings of my theme using `add_pages_page()`. On that page I want to use [wp.media](https://codex.wordpress.org/Javascript_Reference/wp.media) to let the user select one or several images from the library (or upload new ones). I thought the way to go was meta boxes but I can't get...
You Need to use [ACF Options Page](https://wordpress.org/plugins/acf-option-pages/) plugin as well. ***This Plugin has been deleted from the repository. Now you can use the function without the plugin.*** The options page feature provides a set of functions to add extra admin pages and all data saved on an options pa...
287,485
<p>I want to let users put there username in Arabic when they register a new account, I tried a lot of methods put problem still unsolved</p>
[ { "answer_id": 287426, "author": "Narek Zakarian", "author_id": 92573, "author_profile": "https://wordpress.stackexchange.com/users/92573", "pm_score": 3, "selected": true, "text": "<p>You Need to use <a href=\"https://wordpress.org/plugins/acf-option-pages/\" rel=\"nofollow noreferrer\"...
2017/12/01
[ "https://wordpress.stackexchange.com/questions/287485", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132475/" ]
I want to let users put there username in Arabic when they register a new account, I tried a lot of methods put problem still unsolved
You Need to use [ACF Options Page](https://wordpress.org/plugins/acf-option-pages/) plugin as well. ***This Plugin has been deleted from the repository. Now you can use the function without the plugin.*** The options page feature provides a set of functions to add extra admin pages and all data saved on an options pa...
287,488
<p>I am wondering if I could change the size of one specific catalog product image. </p> <p>I have many products with the same size (catalog images-not single product images, not even product thumbnails) and I want to change the size of a specific product, in order to be smaller than the other catalog images. </p> <p...
[ { "answer_id": 287489, "author": "Daniel Fonda", "author_id": 132335, "author_profile": "https://wordpress.stackexchange.com/users/132335", "pm_score": 0, "selected": false, "text": "<p>Without going into too much detail..</p>\n\n<pre><code>global $product;\n\nif($product-&gt;ID == '21')...
2017/12/01
[ "https://wordpress.stackexchange.com/questions/287488", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132478/" ]
I am wondering if I could change the size of one specific catalog product image. I have many products with the same size (catalog images-not single product images, not even product thumbnails) and I want to change the size of a specific product, in order to be smaller than the other catalog images. How can I do tha...
You can use the `single_product_archive_thumbnail_size` filter to change which image size is used for a particular product: ``` function wpse_287488_product_thumbnail_size( $size ) { global $product; if ( $product->get_id() === 123 ) { $size = 'medium'; } return $size; } add_filter( 'single_p...
287,503
<p>I have spent hours researching how to do this but everything I found explains it in a way that goes over my head. I'm not great with coding but I know how to Inspect element and work from there but that doesn't help me in this case.</p> <p>I want to use a different page layout/template on products in a specified ca...
[ { "answer_id": 287506, "author": "Daniel Fonda", "author_id": 132335, "author_profile": "https://wordpress.stackexchange.com/users/132335", "pm_score": 0, "selected": false, "text": "<p>Add this to your funtions.php\n<a href=\"https://gist.github.com/thegdshop/3197540\" rel=\"nofollow no...
2017/12/01
[ "https://wordpress.stackexchange.com/questions/287503", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132485/" ]
I have spent hours researching how to do this but everything I found explains it in a way that goes over my head. I'm not great with coding but I know how to Inspect element and work from there but that doesn't help me in this case. I want to use a different page layout/template on products in a specified category. I ...
Here's my solution... Added the following to `functions.php` in my child theme: ``` add_filter( 'body_class','my_body_classes2' ); function my_body_classes2( $classes ) { if ( is_product() ) { global $post; $terms = get_the_terms( $post->ID, 'product_cat' ); foreach ($terms as $term) { $product_...
287,522
<p>I just can’t understand how add_image_size() and responsive images work. </p> <p>So let’s say I have a thumbnail like <code>720×360</code>. </p> <p>So I’m assuming I need to add the size <code>add_image_size('post-thumbnail', 720, 320, true) //hard crop</code></p> <p>I upload image with the dimensions of 3000×200...
[ { "answer_id": 287523, "author": "Daniel Fonda", "author_id": 132335, "author_profile": "https://wordpress.stackexchange.com/users/132335", "pm_score": 1, "selected": false, "text": "<pre><code>function adjust_image_sizes_attr( $sizes, $size ) {\n $sizes = '(max-width: 709px) 85vw, (ma...
2017/12/01
[ "https://wordpress.stackexchange.com/questions/287522", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/121208/" ]
I just can’t understand how add\_image\_size() and responsive images work. So let’s say I have a thumbnail like `720×360`. So I’m assuming I need to add the size `add_image_size('post-thumbnail', 720, 320, true) //hard crop` I upload image with the dimensions of 3000×2000 to accommodate for retina screens, etc. ...
If you add the code after you have uploaded images onto pages you will also need to regenerate the images with a plugin like Regenerate Thumbnails by Alex Mills (Viper007Bond). <https://wordpress.org/plugins/regenerate-thumbnails/> I was trying to do the same thing and found many pages that offered code that didn't wo...
287,532
<p>I have a fresh Wordpress installation that works fine. I decide to make it work under HTTPS so I go in the General config and change the "Wordpress Address" and the "Site Adress" from <a href="http://my.website.com/blog/" rel="noreferrer">http://my.website.com/blog/</a> to <a href="https://my.website.com/blog/" rel=...
[ { "answer_id": 287539, "author": "David Sword", "author_id": 132362, "author_profile": "https://wordpress.stackexchange.com/users/132362", "pm_score": 2, "selected": false, "text": "<p>After changing the \"Wordpress Address\" and the \"Site Adress\" to <code>https</code>, and keeping <co...
2017/12/01
[ "https://wordpress.stackexchange.com/questions/287532", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132511/" ]
I have a fresh Wordpress installation that works fine. I decide to make it work under HTTPS so I go in the General config and change the "Wordpress Address" and the "Site Adress" from <http://my.website.com/blog/> to <https://my.website.com/blog/>. First, this create a redirection loop so I have to add the following l...
Just a quick note, the code ``` define('FORCE_SSL_ADMIN', true); if ($_SERVER['HTTP_X_FORWARDED_PROTO'] == 'https') $_SERVER['HTTPS']='on'; ``` need to be at the top of the config file just after the `<php` or it will not work.
287,547
<p>I want to import a style only on specific site types (articles (single.php), categories (category.php) and 404 page (404.php)). I tried to use is_page() but I don't know if it works for different site types. Thank you for your help.</p> <p><strong>Update</strong> this is what I tried</p> <pre><code>wp_register_sty...
[ { "answer_id": 287548, "author": "David Sword", "author_id": 132362, "author_profile": "https://wordpress.stackexchange.com/users/132362", "pm_score": 1, "selected": false, "text": "<p><code>is_tax()</code> and <code>is_404()</code> perhaps?</p>\n\n<p><a href=\"https://codex.wordpress.or...
2017/12/01
[ "https://wordpress.stackexchange.com/questions/287547", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132533/" ]
I want to import a style only on specific site types (articles (single.php), categories (category.php) and 404 page (404.php)). I tried to use is\_page() but I don't know if it works for different site types. Thank you for your help. **Update** this is what I tried ``` wp_register_style('style-narrow', '/wp-content/t...
`is_tax()` and `is_404()` perhaps? <https://codex.wordpress.org/Conditional_Tags> --- **UPDATE:** I'm sorry my original answer was vague, to elaborate better: You can add conditional tags in a `wp_enqueue_scripts` hook, choosing to register and enqueue when criteria is met, like so: ``` add_action( 'wp_enqueue_sc...
287,549
<p>I have Set Up a Remote Database to Optimize wordpress Site Performance with MySQL on Ubuntu 16.04. I downloaded the wordpress onto my web server. When I Navigate to the public IP address associated with my web server, i get "Error establishing a database connection". </p> <p>With wordpressdebug mode set to true, th...
[ { "answer_id": 287566, "author": "Terungwa", "author_id": 96667, "author_profile": "https://wordpress.stackexchange.com/users/96667", "pm_score": 0, "selected": false, "text": "<p>adding this function below to my wp-config.php solved the problem:\ndefine('DB_SSL', true);</p>\n\n<p><stron...
2017/12/01
[ "https://wordpress.stackexchange.com/questions/287549", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/96667/" ]
I have Set Up a Remote Database to Optimize wordpress Site Performance with MySQL on Ubuntu 16.04. I downloaded the wordpress onto my web server. When I Navigate to the public IP address associated with my web server, i get "Error establishing a database connection". With wordpressdebug mode set to true, the details ...
The quickest fix would be to go to `sudo vim /etc/mysql/mysql.conf.d/mysqld.cnf` and remove the: `"requiresecuretransport = on"` Then restart via: `sudo systemctl restart mysql`
287,556
<p>I have a subdirectory Wordpress network with >50 sites, it's on a primary domain of <code>wordpress.example.com</code>.</p> <p>A client, <em>johndoe</em>, within my network will (intentionally) have a back-end that includes the main site (for branding and ownership reasons):</p> <p><code>wordpress.example.com/john...
[ { "answer_id": 289248, "author": "Serkan Algur", "author_id": 23042, "author_profile": "https://wordpress.stackexchange.com/users/23042", "pm_score": 0, "selected": false, "text": "<p>Could you check this definitions on your <code>wp-config.php</code> file?</p>\n\n<pre><code>define('ADMI...
2017/12/01
[ "https://wordpress.stackexchange.com/questions/287556", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132362/" ]
I have a subdirectory Wordpress network with >50 sites, it's on a primary domain of `wordpress.example.com`. A client, *johndoe*, within my network will (intentionally) have a back-end that includes the main site (for branding and ownership reasons): `wordpress.example.com/johndoe/wp-admin/` then via domain mapping ...
WordPress is deciding whether you are logged in or not by checking `AUTH_COOKIE` and `LOGGED_IN_COOKIE`. As you have noticed these cookies are set in the same, let,s say, `A` domain which your site is. Adding the same cookies to your second `B` domain would make your user logged in in two `A` and `B` domains. Of course...
287,598
<p>I think i may be getting a little confused, but I have a list and a select button on each line. When the user clicks the button a modal shows up and I am trying to simple get an image (with a post_id) to display.</p> <p>So in PHP I have this:</p> <pre><code>&lt;img id="changeImage"src=" &lt;?php echo $v[0]-&...
[ { "answer_id": 288000, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>As per my understanding I can suggest you that you can probaly use something like font-awesome. This will help yo...
2017/12/02
[ "https://wordpress.stackexchange.com/questions/287598", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/131139/" ]
I think i may be getting a little confused, but I have a list and a select button on each line. When the user clicks the button a modal shows up and I am trying to simple get an image (with a post\_id) to display. So in PHP I have this: ``` <img id="changeImage"src=" <?php echo $v[0]->user_image_id ? wp...
You can add filter for `widget_title` hook. Or change the `$instance['title']` on update.
287,658
<p>I'm having a difficult time trying to update the <code>flamingo_inbound</code> post author after insert.</p> <p>Basically, I have a hidden field in <code>CTF7</code> for the company name that is being sent over and correctly stored in the db. That field corresponds to a particular company page.</p> <p>Here's my co...
[ { "answer_id": 288000, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>As per my understanding I can suggest you that you can probaly use something like font-awesome. This will help yo...
2017/12/04
[ "https://wordpress.stackexchange.com/questions/287658", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132087/" ]
I'm having a difficult time trying to update the `flamingo_inbound` post author after insert. Basically, I have a hidden field in `CTF7` for the company name that is being sent over and correctly stored in the db. That field corresponds to a particular company page. Here's my code so far. ``` function my_update...
You can add filter for `widget_title` hook. Or change the `$instance['title']` on update.
287,662
<p>I see the following string when I print my prepared query:</p> <pre><code>"SELECT p.ID, COALESCE(w.value,Display_name) value, p.post_title, p.post_date, p.post_content,p.post_author,user_login FROM wp_posts p INNER JOIN wp_users a ON a.ID = p.post_author LEFT JOIN wp_bp_xprofile_data w ON w.user_id = a.ID WHERE pos...
[ { "answer_id": 287667, "author": "janh", "author_id": 129206, "author_profile": "https://wordpress.stackexchange.com/users/129206", "pm_score": 1, "selected": false, "text": "<p>Don't put single quotes around placeholders, they are added automatically. Turn '%s' into just %s.</p>\n" },...
2017/12/04
[ "https://wordpress.stackexchange.com/questions/287662", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132641/" ]
I see the following string when I print my prepared query: ``` "SELECT p.ID, COALESCE(w.value,Display_name) value, p.post_title, p.post_date, p.post_content,p.post_author,user_login FROM wp_posts p INNER JOIN wp_users a ON a.ID = p.post_author LEFT JOIN wp_bp_xprofile_data w ON w.user_id = a.ID WHERE post_type = 'repl...
There are view issues with the query: * First what the @janh wrote. * Second why you removing the am/pm when you could easily use the `date("Y-m-d H:i:s");` * Third, there is this little helper for the database table prefixes `$wpdb->prefix` * Users table the column name is `display_name` * Also when you make aliases ...
287,665
<p>my initial <code>functions.php</code> is looks like this</p> <pre><code>&lt;?php /** * SKT Charity functions and definitions * * @package SKT Charity */ global $content_width; if ( ! isset( $content_width ) ) $content_width = 640; /* pixels */ // Set the word limit of post content function skt_charity_con...
[ { "answer_id": 287672, "author": "kierzniak", "author_id": 132363, "author_profile": "https://wordpress.stackexchange.com/users/132363", "pm_score": 0, "selected": false, "text": "<p>@inarolo has right. Your code should be looking like that:</p>\n\n<pre><code>function wpse_287665_mobile_...
2017/12/04
[ "https://wordpress.stackexchange.com/questions/287665", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132645/" ]
my initial `functions.php` is looks like this ``` <?php /** * SKT Charity functions and definitions * * @package SKT Charity */ global $content_width; if ( ! isset( $content_width ) ) $content_width = 640; /* pixels */ // Set the word limit of post content function skt_charity_content($limit) { $content = ex...
The answer by @motivast is correct. However, to avoid using a billion `echo` and apostrophes, you can simply close the PHP tag and open it after your script: ``` function wpse_287665_mobile_menu_script() { ?> <script> jQuery(document).ready(function($){ $("button.menu-toggle").click(function()...
287,677
<p>I'm using a WordPress REST API to get contents of a page. The URL I'm using is:</p> <blockquote> <p><a href="https://sitename.org/wp-json/wp/v2/pages/4322" rel="nofollow noreferrer">https://sitename.org/wp-json/wp/v2/pages/4322</a></p> </blockquote> <p>When I open that URL in browser, I'm getting back valid resp...
[ { "answer_id": 287683, "author": "Drupalizeme", "author_id": 115005, "author_profile": "https://wordpress.stackexchange.com/users/115005", "pm_score": 0, "selected": false, "text": "<p>You can use the following code and should work, if not we should see the server configuration to see wh...
2017/12/04
[ "https://wordpress.stackexchange.com/questions/287677", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132653/" ]
I'm using a WordPress REST API to get contents of a page. The URL I'm using is: > > <https://sitename.org/wp-json/wp/v2/pages/4322> > > > When I open that URL in browser, I'm getting back valid response. But when I try to use that same URL via cURL, I'm getting: > > couldn't connect to host > > > The code...
It seem I am very late for this question, but I post my experience to here anyway, and hope it can help anyone with similar experience, since it is so hard to google an answer for this kind of rare situation. I have a very similar problem. I tested thru Browser and AJAX, they are OK, but I got connection timed out whe...
287,678
<p>Is there a way to count the amount of posts in a CPT and add a different class to 1/3 of said posts? </p> <p>I am using Masonry for a grid and want two different image sizes displayed randomly. I got all that working but the images aren't aligning perfectly which is why the grid looks off (with gaps in between). I ...
[ { "answer_id": 287683, "author": "Drupalizeme", "author_id": 115005, "author_profile": "https://wordpress.stackexchange.com/users/115005", "pm_score": 0, "selected": false, "text": "<p>You can use the following code and should work, if not we should see the server configuration to see wh...
2017/12/04
[ "https://wordpress.stackexchange.com/questions/287678", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132652/" ]
Is there a way to count the amount of posts in a CPT and add a different class to 1/3 of said posts? I am using Masonry for a grid and want two different image sizes displayed randomly. I got all that working but the images aren't aligning perfectly which is why the grid looks off (with gaps in between). I figured if...
It seem I am very late for this question, but I post my experience to here anyway, and hope it can help anyone with similar experience, since it is so hard to google an answer for this kind of rare situation. I have a very similar problem. I tested thru Browser and AJAX, they are OK, but I got connection timed out whe...
287,763
<p>I am using <code>wp_mail()</code> function to send email to user in WordPress. I want to hide sender name like I want to mask sender email as <code>noreply@gmail.com</code> etc.</p> <p>Any help will be appreciated.</p>
[ { "answer_id": 287764, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 1, "selected": true, "text": "<p>See <a href=\"https://developer.wordpress.org/reference/functions/wp_mail/#using-headers-to-set-from-cc-...
2017/12/05
[ "https://wordpress.stackexchange.com/questions/287763", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132725/" ]
I am using `wp_mail()` function to send email to user in WordPress. I want to hide sender name like I want to mask sender email as `noreply@gmail.com` etc. Any help will be appreciated.
See [the documentation](https://developer.wordpress.org/reference/functions/wp_mail/#using-headers-to-set-from-cc-and-bcc-parameters): > > To set the “From:” email address to something other than the WordPress > default sender, or to add “Cc:” and/or “Bcc:” recipients, you must use > the $headers argument. > > > ...
287,830
<pre><code>Warning: The type attribute is unnecessary for JavaScript resources. From line 10, column 146; to line 10, column 176 feed/&quot; /&gt; &lt;script type=&quot;text/javascript&quot;&gt;window Warning: The type attribute for the style element is not needed and should be omitted. From line 11, c...
[ { "answer_id": 287833, "author": "David Sword", "author_id": 132362, "author_profile": "https://wordpress.stackexchange.com/users/132362", "pm_score": 4, "selected": false, "text": "<p>You can remove the <code>type='*'</code> attributes and values from <code>wp_enqueue</code>'ed scripts ...
2017/12/05
[ "https://wordpress.stackexchange.com/questions/287830", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105791/" ]
``` Warning: The type attribute is unnecessary for JavaScript resources. From line 10, column 146; to line 10, column 176 feed/" /> <script type="text/javascript">window Warning: The type attribute for the style element is not needed and should be omitted. From line 11, column 1798; to line 11, column 182...
WordPress 5.3 introduces a considerably simpler way to achieve this. By registering theme support for HTML 5 for `script` and `style`, the `type=""` attribute will be omitted: ``` add_action( 'after_setup_theme', function() { add_theme_support( 'html5', [ 'script', 'style' ] ); } ); ```
287,857
<p>I am not asking you to write the all code or asking a plugin, I am asking a way to build this feature because I don't have any plan in my mind to build this feature.</p> <p>This is the requirement : There are many posts on the website. Logged Users (Front-end users) should have a feature to save list of posts.</p> ...
[ { "answer_id": 287877, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 2, "selected": false, "text": "<p>I'd suggest using using custom tables to keep things lean.</p>\n\n<p>Have two tables: A table of lists ...
2017/12/06
[ "https://wordpress.stackexchange.com/questions/287857", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/123092/" ]
I am not asking you to write the all code or asking a plugin, I am asking a way to build this feature because I don't have any plan in my mind to build this feature. This is the requirement : There are many posts on the website. Logged Users (Front-end users) should have a feature to save list of posts. Ex : * List...
I'd suggest using using custom tables to keep things lean. Have two tables: A table of lists and a table of posts and which lists they belong to. The lists table (let's call it `wp_lists`) would look like: ``` +----+---------+----------------+ | id | user_id | name | +----+---------+----------------+ | 1...
287,858
<p>everytime I analyze free wordpress.org theme, I am not able to find how the css file is linked in the theme. as far as i learned css file should be linked in <code>header.php</code> using link tag. but everytime I check themes I didn't see any code in which they link their css through link tag. check example of this...
[ { "answer_id": 287877, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 2, "selected": false, "text": "<p>I'd suggest using using custom tables to keep things lean.</p>\n\n<p>Have two tables: A table of lists ...
2017/12/06
[ "https://wordpress.stackexchange.com/questions/287858", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/130750/" ]
everytime I analyze free wordpress.org theme, I am not able to find how the css file is linked in the theme. as far as i learned css file should be linked in `header.php` using link tag. but everytime I check themes I didn't see any code in which they link their css through link tag. check example of this theme `header...
I'd suggest using using custom tables to keep things lean. Have two tables: A table of lists and a table of posts and which lists they belong to. The lists table (let's call it `wp_lists`) would look like: ``` +----+---------+----------------+ | id | user_id | name | +----+---------+----------------+ | 1...
287,863
<p>I've been trying to create my own slider for my blog posts recently but I cannot get it to work. I have tried different code online but none of them rotate my list items(These are created by the post loop). Below is code I tried from <a href="https://www.w3schools.com/w3css/tryit.asp?filename=tryw3css_slideshow_rr" ...
[ { "answer_id": 287877, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 2, "selected": false, "text": "<p>I'd suggest using using custom tables to keep things lean.</p>\n\n<p>Have two tables: A table of lists ...
2017/12/06
[ "https://wordpress.stackexchange.com/questions/287863", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/130103/" ]
I've been trying to create my own slider for my blog posts recently but I cannot get it to work. I have tried different code online but none of them rotate my list items(These are created by the post loop). Below is code I tried from [W3Schools](https://www.w3schools.com/w3css/tryit.asp?filename=tryw3css_slideshow_rr) ...
I'd suggest using using custom tables to keep things lean. Have two tables: A table of lists and a table of posts and which lists they belong to. The lists table (let's call it `wp_lists`) would look like: ``` +----+---------+----------------+ | id | user_id | name | +----+---------+----------------+ | 1...
287,884
<p>I wonder if you can help me track down why all my images are being cropped to a 300px size that I've not specified anywhere at all. I know from some digging in the past that WordPress introduced a default size of 768px and basically hid it from us, now I'm wondering if they (or WooCommerce - this is a WooCommerce si...
[ { "answer_id": 287877, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 2, "selected": false, "text": "<p>I'd suggest using using custom tables to keep things lean.</p>\n\n<p>Have two tables: A table of lists ...
2017/12/06
[ "https://wordpress.stackexchange.com/questions/287884", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119546/" ]
I wonder if you can help me track down why all my images are being cropped to a 300px size that I've not specified anywhere at all. I know from some digging in the past that WordPress introduced a default size of 768px and basically hid it from us, now I'm wondering if they (or WooCommerce - this is a WooCommerce site)...
I'd suggest using using custom tables to keep things lean. Have two tables: A table of lists and a table of posts and which lists they belong to. The lists table (let's call it `wp_lists`) would look like: ``` +----+---------+----------------+ | id | user_id | name | +----+---------+----------------+ | 1...
287,886
<p>I'm using the following code to select products with the following post_metas:</p> <p>_product_new, _product_almost_new, _product_old</p> <pre><code>add_action( 'woocommerce_product_query', 'custom_vtp_shop_order' ); function custom_vtp_shop_order($q){ if ( ! $q-&gt;is_main_query() ) return; if (! is_admi...
[ { "answer_id": 287895, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 3, "selected": true, "text": "<p>With <code>WP_Query</code> it's only possible to sort by a single meta value by setting the <code>meta_k...
2017/12/06
[ "https://wordpress.stackexchange.com/questions/287886", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/84924/" ]
I'm using the following code to select products with the following post\_metas: \_product\_new, \_product\_almost\_new, \_product\_old ``` add_action( 'woocommerce_product_query', 'custom_vtp_shop_order' ); function custom_vtp_shop_order($q){ if ( ! $q->is_main_query() ) return; if (! is_admin() && (is_shop(...
With `WP_Query` it's only possible to sort by a single meta value by setting the `meta_key` argument to which key you want to be able to sort by, and `orderby` to `meta_value` (or `meta_value_num` if the value is to be sorted numerically). This is what the arguments would look like: ``` $args = array( 'meta_key' ...
287,893
<p>I'm using Contact Form 7 with an ACF field.</p> <p>In ACF, I created an email field : <code>email</code>.</p> <p>In my Contact Form 7, I have a field called <code>destination-email</code>: <br/><code>[email* destination-email id:exp-email default:shortcode_attr]</code></p> <p>In my template file i have a line :</p> ...
[ { "answer_id": 288012, "author": "Wilco", "author_id": 102737, "author_profile": "https://wordpress.stackexchange.com/users/102737", "pm_score": 3, "selected": true, "text": "<p>You can use php values inside the do_shortcode function\nIn your case it will be like this:</p>\n\n<pre><code>...
2017/12/06
[ "https://wordpress.stackexchange.com/questions/287893", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132818/" ]
I'm using Contact Form 7 with an ACF field. In ACF, I created an email field : `email`. In my Contact Form 7, I have a field called `destination-email`: `[email* destination-email id:exp-email default:shortcode_attr]` In my template file i have a line : ```php <?php echo do_shortcode( '[contact-form-7 id="983" tit...
You can use php values inside the do\_shortcode function In your case it will be like this: ``` <?php echo do_shortcode( '[contact-form-7 id="983" title="Formulaire de contact 1" destination-email="'.get_field( 'email' ).'"]' ); ?> ```
287,909
<p>I am trying to customise my Wordpress homepage. </p> <p>I decided to get fullscreen image theme (TwoFold by Fuel Themes). As I am preparing photography portfolio website, graphic content is very important to me. However, I'd like to add some text below the image slider, ideally it would be a whole page below the ...
[ { "answer_id": 288012, "author": "Wilco", "author_id": 102737, "author_profile": "https://wordpress.stackexchange.com/users/102737", "pm_score": 3, "selected": true, "text": "<p>You can use php values inside the do_shortcode function\nIn your case it will be like this:</p>\n\n<pre><code>...
2017/12/06
[ "https://wordpress.stackexchange.com/questions/287909", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132829/" ]
I am trying to customise my Wordpress homepage. I decided to get fullscreen image theme (TwoFold by Fuel Themes). As I am preparing photography portfolio website, graphic content is very important to me. However, I'd like to add some text below the image slider, ideally it would be a whole page below the current ho...
You can use php values inside the do\_shortcode function In your case it will be like this: ``` <?php echo do_shortcode( '[contact-form-7 id="983" title="Formulaire de contact 1" destination-email="'.get_field( 'email' ).'"]' ); ?> ```
287,930
<p>I have 2 post types, one is for my posts and the other one is used as a submission form. </p> <p>When a user is on a single post page for post type A, I am trying to do several checks to then display content - </p> <p>1) I'm checking if the user is logged in</p> <p>2) if he has published any posts (submitted form...
[ { "answer_id": 287914, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 1, "selected": true, "text": "<p>There are several different forms of PayPal. It sounds like you are using PayPal Standard, which always ta...
2017/12/06
[ "https://wordpress.stackexchange.com/questions/287930", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24067/" ]
I have 2 post types, one is for my posts and the other one is used as a submission form. When a user is on a single post page for post type A, I am trying to do several checks to then display content - 1) I'm checking if the user is logged in 2) if he has published any posts (submitted forms) in post type B 3) I...
There are several different forms of PayPal. It sounds like you are using PayPal Standard, which always takes the visitor to PayPal's website to process the payment. There are a couple of different PayPal Pro type accounts where you can have the visitor fill out a single form, including their payment information *if* ...
287,931
<p>I'm trying to get the category <strong>name</strong> instead of the <strong>ID</strong> from the WP REST API for my Custom Post Type. Some articles about endpoint modification gave me some ideas on how to solve it, but unfortunately i'm not getting it to work. This is my Code (* removed irrelevant code at some lines...
[ { "answer_id": 287933, "author": "kierzniak", "author_id": 132363, "author_profile": "https://wordpress.stackexchange.com/users/132363", "pm_score": 3, "selected": false, "text": "<p>This code will add <code>categories_names</code> field to wp rest api response:</p>\n\n<pre><code>functio...
2017/12/06
[ "https://wordpress.stackexchange.com/questions/287931", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/79865/" ]
I'm trying to get the category **name** instead of the **ID** from the WP REST API for my Custom Post Type. Some articles about endpoint modification gave me some ideas on how to solve it, but unfortunately i'm not getting it to work. This is my Code (\* removed irrelevant code at some lines): **CUSTOM POST TYPE** ``...
This code will add `categories_names` field to wp rest api response: ``` function wpse_287931_register_categories_names_field() { register_rest_field( 'project', 'categories_names', array( 'get_callback' => 'wpse_287931_get_categories_names', 'update_callback' => null, ...
287,946
<p>I've got a frontend form with text, select and checkbox inputs the text and selects update and work just fine, using update_post_meta() however the checkboxes aren't updating. Since they're stored in a serialized array do I need to use a different function or just set it up differently?</p> <pre><code>update_post_m...
[ { "answer_id": 287948, "author": "rzepak", "author_id": 11897, "author_profile": "https://wordpress.stackexchange.com/users/11897", "pm_score": 0, "selected": false, "text": "<p>Shouldn't the name of the checkbox be name=\"customMetaAppliances[]\" ? That way you get an array of them in $...
2017/12/06
[ "https://wordpress.stackexchange.com/questions/287946", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51369/" ]
I've got a frontend form with text, select and checkbox inputs the text and selects update and work just fine, using update\_post\_meta() however the checkboxes aren't updating. Since they're stored in a serialized array do I need to use a different function or just set it up differently? ``` update_post_meta($post_id...
To be compatible with ACF you should first find out how ACF is saving checkboxes values to database. As I now this is serialized array. When we know that we must save our frontend checkboxes in the same way. The good news is you can pass only array to `update_post_meta` and WordPress will take care of serialization. ...
287,952
<p>What is the default wp-content/uploads directory permission? What chmod command do I need to set it correctly?</p>
[ { "answer_id": 287953, "author": "rudtek", "author_id": 77767, "author_profile": "https://wordpress.stackexchange.com/users/77767", "pm_score": 4, "selected": true, "text": "<p>You'll want directories to have 755 and files to have 644.\nyou can navigate to your www directory and use thes...
2017/12/06
[ "https://wordpress.stackexchange.com/questions/287952", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45709/" ]
What is the default wp-content/uploads directory permission? What chmod command do I need to set it correctly?
You'll want directories to have 755 and files to have 644. you can navigate to your www directory and use these 2 commands: ``` find . -type d -print0 | xargs -0 chmod 0755 # For directories ``` or ``` find . -type f -print0 | xargs -0 chmod 0644 # For files ``` (Obviously don't input the # or anything after it w...
287,973
<p>I tried different tests to make the home (a blog index, 3 latest posts) page use a different template than it's following generated paginated pages (blog.com/page/2). Essentially what I am trying to do is get my home page looking different with latest posts and the "Next Posts" links to the /page/2 with a different ...
[ { "answer_id": 287975, "author": "Taj Khan", "author_id": 128610, "author_profile": "https://wordpress.stackexchange.com/users/128610", "pm_score": -1, "selected": false, "text": "<p><a href=\"https://developer.wordpress.org/files/2014/10/wp-hierarchy.png\" rel=\"nofollow noreferrer\">ht...
2017/12/07
[ "https://wordpress.stackexchange.com/questions/287973", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132876/" ]
I tried different tests to make the home (a blog index, 3 latest posts) page use a different template than it's following generated paginated pages (blog.com/page/2). Essentially what I am trying to do is get my home page looking different with latest posts and the "Next Posts" links to the /page/2 with a different tem...
You can use this: ``` $paged = (get_query_var('paged')) ? get_query_var('paged') : 1; ``` `$paged` will have the value 1 in you are or the first page or the value of respective pagination page number. Depending on this you can call `get_template_part()` to load the desired template for the page. Let me know if thi...
287,981
<p>I know there is connection between post table with term table but I am unable to figure it out. </p> <p><code>wp_terms</code>, <code>wp_termmeta</code>, <code>wp_term_relationships</code> &amp; <code>wp_term_taxonomy</code> relation is a little confusing. So, I am unable to write a query to get term id from post id...
[ { "answer_id": 287983, "author": "HU is Sebastian", "author_id": 56587, "author_profile": "https://wordpress.stackexchange.com/users/56587", "pm_score": 2, "selected": false, "text": "<p>I'm not sure what you are trying to accomplish. </p>\n\n<p>It seems you are trying to get the terms a...
2017/12/07
[ "https://wordpress.stackexchange.com/questions/287981", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132878/" ]
I know there is connection between post table with term table but I am unable to figure it out. `wp_terms`, `wp_termmeta`, `wp_term_relationships` & `wp_term_taxonomy` relation is a little confusing. So, I am unable to write a query to get term id from post id. **Actual Problem:** I am using this piece of code to g...
It is not good practice to use query when you have already builtin functions but for your need. **Try this solution**: ``` global $wpdb; $meta = $wpdb->get_row( "SELECT * FROM `wp_postmeta` WHERE `meta_id` = $id" ); //will return same object like returned by get_metadata_by_mid() function print_r($meta); ``` **D...
287,988
<p>I usually use frameworks like Yii(2), Zend or Laravel to build pages but a customer forced us to use Wordpress this time.</p> <p>I integrated Symfony/Twig as my template engine but now I have trouble with localization/translation. Because no matter what I do my strings won't be translated or even found by Wordpress...
[ { "answer_id": 287997, "author": "kierzniak", "author_id": 132363, "author_profile": "https://wordpress.stackexchange.com/users/132363", "pm_score": 3, "selected": true, "text": "<p>I have my own implementation of twig in WordPress as plugin and my translations are working. You can check...
2017/12/07
[ "https://wordpress.stackexchange.com/questions/287988", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132884/" ]
I usually use frameworks like Yii(2), Zend or Laravel to build pages but a customer forced us to use Wordpress this time. I integrated Symfony/Twig as my template engine but now I have trouble with localization/translation. Because no matter what I do my strings won't be translated or even found by Wordpress. Like in...
I have my own implementation of twig in WordPress as plugin and my translations are working. You can check my code. Keep in mind couple of things when when you will test the code: * be sure that your WordPress have set `locale` which you want translate to * be sure that you your `mo` file is compiled from newest vers...
287,990
<p>My custom post type &amp; built in Wordpress blog posts SHARE the built in categories.</p> <p>I have a piece of code that loops through and shows all (built in) categories that have posts assigned to them on 'archive-work.php'</p> <p>I only want to show the categories that have CPT (work) posts assigned to them an...
[ { "answer_id": 287997, "author": "kierzniak", "author_id": 132363, "author_profile": "https://wordpress.stackexchange.com/users/132363", "pm_score": 3, "selected": true, "text": "<p>I have my own implementation of twig in WordPress as plugin and my translations are working. You can check...
2017/12/07
[ "https://wordpress.stackexchange.com/questions/287990", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14149/" ]
My custom post type & built in Wordpress blog posts SHARE the built in categories. I have a piece of code that loops through and shows all (built in) categories that have posts assigned to them on 'archive-work.php' I only want to show the categories that have CPT (work) posts assigned to them and NOT show any other ...
I have my own implementation of twig in WordPress as plugin and my translations are working. You can check my code. Keep in mind couple of things when when you will test the code: * be sure that your WordPress have set `locale` which you want translate to * be sure that you your `mo` file is compiled from newest vers...
287,994
<p>I have added this line in the nginx configuration file</p> <pre><code>try_files $uri $uri/ /index.php?$args; rewrite ^([^.]*[^/])$ $1/ permanent; #adding slash </code></pre> <p>and the permalinks are working fine, but when adding / (please see rewrite rule how i'm adding it) NGINX gives me 404 error.</p> <p>For e...
[ { "answer_id": 287995, "author": "kierzniak", "author_id": 132363, "author_profile": "https://wordpress.stackexchange.com/users/132363", "pm_score": 1, "selected": false, "text": "<p>Your home is working on SSL but some elements might not be loaded from <code>https</code> but <code>http<...
2017/12/07
[ "https://wordpress.stackexchange.com/questions/287994", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/69437/" ]
I have added this line in the nginx configuration file ``` try_files $uri $uri/ /index.php?$args; rewrite ^([^.]*[^/])$ $1/ permanent; #adding slash ``` and the permalinks are working fine, but when adding / (please see rewrite rule how i'm adding it) NGINX gives me 404 error. For example somedomain.com/post/ThisIs...
Your home is working on SSL but some elements might not be loaded from `https` but `http` like third party images or scripts. Look in source of your home site generated by browser and search for `http:` phrase to find which elements you should fix.
288,009
<p>The project that I'm working on have a user login section. Once the user logged in, they should be able to see a list of orders that they made in the past which are stored in the database. The list view is done by a foreach function. In this case, the user must be able to rebook any of those past order by one click ...
[ { "answer_id": 288208, "author": "kierzniak", "author_id": 132363, "author_profile": "https://wordpress.stackexchange.com/users/132363", "pm_score": 0, "selected": false, "text": "<p>To insert something to database you should send data with post request, get this data from request and sa...
2017/12/07
[ "https://wordpress.stackexchange.com/questions/288009", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/124648/" ]
The project that I'm working on have a user login section. Once the user logged in, they should be able to see a list of orders that they made in the past which are stored in the database. The list view is done by a foreach function. In this case, the user must be able to rebook any of those past order by one click and...
To insert something to database you should send data with post request, get this data from request and save it. You created code which will insert last row of your loop on post request. You should create form for each of your previous trip and add hidden input fields to have the opportunity to get them on post request...
288,020
<p>I've got lots of posts with the same title (home estate's properties), and i need to make url of single property -> title + ID (id part, adde automatically) after making new post.</p> <p>And is it possible to change existing one's? (i've got lots of them already created)</p> <p>Please help, i'm stuck</p>
[ { "answer_id": 288208, "author": "kierzniak", "author_id": 132363, "author_profile": "https://wordpress.stackexchange.com/users/132363", "pm_score": 0, "selected": false, "text": "<p>To insert something to database you should send data with post request, get this data from request and sa...
2017/12/07
[ "https://wordpress.stackexchange.com/questions/288020", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132898/" ]
I've got lots of posts with the same title (home estate's properties), and i need to make url of single property -> title + ID (id part, adde automatically) after making new post. And is it possible to change existing one's? (i've got lots of them already created) Please help, i'm stuck
To insert something to database you should send data with post request, get this data from request and save it. You created code which will insert last row of your loop on post request. You should create form for each of your previous trip and add hidden input fields to have the opportunity to get them on post request...
288,040
<p>You can use <a href="https://codex.wordpress.org/Function_Reference/is_admin" rel="nofollow noreferrer"><code>is_admin</code></a> to check to see if the current web page is part of WordPress' administrator interface.</p> <p>Is there a way to see if the page being processed is the registration page?</p>
[ { "answer_id": 288044, "author": "Sean Michaud", "author_id": 43348, "author_profile": "https://wordpress.stackexchange.com/users/43348", "pm_score": 2, "selected": false, "text": "<p>You could create your own simple function.</p>\n\n<pre><code>function is_registration_page() {\n if (...
2017/12/07
[ "https://wordpress.stackexchange.com/questions/288040", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122391/" ]
You can use [`is_admin`](https://codex.wordpress.org/Function_Reference/is_admin) to check to see if the current web page is part of WordPress' administrator interface. Is there a way to see if the page being processed is the registration page?
You could create your own simple function. ``` function is_registration_page() { if ( $GLOBALS['pagenow'] == 'wp-login.php' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'register' ) { return true; } return false; } ```
288,061
<h2>Questions</h2> <ul> <li>Assuming that I wanted to put all the code in a custom page like <code>page-contact.php</code> how can I structure my code so I can receive email? the code works in other PHP projects, but getting an error in a WordPress environment</li> <li>Why am I getting an error that the page cannot be ...
[ { "answer_id": 288044, "author": "Sean Michaud", "author_id": 43348, "author_profile": "https://wordpress.stackexchange.com/users/43348", "pm_score": 2, "selected": false, "text": "<p>You could create your own simple function.</p>\n\n<pre><code>function is_registration_page() {\n if (...
2017/12/08
[ "https://wordpress.stackexchange.com/questions/288061", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104295/" ]
Questions --------- * Assuming that I wanted to put all the code in a custom page like `page-contact.php` how can I structure my code so I can receive email? the code works in other PHP projects, but getting an error in a WordPress environment * Why am I getting an error that the page cannot be found when all i need i...
You could create your own simple function. ``` function is_registration_page() { if ( $GLOBALS['pagenow'] == 'wp-login.php' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'register' ) { return true; } return false; } ```
288,076
<p>Wordpress can't detect any thumbnails size, I re-generated all image but not work.</p> <p>The plugin (Simple Image Sizes) can detected all thumbnails size settings. <a href="https://i.stack.imgur.com/BFW9i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BFW9i.png" alt="enter image description here...
[ { "answer_id": 288044, "author": "Sean Michaud", "author_id": 43348, "author_profile": "https://wordpress.stackexchange.com/users/43348", "pm_score": 2, "selected": false, "text": "<p>You could create your own simple function.</p>\n\n<pre><code>function is_registration_page() {\n if (...
2017/12/08
[ "https://wordpress.stackexchange.com/questions/288076", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132927/" ]
Wordpress can't detect any thumbnails size, I re-generated all image but not work. The plugin (Simple Image Sizes) can detected all thumbnails size settings. [![enter image description here](https://i.stack.imgur.com/BFW9i.png)](https://i.stack.imgur.com/BFW9i.png) But when I want to use, it can't detect any size. [!...
You could create your own simple function. ``` function is_registration_page() { if ( $GLOBALS['pagenow'] == 'wp-login.php' && isset($_REQUEST['action']) && $_REQUEST['action'] == 'register' ) { return true; } return false; } ```
288,089
<p>HTTP header of posts on my site looks like this:</p> <pre><code>accept-ranges:bytes cache-control:public, max-age=0,public,public content-encoding:gzip content-length:5369 content-type:text/html; charset=UTF-8 date:Fri, 08 Dec 2017 07:27:40 GMT expires:Fri, 08 Dec 2017 07:19:33 GMT link:&lt;https://example.com/?p=5...
[ { "answer_id": 288093, "author": "Max Yudin", "author_id": 11761, "author_profile": "https://wordpress.stackexchange.com/users/11761", "pm_score": 5, "selected": true, "text": "<pre><code>&lt;?php\nadd_filter('after_setup_theme', 'remove_redundant_shortlink');\n\nfunction remove_redundan...
2017/12/08
[ "https://wordpress.stackexchange.com/questions/288089", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25053/" ]
HTTP header of posts on my site looks like this: ``` accept-ranges:bytes cache-control:public, max-age=0,public,public content-encoding:gzip content-length:5369 content-type:text/html; charset=UTF-8 date:Fri, 08 Dec 2017 07:27:40 GMT expires:Fri, 08 Dec 2017 07:19:33 GMT link:<https://example.com/?p=5697>; rel=shortli...
``` <?php add_filter('after_setup_theme', 'remove_redundant_shortlink'); function remove_redundant_shortlink() { // remove HTML meta tag // <link rel='shortlink' href='http://example.com/?p=25' /> remove_action('wp_head', 'wp_shortlink_wp_head', 10); // remove HTTP header // Link: <https://example...
288,092
<p>I was to tried create theme options admin page (without settings API)</p> <p>in this code I'd like to know why wp_verify_nonce return false:</p> <pre><code>main file &lt;?php add_action('admin_menu', 'awesome_page_create'); function awesome_page_create() { $page_title = 'My Awesome Admin Page'; $menu_tit...
[ { "answer_id": 288095, "author": "Elex", "author_id": 113687, "author_profile": "https://wordpress.stackexchange.com/users/113687", "pm_score": -1, "selected": false, "text": "<p>I think for your <code>wp_nonce_field</code> you have to use a second parameter (the field name of your custo...
2017/12/08
[ "https://wordpress.stackexchange.com/questions/288092", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132723/" ]
I was to tried create theme options admin page (without settings API) in this code I'd like to know why wp\_verify\_nonce return false: ``` main file <?php add_action('admin_menu', 'awesome_page_create'); function awesome_page_create() { $page_title = 'My Awesome Admin Page'; $menu_title = 'Awesome Admin Pa...
Revised code ------------ ``` if(is_admin()) { add_action('admin_menu', 'awesome_page_create'); function awesome_page_create() { $page_title = 'My Awesome Admin Page'; $menu_title = 'Awesome Admin Page'; $capability = 'edit_posts'; $menu_slug = 'awesome_page'; $function ...
288,099
<p>I'm developing a theme that has a featured posts section before the main loop of posts. Cool and fresh, right?:) All sticky posts with a featured image in place must be displayed in that section and excluded from the main loop. Easy peasy. Doing my research, I stumbled upon a <a href="https://developer.wordpress.com...
[ { "answer_id": 288102, "author": "Drupalizeme", "author_id": 115005, "author_profile": "https://wordpress.stackexchange.com/users/115005", "pm_score": 2, "selected": true, "text": "<p>You can try:</p>\n\n<pre><code>add_action('update_option_sticky_posts', function( $old_value, $value ) {...
2017/12/08
[ "https://wordpress.stackexchange.com/questions/288099", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31277/" ]
I'm developing a theme that has a featured posts section before the main loop of posts. Cool and fresh, right?:) All sticky posts with a featured image in place must be displayed in that section and excluded from the main loop. Easy peasy. Doing my research, I stumbled upon a [pretty old article](https://developer.word...
You can try: ``` add_action('update_option_sticky_posts', function( $old_value, $value ) { $featured_args = array( 'post__in' => $value, 'post_status' => 'publish', 'no_found_rows' => true ); // The Featured Posts query. $featured = new...
288,129
<p>I am wondering how can I add an endpoint where I would return the ninja form plugin data. I have made a function where I am getting the data from the ninja form:</p> <pre><code>add_action('init', function() { function getNinjaFormData(WP_REST_Request $request) { $id = $request-&gt;get_param('id'); $setting...
[ { "answer_id": 288154, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 1, "selected": false, "text": "<p>You need to return a WP_REST_Response object instead of an array.</p>\n\n<p>See <a href=\"https://developer.wordp...
2017/12/08
[ "https://wordpress.stackexchange.com/questions/288129", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/115898/" ]
I am wondering how can I add an endpoint where I would return the ninja form plugin data. I have made a function where I am getting the data from the ninja form: ``` add_action('init', function() { function getNinjaFormData(WP_REST_Request $request) { $id = $request->get_param('id'); $settings = ['label', 'ty...
You need to return a WP\_REST\_Response object instead of an array. See <https://developer.wordpress.org/rest-api/extending-the-rest-api/adding-custom-endpoints/> and <https://developer.wordpress.org/reference/classes/wp_rest_response/>.
288,132
<p>I have this page on my website - </p> <p>It's a custom taxonomy template for a custom post type called Directory Entries with a taxonomy called directory_entry_type which is what's being pulled in here. </p> <p>At the moment it's just pulling in all the posts under the category "Community Directory" - This categor...
[ { "answer_id": 288145, "author": "Adam N", "author_id": 78232, "author_profile": "https://wordpress.stackexchange.com/users/78232", "pm_score": 1, "selected": false, "text": "<p>To clarify, is your query only pulling posts tagged as the parent category and nothing tagged as a child categ...
2017/12/08
[ "https://wordpress.stackexchange.com/questions/288132", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/84954/" ]
I have this page on my website - It's a custom taxonomy template for a custom post type called Directory Entries with a taxonomy called directory\_entry\_type which is what's being pulled in here. At the moment it's just pulling in all the posts under the category "Community Directory" - This category has about 6 c...
To clarify, is your query only pulling posts tagged as the parent category and nothing tagged as a child category? And are you saying you'd like to have everything on this page? You might try changing `child_of` to `cat` and get rid of `depth`. But TBH you may want to try a different approach at querying; this quest...
288,147
<p>I would like to get a list of user_nicenames and the ID. But not all the usernames which is what i'm getting now. I understand I should use the % before and after the $name only nothing seems to be working. This is the only way to get some output I found till now;</p> <pre><code>global $wpdb; //get access to the Wo...
[ { "answer_id": 288149, "author": "Sneha Agarwal", "author_id": 129447, "author_profile": "https://wordpress.stackexchange.com/users/129447", "pm_score": -1, "selected": false, "text": "<p>Your query is right the like parameter will be</p>\n\n<pre><code>global $wpdb; //get access to the W...
2017/12/08
[ "https://wordpress.stackexchange.com/questions/288147", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/129735/" ]
I would like to get a list of user\_nicenames and the ID. But not all the usernames which is what i'm getting now. I understand I should use the % before and after the $name only nothing seems to be working. This is the only way to get some output I found till now; ``` global $wpdb; //get access to the WordPress datab...
Can you verify that $\_POST['name'] is obtaining a value. I suggest echoing it out to the page for debugging (maybe in comment tags if site is live). If $\_POST['name'] is empty, then all results will be returned because the query will say `user_nicename LIKE '%'` Just as a precaution in any case, you should do a cond...
288,157
<p>Is there a way to change the content type for <em>only</em> the password reset email?</p> <p>I have a custom HTML template for it, and have set wp_mail_content_type to text/html and am applying the template with a filter on retrieve_password_message. That all works fine and I get an HTML email for it, but I’m havin...
[ { "answer_id": 288159, "author": "signal2013", "author_id": 132866, "author_profile": "https://wordpress.stackexchange.com/users/132866", "pm_score": 3, "selected": true, "text": "<p>I suspect you implemented the hook something like this:</p>\n\n<pre><code>function wp_set_html_mail_conte...
2017/12/08
[ "https://wordpress.stackexchange.com/questions/288157", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132966/" ]
Is there a way to change the content type for *only* the password reset email? I have a custom HTML template for it, and have set wp\_mail\_content\_type to text/html and am applying the template with a filter on retrieve\_password\_message. That all works fine and I get an HTML email for it, but I’m having a hard tim...
I suspect you implemented the hook something like this: ``` function wp_set_html_mail_content_type() { return 'text/html'; } add_filter( 'wp_mail_content_type', 'wp_set_html_mail_content_type' ); ``` More info: <https://codex.wordpress.org/Plugin_API/Filter_Reference/wp_mail_content_type> Did you need to reset ...
288,210
<p>I have a WordPress website and I changed some CSS with Custom CSS Plugin to adjust the position of the Footer. Here my CSS Changes:</p> <pre><code>.page-id-736 .main-title { visibility: visible; display: none; } .page-id-1981 .main-title { visibility: visible; display: none; } .page-id-2005 .main-title {...
[ { "answer_id": 288216, "author": "Arturo Gallegos", "author_id": 130585, "author_profile": "https://wordpress.stackexchange.com/users/130585", "pm_score": 0, "selected": false, "text": "<p>How could it help with the power of the code in question? If you can not share the URL of your site...
2017/12/09
[ "https://wordpress.stackexchange.com/questions/288210", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/133003/" ]
I have a WordPress website and I changed some CSS with Custom CSS Plugin to adjust the position of the Footer. Here my CSS Changes: ``` .page-id-736 .main-title { visibility: visible; display: none; } .page-id-1981 .main-title { visibility: visible; display: none; } .page-id-2005 .main-title { visibility: ...
The problem is your **footer has a -45px margin** on it. I think you were looking to limit this vertically. so it should be **margin-top: -45px on your footer**. Then you can remove the **overflow-x: hidden; from your body .boxed-container{}** which is why the second scroll bar is appearing ( once you have defined a...
288,231
<p>What would be the best way to split custom WP_Query results into different post types? </p> <p>I'm using multiple queries, but is it the most effective solution in performance terms? </p> <pre><code>$results = new WP_Query(array('post_type' =&gt; 'post_type_1')); $results2 = new WP_Query(array('post_type' =&gt; 'p...
[ { "answer_id": 288245, "author": "Ben HartLenn", "author_id": 6645, "author_profile": "https://wordpress.stackexchange.com/users/6645", "pm_score": 0, "selected": false, "text": "<p>You could try doing one query to the database for all results, then use <a href=\"https://developer.wordpr...
2017/12/09
[ "https://wordpress.stackexchange.com/questions/288231", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/121208/" ]
What would be the best way to split custom WP\_Query results into different post types? I'm using multiple queries, but is it the most effective solution in performance terms? ``` $results = new WP_Query(array('post_type' => 'post_type_1')); $results2 = new WP_Query(array('post_type' => 'post_type_2')); if have po...
There is no need to split the query or do multiple queries. Just use the parameter `orderby` with value `post_type` to sort separated by post types. You can use a second value for additional sorting, e.g. by `date`. See [Codex: Class Reference | WP\_Query | Order & Orderby Parameters](https://codex.wordpress.org/Class_...
288,250
<p>My draft posts will have custom field which contains value as email address. So whenever I publish the post, it will send email to the user. It's working fine. However, if I updates the post, it still sends the email again and again. Here is my piece of code:</p> <pre><code>add_action( 'save_post', 'send_email' ); ...
[ { "answer_id": 288251, "author": "Por", "author_id": 31832, "author_profile": "https://wordpress.stackexchange.com/users/31832", "pm_score": 0, "selected": false, "text": "<pre><code>add_action( 'save_post', 'send_email' );\nfunction send_email( $post_id ) {\n\n if ( !wp_is_post_revis...
2017/12/10
[ "https://wordpress.stackexchange.com/questions/288250", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36797/" ]
My draft posts will have custom field which contains value as email address. So whenever I publish the post, it will send email to the user. It's working fine. However, if I updates the post, it still sends the email again and again. Here is my piece of code: ``` add_action( 'save_post', 'send_email' ); function send_...
You need to use [{old\_status}*to*{new\_status} hook](https://codex.wordpress.org/Post_Status_Transitions#.7Bold_status.7D_to_.7Bnew_status.7D_Hook). And use `draft` and `publish` statuses. This hook will only be executed when your post will change status from `draft` to `publish`. ``` function wpse_288250_send_email(...
288,280
<p>I am using Time.ly's All-In-One Event Calendar plugin. I am trying to get a value from the wp_ai1ec_event table in the column entitled "end". I want to get this based on the post_id. Since this is a custom table it's post_id is the same as the post table's. I have tried everything I can think of to get this value. B...
[ { "answer_id": 288343, "author": "David Sword", "author_id": 132362, "author_profile": "https://wordpress.stackexchange.com/users/132362", "pm_score": 2, "selected": true, "text": "<p>These bigger plugins are often \"too cool\" to use post_meta/post_custom - thats why you were unable to ...
2017/12/10
[ "https://wordpress.stackexchange.com/questions/288280", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/110216/" ]
I am using Time.ly's All-In-One Event Calendar plugin. I am trying to get a value from the wp\_ai1ec\_event table in the column entitled "end". I want to get this based on the post\_id. Since this is a custom table it's post\_id is the same as the post table's. I have tried everything I can think of to get this value. ...
These bigger plugins are often "too cool" to use post\_meta/post\_custom - thats why you were unable to retrieve the data via the normal plugin way of storing additional info. The dev documentation for ai1ec in bleak, I couldn't find any functions to simplify the task you were after (though they do exist in the source ...
288,296
<p>I’m getting overrun with these on my production site:</p> <pre><code>PHP Notice: Trying to get property of non-object in /public_html/wp-includes/class-wp-query.php on line 3728 PHP Notice: Trying to get property of non-object in /public_html/wp-includes/class-wp-query.php on line 3730 PHP Notice: Trying to get ...
[ { "answer_id": 288402, "author": "scytale", "author_id": 128374, "author_profile": "https://wordpress.stackexchange.com/users/128374", "pm_score": 1, "selected": false, "text": "<p>Stage and Prod may be on the same server but are they configured for the same version of PHP?</p>\n\n<p>A W...
2017/12/11
[ "https://wordpress.stackexchange.com/questions/288296", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/133063/" ]
I’m getting overrun with these on my production site: ``` PHP Notice: Trying to get property of non-object in /public_html/wp-includes/class-wp-query.php on line 3728 PHP Notice: Trying to get property of non-object in /public_html/wp-includes/class-wp-query.php on line 3730 PHP Notice: Trying to get property of no...
You can create your own custom error handler and add stack trace to your error log. ``` set_error_handler('wpse_288408_handle_error'); function wpse_288408_handle_error( $errno, $errstr, $errfile, $errline ) { if( $errno === E_USER_NOTICE ) { $message = 'You have an error notice: "%s" in file "%s" at li...