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
317,969
<p>I am trying to change the text color of my current menu item as on hover its green but the background is green so I want the color to be white on hover but it does not seem to want to work, to view hover over the selected page on 'our products'</p> <p><a href="http://beta2018.bedcentregrimsby.co.uk/product-categor...
[ { "answer_id": 317901, "author": "André Kelling", "author_id": 136930, "author_profile": "https://wordpress.stackexchange.com/users/136930", "pm_score": 0, "selected": false, "text": "<p>in general it's not a good idea to insert inline styles. </p>\n\n<p>try with a CSS class and add your...
2018/10/30
[ "https://wordpress.stackexchange.com/questions/317969", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/150429/" ]
I am trying to change the text color of my current menu item as on hover its green but the background is green so I want the color to be white on hover but it does not seem to want to work, to view hover over the selected page on 'our products' [website link](http://beta2018.bedcentregrimsby.co.uk/product-category/bun...
I've had the same issue recently. Inline styles, as well as `<img>` tags, would cause the `410 Gone` status and error message (`The requested resource /wp-admin/post.php is no longer available on this server and there is no forwarding address. Please remove all references to this resource.` upon previewing or publish...
318,029
<p>Is there a way to display a video using only the default video player of the browser, without the <code>mejs</code> / <code>wp-video</code> interface? The additional markup gives me a lot of trouble. I just want to use the <code>&lt;video&gt;</code> element, and handle my custom needs with CSS/JS.</p> <p>I won't sa...
[ { "answer_id": 318039, "author": "Friss", "author_id": 62392, "author_profile": "https://wordpress.stackexchange.com/users/62392", "pm_score": -1, "selected": false, "text": "<p>I would try to use the <strong>embed_oembed_html filter</strong></p>\n\n<p>Here is an ultra basic example</p>\...
2018/10/30
[ "https://wordpress.stackexchange.com/questions/318029", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153292/" ]
Is there a way to display a video using only the default video player of the browser, without the `mejs` / `wp-video` interface? The additional markup gives me a lot of trouble. I just want to use the `<video>` element, and handle my custom needs with CSS/JS. I won't say I'm an expert. I have considerable amount of ex...
I've found the right way digging through the WP documentation: <https://developer.wordpress.org/reference/hooks/wp_video_shortcode/> This code seems to do the trick: ``` function buildVideoPlayer($output, $attr) { // $output contains the default HTML string, created by the WP core // $attr is an associative a...
318,073
<p>I'm trying to set <code>posts_per_page</code> depending on what category is being shown. </p> <p>The following code works.</p> <pre><code>function category_posts_per_page( $query ) { if ( $query-&gt;is_main_query() &amp;&amp; $query-&gt;is_category() &amp;&amp; $query-&gt;is_category('books') ) { $que...
[ { "answer_id": 318084, "author": "Friss", "author_id": 62392, "author_profile": "https://wordpress.stackexchange.com/users/62392", "pm_score": 0, "selected": false, "text": "<p>Maybe you should try this behavior happens only on frontend, with adding !is_admin like this. It is maybe due t...
2018/10/31
[ "https://wordpress.stackexchange.com/questions/318073", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15809/" ]
I'm trying to set `posts_per_page` depending on what category is being shown. The following code works. ``` function category_posts_per_page( $query ) { if ( $query->is_main_query() && $query->is_category() && $query->is_category('books') ) { $query->set('posts_per_page', 2); } } add_action( 'pre_g...
`is_category('category-name')` won't work until after the query is run. If we check source code where those notices are generated, we can see that it's using `get_queried_object`, which gets populated with the results of the main query, and at the `pre_get_posts` stage will still be empty. As an alternate, check the c...
318,117
<p>I'm sorry if this is a already asked Question but i'm trying to get my custom post types displayed in grid like this: </p> <pre><code>&lt;div class="row&gt; &lt;div class="col-md-4&gt; /* Start the Loop */ while (have_posts()) : the_post(); get_template_part('template-parts/post/cont...
[ { "answer_id": 318084, "author": "Friss", "author_id": 62392, "author_profile": "https://wordpress.stackexchange.com/users/62392", "pm_score": 0, "selected": false, "text": "<p>Maybe you should try this behavior happens only on frontend, with adding !is_admin like this. It is maybe due t...
2018/10/31
[ "https://wordpress.stackexchange.com/questions/318117", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153348/" ]
I'm sorry if this is a already asked Question but i'm trying to get my custom post types displayed in grid like this: ``` <div class="row> <div class="col-md-4> /* Start the Loop */ while (have_posts()) : the_post(); get_template_part('template-parts/post/content', get_post_format()); ...
`is_category('category-name')` won't work until after the query is run. If we check source code where those notices are generated, we can see that it's using `get_queried_object`, which gets populated with the results of the main query, and at the `pre_get_posts` stage will still be empty. As an alternate, check the c...
318,165
<p>I am looking for help to put single page favicon that would overwrite global one. Say for example I have wordpress website that is example.com and it has favicon set for every page. What I want is for example.com/page3 to have diffrent favicon. I have seen quite a few options around but I cannot figure out how to ma...
[ { "answer_id": 318260, "author": "thehbhatt", "author_id": 92703, "author_profile": "https://wordpress.stackexchange.com/users/92703", "pm_score": -1, "selected": false, "text": "<p>Here is the link: <a href=\"https://elementor.com/blog/header-footer-builder/\" rel=\"nofollow noreferrer\...
2018/11/01
[ "https://wordpress.stackexchange.com/questions/318165", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153372/" ]
I am looking for help to put single page favicon that would overwrite global one. Say for example I have wordpress website that is example.com and it has favicon set for every page. What I want is for example.com/page3 to have diffrent favicon. I have seen quite a few options around but I cannot figure out how to make ...
If you have a modern theme, where you can upload a favicon with the theme customizer (rather than a hardcoded url in the `header.php`), you can simply use a filter. Take a look at the function [`get_site_icon`](https://developer.wordpress.org/reference/functions/get_site_icon_url/). As you can see it returns the url of...
318,167
<p>So i installed the wp admin package, but i can't seem to get her working, an error pops up telling me xdg-open doenst exist.. For install i used:</p> <pre><code>wp package install git@github.com:wp-cli/admin-command.git Installing package wp-cli/admin-command (dev-master) Updating ~.wp-cli\packages\composer.json to...
[ { "answer_id": 319299, "author": "kero", "author_id": 108180, "author_profile": "https://wordpress.stackexchange.com/users/108180", "pm_score": 3, "selected": true, "text": "<p>This happened due to Windows not yet being supported.</p>\n\n<p>With <a href=\"https://github.com/wp-cli/admin-...
2018/11/01
[ "https://wordpress.stackexchange.com/questions/318167", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/108736/" ]
So i installed the wp admin package, but i can't seem to get her working, an error pops up telling me xdg-open doenst exist.. For install i used: ``` wp package install git@github.com:wp-cli/admin-command.git Installing package wp-cli/admin-command (dev-master) Updating ~.wp-cli\packages\composer.json to require the p...
This happened due to Windows not yet being supported. With [PR#18](https://github.com/wp-cli/admin-command/pull/18) this was resolved, update the package to the latest version and it will work on Windows machines.
318,213
<p>I tried reading the WordPress codex about integrating WordPress into an existing website.</p> <p>I tried using the header information</p> <pre><code>&lt;?php /* Short and sweet */ define('WP_USE_THEMES', false); require('./wp-blog-header.php'); ?&gt; </code></pre> <p>And then the test code</p> <pre><code>&lt;?ph...
[ { "answer_id": 318248, "author": "Bob", "author_id": 116319, "author_profile": "https://wordpress.stackexchange.com/users/116319", "pm_score": 1, "selected": false, "text": "<p>Have you tried using the following?<br></p>\n\n<pre><code>require(dirname(__FILE__) . '/wp-load.php');\n</code>...
2018/11/01
[ "https://wordpress.stackexchange.com/questions/318213", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/152515/" ]
I tried reading the WordPress codex about integrating WordPress into an existing website. I tried using the header information ``` <?php /* Short and sweet */ define('WP_USE_THEMES', false); require('./wp-blog-header.php'); ?> ``` And then the test code ``` <?php // Get the last 3 posts. global $post; $args = arr...
I started writing a pretty long comment, but I figured I would write it as a solution instead. If you mix all your files in one big jumble, then it probably wont work. But if you put WordPress in a subdirectory, then it would work (that's how I used to do it). REMEMBER!!! If you already have a working WordPress-ins...
318,226
<p>I have never used XMLRPC for any activity for my WordPress sites and also not going to do so.</p> <p>There are many articles on disabling XMLRPC on your site for additional security. In the use case scenario that I discussed when if that service is not required, why to disbale it or make it more secure ? I just wis...
[ { "answer_id": 318241, "author": "sandrodz", "author_id": 115734, "author_profile": "https://wordpress.stackexchange.com/users/115734", "pm_score": 2, "selected": false, "text": "<p>As mentioned in comments, if you delete the file, updating WP will bring it back.</p>\n\n<p>It is best to ...
2018/11/02
[ "https://wordpress.stackexchange.com/questions/318226", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/147821/" ]
I have never used XMLRPC for any activity for my WordPress sites and also not going to do so. There are many articles on disabling XMLRPC on your site for additional security. In the use case scenario that I discussed when if that service is not required, why to disbale it or make it more secure ? I just wish to simpl...
You shouldn't delete that file - it will be restored after update - so deleting it makes no sense (and it shouldn't be treated as security fix). You can disable XMLRPC using filter: ``` add_filter('xmlrpc_enabled', '__return_false'); ``` And even block access to that file. Below code for Apache (sandrodz showed cod...
318,249
<p>I'm starting to go a little mad here, I must be missing something obious but I have tried many solutions.</p> <p>My problem: I want to have 6 related products under each product. (Understanding if a category has more then 6 products in it)</p> <p>I currently have the related products grabbing it's shared category....
[ { "answer_id": 318241, "author": "sandrodz", "author_id": 115734, "author_profile": "https://wordpress.stackexchange.com/users/115734", "pm_score": 2, "selected": false, "text": "<p>As mentioned in comments, if you delete the file, updating WP will bring it back.</p>\n\n<p>It is best to ...
2018/11/02
[ "https://wordpress.stackexchange.com/questions/318249", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153434/" ]
I'm starting to go a little mad here, I must be missing something obious but I have tried many solutions. My problem: I want to have 6 related products under each product. (Understanding if a category has more then 6 products in it) I currently have the related products grabbing it's shared category. But when I load ...
You shouldn't delete that file - it will be restored after update - so deleting it makes no sense (and it shouldn't be treated as security fix). You can disable XMLRPC using filter: ``` add_filter('xmlrpc_enabled', '__return_false'); ``` And even block access to that file. Below code for Apache (sandrodz showed cod...
318,273
<p>Since <code>order allow,deny</code> is deprecated in 2.4 I wanted to rewrite the rules in my .htaccess file to use the new rules. Previously I was using:</p> <pre><code>&lt;files wp-config.php&gt; order allow,deny deny from all &lt;/files&gt; </code></pre> <p>Which I've rewritten to:</p> <pre><code>&lt;F...
[ { "answer_id": 318287, "author": "scytale", "author_id": 128374, "author_profile": "https://wordpress.stackexchange.com/users/128374", "pm_score": 1, "selected": false, "text": "<p>The old method works for me, and any requests result in a 403 status response instead of execution of the p...
2018/11/02
[ "https://wordpress.stackexchange.com/questions/318273", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/69042/" ]
Since `order allow,deny` is deprecated in 2.4 I wanted to rewrite the rules in my .htaccess file to use the new rules. Previously I was using: ``` <files wp-config.php> order allow,deny deny from all </files> ``` Which I've rewritten to: ``` <FilesMatch "wp-config.php"> Require all denied </FilesMatch> ...
The old method works for me, and any requests result in a 403 status response instead of execution of the php script. I've not checked your 2nd method, but if it works it will similarly respond with 403 denied/forbidden. To test you simply have to insert the URL of your "wp-config.php" in the address bar of your brows...
318,318
<p>I've made quite an extensive <code>page.php</code> using ACF-repeaters and the flexible content module (1000+ lines of code). The code is getting really spaghetti-like, and I'm not sure how to structure it so it's easier to read and maintain. </p> <p>Here's a pseudo-code-version of it:</p> <pre><code>$all_fields =...
[ { "answer_id": 318324, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 3, "selected": true, "text": "<p>Well, structuring is partly a matter of taste, but it in this case it seems to be a good idea to include all the ...
2018/11/03
[ "https://wordpress.stackexchange.com/questions/318318", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/128304/" ]
I've made quite an extensive `page.php` using ACF-repeaters and the flexible content module (1000+ lines of code). The code is getting really spaghetti-like, and I'm not sure how to structure it so it's easier to read and maintain. Here's a pseudo-code-version of it: ``` $all_fields = get_fields(); foreach( $all_fi...
Well, structuring is partly a matter of taste, but it in this case it seems to be a good idea to include all the functions in a separate file. That includes the code that you would have in both template files. And rather than the chain of `elseif` you could use [PHP's switch statement](http://php.net/manual/en/control-...
318,320
<p>My <code>wp config create</code> command:</p> <pre><code>wp core config --dbname=wordpress --dbuser=wordpress --dbpass='this is not the real password' </code></pre> <p>Running it:</p> <pre><code>$ wp core config --dbname=wordpress --dbuser=wordpress --dbpass='this is not the real password' ERROR 1045 (28000): Acc...
[ { "answer_id": 318324, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 3, "selected": true, "text": "<p>Well, structuring is partly a matter of taste, but it in this case it seems to be a good idea to include all the ...
2018/11/03
[ "https://wordpress.stackexchange.com/questions/318320", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22798/" ]
My `wp config create` command: ``` wp core config --dbname=wordpress --dbuser=wordpress --dbpass='this is not the real password' ``` Running it: ``` $ wp core config --dbname=wordpress --dbuser=wordpress --dbpass='this is not the real password' ERROR 1045 (28000): Access denied for user 'wordpress'@'localhost' (usi...
Well, structuring is partly a matter of taste, but it in this case it seems to be a good idea to include all the functions in a separate file. That includes the code that you would have in both template files. And rather than the chain of `elseif` you could use [PHP's switch statement](http://php.net/manual/en/control-...
318,325
<p>I want to make the code to display the list of the page title in footer. I made the following code in <code>functions.php</code>:</p> <pre><code> add_action('yamada_action', 'list_page_2'); function list_page_2() { global $title_yama; $title_yama = ''; $args = array( 'post_type' ...
[ { "answer_id": 318326, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 1, "selected": false, "text": "<p>It seems you are <a href=\"https://wordpress.stackexchange.com/questions/265952/whats-the-difference-between-hoo...
2018/11/03
[ "https://wordpress.stackexchange.com/questions/318325", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/129234/" ]
I want to make the code to display the list of the page title in footer. I made the following code in `functions.php`: ``` add_action('yamada_action', 'list_page_2'); function list_page_2() { global $title_yama; $title_yama = ''; $args = array( 'post_type' => 'page', 'pos...
Thank you very much for your advice. I can solve this problrems as follows. function.php ``` add_action('yamada_action', 'list_page_2'); function list_page_2() { $title_yama = ''; $args = array( 'post_type' => 'page', 'post_status' => 'publish', ); $queries_yama = new WP_Query($a...
318,341
<p>I'm having a little problem figuring out how to execute shortcodes stored in a mail content option of a plugin.</p> <p>The thing is, I have a field in my options page named '_message' that works with WYSIWYG Editor, and I want to save shortcodes there and then execute them before send the email.</p> <p>There is so...
[ { "answer_id": 318326, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 1, "selected": false, "text": "<p>It seems you are <a href=\"https://wordpress.stackexchange.com/questions/265952/whats-the-difference-between-hoo...
2018/11/03
[ "https://wordpress.stackexchange.com/questions/318341", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153499/" ]
I'm having a little problem figuring out how to execute shortcodes stored in a mail content option of a plugin. The thing is, I have a field in my options page named '\_message' that works with WYSIWYG Editor, and I want to save shortcodes there and then execute them before send the email. There is some way of detect...
Thank you very much for your advice. I can solve this problrems as follows. function.php ``` add_action('yamada_action', 'list_page_2'); function list_page_2() { $title_yama = ''; $args = array( 'post_type' => 'page', 'post_status' => 'publish', ); $queries_yama = new WP_Query($a...
318,361
<p>I'm setting up the wordpress for my webcomic/graphic novel and I'm just hitting a little snag when it comes to the navigation. Here's what I want, a very basic webcomic navigation scheme:</p> <p>&lt;&lt; First | &lt; Previous | Next > | Last >></p> <p>Each of these would be linking to the respective comic pages (w...
[ { "answer_id": 318368, "author": "sandrodz", "author_id": 115734, "author_profile": "https://wordpress.stackexchange.com/users/115734", "pm_score": 1, "selected": false, "text": "<p>This <a href=\"https://gist.github.com/franz-josef-kaiser/818457/c7bf3ce2d12e1340fd44527b3a4a2a8e66fed154\...
2018/11/04
[ "https://wordpress.stackexchange.com/questions/318361", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153517/" ]
I'm setting up the wordpress for my webcomic/graphic novel and I'm just hitting a little snag when it comes to the navigation. Here's what I want, a very basic webcomic navigation scheme: << First | < Previous | Next > | Last >> Each of these would be linking to the respective comic pages (which are seperate posts) d...
This [gist](https://gist.github.com/franz-josef-kaiser/818457/c7bf3ce2d12e1340fd44527b3a4a2a8e66fed154) should get you started. ``` <?php /* Plugin Name: Easy Pagination Deamon Plugin URI: http://wordpress.org/extend/plugins/stats/ Description: Offers the deamon_pagination($range) template tag for a sematica...
318,411
<p>I have two Custom post types: <strong>question</strong> and <strong>answer</strong>. "Questions" are hierarchical and they are parent posts for answers - which are child posts. For every answer, there's a parent question. When someone asks a question, every answer given is correctly attributed to the same question. ...
[ { "answer_id": 318368, "author": "sandrodz", "author_id": 115734, "author_profile": "https://wordpress.stackexchange.com/users/115734", "pm_score": 1, "selected": false, "text": "<p>This <a href=\"https://gist.github.com/franz-josef-kaiser/818457/c7bf3ce2d12e1340fd44527b3a4a2a8e66fed154\...
2018/11/04
[ "https://wordpress.stackexchange.com/questions/318411", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/113108/" ]
I have two Custom post types: **question** and **answer**. "Questions" are hierarchical and they are parent posts for answers - which are child posts. For every answer, there's a parent question. When someone asks a question, every answer given is correctly attributed to the same question. This has already been nicely ...
This [gist](https://gist.github.com/franz-josef-kaiser/818457/c7bf3ce2d12e1340fd44527b3a4a2a8e66fed154) should get you started. ``` <?php /* Plugin Name: Easy Pagination Deamon Plugin URI: http://wordpress.org/extend/plugins/stats/ Description: Offers the deamon_pagination($range) template tag for a sematica...
318,431
<p>When I'm trying to sort my blog posts or my woocommerce in alphabetical order nothing changes. If I access the /?orderby=title-asc or ?orderby=title-desc it brings me the same results.</p> <p>Any sugestions?</p>
[ { "answer_id": 318368, "author": "sandrodz", "author_id": 115734, "author_profile": "https://wordpress.stackexchange.com/users/115734", "pm_score": 1, "selected": false, "text": "<p>This <a href=\"https://gist.github.com/franz-josef-kaiser/818457/c7bf3ce2d12e1340fd44527b3a4a2a8e66fed154\...
2018/11/05
[ "https://wordpress.stackexchange.com/questions/318431", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/147952/" ]
When I'm trying to sort my blog posts or my woocommerce in alphabetical order nothing changes. If I access the /?orderby=title-asc or ?orderby=title-desc it brings me the same results. Any sugestions?
This [gist](https://gist.github.com/franz-josef-kaiser/818457/c7bf3ce2d12e1340fd44527b3a4a2a8e66fed154) should get you started. ``` <?php /* Plugin Name: Easy Pagination Deamon Plugin URI: http://wordpress.org/extend/plugins/stats/ Description: Offers the deamon_pagination($range) template tag for a sematica...
318,444
<p>I am using Automattic's plugin to implement AMP on my website. Currently, to make my videos responsive, I wrap YouTube videos around a custom div. So, a YouTube video on my website looks like this:-</p> <pre><code>&lt;div class="yt"&gt; &lt;iframe&gt;....YT video code...&lt;/iframe&gt; &lt;/div&gt; </code></pre> <...
[ { "answer_id": 318368, "author": "sandrodz", "author_id": 115734, "author_profile": "https://wordpress.stackexchange.com/users/115734", "pm_score": 1, "selected": false, "text": "<p>This <a href=\"https://gist.github.com/franz-josef-kaiser/818457/c7bf3ce2d12e1340fd44527b3a4a2a8e66fed154\...
2018/11/05
[ "https://wordpress.stackexchange.com/questions/318444", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/142951/" ]
I am using Automattic's plugin to implement AMP on my website. Currently, to make my videos responsive, I wrap YouTube videos around a custom div. So, a YouTube video on my website looks like this:- ``` <div class="yt"> <iframe>....YT video code...</iframe> </div> ``` The problem is the `<div class="yt">` and the cl...
This [gist](https://gist.github.com/franz-josef-kaiser/818457/c7bf3ce2d12e1340fd44527b3a4a2a8e66fed154) should get you started. ``` <?php /* Plugin Name: Easy Pagination Deamon Plugin URI: http://wordpress.org/extend/plugins/stats/ Description: Offers the deamon_pagination($range) template tag for a sematica...
318,447
<p>I created a numeric pagination that loads the posts via AJAX.</p> <p>This is the PHP and jQuery code:</p> <pre><code>// PHP Code function ajax_pagination_enqueue_scripts() { wp_enqueue_script( 'ajax-pagination', get_stylesheet_directory_uri() . '/js/ajax-pagination.js', array( 'jquery' ), '1.0', true ); w...
[ { "answer_id": 318448, "author": "Maidul", "author_id": 21142, "author_profile": "https://wordpress.stackexchange.com/users/21142", "pm_score": -1, "selected": false, "text": "<p>You can set a cookie or <a href=\"https://developer.mozilla.org/en-US/docs/Web/API/Storage/LocalStorage\" rel...
2018/11/05
[ "https://wordpress.stackexchange.com/questions/318447", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/140507/" ]
I created a numeric pagination that loads the posts via AJAX. This is the PHP and jQuery code: ``` // PHP Code function ajax_pagination_enqueue_scripts() { wp_enqueue_script( 'ajax-pagination', get_stylesheet_directory_uri() . '/js/ajax-pagination.js', array( 'jquery' ), '1.0', true ); wp_localize_script( 'a...
When you refresh the page, there is currently no state you can use to know you're on page 2. You could use the [History API](https://developer.mozilla.org/en-US/docs/Web/API/History) to update the page URL without refreshing the page: ``` history.pushState(data, title, 'https://yourpage.com/?page=2'); ``` You can a...
318,515
<p>I try to call a function everytime a user login to website.</p> <p>I succeeded with the <code>wp_login</code> hook for user who fill the login form.</p> <p>However I can't find a hook for an user which has the "remember me" option activated when he come back to website (so he already have a login cookie).</p> <p>...
[ { "answer_id": 318521, "author": "sandrodz", "author_id": 115734, "author_profile": "https://wordpress.stackexchange.com/users/115734", "pm_score": 1, "selected": false, "text": "<p>Don't use <code>wp_login</code> hook. Use <code>wp_signon</code> function instead.</p>\n\n<p><a href=\"htt...
2018/11/06
[ "https://wordpress.stackexchange.com/questions/318515", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/147005/" ]
I try to call a function everytime a user login to website. I succeeded with the `wp_login` hook for user who fill the login form. However I can't find a hook for an user which has the "remember me" option activated when he come back to website (so he already have a login cookie). I checked `wp_validate_auth_cookie(...
Don't use `wp_login` hook. Use `wp_signon` function instead. <https://developer.wordpress.org/reference/functions/wp_signon/> ``` wp_signon( array $credentials = array(), string|bool $secure_cookie = '' ) ``` > > The credentials is an array that has ‘user\_login’, ‘user\_password’, > and ‘remember’ indices. If th...
318,534
<p>I was trying to display product thumbnails in 230px (as per recommendations by GTmetrix).</p> <p>Since, I am using storefront the default value is declared in storefront/inc/class-storefront.php</p> <p>The code is as follows:</p> <pre><code>add_theme_support( 'woocommerce', apply_filters( 'storefront_woocommerce...
[ { "answer_id": 318521, "author": "sandrodz", "author_id": 115734, "author_profile": "https://wordpress.stackexchange.com/users/115734", "pm_score": 1, "selected": false, "text": "<p>Don't use <code>wp_login</code> hook. Use <code>wp_signon</code> function instead.</p>\n\n<p><a href=\"htt...
2018/11/06
[ "https://wordpress.stackexchange.com/questions/318534", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153654/" ]
I was trying to display product thumbnails in 230px (as per recommendations by GTmetrix). Since, I am using storefront the default value is declared in storefront/inc/class-storefront.php The code is as follows: ``` add_theme_support( 'woocommerce', apply_filters( 'storefront_woocommerce_args', array( 'single_image...
Don't use `wp_login` hook. Use `wp_signon` function instead. <https://developer.wordpress.org/reference/functions/wp_signon/> ``` wp_signon( array $credentials = array(), string|bool $secure_cookie = '' ) ``` > > The credentials is an array that has ‘user\_login’, ‘user\_password’, > and ‘remember’ indices. If th...
318,583
<p>There are a few websites that I stumble upon now and then that have animated intros like the one here: www.monotwo.com </p> <p>How do I do that in WordPress?</p> <p>And how would I integrate this into a customs theme?</p> <p>Thanks.</p>
[ { "answer_id": 318521, "author": "sandrodz", "author_id": 115734, "author_profile": "https://wordpress.stackexchange.com/users/115734", "pm_score": 1, "selected": false, "text": "<p>Don't use <code>wp_login</code> hook. Use <code>wp_signon</code> function instead.</p>\n\n<p><a href=\"htt...
2018/11/07
[ "https://wordpress.stackexchange.com/questions/318583", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153687/" ]
There are a few websites that I stumble upon now and then that have animated intros like the one here: www.monotwo.com How do I do that in WordPress? And how would I integrate this into a customs theme? Thanks.
Don't use `wp_login` hook. Use `wp_signon` function instead. <https://developer.wordpress.org/reference/functions/wp_signon/> ``` wp_signon( array $credentials = array(), string|bool $secure_cookie = '' ) ``` > > The credentials is an array that has ‘user\_login’, ‘user\_password’, > and ‘remember’ indices. If th...
318,590
<p>I have a very basic question which can be done easily with raw sql query where instead of * we can name the columns of database we want output like </p> <pre><code> select id,name,date from tableA where id&gt;'100' </code></pre> <p>but same thing in <code>Wp_Query</code> is giving whole lot of junk data which...
[ { "answer_id": 318521, "author": "sandrodz", "author_id": 115734, "author_profile": "https://wordpress.stackexchange.com/users/115734", "pm_score": 1, "selected": false, "text": "<p>Don't use <code>wp_login</code> hook. Use <code>wp_signon</code> function instead.</p>\n\n<p><a href=\"htt...
2018/11/07
[ "https://wordpress.stackexchange.com/questions/318590", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153612/" ]
I have a very basic question which can be done easily with raw sql query where instead of \* we can name the columns of database we want output like ``` select id,name,date from tableA where id>'100' ``` but same thing in `Wp_Query` is giving whole lot of junk data which is completely irrelevant to us. We can...
Don't use `wp_login` hook. Use `wp_signon` function instead. <https://developer.wordpress.org/reference/functions/wp_signon/> ``` wp_signon( array $credentials = array(), string|bool $secure_cookie = '' ) ``` > > The credentials is an array that has ‘user\_login’, ‘user\_password’, > and ‘remember’ indices. If th...
318,666
<p>In my WordPress installation <code>(4.9.8.)</code> the editor role isn't allowed to edit the privacy page.</p> <p>It would work with following in my <code>functions.php</code>:</p> <pre><code>$role_object = get_role( 'editor' ); $role_object-&gt;add_cap( 'manage_privacy_options', true ); $role_object-&gt;add_cap( ...
[ { "answer_id": 325784, "author": "Sven", "author_id": 32946, "author_profile": "https://wordpress.stackexchange.com/users/32946", "pm_score": 5, "selected": true, "text": "<p>Editing the privacy policy page is restricted to <code>manage_privacy_options</code> as pointed out in a comment ...
2018/11/08
[ "https://wordpress.stackexchange.com/questions/318666", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136930/" ]
In my WordPress installation `(4.9.8.)` the editor role isn't allowed to edit the privacy page. It would work with following in my `functions.php`: ``` $role_object = get_role( 'editor' ); $role_object->add_cap( 'manage_privacy_options', true ); $role_object->add_cap( 'manage_options' ); // this needs to be active in...
Editing the privacy policy page is restricted to `manage_privacy_options` as pointed out in a comment in the WordPress core file `wp-includes/capabilities.php`: ``` /* * Setting the privacy policy page requires `manage_privacy_options`, * so editing it should require that too. */ if ( (int) get_option( 'wp_page_for...
318,678
<p>How do I change the WordPress template used for the WooCommerce category pages?</p> <p>I can change the product pages by using the single-product.php template, but the category pages just use <strong>page.php</strong> which I don't want to modify because it is so sidely used.</p> <p>How do I modify this template a...
[ { "answer_id": 318680, "author": "kero", "author_id": 108180, "author_profile": "https://wordpress.stackexchange.com/users/108180", "pm_score": 1, "selected": false, "text": "<p>WooCommerce categories are called <code>product_cat</code>. If you check the <a href=\"https://wphierarchy.com...
2018/11/08
[ "https://wordpress.stackexchange.com/questions/318678", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88708/" ]
How do I change the WordPress template used for the WooCommerce category pages? I can change the product pages by using the single-product.php template, but the category pages just use **page.php** which I don't want to modify because it is so sidely used. How do I modify this template and only affect category pages?...
I had same problem and the solution is this ``` function mytheme_add_woocommerce_support() { add_theme_support( 'woocommerce' ); } add_action( 'after_setup_theme', 'mytheme_add_woocommerce_support' ); ```
318,704
<p>I am trying to update the field when post status changes to published. It is getting the values properly but not updating when I check the what update field is returning.</p> <p>It shows some number.</p> <p>Please help not sure whether I should use this along with <code>transition_post_status</code></p> <hr> <p>...
[ { "answer_id": 318912, "author": "mithun raval", "author_id": 153875, "author_profile": "https://wordpress.stackexchange.com/users/153875", "pm_score": 0, "selected": false, "text": "<p>try \"wpseo_title\" Filter for updating wpseo_title.</p>\n\n<pre><code>add_filter('wpseo_title', 'filt...
2018/11/08
[ "https://wordpress.stackexchange.com/questions/318704", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I am trying to update the field when post status changes to published. It is getting the values properly but not updating when I check the what update field is returning. It shows some number. Please help not sure whether I should use this along with `transition_post_status` --- **Update - I have tried below hooks*...
So I installed the [Yoast SEO plugin](https://yoast.com/wordpress/plugins/seo/), and tested your code, and now I can positively say "***neither no nor yes, but you could***" to this question: > > Please help not sure whether I should use this along with > `transition_post_status` > > > `transition_post_status` i...
318,751
<p>I'm using the Gutenberg editor as a replacement for a whiteboard in a classroom. I'm able to make the classroom more interactive by having students work directly inside the Gutenberg editor. As a long-term user of Wordpress it's truly wonderful to see this happen, with non-tech-savy users able to interact with the e...
[ { "answer_id": 318760, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 4, "selected": true, "text": "<blockquote>\n <p>I'm using the Gutenberg editor as a replacement for a whiteboard in a classroom. I'm \n able ...
2018/11/09
[ "https://wordpress.stackexchange.com/questions/318751", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34991/" ]
I'm using the Gutenberg editor as a replacement for a whiteboard in a classroom. I'm able to make the classroom more interactive by having students work directly inside the Gutenberg editor. As a long-term user of Wordpress it's truly wonderful to see this happen, with non-tech-savy users able to interact with the edit...
> > I'm using the Gutenberg editor as a replacement for a whiteboard in a classroom. I'm > able to make the classroom more interactive by having students work directly inside the > Gutenberg editor. > > > What a cool use of WordPress you describe there! > > Is it possible to load this script inside the Guten...
318,783
<p>New to WordPress programming (coming from a more conventional environment) and trying to understand some of its "unique" qualities.</p> <p>There is a directory page on our website and this code resides, that is in <code>functions.php</code>, tweaks the results if condition is true. </p> <pre><code>if( $query-&gt;i...
[ { "answer_id": 318785, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 1, "selected": false, "text": "<p>First up, the first thing you should do is read the <a href=\"https://developer.wordpress.org\" rel=\"n...
2018/11/09
[ "https://wordpress.stackexchange.com/questions/318783", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153797/" ]
New to WordPress programming (coming from a more conventional environment) and trying to understand some of its "unique" qualities. There is a directory page on our website and this code resides, that is in `functions.php`, tweaks the results if condition is true. ``` if( $query->is_post_type_archive( 'directory' ) ...
First up, the first thing you should do is read the [developer docs](https://developer.wordpress.org). This question touches on a lot of topics, and it's not going to be possible to explain them all in one answer. Anyway, `directory` would be a [Custom Post Type](https://developer.wordpress.org/plugins/post-types/) re...
318,801
<p>In May of 2016, I implemented several redirects on a client site using <code>.htaccess</code>. The client verified that all of the <code>.htaccess</code> redirects were working to their satisfaction before we closed out the project. </p> <p>This week, I was notified by the client that these redirects no longer wo...
[ { "answer_id": 318807, "author": "Remzi Cavdar", "author_id": 149484, "author_profile": "https://wordpress.stackexchange.com/users/149484", "pm_score": 0, "selected": false, "text": "<p>Enable the <strong>Apache mod_rewrite module.</strong><br>\nAnd enable the <strong>ReWriteEngine</stro...
2018/11/09
[ "https://wordpress.stackexchange.com/questions/318801", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64749/" ]
In May of 2016, I implemented several redirects on a client site using `.htaccess`. The client verified that all of the `.htaccess` redirects were working to their satisfaction before we closed out the project. This week, I was notified by the client that these redirects no longer work. They don't know when this bega...
> > > ``` > RedirectMatch 301 ^/watermeloncakes/ //www.clienturl.com/watermelon-cakes-1/ > > ``` > > (I assuming `www.clienturl.com` is the *hostname* for this site.) Well, here's the thing... this would never have worked on any version of Apache!? Because protocol-relative URLs are not supported by mod\_alias `...
318,804
<p>I am using this code to display all custom post types along with their count on the "At a Glance" dashboard widget:</p> <pre><code>add_action( 'dashboard_glance_items', 'cpad_at_glance_content_table_end' ); function cpad_at_glance_content_table_end() { $args = array( 'public' =&gt; true, '_builtin' =&gt; fa...
[ { "answer_id": 318813, "author": "rudtek", "author_id": 77767, "author_profile": "https://wordpress.stackexchange.com/users/77767", "pm_score": 3, "selected": true, "text": "<p>I think what you're after is:</p>\n\n<pre><code> // The user is logged, retrieve the user id (this needs to g...
2018/11/09
[ "https://wordpress.stackexchange.com/questions/318804", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153810/" ]
I am using this code to display all custom post types along with their count on the "At a Glance" dashboard widget: ``` add_action( 'dashboard_glance_items', 'cpad_at_glance_content_table_end' ); function cpad_at_glance_content_table_end() { $args = array( 'public' => true, '_builtin' => false, ); $output = 'o...
I think what you're after is: ``` // The user is logged, retrieve the user id (this needs to go above your foreach) $user_ID = get_current_user_id(); // Now we have got the user's id, we can pass it to the foreach of your function(this needs to go into your foreach: echo '<li>Number of '.$post_type->n...
318,816
<p>I installed the Siteimprove plugin to my client's WordPress website and I need to provide editor access to the plugin. Editors by default do not have any access to plugins. I tried to add the following to my <code>functions.php</code>:</p> <pre><code>if (!current_user_can('manage_options')) { add_menu_page( ...
[ { "answer_id": 318820, "author": "Quang Hoang", "author_id": 134874, "author_profile": "https://wordpress.stackexchange.com/users/134874", "pm_score": 1, "selected": false, "text": "<p>I have read the about this function and I see you need to parameter <code>capability</code> to allows t...
2018/11/10
[ "https://wordpress.stackexchange.com/questions/318816", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/115186/" ]
I installed the Siteimprove plugin to my client's WordPress website and I need to provide editor access to the plugin. Editors by default do not have any access to plugins. I tried to add the following to my `functions.php`: ``` if (!current_user_can('manage_options')) { add_menu_page( 'Siteimprove Plugin', ...
I have read the about this function and I see you need to parameter `capability` to allows the user can see the menu as an `admin` or `editor`. Read more the function to know detail: <https://developer.wordpress.org/reference/functions/add_menu_page/> And you can try this the following code. ``` /** * Register menu...
318,824
<p>Total newbie here. I'm a pretty good user of applications, but have never written a single line of code. Installed XAMPP and WP, purchased a template from Envato and plan on working on it over the weekend. Followed instructions for both WP and XAMPP, and all seems to be fine. Running solely on local machine, MAC ru...
[ { "answer_id": 318830, "author": "obiPlabon", "author_id": 135737, "author_profile": "https://wordpress.stackexchange.com/users/135737", "pm_score": 4, "selected": false, "text": "<p>Congratulation Jon, welcome to the WordPress world!</p>\n\n<p>To fix the issue, just add the following li...
2018/11/10
[ "https://wordpress.stackexchange.com/questions/318824", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153823/" ]
Total newbie here. I'm a pretty good user of applications, but have never written a single line of code. Installed XAMPP and WP, purchased a template from Envato and plan on working on it over the weekend. Followed instructions for both WP and XAMPP, and all seems to be fine. Running solely on local machine, MAC runnin...
Congratulation Jon, welcome to the WordPress world! To fix the issue, just add the following line of code in your installed WordPress's `wp-config.php` file. It's a PHP constant declaration which tells the WordPress to avoid the FTP. That's it. ``` define( 'FS_METHOD', 'direct' ); ``` For more info: <https://codex....
318,853
<p>When I activate WooCommerce plugin, the lost your password does not work and can't sent password reset email to users. But when I deactivate WooCommerce, the lost your password link at login page starts working. Is it possible to not use WooCommerce link because it is not working and changes the reset link.</p>
[ { "answer_id": 318857, "author": "jaze", "author_id": 146919, "author_profile": "https://wordpress.stackexchange.com/users/146919", "pm_score": 2, "selected": false, "text": "<p>I hope think this may work.</p>\n\n<p>Insert this code into php file or php insert plugin, WooCommerce will no...
2018/11/10
[ "https://wordpress.stackexchange.com/questions/318853", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/146919/" ]
When I activate WooCommerce plugin, the lost your password does not work and can't sent password reset email to users. But when I deactivate WooCommerce, the lost your password link at login page starts working. Is it possible to not use WooCommerce link because it is not working and changes the reset link.
I hope think this may work. Insert this code into php file or php insert plugin, WooCommerce will no longer change password reset link. ``` function reset_pass_url() { $siteURL = get_option('siteurl'); return "{$siteURL}/wp-login.php?action=lostpassword"; } add_filter( 'lostpassword_url', 'reset_pass_url', 11...
318,892
<p>I am currently using Wordpress, and an element of user_registered returns the time of registration of the user. I have set the correct timezone, but don't know how to get the user_registered output to match my current time. So far, this is what I have.</p> <pre><code> date_default_timezone_set('America/Los_Angeles...
[ { "answer_id": 318989, "author": "Amir", "author_id": 80135, "author_profile": "https://wordpress.stackexchange.com/users/80135", "pm_score": -1, "selected": false, "text": "<p>On the <strong>Settings > General</strong> page, find the section labeled <strong>Timezone</strong>. Select a c...
2018/11/11
[ "https://wordpress.stackexchange.com/questions/318892", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153866/" ]
I am currently using Wordpress, and an element of user\_registered returns the time of registration of the user. I have set the correct timezone, but don't know how to get the user\_registered output to match my current time. So far, this is what I have. ``` date_default_timezone_set('America/Los_Angeles'); $us...
You can get the time offset from WordPress Settings using ``` get_option( 'gmt_offset' ) ``` So I found the easiest method is to do this: ``` gmdate( 'Y-m-d H:i:s', strtotime( get_option( 'gmt_offset' ) . ' hours', strtotime( $udata->user_registered ) ) ) ```
318,920
<p>I'm new here, and new using Wordpress I'm creating a website, <a href="https://www.maispersona.com" rel="nofollow noreferrer">https://www.maispersona.com</a> and I'm trying to modify my search page layout. (You can get into the website and search something to see)</p> <p>I'm using the Elementor plugin. But I'm gett...
[ { "answer_id": 318989, "author": "Amir", "author_id": 80135, "author_profile": "https://wordpress.stackexchange.com/users/80135", "pm_score": -1, "selected": false, "text": "<p>On the <strong>Settings > General</strong> page, find the section labeled <strong>Timezone</strong>. Select a c...
2018/11/11
[ "https://wordpress.stackexchange.com/questions/318920", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153892/" ]
I'm new here, and new using Wordpress I'm creating a website, <https://www.maispersona.com> and I'm trying to modify my search page layout. (You can get into the website and search something to see) I'm using the Elementor plugin. But I'm getting an issue when I try to remove a grey colored div, with a search result i...
You can get the time offset from WordPress Settings using ``` get_option( 'gmt_offset' ) ``` So I found the easiest method is to do this: ``` gmdate( 'Y-m-d H:i:s', strtotime( get_option( 'gmt_offset' ) . ' hours', strtotime( $udata->user_registered ) ) ) ```
318,965
<p>I want to remove it COMPLETELY. Not only the label "Archive: " but EVERYTHING. It should not appear. I've been looking for the solution for hours to no avail.</p> <p>Please help. Thank you!</p>
[ { "answer_id": 318989, "author": "Amir", "author_id": 80135, "author_profile": "https://wordpress.stackexchange.com/users/80135", "pm_score": -1, "selected": false, "text": "<p>On the <strong>Settings > General</strong> page, find the section labeled <strong>Timezone</strong>. Select a c...
2018/11/12
[ "https://wordpress.stackexchange.com/questions/318965", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153772/" ]
I want to remove it COMPLETELY. Not only the label "Archive: " but EVERYTHING. It should not appear. I've been looking for the solution for hours to no avail. Please help. Thank you!
You can get the time offset from WordPress Settings using ``` get_option( 'gmt_offset' ) ``` So I found the easiest method is to do this: ``` gmdate( 'Y-m-d H:i:s', strtotime( get_option( 'gmt_offset' ) . ' hours', strtotime( $udata->user_registered ) ) ) ```
319,028
<p>I'm trying to override a method (<code>my_packages</code>) from the <code>WP Job Manager Paid Listings</code> plugin by extending it's class from within a custom plugin</p> <p>Here is how the source code (none-related code removed) is set up...</p> <pre><code>class WC_Paid_Listings_Orders { private static $inst...
[ { "answer_id": 319032, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 1, "selected": true, "text": "<p>Problem lies in this line:</p>\n\n<pre><code>remove_action('woocommerce_before_my_account', array( $th...
2018/11/12
[ "https://wordpress.stackexchange.com/questions/319028", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57057/" ]
I'm trying to override a method (`my_packages`) from the `WP Job Manager Paid Listings` plugin by extending it's class from within a custom plugin Here is how the source code (none-related code removed) is set up... ``` class WC_Paid_Listings_Orders { private static $instance; public static function get_instanc...
Problem lies in this line: ``` remove_action('woocommerce_before_my_account', array( $this, 'my_packages')); ``` This won't remove action registered by parent class, because `$this` is a different object in this case, so you won't remove any action at all. So how to remove such action? Since you can't access the sa...
319,035
<p>I would like to display a dropdown list of categories (or other taxonomy) inside of a Gutenberg block. I can only think of two ways to do this:</p> <ol> <li>Create an array of the taxonomy in php and use <code>wp_localize_script</code> to make that data available to my block javascript.</li> <li>Use <code>fetch()</...
[ { "answer_id": 320481, "author": "Chad Holden", "author_id": 154908, "author_profile": "https://wordpress.stackexchange.com/users/154908", "pm_score": 1, "selected": false, "text": "<p>Load the elements into a constant using a function like this: </p>\n\n<pre><code>const postSelections =...
2018/11/12
[ "https://wordpress.stackexchange.com/questions/319035", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2044/" ]
I would like to display a dropdown list of categories (or other taxonomy) inside of a Gutenberg block. I can only think of two ways to do this: 1. Create an array of the taxonomy in php and use `wp_localize_script` to make that data available to my block javascript. 2. Use `fetch()`? in the block to reach out to the a...
You don't need `apiFetch` or localization to get a list of all categories. You can do this with the `wp.data` module: ``` wp.data.select('core').getEntityRecords('taxonomy', 'category'); ``` See the [Gutenberg Handbook](https://wordpress.org/gutenberg/handbook/designers-developers/developers/data/data-core/) entry o...
319,054
<p>So I have a metabox which I want to trigger some Javascript when a post is saved (to refresh the page in this use case.) </p> <p>In Classic Editor, this can be done via a simple redirect hooked to <code>save_post</code> (with a high priority)</p> <p>But since Gutenberg converts the saving process for existing meta...
[ { "answer_id": 319071, "author": "majick", "author_id": 76440, "author_profile": "https://wordpress.stackexchange.com/users/76440", "pm_score": 3, "selected": true, "text": "<p>Okay, so way way more hacky solution than I wanted, but got it working...</p>\n\n<p>Here is a slightly simplifi...
2018/11/13
[ "https://wordpress.stackexchange.com/questions/319054", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/76440/" ]
So I have a metabox which I want to trigger some Javascript when a post is saved (to refresh the page in this use case.) In Classic Editor, this can be done via a simple redirect hooked to `save_post` (with a high priority) But since Gutenberg converts the saving process for existing metaboxes into individual AJAX c...
Okay, so way way more hacky solution than I wanted, but got it working... Here is a slightly simplified and abstracted way of doing it from my code, in case anyone ever needs to do the same (as I'm sure more plugins will in the near future.) ``` var reload_check = false; var publish_button_click = false; jQue...
319,057
<p>I've tried to find the information on the Internet and stackoverflow, but there is nothing about it.</p> <p>So I've migrated my website(html,css,js) to WordPress(index.php,header.php,footer.php etc) and I can't figure out how to change a view of posts before adding them to my site.</p> <p>I can see 4 ways of doing...
[ { "answer_id": 319071, "author": "majick", "author_id": 76440, "author_profile": "https://wordpress.stackexchange.com/users/76440", "pm_score": 3, "selected": true, "text": "<p>Okay, so way way more hacky solution than I wanted, but got it working...</p>\n\n<p>Here is a slightly simplifi...
2018/11/13
[ "https://wordpress.stackexchange.com/questions/319057", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153976/" ]
I've tried to find the information on the Internet and stackoverflow, but there is nothing about it. So I've migrated my website(html,css,js) to WordPress(index.php,header.php,footer.php etc) and I can't figure out how to change a view of posts before adding them to my site. I can see 4 ways of doing that: 1)Downloa...
Okay, so way way more hacky solution than I wanted, but got it working... Here is a slightly simplified and abstracted way of doing it from my code, in case anyone ever needs to do the same (as I'm sure more plugins will in the near future.) ``` var reload_check = false; var publish_button_click = false; jQue...
319,129
<p>I thought this question would be an easy find on the internet… however, it seems no one has ever ran into this issue before.</p> <p>There's no problem in listing a search query when you enter your search term, <strong>I needed posts and pages to be differentiated in a way</strong>. For example: I'd like results tha...
[ { "answer_id": 319132, "author": "vm7488", "author_id": 71492, "author_profile": "https://wordpress.stackexchange.com/users/71492", "pm_score": 0, "selected": false, "text": "<p>…Figured it out… 5 minutes later…</p>\n\n<pre><code> $queryIsPost = (get_post_type() === 'post') ? true : f...
2018/11/13
[ "https://wordpress.stackexchange.com/questions/319129", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/71492/" ]
I thought this question would be an easy find on the internet… however, it seems no one has ever ran into this issue before. There's no problem in listing a search query when you enter your search term, **I needed posts and pages to be differentiated in a way**. For example: I'd like results that are posts (articles) ...
That will only tell you if it's a Post or a Page. What if it's a category, tag, archive, or custom post type? Here's how I'd write that, if you care. ``` function xyz_get_post_type_name() { $wp_type = get_post_type( get_the_ID() ); switch ($wp_type) { case 'post' : $type_name = 'Article'; ...
319,139
<p>I have a site we needed some custom php coding to connect to an external database to grab product review urls for several vendors that sell our products. The basic idea we are trying to accomplish is to have the user register their product and then extend their warranty if they are willing to leave a review. I'm usi...
[ { "answer_id": 319141, "author": "firxworx", "author_id": 134244, "author_profile": "https://wordpress.stackexchange.com/users/134244", "pm_score": 2, "selected": false, "text": "<p>Your JS looks to be written inline vs. in its own JS file or at least enqueued on its own. In other words,...
2018/11/13
[ "https://wordpress.stackexchange.com/questions/319139", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/154032/" ]
I have a site we needed some custom php coding to connect to an external database to grab product review urls for several vendors that sell our products. The basic idea we are trying to accomplish is to have the user register their product and then extend their warranty if they are willing to leave a review. I'm using ...
Your JS looks to be written inline vs. in its own JS file or at least enqueued on its own. In other words, it doesn't look like its being loaded properly re WordPress. Note the WP function `wp_enqueue_script()` has a dependency parameter where you can pass an array of script handles (as registered via `wp_register_sc...
319,181
<p>I am having some trouble getting rewrite rules to work as I want in my a WordPress plugin.</p> <p>I added a rewrite rule:</p> <pre><code>add_rewrite_rule('some_url','some_redirected_url', 'top'); </code></pre> <p>The rule is written to .htaccess and the rule works as expected; when inspecting the $_SERVER variabl...
[ { "answer_id": 319141, "author": "firxworx", "author_id": 134244, "author_profile": "https://wordpress.stackexchange.com/users/134244", "pm_score": 2, "selected": false, "text": "<p>Your JS looks to be written inline vs. in its own JS file or at least enqueued on its own. In other words,...
2018/11/14
[ "https://wordpress.stackexchange.com/questions/319181", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153999/" ]
I am having some trouble getting rewrite rules to work as I want in my a WordPress plugin. I added a rewrite rule: ``` add_rewrite_rule('some_url','some_redirected_url', 'top'); ``` The rule is written to .htaccess and the rule works as expected; when inspecting the $\_SERVER variable I get the following: > > $\_...
Your JS looks to be written inline vs. in its own JS file or at least enqueued on its own. In other words, it doesn't look like its being loaded properly re WordPress. Note the WP function `wp_enqueue_script()` has a dependency parameter where you can pass an array of script handles (as registered via `wp_register_sc...
319,214
<p>EDIT: Turns out the solution was to simply re-install wordpress (it was a new blog anyways). Still not sure what the issue really was but that solved it.</p> <p>I have tried every single fix on stackexchange and other websites and nothing has resolved the issue. </p> <p>I have checked to see that wp_ is in front o...
[ { "answer_id": 319196, "author": "vikrant zilpe", "author_id": 153928, "author_profile": "https://wordpress.stackexchange.com/users/153928", "pm_score": 1, "selected": false, "text": "<p>Please, enable the debug mode in WordPress maybe there will be answer. To enable it, open your wp-con...
2018/11/14
[ "https://wordpress.stackexchange.com/questions/319214", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/154094/" ]
EDIT: Turns out the solution was to simply re-install wordpress (it was a new blog anyways). Still not sure what the issue really was but that solved it. I have tried every single fix on stackexchange and other websites and nothing has resolved the issue. I have checked to see that wp\_ is in front of all my tables....
Please, enable the debug mode in WordPress maybe there will be answer. To enable it, open your wp-config.php file and look for define(‘WP\_DEBUG’, false);. Change it to: 'define('WP\_DEBUG', true);' In order to enable the error logging to a file on the server you need to add yet one more similar line: 'define( 'WP\_...
319,215
<p>i am using ACF to <a href="https://www.advancedcustomfields.com/resources/date-picker/" rel="nofollow noreferrer">display an internationalized date</a> with this code :</p> <pre><code>&lt;?php $dateformatstring = "l j F Y"; $unixtimestamp = strtotime(get_field('date')); ?&gt; &lt;?php echo date_i18n($datef...
[ { "answer_id": 319216, "author": "studiok7", "author_id": 150027, "author_profile": "https://wordpress.stackexchange.com/users/150027", "pm_score": 2, "selected": false, "text": "<p>thanks to @kero, i managed to do something like this :</p>\n\n<pre><code>&lt;?php\n $dayNumber = \"l\";...
2018/11/14
[ "https://wordpress.stackexchange.com/questions/319215", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/150027/" ]
i am using ACF to [display an internationalized date](https://www.advancedcustomfields.com/resources/date-picker/) with this code : ``` <?php $dateformatstring = "l j F Y"; $unixtimestamp = strtotime(get_field('date')); ?> <?php echo date_i18n($dateformatstring, $unixtimestamp); ?> ``` but i wish i could se...
thanks to @kero, i managed to do something like this : ``` <?php $dayNumber = "l"; $weekDay = "j"; $month = "F"; $year = "Y"; $unixtimestamp = strtotime(get_field('date')); ?> <?php echo '<span>' . date_i18n($dayNumber, $unixtimestamp) . '</span>'; ?> <?php echo '<span>' . date_i18n($weekDay, $uni...
319,259
<p>I want to get all post which was posted on X Days, I don't want 7 days old post or 1 Month old posts, Because it will return all posts which will be older 7 days or one month. Like Today is 15 SEP, I want to get all posts which was post on 5 SEP. Only 5 sep not older then 5 SEP. Only one Day posts. I have try code ...
[ { "answer_id": 319216, "author": "studiok7", "author_id": 150027, "author_profile": "https://wordpress.stackexchange.com/users/150027", "pm_score": 2, "selected": false, "text": "<p>thanks to @kero, i managed to do something like this :</p>\n\n<pre><code>&lt;?php\n $dayNumber = \"l\";...
2018/11/15
[ "https://wordpress.stackexchange.com/questions/319259", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100690/" ]
I want to get all post which was posted on X Days, I don't want 7 days old post or 1 Month old posts, Because it will return all posts which will be older 7 days or one month. Like Today is 15 SEP, I want to get all posts which was post on 5 SEP. Only 5 sep not older then 5 SEP. Only one Day posts. I have try code lik...
thanks to @kero, i managed to do something like this : ``` <?php $dayNumber = "l"; $weekDay = "j"; $month = "F"; $year = "Y"; $unixtimestamp = strtotime(get_field('date')); ?> <?php echo '<span>' . date_i18n($dayNumber, $unixtimestamp) . '</span>'; ?> <?php echo '<span>' . date_i18n($weekDay, $uni...
319,271
<p>A client of mine has installed contact form 7 for their contact forms but they're getting an error in the From field "(configuration error) Invalid mailbox syntax is used."</p> <p>The form looks like this:</p> <pre><code>[text text-54 placeholder "Your Name"][text text-54 placeholder "Your Company"] [email* email-...
[ { "answer_id": 319275, "author": "vikrant zilpe", "author_id": 153928, "author_profile": "https://wordpress.stackexchange.com/users/153928", "pm_score": 0, "selected": false, "text": "<p><strong>Invalid mailbox syntax is used Error</strong></p>\n\n<p>You can find Invalid mailbox syntax i...
2018/11/15
[ "https://wordpress.stackexchange.com/questions/319271", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/154129/" ]
A client of mine has installed contact form 7 for their contact forms but they're getting an error in the From field "(configuration error) Invalid mailbox syntax is used." The form looks like this: ``` [text text-54 placeholder "Your Name"][text text-54 placeholder "Your Company"] [email* email-317 placeholder "Emai...
**Invalid mailbox syntax is used Error** You can find Invalid mailbox syntax is used error under the To, From, Subject or Additional Headers fields, that are located in the Mail Contact Form tab. solve “Your contact form has a configuration issue” error You have to solve this error. Otherwise, your email might not r...
319,297
<p>I am trying to filter a query to only show posts that are posted by a user with the administrator role.</p> <p>I've created a pre_get_posts action, and trying to use $query->set to filter the posts only in the category pages...</p> <p>So far I have this</p> <pre><code>function remove_unvetted_authors() { $que...
[ { "answer_id": 319301, "author": "kero", "author_id": 108180, "author_profile": "https://wordpress.stackexchange.com/users/108180", "pm_score": 0, "selected": false, "text": "<pre><code>function remove_unvetted_authors() {\n $ids = get_users( array('role' =&gt; 'administrator' ,'field...
2018/11/15
[ "https://wordpress.stackexchange.com/questions/319297", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/111198/" ]
I am trying to filter a query to only show posts that are posted by a user with the administrator role. I've created a pre\_get\_posts action, and trying to use $query->set to filter the posts only in the category pages... So far I have this ``` function remove_unvetted_authors() { $query->set( 'role', 'administ...
There's quite a few issues with this code: 1. `$query` is not defined in your callback function. 2. `role` is not a valid argument for a query. 3. You're passing the `$ids` variable incorrectly. 4. To query for multiple authors you need to use `author__in`. 5. You're checking `is_category()` incorrectly. For the firs...
319,306
<p>Under the appearance admin menu, I have customizer added by the theme, and theme options added by a plugin. I'm using this code to hide both menus ( submenu's of Appearance )for ALL admins apart from a certain USERNAME. </p> <pre><code>function hide_menu() { global $current_user; $current_user = wp_get_cur...
[ { "answer_id": 319554, "author": "coolpasta", "author_id": 143406, "author_profile": "https://wordpress.stackexchange.com/users/143406", "pm_score": 4, "selected": true, "text": "<p>Direct answer:</p>\n\n<pre><code>add_action( 'admin_menu', function() {\n global $current_user;\n $c...
2018/11/15
[ "https://wordpress.stackexchange.com/questions/319306", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62291/" ]
Under the appearance admin menu, I have customizer added by the theme, and theme options added by a plugin. I'm using this code to hide both menus ( submenu's of Appearance )for ALL admins apart from a certain USERNAME. ``` function hide_menu() { global $current_user; $current_user = wp_get_current_user(); ...
Direct answer: ``` add_action( 'admin_menu', function() { global $current_user; $current_user = wp_get_current_user(); $user_name = $current_user->user_login; //check condition for the user means show menu for this user if(is_admin() && $user_name != 'USERNAME') { //We need th...
319,308
<p>I'm using the Advanced Custom Fields plugin and I have created some options pages with:</p> <pre><code>if (function_exists('acf_add_options_page')) { website_settings_init(); } function website_settings_init() { $website_settings = acf_add_options_page(array( 'page_title' =&gt; 'Website Settings', ...
[ { "answer_id": 324917, "author": "Zeth", "author_id": 128304, "author_profile": "https://wordpress.stackexchange.com/users/128304", "pm_score": 3, "selected": true, "text": "<p>I just had the same problem. It's <strong><em>insanely</em></strong> poorly documented on <a href=\"https://www...
2018/11/15
[ "https://wordpress.stackexchange.com/questions/319308", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/39063/" ]
I'm using the Advanced Custom Fields plugin and I have created some options pages with: ``` if (function_exists('acf_add_options_page')) { website_settings_init(); } function website_settings_init() { $website_settings = acf_add_options_page(array( 'page_title' => 'Website Settings', 'menu_tit...
I just had the same problem. It's ***insanely*** poorly documented on [ACF's pages](https://www.advancedcustomfields.com/resources/get-values-from-an-options-page/) (as in, not there at all). The core of your problem is, that you have spaces in your options-page names. And when you access it, using the 'ID', then you...
319,337
<p>The default web address for a domain is:</p> <pre><code>https://www.example.com </code></pre> <p>If I set this as the 'Site Address (URL)' in Wordpress then it seems to take care of the necessary http -> https and non-www -> www redirection on it's own.</p> <p>The problem is though is that Wordpress redirects the...
[ { "answer_id": 319338, "author": "kero", "author_id": 108180, "author_profile": "https://wordpress.stackexchange.com/users/108180", "pm_score": 1, "selected": false, "text": "<p>Just do it in your .htaccess, it will be alot simpler. The important thing is that the rules are <strong>above...
2018/11/15
[ "https://wordpress.stackexchange.com/questions/319337", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29524/" ]
The default web address for a domain is: ``` https://www.example.com ``` If I set this as the 'Site Address (URL)' in Wordpress then it seems to take care of the necessary http -> https and non-www -> www redirection on it's own. The problem is though is that Wordpress redirects the following first: ``` http://exa...
Just do it in your .htaccess, it will be alot simpler. The important thing is that the rules are **above** WordPress' rules. Setting **L** also states, that this shall be the last rule evaluated if a match was found ``` # Redirect to https RewriteEngine On RewriteCond %{HTTPS} off RewriteRule ^(.*)$ https://www.exampl...
319,346
<p>In WooCommerce admin settings (/wp-admin/admin.php?page=wc-settings) there are several fields to set the store address (street, city, country).</p> <p>How can one retrieve this in a theme's templates? I wouldn't want to hardcode such informations into the theme.</p>
[ { "answer_id": 319351, "author": "butlerblog", "author_id": 38603, "author_profile": "https://wordpress.stackexchange.com/users/38603", "pm_score": 0, "selected": false, "text": "<p>There's not a specific function in WooCommerce to return shop (or other) URLs (at least that I know of). ...
2018/11/15
[ "https://wordpress.stackexchange.com/questions/319346", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/77030/" ]
In WooCommerce admin settings (/wp-admin/admin.php?page=wc-settings) there are several fields to set the store address (street, city, country). How can one retrieve this in a theme's templates? I wouldn't want to hardcode such informations into the theme.
The physical address of the store (and many other settings) are stored in WP's options table (wp\_options where "wp\_" is the table prefix being used on the site). The option names are: * woocommerce\_store\_address * woocommerce\_store\_address\_2 * woocommerce\_store\_city * woocommerce\_store\_postcode * woocommer...
319,373
<p>I have added this to my <code>functions.php</code> and need to use <code>ajaxURL</code> in all of enqueued scripts in the template (instead of enqueuing only one script here</p> <pre><code>add_action( 'wp_enqueue_scripts', 'ajaxify_enqueue_scripts' ); function ajaxify_enqueue_scripts() { wp_localize_script( 'aja...
[ { "answer_id": 319374, "author": "vikrant zilpe", "author_id": 153928, "author_profile": "https://wordpress.stackexchange.com/users/153928", "pm_score": 1, "selected": false, "text": "<p>To have the ajaxurl variable available on the frontend the easiest way is to add this snippet to you ...
2018/11/16
[ "https://wordpress.stackexchange.com/questions/319373", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31793/" ]
I have added this to my `functions.php` and need to use `ajaxURL` in all of enqueued scripts in the template (instead of enqueuing only one script here ``` add_action( 'wp_enqueue_scripts', 'ajaxify_enqueue_scripts' ); function ajaxify_enqueue_scripts() { wp_localize_script( 'ajaxify', 'ajaxURL', array('ajax_url' =...
You can conditionally echo the code on only few templates or specific pages. Here is an example: ``` add_action ( 'wp_head', 'my_js_variables' ); function my_js_variables(){ // for specific page templates $current_template = get_page_template(); // return if there is no page template, or if the page template i...
319,378
<p>In Woocommerce Category page default sort dropdown has like below options. <a href="https://i.stack.imgur.com/Qt6Yh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qt6Yh.png" alt="enter image description here"></a></p> <p>My question is what/how products sort by Popularity ? <strong>Not a code</...
[ { "answer_id": 319374, "author": "vikrant zilpe", "author_id": 153928, "author_profile": "https://wordpress.stackexchange.com/users/153928", "pm_score": 1, "selected": false, "text": "<p>To have the ajaxurl variable available on the frontend the easiest way is to add this snippet to you ...
2018/11/16
[ "https://wordpress.stackexchange.com/questions/319378", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/152021/" ]
In Woocommerce Category page default sort dropdown has like below options. [![enter image description here](https://i.stack.imgur.com/Qt6Yh.png)](https://i.stack.imgur.com/Qt6Yh.png) My question is what/how products sort by Popularity ? **Not a code** What is the **measurement** ? like if sort Price: Low to High,then ...
You can conditionally echo the code on only few templates or specific pages. Here is an example: ``` add_action ( 'wp_head', 'my_js_variables' ); function my_js_variables(){ // for specific page templates $current_template = get_page_template(); // return if there is no page template, or if the page template i...
319,416
<p>I have downloaded a theme and installed it. Here the theme has custom fields for limited numbers. For ex. <code>author_name</code>, <code>comments</code> but, I want all the wp_posts to be displayed.</p> <p>And prior to that, actually I have a database associated with this. So basically I want my piece of code to r...
[ { "answer_id": 319374, "author": "vikrant zilpe", "author_id": 153928, "author_profile": "https://wordpress.stackexchange.com/users/153928", "pm_score": 1, "selected": false, "text": "<p>To have the ajaxurl variable available on the frontend the easiest way is to add this snippet to you ...
2018/11/16
[ "https://wordpress.stackexchange.com/questions/319416", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/154200/" ]
I have downloaded a theme and installed it. Here the theme has custom fields for limited numbers. For ex. `author_name`, `comments` but, I want all the wp\_posts to be displayed. And prior to that, actually I have a database associated with this. So basically I want my piece of code to read the whole database and repr...
You can conditionally echo the code on only few templates or specific pages. Here is an example: ``` add_action ( 'wp_head', 'my_js_variables' ); function my_js_variables(){ // for specific page templates $current_template = get_page_template(); // return if there is no page template, or if the page template i...
319,428
<p>I am trying to make a page that queries every post of a specific category ("attractions").</p> <p>I have been able to get the posts successfully, I just need to make the modals work. </p> <p>I have made a button inside of my loop which has the title of whatever post the loop is on. I want it so whenever people cli...
[ { "answer_id": 319374, "author": "vikrant zilpe", "author_id": 153928, "author_profile": "https://wordpress.stackexchange.com/users/153928", "pm_score": 1, "selected": false, "text": "<p>To have the ajaxurl variable available on the frontend the easiest way is to add this snippet to you ...
2018/11/16
[ "https://wordpress.stackexchange.com/questions/319428", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153268/" ]
I am trying to make a page that queries every post of a specific category ("attractions"). I have been able to get the posts successfully, I just need to make the modals work. I have made a button inside of my loop which has the title of whatever post the loop is on. I want it so whenever people click on that button...
You can conditionally echo the code on only few templates or specific pages. Here is an example: ``` add_action ( 'wp_head', 'my_js_variables' ); function my_js_variables(){ // for specific page templates $current_template = get_page_template(); // return if there is no page template, or if the page template i...
319,448
<p>I want to add a sentence at the beginning of all posts of content directly into the post_content WordPress database. How do I? Either through the <code>function.php</code> or the MySQL command.</p>
[ { "answer_id": 319449, "author": "butlerblog", "author_id": 38603, "author_profile": "https://wordpress.stackexchange.com/users/38603", "pm_score": 2, "selected": false, "text": "<p>Rather than insert it directly into the db, why don't you add it to the content when displayed using <code...
2018/11/16
[ "https://wordpress.stackexchange.com/questions/319448", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/154216/" ]
I want to add a sentence at the beginning of all posts of content directly into the post\_content WordPress database. How do I? Either through the `function.php` or the MySQL command.
I'd go for solution posted by @butlerblog - it's a lot easier to manage and change in the future and it's better WP practice. But... If you're asking... Here are the ways you can do this: 1. WP way: ---------- ``` function prepend_content_to_posts() { $to_prepend = 'This will be prepended'; $posts = get_po...
319,474
<p>I'm working on a client's build, and I'd like to change as little as possible. I'm not too familiar with all this, my apologies - I'll try to show where I'm at.</p> <p>The client wants a form submission to prompt a PDF download. There are two different PDFs, two instances of the same form. Fill out form instance 1,...
[ { "answer_id": 319627, "author": "Parth Shah", "author_id": 154328, "author_profile": "https://wordpress.stackexchange.com/users/154328", "pm_score": 1, "selected": true, "text": "<p>You don't need much code for it. just goto contact form > select contact form > additional setting, paste...
2018/11/17
[ "https://wordpress.stackexchange.com/questions/319474", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/154223/" ]
I'm working on a client's build, and I'd like to change as little as possible. I'm not too familiar with all this, my apologies - I'll try to show where I'm at. The client wants a form submission to prompt a PDF download. There are two different PDFs, two instances of the same form. Fill out form instance 1, get PDF A...
You don't need much code for it. just goto contact form > select contact form > additional setting, paste below code. `document.addEventListener( 'wpcf7mailsent', function( event ) { location = 'YOUR_PDF_URL';}, false );`
319,485
<p>I am creating a custom theme with my own HTML. I am trying to override woocommerce template. I have created a template named with <code>woocommerce.php</code> but it still shows template with default structure.</p> <p>I checked the system status and it says that <code>Your theme has a woocommerce.php file, you will...
[ { "answer_id": 319683, "author": "nmr", "author_id": 147428, "author_profile": "https://wordpress.stackexchange.com/users/147428", "pm_score": 3, "selected": false, "text": "<p>It's a custom theme, so first of all you should check if WooCommerce support is declared in the <code>functions...
2018/11/17
[ "https://wordpress.stackexchange.com/questions/319485", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/53934/" ]
I am creating a custom theme with my own HTML. I am trying to override woocommerce template. I have created a template named with `woocommerce.php` but it still shows template with default structure. I checked the system status and it says that `Your theme has a woocommerce.php file, you will not be able to override t...
I fix that by disabling Woocommerce template debug mode in config.php. ``` define( 'WC_TEMPLATE_DEBUG_MODE', false ); ``` You can check if the template debug mode is set via: WP Dashboard -> WooCommerce -> System Status -> Tools
319,494
<p>hy all, I have streaming site, and want to make a toggle button to switch to Dark/light mode using jQuery. please look to my code, what is wrong with my code, bcz this is not work for me.</p> <p>in footer.php (above &lt;/body>)</p> <pre><code>&lt;div class="gelap-terang"&gt;&lt;/div&gt; &lt;script&gt; jQuery.noCon...
[ { "answer_id": 319497, "author": "BlesssMe", "author_id": 154241, "author_profile": "https://wordpress.stackexchange.com/users/154241", "pm_score": -1, "selected": false, "text": "<p>I found this Solution <a href=\"https://stackoverflow.com/questions/33212905/custom-jquery-is-not-working...
2018/11/17
[ "https://wordpress.stackexchange.com/questions/319494", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/154241/" ]
hy all, I have streaming site, and want to make a toggle button to switch to Dark/light mode using jQuery. please look to my code, what is wrong with my code, bcz this is not work for me. in footer.php (above </body>) ``` <div class="gelap-terang"></div> <script> jQuery.noConflict(); jQuery(document).ready(function(...
error is coming because of jQuery.noConflict(); You do not need to add jQuery.noConflict(); in wordpress files because by default wordpress supports jQuery but if you want to use $ then you can use this way without using wp\_enqueue\_script("jquery") If the script is being loaded in the footer (which you should be ...
319,495
<p>I suddenly can't access <code>company.co.za/wp-admin</code>, as it redirects to</p> <pre><code>http://company.co.za/wp-login.php?redirect_to=http%3A%2F%company.co.za%2Fwp-admin%2F&amp;reauth=1 </code></pre> <p>with error 500</p> <p>What should I do to resolve this?</p> <p>I know I can try disabling all plugins, ...
[ { "answer_id": 319523, "author": "Rick Hellewell", "author_id": 29416, "author_profile": "https://wordpress.stackexchange.com/users/29416", "pm_score": 1, "selected": false, "text": "<p>500 errors are hard to diagnose; they are sort of generic. Sometimes the access logs will give you hin...
2018/11/17
[ "https://wordpress.stackexchange.com/questions/319495", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120533/" ]
I suddenly can't access `company.co.za/wp-admin`, as it redirects to ``` http://company.co.za/wp-login.php?redirect_to=http%3A%2F%company.co.za%2Fwp-admin%2F&reauth=1 ``` with error 500 What should I do to resolve this? I know I can try disabling all plugins, but how do I do that without loggin into wp dashboard? ...
There are so many for internal server error. The main reasons for internal server errors are. 1. Corrupt .htaccess file 2. PHP Memory limit 3. Corrupted plugin 4. Incompatible PHP version 5. Corrupted core files In oder to fix this issue, you need to investigate in step by step order. To solve this issue first of al...
319,550
<p>I have written my custom <code>WP_Query</code> and using loop to display post content. I use <code>get_the_category()</code> to display categories of current post and it works fine. Now for some post types there are custom taxonomies instead of categories. </p> <p><strong>Code to get categories</strong>:</p> <pre>...
[ { "answer_id": 319551, "author": "De Coder", "author_id": 144159, "author_profile": "https://wordpress.stackexchange.com/users/144159", "pm_score": 0, "selected": false, "text": "<p>Take a look at these:</p>\n\n<pre><code>$taxonomies = get_post_taxonomies( );\nprint_r( $taxonomies );\nec...
2018/11/18
[ "https://wordpress.stackexchange.com/questions/319550", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/132878/" ]
I have written my custom `WP_Query` and using loop to display post content. I use `get_the_category()` to display categories of current post and it works fine. Now for some post types there are custom taxonomies instead of categories. **Code to get categories**: ``` $categories = get_the_category(); if(!empty($ca...
The first problem with your code, I guess, is that you use [`get_the_taxonomies`](https://codex.wordpress.org/Function_Reference/get_post_taxonomies) function, which will: > > Retrieve all taxonomies of a post with just the names. > > > So its result will be like this: ``` Array ( [0] => category [1] => ...
319,576
<p>I am working on a WordPress website in which there are a lot of wordpress plugins installed.</p> <p>The plugins installed on the wordpress website has the following options:</p> <p><a href="https://i.stack.imgur.com/iaLC9.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iaLC9.jpg" alt="enter imag...
[ { "answer_id": 319551, "author": "De Coder", "author_id": 144159, "author_profile": "https://wordpress.stackexchange.com/users/144159", "pm_score": 0, "selected": false, "text": "<p>Take a look at these:</p>\n\n<pre><code>$taxonomies = get_post_taxonomies( );\nprint_r( $taxonomies );\nec...
2018/11/18
[ "https://wordpress.stackexchange.com/questions/319576", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/151467/" ]
I am working on a WordPress website in which there are a lot of wordpress plugins installed. The plugins installed on the wordpress website has the following options: [![enter image description here](https://i.stack.imgur.com/iaLC9.jpg)](https://i.stack.imgur.com/iaLC9.jpg) When I click on View details option, I am ...
The first problem with your code, I guess, is that you use [`get_the_taxonomies`](https://codex.wordpress.org/Function_Reference/get_post_taxonomies) function, which will: > > Retrieve all taxonomies of a post with just the names. > > > So its result will be like this: ``` Array ( [0] => category [1] => ...
319,585
<p>I have a specific dropdown field on variable products on my WooCommerce site that only ever has one option available. Example: the customer chooses the item “type”, then “color”, and finally “part number”, where “part number” dropdown always has just one option.</p> <p>I want to configure the site to remove the cho...
[ { "answer_id": 319604, "author": "Aparna_29", "author_id": 84165, "author_profile": "https://wordpress.stackexchange.com/users/84165", "pm_score": 2, "selected": false, "text": "<p>Following code solves the purpose:</p>\n\n<pre><code>add_filter('woocommerce_dropdown_variation_attribute_o...
2018/11/19
[ "https://wordpress.stackexchange.com/questions/319585", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/154317/" ]
I have a specific dropdown field on variable products on my WooCommerce site that only ever has one option available. Example: the customer chooses the item “type”, then “color”, and finally “part number”, where “part number” dropdown always has just one option. I want to configure the site to remove the choose an opt...
Following code solves the purpose: ``` add_filter('woocommerce_dropdown_variation_attribute_options_args','fun_select_default_option',10,1); function fun_select_default_option( $args) { if(count($args['options']) > 0) //Check the count of available options in dropdown $args['selected'] = $args['options'][...
319,612
<p>I'm trying to load a slider in my header, but only on the homepage. </p> <p>I'm using The Ultralight template if that helps. </p> <p>I'm trying to (in template-functions.php) do the following: </p> <pre><code>&lt;?php if ( is_page( 'home' ) ) : ?&gt; dynamic_sidebar( 'Homepage Widget' ); &lt;...
[ { "answer_id": 319604, "author": "Aparna_29", "author_id": 84165, "author_profile": "https://wordpress.stackexchange.com/users/84165", "pm_score": 2, "selected": false, "text": "<p>Following code solves the purpose:</p>\n\n<pre><code>add_filter('woocommerce_dropdown_variation_attribute_o...
2018/11/19
[ "https://wordpress.stackexchange.com/questions/319612", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/154336/" ]
I'm trying to load a slider in my header, but only on the homepage. I'm using The Ultralight template if that helps. I'm trying to (in template-functions.php) do the following: ``` <?php if ( is_page( 'home' ) ) : ?> dynamic_sidebar( 'Homepage Widget' ); <?php endif; ?> ``` But this doesn't...
Following code solves the purpose: ``` add_filter('woocommerce_dropdown_variation_attribute_options_args','fun_select_default_option',10,1); function fun_select_default_option( $args) { if(count($args['options']) > 0) //Check the count of available options in dropdown $args['selected'] = $args['options'][...
319,619
<p>I am an amateur WP developer building a site for my wife :) I am using Helium theme and the site is in RTL direction. I have a right side bar.</p> <p>After making some changes by changing the main page content from text <a href="https://i.stack.imgur.com/cGAfc.png" rel="nofollow noreferrer"><img src="https://i.s...
[ { "answer_id": 319623, "author": "André Kelling", "author_id": 136930, "author_profile": "https://wordpress.stackexchange.com/users/136930", "pm_score": 1, "selected": false, "text": "<ol>\n<li><p>You would need to know since when / which change it starts flickering. // you said since th...
2018/11/19
[ "https://wordpress.stackexchange.com/questions/319619", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/148343/" ]
I am an amateur WP developer building a site for my wife :) I am using Helium theme and the site is in RTL direction. I have a right side bar. After making some changes by changing the main page content from text [![enter image description here](https://i.stack.imgur.com/cGAfc.png)](https://i.stack.imgur.com/cGAfc....
1. You would need to know since when / which change it starts flickering. // you said since the content change. So try to change back step by step until you know which content component exactly causes this. 2. Debug that change which caused that flickering. There are playing a lot of factors in here: Theme, Theme CSS,...
319,631
<p>Theme: Education LMS</p> <p>How can I remove the theme information from my footer copyright area, or how can I edit the do_action function? So that only display what I want to display in footer.</p> <pre><code> &lt;div class="col-sm-6"&gt; &lt;div class="site-info"&gt; ...
[ { "answer_id": 319632, "author": "André Kelling", "author_id": 136930, "author_profile": "https://wordpress.stackexchange.com/users/136930", "pm_score": 0, "selected": false, "text": "<p>you would need to overwrite the PHP function in your child-themes functions.php. \nYou can search in ...
2018/11/19
[ "https://wordpress.stackexchange.com/questions/319631", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/154244/" ]
Theme: Education LMS How can I remove the theme information from my footer copyright area, or how can I edit the do\_action function? So that only display what I want to display in footer. ``` <div class="col-sm-6"> <div class="site-info"> <?php do_action( ...
Instead of removing all actions as suggested by @kero, you should remove the desired hooks only using [`remove_action`](https://developer.wordpress.org/reference/functions/remove_action/). Removing all hooks will prevent 3rd party code from adding their code too when removed after they added their stuff (possibly inclu...
319,642
<p>Please bear with me as I am a front-end developer trying to grapple with PHP.</p> <p>I am attempting to add a gravity form to specific pages on my website website by adding a function to my <code>functions.php</code> file. It doesn't matter where it is placed on the page since the form will be initially hidden and t...
[ { "answer_id": 319643, "author": "André Kelling", "author_id": 136930, "author_profile": "https://wordpress.stackexchange.com/users/136930", "pm_score": 0, "selected": false, "text": "<p>if you got following in your <code>functions.php</code></p>\n\n<pre><code>function add_split_test_for...
2018/11/19
[ "https://wordpress.stackexchange.com/questions/319642", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/69042/" ]
Please bear with me as I am a front-end developer trying to grapple with PHP. I am attempting to add a gravity form to specific pages on my website website by adding a function to my `functions.php` file. It doesn't matter where it is placed on the page since the form will be initially hidden and then used for an exit...
Ok I figured it out. I just need to hook into `wp_footer`. The only thing that gets added to `header.php` is the `gravity_form_enqueue_scripts()` function. Per the documentation: > > This function will enqueue the necessary styles and scripts for the specified Gravity Form. This is useful when manually embedding a fo...
319,658
<p>I have modified the CSS on the admin and login pages. But the problem is that sometimes the custom CSS is loaded last, and this makes the change visible. The CSS can change during the loading of the page.</p> <p>Is there any way to edit the CSS before the page renders? I cannot edit the core and plugin files becaus...
[ { "answer_id": 319659, "author": "coolpasta", "author_id": 143406, "author_profile": "https://wordpress.stackexchange.com/users/143406", "pm_score": 0, "selected": false, "text": "<p>You have to open up the place where you're generating that CSS, this could be complex or simple. It all d...
2018/11/19
[ "https://wordpress.stackexchange.com/questions/319658", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/143279/" ]
I have modified the CSS on the admin and login pages. But the problem is that sometimes the custom CSS is loaded last, and this makes the change visible. The CSS can change during the loading of the page. Is there any way to edit the CSS before the page renders? I cannot edit the core and plugin files because I want t...
What theme are you using? I would probably start with making a [child theme](https://codex.wordpress.org/Child_Themes). This will give you more control over when styles are loaded. Here is an example of loading the parent theme styles and then your child theme styles. ``` function my_theme_enqueue_styles() { $pa...
319,667
<p>I am using PowerMag 2.5 as parent and can't seem to find a way to get a working child theme. As far as I am now, I can only extend css in the style.css but as far as overriding, nothing has worked. When I copy over e.g. the header.php from parent to child and make some edits to the code it does not work. The very bi...
[ { "answer_id": 319659, "author": "coolpasta", "author_id": 143406, "author_profile": "https://wordpress.stackexchange.com/users/143406", "pm_score": 0, "selected": false, "text": "<p>You have to open up the place where you're generating that CSS, this could be complex or simple. It all d...
2018/11/19
[ "https://wordpress.stackexchange.com/questions/319667", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/154358/" ]
I am using PowerMag 2.5 as parent and can't seem to find a way to get a working child theme. As far as I am now, I can only extend css in the style.css but as far as overriding, nothing has worked. When I copy over e.g. the header.php from parent to child and make some edits to the code it does not work. The very big f...
What theme are you using? I would probably start with making a [child theme](https://codex.wordpress.org/Child_Themes). This will give you more control over when styles are loaded. Here is an example of loading the parent theme styles and then your child theme styles. ``` function my_theme_enqueue_styles() { $pa...
319,672
<p>I'm trying to sort custom posts in alphabetical order, and I've just now realized that capital letters are being sorted before lowercase. Two restaurants start with 'Cal' and 'CAT' with 'CAT' being returned as the first in alphabetical order.</p> <p>Here're my $args:</p> <pre><code>$args = array( 'numberposts'...
[ { "answer_id": 319659, "author": "coolpasta", "author_id": 143406, "author_profile": "https://wordpress.stackexchange.com/users/143406", "pm_score": 0, "selected": false, "text": "<p>You have to open up the place where you're generating that CSS, this could be complex or simple. It all d...
2018/11/19
[ "https://wordpress.stackexchange.com/questions/319672", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43473/" ]
I'm trying to sort custom posts in alphabetical order, and I've just now realized that capital letters are being sorted before lowercase. Two restaurants start with 'Cal' and 'CAT' with 'CAT' being returned as the first in alphabetical order. Here're my $args: ``` $args = array( 'numberposts' => -1, 'post_typ...
What theme are you using? I would probably start with making a [child theme](https://codex.wordpress.org/Child_Themes). This will give you more control over when styles are loaded. Here is an example of loading the parent theme styles and then your child theme styles. ``` function my_theme_enqueue_styles() { $pa...
319,677
<p>I was in process of deploying my wordpress website <code>mysite.com/NewSite</code> to <code>mysite.com</code> during the deployment I messed up something and my main site has started redirecting from <code>mysite.com</code> to <code>mysite.com/NewSite</code>.</p> <p>I have deleted everything from root folder, check...
[ { "answer_id": 319681, "author": "majick", "author_id": 76440, "author_profile": "https://wordpress.stackexchange.com/users/76440", "pm_score": 1, "selected": false, "text": "<p>According to the Codex instructions:</p>\n\n<p><a href=\"https://codex.wordpress.org/Changing_The_Site_URL\" r...
2018/11/19
[ "https://wordpress.stackexchange.com/questions/319677", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47833/" ]
I was in process of deploying my wordpress website `mysite.com/NewSite` to `mysite.com` during the deployment I messed up something and my main site has started redirecting from `mysite.com` to `mysite.com/NewSite`. I have deleted everything from root folder, checked cpanel redirects section etc but everything looks f...
According to the Codex instructions: <https://codex.wordpress.org/Changing_The_Site_URL> If you add these defines to your wp-config.php ``` define( 'WP_HOME', 'http://example.com' ); define( 'WP_SITEURL', 'http://example.com' ); ``` These will override the options saved in your `wp_options` table, you should then ...
319,690
<p>I am looking to replace a few text strings for only two specific pages on a wordpress site. It should not affect those strings on any other pages. I'd prefer to do this via adding some code to functions.php</p> <p>I think using part of this code would be the first part, just need help with the rest <a href="https:/...
[ { "answer_id": 319694, "author": "vikrant zilpe", "author_id": 153928, "author_profile": "https://wordpress.stackexchange.com/users/153928", "pm_score": 0, "selected": false, "text": "<p><strong>Some Example Here is how to replace all instances of a string in WordPress.\nJust add the fol...
2018/11/20
[ "https://wordpress.stackexchange.com/questions/319690", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136330/" ]
I am looking to replace a few text strings for only two specific pages on a wordpress site. It should not affect those strings on any other pages. I'd prefer to do this via adding some code to functions.php I think using part of this code would be the first part, just need help with the rest <https://wordpress.stackex...
I can't comment so I'll answer and slightly adjust Bhagyashree's which is exactly what you'll need to do based on your question. Except you may want to know how to include the 2 pages rather than duplicating the function. And also passing in an array of strings to replace. ``` function replace_some_text( $content ) { ...
319,744
<p>Travis is giving me ~ <strong>Assignments must be the first block of code on a line</strong> for this specific line of code: </p> <pre><code>$validate_string = $pf_param_string = substr( $pf_param_string, 0, - 1 ); </code></pre> <p>It seems fine to me or am I doing the assignments wrong?</p>
[ { "answer_id": 319745, "author": "kero", "author_id": 108180, "author_profile": "https://wordpress.stackexchange.com/users/108180", "pm_score": 1, "selected": false, "text": "<p>According to <a href=\"https://stackoverflow.com/questions/46579215/how-to-fix-assignments-must-be-the-first-b...
2018/11/20
[ "https://wordpress.stackexchange.com/questions/319744", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136971/" ]
Travis is giving me ~ **Assignments must be the first block of code on a line** for this specific line of code: ``` $validate_string = $pf_param_string = substr( $pf_param_string, 0, - 1 ); ``` It seems fine to me or am I doing the assignments wrong?
You're not supposed to assign multiple variables on a single line. Do them separately: ``` $pf_param_string = substr( $pf_param_string, 0, - 1 ); $validate_string = $pf_param_string; ``` Or, if you don't need both variables, just skip one of them: ``` $validate_string = substr( $pf_param_string, 0, - 1 ); ```
319,770
<p>I am developing a Woocommerce dependent plugin which works, and a settings page which behaves funky and throws a Class 'WC_Settings_Page' not found Fatal Error</p> <pre><code>if ( !defined( 'ABSPATH' ) ) {exit;} if ( !class_exists( 'WooCommerce_Chilexpress_Tags_Settings' ) ) { class WooCommerce_Chilexpress_Tag...
[ { "answer_id": 319792, "author": "Remzi Cavdar", "author_id": 149484, "author_profile": "https://wordpress.stackexchange.com/users/149484", "pm_score": 2, "selected": false, "text": "<p>See working example: <a href=\"https://gist.github.com/bekarice/34aaeda2d4729ef87ad7\" rel=\"nofollow ...
2018/11/20
[ "https://wordpress.stackexchange.com/questions/319770", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114144/" ]
I am developing a Woocommerce dependent plugin which works, and a settings page which behaves funky and throws a Class 'WC\_Settings\_Page' not found Fatal Error ``` if ( !defined( 'ABSPATH' ) ) {exit;} if ( !class_exists( 'WooCommerce_Chilexpress_Tags_Settings' ) ) { class WooCommerce_Chilexpress_Tags_Settings e...
The problem is, by the time your `WooCommerce_Chilexpress_Tags_Settings` is defined, `WC_Settings_Page` has indeed not yet loaded; hence you got the fatal error. And if you want to do it the same way that WooCommerce does it, place the `WooCommerce_Chilexpress_Tags_Settings` in a separate PHP file, e.g. `includes/clas...
319,775
<p>I'm looping through all users with</p> <pre><code>$allusers = get_users($args); foreach ( $allusers as $user ): </code></pre> <p>And then I have an email user button (firstname and lastname are inserted into the subject), and a callback button (firstname and lastname are inserted into ...
[ { "answer_id": 319785, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 2, "selected": true, "text": "<p>I've only seen some parts of your code, but I guess I know where the problem lies... </p>\n\n<p>If thi...
2018/11/20
[ "https://wordpress.stackexchange.com/questions/319775", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/111367/" ]
I'm looping through all users with ``` $allusers = get_users($args); foreach ( $allusers as $user ): ``` And then I have an email user button (firstname and lastname are inserted into the subject), and a callback button (firstname and lastname are inserted into a hidden Contact Form 7 fi...
I've only seen some parts of your code, but I guess I know where the problem lies... If this is what you're printing in the loop: ``` <script type="text/javascript"> jQuery(document).ready(function($) { $('.callback').val('<?php echo $user->first_name; ?> <?php echo $user->last_name; ?>'); }); </script> <?php ec...
319,794
<p>I have a strange problem, when I try to enter the source of an image tag using PHP it shows me the following error in the inspector</p> <pre><code>&lt;img src=(unknown) alt=""&gt; </code></pre> <p>this code fragment gives me the correct url, checked by seeing the CPanel and pasting and copying the address,but when...
[ { "answer_id": 319795, "author": "Carlos Longarela", "author_id": 141152, "author_profile": "https://wordpress.stackexchange.com/users/141152", "pm_score": 1, "selected": true, "text": "<p>I think that you need echo the image, try this:</p>\n\n<pre><code>&lt;php\n$image = wp_get_attachme...
2018/11/21
[ "https://wordpress.stackexchange.com/questions/319794", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/154440/" ]
I have a strange problem, when I try to enter the source of an image tag using PHP it shows me the following error in the inspector ``` <img src=(unknown) alt=""> ``` this code fragment gives me the correct url, checked by seeing the CPanel and pasting and copying the address,but when I try to enter it via php the i...
I think that you need echo the image, try this: ``` <php $image = wp_get_attachment_image_src( $post_thumbnail_id ); //echo( $image[0] ); ?> <img src="<?php echo $image[0]; ?>" alt=""> ```
319,810
<p>So I went through the forum to find a solution before I post a question, however I have yet to find it. I'm new to wordpress and I'm having a lot of fun learning on how to build my own website. However I am unable to add my css to my website this the code I have below. </p> <p><strong>functions.php</strong></p> <p...
[ { "answer_id": 319814, "author": "Remzi Cavdar", "author_id": 149484, "author_profile": "https://wordpress.stackexchange.com/users/149484", "pm_score": 3, "selected": true, "text": "<p>I don't know if you try to add a css file in your theme or plugin. I will provide both examples. Use <a...
2018/11/21
[ "https://wordpress.stackexchange.com/questions/319810", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
So I went through the forum to find a solution before I post a question, however I have yet to find it. I'm new to wordpress and I'm having a lot of fun learning on how to build my own website. However I am unable to add my css to my website this the code I have below. **functions.php** ``` <?php function fearnothi...
I don't know if you try to add a css file in your theme or plugin. I will provide both examples. Use [wp\_enqueue\_style](https://developer.wordpress.org/reference/functions/wp_enqueue_style/) in combination with [get\_theme\_file\_uri](https://developer.wordpress.org/reference/functions/get_theme_file_uri/) to enqueu ...
319,819
<p>Im trying to display a custom taxonomy for a custom post type. So this taxonomy is specific to this custom post type. Unfortunately I cant get them to display. Here is my code in functions.php to register the custom taxonomy:</p> <pre><code>add_action('init', 'products_categories', 0); function products_categories...
[ { "answer_id": 319822, "author": "Greg Winiarski", "author_id": 154460, "author_profile": "https://wordpress.stackexchange.com/users/154460", "pm_score": 2, "selected": true, "text": "<p>it looks like your get_terms() call is incorrect, the argument is not an array and you have a typo in...
2018/11/21
[ "https://wordpress.stackexchange.com/questions/319819", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93537/" ]
Im trying to display a custom taxonomy for a custom post type. So this taxonomy is specific to this custom post type. Unfortunately I cant get them to display. Here is my code in functions.php to register the custom taxonomy: ``` add_action('init', 'products_categories', 0); function products_categories(){ $labels = ...
it looks like your get\_terms() call is incorrect, the argument is not an array and you have a typo in taxonomy name ('product\_category' instead of 'product\_categories') it should be ``` <?php $terms = get_terms( array( 'taxonomy'=>'product_categories', 'hide_empty'=> false ) ); ?> ``` If this will no...
319,824
<p>In functions.php, I want to access the DB once to get an ACF object, and then "save" it locally to prevent further requests to the DB.</p> <p>I thought of first calling the following function in the "init' hook.</p> <p>Then, supposedly, when I call it on later hooks the $current_store var is already set because of...
[ { "answer_id": 319826, "author": "Greg Winiarski", "author_id": 154460, "author_profile": "https://wordpress.stackexchange.com/users/154460", "pm_score": -1, "selected": false, "text": "<p>if the $current_store is some kind of global variable then your function should start with</p>\n\n<...
2018/11/21
[ "https://wordpress.stackexchange.com/questions/319824", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/152801/" ]
In functions.php, I want to access the DB once to get an ACF object, and then "save" it locally to prevent further requests to the DB. I thought of first calling the following function in the "init' hook. Then, supposedly, when I call it on later hooks the $current\_store var is already set because of the use of the ...
This is a good use case for the [Object Cache](https://codex.wordpress.org/Class_Reference/WP_Object_Cache): > > WP\_Object\_Cache is WordPress' class for caching data which may be > computationally expensive to regenerate, such as the result of complex > database queries. > > > You can store things in the cach...
319,861
<p>is it possible to show only the first line of content <code>&lt;?php the_content(); ?&gt;</code> or alternative only content between <code>&lt;b&gt;text&lt;/b&gt;</code>?</p>
[ { "answer_id": 319864, "author": "miguelcalderons", "author_id": 153649, "author_profile": "https://wordpress.stackexchange.com/users/153649", "pm_score": 2, "selected": false, "text": "<p>What you can do is work with this <code>the_excerpt()</code> change this instead of <code>the_conte...
2018/11/21
[ "https://wordpress.stackexchange.com/questions/319861", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153850/" ]
is it possible to show only the first line of content `<?php the_content(); ?>` or alternative only content between `<b>text</b>`?
you could also do something like: ``` function rt_before_after($content) { $replace = "</b>"; $shortcontent = strstr($content, $replace, true).$replace; if ($shortcontent === false) $shortcontent = $content; return $shortcontent; } add_filter('the_content', 'rt_before_after'); ``` It should look for the fi...
319,878
<p>I've stumbled across something that I can't seem to find any documentation on regarding WP 'get_posts' function.</p> <p>I've got a web application that has multiple custom post-types and multiple custom user roles. They're all necessary for an assortment of reasons. Different users types within the organization n...
[ { "answer_id": 319881, "author": "socki03", "author_id": 43511, "author_profile": "https://wordpress.stackexchange.com/users/43511", "pm_score": 0, "selected": false, "text": "<p>Try adding <code>read_seasonal_sessions</code> to your capabilities array and setting that to true. Each new...
2018/11/21
[ "https://wordpress.stackexchange.com/questions/319878", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60844/" ]
I've stumbled across something that I can't seem to find any documentation on regarding WP 'get\_posts' function. I've got a web application that has multiple custom post-types and multiple custom user roles. They're all necessary for an assortment of reasons. Different users types within the organization need to see ...
I have this problem as well, @tony-djukic. I have an administrator user that can see two posts of a custom post type. I have two subscriber users, each are able to only see the opposite post as the other. Here's what I'm using to (apparently not) get all the posts: ``` get_posts(array( 'numberposts' => -1, ...
319,885
<p>I am trying to put three menu items before the <code>Dashboard</code> menu item in admin dashboard. Problem is that <code>Dashboard</code> has menu position <code>2</code>.</p> <p>I can manage to put in two menu items before with position <code>0</code> and <code>1</code>, but <code>2</code> collides with Dashboard...
[ { "answer_id": 319881, "author": "socki03", "author_id": 43511, "author_profile": "https://wordpress.stackexchange.com/users/43511", "pm_score": 0, "selected": false, "text": "<p>Try adding <code>read_seasonal_sessions</code> to your capabilities array and setting that to true. Each new...
2018/11/21
[ "https://wordpress.stackexchange.com/questions/319885", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/143279/" ]
I am trying to put three menu items before the `Dashboard` menu item in admin dashboard. Problem is that `Dashboard` has menu position `2`. I can manage to put in two menu items before with position `0` and `1`, but `2` collides with Dashboard. So my thought was to move the Dashboard position. Is this possible? Can I...
I have this problem as well, @tony-djukic. I have an administrator user that can see two posts of a custom post type. I have two subscriber users, each are able to only see the opposite post as the other. Here's what I'm using to (apparently not) get all the posts: ``` get_posts(array( 'numberposts' => -1, ...
319,901
<p>I've tried to achieve it by using snippet from years ago, but it doesn't seem to work. I need to make it work with Gutenberg (WP 5.0).</p> <p>Is it possible to make it work?</p>
[ { "answer_id": 319904, "author": "LetTheWritersWrite", "author_id": 154481, "author_profile": "https://wordpress.stackexchange.com/users/154481", "pm_score": -1, "selected": false, "text": "<p><a href=\"https://wordpress.stackexchange.com/questions/26753/how-to-disable-edit-post-option-a...
2018/11/22
[ "https://wordpress.stackexchange.com/questions/319901", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136124/" ]
I've tried to achieve it by using snippet from years ago, but it doesn't seem to work. I need to make it work with Gutenberg (WP 5.0). Is it possible to make it work?
The other suggestions (and the accepted answer in your link) temporarily change a user's capabilities globally. That is a hack. There is hook specifically designed for conditionally adjusting capabilities for specific content: [`map_meta_cap`](https://developer.wordpress.org/reference/hooks/map_meta_cap/). When WordPr...
319,915
<p>Strange... I put an if statement for <code>$testvalue = 0</code>. The else part runs and when I echo the value of the <code>$testvalue</code> it gives me a 0.</p> <p>So what is the true value of <code>$testvalue</code>?</p> <p>I need to be able for the if the part to run.</p> <p>I am trying to use the <code>post...
[ { "answer_id": 319916, "author": "Gufran Hasan", "author_id": 137328, "author_profile": "https://wordpress.stackexchange.com/users/137328", "pm_score": 0, "selected": false, "text": "<p>You need to check emptyness of value by using <a href=\"http://php.net/manual/en/function.empty.php\" ...
2018/11/22
[ "https://wordpress.stackexchange.com/questions/319915", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/154499/" ]
Strange... I put an if statement for `$testvalue = 0`. The else part runs and when I echo the value of the `$testvalue` it gives me a 0. So what is the true value of `$testvalue`? I need to be able for the if the part to run. I am trying to use the `post_exists()` function to check if a post exists in the database. ...
You're not checking the value correctly. A single `=` sign is the [assignment operator](http://php.net/manual/en/language.operators.assignment.php). So when you write `$variable = 0` you are *setting* the variable to `0`. This happens regardless of whether or not you're in an `if` statement. So when you write `if ( $t...
319,922
<p>I have 8 Instagram URLs in this <a href="https://blog.wwf.sg/ocean/2018/11/netflix-documentaries-our-planet-okja-dogs/" rel="nofollow noreferrer">post</a> out of which 3 are not converted into embed/iframes.</p> <p>I'm using Gutenberg's Instagram embed blog to add the URL's.<a href="https://blog.wwf.sg/ocean/2018/1...
[ { "answer_id": 319931, "author": "Manoj H L", "author_id": 36203, "author_profile": "https://wordpress.stackexchange.com/users/36203", "pm_score": 3, "selected": true, "text": "<p>Figured it out. </p>\n\n<p>Embed shortcode stores the oemebd data as post meta using md5 hash.</p>\n\n<p><a ...
2018/11/22
[ "https://wordpress.stackexchange.com/questions/319922", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36203/" ]
I have 8 Instagram URLs in this [post](https://blog.wwf.sg/ocean/2018/11/netflix-documentaries-our-planet-okja-dogs/) out of which 3 are not converted into embed/iframes. I'm using Gutenberg's Instagram embed blog to add the URL's.<https://blog.wwf.sg/ocean/2018/11/netflix-documentaries-our-planet-okja-dogs/#> I see ...
Figured it out. Embed shortcode stores the oemebd data as post meta using md5 hash. [wp-includes/class-wp-embed.php](https://github.com/WordPress/WordPress/blob/91da29d9afaa664eb84e1261ebb916b18a362aa9/wp-includes/class-wp-embed.php#L198) ```php // Check for a cached result (stored in the post meta) $key_suffix = m...
319,971
<p>I've been reviewing tutorials on creating blocks for Gutenberg but I am unclear how to handle a particular use case - conditional blocks.</p> <p>I am looking at creating a custom post type for which I will register my own block type. These blocks will only be displayed if certain conditions are true. These condition...
[ { "answer_id": 342130, "author": "David", "author_id": 104457, "author_profile": "https://wordpress.stackexchange.com/users/104457", "pm_score": 0, "selected": false, "text": "<p>If you want to give the editor control over what blocks are displayed to logged in users or not you could use...
2018/11/22
[ "https://wordpress.stackexchange.com/questions/319971", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/109240/" ]
I've been reviewing tutorials on creating blocks for Gutenberg but I am unclear how to handle a particular use case - conditional blocks. I am looking at creating a custom post type for which I will register my own block type. These blocks will only be displayed if certain conditions are true. These conditions will be...
In the edit method for your custom block, when rendering the components you can use the "conditional + &&" pattern: ``` <PanelBody title={ __( 'My Panel' ) } > { myCustomBool && <MyComponent value={theValue} onChange={ value => { myChangeCall...
320,000
<p>I'm looking for adding a custom css in the admin panel by targeting user id cause I have another administrator but I want to hide something from him by css. I'm using this code to put some stylesheet files in the admin panel, but its for all users </p> <pre><code>add_action('admin_head', 'my_custom_fonts'); functi...
[ { "answer_id": 320002, "author": "Gamal Elwazeery", "author_id": 154315, "author_profile": "https://wordpress.stackexchange.com/users/154315", "pm_score": -1, "selected": true, "text": "<p>done it</p>\n\n<pre><code>add_action('admin_head', 'my_custom_fonts');\n\nfunction my_custom_fonts(...
2018/11/23
[ "https://wordpress.stackexchange.com/questions/320000", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/154315/" ]
I'm looking for adding a custom css in the admin panel by targeting user id cause I have another administrator but I want to hide something from him by css. I'm using this code to put some stylesheet files in the admin panel, but its for all users ``` add_action('admin_head', 'my_custom_fonts'); function my_custom_f...
done it ``` add_action('admin_head', 'my_custom_fonts'); function my_custom_fonts() { global $current_user; $user_id = get_current_user_id(); if(is_admin() && $user_id == '2'){ echo ' <link rel="stylesheet" type="text/css" href="../../new.css">'; } } ```
320,016
<p><br> I'm having troubles with the mysqli driver used by wordpress, where it is converting each and every integer value to a string within <code>$wpdb-&gt;get_results("SELECT...")</code>.<br> I know that it is possible so use the the option MYSQLI_OPT_INT_AND_FLOAT_NATIVE with the mysqli driver (<code>$mysqli-&gt;opt...
[ { "answer_id": 320166, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 1, "selected": false, "text": "<blockquote>\n <p>That's why I'm wondering why is Wordpress stuck to this pre-PHP-5.3\n limitation.</p>\...
2018/11/23
[ "https://wordpress.stackexchange.com/questions/320016", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I'm having troubles with the mysqli driver used by wordpress, where it is converting each and every integer value to a string within `$wpdb->get_results("SELECT...")`. I know that it is possible so use the the option MYSQLI\_OPT\_INT\_AND\_FLOAT\_NATIVE with the mysqli driver (`$mysqli->options(MYSQLI_OPT_INT_AND_FL...
> > That's why I'm wondering why is Wordpress stuck to this pre-PHP-5.3 > limitation. > > > Because WordPress has made the decision to support PHP 5.2 due to the large number of hosts that continue to use it. This is an ongoing debate and there's no point rehashing it all here. > > But this means that I have to...
320,046
<p>How can the plugin directory path be returned into <code>&lt;script&gt; &lt;/script&gt;</code> instead of hard coding the path?</p> <p>Here is the custom-page.php:</p> <pre><code>&lt;?php get_header(); ?&gt; &lt;script type="text/javascript" src="http://local.wordpress.test/wp-content/plugins/path-to-file/script....
[ { "answer_id": 320048, "author": "Liam Stewart", "author_id": 121955, "author_profile": "https://wordpress.stackexchange.com/users/121955", "pm_score": 3, "selected": true, "text": "<p>Take a look at this: <a href=\"https://wordpress.stackexchange.com/a/119084/121955\">https://wordpress....
2018/11/23
[ "https://wordpress.stackexchange.com/questions/320046", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/154419/" ]
How can the plugin directory path be returned into `<script> </script>` instead of hard coding the path? Here is the custom-page.php: ``` <?php get_header(); ?> <script type="text/javascript" src="http://local.wordpress.test/wp-content/plugins/path-to-file/script.js"></script> <?php get_footer(); ?> ```
Take a look at this: <https://wordpress.stackexchange.com/a/119084/121955> ``` plugins_url( "path/to/file", __FILE__ ); ``` EDITED: ``` <script src="<?php echo plugins_url( "path/to/file", __FILE__ ); ?>"></script> ```
320,054
<p>I'm trying to use Wordpress paginate function to only show 3 pages at most(client wants it this way) so that when you go up a page it shows the current page you're on and the previous and next page:</p> <p><a href="https://i.stack.imgur.com/4MwdS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4M...
[ { "answer_id": 320069, "author": "Alvaro", "author_id": 16533, "author_profile": "https://wordpress.stackexchange.com/users/16533", "pm_score": 1, "selected": false, "text": "<p>Check the mid_size parameter in <a href=\"https://codex.wordpress.org/Function_Reference/paginate_links\" rel=...
2018/11/23
[ "https://wordpress.stackexchange.com/questions/320054", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93537/" ]
I'm trying to use Wordpress paginate function to only show 3 pages at most(client wants it this way) so that when you go up a page it shows the current page you're on and the previous and next page: [![This is the result they want](https://i.stack.imgur.com/4MwdS.png)](https://i.stack.imgur.com/4MwdS.png) Unfortunate...
Found the answer thanks to the link in the updated part of my question. Here is the solution to it: ``` echo '<div id ="nav_pages">'; echo '<div class="prev_first"></div>'; echo '<div class="pages">'; $pag_args1 = array( 'type' => 'array', 'prev_next' => False, 'end_size' => 0, 'mid_size...
320,103
<p>I've been with this problem for a couple of days and the truth is that I can not find a solution. I have added code manually in wp-header.php and now I need to delete these lines that it generates automatically </p> <p>The lines I want to eliminate are:</p> <pre><code>&lt;link rel="stylesheet" id="create-css" href...
[ { "answer_id": 320107, "author": "Toni Wheeler", "author_id": 154504, "author_profile": "https://wordpress.stackexchange.com/users/154504", "pm_score": 0, "selected": false, "text": "<p>It sounds like you should backup your site first. Then go in to the editor under appearance, and find...
2018/11/24
[ "https://wordpress.stackexchange.com/questions/320103", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/154644/" ]
I've been with this problem for a couple of days and the truth is that I can not find a solution. I have added code manually in wp-header.php and now I need to delete these lines that it generates automatically The lines I want to eliminate are: ``` <link rel="stylesheet" id="create-css" href="http://www.myweb.com/w...
Sounds like some filter is placing the create.css file there. Check your functions.php (or search for the following function inside the theme with your text editor in case some other file is enqueueing those assets) for `wp_enqueue_style` and see if you have that file enqueued. Other way of doing this is using the fil...
320,237
<p>I have added remove button for products in the checkout page.</p> <p>The code - </p> <pre><code>function add_delete( $product_title, $cart_item, $cart_item_key ) { if ( is_checkout() ) { /* Get Cart of the user */ $cart = WC()-&gt;cart-&gt;get_cart(); foreach ( $cart as $cart_key ...
[ { "answer_id": 320186, "author": "pixeline", "author_id": 82, "author_profile": "https://wordpress.stackexchange.com/users/82", "pm_score": 1, "selected": false, "text": "<p>If you want to use php inside the Post Content editing interface, it will not work (for security reasons), unless ...
2018/11/26
[ "https://wordpress.stackexchange.com/questions/320237", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/123392/" ]
I have added remove button for products in the checkout page. The code - ``` function add_delete( $product_title, $cart_item, $cart_item_key ) { if ( is_checkout() ) { /* Get Cart of the user */ $cart = WC()->cart->get_cart(); foreach ( $cart as $cart_key => $cart_value ){ ...
If you want to use php inside the Post Content editing interface, it will not work (for security reasons), unless you install a plugin that allows it. If you mean that the php would be put in the template file, then you can use the functions `the_meta();`([doc](https://codex.wordpress.org/Custom_Fields#Displaying_Cust...
320,244
<p>I tried with this code in <code>functions.php</code>of my website's child theme.</p> <pre><code>add_filter('admin_body_class', 'custom_body_class'); function custom_body_class($classes) { if (is_page(8)) $classes[] = 'home-admin-area'; return $classes; } </code></pre> <p>But the class "home-admin-a...
[ { "answer_id": 320245, "author": "butlerblog", "author_id": 38603, "author_profile": "https://wordpress.stackexchange.com/users/38603", "pm_score": 1, "selected": false, "text": "<p><code>admin_body_class</code> passes its values as a string, not an array. (This differs from <code>body_...
2018/11/26
[ "https://wordpress.stackexchange.com/questions/320244", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/106457/" ]
I tried with this code in `functions.php`of my website's child theme. ``` add_filter('admin_body_class', 'custom_body_class'); function custom_body_class($classes) { if (is_page(8)) $classes[] = 'home-admin-area'; return $classes; } ``` But the class "home-admin-area" is not added. Is there any error...
Use `admin_body_class` both with global post\_id and `get_current_screen` function: ``` add_filter('admin_body_class', 'wpse_320244_admin_body_class'); function wpse_320244_admin_body_class($classes) { global $post; // get_current_screen() returns object with current admin screen // @link https://codex.w...
320,255
<p>I'm trying move an existing Wordpress site to run across two different servers, one with Apache and the main source code and the other that just has the database running on MYSQL.</p> <p>wp-config:</p> <pre><code>define('DB_NAME', 'wp-user'); define('DB_USER', 'wp-user'); define('DB_PASSWORD', 'password'); define(...
[ { "answer_id": 320245, "author": "butlerblog", "author_id": 38603, "author_profile": "https://wordpress.stackexchange.com/users/38603", "pm_score": 1, "selected": false, "text": "<p><code>admin_body_class</code> passes its values as a string, not an array. (This differs from <code>body_...
2018/11/26
[ "https://wordpress.stackexchange.com/questions/320255", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/154745/" ]
I'm trying move an existing Wordpress site to run across two different servers, one with Apache and the main source code and the other that just has the database running on MYSQL. wp-config: ``` define('DB_NAME', 'wp-user'); define('DB_USER', 'wp-user'); define('DB_PASSWORD', 'password'); define('DB_HOST', 'xxx.xxx.x...
Use `admin_body_class` both with global post\_id and `get_current_screen` function: ``` add_filter('admin_body_class', 'wpse_320244_admin_body_class'); function wpse_320244_admin_body_class($classes) { global $post; // get_current_screen() returns object with current admin screen // @link https://codex.w...
320,271
<p>I'm setting up a google map on my site and I'm trying to set the enqueue my scripts up but am getting an error:</p> <p>I have placed this code in my functions.php (actual api key not used here):</p> <pre><code>function rt_load_acf_map() { // Register my scripts for my theme: wp_register_script( 'map-script...
[ { "answer_id": 320282, "author": "Pat J", "author_id": 16121, "author_profile": "https://wordpress.stackexchange.com/users/16121", "pm_score": 1, "selected": false, "text": "<p>Setting the <code>$ver</code> parameter to <code>false</code> (or, probably, <code>''</code>, as you've done), ...
2018/11/26
[ "https://wordpress.stackexchange.com/questions/320271", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/77767/" ]
I'm setting up a google map on my site and I'm trying to set the enqueue my scripts up but am getting an error: I have placed this code in my functions.php (actual api key not used here): ``` function rt_load_acf_map() { // Register my scripts for my theme: wp_register_script( 'map-script', get_stylesheet_dir...
When you call google, the `key` variable name is missing. ``` wp_register_script( 'googlemap', 'https://maps.googleapis.com/maps/api/js?123123123123' , '', '', false ); ``` Should be : ``` wp_register_script( 'googlemap', '//maps.googleapis.com/maps/api/js?key=123123123123123123123123' , '', '', false ); ```
320,278
<p>I build a static page in my WordPress root folder. Now I'm trying to include a list of my categories with <code>echo clpr_categories_list();</code>.</p> <p>Its not working because I some how have to tell the static page where to find my theme. How do I do this? Searched everywhere.</p>
[ { "answer_id": 320282, "author": "Pat J", "author_id": 16121, "author_profile": "https://wordpress.stackexchange.com/users/16121", "pm_score": 1, "selected": false, "text": "<p>Setting the <code>$ver</code> parameter to <code>false</code> (or, probably, <code>''</code>, as you've done), ...
2018/11/26
[ "https://wordpress.stackexchange.com/questions/320278", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/153850/" ]
I build a static page in my WordPress root folder. Now I'm trying to include a list of my categories with `echo clpr_categories_list();`. Its not working because I some how have to tell the static page where to find my theme. How do I do this? Searched everywhere.
When you call google, the `key` variable name is missing. ``` wp_register_script( 'googlemap', 'https://maps.googleapis.com/maps/api/js?123123123123' , '', '', false ); ``` Should be : ``` wp_register_script( 'googlemap', '//maps.googleapis.com/maps/api/js?key=123123123123123123123123' , '', '', false ); ```
320,304
<p>Am try to implement data from database using AJAX based on a drop down list in WordPress. The codes returning 400 bad request in the console. I am hosted the page as localhost.</p> <p>Here is my theme's <code>functions.php</code> //I changed the Code</p> <pre><code> function my_enqueue_scripts() { wp_enqueue_s...
[ { "answer_id": 320309, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 0, "selected": false, "text": "<p>You get 400 error, because there is no callback registered for your AJAX request.</p>\n\n<p>Here's ho...
2018/11/27
[ "https://wordpress.stackexchange.com/questions/320304", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/154128/" ]
Am try to implement data from database using AJAX based on a drop down list in WordPress. The codes returning 400 bad request in the console. I am hosted the page as localhost. Here is my theme's `functions.php` //I changed the Code ``` function my_enqueue_scripts() { wp_enqueue_script('jquery'); } add_action('w...
First, enqueue your script correctly, in `functions.php`: ``` function my_enqueue_scripts() { wp_enqueue_script('jquery'); } add_action('wp_enqueue_scripts', 'my_enqueue_scripts'); ``` Then, `Authenticated` users only (see <https://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_nopriv_(action)>) (can als...
320,331
<p>I am working on a blog with a pretty high number of authors. I want to keep them from accidentally sending a push message to our readers, since the button of the push-plugin we use looks dangerously similar to the "publish"-button. </p> <p>Is there a way to hide an element like this push-button for certain user gro...
[ { "answer_id": 320309, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 0, "selected": false, "text": "<p>You get 400 error, because there is no callback registered for your AJAX request.</p>\n\n<p>Here's ho...
2018/11/27
[ "https://wordpress.stackexchange.com/questions/320331", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/76017/" ]
I am working on a blog with a pretty high number of authors. I want to keep them from accidentally sending a push message to our readers, since the button of the push-plugin we use looks dangerously similar to the "publish"-button. Is there a way to hide an element like this push-button for certain user groups by def...
First, enqueue your script correctly, in `functions.php`: ``` function my_enqueue_scripts() { wp_enqueue_script('jquery'); } add_action('wp_enqueue_scripts', 'my_enqueue_scripts'); ``` Then, `Authenticated` users only (see <https://codex.wordpress.org/Plugin_API/Action_Reference/wp_ajax_nopriv_(action)>) (can als...
320,373
<p>I've searched through WordPress Development and couldn't find the answer, so I either didn't search very well or I couldn't figure out the actual term I needed to search for...</p> <p>I am trying to create a simple mu-plugin to remove update notices, nags and other random notifications created by many of the plugin...
[ { "answer_id": 320374, "author": "kero", "author_id": 108180, "author_profile": "https://wordpress.stackexchange.com/users/108180", "pm_score": 2, "selected": true, "text": "<p>Your question boils down to simple PHP. It is basically how to avoid</p>\n\n<pre><code>'AdminUser' !== $user-&g...
2018/11/27
[ "https://wordpress.stackexchange.com/questions/320373", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/14558/" ]
I've searched through WordPress Development and couldn't find the answer, so I either didn't search very well or I couldn't figure out the actual term I needed to search for... I am trying to create a simple mu-plugin to remove update notices, nags and other random notifications created by many of the plugins I use ac...
Your question boils down to simple PHP. It is basically how to avoid ``` 'AdminUser' !== $user->user_login || 'AdminUser2' !== $user->user_login || 'AdminUser3' !== $user->user_login || 'AdminUser4' !== $user->user_login || etc. ``` One way to solve this is use [`in_array()`](https://secure.php.net/in_array) instead...