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
215,802
<p>I'm looking for the location of a product's prices according to the option which the user selects in the product price. For example, <a href="http://sakala.ir/product/bundle-cashmere-3" rel="noreferrer">this WooCommerce shop</a> has a select which prices change according to the user selection.</p> <p>I want to know...
[ { "answer_id": 222468, "author": "LoicTheAztec", "author_id": 79855, "author_profile": "https://wordpress.stackexchange.com/users/79855", "pm_score": 4, "selected": false, "text": "<p>All the data like different <strong>prices</strong> of a product custom post type are store <em>(for eac...
2016/01/27
[ "https://wordpress.stackexchange.com/questions/215802", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87566/" ]
I'm looking for the location of a product's prices according to the option which the user selects in the product price. For example, [this WooCommerce shop](http://sakala.ir/product/bundle-cashmere-3) has a select which prices change according to the user selection. I want to know where are prices for different option...
All the data like different **prices** of a product custom post type are store *(for each product)* in **postmeta table**. To find the **post id** of all products you have to use this query on **posts table**: ``` SELECT * FROM 'posts' WHERE 'post_type' = 'product' ``` For each **product id** (`post_id`), you c...
215,813
<p>I haven't done anything to my clients site but add some more text to a testimonials page, updated it &amp; then went to go see the page and it's been all smashed together! It's using randomly placed &nbsp; tags instead. I'm starting to pull my hair out as I've tried everything I can think of:</p> <ul> <li>Updated w...
[ { "answer_id": 215832, "author": "vlood", "author_id": 733, "author_profile": "https://wordpress.stackexchange.com/users/733", "pm_score": 0, "selected": false, "text": "<p>You should look at your page.php template file if the theme has it and if not - then look for index.php.</p>\n\n<p>...
2016/01/27
[ "https://wordpress.stackexchange.com/questions/215813", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25108/" ]
I haven't done anything to my clients site but add some more text to a testimonials page, updated it & then went to go see the page and it's been all smashed together! It's using randomly placed   tags instead. I'm starting to pull my hair out as I've tried everything I can think of: * Updated wordpress to the most re...
After taking my older custom theme files over to my computer via FTP I was then able to really dive into what might the problem be. I put up a maintenance page on my website and worked on where the problem might be coming from, steps to find the culprit code were as follows: * Deactivate all plugins and then check o...
215,822
<p>Should one filter the output of builtin WP functions such as <code>get_permalink()</code> and well-known WP plugins such as ACF (Advanced Custom Fields) such as <code>get_field()</code>?</p> <p>For instance <code>get_permalink()</code> calls <code>home_url()</code> which calls <code>get_home_url()</code>, <strong>n...
[ { "answer_id": 215826, "author": "RRikesh", "author_id": 17305, "author_profile": "https://wordpress.stackexchange.com/users/17305", "pm_score": 2, "selected": false, "text": "<p>You should always escape your data, whatever its origin. For your example, the URLs should be escaped using <...
2016/01/27
[ "https://wordpress.stackexchange.com/questions/215822", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34330/" ]
Should one filter the output of builtin WP functions such as `get_permalink()` and well-known WP plugins such as ACF (Advanced Custom Fields) such as `get_field()`? For instance `get_permalink()` calls `home_url()` which calls `get_home_url()`, **none of which do any filtering of the data**. In a similar fashion work ...
Escaping is used to produce valid HTML or other formats, and it depends on context. Escaping a url in something like `<a href="<?php echo $url?>"....` is needed in order to replace any "&" characters with & (although browsers will most likely fix it for you if you don't do it). Escaping a url in an input element lik...
215,841
<p>I'm running the following query trying to get the data and associated meta data of a huge number of posts:</p> <pre><code>SELECT wp_posts.post_title, wp_posts.post_date, wp_posts.ID, wp_postmeta.post_id, wp_postmeta.meta_key FROM wp_postmeta INNER JOIN wp_posts ON wp_postmeta.post_id=wp_posts.id ...
[ { "answer_id": 215833, "author": "vlood", "author_id": 733, "author_profile": "https://wordpress.stackexchange.com/users/733", "pm_score": 0, "selected": false, "text": "<p>If you have some application-layer security going on (a plugin or something) it could be dropping any requests it f...
2016/01/27
[ "https://wordpress.stackexchange.com/questions/215841", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27866/" ]
I'm running the following query trying to get the data and associated meta data of a huge number of posts: ``` SELECT wp_posts.post_title, wp_posts.post_date, wp_posts.ID, wp_postmeta.post_id, wp_postmeta.meta_key FROM wp_postmeta INNER JOIN wp_posts ON wp_postmeta.post_id=wp_posts.id WHERE wp_post...
Since wordpress's execution logic relies on parameters filled by the php-apache connector (mod\_php) running a php command line is not guarantied to produce the same results or any at all, all depending on your local settings. In any case, you should not check if your server is functioning from the server itself as th...
215,847
<p>I'm trying to add some text after a product description in WooCommerce which uses the <code>$post-&gt;post_excerpt</code>. Currently I'm using the following code:</p> <pre><code>add_action( 'woocommerce_single_product_summary', 'd4tw_show_dimensions', 20 ); function d4tw_show_dimensions() { global $product; ...
[ { "answer_id": 215866, "author": "Peyman Mohamadpour", "author_id": 75020, "author_profile": "https://wordpress.stackexchange.com/users/75020", "pm_score": 1, "selected": false, "text": "<p>you may get the <code>excerpt</code> using:</p>\n\n<pre><code>$excerpt = get_the_excerpt();\n</cod...
2016/01/27
[ "https://wordpress.stackexchange.com/questions/215847", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/84806/" ]
I'm trying to add some text after a product description in WooCommerce which uses the `$post->post_excerpt`. Currently I'm using the following code: ``` add_action( 'woocommerce_single_product_summary', 'd4tw_show_dimensions', 20 ); function d4tw_show_dimensions() { global $product; $dimensions = $product->get...
you may get the `excerpt` using: ``` $excerpt = get_the_excerpt(); ``` and append or prepend it as you wish
215,850
<p>I need to create a custom role that is only able to edit and publish his own page (page created by admin and afterwards assigned to the user with the custom role).</p> <p>I have successfully created the new role, and the user under that role is able to edit his own page and publish it, but it still has too much "po...
[ { "answer_id": 216081, "author": "Vasim Shaikh", "author_id": 87704, "author_profile": "https://wordpress.stackexchange.com/users/87704", "pm_score": -1, "selected": false, "text": "<p>Yes,i am not getting you very well this may helpful.</p>\n\n<p><a href=\"http://easywebdesigntutorials....
2016/01/27
[ "https://wordpress.stackexchange.com/questions/215850", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87588/" ]
I need to create a custom role that is only able to edit and publish his own page (page created by admin and afterwards assigned to the user with the custom role). I have successfully created the new role, and the user under that role is able to edit his own page and publish it, but it still has too much "power" insid...
I've managed to solve this with a little bit of "patching" and thanks to the explanation on both these threads: [Remove ability to access certain admin menus](https://wordpress.stackexchange.com/questions/142517/remove-ability-to-access-certain-admin-menus) & [Hide Admin menus per role in Wordpress](https://wordpress.s...
215,871
<p>I was reading over some <a href="https://10up.github.io/Engineering-Best-Practices/php/">best practices from 10up</a> and they mention setting these two flags to false in a WP_Query ( depending on what you're querying ):</p> <ul> <li><code>'update_post_meta_cache' =&gt; false</code>: useful when post meta will not ...
[ { "answer_id": 215876, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 2, "selected": false, "text": "<p>The main point of interest here is the <code>update_post_caches</code> function. It is called after WP_Qu...
2016/01/27
[ "https://wordpress.stackexchange.com/questions/215871", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/7355/" ]
I was reading over some [best practices from 10up](https://10up.github.io/Engineering-Best-Practices/php/) and they mention setting these two flags to false in a WP\_Query ( depending on what you're querying ): * `'update_post_meta_cache' => false`: useful when post meta will not be utilized. * `'update_post_term_cach...
Object cache everywhere ======================= WordPress tries to reduce the number of database queries as much as possible. For example, anytime you get a meta field or a taxonomy field, before querying the database, WordPress looks if that that was already queried and stored in cache, and returns it from there ins...
215,885
<p>I have a number of custom post types as well as a custom taxonomy. I created an archive page for the taxonomy which lists each connected post, so all good there. What I would like to achieve is the following...</p> <p>On my single template for that taxonomy (I've called it Topics), say if the topic was 'cancer', I ...
[ { "answer_id": 216402, "author": "Aftab", "author_id": 64614, "author_profile": "https://wordpress.stackexchange.com/users/64614", "pm_score": -1, "selected": false, "text": "<p>According to what I understand is : </p>\n\n<p>In your taxonomy.php</p>\n\n<p>Add this code :</p>\n\n<pre><cod...
2016/01/27
[ "https://wordpress.stackexchange.com/questions/215885", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87604/" ]
I have a number of custom post types as well as a custom taxonomy. I created an archive page for the taxonomy which lists each connected post, so all good there. What I would like to achieve is the following... On my single template for that taxonomy (I've called it Topics), say if the topic was 'cancer', I would like...
If the URL to the 'cancer' taxonomy term in your example looked like this: ``` yourwebsite.com/topics/cancer/ ``` then you could filter these results by post type with a URLs structured like this: ``` yourwebsite.com/topics/cancer/?post_type=question ``` Just put this in functions.php ``` add_filter( 'pre_get_po...
215,937
<p>I am currently pulling in the post excerpt however there are 2 words at the start of it that I would rather not have in this particular place as there is a title already.</p> <p>I have used wp_trim previously but this only takes words off the end, is there a way to do this for the first 2 words. These words are alw...
[ { "answer_id": 215946, "author": "Ben H", "author_id": 64567, "author_profile": "https://wordpress.stackexchange.com/users/64567", "pm_score": 2, "selected": true, "text": "<p>I used substr to remove the first 21 characters from the string in the end. This was more consistent.</p>\n\n<pr...
2016/01/28
[ "https://wordpress.stackexchange.com/questions/215937", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64567/" ]
I am currently pulling in the post excerpt however there are 2 words at the start of it that I would rather not have in this particular place as there is a title already. I have used wp\_trim previously but this only takes words off the end, is there a way to do this for the first 2 words. These words are always the s...
I used substr to remove the first 21 characters from the string in the end. This was more consistent. ``` $str = get_the_excerpt(); $str2 = substr($str, 21); echo str2; ```
215,948
<p>This is my site <a href="http://185.105.4.132/~orangeye/" rel="nofollow">http://185.105.4.132/~orangeye/</a></p> <p>When I scroll down, a white space appears between my menu bar and slider.</p> <p>how do I remove that?</p> <p>This is what I have done to place the logo at the very top. After doing this, the white ...
[ { "answer_id": 215946, "author": "Ben H", "author_id": 64567, "author_profile": "https://wordpress.stackexchange.com/users/64567", "pm_score": 2, "selected": true, "text": "<p>I used substr to remove the first 21 characters from the string in the end. This was more consistent.</p>\n\n<pr...
2016/01/28
[ "https://wordpress.stackexchange.com/questions/215948", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/81941/" ]
This is my site <http://185.105.4.132/~orangeye/> When I scroll down, a white space appears between my menu bar and slider. how do I remove that? This is what I have done to place the logo at the very top. After doing this, the white space started appearing. ``` .edgtf-page-header { margin-top: 30px; paddin...
I used substr to remove the first 21 characters from the string in the end. This was more consistent. ``` $str = get_the_excerpt(); $str2 = substr($str, 21); echo str2; ```
215,971
<p>I need to put the PHP <code>&lt;?php global $' . $icon_var . '; echo $' . $icon_var . '; ?&gt;</code> inside the variable of a custom menu structure, but it gets commented: </p> <pre><code>&lt;a href="http://slembas.esy.es/"&gt; &lt;!--?php global $icon_home; echo $icon_home; ?--&gt; &lt;span&gt;Page Name&l...
[ { "answer_id": 215946, "author": "Ben H", "author_id": 64567, "author_profile": "https://wordpress.stackexchange.com/users/64567", "pm_score": 2, "selected": true, "text": "<p>I used substr to remove the first 21 characters from the string in the end. This was more consistent.</p>\n\n<pr...
2016/01/28
[ "https://wordpress.stackexchange.com/questions/215971", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86763/" ]
I need to put the PHP `<?php global $' . $icon_var . '; echo $' . $icon_var . '; ?>` inside the variable of a custom menu structure, but it gets commented: ``` <a href="http://slembas.esy.es/"> <!--?php global $icon_home; echo $icon_home; ?--> <span>Page Name</span> </a> ``` Explanation of the variables: `...
I used substr to remove the first 21 characters from the string in the end. This was more consistent. ``` $str = get_the_excerpt(); $str2 = substr($str, 21); echo str2; ```
215,987
<p>I've come quite far, but can't manage to get this to work.</p> <p>I'd like to remove the base slug from my Custom Post Type <code>review</code> and my Custom Taxonomy <code>brand</code>.</p> <p>The final result should be a URL like this: <code>https://example.org/apple/iphone7</code>.</p> <p>Right now I got this:...
[ { "answer_id": 215946, "author": "Ben H", "author_id": 64567, "author_profile": "https://wordpress.stackexchange.com/users/64567", "pm_score": 2, "selected": true, "text": "<p>I used substr to remove the first 21 characters from the string in the end. This was more consistent.</p>\n\n<pr...
2016/01/28
[ "https://wordpress.stackexchange.com/questions/215987", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87365/" ]
I've come quite far, but can't manage to get this to work. I'd like to remove the base slug from my Custom Post Type `review` and my Custom Taxonomy `brand`. The final result should be a URL like this: `https://example.org/apple/iphone7`. Right now I got this: `https://example.org/review/apple/iphone7`. I've read q...
I used substr to remove the first 21 characters from the string in the end. This was more consistent. ``` $str = get_the_excerpt(); $str2 = substr($str, 21); echo str2; ```
216,004
<p>I have a <a href="http://creative-thunder.com/" rel="nofollow">WordPress website</a>. I've tested it for speed test with google tools, but I see some of errors like this:</p> <blockquote> <p>Leverage browser caching Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the bro...
[ { "answer_id": 216019, "author": "Emanuel Rocha Costa", "author_id": 75873, "author_profile": "https://wordpress.stackexchange.com/users/75873", "pm_score": 2, "selected": false, "text": "<p>For WordPress Website optimization you should take a look at: <a href=\"https://codex.wordpress.o...
2016/01/28
[ "https://wordpress.stackexchange.com/questions/216004", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85296/" ]
I have a [WordPress website](http://creative-thunder.com/). I've tested it for speed test with google tools, but I see some of errors like this: > > Leverage browser caching Setting an expiry date or a maximum age in the HTTP headers for static resources instructs the browser to load previously downloaded resources f...
For WordPress Website optimization you should take a look at: <https://codex.wordpress.org/WordPress_Optimization> I took a look at your pagespeed report and the main thing there are the images you are using. There are many plugins that can optimize them for you. I like this one in particular: <https://wordpress.org/p...
216,028
<p>So, I have been working on an SQL query involving the users and usermeta tables in wordpress. I am not getting the correct results. I have the following query written</p> <pre><code>SELECT * FROM IL9_users LEFT JOIN ( SELECT user_id, MAX(case when meta_key = 'first_name' then...
[ { "answer_id": 216019, "author": "Emanuel Rocha Costa", "author_id": 75873, "author_profile": "https://wordpress.stackexchange.com/users/75873", "pm_score": 2, "selected": false, "text": "<p>For WordPress Website optimization you should take a look at: <a href=\"https://codex.wordpress.o...
2016/01/29
[ "https://wordpress.stackexchange.com/questions/216028", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87687/" ]
So, I have been working on an SQL query involving the users and usermeta tables in wordpress. I am not getting the correct results. I have the following query written ``` SELECT * FROM IL9_users LEFT JOIN ( SELECT user_id, MAX(case when meta_key = 'first_name' then meta_value en...
For WordPress Website optimization you should take a look at: <https://codex.wordpress.org/WordPress_Optimization> I took a look at your pagespeed report and the main thing there are the images you are using. There are many plugins that can optimize them for you. I like this one in particular: <https://wordpress.org/p...
216,030
<p>I created a custom post type "Book", and successfully added to WordPress' admin menu as a root category. I can successfully list the post type contents with <code>/wp-admin/edit.php?post_type=test_book</code> &amp; can add via <code>/wp-admin/post-new.php?post_type=test_book</code>.</p> <p>However, I would like to ...
[ { "answer_id": 216032, "author": "AjayShanker", "author_id": 87560, "author_profile": "https://wordpress.stackexchange.com/users/87560", "pm_score": -1, "selected": false, "text": "<p>First you create test_book function and call <code>add_action()</code> function to initialize this funct...
2016/01/29
[ "https://wordpress.stackexchange.com/questions/216030", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/3608/" ]
I created a custom post type "Book", and successfully added to WordPress' admin menu as a root category. I can successfully list the post type contents with `/wp-admin/edit.php?post_type=test_book` & can add via `/wp-admin/post-new.php?post_type=test_book`. However, I would like to add a custom post type "Chapter" (`t...
The code you need to use here has some steps. First you need to create e metabox on your custom post type edit.php which will list all your posts of test\_chapter post type. Then you have to hook the save\_post action so you set the parent of your edited post to the chosen "test\_chapter". The best way is to connect th...
216,047
<p>I am new to PHP and I'm unable to solve the code. It's showing an error.</p> <pre><code>&lt;?php function thumbImg() { if ( has_post_thumbnail() ) { the_post_thumbnail( array(54,54) ); } else { &lt;img src='&lt;?php echo $data['featured_img']; ?&gt;' alt='&lt;?php the_title(); ?&gt;' /&gt; ...
[ { "answer_id": 216050, "author": "macl", "author_id": 72784, "author_profile": "https://wordpress.stackexchange.com/users/72784", "pm_score": 1, "selected": false, "text": "<p>You are mixing html and php content. You should write it like this:</p>\n\n<pre><code>&lt;?php \n\nfunction thum...
2016/01/29
[ "https://wordpress.stackexchange.com/questions/216047", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87218/" ]
I am new to PHP and I'm unable to solve the code. It's showing an error. ``` <?php function thumbImg() { if ( has_post_thumbnail() ) { the_post_thumbnail( array(54,54) ); } else { <img src='<?php echo $data['featured_img']; ?>' alt='<?php the_title(); ?>' /> } } ?> ``` What I am trying to...
You are mixing html and php content. You should write it like this: ``` <?php function thumbImg() { if ( has_post_thumbnail() ) { the_post_thumbnail( array(54,54) ); } else { echo "<img src='{$data['featured_img']}' alt='".get_the_title()."' />"; } } ?> ``` This way, you don't need to open...
216,054
<p>In woocommerce plugin file <code>class-wc-booking-cart-manager.php</code> there is this code</p> <pre><code>/** * Constructor */ public function __construct() { add_filter( 'woocommerce_add_cart_item', array( $this, 'add_cart_item' ), 10, 1 ); } /** * Adjust the price of the book...
[ { "answer_id": 216050, "author": "macl", "author_id": 72784, "author_profile": "https://wordpress.stackexchange.com/users/72784", "pm_score": 1, "selected": false, "text": "<p>You are mixing html and php content. You should write it like this:</p>\n\n<pre><code>&lt;?php \n\nfunction thum...
2016/01/29
[ "https://wordpress.stackexchange.com/questions/216054", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87707/" ]
In woocommerce plugin file `class-wc-booking-cart-manager.php` there is this code ``` /** * Constructor */ public function __construct() { add_filter( 'woocommerce_add_cart_item', array( $this, 'add_cart_item' ), 10, 1 ); } /** * Adjust the price of the booking product based on book...
You are mixing html and php content. You should write it like this: ``` <?php function thumbImg() { if ( has_post_thumbnail() ) { the_post_thumbnail( array(54,54) ); } else { echo "<img src='{$data['featured_img']}' alt='".get_the_title()."' />"; } } ?> ``` This way, you don't need to open...
216,070
<p>in the search box I would like visitors to be able to search for more than one location (houses). The code right now is:</p> <pre><code> &lt;div class="col-md-3 col-sm-6 col-xs-12"&gt; &lt;label for="property_location"&gt;&lt;?php _ex( 'Locatie', 'property search label', 'ci_theme' ); ?&gt;&lt;/label&gt;...
[ { "answer_id": 216079, "author": "AddWeb Solution Pvt Ltd", "author_id": 73643, "author_profile": "https://wordpress.stackexchange.com/users/73643", "pm_score": 0, "selected": false, "text": "<p>You can check:</p>\n\n<p><a href=\"http://codex.wordpress.org/Function_Reference/wp_category_...
2016/01/29
[ "https://wordpress.stackexchange.com/questions/216070", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87719/" ]
in the search box I would like visitors to be able to search for more than one location (houses). The code right now is: ``` <div class="col-md-3 col-sm-6 col-xs-12"> <label for="property_location"><?php _ex( 'Locatie', 'property search label', 'ci_theme' ); ?></label> <div class="ci-select"> ...
[**`wp_dropdown_categories`**](https://developer.wordpress.org/reference/functions/wp_dropdown_categories/) has a filter applied to the output that is called right before the function returns or echos the output. With this you can add a filter to your funtions.php file that manipulates the select field and adds a mult...
216,084
<p>I've a wordpress installation at mytld.com. So far the primary intent was to run a blog and my posts are in the format mytld.com/y/m/postname.</p> <p>Now I want to shift the blog under a new URL structure mytld.com/blog/y/m/postname and instead setup a website under mytld.com by using wordpress pages.</p> <p>I'm l...
[ { "answer_id": 216079, "author": "AddWeb Solution Pvt Ltd", "author_id": 73643, "author_profile": "https://wordpress.stackexchange.com/users/73643", "pm_score": 0, "selected": false, "text": "<p>You can check:</p>\n\n<p><a href=\"http://codex.wordpress.org/Function_Reference/wp_category_...
2016/01/29
[ "https://wordpress.stackexchange.com/questions/216084", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/5195/" ]
I've a wordpress installation at mytld.com. So far the primary intent was to run a blog and my posts are in the format mytld.com/y/m/postname. Now I want to shift the blog under a new URL structure mytld.com/blog/y/m/postname and instead setup a website under mytld.com by using wordpress pages. I'm looking for sugges...
[**`wp_dropdown_categories`**](https://developer.wordpress.org/reference/functions/wp_dropdown_categories/) has a filter applied to the output that is called right before the function returns or echos the output. With this you can add a filter to your funtions.php file that manipulates the select field and adds a mult...
216,115
<p>I'm trying to make my blog posts show an excerpt but can't seem to do it manually. <a href="http://averylawoffice.ca/blog" rel="nofollow">My blog site is here</a>.</p> <p>I've gotten this snippet from the wordpress.org site</p> <pre><code>&lt;?php the_excerpt(); ?&gt; </code></pre> <p>and it tells me to replace t...
[ { "answer_id": 216079, "author": "AddWeb Solution Pvt Ltd", "author_id": 73643, "author_profile": "https://wordpress.stackexchange.com/users/73643", "pm_score": 0, "selected": false, "text": "<p>You can check:</p>\n\n<p><a href=\"http://codex.wordpress.org/Function_Reference/wp_category_...
2016/01/29
[ "https://wordpress.stackexchange.com/questions/216115", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25108/" ]
I'm trying to make my blog posts show an excerpt but can't seem to do it manually. [My blog site is here](http://averylawoffice.ca/blog). I've gotten this snippet from the wordpress.org site ``` <?php the_excerpt(); ?> ``` and it tells me to replace the ``` <?php the_content(); ?> ``` with it. However I can't j...
[**`wp_dropdown_categories`**](https://developer.wordpress.org/reference/functions/wp_dropdown_categories/) has a filter applied to the output that is called right before the function returns or echos the output. With this you can add a filter to your funtions.php file that manipulates the select field and adds a mult...
216,127
<p>I cannot find WP_Query() in my wordpress folder, the global refers to $wp_query but I don't find the class itself. From my wordpress folder, or here directly : <a href="https://core.trac.wordpress.org/browser/tags/4.4.1/src/wp-includes?order=name" rel="nofollow">https://core.trac.wordpress.org/browser/tags/4.4.1/src...
[ { "answer_id": 216079, "author": "AddWeb Solution Pvt Ltd", "author_id": 73643, "author_profile": "https://wordpress.stackexchange.com/users/73643", "pm_score": 0, "selected": false, "text": "<p>You can check:</p>\n\n<p><a href=\"http://codex.wordpress.org/Function_Reference/wp_category_...
2016/01/30
[ "https://wordpress.stackexchange.com/questions/216127", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8432/" ]
I cannot find WP\_Query() in my wordpress folder, the global refers to $wp\_query but I don't find the class itself. From my wordpress folder, or here directly : <https://core.trac.wordpress.org/browser/tags/4.4.1/src/wp-includes?order=name>
[**`wp_dropdown_categories`**](https://developer.wordpress.org/reference/functions/wp_dropdown_categories/) has a filter applied to the output that is called right before the function returns or echos the output. With this you can add a filter to your funtions.php file that manipulates the select field and adds a mult...
216,135
<h2>UPDATE -Feb 2</h2> <p>I've recently brought it back over to a testing server instead of a localhost environment. The address is <a href="http://onlinewebdraft.com/nuggettesting/" rel="nofollow noreferrer">http://onlinewebdraft.com/nuggettesting/</a></p> <p>I have renamed my plugins folder and my genesis and genes...
[ { "answer_id": 216139, "author": "Emanuel Rocha Costa", "author_id": 75873, "author_profile": "https://wordpress.stackexchange.com/users/75873", "pm_score": -1, "selected": false, "text": "<p>Try remove the genesis theme folder and see what happens. Make sure you have the default WordPre...
2016/01/30
[ "https://wordpress.stackexchange.com/questions/216135", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25108/" ]
UPDATE -Feb 2 ------------- I've recently brought it back over to a testing server instead of a localhost environment. The address is <http://onlinewebdraft.com/nuggettesting/> I have renamed my plugins folder and my genesis and genesis child folders to deactivate them but I still get nothing. [![enter image descri...
I have found out how to fix it but can't seem to find out what caused it. The website was fairly new and was launched on April 20th, 2015. Not many updates had been done so maybe thats why? Someone had suggested that I replace all instances of the wordpress core files (except wp-config.php and wp-content as these are ...
216,152
<p>In my WordPress theme I created the custom post type <code>articles</code>. I also created two taxonomies called <code>article</code> &amp; <code>news</code>. How can I display each taxonomy in its own single template? For now it only displays using the <code>single-articles.php</code> template.</p>
[ { "answer_id": 216158, "author": "Nathan Powell", "author_id": 27196, "author_profile": "https://wordpress.stackexchange.com/users/27196", "pm_score": -1, "selected": false, "text": "<p>You will need to read the <a href=\"https://developer.wordpress.org/themes/template-files-section/taxo...
2016/01/30
[ "https://wordpress.stackexchange.com/questions/216152", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83974/" ]
In my WordPress theme I created the custom post type `articles`. I also created two taxonomies called `article` & `news`. How can I display each taxonomy in its own single template? For now it only displays using the `single-articles.php` template.
Use the single\_template filter in your functions file with the correct [conditional tag](https://codex.wordpress.org/Function_Reference/has_term) ``` add_filter( 'single_template', 'single_tax_term_template' ); function single_tax_term_template( $single_template ) { global $post; if ( has_term( '', 'article'...
216,169
<p>Actions usually support the following (if you are creating your plugin using a class based approach):</p> <pre><code>add_action('admin_notices', array(&amp;$this, 'emailNoticeGUI')); </code></pre> <p>The <code>wp_schedule_event</code> does not support this kind of triggering. Is there any way I could do this, but ...
[ { "answer_id": 216158, "author": "Nathan Powell", "author_id": 27196, "author_profile": "https://wordpress.stackexchange.com/users/27196", "pm_score": -1, "selected": false, "text": "<p>You will need to read the <a href=\"https://developer.wordpress.org/themes/template-files-section/taxo...
2016/01/30
[ "https://wordpress.stackexchange.com/questions/216169", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87772/" ]
Actions usually support the following (if you are creating your plugin using a class based approach): ``` add_action('admin_notices', array(&$this, 'emailNoticeGUI')); ``` The `wp_schedule_event` does not support this kind of triggering. Is there any way I could do this, but still use a class based approach? What ar...
Use the single\_template filter in your functions file with the correct [conditional tag](https://codex.wordpress.org/Function_Reference/has_term) ``` add_filter( 'single_template', 'single_tax_term_template' ); function single_tax_term_template( $single_template ) { global $post; if ( has_term( '', 'article'...
216,174
<p>I have a custom post type (projects) which have custom cmb2 meta keys (str_dte and end_dte), so each project has a start date and end date. What I am trying to do is to get projects between two dates.</p> <p>Example:</p> <p>Project #1: start date = 20120101 (Jan 2012) / end date = 20120601 (Jun 2012) (Ymd)</p> <p...
[ { "answer_id": 216181, "author": "nyan", "author_id": 72720, "author_profile": "https://wordpress.stackexchange.com/users/72720", "pm_score": 0, "selected": false, "text": "<p>First, do not use query_posts! (Why not? <a href=\"https://stackoverflow.com/a/25589475\">That is why!</a>)</p>\...
2016/01/30
[ "https://wordpress.stackexchange.com/questions/216174", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/42810/" ]
I have a custom post type (projects) which have custom cmb2 meta keys (str\_dte and end\_dte), so each project has a start date and end date. What I am trying to do is to get projects between two dates. Example: Project #1: start date = 20120101 (Jan 2012) / end date = 20120601 (Jun 2012) (Ymd) Project #2: start dat...
To find projects happening within a range of dates, there are 3 cases you have to account for: * A project starts within the range * A project ends within the range * A project starts before the range and ends after the range You can test for these 3 cases separately with an `OR` meta query and 1 nested `AND`: ``` '...
216,178
<p>I am inserting some post into wordpress using the function <a href="https://developer.wordpress.org/reference/functions/wp_insert_post/">wp_insert_post()</a>.</p> <p>I want to insert some custom fields on each post and reading the documentation I though the meta_info parameter was used for that, I tried something l...
[ { "answer_id": 216180, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 4, "selected": true, "text": "<p>This part of <a href=\"https://core.trac.wordpress.org/browser/tags/4.4/src/wp-includes/post.php#L3259\" rel=\...
2016/01/30
[ "https://wordpress.stackexchange.com/questions/216178", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82844/" ]
I am inserting some post into wordpress using the function [wp\_insert\_post()](https://developer.wordpress.org/reference/functions/wp_insert_post/). I want to insert some custom fields on each post and reading the documentation I though the meta\_info parameter was used for that, I tried something like this: ``` $da...
This part of [`wp_insert_posts()`](https://core.trac.wordpress.org/browser/tags/4.4/src/wp-includes/post.php#L3259) gives it away: ``` if ( ! empty( $postarr['meta_input'] ) ) { foreach ( $postarr['meta_input'] as $field => $value ) { update_post_meta( $post_ID, $field, $value ); } } ...
216,183
<p>Can anyone guide me in the right direction on how to loosen or disable the strong password policy? Would like to do it without the use of a plugin. I'm running a non-public site and don't need strong security. <a href="https://i.stack.imgur.com/gYpZE.jpg" rel="noreferrer"><img src="https://i.stack.imgur.com/gYpZE.jp...
[ { "answer_id": 223453, "author": "MrCalvin", "author_id": 87041, "author_profile": "https://wordpress.stackexchange.com/users/87041", "pm_score": 4, "selected": false, "text": "<p>This will do it :-)</p>\n\n<pre><code>add_action( 'wp_print_scripts', 'DisableStrongPW', 100 );\n\nfunction ...
2016/01/30
[ "https://wordpress.stackexchange.com/questions/216183", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87041/" ]
Can anyone guide me in the right direction on how to loosen or disable the strong password policy? Would like to do it without the use of a plugin. I'm running a non-public site and don't need strong security. [![enter image description here](https://i.stack.imgur.com/gYpZE.jpg)](https://i.stack.imgur.com/gYpZE.jpg)
This will do it :-) ``` add_action( 'wp_print_scripts', 'DisableStrongPW', 100 ); function DisableStrongPW() { if ( wp_script_is( 'wc-password-strength-meter', 'enqueued' ) ) { wp_dequeue_script( 'wc-password-strength-meter' ); } } ``` I found the solution [here](https://nicolamustone.com/2016/01/27...
216,189
<p>I am new to WP-CLI and having trouble finding examples of what I want to do. I know how to create a single page. <code>wp post create --post_type=page --post_status=publish --post_title='Contact'</code></p> <p>Is there a way to create multiple pages with a single command? </p>
[ { "answer_id": 216222, "author": "JediTricks007", "author_id": 49017, "author_profile": "https://wordpress.stackexchange.com/users/49017", "pm_score": 1, "selected": false, "text": "<p>After looking further I found a page on the site. It looks like you can.</p>\n\n<pre><code>wp post gen...
2016/01/30
[ "https://wordpress.stackexchange.com/questions/216189", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/81532/" ]
I am new to WP-CLI and having trouble finding examples of what I want to do. I know how to create a single page. `wp post create --post_type=page --post_status=publish --post_title='Contact'` Is there a way to create multiple pages with a single command?
There are a few ways. As mentioned, [`post generate`](http://wp-cli.org/commands/post/generate/). ``` wp post generate --count=10 --post_type=page --post_date=1999-01-04 curl http://loripsum.net/api/5 | wp post generate --post_content --count=10 ``` You could write your own [custom command](https://github.com/wp-cli...
216,197
<p>To disable a custom post types archive page, we should use the following code:</p> <pre><code>$args = array( 'has_archive' =&gt; false, ); </code></pre> <p>But when we use <code>false</code> for <code>has_archive</code>, the feeds page (like : <code>name.com/books/feed</code>) of that custom post type becomes ...
[ { "answer_id": 216208, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": false, "text": "<p>Set the <code>feeds</code> argument of <code>rewrite</code> to <code>true</code> to generate feed rewrite rules. I...
2016/01/30
[ "https://wordpress.stackexchange.com/questions/216197", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/39305/" ]
To disable a custom post types archive page, we should use the following code: ``` $args = array( 'has_archive' => false, ); ``` But when we use `false` for `has_archive`, the feeds page (like : `name.com/books/feed`) of that custom post type becomes disabled too. Now I want to know how I can disable custom post...
Finally I found a solution for it. I set `has_archive` to `true`. Now both the feed and the archive page of CPT are active. To only disable the archive page of CPT, I use the following filter in the `functions.php` file: ``` function AryanThemes_disable_cpt_archive_template(){ if ( is_post_type_archive('cpt') ) { ...
216,216
<p>Where do we add our custom widget? I keep on getting internal errors, I tried to add the class in wp_content > plugins, or wp_includes > widgets, but I get an internal error.</p> <p>The class is simple, inside "My_Widget.php" :</p> <pre><code>&lt;?php /* Plugin Name: My_Widget Description: my widet description...
[ { "answer_id": 216226, "author": "Prasad Nevase", "author_id": 62283, "author_profile": "https://wordpress.stackexchange.com/users/62283", "pm_score": 2, "selected": true, "text": "<p>I copied the class definition and <code>register_widget( 'My_Widget' );</code> to my theme's functions.p...
2016/01/31
[ "https://wordpress.stackexchange.com/questions/216216", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8432/" ]
Where do we add our custom widget? I keep on getting internal errors, I tried to add the class in wp\_content > plugins, or wp\_includes > widgets, but I get an internal error. The class is simple, inside "My\_Widget.php" : ``` <?php /* Plugin Name: My_Widget Description: my widet description Author: Author */...
I copied the class definition and `register_widget( 'My_Widget' );` to my theme's functions.php file & it did show **My Widget** under `Appearance > Widgets`. So please place this code directly in your theme's functions.php file. It is not recommended to edit anything in **wp-includes** directory.
216,217
<p>I'm trying to sort the popular posts so it shows the most visited in the last week, but it hasn't worked. Anyone have an idea of why it isn't working?</p> <pre><code>&lt;?php $popularpost = new WP_Query( array ( 'posts_per_page' =&gt; 5, 'ignore_sticky_posts' =&gt; 1, 'meta_key' ...
[ { "answer_id": 216233, "author": "Vasim Shaikh", "author_id": 87704, "author_profile": "https://wordpress.stackexchange.com/users/87704", "pm_score": -1, "selected": false, "text": "<p>If you are looking for plugin then this is simple way to install Plugin: WordPress Popular Posts</p>\n\...
2016/01/31
[ "https://wordpress.stackexchange.com/questions/216217", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63307/" ]
I'm trying to sort the popular posts so it shows the most visited in the last week, but it hasn't worked. Anyone have an idea of why it isn't working? ``` <?php $popularpost = new WP_Query( array ( 'posts_per_page' => 5, 'ignore_sticky_posts' => 1, 'meta_key' => 'sw_post_view...
Use `strtotime` to compare dates. ``` $start = strtotime('yesterday'); $end = strtotime( '+1 week',$start); $args = array( 'posts_per_page' => 5, 'ignore_sticky_posts' => 1, 'meta_key' => 'sw_post_views_count', 'orderby' => 'meta_value_num', 'order' => 'DESC', 'date_query' => array( 'a...
216,244
<p>I'm am working on a WooCommerce website, and have all my jQuery in the footer inside script tags. I use PHP to filter out the needed scripts for any particular page.</p> <p>However, I would like to use the suggested method of using wp_enqueue_script to load my jquery. The trouble is that scripts containing PHP wont...
[ { "answer_id": 216245, "author": "Vasim Shaikh", "author_id": 87704, "author_profile": "https://wordpress.stackexchange.com/users/87704", "pm_score": 0, "selected": false, "text": "<pre><code>&lt;?php\n\n// Register the script\nwp_register_script( 'some_handle', 'path/to/myscript.js' );\...
2016/01/31
[ "https://wordpress.stackexchange.com/questions/216244", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87826/" ]
I'm am working on a WooCommerce website, and have all my jQuery in the footer inside script tags. I use PHP to filter out the needed scripts for any particular page. However, I would like to use the suggested method of using wp\_enqueue\_script to load my jquery. The trouble is that scripts containing PHP wont work un...
If you're outputting the script in the footer, you can call `wp_localize_script` at any point after your script is enqueued but before the script is output on `wp_footer` priority 20. ``` function wp_enqueue_woocommerce_style(){ wp_enqueue_script( 'chroma_js', get_template_directory_uri() . '/js/ch...
216,257
<p>I'm quite new to Wordpress, I've build a website and found out in the Google WebMaster tool that one of the most present keyword was <code>[%%LINKS%%]</code>...</p> <p>I've found this code:</p> <pre><code>&lt;div style="display:none"&gt;[%%LINKS%%]&lt;/div&gt; </code></pre> <p>I've browse the whole database and t...
[ { "answer_id": 216278, "author": "markratledge", "author_id": 268, "author_profile": "https://wordpress.stackexchange.com/users/268", "pm_score": 0, "selected": false, "text": "<p><code>[%%LINKS%%]</code>is very suspicious. It's inside a <code>display:none</code> div, so any links output...
2016/01/31
[ "https://wordpress.stackexchange.com/questions/216257", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87832/" ]
I'm quite new to Wordpress, I've build a website and found out in the Google WebMaster tool that one of the most present keyword was `[%%LINKS%%]`... I've found this code: ``` <div style="display:none">[%%LINKS%%]</div> ``` I've browse the whole database and the files on my server, I can't find any trace of the lin...
This looks like a hack, probably in W3TC. Try disabling all the Plugins one by one, and if it doesn't go away, try switching to the default theme. If that did not work, install WordPress from scratch, and transfer the database to it. If you prefer another debug mode, I suppose your script gets hooked into WordPress ...
216,271
<p>I have many security plugins setup. Could someone tell me what changes I need to make to my <a href="http://pastebin.com/6VkejW2R" rel="nofollow"><code>.htaccess</code></a> file (while keeping as much of my current rule set as possible) to make pretty URLs work?</p> <pre><code># BEGIN iThemes Security - Do not modi...
[ { "answer_id": 216274, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 1, "selected": false, "text": "<p>Your htaccess do not have the default wordpress related rules, go to the permalink page and save, if it i...
2016/01/31
[ "https://wordpress.stackexchange.com/questions/216271", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87844/" ]
I have many security plugins setup. Could someone tell me what changes I need to make to my [`.htaccess`](http://pastebin.com/6VkejW2R) file (while keeping as much of my current rule set as possible) to make pretty URLs work? ``` # BEGIN iThemes Security - Do not modify or remove this line # iThemes Security Config De...
Your htaccess do not have the default wordpress related rules, go to the permalink page and save, if it it doesn't help turn off plugins.
216,284
<p>I am trying to implement a new tab next to Media Library. I couldn't find solution to implement this. I found an example how to implement a new tab in this link: <a href="https://gist.github.com/Fab1en/4586865" rel="nofollow noreferrer">https://gist.github.com/Fab1en/4586865</a> However the tab doesn't show up in th...
[ { "answer_id": 216395, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 3, "selected": true, "text": "<p>It's not a tab but you might be able to get started with an upload button. Check out <a href=\"https://core.tra...
2016/02/01
[ "https://wordpress.stackexchange.com/questions/216284", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87763/" ]
I am trying to implement a new tab next to Media Library. I couldn't find solution to implement this. I found an example how to implement a new tab in this link: <https://gist.github.com/Fab1en/4586865> However the tab doesn't show up in the modal form triggered by Add Media button. But if I call the media popup for Fe...
It's not a tab but you might be able to get started with an upload button. Check out [`pre-upload-ui`](https://core.trac.wordpress.org/browser/tags/4.4.1/src/wp-admin/includes/media.php#L1826) and some actions that follow. Namely [`pre-plupload-upload-ui`](https://core.trac.wordpress.org/browser/tags/4.4.1/src/wp-admin...
216,286
<p>How do I get something like below? My code is like this:</p> <pre><code>wp_nav_menu( array( 'theme_location' =&gt; 'header_menu', 'container_id' =&gt; 'menu', 'link_before' =&gt; '&lt;span data-hover="link-text-here"&gt;', 'link_after' =&gt; '&lt;/span&gt;', ) ); </code></pre...
[ { "answer_id": 216287, "author": "AddWeb Solution Pvt Ltd", "author_id": 73643, "author_profile": "https://wordpress.stackexchange.com/users/73643", "pm_score": 3, "selected": true, "text": "<h1>Solution 1: Using customize walker</h1>\n<p>I got some idea from <a href=\"https://wordpress....
2016/02/01
[ "https://wordpress.stackexchange.com/questions/216286", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85768/" ]
How do I get something like below? My code is like this: ``` wp_nav_menu( array( 'theme_location' => 'header_menu', 'container_id' => 'menu', 'link_before' => '<span data-hover="link-text-here">', 'link_after' => '</span>', ) ); ``` I want to get the result below: ``` <nav cl...
Solution 1: Using customize walker ================================== I got some idea from [add span class inside wp\_nav\_menu link anchor tag](https://wordpress.stackexchange.com/questions/72651/add-span-class-inside-wp-nav-menu-link-anchor-tag) and made some changes for your requirements. **1. Add this code below ...
216,291
<p>I want to upload images in a specific folder like <code>http://example.com/custom_folder</code>.</p> <p>Note: Not in <code>http://example.com/wp-content/uploads/custom_folder/image1.jpg</code></p>
[ { "answer_id": 216399, "author": "Aftab", "author_id": 64614, "author_profile": "https://wordpress.stackexchange.com/users/64614", "pm_score": 0, "selected": false, "text": "<p>Add this in your wp-config.php file</p>\n\n<p><code>define( 'UPLOADS', 'custom_folder' );</code></p>\n\n<p>And ...
2016/02/01
[ "https://wordpress.stackexchange.com/questions/216291", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87853/" ]
I want to upload images in a specific folder like `http://example.com/custom_folder`. Note: Not in `http://example.com/wp-content/uploads/custom_folder/image1.jpg`
Try this ``` add_filter('upload_dir', 'upload_image_specific_calback'); function upload_image_specific_calback( $param ){ //$_GET['post'] which is your target post like 10 is post id. //After click update button. if(isset($_GET['post'])){ if($_GET['post'] == 10){ $param = array( ...
216,337
<p>I have 2 custom post types: <code>software</code> and <code>hardware</code>. For SEO reasons I would like to have the permalinks of single <code>software</code> and <code>hardware</code> pages like: </p> <pre><code>https://domain.com/custom-post-name/ </code></pre> <p>But as default WordPress adds post-type slug o...
[ { "answer_id": 216470, "author": "Rico", "author_id": 63388, "author_profile": "https://wordpress.stackexchange.com/users/63388", "pm_score": 0, "selected": false, "text": "<p>SOLVED</p>\n\n<p>with usage of <code>$wp_rewrite</code> you can add a new permalink structure</p>\n\n<pre><code>...
2016/02/01
[ "https://wordpress.stackexchange.com/questions/216337", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63388/" ]
I have 2 custom post types: `software` and `hardware`. For SEO reasons I would like to have the permalinks of single `software` and `hardware` pages like: ``` https://domain.com/custom-post-name/ ``` But as default WordPress adds post-type slug on it like: ``` https://domain.com/post-type-slug/custom-post-name/ ...
Note one Important thing to the above answer: While it'll work fine from the first sight it will cause performance problems. All this code will be called on `init` hook so every page load will cause it to run and `flush_rules()` is very time expensive. So it's recomended to call flush rules upon theme\plugin activat...
216,338
<p>I want to create a post type / format where I can create list type posts... For example... </p> <pre><code>h1.Title: The List Post Title like "Best Salads..." - Intro paragraph h2. Best Veg Salads - Intro -- h3. Salad #1 -- h3. Salad #2 .. -- h3. Salad #X h2. Best Non-Veg Salads - Intro -- h3. NV Salad #1 -- h3. N...
[ { "answer_id": 216340, "author": "Peyman Mohamadpour", "author_id": 75020, "author_profile": "https://wordpress.stackexchange.com/users/75020", "pm_score": 1, "selected": false, "text": "<p>You may simply use <code>register_post_type</code> and <code>register_taxonomy</code> to do so:</p...
2016/02/01
[ "https://wordpress.stackexchange.com/questions/216338", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17306/" ]
I want to create a post type / format where I can create list type posts... For example... ``` h1.Title: The List Post Title like "Best Salads..." - Intro paragraph h2. Best Veg Salads - Intro -- h3. Salad #1 -- h3. Salad #2 .. -- h3. Salad #X h2. Best Non-Veg Salads - Intro -- h3. NV Salad #1 -- h3. NV Salad #2 .. ...
You may simply use `register_post_type` and `register_taxonomy` to do so: ``` function add_cpt_salads(){ $labels = array( 'name' => __( 'Salads', 'your-text-domain' ), 'singular_name' => __( 'Salad', 'your-text-domain' ), 'menu_name' ...
216,346
<p>At first I thought it was an ACF problem, but printing some values helped me to find out that somehow my Loop seems stuck on a single post, but only when some fields are concerned.</p> <p>To sum up my setup: I have installed the Advanced Custom Fields plugin and defined some custom fields (mostly numerical ones), o...
[ { "answer_id": 216340, "author": "Peyman Mohamadpour", "author_id": 75020, "author_profile": "https://wordpress.stackexchange.com/users/75020", "pm_score": 1, "selected": false, "text": "<p>You may simply use <code>register_post_type</code> and <code>register_taxonomy</code> to do so:</p...
2016/02/01
[ "https://wordpress.stackexchange.com/questions/216346", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87900/" ]
At first I thought it was an ACF problem, but printing some values helped me to find out that somehow my Loop seems stuck on a single post, but only when some fields are concerned. To sum up my setup: I have installed the Advanced Custom Fields plugin and defined some custom fields (mostly numerical ones), on which I ...
You may simply use `register_post_type` and `register_taxonomy` to do so: ``` function add_cpt_salads(){ $labels = array( 'name' => __( 'Salads', 'your-text-domain' ), 'singular_name' => __( 'Salad', 'your-text-domain' ), 'menu_name' ...
216,351
<p>I've been messing around with custom comments this week and I'm trying to figure out when I'd want to use a walker and when I'd use a callback... </p> <p>There's some things I can't quite figure out how to change, but the one that's been driving me mad is how to add classes to the children <code>&lt;ul&gt;</code> t...
[ { "answer_id": 216362, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": false, "text": "<p>We could rewrite:</p>\n\n<pre><code>wp_list_comments( array(\n 'callback' =&gt; 'bootstrap_comment_ca...
2016/02/01
[ "https://wordpress.stackexchange.com/questions/216351", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38123/" ]
I've been messing around with custom comments this week and I'm trying to figure out when I'd want to use a walker and when I'd use a callback... There's some things I can't quite figure out how to change, but the one that's been driving me mad is how to add classes to the children `<ul>` tag: `<ul class="children">...
We could rewrite: ``` wp_list_comments( array( 'callback' => 'bootstrap_comment_callback', )); ``` with the null `walker` parameter: ``` wp_list_comments( array( 'walker' => null, 'callback' => 'bootstrap_comment_callback', )); ``` which means we are using the default `Walker_Comme...
216,359
<p>I want to show/hide contents by using radio buttons on a WordPress page. When a user clicks on the radio button with label "red", the corresponding div with the class "red" needs to show up.</p> <p>Here's the (working) example I'm trying to integrate: <a href="http://www.tutorialrepublic.com/codelab.php?topic=faq&a...
[ { "answer_id": 216362, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": false, "text": "<p>We could rewrite:</p>\n\n<pre><code>wp_list_comments( array(\n 'callback' =&gt; 'bootstrap_comment_ca...
2016/02/01
[ "https://wordpress.stackexchange.com/questions/216359", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87912/" ]
I want to show/hide contents by using radio buttons on a WordPress page. When a user clicks on the radio button with label "red", the corresponding div with the class "red" needs to show up. Here's the (working) example I'm trying to integrate: <http://www.tutorialrepublic.com/codelab.php?topic=faq&file=jquery-show-hi...
We could rewrite: ``` wp_list_comments( array( 'callback' => 'bootstrap_comment_callback', )); ``` with the null `walker` parameter: ``` wp_list_comments( array( 'walker' => null, 'callback' => 'bootstrap_comment_callback', )); ``` which means we are using the default `Walker_Comme...
216,376
<p>I need a page template to be used with my plugin. I don't need to replace a theme template such as single or archive.</p> <p>Normally I'd use</p> <pre><code>/* * Template Name: Blah Blah Blah */ </code></pre> <p>to add a template to the page options, however, this isn't working in the plugin, as expected. I know ...
[ { "answer_id": 216382, "author": "тнє Sufi", "author_id": 28744, "author_profile": "https://wordpress.stackexchange.com/users/28744", "pm_score": 1, "selected": false, "text": "<p>There is no straight forward way to this, as per my knowledge. I have tried to search as well, and did not f...
2016/02/01
[ "https://wordpress.stackexchange.com/questions/216376", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8278/" ]
I need a page template to be used with my plugin. I don't need to replace a theme template such as single or archive. Normally I'd use ``` /* * Template Name: Blah Blah Blah */ ``` to add a template to the page options, however, this isn't working in the plugin, as expected. I know how to add a template for a custo...
Here is a fairly simple approach I was able to get working within a plugin. You'll want to reference <https://developer.wordpress.org/reference/hooks/theme_page_templates/> and <https://developer.wordpress.org/reference/hooks/template_include/> as you review the code below. ``` <?php //Add our custom template to the a...
216,397
<p>My permalinks are like mydomain.com/post and have to be like that, but because I use non-English characters (which need to be in the URL and make it really long and weird) for posting in social networks I need to have an extra permalink like mydomain.com/?p=123 (or something like that but with my exact domain).</p> ...
[ { "answer_id": 216400, "author": "alex", "author_id": 87934, "author_profile": "https://wordpress.stackexchange.com/users/87934", "pm_score": 0, "selected": false, "text": "<p>It's not a good idea to have two links pointing to the same Page or Post.there are two approaches: </p>\n\n<ol>\...
2016/02/02
[ "https://wordpress.stackexchange.com/questions/216397", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87933/" ]
My permalinks are like mydomain.com/post and have to be like that, but because I use non-English characters (which need to be in the URL and make it really long and weird) for posting in social networks I need to have an extra permalink like mydomain.com/?p=123 (or something like that but with my exact domain). P.S: I...
You can always use the post ID to link to a page, like this: ``` http://yourdomain.tld/?p=1234 ``` You can find out the Post ID right from the post overview screen. If you hover over the "Edit" or "Delete" link, you can see that the URL has a parameter `post=`. The number behind that is your page ID. It could happen...
216,417
<p>I want to check if a WordPress installation is working from a subdirectory.</p> <p>Common methods to achieve this are listed here: <a href="https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory" rel="nofollow">https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory</a></p> <p>these usually involve ...
[ { "answer_id": 216420, "author": "fischi", "author_id": 15680, "author_profile": "https://wordpress.stackexchange.com/users/15680", "pm_score": 3, "selected": true, "text": "<p>You need to check if the siteurl differs from the home URL:</p>\n\n<pre><code>if ( get_option( 'siteurl' ) !== ...
2016/02/02
[ "https://wordpress.stackexchange.com/questions/216417", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/8421/" ]
I want to check if a WordPress installation is working from a subdirectory. Common methods to achieve this are listed here: <https://codex.wordpress.org/Giving_WordPress_Its_Own_Directory> these usually involve changing an index file and requiring WordPress main file from there, perhaps changing rules in htaccess if ...
You need to check if the siteurl differs from the home URL: ``` if ( get_option( 'siteurl' ) !== get_option( 'home' ) ) { // whatever ``` This also works if `home` is a subdirectory of the root, with WordPress installed in yet another subdirectory. For example: domain.com/blog (URL) and domain.com/blog/wordpress (si...
216,427
<p>Just installed WP in Ubuntu 15.10 desktop on my local, home PC. It's the first time I install this CMS in Linux.</p> <p>After install I came to delete the two native plugins, Aksimet &amp; Hello Dolly.</p> <p>In the first time I did so I was (strangely) asked to fill in FTP credentials. Since I have no FTP I ran t...
[ { "answer_id": 216432, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 0, "selected": false, "text": "<p>Simple solution to this kind of mess that I use, is to have a local FTP server but limit it to the local ...
2016/02/02
[ "https://wordpress.stackexchange.com/questions/216427", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
Just installed WP in Ubuntu 15.10 desktop on my local, home PC. It's the first time I install this CMS in Linux. After install I came to delete the two native plugins, Aksimet & Hello Dolly. In the first time I did so I was (strangely) asked to fill in FTP credentials. Since I have no FTP I ran the FTP problem in Goo...
You need to make sure that the folder permissions/ownership are correct. Run this command to set ownership: ``` chown -R apache:apache /var/www/wordpress/ ```
216,445
<p>Per default, the way to disable autosaving and post revisions, is to modify <code>wp-config.php</code>. Is there a way, to do that from within a <strong>plugin</strong> or a themes <code>functions.php</code>?</p>
[ { "answer_id": 216447, "author": "T.Todua", "author_id": 33667, "author_profile": "https://wordpress.stackexchange.com/users/33667", "pm_score": 1, "selected": false, "text": "<p>i have found this code:</p>\n\n<pre><code>define('my_revisions_amount', 1); // let keep only one revi...
2016/02/02
[ "https://wordpress.stackexchange.com/questions/216445", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/33667/" ]
Per default, the way to disable autosaving and post revisions, is to modify `wp-config.php`. Is there a way, to do that from within a **plugin** or a themes `functions.php`?
i have found this code: ``` define('my_revisions_amount', 1); // let keep only one revision define('my_autosave_interval', 600); // 600 minutes is enough if (is_admin()){ add_filter( 'wp_revisions_to_keep', function(){ return my_revisions_amount; } ); add_filter( 'wp_print_scripts'...
216,468
<p>So I have this in my functions file - it defines the products that are not eligible for free shipping. It works everything is fine. </p> <pre><code>//functions.php function my_free_shipping( $is_available ) { global $woocommerce; // set the product ids that are $product_notfree_ship $product_notfree_ship = array( ...
[ { "answer_id": 216471, "author": "DHRUV GUPTA", "author_id": 76422, "author_profile": "https://wordpress.stackexchange.com/users/76422", "pm_score": 0, "selected": false, "text": "<p>Declare it as </p>\n\n<pre><code>global $product_notfree_ship\n</code></pre>\n\n<p>as you are doing, just...
2016/02/02
[ "https://wordpress.stackexchange.com/questions/216468", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85437/" ]
So I have this in my functions file - it defines the products that are not eligible for free shipping. It works everything is fine. ``` //functions.php function my_free_shipping( $is_available ) { global $woocommerce; // set the product ids that are $product_notfree_ship $product_notfree_ship = array( '1', '2', '3',...
It is all fine. You just need to declare variable global first then you can set the value of this and access globally. ``` function my_free_shipping( $is_available ) { global $woocommerce, $product_notfree_ship; // set the product ids that are $product_notfree_ship $product_notfree_ship = array( '1', '2', '3', '4', '...
216,474
<p>I'm new and getting stuck into to WordPress and really like the Elegant Theme Divi option, however I have a few questions I was hoping someone could help with.</p> <p>I do require that the site I build can offer the following functionality</p> <p>The ability to compare products</p> <p>Ability to register</p> <p>...
[ { "answer_id": 216471, "author": "DHRUV GUPTA", "author_id": 76422, "author_profile": "https://wordpress.stackexchange.com/users/76422", "pm_score": 0, "selected": false, "text": "<p>Declare it as </p>\n\n<pre><code>global $product_notfree_ship\n</code></pre>\n\n<p>as you are doing, just...
2016/02/02
[ "https://wordpress.stackexchange.com/questions/216474", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87988/" ]
I'm new and getting stuck into to WordPress and really like the Elegant Theme Divi option, however I have a few questions I was hoping someone could help with. I do require that the site I build can offer the following functionality The ability to compare products Ability to register Online forms that you can compl...
It is all fine. You just need to declare variable global first then you can set the value of this and access globally. ``` function my_free_shipping( $is_available ) { global $woocommerce, $product_notfree_ship; // set the product ids that are $product_notfree_ship $product_notfree_ship = array( '1', '2', '3', '4', '...
216,480
<p>I am trying to output the latest 5 posts from my blog. I would like each post thumbnail to populate divs in the following format.</p> <pre><code>&lt;div class="row full"&gt; &lt;div class="large-6 medium-6 small-12 columns"&gt;&lt;/div&gt; &lt;div class="large-6 medium-6 small-12 columns"&gt;&lt;/div&gt; &l...
[ { "answer_id": 238883, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 2, "selected": false, "text": "<p>That's a pretty complicated approach you're taking. Why not simply add a counter? Like this: </p>\n\n<pre><code>...
2016/02/02
[ "https://wordpress.stackexchange.com/questions/216480", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/84666/" ]
I am trying to output the latest 5 posts from my blog. I would like each post thumbnail to populate divs in the following format. ``` <div class="row full"> <div class="large-6 medium-6 small-12 columns"></div> <div class="large-6 medium-6 small-12 columns"></div> </div> <div class="row full"> <div class=...
That's a pretty complicated approach you're taking. Why not simply add a counter? Like this: ``` $i=1; echo '<div class="row full">'; if( $query->have_posts() ) { while ( $query->have_posts() ) { $query->the_post(); if ($i < 3) $class = "large-6 medium-6 small-12 columns" else ...
216,493
<p>I want to use the following code multiple times in the same page template, however the template gets too big when it comes to lines of code and therefore size. Every time I use it I change only one parameter and 99% remains the same. The parameter I change is <strong><code>'terms'=&gt;'pop'</code></strong>. I know I...
[ { "answer_id": 216495, "author": "LukeWarm", "author_id": 87806, "author_profile": "https://wordpress.stackexchange.com/users/87806", "pm_score": 0, "selected": false, "text": "<p>Create a new function, put all the code in it and replace 'pop' with $genre. Then call it like this:</p>\n\n...
2016/02/02
[ "https://wordpress.stackexchange.com/questions/216493", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15801/" ]
I want to use the following code multiple times in the same page template, however the template gets too big when it comes to lines of code and therefore size. Every time I use it I change only one parameter and 99% remains the same. The parameter I change is **`'terms'=>'pop'`**. I know I can display all posts and all...
To expand on the answer by Global: Paste this into your theme's functions.php: ``` function get_stations_query( $terms ) { //create new query object $query = new WP_Query( array( 'post_type' => 'stations', 'post_status' => 'publish', 'posts_per_...
216,497
<p>I'm trying to make a custom permalink structure for my posts.</p> <pre><code>www.example.com / post / %post_id% / %posttitle% / </code></pre> <p>In this permalink, the post's ID comes first, then the post's title after it.</p> <hr /> <h2>Things I know until now</h2> <p><code>postname</code> is usually stored in the ...
[ { "answer_id": 216521, "author": "heshamhussain", "author_id": 86130, "author_profile": "https://wordpress.stackexchange.com/users/86130", "pm_score": 1, "selected": false, "text": "<p>What I understand that you want to use <strong>post ID</strong> instead of <strong>Post Title</strong> ...
2016/02/02
[ "https://wordpress.stackexchange.com/questions/216497", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86145/" ]
I'm trying to make a custom permalink structure for my posts. ``` www.example.com / post / %post_id% / %posttitle% / ``` In this permalink, the post's ID comes first, then the post's title after it. --- Things I know until now ----------------------- `postname` is usually stored in the `wp_posts` table in the `po...
We have to do this keeping `post_name` unique. Otherwise, it might cause many troubles. We can use `post_title` with `sanitize_title`. In this way, you can keep your URL nice and clean, and your `post_name` will remain unique as well. First we will need to write custom permalink structure. ``` function my_awesome_per...
216,506
<p>My ultimate goal is to list the latest 5 posts, regardless of category.</p> <p>I would first like to make a <code>WP_Query</code> to get the latest two posts and insert them in to a specific HTML structure.</p> <p>Then I would like to make another <code>WP_Query</code> to get the next three posts and insert them i...
[ { "answer_id": 216507, "author": "bosco", "author_id": 25324, "author_profile": "https://wordpress.stackexchange.com/users/25324", "pm_score": 2, "selected": false, "text": "<p>You can use <a href=\"https://codex.wordpress.org/Class_Reference/WP_Query#Pagination_Parameters\" rel=\"nofoll...
2016/02/02
[ "https://wordpress.stackexchange.com/questions/216506", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/84666/" ]
My ultimate goal is to list the latest 5 posts, regardless of category. I would first like to make a `WP_Query` to get the latest two posts and insert them in to a specific HTML structure. Then I would like to make another `WP_Query` to get the next three posts and insert them in to a differing HTML structure. I've ...
Run one wp\_query for post\_per\_page = 2 and get the IDs of these 2 posts in an array to be excluded in the next 3 posts needed ``` <?php // The Query $next_args = array( 'post_type' => '<your_post_type>', 'post_status' => 'publish', 'posts_per_pag...
216,515
<p>everyone!</p> <p>I was wondering if anyone would be able to tell me how the content in my center column is able to expand its allowed container size and push my right column/widget area to the bottom?</p> <p>Here's a link to the page where I'm having this problem: <a href="https://goo.gl/XFnmnD" rel="nofollow">htt...
[ { "answer_id": 216517, "author": "Cheffheid", "author_id": 64470, "author_profile": "https://wordpress.stackexchange.com/users/64470", "pm_score": 1, "selected": false, "text": "<p>As far as I can tell, the most right column is being nested within the middle reviews column.</p>\n\n<p>I i...
2016/02/03
[ "https://wordpress.stackexchange.com/questions/216515", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88003/" ]
everyone! I was wondering if anyone would be able to tell me how the content in my center column is able to expand its allowed container size and push my right column/widget area to the bottom? Here's a link to the page where I'm having this problem: <https://goo.gl/XFnmnD> Here's a screenshot to show exactly where ...
As far as I can tell, the most right column is being nested within the middle reviews column. I imagine that somewhere in the code (template, sidebar, or widget) there is a conditional statement causing your middle column to not get closed off before the right column starts. To illustrate what is happening, this is h...
216,555
<p>So I have a URL which has a tracking link applied to the end. For some reason WordPress is removing the <code>&amp;</code> which is causing the tracking to fail. You can see the URL example here:</p> <blockquote> <p><a href="http://www.domain.co.uk/internalpage/?&amp;mkwid=smWfvaLGf_dm" rel="nofollow noreferrer">...
[ { "answer_id": 216563, "author": "Arpita Hunka", "author_id": 86864, "author_profile": "https://wordpress.stackexchange.com/users/86864", "pm_score": 0, "selected": false, "text": "<p>You can use here rawurlencode() function. First pass \"?&amp;mkwid=smWfvaLGf_dm\" this url into the func...
2016/02/03
[ "https://wordpress.stackexchange.com/questions/216555", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88030/" ]
So I have a URL which has a tracking link applied to the end. For some reason WordPress is removing the `&` which is causing the tracking to fail. You can see the URL example here: > > <http://www.domain.co.uk/internalpage/?&mkwid=smWfvaLGf_dm> > > > When you go through this, you then get **redirected** in a way ...
Here's the *why* part: [This part](https://github.com/WordPress/WordPress/blob/72c6f7f86f133a0d5ec669526eeb29ca024c0c19/wp-includes/canonical.php#L358-L359) of the `redirect_canonical()` is removing the leading `&` in the *redirect query* part: ``` // tack on any additional query vars $redirect['query'] = preg_replac...
216,573
<p>This is more of a 'Is it possible question" I have a home page which has a full width header and a transparent Navbar, when you scroll this Navbar changes to white. On all my other pages I want this Navbar to start white and stay white as you scroll. </p> <p>At the moment Im using jQuery to make the Navbar turn whi...
[ { "answer_id": 216563, "author": "Arpita Hunka", "author_id": 86864, "author_profile": "https://wordpress.stackexchange.com/users/86864", "pm_score": 0, "selected": false, "text": "<p>You can use here rawurlencode() function. First pass \"?&amp;mkwid=smWfvaLGf_dm\" this url into the func...
2016/02/03
[ "https://wordpress.stackexchange.com/questions/216573", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85362/" ]
This is more of a 'Is it possible question" I have a home page which has a full width header and a transparent Navbar, when you scroll this Navbar changes to white. On all my other pages I want this Navbar to start white and stay white as you scroll. At the moment Im using jQuery to make the Navbar turn white which w...
Here's the *why* part: [This part](https://github.com/WordPress/WordPress/blob/72c6f7f86f133a0d5ec669526eeb29ca024c0c19/wp-includes/canonical.php#L358-L359) of the `redirect_canonical()` is removing the leading `&` in the *redirect query* part: ``` // tack on any additional query vars $redirect['query'] = preg_replac...
216,595
<p>I use events manager pro plugin to show an eventslist. These event-list is showing their thumbnail image in the new (wordpress 4.4) wordpress image size "medium_large" (width 768px). I need an image size of 600x255px which is cropped from the center.</p> <p>How can i update these image size in my functions.php?</p>...
[ { "answer_id": 216597, "author": "denis.stoyanov", "author_id": 76287, "author_profile": "https://wordpress.stackexchange.com/users/76287", "pm_score": 1, "selected": false, "text": "<p>You can call <code>add_image_size()</code> again to update the existing image size. Assuming it is cal...
2016/02/03
[ "https://wordpress.stackexchange.com/questions/216595", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/81609/" ]
I use events manager pro plugin to show an eventslist. These event-list is showing their thumbnail image in the new (wordpress 4.4) wordpress image size "medium\_large" (width 768px). I need an image size of 600x255px which is cropped from the center. How can i update these image size in my functions.php?
You can call `add_image_size()` again to update the existing image size. Assuming it is called `medium_large` (Events Manager Pro is a paid plugin so not very much people have it) you can do something like: ``` <?php function update_medium_large_size_wpse216595() { add_image_size( 'medium_large', 600, 255, array( ...
216,681
<p>I have been searching google but I am really confused. I am trying to display the terms of the taxonomy assigned to the post. I am using <code>the_terms($post-&gt;ID, 'locations');</code>. The custom taxonomy is hierarchical.</p> <p>Example: 3 terms assigned to post: <code>USA(parent) &gt; FL(direct child of "USA")...
[ { "answer_id": 216687, "author": "Optimum Creative", "author_id": 71641, "author_profile": "https://wordpress.stackexchange.com/users/71641", "pm_score": -1, "selected": false, "text": "<p>You should use </p>\n\n<pre><code>get_the_terms(int|object $post, string $taxonomy)\n</code></pre>\...
2016/02/04
[ "https://wordpress.stackexchange.com/questions/216681", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15801/" ]
I have been searching google but I am really confused. I am trying to display the terms of the taxonomy assigned to the post. I am using `the_terms($post->ID, 'locations');`. The custom taxonomy is hierarchical. Example: 3 terms assigned to post: `USA(parent) > FL(direct child of "USA") > Miami(direct child of "FL")`....
To answer your first question > > What is the difference between those functions > > > * [`get_terms()`](https://developer.wordpress.org/reference/functions/get_terms/) returns an array of terms objects that belongs to a specific taxonomy * [`get_the_terms()`](https://developer.wordpress.org/reference/functions/...
216,694
<p>So today I've decided to implement a search form onto my site that obviously returns a result when the user searches for it, but I've run into a little problem.</p> <p><strong>My Problem</strong></p> <p>When the user searches for a result without inputting anything into the search form for some reason it returns 5...
[ { "answer_id": 216722, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 3, "selected": false, "text": "<p>I'm not sure if this is an intended bug or just a bug that was never anticipated, but it is definitely ...
2016/02/04
[ "https://wordpress.stackexchange.com/questions/216694", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85776/" ]
So today I've decided to implement a search form onto my site that obviously returns a result when the user searches for it, but I've run into a little problem. **My Problem** When the user searches for a result without inputting anything into the search form for some reason it returns 5 Pages whereas I would like it...
Just an alternative to the informative answer by @PieterGoosen. After Pieter posted this part: ``` if ( ! empty( $q['s'] ) ) { $search = $this->parse_search( $q ); } ``` it came to mind that it might be possible to re-parse the search query, within the `posts_search` filter, for empty search string. But the [`p...
216,741
<p>I wonder if anyone can help me with this little complex query with ACF.</p> <p>I have the following so far which should display: </p> <ul> <li><p>Pages, </p></li> <li><p>News Articles, </p></li> <li><p>About Articles and </p></li> <li><p>Involved Articles.</p></li> <li><p>Show: only 4.</p></li> </ul> <p>Only disp...
[ { "answer_id": 216761, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 2, "selected": false, "text": "<p>You should really read the <a href=\"https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_...
2016/02/04
[ "https://wordpress.stackexchange.com/questions/216741", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4630/" ]
I wonder if anyone can help me with this little complex query with ACF. I have the following so far which should display: * Pages, * News Articles, * About Articles and * Involved Articles. * Show: only 4. Only display if: the ACF/Meta Key ‘home\_page’ is selected ‘yes’ AND Order by the numeric value of the ACF/M...
You should really read the [documentation on `meta_query`'s](https://codex.wordpress.org/Class_Reference/WP_Query#Custom_Field_Parameters) Here is what is allowed in a `meta_query` * key (string) - Custom field key. * value (string|array) - Custom field value. It can be an array only when compare is `'IN'`, `'NOT IN'...
216,743
<p>I'm trying to find all users that are logged in to WordPress. </p> <p>I can detect myself, but I want to be able to find the other admins. Here is my current code to find myself.</p> <pre><code>if (user_can( $current_user, 'administrator' )) { echo '&lt;div class="admin"&gt; User currently logged in "' ...
[ { "answer_id": 216751, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 2, "selected": false, "text": "<p>Wordpress do not have a true concept of \"logged in\". Although the labels all around use the term, in th...
2016/02/04
[ "https://wordpress.stackexchange.com/questions/216743", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88140/" ]
I'm trying to find all users that are logged in to WordPress. I can detect myself, but I want to be able to find the other admins. Here is my current code to find myself. ``` if (user_can( $current_user, 'administrator' )) { echo '<div class="admin"> User currently logged in "' . $current_user->user...
Wordpress do not have a true concept of "logged in". Although the labels all around use the term, in the code the closest you get is something that might be called "authenticated users". The difference is that the authenticated user might be one that has his browser closed and therefor he is not "logged in". To do wha...
216,752
<p>The WP site I am creating requires creating diff posts for diff categories.</p> <p>What I like is that if someone chose to post under category A, i have a bunch of pre-set settings (tags, banner image etc) in that post.</p> <p>If the person posts under category B, there will be a diff set of settings?</p> <p>Does...
[ { "answer_id": 216754, "author": "Rituparna sonowal", "author_id": 71232, "author_profile": "https://wordpress.stackexchange.com/users/71232", "pm_score": -1, "selected": false, "text": "<p>As per your description ACF will be enough and easiest way to do that. Create custom fields group ...
2016/02/05
[ "https://wordpress.stackexchange.com/questions/216752", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/65697/" ]
The WP site I am creating requires creating diff posts for diff categories. What I like is that if someone chose to post under category A, i have a bunch of pre-set settings (tags, banner image etc) in that post. If the person posts under category B, there will be a diff set of settings? Does anyone know if there's ...
After scouring on the net and bouncing around, I figured out how to fix my problem. 1. Install ACF and create your own post types. 2. In Functions.php, add the following codes to default category for that post type. ``` function add_pastorheart_category_automatically($post_ID) { global $wpdb; if(!wp_is_post_r...
216,756
<p>I wanted to use the site URL change in the general settings page of the admin panel to remove the trailing /wp from my privately hosted wordpress site. After submitting these changes, I am locked out by errors every time I attempt to log in--from a log-in page where the CSS is gone. I have attempted to update the co...
[ { "answer_id": 216758, "author": "techsharez.com", "author_id": 88148, "author_profile": "https://wordpress.stackexchange.com/users/88148", "pm_score": 0, "selected": false, "text": "<p>Have you checked this one? If no just check this post. Hope this will help you to solve your problem ...
2016/02/05
[ "https://wordpress.stackexchange.com/questions/216756", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88146/" ]
I wanted to use the site URL change in the general settings page of the admin panel to remove the trailing /wp from my privately hosted wordpress site. After submitting these changes, I am locked out by errors every time I attempt to log in--from a log-in page where the CSS is gone. I have attempted to update the confi...
Best way > > If you have access to the site via FTP, then this method will help you quickly get a site back up and running, if you changed those values incorrectly. > > > 1. FTP to the site, and get a copy of the active theme's functions.php file. You're going to edit it in a simple text editor and upload it back t...
216,759
<p>I want to create and set a custom taxonomy site-wide based on the users location so that I can call <code>taxonomy_exists( $country )</code> to determine if a user is located in a specific country.</p> <p>I've installed the GeoIP plugin that lets me get the user's country code from <code>$userInfo-&gt;country-&gt;i...
[ { "answer_id": 216758, "author": "techsharez.com", "author_id": 88148, "author_profile": "https://wordpress.stackexchange.com/users/88148", "pm_score": 0, "selected": false, "text": "<p>Have you checked this one? If no just check this post. Hope this will help you to solve your problem ...
2016/02/05
[ "https://wordpress.stackexchange.com/questions/216759", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/81557/" ]
I want to create and set a custom taxonomy site-wide based on the users location so that I can call `taxonomy_exists( $country )` to determine if a user is located in a specific country. I've installed the GeoIP plugin that lets me get the user's country code from `$userInfo->country->isoCode`. To register the custom...
Best way > > If you have access to the site via FTP, then this method will help you quickly get a site back up and running, if you changed those values incorrectly. > > > 1. FTP to the site, and get a copy of the active theme's functions.php file. You're going to edit it in a simple text editor and upload it back t...
216,765
<p>I have a custom ACF field set on all posts, called <code>event_date</code>, I would like to grab all posts within a given <code>category</code>, but have posts that have <code>event_date</code> defined put first in DESC order of <code>event_date</code>. The <code>args</code> I'm using for <code>query_posts</code> a...
[ { "answer_id": 216766, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 3, "selected": true, "text": "<p>You can get both with an <code>OR</code> <code>meta_query</code> that also checks if the key does not exist:</p>\n\...
2016/02/05
[ "https://wordpress.stackexchange.com/questions/216765", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54603/" ]
I have a custom ACF field set on all posts, called `event_date`, I would like to grab all posts within a given `category`, but have posts that have `event_date` defined put first in DESC order of `event_date`. The `args` I'm using for `query_posts` are as follows: ``` $args = array( 'posts_per_page' => -1, 'ca...
You can get both with an `OR` `meta_query` that also checks if the key does not exist: ``` 'meta_query' => array( 'relation' => 'OR', array( 'key' => 'event_date', 'compare' => 'NOT EXISTS', ), array( 'key' => 'event_date', 'value' => date("Ymd", time()), 'compar...
216,793
<p>I would like to find out which page template is in use as I only want to enqueue some javascript if the page is using a certain template. Is this possible?</p>
[ { "answer_id": 216795, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 3, "selected": false, "text": "<p>I'm not sure if this is for front end or back end, so I'm going to handle both.</p>\n\n<h2>BACK END</h2...
2016/02/05
[ "https://wordpress.stackexchange.com/questions/216793", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17862/" ]
I would like to find out which page template is in use as I only want to enqueue some javascript if the page is using a certain template. Is this possible?
I'm not sure if this is for front end or back end, so I'm going to handle both. BACK END -------- You can make use of `get_current_screen()` or the `$pagenow` global. Here are two examples which you can add in a plugin or in your `functions.php` to check the relevant info on an admin page ``` add_action( 'current_sc...
216,802
<p>I have created a custom post type to pull through the date, title, thumbnail and content, some of the posts have images and <code>the_content()</code> is pulling through those images and I don't know how to stop it from doing this, Could someone help me with this issue?</p> <p>My code:</p> <pre><code>&lt;?php if (...
[ { "answer_id": 216808, "author": "Tom Withers", "author_id": 85362, "author_profile": "https://wordpress.stackexchange.com/users/85362", "pm_score": -1, "selected": false, "text": "<p>I figured out how to do this,</p>\n\n<p>Instead of using <code>the_content();</code> Im now using <code>...
2016/02/05
[ "https://wordpress.stackexchange.com/questions/216802", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85362/" ]
I have created a custom post type to pull through the date, title, thumbnail and content, some of the posts have images and `the_content()` is pulling through those images and I don't know how to stop it from doing this, Could someone help me with this issue? My code: ``` <?php if ( have_posts() ) : while ( have_post...
Add this code to your `functions.php` ``` function mdc_remove_img($content) { $content = preg_replace("/<img[^>]+\>/i", "", $content); return $content; } add_filter( 'the_content', 'mdc_remove_img' ); ```
216,821
<p>I have several custom post types (created through CPT UI plugin). I want to display posts from these post types on my page, for example "News". I've created a page and inserted in it shortcode <code>[show_posts post_type="novyny"].</code> I've got a plugin that processes this shortcode</p> <pre><code>function foo($...
[ { "answer_id": 216830, "author": "Sumit", "author_id": 32475, "author_profile": "https://wordpress.stackexchange.com/users/32475", "pm_score": 3, "selected": true, "text": "<p><code>the_posts_pagination</code> uses <code>global</code> query and global query does not have pagination. So i...
2016/02/05
[ "https://wordpress.stackexchange.com/questions/216821", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86327/" ]
I have several custom post types (created through CPT UI plugin). I want to display posts from these post types on my page, for example "News". I've created a page and inserted in it shortcode `[show_posts post_type="novyny"].` I've got a plugin that processes this shortcode ``` function foo($args){ $post_type = $...
`the_posts_pagination` uses `global` query and global query does not have pagination. So it is the correct behavior of WordPress. To overcome from this problem assign custom query to global query then after looping again restore the global query. ``` function foo($args){ $post_type = $args['post_type']; globa...
216,859
<p>I'm trying to delete a variable stored in local storage when user logs out of WordPress, none of the two code blocks below work for me, both have been tested in my functions.php file one at a time. </p> <pre><code> function del_local_reload_var() { $str = &lt;&lt;&lt;HD &lt;script&gt; localS...
[ { "answer_id": 216865, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 1, "selected": false, "text": "<p><code>wp_logout</code> is being triggered server side when the user is logging out, but the fact that it ...
2016/02/06
[ "https://wordpress.stackexchange.com/questions/216859", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/76433/" ]
I'm trying to delete a variable stored in local storage when user logs out of WordPress, none of the two code blocks below work for me, both have been tested in my functions.php file one at a time. ``` function del_local_reload_var() { $str = <<<HD <script> localStorage.removeItem("justOnce");...
`wp_logout` is being triggered server side when the user is logging out, but the fact that it is being triggered do not indicate that there is a browser on the other side that actually triggered it. For example a user might log out via Ajax and then the JS code will not be evaluated. In any case, it is much better to ...
216,879
<p>I am struggling a lot this time working on including a JavaScript files in plugin folder.</p> <p>I am trying to create a plugin by transferring widget files from themes directory. I copied the widget file, but that widget file was depending on a JavaScript file so I created a /js/ folder in plugin directory. where ...
[ { "answer_id": 216880, "author": "mukto90", "author_id": 57944, "author_profile": "https://wordpress.stackexchange.com/users/57944", "pm_score": 1, "selected": false, "text": "<p><strong>UPDATED:</strong></p>\n\n<p>Use this code instead</p>\n\n<pre><code>function Zumper_widget_enqueue_sc...
2016/02/06
[ "https://wordpress.stackexchange.com/questions/216879", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105791/" ]
I am struggling a lot this time working on including a JavaScript files in plugin folder. I am trying to create a plugin by transferring widget files from themes directory. I copied the widget file, but that widget file was depending on a JavaScript file so I created a /js/ folder in plugin directory. where this files...
Your code seems correct, but it will load the script only in admin area beacuse you are enqueuing the script in [`admin_enqueue_scripts` action](https://codex.wordpress.org/Plugin_API/Action_Reference/admin_enqueue_scripts). To load the script in frontend, use `wp_enqueue_scripts` action (which is not the same that [`...
216,894
<p>When I made a Bootstrap carousel in plain HTML it was working just fine, but when I pasted the code into Wordpress the carousel is completely white.</p> <p><br /> It's not a problem with the path because it will work if I change it from</p> <pre><code>&lt;div class="fill" style="background-image:url("img/image01.p...
[ { "answer_id": 232383, "author": "matt", "author_id": 98400, "author_profile": "https://wordpress.stackexchange.com/users/98400", "pm_score": 0, "selected": false, "text": "<pre><code>&lt;div class=\"fill\" style=\"background-image:url(\"img/image01.png\");\"&gt;&lt;/div&gt;\n</code></pr...
2016/02/06
[ "https://wordpress.stackexchange.com/questions/216894", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/84013/" ]
When I made a Bootstrap carousel in plain HTML it was working just fine, but when I pasted the code into Wordpress the carousel is completely white. It's not a problem with the path because it will work if I change it from ``` <div class="fill" style="background-image:url("img/image01.png");"></div> ``` to ``` <i...
What if you use: ``` <div class="fill" style="background-image: url(<?php echo get_stylesheet_directory_uri();?>/img/image01.png);"></div> ``` You need to tell WordPress in "a WordPress-way" where to find the image... Look in codex at [get\_stylesheet\_directory\_uri()](https://codex.wordpress.org/Function_Refe...
216,896
<p>I have a field that lets me enter a price for a product in 'edit post'.</p> <p>Here's how it's currently called: </p> <pre><code>&lt;span class="price"&gt; "$" &lt;?php echo get_post_meta(get_the_ID(),'si-price',true); ?&gt; &lt;/span&gt; </code></pre> <p>Because some products are discontinued, I would like to on...
[ { "answer_id": 232383, "author": "matt", "author_id": 98400, "author_profile": "https://wordpress.stackexchange.com/users/98400", "pm_score": 0, "selected": false, "text": "<pre><code>&lt;div class=\"fill\" style=\"background-image:url(\"img/image01.png\");\"&gt;&lt;/div&gt;\n</code></pr...
2016/02/06
[ "https://wordpress.stackexchange.com/questions/216896", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88223/" ]
I have a field that lets me enter a price for a product in 'edit post'. Here's how it's currently called: ``` <span class="price"> "$" <?php echo get_post_meta(get_the_ID(),'si-price',true); ?> </span> ``` Because some products are discontinued, I would like to only show the "$" if what I type in the box is a numb...
What if you use: ``` <div class="fill" style="background-image: url(<?php echo get_stylesheet_directory_uri();?>/img/image01.png);"></div> ``` You need to tell WordPress in "a WordPress-way" where to find the image... Look in codex at [get\_stylesheet\_directory\_uri()](https://codex.wordpress.org/Function_Refe...
216,903
<p>In my theme, I have a custom post type called sliders. Here the user is allowed to upload images in a <code>meta-box</code>. So, the images are saved as meta data in <code>wp_post_meta</code> table. </p> <p>Now what I want to do is, displaying a slider using its ID. </p> <p>I did like following but no result</p> ...
[ { "answer_id": 232383, "author": "matt", "author_id": 98400, "author_profile": "https://wordpress.stackexchange.com/users/98400", "pm_score": 0, "selected": false, "text": "<pre><code>&lt;div class=\"fill\" style=\"background-image:url(\"img/image01.png\");\"&gt;&lt;/div&gt;\n</code></pr...
2016/02/06
[ "https://wordpress.stackexchange.com/questions/216903", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62209/" ]
In my theme, I have a custom post type called sliders. Here the user is allowed to upload images in a `meta-box`. So, the images are saved as meta data in `wp_post_meta` table. Now what I want to do is, displaying a slider using its ID. I did like following but no result ``` $my_query = new WP_Query('post_type=sli...
What if you use: ``` <div class="fill" style="background-image: url(<?php echo get_stylesheet_directory_uri();?>/img/image01.png);"></div> ``` You need to tell WordPress in "a WordPress-way" where to find the image... Look in codex at [get\_stylesheet\_directory\_uri()](https://codex.wordpress.org/Function_Refe...
216,908
<p>Is there a way to make the admins see only their pod entries in the back-end "View All entries" ?</p> <p>Normal users see only their entries but admins see everything no matter how i configure the roles….</p>
[ { "answer_id": 232383, "author": "matt", "author_id": 98400, "author_profile": "https://wordpress.stackexchange.com/users/98400", "pm_score": 0, "selected": false, "text": "<pre><code>&lt;div class=\"fill\" style=\"background-image:url(\"img/image01.png\");\"&gt;&lt;/div&gt;\n</code></pr...
2016/02/06
[ "https://wordpress.stackexchange.com/questions/216908", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/66972/" ]
Is there a way to make the admins see only their pod entries in the back-end "View All entries" ? Normal users see only their entries but admins see everything no matter how i configure the roles….
What if you use: ``` <div class="fill" style="background-image: url(<?php echo get_stylesheet_directory_uri();?>/img/image01.png);"></div> ``` You need to tell WordPress in "a WordPress-way" where to find the image... Look in codex at [get\_stylesheet\_directory\_uri()](https://codex.wordpress.org/Function_Refe...
216,912
<p>Any expert who knows about removing <a href="https://wordpress.org/plugins/remove-query-strings-from-static-resources/" rel="nofollow noreferrer">Remove Query Strings From Static Resources</a> plugin? It's not working.</p> <p>Also, I have tried to write this code in <code>function.php</code> file of my theme</p> <...
[ { "answer_id": 217973, "author": "CodyA", "author_id": 84632, "author_profile": "https://wordpress.stackexchange.com/users/84632", "pm_score": 3, "selected": false, "text": "<p>It looks like you are using JetPack's Photon which adds query strings to your URLs. According to this thread th...
2016/02/06
[ "https://wordpress.stackexchange.com/questions/216912", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88233/" ]
Any expert who knows about removing [Remove Query Strings From Static Resources](https://wordpress.org/plugins/remove-query-strings-from-static-resources/) plugin? It's not working. Also, I have tried to write this code in `function.php` file of my theme ``` function _remove_script_version( $src ){ $parts = explode( ...
It looks like you are using JetPack's Photon which adds query strings to your URLs. According to this thread there is no way to remove them <https://wordpress.org/support/topic/how-to-remove-photon-query-string?replies=2> If you want to get rid of the query strings I would suggest deactivating photon, using a CDN whic...
216,913
<p>How do I convert file system path to URL? I have found some general PHP solutions that can be error prone.</p> <p>Is there some WordPress specific way to do it?</p>
[ { "answer_id": 216915, "author": "chrisguitarguy", "author_id": 6035, "author_profile": "https://wordpress.stackexchange.com/users/6035", "pm_score": 4, "selected": true, "text": "<p>Kind of depends on where you are in the WordPress environment.</p>\n\n<h2>Plugins</h2>\n\n<p>If you're in...
2016/02/06
[ "https://wordpress.stackexchange.com/questions/216913", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/85230/" ]
How do I convert file system path to URL? I have found some general PHP solutions that can be error prone. Is there some WordPress specific way to do it?
Kind of depends on where you are in the WordPress environment. Plugins ------- If you're in a plugin, you can use [`plugins_url`](https://codex.wordpress.org/Function_Reference/plugins_url). ``` <?php $url = plugins_url('css/admin.css', __FILE__); ``` The above will give you the path relative to the file passed in...
216,929
<p>I'm currently trying to output a list of music titles and would like to have the sorting ignore (but still display) the initial article of the title.</p> <p>For example if I had a list of bands it will be displayed alphabetically in WordPress like this:</p> <ul> <li>Black Sabbath </li> <li>Led Zeppelin</li> <li>Pi...
[ { "answer_id": 216942, "author": "majick", "author_id": 76440, "author_profile": "https://wordpress.stackexchange.com/users/76440", "pm_score": 4, "selected": false, "text": "<p>An easier way may be to go through and change the permalink slug on those posts that need it (under the title ...
2016/02/07
[ "https://wordpress.stackexchange.com/questions/216929", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86933/" ]
I'm currently trying to output a list of music titles and would like to have the sorting ignore (but still display) the initial article of the title. For example if I had a list of bands it will be displayed alphabetically in WordPress like this: * Black Sabbath * Led Zeppelin * Pink Floyd * The Beatles * The Kinks *...
The Problem ----------- I think there's a typo in there: The name of the filter is `posts_fields` not `post_fields`. That could explain why the `title2` field is unknown, because it's definition isn't added to the generated SQL string. Alternative - Single filter --------------------------- We can rewrite it to us...
216,966
<p>Here's the code I'm trying to use.</p> <pre><code>&lt;input type="button" class="next-step" value="Adopt Now" onClick="parent.location='http://example.com/adoption-application/?Name=[Title]'" /&gt; </code></pre> <p>The shortcode Title is defined.</p> <p>End link in browser shows as <a href="http://example.com/ado...
[ { "answer_id": 216972, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 1, "selected": false, "text": "<p>You can not use a shortcode inside an attribute. You need to make a shortcode that will output the whole ...
2016/02/07
[ "https://wordpress.stackexchange.com/questions/216966", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88257/" ]
Here's the code I'm trying to use. ``` <input type="button" class="next-step" value="Adopt Now" onClick="parent.location='http://example.com/adoption-application/?Name=[Title]'" /> ``` The shortcode Title is defined. End link in browser shows as <http://example.com/adoption-application/?Name=[Title]> Should show a...
You can not use a shortcode inside an attribute. You need to make a shortcode that will output the whole element.
217,013
<p>I am working on an enhanced revisioning system, to create a log file for all changes made by users and/or algorithms concerning metadata attached to specific post types.</p> <p>While I am perfectly aware that <code>update_post_meta</code> works for all post types, while <code>update_postmeta</code> just works on po...
[ { "answer_id": 217019, "author": "Adam", "author_id": 13418, "author_profile": "https://wordpress.stackexchange.com/users/13418", "pm_score": 3, "selected": true, "text": "<p>They were both introduced in version 2.9, but were done so in different files.</p>\n\n<p><code>update_postmeta</c...
2016/02/08
[ "https://wordpress.stackexchange.com/questions/217013", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/15680/" ]
I am working on an enhanced revisioning system, to create a log file for all changes made by users and/or algorithms concerning metadata attached to specific post types. While I am perfectly aware that `update_post_meta` works for all post types, while `update_postmeta` just works on post, my question is not dependent...
They were both introduced in version 2.9, but were done so in different files. `update_postmeta` went into [`/wp-admin/includes/post.php`](http://svn.automattic.com/wordpress/tags/2.9/wp-admin/includes/post.php) While... `update_{$meta_type}_meta` went into [`/wp-includes/meta.php`](http://adambrown.info/p/wp_hooks/...
217,027
<p>I have used to following code to change the location of 'single' Wordpress templates.</p> <pre><code>define(SINGLE_PATH, TEMPLATEPATH.'/single/'); add_filter('single_template', 'lsmwp_custom_single'); function lsmwp_custom_single($single) { global $wp_query, $post; if ($post-&gt;post_type == "cpt_operator"){...
[ { "answer_id": 217035, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 4, "selected": true, "text": "<p>You have a lot of issues here. </p>\n\n<ul>\n<li><p>Stay away from defining globals and constants if you...
2016/02/08
[ "https://wordpress.stackexchange.com/questions/217027", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/71177/" ]
I have used to following code to change the location of 'single' Wordpress templates. ``` define(SINGLE_PATH, TEMPLATEPATH.'/single/'); add_filter('single_template', 'lsmwp_custom_single'); function lsmwp_custom_single($single) { global $wp_query, $post; if ($post->post_type == "cpt_operator"){ if(file_ex...
You have a lot of issues here. * Stay away from defining globals and constants if you can. The global scope is an evil place to be. WordPress has made a huge mess of the global scope already, don't make it a bigger mess than it already is. You can make use a static variable inside your function/filter * Avoid using `...
217,038
<p>I need to see all urls of all publish blog posts in the site. How can I get this? I want this for redirecting in .htaccess of old site to new site. This needed in anything page of site.The result is each posts url on a new line.</p>
[ { "answer_id": 217035, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 4, "selected": true, "text": "<p>You have a lot of issues here. </p>\n\n<ul>\n<li><p>Stay away from defining globals and constants if you...
2016/02/08
[ "https://wordpress.stackexchange.com/questions/217038", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88305/" ]
I need to see all urls of all publish blog posts in the site. How can I get this? I want this for redirecting in .htaccess of old site to new site. This needed in anything page of site.The result is each posts url on a new line.
You have a lot of issues here. * Stay away from defining globals and constants if you can. The global scope is an evil place to be. WordPress has made a huge mess of the global scope already, don't make it a bigger mess than it already is. You can make use a static variable inside your function/filter * Avoid using `...
217,072
<p>I'm hoping someone can help me with this seemingly simple problem. </p> <p>This is a custom theme that I've been given, and simply changing the number of displayed posts in the Settings menu is ineffective(it's set to 10). But I can't tell where the number of post excerpts being displayed on the blog page is set. I...
[ { "answer_id": 217077, "author": "idpokute", "author_id": 87895, "author_profile": "https://wordpress.stackexchange.com/users/87895", "pm_score": -1, "selected": false, "text": "<p>Use the following code: </p>\n\n<pre><code>query_posts('posts_per_page=5');\n$blogOptions = ($shortcode_val...
2016/02/08
[ "https://wordpress.stackexchange.com/questions/217072", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35682/" ]
I'm hoping someone can help me with this seemingly simple problem. This is a custom theme that I've been given, and simply changing the number of displayed posts in the Settings menu is ineffective(it's set to 10). But I can't tell where the number of post excerpts being displayed on the blog page is set. It's curren...
That looks like a <http://para.llel.us/support/> theme. You might start there for docs—for instance, they probably have a custom 'Theme Options' page in the admin. Short of that, and presuming you're ok with setting it in code (which may negate any future settings in the admin), you'll first need to find out where `$b...
217,075
<p>I currently use <code>Post name</code> for the permalink structure. I want to add text from a field at the end of the permalink. Is there any hook for the permalink creation when a <code>Post</code> is published?</p> <p>In my case, I use <code>Advanced Custom Fields</code> and every post has a Title and Subtitle. C...
[ { "answer_id": 217079, "author": "stoopkid1", "author_id": 55193, "author_profile": "https://wordpress.stackexchange.com/users/55193", "pm_score": -1, "selected": false, "text": "<p>in your functions.php file, you should be able to accomplish your desired functionality with something lik...
2016/02/08
[ "https://wordpress.stackexchange.com/questions/217075", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/59235/" ]
I currently use `Post name` for the permalink structure. I want to add text from a field at the end of the permalink. Is there any hook for the permalink creation when a `Post` is published? In my case, I use `Advanced Custom Fields` and every post has a Title and Subtitle. Currently, the permalink is `/title/` but I ...
Here is what I did to implement this: ``` function slug_save_post_callback( $post_ID, $post, $update ) { // allow 'publish', 'draft', 'future' if ($post->post_type != 'post' || $post->post_status == 'auto-draft') return; // only change slug when the post is created (both dates are equal) if ($...
217,097
<p>Is possible to check if has any sidebar active on current page?</p> <p>Like this:</p> <p>@edit</p> <p><em>This function also return true even if the current page does not have this sidebar active...</em></p> <pre><code>&lt;?php if(is_active_sidebar('sidebar-1')) { // sidebar-1 is active... } ?&gt; </code></pre> ...
[ { "answer_id": 217281, "author": "Sterling Hamilton", "author_id": 10075, "author_profile": "https://wordpress.stackexchange.com/users/10075", "pm_score": 2, "selected": false, "text": "<p>I believe the issue here is a problem with vernacular.</p>\n\n<p><code>is_active_sidebar</code> isn...
2016/02/09
[ "https://wordpress.stackexchange.com/questions/217097", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/39187/" ]
Is possible to check if has any sidebar active on current page? Like this: @edit *This function also return true even if the current page does not have this sidebar active...* ``` <?php if(is_active_sidebar('sidebar-1')) { // sidebar-1 is active... } ?> ``` But I need to check if has any sidebar active (without s...
I believe the issue here is a problem with vernacular. `is_active_sidebar` isn't page specific -- just checks to see if it has data within it throughout the entire site. You are asking a different question. Sounds like you are asking "does this template reference and sidebars AND do any of those sidebars have data in...
217,103
<p>I am using AngularJS to load a list of my WordPress posts, however I can not get any of my PHP functions to work with my partials file. </p> <p>I've tried using something such as <code>search.php</code> instead of <code>search.html</code> but when doing so I get errors such as fatal error get_post_meta is undefined...
[ { "answer_id": 217281, "author": "Sterling Hamilton", "author_id": 10075, "author_profile": "https://wordpress.stackexchange.com/users/10075", "pm_score": 2, "selected": false, "text": "<p>I believe the issue here is a problem with vernacular.</p>\n\n<p><code>is_active_sidebar</code> isn...
2016/02/09
[ "https://wordpress.stackexchange.com/questions/217103", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/24067/" ]
I am using AngularJS to load a list of my WordPress posts, however I can not get any of my PHP functions to work with my partials file. I've tried using something such as `search.php` instead of `search.html` but when doing so I get errors such as fatal error get\_post\_meta is undefined. Now I know we are not supp...
I believe the issue here is a problem with vernacular. `is_active_sidebar` isn't page specific -- just checks to see if it has data within it throughout the entire site. You are asking a different question. Sounds like you are asking "does this template reference and sidebars AND do any of those sidebars have data in...
217,116
<p>Could you please let me know wordpress action hook that must triggered only once when a user create a new custom post.</p> <p>That means if user creates a new post that hook must be triggered but when user update or edit the post then that hook should not be executed.</p> <p>Previously i was using publish_post but...
[ { "answer_id": 217120, "author": "Max Yudin", "author_id": 11761, "author_profile": "https://wordpress.stackexchange.com/users/11761", "pm_score": 2, "selected": false, "text": "<p>You have to use <code>new_to_publish</code> action as described on <a href=\"https://codex.wordpress.org/Po...
2016/02/09
[ "https://wordpress.stackexchange.com/questions/217116", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74154/" ]
Could you please let me know wordpress action hook that must triggered only once when a user create a new custom post. That means if user creates a new post that hook must be triggered but when user update or edit the post then that hook should not be executed. Previously i was using publish\_post but it always execu...
You have to use `new_to_publish` action as described on [Post Status Transitions](https://codex.wordpress.org/Post_Status_Transitions) Codex page (updated according @prog comment): ``` add_action( 'new_to_publish', 'pms_post_published_notification', 10, 1 ); function pms_post_published_notification( $post ) { if(...
217,125
<p>I found here on WPSE that you can <a href="https://wordpress.stackexchange.com/questions/140319/add-content-before-after-admin-post-wp-list-table">add content before post title</a> in the post page, and in custom post type pages</p> <pre><code> add_action( 'load-edit.php', function(){ $screen = get_curre...
[ { "answer_id": 217182, "author": "Charles Jaimet", "author_id": 43741, "author_profile": "https://wordpress.stackexchange.com/users/43741", "pm_score": 2, "selected": false, "text": "<p>You can do it with JavaScript.</p>\n\n<pre><code>add_action( 'all_admin_notices', function(){\n ech...
2016/02/09
[ "https://wordpress.stackexchange.com/questions/217125", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58895/" ]
I found here on WPSE that you can [add content before post title](https://wordpress.stackexchange.com/questions/140319/add-content-before-after-admin-post-wp-list-table) in the post page, and in custom post type pages ``` add_action( 'load-edit.php', function(){ $screen = get_current_screen(); // ...
You could try to "hijack" the following filter in the `WP_List_Table` class: ``` /** * Filter the list of available list table views. * * The dynamic portion of the hook name, `$this->screen->id`, refers * to the ID of the current screen, usually a string. * * @since 3.5.0 * * @param array $views An array of a...
217,126
<p>Hello I am really sorry if this has been asked before but I couldn't find the exact solution I need. So here's the problem I want to create a search in my Wordpress page. Whenever a user submits the form I want to create a query to search for posts by their categories or their parents/child categories. Here's an exa...
[ { "answer_id": 217173, "author": "Charles Jaimet", "author_id": 43741, "author_profile": "https://wordpress.stackexchange.com/users/43741", "pm_score": 1, "selected": false, "text": "<p>Use this:</p>\n\n<pre><code>$query = new WP_Query( array( 'cat' =&gt; 4 ) );\n</code></pre>\n\n<p>Wher...
2016/02/09
[ "https://wordpress.stackexchange.com/questions/217126", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88373/" ]
Hello I am really sorry if this has been asked before but I couldn't find the exact solution I need. So here's the problem I want to create a search in my Wordpress page. Whenever a user submits the form I want to create a query to search for posts by their categories or their parents/child categories. Here's an exampl...
Use `get_categories` first to get all the post categories to use in the form, then loop through them to display a multicheck input... ``` function hierarchical_category_inputs ($cat, $indent) { $cats = get_categories('hide_empty=false&orderby=name&order=ASC&parent='.$cat); $indent++; if ($cats) { ...
217,135
<p>I am trying to set a single page template that will apply to any page which URL begins with confirmation-.</p> <p>For example (page names):</p> <pre><code>confirmation-tt5, confirmation-556, </code></pre> <p>Should I just create a <code>single-confirmation</code> or will I need a custom filter?</p>
[ { "answer_id": 217137, "author": "James", "author_id": 71177, "author_profile": "https://wordpress.stackexchange.com/users/71177", "pm_score": 0, "selected": false, "text": "<pre><code>$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];\nif (strpos($url,'confirmation') ...
2016/02/09
[ "https://wordpress.stackexchange.com/questions/217135", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/71177/" ]
I am trying to set a single page template that will apply to any page which URL begins with confirmation-. For example (page names): ``` confirmation-tt5, confirmation-556, ``` Should I just create a `single-confirmation` or will I need a custom filter?
We can make use of the `page_template` filter to achieve this. All we need to do is to make sure that `confirmation` is the first word in the page page title ``` add_filter( 'page_template', function ( $template ) { // Get the current page object $post = get_queried_object(); /** * Get the first inst...
217,141
<p>I set up a local environment to customize a friend's WP blog. However almost none of the images are being displayed.</p> <p>The remote site's URL is <code>http://sitename.com</code> and my local virtual host is <code>http://sitename.dev</code>.</p> <p>I have found a couple different cases when the images are not d...
[ { "answer_id": 217137, "author": "James", "author_id": 71177, "author_profile": "https://wordpress.stackexchange.com/users/71177", "pm_score": 0, "selected": false, "text": "<pre><code>$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];\nif (strpos($url,'confirmation') ...
2016/02/09
[ "https://wordpress.stackexchange.com/questions/217141", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88376/" ]
I set up a local environment to customize a friend's WP blog. However almost none of the images are being displayed. The remote site's URL is `http://sitename.com` and my local virtual host is `http://sitename.dev`. I have found a couple different cases when the images are not displayed: * The src URL looks like thi...
We can make use of the `page_template` filter to achieve this. All we need to do is to make sure that `confirmation` is the first word in the page page title ``` add_filter( 'page_template', function ( $template ) { // Get the current page object $post = get_queried_object(); /** * Get the first inst...
217,154
<p>Is there a function I can use which will temporarily output the menu_position of every item in the admin menu?</p> <p>While trying to reorganise the admin menu, the single largest thing slowing me down is trying to mentally keep track of which menu item is where.</p> <p>Being able to see this info while im doing t...
[ { "answer_id": 217137, "author": "James", "author_id": 71177, "author_profile": "https://wordpress.stackexchange.com/users/71177", "pm_score": 0, "selected": false, "text": "<pre><code>$url = 'http://' . $_SERVER['SERVER_NAME'] . $_SERVER['REQUEST_URI'];\nif (strpos($url,'confirmation') ...
2016/02/09
[ "https://wordpress.stackexchange.com/questions/217154", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/77390/" ]
Is there a function I can use which will temporarily output the menu\_position of every item in the admin menu? While trying to reorganise the admin menu, the single largest thing slowing me down is trying to mentally keep track of which menu item is where. Being able to see this info while im doing this would be so ...
We can make use of the `page_template` filter to achieve this. All we need to do is to make sure that `confirmation` is the first word in the page page title ``` add_filter( 'page_template', function ( $template ) { // Get the current page object $post = get_queried_object(); /** * Get the first inst...
217,179
<p>I am developing a WordPress plugin, but before that I have checked the code for the few plugin already developed. I have seen a common approach to restrict the direct where the plugin developer starts the plugin code by the following line </p> <pre><code>// If accessed directly, abort if ( ! defined( 'WPINC' ) ) {...
[ { "answer_id": 217197, "author": "BillK", "author_id": 87352, "author_profile": "https://wordpress.stackexchange.com/users/87352", "pm_score": 1, "selected": false, "text": "<p><code>WPINC</code> is defined by WP before plugins are loaded; so, the fact that it is already defined indicate...
2016/02/09
[ "https://wordpress.stackexchange.com/questions/217179", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83446/" ]
I am developing a WordPress plugin, but before that I have checked the code for the few plugin already developed. I have seen a common approach to restrict the direct where the plugin developer starts the plugin code by the following line ``` // If accessed directly, abort if ( ! defined( 'WPINC' ) ) { die; } `...
*Question 1.* so where it is defined before *Answer:* > > It is defined in WordPress core. > > > Here a quick online [reference](https://core.trac.wordpress.org/browser/trunk/src/wp-settings.php#L18) or for a local reference take a look at the following file in the root of WordPress: `wp-settings.php`. In th...
217,189
<p>I have made my own theme with shortcodes to WordPress.</p> <p>In my filters I have:</p> <pre><code>remove_filter('the_content', 'wpautop'); add_filter('the_content', 'wpautop', 99); add_filter('the_content', 'shortcode_unautop', 100); </code></pre> <p>This should remove paragraph tags around and in my shortcodes....
[ { "answer_id": 217304, "author": "majick", "author_id": 76440, "author_profile": "https://wordpress.stackexchange.com/users/76440", "pm_score": 1, "selected": false, "text": "<p>Maybe try removing all the newlines from the output itself, since this is what is ultimately being messed with...
2016/02/09
[ "https://wordpress.stackexchange.com/questions/217189", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/86744/" ]
I have made my own theme with shortcodes to WordPress. In my filters I have: ``` remove_filter('the_content', 'wpautop'); add_filter('the_content', 'wpautop', 99); add_filter('the_content', 'shortcode_unautop', 100); ``` This should remove paragraph tags around and in my shortcodes. My shortcode output (partial of...
This is the solution: ``` function wpex_fix_shortcodes($content) { return strtr($content, [ '<p>[' => '[', ']</p>' => ']', ']<br />' => ']' ]); } remove_filter('the_content', 'wpautop'); remove_filter('the_content', 'do_shortcode', 11); add_filter('the_content', 'wpautop', 100); add...
217,194
<p>I'm using HB Themes Aegaeus theme and it's great except for the fact that one of the shortcode elements (hb-box) is resizing the images. </p> <p>(Obviously, automatically resizing site elements to fit a mobile device is one of the main reasons to use responsive design, but in this instance, it makes the image subje...
[ { "answer_id": 217304, "author": "majick", "author_id": 76440, "author_profile": "https://wordpress.stackexchange.com/users/76440", "pm_score": 1, "selected": false, "text": "<p>Maybe try removing all the newlines from the output itself, since this is what is ultimately being messed with...
2016/02/09
[ "https://wordpress.stackexchange.com/questions/217194", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/87187/" ]
I'm using HB Themes Aegaeus theme and it's great except for the fact that one of the shortcode elements (hb-box) is resizing the images. (Obviously, automatically resizing site elements to fit a mobile device is one of the main reasons to use responsive design, but in this instance, it makes the image subjects look r...
This is the solution: ``` function wpex_fix_shortcodes($content) { return strtr($content, [ '<p>[' => '[', ']</p>' => ']', ']<br />' => ']' ]); } remove_filter('the_content', 'wpautop'); remove_filter('the_content', 'do_shortcode', 11); add_filter('the_content', 'wpautop', 100); add...
217,210
<p>I ad a custom field to registration form:</p> <pre><code>function wooc_extra_register_fields() { &lt;p class="form-row form-row-first"&gt; &lt;label for="billing_cpf"&gt;&lt;?php _e( 'CPF', 'woocommerce' ); ?&gt; &lt;span class="required"&gt;*&lt;/span&gt;&lt;/label&gt; &lt;input type="text" class="input-text" name...
[ { "answer_id": 217218, "author": "majick", "author_id": 76440, "author_profile": "https://wordpress.stackexchange.com/users/76440", "pm_score": 1, "selected": false, "text": "<p>You should be using <code>add_user_meta</code> instead of <code>update_user_meta</code>:</p>\n\n<pre><code>if ...
2016/02/10
[ "https://wordpress.stackexchange.com/questions/217210", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/79901/" ]
I ad a custom field to registration form: ``` function wooc_extra_register_fields() { <p class="form-row form-row-first"> <label for="billing_cpf"><?php _e( 'CPF', 'woocommerce' ); ?> <span class="required">*</span></label> <input type="text" class="input-text" name="billing_cpf" id="billing_cpf" placeholder="Somente ...
You should be using `add_user_meta` instead of `update_user_meta`: ``` if (isset($_POST['billing_cpf'])) { add_user_meta($customer_id, 'billing_cpf', $POST['billing_cpf'], true); } ``` As this will **only** add the meta if it *does not already exist* - no update. (This will prevent this field from being updatab...
217,242
<p>For example, if I add this code to functions.php:</p> <pre><code>$mysite_address_url="http://my-site.com"; </code></pre> <p>And then add this to one of my .php template files(like index.php or header.php):</p> <pre><code>&lt;?php echo($mysite_address_url); ?&gt; </code></pre> <p>It won't work. Why is this happen...
[ { "answer_id": 217245, "author": "forlogos", "author_id": 20951, "author_profile": "https://wordpress.stackexchange.com/users/20951", "pm_score": 1, "selected": false, "text": "<p>WordPress theme files are called thru functions/classes, so variables declared in <code>functions.php</code>...
2016/02/10
[ "https://wordpress.stackexchange.com/questions/217242", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88444/" ]
For example, if I add this code to functions.php: ``` $mysite_address_url="http://my-site.com"; ``` And then add this to one of my .php template files(like index.php or header.php): ``` <?php echo($mysite_address_url); ?> ``` It won't work. Why is this happens and how can I achieve this with wordpress please?
WordPress theme files are called thru functions/classes, so variables declared in `functions.php` are not recognized by other theme files, until you specify you want to use the global value of the variable. Do so like this in your theme template files: ``` global $mysite_address_url; ``` you can then use `$mysite_ad...
217,251
<p>I want to apply a function if post is updated and if post author id is not 1. For this i tried many functions like</p> <pre><code>&lt;?php if (get_the_modified_time() != get_the_time()) &amp;&amp; ( $author_id != 1 ) : ?&gt; </code></pre> <p>By this code <strong>if post is updated</strong> is working but <strong>i...
[ { "answer_id": 217253, "author": "terminator", "author_id": 55034, "author_profile": "https://wordpress.stackexchange.com/users/55034", "pm_score": 0, "selected": false, "text": "<p>this should work</p>\n\n<pre><code>&lt;?php if (get_the_modified_time() != get_the_time() &amp;&amp; ( $au...
2016/02/10
[ "https://wordpress.stackexchange.com/questions/217251", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/75682/" ]
I want to apply a function if post is updated and if post author id is not 1. For this i tried many functions like ``` <?php if (get_the_modified_time() != get_the_time()) && ( $author_id != 1 ) : ?> ``` By this code **if post is updated** is working but **if post author is not 1** not working. Please help me!
Finally i find answer. The perfect code is ``` <?php $author_id = $post->post_author; if (get_the_modified_time() != get_the_time() && ( $author_id != 1 )): ?> ``` That's all.
217,293
<p>I am trying to redirect the user after login/signup to profile page, but I am not sure why is it not putting the user nickname in url.</p> <pre><code>$current_user = wp_get_current_user(); function aloginuser( $user_id ) { wp_set_current_user($user_id); wp_set_auth_cookie($user_id); wp_redirect( "/prof...
[ { "answer_id": 217273, "author": "Vasim Shaikh", "author_id": 87704, "author_profile": "https://wordpress.stackexchange.com/users/87704", "pm_score": 0, "selected": false, "text": "<p>Found out a quick and easy way to fix it.</p>\n\n<p>Follow these instructions:</p>\n\n<ol>\n<li>Create a...
2016/02/10
[ "https://wordpress.stackexchange.com/questions/217293", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88477/" ]
I am trying to redirect the user after login/signup to profile page, but I am not sure why is it not putting the user nickname in url. ``` $current_user = wp_get_current_user(); function aloginuser( $user_id ) { wp_set_current_user($user_id); wp_set_auth_cookie($user_id); wp_redirect( "/profile/$current_u...
For the record and for anyone who comes next. I found the issue. Although the excerpts is a native WordPress feature it is not supported -in the right way- by the "official" "pre-installed" themes like the twenty-xxx series. Not Supporting (in the right way) a native feature isn't a common sense!!! It is a bad behavi...
217,299
<p>I'd like to know if there is a way to store WP_Query results in variables that I can then go ahead and insert anywhere on the page outside of the loop. For instance, say I want to get the feature image urls of three latest posts and I want to set variables in a way akin to the following.(note that the code below is ...
[ { "answer_id": 217302, "author": "Sören Wrede", "author_id": 68682, "author_profile": "https://wordpress.stackexchange.com/users/68682", "pm_score": 1, "selected": false, "text": "<p><strong>A</strong>) You can store the url in an array. The index of the post currently being displayed is...
2016/02/10
[ "https://wordpress.stackexchange.com/questions/217299", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/84666/" ]
I'd like to know if there is a way to store WP\_Query results in variables that I can then go ahead and insert anywhere on the page outside of the loop. For instance, say I want to get the feature image urls of three latest posts and I want to set variables in a way akin to the following.(note that the code below is fo...
From what I read, you read the URL/path to the post thumbnails is an array. We need to look at a couple of things here to make this as lean and predictable as possible IMPORTANT CONSIDERATIONS ------------------------ * We do need some way to make sure that we get the latest three posts which actually have thumbnails...
217,331
<p>I have a multi-site platform and I'm trying to share the menu that I have in main with other sites that are located in different folders.</p> <p>This is the PHP tag in the main that pulls the menu which I also need in the header of other:</p> <pre><code>&lt;?php dokan_header_user_menu(); ?&gt; </code></pre> <p>I ...
[ { "answer_id": 217335, "author": "fischi", "author_id": 15680, "author_profile": "https://wordpress.stackexchange.com/users/15680", "pm_score": 2, "selected": true, "text": "<h1>Outsource this function into a Plugin</h1>\n<p>If you want a specific function available across multiple theme...
2016/02/11
[ "https://wordpress.stackexchange.com/questions/217331", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58774/" ]
I have a multi-site platform and I'm trying to share the menu that I have in main with other sites that are located in different folders. This is the PHP tag in the main that pulls the menu which I also need in the header of other: ``` <?php dokan_header_user_menu(); ?> ``` I tried using it as it is in the header o...
Outsource this function into a Plugin ===================================== If you want a specific function available across multiple themes, it is best to have it in a Plugin, and activate it networkwide. Find the function ----------------- Locate the function in the theme where it is available. You now have two po...