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
299,582
<p>I am trying to add a new menu item to an already existing nav menu in my theme, I am using some part of this answer <a href="https://wordpress.stackexchange.com/questions/15455/how-to-hard-code-custom-menu-items">How to Hard Code Custom menu items</a></p> <p>I am directly using this code in my plugin</p> <pre><co...
[ { "answer_id": 299572, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 0, "selected": false, "text": "<p>Never manipulate the DB directly, instead write some small wordpress plugin to do it. The amount of gotch...
2018/04/02
[ "https://wordpress.stackexchange.com/questions/299582", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114573/" ]
I am trying to add a new menu item to an already existing nav menu in my theme, I am using some part of this answer [How to Hard Code Custom menu items](https://wordpress.stackexchange.com/questions/15455/how-to-hard-code-custom-menu-items) I am directly using this code in my plugin ``` wp_update_nav_menu_item(2, 0, ...
I misplaced a single quote. This query worked for me and solved my problem. update `wp_postmeta` set `meta_value`= concat( 'a:1:{s:3:"url";s:28:"', `meta_value`, '";}' ) where `meta_key` = '\_woofv\_video\_embed'
299,591
<p>I am developing a plugin. Among other things its backend settings will allow admins to update a site data file from a 3rd party data provider, or to switch on/off a wp-cron job to do this automatically.</p> <p>In this (simplified) code <strong>I <em>assume</em> my wp-cron job will only be run if someone logs in to ...
[ { "answer_id": 299600, "author": "Clinton", "author_id": 122375, "author_profile": "https://wordpress.stackexchange.com/users/122375", "pm_score": 2, "selected": true, "text": "<p>I had to read this a few times to understand it and I am not sure if my interpretation is correct. Anyhow he...
2018/04/02
[ "https://wordpress.stackexchange.com/questions/299591", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/128374/" ]
I am developing a plugin. Among other things its backend settings will allow admins to update a site data file from a 3rd party data provider, or to switch on/off a wp-cron job to do this automatically. In this (simplified) code **I *assume* my wp-cron job will only be run if someone logs in to the WP Dashboard?** (no...
I had to read this a few times to understand it and I am not sure if my interpretation is correct. Anyhow here is my interpretation (apologies if I have gotten this wrong)... You have a CRON job that is intended to update files of some sort. This CRON job will run when someone visits the site whether admin or not at y...
299,617
<p>I have created a custom button for TinyMCE and I would like it to use the Twitter icon from dashicons. I am hoping to be able to do this just through the Javascript with no additional CSS. Is this possible? </p> <p>Here is my current(non-working) attempt:</p> <pre><code>(function () { tinymce.PluginManager.add...
[ { "answer_id": 299635, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": false, "text": "<blockquote>\n <p>I am hoping to be able to do this just through the Javascript with no\n additional CSS. Is t...
2018/04/02
[ "https://wordpress.stackexchange.com/questions/299617", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13286/" ]
I have created a custom button for TinyMCE and I would like it to use the Twitter icon from dashicons. I am hoping to be able to do this just through the Javascript with no additional CSS. Is this possible? Here is my current(non-working) attempt: ``` (function () { tinymce.PluginManager.add('twitter_button_plug...
Here's your easy solution (hopefully this will help other people too): 1) add a custom class for icon, in this example "myicons" ``` (function () { tinymce.PluginManager.add('twitter_button_plugin', function (editor, url) { editor.addButton('mce_tweet_button', { title: 'Insert tweet', ...
299,664
<p>I try to add an existing user to a blog with the function <code>add_user_to_blog($blog_id, $user_id, $role)</code>. The code I use gives me: </p> <blockquote> <p>Catchable fatal error: Object of class WP_Error could not be converted to string in C:\wamp64\www\wordpress\wp-includes\ms-functions.php on line 206...
[ { "answer_id": 299635, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": false, "text": "<blockquote>\n <p>I am hoping to be able to do this just through the Javascript with no\n additional CSS. Is t...
2018/04/03
[ "https://wordpress.stackexchange.com/questions/299664", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/141040/" ]
I try to add an existing user to a blog with the function `add_user_to_blog($blog_id, $user_id, $role)`. The code I use gives me: > > Catchable fatal error: Object of class WP\_Error could not be converted > to string in C:\wamp64\www\wordpress\wp-includes\ms-functions.php on > line 206. > > > What do I need t...
Here's your easy solution (hopefully this will help other people too): 1) add a custom class for icon, in this example "myicons" ``` (function () { tinymce.PluginManager.add('twitter_button_plugin', function (editor, url) { editor.addButton('mce_tweet_button', { title: 'Insert tweet', ...
299,701
<p>There is an author_link hook which is very useful for posts and bios; however, I don't see a hook for comment author link. Does one exist?</p>
[ { "answer_id": 299704, "author": "Oleg Butuzov", "author_id": 14536, "author_profile": "https://wordpress.stackexchange.com/users/14536", "pm_score": 0, "selected": false, "text": "<p>Are you looking for <code>get_comment_author_url</code> ?</p>\n" }, { "answer_id": 299714, "...
2018/04/03
[ "https://wordpress.stackexchange.com/questions/299701", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47326/" ]
There is an author\_link hook which is very useful for posts and bios; however, I don't see a hook for comment author link. Does one exist?
The other two answers probably answer your question, but here's a way look at WordPress source code to be able to determine for yourself whether a certain hook exists for your purposes. You ask whether there is a hook for the comment author link. So let's look at the source for that function: [`comment_author_link()`]...
299,751
<p>I have some code that works to display the children of a single page. I'm using this to display the children of a page in my footer. </p> <pre><code>$args = [ 'post_type'=&gt;'page', //this is the custom post type 'child_of'=&gt; '1452', ]; // we get an array of posts objects $posts = get_posts($args); // start o...
[ { "answer_id": 299704, "author": "Oleg Butuzov", "author_id": 14536, "author_profile": "https://wordpress.stackexchange.com/users/14536", "pm_score": 0, "selected": false, "text": "<p>Are you looking for <code>get_comment_author_url</code> ?</p>\n" }, { "answer_id": 299714, "...
2018/04/04
[ "https://wordpress.stackexchange.com/questions/299751", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/141089/" ]
I have some code that works to display the children of a single page. I'm using this to display the children of a page in my footer. ``` $args = [ 'post_type'=>'page', //this is the custom post type 'child_of'=> '1452', ]; // we get an array of posts objects $posts = get_posts($args); // start our string $str = '<u...
The other two answers probably answer your question, but here's a way look at WordPress source code to be able to determine for yourself whether a certain hook exists for your purposes. You ask whether there is a hook for the comment author link. So let's look at the source for that function: [`comment_author_link()`]...
299,753
<p>I want to check if a term object is in an get_terms array, but i really can't figure out how to do it.</p> <pre><code>$subcat_terms = get_terms([ 'taxonomy' =&gt; 'product_cat' ]); </code></pre> <p>$subcat_terms generates an array like this:</p> <pre><code>array (size=3) 0 =&gt; object(WP_Term)[10551] public...
[ { "answer_id": 299755, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 1, "selected": false, "text": "<p>A simple <code>foreach</code> loop can be used to check if a certain <code>slug</code> (or <code>term_id</c...
2018/04/04
[ "https://wordpress.stackexchange.com/questions/299753", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/111513/" ]
I want to check if a term object is in an get\_terms array, but i really can't figure out how to do it. ``` $subcat_terms = get_terms([ 'taxonomy' => 'product_cat' ]); ``` $subcat\_terms generates an array like this: ``` array (size=3) 0 => object(WP_Term)[10551] public 'term_id' => int 16 public 'name' => s...
WordPress has the `wp_list_pluck` function, which can be helpful here. We can make an array of just term IDs from the array of objects like: ``` $term_ids = wp_list_pluck( $subcat_terms, 'term_id' ); ``` Then we can check `in_array`: ``` $this_id = 42; if( in_array( $this_id, $term_ids ) ){ // do something } ```
299,783
<p>I want to add a widget to my wordpress site, but i can't see it in the back-end of wordpress. I know that i am doing something wrong. The template doesent have a header.php and a footer.php</p> <p>I did put the widget in the functions.php but then i want the header.php. In the header.php i want the widget to appea...
[ { "answer_id": 299755, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 1, "selected": false, "text": "<p>A simple <code>foreach</code> loop can be used to check if a certain <code>slug</code> (or <code>term_id</c...
2018/04/04
[ "https://wordpress.stackexchange.com/questions/299783", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/140728/" ]
I want to add a widget to my wordpress site, but i can't see it in the back-end of wordpress. I know that i am doing something wrong. The template doesent have a header.php and a footer.php I did put the widget in the functions.php but then i want the header.php. In the header.php i want the widget to appear on the h...
WordPress has the `wp_list_pluck` function, which can be helpful here. We can make an array of just term IDs from the array of objects like: ``` $term_ids = wp_list_pluck( $subcat_terms, 'term_id' ); ``` Then we can check `in_array`: ``` $this_id = 42; if( in_array( $this_id, $term_ids ) ){ // do something } ```
299,817
<p>For starters, I'm not a programmer but I'm good at cut and paste. :) I want to create a drop down list that displays each post and I've done that by putting this in my functions.php child theme file using this code: </p> <pre><code>function wpb_recentposts_dropdown() { $string .= '&lt;select id="rpdropdown"&gt...
[ { "answer_id": 299813, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 0, "selected": false, "text": "<blockquote>\n <p>I want similar design for mainsite.com/support. Should I have to create a new theme for this...
2018/04/04
[ "https://wordpress.stackexchange.com/questions/299817", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/116037/" ]
For starters, I'm not a programmer but I'm good at cut and paste. :) I want to create a drop down list that displays each post and I've done that by putting this in my functions.php child theme file using this code: ``` function wpb_recentposts_dropdown() { $string .= '<select id="rpdropdown"> <option value...
I was stuck at this for hours. But apparently solution is more easier than I had expected. I don't have to create new theme for the subsite. To make subsite homepage show blog posts instead of custom `front-page.php`, I went to Settings > Reading and selected static page and set posts page to "Blog" and left homepage...
299,820
<p>I have this code in a page of my custom theme:</p> <pre><code>$args = array( 'public' =&gt; true, '_builtin' =&gt; false ); $output = 'names'; // names or objects, note names is the default $operator = 'and'; // 'and' or 'or' $post_types = get_post_types( $args, $output, $operator ); </code></pre> <p>Thi...
[ { "answer_id": 299822, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 1, "selected": false, "text": "<p>First of all, you don't need to create variables just to pass them as arguments when calling a functi...
2018/04/04
[ "https://wordpress.stackexchange.com/questions/299820", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/111714/" ]
I have this code in a page of my custom theme: ``` $args = array( 'public' => true, '_builtin' => false ); $output = 'names'; // names or objects, note names is the default $operator = 'and'; // 'and' or 'or' $post_types = get_post_types( $args, $output, $operator ); ``` This code if loaded in a wp-admin p...
Custom post types can only be registered on the `init` hook. So if you're trying to get the post types before the `init` hook, you will only ever get the built-in ones. To get custom post types, you need to use a hook after `init`, or later on `init` than the custom post types were registered. ``` function wpse_func(...
299,824
<p>[LAST UPDATE]</p> <p>Using get_nav_menu_locations() I'm able to find all menu locations provided by theme and relative menu assigned.</p> <p>I'm already able to see if a specific menu contains an item related to a page.</p> <p>Now the problem is to extract a valid menu item from an istance of WP_Post.</p> <p>Tri...
[ { "answer_id": 299835, "author": "Pabamato", "author_id": 60079, "author_profile": "https://wordpress.stackexchange.com/users/60079", "pm_score": 0, "selected": false, "text": "<p>I asume you want to add a new item to the main menu on a given page:</p>\n\n<pre><code>add_filter( 'wp_nav_m...
2018/04/04
[ "https://wordpress.stackexchange.com/questions/299824", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73249/" ]
[LAST UPDATE] Using get\_nav\_menu\_locations() I'm able to find all menu locations provided by theme and relative menu assigned. I'm already able to see if a specific menu contains an item related to a page. Now the problem is to extract a valid menu item from an istance of WP\_Post. Tried this ``` $item = ar...
In order to know what are locations provided by theme for menus: ``` $locations = get_nav_menu_locations(); ``` This command will return an associative array that has for keys the locations and for values the ids of menu assigned to that location. To know what pages are associated to a menu: ``` $idmenu = $locati...
299,826
<p>How would you go about setting the correct language returned in AJAX calls, when you are not using any plugin? </p> <p>All other strings in page work fine just by defining WPLANG to a proper locale. </p> <p>Example: </p> <pre><code>function lpml_get_quiz_result_callback() { // do plenty of stuff before this...
[ { "answer_id": 299835, "author": "Pabamato", "author_id": 60079, "author_profile": "https://wordpress.stackexchange.com/users/60079", "pm_score": 0, "selected": false, "text": "<p>I asume you want to add a new item to the main menu on a given page:</p>\n\n<pre><code>add_filter( 'wp_nav_m...
2018/04/04
[ "https://wordpress.stackexchange.com/questions/299826", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65585/" ]
How would you go about setting the correct language returned in AJAX calls, when you are not using any plugin? All other strings in page work fine just by defining WPLANG to a proper locale. Example: ``` function lpml_get_quiz_result_callback() { // do plenty of stuff before this // this is always ret...
In order to know what are locations provided by theme for menus: ``` $locations = get_nav_menu_locations(); ``` This command will return an associative array that has for keys the locations and for values the ids of menu assigned to that location. To know what pages are associated to a menu: ``` $idmenu = $locati...
299,836
<p>Consider the following class.</p> <pre><code>&lt;?php class MCQAcademy_Endpoint extends WP_REST_Controller { /** * Register the routes for the objects of the controller. */ public function register_routes() { $version = '1'; $namespace = 'custompath/v' . $version; $base = ...
[ { "answer_id": 299843, "author": "Pabamato", "author_id": 60079, "author_profile": "https://wordpress.stackexchange.com/users/60079", "pm_score": 4, "selected": false, "text": "<p>Logged in on your website doesn't mean the user is authenticated in the REST API request, that's why you are...
2018/04/04
[ "https://wordpress.stackexchange.com/questions/299836", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/130217/" ]
Consider the following class. ``` <?php class MCQAcademy_Endpoint extends WP_REST_Controller { /** * Register the routes for the objects of the controller. */ public function register_routes() { $version = '1'; $namespace = 'custompath/v' . $version; $base = 'endpointbase'; ...
Logged in on your website doesn't mean the user is authenticated in the REST API request, that's why you are not getting the correct user or a `Id = 0` Please take a look to the REST API authentication methods on the docs: <https://developer.wordpress.org/rest-api/using-the-rest-api/authentication/> > > For devel...
299,844
<p>I am working on a new theme for a site, but the majority of the posts don't have a featured image set. Throughout the new theme I am pulling in featured images using <code>the_post_thumbnail_url</code>. I am wondering if there is a function I can add to <code>functions.php</code> to override this url, globally, with...
[ { "answer_id": 299845, "author": "Samuel Asor", "author_id": 84265, "author_profile": "https://wordpress.stackexchange.com/users/84265", "pm_score": 2, "selected": false, "text": "<p>Well, depending on the thumbnails you have defined, you could do a check if the post <em>\"has\"</em> a t...
2018/04/04
[ "https://wordpress.stackexchange.com/questions/299844", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38829/" ]
I am working on a new theme for a site, but the majority of the posts don't have a featured image set. Throughout the new theme I am pulling in featured images using `the_post_thumbnail_url`. I am wondering if there is a function I can add to `functions.php` to override this url, globally, with a url to a placeholder i...
If you know the URL of the placeholder image, you sure can do it. [`get_the_post_thumbnail_url()`](https://developer.wordpress.org/reference/functions/get_the_post_thumbnail_url/) function calls the [`wp_get_attachment_image_url()`](https://developer.wordpress.org/reference/functions/wp_get_attachment_image_url/) func...
299,859
<p>I cannot get it so that my user role for a supplier can read the shipments post type. It shows up in their menu but when you click on it you get <em>you are not allowed to view this page</em> error message.</p> <p>It works if I <code>add_cap('read_posts')</code> but I don't want them to view the regular posts just ...
[ { "answer_id": 300478, "author": "Myles", "author_id": 141270, "author_profile": "https://wordpress.stackexchange.com/users/141270", "pm_score": 3, "selected": false, "text": "<p>Your custom post type looks like it's set up properly. It works on my test install. Try this instead of whate...
2018/04/05
[ "https://wordpress.stackexchange.com/questions/299859", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/92318/" ]
I cannot get it so that my user role for a supplier can read the shipments post type. It shows up in their menu but when you click on it you get *you are not allowed to view this page* error message. It works if I `add_cap('read_posts')` but I don't want them to view the regular posts just the shipments post type. I ...
Your custom post type looks like it's set up properly. It works on my test install. Try this instead of whatever add\_role and add\_cap code you're currently using. (For testing purposes only. Don't use it in production code, for reasons outlined below.) It's working for me: ``` function prefix_set_up_supplier_role(){...
299,868
<p>I tried searching but I can't seem to find a similar question so I am hoping that as an amateur, I am just making a big simple mistake.</p> <p><strong>What I want</strong></p> <p>I want to install Font Awesome to my WordPress theme and I want to do it locally.</p> <p><strong>Folder structure</strong></p> <p>This...
[ { "answer_id": 299869, "author": "Quang Hoang", "author_id": 134874, "author_profile": "https://wordpress.stackexchange.com/users/134874", "pm_score": 2, "selected": false, "text": "<p>You can edit and try again.</p>\n\n<pre><code>function add_font_awesome(){\n wp_enqueue_style( 'styl...
2018/04/05
[ "https://wordpress.stackexchange.com/questions/299868", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136144/" ]
I tried searching but I can't seem to find a similar question so I am hoping that as an amateur, I am just making a big simple mistake. **What I want** I want to install Font Awesome to my WordPress theme and I want to do it locally. **Folder structure** This image is my folder structure: [![enter image descriptio...
Considering the folder structure "/public\_html/wp-content/themes/TestTheme/static/fontawesome/" as folder location for Font Awesome use following instead 1 use following instead of the one you used for js include ``` <script defer src="<?php echo get_template_directory_uri(); ?>/static/fontawesome/fontawesome-all.js...
299,968
<p>I just rehosted a site for a client, and am now receiving emails from the site stating I've recently requested to have the administration email changed. I didn't request it, and I've deleted the account the former admin could have used to log in. I've also changed all other passwords, and the host has changed. </p> ...
[ { "answer_id": 299969, "author": "Beee", "author_id": 103402, "author_profile": "https://wordpress.stackexchange.com/users/103402", "pm_score": 2, "selected": false, "text": "<p>I think someone entered the password reset form and you probably have an easy user login for the administrator...
2018/04/06
[ "https://wordpress.stackexchange.com/questions/299968", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/69226/" ]
I just rehosted a site for a client, and am now receiving emails from the site stating I've recently requested to have the administration email changed. I didn't request it, and I've deleted the account the former admin could have used to log in. I've also changed all other passwords, and the host has changed. This i...
I think someone entered the password reset form and you probably have an easy user login for the administrator like 'admin' or so, so that's what they probably entered. The email also says: ``` You can safely ignore and delete this email if you do not want to take this action. ``` So just ignore it.
300,008
<p>How can visitors redirect wp-admin to the homepage?</p> <p><strong>My site details:</strong> 1. I used BuddyPress; 2. Users can sign up and login via BuddyPress; 3. User role only Admin and Author;</p> <p><strong>Needs:</strong> 1. wp-admin only admin can access, if not an admin, and visitors and Authors then redi...
[ { "answer_id": 300018, "author": "DaveLak", "author_id": 119673, "author_profile": "https://wordpress.stackexchange.com/users/119673", "pm_score": 3, "selected": true, "text": "<p>The <a href=\"https://codex.wordpress.org/Plugin_API/Action_Reference/admin_init\" rel=\"nofollow noreferrer...
2018/04/06
[ "https://wordpress.stackexchange.com/questions/300008", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
How can visitors redirect wp-admin to the homepage? **My site details:** 1. I used BuddyPress; 2. Users can sign up and login via BuddyPress; 3. User role only Admin and Author; **Needs:** 1. wp-admin only admin can access, if not an admin, and visitors and Authors then redirect to home page; 2. Users force use Buddy...
The [codex entry for the `admin_init` hook has an example](https://codex.wordpress.org/Plugin_API/Action_Reference/admin_init) showing you how to do this. ``` /** * Restrict access to the administration screens. * * Only administrators will be allowed to access the admin screens, * all other users will be automati...
300,029
<p>I'm working on my first ever WP project.</p> <p>I have a theme that tiles all posts across the homepage - and I need to add a repeating advert every 5-6 posts.</p> <p>My thought was to change the database query that lists the posts and add the advert every so many loops.</p> <p>Can someone point me in the directi...
[ { "answer_id": 300030, "author": "David Sword", "author_id": 132362, "author_profile": "https://wordpress.stackexchange.com/users/132362", "pm_score": 2, "selected": false, "text": "<p>Probably just add a counter, show ad on multiples of 6. </p>\n\n<p>Something like </p>\n\n<pre><code>$c...
2018/04/06
[ "https://wordpress.stackexchange.com/questions/300029", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/141280/" ]
I'm working on my first ever WP project. I have a theme that tiles all posts across the homepage - and I need to add a repeating advert every 5-6 posts. My thought was to change the database query that lists the posts and add the advert every so many loops. Can someone point me in the direction of where to find the ...
Probably just add a counter, show ad on multiples of 6. Something like ``` $count = 0; $adEvery = 6; if (have_posts()) : while (have_posts()) : the_post(); // Individual Post $count++; if ($count%$adEvery == 0) { // your ad } endwhile; else : // No Posts ...
300,076
<p>We have developed a mobile application using the <a href="https://wordpress.org/plugins/json-api" rel="nofollow noreferrer">JSON API</a> plugin.</p> <p>The current website is running on HTTP, we are planning to change the website to HTTPS.</p> <p>Currently, mobile users on the live app are on HTTP; if we change th...
[ { "answer_id": 300030, "author": "David Sword", "author_id": 132362, "author_profile": "https://wordpress.stackexchange.com/users/132362", "pm_score": 2, "selected": false, "text": "<p>Probably just add a counter, show ad on multiples of 6. </p>\n\n<p>Something like </p>\n\n<pre><code>$c...
2018/04/07
[ "https://wordpress.stackexchange.com/questions/300076", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/124623/" ]
We have developed a mobile application using the [JSON API](https://wordpress.org/plugins/json-api) plugin. The current website is running on HTTP, we are planning to change the website to HTTPS. Currently, mobile users on the live app are on HTTP; if we change the website to HTTPS then the app doesn't work so we hav...
Probably just add a counter, show ad on multiples of 6. Something like ``` $count = 0; $adEvery = 6; if (have_posts()) : while (have_posts()) : the_post(); // Individual Post $count++; if ($count%$adEvery == 0) { // your ad } endwhile; else : // No Posts ...
300,084
<p>On archive pages, I let WordPress handle the archive page and load the first 10 posts, then I load more posts with AJAX requests, and this AJAX request is returning weird results.</p> <p>My query inside the AJAX handler looks like this:</p> <pre><code>$query_args = array( 'post_type' =&gt; 'post', 'posts_p...
[ { "answer_id": 300088, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 0, "selected": false, "text": "<p>Just use the <code>paged</code> parameter to get the 2nd (or 3rd or 4th etc.) page:</p>\n\n<pre><code>$...
2018/04/07
[ "https://wordpress.stackexchange.com/questions/300084", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/91948/" ]
On archive pages, I let WordPress handle the archive page and load the first 10 posts, then I load more posts with AJAX requests, and this AJAX request is returning weird results. My query inside the AJAX handler looks like this: ``` $query_args = array( 'post_type' => 'post', 'posts_per_page' => get_option( ...
Fixed it. After all it was really dumb error on my part. The `WP_Query()` does not filter out unpublished posts by default. The internal archive page query does filter these posts out. I had to add `'post_status' => 'publish'` to the `$query_args` array and everything is now working as expected. The final query then ...
300,109
<p>I updated from http to https today. So far, so good. Everything is working, but the redirect command. When I click on external social media or websites that link to my blog still using the old version http, it's not being redirected.</p> <p>This is how part of my file looks:</p> <pre><code># -FrontPage- IndexIgnor...
[ { "answer_id": 300112, "author": "MrWhite", "author_id": 8259, "author_profile": "https://wordpress.stackexchange.com/users/8259", "pm_score": 3, "selected": true, "text": "<p>You've put the redirect code in the wrong place. It needs to go <em>before</em> the <code># BEGIN WordPress</cod...
2018/04/07
[ "https://wordpress.stackexchange.com/questions/300109", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/6903/" ]
I updated from http to https today. So far, so good. Everything is working, but the redirect command. When I click on external social media or websites that link to my blog still using the old version http, it's not being redirected. This is how part of my file looks: ``` # -FrontPage- IndexIgnore .htaccess */.??* *~...
You've put the redirect code in the wrong place. It needs to go *before* the `# BEGIN WordPress` section. By placing the redirect code *after* the WordPress front-controller it will never be processed unless the request is for a physical file. However, your first attempt is not correct (it's missing the check for HTTP...
300,147
<p>I have a WP installation in the root of my domain (running on Apache / Linux).</p> <p>I need to create a new WP installation (for various reasons that are outside of this post) and I have a choice of creating this second installation within either a) a subdomain or b) a folder in the main domain. </p> <p>So I can ...
[ { "answer_id": 300112, "author": "MrWhite", "author_id": 8259, "author_profile": "https://wordpress.stackexchange.com/users/8259", "pm_score": 3, "selected": true, "text": "<p>You've put the redirect code in the wrong place. It needs to go <em>before</em> the <code># BEGIN WordPress</cod...
2018/04/08
[ "https://wordpress.stackexchange.com/questions/300147", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/141362/" ]
I have a WP installation in the root of my domain (running on Apache / Linux). I need to create a new WP installation (for various reasons that are outside of this post) and I have a choice of creating this second installation within either a) a subdomain or b) a folder in the main domain. So I can create this new i...
You've put the redirect code in the wrong place. It needs to go *before* the `# BEGIN WordPress` section. By placing the redirect code *after* the WordPress front-controller it will never be processed unless the request is for a physical file. However, your first attempt is not correct (it's missing the check for HTTP...
300,184
<p>I'm creating a WordPress theme in which I'm using the Redux Framework for creating the theme's options page.</p> <p>I want to show multiple blog layouts without creating custom WP templates. I saw in many themes the URL is something like </p> <ul> <li>theme.com?home_layout=grid&amp;sidebar=left</li> <li>theme.com?...
[ { "answer_id": 300112, "author": "MrWhite", "author_id": 8259, "author_profile": "https://wordpress.stackexchange.com/users/8259", "pm_score": 3, "selected": true, "text": "<p>You've put the redirect code in the wrong place. It needs to go <em>before</em> the <code># BEGIN WordPress</cod...
2018/04/09
[ "https://wordpress.stackexchange.com/questions/300184", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/141383/" ]
I'm creating a WordPress theme in which I'm using the Redux Framework for creating the theme's options page. I want to show multiple blog layouts without creating custom WP templates. I saw in many themes the URL is something like * theme.com?home\_layout=grid&sidebar=left * theme.com?home\_layout=list&sidebar=none ...
You've put the redirect code in the wrong place. It needs to go *before* the `# BEGIN WordPress` section. By placing the redirect code *after* the WordPress front-controller it will never be processed unless the request is for a physical file. However, your first attempt is not correct (it's missing the check for HTTP...
300,207
<p>I'm trying to pass an argument in to the 'init' hook (please see below for what I'm trying to do).</p> <pre><code>//define post type name $pt_name = 'post'; //remove default wysiwyg editor add_action('init', function($pt_name) { $post_type = $pt_name; remove_post_type_support( $post_type, 'editor'); }, 100...
[ { "answer_id": 300208, "author": "bueltge", "author_id": 170, "author_profile": "https://wordpress.stackexchange.com/users/170", "pm_score": 1, "selected": false, "text": "<p>The <a href=\"https://developer.wordpress.org/reference/hooks/init/\" rel=\"nofollow noreferrer\"><code>init</cod...
2018/04/09
[ "https://wordpress.stackexchange.com/questions/300207", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/141411/" ]
I'm trying to pass an argument in to the 'init' hook (please see below for what I'm trying to do). ``` //define post type name $pt_name = 'post'; //remove default wysiwyg editor add_action('init', function($pt_name) { $post_type = $pt_name; remove_post_type_support( $post_type, 'editor'); }, 100); ``` It se...
The one thing you are missing is the use of `use` (<http://php.net/manual/en/functions.anonymous.php> example #3) You code will look something like ``` //define post type name $pt_name = 'post'; //remove default wysiwyg editor add_action('init', function() use ($pt_name) { $post_type = $pt_name; remove_post...
300,219
<p>WordPress panel service "log out everywhere else" is doing a nice job. I want to use this as a function outside the panel.</p> <p><strong>Screenshoot</strong></p> <p><a href="https://i.stack.imgur.com/SAGpi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SAGpi.png" alt="enter image description h...
[ { "answer_id": 300225, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 4, "selected": true, "text": "<p>That button sends an AJAX request that runs <a href=\"https://developer.wordpress.org/reference/function...
2018/04/09
[ "https://wordpress.stackexchange.com/questions/300219", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/84842/" ]
WordPress panel service "log out everywhere else" is doing a nice job. I want to use this as a function outside the panel. **Screenshoot** [![enter image description here](https://i.stack.imgur.com/SAGpi.png)](https://i.stack.imgur.com/SAGpi.png)
That button sends an AJAX request that runs [`wp_ajax_destroy_sessions()`](https://developer.wordpress.org/reference/functions/wp_ajax_destroy_sessions/). It's not really abstracted in such a way that you can re-use it outside of AJAX, but if you copy the source into your own function, minus the JSON parts, then you ...
300,222
<p>So over on wordpress I have a custom post type called crosses, and I need to list them on my search results page in order with the shortest titles first and longest titles last. I thought the way to do it would be to create a custom field called "name-length" and then include a function to count the number of letter...
[ { "answer_id": 300268, "author": "Liam Stewart", "author_id": 121955, "author_profile": "https://wordpress.stackexchange.com/users/121955", "pm_score": 1, "selected": true, "text": "<p>Add the following to your <code>functions.php</code> for the on save. This will create a meta value on ...
2018/04/09
[ "https://wordpress.stackexchange.com/questions/300222", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/141421/" ]
So over on wordpress I have a custom post type called crosses, and I need to list them on my search results page in order with the shortest titles first and longest titles last. I thought the way to do it would be to create a custom field called "name-length" and then include a function to count the number of letters i...
Add the following to your `functions.php` for the on save. This will create a meta value on save that stores the length of the post title. ``` function save_crosses_title_length( $post_id ) { $title = get_the_title($post_id);//get the title $length = strlen( $title );// get the length of title if ( get_post_me...
300,233
<p>I'm working on my Plugin &amp; i wanted to declare one of the global wordpress variables which is <code>$current_screen</code> To Check whether The user is on the target page or some other page, my Approach was like this , but it didn't work out .</p> <pre><code>class my_Class { public $current_screen; pu...
[ { "answer_id": 300234, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 2, "selected": false, "text": "<p>It's not enough to call <code>global</code> in <code>__construct()</code>. <code>global</code> only mak...
2018/04/09
[ "https://wordpress.stackexchange.com/questions/300233", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/133002/" ]
I'm working on my Plugin & i wanted to declare one of the global wordpress variables which is `$current_screen` To Check whether The user is on the target page or some other page, my Approach was like this , but it didn't work out . ``` class my_Class { public $current_screen; public function __construct() {...
The `$current_screen` is passed as a variable to callables hooked from the `current_screen` hook. Before this hook, the `$current_screen` isn't set up, so globalizing the variable won't do anything anyway. Also, WordPress offers the convenience function `get_current_screen()` that returns the global `$current_screen`...
300,240
<p>So basically I have these service categories, under that there are the actual services. I am basically trying to loop through the categories and display category title, then underneath that I want to loop through all of the corresponding child items. I'm using "Toolset" custom field plugin with Wordpress. I have the...
[ { "answer_id": 300234, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 2, "selected": false, "text": "<p>It's not enough to call <code>global</code> in <code>__construct()</code>. <code>global</code> only mak...
2018/04/09
[ "https://wordpress.stackexchange.com/questions/300240", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/141430/" ]
So basically I have these service categories, under that there are the actual services. I am basically trying to loop through the categories and display category title, then underneath that I want to loop through all of the corresponding child items. I'm using "Toolset" custom field plugin with Wordpress. I have the lo...
The `$current_screen` is passed as a variable to callables hooked from the `current_screen` hook. Before this hook, the `$current_screen` isn't set up, so globalizing the variable won't do anything anyway. Also, WordPress offers the convenience function `get_current_screen()` that returns the global `$current_screen`...
300,261
<p>I am going to make plugin, collecting post views from Google Analytics. The main idea is to get views per post and store them with post meta. </p> <p>Problem:<br> My blog has a lot of posts and google analytics returns data very slow. It is about 30min for example to collect all data.</p> <p>Possible solutions:</p...
[ { "answer_id": 300234, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 2, "selected": false, "text": "<p>It's not enough to call <code>global</code> in <code>__construct()</code>. <code>global</code> only mak...
2018/04/09
[ "https://wordpress.stackexchange.com/questions/300261", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/126253/" ]
I am going to make plugin, collecting post views from Google Analytics. The main idea is to get views per post and store them with post meta. Problem: My blog has a lot of posts and google analytics returns data very slow. It is about 30min for example to collect all data. Possible solutions: 1. Use Linux cronta...
The `$current_screen` is passed as a variable to callables hooked from the `current_screen` hook. Before this hook, the `$current_screen` isn't set up, so globalizing the variable won't do anything anyway. Also, WordPress offers the convenience function `get_current_screen()` that returns the global `$current_screen`...
300,270
<p>Is it possible to save the content (inside the WP WYSIWYG (<code>the_content</code>)) into a custom field?</p> <p><strong>This is what I have so far:</strong></p> <pre><code>add_action('edit_post', 'save_content_to_field'); function save_content_to_field($post_ID) { global $wpdb; if(!wp_is_post_revision($...
[ { "answer_id": 300329, "author": "bpy", "author_id": 18693, "author_profile": "https://wordpress.stackexchange.com/users/18693", "pm_score": 1, "selected": true, "text": "<p>OK!</p>\n\n<p>I found this way and this might be useful to someone:</p>\n\n<pre><code>add_action('edit_post', 'sav...
2018/04/09
[ "https://wordpress.stackexchange.com/questions/300270", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/18693/" ]
Is it possible to save the content (inside the WP WYSIWYG (`the_content`)) into a custom field? **This is what I have so far:** ``` add_action('edit_post', 'save_content_to_field'); function save_content_to_field($post_ID) { global $wpdb; if(!wp_is_post_revision($post_ID)) { $content = get_the_conten...
OK! I found this way and this might be useful to someone: ``` add_action('edit_post', 'save_content_to_field'); function save_content_to_field($post_ID) { global $wpdb; if(!wp_is_post_revision($post_ID)) { //$content = get_the_content($post_ID); global $post; $content = apply_filters(...
300,316
<p>I have created an <code>opps</code> custom post type and registered a custom API field of <code>closed</code> for it with the following code: </p> <pre><code>public function get_opp_state() { register_rest_field( 'opps', 'closed', array( 'get_callback' =&gt; array( $this, 'get_opp_state_callback' ), ...
[ { "answer_id": 300328, "author": "Aurovrata", "author_id": 52120, "author_profile": "https://wordpress.stackexchange.com/users/52120", "pm_score": 0, "selected": false, "text": "<p>When modifying a REST request, you have <a href=\"https://developer.wordpress.org/rest-api/extending-the-re...
2018/04/10
[ "https://wordpress.stackexchange.com/questions/300316", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/129417/" ]
I have created an `opps` custom post type and registered a custom API field of `closed` for it with the following code: ``` public function get_opp_state() { register_rest_field( 'opps', 'closed', array( 'get_callback' => array( $this, 'get_opp_state_callback' ), 'update_callback' => null, ...
After a lot of digging I seem to have found a solution myself, and a pretty powerful one, which makes use of a `rest_{ post_type }_query` filter (replace the { post\_type } part with the slug of your custom post type. You can use `rest_post_query` to alter the default `/wp-json/wp/v2/posts` request): ``` public functi...
300,356
<p>I need custom CSS for admin. So if user is not logged in or is anything else but admin there is one CSS, and for admin only different CSS.</p> <p>I tried this code in functions.php:</p> <pre><code>function wpa66834_role_admin_body_class( $classes ) { global $current_user; foreach( $current_user-&gt;roles a...
[ { "answer_id": 300357, "author": "Petra Žagar", "author_id": 141505, "author_profile": "https://wordpress.stackexchange.com/users/141505", "pm_score": -1, "selected": false, "text": "<p>Solution: </p>\n\n<pre><code>function add_custom_styles() {\n if ( is_admin() ) { ?&gt;\n &lt;s...
2018/04/10
[ "https://wordpress.stackexchange.com/questions/300356", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/141505/" ]
I need custom CSS for admin. So if user is not logged in or is anything else but admin there is one CSS, and for admin only different CSS. I tried this code in functions.php: ``` function wpa66834_role_admin_body_class( $classes ) { global $current_user; foreach( $current_user->roles as $role ) $class...
The code that you've tried already adds the role CSS class to the `admin_body_class`, which only affects the admin area/backend. Simply change the filter to alter the frontend body class `body_class`, eg. ``` function wpa66834_role_admin_body_class( $classes ) { global $current_user; foreach( $current_user->ro...
300,379
<p>I'm currently using twentyseventeen child theme and I need to <strong>modify the link on single post page below the article</strong>. His href is forwarding to category of the post. </p> <p>I'm pretty new to filters in wp so I really don't know which filter should I use in this case. Also i would love to know, how ...
[ { "answer_id": 300385, "author": "Mat", "author_id": 37985, "author_profile": "https://wordpress.stackexchange.com/users/37985", "pm_score": 3, "selected": true, "text": "<p>The category link that you are referring to, that is displayed beneath the single post page content is not added w...
2018/04/10
[ "https://wordpress.stackexchange.com/questions/300379", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/141518/" ]
I'm currently using twentyseventeen child theme and I need to **modify the link on single post page below the article**. His href is forwarding to category of the post. I'm pretty new to filters in wp so I really don't know which filter should I use in this case. Also i would love to know, how could i know or where t...
The category link that you are referring to, that is displayed beneath the single post page content is not added with a filter. It is displayed via a function called `twentyseventeen_entry_footer()`. If you take a look at the themes files you can find the function on line #59, within the file: `/wp-content/themes/twe...
300,397
<p>I have a simple database query script alongside with my WordPress installation, to which I pass a parameter using the following URL: <code>http://example.com/db/?p=foo</code>.</p> <p>My database script reads the parameter with</p> <pre><code>$pid = $_GET['p']; </code></pre> <p>Everthing works fine, IF the paramet...
[ { "answer_id": 300506, "author": "nounours", "author_id": 141532, "author_profile": "https://wordpress.stackexchange.com/users/141532", "pm_score": 2, "selected": false, "text": "<p>Thanks to Tom, I looked more carefully to the plugins.</p>\n\n<p>And I can confirm that the problem is NOT...
2018/04/10
[ "https://wordpress.stackexchange.com/questions/300397", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/141532/" ]
I have a simple database query script alongside with my WordPress installation, to which I pass a parameter using the following URL: `http://example.com/db/?p=foo`. My database script reads the parameter with ``` $pid = $_GET['p']; ``` Everthing works fine, IF the parameter does NOT START WITH A NUMBER. so, `?p=fo...
Thanks to Tom, I looked more carefully to the plugins. And I can confirm that the problem is NOT RELATED to mod\_rewrite, but to a plugin conflict. (sorry that I posted such a suspicion, but I read somewhere a very similar problem that was explained like that.) Deactivating plugin by plugin, I found that one you made...
300,406
<p>I am trying to add a custom coloumn to post quick edit and everything is almost working. Custom meta is saved and passed but if I click on quick edit the preview is blank. This is the error it gives me:</p> <blockquote> <p><strong>Notice</strong>: Undefined variable: <strong>post_id</strong> in /home/etimueit/public...
[ { "answer_id": 300407, "author": "Mat", "author_id": 37985, "author_profile": "https://wordpress.stackexchange.com/users/37985", "pm_score": 2, "selected": false, "text": "<p>Sorry, I've had to change my answer after checking the WordPress Codex on adding custom editable data to the quic...
2018/04/10
[ "https://wordpress.stackexchange.com/questions/300406", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4107/" ]
I am trying to add a custom coloumn to post quick edit and everything is almost working. Custom meta is saved and passed but if I click on quick edit the preview is blank. This is the error it gives me: > > **Notice**: Undefined variable: **post\_id** in /home/etimueit/public\_html/wp-content/themes/caru/functions.ph...
Here we are, finally found a solution, I leave it here so maybe it can help (maybe also future me XD ). ``` /** ``` \* \* Aggiungi Disponibilità nel Quick Edit \*/ ``` function etdispo_quickedit_custom_posts_columns( $posts_columns ) { $posts_columns['et2018-quantita_birra'] = __( 'Disponibilità', 'etdispo' );...
300,411
<p>I'm currently developing a wordpress version of a website on a dev.acme.com domain, while the old site (www.acme.com) remains active (if it's relevant, it's not on a wordpress platform.) The content will be migrated over at some point (that part has been tested and is going to work fine.)</p> <p>All my URLs (for im...
[ { "answer_id": 300407, "author": "Mat", "author_id": 37985, "author_profile": "https://wordpress.stackexchange.com/users/37985", "pm_score": 2, "selected": false, "text": "<p>Sorry, I've had to change my answer after checking the WordPress Codex on adding custom editable data to the quic...
2018/04/10
[ "https://wordpress.stackexchange.com/questions/300411", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59932/" ]
I'm currently developing a wordpress version of a website on a dev.acme.com domain, while the old site (www.acme.com) remains active (if it's relevant, it's not on a wordpress platform.) The content will be migrated over at some point (that part has been tested and is going to work fine.) All my URLs (for images and l...
Here we are, finally found a solution, I leave it here so maybe it can help (maybe also future me XD ). ``` /** ``` \* \* Aggiungi Disponibilità nel Quick Edit \*/ ``` function etdispo_quickedit_custom_posts_columns( $posts_columns ) { $posts_columns['et2018-quantita_birra'] = __( 'Disponibilità', 'etdispo' );...
300,415
<p>I'm trying to add a filter to the add media button for a custom post type. I'm using add_filter('media_send_to_editor') and it work's fine, but I'm having difficulty finding a way to determine the post type of the admin page so that I can only perform the filter on that specific post type. Any ideas on how I can get...
[ { "answer_id": 300407, "author": "Mat", "author_id": 37985, "author_profile": "https://wordpress.stackexchange.com/users/37985", "pm_score": 2, "selected": false, "text": "<p>Sorry, I've had to change my answer after checking the WordPress Codex on adding custom editable data to the quic...
2018/04/11
[ "https://wordpress.stackexchange.com/questions/300415", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136939/" ]
I'm trying to add a filter to the add media button for a custom post type. I'm using add\_filter('media\_send\_to\_editor') and it work's fine, but I'm having difficulty finding a way to determine the post type of the admin page so that I can only perform the filter on that specific post type. Any ideas on how I can ge...
Here we are, finally found a solution, I leave it here so maybe it can help (maybe also future me XD ). ``` /** ``` \* \* Aggiungi Disponibilità nel Quick Edit \*/ ``` function etdispo_quickedit_custom_posts_columns( $posts_columns ) { $posts_columns['et2018-quantita_birra'] = __( 'Disponibilità', 'etdispo' );...
300,424
<p>I'm trying to set WordPress permalink in sitename/post name in Hindi language but it's gives me <code>%e0%a4%b2%e0%a5%8b%e0%a4%b0%e0%a4%ae-%e0%a4%87%e0%a4%aa%e0%a5%8d%e0%a4%b8%e0%a4%ae-%e0%a4%95%e0%a5%8d%e0%a4%af%e0%a4%be-%e0%a4%b9%e0%a5%88/</code></p> <p>This kind of permalink .</p>
[ { "answer_id": 300407, "author": "Mat", "author_id": 37985, "author_profile": "https://wordpress.stackexchange.com/users/37985", "pm_score": 2, "selected": false, "text": "<p>Sorry, I've had to change my answer after checking the WordPress Codex on adding custom editable data to the quic...
2018/04/11
[ "https://wordpress.stackexchange.com/questions/300424", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/141551/" ]
I'm trying to set WordPress permalink in sitename/post name in Hindi language but it's gives me `%e0%a4%b2%e0%a5%8b%e0%a4%b0%e0%a4%ae-%e0%a4%87%e0%a4%aa%e0%a5%8d%e0%a4%b8%e0%a4%ae-%e0%a4%95%e0%a5%8d%e0%a4%af%e0%a4%be-%e0%a4%b9%e0%a5%88/` This kind of permalink .
Here we are, finally found a solution, I leave it here so maybe it can help (maybe also future me XD ). ``` /** ``` \* \* Aggiungi Disponibilità nel Quick Edit \*/ ``` function etdispo_quickedit_custom_posts_columns( $posts_columns ) { $posts_columns['et2018-quantita_birra'] = __( 'Disponibilità', 'etdispo' );...
300,472
<p>I'm trying to set up a number of 301 redirects using the .htaccess file. For some reason it is not working for me.</p> <pre><code># BEGIN WordPress &lt;IfModule mod_rewrite.c&gt; RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d Rew...
[ { "answer_id": 300545, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 1, "selected": false, "text": "<p>In general it is much better to handle redirect on the PHP side. (assuming is is implemented by semi comp...
2018/04/11
[ "https://wordpress.stackexchange.com/questions/300472", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/69376/" ]
I'm trying to set up a number of 301 redirects using the .htaccess file. For some reason it is not working for me. ``` # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{REQUEST_FILENAME} !-f RewriteCond %{REQUEST_FILENAME} !-d RewriteRule . /index.ph...
In general it is much better to handle redirect on the PHP side. (assuming is is implemented by semi competent developer) It is more flexible and uses less overhead. Specifically to the question, the set of wordpress rules will handle **all** URLs, therefor your rule is too late and you should move it to be before the...
300,555
<p>I'm bringing up an issue that could not be solved after googling for solutions over a few days. The goal I have to meet is to output a pagination for a custom post type named office-magazines with working links. I already managed to output the pagination but clicking any of the links within it takes me to the top pa...
[ { "answer_id": 300531, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 2, "selected": false, "text": "<p>It's a bit different in WP than in Drupal. First, the <code>admin</code> role is specifically designed to...
2018/04/12
[ "https://wordpress.stackexchange.com/questions/300555", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/141638/" ]
I'm bringing up an issue that could not be solved after googling for solutions over a few days. The goal I have to meet is to output a pagination for a custom post type named office-magazines with working links. I already managed to output the pagination but clicking any of the links within it takes me to the top page....
1. Install User Role Editor Plugin 2. Create a Role for them assign everything except removing admin.
300,582
<p>I'm working on a rather large WordPress project with over 40 plugins, also including a bunch of custom-made plugins specific to this project.</p> <p>This makes navigating the WordPress plugins folder rather troublesome. Is it possible to "organize" the plugins folder to look more like the example below?</p> <pre><...
[ { "answer_id": 300531, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 2, "selected": false, "text": "<p>It's a bit different in WP than in Drupal. First, the <code>admin</code> role is specifically designed to...
2018/04/12
[ "https://wordpress.stackexchange.com/questions/300582", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22588/" ]
I'm working on a rather large WordPress project with over 40 plugins, also including a bunch of custom-made plugins specific to this project. This makes navigating the WordPress plugins folder rather troublesome. Is it possible to "organize" the plugins folder to look more like the example below? ``` - plugins - ...
1. Install User Role Editor Plugin 2. Create a Role for them assign everything except removing admin.
300,585
<p>I've a bug that I cannot reproduce on my local/staging evn and occurs only on prod(having the same code, db and files). Here is what I get when visiting all of the default post types/taxonomies or custom created by me or plugins(it's not bugged on settings pages for ex):</p> <p>When visiting <code>/wp-admin/edit.ph...
[ { "answer_id": 300592, "author": "Oleg Butuzov", "author_id": 14536, "author_profile": "https://wordpress.stackexchange.com/users/14536", "pm_score": 1, "selected": false, "text": "<p>What you can do is copy live DB, and deploy it to dev. Once you do that, start to disabling plugins one ...
2018/04/12
[ "https://wordpress.stackexchange.com/questions/300585", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/128600/" ]
I've a bug that I cannot reproduce on my local/staging evn and occurs only on prod(having the same code, db and files). Here is what I get when visiting all of the default post types/taxonomies or custom created by me or plugins(it's not bugged on settings pages for ex): When visiting `/wp-admin/edit.php?post_type=pag...
Posting the solution I've found for my problem. It appears that we have mod\_security on our prod env, and recommended clause is to replace "server info" and on what the site is hosted on(for security reasons). In my case it was replaced with IIS 6, and that tricked the WordPress installation as well, which on it's ...
300,594
<p>Let's say I want to build a function that allows my users to like posts in my website.</p> <p>My intention is to store the ID of the user that liked the post as metadata.</p> <p>My question is what's the best way to go in terms of performance and 'queribility'.</p> <p>Separate row for each like:</p> <p><code>'li...
[ { "answer_id": 300595, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 2, "selected": false, "text": "<p>Very simple, meta should not be queried as it do not scale. Once this is out of the way, you should prefe...
2018/04/12
[ "https://wordpress.stackexchange.com/questions/300594", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/126374/" ]
Let's say I want to build a function that allows my users to like posts in my website. My intention is to store the ID of the user that liked the post as metadata. My question is what's the best way to go in terms of performance and 'queribility'. Separate row for each like: `'liked_by'=>'3'` `'liked_by'=>'21'` ...
**Neither option are the correct option for your use case** Your question is barking up the wrong tree, because you neglected to mention that you intend to search for these posts based on the values the meta holds. If you're displaying a post, you can use either method, though the first is cleaner/simpler to handle i...
300,621
<p>In my functions.php file I am loading a particular js script on only the page it is required, as I don't want to load it unnecessarily on pages that don't require it.</p> <pre><code>function tabs_enqueue() { if(is_page( 205 )) { wp_enqueue_script( 'ui', get_template_directory_uri() . '/js/ui/jquery-ui.m...
[ { "answer_id": 300623, "author": "Felipe Elia", "author_id": 122788, "author_profile": "https://wordpress.stackexchange.com/users/122788", "pm_score": 2, "selected": false, "text": "<p>You don't need to add it on a template, you can use the <a href=\"https://developer.wordpress.org/refer...
2018/04/12
[ "https://wordpress.stackexchange.com/questions/300621", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/140276/" ]
In my functions.php file I am loading a particular js script on only the page it is required, as I don't want to load it unnecessarily on pages that don't require it. ``` function tabs_enqueue() { if(is_page( 205 )) { wp_enqueue_script( 'ui', get_template_directory_uri() . '/js/ui/jquery-ui.min.js', [], '1...
You don't need to add it on a template, you can use the [wp\_add\_inline\_script()](https://developer.wordpress.org/reference/functions/wp_add_inline_script/) function. It'd be something like: ``` function tabs_enqueue() { if(is_page( 205 )) { wp_enqueue_script( 'ui', get_template_directory_uri() . '/js/ui...
300,624
<p>I have created a new control (checkbox) in WP Customizer. The way it should work is as it follows: the corresponding section should display the last published post when the checkbox is checked (true) or a custom background image (and some content) when the checkbox is unchecked (false).</p> <p>Everything works fine...
[ { "answer_id": 300623, "author": "Felipe Elia", "author_id": 122788, "author_profile": "https://wordpress.stackexchange.com/users/122788", "pm_score": 2, "selected": false, "text": "<p>You don't need to add it on a template, you can use the <a href=\"https://developer.wordpress.org/refer...
2018/04/12
[ "https://wordpress.stackexchange.com/questions/300624", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/141683/" ]
I have created a new control (checkbox) in WP Customizer. The way it should work is as it follows: the corresponding section should display the last published post when the checkbox is checked (true) or a custom background image (and some content) when the checkbox is unchecked (false). Everything works fine on first ...
You don't need to add it on a template, you can use the [wp\_add\_inline\_script()](https://developer.wordpress.org/reference/functions/wp_add_inline_script/) function. It'd be something like: ``` function tabs_enqueue() { if(is_page( 205 )) { wp_enqueue_script( 'ui', get_template_directory_uri() . '/js/ui...
300,683
<p>I am playing with Gutenberg and I am a bit confused about how it should save to meta. Here is my custom post and meta:</p> <pre><code>add_action( 'init', function() { register_post_type( 'game', [ 'label' =&gt; 'Games', 'public' =&gt; true, 'supports' =&gt; [ 'editor', 'custom-fields' ],...
[ { "answer_id": 306402, "author": "LABCAT", "author_id": 145531, "author_profile": "https://wordpress.stackexchange.com/users/145531", "pm_score": 0, "selected": false, "text": "<p>I am trying to learn how to do this also. You have incorrectly registered your meta value, it should be:</p>...
2018/04/13
[ "https://wordpress.stackexchange.com/questions/300683", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/67305/" ]
I am playing with Gutenberg and I am a bit confused about how it should save to meta. Here is my custom post and meta: ``` add_action( 'init', function() { register_post_type( 'game', [ 'label' => 'Games', 'public' => true, 'supports' => [ 'editor', 'custom-fields' ], 'show_in_rest'...
The meta value is read when the block loads and assigned to the block attribute. Changes to the block will update the attribute and when the post saves the value will save to the meta. So, as far as I understood, there is no need to actually save anything in the `registerBlockType` js function. The block only saves to ...
300,710
<p>I am new to wordpress, and I am trying to add multiple custom post types in the functions.php. </p> <p>Adding one cpt is fine. but if I use the same function to add the second cpt (with just a change of the function name), the second cpt doesn't show in the dashboard menu.</p> <p>Below are the codes. I would great...
[ { "answer_id": 300711, "author": "David Sword", "author_id": 132362, "author_profile": "https://wordpress.stackexchange.com/users/132362", "pm_score": 2, "selected": false, "text": "<p>Your snippet is missing</p>\n\n<pre><code>add_action('init', 'create_new_cpt2');\n</code></pre>\n" },...
2018/04/13
[ "https://wordpress.stackexchange.com/questions/300710", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/141736/" ]
I am new to wordpress, and I am trying to add multiple custom post types in the functions.php. Adding one cpt is fine. but if I use the same function to add the second cpt (with just a change of the function name), the second cpt doesn't show in the dashboard menu. Below are the codes. I would greatly appreciate hel...
Your snippet is missing ``` add_action('init', 'create_new_cpt2'); ```
300,736
<p>i'm working in android application that use wordpress rest api to get blog from website to , i don't have any knowledge about php or wordpress , but i take some time to learn about it , any way my problem is on the json .the content contain paragraphs unknown and i don't know how to solve this problem ,please help <...
[ { "answer_id": 300738, "author": "Mat", "author_id": 37985, "author_profile": "https://wordpress.stackexchange.com/users/37985", "pm_score": 3, "selected": true, "text": "<p>The content that you are referring to is coming from the Elegant Themes Page Builder plugin on that site.</p>\n\n<...
2018/04/13
[ "https://wordpress.stackexchange.com/questions/300736", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/140958/" ]
i'm working in android application that use wordpress rest api to get blog from website to , i don't have any knowledge about php or wordpress , but i take some time to learn about it , any way my problem is on the json .the content contain paragraphs unknown and i don't know how to solve this problem ,please help [![a...
The content that you are referring to is coming from the Elegant Themes Page Builder plugin on that site. The page builder uses [WordPress Shortcodes](https://codex.wordpress.org/shortcode) to render the content on the WordPress site. However, when you use the REST API, the content is pulled from the WordPress databas...
300,764
<p>There are two ways that WordPress updates translation files inside Languages folder: 1. Automatic updates whenever it gets triggered. 2. Manually when user requests it on "Updates" page.</p> <p>Is there a way to disable both of them, so no changes can apply to Languages folder?</p>
[ { "answer_id": 301821, "author": "Rahmat Baghdadi", "author_id": 131970, "author_profile": "https://wordpress.stackexchange.com/users/131970", "pm_score": 2, "selected": false, "text": "<p>I have this snippet that disables automatic translation update:</p>\n\n<pre><code>if( function_exis...
2018/04/14
[ "https://wordpress.stackexchange.com/questions/300764", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/131970/" ]
There are two ways that WordPress updates translation files inside Languages folder: 1. Automatic updates whenever it gets triggered. 2. Manually when user requests it on "Updates" page. Is there a way to disable both of them, so no changes can apply to Languages folder?
You've already given the answer using `auto_update_translation`. I wasn't aware this didn't work after manual updates (and haven't tried it) but perhaps also look at [async\_update\_translation](https://developer.wordpress.org/reference/hooks/async_update_translation/) which according the documentation *"Asynchronously...
300,776
<p>I try to find a way to get products ID by custom field in a category. I use this:</p> <pre><code>// Get the category $catsearched = $atts['category_id']; // Get all product of categoryselected $product_args = array( 'post_type' =&gt; 'product', 'post_status' =&gt; 'publish', 'posts_per_page' =&gt; -1, ...
[ { "answer_id": 333185, "author": "Bret Weinraub", "author_id": 70438, "author_profile": "https://wordpress.stackexchange.com/users/70438", "pm_score": 0, "selected": false, "text": "<p>This may help; this function returns a list of product where a custom field is set to any value.</p>\n\...
2018/04/14
[ "https://wordpress.stackexchange.com/questions/300776", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114157/" ]
I try to find a way to get products ID by custom field in a category. I use this: ``` // Get the category $catsearched = $atts['category_id']; // Get all product of categoryselected $product_args = array( 'post_type' => 'product', 'post_status' => 'publish', 'posts_per_page' => -1, 'fields' => 'ids', ...
``` $args = array( 'post_type' => 'product', 'meta_key' => 'YOUR_FIELD_ID', 'meta_value' => array('yes'), //'meta_value' => array('yes'), 'meta_compare' => 'IN' //'meta_compare' => 'NOT IN' ); $products = wc_get_products($args); foreach ($products as $product) { //do your logic } ```
300,807
<p>Is there a way to alter/change core <code>has_post_thumbnail</code> function?</p> <p>I need to check folder on server with images first before code looks for post image attachment.</p> <p>I see lots of filters to change image html but they either affect single post page or loop thumbnail and with woocommerce sever...
[ { "answer_id": 300811, "author": "Krzysiek Dróżdż", "author_id": 34172, "author_profile": "https://wordpress.stackexchange.com/users/34172", "pm_score": 2, "selected": false, "text": "<p>Yes, there is a way to do that... Let's take a look at <code>has_post_thumbnail</code> function itsel...
2018/04/15
[ "https://wordpress.stackexchange.com/questions/300807", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/125675/" ]
Is there a way to alter/change core `has_post_thumbnail` function? I need to check folder on server with images first before code looks for post image attachment. I see lots of filters to change image html but they either affect single post page or loop thumbnail and with woocommerce several other places plus admin t...
Yes, there is a way to do that... Let's take a look at `has_post_thumbnail` function itself: ``` function has_post_thumbnail( $post = null ) { return (bool) get_post_thumbnail_id( $post ); } ``` As you can see, all it really does is getting post thumbnail ID and checking if it exists. But there are no filters in...
300,857
<p>I am creating a single-page child theme, in which (apologies to the Wordpress community) I am basically trying to stay out of using PHP or the Wordpress API as much as possible, because I really just want to deploy a single page with its own scripts and style.</p> <p>I'm having problems with relative file paths. I ...
[ { "answer_id": 300860, "author": "rudtek", "author_id": 77767, "author_profile": "https://wordpress.stackexchange.com/users/77767", "pm_score": 1, "selected": false, "text": "<p>You should be using <code>get_stylesheet_directory_uri()</code>. This is the same function as <code>get_templ...
2018/04/15
[ "https://wordpress.stackexchange.com/questions/300857", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/141801/" ]
I am creating a single-page child theme, in which (apologies to the Wordpress community) I am basically trying to stay out of using PHP or the Wordpress API as much as possible, because I really just want to deploy a single page with its own scripts and style. I'm having problems with relative file paths. I have gathe...
Relative paths in CSS are relative to the stylesheet file. So if you have this structure: ``` - style.css - images/ -- logo.png -- background.jpg ``` Then the paths in CSS for the images would be `url(images/logo.png)` and `url(images/background.jpg)`. This is because the relative paths in CSS are relative to the st...
300,896
<p>I got a weird problem: First of all I provide my folder structure:</p> <pre><code> wp-content/themes/theme ├──content.php ├──footer.php ├──functions.php ├──header.php ├──home.php ├──index.php ├──page.php ├──main.js ├──style.css │ ├── media/ │ └── img/ │ ├─...
[ { "answer_id": 300897, "author": "wpdev", "author_id": 133897, "author_profile": "https://wordpress.stackexchange.com/users/133897", "pm_score": 0, "selected": false, "text": "<p>If you are using tag in any php file, just use <a href=\"https://developer.wordpress.org/reference/functions...
2018/04/16
[ "https://wordpress.stackexchange.com/questions/300896", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/141857/" ]
I got a weird problem: First of all I provide my folder structure: ``` wp-content/themes/theme ├──content.php ├──footer.php ├──functions.php ├──header.php ├──home.php ├──index.php ├──page.php ├──main.js ├──style.css │ ├── media/ │ └── img/ │ ├── beach.mp4 ...
Relative paths in css files are relative to the css file location, but in PHP they are relative to the website URL not to the php file location in the server. So to make sure you get the right URL for any resource you want to load in PHP files you can use the function [get\_template\_directory\_uri()](https://develope...
300,912
<p>I'm new to WordPress I want to add simple color picker in theme options.I tried but not getting can anyone suggest me? </p>
[ { "answer_id": 300916, "author": "Bhupen", "author_id": 128529, "author_profile": "https://wordpress.stackexchange.com/users/128529", "pm_score": 3, "selected": true, "text": "<p>Working code to set color customizer in wordpress theme settings:</p>\n\n<pre><code> function color_customiz...
2018/04/16
[ "https://wordpress.stackexchange.com/questions/300912", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/131806/" ]
I'm new to WordPress I want to add simple color picker in theme options.I tried but not getting can anyone suggest me?
Working code to set color customizer in wordpress theme settings: ``` function color_customizer($wp_customize){ $wp_customize->add_section( 'theme_colors_settings', array( 'title' => __( 'Theme Colors Settings', 'themeslug' ), 'priority' => 5, ) ); $theme_colors = array(); // Navigation B...
300,925
<p>For some reason I cant seem to enqueue external JS files. I can enqueue external css files but not the JS files. I have a custom theme using the bootstrap css frame work. My functions.php is as follows:</p> <pre><code>function add_css_scripts(){ wp_enqueue_style('boot-strap','https://stackpath.bootstrapcdn.com/...
[ { "answer_id": 300927, "author": "Abhik", "author_id": 26991, "author_profile": "https://wordpress.stackexchange.com/users/26991", "pm_score": 1, "selected": false, "text": "<p>Using external jQuery is a bad idea. The bundled one is optimized to work better with WordPress. </p>\n\n<p>Fo...
2018/04/16
[ "https://wordpress.stackexchange.com/questions/300925", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93537/" ]
For some reason I cant seem to enqueue external JS files. I can enqueue external css files but not the JS files. I have a custom theme using the bootstrap css frame work. My functions.php is as follows: ``` function add_css_scripts(){ wp_enqueue_style('boot-strap','https://stackpath.bootstrapcdn.com/bootstrap/4.1....
instead of using `get_template_directory_uri().'/assets/js/pre.js','1.0.0'` try using `get_theme_file_uri('/assets/js/pre.js','1.0.0')` It worked for me, for some reason when use `get_template_directory_uri()` you will get a 403 error
300,988
<p>maybe u can help to solve this problem. for example i have this link</p> <pre><code>https://direktoriku.com/shopping/?user= </code></pre> <p>and i want to add username after login, like <code>https://direktoriku.com/shopping/?user=admin</code></p> <p>I want to make it on button.</p> <pre><code>&lt;a href="https:...
[ { "answer_id": 300927, "author": "Abhik", "author_id": 26991, "author_profile": "https://wordpress.stackexchange.com/users/26991", "pm_score": 1, "selected": false, "text": "<p>Using external jQuery is a bad idea. The bundled one is optimized to work better with WordPress. </p>\n\n<p>Fo...
2018/04/17
[ "https://wordpress.stackexchange.com/questions/300988", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/141909/" ]
maybe u can help to solve this problem. for example i have this link ``` https://direktoriku.com/shopping/?user= ``` and i want to add username after login, like `https://direktoriku.com/shopping/?user=admin` I want to make it on button. ``` <a href="https://direktoriku.com/shopping/?user=username"> <button>Cl...
instead of using `get_template_directory_uri().'/assets/js/pre.js','1.0.0'` try using `get_theme_file_uri('/assets/js/pre.js','1.0.0')` It worked for me, for some reason when use `get_template_directory_uri()` you will get a 403 error
301,030
<p>I get 500 error on wp-json.</p> <p>if I try to <code>echo get_rest_url()</code> I get <code>example.com/wp-json</code>, which then gives me error 500. I added <code>RewriteCond %{REQUEST_URI} !^/wp-json</code> to my .htaccess, which gave me 404 error instead.</p> <p>I use postname as settings for permalinks. I've ...
[ { "answer_id": 308870, "author": "Tiago Aranha", "author_id": 137668, "author_profile": "https://wordpress.stackexchange.com/users/137668", "pm_score": -1, "selected": false, "text": "<p>Create a .htaccess file with</p>\n\n<pre><code># BEGIN WordPress\n&lt;IfModule mod_rewrite.c&gt;\nRew...
2018/04/17
[ "https://wordpress.stackexchange.com/questions/301030", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/134908/" ]
I get 500 error on wp-json. if I try to `echo get_rest_url()` I get `example.com/wp-json`, which then gives me error 500. I added `RewriteCond %{REQUEST_URI} !^/wp-json` to my .htaccess, which gave me 404 error instead. I use postname as settings for permalinks. I've tried `http://example.com/?rest_route=/wp-json/v2/...
Are you trying to use that function without first initiating it in an action? It should be done like so: ``` add_action( 'rest_api_init', 'add_custom_users_api'); function add_custom_users_api() { register_rest_route( 'route', array( 'methods' => 'GET', ...
301,048
<p>I've created a custom loop for posts, that works with Bootstrap, in which, I've added pagination - however it doesn't seem to be working. It just shows an empty button...</p> <pre><code>&lt;?php $args = array( 'post_type' =&gt; 'post', 'posts_per_page' =&gt; 1 ); $my_query = null; $my...
[ { "answer_id": 301050, "author": "NikHiL Gadhiya", "author_id": 136899, "author_profile": "https://wordpress.stackexchange.com/users/136899", "pm_score": 2, "selected": false, "text": "<p>only just use echo and get_</p>\n\n<pre><code>&lt;?php $args = array(\n 'post_type' =&gt; 'post'...
2018/04/17
[ "https://wordpress.stackexchange.com/questions/301048", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122279/" ]
I've created a custom loop for posts, that works with Bootstrap, in which, I've added pagination - however it doesn't seem to be working. It just shows an empty button... ``` <?php $args = array( 'post_type' => 'post', 'posts_per_page' => 1 ); $my_query = null; $my_query = new WP_Query($...
only just use echo and get\_ ``` <?php $args = array( 'post_type' => 'post', 'posts_per_page' => 1 ); $my_query = null; $my_query = new WP_Query($args); if( $my_query->have_posts() ) { $i = 0; while ($my_query->have_posts()) : $my_query->the_post(); if($i % 2 == 0) { ?> <div class="r...
301,051
<p>I am able to filter tags archives by adding a parameter like ?post_type=slug to the url and this works fine except for search results. I mean where the url contains a search term like:</p> <pre><code>site.com/?s=searched&amp;post_type=slug </code></pre> <p>How can i make the "&amp;post_type=slug" also work in this...
[ { "answer_id": 301054, "author": "Aurovrata", "author_id": 52120, "author_profile": "https://wordpress.stackexchange.com/users/52120", "pm_score": 0, "selected": false, "text": "<p>The <code>s=keyword</code> url parameter is by default used to <a href=\"https://codex.wordpress.org/Class_...
2018/04/17
[ "https://wordpress.stackexchange.com/questions/301051", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/77283/" ]
I am able to filter tags archives by adding a parameter like ?post\_type=slug to the url and this works fine except for search results. I mean where the url contains a search term like: ``` site.com/?s=searched&post_type=slug ``` How can i make the "&post\_type=slug" also work in this case? EDIT: It wasn't working ...
By all rights it should work, here's the same thing applied to my own site: tomjn.com/?s=talk&post\_type=tomjn\_talks vs tomjn.com/?s=talk . Something else is the problem Specifically, if you replace the main query with a `query_posts` call or a `WP_Query`, that query won't take into account parameters passed via the...
301,056
<p>I want to create a helper redirect function that looks like the following:</p> <pre><code>/** * Just an example of using redirect() */ public function validate_something() { if (1 == 0) { $this-&gt;redirect('register'); } } </code></pre> <p>However, on <code>public function redirect()</code>, I w...
[ { "answer_id": 301057, "author": "Oleg Butuzov", "author_id": 14536, "author_profile": "https://wordpress.stackexchange.com/users/14536", "pm_score": -1, "selected": false, "text": "<p>Add actions/filters in constructor method.</p>\n\n<pre><code>public function __construct(){\n add_act...
2018/04/17
[ "https://wordpress.stackexchange.com/questions/301056", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27278/" ]
I want to create a helper redirect function that looks like the following: ``` /** * Just an example of using redirect() */ public function validate_something() { if (1 == 0) { $this->redirect('register'); } } ``` However, on `public function redirect()`, I would like to use some functions that are...
The core problem is that you are not writing OOP. OOP is about identifying objects in your system, not actions. If you want to identify actions than you are better to follow functional design paradigms (and with wordpress hook system, functional design make much more sense). In your case redirect is an action, that pr...
301,067
<p><strong>What I tested</strong></p> <p><strong>Wordpress Version</strong>: 4.9.5</p> <p><strong>PHP Version</strong>: 7.1.7/7.1.4/7.2.0/7.0.3/5.6.20/5.5.38/5.4.45</p> <p><strong>Web Server</strong>: Nginx 1.10.1/Apache 2.4.10</p> <p><strong>Environment/Host</strong>: Flywheel local <a href="https://local.getflywh...
[ { "answer_id": 301076, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": true, "text": "<p>I got curious, so I tested this barebone demo:</p>\n\n<pre><code>add_action( 'rest_api_init', function () {\n ...
2018/04/17
[ "https://wordpress.stackexchange.com/questions/301067", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63445/" ]
**What I tested** **Wordpress Version**: 4.9.5 **PHP Version**: 7.1.7/7.1.4/7.2.0/7.0.3/5.6.20/5.5.38/5.4.45 **Web Server**: Nginx 1.10.1/Apache 2.4.10 **Environment/Host**: Flywheel local <https://local.getflywheel.com/> **PCRE Library Version**: 8.38 2015-11-23 I have been trying to work with `register_rest_rou...
I got curious, so I tested this barebone demo: ``` add_action( 'rest_api_init', function () { register_rest_route( 'wpse/v1', '/post_by_permalink/(?P<path>[\S]+)', [ 'methods' => WP_REST_Server::READABLE, 'callback' => 'wpse_callback', 'show_in_rest' => true ] ); }); function ...
301,152
<p>I've got an archive page for to display custom post types. </p> <p>Within the WP_Query that displays the custom posts types I want to display an ACF (Advanced Custom Field) or, if the user hasn't filled out the ACF, then the title should appear.</p> <p>I've tried this and the ACF field displays ok, but when it's n...
[ { "answer_id": 301153, "author": "Mat", "author_id": 37985, "author_profile": "https://wordpress.stackexchange.com/users/37985", "pm_score": 0, "selected": false, "text": "<p>If in doubt, check the documentation first: <a href=\"https://www.advancedcustomfields.com/resources/get_field/\"...
2018/04/18
[ "https://wordpress.stackexchange.com/questions/301152", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/76109/" ]
I've got an archive page for to display custom post types. Within the WP\_Query that displays the custom posts types I want to display an ACF (Advanced Custom Field) or, if the user hasn't filled out the ACF, then the title should appear. I've tried this and the ACF field displays ok, but when it's not filled out, t...
If in doubt, check the documentation first: <https://www.advancedcustomfields.com/resources/get_field/> **Check if value exists** This example shows how to check if a value exists for a field. ``` $value = get_field( 'text_field' ); if ( $value ) { echo $value; } else { echo 'empty'; } ``` So, in for your...
301,172
<p>My Wordpress website is often going down with the error message "error establishing a database connection" and when I contacted my hosting server, they replied that the query takes a long time(more than 25 sec) and killed the database connection. So that they asked to optimize the wp_option table. Kindly guide me to...
[ { "answer_id": 301153, "author": "Mat", "author_id": 37985, "author_profile": "https://wordpress.stackexchange.com/users/37985", "pm_score": 0, "selected": false, "text": "<p>If in doubt, check the documentation first: <a href=\"https://www.advancedcustomfields.com/resources/get_field/\"...
2018/04/18
[ "https://wordpress.stackexchange.com/questions/301172", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119805/" ]
My Wordpress website is often going down with the error message "error establishing a database connection" and when I contacted my hosting server, they replied that the query takes a long time(more than 25 sec) and killed the database connection. So that they asked to optimize the wp\_option table. Kindly guide me to o...
If in doubt, check the documentation first: <https://www.advancedcustomfields.com/resources/get_field/> **Check if value exists** This example shows how to check if a value exists for a field. ``` $value = get_field( 'text_field' ); if ( $value ) { echo $value; } else { echo 'empty'; } ``` So, in for your...
301,176
<p>I was wondering if you can change "the type" of a wordpress custom post type. So: when I create a custom post type to somehow remove the post list:<img src="https://i.stack.imgur.com/3Bipq.jpg" alt="enter image description here"> and jump directly to the edit page...</p> <p>I am trying to do this because I got a se...
[ { "answer_id": 301153, "author": "Mat", "author_id": 37985, "author_profile": "https://wordpress.stackexchange.com/users/37985", "pm_score": 0, "selected": false, "text": "<p>If in doubt, check the documentation first: <a href=\"https://www.advancedcustomfields.com/resources/get_field/\"...
2018/04/18
[ "https://wordpress.stackexchange.com/questions/301176", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/141857/" ]
I was wondering if you can change "the type" of a wordpress custom post type. So: when I create a custom post type to somehow remove the post list:![enter image description here](https://i.stack.imgur.com/3Bipq.jpg) and jump directly to the edit page... I am trying to do this because I got a section on my page where a...
If in doubt, check the documentation first: <https://www.advancedcustomfields.com/resources/get_field/> **Check if value exists** This example shows how to check if a value exists for a field. ``` $value = get_field( 'text_field' ); if ( $value ) { echo $value; } else { echo 'empty'; } ``` So, in for your...
301,183
<p>I need for a specific plugin to override the wordpress function <code>get_avatar()</code> to bind the profile image to an other image with some condition.</p> <p>How can I do this ? Is there a specific hook or filter to do this ?</p>
[ { "answer_id": 301153, "author": "Mat", "author_id": 37985, "author_profile": "https://wordpress.stackexchange.com/users/37985", "pm_score": 0, "selected": false, "text": "<p>If in doubt, check the documentation first: <a href=\"https://www.advancedcustomfields.com/resources/get_field/\"...
2018/04/18
[ "https://wordpress.stackexchange.com/questions/301183", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/128094/" ]
I need for a specific plugin to override the wordpress function `get_avatar()` to bind the profile image to an other image with some condition. How can I do this ? Is there a specific hook or filter to do this ?
If in doubt, check the documentation first: <https://www.advancedcustomfields.com/resources/get_field/> **Check if value exists** This example shows how to check if a value exists for a field. ``` $value = get_field( 'text_field' ); if ( $value ) { echo $value; } else { echo 'empty'; } ``` So, in for your...
301,188
<p>I am trying to create a function which either deletes all the postmeta with the meta_key "bakground-video", or edits the meta_value to empty it from the values. There might be multiple postmeta with the meta_key "background-video" and I want the function to run on all of them.</p> <p>I will use this function on a m...
[ { "answer_id": 301192, "author": "Pat J", "author_id": 16121, "author_profile": "https://wordpress.stackexchange.com/users/16121", "pm_score": 1, "selected": true, "text": "<p>Untested, but this might be what you're looking for:</p>\n\n<pre><code>$args = array( 'fields' =&gt; 'i...
2018/04/18
[ "https://wordpress.stackexchange.com/questions/301188", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/138051/" ]
I am trying to create a function which either deletes all the postmeta with the meta\_key "bakground-video", or edits the meta\_value to empty it from the values. There might be multiple postmeta with the meta\_key "background-video" and I want the function to run on all of them. I will use this function on a multisit...
Untested, but this might be what you're looking for: ``` $args = array( 'fields' => 'ids', 'posts_per_page' => -1, 'post_type' => 'attachment', 'meta_key' => 'background-video' ); $all_ids = new WP_Query( $args ); if ( $all_ids->have_po...
301,190
<p>I want a function to check if the comment id has children (replies) or not.</p>
[ { "answer_id": 301195, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 4, "selected": true, "text": "<p>Here's one example how to construct such a custom function:</p>\n\n<pre><code>/**\n * Check if a comment has c...
2018/04/18
[ "https://wordpress.stackexchange.com/questions/301190", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/138795/" ]
I want a function to check if the comment id has children (replies) or not.
Here's one example how to construct such a custom function: ``` /** * Check if a comment has children. * * @param int $comment_id Comment ID * @return bool Has comment children. */ function has_comment_children_wpse( $comment_id ) { return get_comments( [ 'parent' => $comment_id, 'count' => true ]...
301,222
<p>Where could I find a framework for a homepage where I can have an HTML video stretched all the way across (to a certain max resolution would be fine, like max-width: 2500px or something)?</p> <p>I am using a TwentyTwelve theme I customized. All I need is a top header bar for logo and nav (100px tall) and a footer ...
[ { "answer_id": 301195, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 4, "selected": true, "text": "<p>Here's one example how to construct such a custom function:</p>\n\n<pre><code>/**\n * Check if a comment has c...
2018/04/19
[ "https://wordpress.stackexchange.com/questions/301222", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31630/" ]
Where could I find a framework for a homepage where I can have an HTML video stretched all the way across (to a certain max resolution would be fine, like max-width: 2500px or something)? I am using a TwentyTwelve theme I customized. All I need is a top header bar for logo and nav (100px tall) and a footer of the same...
Here's one example how to construct such a custom function: ``` /** * Check if a comment has children. * * @param int $comment_id Comment ID * @return bool Has comment children. */ function has_comment_children_wpse( $comment_id ) { return get_comments( [ 'parent' => $comment_id, 'count' => true ]...
301,239
<p>[<strong>Edited</strong>]</p> <p>I changed the purpose of my site into an language learning site.</p> <p>Now the CPT is setup as following:</p> <p><strong>{ Language } - { Subject }</strong></p> <ul> <li>English speaking (slug: english-speaking )</li> <li>English writing (english-writing )</li> <li>English readi...
[ { "answer_id": 301195, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 4, "selected": true, "text": "<p>Here's one example how to construct such a custom function:</p>\n\n<pre><code>/**\n * Check if a comment has c...
2018/04/19
[ "https://wordpress.stackexchange.com/questions/301239", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/137035/" ]
[**Edited**] I changed the purpose of my site into an language learning site. Now the CPT is setup as following: **{ Language } - { Subject }** * English speaking (slug: english-speaking ) * English writing (english-writing ) * English reading ( english-speaking ) * English writing (english-writing) --- **Single ...
Here's one example how to construct such a custom function: ``` /** * Check if a comment has children. * * @param int $comment_id Comment ID * @return bool Has comment children. */ function has_comment_children_wpse( $comment_id ) { return get_comments( [ 'parent' => $comment_id, 'count' => true ]...
301,255
<p>I realise this is perhaps more of a php question, but it relates to WP use.</p> <p>Can the example below, be modified (and if so, how?) to fully concatenate the 2 echos rather than having them separate?</p> <pre><code>if... { echo '&lt;p&gt;', get_template_part( 'templates/xxx' ); echo '&lt;/p&gt;'; } </code></pre...
[ { "answer_id": 301257, "author": "mmm", "author_id": 74311, "author_profile": "https://wordpress.stackexchange.com/users/74311", "pm_score": 2, "selected": true, "text": "<p>this is more a PHP question </p>\n\n<p>you can try these folowing forms : </p>\n\n<pre><code>if (...) {\n echo ...
2018/04/19
[ "https://wordpress.stackexchange.com/questions/301255", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103213/" ]
I realise this is perhaps more of a php question, but it relates to WP use. Can the example below, be modified (and if so, how?) to fully concatenate the 2 echos rather than having them separate? ``` if... { echo '<p>', get_template_part( 'templates/xxx' ); echo '</p>'; } ```
this is more a PHP question you can try these folowing forms : ``` if (...) { echo '<p>'; get_template_part('templates/xxx'); echo '</p>'; } ``` or ``` if (...) { ?> <p> <?php get_template_part('templates/xxx'); ?> </p> <?php } ```
301,281
<p>I am trying to display WooCommerce products in custom loop. This is my code:</p> <pre><code>&lt;?php $args = array( 'post_type' =&gt; 'product', 'posts_per_page' =&gt; 6, 'product_cat' =&gt; 'apparel', 'orderby' =&gt; 'date' ); $loop = new WP_Query( $args ); while ( $loop-&gt;have_posts() ) : $loop-&gt;the_p...
[ { "answer_id": 301340, "author": "Dharmishtha Patel", "author_id": 135085, "author_profile": "https://wordpress.stackexchange.com/users/135085", "pm_score": 4, "selected": true, "text": "<pre><code>&lt;ul class=\"products\"&gt;\n &lt;?php\n $args = array(\n 'post_typ...
2018/04/19
[ "https://wordpress.stackexchange.com/questions/301281", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/137372/" ]
I am trying to display WooCommerce products in custom loop. This is my code: ``` <?php $args = array( 'post_type' => 'product', 'posts_per_page' => 6, 'product_cat' => 'apparel', 'orderby' => 'date' ); $loop = new WP_Query( $args ); while ( $loop->have_posts() ) : $loop->the_post(); global $product; ?> <div ...
``` <ul class="products"> <?php $args = array( 'post_type' => 'product', 'posts_per_page' => 12 ); $loop = new WP_Query( $args ); if ( $loop->have_posts() ) { while ( $loop->have_posts() ) : $loop->the_post(); wc_get_template_pa...
301,282
<p>I currently use this code in the main plugins file itself. But that plugin is not my own so I would prefer to be able to upgrade it normally without every time adding this code.</p> <pre><code>if ( defined( 'WP_CLI' ) &amp;&amp; WP_CLI ) { exit; } </code></pre> <p>I need to do this because this plugin produces...
[ { "answer_id": 301286, "author": "Jacob Peattie", "author_id": 39152, "author_profile": "https://wordpress.stackexchange.com/users/39152", "pm_score": 5, "selected": true, "text": "<p>One of the first things WordPress does to load plugins is get the active plugins as saved in the databas...
2018/04/19
[ "https://wordpress.stackexchange.com/questions/301282", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38602/" ]
I currently use this code in the main plugins file itself. But that plugin is not my own so I would prefer to be able to upgrade it normally without every time adding this code. ``` if ( defined( 'WP_CLI' ) && WP_CLI ) { exit; } ``` I need to do this because this plugin produces errors and stops wp-cli to execut...
One of the first things WordPress does to load plugins is get the active plugins as saved in the database: ``` $active_plugins = (array) get_option( 'active_plugins', array() ); ``` Since it uses `get_option()` we can use the [`option_active_plugins`](https://developer.wordpress.org/reference/hooks/option_option/) f...
301,306
<p>I have uploaded a file called page-testtest.php to my template folder. Aren't I supposed to get to this file when I go to <strong>example.com/testtest</strong></p> <p>It seems very strange to me because the documentation clearly states that I should go to that file without any struggle. Instead I get "Oops! That pa...
[ { "answer_id": 301308, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 0, "selected": false, "text": "<p>Just creating the theme template doesn't create the Page itself. You'll also need to create the Page - ty...
2018/04/19
[ "https://wordpress.stackexchange.com/questions/301306", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/125637/" ]
I have uploaded a file called page-testtest.php to my template folder. Aren't I supposed to get to this file when I go to **example.com/testtest** It seems very strange to me because the documentation clearly states that I should go to that file without any struggle. Instead I get "Oops! That page can’t be found." By...
A template is not a page you can load directly. A template is used for the formatting ('building') of a 'page' (created via Page, Add) or 'post' (created via Post, Add). On that page/post editing page, there is a place to specify the template that the WP will use when the page is output. There are default templates u...
301,392
<p>my wordpress shows the wrong time, <a href="https://i.stack.imgur.com/hTOhO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hTOhO.jpg" alt="enter image description here"></a></p> <p>UTC time on the picture should be 18:06:28 and localtime 15:06:28, so the UTC time is showed as local time, I use m...
[ { "answer_id": 301400, "author": "atempel", "author_id": 132268, "author_profile": "https://wordpress.stackexchange.com/users/132268", "pm_score": 2, "selected": false, "text": "<p>This might be a solution for you:\n<a href=\"https://wordpress.org/support/topic/utc-time-and-local-time-pr...
2018/04/20
[ "https://wordpress.stackexchange.com/questions/301392", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/142149/" ]
my wordpress shows the wrong time, [![enter image description here](https://i.stack.imgur.com/hTOhO.jpg)](https://i.stack.imgur.com/hTOhO.jpg) UTC time on the picture should be 18:06:28 and localtime 15:06:28, so the UTC time is showed as local time, I use my own vps on digital ocean and time zone is correct, ``` ls ...
This might be a solution for you: <https://wordpress.org/support/topic/utc-time-and-local-time-problems/> It says that it's a problem with PHP config, not Wordpress. (Bringing the solution here for ease of reference) 1. If you have shell access, do you get the correct date/time when you type “date” at the command li...
301,413
<p>I need to programmatically create a page that uses a specific/custom template as defined programmatically. Both the page and template are created/used by my plugin.</p> <p>The plugin files include a page template. The plugin code (with a button press) will create the page ('mycustompage') (similar to the technique ...
[ { "answer_id": 301476, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": -1, "selected": false, "text": "<p>I'm going to ignore your attempted solution and address the original problem:</p>\n\n<p><strong><em>Emoji a...
2018/04/20
[ "https://wordpress.stackexchange.com/questions/301413", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29416/" ]
I need to programmatically create a page that uses a specific/custom template as defined programmatically. Both the page and template are created/used by my plugin. The plugin files include a page template. The plugin code (with a button press) will create the page ('mycustompage') (similar to the technique here [Add ...
The question was about how to use a template that is not in the theme's folder, but in a plugin's folder. The template needs to be used for a specific page. The need for the answer doesn't matter. There is a need; how do I do it? And the answer is to use the `template_include` filter (see [here](https://codex.wordpres...
301,426
<p>I want to remove the link from the date, this link leads to archiving. I'd be happy to get help - thank you very much</p> <p><a href="https://i.stack.imgur.com/Oh03C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Oh03C.png" alt="Attached picture"></a></p>
[ { "answer_id": 301427, "author": "Munish Kumar", "author_id": 142176, "author_profile": "https://wordpress.stackexchange.com/users/142176", "pm_score": 2, "selected": true, "text": "<p>I don't know which theme your are using, I am explaining you same thing for twenty seventeen theme, go ...
2018/04/21
[ "https://wordpress.stackexchange.com/questions/301426", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/142174/" ]
I want to remove the link from the date, this link leads to archiving. I'd be happy to get help - thank you very much [![Attached picture](https://i.stack.imgur.com/Oh03C.png)](https://i.stack.imgur.com/Oh03C.png)
I don't know which theme your are using, I am explaining you same thing for twenty seventeen theme, go to wp-content\themes\twentyseventeen\inc\template-tags.php, You will find function twentyseventeen\_time\_link() there. In this function you will get code as like ``` return sprintf( /* translators: %s: po...
301,438
<p>I have made two dropdown list which is a custom fields.</p> <p><strong>Custom Field 1</strong> :- industry </p> <p><strong>Values of Custom Field 1</strong> :- financial_services,ecommerce,insurances, etc.</p> <p><strong>Custom Field 2</strong> :- primary_functionality</p> <p><strong>Values of Custom Field 2</st...
[ { "answer_id": 301427, "author": "Munish Kumar", "author_id": 142176, "author_profile": "https://wordpress.stackexchange.com/users/142176", "pm_score": 2, "selected": true, "text": "<p>I don't know which theme your are using, I am explaining you same thing for twenty seventeen theme, go ...
2018/04/21
[ "https://wordpress.stackexchange.com/questions/301438", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103292/" ]
I have made two dropdown list which is a custom fields. **Custom Field 1** :- industry **Values of Custom Field 1** :- financial\_services,ecommerce,insurances, etc. **Custom Field 2** :- primary\_functionality **Values of Custom Field 2** :- platform\_decision\_engine,user\_authentication,data\_provider\_verifica...
I don't know which theme your are using, I am explaining you same thing for twenty seventeen theme, go to wp-content\themes\twentyseventeen\inc\template-tags.php, You will find function twentyseventeen\_time\_link() there. In this function you will get code as like ``` return sprintf( /* translators: %s: po...
301,484
<p>I have this line of code : </p> <pre><code> $out .= get_the_post_thumbnail('', '', array( 'alt' =&gt; the_title_attribute (array('echo' =&gt; 0) ), 'class' =&gt; 'img-responsive', 'srcset' =&gt; get_the_post_thumbnail_url( "xs" ) ) ); </code></pre> <p>Which is wrong (in respect to the srcset attribute i...
[ { "answer_id": 301488, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p><code>wp_get_attachment_image_srcset</code> is the key here:</p>\n\n<pre><code>wp_get_attachment_image_srcse...
2018/04/22
[ "https://wordpress.stackexchange.com/questions/301484", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/142209/" ]
I have this line of code : ``` $out .= get_the_post_thumbnail('', '', array( 'alt' => the_title_attribute (array('echo' => 0) ), 'class' => 'img-responsive', 'srcset' => get_the_post_thumbnail_url( "xs" ) ) ); ``` Which is wrong (in respect to the srcset attribute implementation) I'm trying to add srcse...
`wp_get_attachment_image_srcset` is the key here: ``` wp_get_attachment_image_srcset( int $attachment_id, array|string $size = 'medium', array $image_meta = null ) ``` I believe the missing information you lack, is that post thumbnails are actually an attachment ID. In combination with `get_post_thumbnail_id` you sh...
301,522
<p><strong>Hello Guys</strong></p> <p>I have a running business website for a company that have a lot of plugins and user database ext... The issue that we want to create a fresh WordPress installation + a totally new theme , we need to edit the new theme then import all database including users/posts/comments after ...
[ { "answer_id": 301488, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p><code>wp_get_attachment_image_srcset</code> is the key here:</p>\n\n<pre><code>wp_get_attachment_image_srcse...
2018/04/22
[ "https://wordpress.stackexchange.com/questions/301522", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/142241/" ]
**Hello Guys** I have a running business website for a company that have a lot of plugins and user database ext... The issue that we want to create a fresh WordPress installation + a totally new theme , we need to edit the new theme then import all database including users/posts/comments after that put the new templa...
`wp_get_attachment_image_srcset` is the key here: ``` wp_get_attachment_image_srcset( int $attachment_id, array|string $size = 'medium', array $image_meta = null ) ``` I believe the missing information you lack, is that post thumbnails are actually an attachment ID. In combination with `get_post_thumbnail_id` you sh...
301,538
<p>I am trying to use a simple <code>publish_post / publish_page</code> hook to get the URL of the post/page when it is either published or updated so I can later turn it into a static page.</p> <p>Is it possible to add this hook outside of the theme functions.php file, because this is far more preferable to me? I als...
[ { "answer_id": 301488, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p><code>wp_get_attachment_image_srcset</code> is the key here:</p>\n\n<pre><code>wp_get_attachment_image_srcse...
2018/04/23
[ "https://wordpress.stackexchange.com/questions/301538", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/142252/" ]
I am trying to use a simple `publish_post / publish_page` hook to get the URL of the post/page when it is either published or updated so I can later turn it into a static page. Is it possible to add this hook outside of the theme functions.php file, because this is far more preferable to me? I also am unsure how to gr...
`wp_get_attachment_image_srcset` is the key here: ``` wp_get_attachment_image_srcset( int $attachment_id, array|string $size = 'medium', array $image_meta = null ) ``` I believe the missing information you lack, is that post thumbnails are actually an attachment ID. In combination with `get_post_thumbnail_id` you sh...
301,540
<p>Thank you in advance,</p> <p>I know that if you want to edit the appearence of the search page there is search.php file that you can mess with.</p> <p>I am using TOTAL theme in wordpress, I have decided to customize the themes POSTS page appearance completely, I did inspect element to look and tried matching the c...
[ { "answer_id": 301488, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p><code>wp_get_attachment_image_srcset</code> is the key here:</p>\n\n<pre><code>wp_get_attachment_image_srcse...
2018/04/23
[ "https://wordpress.stackexchange.com/questions/301540", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/125422/" ]
Thank you in advance, I know that if you want to edit the appearence of the search page there is search.php file that you can mess with. I am using TOTAL theme in wordpress, I have decided to customize the themes POSTS page appearance completely, I did inspect element to look and tried matching the code with themes f...
`wp_get_attachment_image_srcset` is the key here: ``` wp_get_attachment_image_srcset( int $attachment_id, array|string $size = 'medium', array $image_meta = null ) ``` I believe the missing information you lack, is that post thumbnails are actually an attachment ID. In combination with `get_post_thumbnail_id` you sh...
301,593
<p>I am trying to build a query that returns all posts, with a meta value that exists in a set of values.</p> <p>My posts have a meta key called <code>Asin_unique</code> and I want to find all posts, that have the value <code>B006MWDNVI</code>,<code>B00BCMCIS2</code>, or <code>B01ARRJFGA</code> in this field.</p> <p>...
[ { "answer_id": 301597, "author": "Munish Kumar", "author_id": 142176, "author_profile": "https://wordpress.stackexchange.com/users/142176", "pm_score": 2, "selected": false, "text": "<p>Check This Will Work for you.</p>\n\n<pre><code>$args = array(\n 'post_status' =&gt; 'any',\n '...
2018/04/23
[ "https://wordpress.stackexchange.com/questions/301593", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118091/" ]
I am trying to build a query that returns all posts, with a meta value that exists in a set of values. My posts have a meta key called `Asin_unique` and I want to find all posts, that have the value `B006MWDNVI`,`B00BCMCIS2`, or `B01ARRJFGA` in this field. This is what I have built so far, but it only returns me the ...
Check This Will Work for you. ``` $args = array( 'post_status' => 'any', 'post_type' => 'any', 'numberposts' => -1, 'meta_query' => array( array( 'key' => 'Asin_unique', 'value' => array('B006MWDNVI','B00BCMCIS2','B01ARRJFGA'), 'compare' => 'IN', ...
301,621
<p>Despite using;</p> <pre><code>$mysqli = new mysqli("localhost", "user", "pass", "db"); $mysqli-&gt;query('SET SQL_BIG_SELECTS = 1'); $mysqli-&gt;query('SET MAX_JOIN_SIZE = 999'); $the_query = new WP_Query( $args ); </code></pre> <p>I'm receiving;</p> <blockquote> <p>[23-Apr-2018 14:37:31 UTC] WordPress datab...
[ { "answer_id": 301597, "author": "Munish Kumar", "author_id": 142176, "author_profile": "https://wordpress.stackexchange.com/users/142176", "pm_score": 2, "selected": false, "text": "<p>Check This Will Work for you.</p>\n\n<pre><code>$args = array(\n 'post_status' =&gt; 'any',\n '...
2018/04/23
[ "https://wordpress.stackexchange.com/questions/301621", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/134867/" ]
Despite using; ``` $mysqli = new mysqli("localhost", "user", "pass", "db"); $mysqli->query('SET SQL_BIG_SELECTS = 1'); $mysqli->query('SET MAX_JOIN_SIZE = 999'); $the_query = new WP_Query( $args ); ``` I'm receiving; > > [23-Apr-2018 14:37:31 UTC] WordPress database error > The SELECT would examine more than M...
Check This Will Work for you. ``` $args = array( 'post_status' => 'any', 'post_type' => 'any', 'numberposts' => -1, 'meta_query' => array( array( 'key' => 'Asin_unique', 'value' => array('B006MWDNVI','B00BCMCIS2','B01ARRJFGA'), 'compare' => 'IN', ...
301,647
<p>As an example, my site is <code>mysite.com</code></p> <p>I want <code>mysite.com/wordpress_plugins</code> to return the output of <code>get_plugins()</code> from <a href="https://codex.wordpress.org/Function_Reference/get_plugins" rel="nofollow noreferrer">https://codex.wordpress.org/Function_Reference/get_plugins<...
[ { "answer_id": 301597, "author": "Munish Kumar", "author_id": 142176, "author_profile": "https://wordpress.stackexchange.com/users/142176", "pm_score": 2, "selected": false, "text": "<p>Check This Will Work for you.</p>\n\n<pre><code>$args = array(\n 'post_status' =&gt; 'any',\n '...
2018/04/23
[ "https://wordpress.stackexchange.com/questions/301647", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/139891/" ]
As an example, my site is `mysite.com` I want `mysite.com/wordpress_plugins` to return the output of `get_plugins()` from <https://codex.wordpress.org/Function_Reference/get_plugins> How can I do this?
Check This Will Work for you. ``` $args = array( 'post_status' => 'any', 'post_type' => 'any', 'numberposts' => -1, 'meta_query' => array( array( 'key' => 'Asin_unique', 'value' => array('B006MWDNVI','B00BCMCIS2','B01ARRJFGA'), 'compare' => 'IN', ...
301,649
<p>What is the secure way to use wp_get_attachment_image() in a template?</p>
[ { "answer_id": 301650, "author": "Levi Dulstein", "author_id": 101988, "author_profile": "https://wordpress.stackexchange.com/users/101988", "pm_score": 3, "selected": true, "text": "<p>Running the output through escaping function should be just fine.\nYou can either use <code>wp_kses_po...
2018/04/23
[ "https://wordpress.stackexchange.com/questions/301649", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59289/" ]
What is the secure way to use wp\_get\_attachment\_image() in a template?
Running the output through escaping function should be just fine. You can either use `wp_kses_post()`, which by default allows the same html attributes that you would use in the post content ([see in code reference](https://developer.wordpress.org/reference/functions/wp_kses_post/)): ``` echo wp_kses_post( wp_get_atta...
301,670
<p>I have an existing website with pages like:</p> <pre><code>http://www.website.come/page1.htm http://www.website.come/page2.htm http://www.website.come/page3.htm </code></pre> <p>etc.</p> <p>And I have redesigned my website in WordPress that has links like:</p> <pre><code>http://www.website.come/page1/ http://www...
[ { "answer_id": 301672, "author": "ssk8323", "author_id": 142341, "author_profile": "https://wordpress.stackexchange.com/users/142341", "pm_score": 1, "selected": false, "text": "<p>Sorry for incomplete answer,\nUse the 301 redirects.\nThis link give an idea about redirects <a href=\"http...
2018/04/24
[ "https://wordpress.stackexchange.com/questions/301670", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/142337/" ]
I have an existing website with pages like: ``` http://www.website.come/page1.htm http://www.website.come/page2.htm http://www.website.come/page3.htm ``` etc. And I have redesigned my website in WordPress that has links like: ``` http://www.website.come/page1/ http://www.website.come/page2/ http://www.website.come...
Sorry for incomplete answer, Use the 301 redirects. This link give an idea about redirects <https://moz.com/learn/seo/redirection> <https://wordpress.org/plugins/simple-301-redirects/> For the wordpres there are free good plugins for add *html / htm* extension to urls. This for - "*.html*" <https://wordpress.org/plu...
301,675
<p>I am new to plugin develop and I have a problem with settings page of my new plugin.</p> <p>My page seems to save correctly settings data to wordpress database, but after a few hours/days value stored on database disappear.</p> <p>the code of the main page of the plugin is:</p> <pre><code>//security defined( 'ABS...
[ { "answer_id": 301672, "author": "ssk8323", "author_id": 142341, "author_profile": "https://wordpress.stackexchange.com/users/142341", "pm_score": 1, "selected": false, "text": "<p>Sorry for incomplete answer,\nUse the 301 redirects.\nThis link give an idea about redirects <a href=\"http...
2018/04/24
[ "https://wordpress.stackexchange.com/questions/301675", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/142301/" ]
I am new to plugin develop and I have a problem with settings page of my new plugin. My page seems to save correctly settings data to wordpress database, but after a few hours/days value stored on database disappear. the code of the main page of the plugin is: ``` //security defined( 'ABSPATH' ) or die( 'No script k...
Sorry for incomplete answer, Use the 301 redirects. This link give an idea about redirects <https://moz.com/learn/seo/redirection> <https://wordpress.org/plugins/simple-301-redirects/> For the wordpres there are free good plugins for add *html / htm* extension to urls. This for - "*.html*" <https://wordpress.org/plu...
301,687
<p>I have been to trying to add one more column of mobile number field in the account page of a user in admin. So i found this good looking code from </p> <p><a href="https://coderwall.com/p/g72jfg/adding-a-phone-numer-field-to-wordpress-user-profile" rel="nofollow noreferrer">https://coderwall.com/p/g72jfg/adding-a-p...
[ { "answer_id": 302224, "author": "user141080", "author_id": 141080, "author_profile": "https://wordpress.stackexchange.com/users/141080", "pm_score": 3, "selected": true, "text": "<p>i built an small/simple example and i hope it will help you.</p>\n\n<p><strong>Admin dashboard widget wit...
2018/04/24
[ "https://wordpress.stackexchange.com/questions/301687", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/129972/" ]
I have been to trying to add one more column of mobile number field in the account page of a user in admin. So i found this good looking code from <https://coderwall.com/p/g72jfg/adding-a-phone-numer-field-to-wordpress-user-profile> Now what i am trying to do, is to build a custom widget for the dashboard so that th...
i built an small/simple example and i hope it will help you. **Admin dashboard widget with an save button** [![Admin dashboard widget with an save button](https://i.stack.imgur.com/WZjxz.png)](https://i.stack.imgur.com/WZjxz.png) First, we register a function which tells wordpress that we want to create an admin das...
301,706
<p>I'm using custom instances of <code>wp_editor();</code> to allow rich text editing of Post Meta associated with a Post Object.</p> <p>I'd like to perform much of the same sanitization that occurs with <code>post_content</code> for the values of these fields.</p> <p><strong>Here's what I've come up with:</strong></...
[ { "answer_id": 301717, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 3, "selected": true, "text": "<p><code>wp_kses</code> to the rescue!</p>\n\n<h2>My Editor Contains everything a Post Might</h2>\n\n<p>Pass the...
2018/04/24
[ "https://wordpress.stackexchange.com/questions/301706", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/9579/" ]
I'm using custom instances of `wp_editor();` to allow rich text editing of Post Meta associated with a Post Object. I'd like to perform much of the same sanitization that occurs with `post_content` for the values of these fields. **Here's what I've come up with:** > > Please let me know if this is an okay approach,...
`wp_kses` to the rescue! My Editor Contains everything a Post Might ------------------------------------------ Pass the result through `wp_kses_post` on the way in and out, and all should be good. Remember, this will strip out anything added by `the_content` filter, so to preserve oembeds and shortcodes, use this: ...
301,710
<p>I’m lost I don’t know where to turn.</p> <p>I am trying to get my thumbnails to NOT be compressed at all. My uploads are nice and colorful, but the thumbnails gets very visibly duller and poorer quality. I already added this code to my function.php file in my child and parent theme:</p> <pre><code>add_filter(‘jpeg...
[ { "answer_id": 301711, "author": "robwatson_dev", "author_id": 137115, "author_profile": "https://wordpress.stackexchange.com/users/137115", "pm_score": 2, "selected": false, "text": "<p>Uninstall the plugin and add this to your functions.php file</p>\n\n<pre><code>add_filter('jpeg_quali...
2018/04/24
[ "https://wordpress.stackexchange.com/questions/301710", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/142379/" ]
I’m lost I don’t know where to turn. I am trying to get my thumbnails to NOT be compressed at all. My uploads are nice and colorful, but the thumbnails gets very visibly duller and poorer quality. I already added this code to my function.php file in my child and parent theme: ``` add_filter(‘jpeg_quality’, function($...
Uninstall the plugin and add this to your functions.php file ``` add_filter('jpeg_quality', function($arg){return 100;}); add_filter( 'wp_editor_set_quality', function($arg){return 100;} ); ``` However please be aware that . you should still compress you images prior to uploading them for the performance enhancement...
301,721
<pre><code>// Creates the function function my_custom_javascript() { // Loads the script into the function wp_enqueue_scripts('my_custom_javascript', plugin_dir_url(__FILE__) . '/assets/js/custom.js', array('jquery')); } // calls the function where the script is located add_action('wp_enqueue_scripts', 'my_custom...
[ { "answer_id": 301724, "author": "Pat J", "author_id": 16121, "author_profile": "https://wordpress.stackexchange.com/users/16121", "pm_score": 2, "selected": false, "text": "<p>You're using the function <a href=\"https://developer.wordpress.org/reference/functions/wp_enqueue_scripts/\" r...
2018/04/24
[ "https://wordpress.stackexchange.com/questions/301721", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/142388/" ]
``` // Creates the function function my_custom_javascript() { // Loads the script into the function wp_enqueue_scripts('my_custom_javascript', plugin_dir_url(__FILE__) . '/assets/js/custom.js', array('jquery')); } // calls the function where the script is located add_action('wp_enqueue_scripts', 'my_custom_javasc...
You're using the function [`wp_enqueue_scripts()`](https://developer.wordpress.org/reference/functions/wp_enqueue_scripts/) where you should be using **[`wp_enqueue_script()`](https://developer.wordpress.org/reference/functions/wp_enqueue_script/)**. ``` function my_custom_javascript(){ // Creates the function wp_...
301,729
<p>When WooCoomerce updated to version 3.3, the 'Uncategorized' product category was added and then appeared on all pages (including the WooCommerce shop page) where products were displayed if there are any products with. All products that do not have at least one assigned category is then then (logically I guess) assi...
[ { "answer_id": 301731, "author": "Clinton", "author_id": 122375, "author_profile": "https://wordpress.stackexchange.com/users/122375", "pm_score": 4, "selected": true, "text": "<p>I solved this problem based on code kindly provided by rynoldos (<a href=\"https://gist.github.com/rynaldos/...
2018/04/24
[ "https://wordpress.stackexchange.com/questions/301729", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/129826/" ]
When WooCoomerce updated to version 3.3, the 'Uncategorized' product category was added and then appeared on all pages (including the WooCommerce shop page) where products were displayed if there are any products with. All products that do not have at least one assigned category is then then (logically I guess) assigne...
I solved this problem based on code kindly provided by rynoldos (<https://gist.github.com/rynaldos/a9d357b1e3791afd9bea48833ff95994>) as follows: Include the following code in your functions.php file: ``` /** Remove categories from shop and other pages * in Woocommerce */ function wc_hide_selected_terms( $terms, $t...
301,747
<p>i'm developing a plugin wich uses GET parametters to decide what to render to the user(example: login, logout, change password etc..), the thing is this works in the standards wordpress themes but when i changed to my clients theme(Sereno) every time i call the url with the parametter it render a POST page... exampl...
[ { "answer_id": 301762, "author": "fuxia", "author_id": 73, "author_profile": "https://wordpress.stackexchange.com/users/73", "pm_score": 1, "selected": false, "text": "<p>WordPress is removing all unknown (not registered) <code>$_GET</code> parameters while processing the request (same i...
2018/04/24
[ "https://wordpress.stackexchange.com/questions/301747", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/136398/" ]
i'm developing a plugin wich uses GET parametters to decide what to render to the user(example: login, logout, change password etc..), the thing is this works in the standards wordpress themes but when i changed to my clients theme(Sereno) every time i call the url with the parametter it render a POST page... example ...
WordPress is removing all unknown (not registered) `$_GET` parameters while processing the request (same is true for `$_POST`). You can either register the custom variable, or just go the canonical PHP way by using [`filter_input()`](http://php.net/manual/en/function.filter-input.php). This will access the original, ...
301,749
<p>I am having a problem with the Wordpress Admin bar covering and overlapping my fixed menu header. The theme originally did not have a fixed menu header but I edited the CSS to add one. Also, I added a background color change for the header's menu (in case this complicates the fix).</p> <p>I have tried using numer...
[ { "answer_id": 301754, "author": "Milan Bastola", "author_id": 137372, "author_profile": "https://wordpress.stackexchange.com/users/137372", "pm_score": 1, "selected": false, "text": "<p>One solution to your problem is hiding admin bar from front-end. Maybe there is problem in your css t...
2018/04/24
[ "https://wordpress.stackexchange.com/questions/301749", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/142398/" ]
I am having a problem with the Wordpress Admin bar covering and overlapping my fixed menu header. The theme originally did not have a fixed menu header but I edited the CSS to add one. Also, I added a background color change for the header's menu (in case this complicates the fix). I have tried using numerous fixes fo...
One solution to your problem is hiding admin bar from front-end. Maybe there is problem in your css too. To hide admin bar from front-end: 1. To remove the toolbar from your site, go to Users > Your Profile. Scroll down to “Toolbar” and uncheck “Show Toolbar when viewing site.” 2. Add `add_filter(‘show_admin_bar’, ...
301,755
<p>I want to change the word "Tags" in Wordpress to something else, i.e. Related Posts, Locations, etc - I've searched all over and I just cannot find it, can any one help?? </p>
[ { "answer_id": 301758, "author": "Milan Bastola", "author_id": 137372, "author_profile": "https://wordpress.stackexchange.com/users/137372", "pm_score": -1, "selected": false, "text": "<p>My suggestion is, You should try creating custom post types instead changing WP Core functionality. ...
2018/04/24
[ "https://wordpress.stackexchange.com/questions/301755", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/142404/" ]
I want to change the word "Tags" in Wordpress to something else, i.e. Related Posts, Locations, etc - I've searched all over and I just cannot find it, can any one help??
The other answers here talk about changing how the translation works, which is a bad practice if there are instances of the word "tag" that you actually want to still be tag. What you likely want is to change the labels of the "tag" taxonomy. ``` function wpse301755_change_tags_labels( $args, $taxonomy ) { if ( 'p...
301,761
<p>The theme our site was built with makes the tables look huge and that's fine for almost all of the site but we have one page with an 25-row table that needs to be super compact and simple so it fits in less than one page. Is there a way to tell Wordpress to ignore all themes and table styles for just one section of ...
[ { "answer_id": 301758, "author": "Milan Bastola", "author_id": 137372, "author_profile": "https://wordpress.stackexchange.com/users/137372", "pm_score": -1, "selected": false, "text": "<p>My suggestion is, You should try creating custom post types instead changing WP Core functionality. ...
2018/04/24
[ "https://wordpress.stackexchange.com/questions/301761", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/142412/" ]
The theme our site was built with makes the tables look huge and that's fine for almost all of the site but we have one page with an 25-row table that needs to be super compact and simple so it fits in less than one page. Is there a way to tell Wordpress to ignore all themes and table styles for just one section of the...
The other answers here talk about changing how the translation works, which is a bad practice if there are instances of the word "tag" that you actually want to still be tag. What you likely want is to change the labels of the "tag" taxonomy. ``` function wpse301755_change_tags_labels( $args, $taxonomy ) { if ( 'p...
301,797
<p>I'm trying to add an action every time someone presses the 'Publish'-button. I've made this function:</p> <pre><code>function custom_set_category_on_cpt( $post_ID, $post, $update ) { echo '&lt;p&gt;This does not show, unless I hook it onto admin_head or admin_footer&lt;/p&gt;'; if ( 'publish' === $post-&gt;post_s...
[ { "answer_id": 301809, "author": "forsvunnet", "author_id": 45792, "author_profile": "https://wordpress.stackexchange.com/users/45792", "pm_score": 1, "selected": false, "text": "<p>When editing a post using the admin interface the wp-admin/post.php script redirects you after saving the ...
2018/04/25
[ "https://wordpress.stackexchange.com/questions/301797", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/128304/" ]
I'm trying to add an action every time someone presses the 'Publish'-button. I've made this function: ``` function custom_set_category_on_cpt( $post_ID, $post, $update ) { echo '<p>This does not show, unless I hook it onto admin_head or admin_footer</p>'; if ( 'publish' === $post->post_status ) { echo '<p>I can't...
When editing a post using the admin interface the wp-admin/post.php script redirects you after saving the post. This is done to avoid resubmitting the post request if you refresh the page after submitting. It also means that you're not able to output anything during the `save_post` action. ``` case 'editpost': che...
301,840
<p>I'm taking my first steps in Gutenberg block development and I'm already stuck. My block JS script makes use of a couple lodash functions (<code>filter</code> and <code>pick</code>). I'm registering my block using the following function:</p> <pre><code>function register_block() { wp_register_script( 'bl...
[ { "answer_id": 301847, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 2, "selected": false, "text": "<p>The problem is that lodash isn't a script dependency, it's an NPM dependency:</p>\n\n<pre><code>array( 'wp-b...
2018/04/25
[ "https://wordpress.stackexchange.com/questions/301840", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33049/" ]
I'm taking my first steps in Gutenberg block development and I'm already stuck. My block JS script makes use of a couple lodash functions (`filter` and `pick`). I'm registering my block using the following function: ``` function register_block() { wp_register_script( 'block-script', plugins_url( 'b...
In the block script I had to replace: ``` import pick from 'lodash/pick'; ``` with: ``` const { pick } = lodash; ``` And now it seems to work for me.
301,846
<p>im using this piece of code to show my div only on homepage.</p> <pre><code>&lt;?php if ( is_front_page() ) :?&gt; </code></pre> <p></p> <p>but it's shown on pagination 2, 3 and so on. is there any help regarding to fixing this issue? </p>
[ { "answer_id": 301848, "author": "Shameem Ali", "author_id": 137710, "author_profile": "https://wordpress.stackexchange.com/users/137710", "pm_score": -1, "selected": false, "text": "<p>See: <a href=\"http://codex.wordpress.org/Function_Reference/is_home\" rel=\"nofollow noreferrer\">htt...
2018/04/25
[ "https://wordpress.stackexchange.com/questions/301846", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24762/" ]
im using this piece of code to show my div only on homepage. ``` <?php if ( is_front_page() ) :?> ``` but it's shown on pagination 2, 3 and so on. is there any help regarding to fixing this issue?
Thank you guys for quick response. Here is the code that worked for me. ``` <?php if( is_home() != '' && !is_paged()) { ?> div here <?php } ?> ```