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
207,442
<p>I want to use a svg as a custom header in WordPress.</p> <p>I tried two ways:</p> <h1>First</h1> <p>I want the user to be able to upload their own svg as a custom header. So I enabled svg uploads in the functions.php:</p> <pre><code>function cc_mime_types($mimes) { $mimes['svg'] = 'image/svg+xml'; return $mi...
[ { "answer_id": 207786, "author": "Afterlame", "author_id": 28865, "author_profile": "https://wordpress.stackexchange.com/users/28865", "pm_score": 3, "selected": true, "text": "<p>I solved it using the second way.</p>\n\n<p>I found out that you have to register the default image also.\nS...
2015/11/03
[ "https://wordpress.stackexchange.com/questions/207442", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28865/" ]
I want to use a svg as a custom header in WordPress. I tried two ways: First ===== I want the user to be able to upload their own svg as a custom header. So I enabled svg uploads in the functions.php: ``` function cc_mime_types($mimes) { $mimes['svg'] = 'image/svg+xml'; return $mimes; } add_filter('upload_mimes...
I solved it using the second way. I found out that you have to register the default image also. So after registering the svg as a default header it displays like it should! Here is my code: ``` register_default_headers( array( 'kami-logo' => array( 'url' => get_stylesheet_directory_uri() . '/images/log...
207,450
<p>My Woocommerce store has virtual products that don't require shipping. I have disabled the shipping options from the customer on checkout, but now I want to hide it on the backend as well.</p> <p>When viewing orders on the admin side, I have 3 columns: General Details, Billing Details and Shipping Details. I want to...
[ { "answer_id": 207456, "author": "Sladix", "author_id": 27423, "author_profile": "https://wordpress.stackexchange.com/users/27423", "pm_score": -1, "selected": true, "text": "<p>There is no \"clean\" solution for what you are asking.</p>\n\n<p>However, you can manually delete this block ...
2015/11/03
[ "https://wordpress.stackexchange.com/questions/207450", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1118/" ]
My Woocommerce store has virtual products that don't require shipping. I have disabled the shipping options from the customer on checkout, but now I want to hide it on the backend as well. When viewing orders on the admin side, I have 3 columns: General Details, Billing Details and Shipping Details. I want to remove t...
There is no "clean" solution for what you are asking. However, you can manually delete this block by editing woocommerce/includes/admin/class-wc-meta-box-order-data.php line 315-397.
207,478
<p>The URL of our old WordPress MU (it is WPMU, not WordPress Multisite) installation with several blogs has changed. This URL change was updated directly in the DB in the <code>wp_blogs</code> and <code>wp_site</code> tables, and elsewhere. Now the blogs are accessible, but the permalinks of all posts across all blogs...
[ { "answer_id": 207456, "author": "Sladix", "author_id": 27423, "author_profile": "https://wordpress.stackexchange.com/users/27423", "pm_score": -1, "selected": true, "text": "<p>There is no \"clean\" solution for what you are asking.</p>\n\n<p>However, you can manually delete this block ...
2015/11/03
[ "https://wordpress.stackexchange.com/questions/207478", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82947/" ]
The URL of our old WordPress MU (it is WPMU, not WordPress Multisite) installation with several blogs has changed. This URL change was updated directly in the DB in the `wp_blogs` and `wp_site` tables, and elsewhere. Now the blogs are accessible, but the permalinks of all posts across all blogs are like: ``` http://ex...
There is no "clean" solution for what you are asking. However, you can manually delete this block by editing woocommerce/includes/admin/class-wc-meta-box-order-data.php line 315-397.
207,482
<p>Is it possible to add a class <code>loggedout</code> on the body of every page for all logged out users using a function or JS?</p> <p>My theme already adds a class 'loggedin' for all logged in users. </p>
[ { "answer_id": 207484, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": true, "text": "<p>Presumably your theme is using the <a href=\"https://developer.wordpress.org/reference/functions/body_class/\" rel=...
2015/11/03
[ "https://wordpress.stackexchange.com/questions/207482", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40727/" ]
Is it possible to add a class `loggedout` on the body of every page for all logged out users using a function or JS? My theme already adds a class 'loggedin' for all logged in users.
Presumably your theme is using the [`body_class`](https://developer.wordpress.org/reference/functions/body_class/) function to output classes. You can [add a filter](https://codex.wordpress.org/Plugin_API/Filter_Reference/body_class) to remove or add your own classes. ``` function wpd_logged_out_body_class( $classes )...
207,502
<p>I'm building a custom theme for a client and I've been adding stylesheets incorrectly for a while, so I decided to do it the correct way :-).</p> <p>However, when I add the stylesheet to my <code>functions.php</code> file like so:</p> <pre><code>wp_enqueue_style('theme-styles', get_template_directory_uri() . '/css...
[ { "answer_id": 207484, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": true, "text": "<p>Presumably your theme is using the <a href=\"https://developer.wordpress.org/reference/functions/body_class/\" rel=...
2015/11/03
[ "https://wordpress.stackexchange.com/questions/207502", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73064/" ]
I'm building a custom theme for a client and I've been adding stylesheets incorrectly for a while, so I decided to do it the correct way :-). However, when I add the stylesheet to my `functions.php` file like so: ``` wp_enqueue_style('theme-styles', get_template_directory_uri() . '/css/all.css', array(), false , 'all...
Presumably your theme is using the [`body_class`](https://developer.wordpress.org/reference/functions/body_class/) function to output classes. You can [add a filter](https://codex.wordpress.org/Plugin_API/Filter_Reference/body_class) to remove or add your own classes. ``` function wpd_logged_out_body_class( $classes )...
207,604
<p>My wordPress database was hacked and all users_names were changed to the same thing. I'd like to write a mySql query to replace all usernames that = "x" to the user_nicename. I'm unsure how to do this - any suggestions?</p>
[ { "answer_id": 207617, "author": "HU is Sebastian", "author_id": 56587, "author_profile": "https://wordpress.stackexchange.com/users/56587", "pm_score": 2, "selected": false, "text": "<p>This should be working:</p>\n\n<p>Be sure that your DB prefix is \"wp_\"</p>\n\n<pre><code>Update wp_...
2015/11/04
[ "https://wordpress.stackexchange.com/questions/207604", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83012/" ]
My wordPress database was hacked and all users\_names were changed to the same thing. I'd like to write a mySql query to replace all usernames that = "x" to the user\_nicename. I'm unsure how to do this - any suggestions?
This should be working: Be sure that your DB prefix is "wp\_" ``` Update wp_users set wp_users.user_login=wp_users.user_nicename where wp_users.user_login="x" ```
207,607
<p>I would like to set a button on my site that links to a registration page (this registration is off site by a company called Wufoo so it will not be registering on the WordPress site) if a visitor has not filled out the registration page before. With Wufoo, I have embed code, so when the user clicks the button on...
[ { "answer_id": 207617, "author": "HU is Sebastian", "author_id": 56587, "author_profile": "https://wordpress.stackexchange.com/users/56587", "pm_score": 2, "selected": false, "text": "<p>This should be working:</p>\n\n<p>Be sure that your DB prefix is \"wp_\"</p>\n\n<pre><code>Update wp_...
2015/11/04
[ "https://wordpress.stackexchange.com/questions/207607", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/77767/" ]
I would like to set a button on my site that links to a registration page (this registration is off site by a company called Wufoo so it will not be registering on the WordPress site) if a visitor has not filled out the registration page before. With Wufoo, I have embed code, so when the user clicks the button on my ...
This should be working: Be sure that your DB prefix is "wp\_" ``` Update wp_users set wp_users.user_login=wp_users.user_nicename where wp_users.user_login="x" ```
207,612
<p>When you visit any wordpress post and click on the "Post Comment" button it just post that blank data to the server and while doing the check at php level it shows this annoying error message to users:</p> <p><a href="https://i.stack.imgur.com/eDrhk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com...
[ { "answer_id": 207617, "author": "HU is Sebastian", "author_id": 56587, "author_profile": "https://wordpress.stackexchange.com/users/56587", "pm_score": 2, "selected": false, "text": "<p>This should be working:</p>\n\n<p>Be sure that your DB prefix is \"wp_\"</p>\n\n<pre><code>Update wp_...
2015/11/04
[ "https://wordpress.stackexchange.com/questions/207612", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/50584/" ]
When you visit any wordpress post and click on the "Post Comment" button it just post that blank data to the server and while doing the check at php level it shows this annoying error message to users: [![enter image description here](https://i.stack.imgur.com/eDrhk.jpg)](https://i.stack.imgur.com/eDrhk.jpg) we all h...
This should be working: Be sure that your DB prefix is "wp\_" ``` Update wp_users set wp_users.user_login=wp_users.user_nicename where wp_users.user_login="x" ```
207,633
<p>I have menus set corresponding to a custom field on a page. Ie I have menu1, menu2, and menu3 on three pages under custom field => MenuName. Under functions.php I have:</p> <pre><code>/* Add Menu Locations */ add_action( 'init', 'register_my_menus' ); function register_my_menus() { register_nav_menus( a...
[ { "answer_id": 207634, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 4, "selected": true, "text": "<p><code>wp_nav_menu</code> has the argument <code>fallback_cb</code>, which is the function called if a menu doesn't ...
2015/11/05
[ "https://wordpress.stackexchange.com/questions/207633", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45709/" ]
I have menus set corresponding to a custom field on a page. Ie I have menu1, menu2, and menu3 on three pages under custom field => MenuName. Under functions.php I have: ``` /* Add Menu Locations */ add_action( 'init', 'register_my_menus' ); function register_my_menus() { register_nav_menus( array( ...
`wp_nav_menu` has the argument `fallback_cb`, which is the function called if a menu doesn't exist. This is set to `wp_page_menu` by default, which is why you see a list of pages if the menu doesn't exist. If you explicitly set that to `false`, then nothing will be output if the menu doesn't exist. EDIT- Given a menu...
207,641
<p>I have added a new tab for profile tab using following code.</p> <pre><code>add_action('bp_setup_nav', 'mb_bp_profile_menu_posts', 301 ); function mb_bp_profile_menu_posts() { global $bp; bp_core_new_nav_item( array( 'name' =&gt; 'My Posts', 'slug' =&gt; 'posts', 'position' =&gt; 11, ...
[ { "answer_id": 207642, "author": "Bharat", "author_id": 82996, "author_profile": "https://wordpress.stackexchange.com/users/82996", "pm_score": 0, "selected": false, "text": "<p>BuddyPress plugin provides support for this question. This link will help you.\n<a href=\"https://buddypress.o...
2015/11/05
[ "https://wordpress.stackexchange.com/questions/207641", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83030/" ]
I have added a new tab for profile tab using following code. ``` add_action('bp_setup_nav', 'mb_bp_profile_menu_posts', 301 ); function mb_bp_profile_menu_posts() { global $bp; bp_core_new_nav_item( array( 'name' => 'My Posts', 'slug' => 'posts', 'position' => 11, 'default_subnav_...
Please check the code below. I guess you are facing 404 because it's not getting the `slug` & the `url` properly. ``` add_action( 'bp_setup_nav', 'mb_bp_profile_menu_posts' ); function mb_bp_profile_menu_posts() { global $bp; bp_core_new_nav_item( array( 'name' => 'My Posts'...
207,681
<p>One of the major problems I have with a big site is the number of templates. So I figure I could call an optional footer within the page using a shortcode.</p> <pre><code>function trainer_footer( ){ get_footer('rctrainer'); } add_shortcode( 'trainer', 'trainer_footer' ); </code></pre> <p>This works.</p> <p>But ...
[ { "answer_id": 207642, "author": "Bharat", "author_id": 82996, "author_profile": "https://wordpress.stackexchange.com/users/82996", "pm_score": 0, "selected": false, "text": "<p>BuddyPress plugin provides support for this question. This link will help you.\n<a href=\"https://buddypress.o...
2015/11/05
[ "https://wordpress.stackexchange.com/questions/207681", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57686/" ]
One of the major problems I have with a big site is the number of templates. So I figure I could call an optional footer within the page using a shortcode. ``` function trainer_footer( ){ get_footer('rctrainer'); } add_shortcode( 'trainer', 'trainer_footer' ); ``` This works. But there are two questions; 1. the ...
Please check the code below. I guess you are facing 404 because it's not getting the `slug` & the `url` properly. ``` add_action( 'bp_setup_nav', 'mb_bp_profile_menu_posts' ); function mb_bp_profile_menu_posts() { global $bp; bp_core_new_nav_item( array( 'name' => 'My Posts'...
207,683
<p>I have the following problem. I got a plugin that is huge due to all the data needed. The data is all the countries and cities in the world and also a maxmind.mmdb database.</p> <h2>1 - Issue</h2> <p>Currently I got everything packed in the plugin which makes a 20mb plugin and that creates a problem for users with l...
[ { "answer_id": 207689, "author": "Bruno Cantuaria", "author_id": 65717, "author_profile": "https://wordpress.stackexchange.com/users/65717", "pm_score": 2, "selected": false, "text": "<p>I can see two options:</p>\n\n<ul>\n<li>You create an API with the city info and make the plugin use ...
2015/11/05
[ "https://wordpress.stackexchange.com/questions/207683", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/4130/" ]
I have the following problem. I got a plugin that is huge due to all the data needed. The data is all the countries and cities in the world and also a maxmind.mmdb database. 1 - Issue --------- Currently I got everything packed in the plugin which makes a 20mb plugin and that creates a problem for users with limited ...
To directly answer your questions: Your proposed solution is indeed viable, just make sure your CDN solution (Amazon S3 for example) is configured to accept both secure (http) and insecure (https) connections. As far as your next question, CSV is by nature a great way to store a representation of a table. Another alt...
207,712
<p>I have a cpt called "auto" and i make a frontend form to create new post with "pending" status. After the post submission i would receive an email with a notification of the new post.</p> <pre><code>function newpost_notify() { $mailadmin = 'xxx@domain.com'; $subject = 'Subject'; $headers = 'MIME-Version: 1....
[ { "answer_id": 207689, "author": "Bruno Cantuaria", "author_id": 65717, "author_profile": "https://wordpress.stackexchange.com/users/65717", "pm_score": 2, "selected": false, "text": "<p>I can see two options:</p>\n\n<ul>\n<li>You create an API with the city info and make the plugin use ...
2015/11/05
[ "https://wordpress.stackexchange.com/questions/207712", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/71371/" ]
I have a cpt called "auto" and i make a frontend form to create new post with "pending" status. After the post submission i would receive an email with a notification of the new post. ``` function newpost_notify() { $mailadmin = 'xxx@domain.com'; $subject = 'Subject'; $headers = 'MIME-Version: 1.0' . "\r\n"; ...
To directly answer your questions: Your proposed solution is indeed viable, just make sure your CDN solution (Amazon S3 for example) is configured to accept both secure (http) and insecure (https) connections. As far as your next question, CSV is by nature a great way to store a representation of a table. Another alt...
207,715
<p>I need to add a shortcode into one of the PHP files (replacing a search bar code that is hardcoded into the header PHP file). How do I add a shortcode to the header PHP file?</p> <p>This is the code that I am looking at:</p> <pre><code>&lt;?php if ( (is_front_page()) &amp;&amp; (of_get_option('g_search_box_id') ==...
[ { "answer_id": 207720, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 2, "selected": false, "text": "<p>Use <a href=\"https://developer.wordpress.org/reference/functions/do_shortcode/\" rel=\"nofollow\"><code>do_shortc...
2015/11/05
[ "https://wordpress.stackexchange.com/questions/207715", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83069/" ]
I need to add a shortcode into one of the PHP files (replacing a search bar code that is hardcoded into the header PHP file). How do I add a shortcode to the header PHP file? This is the code that I am looking at: ``` <?php if ( (is_front_page()) && (of_get_option('g_search_box_id') == 'yes') ) { ?> <div class="s...
In general, inserting and executing shortcodes directly into templates files is not good idea and it is not what shortcodes are intented for. Instead, you should use the shortcode callback just like any other [PHP function or template tag](https://codex.wordpress.org/Template_Tags). For example, let's imaging this sho...
207,725
<p>I need a way of taking a variable from a plugin's settings and write it to a small key file located in the plugin's directory. The entire contents of the key file is this: </p> <pre><code>&lt;?php $transaction_key = "npo7d3A0d2hhTYF5w9uo"; ?&gt; </code></pre> <p>I've tried to use <code>file_put_contents</code>, bu...
[ { "answer_id": 207729, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 1, "selected": false, "text": "<p>It is impossible especially if you also need to keep the key in secret. Just use the DB.</p>\n" }, { ...
2015/11/05
[ "https://wordpress.stackexchange.com/questions/207725", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83075/" ]
I need a way of taking a variable from a plugin's settings and write it to a small key file located in the plugin's directory. The entire contents of the key file is this: ``` <?php $transaction_key = "npo7d3A0d2hhTYF5w9uo"; ?> ``` I've tried to use `file_put_contents`, but I can't get it to work. Anyone know how t...
It is impossible especially if you also need to keep the key in secret. Just use the DB.
207,726
<p>I want to get the first blockquote from the post (even if the user writes only one, or more than one) in the Quote Post Format, in order to show it in the archive Loop. For example:</p> <pre><code>$quote = has_post_format( 'quote' ); if ( $quote ) { if ( *the post has no quotes* ){ // Don't show anythin...
[ { "answer_id": 207741, "author": "MarketHubb", "author_id": 59093, "author_profile": "https://wordpress.stackexchange.com/users/59093", "pm_score": 0, "selected": false, "text": "<p>Try something like this:</p>\n\n<pre><code>&lt;?php \n // Check is post has quote format \n ...
2015/11/05
[ "https://wordpress.stackexchange.com/questions/207726", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82894/" ]
I want to get the first blockquote from the post (even if the user writes only one, or more than one) in the Quote Post Format, in order to show it in the archive Loop. For example: ``` $quote = has_post_format( 'quote' ); if ( $quote ) { if ( *the post has no quotes* ){ // Don't show anything } else {...
I finally found a solution that works. In case you need it, here it is: ``` <?php if (has_post_format('quote', $post->ID)) { $content = trim(get_the_content()); // Take the first quote from the content $quote_string = extract_from_string('<blockquote>', '</blockquote>', $content); // Make sure there's ...
207,751
<p>I've looked for plugins and couldn't find anything and I believe this should be a core feature.</p> <p><strong>The Problem:</strong></p> <p>The current methodology for replacing a custom link, or any menu link is by doing the following process:</p> <ol> <li>Remove old menu link</li> <li>Insert new link</li> <li>D...
[ { "answer_id": 208881, "author": "cbos", "author_id": 83730, "author_profile": "https://wordpress.stackexchange.com/users/83730", "pm_score": 1, "selected": false, "text": "<p>Although this does not directly answer the question, the code on which it is based provides the functionality. ...
2015/11/06
[ "https://wordpress.stackexchange.com/questions/207751", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82468/" ]
I've looked for plugins and couldn't find anything and I believe this should be a core feature. **The Problem:** The current methodology for replacing a custom link, or any menu link is by doing the following process: 1. Remove old menu link 2. Insert new link 3. Drag new link from end of list 4. Drop new link in de...
Although this does not directly answer the question, the code on which it is based provides the functionality. The code set is: ``` function install_menus() { require_once dirname( __FILE__) . '/data.php'; $menus = get_menus_data(); if ( ! empty ( $menus ) ) foreach ( $menus as $menu ) { if ( $menu...
207,816
<p>I'm building a site for ordering food online. It's not a shop (visitors will not be able to pay online, just to order for delivery). My initial idea was to define all the food and drink items as custom post types. But I haven't figured out how to set up product variations. For example, a pizza may be small, medium o...
[ { "answer_id": 207819, "author": "jdm2112", "author_id": 45202, "author_profile": "https://wordpress.stackexchange.com/users/45202", "pm_score": 0, "selected": false, "text": "<p>Yes, this is exactly the purpose for custom post types. To handle your product variations, several custom fi...
2015/11/06
[ "https://wordpress.stackexchange.com/questions/207816", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/20681/" ]
I'm building a site for ordering food online. It's not a shop (visitors will not be able to pay online, just to order for delivery). My initial idea was to define all the food and drink items as custom post types. But I haven't figured out how to set up product variations. For example, a pizza may be small, medium or l...
Use it can be done using CUSTOM META BOX. Add following to function.php: ``` /* Adds pizza size meta box to the post editing screen ******************************************************/ function prfx_custom_meta() { add_meta_box( 'prfx_meta', __( 'Pizza Size', 'prfx-textdomain' ), 'prfx_meta_callback', 'post' )...
207,845
<p>I'm trying to get post meta to be updated/replaced with $wpdb and running into issues. I have working SQL, but cannot get it work when coding it up for my WP plugin. </p> <p><strong>Extra note:</strong></p> <p>The post meta being saved is for example is Twitter follower count that I need the number to be saved to ...
[ { "answer_id": 207819, "author": "jdm2112", "author_id": 45202, "author_profile": "https://wordpress.stackexchange.com/users/45202", "pm_score": 0, "selected": false, "text": "<p>Yes, this is exactly the purpose for custom post types. To handle your product variations, several custom fi...
2015/11/06
[ "https://wordpress.stackexchange.com/questions/207845", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/66224/" ]
I'm trying to get post meta to be updated/replaced with $wpdb and running into issues. I have working SQL, but cannot get it work when coding it up for my WP plugin. **Extra note:** The post meta being saved is for example is Twitter follower count that I need the number to be saved to the database so I can export t...
Use it can be done using CUSTOM META BOX. Add following to function.php: ``` /* Adds pizza size meta box to the post editing screen ******************************************************/ function prfx_custom_meta() { add_meta_box( 'prfx_meta', __( 'Pizza Size', 'prfx-textdomain' ), 'prfx_meta_callback', 'post' )...
207,895
<p>I want to get the URL of a page's "featured image", as I want to use the page's featured image as the background image for the banner at the top of the page. The background image for the banner changes according to what page I'm on, as they will have different featured images. </p>
[ { "answer_id": 207898, "author": "kittsville", "author_id": 52428, "author_profile": "https://wordpress.stackexchange.com/users/52428", "pm_score": 3, "selected": false, "text": "<p>Adapted from <a href=\"https://wordpress.org/support/topic/retrieveing-featured-image-url\" rel=\"noreferr...
2015/11/07
[ "https://wordpress.stackexchange.com/questions/207895", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83182/" ]
I want to get the URL of a page's "featured image", as I want to use the page's featured image as the background image for the banner at the top of the page. The background image for the banner changes according to what page I'm on, as they will have different featured images.
Adapted from [this thread](https://wordpress.org/support/topic/retrieveing-featured-image-url) on the WP forums: ``` <?php if (has_post_thumbnail( $post->ID ) ): ?> <?php $image = wp_get_attachment_image_src(get_post_thumbnail_id($post->ID), 'single-post-thumbnail'); ?> <style> #banner-id { background-image: url...
207,924
<p>Im trying to only show a taxonomy for the <code>editor</code> and <code>administrator</code> but I haven't found a solution on SO or here. The closest thing I was able to find was <a href="https://stackoverflow.com/questions/4249694/how-do-i-remove-a-taxonomy-from-wordpress">How do I remove a taxonomy from Wordpres...
[ { "answer_id": 207933, "author": "mrbobbybryant", "author_id": 64953, "author_profile": "https://wordpress.stackexchange.com/users/64953", "pm_score": 4, "selected": true, "text": "<p>When registering your taxonomy you can pass an argument called <strong>capabilities</strong>. Simply pas...
2015/11/07
[ "https://wordpress.stackexchange.com/questions/207924", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25271/" ]
Im trying to only show a taxonomy for the `editor` and `administrator` but I haven't found a solution on SO or here. The closest thing I was able to find was [How do I remove a taxonomy from Wordpress?](https://stackoverflow.com/questions/4249694/how-do-i-remove-a-taxonomy-from-wordpress) on SO. What is the proper way ...
When registering your taxonomy you can pass an argument called **capabilities**. Simply passing capabiities that only admins and editors have. ``` $args = array( 'capabilities' => array( 'manage_options', 'edit_posts' ) ); register_taxonomy( 'foobar', 'post', $args ); ``` <https://codex.wordpress.org/Roles_and...
207,947
<p>I'd like to (in php) display a given user's avatar and bio (description) and some social media for them (based on their profile info fields). For example, on Page1, display user Walt Whitman's (user number 9999) picture, description (bio), and social media links, regardless of who wrote the page or who is logged in ...
[ { "answer_id": 207959, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 4, "selected": true, "text": "<p>You can make use of </p>\n\n<ul>\n<li><p><a href=\"https://codex.wordpress.org/Function_Reference/wp_get...
2015/11/08
[ "https://wordpress.stackexchange.com/questions/207947", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73570/" ]
I'd like to (in php) display a given user's avatar and bio (description) and some social media for them (based on their profile info fields). For example, on Page1, display user Walt Whitman's (user number 9999) picture, description (bio), and social media links, regardless of who wrote the page or who is logged in rea...
You can make use of * [`wp_get_current_user()`](https://codex.wordpress.org/Function_Reference/wp_get_current_user) or * [`get_currentuserinfo()`](https://codex.wordpress.org/get_currentuserinfo) (*to which `wp_get_current_user()` is a wrapper function to*) or * [`get_current_user_id()`](https://developer.wordpress.o...
207,960
<p>I have some scheduled events in my WordPress site. For that I use a cron job, so it has created an option in the <code>wp_options</code> table. </p> <p>After some days, my site is getting slow. When I check my database, it has more than 2MB of data in the cron field, so I am thinking to clean it now. Will that affe...
[ { "answer_id": 207970, "author": "mrbobbybryant", "author_id": 64953, "author_profile": "https://wordpress.stackexchange.com/users/64953", "pm_score": 0, "selected": false, "text": "<p>You should check out this developer plugin. It gives you fine control when working with cron. <a href=\...
2015/11/08
[ "https://wordpress.stackexchange.com/questions/207960", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43308/" ]
I have some scheduled events in my WordPress site. For that I use a cron job, so it has created an option in the `wp_options` table. After some days, my site is getting slow. When I check my database, it has more than 2MB of data in the cron field, so I am thinking to clean it now. Will that affect my site's cron ope...
Thanks for all of your comments. I found solution by myself. The reason is the action hook we have to use it like this. otherwise, the function will be called every page we load. so here is the code , that i used to solve it. ``` add_action( 'switch_theme', 'kv_event_scheduler' ); function kv_event_scheduler() { ...
207,967
<p>Because I want to use jQuery 2.1 instead of 1.11, I first have to de-register jQuery. Then register it with the new values. :</p> <pre><code>add_action( 'wp_enqueue_scripts', 'add_scripts' ); function add_scripts() { wp_deregister_script('jquery'); wp_register_script( 'jquery', 'http://ajax.googleapis.com/...
[ { "answer_id": 207968, "author": "HU is Sebastian", "author_id": 56587, "author_profile": "https://wordpress.stackexchange.com/users/56587", "pm_score": 1, "selected": false, "text": "<p>No 1: you have to put your jquery deregister etc. Stuff into a function that is called with the wp_en...
2015/11/08
[ "https://wordpress.stackexchange.com/questions/207967", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1447/" ]
Because I want to use jQuery 2.1 instead of 1.11, I first have to de-register jQuery. Then register it with the new values. : ``` add_action( 'wp_enqueue_scripts', 'add_scripts' ); function add_scripts() { wp_deregister_script('jquery'); wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jque...
In theory the code you wrote should work, in the practical application you are missing some good practices which it might impact on how your code is working, so it's better run through a bit of troubleshooting to tick off everything from the checklist. By de-registering `jquery` you are taking away both the jQuery cor...
207,990
<p>I'm looking for a hook that can be used before WP reads the DB to authenticate the user's login credentials, but can't seem to find one anywhere. Does one exist?</p> <p>I tried <code>add_filter/action('authenticate', 'customcode', 30, 3)</code>, but this seems to execute as soon as the <code>wp-login.php</code> pag...
[ { "answer_id": 207998, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 3, "selected": false, "text": "<p>If you look at the code for <code>wp-login.php</code> <a href=\"https://core.trac.wordpress.org/browser/tags...
2015/11/08
[ "https://wordpress.stackexchange.com/questions/207990", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83223/" ]
I'm looking for a hook that can be used before WP reads the DB to authenticate the user's login credentials, but can't seem to find one anywhere. Does one exist? I tried `add_filter/action('authenticate', 'customcode', 30, 3)`, but this seems to execute as soon as the `wp-login.php` page is requested, rather than afte...
Ah, turns out `add_filter/action('authenticate', 'customcode', 30, 3)` was what I was looking for... The problem was, I had the priority too low so whatever response I was creating with my custom code was over-ridden by the other filters. So dumping `global $wp_filter['authenticate']` I could see the following filter...
207,996
<p>I have this simple javascript file for checking boxes in a tree view menu:</p> <h2>treeview.js</h2> <pre><code>$(".acidjs-css3-treeview").delegate("label input:checkbox", "change", function() { var checkbox = $(this), selectNestedListCheckbox = checkbox.parents("li").children("label").children(...
[ { "answer_id": 207998, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 3, "selected": false, "text": "<p>If you look at the code for <code>wp-login.php</code> <a href=\"https://core.trac.wordpress.org/browser/tags...
2015/11/08
[ "https://wordpress.stackexchange.com/questions/207996", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/80327/" ]
I have this simple javascript file for checking boxes in a tree view menu: treeview.js ----------- ``` $(".acidjs-css3-treeview").delegate("label input:checkbox", "change", function() { var checkbox = $(this), selectNestedListCheckbox = checkbox.parents("li").children("label").children("input"), ...
Ah, turns out `add_filter/action('authenticate', 'customcode', 30, 3)` was what I was looking for... The problem was, I had the priority too low so whatever response I was creating with my custom code was over-ridden by the other filters. So dumping `global $wp_filter['authenticate']` I could see the following filter...
208,001
<p>So I have a page template that is setup as follows <em>(using Kleo theme)</em>:</p> <h2>Search template</h2> <pre><code>get_header(); ?&gt; &lt;?php //create right sidebar template kleo_switch_layout('right'); ?&gt; &lt;?php get_template_part('page-parts/general-title-section'); ?&gt; &lt;?php get_template_par...
[ { "answer_id": 208049, "author": "David Avellan", "author_id": 80327, "author_profile": "https://wordpress.stackexchange.com/users/80327", "pm_score": 2, "selected": true, "text": "<p>Well, I got it working by making my own own parse php as follows:</p>\n<h2>parse.php</h2>\n<pre><code>&l...
2015/11/08
[ "https://wordpress.stackexchange.com/questions/208001", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/80327/" ]
So I have a page template that is setup as follows *(using Kleo theme)*: Search template --------------- ``` get_header(); ?> <?php //create right sidebar template kleo_switch_layout('right'); ?> <?php get_template_part('page-parts/general-title-section'); ?> <?php get_template_part('page-parts/general-before-wrap...
Well, I got it working by making my own own parse php as follows: parse.php --------- ``` <?php $tags = $_POST['tag']; $search = $_POST['s']; $count = count($tags); $i = 0; if(!empty($search)) $uri = "https://example.com/?s=$search&"; else $uri = "https://example.com/?tag="; foreach($tags as $name=>$value) ...
208,044
<p>My posts have a custom field named <em>production</em>_date and formatted YYYYMMDD.</p> <p>How can I form a meta_query to select only the YYYY part?</p> <pre><code>$meta_query_args = array( array( 'key' =&gt; 'production_date', 'value' =&gt; '2004', 'compare' =&gt; '???' ) ); ...
[ { "answer_id": 208066, "author": "phatskat", "author_id": 20143, "author_profile": "https://wordpress.stackexchange.com/users/20143", "pm_score": -1, "selected": false, "text": "<p>You could use PHP's <a href=\"http://it2.php.net/manual/en/function.date.php\" rel=\"nofollow\"><code>date<...
2015/11/09
[ "https://wordpress.stackexchange.com/questions/208044", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1381/" ]
My posts have a custom field named *production*\_date and formatted YYYYMMDD. How can I form a meta\_query to select only the YYYY part? ``` $meta_query_args = array( array( 'key' => 'production_date', 'value' => '2004', 'compare' => '???' ) ); ```
The handy thing about how ACF stores dates as `YYYYMMDD` is you can treat them like integers and get a similar level of functionality as if you were using "true" dates. For example, to get all dates after 1st Jan 2011, use `> 20110101`. Those before June 1st 2012? `< 20120601`. And for your case, all dates within 2004...
208,051
<p>Yes we love to make the url more shorter ,more clean.</p> <p>Lets say we have css url like this</p> <pre><code>xxx.com/wp-content/theme_name/css/my_custom_css.css </code></pre> <p>However i would love to display it like this</p> <pre><code>xxx.com/css/my_custom_css.css </code></pre> <p>So i think rewriting is b...
[ { "answer_id": 208069, "author": "phatskat", "author_id": 20143, "author_profile": "https://wordpress.stackexchange.com/users/20143", "pm_score": 1, "selected": true, "text": "<p><strike>From <a href=\"https://wordpress.stackexchange.com/a/35118/20143\">this other answer on the WP SE</a>...
2015/11/09
[ "https://wordpress.stackexchange.com/questions/208051", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82119/" ]
Yes we love to make the url more shorter ,more clean. Lets say we have css url like this ``` xxx.com/wp-content/theme_name/css/my_custom_css.css ``` However i would love to display it like this ``` xxx.com/css/my_custom_css.css ``` So i think rewriting is best choice. I created a plugin made a new file rewrite....
From [this other answer on the WP SE](https://wordpress.stackexchange.com/a/35118/20143) ``` add_action('generate_rewrite_rules', 'roots_add_rewrites'); function roots_add_rewrites($content) { $theme_name = next(explode('/themes/', get_stylesheet_directory())); global $wp_rewrite; $roots_new_non_wp_rules ...
208,058
<p>I am trying to loop through custom post types and the code makes the page completely white but when I view source I can see my error:</p> <pre><code>Parse error: syntax error, unexpected 'else' (T_ELSE) </code></pre> <p>Here is my code, I am not sure why this is breaking as it was copy and pasted from a tutorial, ...
[ { "answer_id": 208069, "author": "phatskat", "author_id": 20143, "author_profile": "https://wordpress.stackexchange.com/users/20143", "pm_score": 1, "selected": true, "text": "<p><strike>From <a href=\"https://wordpress.stackexchange.com/a/35118/20143\">this other answer on the WP SE</a>...
2015/11/09
[ "https://wordpress.stackexchange.com/questions/208058", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83271/" ]
I am trying to loop through custom post types and the code makes the page completely white but when I view source I can see my error: ``` Parse error: syntax error, unexpected 'else' (T_ELSE) ``` Here is my code, I am not sure why this is breaking as it was copy and pasted from a tutorial, I have tried it in numerou...
From [this other answer on the WP SE](https://wordpress.stackexchange.com/a/35118/20143) ``` add_action('generate_rewrite_rules', 'roots_add_rewrites'); function roots_add_rewrites($content) { $theme_name = next(explode('/themes/', get_stylesheet_directory())); global $wp_rewrite; $roots_new_non_wp_rules ...
208,076
<p>I am currently trying to make a plugin which updates the stock count of my WooCommerce products. So I wanted to access the wc_update_product_stock function, but an error got returned instead.</p> <p>Code in plugin php file:</p> <blockquote> <p>wc_update_product_stock($id,$stock);</p> </blockquote> <p>error in ...
[ { "answer_id": 208078, "author": "akasapriya", "author_id": 82007, "author_profile": "https://wordpress.stackexchange.com/users/82007", "pm_score": 2, "selected": true, "text": "<p>If you've already invoked the product, e.g. with</p>\n\n<p><code>$product = new WC_Product($id);</code></p>...
2015/11/09
[ "https://wordpress.stackexchange.com/questions/208076", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83278/" ]
I am currently trying to make a plugin which updates the stock count of my WooCommerce products. So I wanted to access the wc\_update\_product\_stock function, but an error got returned instead. Code in plugin php file: > > wc\_update\_product\_stock($id,$stock); > > > error in log: > > Fatal error: Call to u...
If you've already invoked the product, e.g. with `$product = new WC_Product($id);` then you can update the stock level with `$product->set_stock($stock);` For more information check the documentation: <https://docs.woothemes.com/wc-apidocs/class-WC_Product.html#_set_stock>
208,094
<p>Ok, so we know Wordpress comes with a built in search form. However, I've created a custom archive page that lists posts from a specific post type. I would like to integrate a search box that only searches for posts related to that specific post.</p> <p>I see a lot of people approaching this in several ways but no ...
[ { "answer_id": 208101, "author": "Bruno Cantuaria", "author_id": 65717, "author_profile": "https://wordpress.stackexchange.com/users/65717", "pm_score": 0, "selected": false, "text": "<p>You can edit the search form redirecting it to your custom archive page. Then, in the custom archive ...
2015/11/09
[ "https://wordpress.stackexchange.com/questions/208094", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21245/" ]
Ok, so we know Wordpress comes with a built in search form. However, I've created a custom archive page that lists posts from a specific post type. I would like to integrate a search box that only searches for posts related to that specific post. I see a lot of people approaching this in several ways but no working ex...
To enable search on a custom post type archive, I use the [pre\_get\_posts](https://developer.wordpress.org/reference/hooks/pre_get_posts/) hook. Add this code to your theme functions.php file. Here is an example of enabling search on a post type called "resource": ``` // Enable resource search add_action('pre_get...
208,111
<p>I need to run <code>wp_enqueue</code> on javascript files after the DOM has been populated because I need to target a div. </p> <p><strong>EDIT</strong></p> <p>I am trying to add the following three scripts:</p> <pre><code>wp_enqueue_script('react_js', '/scripts/react.min.js' ); wp_enqueue_script('startReact_js'...
[ { "answer_id": 208172, "author": "Blaine", "author_id": 68877, "author_profile": "https://wordpress.stackexchange.com/users/68877", "pm_score": 1, "selected": false, "text": "<p>Have you looked at <a href=\"https://codex.wordpress.org/Function_Reference/wp_enqueue_script\" rel=\"nofollow...
2015/11/10
[ "https://wordpress.stackexchange.com/questions/208111", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83013/" ]
I need to run `wp_enqueue` on javascript files after the DOM has been populated because I need to target a div. **EDIT** I am trying to add the following three scripts: ``` wp_enqueue_script('react_js', '/scripts/react.min.js' ); wp_enqueue_script('startReact_js', '/scripts/test.js', array('react_js'), '', true); w...
Have you looked at [wp\_enqueue\_script](https://codex.wordpress.org/Function_Reference/wp_enqueue_script) in the WordPress codex? You'll most likely need to add this to `functions.php` in your theme's directory. Also, where are you enqueuing the `startapp_js` dependency? ``` function prefix_enqueue_scripts() { w...
208,129
<p>How to hide/disable any plugin notices for non admin users in dashboard? Can you please help me with this? Thanks</p>
[ { "answer_id": 208137, "author": "Adrian Spiac", "author_id": 26990, "author_profile": "https://wordpress.stackexchange.com/users/26990", "pm_score": 2, "selected": false, "text": "<p>The simplest way would be to hide the notifications via CSS, see below:</p>\n\n<pre><code> function h...
2015/11/10
[ "https://wordpress.stackexchange.com/questions/208129", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32573/" ]
How to hide/disable any plugin notices for non admin users in dashboard? Can you please help me with this? Thanks
The simplest way would be to hide the notifications via CSS, see below: ``` function hide_update_msg_non_admins(){ if (!current_user_can( 'manage_options' )) { // non-admin users echo '<style>#setting-error-tgmpa>.updated settings-error notice is-dismissible, .update-nag, .updated { display: none;...
208,135
<p>I have a function to be run every 5 minutes. I've referred following from the codex:</p> <pre><code>&lt;?php wp_schedule_event(time(), 'hourly', 'my_schedule_hook', $args); ?&gt; </code></pre> <p>I want to run this function just every 5 minuets regardless of when to start. How can I this?</p> <p>Also it says cod...
[ { "answer_id": 208141, "author": "Andrew Welch", "author_id": 17862, "author_profile": "https://wordpress.stackexchange.com/users/17862", "pm_score": 1, "selected": false, "text": "<p>I'm afraid that other than waiting for someone to visit your site which runs a function, the only other ...
2015/11/10
[ "https://wordpress.stackexchange.com/questions/208135", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/69828/" ]
I have a function to be run every 5 minutes. I've referred following from the codex: ``` <?php wp_schedule_event(time(), 'hourly', 'my_schedule_hook', $args); ?> ``` I want to run this function just every 5 minuets regardless of when to start. How can I this? Also it says codex says cron will be run when a visitor...
You can create new schedule times via cron\_schedules: ``` function my_cron_schedules($schedules){ if(!isset($schedules["5min"])){ $schedules["5min"] = array( 'interval' => 5*60, 'display' => __('Once every 5 minutes')); } if(!isset($schedules["30min"])){ $schedules[...
208,149
<p>I tried to set up a custom post type in Wordpress, and everything worked just fine.</p> <p>Until displaying a single post from my custom post type. First it didn't automatically use the <code>single.php</code> (as it should), and then I tried to create a custom <code>single-{custom_post_type}.php</code> but it does...
[ { "answer_id": 208141, "author": "Andrew Welch", "author_id": 17862, "author_profile": "https://wordpress.stackexchange.com/users/17862", "pm_score": 1, "selected": false, "text": "<p>I'm afraid that other than waiting for someone to visit your site which runs a function, the only other ...
2015/11/10
[ "https://wordpress.stackexchange.com/questions/208149", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/76549/" ]
I tried to set up a custom post type in Wordpress, and everything worked just fine. Until displaying a single post from my custom post type. First it didn't automatically use the `single.php` (as it should), and then I tried to create a custom `single-{custom_post_type}.php` but it doesn't even use that one :/ I'm ki...
You can create new schedule times via cron\_schedules: ``` function my_cron_schedules($schedules){ if(!isset($schedules["5min"])){ $schedules["5min"] = array( 'interval' => 5*60, 'display' => __('Once every 5 minutes')); } if(!isset($schedules["30min"])){ $schedules[...
208,154
<p>Happily coding along all of a sudden I realise my homepage is now showing blog posts and the setting to set a static home page is missing from the reading option (see screen shot).</p> <p>In the database the option show_on_front was now magically set to posts as well. </p> <p>Some people have said that it is becau...
[ { "answer_id": 242682, "author": "Koen de Graaf", "author_id": 104925, "author_profile": "https://wordpress.stackexchange.com/users/104925", "pm_score": 4, "selected": false, "text": "<p>I just had the same problem but fixed it quickly! :-)</p>\n\n<p>In my case, my homepage was on <em>dr...
2015/11/10
[ "https://wordpress.stackexchange.com/questions/208154", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17862/" ]
Happily coding along all of a sudden I realise my homepage is now showing blog posts and the setting to set a static home page is missing from the reading option (see screen shot). In the database the option show\_on\_front was now magically set to posts as well. Some people have said that it is because there are no...
I just had the same problem but fixed it quickly! :-) In my case, my homepage was on *draft*. Apparently, the settings then can't find the homepage anymore. It thinks it's gone and disables the option to set a default homepage. So turn on your homepage to visible. (also name it "Home") Hope it works for you! Cheers,...
208,164
<p>I work a bit with the wordpress API and I want to try to include a <code>&lt;meta&gt;</code>-tag into my head area of my website.</p> <p><strong>This is my code (<em>works everything fine!</em>):</strong></p> <pre><code>class dmd_noindex_options_page{ function __construct() { add_action( 'wp_head', arr...
[ { "answer_id": 208165, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": true, "text": "<p>I just skimmed through the <code>WPSEO_Frontend</code> class and found the <code>wpseo_robots</code> filter fo...
2015/11/10
[ "https://wordpress.stackexchange.com/questions/208164", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/78481/" ]
I work a bit with the wordpress API and I want to try to include a `<meta>`-tag into my head area of my website. **This is my code (*works everything fine!*):** ``` class dmd_noindex_options_page{ function __construct() { add_action( 'wp_head', array( $this, 'set_meta') ); } function set_meta(){ ...
I just skimmed through the `WPSEO_Frontend` class and found the `wpseo_robots` filter for the *meta robots content* string. You might try something like: ``` add_filter( 'wpseo_robots', function( $content ) { // your logic here ... return $content; } ); ``` to override the *robots meta content*...
208,174
<p>Here's the situation. I needed to create a copy of the website online so that I could redesign it and collaborate with others to redo the content. Consequently: </p> <ul> <li>I copied a website (example.org) to test.example.org. (Copied the example.org folder entire via ssh command) </li> <li>modified the wp-config...
[ { "answer_id": 208165, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": true, "text": "<p>I just skimmed through the <code>WPSEO_Frontend</code> class and found the <code>wpseo_robots</code> filter fo...
2015/11/10
[ "https://wordpress.stackexchange.com/questions/208174", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83338/" ]
Here's the situation. I needed to create a copy of the website online so that I could redesign it and collaborate with others to redo the content. Consequently: * I copied a website (example.org) to test.example.org. (Copied the example.org folder entire via ssh command) * modified the wp-config file to connect to a ...
I just skimmed through the `WPSEO_Frontend` class and found the `wpseo_robots` filter for the *meta robots content* string. You might try something like: ``` add_filter( 'wpseo_robots', function( $content ) { // your logic here ... return $content; } ); ``` to override the *robots meta content*...
208,181
<p>I want to add a custom template for a custom post (<code>'post_type' =&gt; 'matches'</code>).</p> <p>I am writing a plugin.I keep my template in the <code>templates/fp-fixture-template.php</code> file.</p> <p>Here is the function:</p> <pre><code>function fixture_template( $template_path ) { if ( get_post_typ...
[ { "answer_id": 208182, "author": "ville6000", "author_id": 62041, "author_profile": "https://wordpress.stackexchange.com/users/62041", "pm_score": 3, "selected": false, "text": "<p>This plugin looks for <code>page_contact.php</code> from active theme's folder and uses plugin's <code>temp...
2015/11/10
[ "https://wordpress.stackexchange.com/questions/208181", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83330/" ]
I want to add a custom template for a custom post (`'post_type' => 'matches'`). I am writing a plugin.I keep my template in the `templates/fp-fixture-template.php` file. Here is the function: ``` function fixture_template( $template_path ) { if ( get_post_type() == 'matches' ) { if ( is_single() ) { ...
This plugin looks for `page_contact.php` from active theme's folder and uses plugin's `templates/page_contact.php` as a fallback. ``` <?php /** * Plugin Name: Test Plugin */ add_filter( 'template_include', 'contact_page_template', 99 ); function contact_page_template( $template ) { $file_name = 'page_contact.p...
208,218
<p>We use the latest versions of WordPress with the Woocommerce plugin. I'm searching for the best way to apply jquery to custom post types such as WC. I have a lot of hooks already for Woocommerce, so for now I have added some jquery into a meta box that I have previously added to the edit.php page. For instance, I'm ...
[ { "answer_id": 208222, "author": "Dan Wist", "author_id": 83360, "author_profile": "https://wordpress.stackexchange.com/users/83360", "pm_score": 0, "selected": false, "text": "<p>You can use the get_current_screen() function...it returns an object that contains lots of useful informatio...
2015/11/10
[ "https://wordpress.stackexchange.com/questions/208218", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83280/" ]
We use the latest versions of WordPress with the Woocommerce plugin. I'm searching for the best way to apply jquery to custom post types such as WC. I have a lot of hooks already for Woocommerce, so for now I have added some jquery into a meta box that I have previously added to the edit.php page. For instance, I'm usi...
The previous answer works good with my example above using this hook: ``` add_action( 'admin_head', 'woocommerce_admin_init' ); function woocommerce_admin_init() { $screen = get_current_screen(); if ( $screen->post_type == "shop_order" ) { ?> <script type="text/javascript"> jQuery(document).rea...
208,225
<p>Looking for a reason why <code>get_post_meta()</code> doesn't work with <code>home.php</code>. From my reading I understand that it's a template and not a post or page, per "<a href="https://wordpress.stackexchange.com/questions/92285/custom-fields-wont-display-on-my-blog-page?lq=1">Custom fields won't display on m...
[ { "answer_id": 208229, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 2, "selected": false, "text": "<p>The home page (<em>this goes for the blogpage any archive page as well</em>) does not have a post ID as...
2015/11/10
[ "https://wordpress.stackexchange.com/questions/208225", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25271/" ]
Looking for a reason why `get_post_meta()` doesn't work with `home.php`. From my reading I understand that it's a template and not a post or page, per "[Custom fields won't display on my blog page](https://wordpress.stackexchange.com/questions/92285/custom-fields-wont-display-on-my-blog-page?lq=1)". The closest page I ...
If your posts page is a static page selected under Settings > Reading > **Front page displays**, then `get_queried_object_id()` will return the ID for that page which you can use to fetch meta data. ``` $check_meta = get_post_meta( get_queried_object_id(), 'checkbox', true ); $header_meta = get_post_meta( get_q...
208,259
<p><strong>There is an Edit at the end of this question.</strong></p> <p>I want to to include a file, in a script tag, from the js sub directory of the theme's directory. I want to do so in the theme's index, search, single, archive, etc. php files.</p> <p>The URL of the theme I'm using is: <a href="http://www.exampl...
[ { "answer_id": 208229, "author": "Pieter Goosen", "author_id": 31545, "author_profile": "https://wordpress.stackexchange.com/users/31545", "pm_score": 2, "selected": false, "text": "<p>The home page (<em>this goes for the blogpage any archive page as well</em>) does not have a post ID as...
2015/11/11
[ "https://wordpress.stackexchange.com/questions/208259", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83376/" ]
**There is an Edit at the end of this question.** I want to to include a file, in a script tag, from the js sub directory of the theme's directory. I want to do so in the theme's index, search, single, archive, etc. php files. The URL of the theme I'm using is: <http://www.example.com/welg/wp-content/themes/mytheme> ...
If your posts page is a static page selected under Settings > Reading > **Front page displays**, then `get_queried_object_id()` will return the ID for that page which you can use to fetch meta data. ``` $check_meta = get_post_meta( get_queried_object_id(), 'checkbox', true ); $header_meta = get_post_meta( get_q...
208,300
<p>Metadata is information about an image, and can be included in JPEG image files.</p> <p>EXIF metadata is information about the image recorded directly from the camera – for example, the exposure time and the date the photo was taken.</p> <p>WordPress preserves EXIF information in full size images loaded to your we...
[ { "answer_id": 238971, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": 2, "selected": false, "text": "<p>This issue has been fixed <a href=\"https://developer.wordpress.org/reference/hooks/image_strip_meta/\" rel=\"no...
2015/11/11
[ "https://wordpress.stackexchange.com/questions/208300", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/47846/" ]
Metadata is information about an image, and can be included in JPEG image files. EXIF metadata is information about the image recorded directly from the camera – for example, the exposure time and the date the photo was taken. WordPress preserves EXIF information in full size images loaded to your website. It will al...
This issue has been fixed [with a filter](https://developer.wordpress.org/reference/hooks/image_strip_meta/) in Wordpress 4.5. If you want to preserve the exif data when resizing use ``` add_filter ('image_strip_meta', false); ```
208,306
<p>I only do a SELECT on a whole table - and the table is defined in a variable:</p> <pre><code>$table = $wpdb-&gt;prefix . 'members'; </code></pre> <p>Do I have to bind a parameter to this variable?</p> <p>This caused an error:</p> <pre><code>$result = $wpdb-&gt;get_results($wpdb-&gt;prepare("SELECT * FROM %s", $t...
[ { "answer_id": 208309, "author": "CapitanFindus", "author_id": 63722, "author_profile": "https://wordpress.stackexchange.com/users/63722", "pm_score": 0, "selected": false, "text": "<p>It's just a wrong bracket closing, <code>$wpdb-&gt;prepare</code> only requires the <code>query string<...
2015/11/11
[ "https://wordpress.stackexchange.com/questions/208306", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82394/" ]
I only do a SELECT on a whole table - and the table is defined in a variable: ``` $table = $wpdb->prefix . 'members'; ``` Do I have to bind a parameter to this variable? This caused an error: ``` $result = $wpdb->get_results($wpdb->prepare("SELECT * FROM %s", $table, ARRAY_A)); ``` But if I skip the "%s", this g...
No, you do not want to swap out the tablename. If you do, the table name will be wrapped in quotes and it will trigger a SQL error. Try: ``` $table = $wpdb->prefix . 'members'; $qry = $wpdb->prepare("SELECT * FROM %s", $table); var_dump($qry); $qry = "SELECT * FROM $table"; var_dump($result); ``` The first string ...
208,307
<p>I'm using this code for generating a Feed from lasted modified post</p> <pre><code>mysqli_query( $conn, "SELECT * FROM wp_posts WHERE post_status = 'publish' AND post_type = 'post' AND DATE(post_modified) &gt; DATE(post_date) ORDER BY post_modified DESC LIMIT 50" ); </code...
[ { "answer_id": 208314, "author": "Bharat", "author_id": 83408, "author_profile": "https://wordpress.stackexchange.com/users/83408", "pm_score": 0, "selected": false, "text": "<pre><code>$lastupdated_args = array(\n 'paged' =&gt; $paged,\n 'post_status' =&gt; 'publish',\n 'post_t...
2015/11/11
[ "https://wordpress.stackexchange.com/questions/208307", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I'm using this code for generating a Feed from lasted modified post ``` mysqli_query( $conn, "SELECT * FROM wp_posts WHERE post_status = 'publish' AND post_type = 'post' AND DATE(post_modified) > DATE(post_date) ORDER BY post_modified DESC LIMIT 50" ); ``` and it works perf...
You can use the `posts_where` filter: ``` // Add custom filter add_filter( 'posts_where', 'wpse_modified' ); // Fetch posts $query = new WP_Query( $lastupdated_args ); ``` where you can define the filter callback as: ``` function wpse_modified( $where ) { global $wpdb; // Run only once: remove_filter( cur...
208,339
<p>I've got a custom post type called <code>course</code>. Within a course post, I have a number of custom fields, specifically (all AFC select dropdowns): <code>course_or_project</code>, <code>time_to_complete_project</code>, <code>time_to_complete_course</code> and <code>difficulty</code>. I also have a taxonomy call...
[ { "answer_id": 208314, "author": "Bharat", "author_id": 83408, "author_profile": "https://wordpress.stackexchange.com/users/83408", "pm_score": 0, "selected": false, "text": "<pre><code>$lastupdated_args = array(\n 'paged' =&gt; $paged,\n 'post_status' =&gt; 'publish',\n 'post_t...
2015/11/11
[ "https://wordpress.stackexchange.com/questions/208339", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/36920/" ]
I've got a custom post type called `course`. Within a course post, I have a number of custom fields, specifically (all AFC select dropdowns): `course_or_project`, `time_to_complete_project`, `time_to_complete_course` and `difficulty`. I also have a taxonomy called `course_project_category`. My aim is to be able to cre...
You can use the `posts_where` filter: ``` // Add custom filter add_filter( 'posts_where', 'wpse_modified' ); // Fetch posts $query = new WP_Query( $lastupdated_args ); ``` where you can define the filter callback as: ``` function wpse_modified( $where ) { global $wpdb; // Run only once: remove_filter( cur...
208,347
<p>take <code>the_category()</code> as an example:</p> <p>Here is the output of the_category function in the wordpress loop:</p> <pre><code> &lt;ul class="post-categories"&gt; &lt;li&gt; &lt;a href="http://example.com/category/another-category/" rel="category tag"&gt; Another Category...
[ { "answer_id": 208314, "author": "Bharat", "author_id": 83408, "author_profile": "https://wordpress.stackexchange.com/users/83408", "pm_score": 0, "selected": false, "text": "<pre><code>$lastupdated_args = array(\n 'paged' =&gt; $paged,\n 'post_status' =&gt; 'publish',\n 'post_t...
2015/11/11
[ "https://wordpress.stackexchange.com/questions/208347", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83191/" ]
take `the_category()` as an example: Here is the output of the\_category function in the wordpress loop: ``` <ul class="post-categories"> <li> <a href="http://example.com/category/another-category/" rel="category tag"> Another Category </a> </li> <li> ...
You can use the `posts_where` filter: ``` // Add custom filter add_filter( 'posts_where', 'wpse_modified' ); // Fetch posts $query = new WP_Query( $lastupdated_args ); ``` where you can define the filter callback as: ``` function wpse_modified( $where ) { global $wpdb; // Run only once: remove_filter( cur...
208,350
<p>I want to make a logo manager in the Customizer, but how do I set different image sizes with the <code>WP_Customize_Cropped_Image_Control</code> class? </p> <p>Example from <a href="https://make.wordpress.org/core/2015/07/16/new-customizer-media-controls-in-4-3-and-4-2/" rel="nofollow">Make WordPress Core:</a></p> ...
[ { "answer_id": 208314, "author": "Bharat", "author_id": 83408, "author_profile": "https://wordpress.stackexchange.com/users/83408", "pm_score": 0, "selected": false, "text": "<pre><code>$lastupdated_args = array(\n 'paged' =&gt; $paged,\n 'post_status' =&gt; 'publish',\n 'post_t...
2015/11/11
[ "https://wordpress.stackexchange.com/questions/208350", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83187/" ]
I want to make a logo manager in the Customizer, but how do I set different image sizes with the `WP_Customize_Cropped_Image_Control` class? Example from [Make WordPress Core:](https://make.wordpress.org/core/2015/07/16/new-customizer-media-controls-in-4-3-and-4-2/) ``` $wp_customize->add_control( new WP_Customize_C...
You can use the `posts_where` filter: ``` // Add custom filter add_filter( 'posts_where', 'wpse_modified' ); // Fetch posts $query = new WP_Query( $lastupdated_args ); ``` where you can define the filter callback as: ``` function wpse_modified( $where ) { global $wpdb; // Run only once: remove_filter( cur...
208,354
<p>I need to add multiple taxonomy filters to the functions.php file to remove (3) irrelevant taxonomies from the Yoast SEO sitemap index. I have been able to successfully add one filter, but when I add the other two filters, I keep getting a 500 server error. I should note that I am a novice when it comes to PHP so I ...
[ { "answer_id": 208357, "author": "Will", "author_id": 44795, "author_profile": "https://wordpress.stackexchange.com/users/44795", "pm_score": 2, "selected": false, "text": "<p>Try PHP's <a href=\"http://php.net/manual/en/function.in-array.php\" rel=\"nofollow\"><code>in_array</code></a>....
2015/11/11
[ "https://wordpress.stackexchange.com/questions/208354", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83428/" ]
I need to add multiple taxonomy filters to the functions.php file to remove (3) irrelevant taxonomies from the Yoast SEO sitemap index. I have been able to successfully add one filter, but when I add the other two filters, I keep getting a 500 server error. I should note that I am a novice when it comes to PHP so I ima...
Try PHP's [`in_array`](http://php.net/manual/en/function.in-array.php). ``` function sitemap_exclude_taxonomy( $value, $taxonomy ) { $excludes = ['scope', 'layout_type', 'foo', 'bar']; if ( in_array( $taxonomy, $excludes ) return true; } add_filter( 'wpseo_sitemap_exclude_taxonomy', 'sitemap_exclude_taxonomy...
208,367
<p>I have recently been invited to the letsencrypt SSL beta, and have now spotted a potential problem.</p> <p>My main site tomjn.com is a multisite, and I have the opportunity to add certificates for tomjn.com and www.tomjn.com, but I also have other subdomains, subdomains i do not have SSL certificates for.</p> <p>I...
[ { "answer_id": 208357, "author": "Will", "author_id": 44795, "author_profile": "https://wordpress.stackexchange.com/users/44795", "pm_score": 2, "selected": false, "text": "<p>Try PHP's <a href=\"http://php.net/manual/en/function.in-array.php\" rel=\"nofollow\"><code>in_array</code></a>....
2015/11/12
[ "https://wordpress.stackexchange.com/questions/208367", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/736/" ]
I have recently been invited to the letsencrypt SSL beta, and have now spotted a potential problem. My main site tomjn.com is a multisite, and I have the opportunity to add certificates for tomjn.com and www.tomjn.com, but I also have other subdomains, subdomains i do not have SSL certificates for. Is it possible to ...
Try PHP's [`in_array`](http://php.net/manual/en/function.in-array.php). ``` function sitemap_exclude_taxonomy( $value, $taxonomy ) { $excludes = ['scope', 'layout_type', 'foo', 'bar']; if ( in_array( $taxonomy, $excludes ) return true; } add_filter( 'wpseo_sitemap_exclude_taxonomy', 'sitemap_exclude_taxonomy...
208,384
<p>I am using storefront theme, where there is options for the Full Width in the pages but not in the Product Page and Product Category Page in the Store Front Theme</p> <p>As i played with css and i go this line in the template</p> <pre><code>&lt;div id="primary" class="content-area"&gt; </code></pre> <p>As i remov...
[ { "answer_id": 217419, "author": "Iggy", "author_id": 32150, "author_profile": "https://wordpress.stackexchange.com/users/32150", "pm_score": 2, "selected": false, "text": "<p>for product page, you can put in functions.php</p>\n\n<pre><code>function remove_storefront_sidebar() {\n if ...
2015/11/12
[ "https://wordpress.stackexchange.com/questions/208384", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/71459/" ]
I am using storefront theme, where there is options for the Full Width in the pages but not in the Product Page and Product Category Page in the Store Front Theme As i played with css and i go this line in the template ``` <div id="primary" class="content-area"> ``` As i removed the content-area class i can able to...
for product page, you can put in functions.php ``` function remove_storefront_sidebar() { if ( is_product() ) { remove_action( 'storefront_sidebar', 'storefront_get_sidebar', 10 ); } } add_action( 'get_header', 'remove_storefront_sidebar' ); ``` It works with latest woocommerce 2.5.2 Also CSS is needed: ...
208,423
<p>I have AJAX form submission working fine locally. But when pushed to my staging server the process page is 404'ing. I cannot access it directly neither as it 404's but checking on the server and its 100% there with correct permissions too.</p> <p>The code for the AJAX:</p> <pre><code>$('body').on('submit', '.produ...
[ { "answer_id": 208431, "author": "Mateusz Paulski", "author_id": 83472, "author_profile": "https://wordpress.stackexchange.com/users/83472", "pm_score": -1, "selected": false, "text": "<p>maybe try this:</p>\n\n<pre><code>$('body').on('submit', '.product-form', function(e){\n e.preven...
2015/11/12
[ "https://wordpress.stackexchange.com/questions/208423", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82942/" ]
I have AJAX form submission working fine locally. But when pushed to my staging server the process page is 404'ing. I cannot access it directly neither as it 404's but checking on the server and its 100% there with correct permissions too. The code for the AJAX: ``` $('body').on('submit', '.product-form', function(e)...
Take a look at [wp localize script](https://codex.wordpress.org/Function_Reference/wp_localize_script). It'll allow you to encode your url into a separate javascript object before your script is loaded. [get\_template\_directory](https://codex.wordpress.org/Function_Reference/get_template_directory) retrieves the absol...
208,457
<p>I am continuing on from a topic I already <a href="https://wordpress.stackexchange.com/questions/208353/different-text-widgets-in-sidebar-on-many-different-pages">posted</a> but with a different angle. Please bare with me as I try to provide as much information as possible.</p> <p>I am looking to add a simple <str...
[ { "answer_id": 208463, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 4, "selected": true, "text": "<p>You <em>could</em> dynamically register sidebars. When you register sidebars, you could query for all of your anima...
2015/11/12
[ "https://wordpress.stackexchange.com/questions/208457", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83426/" ]
I am continuing on from a topic I already [posted](https://wordpress.stackexchange.com/questions/208353/different-text-widgets-in-sidebar-on-many-different-pages) but with a different angle. Please bare with me as I try to provide as much information as possible. I am looking to add a simple **text area** called "Quic...
You *could* dynamically register sidebars. When you register sidebars, you could query for all of your animal pages, loop over all pages, and register a unique sidebar for each page. Adding a page would automatically create a sidebar for it. *However* - that's a lot of sidebars. For something tightly coupled with the ...
208,471
<p>I have been given a job to amend a Wordpress site. I have only been given access to Cpanel. My questions are can i log in to the back end of Wordpress via Cpanel? If you can't login via Cpanel can i change the details like username and password so i can log in?</p> <p>I have tried going into mySQL database to the p...
[ { "answer_id": 208473, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p>There are 5 options</p>\n\n<h2>1) Ask The Client</h2>\n\n<p>You haven't been given what you need to do your ...
2015/11/12
[ "https://wordpress.stackexchange.com/questions/208471", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83501/" ]
I have been given a job to amend a Wordpress site. I have only been given access to Cpanel. My questions are can i log in to the back end of Wordpress via Cpanel? If you can't login via Cpanel can i change the details like username and password so i can log in? I have tried going into mySQL database to the phpmyadmin ...
There are 5 options 1) Ask The Client ----------------- You haven't been given what you need to do your work, so you should request it rather than hacking in to the clients site. This would be the Professional and ethical thing to do 2) Reset Password link ---------------------- Using the standard password reset li...
208,477
<p>I have some PHP experience, but hardly any WP theme writing experience...I'm just starting the journey.</p> <p>All of the themes I have looked at so far in the .org repository have code that looks like this:</p> <pre><code>&lt;?php if (condition) { ?&gt; ..some html &lt;?php } else { ?&gt; ..some other html &lt;?p...
[ { "answer_id": 208482, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 4, "selected": true, "text": "<p>As always, people copy paste whatever they learned from and IIRC the first style is the coding style of wo...
2015/11/12
[ "https://wordpress.stackexchange.com/questions/208477", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82933/" ]
I have some PHP experience, but hardly any WP theme writing experience...I'm just starting the journey. All of the themes I have looked at so far in the .org repository have code that looks like this: ``` <?php if (condition) { ?> ..some html <?php } else { ?> ..some other html <?php } ?> ``` instead of: ``` <?php...
As always, people copy paste whatever they learned from and IIRC the first style is the coding style of wordpress core. As you said yourself, when there is a big block of generated HTML it is easier to look at (and balance tags) under the first style, but pragmatic people will use the second whenever that is not the c...
208,480
<p>There is a horizontal box of one-line height at the bottom with the character "p" in it that I want to get rid of for end users. I don't really care if it is there in the Dashboard Editor for site admins/editors. This line seems to indicate the formatting of the line where the cursor is. End users are providing ...
[ { "answer_id": 208491, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 1, "selected": false, "text": "<p>This is how the tinymce statusbar displays on my intsall:</p>\n\n<pre><code>&lt;div id=\"mceu_34\" class=\"mc...
2015/11/12
[ "https://wordpress.stackexchange.com/questions/208480", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83503/" ]
There is a horizontal box of one-line height at the bottom with the character "p" in it that I want to get rid of for end users. I don't really care if it is there in the Dashboard Editor for site admins/editors. This line seems to indicate the formatting of the line where the cursor is. End users are providing feedbac...
This is how the tinymce statusbar displays on my intsall: ``` <div id="mceu_34" class="mce-statusbar mce-container mce-panel mce-stack-layout-item mce-last" hidefocus="1" tabindex="-1" role="group"> <div id="mceu_34-body" class="mce-container-body mce-flow-layout"> <div id="mceu_35" class="mce-path mce-flo...
208,487
<p>I've been tasked with converting about 100 sites in my multisite instance to HTTPS.</p> <p>I can easily write a script to hit the DB and change the <code>siteurl</code> and <code>home</code> values to HTTPS, which inturn should force the site to enqueue scripts and future embeded images to HTTPS right?</p> <p>Well...
[ { "answer_id": 208490, "author": "John Lucey", "author_id": 83434, "author_profile": "https://wordpress.stackexchange.com/users/83434", "pm_score": 0, "selected": false, "text": "<p>This process actually involves purchasing a security Certificate and applying it to your server for your w...
2015/11/12
[ "https://wordpress.stackexchange.com/questions/208487", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19536/" ]
I've been tasked with converting about 100 sites in my multisite instance to HTTPS. I can easily write a script to hit the DB and change the `siteurl` and `home` values to HTTPS, which inturn should force the site to enqueue scripts and future embeded images to HTTPS right? Well I'll also need to go through all post\...
You could run a script to UPDATE all urls and guids to https, if you want a clean setup. But also consider alternatives such as: ``` <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.yoursite.com/$1 [R,L] </IfModule> ``` In wp-config.php for the backend: ``` d...
208,532
<p>I am trying to login a user from custom user registration form. My Code for Custom user Register is </p> <pre><code>function register_user($data) { $userdata = array( 'user_login' =&gt; $data['email'], 'user_email' =&gt; $data['email'], 'user_pass' =&gt; $data['pssword'],...
[ { "answer_id": 208490, "author": "John Lucey", "author_id": 83434, "author_profile": "https://wordpress.stackexchange.com/users/83434", "pm_score": 0, "selected": false, "text": "<p>This process actually involves purchasing a security Certificate and applying it to your server for your w...
2015/11/13
[ "https://wordpress.stackexchange.com/questions/208532", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/77484/" ]
I am trying to login a user from custom user registration form. My Code for Custom user Register is ``` function register_user($data) { $userdata = array( 'user_login' => $data['email'], 'user_email' => $data['email'], 'user_pass' => $data['pssword'], 'user_nice...
You could run a script to UPDATE all urls and guids to https, if you want a clean setup. But also consider alternatives such as: ``` <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.yoursite.com/$1 [R,L] </IfModule> ``` In wp-config.php for the backend: ``` d...
208,545
<p>I have a site with numerous custom post types that are created using a class. I was considering whether it was worth creating a custom taxonomy for each custom post type to offer a way of organizing and categorizing within that custom post type <em>-e.g</em> terms and tags that only apply to that post type and not o...
[ { "answer_id": 208490, "author": "John Lucey", "author_id": 83434, "author_profile": "https://wordpress.stackexchange.com/users/83434", "pm_score": 0, "selected": false, "text": "<p>This process actually involves purchasing a security Certificate and applying it to your server for your w...
2015/11/13
[ "https://wordpress.stackexchange.com/questions/208545", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/17862/" ]
I have a site with numerous custom post types that are created using a class. I was considering whether it was worth creating a custom taxonomy for each custom post type to offer a way of organizing and categorizing within that custom post type *-e.g* terms and tags that only apply to that post type and not others (so ...
You could run a script to UPDATE all urls and guids to https, if you want a clean setup. But also consider alternatives such as: ``` <IfModule mod_rewrite.c> RewriteEngine On RewriteCond %{SERVER_PORT} 80 RewriteRule ^(.*)$ https://www.yoursite.com/$1 [R,L] </IfModule> ``` In wp-config.php for the backend: ``` d...
208,565
<p>I looked at some code for an article and saw that there was a shortcode contained in a <code>&lt;p&gt;</code> tag:</p> <pre><code>&lt;p&gt;Blabla&lt;/p&gt; &lt;p&gt;[shortcode]&lt;/p&gt; &lt;p&gt;Wofwof&lt;/p&gt; </code></pre> <p>The shortcode doesn't seem to work. Could it have anything to do with that it's conta...
[ { "answer_id": 208550, "author": "shadylane", "author_id": 82498, "author_profile": "https://wordpress.stackexchange.com/users/82498", "pm_score": 0, "selected": false, "text": "<p>I'm not sure if it's the cause, but wouldn't you be better off using mod_php? The performance should be muc...
2015/11/13
[ "https://wordpress.stackexchange.com/questions/208565", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83551/" ]
I looked at some code for an article and saw that there was a shortcode contained in a `<p>` tag: ``` <p>Blabla</p> <p>[shortcode]</p> <p>Wofwof</p> ``` The shortcode doesn't seem to work. Could it have anything to do with that it's contained in the paragraph tag?
so i managed to figure out what the problem was, your inputs were all help full in pointing me in the right direction. so what was causing my high disk i/o was the php\_cgi\_maxrequest value which was set at 99999, so i increased the value to 200,000 in the disk i/o shot down drastically, and i'm experiencing a more st...
208,608
<p>I'm looking for a safe and fast way to delete all of one custom post type's posts. Using <code>get_posts()</code> and <code>wp_delete_post()</code> for each returned post does not work; it's not fast enough due to the sheer amount of database queries involved (timeout error).</p> <p>Preferably, I'm looking for a si...
[ { "answer_id": 275584, "author": "pathusutariya", "author_id": 125122, "author_profile": "https://wordpress.stackexchange.com/users/125122", "pm_score": 5, "selected": false, "text": "<p>You can delete all post via <code>$wpdb</code></p>\n\n<pre><code>DELETE FROM wp_posts WHERE post_type...
2015/11/13
[ "https://wordpress.stackexchange.com/questions/208608", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/32848/" ]
I'm looking for a safe and fast way to delete all of one custom post type's posts. Using `get_posts()` and `wp_delete_post()` for each returned post does not work; it's not fast enough due to the sheer amount of database queries involved (timeout error). Preferably, I'm looking for a single database query to run that ...
You can delete all post via `$wpdb` ``` DELETE FROM wp_posts WHERE post_type='post_type'; DELETE FROM wp_postmeta WHERE post_id NOT IN (SELECT id FROM wp_posts); DELETE FROM wp_term_relationships WHERE object_id NOT IN (SELECT id FROM wp_posts) ``` or use this query replace it with {{your CPT}} with your Custom Post...
208,615
<p>I have a WordPress theme that includes jQuery, but for some reason the "$" doesn't let me call jQuery. I know I can wrap <a href="https://stackoverflow.com/questions/10371539/why-define-anonymous-function-and-pass-jquery-as-the-argument/10372429#10372429">jQuery calls in an anonymous function</a>, but I have other p...
[ { "answer_id": 208617, "author": "Kvvaradha", "author_id": 43308, "author_profile": "https://wordpress.stackexchange.com/users/43308", "pm_score": 0, "selected": false, "text": "<p>Instead of $ use 'jQuery'. I am not sure about your WordPress version. For the updates with jQuery. 1. 9....
2015/11/14
[ "https://wordpress.stackexchange.com/questions/208615", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13981/" ]
I have a WordPress theme that includes jQuery, but for some reason the "$" doesn't let me call jQuery. I know I can wrap [jQuery calls in an anonymous function](https://stackoverflow.com/questions/10371539/why-define-anonymous-function-and-pass-jquery-as-the-argument/10372429#10372429), but I have other plugins that re...
> > Why doesn't jQuery default to the "$" when the script is added this > way? > > > The `$` alias has been chosen by several different libraries an alias. This causes conflict if you try to use more than one library. It is a bit ridiculous, actually-- like several major corporations all deciding to use the same ...
208,616
<p>I have tried many answers here on stackoverflow but couldnt find a solution to my problem. I have created a custom post type called <code>ph_products</code> and custom taxonomies with the name <code>ph_category</code>.</p> <p>Then I created some categories for that custom post type like this:</p> <pre><code>blue-p...
[ { "answer_id": 208617, "author": "Kvvaradha", "author_id": 43308, "author_profile": "https://wordpress.stackexchange.com/users/43308", "pm_score": 0, "selected": false, "text": "<p>Instead of $ use 'jQuery'. I am not sure about your WordPress version. For the updates with jQuery. 1. 9....
2015/11/14
[ "https://wordpress.stackexchange.com/questions/208616", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64793/" ]
I have tried many answers here on stackoverflow but couldnt find a solution to my problem. I have created a custom post type called `ph_products` and custom taxonomies with the name `ph_category`. Then I created some categories for that custom post type like this: ``` blue-products blue-sub-products green-product...
> > Why doesn't jQuery default to the "$" when the script is added this > way? > > > The `$` alias has been chosen by several different libraries an alias. This causes conflict if you try to use more than one library. It is a bit ridiculous, actually-- like several major corporations all deciding to use the same ...
208,677
<p>During a large brute force attack, I'd like to shut off the ability to log into WordPress entirely. The only account on the site is mine, so there's no reason for visitors to login and it wouldn't hurt their experience on the site. </p> <p>When I need to login, I can remove the code. Alternatively, I can limit logi...
[ { "answer_id": 208678, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 2, "selected": false, "text": "<p>Failing to authenticate should do the trick for all the kinds of possible authentication - login form, xm...
2015/11/14
[ "https://wordpress.stackexchange.com/questions/208677", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27742/" ]
During a large brute force attack, I'd like to shut off the ability to log into WordPress entirely. The only account on the site is mine, so there's no reason for visitors to login and it wouldn't hurt their experience on the site. When I need to login, I can remove the code. Alternatively, I can limit logins to just...
Failing to authenticate should do the trick for all the kinds of possible authentication - login form, xmlrpc, ajax, whatever **Edit**: actually realized there is a way to save sending the user related query to the DB ``` function wpse208677_authenticate($user,$username,$pass) { remove_filter('authenticate','wp_aut...
208,710
<p>this is my link. <a href="http://redesign.conei-sa.com/apps_cat" rel="nofollow">http://redesign.conei-sa.com/apps_cat</a> . not found .</p> <p>My code in function.php. </p> <pre><code>function prefix_register_post_type() { register_post_type( 'application', array( 'labels' =...
[ { "answer_id": 208714, "author": "Tung Du", "author_id": 83304, "author_profile": "https://wordpress.stackexchange.com/users/83304", "pm_score": 1, "selected": false, "text": "<p>It's not how taxonomy work. The apps_cat is just the taxonomy, not the term. Like category, you will receive ...
2015/11/15
[ "https://wordpress.stackexchange.com/questions/208710", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83123/" ]
this is my link. <http://redesign.conei-sa.com/apps_cat> . not found . My code in function.php. ``` function prefix_register_post_type() { register_post_type( 'application', array( 'labels' => array( 'name' => __('Application', 'text_domain'), ...
It's not how taxonomy work. The apps\_cat is just the taxonomy, not the term. Like category, you will receive not found with <http://redesign.conei-sa.com/category>. You must point to a specific term of apps\_cat. apps\_cat can't have any post, only the term of it has. Anyway, if you got not found with term page, try ...
208,733
<p>I've been handed a vulnerability report(1) that seems to be implying that there may be a security issue in the way Wordpress handles URLs with following tildes. It seems the scanner thinks the website may be serving up some directory listings and the such.</p> <p>I was surprised that my website was still serving co...
[ { "answer_id": 222004, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": false, "text": "<p>Yes it seems strange that we should have the same match for: </p>\n\n<pre><code>example.tld/2016/03/29/test/\...
2015/11/15
[ "https://wordpress.stackexchange.com/questions/208733", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22457/" ]
I've been handed a vulnerability report(1) that seems to be implying that there may be a security issue in the way Wordpress handles URLs with following tildes. It seems the scanner thinks the website may be serving up some directory listings and the such. I was surprised that my website was still serving content on t...
Let's go simple =============== If I understand OP well, your problem is that urls containing a tilde are matched at all. All other answers focus on the fact that sanitization for query strips out some characters before perform the query, however one should be capable to prevent a rewrite rule to don't match under so...
208,740
<p>I am trying to get the json data of my posts. I have tried with both v1.2.4 and v2 of the REST API plugin.</p> <p>If I enter</p> <pre><code>http://example.com/wp-json/posts?type=magazine </code></pre> <p>or</p> <pre><code>http://example.com/wp-json/posts?type=magazine&amp;filter[posts_per_page]=-1 </code></pre> ...
[ { "answer_id": 245792, "author": "Edukondalu Thaviti", "author_id": 104441, "author_profile": "https://wordpress.stackexchange.com/users/104441", "pm_score": 1, "selected": false, "text": "<p>Try this instead for pagination. It returns all the posts on my site.</p>\n\n<pre><code>http://e...
2015/11/15
[ "https://wordpress.stackexchange.com/questions/208740", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/74398/" ]
I am trying to get the json data of my posts. I have tried with both v1.2.4 and v2 of the REST API plugin. If I enter ``` http://example.com/wp-json/posts?type=magazine ``` or ``` http://example.com/wp-json/posts?type=magazine&filter[posts_per_page]=-1 ``` just an empty array is returned. If I enter ``` http:/...
Try this instead for pagination. It returns all the posts on my site. ``` http://example.com/wp-json/wp/v2/posts/?filter[category_name]=country&filter[posts_per_page]=-1 ```
208,756
<p>Filter</p> <pre><code> add_filter( 'the_content', 'sandy_posts_filter' ); function sandy_posts_filter( $content ) { global $post; $review_box_pos =get_post_meta( $post-&gt;ID, 'repeatable_fields', true ); if (is_array($review_box_pos)) { foreach ($review_box_pos as $k...
[ { "answer_id": 245792, "author": "Edukondalu Thaviti", "author_id": 104441, "author_profile": "https://wordpress.stackexchange.com/users/104441", "pm_score": 1, "selected": false, "text": "<p>Try this instead for pagination. It returns all the posts on my site.</p>\n\n<pre><code>http://e...
2015/11/16
[ "https://wordpress.stackexchange.com/questions/208756", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/82877/" ]
Filter ``` add_filter( 'the_content', 'sandy_posts_filter' ); function sandy_posts_filter( $content ) { global $post; $review_box_pos =get_post_meta( $post->ID, 'repeatable_fields', true ); if (is_array($review_box_pos)) { foreach ($review_box_pos as $key => $val) { ...
Try this instead for pagination. It returns all the posts on my site. ``` http://example.com/wp-json/wp/v2/posts/?filter[category_name]=country&filter[posts_per_page]=-1 ```
208,760
<p>I want to totally disable this functionality from WordPress because I'm implementing my own version of this with Javascript.</p> <p>When I try to grab all the content in a post via the <code>get_the_content()</code> or <code>the_content()</code> it gives me only the first page, since the content has the page breaks...
[ { "answer_id": 208762, "author": "Milo", "author_id": 4771, "author_profile": "https://wordpress.stackexchange.com/users/4771", "pm_score": 4, "selected": true, "text": "<p><strong>EDIT -</strong> Now that 4.4 is out, you should use the <code>content_pagination</code> filter. See birgire...
2015/11/16
[ "https://wordpress.stackexchange.com/questions/208760", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35549/" ]
I want to totally disable this functionality from WordPress because I'm implementing my own version of this with Javascript. When I try to grab all the content in a post via the `get_the_content()` or `the_content()` it gives me only the first page, since the content has the page breaks. When I use `$post->the_content...
**EDIT -** Now that 4.4 is out, you should use the `content_pagination` filter. See birgire's answer below. --- You can add formatting to raw post content by [applying](https://codex.wordpress.org/Function_Reference/apply_filters) the [content filters](https://codex.wordpress.org/Plugin_API/Filter_Reference/the_conte...
208,761
<p>I'm moving my WordPress site to a new host, and in the process I want to make a one time change to the Permalinks. I want to rewrite the URLs from <code>/2015/11/sample-post/</code> to <code>/sample-post/</code> but how can I accomplish that?</p>
[ { "answer_id": 208763, "author": "Kvvaradha", "author_id": 43308, "author_profile": "https://wordpress.stackexchange.com/users/43308", "pm_score": 0, "selected": false, "text": "<p>Go-to <code>settings -&gt; permalink</code>. and than add it like this: <code>%post_name%</code>.</p>\n" ...
2015/11/16
[ "https://wordpress.stackexchange.com/questions/208761", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83671/" ]
I'm moving my WordPress site to a new host, and in the process I want to make a one time change to the Permalinks. I want to rewrite the URLs from `/2015/11/sample-post/` to `/sample-post/` but how can I accomplish that?
The most efficient way to accomplish this would be to change the structure to `/%postname%/` and add a 301 redirect to your .htaccess file for the old structure: ``` RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(?!page/)(.+)$ http://example.com/$3 ``` Change `example.com` to your domain and add the redirect above the `...
208,776
<p>I'm working on an application using WP as my CMS. I was successfully creating new posts and working with them in my app. </p> <p>But I noticed when visitors went to the website they were being listed in the blog (in the loop). I don't want them to show up there so after doing some research I decided to change my po...
[ { "answer_id": 208763, "author": "Kvvaradha", "author_id": 43308, "author_profile": "https://wordpress.stackexchange.com/users/43308", "pm_score": 0, "selected": false, "text": "<p>Go-to <code>settings -&gt; permalink</code>. and than add it like this: <code>%post_name%</code>.</p>\n" ...
2015/11/16
[ "https://wordpress.stackexchange.com/questions/208776", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/29247/" ]
I'm working on an application using WP as my CMS. I was successfully creating new posts and working with them in my app. But I noticed when visitors went to the website they were being listed in the blog (in the loop). I don't want them to show up there so after doing some research I decided to change my post type fr...
The most efficient way to accomplish this would be to change the structure to `/%postname%/` and add a 301 redirect to your .htaccess file for the old structure: ``` RedirectMatch 301 ^/([0-9]{4})/([0-9]{2})/(?!page/)(.+)$ http://example.com/$3 ``` Change `example.com` to your domain and add the redirect above the `...
208,792
<p>I've changed the default registering option by allowing people to sign up with their e-mail addresses. They also have an option to add their firstname, lastname but it's not required. </p> <pre><code>// Allow email instead of nickname for login add_filter('authenticate', function($user, $email, $password){ //...
[ { "answer_id": 278147, "author": "Crazycoolcam", "author_id": 28144, "author_profile": "https://wordpress.stackexchange.com/users/28144", "pm_score": 2, "selected": false, "text": "<p>Surprised to see this unanswered for this long. This is pretty simple to do with a simple block of code:...
2015/11/16
[ "https://wordpress.stackexchange.com/questions/208792", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/34301/" ]
I've changed the default registering option by allowing people to sign up with their e-mail addresses. They also have an option to add their firstname, lastname but it's not required. ``` // Allow email instead of nickname for login add_filter('authenticate', function($user, $email, $password){ //Check for empt...
Surprised to see this unanswered for this long. This is pretty simple to do with a simple block of code: ``` function set_my_nice_name() { global $wpdb; $user_table = $wpdb->prefix . 'users'; $wpdb->query("UPDATE $user_table SET `user_nicename`=`ID`"); } add_action('init', 'set_my_nice_name'); ``` This w...
208,799
<p>I'm developing an eCommerce site using Woo-Commerce, i'm hoping to introduce some JavaScript to my sale pages only, in the name of a finance slider. What is the best way to go about including a specific piece of JavaScript on my Woo-Commerce sale page only.</p> <p>I'm new to WP so apologies if this is obvious, goog...
[ { "answer_id": 278147, "author": "Crazycoolcam", "author_id": 28144, "author_profile": "https://wordpress.stackexchange.com/users/28144", "pm_score": 2, "selected": false, "text": "<p>Surprised to see this unanswered for this long. This is pretty simple to do with a simple block of code:...
2015/11/16
[ "https://wordpress.stackexchange.com/questions/208799", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83395/" ]
I'm developing an eCommerce site using Woo-Commerce, i'm hoping to introduce some JavaScript to my sale pages only, in the name of a finance slider. What is the best way to go about including a specific piece of JavaScript on my Woo-Commerce sale page only. I'm new to WP so apologies if this is obvious, google didn't ...
Surprised to see this unanswered for this long. This is pretty simple to do with a simple block of code: ``` function set_my_nice_name() { global $wpdb; $user_table = $wpdb->prefix . 'users'; $wpdb->query("UPDATE $user_table SET `user_nicename`=`ID`"); } add_action('init', 'set_my_nice_name'); ``` This w...
208,823
<p>I want to setup an Android and iOS App that calls my WP site via WebView. Somehow, i wasn't able to find the best way to do this via Google. First I was thinking about putting some Code in my functions.php that detects if I am a WebView App Visitor and then deliver another Theme. Then I thought about using the Multi...
[ { "answer_id": 278147, "author": "Crazycoolcam", "author_id": 28144, "author_profile": "https://wordpress.stackexchange.com/users/28144", "pm_score": 2, "selected": false, "text": "<p>Surprised to see this unanswered for this long. This is pretty simple to do with a simple block of code:...
2015/11/16
[ "https://wordpress.stackexchange.com/questions/208823", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/71313/" ]
I want to setup an Android and iOS App that calls my WP site via WebView. Somehow, i wasn't able to find the best way to do this via Google. First I was thinking about putting some Code in my functions.php that detects if I am a WebView App Visitor and then deliver another Theme. Then I thought about using the Multisit...
Surprised to see this unanswered for this long. This is pretty simple to do with a simple block of code: ``` function set_my_nice_name() { global $wpdb; $user_table = $wpdb->prefix . 'users'; $wpdb->query("UPDATE $user_table SET `user_nicename`=`ID`"); } add_action('init', 'set_my_nice_name'); ``` This w...
208,831
<p>I have written up a page template that will list posts in the same category as the name of the page. I am wondering how to alter it to get it to return the posts in alphabetical order?</p> <p>I have been reading over and playing with how to change the template with the <a href="https://codex.wordpress.org/Alphabeti...
[ { "answer_id": 208833, "author": "pwbred", "author_id": 6154, "author_profile": "https://wordpress.stackexchange.com/users/6154", "pm_score": 1, "selected": false, "text": "<p>You need to look closer at query_posts and order your posts by the title, as it says on the <a href=\"https://co...
2015/11/16
[ "https://wordpress.stackexchange.com/questions/208831", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83426/" ]
I have written up a page template that will list posts in the same category as the name of the page. I am wondering how to alter it to get it to return the posts in alphabetical order? I have been reading over and playing with how to change the template with the [Alphabetizing Posts Codex Page](https://codex.wordpress...
As I have stated, never ever use `query_posts`. The page you have linked to in the codex is worth nothing and completely wrong. For extra info on why not to use `query_posts`, check [my answer here](https://wordpress.stackexchange.com/a/191934/31545) and the answer by [@Rarst](https://wordpress.stackexchange.com/a/1755...
208,843
<p>Is there any benefit perfomance wise when defining a constant in the wp-config.php like so</p> <pre><code>&lt;php define('PATH_TO_THEME', get_stylesheet_directory_uri() ); ?&gt; </code></pre> <p>and then referring to <code>PATH_TO_THEME</code> instead using <code>get_stylesheet_directory_uri()</code> multiple time...
[ { "answer_id": 208833, "author": "pwbred", "author_id": 6154, "author_profile": "https://wordpress.stackexchange.com/users/6154", "pm_score": 1, "selected": false, "text": "<p>You need to look closer at query_posts and order your posts by the title, as it says on the <a href=\"https://co...
2015/11/16
[ "https://wordpress.stackexchange.com/questions/208843", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/67074/" ]
Is there any benefit perfomance wise when defining a constant in the wp-config.php like so ``` <php define('PATH_TO_THEME', get_stylesheet_directory_uri() ); ?> ``` and then referring to `PATH_TO_THEME` instead using `get_stylesheet_directory_uri()` multiple times? I got this from a wordpress handbook, saying that ...
As I have stated, never ever use `query_posts`. The page you have linked to in the codex is worth nothing and completely wrong. For extra info on why not to use `query_posts`, check [my answer here](https://wordpress.stackexchange.com/a/191934/31545) and the answer by [@Rarst](https://wordpress.stackexchange.com/a/1755...
208,873
<p>I am going to install and use AWS SDK for PHP to facilitate uploads/list objects directly from the front-end of my WordPress instance to S3. What is the best practice to do that ?</p> <p>P.S: I don't want to use plugins</p>
[ { "answer_id": 208833, "author": "pwbred", "author_id": 6154, "author_profile": "https://wordpress.stackexchange.com/users/6154", "pm_score": 1, "selected": false, "text": "<p>You need to look closer at query_posts and order your posts by the title, as it says on the <a href=\"https://co...
2015/11/16
[ "https://wordpress.stackexchange.com/questions/208873", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/81228/" ]
I am going to install and use AWS SDK for PHP to facilitate uploads/list objects directly from the front-end of my WordPress instance to S3. What is the best practice to do that ? P.S: I don't want to use plugins
As I have stated, never ever use `query_posts`. The page you have linked to in the codex is worth nothing and completely wrong. For extra info on why not to use `query_posts`, check [my answer here](https://wordpress.stackexchange.com/a/191934/31545) and the answer by [@Rarst](https://wordpress.stackexchange.com/a/1755...
208,884
<p>I have a custom Post type called product which has a Methabox with a Custom Field Called <code>Price</code> I entered <code>$</code> for some of the products and I need to remove them from the WP table. Now can you please let me know how I can do that? I mean I need to know which table is storing the data from Metab...
[ { "answer_id": 208885, "author": "Mateusz Marchel", "author_id": 83704, "author_profile": "https://wordpress.stackexchange.com/users/83704", "pm_score": 3, "selected": true, "text": "<p>In case you use native custom fields, you should look for them in wp_postmeta table (your table prefix...
2015/11/17
[ "https://wordpress.stackexchange.com/questions/208884", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31793/" ]
I have a custom Post type called product which has a Methabox with a Custom Field Called `Price` I entered `$` for some of the products and I need to remove them from the WP table. Now can you please let me know how I can do that? I mean I need to know which table is storing the data from Metaboxes? **Update** ``` ad...
In case you use native custom fields, you should look for them in wp\_postmeta table (your table prefix can be different than 'wp').
208,893
<p>I'm trying to change the menu in a primary and a secondary menu depending on the page which is visited.</p> <p>My primary menu is in the top of the page, and it looks like this:</p> <hr> <p>Index | About | Contact</p> <hr> <p>And my second menu is a dropdown menu, under the header, and it looks like this:</p> ...
[ { "answer_id": 208901, "author": "Omar", "author_id": 83743, "author_profile": "https://wordpress.stackexchange.com/users/83743", "pm_score": -1, "selected": false, "text": "<p>You have to create two menus and call them with a conditional in <code>header.php</code> file, like this: </p>\...
2015/11/17
[ "https://wordpress.stackexchange.com/questions/208893", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83740/" ]
I'm trying to change the menu in a primary and a secondary menu depending on the page which is visited. My primary menu is in the top of the page, and it looks like this: --- Index | About | Contact --- And my second menu is a dropdown menu, under the header, and it looks like this: --- Write New | Help | Profil...
You most probably used the theme location part wrongly. Here is an example of how it should be done Follow the comments in code for explanation :-) ``` add_filter( 'wp_nav_menu_args', function ( $args ) { if ( is_page( 2 ) //Only target page 2 && $args['theme_location'] === 'primary' ) { // Check an...
208,896
<p>I have a custom post type to list countries but I am not sure how to create them with this permalink structure:</p> <ul> <li>Country archive: <code>/map</code></li> <li>Country single: <code>/map/country/england</code></li> </ul> <p>How can I achieve this? Heres my country post code: </p> <pre><code>function coun...
[ { "answer_id": 208899, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 2, "selected": false, "text": "<p>You just want a hierarchical post type. Change <code>'hierarchical' =&gt; false,</code> to <code>'h...
2015/11/17
[ "https://wordpress.stackexchange.com/questions/208896", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40814/" ]
I have a custom post type to list countries but I am not sure how to create them with this permalink structure: * Country archive: `/map` * Country single: `/map/country/england` How can I achieve this? Heres my country post code: ``` function countries() { $labels = array( 'name' => _...
You just want a hierarchical post type. Change `'hierarchical' => false,` to `'hierarchical' => true,` and nest your posts appropriately
208,979
<p>I am developing a swear filter plugin for my blog. It is supposed to deny submissions containing any words in a text file called <code>swears.txt</code>. Here is the code I am using for the comment form on single post page:</p> <pre><code>&lt;?php if (isset($_POST['submit'])) { echo 'Submitted'; // for debuggin...
[ { "answer_id": 208983, "author": "Mateusz Hajdziony", "author_id": 15865, "author_profile": "https://wordpress.stackexchange.com/users/15865", "pm_score": 2, "selected": true, "text": "<p>This might not directly answer your question (because I haven't even thought about why the <code>$_P...
2015/11/17
[ "https://wordpress.stackexchange.com/questions/208979", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83779/" ]
I am developing a swear filter plugin for my blog. It is supposed to deny submissions containing any words in a text file called `swears.txt`. Here is the code I am using for the comment form on single post page: ``` <?php if (isset($_POST['submit'])) { echo 'Submitted'; // for debugging purposes $swearsFile =...
This might not directly answer your question (because I haven't even thought about why the `$_POST['submit']` would be ignored or if it is even correct), but you should use filters/actions whenever possible. The correct filter for filtering comment text is [`pre_comment_content`](https://developer.wordpress.org/refere...
209,016
<p>I am developing a website where I have modified the comment form to have review rating capabilities. I ask them to rate them on food, service and location. For each of those option there is “bad”(1),”okay”(2),”Good”(3). I store each in a custom comment field like the following “review_service”=1 &amp; “review_food”=...
[ { "answer_id": 208985, "author": "aifrim", "author_id": 58040, "author_profile": "https://wordpress.stackexchange.com/users/58040", "pm_score": 1, "selected": false, "text": "<p>Whatever the <code>action/filter</code> you <strong>hooked</strong> your code into they <em>(the callbacks)</e...
2015/11/17
[ "https://wordpress.stackexchange.com/questions/209016", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/28123/" ]
I am developing a website where I have modified the comment form to have review rating capabilities. I ask them to rate them on food, service and location. For each of those option there is “bad”(1),”okay”(2),”Good”(3). I store each in a custom comment field like the following “review\_service”=1 & “review\_food”=3. R...
Actions and filters are resolved in a linear fashion when processing the request. They do not run asynchronously. If you have some heavy processing that runs during every request (i.e. you use action and filter hooks that run during every page load for every user, like `template_redirect`, `init` or whatever usual hook...
209,046
<p>I use the below code to delete custom posts with status 'expired' (thanks to <a href="https://stackoverflow.com/q/27386129/1354580">Jamie Keefer</a>). Posts are set as 'expired' by a 3rd party plugin. Users have only a frontend access to their posts (adverts).</p> <p>My question is: <strong>how to delete them after...
[ { "answer_id": 209080, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": false, "text": "<h2>The native trash bin</h2>\n\n<p>It sounds like you're implementing your own version of the WordPress <strong...
2015/11/18
[ "https://wordpress.stackexchange.com/questions/209046", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/25187/" ]
I use the below code to delete custom posts with status 'expired' (thanks to [Jamie Keefer](https://stackoverflow.com/q/27386129/1354580)). Posts are set as 'expired' by a 3rd party plugin. Users have only a frontend access to their posts (adverts). My question is: **how to delete them after a number of days after the...
WP Cron jobs are not reliable as it needs someone to visit the site at the time the event should fire. If you need precise timing, you should use server cron jobs. Anyways, lets look at your code and what is wrong and we can fix it * `wp` is a better hook to use to hook your scheduled event, this is the earliest tha...
209,059
<p>I'm on ubuntu vps running nginx</p> <p>Running w3 total cache on wordpress.</p> <p>Everything works fine except for when i enable "rewrite url structure", and it breaks, 404 probably to the minified files.</p> <p>How to proceed?</p> <p>Am i missing some package on my vps? what should I install?</p> <p>Permalink...
[ { "answer_id": 209067, "author": "riteshsanap", "author_id": 55324, "author_profile": "https://wordpress.stackexchange.com/users/55324", "pm_score": 1, "selected": false, "text": "<p>W3 Total cache generates a <code>nginx.conf</code> file in the root of your blog.</p>\n\n<p>you need to i...
2015/11/18
[ "https://wordpress.stackexchange.com/questions/209059", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57389/" ]
I'm on ubuntu vps running nginx Running w3 total cache on wordpress. Everything works fine except for when i enable "rewrite url structure", and it breaks, 404 probably to the minified files. How to proceed? Am i missing some package on my vps? what should I install? Permalink for wordpress work fine though **Not...
W3 Total cache generates a `nginx.conf` file in the root of your blog. you need to include that file in your nginx configuration file, for W3 Total cache to work properly. For example if your file is in the `/etc/nginx/sites-available/MyWordPress` then edit that file to include your blogs `nginx.conf` generated by W...
209,060
<p>I have this code:</p> <pre><code>Search: &lt;input type="text" id="fname" onkeyup="myfunction()"&gt; &lt;a id="sear" href="" target="_blank"&gt;Search&lt;/a&gt; &lt;script&gt; function myFunction() { var x = document.getElementById("fname").value; var url = "https://www.google.co.in/search?q=all+"+x+"&amp;biw=1366...
[ { "answer_id": 209067, "author": "riteshsanap", "author_id": 55324, "author_profile": "https://wordpress.stackexchange.com/users/55324", "pm_score": 1, "selected": false, "text": "<p>W3 Total cache generates a <code>nginx.conf</code> file in the root of your blog.</p>\n\n<p>you need to i...
2015/11/18
[ "https://wordpress.stackexchange.com/questions/209060", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83782/" ]
I have this code: ``` Search: <input type="text" id="fname" onkeyup="myfunction()"> <a id="sear" href="" target="_blank">Search</a> <script> function myFunction() { var x = document.getElementById("fname").value; var url = "https://www.google.co.in/search?q=all+"+x+"&biw=1366&bih=643&source=lnms&tbm=isch"; document.g...
W3 Total cache generates a `nginx.conf` file in the root of your blog. you need to include that file in your nginx configuration file, for W3 Total cache to work properly. For example if your file is in the `/etc/nginx/sites-available/MyWordPress` then edit that file to include your blogs `nginx.conf` generated by W...
209,069
<p>I have this code:</p> <pre><code>Search: &lt;input type="text" id="fname" onkeyup="myfunction()"&gt; &lt;a id="sear" href="" target="_blank"&gt;Search&lt;/a&gt; &lt;script&gt; function myFunction() { var x = document.getElementById("fname").value; var url = "https://www.google.co.in/search?q=all+"+x+"&amp;biw=1366...
[ { "answer_id": 209075, "author": "daniyalahmad", "author_id": 69626, "author_profile": "https://wordpress.stackexchange.com/users/69626", "pm_score": 0, "selected": false, "text": "<p>There is issue in your JS code and the html that you are not calling your JS function. </p>\n\n<p>Try th...
2015/11/18
[ "https://wordpress.stackexchange.com/questions/209069", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83782/" ]
I have this code: ``` Search: <input type="text" id="fname" onkeyup="myfunction()"> <a id="sear" href="" target="_blank">Search</a> <script> function myFunction() { var x = document.getElementById("fname").value; var url = "https://www.google.co.in/search?q=all+"+x+"&biw=1366&bih=643&source=lnms&tbm=isch"; document.g...
You have a typo in `onkeyup="myfunction()"`. Your function is named myFunction, not myfunction (function names are case sensitive).
209,089
<p>I want to show 8 recent products from multiple authors on the frontpage. Need to show 1 recent product per author.</p> <p>Currently i'm using basic wp query to show recent 8 products. </p> <pre><code>$args = array ( 'post_type' =&gt; array( 'product' ), 'posts_per_page' =&gt; '8', 'order' ...
[ { "answer_id": 209092, "author": "s_ha_dum", "author_id": 21376, "author_profile": "https://wordpress.stackexchange.com/users/21376", "pm_score": 4, "selected": true, "text": "<p>I believe that you can achieve this effect by grouping the query by author ID, which will require a filter(<a...
2015/11/18
[ "https://wordpress.stackexchange.com/questions/209089", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/77725/" ]
I want to show 8 recent products from multiple authors on the frontpage. Need to show 1 recent product per author. Currently i'm using basic wp query to show recent 8 products. ``` $args = array ( 'post_type' => array( 'product' ), 'posts_per_page' => '8', 'order' => 'DESC', 'or...
I believe that you can achieve this effect by grouping the query by author ID, which will require a filter([mostly cribbed from the Codex](https://codex.wordpress.org/Plugin_API/Filter_Reference/posts_groupby)): ``` function my_posts_groupby($groupby) { global $wpdb; $groupby = "{$wpdb->posts}.post_author"; ...
209,105
<p>I have created a custom route in WP API (v2 beta 4) to set a site option. I'm using AngularJS to make the API call, and for some reason, I'm not able to access the data sent within the request. Here is what I have so far:</p> <pre><code>gvl.service('gvlOptionService', ['$http', function($http) { this.updateO...
[ { "answer_id": 212119, "author": "jgraup", "author_id": 84219, "author_profile": "https://wordpress.stackexchange.com/users/84219", "pm_score": 3, "selected": false, "text": "<p>In a <a href=\"https://wordpress.stackexchange.com/questions/210597/query-wp-rest-api-v2-by-multiple-meta-keys...
2015/11/18
[ "https://wordpress.stackexchange.com/questions/209105", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83856/" ]
I have created a custom route in WP API (v2 beta 4) to set a site option. I'm using AngularJS to make the API call, and for some reason, I'm not able to access the data sent within the request. Here is what I have so far: ``` gvl.service('gvlOptionService', ['$http', function($http) { this.updateOption = function...
In a [previous answer](https://wordpress.stackexchange.com/questions/210597/query-wp-rest-api-v2-by-multiple-meta-keys/212113#212113) is was able to access the data in a [custom endpoint](http://v2.wp-api.org/extending/adding/) using ``` $parameters = $request->get_query_params(); ``` Check the query params for `op...
209,109
<p>I'm trying to update a custom field after a post thumbnail (Featured Image) is either added or removed from a post. The aim of this is to keep track of whether a featured image has been added or removed in order to do a synchronised export of only the updated 'dirty' posts for use in an external service.</p> <p>I'v...
[ { "answer_id": 209967, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": true, "text": "<p>I think you want to use the <code>added_post_meta</code> hook instead of <code>updated_post_meta</code> becaus...
2015/11/18
[ "https://wordpress.stackexchange.com/questions/209109", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/184/" ]
I'm trying to update a custom field after a post thumbnail (Featured Image) is either added or removed from a post. The aim of this is to keep track of whether a featured image has been added or removed in order to do a synchronised export of only the updated 'dirty' posts for use in an external service. I've looked t...
I think you want to use the `added_post_meta` hook instead of `updated_post_meta` because you're not updating the meta here, only adding it. At least in the case of the `_thumbnail_id`, where we must delete it before adding it again (no update) through the admin UI. Investigating this further we see that this part of ...
209,128
<p>Can you please let me know how I can add a class to an image getting from Post Content? I have a page called <code>promotion</code> and it only contains an image which I uploaded through <code>Add Media</code> now in page I have </p> <pre><code>&lt;div class="container"&gt; &lt;?php if ( have_posts() ) : ?&gt; ...
[ { "answer_id": 209967, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 3, "selected": true, "text": "<p>I think you want to use the <code>added_post_meta</code> hook instead of <code>updated_post_meta</code> becaus...
2015/11/18
[ "https://wordpress.stackexchange.com/questions/209128", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31793/" ]
Can you please let me know how I can add a class to an image getting from Post Content? I have a page called `promotion` and it only contains an image which I uploaded through `Add Media` now in page I have ``` <div class="container"> <?php if ( have_posts() ) : ?> <?php while ( have_posts() ) : the_post(); ?> ...
I think you want to use the `added_post_meta` hook instead of `updated_post_meta` because you're not updating the meta here, only adding it. At least in the case of the `_thumbnail_id`, where we must delete it before adding it again (no update) through the admin UI. Investigating this further we see that this part of ...
209,183
<p>I'm using a custom meta field, to specify which post will appear as a featured one in the front page.</p> <p>This meta field is a true/false value, declared through ACF.</p> <p>I want this condition to only be applied to one post, i.e. when the user declares a post as "featured", and saves it, all the other ones (...
[ { "answer_id": 209187, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": false, "text": "<blockquote>\n <p>I want this condition to only be applied to one post, i.e. when the\n user declares a post a...
2015/11/19
[ "https://wordpress.stackexchange.com/questions/209183", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/39150/" ]
I'm using a custom meta field, to specify which post will appear as a featured one in the front page. This meta field is a true/false value, declared through ACF. I want this condition to only be applied to one post, i.e. when the user declares a post as "featured", and saves it, all the other ones (theoretically onl...
> > I want this condition to only be applied to one post, i.e. when the > user declares a post as "featured", and saves it, all the other ones > (theoretically only the last one) that have this meta value checked, > should be turned "off". > > > You might then try to save the one and only featured post ID as an...
209,201
<p>djeddiedavid.info</p> <p>this is my website i want to remove a date that show on wordpress posts anyone help me ?</p> <p><a href="https://i.stack.imgur.com/5Rhn7.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5Rhn7.jpg" alt="enter image description here"></a></p> <p>date that show on the botto...
[ { "answer_id": 209203, "author": "Tomme", "author_id": 83919, "author_profile": "https://wordpress.stackexchange.com/users/83919", "pm_score": 0, "selected": false, "text": "<p>Based of the theme Twenty Fifteen and other popular ones, simply adding <code>.entry-date { display: none; }</c...
2015/11/19
[ "https://wordpress.stackexchange.com/questions/209201", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/79858/" ]
djeddiedavid.info this is my website i want to remove a date that show on wordpress posts anyone help me ? [![enter image description here](https://i.stack.imgur.com/5Rhn7.jpg)](https://i.stack.imgur.com/5Rhn7.jpg) date that show on the bottom of DJ upcoming event
Try adding this to your CSS: ``` .latest-post h4 + p { display: none; } ```
209,224
<pre><code>function the_alt_title($title= '') { $page = get_page_by_title($title); if ($p = get_post_meta($page-&gt;ID, "_x_entry_alternate_index_title", true)) { $title = $p; } return $title; } add_filter('the_title', 'the_alt_title', 10, 1); </code></pre> <p>My theme uses something called <c...
[ { "answer_id": 209203, "author": "Tomme", "author_id": 83919, "author_profile": "https://wordpress.stackexchange.com/users/83919", "pm_score": 0, "selected": false, "text": "<p>Based of the theme Twenty Fifteen and other popular ones, simply adding <code>.entry-date { display: none; }</c...
2015/11/19
[ "https://wordpress.stackexchange.com/questions/209224", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40727/" ]
``` function the_alt_title($title= '') { $page = get_page_by_title($title); if ($p = get_post_meta($page->ID, "_x_entry_alternate_index_title", true)) { $title = $p; } return $title; } add_filter('the_title', 'the_alt_title', 10, 1); ``` My theme uses something called `alternate index title` ...
Try adding this to your CSS: ``` .latest-post h4 + p { display: none; } ```
209,246
<p>I'm very new to WordPress. I've read a common problem beginners make is installing in the wrong directory. Could someone verify mine is installed correctly? I'd like to use Storefront theme with Boutique child theme. <br/></p> <pre><code> Host1/mydomain/public_html/wp Host1/mydomain/public_html/wp-admin ...
[ { "answer_id": 209203, "author": "Tomme", "author_id": 83919, "author_profile": "https://wordpress.stackexchange.com/users/83919", "pm_score": 0, "selected": false, "text": "<p>Based of the theme Twenty Fifteen and other popular ones, simply adding <code>.entry-date { display: none; }</c...
2015/11/19
[ "https://wordpress.stackexchange.com/questions/209246", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83935/" ]
I'm very new to WordPress. I've read a common problem beginners make is installing in the wrong directory. Could someone verify mine is installed correctly? I'd like to use Storefront theme with Boutique child theme. ``` Host1/mydomain/public_html/wp Host1/mydomain/public_html/wp-admin Host1/m...
Try adding this to your CSS: ``` .latest-post h4 + p { display: none; } ```
209,256
<p>I was customizing theme for some body, basically i just added a taxonomy for the custom post type client which was allready there. There were already 6 posts , I added like 30 more posts , set featured image ,page attributes title , selcted taxonomy term etc.</p> <p>But suddenly now i am unable to add featured imag...
[ { "answer_id": 209279, "author": "Vig", "author_id": 83950, "author_profile": "https://wordpress.stackexchange.com/users/83950", "pm_score": 1, "selected": false, "text": "<p>It looks like there's something wrong with the images or the media path WordPress is using to search for the file...
2015/11/19
[ "https://wordpress.stackexchange.com/questions/209256", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/55034/" ]
I was customizing theme for some body, basically i just added a taxonomy for the custom post type client which was allready there. There were already 6 posts , I added like 30 more posts , set featured image ,page attributes title , selcted taxonomy term etc. But suddenly now i am unable to add featured image for the ...
Try checking your Browsers Javascript console, Media Library in WordPress is heavily depended on javascript's such as jQuery. also if your Javascript is broken due to concatenation, then add the below line in your `wp-config.php` file. ``` define( 'CONCATENATE_SCRIPTS', false ); ``` Or you can even try re-installi...
209,275
<p>If I pass in <code>'style' =&gt; 'none'</code> as an argument to <code>wp_list_categories</code>, the <code>&lt;li&gt;</code> tags are removed. That's great, but <code>&lt;br&gt;</code> tags are injected. How can I remove them?</p>
[ { "answer_id": 209277, "author": "James Jones", "author_id": 58884, "author_profile": "https://wordpress.stackexchange.com/users/58884", "pm_score": 1, "selected": false, "text": "<p>Try something like this:</p>\n\n<pre><code>$args = array( \n 'echo' =&gt; 0,\n // your other parame...
2015/11/20
[ "https://wordpress.stackexchange.com/questions/209275", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51378/" ]
If I pass in `'style' => 'none'` as an argument to `wp_list_categories`, the `<li>` tags are removed. That's great, but `<br>` tags are injected. How can I remove them?
The new `separator` attribute of `wp_list_categories()` ------------------------------------------------------- I think you are looking for the new `separator` attribute, that will be [introduced here in WordPress 4.4](https://github.com/WordPress/WordPress/blob/1579e45d4199a7fe8f7bae0e49f81ba483bdf6ab/wp-includes/cat...
209,283
<p>I created a custom post type <code>tickets</code>, than I added few tickets in it. But with the following code, I tried to show list of tickets submitted by the current user and its not working for me. </p> <pre><code>global $post, $paged, $current_user; get_currentuserinfo(); if(empty($paged)) $paged = 1; $ar...
[ { "answer_id": 209284, "author": "Mr Rethman", "author_id": 27393, "author_profile": "https://wordpress.stackexchange.com/users/27393", "pm_score": 0, "selected": false, "text": "<p>Hard to say without seeing the code. But ill give it a try.\n1. ) If your not seeing any results of your p...
2015/11/20
[ "https://wordpress.stackexchange.com/questions/209283", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/43308/" ]
I created a custom post type `tickets`, than I added few tickets in it. But with the following code, I tried to show list of tickets submitted by the current user and its not working for me. ``` global $post, $paged, $current_user; get_currentuserinfo(); if(empty($paged)) $paged = 1; $args = array( ...
As of @cybmeta word's, I answered my question here. Thank you for all of your effort. In future, if someone comes to read this article, just remember, default arguments also affecting your results. So my final working code it. ``` global $post, $paged, $current_user; get_currentuserinfo(); if(empty($paged)) $paged ...
209,338
<p>I have a page on my wordpresss with url <code>/sca</code>. I want all traffic from <code>/sca/project_0</code> to direct to <code>/sca?urn=project_0</code>. I added a rule to my <code>.htaccess</code> file but it is not working. I don't think this a problem with mod_rewrite as permalinks are working. Here is my <cod...
[ { "answer_id": 209342, "author": "Jeff Mattson", "author_id": 93714, "author_profile": "https://wordpress.stackexchange.com/users/93714", "pm_score": 0, "selected": false, "text": "<p>Try:</p>\n\n<pre><code> RewriteRule ^sca/([^/]*)$ sca\\?urn=$1 \n</code></pre>\n" }, { "answer_i...
2015/11/20
[ "https://wordpress.stackexchange.com/questions/209338", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12000/" ]
I have a page on my wordpresss with url `/sca`. I want all traffic from `/sca/project_0` to direct to `/sca?urn=project_0`. I added a rule to my `.htaccess` file but it is not working. I don't think this a problem with mod\_rewrite as permalinks are working. Here is my `.htaccess` file: ``` # BEGIN WordPress <IfModul...
If this address already gets traffic (from inbound links etc.) why don't you try a good old fashioned redirect like this: ``` Redirect 301 /sca/project_0 http://www.yourdomain.com/sca?urn=project_0 # BEGIN WordPress <IfModule mod_rewrite.c> RewriteEngine On RewriteBase / RewriteRule ^index\.php$ - [L] RewriteCond %{R...
209,348
<p>I am building a child theme for my personal use. Not very familiar with php, can only do basic things based on logic. I need to exclude one tag from being displayed on the tag list on a single post. Preferably so nothing is displayed at all when this tag is the only tag assigned to the post (I mean, no "Tags" title,...
[ { "answer_id": 209349, "author": "jas", "author_id": 80247, "author_profile": "https://wordpress.stackexchange.com/users/80247", "pm_score": 2, "selected": true, "text": "<pre><code>$tags = get_the_tags( $post-&gt;ID );\n$separator = ' ';\n$output = '';\nif($tags){\necho '&lt;div class=\...
2015/11/20
[ "https://wordpress.stackexchange.com/questions/209348", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/83992/" ]
I am building a child theme for my personal use. Not very familiar with php, can only do basic things based on logic. I need to exclude one tag from being displayed on the tag list on a single post. Preferably so nothing is displayed at all when this tag is the only tag assigned to the post (I mean, no "Tags" title, no...
``` $tags = get_the_tags( $post->ID ); $separator = ' '; $output = ''; if($tags){ echo '<div class="entry-tags">'; echo "<p><span>" . __('Tags', 'tracks') . "</span>"; foreach($tags as $tag) { // dpm($tag) here by uncomment you can check tag slug which you want to exclude if($tag->sl...