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
264,446
<p>I use TinyMce on my customizer (for obv reasons). But i encounter a problem that i do not seem to have the answer to. Let me first share you my code that are crucial:</p> <p><strong>Functions.php</strong></p> <pre><code>// text editor if ( ! class_exists( 'WP_Customize_Control' ) ) return NULL; /** * Class ...
[ { "answer_id": 264636, "author": "CompactCode", "author_id": 118063, "author_profile": "https://wordpress.stackexchange.com/users/118063", "pm_score": 3, "selected": true, "text": "<p>My problem has been \"solved\" by doing the following :</p>\n\n<p>The problem is that do_action is getti...
2017/04/21
[ "https://wordpress.stackexchange.com/questions/264446", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118063/" ]
I use TinyMce on my customizer (for obv reasons). But i encounter a problem that i do not seem to have the answer to. Let me first share you my code that are crucial: **Functions.php** ``` // text editor if ( ! class_exists( 'WP_Customize_Control' ) ) return NULL; /** * Class to create a custom tags control *...
My problem has been "solved" by doing the following : The problem is that do\_action is getting called each time that i have a new class. But it needs to be called only in the last. Otherwise this creates a bunch of admin\_print\_footer\_scripts. Since i'm writing the code myself and i don't intend on selling this fo...
264,479
<p>I want to remove the page name from displaying in my browser's tab. How do I hide the page name and only show the name of my website?</p> <p><a href="https://i.stack.imgur.com/EFpCB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EFpCB.png" alt="enter image description here"></a></p>
[ { "answer_id": 264480, "author": "JItendra Rana", "author_id": 87433, "author_profile": "https://wordpress.stackexchange.com/users/87433", "pm_score": 2, "selected": true, "text": "<p>You can either use this code in your function.php </p>\n\n<pre><code>remove_all_filters( 'wp_title' );\n...
2017/04/22
[ "https://wordpress.stackexchange.com/questions/264479", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/108734/" ]
I want to remove the page name from displaying in my browser's tab. How do I hide the page name and only show the name of my website? [![enter image description here](https://i.stack.imgur.com/EFpCB.png)](https://i.stack.imgur.com/EFpCB.png)
You can either use this code in your function.php ``` remove_all_filters( 'wp_title' ); add_filter('wp_title', 'filter_pagetitle', 99,1); function filter_pagetitle($title) { $title = get_bloginfo('name'); return $title; } ``` Or install plugin like [Yoast SEO](https://wordpress.org/plugins/wordpress-seo/). ...
264,483
<p>I am doing the code work for a website that someone else will be managing. I'm worried that just telling them not to use the code editor for appearance or plugins won't be enough to stop them from doing so.</p> <p>I've tried the standard WordPress <code>add_role( $role, $title, $capability )</code> but I can't fig...
[ { "answer_id": 264480, "author": "JItendra Rana", "author_id": 87433, "author_profile": "https://wordpress.stackexchange.com/users/87433", "pm_score": 2, "selected": true, "text": "<p>You can either use this code in your function.php </p>\n\n<pre><code>remove_all_filters( 'wp_title' );\n...
2017/04/22
[ "https://wordpress.stackexchange.com/questions/264483", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118207/" ]
I am doing the code work for a website that someone else will be managing. I'm worried that just telling them not to use the code editor for appearance or plugins won't be enough to stop them from doing so. I've tried the standard WordPress `add_role( $role, $title, $capability )` but I can't figure out what combinati...
You can either use this code in your function.php ``` remove_all_filters( 'wp_title' ); add_filter('wp_title', 'filter_pagetitle', 99,1); function filter_pagetitle($title) { $title = get_bloginfo('name'); return $title; } ``` Or install plugin like [Yoast SEO](https://wordpress.org/plugins/wordpress-seo/). ...
264,488
<p>I want to write update query to expire transients . I will upadte their time to 1 in wordpress option table. </p> <p>My query for update is </p> <pre><code>$wpdb-&gt;update( 'options', array( 'option_value' =&gt; '1', // string ), array( 'option_name' =&gt; '%re_compare%' ) ); </code...
[ { "answer_id": 264492, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 1, "selected": false, "text": "<p>Transients are not guaranteed to use database at all. They will use object cache if it is enabled.</p>\n\n<p>And si...
2017/04/22
[ "https://wordpress.stackexchange.com/questions/264488", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105243/" ]
I want to write update query to expire transients . I will upadte their time to 1 in wordpress option table. My query for update is ``` $wpdb->update( 'options', array( 'option_value' => '1', // string ), array( 'option_name' => '%re_compare%' ) ); ``` Its not working . Basically I...
Transients are not guaranteed to use database at all. They will use object cache if it is enabled. And since there is no bulk delete in object cache API, effectively there is no reliable way to clear out transients across all possible environments. There are some *performance* reasons to clear them out of database (w...
264,498
<p>I have 2 plugins</p> <p>1) FAT Gallery</p> <p>2) Salon Booking</p> <p>So FAT Gallery has a certain js lib (select2) which conflicts with Salon Booking Settings page.</p> <p>In this URL</p> <pre><code>example.com/wp-admin/post-new.php?post_type=sln_booking </code></pre> <p>I'm trying to <code>DISABLE</code> the...
[ { "answer_id": 264501, "author": "Max Yudin", "author_id": 11761, "author_profile": "https://wordpress.stackexchange.com/users/11761", "pm_score": 3, "selected": true, "text": "<p>That's pretty easy.</p>\n\n<p>Remember, I don't know exactly what's the plugin's file name and directory, an...
2017/04/22
[ "https://wordpress.stackexchange.com/questions/264498", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82936/" ]
I have 2 plugins 1) FAT Gallery 2) Salon Booking So FAT Gallery has a certain js lib (select2) which conflicts with Salon Booking Settings page. In this URL ``` example.com/wp-admin/post-new.php?post_type=sln_booking ``` I'm trying to `DISABLE` the FAT Gallery because it causes js error and i cant do my job. An...
That's pretty easy. Remember, I don't know exactly what's the plugin's file name and directory, and the following code was not tested. Put this to the `functions.php` or create a small plugin. ``` <?php add_filter( 'option_active_plugins', 'wpse264498_deactivate_fat_gallery' ); function wpse264498_deactivate_fat_ga...
264,505
<p>I use the following method to add a $_GET Variable to my custom post type in wordpress.</p> <pre><code> add_filter('query_vars', 'add_type2_var', 0, 1); function add_type2_var($vars){ $vars[] = 'type2'; return $vars; } add_rewrite_rule('/?c/(.[^/])/(.[^/])/(.*)$',"/c/$1/$2?type2=$3",'top'); </code></pre> <p>My c...
[ { "answer_id": 264501, "author": "Max Yudin", "author_id": 11761, "author_profile": "https://wordpress.stackexchange.com/users/11761", "pm_score": 3, "selected": true, "text": "<p>That's pretty easy.</p>\n\n<p>Remember, I don't know exactly what's the plugin's file name and directory, an...
2017/04/22
[ "https://wordpress.stackexchange.com/questions/264505", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/68381/" ]
I use the following method to add a $\_GET Variable to my custom post type in wordpress. ``` add_filter('query_vars', 'add_type2_var', 0, 1); function add_type2_var($vars){ $vars[] = 'type2'; return $vars; } add_rewrite_rule('/?c/(.[^/])/(.[^/])/(.*)$',"/c/$1/$2?type2=$3",'top'); ``` My custom post type is non-hi...
That's pretty easy. Remember, I don't know exactly what's the plugin's file name and directory, and the following code was not tested. Put this to the `functions.php` or create a small plugin. ``` <?php add_filter( 'option_active_plugins', 'wpse264498_deactivate_fat_gallery' ); function wpse264498_deactivate_fat_ga...
264,509
<p>I'm attempting to display a specific taxonomy (channel) in the archive.php page. I want to display the taxonomy's URL, name, post count, and taxonomy image.</p> <p>This is what I have that's working so far:</p> <pre><code>&lt;?php $taxonomy = 'channel'; $tax_terms = get_terms($taxonomy); $image_url = print apply_f...
[ { "answer_id": 264501, "author": "Max Yudin", "author_id": 11761, "author_profile": "https://wordpress.stackexchange.com/users/11761", "pm_score": 3, "selected": true, "text": "<p>That's pretty easy.</p>\n\n<p>Remember, I don't know exactly what's the plugin's file name and directory, an...
2017/04/22
[ "https://wordpress.stackexchange.com/questions/264509", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35798/" ]
I'm attempting to display a specific taxonomy (channel) in the archive.php page. I want to display the taxonomy's URL, name, post count, and taxonomy image. This is what I have that's working so far: ``` <?php $taxonomy = 'channel'; $tax_terms = get_terms($taxonomy); $image_url = print apply_filters( 'taxonomy-images...
That's pretty easy. Remember, I don't know exactly what's the plugin's file name and directory, and the following code was not tested. Put this to the `functions.php` or create a small plugin. ``` <?php add_filter( 'option_active_plugins', 'wpse264498_deactivate_fat_gallery' ); function wpse264498_deactivate_fat_ga...
264,511
<p>At this moment I use functions as described in the "Theme handbook" from the WordPress site. The problem is that the stylesheet is loading on the backend pages too and it affects the layout of the backend pages. This behavior is not wanted.</p> <p>The code I use to load the stylesheet -> <a href="https://pastebin.c...
[ { "answer_id": 264514, "author": "Max Yudin", "author_id": 11761, "author_profile": "https://wordpress.stackexchange.com/users/11761", "pm_score": 1, "selected": true, "text": "<p>There is a conditional tag <code>is_admin()</code> which checks are you in the Administration Panel or Front...
2017/04/22
[ "https://wordpress.stackexchange.com/questions/264511", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118223/" ]
At this moment I use functions as described in the "Theme handbook" from the WordPress site. The problem is that the stylesheet is loading on the backend pages too and it affects the layout of the backend pages. This behavior is not wanted. The code I use to load the stylesheet -> <https://pastebin.com/rAMZSu3u> Does...
There is a conditional tag `is_admin()` which checks are you in the Administration Panel or Frontend. So, ``` if( !is_admin() ) { wp_enqueue_style( 'css-minified', get_stylesheet_directory_uri() . DIRECTORY_SEPARATOR . 'style.css', [], null, 'all' ); wp_enqueue_styl...
264,527
<p>I'm currently trying to build a wordpress plugin. I'd like its users to be able to add an upload file to the settings field menu of my plugin and then to be registered into the wordpress database, is there some way to do that?</p>
[ { "answer_id": 264579, "author": "Nate", "author_id": 87380, "author_profile": "https://wordpress.stackexchange.com/users/87380", "pm_score": 0, "selected": false, "text": "<p>The media manager is loaded using jQuery.<br>\nHere is a sample JS file that I've found. I hope it helps.</p>\n\...
2017/04/22
[ "https://wordpress.stackexchange.com/questions/264527", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118080/" ]
I'm currently trying to build a wordpress plugin. I'd like its users to be able to add an upload file to the settings field menu of my plugin and then to be registered into the wordpress database, is there some way to do that?
I think I've been down that road. Take a look at `wp_handle_upload`, which will upload your file to the /uploads directory and then `wp_insert_attachment` and `wp_generate_attachment_metadata` to list said upload in the media library as an attachment which will 'register it in the wordpress database'. Then you can quer...
264,531
<p>I have 20,000 fake subscribers I'd like to get rid of. The admin panel only lets you delete 200 at a time.</p> <p>How can I bulk delete all Wordpress subscribers via MySQL?</p>
[ { "answer_id": 264579, "author": "Nate", "author_id": 87380, "author_profile": "https://wordpress.stackexchange.com/users/87380", "pm_score": 0, "selected": false, "text": "<p>The media manager is loaded using jQuery.<br>\nHere is a sample JS file that I've found. I hope it helps.</p>\n\...
2017/04/22
[ "https://wordpress.stackexchange.com/questions/264531", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34762/" ]
I have 20,000 fake subscribers I'd like to get rid of. The admin panel only lets you delete 200 at a time. How can I bulk delete all Wordpress subscribers via MySQL?
I think I've been down that road. Take a look at `wp_handle_upload`, which will upload your file to the /uploads directory and then `wp_insert_attachment` and `wp_generate_attachment_metadata` to list said upload in the media library as an attachment which will 'register it in the wordpress database'. Then you can quer...
264,548
<p>The WordPress editor keeps adding “amp;” after every “&amp;”.</p> <p>This effectively breaks all my custom links. How can i stop this? I don’t mind all the others things the editor does to the formatting i just need it to stop adding “amp;”. Is there a filter i can use?</p>
[ { "answer_id": 264996, "author": "Christine Cooper", "author_id": 24875, "author_profile": "https://wordpress.stackexchange.com/users/24875", "pm_score": 2, "selected": true, "text": "<p>One solution is to hook into <code>wp_insert_post_data</code> and do some regex magic to replace all ...
2017/04/23
[ "https://wordpress.stackexchange.com/questions/264548", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/77283/" ]
The WordPress editor keeps adding “amp;” after every “&”. This effectively breaks all my custom links. How can i stop this? I don’t mind all the others things the editor does to the formatting i just need it to stop adding “amp;”. Is there a filter i can use?
One solution is to hook into `wp_insert_post_data` and do some regex magic to replace all instances of `&amp;` with `&`: ``` // when saving posts, replace &amp; with & function cc_wpse_264548_unamp( $data ) { $data['post_content'] = preg_replace( "/&amp;/", // find '&amp;' "&", // replace with '&'...
264,565
<p>i would want to customize the navigation menu so that its dropdown-menu stays active all the time, i don't want it to appear on hover, but when the page of the active main menu item has loaded and the submenu should remain visible. So when the home page loads it's submenu should be visible just like at www.dailymail...
[ { "answer_id": 264570, "author": "Mervan Agency", "author_id": 118206, "author_profile": "https://wordpress.stackexchange.com/users/118206", "pm_score": 1, "selected": false, "text": "<p>We have created a CodePen to demonstrate how you can achieve that using HTML/CSS/JS. Hope that will ...
2017/04/23
[ "https://wordpress.stackexchange.com/questions/264565", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118256/" ]
i would want to customize the navigation menu so that its dropdown-menu stays active all the time, i don't want it to appear on hover, but when the page of the active main menu item has loaded and the submenu should remain visible. So when the home page loads it's submenu should be visible just like at www.dailymail.co...
WordPress automatically generates "current-menu-item" class to the menu of the current page you visit. So in this case, you can do something like- ``` .current-menu-item ul.sub-menu { display: block !important; } ```
264,606
<p>I have a website with two user role named “A” and “B” when anyone doing registration with "A" then i want to send a welcome email and when with “B” wanna send different welcome email, is it possible? Thanks in advance</p>
[ { "answer_id": 264609, "author": "Jared Cobb", "author_id": 6737, "author_profile": "https://wordpress.stackexchange.com/users/6737", "pm_score": 1, "selected": false, "text": "<p>Yes, this is possible. WordPress defines a function named <a href=\"https://developer.wordpress.org/referenc...
2017/04/23
[ "https://wordpress.stackexchange.com/questions/264606", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/96944/" ]
I have a website with two user role named “A” and “B” when anyone doing registration with "A" then i want to send a welcome email and when with “B” wanna send different welcome email, is it possible? Thanks in advance
Yes, this is possible. WordPress defines a function named [`wp_new_user_notification`](https://developer.wordpress.org/reference/functions/wp_new_user_notification/). You can override this function by creating your own version (also named `wp_new_user_notification`) in your own theme or plugin. You may wish to start b...
264,608
<p>I've searched multiple forums, and not finding anything quite like this... On a site I manage, there are several parent pages with links to child pages embedded in images. Each image links to the corresponding child page without a problem. ONE of the parents pages, however, when I click on any of the images (or even...
[ { "answer_id": 264609, "author": "Jared Cobb", "author_id": 6737, "author_profile": "https://wordpress.stackexchange.com/users/6737", "pm_score": 1, "selected": false, "text": "<p>Yes, this is possible. WordPress defines a function named <a href=\"https://developer.wordpress.org/referenc...
2017/04/23
[ "https://wordpress.stackexchange.com/questions/264608", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118239/" ]
I've searched multiple forums, and not finding anything quite like this... On a site I manage, there are several parent pages with links to child pages embedded in images. Each image links to the corresponding child page without a problem. ONE of the parents pages, however, when I click on any of the images (or even tr...
Yes, this is possible. WordPress defines a function named [`wp_new_user_notification`](https://developer.wordpress.org/reference/functions/wp_new_user_notification/). You can override this function by creating your own version (also named `wp_new_user_notification`) in your own theme or plugin. You may wish to start b...
264,617
<p>I have made simple wordpress layout and the border-bottom in footer do not show. Here is the part of the code of my <code>style.css</code> file:</p> <pre><code>.site-header { border-bottom: 2px solid #999; } .site-footer { border-top: 20px solid #999; } </code></pre> <p>The header border shows correctly b...
[ { "answer_id": 264609, "author": "Jared Cobb", "author_id": 6737, "author_profile": "https://wordpress.stackexchange.com/users/6737", "pm_score": 1, "selected": false, "text": "<p>Yes, this is possible. WordPress defines a function named <a href=\"https://developer.wordpress.org/referenc...
2017/04/23
[ "https://wordpress.stackexchange.com/questions/264617", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118380/" ]
I have made simple wordpress layout and the border-bottom in footer do not show. Here is the part of the code of my `style.css` file: ``` .site-header { border-bottom: 2px solid #999; } .site-footer { border-top: 20px solid #999; } ``` The header border shows correctly but the footer doesn't. Thank you for ...
Yes, this is possible. WordPress defines a function named [`wp_new_user_notification`](https://developer.wordpress.org/reference/functions/wp_new_user_notification/). You can override this function by creating your own version (also named `wp_new_user_notification`) in your own theme or plugin. You may wish to start b...
264,642
<p>I have sidebar.php and it show 10 popularpost of my wordpress post. But i want just Display popularpost of the last 2 days. How i can correct it?</p> <p>Thanks</p> <pre><code> &lt;/div&gt; &lt;?php } if (of_get_option('most_radio')==1) { ?&gt; &lt;div class="rmen...
[ { "answer_id": 264645, "author": "v-stackOverFollower", "author_id": 118148, "author_profile": "https://wordpress.stackexchange.com/users/118148", "pm_score": 1, "selected": true, "text": "<p>in argument list please also pass date_query, try below example.</p>\n\n<pre><code>$args = array...
2017/04/24
[ "https://wordpress.stackexchange.com/questions/264642", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118301/" ]
I have sidebar.php and it show 10 popularpost of my wordpress post. But i want just Display popularpost of the last 2 days. How i can correct it? Thanks ``` </div> <?php } if (of_get_option('most_radio')==1) { ?> <div class="rmenu col-lg-12 col-sm-12 col-xs-12"> ...
in argument list please also pass date\_query, try below example. ``` $args = array( 'posts_per_page' => 10, 'post_type' => 'post', 'order' => 'DESC', 'date_query' => array( 'after' => '2 days ago', 'inclusive' => true ) ); $posts = get_posts($args); ```
264,681
<p>We moved the site to HTTPS recently (for the most part following this guide: <a href="https://www.bram.us/2014/12/06/migrating-your-wordpress-website-from-http-to-https/" rel="nofollow noreferrer">https://www.bram.us/2014/12/06/migrating-your-wordpress-website-from-http-to-https/</a> ) </p> <p>Now, most things are ...
[ { "answer_id": 264687, "author": "ahendwh2", "author_id": 112098, "author_profile": "https://wordpress.stackexchange.com/users/112098", "pm_score": 0, "selected": false, "text": "<p>Did you cleared (resaved) your permalinks?</p>\n\n<p><strong>Settings -> Permalinks -> Click on \"Save Cha...
2017/04/24
[ "https://wordpress.stackexchange.com/questions/264681", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/116966/" ]
We moved the site to HTTPS recently (for the most part following this guide: <https://www.bram.us/2014/12/06/migrating-your-wordpress-website-from-http-to-https/> ) Now, most things are working perfectly - with the site loading as HTTPS and having the green icon on most pages. (The site name has been updated to refer...
If you are using Apache as your web server then add ``` # ensure https RewriteCond %{HTTP:X-Forwarded-Proto} !https RewriteCond %{HTTPS} off RewriteRule ^ https://%{HTTP_HOST}%{REQUEST_URI} [L,R=301] ``` in your .htaccess file, this can be found in the root wordpress directory. Alternatively you can use [WP Force S...
264,686
<p>I have a problem with Add to Basket background and width display on mobile phone. I do not know why it has been like that.</p> <p>Can you guys checkout my website <a href="https://www.theturkishshop.com" rel="nofollow noreferrer">https://www.theturkishshop.com</a> and let me know how I can fix "ADD TO BASKET" butto...
[ { "answer_id": 264689, "author": "Tarun modi", "author_id": 115973, "author_profile": "https://wordpress.stackexchange.com/users/115973", "pm_score": 0, "selected": false, "text": "<p>Hello You needs to add following css:</p>\n\n<pre><code>a.button.product_type_simple.add_to_cart_button....
2017/04/24
[ "https://wordpress.stackexchange.com/questions/264686", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/107174/" ]
I have a problem with Add to Basket background and width display on mobile phone. I do not know why it has been like that. Can you guys checkout my website <https://www.theturkishshop.com> and let me know how I can fix "ADD TO BASKET" button, which is displaying not correctly ( the background of the left is white). Th...
You have to add `background-image: none !important;` to your buttons CSS. Complete CSS-Rule: ``` @media screen and (max-width: 767px) { a.button.product_type_simple.add_to_cart_button.ajax_add_to_cart { background-image: none !important; } } ```
264,693
<p>Looking for some fresh eyes on this,</p> <p>I have a custom archive for my CPT and it's Taxonomies.</p> <p>The page has a input search form to filter posts of the CPT as well as drop downs to filter by terms.</p> <p>The issue is that on page load, when the loop instantiates WP_Query args are overridden by <code>g...
[ { "answer_id": 264689, "author": "Tarun modi", "author_id": 115973, "author_profile": "https://wordpress.stackexchange.com/users/115973", "pm_score": 0, "selected": false, "text": "<p>Hello You needs to add following css:</p>\n\n<pre><code>a.button.product_type_simple.add_to_cart_button....
2017/04/24
[ "https://wordpress.stackexchange.com/questions/264693", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/96432/" ]
Looking for some fresh eyes on this, I have a custom archive for my CPT and it's Taxonomies. The page has a input search form to filter posts of the CPT as well as drop downs to filter by terms. The issue is that on page load, when the loop instantiates WP\_Query args are overridden by `get_query_vars`. For example...
You have to add `background-image: none !important;` to your buttons CSS. Complete CSS-Rule: ``` @media screen and (max-width: 767px) { a.button.product_type_simple.add_to_cart_button.ajax_add_to_cart { background-image: none !important; } } ```
264,749
<p>Is there a way to trigger the post saving or updating event in code? such as <code>do_action('save_post', $post_id)</code>; The function here seems to imply that a WP_POST object needs to be passed in. Is there a way to basically imitate the action of updating the post with all its existing values. The point is for ...
[ { "answer_id": 264785, "author": "Welcher", "author_id": 27210, "author_profile": "https://wordpress.stackexchange.com/users/27210", "pm_score": -1, "selected": false, "text": "<p>The answer to your question is to call <code>do_action</code> with the correct parameters. However, I would ...
2017/04/24
[ "https://wordpress.stackexchange.com/questions/264749", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/117263/" ]
Is there a way to trigger the post saving or updating event in code? such as `do_action('save_post', $post_id)`; The function here seems to imply that a WP\_POST object needs to be passed in. Is there a way to basically imitate the action of updating the post with all its existing values. The point is for the other hoo...
It's [`wp_insert_post()`](https://developer.wordpress.org/reference/functions/wp_insert_post/) vs. [`wp_update_post()`](https://developer.wordpress.org/reference/functions/wp_update_post/) - where update will ultimately also call: ``` return wp_insert_post( $postarr, $wp_error, $fire_after_hooks ); ``` The term "onc...
264,757
<p>I have built an store on WooCommerce, I've used <a href="https://wordpress.org/support/plugin/wc-cancel-order" rel="nofollow noreferrer">WC Cancel Order</a> plugin to implement Cancel Order functionality for COD as well. But when any user requests for cancellation and even after it's approved by the admin, the quant...
[ { "answer_id": 264785, "author": "Welcher", "author_id": 27210, "author_profile": "https://wordpress.stackexchange.com/users/27210", "pm_score": -1, "selected": false, "text": "<p>The answer to your question is to call <code>do_action</code> with the correct parameters. However, I would ...
2017/04/24
[ "https://wordpress.stackexchange.com/questions/264757", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114978/" ]
I have built an store on WooCommerce, I've used [WC Cancel Order](https://wordpress.org/support/plugin/wc-cancel-order) plugin to implement Cancel Order functionality for COD as well. But when any user requests for cancellation and even after it's approved by the admin, the quantity of the product does not restore.
It's [`wp_insert_post()`](https://developer.wordpress.org/reference/functions/wp_insert_post/) vs. [`wp_update_post()`](https://developer.wordpress.org/reference/functions/wp_update_post/) - where update will ultimately also call: ``` return wp_insert_post( $postarr, $wp_error, $fire_after_hooks ); ``` The term "onc...
264,780
<p>I'm trying to do custom function when new user register then adds new user role, new user role is the username. </p> <p>For example, when user register and the username is apple, It will automatically create a role called Apple and assign to Apple user.</p> <pre><code>add_action( 'user_register', 'add_new_role' );...
[ { "answer_id": 264786, "author": "hwl", "author_id": 118366, "author_profile": "https://wordpress.stackexchange.com/users/118366", "pm_score": 0, "selected": false, "text": "<p>The function <em>get_userdata()</em> will return a WP_User object so you can access the <em>user_login</em> (ak...
2017/04/25
[ "https://wordpress.stackexchange.com/questions/264780", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118364/" ]
I'm trying to do custom function when new user register then adds new user role, new user role is the username. For example, when user register and the username is apple, It will automatically create a role called Apple and assign to Apple user. ``` add_action( 'user_register', 'add_new_role' ); function add_new_ro...
The [`user_register`](https://codex.wordpress.org/Plugin_API/Action_Reference/user_register) hook passes the parameter `$user_id` to your function. Get the login name after instantiating a user object with [`get_userdata( $user_id )`](https://codex.wordpress.org/Function_Reference/get_userdata). Update the assigned u...
264,802
<p>I want to know is there any wordpres function that allow me to check whether the given string is title of any wordpress custom post type or not.</p>
[ { "answer_id": 264806, "author": "David Klhufek", "author_id": 113922, "author_profile": "https://wordpress.stackexchange.com/users/113922", "pm_score": 2, "selected": false, "text": "<p>you can do it with Function <strong>post_type_exists</strong>\n<a href=\"https://codex.wordpress.org/...
2017/04/25
[ "https://wordpress.stackexchange.com/questions/264802", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/117292/" ]
I want to know is there any wordpres function that allow me to check whether the given string is title of any wordpress custom post type or not.
you can do it with Function **post\_type\_exists** <https://codex.wordpress.org/Function_Reference/post_type_exists> **Examples** ``` if ( post_type_exists( 'book' ) ) { echo 'the Book post type exists'; } $exists = post_type_exists( 'post' ); // returns true $exists = post_type_exists( 'page' ); // returns true ...
264,822
<p>I currently have a multisite install with 4 sites and 4 domains, like so:</p> <p><code>Site 1</code> -> <code>site1.com</code></p> <p><code>Site 2</code> -> <code>site2.com</code></p> <p><code>Site 3</code> -> <code>site3.com</code></p> <p><code>Site 4</code> -> <code>site4.com</code></p> <p>There was a typo in...
[ { "answer_id": 264806, "author": "David Klhufek", "author_id": 113922, "author_profile": "https://wordpress.stackexchange.com/users/113922", "pm_score": 2, "selected": false, "text": "<p>you can do it with Function <strong>post_type_exists</strong>\n<a href=\"https://codex.wordpress.org/...
2017/04/25
[ "https://wordpress.stackexchange.com/questions/264822", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82285/" ]
I currently have a multisite install with 4 sites and 4 domains, like so: `Site 1` -> `site1.com` `Site 2` -> `site2.com` `Site 3` -> `site3.com` `Site 4` -> `site4.com` There was a typo in the domain of `Site 3`, so we changed `site3.com` to `site3-new.com`. So far so good. Now we want `site3-new.com` to show `Si...
you can do it with Function **post\_type\_exists** <https://codex.wordpress.org/Function_Reference/post_type_exists> **Examples** ``` if ( post_type_exists( 'book' ) ) { echo 'the Book post type exists'; } $exists = post_type_exists( 'post' ); // returns true $exists = post_type_exists( 'page' ); // returns true ...
264,866
<p>Is it possible to create a sign up form that can work through WP REST API for visitors to be able to create accounts on my site?</p> <p>I can create such a form and use it to create new users. This works with wp_rest nonce when I am logged in as administrator.</p> <p>But if there is a visitor which is not logged i...
[ { "answer_id": 265005, "author": "JSP", "author_id": 23259, "author_profile": "https://wordpress.stackexchange.com/users/23259", "pm_score": 2, "selected": false, "text": "<p>You could create your own signup routine using <code>wp-includes/rest-api/endpoints/class-wp-rest-users-controlle...
2017/04/25
[ "https://wordpress.stackexchange.com/questions/264866", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118403/" ]
Is it possible to create a sign up form that can work through WP REST API for visitors to be able to create accounts on my site? I can create such a form and use it to create new users. This works with wp\_rest nonce when I am logged in as administrator. But if there is a visitor which is not logged in, the same form...
hopefully you've found the answer already. Here's our solution, for your reference. :D The following code should add User Registration via REST API to your WordPress Website. It supports Registration of 'subscriber' and 'customer'. Add it to your function.php ``` add_action('rest_api_init', 'wp_rest_user_endpoints')...
264,896
<p>I'm trying to query a custom post type's category to display in another custom post type, but only if they have matching categories.</p> <p>I'm new to coding a fairly complex WordPress site from scratch (it's fun) - I think I am probably typing the query wrong - any help will be appreciated.</p> <pre><code> &lt...
[ { "answer_id": 264900, "author": "jdm2112", "author_id": 45202, "author_profile": "https://wordpress.stackexchange.com/users/45202", "pm_score": 0, "selected": false, "text": "<p>Based on your posted code, you have a mismatch in your variable<code>$cat_id</code>. In the first instance, ...
2017/04/25
[ "https://wordpress.stackexchange.com/questions/264896", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114208/" ]
I'm trying to query a custom post type's category to display in another custom post type, but only if they have matching categories. I'm new to coding a fairly complex WordPress site from scratch (it's fun) - I think I am probably typing the query wrong - any help will be appreciated. ``` <section id="meet-team">...
if you are adding the custom query into the single template, try working with [`get_the_category()`](https://developer.wordpress.org/reference/functions/get_the_category/) to get the cat\_id for your query; also, [`get_posts()`](https://codex.wordpress.org/Template_Tags/get_posts) does not work with `if( have_posts() ...
264,924
<p>This is my table. I simply would like one select statement that returns coupon_code, max_uses, and times_used. I don't know how to join it all to do that.</p> <pre><code>mysql&gt; select * from wp_postmeta where post_id = '207717'; +---------+---------+------------------------+-------------------------------+ | m...
[ { "answer_id": 264926, "author": "Welcher", "author_id": 27210, "author_profile": "https://wordpress.stackexchange.com/users/27210", "pm_score": 1, "selected": false, "text": "<p>If you use <a href=\"https://developer.wordpress.org/reference/functions/get_post_meta/\" rel=\"nofollow nore...
2017/04/26
[ "https://wordpress.stackexchange.com/questions/264924", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118439/" ]
This is my table. I simply would like one select statement that returns coupon\_code, max\_uses, and times\_used. I don't know how to join it all to do that. ``` mysql> select * from wp_postmeta where post_id = '207717'; +---------+---------+------------------------+-------------------------------+ | meta_id | post_id...
If you use [get\_post\_meta()](https://developer.wordpress.org/reference/functions/get_post_meta/) with just the first parameter ( post ID ) you'll get an array of all the post meta for the passed ID. You'll get more than you expect but you can then use any number of ways to get the data that you want out. `$post_meta...
264,930
<p>I am using Wordpress, I have some URL issue. </p> <p>My current URL is IP address on server: <code>http://www.192.10.1.22/states/?q=ohio</code></p> <p>I want URL: <code>http://www.192.10.1.22/states/ohio</code></p> <p>I used following code in <code>functions.php</code> file and it's working in my local but when I...
[ { "answer_id": 264926, "author": "Welcher", "author_id": 27210, "author_profile": "https://wordpress.stackexchange.com/users/27210", "pm_score": 1, "selected": false, "text": "<p>If you use <a href=\"https://developer.wordpress.org/reference/functions/get_post_meta/\" rel=\"nofollow nore...
2017/04/26
[ "https://wordpress.stackexchange.com/questions/264930", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118443/" ]
I am using Wordpress, I have some URL issue. My current URL is IP address on server: `http://www.192.10.1.22/states/?q=ohio` I want URL: `http://www.192.10.1.22/states/ohio` I used following code in `functions.php` file and it's working in my local but when I upload in Cpanel then it's now working given me an error...
If you use [get\_post\_meta()](https://developer.wordpress.org/reference/functions/get_post_meta/) with just the first parameter ( post ID ) you'll get an array of all the post meta for the passed ID. You'll get more than you expect but you can then use any number of ways to get the data that you want out. `$post_meta...
264,932
<p>Some time ago, I added the following lines to my custom theme's functions.php file, in order to allow authors on my site to edit posts and drafts from all users:</p> <pre><code>function add_theme_caps() { $role = get_role( 'author' ); $role-&gt;add_cap( 'edit_others_posts' ); } add_action( 'admin_init', 'add_theme_...
[ { "answer_id": 264946, "author": "JCM", "author_id": 100958, "author_profile": "https://wordpress.stackexchange.com/users/100958", "pm_score": 1, "selected": false, "text": "<p>It looks like I have solved my own problem. I'm guessing that a function like that creates a permanent change,...
2017/04/26
[ "https://wordpress.stackexchange.com/questions/264932", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/100958/" ]
Some time ago, I added the following lines to my custom theme's functions.php file, in order to allow authors on my site to edit posts and drafts from all users: ``` function add_theme_caps() { $role = get_role( 'author' ); $role->add_cap( 'edit_others_posts' ); } add_action( 'admin_init', 'add_theme_caps'); ``` It ...
It looks like I have solved my own problem. I'm guessing that a function like that creates a permanent change, regardless of whether the function remains in the functions.php file. So, to fix this, I just added a new function reversing this adding. Here is that function: ``` function remove_theme_caps() { $role = get_...
264,939
<p>I want to fetch multiple posts with categories and tags currently I'm using this query:</p> <pre><code>$pagesize = 20; $pageNumber = 1; $mysql = mysqli_query($con,"SELECT p.post_title, p.ID, p.post_content, p.post_date, p.post_name as url, t.name as category_name FROM wp_posts p, wp_...
[ { "answer_id": 264946, "author": "JCM", "author_id": 100958, "author_profile": "https://wordpress.stackexchange.com/users/100958", "pm_score": 1, "selected": false, "text": "<p>It looks like I have solved my own problem. I'm guessing that a function like that creates a permanent change,...
2017/04/26
[ "https://wordpress.stackexchange.com/questions/264939", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118452/" ]
I want to fetch multiple posts with categories and tags currently I'm using this query: ``` $pagesize = 20; $pageNumber = 1; $mysql = mysqli_query($con,"SELECT p.post_title, p.ID, p.post_content, p.post_date, p.post_name as url, t.name as category_name FROM wp_posts p, wp_terms t, ...
It looks like I have solved my own problem. I'm guessing that a function like that creates a permanent change, regardless of whether the function remains in the functions.php file. So, to fix this, I just added a new function reversing this adding. Here is that function: ``` function remove_theme_caps() { $role = get_...
264,942
<p>I was trying to find an answer since many days. Can It be done that => Can we have one admin panel for 2 different wordpress sites ?</p> <p>2- Can we have 2 different wordpress websites that uses the single database ??</p>
[ { "answer_id": 264946, "author": "JCM", "author_id": 100958, "author_profile": "https://wordpress.stackexchange.com/users/100958", "pm_score": 1, "selected": false, "text": "<p>It looks like I have solved my own problem. I'm guessing that a function like that creates a permanent change,...
2017/04/26
[ "https://wordpress.stackexchange.com/questions/264942", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118454/" ]
I was trying to find an answer since many days. Can It be done that => Can we have one admin panel for 2 different wordpress sites ? 2- Can we have 2 different wordpress websites that uses the single database ??
It looks like I have solved my own problem. I'm guessing that a function like that creates a permanent change, regardless of whether the function remains in the functions.php file. So, to fix this, I just added a new function reversing this adding. Here is that function: ``` function remove_theme_caps() { $role = get_...
264,964
<p>is it possible to make my website redirect every link that starts with something like ​</p> <blockquote> <p>/nl​/products/motors​/</p> </blockquote> <p>to just </p> <blockquote> <p>/motors/</p> </blockquote> <p>even when a link has something like </p> <blockquote> <p>/nl/products/motors/allotherinfo/morei...
[ { "answer_id": 264966, "author": "Aishan", "author_id": 89530, "author_profile": "https://wordpress.stackexchange.com/users/89530", "pm_score": -1, "selected": false, "text": "<p>Redirect rule if the URL contains a certain word?\nPlease try with the code below:</p>\n\n<pre><code>RewriteC...
2017/04/26
[ "https://wordpress.stackexchange.com/questions/264964", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/90770/" ]
is it possible to make my website redirect every link that starts with something like ​ > > /nl​/products/motors​/ > > > to just > > /motors/ > > > even when a link has something like > > /nl/products/motors/allotherinfo/moreinfo/ect./ > > > to redirect something like this to > > /motors/ > > >...
You can use below code in .htaccess file ``` Redirect ^/nl​/products/motors​/.*$ /motors/ ``` So here if you url will match /nl/products/motors/ then it will redirect to /motors/
264,969
<p>I've tried this for the plugin BP Activity Share but it doesn't seem to work... this is what I have, where am I going wrong?</p> <pre><code>/**disable the BP Activity share for all except admin**/ add_action('admin_init', 'my_filter_the_plugins'); function my_filter_the_plugins() { global $current_user; ...
[ { "answer_id": 264976, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 3, "selected": false, "text": "<p>This is actually a basic PHP problem:</p>\n\n<pre><code>if (in_array('Participant', 'Subscriber', $current_u...
2017/04/26
[ "https://wordpress.stackexchange.com/questions/264969", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118468/" ]
I've tried this for the plugin BP Activity Share but it doesn't seem to work... this is what I have, where am I going wrong? ``` /**disable the BP Activity share for all except admin**/ add_action('admin_init', 'my_filter_the_plugins'); function my_filter_the_plugins() { global $current_user; if (in_array(...
This is actually a basic PHP problem: ``` if (in_array('Participant', 'Subscriber', $current_user->roles)) { ``` That's not how `in_array` works. `in_array` checks if the first bit is in the second bit. So is `Participant` inside `$current_user->roles`. What you've written however, checks if `Participant` is inside...
264,987
<p>I have made a favorite plugin. With a shortcode I'm able to display the button to 'a wish/favorite list' anywhere I want the button. This button is for adding the post_IDs of pages/posts/blogs/articles etc in a cookie array with this code:<br></p> <pre><code>&lt;?php if (isset($_POST['submit_wishlist'])){ if (!...
[ { "answer_id": 264993, "author": "Laxmana", "author_id": 40948, "author_profile": "https://wordpress.stackexchange.com/users/40948", "pm_score": 2, "selected": false, "text": "<p>You need to put the id of each item inside form to indicate the item that will be deleted.</p>\n\n<pre><code>...
2017/04/26
[ "https://wordpress.stackexchange.com/questions/264987", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/115316/" ]
I have made a favorite plugin. With a shortcode I'm able to display the button to 'a wish/favorite list' anywhere I want the button. This button is for adding the post\_IDs of pages/posts/blogs/articles etc in a cookie array with this code: ``` <?php if (isset($_POST['submit_wishlist'])){ if (!isset($_COOKIE['fa...
You need to put the id of each item inside form to indicate the item that will be deleted. ``` <?php $all_favorites= unserialize($_COOKIE['favorites']); echo '<table>'; foreach($all_favorites as $key => $value) { echo '<tr>'; echo 'Post-ID = ' . $value . ' '; ?> <form method="POST"> <input type="hidden" n...
264,997
<p>I've literally spent half a day trying to find a solution for this problem.</p> <p>From one WordPress installation I need to query multiple other WordPress installations' databases.</p> <p>I'd very much like to use the $wpdb way, as this is what I've always used (just haven't ever had the need to access more than ...
[ { "answer_id": 265002, "author": "user1049961", "author_id": 47664, "author_profile": "https://wordpress.stackexchange.com/users/47664", "pm_score": 1, "selected": false, "text": "<p>The <code>$new_db_connection</code> is your new db object. </p>\n\n<p>Just use that to access the other d...
2017/04/26
[ "https://wordpress.stackexchange.com/questions/264997", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118480/" ]
I've literally spent half a day trying to find a solution for this problem. From one WordPress installation I need to query multiple other WordPress installations' databases. I'd very much like to use the $wpdb way, as this is what I've always used (just haven't ever had the need to access more than one database). I...
The `$new_db_connection` is your new db object. Just use that to access the other db, ie. ``` $new_db_connection->get_row("your query"); ```
265,010
<p>I need to allow .exe file uploads through the admin media manager. So far I have tried</p> <pre><code>function enable_extended_upload ( $mime_types = array() ) { $mime_types['exe'] = 'application/octet-stream'; return $mime_types; } add_filter('upload_mimes', 'enable_extended_upload'); </code></pre> <p>T...
[ { "answer_id": 265657, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 1, "selected": false, "text": "<p>WordPress provide a hook to change the default mime types, like your hint in the question. The follow small code ...
2017/04/26
[ "https://wordpress.stackexchange.com/questions/265010", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44937/" ]
I need to allow .exe file uploads through the admin media manager. So far I have tried ``` function enable_extended_upload ( $mime_types = array() ) { $mime_types['exe'] = 'application/octet-stream'; return $mime_types; } add_filter('upload_mimes', 'enable_extended_upload'); ``` Three different sources hav...
WordPress provide a hook to change the default mime types, like your hint in the question. The follow small code source demonstrated the change to allow a exe-file. ``` add_filter( 'upload_mimes', 'fb_enable_extended_upload' ); function fb_enable_extended_upload ( array $mime_types = [] ) { $mime_types[ 'exe' ] =...
265,020
<p>I've seen many solutions but none seem to work for me... I've got a grid off the loop/content on <code>single.php</code> that renders the whole grid as is, so I use the function as below which works fine, but only if I specify the exact taxonomy term (<code>client-1</code>).</p> <pre><code>function my_query_args($q...
[ { "answer_id": 265029, "author": "essexboyracer", "author_id": 74358, "author_profile": "https://wordpress.stackexchange.com/users/74358", "pm_score": 0, "selected": false, "text": "<p>Have a look at <a href=\"https://codex.wordpress.org/Function_Reference/wp_get_post_terms\" rel=\"nofol...
2017/04/26
[ "https://wordpress.stackexchange.com/questions/265020", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118493/" ]
I've seen many solutions but none seem to work for me... I've got a grid off the loop/content on `single.php` that renders the whole grid as is, so I use the function as below which works fine, but only if I specify the exact taxonomy term (`client-1`). ``` function my_query_args($query_args, $grid_name) { if ($grid_n...
**SOLVED** This was what I was looking for and it works like a charm. ``` function my_query_args($query_args, $grid_name) { $term_list = get_the_terms( get_the_ID(), 'category' )[0]->slug; if ($grid_name == 'JTS-SINGLE') { $query_args['tax_query'] = array( array( 'taxonomy' => 'category', ...
265,068
<p>My theme automatically puts the sidebar above the content rather than below it when going responsive/mobile. </p> <p>I am trying to figure out how I can get it to go below the content instead, as having it above is really hurting customer experience because they have to scroll so much to see the product.</p> <p>Th...
[ { "answer_id": 265071, "author": "Aishan", "author_id": 89530, "author_profile": "https://wordpress.stackexchange.com/users/89530", "pm_score": 2, "selected": false, "text": "<p>Depending on which device you want to target, you'll need to use a media query, you can read more about those ...
2017/04/27
[ "https://wordpress.stackexchange.com/questions/265068", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/94819/" ]
My theme automatically puts the sidebar above the content rather than below it when going responsive/mobile. I am trying to figure out how I can get it to go below the content instead, as having it above is really hurting customer experience because they have to scroll so much to see the product. This is the demo of...
Depending on which device you want to target, you'll need to use a media query, you can read more about those here: [CssTrick](http://css-tricks.com/snippets/css/media-queries-for-standard-devices/): ``` @media only screen and (max-width : 320px) { #content { display: flex; /* Optional, if you want ...
265,092
<p>I need to pass a php string that is stored in <code>$attr['footer_caption']</code> inside a shortcode function to a js file where the highcharts are initialized.</p> <pre><code>$fields = array( array( 'label' =&gt; esc_html( 'Footer label' ), 'description' =&gt; esc_html( 'Choose th...
[ { "answer_id": 265071, "author": "Aishan", "author_id": 89530, "author_profile": "https://wordpress.stackexchange.com/users/89530", "pm_score": 2, "selected": false, "text": "<p>Depending on which device you want to target, you'll need to use a media query, you can read more about those ...
2017/04/27
[ "https://wordpress.stackexchange.com/questions/265092", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/117473/" ]
I need to pass a php string that is stored in `$attr['footer_caption']` inside a shortcode function to a js file where the highcharts are initialized. ``` $fields = array( array( 'label' => esc_html( 'Footer label' ), 'description' => esc_html( 'Choose the footer label' ), ...
Depending on which device you want to target, you'll need to use a media query, you can read more about those here: [CssTrick](http://css-tricks.com/snippets/css/media-queries-for-standard-devices/): ``` @media only screen and (max-width : 320px) { #content { display: flex; /* Optional, if you want ...
265,104
<p>I'm trying to run a query twice, once in a template part (page.php) and once in theme's functions.php. I'm doing this because i need to output some styles to theme's header, since i'm not allowed to use hardcoded inline styles.</p> <p>This is my main query:</p> <pre><code>if (have_posts()) { while (have_posts(...
[ { "answer_id": 265289, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 3, "selected": true, "text": "<p>You could cache the results for that page load. It should hit it in <code>header.php</code>, cache the objec...
2017/04/27
[ "https://wordpress.stackexchange.com/questions/265104", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/94498/" ]
I'm trying to run a query twice, once in a template part (page.php) and once in theme's functions.php. I'm doing this because i need to output some styles to theme's header, since i'm not allowed to use hardcoded inline styles. This is my main query: ``` if (have_posts()) { while (have_posts()) { the_post...
You could cache the results for that page load. It should hit it in `header.php`, cache the object, and in `index.php` you can check availability. Header ====== ``` $custom_query = new WP_Query( $args ); if( $custom_query->have_posts() ) { // Cache Query before loop wp_cache_add( 'custom_query', $custom_que...
265,120
<p>I'm finding this next to impossible to find any info on. I'm looking for a way to assign each category level a number and then add that number to the body class. e.g. the parent category archive would show the class <code>.catlevel-1</code>, whereas the child category archive would show class <code>.catlevel-2</code...
[ { "answer_id": 265125, "author": "Vinod Dalvi", "author_id": 14347, "author_profile": "https://wordpress.stackexchange.com/users/14347", "pm_score": 3, "selected": true, "text": "<p>You can achieve this by using the following custom code. You can use the code by adding it in the function...
2017/04/27
[ "https://wordpress.stackexchange.com/questions/265120", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37346/" ]
I'm finding this next to impossible to find any info on. I'm looking for a way to assign each category level a number and then add that number to the body class. e.g. the parent category archive would show the class `.catlevel-1`, whereas the child category archive would show class `.catlevel-2` ... and so on.
You can achieve this by using the following custom code. You can use the code by adding it in the functions.php file of child theme or in the custom plugin file. ``` add_filter( 'body_class', 'custom_cat_archiev_class' ); function custom_cat_archiev_class( $classes ) { if ( is_category() ) { $cat = get_que...
265,149
<p>I would like to display two different post types in the same query... nothing strange so far. But I would like to declare what taxonomies include and what exclude for both post types, so, for instance, I would like to display posts from the category "16" but that do not belong to "19" as well, and portfolio items fr...
[ { "answer_id": 265155, "author": "BlueSuiter", "author_id": 92665, "author_profile": "https://wordpress.stackexchange.com/users/92665", "pm_score": 0, "selected": false, "text": "<p>Try to run it like this, verify the results.\nAlso, make sure there are enough posts to give you results. ...
2017/04/27
[ "https://wordpress.stackexchange.com/questions/265149", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33681/" ]
I would like to display two different post types in the same query... nothing strange so far. But I would like to declare what taxonomies include and what exclude for both post types, so, for instance, I would like to display posts from the category "16" but that do not belong to "19" as well, and portfolio items from ...
Ok, according to the codex, if you use `tax_query` in your arguments for WP\_Query, then it will change the default of `post_type` from `posts` to `any`, BUT if a post\_type has `exclude_from_search` set to `true` then it still won't include it in `any`. So since we don't know what the configuration is on the portfolio...
265,164
<p>I have a custom WP table that I query to get back an array of values. What I need is to make these variables exist throughout the entire WP site. </p> <p>I'm not sure what the best way to do that is. Here's my function: </p> <pre><code>function get_dealer_info(){ global $wpdb; $table_name = $wpdb-&gt;prefix ....
[ { "answer_id": 265165, "author": "somebodysomewhere", "author_id": 44937, "author_profile": "https://wordpress.stackexchange.com/users/44937", "pm_score": 1, "selected": false, "text": "<p>Notice how in your function you are globalizing <code>$wpdb</code>? That's because somewhere else i...
2017/04/27
[ "https://wordpress.stackexchange.com/questions/265164", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44899/" ]
I have a custom WP table that I query to get back an array of values. What I need is to make these variables exist throughout the entire WP site. I'm not sure what the best way to do that is. Here's my function: ``` function get_dealer_info(){ global $wpdb; $table_name = $wpdb->prefix . "dealer_info"; $deale...
Do not use globals. Ever. 1. You **don't need** your object everywhere. You need it only where your code is running. 2. Globals are hard to debug, everyone can write to them or just delete them. 3. Unit tests with globals are possible, but awkward. You have to change the global state for each test, ie. something outs...
265,172
<p>my site started acting up a few days ago, running the debug I get these lines.</p> <p>Tried to mess around with the DB but couldn't get my head through it.</p> <p>Do you have any idea what those lines imply?</p> <blockquote> <p>Warning: mysqli_real_connect(): (HY000/2002): Can't connect to local MySQL server ...
[ { "answer_id": 265197, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 0, "selected": false, "text": "<p>Try using the IP address of your local server instead of <code>localhost</code>. That means set <code>127....
2017/04/27
[ "https://wordpress.stackexchange.com/questions/265172", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118596/" ]
my site started acting up a few days ago, running the debug I get these lines. Tried to mess around with the DB but couldn't get my head through it. Do you have any idea what those lines imply? > > Warning: mysqli\_real\_connect(): (HY000/2002): Can't connect to local > MySQL server through socket '/var/lib/mysql/...
I had this same error. For me, this happened because I moved the datadir of my database. On centos - the default location of the datadir is /var/lib/mysql - and the default loc of the socket file is /var/lib/mysql/mysql.sock I moved the datadir to /datadir/mysql. The Mysql db server started fine and the 'mysql' comm...
265,177
<p>I've installed Custom Post Type UI plugin on my client's site. I have registered two new post types called Resources and Case Studies. I've enabled them to have categories and tags support. All of this works fine.</p> <p>However, I want to be able to show a list of categories for only the case studies in the case s...
[ { "answer_id": 265197, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 0, "selected": false, "text": "<p>Try using the IP address of your local server instead of <code>localhost</code>. That means set <code>127....
2017/04/27
[ "https://wordpress.stackexchange.com/questions/265177", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/116115/" ]
I've installed Custom Post Type UI plugin on my client's site. I have registered two new post types called Resources and Case Studies. I've enabled them to have categories and tags support. All of this works fine. However, I want to be able to show a list of categories for only the case studies in the case studies sid...
I had this same error. For me, this happened because I moved the datadir of my database. On centos - the default location of the datadir is /var/lib/mysql - and the default loc of the socket file is /var/lib/mysql/mysql.sock I moved the datadir to /datadir/mysql. The Mysql db server started fine and the 'mysql' comm...
265,234
<p>I've created a simple custom post type. In my wordpress site, permalinks are set to Post Name.</p> <p>In the admin screen for posts of my custom post type, no permalink editor is displayed.</p> <p>How do I make this show up, as it does normally for the default post types?</p> <p>This is how I've created the defin...
[ { "answer_id": 265236, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 3, "selected": true, "text": "<p>Your CPT is not public, therefor the \"posts\" of that type have no reason to have a public URL (AKA perma...
2017/04/28
[ "https://wordpress.stackexchange.com/questions/265234", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26187/" ]
I've created a simple custom post type. In my wordpress site, permalinks are set to Post Name. In the admin screen for posts of my custom post type, no permalink editor is displayed. How do I make this show up, as it does normally for the default post types? This is how I've created the definition: ``` function reg...
Your CPT is not public, therefor the "posts" of that type have no reason to have a public URL (AKA permalink), therefor wordpress do not bother to add the permalink (actually slug) UI.
265,297
<p>We have a site that somehow has both http and https versions accessible. We want to force it all to https. When we try to set the WordPress and Site URLS to https the site ends up in a redirect loop.</p> <p>Using Really Simple SSL doesn't really help as we still end up with a redirect loop.</p> <p>Redirection plug...
[ { "answer_id": 265320, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 3, "selected": true, "text": "<p>If you can access the SSL version of your blog without a problem, then it means you can redirect all your tr...
2017/04/28
[ "https://wordpress.stackexchange.com/questions/265297", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/111880/" ]
We have a site that somehow has both http and https versions accessible. We want to force it all to https. When we try to set the WordPress and Site URLS to https the site ends up in a redirect loop. Using Really Simple SSL doesn't really help as we still end up with a redirect loop. Redirection plugin isn't doing an...
If you can access the SSL version of your blog without a problem, then it means you can redirect all your traffic to it. To do so, take these 2 steps: 1. Access your database using PhpMyAdmin or any other software you want. Head over to `wp_options` table, and change to values of `siteurl` and `homeurl` to SSL version...
265,318
<p>I am trying to understand when usage of admin url is required. If I do this in my plugins page, they all do the same thing.</p> <pre><code>&lt;a href="&lt;?php echo admin_url("admin.php?page=fap_playlist_manager"); ?&gt;"&gt;Back to Playlist manager&lt;/a&gt; &lt;a href="admin.php?page=fap_playlist_manager"&gt;Bac...
[ { "answer_id": 265308, "author": "Mervan Agency", "author_id": 118206, "author_profile": "https://wordpress.stackexchange.com/users/118206", "pm_score": 1, "selected": false, "text": "<p>I am not sure how you removed <code>?p=</code> from the link but you can use <code>get_shortlink</cod...
2017/04/29
[ "https://wordpress.stackexchange.com/questions/265318", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45321/" ]
I am trying to understand when usage of admin url is required. If I do this in my plugins page, they all do the same thing. ``` <a href="<?php echo admin_url("admin.php?page=fap_playlist_manager"); ?>">Back to Playlist manager</a> <a href="admin.php?page=fap_playlist_manager">Back to Playlist manager</a> <a href="?p...
I am not sure how you removed `?p=` from the link but you can use `get_shortlink` filter to override the shortlink. You can refer following article for more details. <http://www.wpbeginner.com/wp-themes/how-to-display-wordpress-shortlinks-in-your-theme/> Reference to `get_shortlink` filter: <https://developer.wordpre...
265,324
<p><code>bootstrap-slider.js</code> offered by seiyria not working in WordPress. It seems that resource file isn't linked properly. What am I missing here? Any idea?</p> <p>Link Resource to WordPress(<code>functions.php</code>): </p> <pre><code>if (!function_exists('techcare_enqueue_scripts')): function techcare_e...
[ { "answer_id": 265308, "author": "Mervan Agency", "author_id": 118206, "author_profile": "https://wordpress.stackexchange.com/users/118206", "pm_score": 1, "selected": false, "text": "<p>I am not sure how you removed <code>?p=</code> from the link but you can use <code>get_shortlink</cod...
2017/04/29
[ "https://wordpress.stackexchange.com/questions/265324", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118691/" ]
`bootstrap-slider.js` offered by seiyria not working in WordPress. It seems that resource file isn't linked properly. What am I missing here? Any idea? Link Resource to WordPress(`functions.php`): ``` if (!function_exists('techcare_enqueue_scripts')): function techcare_enqueue_scripts() { /* Enqueue Scripts Be...
I am not sure how you removed `?p=` from the link but you can use `get_shortlink` filter to override the shortlink. You can refer following article for more details. <http://www.wpbeginner.com/wp-themes/how-to-display-wordpress-shortlinks-in-your-theme/> Reference to `get_shortlink` filter: <https://developer.wordpre...
265,328
<p>I have created a child theme. </p> <p>In the parent theme there is a file <code>functions_custom.php</code>, which has some functions definitions. The file included in <code>functions.php</code> in the parent theme.</p> <p>Now I want to make some changes in one function that's in the <code>functions_custom.php</co...
[ { "answer_id": 265336, "author": "Mervan Agency", "author_id": 118206, "author_profile": "https://wordpress.stackexchange.com/users/118206", "pm_score": 3, "selected": false, "text": "<p>I am not sure if the function in the <code>functions_custom.php</code> that you wants to override is ...
2017/04/29
[ "https://wordpress.stackexchange.com/questions/265328", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74147/" ]
I have created a child theme. In the parent theme there is a file `functions_custom.php`, which has some functions definitions. The file included in `functions.php` in the parent theme. Now I want to make some changes in one function that's in the `functions_custom.php` file and the function used in `single.php` to ...
I am not sure if the function in the `functions_custom.php` that you wants to override is a pluggable functions like below: ``` if ( ! function_exists ( 'function_name' ) ) { function function_name() { // Function Code } } ``` If it is pluggable function then you can simply write function with same n...
265,335
<p>I have a custom post loop going into a template I made - the row has to be outside of the loop, or the posts don't line up vertically. However, I need some spacing between the posts - image below to illustrate: <a href="https://i.stack.imgur.com/KtZ3m.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.co...
[ { "answer_id": 265353, "author": "Disk01", "author_id": 82479, "author_profile": "https://wordpress.stackexchange.com/users/82479", "pm_score": 1, "selected": false, "text": "<p>There are several possible ways that you could do, these are:</p>\n\n<ol>\n<li>Adding <code>&lt;br /&gt;</code...
2017/04/29
[ "https://wordpress.stackexchange.com/questions/265335", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114208/" ]
I have a custom post loop going into a template I made - the row has to be outside of the loop, or the posts don't line up vertically. However, I need some spacing between the posts - image below to illustrate: [![Showing my row of posts with no padding](https://i.stack.imgur.com/KtZ3m.jpg)](https://i.stack.imgur.com/K...
There are several possible ways that you could do, these are: 1. Adding `<br />` html tag 2. Making it inside `<div style="...">....</div>` **Example:** ``` <div style="padding:10px;">...</div> ``` You can also use `<table>` if you want
265,337
<p>i need to call a javascript only if screen resolution is greater than 500.</p> <p>I found below code...</p> <pre><code>&lt;script type='text/javascript' src='&lt;?php echo $urlPlugin?&gt;js/jquery.themepunch.revolution.min.js?rev=&lt;?php echo RevSliderGlobals::SLIDER_REVISION; ?&gt;'&gt;&lt;/script&gt; </code></p...
[ { "answer_id": 265339, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 0, "selected": false, "text": "<p>You don't make it conditional on the server side, you just do not initialize/run it on client side when y...
2017/04/29
[ "https://wordpress.stackexchange.com/questions/265337", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86147/" ]
i need to call a javascript only if screen resolution is greater than 500. I found below code... ``` <script type='text/javascript' src='<?php echo $urlPlugin?>js/jquery.themepunch.revolution.min.js?rev=<?php echo RevSliderGlobals::SLIDER_REVISION; ?>'></script> ``` So, i modified it as below... ``` <script> if (w...
you can use Window matchMedia() Method <https://www.w3schools.com/jsref/met_win_matchmedia.asp> like this: ``` <script type="text/javascript"> if (matchMedia('only screen and (min-width: 500px)').matches) { } </script> ```
265,363
<p>So, we are building an internal WordPress theme for our company that will be used for a few dozen of our websites. The only thing that will differ between the sites is the color scheme.</p> <p>We're trying to figure out what the best way to handle the colors to still allow updates to all sites without having to in...
[ { "answer_id": 265339, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 0, "selected": false, "text": "<p>You don't make it conditional on the server side, you just do not initialize/run it on client side when y...
2017/04/30
[ "https://wordpress.stackexchange.com/questions/265363", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73975/" ]
So, we are building an internal WordPress theme for our company that will be used for a few dozen of our websites. The only thing that will differ between the sites is the color scheme. We're trying to figure out what the best way to handle the colors to still allow updates to all sites without having to individually ...
you can use Window matchMedia() Method <https://www.w3schools.com/jsref/met_win_matchmedia.asp> like this: ``` <script type="text/javascript"> if (matchMedia('only screen and (min-width: 500px)').matches) { } </script> ```
265,365
<p>I'm trying to add the attribute data-featherlight with a value of 'mylightbox' to all my post featured images. I believe this is the code I need, but I do not know where I put it. I'm working with the baseline twentyseventeen theme.</p> <pre><code>if ( has_post_thumbnail() ) { the_post_thumbnail(); the_post_thumbna...
[ { "answer_id": 267164, "author": "Ajay Malhotra", "author_id": 118989, "author_profile": "https://wordpress.stackexchange.com/users/118989", "pm_score": 1, "selected": false, "text": "<p>You can try like this:</p>\n\n<pre><code>if ( has_post_thumbnail() ) { // check if the post has a Pos...
2017/04/30
[ "https://wordpress.stackexchange.com/questions/265365", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118713/" ]
I'm trying to add the attribute data-featherlight with a value of 'mylightbox' to all my post featured images. I believe this is the code I need, but I do not know where I put it. I'm working with the baseline twentyseventeen theme. ``` if ( has_post_thumbnail() ) { the_post_thumbnail(); the_post_thumbnail('post_thumb...
You can try like this: ``` if ( has_post_thumbnail() ) { // check if the post has a Post Thumbnail assigned to it. the_post_thumbnail( 'full', array( 'class' => 'responsive-class' ) ); // show featured image } ```
265,417
<p>I have a hook, that detects opening the post(publication):</p> <pre><code>add_action('the_post', 'post_callback'); function post_callback($post) { $post-&gt;post_title = "New title"; $post-&gt;post_content = "New content"; } </code></pre> <p>It replaces <code>post_title, $post-&gt;post_content</code> data o...
[ { "answer_id": 265441, "author": "Toufic Batache", "author_id": 118735, "author_profile": "https://wordpress.stackexchange.com/users/118735", "pm_score": 3, "selected": true, "text": "<p>I have recently solved my issue, I went on wordpress support, found my issue and <a href=\"https://su...
2017/04/30
[ "https://wordpress.stackexchange.com/questions/265417", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118742/" ]
I have a hook, that detects opening the post(publication): ``` add_action('the_post', 'post_callback'); function post_callback($post) { $post->post_title = "New title"; $post->post_content = "New content"; } ``` It replaces `post_title, $post->post_content` data on the custom values. How to change HTML meta ...
I have recently solved my issue, I went on wordpress support, found my issue and [how to fix it](https://support.cloudflare.com/hc/en-us/articles/203487280-How-do-I-fix-mixed-content-issues-or-the-infinite-redirect-loop-error-after-enabling-Flexible-SSL-with-WordPress-). I installed the [SSL Insecure Content Fixer plug...
265,449
<p>I am using the following code (<a href="https://developer.wordpress.org/reference/hooks/set_user_role/" rel="nofollow noreferrer">https://developer.wordpress.org/reference/hooks/set_user_role/</a>) to sync user role between his blogs on a multisite installation.</p> <p>My question is if this approach can lead to an...
[ { "answer_id": 265460, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": true, "text": "<p>Yes it will give you infinite loop, because you're calling the <code>WP_User::set_role</code> method within th...
2017/05/01
[ "https://wordpress.stackexchange.com/questions/265449", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/30792/" ]
I am using the following code (<https://developer.wordpress.org/reference/hooks/set_user_role/>) to sync user role between his blogs on a multisite installation. My question is if this approach can lead to an infinite loop? ``` // Sync user role add_action( 'set_user_role', 'sync_user_role', 10, 2 ); function sync_us...
Yes it will give you infinite loop, because you're calling the `WP_User::set_role` method within the `set_user_role` action that's again fired within the the `WP_User::set_role` method. Not sure what the setup is but you can try to run it only once, with ``` remove_action( current_action(), __FUNCTION__ ); ``` as t...
265,487
<p>I need help with structuring permalink for the custom post type that I made. I think I tried all the answers here. I'm hoping somebody can help me. </p> <p><strong>More Info</strong></p> <p>The custom post is looks like this in my url <code>www.domain.com/oa/beauty/post-name</code> but I want it to looks like this...
[ { "answer_id": 265460, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": true, "text": "<p>Yes it will give you infinite loop, because you're calling the <code>WP_User::set_role</code> method within th...
2017/05/01
[ "https://wordpress.stackexchange.com/questions/265487", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118572/" ]
I need help with structuring permalink for the custom post type that I made. I think I tried all the answers here. I'm hoping somebody can help me. **More Info** The custom post is looks like this in my url `www.domain.com/oa/beauty/post-name` but I want it to looks like this `www.domain.com/beauty/post-name/` The `...
Yes it will give you infinite loop, because you're calling the `WP_User::set_role` method within the `set_user_role` action that's again fired within the the `WP_User::set_role` method. Not sure what the setup is but you can try to run it only once, with ``` remove_action( current_action(), __FUNCTION__ ); ``` as t...
265,499
<p>I am building an <a href="http://www.wpbeginner.com/wp-tutorials/how-to-create-advanced-search-form-in-wordpress-for-custom-post-types/" rel="nofollow noreferrer">advanced search form</a> but the search is showing all post all time with this error too <code>array_key_exists() expects parameter 2 to be array, string ...
[ { "answer_id": 265505, "author": "Howdy_McGee", "author_id": 7355, "author_profile": "https://wordpress.stackexchange.com/users/7355", "pm_score": 2, "selected": true, "text": "<p>The core issue is that you're having trouble creating a filtered search. Why not use a <code>pre_get_posts</...
2017/05/01
[ "https://wordpress.stackexchange.com/questions/265499", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27425/" ]
I am building an [advanced search form](http://www.wpbeginner.com/wp-tutorials/how-to-create-advanced-search-form-in-wordpress-for-custom-post-types/) but the search is showing all post all time with this error too `array_key_exists() expects parameter 2 to be array, string was given` this is my code in `header.php` ...
The core issue is that you're having trouble creating a filtered search. Why not use a `pre_get_posts` hook to modify the query before it actually gets called, then you don't need to modify the template files at all: ``` /** * Modify WP_Query before it asks the database what data to retrieve * Belongs in functions.p...
265,507
<p>I am in the process of changing my protocol from http to https.</p> <p>I have wordpress installed as a subdirectory (eg: www.example.com/blog)</p> <p>I have the server behind a load balancer, requests to the load balancer are encrypted but requests from the load balancer to the server are not.</p> <p>I updated th...
[ { "answer_id": 265509, "author": "mayersdesign", "author_id": 106965, "author_profile": "https://wordpress.stackexchange.com/users/106965", "pm_score": 0, "selected": false, "text": "<p>You need to update the baseurls in your database. Namely the option_values for <strong><em>siteurl</em...
2017/05/01
[ "https://wordpress.stackexchange.com/questions/265507", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102281/" ]
I am in the process of changing my protocol from http to https. I have wordpress installed as a subdirectory (eg: www.example.com/blog) I have the server behind a load balancer, requests to the load balancer are encrypted but requests from the load balancer to the server are not. I updated the `home` and `siteurl` p...
This is somewhat of a guess, but it is probably a result of the web server configuration. What your server probably does is to see that the request want to load the `blog` url of the site. It checks out and sees that `blog` is a directory adds a slash and redirects to it. Now because the load balancer sends an `http` r...
265,523
<p>I have a custom post type, <code>card</code>, that I'm exposing through the WP REST API. Is there a way to require authentication, with cookie or Basic Auth header? I see an argument under the POST method block for password, but I'm not sure how to use it.</p> <p><a href="https://i.stack.imgur.com/qTKgd.png" rel="n...
[ { "answer_id": 266466, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 5, "selected": true, "text": "<p>When we register a rest route with <a href=\"https://developer.wordpress.org/reference/functions/register_rest...
2017/05/01
[ "https://wordpress.stackexchange.com/questions/265523", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83970/" ]
I have a custom post type, `card`, that I'm exposing through the WP REST API. Is there a way to require authentication, with cookie or Basic Auth header? I see an argument under the POST method block for password, but I'm not sure how to use it. [![enter image description here](https://i.stack.imgur.com/qTKgd.png)](ht...
When we register a rest route with [`register_rest_route()`](https://developer.wordpress.org/reference/functions/register_rest_route/), then we can use the `permission_callback` parameter with the kind of permission we want. Check for example how `WP_REST_Posts_Controller::register_routes()` and `WP_REST_Users_Control...
265,568
<p>Is there any way through which I can declare the dynamic variable in php. for eg, I am using a for loop and the variable name is $message. and I want to add some dynamic data at the end of the variable name. code is below</p> <pre><code>foreach ($quant as $quantity) { $message.$quantity['type'] = 'List...
[ { "answer_id": 265530, "author": "Scott R. Godin", "author_id": 118816, "author_profile": "https://wordpress.stackexchange.com/users/118816", "pm_score": 2, "selected": false, "text": "<p>One thing you can do to help reduce the amount of bloat is add a plugin that controls the number of ...
2017/05/02
[ "https://wordpress.stackexchange.com/questions/265568", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118777/" ]
Is there any way through which I can declare the dynamic variable in php. for eg, I am using a for loop and the variable name is $message. and I want to add some dynamic data at the end of the variable name. code is below ``` foreach ($quant as $quantity) { $message.$quantity['type'] = 'Listing ID : '.$qu...
One thing you can do to help reduce the amount of bloat is add a plugin that controls the number of previous revisions kept for Pages, Posts, etc (preferably one that allows for separate values for each type, such as last 5 revisions for pages and last 20 revisions for posts, or whatever.) There are numerous plugins t...
265,572
<p>I was trying to remove a div having some ID from the_content WordPress. I am trying to achieve something like this</p> <pre><code>jQuery( "#some_id" ).remove(); </code></pre> <p>but on server side,</p> <p>I don't have a clue how I can do this on server side within the_content filter hook.</p> <pre><code>add_filt...
[ { "answer_id": 265530, "author": "Scott R. Godin", "author_id": 118816, "author_profile": "https://wordpress.stackexchange.com/users/118816", "pm_score": 2, "selected": false, "text": "<p>One thing you can do to help reduce the amount of bloat is add a plugin that controls the number of ...
2017/05/02
[ "https://wordpress.stackexchange.com/questions/265572", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118848/" ]
I was trying to remove a div having some ID from the\_content WordPress. I am trying to achieve something like this ``` jQuery( "#some_id" ).remove(); ``` but on server side, I don't have a clue how I can do this on server side within the\_content filter hook. ``` add_filter( 'the_content', 'my_the_content_filter'...
One thing you can do to help reduce the amount of bloat is add a plugin that controls the number of previous revisions kept for Pages, Posts, etc (preferably one that allows for separate values for each type, such as last 5 revisions for pages and last 20 revisions for posts, or whatever.) There are numerous plugins t...
265,573
<p>I have a function that runs with user input variable (comma separated numeric string) to update the terms (by id) in a custom taxonomy on a custom post type. Even though <a href="https://codex.wordpress.org/Function_Reference/wp_set_post_terms" rel="nofollow noreferrer">the docs say</a> I should use <code>wp_set_obj...
[ { "answer_id": 265577, "author": "Stephen", "author_id": 11023, "author_profile": "https://wordpress.stackexchange.com/users/11023", "pm_score": 3, "selected": true, "text": "<p>After much trial and error, I have found a solution that will allow wp_set_object_terms to be used. Despite al...
2017/05/02
[ "https://wordpress.stackexchange.com/questions/265573", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/11023/" ]
I have a function that runs with user input variable (comma separated numeric string) to update the terms (by id) in a custom taxonomy on a custom post type. Even though [the docs say](https://codex.wordpress.org/Function_Reference/wp_set_post_terms) I should use `wp_set_object_terms`, I can only get my terms to update...
After much trial and error, I have found a solution that will allow wp\_set\_object\_terms to be used. Despite already checking if my strings were integers, apparently I needed to convert the array explicitly as well. So I changed this: `$customtax = $customtaxarray;` to this: `$customtax = array_map('intval',$custo...
265,603
<p><strong>Is there a way to extend the Wordpress Customizer, in order to enable multiple selections?</strong></p> <p>This looks like what I want: <a href="https://github.com/lucatume/multi-image-control" rel="nofollow noreferrer">https://github.com/lucatume/multi-image-control</a>. I don't get it to work. It only sho...
[ { "answer_id": 266407, "author": "Tom Groot", "author_id": 118863, "author_profile": "https://wordpress.stackexchange.com/users/118863", "pm_score": 4, "selected": true, "text": "<p>What I eventually did was <strong>extending the <code>WP_Customize_Control</code></strong> class as follow...
2017/05/02
[ "https://wordpress.stackexchange.com/questions/265603", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118863/" ]
**Is there a way to extend the Wordpress Customizer, in order to enable multiple selections?** This looks like what I want: <https://github.com/lucatume/multi-image-control>. I don't get it to work. It only shows `add` button and `remove` button but they don't do anything. Is there another existing extension script t...
What I eventually did was **extending the `WP_Customize_Control`** class as follows: ``` <?php if (!class_exists('WP_Customize_Image_Control')) { return null; } class Multi_Image_Custom_Control extends WP_Customize_Control { public function enqueue() { wp_enqueue_style('multi-image-style', get_temp...
265,614
<p>I'd like to remove, or at least hide, the Order field from the Page Attributes box. Anyone have a way to go about do this?</p> <p><img src="https://i.stack.imgur.com/ykpQb.png" alt="order"></p>
[ { "answer_id": 265626, "author": "wp.ryan.b", "author_id": 49571, "author_profile": "https://wordpress.stackexchange.com/users/49571", "pm_score": 1, "selected": false, "text": "<p>I went with jQuery to remove the elements.</p>\n\n<pre><code>jQuery(document).ready(function() {\n jQuery(...
2017/05/02
[ "https://wordpress.stackexchange.com/questions/265614", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49571/" ]
I'd like to remove, or at least hide, the Order field from the Page Attributes box. Anyone have a way to go about do this? ![order](https://i.stack.imgur.com/ykpQb.png)
I went with jQuery to remove the elements. ``` jQuery(document).ready(function() { jQuery('#pageparentdiv label[for=menu_order]').parents('p').eq(0).remove(); jQuery('#pageparentdiv input#menu_order').remove(); }); ```
265,656
<p>I think that everything is in the title. I would like to find a way to change the status of a post to "pending" when the post is updated when the user is an "author". I already tried with differents plugin but none of them worked. I'm new to wordpress so i don't really understand how am i suppose to modify the code ...
[ { "answer_id": 265659, "author": "Aishan", "author_id": 89530, "author_profile": "https://wordpress.stackexchange.com/users/89530", "pm_score": 0, "selected": false, "text": "<p>The user with author role is somebody who can publish and manage their own posts. So you can't change \nthe de...
2017/05/03
[ "https://wordpress.stackexchange.com/questions/265656", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118909/" ]
I think that everything is in the title. I would like to find a way to change the status of a post to "pending" when the post is updated when the user is an "author". I already tried with differents plugin but none of them worked. I'm new to wordpress so i don't really understand how am i suppose to modify the code to ...
It is possible to **stop author to publish post**, and force him to **Submit For Preview**. Just add this code to your `functions.php` and you are all done. ``` <?php function take_away_publish_permissions() { $user = get_role('author'); $user->add_cap('publish_posts',false); } add_action('ini...
265,671
<p>I have a question which i can't sort out.</p> <p>I'm having 1 WordPress installation on one main domain. But now I have many more domains refering to the main domain. What I want now is the following:</p> <ul> <li>When people go to the main domain "www.a.com" the logo "a.com" needs to show.</li> <li>When people go...
[ { "answer_id": 265659, "author": "Aishan", "author_id": 89530, "author_profile": "https://wordpress.stackexchange.com/users/89530", "pm_score": 0, "selected": false, "text": "<p>The user with author role is somebody who can publish and manage their own posts. So you can't change \nthe de...
2017/05/03
[ "https://wordpress.stackexchange.com/questions/265671", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118918/" ]
I have a question which i can't sort out. I'm having 1 WordPress installation on one main domain. But now I have many more domains refering to the main domain. What I want now is the following: * When people go to the main domain "www.a.com" the logo "a.com" needs to show. * When people go the another domain for exam...
It is possible to **stop author to publish post**, and force him to **Submit For Preview**. Just add this code to your `functions.php` and you are all done. ``` <?php function take_away_publish_permissions() { $user = get_role('author'); $user->add_cap('publish_posts',false); } add_action('ini...
265,733
<p>I'm wondering when does WordPress initiate its main query which sets the global <code>$wp_query</code> and enable us to use <code>has_posts()</code> and <code>the_post()</code> functions. If I create a page using archive template, how does it know how to set its query?</p> <p>I'm looking at the <em>archive.php</em>...
[ { "answer_id": 265737, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": false, "text": "<p>After plugins and theme functions are loaded, WordPress parses the incoming request into query variables, by going...
2017/05/03
[ "https://wordpress.stackexchange.com/questions/265733", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/117263/" ]
I'm wondering when does WordPress initiate its main query which sets the global `$wp_query` and enable us to use `has_posts()` and `the_post()` functions. If I create a page using archive template, how does it know how to set its query? I'm looking at the *archive.php* in one of the WordPress default themes. They have...
User [Rarst](https://wordpress.stackexchange.com/users/847/rarst) has a [very famous answer](https://wordpress.stackexchange.com/a/26622/7355) where he lays out [the load process](https://i.imgur.com/SqQQE.png). Looking at this graph whenever [`wp-blog-header.php`](https://github.com/WordPress/WordPress/blob/master/wp-...
265,740
<p>I was just wondering if it's possible somehow <em>(via an addon maybe?)</em> to set the initial focus when the WordPress media library pops up to be the search field?</p> <p>I have a lot of posts where I need to select images very fast and need to type in the names of the images to find them and this would be excep...
[ { "answer_id": 265744, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 3, "selected": true, "text": "<p>Here's some code that will set the focus to the search field when clicking on the <kbd>Add Media</kbd> butto...
2017/05/03
[ "https://wordpress.stackexchange.com/questions/265740", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118957/" ]
I was just wondering if it's possible somehow *(via an addon maybe?)* to set the initial focus when the WordPress media library pops up to be the search field? I have a lot of posts where I need to select images very fast and need to type in the names of the images to find them and this would be exceptionally handy ex...
Here's some code that will set the focus to the search field when clicking on the `Add Media` button or when opening the media modal when setting a featured image. Add this code to your theme's `functions.php` or to a plugin to use it. Note: This is an updated version of my original solution. I think this one is a lit...
265,755
<p>I didn't know how exactly I should form my title, so the question may be little different. I am new with WordPress developing and would need some advice. I don't need any code, I just want to hear your advice. </p> <p>I have a page Books, and I'd like to allow admin to add books to that page through the admin dashb...
[ { "answer_id": 265756, "author": "Greg36", "author_id": 64017, "author_profile": "https://wordpress.stackexchange.com/users/64017", "pm_score": 0, "selected": false, "text": "<p>You should use widgets for that only if the books there will be needed temporary when you delete widget its co...
2017/05/03
[ "https://wordpress.stackexchange.com/questions/265755", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118483/" ]
I didn't know how exactly I should form my title, so the question may be little different. I am new with WordPress developing and would need some advice. I don't need any code, I just want to hear your advice. I have a page Books, and I'd like to allow admin to add books to that page through the admin dashboard. Basi...
If you want to do it the "WordPress-way", you would create a custom post-type for books called "book" ( For this take a look at <https://codex.wordpress.org/Function_Reference/register_post_type> ). Then you would create an archive page for that post-type called "archive-book.php". I hope this helps a little bit. If y...
265,783
<p>I am making a pagination for this website by using a custom query and <strong>get_next_posts_link</strong>, <strong>get_previous_posts_link</strong>. The problem is that the link to older entries (<strong>get_next_posts_link</strong>) only works once, meaning that if I click on it the second time, it will always lea...
[ { "answer_id": 265756, "author": "Greg36", "author_id": 64017, "author_profile": "https://wordpress.stackexchange.com/users/64017", "pm_score": 0, "selected": false, "text": "<p>You should use widgets for that only if the books there will be needed temporary when you delete widget its co...
2017/05/04
[ "https://wordpress.stackexchange.com/questions/265783", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/109276/" ]
I am making a pagination for this website by using a custom query and **get\_next\_posts\_link**, **get\_previous\_posts\_link**. The problem is that the link to older entries (**get\_next\_posts\_link**) only works once, meaning that if I click on it the second time, it will always lead to the home page, this is weird...
If you want to do it the "WordPress-way", you would create a custom post-type for books called "book" ( For this take a look at <https://codex.wordpress.org/Function_Reference/register_post_type> ). Then you would create an archive page for that post-type called "archive-book.php". I hope this helps a little bit. If y...
265,806
<p>I have the following WP_Query:</p> <pre><code>$custom_query_args = array( 'post_type' =&gt; 'mcg_event', 'posts_per_page' =&gt; -1, 'meta_query' =&gt; array( 'relation' =&gt; 'AND', array( 'key' =&gt; 'event_status', 'value' =&gt; 'archived', ...
[ { "answer_id": 265756, "author": "Greg36", "author_id": 64017, "author_profile": "https://wordpress.stackexchange.com/users/64017", "pm_score": 0, "selected": false, "text": "<p>You should use widgets for that only if the books there will be needed temporary when you delete widget its co...
2017/05/04
[ "https://wordpress.stackexchange.com/questions/265806", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119008/" ]
I have the following WP\_Query: ``` $custom_query_args = array( 'post_type' => 'mcg_event', 'posts_per_page' => -1, 'meta_query' => array( 'relation' => 'AND', array( 'key' => 'event_status', 'value' => 'archived', ), array( ...
If you want to do it the "WordPress-way", you would create a custom post-type for books called "book" ( For this take a look at <https://codex.wordpress.org/Function_Reference/register_post_type> ). Then you would create an archive page for that post-type called "archive-book.php". I hope this helps a little bit. If y...
265,818
<p><a href="https://i.stack.imgur.com/cwSWN.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cwSWN.jpg" alt="enter image description here"></a></p> <p>As you can see the phrase is <strong><em>Want create site? Free wordpress themes..</em></strong></p> <p>I tried editing in Yoast Facebook option stil...
[ { "answer_id": 265820, "author": "Alex MacArthur", "author_id": 89080, "author_profile": "https://wordpress.stackexchange.com/users/89080", "pm_score": 0, "selected": false, "text": "<p>The plugin is pulling that content from somewhere on your page and placing it in Open Graph meta tags....
2017/05/04
[ "https://wordpress.stackexchange.com/questions/265818", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119011/" ]
[![enter image description here](https://i.stack.imgur.com/cwSWN.jpg)](https://i.stack.imgur.com/cwSWN.jpg) As you can see the phrase is ***Want create site? Free wordpress themes..*** I tried editing in Yoast Facebook option still the phrase shows up, any solution?
There's a reason people say that you shouldn't download free themes from outside of wordpress.org, they might contain hidden surprises In your case, the theme inserts an advertisement at the beginning of the post content div: ``` <div style="position:absolute;top:0;left:-9999px;">Want create site? Find <a href="http:...
265,826
<p>I have a PHP(Laravel) application that pushes data to WooCommerce through the WooCommerce REST API, everything works except for images. I was able to pin this down to <code>wp_safe_remote_get()</code> and <code>$args['reject_unsafe_urls']</code>.</p> <p>I had found a way around this, but I cannot recall where I fou...
[ { "answer_id": 265820, "author": "Alex MacArthur", "author_id": 89080, "author_profile": "https://wordpress.stackexchange.com/users/89080", "pm_score": 0, "selected": false, "text": "<p>The plugin is pulling that content from somewhere on your page and placing it in Open Graph meta tags....
2017/05/04
[ "https://wordpress.stackexchange.com/questions/265826", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/42713/" ]
I have a PHP(Laravel) application that pushes data to WooCommerce through the WooCommerce REST API, everything works except for images. I was able to pin this down to `wp_safe_remote_get()` and `$args['reject_unsafe_urls']`. I had found a way around this, but I cannot recall where I found it. I seem to remember a hook...
There's a reason people say that you shouldn't download free themes from outside of wordpress.org, they might contain hidden surprises In your case, the theme inserts an advertisement at the beginning of the post content div: ``` <div style="position:absolute;top:0;left:-9999px;">Want create site? Find <a href="http:...
265,868
<p>I have the following query:</p> <pre><code>&lt;?php $args = array( 'hide_empty' =&gt; false, 'orderby' =&gt; 'title', 'order' =&gt; 'DESC' ); $terms = get_terms( 'projets-location', $args ); if ( !empty( $terms ) &amp;&amp; !is_wp_error( $terms ) ){ foreach ( $terms as $term ) { ?&gt; ...
[ { "answer_id": 265873, "author": "Mervan Agency", "author_id": 118206, "author_profile": "https://wordpress.stackexchange.com/users/118206", "pm_score": 0, "selected": false, "text": "<p>As per the WordPress Codex for <code>get_terms</code> on this link \n <a href=\"https://developer.wor...
2017/05/04
[ "https://wordpress.stackexchange.com/questions/265868", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28065/" ]
I have the following query: ``` <?php $args = array( 'hide_empty' => false, 'orderby' => 'title', 'order' => 'DESC' ); $terms = get_terms( 'projets-location', $args ); if ( !empty( $terms ) && !is_wp_error( $terms ) ){ foreach ( $terms as $term ) { ?> <h5 id="<?php echo $term->slug; ?>...
> > Since 4.5.0, taxonomies should be passed via the ‘taxonomy’ argument > in the $args array: > > > ``` $terms = get_terms( array( 'taxonomy' => 'projets-location', 'orderby' => 'name', 'order' => 'DESC' ) ); ```
265,903
<p>Hello in the <code>init</code> action, I would like to add a filter to a fairly large function to modify variables in the <code>$vars</code> array, for example the Wordpress post ID.</p> <p>That is to say:</p> <pre class="lang-php prettyprint-override"><code> add_action( 'init',function(){ //code ...
[ { "answer_id": 266152, "author": "Nathan Johnson", "author_id": 106269, "author_profile": "https://wordpress.stackexchange.com/users/106269", "pm_score": 1, "selected": false, "text": "<p>Yes, it's possible to do something like that. And in fact, if you want to remove actions/filters, th...
2017/05/04
[ "https://wordpress.stackexchange.com/questions/265903", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/78261/" ]
Hello in the `init` action, I would like to add a filter to a fairly large function to modify variables in the `$vars` array, for example the Wordpress post ID. That is to say: ```php add_action( 'init',function(){ //code add_filter( 'query_vars',function($vars){ $vars[] = array('ID' ...
To alter the page ID before the query is run, hook the [`request`](https://codex.wordpress.org/Plugin_API/Filter_Reference/request) filter. If you're using pretty permalinks, `pagename` will be set, you can overwrite `pagename` with another page slug: ``` function wpd_265903_request( $request ) { if( isset( $requ...
265,906
<p>I am trying to use wp_add_inline_style in plugin. I want to add some style when shortcode runs.</p> <pre><code>add_action('wp_enqueue_scripts', 'cod_enqueue_scripts'); add_shortcode('cod', 'cod_process_shortcode'); function cod_enqueue_scripts() { wp_enqueue_style('cod-style', plugins_url('css/style.css', __FI...
[ { "answer_id": 265908, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 4, "selected": true, "text": "<p>Here's a solution based on <a href=\"https://www.cssigniter.com/ignite/late-enqueue-inline-css-wordpress/\" ...
2017/05/04
[ "https://wordpress.stackexchange.com/questions/265906", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45321/" ]
I am trying to use wp\_add\_inline\_style in plugin. I want to add some style when shortcode runs. ``` add_action('wp_enqueue_scripts', 'cod_enqueue_scripts'); add_shortcode('cod', 'cod_process_shortcode'); function cod_enqueue_scripts() { wp_enqueue_style('cod-style', plugins_url('css/style.css', __FILE__)); } ...
Here's a solution based on [this post](https://www.cssigniter.com/ignite/late-enqueue-inline-css-wordpress/), which allows the inline CSS to be rendered by a shortcode using a dependency without a path (basically a null file). ``` // Optional base styles add_action( 'wp_enqueue_scripts', 'cod_enqueue_scripts' ); funct...
265,907
<p>So I'm building my first custom WooCommerce store and I'm finding that my styles class names are becoming a over the top and lengthy, or is this how it is. I use the inspector tool in Chrome to get the class names.</p> <p>Here is an example of what I'm working with at the moment:</p> <pre><code>.woocommerce ul.pr...
[ { "answer_id": 267324, "author": "Aniruddha Gawade", "author_id": 101818, "author_profile": "https://wordpress.stackexchange.com/users/101818", "pm_score": 1, "selected": false, "text": "<p>It is always a good practice to use maximum number of classes, because using more classes gives mo...
2017/05/04
[ "https://wordpress.stackexchange.com/questions/265907", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93077/" ]
So I'm building my first custom WooCommerce store and I'm finding that my styles class names are becoming a over the top and lengthy, or is this how it is. I use the inspector tool in Chrome to get the class names. Here is an example of what I'm working with at the moment: ``` .woocommerce ul.products li.product a ...
What i do is, disable Woocommerce default styles depending on what i want to customize, instead of overwriting the css. Woocommerce loads 3 styles by default: woocommerce-general.css woocommerce-layout.css woocommerce-smallscreen.css If you want to fully customize you can disable all styles or, just the ones that you...
265,929
<p>i want to get the latest date of post in the homepage of my site. in this code :</p> <pre><code>the_modified_date('d F Y'); </code></pre> <p>date is different in different pages (For example page 1,2,...). i want to show <strong>just</strong> the date of <strong>latest post</strong> that published. thanks.</p>
[ { "answer_id": 265932, "author": "Sapere Aude", "author_id": 119069, "author_profile": "https://wordpress.stackexchange.com/users/119069", "pm_score": 1, "selected": false, "text": "<p>you can use <code>get_the_date('d F Y');</code></p>\n" }, { "answer_id": 265933, "author": ...
2017/05/05
[ "https://wordpress.stackexchange.com/questions/265929", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118232/" ]
i want to get the latest date of post in the homepage of my site. in this code : ``` the_modified_date('d F Y'); ``` date is different in different pages (For example page 1,2,...). i want to show **just** the date of **latest post** that published. thanks.
you can use `get_the_date('d F Y');`
265,997
<p>My code is like following:</p> <pre><code>&lt;?php function shortcode_callback() { ob_start(); //my code here ob_get_clean(); } add_shortcode('shortcode', 'shortcode_callback'); ?&gt; </code></pre> <p>The above shortcode add to the page but the tile is showing at the ...
[ { "answer_id": 266002, "author": "Faysal Mahamud", "author_id": 83752, "author_profile": "https://wordpress.stackexchange.com/users/83752", "pm_score": 1, "selected": false, "text": "<p>You Must return output, Follow the following code.</p>\n\n<pre><code>function shortcode_callback() {\n...
2017/05/05
[ "https://wordpress.stackexchange.com/questions/265997", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/115973/" ]
My code is like following: ``` <?php function shortcode_callback() { ob_start(); //my code here ob_get_clean(); } add_shortcode('shortcode', 'shortcode_callback'); ?> ``` The above shortcode add to the page but the tile is showing at the bottom of the shortcode: My Tit...
You needs to change buffer like this: ``` <?php function shortcode_callback() { ob_start(); //my code here return ob_get_clean(); } add_shortcode('shortcode', 'shortcode_callback'); ?> ``` Please check after replace ob\_get\_clean(); in your code with return ob\_get\_cl...
266,005
<p>I wasn't sure how to ask this. In WP, when the program runs, is it all "sequential"? By this I mean does WP hit the hook you registered and call it, wait, then proceed, synchronous? There's no Dependency Injection of IoC that I could find and no async.</p> <p>I looked a the core, and I couldn't tell. I saw refe...
[ { "answer_id": 266008, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 2, "selected": false, "text": "<p><strong>Yes it's all linear/sequential</strong>. There is no multi-threading or parallel execution in a PHP ...
2017/05/05
[ "https://wordpress.stackexchange.com/questions/266005", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/49089/" ]
I wasn't sure how to ask this. In WP, when the program runs, is it all "sequential"? By this I mean does WP hit the hook you registered and call it, wait, then proceed, synchronous? There's no Dependency Injection of IoC that I could find and no async. I looked a the core, and I couldn't tell. I saw references to a fe...
The `do_action()` and `apply_filters()` are both wrappers of the ``` WP_Hook::apply_filters() ``` method, that invokes the registered callbacks in **sequential** order ([src](https://core.trac.wordpress.org/browser/tags/4.7/src/wp-includes/class-wp-hook.php#L276)). **Here's a simple test:** Let's define a callback...
266,026
<p>I'm on WordPress 4.7.4 and on my custom post types, I cannot assign tags as a regular user. </p> <p>I have used CPTUI for creating everything, have mapped and created custom capabilities, have assigned roles to the custom caps, and have verified the user's roles are correct using <code>get_userdata()</code>, but I ...
[ { "answer_id": 276245, "author": "Nathan", "author_id": 119119, "author_profile": "https://wordpress.stackexchange.com/users/119119", "pm_score": 0, "selected": false, "text": "<p>No matter what I tried, I couldn't get this working. I don't believe manually changing the terms are support...
2017/05/05
[ "https://wordpress.stackexchange.com/questions/266026", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119119/" ]
I'm on WordPress 4.7.4 and on my custom post types, I cannot assign tags as a regular user. I have used CPTUI for creating everything, have mapped and created custom capabilities, have assigned roles to the custom caps, and have verified the user's roles are correct using `get_userdata()`, but I can't seem to get thi...
It seems that although WP core creates four capability mappings for the built-in post\_tag taxonomy (`manage_terms => manage_post_tags, edit_terms => edit_post_tags, delete_terms => delete_post_tags, assign_terms => assign_post_tags`) when it is registered, it uses different values when checking if the user has one of ...
266,046
<p>I want to add "Recent Posts" widget in a sidebar without a title but every time I add it, it shows "Recent Posts" text as title. How do I have it without title? I don't want to use any plugin for this.</p> <p>Thank You.</p>
[ { "answer_id": 276245, "author": "Nathan", "author_id": 119119, "author_profile": "https://wordpress.stackexchange.com/users/119119", "pm_score": 0, "selected": false, "text": "<p>No matter what I tried, I couldn't get this working. I don't believe manually changing the terms are support...
2017/05/06
[ "https://wordpress.stackexchange.com/questions/266046", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51790/" ]
I want to add "Recent Posts" widget in a sidebar without a title but every time I add it, it shows "Recent Posts" text as title. How do I have it without title? I don't want to use any plugin for this. Thank You.
It seems that although WP core creates four capability mappings for the built-in post\_tag taxonomy (`manage_terms => manage_post_tags, edit_terms => edit_post_tags, delete_terms => delete_post_tags, assign_terms => assign_post_tags`) when it is registered, it uses different values when checking if the user has one of ...
266,055
<p>I'm loading custom css stylesheet in my child theme 'functions.php' using this code</p> <pre><code>if (ICL_LANGUAGE_CODE == 'ar') { ?&gt; &lt;link rel="stylesheet" href="&lt;?php echo get_stylesheet_directory_uri() . '/css/rtl.css' ?&gt;" type="text/css"&gt; </code></pre> <p>When doing so, the media library can'...
[ { "answer_id": 266064, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": true, "text": "<p>If you are echoing this code straight from <code>functions.php</code> it would output way before anything else. It i...
2017/05/06
[ "https://wordpress.stackexchange.com/questions/266055", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102827/" ]
I'm loading custom css stylesheet in my child theme 'functions.php' using this code ``` if (ICL_LANGUAGE_CODE == 'ar') { ?> <link rel="stylesheet" href="<?php echo get_stylesheet_directory_uri() . '/css/rtl.css' ?>" type="text/css"> ``` When doing so, the media library can't be loaded, it just stick like this image:...
If you are echoing this code straight from `functions.php` it would output way before anything else. It is too early in the load process. In most cases [enqueue](https://developer.wordpress.org/reference/functions/wp_enqueue_style/) API functions should be used to output assets. Outside of that it is impossible to gu...
266,094
<p>First, thank you for your help. </p> <p>I have created a custom template, added two metaboxes in Pages using a 'Page_Fiche_Metier.php' template. One meta box is to upload an image. But the Upload Button is not opening the media library, although I have added the jQuery script. </p> <pre><code>Here is the code for...
[ { "answer_id": 266064, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": true, "text": "<p>If you are echoing this code straight from <code>functions.php</code> it would output way before anything else. It i...
2017/05/06
[ "https://wordpress.stackexchange.com/questions/266094", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119161/" ]
First, thank you for your help. I have created a custom template, added two metaboxes in Pages using a 'Page\_Fiche\_Metier.php' template. One meta box is to upload an image. But the Upload Button is not opening the media library, although I have added the jQuery script. ``` Here is the code for the meta-boxes.php...
If you are echoing this code straight from `functions.php` it would output way before anything else. It is too early in the load process. In most cases [enqueue](https://developer.wordpress.org/reference/functions/wp_enqueue_style/) API functions should be used to output assets. Outside of that it is impossible to gu...
266,104
<p>I want to display every 3 products in a <code>&lt;ul&gt;</code></p> <p>Example of how HTML should look:</p> <pre><code>&lt;ul&gt; &lt;li&gt;product looping 1&lt;/li&gt; &lt;li&gt;product looping 2&lt;/li&gt; &lt;li&gt;product looping 3&lt;/li&gt; &lt;/ul&gt; &lt;ul&gt; &lt;li&gt;product looping 4&l...
[ { "answer_id": 266064, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 3, "selected": true, "text": "<p>If you are echoing this code straight from <code>functions.php</code> it would output way before anything else. It i...
2017/05/07
[ "https://wordpress.stackexchange.com/questions/266104", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119173/" ]
I want to display every 3 products in a `<ul>` Example of how HTML should look: ``` <ul> <li>product looping 1</li> <li>product looping 2</li> <li>product looping 3</li> </ul> <ul> <li>product looping 4</li> <li>product looping 5</li> <li>product looping 6</li> </ul> ``` WP\_Query Code: ```...
If you are echoing this code straight from `functions.php` it would output way before anything else. It is too early in the load process. In most cases [enqueue](https://developer.wordpress.org/reference/functions/wp_enqueue_style/) API functions should be used to output assets. Outside of that it is impossible to gu...
266,141
<p>Is it possible to loop through all the pages in a website? If so, how?</p> <p>I'm building a one-pager resume website, and I want to display all of the website's pages as parts of my main page.</p>
[ { "answer_id": 266145, "author": "Picard", "author_id": 118566, "author_profile": "https://wordpress.stackexchange.com/users/118566", "pm_score": 1, "selected": false, "text": "<p>Are you talking about something like this:</p>\n\n<pre><code> $pages = get_pages(); \n foreach ($pages a...
2017/05/07
[ "https://wordpress.stackexchange.com/questions/266141", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/116705/" ]
Is it possible to loop through all the pages in a website? If so, how? I'm building a one-pager resume website, and I want to display all of the website's pages as parts of my main page.
I was able to learn how to do it. Here's a solution: ``` $pages = get_pages(); foreach($pages as $page) { echo($page->post_content); } ```
266,146
<p>As I'm new to Linux and WPCLI, I moved a site from one VPS to another but URL stayed the same and PHPmyadmin doesn't work so as of the moment I can't change the site URL from PHPmyadmin.</p> <p>When I try to navigate to the site from the browser (after setting up a database, changing wp-config.php accordingly, uplo...
[ { "answer_id": 266145, "author": "Picard", "author_id": 118566, "author_profile": "https://wordpress.stackexchange.com/users/118566", "pm_score": 1, "selected": false, "text": "<p>Are you talking about something like this:</p>\n\n<pre><code> $pages = get_pages(); \n foreach ($pages a...
2017/05/07
[ "https://wordpress.stackexchange.com/questions/266146", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
As I'm new to Linux and WPCLI, I moved a site from one VPS to another but URL stayed the same and PHPmyadmin doesn't work so as of the moment I can't change the site URL from PHPmyadmin. When I try to navigate to the site from the browser (after setting up a database, changing wp-config.php accordingly, uploading site...
I was able to learn how to do it. Here's a solution: ``` $pages = get_pages(); foreach($pages as $page) { echo($page->post_content); } ```
266,151
<blockquote> <p>Can we please stick ourselves to the genuine solution, not a slipshod remedy. The objective of this question is to completely get rid of the class "widget-item". please do not post compromised solutions like manipulating CSS etc else the objective of posting the question will be defied.</p> </...
[ { "answer_id": 266157, "author": "Picard", "author_id": 118566, "author_profile": "https://wordpress.stackexchange.com/users/118566", "pm_score": 2, "selected": false, "text": "<p>The most straightforward way would be to overwrite this in your CSS file, for instance like this:</p>\n\n<pr...
2017/05/07
[ "https://wordpress.stackexchange.com/questions/266151", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105791/" ]
> > Can we please stick ourselves to the genuine solution, not a slipshod > remedy. The objective of this question is to completely get rid of the > class "widget-item". please do not post compromised solutions like > manipulating CSS etc else the objective of posting the question will > be defied. > > > I wan...
The most straightforward way would be to overwrite this in your CSS file, for instance like this: ``` .widgettitle { padding: 0; margin: 0; } ``` Alternatively you can change the name of the class when registering your widget (possibly in your functions.php file) - look for the `'before_title'` parameter. He...
266,243
<p>I'm trying to count results for a given query, but I don't actually need the posts so I'm trying to figure out if there's a way to count posts without querying them. Something similar to <a href="https://codex.wordpress.org/Function_Reference/wp_count_posts" rel="nofollow noreferrer">https://codex.wordpress.org/Func...
[ { "answer_id": 266248, "author": "Emin Rahmanov", "author_id": 119256, "author_profile": "https://wordpress.stackexchange.com/users/119256", "pm_score": -1, "selected": false, "text": "<p>You set posts_per_page 0 value. posts_per_page for all posts set -1 or another positive number</p>...
2017/05/08
[ "https://wordpress.stackexchange.com/questions/266243", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23829/" ]
I'm trying to count results for a given query, but I don't actually need the posts so I'm trying to figure out if there's a way to count posts without querying them. Something similar to <https://codex.wordpress.org/Function_Reference/wp_count_posts> I'm counting posts by meta key/value so `wp_count_posts()` won't wor...
The non perfect solution is to just minimize the amount of information carried by the query, and the side effects. This can be done by requesting only the post IDs and not populating any caches. Your query should be something like ``` $query = new WP_Query(array( ... 'fields' => 'ids', 'cache_results' => false...
266,255
<p>I'm using twenty seventeen theme on wordpress (writing a child theme) When the home page first loads the nav bar is at the bottom of the screen, but the sub menu opens downwards and is therefore hidden. I'd like it to fly upwards until the page has scrolled down. First, is there a simple way to change this that I'm ...
[ { "answer_id": 266248, "author": "Emin Rahmanov", "author_id": 119256, "author_profile": "https://wordpress.stackexchange.com/users/119256", "pm_score": -1, "selected": false, "text": "<p>You set posts_per_page 0 value. posts_per_page for all posts set -1 or another positive number</p>...
2017/05/08
[ "https://wordpress.stackexchange.com/questions/266255", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/71273/" ]
I'm using twenty seventeen theme on wordpress (writing a child theme) When the home page first loads the nav bar is at the bottom of the screen, but the sub menu opens downwards and is therefore hidden. I'd like it to fly upwards until the page has scrolled down. First, is there a simple way to change this that I'm per...
The non perfect solution is to just minimize the amount of information carried by the query, and the side effects. This can be done by requesting only the post IDs and not populating any caches. Your query should be something like ``` $query = new WP_Query(array( ... 'fields' => 'ids', 'cache_results' => false...
266,270
<p>I am trying to retrieve posts from a category. I have 2 level and 3 level category hierarchy. I am using tax query in pre get posts filter to alter the query. </p> <p>The query works fine for the first level and third level category but shows no result for second level category. The query when examined has 0 = 1 ad...
[ { "answer_id": 266248, "author": "Emin Rahmanov", "author_id": 119256, "author_profile": "https://wordpress.stackexchange.com/users/119256", "pm_score": -1, "selected": false, "text": "<p>You set posts_per_page 0 value. posts_per_page for all posts set -1 or another positive number</p>...
2017/05/08
[ "https://wordpress.stackexchange.com/questions/266270", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21005/" ]
I am trying to retrieve posts from a category. I have 2 level and 3 level category hierarchy. I am using tax query in pre get posts filter to alter the query. The query works fine for the first level and third level category but shows no result for second level category. The query when examined has 0 = 1 added in the...
The non perfect solution is to just minimize the amount of information carried by the query, and the side effects. This can be done by requesting only the post IDs and not populating any caches. Your query should be something like ``` $query = new WP_Query(array( ... 'fields' => 'ids', 'cache_results' => false...
266,272
<p>I've written a shortcode for fetching the most viewed posts in the past week. I use a filter as the following in my shortcode's function:</p> <pre><code>function weeks_popular(){ //Filter the date function filter_where($where = '') { $where .= " AND post_date &gt; '" . date('Y-m-d', strtotime('-7 da...
[ { "answer_id": 266293, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": true, "text": "<p>Note that you're returning from the shortcode's callback with:</p>\n\n<pre><code>return $pops_content;\n</code...
2017/05/08
[ "https://wordpress.stackexchange.com/questions/266272", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/94498/" ]
I've written a shortcode for fetching the most viewed posts in the past week. I use a filter as the following in my shortcode's function: ``` function weeks_popular(){ //Filter the date function filter_where($where = '') { $where .= " AND post_date > '" . date('Y-m-d', strtotime('-7 days')) . "'"; ...
Note that you're returning from the shortcode's callback with: ``` return $pops_content; ``` before removing the filter's callback with: ``` remove_filter('posts_where', 'filter_where'); ``` So it's never called. That means you're affecting all the later `WP_Query` instances with your filter. Note that you can...
266,384
<p>I have created a landing page that is only available to a certain audience. When users visit this page I would like to create a cookie that can be passed on upon completing a booking form on another page. I am using Wordpress and can't figure out how to set a page specific cookie. I am able to set a global cookie th...
[ { "answer_id": 266386, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": true, "text": "<p>WordPress doesn't know if it's a page yet, <code>init</code> fires before the query is run. You need to hook a late...
2017/05/09
[ "https://wordpress.stackexchange.com/questions/266384", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/115021/" ]
I have created a landing page that is only available to a certain audience. When users visit this page I would like to create a cookie that can be passed on upon completing a booking form on another page. I am using Wordpress and can't figure out how to set a page specific cookie. I am able to set a global cookie throu...
WordPress doesn't know if it's a page yet, `init` fires before the query is run. You need to hook a later action, like `wp`. Have a look at [Action Reference](https://codex.wordpress.org/Plugin_API/Action_Reference#Actions_Run_During_a_Typical_Request) to see the order of actions during a request.
266,401
<p>Coders. I'm really new in WP Coding, I have zero knowledge, here we are. I created a plugin (actually found it, but I did some modifications) which update all my wp posts.</p> <p>Let's show you the code,</p> <pre><code>if ( ! class_exists( 'MyPlugin_BulkUpdatePosts' ) ) : class MyPlugin_BulkUpdatePosts { publ...
[ { "answer_id": 266403, "author": "Picard", "author_id": 118566, "author_profile": "https://wordpress.stackexchange.com/users/118566", "pm_score": 0, "selected": false, "text": "<p>10k+ updates must take time. Depending what you need you could operate on the Wordpress tables like <code>wp...
2017/05/09
[ "https://wordpress.stackexchange.com/questions/266401", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/116204/" ]
Coders. I'm really new in WP Coding, I have zero knowledge, here we are. I created a plugin (actually found it, but I did some modifications) which update all my wp posts. Let's show you the code, ``` if ( ! class_exists( 'MyPlugin_BulkUpdatePosts' ) ) : class MyPlugin_BulkUpdatePosts { public function __constru...
One implementation detail of how WP works with database is that it always drags *all* query results into PHP values and memory space. In other words it is highly unlikely to throw any heavy query at WP and not have it collapse. Notably any plugins that deal with large queries (such as database backup ones) often write ...
266,423
<p>When I go through the database of a fresh Wordpress 4 install I find, for example:</p> <pre><code>wp_posts wp_terms wp_users </code></pre> <p>Yet I didn't find `wp_pages'. Where is it?</p>
[ { "answer_id": 266424, "author": "Community", "author_id": -1, "author_profile": "https://wordpress.stackexchange.com/users/-1", "pm_score": 0, "selected": false, "text": "<p>I entered to wp_posts and it seems all pages are inside there.</p>\n" }, { "answer_id": 266426, "auth...
2017/05/09
[ "https://wordpress.stackexchange.com/questions/266423", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
When I go through the database of a fresh Wordpress 4 install I find, for example: ``` wp_posts wp_terms wp_users ``` Yet I didn't find `wp\_pages'. Where is it?
the wp\_posts include all post types (post, page, custom post..), and to differentiate between them there is a field called post\_type used to specify the name of the current entry whether it's a page, post or a custom post. Query below will get list of pages ``` SELECT * FROM wp_posts where post_type = 'page'; ```
266,429
<p>The author section of my first <strong>WordPress theme</strong> is currently <strong>hard coded in HTML</strong>. </p> <p>See the live website <a href="http://codepen.trafficopedia.com/site01/8/" rel="nofollow noreferrer">here</a>. </p> <p><a href="https://www.screencast.com/t/j7ZZxDUFsac" rel="nofollow noreferrer...
[ { "answer_id": 266436, "author": "Aniruddha Gawade", "author_id": 101818, "author_profile": "https://wordpress.stackexchange.com/users/101818", "pm_score": 1, "selected": false, "text": "<p>Yes, those fields will be user meta. And for storing social links of a user you'll have to add cus...
2017/05/10
[ "https://wordpress.stackexchange.com/questions/266429", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105791/" ]
The author section of my first **WordPress theme** is currently **hard coded in HTML**. See the live website [here](http://codepen.trafficopedia.com/site01/8/). [This One.](https://www.screencast.com/t/j7ZZxDUFsac) These **social media Icons** and the link associated with them are not provided in the backend autho...
Add user contact methods using the `user_contactmethods` filter in your theme's `functions.php` or via a plugin: User contact method entries are stored in the `wp_usermeta` table. The URL field is special; it's stored in the `user_url` field in the `wp_users` table. ``` // Add user contact methods add_filter( 'user_c...
266,432
<p>I have added a message button on my site (I'm using a plugin which enables private messaging) by adding the plugin's shortcode to my footer.php:</p> <pre><code>&lt;div class="msgshort"&gt;&lt;?php echo do_shortcode('[ultimatemember_message_button user_id=1]'); ?&gt;&lt;/div&gt; </code></pre> <p>Here is a screensho...
[ { "answer_id": 266435, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 2, "selected": true, "text": "<p>WordPress provides the <a href=\"https://developer.wordpress.org/reference/functions/_x/\" rel=\"nofollow no...
2017/05/10
[ "https://wordpress.stackexchange.com/questions/266432", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104629/" ]
I have added a message button on my site (I'm using a plugin which enables private messaging) by adding the plugin's shortcode to my footer.php: ``` <div class="msgshort"><?php echo do_shortcode('[ultimatemember_message_button user_id=1]'); ?></div> ``` Here is a screenshot of how it looks on my site: <https://ibb.c...
WordPress provides the [`_x()`](https://developer.wordpress.org/reference/functions/_x/) function which is just like [`__()`](https://developer.wordpress.org/reference/functions/__/), but it adds the `$context` parameter which is used to differentiate between identical strings. In the example below, some output is gen...
266,461
<p>For miskate i change the url of my wordpress on settings -> general. In order to revert this i changed the wp-config.php file and add this too config.php </p> <pre><code>define('WP_HOME','localhost/wordpress'); define('WP_SITEURL','localhost/wordpress'); </code></pre> <p>Then i restarted the apache and i hope i co...
[ { "answer_id": 266464, "author": "bynicolas", "author_id": 99217, "author_profile": "https://wordpress.stackexchange.com/users/99217", "pm_score": 2, "selected": false, "text": "<p>Don't edit your <code>wp-config.php</code> file directly.</p>\n\n<p>Instead, with PHPMyAdmin, access your d...
2017/05/10
[ "https://wordpress.stackexchange.com/questions/266461", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119378/" ]
For miskate i change the url of my wordpress on settings -> general. In order to revert this i changed the wp-config.php file and add this too config.php ``` define('WP_HOME','localhost/wordpress'); define('WP_SITEURL','localhost/wordpress'); ``` Then i restarted the apache and i hope i could enter again on my admi...
Don't edit your `wp-config.php` file directly. Instead, with PHPMyAdmin, access your database and check for the table `_options`. You should see entries there for `site_url` and `home_url` change those values back to what you need
266,476
<p>I have installed a wordpress server locally in mi pc, recentlly I have some issues uploading files using <code>wordpress media</code>. </p> <p>I got some errors like</p> <pre><code>Wordpress cannot create directory `wp-content/uploads/2017/05`. Check permissions in the above directory. </code></pre> <p>I checked...
[ { "answer_id": 266477, "author": "JItendra Rana", "author_id": 87433, "author_profile": "https://wordpress.stackexchange.com/users/87433", "pm_score": 0, "selected": false, "text": "<p>I have had similar problem in past. Try adding following to your wp-config.php </p>\n\n<pre><code>defin...
2017/05/10
[ "https://wordpress.stackexchange.com/questions/266476", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102360/" ]
I have installed a wordpress server locally in mi pc, recentlly I have some issues uploading files using `wordpress media`. I got some errors like ``` Wordpress cannot create directory `wp-content/uploads/2017/05`. Check permissions in the above directory. ``` I checked directory permissions, and I set up to 777 ...
add this below line to your ***wp-config.php*** (if you did not add it yet) ``` define('FS_METHOD', 'direct'); ``` Check which user run your servers too (not only php7-fpm). > > ps aux|grep nginx > > > ps aux|grep apache > > > if your server works on www-data then, ``` cd ../your_wordpress_dir/ sudo find . ...