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
242,302
<p>I want to make post titles mandatory in the post editor without Javascript or PHP validation, I'd like something really simple like adding the HTML "required" attribute to the post title input element.</p> <p>I see there is "edit_form_top" and "edit_form_after_title" but those hook juste before and just after the t...
[ { "answer_id": 242345, "author": "brianjohnhanna", "author_id": 65403, "author_profile": "https://wordpress.stackexchange.com/users/65403", "pm_score": 2, "selected": false, "text": "<p>There is <a href=\"https://core.trac.wordpress.org/browser/tags/4.6/src/wp-admin/edit-form-advanced.ph...
2016/10/11
[ "https://wordpress.stackexchange.com/questions/242302", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/1381/" ]
I want to make post titles mandatory in the post editor without Javascript or PHP validation, I'd like something really simple like adding the HTML "required" attribute to the post title input element. I see there is "edit\_form\_top" and "edit\_form\_after\_title" but those hook juste before and just after the title ...
There is [no hook](https://core.trac.wordpress.org/browser/tags/4.6/src/wp-admin/edit-form-advanced.php#L541) to change the HTML of the input (only the `enter_title_here` filter to change the placeholder text). You could pull this off easily with jQuery, though. Try this in your functionality plugin or theme's `functio...
242,331
<p>I hope the title makes sense. I currently want to hide the default WYSIWYG editor on some of the pages but display it on others. </p> <p>Is there a filter or a hook for the functions file? </p>
[ { "answer_id": 242342, "author": "Patrick S", "author_id": 30753, "author_profile": "https://wordpress.stackexchange.com/users/30753", "pm_score": 0, "selected": false, "text": "<pre><code>remove_post_type_support( 'page', 'editor' );\n</code></pre>\n\n<p>You can use it in several ways, ...
2016/10/11
[ "https://wordpress.stackexchange.com/questions/242331", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101285/" ]
I hope the title makes sense. I currently want to hide the default WYSIWYG editor on some of the pages but display it on others. Is there a filter or a hook for the functions file?
I hope I understood your question right. The following code will remove the editor from the pages using particular templates: ``` <?php function wpse242371_remove_editor_from_some_pages() { global $post; if( ! is_a($post, 'WP_Post') ) { return; } /* basename is used for templates that are i...
242,360
<p>I am developing a WordPress theme and there I used a custom post type <code>insurance_all</code> and a custom taxonomy <code>insurnce_all_categories</code> for the post type. But when I try to add a category the AJAX is not working but if I refresh the page the category is loaded. When I want to delete the category ...
[ { "answer_id": 242365, "author": "stims", "author_id": 104727, "author_profile": "https://wordpress.stackexchange.com/users/104727", "pm_score": 0, "selected": false, "text": "<p>Your taxonomy registration in your example is showing this:</p>\n\n<pre><code>function insurance_all_category...
2016/10/12
[ "https://wordpress.stackexchange.com/questions/242360", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/84311/" ]
I am developing a WordPress theme and there I used a custom post type `insurance_all` and a custom taxonomy `insurnce_all_categories` for the post type. But when I try to add a category the AJAX is not working but if I refresh the page the category is loaded. When I want to delete the category `An unidentified error ha...
Your taxonomy registration in your example is showing this: ``` function insurance_all_category(){ $labels = array( 'name' =>_x( 'Insurance all category', 'taxonomy general name' ), 'singular_name' => _x( 'Category', 'taxonomy singular name' ), 'search_items' => __( 'Search Category' ...
242,391
<p>I've about 12 records and that means I should have 4 pages. My best attempt so far at getting pagination to work is this, and I'd really appreciate if someone could tell me where exactly am I going wrong?</p> <pre><code> &lt;div id="main-content"&gt; &lt;div class="container"&gt; &lt;?php ...
[ { "answer_id": 242373, "author": "cybmeta", "author_id": 37428, "author_profile": "https://wordpress.stackexchange.com/users/37428", "pm_score": 4, "selected": true, "text": "<p>The alternative to <a href=\"https://developer.wordpress.org/reference/hooks/wp_head/\" rel=\"noreferrer\"><co...
2016/10/12
[ "https://wordpress.stackexchange.com/questions/242391", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/21100/" ]
I've about 12 records and that means I should have 4 pages. My best attempt so far at getting pagination to work is this, and I'd really appreciate if someone could tell me where exactly am I going wrong? ``` <div id="main-content"> <div class="container"> <?php $paged = ( get_query_var('...
The alternative to [`wp_head`](https://developer.wordpress.org/reference/hooks/wp_head/) action in admin area is [`admin_head`](https://developer.wordpress.org/reference/hooks/admin_head/). But, if your CSS depends on another stylesheet, you should use [`wp_add_inline_style()`](https://codex.wordpress.org/Function_Refe...
242,423
<p>I have a strange request I thought would be simple. I need to break the Wordpress pagination. Specifically, I need to make the <code>/page/2/</code>, <code>/page/3/</code>, and so on, links disabled.</p> <p>I tried:</p> <pre><code>RewriteRule ^page/[0-9] http://www.mysite[dot]com/404.php [R] </code></pre> <p>But ...
[ { "answer_id": 242429, "author": "Nick Barth", "author_id": 101651, "author_profile": "https://wordpress.stackexchange.com/users/101651", "pm_score": 0, "selected": false, "text": "<p>That rule looks OK; the problem might be where you put it. Order matters in .htaccess, so be sure you're...
2016/10/12
[ "https://wordpress.stackexchange.com/questions/242423", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88384/" ]
I have a strange request I thought would be simple. I need to break the Wordpress pagination. Specifically, I need to make the `/page/2/`, `/page/3/`, and so on, links disabled. I tried: ``` RewriteRule ^page/[0-9] http://www.mysite[dot]com/404.php [R] ``` But that is a no go... Anyone? Thanks
Thanks Nick! I thought that would work, and I placed it right after "RewriteEngine On" so it came first. I did find a working solution for handling it though (after 2 hrs): ``` RewriteRule ^page/(.*)$ /$1 [G] ``` In case anyone else needs to do the same ...
242,428
<p>I am new to wp dev and trying to figure out how to replace or change the query woocommerce makes that shows all my products on any archive page, or page that shows my list of products, not sure what it is called but the page that shows the pic, name, price &amp; link to product page. I have multiple categories so i ...
[ { "answer_id": 242429, "author": "Nick Barth", "author_id": 101651, "author_profile": "https://wordpress.stackexchange.com/users/101651", "pm_score": 0, "selected": false, "text": "<p>That rule looks OK; the problem might be where you put it. Order matters in .htaccess, so be sure you're...
2016/10/12
[ "https://wordpress.stackexchange.com/questions/242428", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104167/" ]
I am new to wp dev and trying to figure out how to replace or change the query woocommerce makes that shows all my products on any archive page, or page that shows my list of products, not sure what it is called but the page that shows the pic, name, price & link to product page. I have multiple categories so i guess i...
Thanks Nick! I thought that would work, and I placed it right after "RewriteEngine On" so it came first. I did find a working solution for handling it though (after 2 hrs): ``` RewriteRule ^page/(.*)$ /$1 [G] ``` In case anyone else needs to do the same ...
242,462
<p>I have a custom meta field that I want to display as my excerpt. I use a filter that does this for me:</p> <pre><code>add_filter( 'get_the_excerpt', function($output){ $output=get_post_meta(get_the_ID(), 'my_meta_field', true); return $output; }); </code></pre> <p>Now whenever I use <code>get_the_excerpt()</co...
[ { "answer_id": 242465, "author": "Jonny Perl", "author_id": 40765, "author_profile": "https://wordpress.stackexchange.com/users/40765", "pm_score": -1, "selected": false, "text": "<p>Even if you're not in the loop, if you're on within a post or page (or other post type) generated from Wo...
2016/10/12
[ "https://wordpress.stackexchange.com/questions/242462", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/10595/" ]
I have a custom meta field that I want to display as my excerpt. I use a filter that does this for me: ``` add_filter( 'get_the_excerpt', function($output){ $output=get_post_meta(get_the_ID(), 'my_meta_field', true); return $output; }); ``` Now whenever I use `get_the_excerpt()` or `the_excerpt()` inside of the ...
In spite of what the Codex says, since WP 4.5, where the addition of the post argument to the function get\_the\_excerpt was added, this filter takes two arguments. The second argument is the post object whose excerpt you are manipulating. So the function still works in the loop without an explicit post, we make the ...
242,464
<p>I am looking to add the option of adding an anchor to my page in the Menu's page.</p> <p>By default, the link has the <code>Navigation Label</code> with the link to the page, a <code>Remove</code> and a <code>Cancel</code> link. However, I need to add a page with a named anchor. So far, I've added all my links with...
[ { "answer_id": 242470, "author": "socki03", "author_id": 43511, "author_profile": "https://wordpress.stackexchange.com/users/43511", "pm_score": 3, "selected": true, "text": "<p>There's a specific filter for each nav item's attributes: <a href=\"https://codex.wordpress.org/Plugin_API/Fil...
2016/10/12
[ "https://wordpress.stackexchange.com/questions/242464", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/89512/" ]
I am looking to add the option of adding an anchor to my page in the Menu's page. By default, the link has the `Navigation Label` with the link to the page, a `Remove` and a `Cancel` link. However, I need to add a page with a named anchor. So far, I've added all my links with `Custom Links`, but I would prefer being a...
There's a specific filter for each nav item's attributes: [nav\_menu\_link\_attributes](https://codex.wordpress.org/Plugin_API/Filter_Reference/nav_menu_link_attributes). So, you can put in your functions.php file something like: ``` function mysite_add_anchor( $atts, $item, $args ) { $atts['href'] .= ( !empty( ...
242,473
<p>I'm trying to create a portfolio with WordPress using a Custom Post Type to display my projects. Each project I want to display on my static front page with a featured image as a thumbnail, and by clicking on a thumbnail would take me directly to the project.</p> <p>How do I post Custom Post Types to the static fr...
[ { "answer_id": 242475, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 3, "selected": false, "text": "<p><strong>Edit: This answer was written before I realised the OP has a static front page.</strong> ...
2016/10/12
[ "https://wordpress.stackexchange.com/questions/242473", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104792/" ]
I'm trying to create a portfolio with WordPress using a Custom Post Type to display my projects. Each project I want to display on my static front page with a featured image as a thumbnail, and by clicking on a thumbnail would take me directly to the project. How do I post Custom Post Types to the static front page? I...
So if you've registered a CPT called `wpse_242473_custom_post_type` you can use this to put 6 recent posts of that type onto your static front page (or anywhere). You can use a shortcode or a template tag and the function should work for both. It's a modification of some code I use in a lot of sites. Put it in your th...
242,493
<p>I am trying to get all categories which are having products but getting also the categories which are having no products. </p> <p>WordPress version 4.6.1</p> <pre><code>wp_dropdown_categories( array( 'class' =&gt; 'product-category-field', 'id' =&gt; 'product-category', 'name' =&...
[ { "answer_id": 242475, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 3, "selected": false, "text": "<p><strong>Edit: This answer was written before I realised the OP has a static front page.</strong> ...
2016/10/13
[ "https://wordpress.stackexchange.com/questions/242493", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/81273/" ]
I am trying to get all categories which are having products but getting also the categories which are having no products. WordPress version 4.6.1 ``` wp_dropdown_categories( array( 'class' => 'product-category-field', 'id' => 'product-category', 'name' => 'category', 'tax...
So if you've registered a CPT called `wpse_242473_custom_post_type` you can use this to put 6 recent posts of that type onto your static front page (or anywhere). You can use a shortcode or a template tag and the function should work for both. It's a modification of some code I use in a lot of sites. Put it in your th...
242,517
<p>On my site I hava two forms witch send email. The one whit no attachment needed is sent correnctly, but the other ony witch has an attachment does not get sent. I am using SMTP config whit Postman SMTP plugin.</p> <pre><code>move_uploaded_file($_FILES["cv"]["tmp_name"],WP_CONTENT_DIR .'/uploads/CV/'.basename($_FILE...
[ { "answer_id": 242475, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 3, "selected": false, "text": "<p><strong>Edit: This answer was written before I realised the OP has a static front page.</strong> ...
2016/10/13
[ "https://wordpress.stackexchange.com/questions/242517", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/99365/" ]
On my site I hava two forms witch send email. The one whit no attachment needed is sent correnctly, but the other ony witch has an attachment does not get sent. I am using SMTP config whit Postman SMTP plugin. ``` move_uploaded_file($_FILES["cv"]["tmp_name"],WP_CONTENT_DIR .'/uploads/CV/'.basename($_FILES['cv']['name'...
So if you've registered a CPT called `wpse_242473_custom_post_type` you can use this to put 6 recent posts of that type onto your static front page (or anywhere). You can use a shortcode or a template tag and the function should work for both. It's a modification of some code I use in a lot of sites. Put it in your th...
242,536
<p>I am currently trying to add a list of categories that a custom post is in (only have 3 categories). by using the code below, I have managed to output ALL categories into a list but what am I missing to filter just the categories that that post is in... Been stuck for days!</p> <p>Here is the link to better explain...
[ { "answer_id": 242538, "author": "socki03", "author_id": 43511, "author_profile": "https://wordpress.stackexchange.com/users/43511", "pm_score": 2, "selected": false, "text": "<p>It doesn't matter that you're trying to pull taxonomy from a CPT, you can use <a href=\"https://codex.wordpre...
2016/10/13
[ "https://wordpress.stackexchange.com/questions/242536", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104841/" ]
I am currently trying to add a list of categories that a custom post is in (only have 3 categories). by using the code below, I have managed to output ALL categories into a list but what am I missing to filter just the categories that that post is in... Been stuck for days! Here is the link to better explain - <http:/...
EDITS: ``` <div id="job-manager-job-dashboard"> <h3><?php _e( 'Job listings are shown in the table below.', 'wp-job-manager' ); ?></h3> <table class="job-manager-jobs"> <thead> <tr> <?php foreach ( $job_dashboard_columns as $key => $column ) : ?> ...
242,546
<p>My theme uses this code which I am trying to convert to a shortcode so I can use on custom templates:</p> <pre><code>&lt;div class="x-breadcrumb-wrap"&gt; &lt;div class="x-container max width"&gt; &lt;?php x_breadcrumbs(); ?&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>I know I have to ...
[ { "answer_id": 242547, "author": "Nabil Kadimi", "author_id": 17187, "author_profile": "https://wordpress.stackexchange.com/users/17187", "pm_score": 1, "selected": false, "text": "<p>This should do it, I used output buffering with <code>ob_start()</code> and <code>ob_get_clean</code>:</...
2016/10/13
[ "https://wordpress.stackexchange.com/questions/242546", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/40727/" ]
My theme uses this code which I am trying to convert to a shortcode so I can use on custom templates: ``` <div class="x-breadcrumb-wrap"> <div class="x-container max width"> <?php x_breadcrumbs(); ?> </div> </div> ``` I know I have to add a shortcode like this to my `functions.php` but can'...
This should do it, I used output buffering with `ob_start()` and `ob_get_clean`: ``` <?php /** * Breadcrumbs based on theme's functions * * @author Nabil Kadimi <nabil@kadimi.com> * @link http://wordpress.stackexchange.com/a/242547/17187 */ add_action( 'init', function() { add_shortcode( 'mycrumbs', func...
242,560
<p>I have a wordpress website hosted on GoDaddy.</p> <p>I am an advanced stripe user and have integrated stripe with many Ruby on Rails apps , along with stripe-webhook integration with the Rails. Also i am well versed in how web-hooks work. But recently i was made owner of a wordpress website hosted on GoDaddy and on...
[ { "answer_id": 243250, "author": "AmrataB", "author_id": 105254, "author_profile": "https://wordpress.stackexchange.com/users/105254", "pm_score": 4, "selected": true, "text": "<p>I recently had the same problem and pippins stripe integration plugin seemed to answer it but it had a lot o...
2016/10/13
[ "https://wordpress.stackexchange.com/questions/242560", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104856/" ]
I have a wordpress website hosted on GoDaddy. I am an advanced stripe user and have integrated stripe with many Ruby on Rails apps , along with stripe-webhook integration with the Rails. Also i am well versed in how web-hooks work. But recently i was made owner of a wordpress website hosted on GoDaddy and on that webs...
I recently had the same problem and pippins stripe integration plugin seemed to answer it but it had a lot of extra code I did not need so I removed it and made a concise version just for the webhook integration: [WPStripeWebhook](https://github.com/amratab/WPStripeWebhook). README is self explanatory. Basically make c...
242,564
<p>I want to get all users with their respective data. I already get all the users:</p> <pre><code>$users = array(); $users_query = new WP_User_Query( array( 'role' =&gt; 'subscriber', 'orderby' =&gt; 'user_registered', 'number' =&gt; 8, 'order' =&gt; 'DESC', 'fields' =&gt; array('ID', 'display_...
[ { "answer_id": 242575, "author": "stims", "author_id": 104727, "author_profile": "https://wordpress.stackexchange.com/users/104727", "pm_score": 2, "selected": false, "text": "<p>All the metadata should be there, you can access them with magic methods.</p>\n\n<p>If you have a metadatum c...
2016/10/13
[ "https://wordpress.stackexchange.com/questions/242564", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/38735/" ]
I want to get all users with their respective data. I already get all the users: ``` $users = array(); $users_query = new WP_User_Query( array( 'role' => 'subscriber', 'orderby' => 'user_registered', 'number' => 8, 'order' => 'DESC', 'fields' => array('ID', 'display_name') ) ); $results = $users...
All the metadata should be there, you can access them with magic methods. If you have a metadatum called with the key `shoes`, you can access it like this ``` $userObject->shoes ```
242,580
<p>I am trying to create a custom role in a wordpress multisite environment. This role is to have the same capabilities as an admin but also have the ability to commit unfiltered HTML like super admins. I have had success in creating the role and set unfiltered_html to true, but the text editor still strips Iframes and...
[ { "answer_id": 291464, "author": "MastaBaba", "author_id": 43252, "author_profile": "https://wordpress.stackexchange.com/users/43252", "pm_score": 1, "selected": false, "text": "<p>This had me baffled for a while as well. Not exactly a solution for your problem, but this should get you o...
2016/10/13
[ "https://wordpress.stackexchange.com/questions/242580", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104866/" ]
I am trying to create a custom role in a wordpress multisite environment. This role is to have the same capabilities as an admin but also have the ability to commit unfiltered HTML like super admins. I have had success in creating the role and set unfiltered\_html to true, but the text editor still strips Iframes and o...
This had me baffled for a while as well. Not exactly a solution for your problem, but this should get you on your way. ``` add_action( 'admin_init', 'my_kses_remove_filters' ); function my_kses_remove_filters() { $current_user = wp_get_current_user(); if ( my_user_has_role( 'administrator', $current_user ) ) ...
242,615
<p>I have a checkbox in the customizer which lets you choose to display content or not. I've got everything to work besides displaying the page content; it echoes the HTML tags but not the WordPress dynamic page date.</p> <pre><code>&lt;?php $servicescontent = get_theme_mod('services-page', 1); $mod = new WP_Query( a...
[ { "answer_id": 291464, "author": "MastaBaba", "author_id": 43252, "author_profile": "https://wordpress.stackexchange.com/users/43252", "pm_score": 1, "selected": false, "text": "<p>This had me baffled for a while as well. Not exactly a solution for your problem, but this should get you o...
2016/10/14
[ "https://wordpress.stackexchange.com/questions/242615", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104810/" ]
I have a checkbox in the customizer which lets you choose to display content or not. I've got everything to work besides displaying the page content; it echoes the HTML tags but not the WordPress dynamic page date. ``` <?php $servicescontent = get_theme_mod('services-page', 1); $mod = new WP_Query( array( 'page_id' =>...
This had me baffled for a while as well. Not exactly a solution for your problem, but this should get you on your way. ``` add_action( 'admin_init', 'my_kses_remove_filters' ); function my_kses_remove_filters() { $current_user = wp_get_current_user(); if ( my_user_has_role( 'administrator', $current_user ) ) ...
242,631
<p>I wonder, how can I create two separate login pages for two specific users?</p> <p>Say, for example: I have two users on my site. Admin and Viewer.</p> <p>On my site's frontend I want to create two different login pages. One login form for Admin only and one login form for Viewer only. I want them to be on a diffe...
[ { "answer_id": 242634, "author": "Cristian Stan", "author_id": 101642, "author_profile": "https://wordpress.stackexchange.com/users/101642", "pm_score": -1, "selected": false, "text": "<p>If you are trying to achieve a separate login form on a different page than the one for admins then ...
2016/10/14
[ "https://wordpress.stackexchange.com/questions/242631", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104902/" ]
I wonder, how can I create two separate login pages for two specific users? Say, for example: I have two users on my site. Admin and Viewer. On my site's frontend I want to create two different login pages. One login form for Admin only and one login form for Viewer only. I want them to be on a different url too. I...
On-topic answer: You can just put `<?php wp_login_form(); ?>` into any of your theme templates to render a login form on the front end of your site. Or make your own shortcode `[loginform]` by putting this into your theme's `functions.php`: ``` function wpse_242473_login_form() { return wp_login_form( 'echo' => ...
242,633
<p>I want to edit the edit-tags.php, particularly the post_tag page. I want to add some content as shown in the pic below.</p> <p><a href="https://i.stack.imgur.com/kfGmT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kfGmT.png" alt="enter image description here"></a></p> <p>I have found the way t...
[ { "answer_id": 242634, "author": "Cristian Stan", "author_id": 101642, "author_profile": "https://wordpress.stackexchange.com/users/101642", "pm_score": -1, "selected": false, "text": "<p>If you are trying to achieve a separate login form on a different page than the one for admins then ...
2016/10/14
[ "https://wordpress.stackexchange.com/questions/242633", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13291/" ]
I want to edit the edit-tags.php, particularly the post\_tag page. I want to add some content as shown in the pic below. [![enter image description here](https://i.stack.imgur.com/kfGmT.png)](https://i.stack.imgur.com/kfGmT.png) I have found the way to detect the page with the [get\_current\_screen](https://codex.wor...
On-topic answer: You can just put `<?php wp_login_form(); ?>` into any of your theme templates to render a login form on the front end of your site. Or make your own shortcode `[loginform]` by putting this into your theme's `functions.php`: ``` function wpse_242473_login_form() { return wp_login_form( 'echo' => ...
242,643
<p><a href="https://i.stack.imgur.com/L25ZN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L25ZN.png" alt="enter image description here"></a>I want to show the count of a particular category, that means how many posts does a particular category have?</p> <p>I want the number as same as in the pictu...
[ { "answer_id": 242650, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 1, "selected": false, "text": "<p>Just call <code>get_categories()</code>. You'll get back an array of term objects:</p>\n\n<pre><c...
2016/10/14
[ "https://wordpress.stackexchange.com/questions/242643", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104901/" ]
[![enter image description here](https://i.stack.imgur.com/L25ZN.png)](https://i.stack.imgur.com/L25ZN.png)I want to show the count of a particular category, that means how many posts does a particular category have? I want the number as same as in the picture, but they are echoing like: > > Bathroom Scales (1) > ...
Just call `get_categories()`. You'll get back an array of term objects: ``` array( [0] => WP_Term Object ( [term_id] => [name] => [slug] => [term_group] => [term_taxonomy_id] => [taxonomy] => [description] => [parent] => [count] => ...
242,652
<p>I'm making a limitation for image upload based on @brasofilo <a href="https://wordpress.stackexchange.com/a/73921/13291">excellent snippet</a>. In short, it limits user to only uploading image with minimum dimension.</p> <p>However I want to apply this only when user is uploading a featured image. I tried using <co...
[ { "answer_id": 242667, "author": "AddWeb Solution Pvt Ltd", "author_id": 73643, "author_profile": "https://wordpress.stackexchange.com/users/73643", "pm_score": -1, "selected": false, "text": "<p>Add below code to your current theme's functions.php file, and it will limit minimum image d...
2016/10/14
[ "https://wordpress.stackexchange.com/questions/242652", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/13291/" ]
I'm making a limitation for image upload based on @brasofilo [excellent snippet](https://wordpress.stackexchange.com/a/73921/13291). In short, it limits user to only uploading image with minimum dimension. However I want to apply this only when user is uploading a featured image. I tried using `$pagenow` as a conditio...
Determining if an attachment actually is a *featured image* is easy: ``` get_post_thumbnail_id( get_post() ); ``` which is a convenience function around ``` get_post_meta( get_post()->ID, '_thumbnail_id', true ); ``` It is a bit more complicated if you know nothing than the File name or Url. ``` add_filter( 'wp...
242,685
<p>I need to get query results after they have executed </p> <pre><code> add_filter('query', 'query_recorder_wrapper_wptc'); </code></pre> <p>I use <code>query</code> filter to get all queries before they executed, I also want after they executed. I exhausted of searching this.</p> <p>Is there any <code>hooks</co...
[ { "answer_id": 242687, "author": "stims", "author_id": 104727, "author_profile": "https://wordpress.stackexchange.com/users/104727", "pm_score": 1, "selected": false, "text": "<p>What you can do is use the <code>wp</code> action with the global variable <code>$wp_query</code>, like so:</...
2016/10/14
[ "https://wordpress.stackexchange.com/questions/242685", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/67717/" ]
I need to get query results after they have executed ``` add_filter('query', 'query_recorder_wrapper_wptc'); ``` I use `query` filter to get all queries before they executed, I also want after they executed. I exhausted of searching this. Is there any `hooks` or script for this? Thanks
Extending the `wpdb` class -------------------------- We can create the `db.php` file under `wp-content/` directory to override the `wpdb` class to our needs. I checked this site for such examples and found one by @MarkKaplun [here](https://wordpress.stackexchange.com/a/160819/26350). Here's an example how one can ...
242,686
<p>I am creating something which passes featured image URLs to a separate JavaScript file which uses <code>parallax.js</code> to create a parallax background for each entry for an archive page.</p> <p>This works fine when each post has an image.</p> <p>I have been working on having a default image where there is no f...
[ { "answer_id": 242689, "author": "stims", "author_id": 104727, "author_profile": "https://wordpress.stackexchange.com/users/104727", "pm_score": 2, "selected": true, "text": "<p>Instead of </p>\n\n<p><code>get_template_url()</code></p>\n\n<p>user</p>\n\n<p><code>get_template_directory_ur...
2016/10/14
[ "https://wordpress.stackexchange.com/questions/242686", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101227/" ]
I am creating something which passes featured image URLs to a separate JavaScript file which uses `parallax.js` to create a parallax background for each entry for an archive page. This works fine when each post has an image. I have been working on having a default image where there is no featured image but am having ...
Instead of `get_template_url()` user `get_template_directory_uri()` for parent theme and `get_stylesheet_directory_uri()` for child theme or parent theme if not child theme present NOTE: this will require a slash like so: ``` $image_link_url = get_template_directory_uri() . '/images/placeholder_bg.png'; ```
242,693
<p>I have solved the main query:</p> <p>For WordPress dashboard, I needed the list of all posts related to all post types in:</p> <pre><code>edit.php?post_type=product </code></pre> <p>Using the concept of: </p> <pre><code>edit.php?post_type=product&amp;showall=true </code></pre> <p>With function in backend <code>...
[ { "answer_id": 243222, "author": "T.Todua", "author_id": 33667, "author_profile": "https://wordpress.stackexchange.com/users/33667", "pm_score": 1, "selected": false, "text": "<p><code>Invalid Post Type</code> might be shown,whenever you have a mistake(type or etc..) in <code>'product', ...
2016/10/14
[ "https://wordpress.stackexchange.com/questions/242693", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/73730/" ]
I have solved the main query: For WordPress dashboard, I needed the list of all posts related to all post types in: ``` edit.php?post_type=product ``` Using the concept of: ``` edit.php?post_type=product&showall=true ``` With function in backend `function.php` ``` function show_all_posttypes( $query ) { if...
`Invalid Post Type` might be shown,whenever you have a mistake(type or etc..) in `'product', 'second_type_product', 'third_type_product'` . Ensure that you have correct words there.
242,716
<p>I'm running WordPress 4.6.1 and I am trying to learn how to filter custom post types by a category taxonomy process. This is very helpful as non-technical folks can easily filter custom post type posts by category in the admin.</p> <blockquote> <p>This is my setup...</p> </blockquote> <ol> <li><p>I'm building a...
[ { "answer_id": 242720, "author": "bdtheme", "author_id": 83330, "author_profile": "https://wordpress.stackexchange.com/users/83330", "pm_score": 0, "selected": false, "text": "<p>You can try with the following codes:</p>\n\n<pre><code>$terms = wp_get_post_terms( $post-&gt;ID, array('cate...
2016/10/14
[ "https://wordpress.stackexchange.com/questions/242716", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98671/" ]
I'm running WordPress 4.6.1 and I am trying to learn how to filter custom post types by a category taxonomy process. This is very helpful as non-technical folks can easily filter custom post type posts by category in the admin. > > This is my setup... > > > 1. I'm building a child theme off of tweentysixteen 2. I...
You are doing a little mistake in your `$pargs` [As per documentation](https://developer.wordpress.org/reference/classes/wp_query/) > > **Important Note:** tax\_query takes an array of tax query arguments arrays (it takes an array of arrays). Also you have "post\_per\_page" instead of "posts\_per\_page" > > > ``...
242,730
<p>To avoid collisions with other plugins, one should prefix all global functions, actions and plugins with a unique prefix, e.g.:</p> <pre><code>function xyz_function_name() { ... } </code></pre> <p>The question is, how do I verify that <code>xyz</code> is indeed unique? For instance, Yoast SEO uses <code>wpseo_</co...
[ { "answer_id": 243058, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 4, "selected": true, "text": "<p>You can use the <a href=\"https://github.com/markjaquith/WordPress-Plugin-Directory-Slurper\">WordPres Plugi...
2016/10/14
[ "https://wordpress.stackexchange.com/questions/242730", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/12248/" ]
To avoid collisions with other plugins, one should prefix all global functions, actions and plugins with a unique prefix, e.g.: ``` function xyz_function_name() { ... } ``` The question is, how do I verify that `xyz` is indeed unique? For instance, Yoast SEO uses `wpseo_` which I can imagine other SEO plugin could e...
You can use the [WordPres Plugin Directory Slurper](https://github.com/markjaquith/WordPress-Plugin-Directory-Slurper) shell script by Mark Jaquith to download the the most recent version of all plugins from the WordPress.org repo. Once the plugins have been downloaded, you can grep for the plugin/hook prefix you want ...
242,764
<p>I'm completely stuck and would very much appreciate some pointers/advise.</p> <p><strong>The problem</strong>: I want to create a search function that will let me filter Japanese onsen by their amenities, e.g. parking, sauna, bedrock bath, etc. which are stored as metadata in the post (a checklist).</p> <p>I have ...
[ { "answer_id": 243058, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 4, "selected": true, "text": "<p>You can use the <a href=\"https://github.com/markjaquith/WordPress-Plugin-Directory-Slurper\">WordPres Plugi...
2016/10/15
[ "https://wordpress.stackexchange.com/questions/242764", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/62598/" ]
I'm completely stuck and would very much appreciate some pointers/advise. **The problem**: I want to create a search function that will let me filter Japanese onsen by their amenities, e.g. parking, sauna, bedrock bath, etc. which are stored as metadata in the post (a checklist). I have registered these amenities as ...
You can use the [WordPres Plugin Directory Slurper](https://github.com/markjaquith/WordPress-Plugin-Directory-Slurper) shell script by Mark Jaquith to download the the most recent version of all plugins from the WordPress.org repo. Once the plugins have been downloaded, you can grep for the plugin/hook prefix you want ...
242,773
<p>I need to pass arrays to a function from multiple functions. I am using <code>apply_filters_ref_array()</code> for that. The problem is it only accepts the array passed from highest priority callbak. Here is the scenario: </p> <pre><code>//First Callbak function first_callback() { $html['abc'] = 'xyz'; r...
[ { "answer_id": 243058, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 4, "selected": true, "text": "<p>You can use the <a href=\"https://github.com/markjaquith/WordPress-Plugin-Directory-Slurper\">WordPres Plugi...
2016/10/15
[ "https://wordpress.stackexchange.com/questions/242773", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/26991/" ]
I need to pass arrays to a function from multiple functions. I am using `apply_filters_ref_array()` for that. The problem is it only accepts the array passed from highest priority callbak. Here is the scenario: ``` //First Callbak function first_callback() { $html['abc'] = 'xyz'; return $html; } add_filter...
You can use the [WordPres Plugin Directory Slurper](https://github.com/markjaquith/WordPress-Plugin-Directory-Slurper) shell script by Mark Jaquith to download the the most recent version of all plugins from the WordPress.org repo. Once the plugins have been downloaded, you can grep for the plugin/hook prefix you want ...
242,780
<p>I currently use this conditional code...</p> <pre><code>&lt;?php if ( $paged &lt; 2 ) echo 'some text'; else echo 'some other text'; ?&gt; </code></pre> <p>I need to add some more php between the 'if' and 'else'...</p> <pre><code>&lt;p&gt;Text...&lt;?php $published_posts = wp_count_posts('item'); echo $published_...
[ { "answer_id": 242782, "author": "Anish", "author_id": 104559, "author_profile": "https://wordpress.stackexchange.com/users/104559", "pm_score": 2, "selected": true, "text": "<blockquote>\n<p><a href=\"http://php.net/manual/en/control-structures.if.php\" rel=\"nofollow noreferrer\">As PH...
2016/10/15
[ "https://wordpress.stackexchange.com/questions/242780", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/103213/" ]
I currently use this conditional code... ``` <?php if ( $paged < 2 ) echo 'some text'; else echo 'some other text'; ?> ``` I need to add some more php between the 'if' and 'else'... ``` <p>Text...<?php $published_posts = wp_count_posts('item'); echo $published_posts->publish; ?> text... <?php echo do_shortcode("[co...
> > [As PHP documentation says](http://php.net/manual/en/control-structures.if.php) > > > Often you'd want to have more than one statement to be executed conditionally. Of course, there's no need to wrap each statement with an if clause. Instead, you can group several statements into a statement group. > > > So ...
242,786
<p>I have some specific functionality based on post's tags.</p> <p>How can I send email to admin@blog.com when: 1) user add new post with specific tag (ex. 'tag1') OR 2) user edit his pending post and assign specific tag ('tag1')?</p> <p>Thanks =) </p>
[ { "answer_id": 242782, "author": "Anish", "author_id": 104559, "author_profile": "https://wordpress.stackexchange.com/users/104559", "pm_score": 2, "selected": true, "text": "<blockquote>\n<p><a href=\"http://php.net/manual/en/control-structures.if.php\" rel=\"nofollow noreferrer\">As PH...
2016/10/15
[ "https://wordpress.stackexchange.com/questions/242786", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/-1/" ]
I have some specific functionality based on post's tags. How can I send email to admin@blog.com when: 1) user add new post with specific tag (ex. 'tag1') OR 2) user edit his pending post and assign specific tag ('tag1')? Thanks =)
> > [As PHP documentation says](http://php.net/manual/en/control-structures.if.php) > > > Often you'd want to have more than one statement to be executed conditionally. Of course, there's no need to wrap each statement with an if clause. Instead, you can group several statements into a statement group. > > > So ...
242,813
<p>I've searched all day for this and couldn't find a plugin that allow me to restrict the access to specific pages in the wp-admin backed by user role.</p> <p>Example: I have several users on my website and I want them to only see the pages that they are allowed to edit. I've done this manually by code and it's worki...
[ { "answer_id": 242818, "author": "Sumesh S", "author_id": 104736, "author_profile": "https://wordpress.stackexchange.com/users/104736", "pm_score": 0, "selected": false, "text": "<p>Use Advanced Access Manager ( <a href=\"https://wordpress.org/plugins/advanced-access-manager/\" rel=\"nof...
2016/10/16
[ "https://wordpress.stackexchange.com/questions/242813", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104993/" ]
I've searched all day for this and couldn't find a plugin that allow me to restrict the access to specific pages in the wp-admin backed by user role. Example: I have several users on my website and I want them to only see the pages that they are allowed to edit. I've done this manually by code and it's working (see co...
``` if( is_admin() ) { add_filter( 'init', 'custom_restrict_pages_from_admin' ); } function custom_restrict_pages_from_admin() { global $pagenow; $arr = array( 'update-core.php', 'edit.php' ); if( custom_check_user_roles() && in_array( $pagenow , $arr ) ) { //echo some cus...
242,814
<p>I want to use a URL to display content in the frontend. For example</p> <ul> <li>domain.tld/?myplugin&amp;confirmey=KEY&amp;mail=MAIL</li> </ul> <p>But i don´t know the way(s?) to do it. For example i have a user that clicks on a confirm link in an E-Mail and i want to show him a page with some text.</p> <ul> <li...
[ { "answer_id": 242818, "author": "Sumesh S", "author_id": 104736, "author_profile": "https://wordpress.stackexchange.com/users/104736", "pm_score": 0, "selected": false, "text": "<p>Use Advanced Access Manager ( <a href=\"https://wordpress.org/plugins/advanced-access-manager/\" rel=\"nof...
2016/10/16
[ "https://wordpress.stackexchange.com/questions/242814", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54551/" ]
I want to use a URL to display content in the frontend. For example * domain.tld/?myplugin&confirmey=KEY&mail=MAIL But i don´t know the way(s?) to do it. For example i have a user that clicks on a confirm link in an E-Mail and i want to show him a page with some text. * Must exist a real page in WordPres? * Can i in...
``` if( is_admin() ) { add_filter( 'init', 'custom_restrict_pages_from_admin' ); } function custom_restrict_pages_from_admin() { global $pagenow; $arr = array( 'update-core.php', 'edit.php' ); if( custom_check_user_roles() && in_array( $pagenow , $arr ) ) { //echo some cus...
242,834
<p>The WordPress area of my site (which has registration) is in for example <code>mydomain.com/members/</code></p> <p>I would like to know from a PHP routine in my <code>public_html</code> root <code>mydomain.com/offers.php</code> if they are logged into the WordPress area <code>mydomain.com/members</code></p> <p>I h...
[ { "answer_id": 242818, "author": "Sumesh S", "author_id": 104736, "author_profile": "https://wordpress.stackexchange.com/users/104736", "pm_score": 0, "selected": false, "text": "<p>Use Advanced Access Manager ( <a href=\"https://wordpress.org/plugins/advanced-access-manager/\" rel=\"nof...
2016/10/16
[ "https://wordpress.stackexchange.com/questions/242834", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105005/" ]
The WordPress area of my site (which has registration) is in for example `mydomain.com/members/` I would like to know from a PHP routine in my `public_html` root `mydomain.com/offers.php` if they are logged into the WordPress area `mydomain.com/members` I have tried various things to try and get this to work without ...
``` if( is_admin() ) { add_filter( 'init', 'custom_restrict_pages_from_admin' ); } function custom_restrict_pages_from_admin() { global $pagenow; $arr = array( 'update-core.php', 'edit.php' ); if( custom_check_user_roles() && in_array( $pagenow , $arr ) ) { //echo some cus...
242,839
<p>I have this shortcode</p> <pre><code>[broo_user_badges username=""] </code></pre> <p>and I have to put username between " " But, username is in URL: /author/peter. So, when page domain.com/author/peter was loaded, on that page this shortcode should be generated:</p> <pre><code>[broo_user_badges username="peter"] ...
[ { "answer_id": 242818, "author": "Sumesh S", "author_id": 104736, "author_profile": "https://wordpress.stackexchange.com/users/104736", "pm_score": 0, "selected": false, "text": "<p>Use Advanced Access Manager ( <a href=\"https://wordpress.org/plugins/advanced-access-manager/\" rel=\"nof...
2016/10/16
[ "https://wordpress.stackexchange.com/questions/242839", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105007/" ]
I have this shortcode ``` [broo_user_badges username=""] ``` and I have to put username between " " But, username is in URL: /author/peter. So, when page domain.com/author/peter was loaded, on that page this shortcode should be generated: ``` [broo_user_badges username="peter"] ``` I found this ``` add_shortcod...
``` if( is_admin() ) { add_filter( 'init', 'custom_restrict_pages_from_admin' ); } function custom_restrict_pages_from_admin() { global $pagenow; $arr = array( 'update-core.php', 'edit.php' ); if( custom_check_user_roles() && in_array( $pagenow , $arr ) ) { //echo some cus...
242,872
<p>I'm having a really annoying problem with <a href="https://wordpress.org/plugins/black-studio-tinymce-widget/" rel="nofollow">Black Studio TinyMCE Widget</a> in Wordpress, wherein the plugin always adds paragraph <code>p</code> tags around any text, image, link, object when switching from Visual editing mode to HTML...
[ { "answer_id": 242818, "author": "Sumesh S", "author_id": 104736, "author_profile": "https://wordpress.stackexchange.com/users/104736", "pm_score": 0, "selected": false, "text": "<p>Use Advanced Access Manager ( <a href=\"https://wordpress.org/plugins/advanced-access-manager/\" rel=\"nof...
2016/10/16
[ "https://wordpress.stackexchange.com/questions/242872", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105038/" ]
I'm having a really annoying problem with [Black Studio TinyMCE Widget](https://wordpress.org/plugins/black-studio-tinymce-widget/) in Wordpress, wherein the plugin always adds paragraph `p` tags around any text, image, link, object when switching from Visual editing mode to HTML mode within the widget. The switch is...
``` if( is_admin() ) { add_filter( 'init', 'custom_restrict_pages_from_admin' ); } function custom_restrict_pages_from_admin() { global $pagenow; $arr = array( 'update-core.php', 'edit.php' ); if( custom_check_user_roles() && in_array( $pagenow , $arr ) ) { //echo some cus...
242,875
<p>When I insert this code in functions.php:</p> <pre><code>add_action( 'pre_get_posts', 'my_change_sort_order'); function my_change_sort_order($query){ if(is_post_type_archive()): //If you wanted it for the archive of a custom post type use: is_post_type_archive( $post_type ) //Set the order ASC or D...
[ { "answer_id": 242878, "author": "Robbert", "author_id": 25834, "author_profile": "https://wordpress.stackexchange.com/users/25834", "pm_score": 0, "selected": false, "text": "<p>Since you only want to hook into the posts on your homepage, I think you only need something like this:</p>\n...
2016/10/16
[ "https://wordpress.stackexchange.com/questions/242875", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105039/" ]
When I insert this code in functions.php: ``` add_action( 'pre_get_posts', 'my_change_sort_order'); function my_change_sort_order($query){ if(is_post_type_archive()): //If you wanted it for the archive of a custom post type use: is_post_type_archive( $post_type ) //Set the order ASC or DESC $qu...
Since you only want to hook into the posts on your homepage, I think you only need something like this: ``` <?php add_action( 'pre_get_posts', 'my_change_sort_order'); function my_change_sort_order( $query ){ if ( ! is_admin() && $query->is_main_query() ) : if ( is_front_page() ) : //Set the order...
242,896
<p>How can we apply filters only to posts with a specific custom post type? I would like some of my custom posts to start out in HTML mode for their editors. This is what I am working with so far...</p> <pre><code> add_filter( 'wp_default_editor', create_function('', 'return "html";') ); </code></pre>
[ { "answer_id": 242895, "author": "mike510a", "author_id": 103274, "author_profile": "https://wordpress.stackexchange.com/users/103274", "pm_score": 0, "selected": false, "text": "<p>One way is to modify the file: <em>front-page.php</em> in your child theme's folder and include this:</p>\...
2016/10/17
[ "https://wordpress.stackexchange.com/questions/242896", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98671/" ]
How can we apply filters only to posts with a specific custom post type? I would like some of my custom posts to start out in HTML mode for their editors. This is what I am working with so far... ``` add_filter( 'wp_default_editor', create_function('', 'return "html";') ); ```
You can do it in two different ways 01) Go to Settings > Reading and make the designation change and click “save changes”. [![enter image description here](https://i.stack.imgur.com/98af1.png)](https://i.stack.imgur.com/98af1.png) 02) Go to Appearance > Customize > Static Front Page and choose to display the latest p...
242,910
<p>I created a search form which searching by category filter and keyword input. The search form code is here-</p> <pre><code>&lt;form action="&lt;?php bloginfo('url'); ?&gt;" method="get" role="search" class="dropdown-form"&gt; &lt;div class="input-group"&gt; &lt;span class="in...
[ { "answer_id": 242947, "author": "birgire", "author_id": 26350, "author_profile": "https://wordpress.stackexchange.com/users/26350", "pm_score": 2, "selected": false, "text": "<h2>The <em>Why</em> part</h2>\n\n<p>In the core <code>is_search()</code> function there's a check if the global...
2016/10/17
[ "https://wordpress.stackexchange.com/questions/242910", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/75264/" ]
I created a search form which searching by category filter and keyword input. The search form code is here- ``` <form action="<?php bloginfo('url'); ?>" method="get" role="search" class="dropdown-form"> <div class="input-group"> <span class="input-group-addon"> ...
The *Why* part -------------- In the core `is_search()` function there's a check if the global `$wp_query` is set: ``` global $wp_query; if ( ! isset( $wp_query ) ) { _doing_it_wrong( __FUNCTION__, __( 'Conditional query tags do not work before the query is run. Before then, they always retur...
242,914
<p>I want to make a search button that search only within my website.</p> <ol> <li>Do I need external PHP or PERL script? </li> <li>Can it done by JavaScript? </li> <li>Or simply by HTML.</li> </ol> <p>I tried to create a form using HTML:</p> <pre><code>&lt;form&gt; &lt;input type="search" name="banner_search" c...
[ { "answer_id": 242916, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 2, "selected": true, "text": "<p>You can use WordPress's internal search by calling the <a href=\"https://developer.wordpress.org/reference/f...
2016/10/17
[ "https://wordpress.stackexchange.com/questions/242914", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104901/" ]
I want to make a search button that search only within my website. 1. Do I need external PHP or PERL script? 2. Can it done by JavaScript? 3. Or simply by HTML. I tried to create a form using HTML: ``` <form> <input type="search" name="banner_search" class="banner-text-box" > <input type="submit" name="" val...
You can use WordPress's internal search by calling the [`get_search_form()`](https://developer.wordpress.org/reference/functions/get_search_form/) function: ``` <?php get_search_form(); ?> ``` `get_search_form()` will use a default HTML form, but you can create your own custom form by adding a `searchform.php` file ...
242,929
<p>I want to display all post with its own category. I tried but the loop is fetching all existing categories. Here is my code:</p> <pre><code>&lt;?php //query to echo the categories $cat_counts = wp_list_pluck( get_categories(),'count', 'name' );?&gt; &lt;?php foreach ( $cat_counts as $name =&gt; $count ) {?&gt;...
[ { "answer_id": 242916, "author": "Dave Romsey", "author_id": 2807, "author_profile": "https://wordpress.stackexchange.com/users/2807", "pm_score": 2, "selected": true, "text": "<p>You can use WordPress's internal search by calling the <a href=\"https://developer.wordpress.org/reference/f...
2016/10/17
[ "https://wordpress.stackexchange.com/questions/242929", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104901/" ]
I want to display all post with its own category. I tried but the loop is fetching all existing categories. Here is my code: ``` <?php //query to echo the categories $cat_counts = wp_list_pluck( get_categories(),'count', 'name' );?> <?php foreach ( $cat_counts as $name => $count ) {?> <li> <a href="#"...
You can use WordPress's internal search by calling the [`get_search_form()`](https://developer.wordpress.org/reference/functions/get_search_form/) function: ``` <?php get_search_form(); ?> ``` `get_search_form()` will use a default HTML form, but you can create your own custom form by adding a `searchform.php` file ...
242,938
<p>I would like to use both the <code>meta_query</code> and the <code>tax_query</code>, but using the following I can get results for the <code>meta_query</code>. What am I doing wrong?</p> <pre><code>$wp_query = new WP_Query( array( 'post_type' =&gt; 'whatson', 'post_status' =&gt; 'publi...
[ { "answer_id": 242940, "author": "MrFox", "author_id": 69240, "author_profile": "https://wordpress.stackexchange.com/users/69240", "pm_score": 2, "selected": false, "text": "<p>Would you believe it, as soon as I posted this I remembered I asked a question about a query last year. I had a...
2016/10/17
[ "https://wordpress.stackexchange.com/questions/242938", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/69240/" ]
I would like to use both the `meta_query` and the `tax_query`, but using the following I can get results for the `meta_query`. What am I doing wrong? ``` $wp_query = new WP_Query( array( 'post_type' => 'whatson', 'post_status' => 'publish', 'meta_query' => array( ...
Would you believe it, as soon as I posted this I remembered I asked a question about a query last year. I had a look over it and I've adapted my new query like so: ``` $category_slug = filter_input( INPUT_GET, 'eventtype', FILTER_SANITIZE_STRING ); $cat_query = []; if( $event_type ){ $cat_query = [ ...
243,012
<p>I'm disabling <a href="https://hackertarget.com/wordpress-user-enumeration/" rel="nofollow">user enumeration</a> for security purposes in order to prevent usernames from being revealed by looking up the user IDs. Instead, whenever someone tried to find out the username by their ID, such as visiting the following:</p...
[ { "answer_id": 243018, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 2, "selected": true, "text": "<p><strong>Logic #1</strong> is checking the returned value of the <code>preg_match</code> function with respe...
2016/10/17
[ "https://wordpress.stackexchange.com/questions/243012", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98212/" ]
I'm disabling [user enumeration](https://hackertarget.com/wordpress-user-enumeration/) for security purposes in order to prevent usernames from being revealed by looking up the user IDs. Instead, whenever someone tried to find out the username by their ID, such as visiting the following: ``` http://example.com?author=...
**Logic #1** is checking the returned value of the `preg_match` function with respect to `0` and with operator `===`. That means the returned value of the `preg_match` function has to be `(int) 0` or `(string) 0`. And after that it is checking if `$_REQUEST['author']` is empty or not. And in **Logic #2** is checking t...
243,040
<p>I've created a custom taxonomy for the product post type created by WooCommerce. I want to use this taxonomy to the permalinks of the products.</p> <p>I stumbled upon <a href="https://wordpress.stackexchange.com/a/162670/2830">this</a> which seemed to be perfect for what I wanted to do. However, I'm having little l...
[ { "answer_id": 243041, "author": "INT", "author_id": 2830, "author_profile": "https://wordpress.stackexchange.com/users/2830", "pm_score": 3, "selected": true, "text": "<p>As always it was too simple in the end, was using the wrong hook. <code>post_link</code> is for posts only should us...
2016/10/17
[ "https://wordpress.stackexchange.com/questions/243040", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/2830/" ]
I've created a custom taxonomy for the product post type created by WooCommerce. I want to use this taxonomy to the permalinks of the products. I stumbled upon [this](https://wordpress.stackexchange.com/a/162670/2830) which seemed to be perfect for what I wanted to do. However, I'm having little luck getting it to wor...
As always it was too simple in the end, was using the wrong hook. `post_link` is for posts only should use `post_type_link` instead. ``` /** * replace the '%item%' tag with the first * term slug in the item taxonomy * * @wp-hook post_link * @param string $permalink * @param WP_Post $post * @return string */ ...
243,043
<p>I having an issue getting a variable to work for one of my arguments in a query. I am using a custom post type and category name as terms to determine which categories are displayed.</p> <p>When I hardcode the values into the terms it works fine, but when I use a variable it doesn't seem to work.</p> <p><strong>Th...
[ { "answer_id": 243048, "author": "rudtek", "author_id": 77767, "author_profile": "https://wordpress.stackexchange.com/users/77767", "pm_score": 1, "selected": false, "text": "<p>just upload it through ftp or your domain hosting panel to your public_html (www) directory. It will be there...
2016/10/17
[ "https://wordpress.stackexchange.com/questions/243043", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105139/" ]
I having an issue getting a variable to work for one of my arguments in a query. I am using a custom post type and category name as terms to determine which categories are displayed. When I hardcode the values into the terms it works fine, but when I use a variable it doesn't seem to work. **This code works:** ``` $...
just upload it through ftp or your domain hosting panel to your public\_html (www) directory. It will be there as a link to www.example.com/myfile.pdf. The case may be that if you have wordpress and installed any security plugins you'll have to allow the exception within that plugin as well.
243,070
<p>Using the <a href="https://codex.wordpress.org/Function_Reference/remove_menu_page" rel="noreferrer"><code>remove_menu_page()</code></a> function works for removing the default admin menu items by their slug like so:</p> <pre><code>add_action( 'admin_menu', 'hide_menu' ); function hide_menu() { remove_menu_pag...
[ { "answer_id": 243073, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 4, "selected": false, "text": "<p>Place this below temporary code in your <code>functions.php</code> or any where that can be executed.</p>\...
2016/10/18
[ "https://wordpress.stackexchange.com/questions/243070", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98212/" ]
Using the [`remove_menu_page()`](https://codex.wordpress.org/Function_Reference/remove_menu_page) function works for removing the default admin menu items by their slug like so: ``` add_action( 'admin_menu', 'hide_menu' ); function hide_menu() { remove_menu_page( 'index.php' ); // Dashboard remove_menu_page( ...
Thanks to the answer that [the\_dramatist](https://wordpress.stackexchange.com/users/44192) posted, it was a matter of just hooking to the [`admin_init`](https://codex.wordpress.org/Plugin_API/Action_Reference/admin_init) tag. The slugs for those plugin pages can be retrieved by the debug script that the\_dramatist pro...
243,168
<p>I'm using ACF (Advance Custom Fields) plugin in my theme. This plugin provides a simpler methods <code>get_field()</code> which we can use in place of WordPress native <code>get_post_meta()</code> method. Now, the issue is the <code>get_field()</code> method works fine if ACF plugin is active, but when the plugin is...
[ { "answer_id": 244263, "author": "David", "author_id": 12976, "author_profile": "https://wordpress.stackexchange.com/users/12976", "pm_score": 0, "selected": false, "text": "<p>The <a href=\"https://codex.wordpress.org/Plugin_API/Action_Reference/after_setup_theme\" rel=\"nofollow\">afte...
2016/10/18
[ "https://wordpress.stackexchange.com/questions/243168", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/45269/" ]
I'm using ACF (Advance Custom Fields) plugin in my theme. This plugin provides a simpler methods `get_field()` which we can use in place of WordPress native `get_post_meta()` method. Now, the issue is the `get_field()` method works fine if ACF plugin is active, but when the plugin is not active the theme front-end thro...
The issue has been solved. It seems ACF plugin defined `get_field()` function is not able to override the theme defined `get_field()` function on ACF plugin activation. Therefore, it throws `Fatal error: Cannot redeclare get_field(`) error if we use the following code: ``` if ( !function_exists('get_field') ) { f...
243,176
<p>I know from <a href="https://wordpress.stackexchange.com/questions/180137/retrieving-pages-with-multiple-tags-using-rest-api">this post</a> that I can get posts by tag <em>name</em> by just specifying a <code>filter[tag]</code> query parameter. And similarly with <code>filter[category_name]</code>.</p> <p>Is there ...
[ { "answer_id": 244263, "author": "David", "author_id": 12976, "author_profile": "https://wordpress.stackexchange.com/users/12976", "pm_score": 0, "selected": false, "text": "<p>The <a href=\"https://codex.wordpress.org/Plugin_API/Action_Reference/after_setup_theme\" rel=\"nofollow\">afte...
2016/10/18
[ "https://wordpress.stackexchange.com/questions/243176", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102669/" ]
I know from [this post](https://wordpress.stackexchange.com/questions/180137/retrieving-pages-with-multiple-tags-using-rest-api) that I can get posts by tag *name* by just specifying a `filter[tag]` query parameter. And similarly with `filter[category_name]`. Is there a way to get posts that are **not** in a list of t...
The issue has been solved. It seems ACF plugin defined `get_field()` function is not able to override the theme defined `get_field()` function on ACF plugin activation. Therefore, it throws `Fatal error: Cannot redeclare get_field(`) error if we use the following code: ``` if ( !function_exists('get_field') ) { f...
243,178
<p>I am using hard-crop on featured images like this :</p> <pre><code>add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size ( 635, 200, true ); </code></pre> <p>I have no other plugin installed, not even Jetpack. No matter how large the image I upload wordpress won't add srcset for my cropped featured image...
[ { "answer_id": 243284, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 4, "selected": true, "text": "<p>To show a srcset, there must be multiple image sizes of the same aspect ratio. When you set your t...
2016/10/18
[ "https://wordpress.stackexchange.com/questions/243178", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104433/" ]
I am using hard-crop on featured images like this : ``` add_theme_support( 'post-thumbnails' ); set_post_thumbnail_size ( 635, 200, true ); ``` I have no other plugin installed, not even Jetpack. No matter how large the image I upload wordpress won't add srcset for my cropped featured images. ***EDIT***: The proble...
To show a srcset, there must be multiple image sizes of the same aspect ratio. When you set your thumbnail to hard crop without creating any other image sizes you are ensuring that there won't be a srcset. You might find my answer [here](https://wordpress.stackexchange.com/a/241906/94267) helpful. Briefly, in your ...
243,209
<p>My client has dragged around the sub-categories in the admin panel to change their order. </p> <p>I have the following code that outputs the sub-categories of a specific category parent:</p> <pre><code>$mainCategory = get_categories( array ( 'parent' =&gt; $category_id['term_id'], 't...
[ { "answer_id": 243225, "author": "Aurovrata", "author_id": 52120, "author_profile": "https://wordpress.stackexchange.com/users/52120", "pm_score": 0, "selected": false, "text": "<p>Why don't you use the <a href=\"https://codex.wordpress.org/Navigation_Menus\" rel=\"nofollow\">Navigationa...
2016/10/19
[ "https://wordpress.stackexchange.com/questions/243209", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31560/" ]
My client has dragged around the sub-categories in the admin panel to change their order. I have the following code that outputs the sub-categories of a specific category parent: ``` $mainCategory = get_categories( array ( 'parent' => $category_id['term_id'], 'taxonomy' => 'product_ca...
Answering for posterity, since I ran into the same issue and this thread is the closest thing I found to what I was looking for. The solution turned out to be quite simple. If you don't specify 'orderby' in your arguments, the default sort order will be used (the category order in the Woo admin). Just remove that par...
243,233
<p>I know it has been asked many times on this website but I can't really get it to work with those examples. </p> <p>This is my function so far:</p> <pre><code>$city_ids = get_pages( array( "hierarchical" =&gt; 0, "sort_column" =&gt; "menu_order", "sort_order" =&gt; "desc", "m...
[ { "answer_id": 243225, "author": "Aurovrata", "author_id": 52120, "author_profile": "https://wordpress.stackexchange.com/users/52120", "pm_score": 0, "selected": false, "text": "<p>Why don't you use the <a href=\"https://codex.wordpress.org/Navigation_Menus\" rel=\"nofollow\">Navigationa...
2016/10/19
[ "https://wordpress.stackexchange.com/questions/243233", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104179/" ]
I know it has been asked many times on this website but I can't really get it to work with those examples. This is my function so far: ``` $city_ids = get_pages( array( "hierarchical" => 0, "sort_column" => "menu_order", "sort_order" => "desc", "meta_key" => "country", ...
Answering for posterity, since I ran into the same issue and this thread is the closest thing I found to what I was looking for. The solution turned out to be quite simple. If you don't specify 'orderby' in your arguments, the default sort order will be used (the category order in the Woo admin). Just remove that par...
243,238
<p>I created new custom field within my nav menu items as multiple select options i used <code>update_post_meta()</code> as below</p> <pre><code>function YPE_update_custom_fields($menu_id, $menu_item_db_id, $menu_item_data) { if (is_array($_REQUEST['menu-item-content-multiple'])) { update_post_meta($menu_i...
[ { "answer_id": 243241, "author": "Benoti", "author_id": 58141, "author_profile": "https://wordpress.stackexchange.com/users/58141", "pm_score": 0, "selected": false, "text": "<p>You don't use <code>selected()</code> function correctly. <code>selected()</code> need 1 required parameters a...
2016/10/19
[ "https://wordpress.stackexchange.com/questions/243238", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37216/" ]
I created new custom field within my nav menu items as multiple select options i used `update_post_meta()` as below ``` function YPE_update_custom_fields($menu_id, $menu_item_db_id, $menu_item_data) { if (is_array($_REQUEST['menu-item-content-multiple'])) { update_post_meta($menu_item_db_id, '_menu_item_co...
You do this: ``` $item->content_multiple = get_post_meta($item->ID, '_menu_item_content_multiple', true); ``` Note how you set the third parameter of `get_post_meta()` to `true`, which means that only one value will be returned. [If you read the docs](https://developer.wordpress.org/reference/functions/get_post_meta...
243,245
<p>I'm trying to figure out how to redeclare a theme's function from within a plugin. The problem is that I'm getting a "Fatal error: Cannot redeclare" when trying to activate the plugin. But if I add the code to already activated plugin - everything is working as expected. Is there something obvious that I'm missing? ...
[ { "answer_id": 243247, "author": "Tom J Nowell", "author_id": 736, "author_profile": "https://wordpress.stackexchange.com/users/736", "pm_score": 1, "selected": false, "text": "<p>You can only declare a function once.</p>\n\n<p>My reccomendation is that you put the functions in the plugi...
2016/10/19
[ "https://wordpress.stackexchange.com/questions/243245", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/31277/" ]
I'm trying to figure out how to redeclare a theme's function from within a plugin. The problem is that I'm getting a "Fatal error: Cannot redeclare" when trying to activate the plugin. But if I add the code to already activated plugin - everything is working as expected. Is there something obvious that I'm missing? H...
You can only declare a function once. My reccomendation is that you put the functions in the plugin, then use filters to override in the theme, e.g. In the plugins: ``` function my_awesome_function() { return apply_filters( 'my_awesome_function', "plugin" ); } ``` In your theme: ``` add_filter( 'my_awesome_fu...
243,276
<p>I'd like to get post data from a private page to show on the rest of the site. The code looks like this:</p> <pre><code>$the_query = new WP_Query( 'page_id=1457' ); while($the_query -&gt; have_posts()) : $the_query -&gt; the_post(); setup_postdata( $the_query ); // do something; endwhile; </code></pre> <p>...
[ { "answer_id": 243277, "author": "TheDeadMedic", "author_id": 1685, "author_profile": "https://wordpress.stackexchange.com/users/1685", "pm_score": 0, "selected": false, "text": "<p>You don't need a query for this - in fact, that's part of the problem (WordPress will automatically \"filt...
2016/10/19
[ "https://wordpress.stackexchange.com/questions/243276", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105264/" ]
I'd like to get post data from a private page to show on the rest of the site. The code looks like this: ``` $the_query = new WP_Query( 'page_id=1457' ); while($the_query -> have_posts()) : $the_query -> the_post(); setup_postdata( $the_query ); // do something; endwhile; ``` But I don't get the data. Is it...
`setup_postdata` takes a post object of type `\WP_Post`, but you're passing it a `WP_Query` instead e.g. ``` global $post; setup_postdata( $post ); ``` Thankfully the solution is trivial, when you call `the_post`, it sets up the current post data for you, so removing that line is all you need to do. The second iss...
243,322
<p>I want to increase the width of the expanded sidebar in the WP customizer. </p> <p>The relevant customizer markup:</p> <pre><code>&lt;div class="wp-full-overlay expanded preview-desktop"&gt; &lt;form id="customize-controls" class="wrap wp-full-overlay-sidebar"&gt; &lt;div id="customize-preview" class="wp-ful...
[ { "answer_id": 243400, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 2, "selected": true, "text": "<p>Enqueue a style sheet to your admin or dashboard with <code>admin_enqueue_scripts</code> hook like below-</...
2016/10/19
[ "https://wordpress.stackexchange.com/questions/243322", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/89739/" ]
I want to increase the width of the expanded sidebar in the WP customizer. The relevant customizer markup: ``` <div class="wp-full-overlay expanded preview-desktop"> <form id="customize-controls" class="wrap wp-full-overlay-sidebar"> <div id="customize-preview" class="wp-full-overlay-main"> ``` The CSS: ```...
Enqueue a style sheet to your admin or dashboard with `admin_enqueue_scripts` hook like below- ``` add_action( 'admin_enqueue_scripts', 'the_dramatist_admin_styles' ); function the_dramatist_admin_styles() { wp_enqueue_style( 'admin-css-override', get_template_directory_uri() . '/your-admin-css-file.css', false );...
243,334
<p>I am new with Wordpress, I want to hide a custom fields from particular post types and the problem is the custom fields are same for other post types, if I remove the custom fields it will also remove from all post types and I want to hide custom fields for only specific post types.</p> <p>For example the post type...
[ { "answer_id": 243347, "author": "cowgill", "author_id": 5549, "author_profile": "https://wordpress.stackexchange.com/users/5549", "pm_score": 1, "selected": false, "text": "<p>This should do it. Tested locally and it works.</p>\n\n<pre><code>// Hide 'included' and 'not included' custom ...
2016/10/20
[ "https://wordpress.stackexchange.com/questions/243334", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105184/" ]
I am new with Wordpress, I want to hide a custom fields from particular post types and the problem is the custom fields are same for other post types, if I remove the custom fields it will also remove from all post types and I want to hide custom fields for only specific post types. For example the post types are: > ...
This should do it. Tested locally and it works. ``` // Hide 'included' and 'not included' custom meta fields // from the edit 'excursion' post type page. function my_exclude_custom_fields( $protected, $meta_key ) { if ( 'excursion' == get_post_type() ) { if ( in_array( $meta_key, array( 'included', 'not inclu...
243,345
<p>I would like to know is there a hook in wordpress to edit prefix and postfix of the_title in wordpress.</p> <p>The code in content.php</p> <pre><code>the_title( '&lt;h1 class="entry-title"&gt;', '&lt;/h1&gt;' ); </code></pre> <p>I would like to add content after the closing tag of h1.</p> <p>When I use the_title...
[ { "answer_id": 243355, "author": "startToday", "author_id": 104608, "author_profile": "https://wordpress.stackexchange.com/users/104608", "pm_score": 0, "selected": false, "text": "<p>Using get_the_title() will work for you:</p>\n\n<pre><code>&lt;h1&gt;&lt;?php echo get_the_title(); ?&gt...
2016/10/20
[ "https://wordpress.stackexchange.com/questions/243345", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105312/" ]
I would like to know is there a hook in wordpress to edit prefix and postfix of the\_title in wordpress. The code in content.php ``` the_title( '<h1 class="entry-title">', '</h1>' ); ``` I would like to add content after the closing tag of h1. When I use the\_title hook the content is added inside the h1 tag. Lik...
You can use it that way : ``` function add_suffix_to_title($title, $id = null){ if (! is_admin()) { return '<h1>'.$title.'</h1> Your Suffix'; } return $title; } add_action( 'the_title', 'add_suffix_to_title', 10, 1 ); ``` And when you invoke the "the\_title" function remove the h1 tag : ``` t...
243,365
<p>I've added a simple shortcode into my <code>functions.php</code> file which results in creating an Bootstrap Collapse into post. But when I try using that shortcode the accordion structure is not as supposed. Here's my code in <code>functions.php</code> file:</p> <pre><code>function sth_collapse($atts, $content = n...
[ { "answer_id": 243383, "author": "M-R", "author_id": 17061, "author_profile": "https://wordpress.stackexchange.com/users/17061", "pm_score": 3, "selected": true, "text": "<p>Make sure, your closing [collapse] does not miss \"/\" or is not converting to \"[collapse/]\".</p>\n" }, { ...
2016/10/20
[ "https://wordpress.stackexchange.com/questions/243365", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104608/" ]
I've added a simple shortcode into my `functions.php` file which results in creating an Bootstrap Collapse into post. But when I try using that shortcode the accordion structure is not as supposed. Here's my code in `functions.php` file: ``` function sth_collapse($atts, $content = null) { $atts = shortcode_atts(ar...
Make sure, your closing [collapse] does not miss "/" or is not converting to "[collapse/]".
243,373
<p>Sorry if this is a duplicate – I can't find an answer.</p> <p>How do I rewrite a custom post type archive page to a 'man-made' WordPress page?</p> <p>For example:</p> <ul> <li>Single page: <code>http://www.mywebsite.com/cool-post-type/awesome-single-post/</code></li> <li>Archive page: <code>http://www.mywebsite.c...
[ { "answer_id": 243376, "author": "socki03", "author_id": 43511, "author_profile": "https://wordpress.stackexchange.com/users/43511", "pm_score": 5, "selected": true, "text": "<p>This one's actually pretty easy. When you declare your post type using <a href=\"https://developer.wordpress....
2016/10/20
[ "https://wordpress.stackexchange.com/questions/243373", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105331/" ]
Sorry if this is a duplicate – I can't find an answer. How do I rewrite a custom post type archive page to a 'man-made' WordPress page? For example: * Single page: `http://www.mywebsite.com/cool-post-type/awesome-single-post/` * Archive page: `http://www.mywebsite.com/cool-post-type/` I want `http://www.mywebsite.c...
This one's actually pretty easy. When you declare your post type using [register\_post\_type](https://developer.wordpress.org/reference/functions/register_post_type/), you need to add a new argument for 'has\_archive'. So you'll add in something to the effect of: ``` 'has_archive' => 'about-cool-post-types' ``` The...
243,377
<p>I trying to program the following rules:</p> <ol> <li>When attachment uploaded on wp-admin/post.php page, on the act of uploading, rename it to <code>{post-slug}-{n}-[WxH].{ext}</code></li> <li>When attachment uploaded on wp-admin/upload.php page, on the act of uploading, rename it to <code>{site-name}-{n}-[WxH].{e...
[ { "answer_id": 243385, "author": "Niels van Renselaar", "author_id": 67313, "author_profile": "https://wordpress.stackexchange.com/users/67313", "pm_score": 0, "selected": false, "text": "<p>I suppose you could change the filename trough <a href=\"https://codex.wordpress.org/Plugin_API/F...
2016/10/20
[ "https://wordpress.stackexchange.com/questions/243377", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/35834/" ]
I trying to program the following rules: 1. When attachment uploaded on wp-admin/post.php page, on the act of uploading, rename it to `{post-slug}-{n}-[WxH].{ext}` 2. When attachment uploaded on wp-admin/upload.php page, on the act of uploading, rename it to `{site-name}-{n}-[WxH].{ext}` Where `{n}` is the numerical ...
The best way of doing this might be to attach a custom field to each post to keep the increment {n}. Something to the effect of: ``` $attach_inc = 1; if ( is_single() ) { if ( $attach_inc = get_post_meta( $post_id, 'attachment_inc', true ) ) { $attach_inc++; update_post_meta( $post_id, 'attachmen...
243,384
<p>I want to dequeue all styles and scripts that are loaded on the front-end (EG. not the admin panel) by default.</p> <p>I found this <a href="https://codex.wordpress.org/Function_Reference/wp_dequeue_script" rel="nofollow">function</a>, but am not sure how to utilize it to accomplish my goal.</p> <p>I'm seeing a to...
[ { "answer_id": 243388, "author": "Niels van Renselaar", "author_id": 67313, "author_profile": "https://wordpress.stackexchange.com/users/67313", "pm_score": 2, "selected": false, "text": "<p>I'm not sure what more you need that the example there, and remember that some scripts are needed...
2016/10/20
[ "https://wordpress.stackexchange.com/questions/243384", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/51704/" ]
I want to dequeue all styles and scripts that are loaded on the front-end (EG. not the admin panel) by default. I found this [function](https://codex.wordpress.org/Function_Reference/wp_dequeue_script), but am not sure how to utilize it to accomplish my goal. I'm seeing a ton of assets that I don't need on the front ...
I'm not sure what more you need that the example there, and remember that some scripts are needed for stuff like the admin bar and are not enqueued if you are not logged in. ``` function wpdocs_dequeue_script() { wp_dequeue_script( 'jquery-ui-core' ); } add_action( 'wp_print_scripts', 'wpdocs_dequeue_script', 100 ...
243,396
<p>I am adding a new query string parameter to be passed into the URL so that I can manipulate the REST API responses.</p> <p>I added this to my <code>functions.php</code></p> <pre><code>add_filter('query_vars', function ($vars) { $vars[] = 'xyz'; return $vars; }); </code></pre> <p>This should make t...
[ { "answer_id": 243413, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 1, "selected": false, "text": "<p>I'm not sure it quite works like that. Try inspecting <code>$query-&gt;public_query_vars</code> ...
2016/10/20
[ "https://wordpress.stackexchange.com/questions/243396", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/102669/" ]
I am adding a new query string parameter to be passed into the URL so that I can manipulate the REST API responses. I added this to my `functions.php` ``` add_filter('query_vars', function ($vars) { $vars[] = 'xyz'; return $vars; }); ``` This should make the parameter `xyz` available in the WP\_Quer...
I'm not sure it quite works like that. Try inspecting `$query->public_query_vars` instead and I think you'll see it added in there. The way I usually use it is like this: ``` add_filter( 'query_vars', 'add_test_query_vars'); function add_test_query_vars($vars){ $vars[] = "test"; return $vars; } ``` So the...
243,403
<p>I am working on a new site but I am using the users from an old site.</p> <p>I created all my user roles, which match the user roles on the other site. I deleted the user and usermeta table from the new site and imported these tables from the old site.</p> <p>I can now see all the users and I can login with the us...
[ { "answer_id": 243413, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 1, "selected": false, "text": "<p>I'm not sure it quite works like that. Try inspecting <code>$query-&gt;public_query_vars</code> ...
2016/10/20
[ "https://wordpress.stackexchange.com/questions/243403", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/19217/" ]
I am working on a new site but I am using the users from an old site. I created all my user roles, which match the user roles on the other site. I deleted the user and usermeta table from the new site and imported these tables from the old site. I can now see all the users and I can login with the users. The issue I ...
I'm not sure it quite works like that. Try inspecting `$query->public_query_vars` instead and I think you'll see it added in there. The way I usually use it is like this: ``` add_filter( 'query_vars', 'add_test_query_vars'); function add_test_query_vars($vars){ $vars[] = "test"; return $vars; } ``` So the...
243,408
<p>I don't know how to turn some WP QUERY parameters into url query strings. Most of them are straight forward, but there are some I don't know how to get working. For example, for these WP_QUERY parameters:</p> <pre><code>$args = array( 'post_type' =&gt; 'post', 's' =&gt; 'keyword', ); </code></pre> <p>the q...
[ { "answer_id": 243413, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 1, "selected": false, "text": "<p>I'm not sure it quite works like that. Try inspecting <code>$query-&gt;public_query_vars</code> ...
2016/10/20
[ "https://wordpress.stackexchange.com/questions/243408", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88767/" ]
I don't know how to turn some WP QUERY parameters into url query strings. Most of them are straight forward, but there are some I don't know how to get working. For example, for these WP\_QUERY parameters: ``` $args = array( 'post_type' => 'post', 's' => 'keyword', ); ``` the query string for this is: `?s=ke...
I'm not sure it quite works like that. Try inspecting `$query->public_query_vars` instead and I think you'll see it added in there. The way I usually use it is like this: ``` add_filter( 'query_vars', 'add_test_query_vars'); function add_test_query_vars($vars){ $vars[] = "test"; return $vars; } ``` So the...
243,423
<p>I want to add a button to TinyMCE editor, which opens Media Uploader of WordPress. I have used <code>wp_editor()</code>. Here is my code-</p> <pre><code>$editor = array( 'textarea_name' =&gt; 'message', 'media_buttons' =&gt; false, 'textarea_rows' =&gt; 8, 'quicktags' =&gt; false, 'drag_drop...
[ { "answer_id": 243413, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 1, "selected": false, "text": "<p>I'm not sure it quite works like that. Try inspecting <code>$query-&gt;public_query_vars</code> ...
2016/10/20
[ "https://wordpress.stackexchange.com/questions/243423", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57944/" ]
I want to add a button to TinyMCE editor, which opens Media Uploader of WordPress. I have used `wp_editor()`. Here is my code- ``` $editor = array( 'textarea_name' => 'message', 'media_buttons' => false, 'textarea_rows' => 8, 'quicktags' => false, 'drag_drop_upload' => true, 'tinymce' ...
I'm not sure it quite works like that. Try inspecting `$query->public_query_vars` instead and I think you'll see it added in there. The way I usually use it is like this: ``` add_filter( 'query_vars', 'add_test_query_vars'); function add_test_query_vars($vars){ $vars[] = "test"; return $vars; } ``` So the...
243,428
<p>I want to modify wordpress's core files to get a desired result for cropping and saving uploaded images. However, i can't find the function that handles the uploaded images and crops, renames and saves them.</p> <p>I thought this function may have something to do with thumbnails :<code>wp_generate_attachment_metada...
[ { "answer_id": 243413, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 1, "selected": false, "text": "<p>I'm not sure it quite works like that. Try inspecting <code>$query-&gt;public_query_vars</code> ...
2016/10/20
[ "https://wordpress.stackexchange.com/questions/243428", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/94498/" ]
I want to modify wordpress's core files to get a desired result for cropping and saving uploaded images. However, i can't find the function that handles the uploaded images and crops, renames and saves them. I thought this function may have something to do with thumbnails :`wp_generate_attachment_metadata` Can anyone...
I'm not sure it quite works like that. Try inspecting `$query->public_query_vars` instead and I think you'll see it added in there. The way I usually use it is like this: ``` add_filter( 'query_vars', 'add_test_query_vars'); function add_test_query_vars($vars){ $vars[] = "test"; return $vars; } ``` So the...
243,436
<p>I'm using a weird SELECT query to calculate the average of all the post ratings (stored in <code>wp_postmeta</code>) for a certain user.</p> <p>My query basically uses the following arguments:</p> <blockquote> <p><code>post_author = 1</code> AND <code>meta_key = 'rating'</code> AND <code>meta_value != 0</code>.<...
[ { "answer_id": 243413, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 1, "selected": false, "text": "<p>I'm not sure it quite works like that. Try inspecting <code>$query-&gt;public_query_vars</code> ...
2016/10/20
[ "https://wordpress.stackexchange.com/questions/243436", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/22588/" ]
I'm using a weird SELECT query to calculate the average of all the post ratings (stored in `wp_postmeta`) for a certain user. My query basically uses the following arguments: > > `post_author = 1` AND `meta_key = 'rating'` AND `meta_value != 0`. > > > This query works perfectly fine on it's own, but here's where...
I'm not sure it quite works like that. Try inspecting `$query->public_query_vars` instead and I think you'll see it added in there. The way I usually use it is like this: ``` add_filter( 'query_vars', 'add_test_query_vars'); function add_test_query_vars($vars){ $vars[] = "test"; return $vars; } ``` So the...
243,448
<p>I am trying to figure out the best way to do something similar with <a href="http://getbootstrap.com/javascript/" rel="nofollow noreferrer">http://getbootstrap.com/javascript/</a> <a href="https://i.stack.imgur.com/Dn0Ms.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Dn0Ms.jpg" alt="enter image d...
[ { "answer_id": 243413, "author": "Andy Macaulay-Brook", "author_id": 94267, "author_profile": "https://wordpress.stackexchange.com/users/94267", "pm_score": 1, "selected": false, "text": "<p>I'm not sure it quite works like that. Try inspecting <code>$query-&gt;public_query_vars</code> ...
2016/10/21
[ "https://wordpress.stackexchange.com/questions/243448", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105375/" ]
I am trying to figure out the best way to do something similar with <http://getbootstrap.com/javascript/> [![enter image description here](https://i.stack.imgur.com/Dn0Ms.jpg)](https://i.stack.imgur.com/Dn0Ms.jpg) I understand that I have to use scrollspy and work on couple jQuery line for "scroll-to" thing and also w...
I'm not sure it quite works like that. Try inspecting `$query->public_query_vars` instead and I think you'll see it added in there. The way I usually use it is like this: ``` add_filter( 'query_vars', 'add_test_query_vars'); function add_test_query_vars($vars){ $vars[] = "test"; return $vars; } ``` So the...
243,476
<p>I want to exclude some specific post types from generating sitemaps in yoast seo plugin. Please provide suggestions to do this. Thanks in advance.</p>
[ { "answer_id": 280973, "author": "iMarkDesigns", "author_id": 88981, "author_profile": "https://wordpress.stackexchange.com/users/88981", "pm_score": 2, "selected": false, "text": "<p>If you are using <code>functions.php</code> script to register custom post type, you should declare <cod...
2016/10/21
[ "https://wordpress.stackexchange.com/questions/243476", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105401/" ]
I want to exclude some specific post types from generating sitemaps in yoast seo plugin. Please provide suggestions to do this. Thanks in advance.
If you are using `functions.php` script to register custom post type, you should declare `false` to `'has_archive' => true,`. ``` function custom_post_type() { $labels = array( ... ); $args = array( // you have to set it to False. 'has_archive' => false, ); register_post_type( 'post_type', $args ); ...
243,482
<p>I have a function which processes custom metabox data on saving my custom post type:</p> <pre><code>add_action('save_post_customtypehere','myown_save_customtype_fn'); function myown_save_customtype_fn($ID) { ... } </code></pre> <p>However, the function also runs when I trash items within this CPT (I guess it's eff...
[ { "answer_id": 243483, "author": "websupporter", "author_id": 48693, "author_profile": "https://wordpress.stackexchange.com/users/48693", "pm_score": 3, "selected": true, "text": "<p><a href=\"https://codex.wordpress.org/Plugin_API/Action_Reference/save_post\" rel=\"nofollow\"><code>save...
2016/10/21
[ "https://wordpress.stackexchange.com/questions/243482", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/101959/" ]
I have a function which processes custom metabox data on saving my custom post type: ``` add_action('save_post_customtypehere','myown_save_customtype_fn'); function myown_save_customtype_fn($ID) { ... } ``` However, the function also runs when I trash items within this CPT (I guess it's effectively saving the post t...
[`save_post`](https://codex.wordpress.org/Plugin_API/Action_Reference/save_post) gets fired, once the post is saved. We get the current post object as the second parameter. So we can check, if the current post status is trash: ``` <?php add_action( 'save_post', function( $post_ID, $post, $update ) { if ( 'trash' =...
243,516
<p>I was able to add part of the in product description with this code:</p> <pre><code>function get_ecommerce_excerpt(){ $excerpt = get_the_excerpt(); $excerpt = preg_replace(" ([.*?])",'',$excerpt); $excerpt = strip_shortcodes($excerpt); $excerpt = strip_tags($excerpt); $excerpt = substr($excerpt,...
[ { "answer_id": 243587, "author": "Benoti", "author_id": 58141, "author_profile": "https://wordpress.stackexchange.com/users/58141", "pm_score": 1, "selected": false, "text": "<p>The brief description of a WooCommerce product is store as post_excerpt, to programmatically add some text, yo...
2016/10/21
[ "https://wordpress.stackexchange.com/questions/243516", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/60721/" ]
I was able to add part of the in product description with this code: ``` function get_ecommerce_excerpt(){ $excerpt = get_the_excerpt(); $excerpt = preg_replace(" ([.*?])",'',$excerpt); $excerpt = strip_shortcodes($excerpt); $excerpt = strip_tags($excerpt); $excerpt = substr($excerpt, 0, 100); ...
The brief description of a WooCommerce product is store as post\_excerpt, to programmatically add some text, you need to hook through product excerpt. ``` add_filter('get_the_excerpt', 'custom_excerpt'); function exc($custom_excerpt) { global $post; if($post->post_type == 'product'){ $custom_add = __...
243,518
<p>I am using WordPress 4.6.1 .</p> <p>Everything was working fine then suddenly I started getting a error message &quot; <strong>403 Access Denied</strong> &quot; when I tried to access new post using link of post. I tried different method to check what is causing the error but not able to find.</p> <p>No error is com...
[ { "answer_id": 243519, "author": "Ryan Konkolewski", "author_id": 105426, "author_profile": "https://wordpress.stackexchange.com/users/105426", "pm_score": 0, "selected": false, "text": "<p>I've come across a similar problem before. I suggest disabling all plugins and seeing if this reso...
2016/10/21
[ "https://wordpress.stackexchange.com/questions/243518", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105427/" ]
I am using WordPress 4.6.1 . Everything was working fine then suddenly I started getting a error message " **403 Access Denied** " when I tried to access new post using link of post. I tried different method to check what is causing the error but not able to find. No error is coming in old, Only getting error in new ...
Generate your `.htaccess` again. For that go to `Settings >> Permalinks` then hit `Save Changes` button. It will re-generate your `.htaccess` file. If it's no resolved, you can try the `FTP` described in comment by @Benoti. If that's also not worked please try [this blog](http://www.wpbeginner.com/wp-tutorials/how-to-f...
243,522
<p>I have a multisite network set up with around 250 sites. I'd like to be able to copy users with their assigned role from the main site in the network to subsites. Here is how I attempted to do this:</p> <p><strong>functions.php</strong></p> <pre><code>add_action('wp','add_current_user_to_site',10); function add_c...
[ { "answer_id": 243558, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 2, "selected": false, "text": "<p>You can use the below function to copy all the users to all the subsite. It's actually getting all the use...
2016/10/21
[ "https://wordpress.stackexchange.com/questions/243522", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88515/" ]
I have a multisite network set up with around 250 sites. I'd like to be able to copy users with their assigned role from the main site in the network to subsites. Here is how I attempted to do this: **functions.php** ``` add_action('wp','add_current_user_to_site',10); function add_current_user_to_site() { if(!i...
Using the other answer provided, it appears there are two ways to copy users with their assigned roles from the main site to subsites in a WordPress multisite network. It can be set up to either add the current user or all users from a site (I chose the main network site, `blog_id=1`) to the subsite when they visit th...
243,537
<p>So I'm working on a custom save-post filter. It's working to handle the external API calls I'm using to generate information, which is super awesome. In total, I'm grabbing file info from an API, downloading a couple of files, writing them to a directory, zipping them and deleting them. It all works. During this pro...
[ { "answer_id": 243551, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 0, "selected": false, "text": "<p>I think the main problem is in the <code>if</code> block. It does <code>return</code> before executing <co...
2016/10/21
[ "https://wordpress.stackexchange.com/questions/243537", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/57332/" ]
So I'm working on a custom save-post filter. It's working to handle the external API calls I'm using to generate information, which is super awesome. In total, I'm grabbing file info from an API, downloading a couple of files, writing them to a directory, zipping them and deleting them. It all works. During this proces...
I solved my own problem. save-post hooks in before the form is saved. It even gives us access to the $\_POST object and allows us to interact with it before the original save happens. What this means essentially is that I'm overwriting my values with blank formdata. Rather than updating post meta, I've documented...
243,541
<p>In order to query products based on custom fields, from the plugin advanced custom fields, i have to use this wp query script, to query it correctly.</p> <p>However, when i copied this script, changed the needed values, and inserted it into functions.php, it crashes the site. </p> <p>I believe its a parse or synta...
[ { "answer_id": 243542, "author": "cowgill", "author_id": 5549, "author_profile": "https://wordpress.stackexchange.com/users/5549", "pm_score": 2, "selected": false, "text": "<p>It's hard to debug only seeing a portion of your code.</p>\n\n<p>For starters, you've got two <code>&lt;?php</c...
2016/10/22
[ "https://wordpress.stackexchange.com/questions/243541", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/77322/" ]
In order to query products based on custom fields, from the plugin advanced custom fields, i have to use this wp query script, to query it correctly. However, when i copied this script, changed the needed values, and inserted it into functions.php, it crashes the site. I believe its a parse or syntax error because i...
It's hard to debug only seeing a portion of your code. For starters, you've got two `<?php` opening tags at the top which would certainly cause an error. But I think that's leftover from your copy and paste. * Look at your php server log which will tell you what file and line number the error is occurring. * Put the...
243,545
<p>i am a little confused how to use escape function on a variable having html code in it. i have tried this <a href="https://codex.wordpress.org/Validating_Sanitizing_and_Escaping_User_Data" rel="nofollow">https://codex.wordpress.org/Validating_Sanitizing_and_Escaping_User_Data</a> but i could not figure it out. he...
[ { "answer_id": 243547, "author": "cowgill", "author_id": 5549, "author_profile": "https://wordpress.stackexchange.com/users/5549", "pm_score": 0, "selected": false, "text": "<p>Your code looks and works fine for me. The HTML in <code>value</code> is preserved.</p>\n\n<p>My only recommend...
2016/10/22
[ "https://wordpress.stackexchange.com/questions/243545", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105445/" ]
i am a little confused how to use escape function on a variable having html code in it. i have tried this <https://codex.wordpress.org/Validating_Sanitizing_and_Escaping_User_Data> but i could not figure it out. here is my code: ``` $output = '<p>'; $output .= '<label for="' . esc_attr( $this->get_field_id(...
You are looking for `wp_kses()`. <https://developer.wordpress.org/reference/functions/wp_kses/> There are more helper functions like `wp_kses_post()` and `wp_kses_data()`
243,573
<p>I am importing an rss feed from a job listing site and creating a post for each listing i import with wp_insert_post to save the data and display expired listings in an archive later. </p> <p>I need a solution to keep wp_insert_post from creating duplicats while it still updates the post if certain values have been...
[ { "answer_id": 243547, "author": "cowgill", "author_id": 5549, "author_profile": "https://wordpress.stackexchange.com/users/5549", "pm_score": 0, "selected": false, "text": "<p>Your code looks and works fine for me. The HTML in <code>value</code> is preserved.</p>\n\n<p>My only recommend...
2016/10/22
[ "https://wordpress.stackexchange.com/questions/243573", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105461/" ]
I am importing an rss feed from a job listing site and creating a post for each listing i import with wp\_insert\_post to save the data and display expired listings in an archive later. I need a solution to keep wp\_insert\_post from creating duplicats while it still updates the post if certain values have been updat...
You are looking for `wp_kses()`. <https://developer.wordpress.org/reference/functions/wp_kses/> There are more helper functions like `wp_kses_post()` and `wp_kses_data()`
243,588
<p>I would like to query and sort posts by meta key "popularity" and these posts must have also another meta key "gone" with value "1" to query</p> <pre><code>$args = array( 'post_status' =&gt; 'publish', 'posts_per_page' =&gt; '150', 'cat' =&gt; $cat_id, 'order' =&gt; 'DESC' 'meta_que...
[ { "answer_id": 243547, "author": "cowgill", "author_id": 5549, "author_profile": "https://wordpress.stackexchange.com/users/5549", "pm_score": 0, "selected": false, "text": "<p>Your code looks and works fine for me. The HTML in <code>value</code> is preserved.</p>\n\n<p>My only recommend...
2016/10/22
[ "https://wordpress.stackexchange.com/questions/243588", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/97811/" ]
I would like to query and sort posts by meta key "popularity" and these posts must have also another meta key "gone" with value "1" to query ``` $args = array( 'post_status' => 'publish', 'posts_per_page' => '150', 'cat' => $cat_id, 'order' => 'DESC' 'meta_query' => array( 're...
You are looking for `wp_kses()`. <https://developer.wordpress.org/reference/functions/wp_kses/> There are more helper functions like `wp_kses_post()` and `wp_kses_data()`
243,594
<p>I am trying to add a custom info notice after the post has been deleted from the trash, but I'm not having any luck with it</p> <pre><code>add_action( 'delete_post', 'show_admin_notice' ); /** * Show admin notice after post delete * * @since 1.0.0. */ function show_admin_notice(){ add_action( 'admin_notices...
[ { "answer_id": 243602, "author": "T.Todua", "author_id": 33667, "author_profile": "https://wordpress.stackexchange.com/users/33667", "pm_score": 0, "selected": false, "text": "<p>I think this will solve:</p>\n\n<pre><code>if(isset($_GET['post_status']) &amp;&amp; $_GET['post_status']=='t...
2016/10/22
[ "https://wordpress.stackexchange.com/questions/243594", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/58895/" ]
I am trying to add a custom info notice after the post has been deleted from the trash, but I'm not having any luck with it ``` add_action( 'delete_post', 'show_admin_notice' ); /** * Show admin notice after post delete * * @since 1.0.0. */ function show_admin_notice(){ add_action( 'admin_notices', 'show_post_...
Checking the bulk counts ------------------------ We can check the *bulk counts*, to see if any post was *deleted*: ``` add_filter( 'bulk_post_updated_messages', function( $bulk_messages, $bulk_counts ) { // Check the bulk counts for 'deleted' and add notice if it's gt 0 if( isset( $bulk_counts['deleted'] ) &...
243,615
<p>I have multiple selected box within my nav menus i used <code>add_post_meta()</code> for adding values and <code>delete_post_meta</code> for deleting selected options. the code work, means add and delete options correctly but i have small problem</p> <p>When i delete options <code>delete_post_meta()</code> delete s...
[ { "answer_id": 243621, "author": "SAFEEN 1990", "author_id": 82436, "author_profile": "https://wordpress.stackexchange.com/users/82436", "pm_score": 0, "selected": false, "text": "<p>Before selecting any value you don't have an <code>array()</code> means you must select options until the...
2016/10/22
[ "https://wordpress.stackexchange.com/questions/243615", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/37216/" ]
I have multiple selected box within my nav menus i used `add_post_meta()` for adding values and `delete_post_meta` for deleting selected options. the code work, means add and delete options correctly but i have small problem When i delete options `delete_post_meta()` delete selected options except the first one means ...
I think it is just a matter of logic. If you don't select any value, `$_REQUEST['menu-item-custom-category'][$menu_item_db_id]` is empty. So, the next line `delete_post_meta()` is never triggered in your code. Just think in the logic you need to know when to delete previous meta value. For example: ``` if( !empty( $_...
243,617
<p>I want to create custom thumbnail dialogues for the homepage of my WordPress installation.</p> <p>This is what I want to achieve:<a href="https://i.stack.imgur.com/6J4ud.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6J4ud.png" alt="image"></a></p> <p>This is the bootstrap code for the image ab...
[ { "answer_id": 243621, "author": "SAFEEN 1990", "author_id": 82436, "author_profile": "https://wordpress.stackexchange.com/users/82436", "pm_score": 0, "selected": false, "text": "<p>Before selecting any value you don't have an <code>array()</code> means you must select options until the...
2016/10/22
[ "https://wordpress.stackexchange.com/questions/243617", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/48024/" ]
I want to create custom thumbnail dialogues for the homepage of my WordPress installation. This is what I want to achieve:[![image](https://i.stack.imgur.com/6J4ud.png)](https://i.stack.imgur.com/6J4ud.png) This is the bootstrap code for the image above: ``` <div class="row"> <div class="col-sm-6 col-md-4"> ...
I think it is just a matter of logic. If you don't select any value, `$_REQUEST['menu-item-custom-category'][$menu_item_db_id]` is empty. So, the next line `delete_post_meta()` is never triggered in your code. Just think in the logic you need to know when to delete previous meta value. For example: ``` if( !empty( $_...
243,633
<p>I'm starting to build a WordPress theme from scratch. I have MAMP all loaded and running on my computer and WordPress is loaded fine. I have the below three files all in the same folder </p> <p>C:/MAMP/htdocs/wordpress/wp-content/themes/testtheme</p> <p>The problem is I can't get the hook in the functions file t...
[ { "answer_id": 243634, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 2, "selected": false, "text": "<p>Your theme has to call <code>wp_head()</code> in the head section of the html (probably best to place it ...
2016/10/23
[ "https://wordpress.stackexchange.com/questions/243633", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105486/" ]
I'm starting to build a WordPress theme from scratch. I have MAMP all loaded and running on my computer and WordPress is loaded fine. I have the below three files all in the same folder C:/MAMP/htdocs/wordpress/wp-content/themes/testtheme The problem is I can't get the hook in the functions file to actually run the ...
Your theme has to call `wp_head()` in the head section of the html (probably best to place it at the end of it) and `wp_footer()` somewhere in your footer section. Those are **mandatory** function calls for all themes that want to be able to integrate with plugins and some core functionality like enqueuing JS and CSS d...
243,672
<p>Does anybody have experienced this issue: using admin_url() in add_menu_page() returns an url that contains the domain name twice:</p> <pre><code>add_submenu_page( 'smart-crm', __('WP SMART CRM Documents', 'mytextdomain'), __('Documents', 'mytextdomain'), 'manage_options', ad...
[ { "answer_id": 243634, "author": "Mark Kaplun", "author_id": 23970, "author_profile": "https://wordpress.stackexchange.com/users/23970", "pm_score": 2, "selected": false, "text": "<p>Your theme has to call <code>wp_head()</code> in the head section of the html (probably best to place it ...
2016/10/23
[ "https://wordpress.stackexchange.com/questions/243672", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/64435/" ]
Does anybody have experienced this issue: using admin\_url() in add\_menu\_page() returns an url that contains the domain name twice: ``` add_submenu_page( 'smart-crm', __('WP SMART CRM Documents', 'mytextdomain'), __('Documents', 'mytextdomain'), 'manage_options', admin_url('ad...
Your theme has to call `wp_head()` in the head section of the html (probably best to place it at the end of it) and `wp_footer()` somewhere in your footer section. Those are **mandatory** function calls for all themes that want to be able to integrate with plugins and some core functionality like enqueuing JS and CSS d...
243,687
<p>I am struggling with getting post queries by coordinates. I have meta fields <code>map_lat</code> and <code>map_lng</code> for almost all post types. I am trying to return posts from one custom post type ("beaches" in this example):</p> <pre><code>function get_nearby_locations($lat, $long, $distance){ global $w...
[ { "answer_id": 243688, "author": "cowgill", "author_id": 5549, "author_profile": "https://wordpress.stackexchange.com/users/5549", "pm_score": 4, "selected": true, "text": "<p>Close. You need another <code>INNER JOIN</code> and should escape all your variables using <code>$wpdb-&gt;prepa...
2016/10/23
[ "https://wordpress.stackexchange.com/questions/243687", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105189/" ]
I am struggling with getting post queries by coordinates. I have meta fields `map_lat` and `map_lng` for almost all post types. I am trying to return posts from one custom post type ("beaches" in this example): ``` function get_nearby_locations($lat, $long, $distance){ global $wpdb; $nearbyLocations = $wpdb->g...
Close. You need another `INNER JOIN` and should escape all your variables using `$wpdb->prepare`. I've also included a more efficient Haversine formula ([source](https://developers.google.com/maps/articles/phpsqlsearch_v3#findnearsql)) to calculate the radius. If you use kilometers, then change the `$earth_radius` to...
243,703
<p>I’m tryin to insert shortcode through add_action :</p> <pre><code>add_action('woocommerce_single_product_summary', 'quotation_form', 61); function quotation_form() { $produk = get_the_title(); $shortkode = sprintf( '[zendesk_request_form size="3" group="extra-field" subject="Quotation For %s"]', $produk ); $shortko...
[ { "answer_id": 243712, "author": "Pascal Knecht", "author_id": 105101, "author_profile": "https://wordpress.stackexchange.com/users/105101", "pm_score": 1, "selected": false, "text": "<p>Your problem is that the $product variable is not defined. I see two possible solutions:</p>\n\n<ul>\...
2016/10/24
[ "https://wordpress.stackexchange.com/questions/243703", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/88402/" ]
I’m tryin to insert shortcode through add\_action : ``` add_action('woocommerce_single_product_summary', 'quotation_form', 61); function quotation_form() { $produk = get_the_title(); $shortkode = sprintf( '[zendesk_request_form size="3" group="extra-field" subject="Quotation For %s"]', $produk ); $shortkode = do_short...
I solved this with dirty way.. hope someone else can provide more efficient solution, my final working code for problem above: ``` $shortkode = '[zendesk_request_form size="3" group="extra-field" subject="Quotation For -wkwkwk-"]'; $shortkode = do_shortcode( $shortkode ); add_action('woocommerce_single_product_summary...
243,718
<p><strong>UPDATE</strong> Refrased the question</p> <p>On the backend widget page <code>widgets.php</code>, there is a list of available widgets. Items in this list have the same classes and a <a href="https://developer.wordpress.org/reference/functions/wp_list_widgets/" rel="nofollow">dynamically generated ID</a>, w...
[ { "answer_id": 243719, "author": "cjbj", "author_id": 75495, "author_profile": "https://wordpress.stackexchange.com/users/75495", "pm_score": -1, "selected": false, "text": "<p>Indeed, all html is stripped from the widget name in the backend by this line (WP 4.6) in the <a href=\"https:/...
2016/10/24
[ "https://wordpress.stackexchange.com/questions/243718", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/75495/" ]
**UPDATE** Refrased the question On the backend widget page `widgets.php`, there is a list of available widgets. Items in this list have the same classes and a [dynamically generated ID](https://developer.wordpress.org/reference/functions/wp_list_widgets/), which changes if a new widget is inserted (alphabetically) in...
Just as @MarkKaplun [mentioned](https://wordpress.stackexchange.com/questions/243718/can-i-individually-style-items-in-the-backend-widget-list/244667#comment363657_243719) in a comment, it's possible with CSS. Also with Javascript. CSS Approach ------------ Let's look at the *Calendar* widget, as an example. The *id...
243,721
<p>I want to query two post types: 'projects' all of them and 'posts' by taxonomy 'light'. Does someone know how can this be achieved?</p> <p>Kris</p>
[ { "answer_id": 243733, "author": "amit singh", "author_id": 105452, "author_profile": "https://wordpress.stackexchange.com/users/105452", "pm_score": -1, "selected": false, "text": "<p>Have you registered any custom taxonomy for projects and posts? what is the slug of that taxonomy?</p>\...
2016/10/24
[ "https://wordpress.stackexchange.com/questions/243721", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105539/" ]
I want to query two post types: 'projects' all of them and 'posts' by taxonomy 'light'. Does someone know how can this be achieved? Kris
I solved my problem by automatically adding the tag 'light' to all my projects. And then query all the post and projects with the light tag like this: Query post by taxonomy tag 'light': ``` $args = array( 'post_type' => array( 'projects' , 'post' ), 'tax_query' => array( 'relation' => 'OR', ...
243,740
<p>While building a custom theme, I've been stuck on how to add a CSS class to a certain theme menu (meaning a custom menu that is associated with a theme menu position).</p> <p>So far, in my template I have</p> <pre><code> &lt;?php if (has_nav_menu('main-menu')) : ?&gt; &lt;nav class="topmenu" role="navigation...
[ { "answer_id": 243745, "author": "Florin Sarba", "author_id": 105556, "author_profile": "https://wordpress.stackexchange.com/users/105556", "pm_score": 1, "selected": false, "text": "<p>You can use the <code>nav_menu_css_class</code> filter which is applied to every menu item in the spec...
2016/10/24
[ "https://wordpress.stackexchange.com/questions/243740", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/63707/" ]
While building a custom theme, I've been stuck on how to add a CSS class to a certain theme menu (meaning a custom menu that is associated with a theme menu position). So far, in my template I have ``` <?php if (has_nav_menu('main-menu')) : ?> <nav class="topmenu" role="navigation"> <?php wp_nav_menu(...
You can use the `nav_menu_css_class` filter which is applied to every menu item in the specified nav menu. ``` add_filter('nav_menu_css_class' , 'special_nav_class' , 10 , 2); function special_nav_class($classes, $item){ $classes[] = 'your-custom-class'; return $classes; } ``` More info: <http://www.wpbegin...
243,794
<p>I have a Wordpress installation in the root directory of my host. It includes an SSL certificate for that primary domain (e.g. <code>domain.com</code>; not a wildcard certificate).</p> <p>When I include <code>define('FORCE_SSL_ADMIN', true);</code> in wp-config.php, suddenly all subdomains also try to redirect to h...
[ { "answer_id": 243828, "author": "cowgill", "author_id": 5549, "author_profile": "https://wordpress.stackexchange.com/users/5549", "pm_score": -1, "selected": false, "text": "<p>It sounds like you're using <a href=\"https://codex.wordpress.org/Create_A_Network\" rel=\"nofollow\">WordPres...
2016/10/24
[ "https://wordpress.stackexchange.com/questions/243794", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/78022/" ]
I have a Wordpress installation in the root directory of my host. It includes an SSL certificate for that primary domain (e.g. `domain.com`; not a wildcard certificate). When I include `define('FORCE_SSL_ADMIN', true);` in wp-config.php, suddenly all subdomains also try to redirect to https, despite the fact that ther...
It turns out that the shared server I have at Network Solutions is forcing HSTS through their service. And since it's a shared hosting server, they refuse to change it. The solution: I purchased a Wildcard certificate, and installed it on multiple servers for each subdomain.
243,810
<p>For my custom settings field, I am looking to insert it <a href="https://i.stack.imgur.com/Cds8f.png" rel="nofollow noreferrer">right after the <em>Site Address (URL)</em> field</a> in the <em>General</em> settings page.</p> <p>I'm able to add the custom field sucessfully using the <code>add_settings_field()</code>...
[ { "answer_id": 243814, "author": "wassereimer", "author_id": 54551, "author_profile": "https://wordpress.stackexchange.com/users/54551", "pm_score": 0, "selected": false, "text": "<p>I think that this is not possible without modifying the core-files. We only have one time <code>do_settin...
2016/10/24
[ "https://wordpress.stackexchange.com/questions/243810", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/98212/" ]
For my custom settings field, I am looking to insert it [right after the *Site Address (URL)* field](https://i.stack.imgur.com/Cds8f.png) in the *General* settings page. I'm able to add the custom field sucessfully using the `add_settings_field()`. Be default, it add the custom field [at the bottom](https://i.stack.im...
Figured it out by using the following jQuery function. The `#protocol_relative` is the field I am inserting and `#home-description` is the field I am inserting it after: ``` add_action( 'admin_footer', 'insert_field' ); function insert_field() { # Insert the settings field after the 'Site Address (URL)' ?> <sc...
243,811
<p>I want to update multiple rows in one query using wpdb->update. I get no error in the <a href="https://codex.wordpress.org/Debugging_in_WordPress#WP_DEBUG_LOG" rel="nofollow">debug.log</a> file but only the last row is updated.</p> <pre><code>$my_update = $wpdb-&gt;update( $wpdb-&gt;prefix . 'my_settings', ...
[ { "answer_id": 243825, "author": "cowgill", "author_id": 5549, "author_profile": "https://wordpress.stackexchange.com/users/5549", "pm_score": 0, "selected": false, "text": "<p>Your syntax looks okay. My guess is your first two variables are empty. </p>\n\n<p>Try hardcoding in values to ...
2016/10/24
[ "https://wordpress.stackexchange.com/questions/243811", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/54551/" ]
I want to update multiple rows in one query using wpdb->update. I get no error in the [debug.log](https://codex.wordpress.org/Debugging_in_WordPress#WP_DEBUG_LOG) file but only the last row is updated. ``` $my_update = $wpdb->update( $wpdb->prefix . 'my_settings', array( 'value' => $tmp_mail_smtp, ...
I googled a lot the last days and a few times i´ve seen postings that say that the `$wpdb->update` function doens´t support multiple updates and that this is not well documented. -> Sorry i don´t have links anymore... I think that this is true because i couldn´t get it to work and i found not a single example witch wo...
243,819
<p>I'm creating a wordpress theme for a client to use in his existent wordpress site. Anyways, I've completed the theme except one specific thing. I see that he has lots of pages with the keyword Module in the title. Example of the title would be "How to create this product: Module 1." In his previous theme, they had a...
[ { "answer_id": 243825, "author": "cowgill", "author_id": 5549, "author_profile": "https://wordpress.stackexchange.com/users/5549", "pm_score": 0, "selected": false, "text": "<p>Your syntax looks okay. My guess is your first two variables are empty. </p>\n\n<p>Try hardcoding in values to ...
2016/10/24
[ "https://wordpress.stackexchange.com/questions/243819", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105584/" ]
I'm creating a wordpress theme for a client to use in his existent wordpress site. Anyways, I've completed the theme except one specific thing. I see that he has lots of pages with the keyword Module in the title. Example of the title would be "How to create this product: Module 1." In his previous theme, they had a wo...
I googled a lot the last days and a few times i´ve seen postings that say that the `$wpdb->update` function doens´t support multiple updates and that this is not well documented. -> Sorry i don´t have links anymore... I think that this is true because i couldn´t get it to work and i found not a single example witch wo...
243,839
<p>I put my timezone in <strong>America/Lima</strong> ( Setting > General )</p> <p>But <strong>current_time('timestamp')</strong> show other datetime.</p> <p>For example: Now in Lima it is 2015-10-25 12:01:00 but current_time('timestamp') says : 2016-10-24 19:01:05</p> <p>Something am I doing wrong?</p> <p>PD: My v...
[ { "answer_id": 243825, "author": "cowgill", "author_id": 5549, "author_profile": "https://wordpress.stackexchange.com/users/5549", "pm_score": 0, "selected": false, "text": "<p>Your syntax looks okay. My guess is your first two variables are empty. </p>\n\n<p>Try hardcoding in values to ...
2016/10/25
[ "https://wordpress.stackexchange.com/questions/243839", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/27785/" ]
I put my timezone in **America/Lima** ( Setting > General ) But **current\_time('timestamp')** show other datetime. For example: Now in Lima it is 2015-10-25 12:01:00 but current\_time('timestamp') says : 2016-10-24 19:01:05 Something am I doing wrong? PD: My variables in wp\_option are: **gmt\_offset** is empty, *...
I googled a lot the last days and a few times i´ve seen postings that say that the `$wpdb->update` function doens´t support multiple updates and that this is not well documented. -> Sorry i don´t have links anymore... I think that this is true because i couldn´t get it to work and i found not a single example witch wo...
243,851
<p>I just created a child theme and activated it.But when I visit the page,it's completely blank.</p> <p>In the display is the themes folder where I have my parent theme and the child,then below is the site details from the parent style.css which I simply copied and pasted to the child stylesheet.</p> <p><a href="htt...
[ { "answer_id": 243855, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 2, "selected": false, "text": "<p>I think you've nothing in the <code>index.php</code> file. So what is happening that the child theme is ca...
2016/10/25
[ "https://wordpress.stackexchange.com/questions/243851", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/99178/" ]
I just created a child theme and activated it.But when I visit the page,it's completely blank. In the display is the themes folder where I have my parent theme and the child,then below is the site details from the parent style.css which I simply copied and pasted to the child stylesheet. [![enter image description he...
I think you've nothing in the `index.php` file. So what is happening that the child theme is calling the child theme's `index.php` over parent theme's `index.php`. And you have nothing on `index.php`. So the site is showing nothing. Delete the child theme's `index.php`. You'll see the site live.
243,856
<p>Hello I'm in a bit of a trouble. I don't know what's wrong with what I'm doing. I want to add class to current category. So my php looks like this:</p> <pre><code> &lt;menu id="nav"&gt; &lt;ul&gt; &lt;?php $cat_id = get_cat_ID(); foreach( $categories as $c ):?&gt; ...
[ { "answer_id": 243858, "author": "Aniruddha Gawade", "author_id": 101818, "author_profile": "https://wordpress.stackexchange.com/users/101818", "pm_score": 2, "selected": true, "text": "<p>You can use <code>get_queried_object()</code>, which will return category object.</p>\n\n<p>See doc...
2016/10/25
[ "https://wordpress.stackexchange.com/questions/243856", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105264/" ]
Hello I'm in a bit of a trouble. I don't know what's wrong with what I'm doing. I want to add class to current category. So my php looks like this: ``` <menu id="nav"> <ul> <?php $cat_id = get_cat_ID(); foreach( $categories as $c ):?> <li class="<?php if(($c-...
You can use `get_queried_object()`, which will return category object. See documentation: <https://codex.wordpress.org/Function_Reference/get_queried_object>
243,877
<p>I have written this function for loggin user out. The user is loggin out but not redirecting to the page instead goes to home page which default logout Url. i have tried wp_logout_url() and also wp_redirect().</p> <pre><code>function wc_registration_redirect( $redirect_to) { wp_logout(); wp_redirect( '/my-a...
[ { "answer_id": 243878, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 1, "selected": false, "text": "<p>You need to hook it to <code>wp_logout</code> actions hook and remove the <code>wp_logout();</code> from t...
2016/10/25
[ "https://wordpress.stackexchange.com/questions/243877", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105617/" ]
I have written this function for loggin user out. The user is loggin out but not redirecting to the page instead goes to home page which default logout Url. i have tried wp\_logout\_url() and also wp\_redirect(). ``` function wc_registration_redirect( $redirect_to) { wp_logout(); wp_redirect( '/my-account'); ...
The correct method for changing the logout redirect is the `logout_redirect` filter: ``` /** * Filters the log out redirect URL. * * @since 4.2.0 * * @param string $redirect_to The redirect destination URL. * @param string $requested_redirect_to The requested redirect destination URL passed as a para...
243,882
<p>I'm building a WordPress website that will have around 50 smaller sites in it; <em>either a state with each county being the smaller site</em>.</p> <p>Each site will be managed by a different person.</p> <p>I've just started with multisite and was wondering if this is the best way to go or if there is a better way...
[ { "answer_id": 243878, "author": "CodeMascot", "author_id": 44192, "author_profile": "https://wordpress.stackexchange.com/users/44192", "pm_score": 1, "selected": false, "text": "<p>You need to hook it to <code>wp_logout</code> actions hook and remove the <code>wp_logout();</code> from t...
2016/10/25
[ "https://wordpress.stackexchange.com/questions/243882", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105621/" ]
I'm building a WordPress website that will have around 50 smaller sites in it; *either a state with each county being the smaller site*. Each site will be managed by a different person. I've just started with multisite and was wondering if this is the best way to go or if there is a better way to do this.
The correct method for changing the logout redirect is the `logout_redirect` filter: ``` /** * Filters the log out redirect URL. * * @since 4.2.0 * * @param string $redirect_to The redirect destination URL. * @param string $requested_redirect_to The requested redirect destination URL passed as a para...
243,883
<p>so, I've encountered on a problem. </p> <p>What i want?</p> <ul> <li>I want that my search finds any text on the page</li> </ul> <p>What is the problem?</p> <ul> <li>Search is only for posts / media / pages. I have one plugin in which I've stored some data and that data is visible on the page, and I want to be a...
[ { "answer_id": 243901, "author": "Christopher Corrales", "author_id": 105589, "author_profile": "https://wordpress.stackexchange.com/users/105589", "pm_score": 0, "selected": false, "text": "<p>WP default search is not good, try this plugin: <a href=\"https://wordpress.org/plugins/search...
2016/10/25
[ "https://wordpress.stackexchange.com/questions/243883", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/89803/" ]
so, I've encountered on a problem. What i want? * I want that my search finds any text on the page What is the problem? * Search is only for posts / media / pages. I have one plugin in which I've stored some data and that data is visible on the page, and I want to be able to search that data. What did I tried? *...
Use [mark.js](https://markjs.io/), a jQuery plugin ================================================== [mark.js](https://markjs.io/) is such a plugin that is written in pure JavaScript, but is also available as jQuery plugin. It was developed to offer more opportunities than the other plugins with options to: * search...
243,888
<p>I believe Jetpack is using "Font Awesome" to display social icons. This is the css <code>content: "\f203";</code> to display facebook for example. If I look in the site source I can't find anywhere the "Font Awesome" being downloaded.</p> <p>How does this works? </p> <p>The thing is that I just want to use those ...
[ { "answer_id": 243894, "author": "TomC", "author_id": 36980, "author_profile": "https://wordpress.stackexchange.com/users/36980", "pm_score": 1, "selected": false, "text": "<p>If you don't want to rely on Jetpack for font awesome you need to have the CSS files loaded. Best way (in my opi...
2016/10/25
[ "https://wordpress.stackexchange.com/questions/243888", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/104433/" ]
I believe Jetpack is using "Font Awesome" to display social icons. This is the css `content: "\f203";` to display facebook for example. If I look in the site source I can't find anywhere the "Font Awesome" being downloaded. How does this works? The thing is that I just want to use those icons in my header without m...
If you don't want to rely on Jetpack for font awesome you need to have the CSS files loaded. Best way (in my opinion) to do this is via the CDN. I use the following: ``` // Add font awesome & bootstrap function awesome_css() { wp_enqueue_style("fontawesome", 'https://maxcdn.bootstrapcdn.com/font-awesome/4.5.0/css/...
243,912
<p>I have a custom post type <code>acme_reviews</code>. I've namespaced it as suggested in tutorials to prevent future conflicts. But I want its archive page to simply be <code>acme.com/reviews</code>, not <code>acme.com/acme_reviews</code>. How do I achieve this? This is my code:</p> <pre><code>function create_review...
[ { "answer_id": 243913, "author": "Fencer04", "author_id": 98527, "author_profile": "https://wordpress.stackexchange.com/users/98527", "pm_score": 3, "selected": true, "text": "<p>The register_post_type has_archive option also accepts a string. That string will be used for the archives. S...
2016/10/25
[ "https://wordpress.stackexchange.com/questions/243912", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105495/" ]
I have a custom post type `acme_reviews`. I've namespaced it as suggested in tutorials to prevent future conflicts. But I want its archive page to simply be `acme.com/reviews`, not `acme.com/acme_reviews`. How do I achieve this? This is my code: ``` function create_reviews_post_type() { register_post_type('acme_re...
The register\_post\_type has\_archive option also accepts a string. That string will be used for the archives. See the changes in the code below: ``` function create_reviews_post_type() { register_post_type('acme_reviews', array( 'labels' => array( 'name' => __('Reviews'), 'singular...
243,925
<p>i am trying to add re-order for user panel in wordpress. I tried to intall some plugin called post re-order but did not work out for user panel. plz suggest me with the best idea.</p> <p>thx <a href="https://i.stack.imgur.com/E8JxI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E8JxI.png" alt="en...
[ { "answer_id": 243963, "author": "The J", "author_id": 98010, "author_profile": "https://wordpress.stackexchange.com/users/98010", "pm_score": 0, "selected": false, "text": "<p>You can use an Admin Menu order plugin. There are several, <a href=\"https://wordpress.org/plugins/admin-menu-e...
2016/10/25
[ "https://wordpress.stackexchange.com/questions/243925", "https://wordpress.stackexchange.com", "https://wordpress.stackexchange.com/users/105644/" ]
i am trying to add re-order for user panel in wordpress. I tried to intall some plugin called post re-order but did not work out for user panel. plz suggest me with the best idea. thx [![enter image description here](https://i.stack.imgur.com/E8JxI.png)](https://i.stack.imgur.com/E8JxI.png) screenshot of wp backend pa...
You can re order admin left menu by below code: ``` /* * Code below groups Dashboard/Posts/Pages/Comments together at the top of the dashboard menu. * If you were to have a custom type that you want to add to the group use the following edit.php?post_type=YOURPOSTTYPENAME */ function reorder_my_admin_menu( $__retur...