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
270,281
<p>I have a very basic theme that is running WooCommerce beautifully so far. In my functions.php I've setup the following to support <code>woocommerce</code>.</p> <pre><code>// // WooCommerce Hooks and Theme Overrides // remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10); remov...
[ { "answer_id": 270269, "author": "Rick Hellewell", "author_id": 29416, "author_profile": "https://wordpress.stackexchange.com/users/29416", "pm_score": 0, "selected": false, "text": "<p>I suspect a theme error. Try a different theme (like the standard ones - Twenty-whatevers).</p>\n" }...
2017/06/15
[ "https://wordpress.stackexchange.com/questions/270281", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/44017/" ]
I have a very basic theme that is running WooCommerce beautifully so far. In my functions.php I've setup the following to support `woocommerce`. ``` // // WooCommerce Hooks and Theme Overrides // remove_action( 'woocommerce_before_main_content', 'woocommerce_output_content_wrapper', 10); remove_action( 'woocommerce_af...
I found it at last! Using the browser debugger, I found that there was a "editor.wp" which was undefined (in the complete version of the js file). Then I understood that the "wordpress" plugin was not used in the editor. When calling the function wp\_editor, I was setting a list of plugin : paste, wplink, textcolor. ...
270,286
<p>What's the difference beetween </p> <p><code>define( 'WP_MEMORY_LIMIT', '96M' );</code> and <code>define( 'WP_MAX_MEMORY_LIMIT', '256M' );</code></p> <p>In my host I have this </p> <pre><code>define( 'WP_MEMORY_LIMIT', '786M' ); define( 'WP_MAX_MEMORY_LIMIT', '512M' ); </code></pre> <p>is this correct, should ...
[ { "answer_id": 270288, "author": "joetek", "author_id": 62298, "author_profile": "https://wordpress.stackexchange.com/users/62298", "pm_score": 2, "selected": false, "text": "<p>The <code>WP_MEMORY_LIMIT</code> is the default limit set in the front-end, but it can be raised up to <code>W...
2017/06/15
[ "https://wordpress.stackexchange.com/questions/270286", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/119118/" ]
What's the difference beetween `define( 'WP_MEMORY_LIMIT', '96M' );` and `define( 'WP_MAX_MEMORY_LIMIT', '256M' );` In my host I have this ``` define( 'WP_MEMORY_LIMIT', '786M' ); define( 'WP_MAX_MEMORY_LIMIT', '512M' ); ``` is this correct, should the `WP_MAX_MEMORY_LIMIT` be higher ?
WordPress tells us: > > the WP\_MEMORY\_LIMIT option allows you to specify the maximum amount of > memory that can be consumed by PHP. This setting may be necessary in > the event you receive a message such as "Allowed memory size of xxxxxx > bytes exhausted". > > > Or as the [PHP docs put it](http://php.net/...
270,291
<p>I am running into a strange issue where <code>content_arr['extended']</code> or <code>content_arr['main']</code> is removing the paragraph tags in the output.</p> <p>Any help, or insight into something i am over looking, trying to resolve this would be greatly appreciated.</p>
[ { "answer_id": 270361, "author": "Zach Smith", "author_id": 1354, "author_profile": "https://wordpress.stackexchange.com/users/1354", "pm_score": 1, "selected": false, "text": "<p>seems when i add the following using <code>wpautop</code> to the output it resolves the problem. i would lov...
2017/06/15
[ "https://wordpress.stackexchange.com/questions/270291", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1354/" ]
I am running into a strange issue where `content_arr['extended']` or `content_arr['main']` is removing the paragraph tags in the output. Any help, or insight into something i am over looking, trying to resolve this would be greatly appreciated.
seems when i add the following using `wpautop` to the output it resolves the problem. i would love to know from someone smarter than myself why this fixes it. why when we just use `the_content` the p tags are included, but when we use `get_extended` do the p tags get removed? ``` $content_arr = get_extended ( $post->p...
270,294
<p>i am building the following script to query data from every child page of a certain page. i have it working fine, but i am unable to get the featured image, because i am using <code>$post-&gt;ID</code>. what would i change <code>$post-&gt;ID</code> to be in order to work correctly with the rest of my function? any h...
[ { "answer_id": 270296, "author": "Asaf Lopez", "author_id": 121826, "author_profile": "https://wordpress.stackexchange.com/users/121826", "pm_score": 3, "selected": true, "text": "<p>Try with <code>get_the_ID()</code></p>\n\n<pre><code>$image_uploaded_meta_id = get_post_meta(get_the_ID()...
2017/06/15
[ "https://wordpress.stackexchange.com/questions/270294", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1354/" ]
i am building the following script to query data from every child page of a certain page. i have it working fine, but i am unable to get the featured image, because i am using `$post->ID`. what would i change `$post->ID` to be in order to work correctly with the rest of my function? any help would be greatly appreciate...
Try with `get_the_ID()` ``` $image_uploaded_meta_id = get_post_meta(get_the_ID(), '_listing_image_id', true); ``` `get_the_ID()` is a core Wordpress function that acts directly inside the Wordpress Loop, retrieving the id of the current item being loaded. `$post->id` is not working because the variable `$post` has n...
270,303
<p>I created wp-theme, use plugin Custom Post Type UI.</p> <p>Created sections - <code>Customers</code> and <code>Projects</code>.</p> <p><a href="https://i.stack.imgur.com/Pj03P.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Pj03P.png" alt="enter image description here"></a></p> <p><a href="http...
[ { "answer_id": 270315, "author": "Ronald", "author_id": 27469, "author_profile": "https://wordpress.stackexchange.com/users/27469", "pm_score": 1, "selected": false, "text": "<p>Multiple loops in the same page </p>\n\n<pre><code>&lt;?php\n// this is for customer posts\n$args = array(\n ...
2017/06/16
[ "https://wordpress.stackexchange.com/questions/270303", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120398/" ]
I created wp-theme, use plugin Custom Post Type UI. Created sections - `Customers` and `Projects`. [![enter image description here](https://i.stack.imgur.com/Pj03P.png)](https://i.stack.imgur.com/Pj03P.png) [![enter image description here](https://i.stack.imgur.com/3KZV1.png)](https://i.stack.imgur.com/3KZV1.png) [...
i found solution: ``` <?php if( have_rows('project-sections') ): ?> <?php $i = 0; ?> <?php while( have_rows('project-sections') ): the_row(); ?> <section class="<?php if ($i % 2 == 0) : ?>bg-gray<?php else: ?>bg-white<?php endif; ?>"> <div class="container"> ...
270,304
<p>I would like to add a CSS class to the body if a visitor goes to the second or third etc. page of the website. Or vice-versa: add a class only on the first visited page. The goal is that I can distinguish the first visited page. </p> <p>Do you have any idea how can I solve this? Javascript? WP_SESSIONS?</p>
[ { "answer_id": 270315, "author": "Ronald", "author_id": 27469, "author_profile": "https://wordpress.stackexchange.com/users/27469", "pm_score": 1, "selected": false, "text": "<p>Multiple loops in the same page </p>\n\n<pre><code>&lt;?php\n// this is for customer posts\n$args = array(\n ...
2017/06/16
[ "https://wordpress.stackexchange.com/questions/270304", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48882/" ]
I would like to add a CSS class to the body if a visitor goes to the second or third etc. page of the website. Or vice-versa: add a class only on the first visited page. The goal is that I can distinguish the first visited page. Do you have any idea how can I solve this? Javascript? WP\_SESSIONS?
i found solution: ``` <?php if( have_rows('project-sections') ): ?> <?php $i = 0; ?> <?php while( have_rows('project-sections') ): the_row(); ?> <section class="<?php if ($i % 2 == 0) : ?>bg-gray<?php else: ?>bg-white<?php endif; ?>"> <div class="container"> ...
270,309
<p>So i am developing a hybrid app using cordova and jquery mobile. I need to login to a wordpress blog site and create a new post in my hybrid app. I am using JSON Api plugin(<a href="https://wordpress.org/plugins/json-api/" rel="nofollow noreferrer">https://wordpress.org/plugins/json-api/</a>) to perform AJAX post. T...
[ { "answer_id": 270315, "author": "Ronald", "author_id": 27469, "author_profile": "https://wordpress.stackexchange.com/users/27469", "pm_score": 1, "selected": false, "text": "<p>Multiple loops in the same page </p>\n\n<pre><code>&lt;?php\n// this is for customer posts\n$args = array(\n ...
2017/06/16
[ "https://wordpress.stackexchange.com/questions/270309", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/121899/" ]
So i am developing a hybrid app using cordova and jquery mobile. I need to login to a wordpress blog site and create a new post in my hybrid app. I am using JSON Api plugin(<https://wordpress.org/plugins/json-api/>) to perform AJAX post. The issue is when i try to create a new post using the `create_post method`,i get ...
i found solution: ``` <?php if( have_rows('project-sections') ): ?> <?php $i = 0; ?> <?php while( have_rows('project-sections') ): the_row(); ?> <section class="<?php if ($i % 2 == 0) : ?>bg-gray<?php else: ?>bg-white<?php endif; ?>"> <div class="container"> ...
270,328
<p>How can I send username and password of new registration to admin using email.</p>
[ { "answer_id": 270315, "author": "Ronald", "author_id": 27469, "author_profile": "https://wordpress.stackexchange.com/users/27469", "pm_score": 1, "selected": false, "text": "<p>Multiple loops in the same page </p>\n\n<pre><code>&lt;?php\n// this is for customer posts\n$args = array(\n ...
2017/06/16
[ "https://wordpress.stackexchange.com/questions/270328", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/110592/" ]
How can I send username and password of new registration to admin using email.
i found solution: ``` <?php if( have_rows('project-sections') ): ?> <?php $i = 0; ?> <?php while( have_rows('project-sections') ): the_row(); ?> <section class="<?php if ($i % 2 == 0) : ?>bg-gray<?php else: ?>bg-white<?php endif; ?>"> <div class="container"> ...
270,366
<p>I am an experienced PHP developer, but new to WordPress. I created a site and added some custom JavaScript, CSS, and a number of shortcodes. My CSS was just added to style.css (The default when I clicked on Appearance->Editor in the sidebar) and the hooks to my JavaScript as well as my shortcodes were in my theme's ...
[ { "answer_id": 270315, "author": "Ronald", "author_id": 27469, "author_profile": "https://wordpress.stackexchange.com/users/27469", "pm_score": 1, "selected": false, "text": "<p>Multiple loops in the same page </p>\n\n<pre><code>&lt;?php\n// this is for customer posts\n$args = array(\n ...
2017/06/16
[ "https://wordpress.stackexchange.com/questions/270366", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/121934/" ]
I am an experienced PHP developer, but new to WordPress. I created a site and added some custom JavaScript, CSS, and a number of shortcodes. My CSS was just added to style.css (The default when I clicked on Appearance->Editor in the sidebar) and the hooks to my JavaScript as well as my shortcodes were in my theme's fun...
i found solution: ``` <?php if( have_rows('project-sections') ): ?> <?php $i = 0; ?> <?php while( have_rows('project-sections') ): the_row(); ?> <section class="<?php if ($i % 2 == 0) : ?>bg-gray<?php else: ?>bg-white<?php endif; ?>"> <div class="container"> ...
270,376
<p>I am running WP Multisite in version 4.8</p> <p>I have a site in the network that lost the visual editor toolbar a ways back (not exactly sure when it disappeared). When you go to Text view mode the content and markup is entirely visible. When you go to Visual view mode the content is there but white text on white ...
[ { "answer_id": 270315, "author": "Ronald", "author_id": 27469, "author_profile": "https://wordpress.stackexchange.com/users/27469", "pm_score": 1, "selected": false, "text": "<p>Multiple loops in the same page </p>\n\n<pre><code>&lt;?php\n// this is for customer posts\n$args = array(\n ...
2017/06/16
[ "https://wordpress.stackexchange.com/questions/270376", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/121949/" ]
I am running WP Multisite in version 4.8 I have a site in the network that lost the visual editor toolbar a ways back (not exactly sure when it disappeared). When you go to Text view mode the content and markup is entirely visible. When you go to Visual view mode the content is there but white text on white background...
i found solution: ``` <?php if( have_rows('project-sections') ): ?> <?php $i = 0; ?> <?php while( have_rows('project-sections') ): the_row(); ?> <section class="<?php if ($i % 2 == 0) : ?>bg-gray<?php else: ?>bg-white<?php endif; ?>"> <div class="container"> ...
270,383
<p>On my WordPress site, I am using the human time difference for the post date. If you have a post that was posted <code>59 minutes ago</code> or under it appears as posted <code>1 min ago</code>, <code>5 mins ago</code>, or posted <code>35 mins ago</code>. Is there a way that I can change mins to minutes?</p> <p>Th...
[ { "answer_id": 270385, "author": "Picard", "author_id": 118566, "author_profile": "https://wordpress.stackexchange.com/users/118566", "pm_score": 3, "selected": true, "text": "<p>You can do:</p>\n\n<pre><code>echo str_replace('mins', 'minutes', human_time_diff( get_the_time('U'), current...
2017/06/16
[ "https://wordpress.stackexchange.com/questions/270383", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/121640/" ]
On my WordPress site, I am using the human time difference for the post date. If you have a post that was posted `59 minutes ago` or under it appears as posted `1 min ago`, `5 mins ago`, or posted `35 mins ago`. Is there a way that I can change mins to minutes? This is the code I have. ``` <div class="front-page-date...
You can do: ``` echo str_replace('mins', 'minutes', human_time_diff( get_the_time('U'), current_time('timestamp') ) . ' ago'); ``` **Update:** The same using filter as suggested: ``` add_filter('human_time_diff', 'new_human_time_diff', 10, 2); function new_human_time_diff($from, $to) { // remove filter to pre...
270,397
<p><strong>BOUNTY EDIT :</strong></p> <p>I have a plugin which does have links similar to below:</p> <blockquote> <p>mydomain.com/wp-content/plugins/myplugin/includes/categories.php?c=9</p> </blockquote> <p>I want these links to be more SEO friendly and to work like this:</p> <blockquote> <p>mydomain.com/wp-con...
[ { "answer_id": 270400, "author": "Morgan Estes", "author_id": 26317, "author_profile": "https://wordpress.stackexchange.com/users/26317", "pm_score": 1, "selected": false, "text": "<p>Rewrite rules expect the new location to go off <code>index.php</code>. If you change it to <code>'index...
2017/06/17
[ "https://wordpress.stackexchange.com/questions/270397", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/112778/" ]
**BOUNTY EDIT :** I have a plugin which does have links similar to below: > > mydomain.com/wp-content/plugins/myplugin/includes/categories.php?c=9 > > > I want these links to be more SEO friendly and to work like this: > > mydomain.com/wp-content/plugins/myplugin/includes/categories/9/ > > > **SOLUTIONS I ...
Why don't we create our own template file, and do our stuff there? Here's what I'm going to do: 1. Create a custom page template 2. Call the required plugin's functions inside the page 3. Redirect the plugins URLs to the page 4. Get the query var and process the request --- - The page template -------------------- ...
270,405
<p>I've got a shortcode working to return tags that are used on a particular post but can't figure out how to return the description with it.</p> <pre><code>function returnpost_tags(){ return get_the_tag_list('',', ',' '); } add_shortcode('post-tags', 'returnpost_tags'); </code></pre> <p>I tried </p> <pre>...
[ { "answer_id": 270408, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 0, "selected": false, "text": "<p>If you are trying to work with the tags, you can use <a href=\"https://codex.wordpress.org/Function_Referen...
2017/06/17
[ "https://wordpress.stackexchange.com/questions/270405", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/121961/" ]
I've got a shortcode working to return tags that are used on a particular post but can't figure out how to return the description with it. ``` function returnpost_tags(){ return get_the_tag_list('',', ',' '); } add_shortcode('post-tags', 'returnpost_tags'); ``` I tried ``` return get_the_tag_list('',', '...
This is how you can loop with custom taxonomy. ``` function returnpost_tags(){ // get tags by post ID $post_ID = get_the_ID(); // here, you can add any custom tag $terms = get_the_terms( $post_ID , 'post_tag' ); echo '<ul>'; foreach ( $terms as $term ) { // The $term is an object, so we don't need to specify the ...
270,416
<p>I'm using the 2017 theme. I'm trying to set up a simple website where a user is able to easily add a photo with accompanying text (description). The uploaded content should appear on one page where the photo will be in one column and the description (not caption - it's longer than just a caption) will be displayed o...
[ { "answer_id": 270408, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 0, "selected": false, "text": "<p>If you are trying to work with the tags, you can use <a href=\"https://codex.wordpress.org/Function_Referen...
2017/06/17
[ "https://wordpress.stackexchange.com/questions/270416", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/121978/" ]
I'm using the 2017 theme. I'm trying to set up a simple website where a user is able to easily add a photo with accompanying text (description). The uploaded content should appear on one page where the photo will be in one column and the description (not caption - it's longer than just a caption) will be displayed on t...
This is how you can loop with custom taxonomy. ``` function returnpost_tags(){ // get tags by post ID $post_ID = get_the_ID(); // here, you can add any custom tag $terms = get_the_terms( $post_ID , 'post_tag' ); echo '<ul>'; foreach ( $terms as $term ) { // The $term is an object, so we don't need to specify the ...
270,427
<p>I have a problem with my shop columns in WooCommerce.</p> <p>I would like to display 4 columns in my shop but unfortunately there is just 3 columns.</p> <p>I use the Storefront theme for my shop, so I have looked the <code>storefront-template-fonction.php</code> file and the different <code>apply_filters</code> ar...
[ { "answer_id": 270408, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 0, "selected": false, "text": "<p>If you are trying to work with the tags, you can use <a href=\"https://codex.wordpress.org/Function_Referen...
2017/06/17
[ "https://wordpress.stackexchange.com/questions/270427", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/121985/" ]
I have a problem with my shop columns in WooCommerce. I would like to display 4 columns in my shop but unfortunately there is just 3 columns. I use the Storefront theme for my shop, so I have looked the `storefront-template-fonction.php` file and the different `apply_filters` are setting up on 'columns'=>4. Exemple:...
This is how you can loop with custom taxonomy. ``` function returnpost_tags(){ // get tags by post ID $post_ID = get_the_ID(); // here, you can add any custom tag $terms = get_the_terms( $post_ID , 'post_tag' ); echo '<ul>'; foreach ( $terms as $term ) { // The $term is an object, so we don't need to specify the ...
270,446
<p>I am trying to set up a featured content section of my blog. This will contain two sticky posts.</p> <p>I have a custom loop which will only display the two sticky posts, in the loop I then get a <code>content-featured.php</code> template which has the structure of the sticky posts.</p> <p>In the main post div I u...
[ { "answer_id": 270450, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 3, "selected": true, "text": "<p>Here's a solution that adds additional sticky classes, one for the post ID and one for the sticky post count...
2017/06/17
[ "https://wordpress.stackexchange.com/questions/270446", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/121998/" ]
I am trying to set up a featured content section of my blog. This will contain two sticky posts. I have a custom loop which will only display the two sticky posts, in the loop I then get a `content-featured.php` template which has the structure of the sticky posts. In the main post div I use `post_class()`. I know I ...
Here's a solution that adds additional sticky classes, one for the post ID and one for the sticky post counter. ``` /** * Adds .featured-{$post_id} and .featured-{$sticky_counter} * class names to sticky posts. * * @param array $classes An array of post classes. * @param array $class An array of additional clas...
270,523
<p>i wanted to know if "Alt title" is needed like "Title" for post thumbnails and how can add it in my related post query... i'm using this code to get the post thumbnail:</p> <pre><code>&lt;div class="td-module-thumb"&gt; &lt;a href="&lt;?php the_permalink(); ?&gt;" title="&lt;?php the_title_attribute(); ?&gt;"&gt; &...
[ { "answer_id": 270525, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 4, "selected": true, "text": "<p>It is necessary to set an <code>alt</code> value for all of your images, in case a browser can not load the ...
2017/06/19
[ "https://wordpress.stackexchange.com/questions/270523", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/117100/" ]
i wanted to know if "Alt title" is needed like "Title" for post thumbnails and how can add it in my related post query... i'm using this code to get the post thumbnail: ``` <div class="td-module-thumb"> <a href="<?php the_permalink(); ?>" title="<?php the_title_attribute(); ?>"> <?php if (has_post_thumbnail()) { the_p...
It is necessary to set an `alt` value for all of your images, in case a browser can not load the image or the visitor is using screen reader. You have two options. Either use the featured image's caption (which can some times be blank) or use the post's title as `alt`. You can get the caption by using [`get_post_meta...
270,578
<p>I have a custom post status and the issue I have is that the filter option for it that automatically appears above the post listings on the edit.php page of the WP admin shows a total count of all the posts with this status. I want it to show a count that is specific to the user in question.</p> <p>So for example<...
[ { "answer_id": 270525, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 4, "selected": true, "text": "<p>It is necessary to set an <code>alt</code> value for all of your images, in case a browser can not load the ...
2017/06/19
[ "https://wordpress.stackexchange.com/questions/270578", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28543/" ]
I have a custom post status and the issue I have is that the filter option for it that automatically appears above the post listings on the edit.php page of the WP admin shows a total count of all the posts with this status. I want it to show a count that is specific to the user in question. So for example > > All (...
It is necessary to set an `alt` value for all of your images, in case a browser can not load the image or the visitor is using screen reader. You have two options. Either use the featured image's caption (which can some times be blank) or use the post's title as `alt`. You can get the caption by using [`get_post_meta...
270,579
<p>Is there anyway at all to get the title of a widget from the widget id? The post title can be used by using </p> <pre><code>get_the_title() </code></pre> <p>Is there a way to get the title for a widget using the same kind or function?</p>
[ { "answer_id": 270673, "author": "dbeja", "author_id": 9585, "author_profile": "https://wordpress.stackexchange.com/users/9585", "pm_score": 2, "selected": false, "text": "<p>You can get the widget name from the widget id with this:</p>\n\n<pre><code>&lt;?php\n global $wp_registered_w...
2017/06/19
[ "https://wordpress.stackexchange.com/questions/270579", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/121807/" ]
Is there anyway at all to get the title of a widget from the widget id? The post title can be used by using ``` get_the_title() ``` Is there a way to get the title for a widget using the same kind or function?
You can get the widget name from the widget id with this: ``` <?php global $wp_registered_widgets; $id = 'recent-comments-1'; // example if ( isset($wp_registered_widgets[$id]['name']) ) { echo $wp_registered_widgets[$id]['name']; } ?> ```
270,615
<p>I'm trying to add multiple page IDs into an if else statement. This is my code so far: </p> <pre><code>if ( is_page(ID) || is_page(ID) ) { get_header('header_alt'); } else { get_header(); } </code></pre> <p>I tried a few other solutions found on google, yet it always only works on the initial page afte...
[ { "answer_id": 270616, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 4, "selected": false, "text": "<p>You can pass an array of IDs to <a href=\"https://developer.wordpress.org/reference/functions/is_page/\" re...
2017/06/19
[ "https://wordpress.stackexchange.com/questions/270615", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/121732/" ]
I'm trying to add multiple page IDs into an if else statement. This is my code so far: ``` if ( is_page(ID) || is_page(ID) ) { get_header('header_alt'); } else { get_header(); } ``` I tried a few other solutions found on google, yet it always only works on the initial page after clearing the cache.
You can pass an array of IDs to [`is_page`](https://developer.wordpress.org/reference/functions/is_page/) instead of using multiple `is_page`: ``` if( is_page( array( 11, 22, 33, 44 ) ) ) { // Your code } ``` Also, if you are using it in a loop, you should consider this note: > > Due to certain global variable...
270,619
<p>I'm trying to create a custom shortcode that uses another shortcode for a couple audio players on a Grid displaying a custom post type using Visual Composer. </p> <p>The audio player that I would like to use is the Compact Audio Player plugin which uses a shortcode of <code>[sc_embed_player fileurl="URL OF THE MP3 ...
[ { "answer_id": 270620, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 1, "selected": false, "text": "<p>Do not use <code>echo</code> in your shortcode. Use <code>return</code> instead.</p>\n\n<pre><code>function...
2017/06/19
[ "https://wordpress.stackexchange.com/questions/270619", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122133/" ]
I'm trying to create a custom shortcode that uses another shortcode for a couple audio players on a Grid displaying a custom post type using Visual Composer. The audio player that I would like to use is the Compact Audio Player plugin which uses a shortcode of `[sc_embed_player fileurl="URL OF THE MP3 FILE"]`. What...
Do not use `echo` in your shortcode. Use `return` instead. ``` function get_generic_demo() { //Get the field's value $demo = get_field( 'generic_demo'); //Save the URL into a variable $url = $demo['url']; // Pass it to the other shortcode and return its value return do_shortcode('[sc_embed_play...
270,640
<p>Im not sure if my title its the correct, i need to make something in homepage to show recent custom-taxonomies used in my latest posts... like, for example:</p> <p>I make a new post and i use a custom taxonomy called Actors: Juan</p> <p>i want to show "Juan" taxonomy in the homepage, below a title that say "Recent...
[ { "answer_id": 270620, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 1, "selected": false, "text": "<p>Do not use <code>echo</code> in your shortcode. Use <code>return</code> instead.</p>\n\n<pre><code>function...
2017/06/20
[ "https://wordpress.stackexchange.com/questions/270640", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/117100/" ]
Im not sure if my title its the correct, i need to make something in homepage to show recent custom-taxonomies used in my latest posts... like, for example: I make a new post and i use a custom taxonomy called Actors: Juan i want to show "Juan" taxonomy in the homepage, below a title that say "Recent actors" or somet...
Do not use `echo` in your shortcode. Use `return` instead. ``` function get_generic_demo() { //Get the field's value $demo = get_field( 'generic_demo'); //Save the URL into a variable $url = $demo['url']; // Pass it to the other shortcode and return its value return do_shortcode('[sc_embed_play...
270,645
<p>I am trying to write cache plugin for my web site. How can I control if post or page updated or added new page or post</p>
[ { "answer_id": 270650, "author": "Sebastian Kurzynowski", "author_id": 108925, "author_profile": "https://wordpress.stackexchange.com/users/108925", "pm_score": 0, "selected": false, "text": "<p>Whenever a post or page is updated or created there is action hook triggered <code>save_post<...
2017/06/20
[ "https://wordpress.stackexchange.com/questions/270645", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122055/" ]
I am trying to write cache plugin for my web site. How can I control if post or page updated or added new page or post
add below action in your main function file of your plugin ``` add_action( 'wp_insert_post', 'my_project_updated_post', 10, 3 ); function my_project_updated_post( $post_id, $post, $update ) { // your code goes here // Every time you will get updated or newly created post id here. } ```
270,647
<p>I would like to call a function when a I save a setting/option in a custom admin page.</p>
[ { "answer_id": 270650, "author": "Sebastian Kurzynowski", "author_id": 108925, "author_profile": "https://wordpress.stackexchange.com/users/108925", "pm_score": 0, "selected": false, "text": "<p>Whenever a post or page is updated or created there is action hook triggered <code>save_post<...
2017/06/20
[ "https://wordpress.stackexchange.com/questions/270647", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122153/" ]
I would like to call a function when a I save a setting/option in a custom admin page.
add below action in your main function file of your plugin ``` add_action( 'wp_insert_post', 'my_project_updated_post', 10, 3 ); function my_project_updated_post( $post_id, $post, $update ) { // your code goes here // Every time you will get updated or newly created post id here. } ```
270,670
<p>I'm trying to manually fill the Open Graph tags and I'm having some troubles in setting the content for the <code>og:image</code> tag.</p> <p>In a single post page, I set it this way:</p> <pre><code>&lt;?php $thumbnailSrc = wp_get_attachment_image_src(get_post_thumbnail_id($post-&gt;ID), 'medium'); $image =...
[ { "answer_id": 270664, "author": "Pribhav", "author_id": 122156, "author_profile": "https://wordpress.stackexchange.com/users/122156", "pm_score": 4, "selected": true, "text": "<p>It is not possible by WooCommerce default configuration.</p>\n\n<p>You have to install below plugin.</p>\n\n...
2017/06/20
[ "https://wordpress.stackexchange.com/questions/270670", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13206/" ]
I'm trying to manually fill the Open Graph tags and I'm having some troubles in setting the content for the `og:image` tag. In a single post page, I set it this way: ``` <?php $thumbnailSrc = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'medium'); $image = esc_attr($thumbnailSrc[0]); ?> <meta ...
It is not possible by WooCommerce default configuration. You have to install below plugin. <https://codecanyon.net/item/woocommerce-role-based-payment-shipping-methods/18953727> or programmatically, you can refer below link. <https://businessbloomer.com/disable-payment-gateway-specific-user-role-woocommerce/>
270,675
<p>I want to convert PHP website into WordPress. So, I want to know there are a .html at end of the URL when WordPress permalink is not ended with .html. So, is it affected to SEO?</p>
[ { "answer_id": 270685, "author": "kero", "author_id": 108180, "author_profile": "https://wordpress.stackexchange.com/users/108180", "pm_score": 1, "selected": false, "text": "<p>If you currently have <code>/path/to/site.html</code> and change it to <code>/path/to/site</code>, this will a...
2017/06/20
[ "https://wordpress.stackexchange.com/questions/270675", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114646/" ]
I want to convert PHP website into WordPress. So, I want to know there are a .html at end of the URL when WordPress permalink is not ended with .html. So, is it affected to SEO?
If you currently have `/path/to/site.html` and change it to `/path/to/site`, this will affect SEO, as search engines think they know the url (the former). However, there are solutions to this. You can either keep the `.html` at the end of the URL (there should be no problem to use a WordPress permalink with .html in t...
270,737
<p>After the update to <strong>Wordpress 4.8</strong> my widget's textarea has disappeared and my console says: </p> <pre><code>[Error] ReferenceError: Can't find variable: wp Global Code (widgets.php:202) </code></pre> <p>Looking at the file I can identify this line causing the issue:</p> <pre><code>wp.textWidgets....
[ { "answer_id": 270740, "author": "Andrew Dinmore", "author_id": 115658, "author_profile": "https://wordpress.stackexchange.com/users/115658", "pm_score": 0, "selected": false, "text": "<p>Looks like you need to enqueue the editor scripts manually, after 4.8, using <code>wp_enqueue_editor...
2017/06/20
[ "https://wordpress.stackexchange.com/questions/270737", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93927/" ]
After the update to **Wordpress 4.8** my widget's textarea has disappeared and my console says: ``` [Error] ReferenceError: Can't find variable: wp Global Code (widgets.php:202) ``` Looking at the file I can identify this line causing the issue: ``` wp.textWidgets.init(); ``` Now, I've got installed many plugins...
Looks like you need to enqueue the editor scripts manually, after 4.8, using `wp_enqueue_editor()` in your theme/plugin: <https://make.wordpress.org/core/2017/05/20/editor-api-changes-in-4-8/>
270,777
<p>I'm having trouble with my WordPress theme.</p> <p>I'm getting the error below after uploading a featured image into my portfolio item(s):</p> <blockquote> <p>Warning: Invalid argument supplied for foreach() in /home2/maryhtran/public_html/wp-content/themes/Motive/portfolio-list.php on line 150</p> </blockquote>...
[ { "answer_id": 270780, "author": "Rick Hellewell", "author_id": 29416, "author_profile": "https://wordpress.stackexchange.com/users/29416", "pm_score": 0, "selected": false, "text": "<p>The error is in your theme. Contact the theme support people. That is the proper place to ask theme-re...
2017/06/21
[ "https://wordpress.stackexchange.com/questions/270777", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122237/" ]
I'm having trouble with my WordPress theme. I'm getting the error below after uploading a featured image into my portfolio item(s): > > Warning: Invalid argument supplied for foreach() in /home2/maryhtran/public\_html/wp-content/themes/Motive/portfolio-list.php on line 150 > > > This is the code that is causing ...
It happens when the `foreach()` is fed with an invalid entry, because there is no term returned. To prevent this, wrap your loop inside a conditional: ``` // Get the terms( categories ) for the portfolio item $terms = get_the_terms( $post_item->ID, 'portfolio_categories' ); if(is_array($terms) || is_object($terms)){ ...
270,783
<p>I am trying to implement a simple login inside my plugin following <a href="http://www.w3schools.in/php-script/php-login-without-using-database/" rel="nofollow noreferrer">this tutorial</a>. I have successfully implemented the login inside a WP admin page, but I can't seem to redirect it to <code>index.php</code>. A...
[ { "answer_id": 271074, "author": "Pravin Work", "author_id": 120969, "author_profile": "https://wordpress.stackexchange.com/users/120969", "pm_score": 0, "selected": false, "text": "<p>try adding submenu pages</p>\n\n<pre><code>add_submenu_page( 'sample-plugin', 'Sample Page', 'title', '...
2017/06/21
[ "https://wordpress.stackexchange.com/questions/270783", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/121819/" ]
I am trying to implement a simple login inside my plugin following [this tutorial](http://www.w3schools.in/php-script/php-login-without-using-database/). I have successfully implemented the login inside a WP admin page, but I can't seem to redirect it to `index.php`. Also, `index.php` must still be contained inside an ...
Using add\_submenu\_page function WordPress you can add multiple pages/menu In order to add a new top-level menu to WordPress administration dashboard, You can use `add_menu_page()` function. This function has the following syntax. ``` //add plugin menu add_menu_page($page_title, $menu_title, $capability, $menu...
270,784
<p>I tried this code to create some meta boxes is all working fine, the problem I am facing is how to sanitize the text fields and update post meta </p> <pre><code> function Print_price_fileds($cnt, $p = null) { if ($p === null){ $a = $b = $c = ''; }else{ $a = $p['n']; $b = $p['d']; $c = $p[...
[ { "answer_id": 270794, "author": "Sebastian Kurzynowski", "author_id": 108925, "author_profile": "https://wordpress.stackexchange.com/users/108925", "pm_score": 2, "selected": false, "text": "<p>Wordpress use <code>add_magic_quotes()</code> to escape incoming data from <code>$_POST</code...
2017/06/21
[ "https://wordpress.stackexchange.com/questions/270784", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122240/" ]
I tried this code to create some meta boxes is all working fine, the problem I am facing is how to sanitize the text fields and update post meta ``` function Print_price_fileds($cnt, $p = null) { if ($p === null){ $a = $b = $c = ''; }else{ $a = $p['n']; $b = $p['d']; $c = $p['p']; } ...
The best way to sanitize text fields within WordPress is to use [`sanitize_text_field()`](https://developer.wordpress.org/reference/functions/sanitize_text_field/) function: ``` $data = sanitize_text_field( $_POST['key'] ); ``` Additionally, if you register the meta field properly width [`register_meta()`](https://d...
270,797
<p>I have multi site. (3 websites) So I want to apply different theme in one of the website. But when I activate the theme. All the sites are affected. Is it how the multisite works?? Can somebody clarify what can be done with multi site?</p> <ol> <li>Install MultiSite (Sub-Directory)</li> <li><p>Modified wp-config.ph...
[ { "answer_id": 270794, "author": "Sebastian Kurzynowski", "author_id": 108925, "author_profile": "https://wordpress.stackexchange.com/users/108925", "pm_score": 2, "selected": false, "text": "<p>Wordpress use <code>add_magic_quotes()</code> to escape incoming data from <code>$_POST</code...
2017/06/21
[ "https://wordpress.stackexchange.com/questions/270797", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/113284/" ]
I have multi site. (3 websites) So I want to apply different theme in one of the website. But when I activate the theme. All the sites are affected. Is it how the multisite works?? Can somebody clarify what can be done with multi site? 1. Install MultiSite (Sub-Directory) 2. Modified wp-config.php and .htaccess ``` d...
The best way to sanitize text fields within WordPress is to use [`sanitize_text_field()`](https://developer.wordpress.org/reference/functions/sanitize_text_field/) function: ``` $data = sanitize_text_field( $_POST['key'] ); ``` Additionally, if you register the meta field properly width [`register_meta()`](https://d...
270,834
<p>I have registered scripts which are supposed to load in head section. But for some reason I don't get these links loaded in head. Instead of loading scripts in head these are loading in footer.</p> <pre><code> add_action('init', 'my_enqueued_assets'); function my_enqueued_assets() { //Register Css ...
[ { "answer_id": 270835, "author": "joetek", "author_id": 62298, "author_profile": "https://wordpress.stackexchange.com/users/62298", "pm_score": 0, "selected": false, "text": "<p>The final argument in the <code>wp-enqueue-script</code> <a href=\"https://developer.wordpress.org/reference/f...
2017/06/21
[ "https://wordpress.stackexchange.com/questions/270834", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120969/" ]
I have registered scripts which are supposed to load in head section. But for some reason I don't get these links loaded in head. Instead of loading scripts in head these are loading in footer. ``` add_action('init', 'my_enqueued_assets'); function my_enqueued_assets() { //Register Css wp_regist...
This happens because of the order of execution of your WordPress page. In your code it goes like this: 1. At `init`, which is early in the generation process of the page, you are registering the scripts. That is, you are telling WP that you want to use these later on. No html is generated. 2. At `init` you are also re...
270,855
<p>I'm editing the category.php template and I need an array of current category child's.</p> <p>I'm able to get an array with current category child's but there are too many keys, I'm using the following:</p> <pre><code>//get category ID $catego = get_category( get_query_var( 'cat' ) ); $cat_id = $ca...
[ { "answer_id": 270856, "author": "Senta", "author_id": 122290, "author_profile": "https://wordpress.stackexchange.com/users/122290", "pm_score": 0, "selected": false, "text": "<p>A foreach loop works:</p>\n\n<pre><code>$category_id = array();\nforeach ($catlist as $cat){\n $category_i...
2017/06/21
[ "https://wordpress.stackexchange.com/questions/270855", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85288/" ]
I'm editing the category.php template and I need an array of current category child's. I'm able to get an array with current category child's but there are too many keys, I'm using the following: ``` //get category ID $catego = get_category( get_query_var( 'cat' ) ); $cat_id = $catego->cat_ID; //list...
Try this : ``` // This converts the WP_Term Object to array. $catlist = json_decode(json_encode($catlist),true); $category_id = array_column($catlist, 'cat_ID'); print_r($category_id); ```
270,886
<p>I have a caching plugin (WP Rocket) so I am aware of the issues with wp-cron and scheduled posts. So, I disabled <strong>wp-cron</strong> and then set up a system cron. Now, I noticed that when a post is scheduled it's not set to <strong>HH:MM:00</strong> but has some number greater than <strong>0</strong> seconds....
[ { "answer_id": 270856, "author": "Senta", "author_id": 122290, "author_profile": "https://wordpress.stackexchange.com/users/122290", "pm_score": 0, "selected": false, "text": "<p>A foreach loop works:</p>\n\n<pre><code>$category_id = array();\nforeach ($catlist as $cat){\n $category_i...
2017/06/21
[ "https://wordpress.stackexchange.com/questions/270886", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122301/" ]
I have a caching plugin (WP Rocket) so I am aware of the issues with wp-cron and scheduled posts. So, I disabled **wp-cron** and then set up a system cron. Now, I noticed that when a post is scheduled it's not set to **HH:MM:00** but has some number greater than **0** seconds. So, I set the system cron to run wp-cron a...
Try this : ``` // This converts the WP_Term Object to array. $catlist = json_decode(json_encode($catlist),true); $category_id = array_column($catlist, 'cat_ID'); print_r($category_id); ```
270,901
<p>I am trying to create a new post with tags. Not having any luck and am not able to find any explanations online of what I may be doing wrong.</p> <pre><code>methods: { createPost: function() { let title = this.newPostTitle; let content = this.newPostContent; let postCategories = this.postCategories; ...
[ { "answer_id": 270905, "author": "mrben522", "author_id": 84703, "author_profile": "https://wordpress.stackexchange.com/users/84703", "pm_score": 1, "selected": false, "text": "<p>Sounds like it's expecting tag IDs as integers and you're sending strings. <code>split</code> returns an ar...
2017/06/21
[ "https://wordpress.stackexchange.com/questions/270901", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/121807/" ]
I am trying to create a new post with tags. Not having any luck and am not able to find any explanations online of what I may be doing wrong. ``` methods: { createPost: function() { let title = this.newPostTitle; let content = this.newPostContent; let postCategories = this.postCategories; let tags =...
Sounds like it's expecting tag IDs as integers and you're sending strings. `split` returns an array of strings, even if those strings are numbers. Instead of using `.split` try something like this ``` let tags = JSON.parse("[" + this.newPostTags + "]"); ``` If you really like split then you would do this: ``` let t...
270,910
<p>I apologize in advance for the likely misuse of coding terminology. I am not very skilled when it comes to this. </p> <p>In a separate website, I have links which when clicked bring up a .pdf of images corresponding to the feature's unique id: <br/> <code>/Images/{ID}.pdf</code> <br/> which results in something lik...
[ { "answer_id": 270905, "author": "mrben522", "author_id": 84703, "author_profile": "https://wordpress.stackexchange.com/users/84703", "pm_score": 1, "selected": false, "text": "<p>Sounds like it's expecting tag IDs as integers and you're sending strings. <code>split</code> returns an ar...
2017/06/21
[ "https://wordpress.stackexchange.com/questions/270910", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122313/" ]
I apologize in advance for the likely misuse of coding terminology. I am not very skilled when it comes to this. In a separate website, I have links which when clicked bring up a .pdf of images corresponding to the feature's unique id: `/Images/{ID}.pdf` which results in something like `example.com/Images/123...
Sounds like it's expecting tag IDs as integers and you're sending strings. `split` returns an array of strings, even if those strings are numbers. Instead of using `.split` try something like this ``` let tags = JSON.parse("[" + this.newPostTags + "]"); ``` If you really like split then you would do this: ``` let t...
270,930
<p>The idea is to immediately show the post matching the search term. The search term will be alphanumeric and unique for each post (set as title). It could override search in content (for performance), I just need the title.</p> <p>The search will be provided through a barcode reader, so it will be unique and precis...
[ { "answer_id": 270933, "author": "Sebastian Kurzynowski", "author_id": 108925, "author_profile": "https://wordpress.stackexchange.com/users/108925", "pm_score": 0, "selected": false, "text": "<p>Custom <code>template</code> where You have custom <code>query</code>. This <code>query</code...
2017/06/22
[ "https://wordpress.stackexchange.com/questions/270930", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122334/" ]
The idea is to immediately show the post matching the search term. The search term will be alphanumeric and unique for each post (set as title). It could override search in content (for performance), I just need the title. The search will be provided through a barcode reader, so it will be unique and precise. I'm tr...
Here's a solution that I came up with that uses a hidden field on the search form which we will later check in our filters to modify WP's default search/redirect behavior. This is the search form I used. Note the addition of the hidden field `barcode-reader` with a value of `1`. I added the search form to a page templ...
270,934
<p>I have cloned the "proceed to cart" button and float on the upper-right corner on the Woocommerce cart page. However I want this button to appear only when the browser is compressed (simulating mobile display), but go away when browser is stretched to the size of PC display. How to do it?</p> <p>Here is the code I ...
[ { "answer_id": 270933, "author": "Sebastian Kurzynowski", "author_id": 108925, "author_profile": "https://wordpress.stackexchange.com/users/108925", "pm_score": 0, "selected": false, "text": "<p>Custom <code>template</code> where You have custom <code>query</code>. This <code>query</code...
2017/06/22
[ "https://wordpress.stackexchange.com/questions/270934", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122069/" ]
I have cloned the "proceed to cart" button and float on the upper-right corner on the Woocommerce cart page. However I want this button to appear only when the browser is compressed (simulating mobile display), but go away when browser is stretched to the size of PC display. How to do it? Here is the code I came up, b...
Here's a solution that I came up with that uses a hidden field on the search form which we will later check in our filters to modify WP's default search/redirect behavior. This is the search form I used. Note the addition of the hidden field `barcode-reader` with a value of `1`. I added the search form to a page templ...
270,937
<p>I'm learning about coding plugin.</p> <p>I trying to create a form in plugin page and it can send mail.</p> <p>This is my code, but it doesn't work(I did not receive email and did not show any error).</p> <pre><code>add_action('admin_menu', 'add_contact_us_page'); function add_contact_us_page() { add_menu_p...
[ { "answer_id": 270943, "author": "Paul Burilichev", "author_id": 122299, "author_profile": "https://wordpress.stackexchange.com/users/122299", "pm_score": 2, "selected": true, "text": "<p>I suggest you first of all to separate code from markup, especially dividing your executing file lik...
2017/06/22
[ "https://wordpress.stackexchange.com/questions/270937", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118364/" ]
I'm learning about coding plugin. I trying to create a form in plugin page and it can send mail. This is my code, but it doesn't work(I did not receive email and did not show any error). ``` add_action('admin_menu', 'add_contact_us_page'); function add_contact_us_page() { add_menu_page( __( 'Contact Us...
I suggest you first of all to separate code from markup, especially dividing your executing file like the function `support_form()`. Next, please try to send email without form with hard coded message. It is possible you have mis-configuration on your server if you developing on local machine. And finally, you should...
270,951
<p>My footer is wide in my worspress page. But in one page it is not wide. How can i fix this problem. I use Simple Job Board plugin.</p> <p>This is the page with problem. <a href="http://balikesirkolej.com/jobs/sinif-ogretmeni/" rel="nofollow noreferrer">http://balikesirkolej.com/jobs/sinif-ogretmeni/</a></p> <p>Thi...
[ { "answer_id": 270943, "author": "Paul Burilichev", "author_id": 122299, "author_profile": "https://wordpress.stackexchange.com/users/122299", "pm_score": 2, "selected": true, "text": "<p>I suggest you first of all to separate code from markup, especially dividing your executing file lik...
2017/06/22
[ "https://wordpress.stackexchange.com/questions/270951", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122348/" ]
My footer is wide in my worspress page. But in one page it is not wide. How can i fix this problem. I use Simple Job Board plugin. This is the page with problem. <http://balikesirkolej.com/jobs/sinif-ogretmeni/> This is the page without problem <http://balikesirkolej.com/is-basvurusu/>
I suggest you first of all to separate code from markup, especially dividing your executing file like the function `support_form()`. Next, please try to send email without form with hard coded message. It is possible you have mis-configuration on your server if you developing on local machine. And finally, you should...
270,966
<p>i placed 'Gravity Forms User Registration Add-On's login widget in a page that registered users can login to my site. how do i redirect users to previous page that came from to login page after they submit login form? </p>
[ { "answer_id": 270976, "author": "Pirlanta Web", "author_id": 122358, "author_profile": "https://wordpress.stackexchange.com/users/122358", "pm_score": 0, "selected": false, "text": "<p>by help of gravity forms documentation i wrote this code , but it doesn't work!</p>\n\n<blockquote>\n ...
2017/06/22
[ "https://wordpress.stackexchange.com/questions/270966", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122358/" ]
i placed 'Gravity Forms User Registration Add-On's login widget in a page that registered users can login to my site. how do i redirect users to previous page that came from to login page after they submit login form?
here is the solution : ``` add_filter('gform_user_registration_login_args','registration_login_args',10, 1); function registration_login_args( $args ) { $args['login_redirect'] = rgpost('login_redirect') ? rgpost('login_redirect') : RGForms::get('HTTP_REFERER', $_SERVER); return $args; } ```
270,974
<p>I am trying to show cross sells on a single product page rather than in the cart:</p> <p>So far I've tried the following code:</p> <pre><code>&lt;?php do_action( 'woocommerce_after_single_product_summary_data_tabs' ); ?&gt; &lt;?php if ( $product-&gt;get_upsell_ids() ) : ?&gt; ...
[ { "answer_id": 270975, "author": "Alpesh Rathod", "author_id": 71458, "author_profile": "https://wordpress.stackexchange.com/users/71458", "pm_score": 1, "selected": false, "text": "<p>find this code and remove it </p>\n\n<p>1: get the ids of the cross sell products using the ‘_crosssel...
2017/06/22
[ "https://wordpress.stackexchange.com/questions/270974", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122104/" ]
I am trying to show cross sells on a single product page rather than in the cart: So far I've tried the following code: ``` <?php do_action( 'woocommerce_after_single_product_summary_data_tabs' ); ?> <?php if ( $product->get_upsell_ids() ) : ?> ...
``` add_action('woocommerce_after_single_product_summary', 'show_cross_sell_in_single_product', 30); function show_cross_sell_in_single_product(){ $crosssells = get_post_meta( get_the_ID(), '_crosssell_ids',true); if(empty($crosssells)){ return; } $args = array( 'post_type' => 'produc...
270,985
<p>If I update WordPress my custom data will be deleted from the wp_users table? I add new custom field and store data to users at this field if I update WordPress and WordPress needs to update this table my custom field will be deleted?</p>
[ { "answer_id": 270987, "author": "Ruturaj", "author_id": 43266, "author_profile": "https://wordpress.stackexchange.com/users/43266", "pm_score": 0, "selected": false, "text": "<p>No, your Custom User Data (i.e. User Meta) will remain safe in database even after you update your WordPress....
2017/06/22
[ "https://wordpress.stackexchange.com/questions/270985", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/117356/" ]
If I update WordPress my custom data will be deleted from the wp\_users table? I add new custom field and store data to users at this field if I update WordPress and WordPress needs to update this table my custom field will be deleted?
It is possible, especially if the update includes changes to the user table. The only way to be sure is to test it, but for future reference: **Never modify the scheme of WordPress Tables** If you need to add additional information about something, WordPress provides meta, user meta, site meta, post meta, comment met...
271,032
<p>it is very difficult to find an online article, or even in the WP codex, to create a section inside a section for the theme options. the below screenshot shows what i am trying to create: <a href="https://i.stack.imgur.com/ZA2xi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZA2xi.png" alt="ente...
[ { "answer_id": 270987, "author": "Ruturaj", "author_id": 43266, "author_profile": "https://wordpress.stackexchange.com/users/43266", "pm_score": 0, "selected": false, "text": "<p>No, your Custom User Data (i.e. User Meta) will remain safe in database even after you update your WordPress....
2017/06/22
[ "https://wordpress.stackexchange.com/questions/271032", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1354/" ]
it is very difficult to find an online article, or even in the WP codex, to create a section inside a section for the theme options. the below screenshot shows what i am trying to create: [![enter image description here](https://i.stack.imgur.com/ZA2xi.png)](https://i.stack.imgur.com/ZA2xi.png) i have the simple code ...
It is possible, especially if the update includes changes to the user table. The only way to be sure is to test it, but for future reference: **Never modify the scheme of WordPress Tables** If you need to add additional information about something, WordPress provides meta, user meta, site meta, post meta, comment met...
271,034
<p>Hello I have a small issue regarding my linking in my style.css</p> <p>For example:</p> <pre><code>@font-face { src: url('wp-content/themes/mytheme/fonts/font.ttf'); } </code></pre> <p>and</p> <pre><code>.div { background: url('wp-content/themes/mytheme/images/img.png'); } </code></pre> <p>My home page ...
[ { "answer_id": 271037, "author": "hwl", "author_id": 118366, "author_profile": "https://wordpress.stackexchange.com/users/118366", "pm_score": 2, "selected": false, "text": "<p>For the following structure:</p>\n\n<pre><code>/wp-content/\n /themes/\n /mytheme/\n style...
2017/06/22
[ "https://wordpress.stackexchange.com/questions/271034", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/112836/" ]
Hello I have a small issue regarding my linking in my style.css For example: ``` @font-face { src: url('wp-content/themes/mytheme/fonts/font.ttf'); } ``` and ``` .div { background: url('wp-content/themes/mytheme/images/img.png'); } ``` My home page works perfectly, assets link correctly but when I go to ...
You're using relative URLs that will always look inside the current URL structure. You either need to add a slash before wp-content, or put in the full URL to the resources. So for example: `src: url('/wp-content/themes/mytheme/fonts/font.ttf');` or `src: url('http://example.com/wp-content/themes/mytheme/fonts/font.t...
271,046
<p>I'm using the Twenty Seventeen theme and would like to add an image and some links to the left part under the page title. I searched all over the web, but couldn't find a good solution. Is there any way to accomplish that without creating a custom static page?</p> <p><a href="https://i.stack.imgur.com/iSxMG.png" r...
[ { "answer_id": 271720, "author": "Paul Burilichev", "author_id": 122299, "author_profile": "https://wordpress.stackexchange.com/users/122299", "pm_score": 0, "selected": false, "text": "<p>I suppose that the most obvious way is javascript which will be used after the page loaded. By the ...
2017/06/22
[ "https://wordpress.stackexchange.com/questions/271046", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122418/" ]
I'm using the Twenty Seventeen theme and would like to add an image and some links to the left part under the page title. I searched all over the web, but couldn't find a good solution. Is there any way to accomplish that without creating a custom static page? [![enter image description here](https://i.stack.imgur.com...
There doesn't seem to be any specific function to hook to, so a back-end solution would require altering the "/template-parts/page/content-page.php template file (via a [child theme](https://codex.wordpress.org/Child_Themes), preferably), namely adding your desired elements right before the closing `</header>` tag, for...
271,076
<h1>What I want to accomplish</h1> <p>I need an aside to pull the last 5 posts from a specific set of 5 categories. </p> <p>Not the latest of each, not the last 5 of each, but the last 5 total posts from the 5 categories.</p> <p>The category IDs are: 89,90,91,92,93</p> <h1>Background</h1> <p>I have 5 different cat...
[ { "answer_id": 271088, "author": "WizardCoder", "author_id": 121085, "author_profile": "https://wordpress.stackexchange.com/users/121085", "pm_score": 1, "selected": false, "text": "<p><code>get_category('91')</code> is always going to return an object of category ID 91's data. This mean...
2017/06/23
[ "https://wordpress.stackexchange.com/questions/271076", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104295/" ]
What I want to accomplish ========================= I need an aside to pull the last 5 posts from a specific set of 5 categories. Not the latest of each, not the last 5 of each, but the last 5 total posts from the 5 categories. The category IDs are: 89,90,91,92,93 Background ========== I have 5 different category...
`get_category('91')` is always going to return an object of category ID 91's data. This means your if statement is always going to return as true. You need to get the current iterated posts assigned category ID and then check if it is 91. ``` <!-- Return objects of current iterated posts associated categories --> $cat...
271,096
<p>What is the best way to modify the <code>&lt;header&gt;</code> element on all pages? I need to edit the <code>&lt;header&gt;</code> element on every page from:</p> <pre><code>&lt;header class="light"&gt; </code></pre> <p>To </p> <pre><code>&lt;header class="light" itemscope="itemscope" itemtype="http://schema.or...
[ { "answer_id": 271101, "author": "Por", "author_id": 31832, "author_profile": "https://wordpress.stackexchange.com/users/31832", "pm_score": 0, "selected": false, "text": "<p>I am not sure that that kind of filter is available in wordpress. But, you could do it though javascript. And mor...
2017/06/23
[ "https://wordpress.stackexchange.com/questions/271096", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51204/" ]
What is the best way to modify the `<header>` element on all pages? I need to edit the `<header>` element on every page from: ``` <header class="light"> ``` To ``` <header class="light" itemscope="itemscope" itemtype="http://schema.org/WPHeader"> ``` and I would like it to read Is there a way to do this via a cu...
The `<header>` elements are usually echoed directly by the theme. So without any hook or filter to change them. In that case, there is no way to change those elements with a function. Check your theme. You could, of course, use javascript to place you attributes, but that would happen on the user end. Search engines w...
271,193
<p>I know how to use shortcodes, even making them but what I need to understand is that a shortcode is a plain text stored in database as a post content, So how a plain text like this can be converted into dynamic.</p> <p>What I want to know is how an <code>x</code> text can be handled before the server send it to the...
[ { "answer_id": 271194, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 5, "selected": true, "text": "<p>When using <code>the_content()</code>, WordPress will run several filters to process the text coming from th...
2017/06/24
[ "https://wordpress.stackexchange.com/questions/271193", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102224/" ]
I know how to use shortcodes, even making them but what I need to understand is that a shortcode is a plain text stored in database as a post content, So how a plain text like this can be converted into dynamic. What I want to know is how an `x` text can be handled before the server send it to the browser to behave de...
When using `the_content()`, WordPress will run several filters to process the text coming from the editor. These filters process the content before it is sent to the browser. `do_shortcode` is the filter that handles shortcodes. From `/wp-includes/default-filters.php`: ``` // Shortcodes add_filter( 'the_content', 'd...
271,195
<p>I have a <a href="https://developer.wordpress.org/reference/functions/add_image_size/" rel="nofollow noreferrer">custom image size</a> <code>hello-image</code>:</p> <pre><code>add_image_size( 'hello-image', 700, 300, true ); </code></pre> <p>Whenever an image is uploaded, I compress the cropped <code>hello-image</...
[ { "answer_id": 271198, "author": "berend", "author_id": 120717, "author_profile": "https://wordpress.stackexchange.com/users/120717", "pm_score": 0, "selected": false, "text": "<p>Interesting, I tried it and the small image gets displayed 670x300 and the big image 700x300. Seems to me li...
2017/06/24
[ "https://wordpress.stackexchange.com/questions/271195", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24875/" ]
I have a [custom image size](https://developer.wordpress.org/reference/functions/add_image_size/) `hello-image`: ``` add_image_size( 'hello-image', 700, 300, true ); ``` Whenever an image is uploaded, I compress the cropped `hello-image` sized image to `40%` JPEG compression. It works great in all cases except... T...
*Some suggestions:* If you want to try out the *Image Editor API* you can try to replace ``` imagejpeg( $resource, $image, 35 ); ``` with: ``` $editor = wp_get_image_editor( $image ); if ( ! is_wp_error( $editor ) ) { $editor->set_quality( 35 ); $editor->save( $image ); } unset( $editor ); ``` Also tr...
271,226
<p>I am currently trying my hand at creating a WP theme using angular JS. I am trying to work through this tutorial: <a href="https://1fix.io/blog/2014/11/05/angularjs-json-api-wp-theme/" rel="nofollow noreferrer">https://1fix.io/blog/2014/11/05/angularjs-json-api-wp-theme/</a></p> <p>However, I am near the end of thi...
[ { "answer_id": 271227, "author": "Picard", "author_id": 118566, "author_profile": "https://wordpress.stackexchange.com/users/118566", "pm_score": 1, "selected": false, "text": "<p>Looking at the post format generated by the REST API I think you should access the title like:</p>\n\n<pre><...
2017/06/24
[ "https://wordpress.stackexchange.com/questions/271226", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122535/" ]
I am currently trying my hand at creating a WP theme using angular JS. I am trying to work through this tutorial: <https://1fix.io/blog/2014/11/05/angularjs-json-api-wp-theme/> However, I am near the end of this, and my ng-repeat is not returning a list of my posts. This is my scripts.js: ``` angular.module('app', ...
It looks like the tutorial you linked is using `success`, and you've changed it to `then`. The `success` method has been [deprecated](https://code.angularjs.org/1.5.10/docs/api/ng/service/$http#deprecation-notice), so you were correct to do that. However, because `then` returns data a little differently from `success...
271,244
<p>My wp-config.php already has </p> <pre><code>define('ALLOW_UNFILTERED_UPLOADS', true); </code></pre> <p>But when I upload a .nb file, it shows "This file type is not allowed. Please try another"</p> <p>How do I allow to upload any type of files? My WP version is 4.7.3.</p>
[ { "answer_id": 271246, "author": "Frank P. Walentynowicz", "author_id": 32851, "author_profile": "https://wordpress.stackexchange.com/users/32851", "pm_score": 2, "selected": false, "text": "<h3>Original Answer</h3>\n\n<p>Add the code below to your current theme's <code>functions.php</co...
2017/06/24
[ "https://wordpress.stackexchange.com/questions/271244", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58945/" ]
My wp-config.php already has ``` define('ALLOW_UNFILTERED_UPLOADS', true); ``` But when I upload a .nb file, it shows "This file type is not allowed. Please try another" How do I allow to upload any type of files? My WP version is 4.7.3.
### Original Answer Add the code below to your current theme's `functions.php`: ``` function wpse_add_nb_mime_type( $allowed_mimes ) { $allowed_mimes['nb'] = 'application/mathematica'; return $allowed_mimes; } add_filter( 'mime_types', 'wpse_add_nb_mime_type', 10, 1 ); ``` Remove `define`, mentioned in your...
271,258
<p>What i want to get and have no clue how start is:</p> <p>Query posts (for example from specific category, ordered by date) but to have the posts from same author numbered by there count in that posts list.</p> <blockquote> <p><strong>For example:</strong></p> <p><strong>Date:</strong> 1/8/2017 <strong>Title...
[ { "answer_id": 271260, "author": "Por", "author_id": 31832, "author_profile": "https://wordpress.stackexchange.com/users/31832", "pm_score": 0, "selected": false, "text": "<p>If you have deleted the posts, you can't no longer access it. If you would like to verify your deleted post are a...
2017/06/25
[ "https://wordpress.stackexchange.com/questions/271258", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122089/" ]
What i want to get and have no clue how start is: Query posts (for example from specific category, ordered by date) but to have the posts from same author numbered by there count in that posts list. > > **For example:** > > > **Date:** 1/8/2017 **Title:** Great post **Author:** John **Number:** 1 > > > **Date:**...
If your post isn't in Trash, then it was completely deleted. The only way to restore it is recovering your database from an earlier backup. If you don't have backups and your post was deleted from the database - there is no way to restore it.
271,289
<p>In a clean WordPress installation, how do you add meta keywords and meta description in head tag of my WordPress pages? There aren't any fields for these.</p> <p>I don't want to touch my code since I'm new to WordPress. I want to do this only by WordPress itself.</p>
[ { "answer_id": 271301, "author": "BenB", "author_id": 62909, "author_profile": "https://wordpress.stackexchange.com/users/62909", "pm_score": 0, "selected": false, "text": "<p>If you meaning how you could add the html tags to header:</p>\n\n<ol>\n<li>You could or copy the file header.php...
2017/06/25
[ "https://wordpress.stackexchange.com/questions/271289", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22989/" ]
In a clean WordPress installation, how do you add meta keywords and meta description in head tag of my WordPress pages? There aren't any fields for these. I don't want to touch my code since I'm new to WordPress. I want to do this only by WordPress itself.
I assume you are trying to add metadata to the header, such as Open Graph. To do so, you can hook into `wp_head` and output your content there directly. Add this piece of code to your theme's (or your child theme's) `functions.php` file: ``` //Hook to wp_head add_action('wp_head','add_my_metadata'); function add_my_me...
271,293
<p>The theme I'm using makes extensive use of internal stylesheets to style various types of pages and their elements. For example, through their plugin UI, I can configure a specific page's hero layout and content... including font, size and color for various text elements. After configuring the hero and publishing th...
[ { "answer_id": 271309, "author": "Cedon", "author_id": 80069, "author_profile": "https://wordpress.stackexchange.com/users/80069", "pm_score": 0, "selected": false, "text": "<p>You would add dependencies to your <code>wp_enqueue_style()</code> function calls.</p>\n\n<pre><code>function m...
2017/06/25
[ "https://wordpress.stackexchange.com/questions/271293", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/118789/" ]
The theme I'm using makes extensive use of internal stylesheets to style various types of pages and their elements. For example, through their plugin UI, I can configure a specific page's hero layout and content... including font, size and color for various text elements. After configuring the hero and publishing the p...
It's not elegant but it works. Add these lines to functions.php: ``` ob_start(); add_action('shutdown', function() { $final = ''; $levels = ob_get_level(); for ($i = 0; $i < $levels; $i++) { $final .= ob_get_clean(); } // append styles just before </head> $final = str_replace( "</hea...
271,295
<p>Let me start by saying I know there are other posts about this, and a lot of documentation is available for this topic, but none of these resources have helped me to solve my issue.</p> <p>I'm a beginner at creating plugins for WordPress. This is my first, so I'm sure I'm missing something simple, but everything I ...
[ { "answer_id": 271309, "author": "Cedon", "author_id": 80069, "author_profile": "https://wordpress.stackexchange.com/users/80069", "pm_score": 0, "selected": false, "text": "<p>You would add dependencies to your <code>wp_enqueue_style()</code> function calls.</p>\n\n<pre><code>function m...
2017/06/25
[ "https://wordpress.stackexchange.com/questions/271295", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122585/" ]
Let me start by saying I know there are other posts about this, and a lot of documentation is available for this topic, but none of these resources have helped me to solve my issue. I'm a beginner at creating plugins for WordPress. This is my first, so I'm sure I'm missing something simple, but everything I have read ...
It's not elegant but it works. Add these lines to functions.php: ``` ob_start(); add_action('shutdown', function() { $final = ''; $levels = ob_get_level(); for ($i = 0; $i < $levels; $i++) { $final .= ob_get_clean(); } // append styles just before </head> $final = str_replace( "</hea...
271,296
<p>I'm trying to format a number in a table cell with comma separators between thousands. The number is coming from a custom field generated in Advanced Custom Fields plugin, where it is required to be a number. </p> <p>(But I've also tried just entering the number directly in the below examples.)</p> <p>I'm getting ...
[ { "answer_id": 271302, "author": "BenB", "author_id": 62909, "author_profile": "https://wordpress.stackexchange.com/users/62909", "pm_score": 3, "selected": true, "text": "<p>Seems like the function you using is the <a href=\"https://www.advancedcustomfields.com/resources/the_field/\" re...
2017/06/25
[ "https://wordpress.stackexchange.com/questions/271296", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/41091/" ]
I'm trying to format a number in a table cell with comma separators between thousands. The number is coming from a custom field generated in Advanced Custom Fields plugin, where it is required to be a number. (But I've also tried just entering the number directly in the below examples.) I'm getting the correct numbe...
Seems like the function you using is the [the\_field](https://www.advancedcustomfields.com/resources/the_field/) function from of [ACF](https://www.advancedcustomfields.com) which is a function that outputs a string so the formatting number\_formatt dosent effect the output. This code: ``` <?php echo number_format...
271,322
<p>I'm trying to create a custom WordPress theme from scratch. As you can see, my file structure looks like this - footer.php, header.php, index.php, about.php, and contact.php within my theme folder:</p> <p><a href="https://i.stack.imgur.com/zLjPX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zLj...
[ { "answer_id": 271324, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 1, "selected": false, "text": "<p>Theme PHP files never get linked to or loaded directly. You create pages via the admin interface, whose content li...
2017/06/26
[ "https://wordpress.stackexchange.com/questions/271322", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/116029/" ]
I'm trying to create a custom WordPress theme from scratch. As you can see, my file structure looks like this - footer.php, header.php, index.php, about.php, and contact.php within my theme folder: [![enter image description here](https://i.stack.imgur.com/zLjPX.png)](https://i.stack.imgur.com/zLjPX.png) I've complet...
The answer to this question is yes, creating the pages in WordPress does allow you to change the link structure. What I needed to do was rework `index.php` so that it used the [WordPress Loop](https://codex.wordpress.org/The_Loop), and then displayed the front page as whatever the front page was set to in the WordPress...
271,327
<p>I manage a Wordpress site. The regular site (outside the admin login) is normal, but when I went to log in to the admin panel today, and got this brute force protection screen: <a href="https://i.stack.imgur.com/7Q2LP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7Q2LP.png" alt="brute force prev...
[ { "answer_id": 271329, "author": "Rick Hellewell", "author_id": 29416, "author_profile": "https://wordpress.stackexchange.com/users/29416", "pm_score": 0, "selected": false, "text": "<p>Do you have JetPack activated? It has some brute-force capabilities. </p>\n\n<p>I'd also suggest looki...
2017/06/26
[ "https://wordpress.stackexchange.com/questions/271327", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122594/" ]
I manage a Wordpress site. The regular site (outside the admin login) is normal, but when I went to log in to the admin panel today, and got this brute force protection screen: [![brute force prevention screen](https://i.stack.imgur.com/7Q2LP.png)](https://i.stack.imgur.com/7Q2LP.png) I don't have any brute force prot...
It looks like a poorly coded hosting-side protection. I say poorly coded because "Wordpress" is misspelled and it uses `<script language="javascript">`. Ask your host. This is definitely not WordPress native behaviour. Also, check your document root, as the file seems to be self-contained. It might be an extra HTML ...
271,338
<p>I've been trying to achieve a seemingly simple permalink structure customization without success. The goal is to always have <code>/aa-bb/</code> in front of each possible permalink, where aa is a language code and bb a country code. Whatever comes after this should behave exactly like it would normally. So where no...
[ { "answer_id": 271343, "author": "Por", "author_id": 31832, "author_profile": "https://wordpress.stackexchange.com/users/31832", "pm_score": 0, "selected": false, "text": "<p>I believe that you could use <a href=\"https://wordpress.org/plugins/polylang/\" rel=\"nofollow noreferrer\">poly...
2017/06/26
[ "https://wordpress.stackexchange.com/questions/271338", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20044/" ]
I've been trying to achieve a seemingly simple permalink structure customization without success. The goal is to always have `/aa-bb/` in front of each possible permalink, where aa is a language code and bb a country code. Whatever comes after this should behave exactly like it would normally. So where normally you'd h...
I'm working on a similar solution right now - the website must have language codes in all URLs (except the default language), but only pages are translatable in a way WPML/Polylang plugins do it. For news (blog) we just show posts in particular language (they are separate, not translations of each other). All the other...
271,341
<p>I am trying to Auto update the woocommerce cart after quantity is changed. The following code within the function.php is working, BUT updates the cart only if I change the quantity twice. Do you know how to fix that?</p> <pre><code>add_action( 'wp_footer', 'cart_update_qty_script' ); function cart_update_qty_script...
[ { "answer_id": 271369, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 1, "selected": false, "text": "<p>Your above code works pretty well in my local system. Don't know why its not working on your system. But y...
2017/06/26
[ "https://wordpress.stackexchange.com/questions/271341", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122426/" ]
I am trying to Auto update the woocommerce cart after quantity is changed. The following code within the function.php is working, BUT updates the cart only if I change the quantity twice. Do you know how to fix that? ``` add_action( 'wp_footer', 'cart_update_qty_script' ); function cart_update_qty_script() { if (i...
Almost one year late, but this question might still get visitors: You trigger the click, but the button doesn't have enough time to become enabled, so that is why, by the time you click the second time the button becomes enabled. Remove the "disabled" propriety before triggering the click: ``` <script> jQuery(...
271,350
<p>When trashing a post, also trash related comments so here is what i want, what‘s’ the sql Command</p> <p>I want to move some post to trash according their ID, what is the sql command,I can restore these post and their comments using sql command</p>
[ { "answer_id": 271354, "author": "Picard", "author_id": 118566, "author_profile": "https://wordpress.stackexchange.com/users/118566", "pm_score": 2, "selected": false, "text": "<p>I would discourage using raw SQL for moving a post to a trash or back, especially since there's a build in f...
2017/06/26
[ "https://wordpress.stackexchange.com/questions/271350", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122605/" ]
When trashing a post, also trash related comments so here is what i want, what‘s’ the sql Command I want to move some post to trash according their ID, what is the sql command,I can restore these post and their comments using sql command
I would discourage using raw SQL for moving a post to a trash or back, especially since there's a build in function for it: ``` wp_trash_post( $post_id ); ``` More about the [wp\_trash\_post()](https://codex.wordpress.org/Function_Reference/wp_trash_post) function. The opposite is: ``` wp_untrash_post( $post_id ...
271,375
<p>I have created a custom post type called 'articles' with all the same capabilities as the general post type &amp; I am using the same template to display both archives. </p> <p>The blog page that uses the built in posts shows posted on and by, </p> <p><a href="http://madebyfactory.com/backstage/" rel="nofollow nor...
[ { "answer_id": 271377, "author": "Den Isahac", "author_id": 113233, "author_profile": "https://wordpress.stackexchange.com/users/113233", "pm_score": 0, "selected": false, "text": "<p>This specific line in your code prevents the execution of the <code>factorypress_posted_on</code> method...
2017/06/26
[ "https://wordpress.stackexchange.com/questions/271375", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/114456/" ]
I have created a custom post type called 'articles' with all the same capabilities as the general post type & I am using the same template to display both archives. The blog page that uses the built in posts shows posted on and by, [Seen here](http://madebyfactory.com/backstage/) The custom post type page omits th...
If you're using a custom archive template I think you should add the conditional is\_post\_type\_archive() ``` if ( 'post' === get_post_type() || is_post_type_archive( array( 'articles' ) ) ); ```
271,425
<p>I am experimenting creating a WordPress plugin using create-react-app. To make things simple, I am trying to develop a click-to-tweet plugin.</p> <p>The shortcode part (in PHP ) looks like:</p> <pre><code>// Shortcode to output needed markup add_shortcode( 'react_click_to_tweet', 'react_click_to_tweet_test' ); fun...
[ { "answer_id": 271436, "author": "Cedon", "author_id": 80069, "author_profile": "https://wordpress.stackexchange.com/users/80069", "pm_score": 1, "selected": false, "text": "<p>WordPress has a function, <a href=\"https://developer.wordpress.org/reference/functions/wp_localize_script/\" r...
2017/06/26
[ "https://wordpress.stackexchange.com/questions/271425", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122642/" ]
I am experimenting creating a WordPress plugin using create-react-app. To make things simple, I am trying to develop a click-to-tweet plugin. The shortcode part (in PHP ) looks like: ``` // Shortcode to output needed markup add_shortcode( 'react_click_to_tweet', 'react_click_to_tweet_test' ); function react_click_to_...
WordPress has a function, [`wp_localize_script()`](https://developer.wordpress.org/reference/functions/wp_localize_script/) that can do this. You create an array of values that you want to access in your JavaScript file and then inject it as an object. You would modify your enqueue function like this: ``` function in...
271,443
<p>How do I call a custom post type with <code>WP_Query</code>?</p> <p>This is my custom post type. How do I display it in my code?</p> <pre><code>&lt;?php // Hooking up our function to theme setup add_action( 'init', 'create_post_type' ); add_theme_support('post-thumbnails'); function setup_types() { register_p...
[ { "answer_id": 271436, "author": "Cedon", "author_id": 80069, "author_profile": "https://wordpress.stackexchange.com/users/80069", "pm_score": 1, "selected": false, "text": "<p>WordPress has a function, <a href=\"https://developer.wordpress.org/reference/functions/wp_localize_script/\" r...
2017/06/27
[ "https://wordpress.stackexchange.com/questions/271443", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122658/" ]
How do I call a custom post type with `WP_Query`? This is my custom post type. How do I display it in my code? ``` <?php // Hooking up our function to theme setup add_action( 'init', 'create_post_type' ); add_theme_support('post-thumbnails'); function setup_types() { register_post_type('mytype', array( '...
WordPress has a function, [`wp_localize_script()`](https://developer.wordpress.org/reference/functions/wp_localize_script/) that can do this. You create an array of values that you want to access in your JavaScript file and then inject it as an object. You would modify your enqueue function like this: ``` function in...
271,448
<p>I want to show recent posts in my Android application and I'm using this end point to get the list of posts <a href="https://www.geekdashboard.com/wp-json/wp/v2/posts" rel="nofollow noreferrer">https://www.geekdashboard.com/wp-json/wp/v2/posts</a></p> <p>How can I get the complete URL of the featured image instead o...
[ { "answer_id": 271455, "author": "ville6000", "author_id": 62041, "author_profile": "https://wordpress.stackexchange.com/users/62041", "pm_score": 4, "selected": true, "text": "<p>You can modifiy REST API responses in themes functions.php like this.</p>\n\n<pre><code>function ws_register...
2017/06/27
[ "https://wordpress.stackexchange.com/questions/271448", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/116313/" ]
I want to show recent posts in my Android application and I'm using this end point to get the list of posts <https://www.geekdashboard.com/wp-json/wp/v2/posts> How can I get the complete URL of the featured image instead of its id? ``` "featured_media": 39913, ``` I don't want to use any plugins and is it possible ...
You can modifiy REST API responses in themes functions.php like this. ``` function ws_register_images_field() { register_rest_field( 'post', 'images', array( 'get_callback' => 'ws_get_images_urls', 'update_callback' => null, 'schema' => null,...
271,451
<p>Simple questions - how do I delete all categories programatically?</p> <p>For instance this returns a list of all categories </p> <pre><code>$args = array( "hide_empty" =&gt; 0, "type" =&gt; "post", "orderby" =&gt; "name", "order" =&gt; "ASC" ); $types = get_categories($args); </co...
[ { "answer_id": 271458, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 3, "selected": true, "text": "<p>Please have look on the below code block-</p>\n\n<pre><code>$args = array(\n \"hide_empty\" =&gt; 0,\n ...
2017/06/27
[ "https://wordpress.stackexchange.com/questions/271451", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122667/" ]
Simple questions - how do I delete all categories programatically? For instance this returns a list of all categories ``` $args = array( "hide_empty" => 0, "type" => "post", "orderby" => "name", "order" => "ASC" ); $types = get_categories($args); ``` How do I simply delete them so ...
Please have look on the below code block- ``` $args = array( "hide_empty" => 0, "type" => "post", "orderby" => "name", "order" => "ASC" ); $types = get_categories($args); foreach ( $types as $type) { wp_delete_category( $type->ID ); } ``` The function [`wp_delete_category`](https:/...
271,478
<p>How can I set the default subtitle in wordpress videos?</p> <p>Here is the shortcode that wp created after adding a video with a subtitle from media:</p> <pre><code>[video width="960" height="540" mp4="example.com/wp-content/uploads/test.mp4" ]&lt;track srclang="En" label="English" ki...
[ { "answer_id": 271458, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 3, "selected": true, "text": "<p>Please have look on the below code block-</p>\n\n<pre><code>$args = array(\n \"hide_empty\" =&gt; 0,\n ...
2017/06/27
[ "https://wordpress.stackexchange.com/questions/271478", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122684/" ]
How can I set the default subtitle in wordpress videos? Here is the shortcode that wp created after adding a video with a subtitle from media: ``` [video width="960" height="540" mp4="example.com/wp-content/uploads/test.mp4" ]<track srclang="En" label="English" kind="subtitles" src=...
Please have look on the below code block- ``` $args = array( "hide_empty" => 0, "type" => "post", "orderby" => "name", "order" => "ASC" ); $types = get_categories($args); foreach ( $types as $type) { wp_delete_category( $type->ID ); } ``` The function [`wp_delete_category`](https:/...
271,506
<p>Currently, my homepage contains a few of the latest posts. Therefore, when the homepage is shared via social media (i.e. Facebook), the thumbnail image which is displayed comes from the top image in the latest post.</p> <p>What I am trying to do, is to set it so that when the homepage is shared, a specific, default...
[ { "answer_id": 271508, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 4, "selected": true, "text": "<p>Several options:</p>\n\n<p><strong>Out-of-the-box plugin</strong></p>\n\n<p>If you're using Yoast WordPres...
2017/06/27
[ "https://wordpress.stackexchange.com/questions/271506", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/106748/" ]
Currently, my homepage contains a few of the latest posts. Therefore, when the homepage is shared via social media (i.e. Facebook), the thumbnail image which is displayed comes from the top image in the latest post. What I am trying to do, is to set it so that when the homepage is shared, a specific, default image wil...
Several options: **Out-of-the-box plugin** If you're using Yoast WordPress SEO, you have a built-in setting for Facebook images. Under your SEO > Social menu, go to the Facebook tab and select an image under "Frontpage settings." You can also set an image as a fallback, for posts that have no featured image, under "D...
271,511
<p>I'm registering custom post type in the plugin, but want to allow users of the plugin modify it afterwards (e.g. if they are installing for clients, etc.)</p> <pre><code>function create_reviews_post_type() { register_post_type('reviews', array( 'labels' =&gt; array( 'name' =&gt; __('Reviews'...
[ { "answer_id": 271513, "author": "Spartacus", "author_id": 32329, "author_profile": "https://wordpress.stackexchange.com/users/32329", "pm_score": 2, "selected": false, "text": "<p>You could do something simple like providing them filters to modify.</p>\n\n<pre><code>function create_revi...
2017/06/27
[ "https://wordpress.stackexchange.com/questions/271511", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/121208/" ]
I'm registering custom post type in the plugin, but want to allow users of the plugin modify it afterwards (e.g. if they are installing for clients, etc.) ``` function create_reviews_post_type() { register_post_type('reviews', array( 'labels' => array( 'name' => __('Reviews'), 'sing...
WordPress provides the [`register_post_type_args` filter](https://developer.wordpress.org/reference/hooks/register_post_type_args/) to let users do this: ``` function wpd_modify_post_type( $args, $post_type ){ if( 'reviews' == $post_type ){ $args['labels']['name'] = 'New name'; $args['labels']['sin...
271,515
<p>From what I've read (<a href="https://wordpress.stackexchange.com/questions/246679/check-if-favicon-is-set-in-customizer">Check if Favicon is set in Customizer</a> and others), it appears checking to see if a site icon is set in a theme should be easy. It doesn't seem to be working for me. I'd like to have a set of ...
[ { "answer_id": 271519, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 2, "selected": false, "text": "<p>Let's check if the site icon is set, and then print it:</p>\n\n<pre><code>&lt;?php if (get_option('site_ico...
2017/06/27
[ "https://wordpress.stackexchange.com/questions/271515", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31284/" ]
From what I've read ([Check if Favicon is set in Customizer](https://wordpress.stackexchange.com/questions/246679/check-if-favicon-is-set-in-customizer) and others), it appears checking to see if a site icon is set in a theme should be easy. It doesn't seem to be working for me. I'd like to have a set of default site i...
There exists a special function to check if the *site icon* is set, namely the [`has_site_icon()`](https://developer.wordpress.org/reference/functions/has_site_icon/) function. So you could try: ``` add_action( 'wp_head', 'wpse_default_site_icon', 99 ); add_action( 'login_head', 'wpse_default_site_icon', 99 ); f...
271,549
<p>I want to call a function on particular page like 'contact-us' from function.php of child theme.</p> <p>i tried this function</p> <pre><code> if( is_page('contact-us')) { echo "hello check"; //either in about us, or contact, or management page is in view } else { echo "Not working"; } </code></p...
[ { "answer_id": 271556, "author": "DrewAPicture", "author_id": 33309, "author_profile": "https://wordpress.stackexchange.com/users/33309", "pm_score": 3, "selected": true, "text": "<p>The problem is that you're trying to use <code>is_page()</code>, a conditional function intended only to ...
2017/06/28
[ "https://wordpress.stackexchange.com/questions/271549", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/116990/" ]
I want to call a function on particular page like 'contact-us' from function.php of child theme. i tried this function ``` if( is_page('contact-us')) { echo "hello check"; //either in about us, or contact, or management page is in view } else { echo "Not working"; } ``` But getting else part on e...
The problem is that you're trying to use `is_page()`, a conditional function intended only to run adjacent to the query, too early. Try running your code inside a callback that 1) only fires on the front-end, 2) fires after the page has partially loaded. For instance, `wp_head`. ``` function prefix_run_on_contact_us()...
271,550
<p>I'm looking for widget or php query which I will be able to use as something like "on this day in history".</p> <p>This query I want to show: Posts published in the past on the same day and month, from whole years of publication.</p> <p>Thank you in advance for help. </p>
[ { "answer_id": 271556, "author": "DrewAPicture", "author_id": 33309, "author_profile": "https://wordpress.stackexchange.com/users/33309", "pm_score": 3, "selected": true, "text": "<p>The problem is that you're trying to use <code>is_page()</code>, a conditional function intended only to ...
2017/06/28
[ "https://wordpress.stackexchange.com/questions/271550", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122729/" ]
I'm looking for widget or php query which I will be able to use as something like "on this day in history". This query I want to show: Posts published in the past on the same day and month, from whole years of publication. Thank you in advance for help.
The problem is that you're trying to use `is_page()`, a conditional function intended only to run adjacent to the query, too early. Try running your code inside a callback that 1) only fires on the front-end, 2) fires after the page has partially loaded. For instance, `wp_head`. ``` function prefix_run_on_contact_us()...
271,563
<p>I am trying to use WordPress with a bootstrap template, class <code>navbar-fixed-top</code> is conflicting with <code>body_class();</code></p> <p>Is there a workaround to this problem?</p> <h2>Edit 1:</h2> <p>Additional details,</p> <p>I can't see the nav, thet's the main issue. I'm trying to use <code>&lt;?php ...
[ { "answer_id": 271885, "author": "Amoy N", "author_id": 100875, "author_profile": "https://wordpress.stackexchange.com/users/100875", "pm_score": 1, "selected": false, "text": "<p>Why not use a navwalker to create your bootstrap menu?\nTry <a href=\"https://github.com/wp-bootstrap/wp-boo...
2017/06/28
[ "https://wordpress.stackexchange.com/questions/271563", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/97698/" ]
I am trying to use WordPress with a bootstrap template, class `navbar-fixed-top` is conflicting with `body_class();` Is there a workaround to this problem? Edit 1: ------- Additional details, I can't see the nav, thet's the main issue. I'm trying to use `<?php body_class(); ?>` to fix this up but no results. [![ca...
Why not use a navwalker to create your bootstrap menu? Try <https://github.com/wp-bootstrap/wp-bootstrap-navwalker> You can get the fixed-top to add to the menu ``` <nav class="navbar navbar-default navbar-fixed-top" temscope="itemscope" itemtype="http://schema.org/SiteNavigationElement" role="navigation"> ...
271,612
<p>I am trying to find a function which will add <strong>ADDITIONAL</strong> button next to the standard "Add to cart" button in woo commerce product page.</p> <ol> <li>I added a woocommerce folder into my childe theme in order to modify single-product => add-to-cart => simple.php</li> <li>Inside simple.php I found th...
[ { "answer_id": 271634, "author": "LWS-Mo", "author_id": 88895, "author_profile": "https://wordpress.stackexchange.com/users/88895", "pm_score": 5, "selected": true, "text": "<p>You dont need to modify your template files for this, instead you can use the WooCommerce hook <code>woocommerc...
2017/06/28
[ "https://wordpress.stackexchange.com/questions/271612", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7730/" ]
I am trying to find a function which will add **ADDITIONAL** button next to the standard "Add to cart" button in woo commerce product page. 1. I added a woocommerce folder into my childe theme in order to modify single-product => add-to-cart => simple.php 2. Inside simple.php I found the standard "Add to cart" button ...
You dont need to modify your template files for this, instead you can use the WooCommerce hook `woocommerce_after_add_to_cart_button`. This hook will add content after the "Add to cart" button. If the customer clicks on this button, the product should get added to the cart, and the customer should be send to the check...
271,622
<p>Say I wanted to add a site-wide snippet of JavaScript to my website but was using a child theme so as to not tamper with the original theme. Would I have to add a new .js file to the child theme, or could the script go into functions.php? Or, even better, could it be added with a plugin?</p>
[ { "answer_id": 271624, "author": "kero", "author_id": 108180, "author_profile": "https://wordpress.stackexchange.com/users/108180", "pm_score": 0, "selected": false, "text": "<p>Yes.</p>\n\n<p>Add the javascript file to the folder and call <a href=\"https://developer.wordpress.org/refere...
2017/06/28
[ "https://wordpress.stackexchange.com/questions/271622", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/120427/" ]
Say I wanted to add a site-wide snippet of JavaScript to my website but was using a child theme so as to not tamper with the original theme. Would I have to add a new .js file to the child theme, or could the script go into functions.php? Or, even better, could it be added with a plugin?
You can do different things: 1. **Enqueue** the new JS file via `plugin` 2. **Enqueue** the new JS file via `functions.php` 3. Add your JS code into `functions.php` through `wp_header` or `wp_footer` For adding new JS files to a wordpress site you should **enqueue** these files with `wp_enqueue_style()` and/or `wp_en...
271,625
<p>I am able to download a file in csv format for my table , but how to add column headers to the same file . </p> <p>The current code is following -</p> <pre><code>// load wpdb $path = $_SERVER['DOCUMENT_ROOT']; include_once $path . '/wp-load.php'; ...
[ { "answer_id": 271635, "author": "Sebastian Kurzynowski", "author_id": 108925, "author_profile": "https://wordpress.stackexchange.com/users/108925", "pm_score": 1, "selected": false, "text": "<p>You should build Your columns schemat in array. Than add this on the top of csv and than You ...
2017/06/28
[ "https://wordpress.stackexchange.com/questions/271625", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/92345/" ]
I am able to download a file in csv format for my table , but how to add column headers to the same file . The current code is following - ``` // load wpdb $path = $_SERVER['DOCUMENT_ROOT']; include_once $path . '/wp-load.php'; global $wpdb; ...
You should build Your columns schemat in array. Than add this on the top of csv and than You can add content of Your csv. ``` $string_headers = 'post_title,post_author,etc....'; if(count($results) > 0) { $result = $string_header; foreach($results as $result){ $tmp_result = array_values($result); $resu...
271,628
<p>I am trying to customize the search results for a generic search, but <strong>only</strong> if it's using the <code>search.php</code> template. I have other searches on my site, and I don't want this filter interfering with them. Everything works on the following code, except for <code>is_page_template('search.php')...
[ { "answer_id": 271632, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 2, "selected": false, "text": "<p>There is a workaround that might cost you an extra query. However, @Milo once mentioned that WordPress is p...
2017/06/28
[ "https://wordpress.stackexchange.com/questions/271628", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/94213/" ]
I am trying to customize the search results for a generic search, but **only** if it's using the `search.php` template. I have other searches on my site, and I don't want this filter interfering with them. Everything works on the following code, except for `is_page_template('search.php')`. Once I enter that line of c...
Lets break it down step by step: `if ($query->is_search && is_page_template('search')) {` There are 3 problems here `is_page_template` ------------------ `search.php` isn't a page template, that's not how the search template is loaded. So this won't work. But if it did work, there's a new problem. Functions such a...
271,661
<p>My loop displays featured posts and then posts in reverse chronological order. </p> <p>However when I use <code>&lt;?php echo get_previous_post(); ?&gt;</code> it grabs posts in reverse chronological order.</p> <p>How do I add a filter to the previous post function similiar to <a href="https://wordpress.stackexc...
[ { "answer_id": 271632, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 2, "selected": false, "text": "<p>There is a workaround that might cost you an extra query. However, @Milo once mentioned that WordPress is p...
2017/06/28
[ "https://wordpress.stackexchange.com/questions/271661", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122778/" ]
My loop displays featured posts and then posts in reverse chronological order. However when I use `<?php echo get_previous_post(); ?>` it grabs posts in reverse chronological order. How do I add a filter to the previous post function similiar to [this](https://wordpress.stackexchange.com/questions/194597/how-can-i-g...
Lets break it down step by step: `if ($query->is_search && is_page_template('search')) {` There are 3 problems here `is_page_template` ------------------ `search.php` isn't a page template, that's not how the search template is loaded. So this won't work. But if it did work, there's a new problem. Functions such a...
271,662
<p>I have a subdomain multisite network. I have implemented a system in order to create new subdomains programmatically, just filling a form.</p> <p>Now I have a need: when a new blog is created, I'd like to set its permalink structure to /postname/.</p> <p>I've tried these solutions:</p> <p><strong><a href="https:/...
[ { "answer_id": 271665, "author": "WebElaine", "author_id": 102815, "author_profile": "https://wordpress.stackexchange.com/users/102815", "pm_score": 1, "selected": false, "text": "<p>You should be able to create an mu-plugin (required plugin) that fires on the <code>activate_blog</code> ...
2017/06/28
[ "https://wordpress.stackexchange.com/questions/271662", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32321/" ]
I have a subdomain multisite network. I have implemented a system in order to create new subdomains programmatically, just filling a form. Now I have a need: when a new blog is created, I'd like to set its permalink structure to /postname/. I've tried these solutions: **[How to set permalink structure via functions....
With a "mu-plugins", the solution is... ``` add_action( 'wpmu_new_blog', function( $blog_id ){ switch_to_blog( $blog_id ); global $wp_rewrite; $wp_rewrite->set_permalink_structure('/%postname%/'); $wp_rewrite->flush_rules(); restore_current_blog(); }, 10 ); ```
271,672
<p>I want my WP <strong>default gallery</strong> to go from 4 columns on computer screens down to 2 on mobile devices.</p>
[ { "answer_id": 271675, "author": "DigitalDesigner", "author_id": 111895, "author_profile": "https://wordpress.stackexchange.com/users/111895", "pm_score": 3, "selected": true, "text": "<p>You can try using css to control the visual layout.</p>\n\n<p>I have tested on my dev server and thi...
2017/06/28
[ "https://wordpress.stackexchange.com/questions/271672", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122774/" ]
I want my WP **default gallery** to go from 4 columns on computer screens down to 2 on mobile devices.
You can try using css to control the visual layout. I have tested on my dev server and this was successful. ``` @media only screen and ( max-width: 320px ) { .gallery-item {float:left;width:50% !important;} } ``` what we have done is set the column to 50% the total container width when viewing on devices sm...
271,677
<p><strong>Short description:</strong> I've created a bunch of terms and attached them to an existing taxonomy for a certain custom-post that already exist using the SQL code below. After doing this I'd like to update wp_term_taxonomy.count . I set it to 0 (dumb?) so the new terms are not appearing in search forms (the...
[ { "answer_id": 271675, "author": "DigitalDesigner", "author_id": 111895, "author_profile": "https://wordpress.stackexchange.com/users/111895", "pm_score": 3, "selected": true, "text": "<p>You can try using css to control the visual layout.</p>\n\n<p>I have tested on my dev server and thi...
2017/06/28
[ "https://wordpress.stackexchange.com/questions/271677", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/121811/" ]
**Short description:** I've created a bunch of terms and attached them to an existing taxonomy for a certain custom-post that already exist using the SQL code below. After doing this I'd like to update wp\_term\_taxonomy.count . I set it to 0 (dumb?) so the new terms are not appearing in search forms (they do appear on...
You can try using css to control the visual layout. I have tested on my dev server and this was successful. ``` @media only screen and ( max-width: 320px ) { .gallery-item {float:left;width:50% !important;} } ``` what we have done is set the column to 50% the total container width when viewing on devices sm...
271,682
<h2><strong>The Problem</strong></h2> <p>So I installed a plugin (iHomeFinder's Optima Express), and it works perfectly fine. The page it made is <a href="http://conradbowenrealestate.com/homes-for-sale-search/" rel="nofollow noreferrer">conradbowenrealestate.com/homes-for-sale-search</a>. However, this page isn't m...
[ { "answer_id": 271675, "author": "DigitalDesigner", "author_id": 111895, "author_profile": "https://wordpress.stackexchange.com/users/111895", "pm_score": 3, "selected": true, "text": "<p>You can try using css to control the visual layout.</p>\n\n<p>I have tested on my dev server and thi...
2017/06/28
[ "https://wordpress.stackexchange.com/questions/271682", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/115413/" ]
**The Problem** --------------- So I installed a plugin (iHomeFinder's Optima Express), and it works perfectly fine. The page it made is [conradbowenrealestate.com/homes-for-sale-search](http://conradbowenrealestate.com/homes-for-sale-search/). However, this page isn't made in WordPress, it doesn't even exist to it....
You can try using css to control the visual layout. I have tested on my dev server and this was successful. ``` @media only screen and ( max-width: 320px ) { .gallery-item {float:left;width:50% !important;} } ``` what we have done is set the column to 50% the total container width when viewing on devices sm...
271,740
<p>My website is currently on localhost but painfully slow.</p> <p>I am going to upload it to <code>000webhost.com</code> who offer a free hosting service. I am keen to see if this speeds things up.</p> <p>I was wondering if there is anything I need to do when uploading my website, taking off localhost and moving to ...
[ { "answer_id": 271675, "author": "DigitalDesigner", "author_id": 111895, "author_profile": "https://wordpress.stackexchange.com/users/111895", "pm_score": 3, "selected": true, "text": "<p>You can try using css to control the visual layout.</p>\n\n<p>I have tested on my dev server and thi...
2017/06/29
[ "https://wordpress.stackexchange.com/questions/271740", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122361/" ]
My website is currently on localhost but painfully slow. I am going to upload it to `000webhost.com` who offer a free hosting service. I am keen to see if this speeds things up. I was wondering if there is anything I need to do when uploading my website, taking off localhost and moving to `000webhost.com`. Currently...
You can try using css to control the visual layout. I have tested on my dev server and this was successful. ``` @media only screen and ( max-width: 320px ) { .gallery-item {float:left;width:50% !important;} } ``` what we have done is set the column to 50% the total container width when viewing on devices sm...
271,786
<p>I have two WordPress websites on the same domain and on the same database. All my accounts created on the first main website also works on the second website and is automatically logging in.</p> <p>But the administrator isn't functioning anymore. If I sign up as administrator and go to the intranet website I should...
[ { "answer_id": 271792, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p>User roles aren't stored in the user or user meta table, they have their own table, and they're on a per sit...
2017/06/29
[ "https://wordpress.stackexchange.com/questions/271786", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122754/" ]
I have two WordPress websites on the same domain and on the same database. All my accounts created on the first main website also works on the second website and is automatically logging in. But the administrator isn't functioning anymore. If I sign up as administrator and go to the intranet website I should be able t...
User roles aren't stored in the user or user meta table, they have their own table, and they're on a per site basis so reusing them isn't so simple for setups like this. In your case it would be **significantly** easier to use a multisite install using subdirectories rather than subdomains, then all of this would be t...
271,814
<p>In my projects I have some components which I use in a lot of custom Plugins as well as in some custom coded Themes like e.g. admin image or video selectors.</p> <p>Those I am holding in custom git repositories. However as those components are used in both - themes and plugins - I always have to manually change the...
[ { "answer_id": 271819, "author": "Rarst", "author_id": 847, "author_profile": "https://wordpress.stackexchange.com/users/847", "pm_score": 2, "selected": false, "text": "<blockquote>\n <p>Is there a way to determine if my current PHP file is within the plugins' folder or within the them...
2017/06/29
[ "https://wordpress.stackexchange.com/questions/271814", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12035/" ]
In my projects I have some components which I use in a lot of custom Plugins as well as in some custom coded Themes like e.g. admin image or video selectors. Those I am holding in custom git repositories. However as those components are used in both - themes and plugins - I always have to manually change the URL gette...
> > Is there a way to determine if my current PHP file is within the plugins' folder or within the themes' folder > > > Broadly you always have path to current file (`__FILE__`) so you can always examine it for where you are and compare with context. This might be good enough in custom site, but likely too brittle...
271,820
<p>I have used the Advanced Custom Fields plugin two create two fields, review score and review summary.</p> <p>I can display these fields on a post no problem, but it displays after everything else like share buttons, author box, pagination, etc.</p> <p>How can I modify my code so that the custom fields show above e...
[ { "answer_id": 271845, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 1, "selected": false, "text": "<p>Plugins typically insert their content via <code>the_content</code> filter. The filter runs when <code>the_content...
2017/06/29
[ "https://wordpress.stackexchange.com/questions/271820", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/121998/" ]
I have used the Advanced Custom Fields plugin two create two fields, review score and review summary. I can display these fields on a post no problem, but it displays after everything else like share buttons, author box, pagination, etc. How can I modify my code so that the custom fields show above everything else, j...
Plugins typically insert their content via `the_content` filter. The filter runs when `the_content()` function is called, and passes the content through the filter before output. Remember, with a filter, you need to append to the existing content, then `return` the results. ``` add_filter( 'the_content', 'wpd_content...
271,826
<p>I am creating a custom post type and I added the comment option for it. Now all the comments submitted in that post type are also added to the general comment section. </p> <p>How can I make sure the comment for a specific post type are separated from the general comments in the dashboard area? </p>
[ { "answer_id": 271831, "author": "Rick Hellewell", "author_id": 29416, "author_profile": "https://wordpress.stackexchange.com/users/29416", "pm_score": 0, "selected": false, "text": "<p>Comments need to belong to a post $id. Check your code to make sure that the comment-saving/processing...
2017/06/29
[ "https://wordpress.stackexchange.com/questions/271826", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122864/" ]
I am creating a custom post type and I added the comment option for it. Now all the comments submitted in that post type are also added to the general comment section. How can I make sure the comment for a specific post type are separated from the general comments in the dashboard area?
All comments are just listed under **"Comments"** there is no attribute or parameter which creates a seperate **"Comments"** section/page for your custom post-type. Atleast not that I know of. *However, you could add a filter to the comments list, to filter all comments based on post-types.* It will be just like a...
271,832
<p>I've migrated a site from a live server to a localhost using the WP Migrate DB plugin. I've done this process a couple of times before and it's all been fine. This time however I've migrated a site from an https: connection and I can't get into the site on my localhost. It gives me the following error:</p> <pre><...
[ { "answer_id": 271833, "author": "Rick Hellewell", "author_id": 29416, "author_profile": "https://wordpress.stackexchange.com/users/29416", "pm_score": 2, "selected": false, "text": "<p>In the wp_options table, you will find two rows that have the site URL. Change those two values.</p>\n...
2017/06/29
[ "https://wordpress.stackexchange.com/questions/271832", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/106972/" ]
I've migrated a site from a live server to a localhost using the WP Migrate DB plugin. I've done this process a couple of times before and it's all been fine. This time however I've migrated a site from an https: connection and I can't get into the site on my localhost. It gives me the following error: ``` This site c...
This is because the `site_url` and `homeurl` of your original installation are set to HTTPS in the database, so you can't access your website on localhost unless you: 1. Change these values to non-ssl 2. Install a SSL certificate on localhost I will only explain the first case since installing a certificate is out of...
271,876
<p>I want to create new post page after every 25 (li /li) tags. Is it possible?</p>
[ { "answer_id": 271833, "author": "Rick Hellewell", "author_id": 29416, "author_profile": "https://wordpress.stackexchange.com/users/29416", "pm_score": 2, "selected": false, "text": "<p>In the wp_options table, you will find two rows that have the site URL. Change those two values.</p>\n...
2017/06/30
[ "https://wordpress.stackexchange.com/questions/271876", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122896/" ]
I want to create new post page after every 25 (li /li) tags. Is it possible?
This is because the `site_url` and `homeurl` of your original installation are set to HTTPS in the database, so you can't access your website on localhost unless you: 1. Change these values to non-ssl 2. Install a SSL certificate on localhost I will only explain the first case since installing a certificate is out of...
271,877
<p>I am trying to filter by a meta query but no matter what I try I can not make it work.</p> <p>Basically I want this query in through the rest API:</p> <pre><code>wp-json/wp/v2/books?meta_query[relation]=OR&amp;meta_query[0][key]=arkivera&amp;meta_query[0][value]=1&amp;meta_query[0][compare]== </code></pre> <p>Ive...
[ { "answer_id": 271887, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 5, "selected": true, "text": "<p>You can write your own REST handler for custom queries if you want. In your case, the query can done by doin...
2017/06/30
[ "https://wordpress.stackexchange.com/questions/271877", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/93224/" ]
I am trying to filter by a meta query but no matter what I try I can not make it work. Basically I want this query in through the rest API: ``` wp-json/wp/v2/books?meta_query[relation]=OR&meta_query[0][key]=arkivera&meta_query[0][value]=1&meta_query[0][compare]== ``` Ive tried several different custom fields but it...
You can write your own REST handler for custom queries if you want. In your case, the query can done by doing so: ``` // Register a REST route add_action( 'rest_api_init', function () { //Path to meta query route register_rest_route( 'tchernitchenko/v2', '/my_meta_query/', array( 'methods' => 'GET'...
271,878
<p>I am used to creating websites outside of wordpress just using HTML, CSS and JS. Normally if I want to create a link to a page, about-us.html, I simply add:</p> <pre><code>&lt;a href="/about-us.html"&gt;About Us&lt;/a&gt; </code></pre> <p>I have an HTML based template which I converted to wordpress theme via FTP. ...
[ { "answer_id": 271881, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 3, "selected": true, "text": "<p>WordPress doesn't work that way. In WordPress, none of the posts or pages that you visit actually <em>exist<...
2017/06/30
[ "https://wordpress.stackexchange.com/questions/271878", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122624/" ]
I am used to creating websites outside of wordpress just using HTML, CSS and JS. Normally if I want to create a link to a page, about-us.html, I simply add: ``` <a href="/about-us.html">About Us</a> ``` I have an HTML based template which I converted to wordpress theme via FTP. If I want to accomplish the same thing...
WordPress doesn't work that way. In WordPress, none of the posts or pages that you visit actually *exist* anywhere on the disk. The content is grabbed from database and then the template files are filled with them and sent to browser. In your case, you should create a file name `about-us.php` instead of `about-us.html...
271,879
<p>So this is what I'm fruitlessly trying to achieve - let's say there's a menu like the following...</p> <p><a href="https://i.stack.imgur.com/yIbO2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yIbO2.png" alt="enter image description here"></a></p> <p>What I'd like to do is to generate a menu w...
[ { "answer_id": 271881, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 3, "selected": true, "text": "<p>WordPress doesn't work that way. In WordPress, none of the posts or pages that you visit actually <em>exist<...
2017/06/30
[ "https://wordpress.stackexchange.com/questions/271879", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122407/" ]
So this is what I'm fruitlessly trying to achieve - let's say there's a menu like the following... [![enter image description here](https://i.stack.imgur.com/yIbO2.png)](https://i.stack.imgur.com/yIbO2.png) What I'd like to do is to generate a menu with just the title and the link of the current page the user is on a...
WordPress doesn't work that way. In WordPress, none of the posts or pages that you visit actually *exist* anywhere on the disk. The content is grabbed from database and then the template files are filled with them and sent to browser. In your case, you should create a file name `about-us.php` instead of `about-us.html...
271,893
<p>When I do something like:</p> <pre><code>$prevPost = get_previous_post(); </code></pre> <p>I can then do:</p> <pre><code>$prevPost-&gt;post_title; $prevPost-&gt;post_content; ... </code></pre> <p>Why can't I get the permalink?</p> <pre><code>$prevPost-&gt;post_url; // NULL $prevPost-&gt;post_permalink; // NULL ...
[ { "answer_id": 271881, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 3, "selected": true, "text": "<p>WordPress doesn't work that way. In WordPress, none of the posts or pages that you visit actually <em>exist<...
2017/06/30
[ "https://wordpress.stackexchange.com/questions/271893", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122905/" ]
When I do something like: ``` $prevPost = get_previous_post(); ``` I can then do: ``` $prevPost->post_title; $prevPost->post_content; ... ``` Why can't I get the permalink? ``` $prevPost->post_url; // NULL $prevPost->post_permalink; // NULL ``` Obviously, as stated in the [codex](https://codex.wordpress.org/Cl...
WordPress doesn't work that way. In WordPress, none of the posts or pages that you visit actually *exist* anywhere on the disk. The content is grabbed from database and then the template files are filled with them and sent to browser. In your case, you should create a file name `about-us.php` instead of `about-us.html...
271,927
<p>I'm wondering what the best practice is for storing images, css, js etc in my file manager. I've come up with these 2 possible options as my preferred options.</p> <ol> <li>Create folders (<code>images/</code>, <code>css/</code>, <code>js/</code>) in the root directory</li> </ol> <p>And refer to these files like <...
[ { "answer_id": 271881, "author": "Johansson", "author_id": 94498, "author_profile": "https://wordpress.stackexchange.com/users/94498", "pm_score": 3, "selected": true, "text": "<p>WordPress doesn't work that way. In WordPress, none of the posts or pages that you visit actually <em>exist<...
2017/06/30
[ "https://wordpress.stackexchange.com/questions/271927", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122624/" ]
I'm wondering what the best practice is for storing images, css, js etc in my file manager. I've come up with these 2 possible options as my preferred options. 1. Create folders (`images/`, `css/`, `js/`) in the root directory And refer to these files like `<img src="/images/image1.png">` for example... OR 2. Creat...
WordPress doesn't work that way. In WordPress, none of the posts or pages that you visit actually *exist* anywhere on the disk. The content is grabbed from database and then the template files are filled with them and sent to browser. In your case, you should create a file name `about-us.php` instead of `about-us.html...
271,934
<p>So, I'm totally new to WordPress and trying to "convert" a static site to a WP theme.</p> <p>I have a page where I'd like to use the featured image as a background for a div.</p> <p>I was wondering what is the best way or whats the convention to do that? </p> <p>It doesn't matter if its a featured image or whatev...
[ { "answer_id": 271941, "author": "samjco", "author_id": 29133, "author_profile": "https://wordpress.stackexchange.com/users/29133", "pm_score": 0, "selected": false, "text": "<p><strong>Here is an example of in-page styling. :)</strong> </p>\n\n<pre><code>&lt;?php get_header(); ...
2017/06/30
[ "https://wordpress.stackexchange.com/questions/271934", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/70511/" ]
So, I'm totally new to WordPress and trying to "convert" a static site to a WP theme. I have a page where I'd like to use the featured image as a background for a div. I was wondering what is the best way or whats the convention to do that? It doesn't matter if its a featured image or whatever, I just want the user...
There's two possible options in creating a stylesheet from a dynamically generated value. The first options is **Inline stylesheet**, as follows: ``` <div id="hero" style="background-image: url(<?php // TODO retrieve image here. ?>); "> </div> ``` And the second options is to use an **Internal stylesheet**, and p...
271,964
<p>After a user registers using WooCommerce's registration form, I want to redirect them to a custom page, such as my other website, instead of the <code>my-account</code> page. </p> <pre><code>add_action('woocommerce_registration_redirect', 'ps_wc_registration_redirect',10); function ps_wc_registration_redirect( $re...
[ { "answer_id": 271985, "author": "Regolith", "author_id": 103884, "author_profile": "https://wordpress.stackexchange.com/users/103884", "pm_score": 0, "selected": false, "text": "<p>try setting the function as below, also there is no need of parameter to the function if you are manually ...
2017/07/01
[ "https://wordpress.stackexchange.com/questions/271964", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122941/" ]
After a user registers using WooCommerce's registration form, I want to redirect them to a custom page, such as my other website, instead of the `my-account` page. ``` add_action('woocommerce_registration_redirect', 'ps_wc_registration_redirect',10); function ps_wc_registration_redirect( $redirect_to ) { $redi...
Internally, WooCommerce uses WordPress' `wp_safe_redirect()` which does not allow redirects to external hosts. In order to get around this, we must add our desired host to the whitelist. The whitelist can be modified using the `allowed_redirect_hosts` which has been demonstrated below: ``` /** * Adds example.com to t...
271,968
<p>I have been struggling with an archive template for a custom post type. I want to display the posts grouped alphabetically by a custom taxonomy called countryname. I tried more than half a dozen examples and finally found one that almost works.</p> <p>Here is my code so far. When I get this working I will pull in t...
[ { "answer_id": 271976, "author": "Den Isahac", "author_id": 113233, "author_profile": "https://wordpress.stackexchange.com/users/113233", "pm_score": 3, "selected": true, "text": "<p>You're almost there. Since <code>the_title</code> inside your custom loop is one of the <em>Post template...
2017/07/01
[ "https://wordpress.stackexchange.com/questions/271968", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36252/" ]
I have been struggling with an archive template for a custom post type. I want to display the posts grouped alphabetically by a custom taxonomy called countryname. I tried more than half a dozen examples and finally found one that almost works. Here is my code so far. When I get this working I will pull in the postmet...
You're almost there. Since `the_title` inside your custom loop is one of the *Post template tags* you need to assign the global `$post` to use the new data from the custom query. ``` <?php global $post; // Access the global $post object. // Setup query to return each custom post within this taxonomy category ...
271,987
<p>I have a problem with this request with <code>get_posts</code>,when I want to order by title with year, order by doesn't work but when I do it without year, the request works. </p> <pre><code> $args = array( 'post_type' =&gt; 'projects', 'posts_per_page' =&gt; -1, 'year' =&gt; date( 'Y'...
[ { "answer_id": 271996, "author": "Cesar Henrique Damascena", "author_id": 109804, "author_profile": "https://wordpress.stackexchange.com/users/109804", "pm_score": 1, "selected": true, "text": "<p>I tried your code and is working fine for me</p>\n\n<pre><code>$args = array( 'post_type' =...
2017/07/01
[ "https://wordpress.stackexchange.com/questions/271987", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/122961/" ]
I have a problem with this request with `get_posts`,when I want to order by title with year, order by doesn't work but when I do it without year, the request works. ``` $args = array( 'post_type' => 'projects', 'posts_per_page' => -1, 'year' => date( 'Y' )-2, 'orderby'=> 'title',...
I tried your code and is working fine for me ``` $args = array( 'post_type' => 'project','posts_per_page' => -1,'year' => date('Y') - 2, 'orderby'=> 'title','order' => 'ASC'); $myposts = get_posts( $args ); ``` The thing is as you can see he is only fetching the posts from 2015. If you don't have any posts with the...
271,997
<p>I want to run a <strong>function A()</strong> when a post is published and <strong>function B()</strong> when the same post is edited or updated. </p> <p>For this, I found <em>publish_post</em> action which is triggered whenever a post is published, or if it is edited and the status is changed to publish.</p> <p>H...
[ { "answer_id": 272001, "author": "BenB", "author_id": 62909, "author_profile": "https://wordpress.stackexchange.com/users/62909", "pm_score": 1, "selected": false, "text": "<p>You could achieve this with save_post hook.</p>\n\n<p>Example similar to code in <a href=\"https://codex.wordpre...
2017/07/01
[ "https://wordpress.stackexchange.com/questions/271997", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/23717/" ]
I want to run a **function A()** when a post is published and **function B()** when the same post is edited or updated. For this, I found *publish\_post* action which is triggered whenever a post is published, or if it is edited and the status is changed to publish. How can I use this *publish\_post* action to know ...
With the `post_updated` hook you can trigger an action when the post is updated. He passes 3 parameters: * `$post_ID` (the post ID), * `$post_after`(the post object after the edit), * `$post_before` (the post object before the edit) Here's an example: ``` <?php function check_values($post_ID, $post_after, $post_bef...